Agora Server Gateway SDK C++ API Reference
IAgoraService.h
Go to the documentation of this file.
1// Agora SDK
2//
3// Copyright (c) 2018 Agora.io. All rights reserved.
4//
5
6#pragma once // NOLINT(build/header_guard)
7
8#include "IAgoraLog.h"
9#include "AgoraBase.h"
10#include "AgoraOptional.h"
11
12namespace agora {
13namespace rtc {
14class IRtcConnection;
15class IRtmpConnection;
16class ILocalUser;
17struct TConnectionInfo;
18struct RtcConnectionConfiguration;
19struct RtmpConnectionConfiguration;
20class ILocalAudioTrack;
21class IAudioPcmDataSender;
22class IAudioEncodedFrameSender;
23class IVideoFrameSender;
24class IVideoEncodedImageSender;
25class IVideoSourceNode;
26class IVideoMixerSource;
27class ILocalVideoTrack;
28class IMediaNodeFactory;
29
38 // absl::optional<DtxStatus> dtx;
39 // double bitrate_priority = 1.0;
40 // absl::optional<int> ptime;
41 // FEC parameters
42 // Rtx parameters
43
45};
46
47} // namespace rtc
48
49namespace signaling {
50class ISignalingEngine;
51}
52
53namespace base {
54class IEngineBase;
55class IServiceObserver;
56
87
91 void* context;
93
96 const char* appId;
97
103 unsigned int areaCode;
104
121
124 IServiceObserver* serviceObserver;
125
135 bool useExternalEglContext;
137
147
149 enableAudioDevice(true),
150 enableVideo(false),
151 context(NULL),
152 appId(NULL),
156 useStringUid(false),
157 serviceObserver(NULL),
158 useExternalEglContext(false){}
159};
161
164struct AudioSessionConfiguration {
177 Optional<bool> playbackAndRecord;
186 Optional<bool> chatMode;
195 Optional<bool> defaultToSpeaker;
204 Optional<bool> overrideSpeaker;
213 Optional<bool> allowMixWithOthers;
224 Optional<bool> allowBluetooth;
236 Optional<bool> allowBluetoothA2DP;
243 Optional<double> sampleRate;
250 Optional<double> ioBufferDuration;
254 Optional<int> inputNumberOfChannels;
258 Optional<int> outputNumberOfChannels;
259
260 void SetAll(AudioSessionConfiguration& change) {
261 SetFrom(&playbackAndRecord, change.playbackAndRecord);
262 SetFrom(&chatMode, change.chatMode);
263 SetFrom(&defaultToSpeaker, change.defaultToSpeaker);
264 SetFrom(&overrideSpeaker, change.overrideSpeaker);
265 SetFrom(&allowMixWithOthers, change.allowMixWithOthers);
266 SetFrom(&allowBluetooth, change.allowBluetooth);
267 SetFrom(&allowBluetoothA2DP, change.allowBluetoothA2DP);
268 SetFrom(&sampleRate, change.sampleRate);
269 SetFrom(&ioBufferDuration, change.ioBufferDuration);
270 SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels);
271 SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels);
272 }
273
274 bool operator==(const AudioSessionConfiguration& o) const {
275 return playbackAndRecord == o.playbackAndRecord && chatMode == o.chatMode &&
276 defaultToSpeaker == o.defaultToSpeaker && overrideSpeaker == o.overrideSpeaker &&
277 allowMixWithOthers == o.allowMixWithOthers && allowBluetooth == o.allowBluetooth &&
278 allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate &&
279 ioBufferDuration == o.ioBufferDuration &&
280 inputNumberOfChannels == o.inputNumberOfChannels &&
281 outputNumberOfChannels == o.outputNumberOfChannels;
282 }
283 bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); }
284
285 private:
286 template <typename T>
287 static void SetFrom(Optional<T>* s, const Optional<T>& o) {
288 if (o) {
289 *s = o;
290 }
291 }
292};
294
306};
307
320
325
327 : ccMode(rtc::CC_ENABLED),
329 targetBitrate(6500) {}
330};
332
335class IServiceObserver {
336public:
337 virtual ~IServiceObserver() {}
338
343 virtual void onPermissionError(agora::rtc::PERMISSION_TYPE permissionType) {}
348 virtual void onAudioDeviceError(ERROR_CODE_TYPE error, const char* description) {}
349};
351
362 public:
371 virtual int initialize(const AgoraServiceConfiguration& config) = 0;
372
374
377 virtual void atExit(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
379
387 virtual int release() = 0;
388
399 virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
400
402
411 virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
412
421 virtual int getAudioSessionConfiguration(AudioSessionConfiguration* config) = 0;
423
443 virtual int setLogFile(const char* filePath, unsigned int fileSize, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
463 virtual int setLogFilter(unsigned int filters, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
464
473 virtual agora_refptr<rtc::IRtcConnection> createRtcConnection(
474 const rtc::RtcConnectionConfiguration& cfg) = 0;
475
486 virtual agora_refptr<rtc::IRtmpConnection> createRtmpConnection(
487 const rtc::RtmpConnectionConfiguration& cfg) = 0;
488
500 virtual agora_refptr<rtc::ILocalAudioTrack> createLocalAudioTrack() = 0;
501
513 virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
514 agora_refptr<rtc::IAudioPcmDataSender> audioSource) = 0;
515
528 virtual agora_refptr<rtc::ILocalAudioTrack> createDirectCustomAudioTrack(
529 agora_refptr<rtc::IAudioPcmDataSender> audioSource) = 0;
530
544 virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
545 agora_refptr<rtc::IAudioEncodedFrameSender> audioSource, TMixMode mixMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
546
554 virtual agora_refptr<rtc::IMediaNodeFactory> createMediaNodeFactory() = 0;
555
568 virtual agora_refptr<rtc::ILocalVideoTrack> createMixedVideoTrack(agora_refptr<rtc::IVideoMixerSource> videoSource,
569 const char* id = OPTIONAL_NULLPTR) = 0;
570
582 virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
583 agora_refptr<rtc::IVideoFrameSender> videoSource, const char* id = OPTIONAL_NULLPTR) = 0;
584
585
598 virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
599 agora_refptr<rtc::IVideoEncodedImageSender> videoSource,
600 const rtc::SenderOptions& options,
601 const char* id = OPTIONAL_NULLPTR) = 0;
613 virtual agora_refptr<base::IAgoraParameter> getAgoraParameter() = 0;
614 protected:
615 virtual ~IAgoraService() {}
616};
617
618} // namespace base
619} // namespace agora
620
#define AGORA_CALL
Definition: AgoraBase.h:65
#define AGORA_API
Definition: AgoraBase.h:64
#define OPTIONAL_NULLPTR
Definition: AgoraBase.h:81
Definition: AgoraOptional.h:413
Definition: IAgoraService.h:361
virtual agora_refptr< rtc::ILocalAudioTrack > createDirectCustomAudioTrack(agora_refptr< rtc::IAudioPcmDataSender > audioSource)=0
virtual int setLogFile(const char *filePath, unsigned int fileSize, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual agora_refptr< rtc::ILocalVideoTrack > createCustomVideoTrack(agora_refptr< rtc::IVideoFrameSender > videoSource, const char *id=OPTIONAL_NULLPTR)=0
virtual agora_refptr< rtc::ILocalAudioTrack > createCustomAudioTrack(agora_refptr< rtc::IAudioPcmDataSender > audioSource)=0
virtual agora_refptr< rtc::ILocalVideoTrack > createMixedVideoTrack(agora_refptr< rtc::IVideoMixerSource > videoSource, const char *id=OPTIONAL_NULLPTR)=0
virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int initialize(const AgoraServiceConfiguration &config)=0
virtual agora_refptr< rtc::ILocalVideoTrack > createCustomVideoTrack(agora_refptr< rtc::IVideoEncodedImageSender > videoSource, const rtc::SenderOptions &options, const char *id=OPTIONAL_NULLPTR)=0
virtual agora_refptr< rtc::IMediaNodeFactory > createMediaNodeFactory()=0
virtual agora_refptr< rtc::ILocalAudioTrack > createLocalAudioTrack()=0
virtual ~IAgoraService()
Definition: IAgoraService.h:615
virtual agora_refptr< base::IAgoraParameter > getAgoraParameter()=0
virtual agora_refptr< rtc::IRtcConnection > createRtcConnection(const rtc::RtcConnectionConfiguration &cfg)=0
virtual int setLogFilter(unsigned int filters, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual agora_refptr< rtc::ILocalAudioTrack > createCustomAudioTrack(agora_refptr< rtc::IAudioEncodedFrameSender > audioSource, TMixMode mixMode, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual agora_refptr< rtc::IRtmpConnection > createRtmpConnection(const rtc::RtmpConnectionConfiguration &cfg)=0
AGORA_API agora::base::IAgoraService *AGORA_CALL createAgoraService()
TMixMode
Definition: IAgoraService.h:297
@ MIX_ENABLED
Definition: IAgoraService.h:301
@ MIX_DISABLED
Definition: IAgoraService.h:305
AUDIO_SCENARIO_TYPE
Definition: AgoraBase.h:2638
@ AUDIO_SCENARIO_DEFAULT
Definition: AgoraBase.h:2642
TCcMode
Definition: AgoraBase.h:4978
@ CC_ENABLED
Definition: AgoraBase.h:4982
AUDIO_PROFILE_TYPE
Definition: AgoraBase.h:2598
@ AUDIO_PROFILE_DEFAULT
Definition: AgoraBase.h:2604
VIDEO_CODEC_TYPE
Definition: AgoraBase.h:1552
@ VIDEO_CODEC_H264
Definition: AgoraBase.h:1564
@ AREA_CODE_GLOB
Definition: AgoraBase.h:4376
Definition: AgoraBase.h:86
bool operator!=(const Optional< T > &lhs, const Optional< U > &rhs)
Definition: AgoraOptional.h:692
bool operator==(const Optional< T > &lhs, const Optional< U > &rhs)
Definition: AgoraOptional.h:683
CHANNEL_PROFILE_TYPE
Definition: AgoraBase.h:306
@ CHANNEL_PROFILE_LIVE_BROADCASTING
Definition: AgoraBase.h:318
Definition: IAgoraService.h:62
agora::CHANNEL_PROFILE_TYPE channelProfile
Definition: IAgoraService.h:107
commons::LogConfig logConfig
Definition: IAgoraService.h:115
bool domainLimit
Definition: IAgoraService.h:146
unsigned int areaCode
Definition: IAgoraService.h:103
bool useStringUid
Definition: IAgoraService.h:119
bool enableAudioDevice
Definition: IAgoraService.h:79
const char * appId
Definition: IAgoraService.h:96
bool enableAudioProcessor
Definition: IAgoraService.h:68
rtc::AUDIO_SCENARIO_TYPE audioScenario
Definition: IAgoraService.h:111
bool enableVideo
Definition: IAgoraService.h:85
AgoraServiceConfiguration()
Definition: IAgoraService.h:148
Definition: IAgoraService.h:311
rtc::VIDEO_CODEC_TYPE codecType
Definition: IAgoraService.h:319
rtc::TCcMode ccMode
Definition: IAgoraService.h:315
SenderOptions()
Definition: IAgoraService.h:326
int targetBitrate
Definition: IAgoraService.h:324
Definition: IAgoraLog.h:123
Definition: IAgoraService.h:33
AudioEncoderConfiguration()
Definition: IAgoraService.h:44
AUDIO_PROFILE_TYPE audioProfile
Definition: IAgoraService.h:37
Definition: NGIAgoraRtcConnection.h:55
Definition: NGIAgoraRtmpConnection.h:208