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
44 AudioEncoderConfiguration() : audioProfile(AUDIO_PROFILE_DEFAULT) {}
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() = 0;
379
387 virtual int release() = 0;
388
399
401
409 virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config) = 0;
410
419 virtual int getAudioSessionConfiguration(AudioSessionConfiguration* config) = 0;
421
440 virtual int setLogFile(const char* filePath, unsigned int fileSize) = 0;
459 virtual int setLogFilter(unsigned int filters) = 0;
460
469 virtual agora_refptr<rtc::IRtcConnection> createRtcConnection(
470 const rtc::RtcConnectionConfiguration& cfg) = 0;
471
482 virtual agora_refptr<rtc::IRtmpConnection> createRtmpConnection(
483 const rtc::RtmpConnectionConfiguration& cfg) = 0;
484
496 virtual agora_refptr<rtc::ILocalAudioTrack> createLocalAudioTrack() = 0;
497
509 virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
510 agora_refptr<rtc::IAudioPcmDataSender> audioSource) = 0;
511
524 virtual agora_refptr<rtc::ILocalAudioTrack> createDirectCustomAudioTrack(
525 agora_refptr<rtc::IAudioPcmDataSender> audioSource) = 0;
526
528
540 virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
541 agora_refptr<rtc::IAudioPcmDataSender> audioSource, bool enableAec) = 0;
543
545
558 virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
559 agora_refptr<rtc::IAudioPcmDataSender> audioSource,
560 agora_refptr<rtc::IAudioPcmDataSender> audioReverseSource, int audioSourceDelay) = 0;
562
574 virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
575 agora_refptr<rtc::IAudioEncodedFrameSender> audioSource, TMixMode mixMode) = 0;
576
584 virtual agora_refptr<rtc::IMediaNodeFactory> createMediaNodeFactory() = 0;
585
598 virtual agora_refptr<rtc::ILocalVideoTrack> createMixedVideoTrack(agora_refptr<rtc::IVideoMixerSource> videoSource,
599 const char* id = OPTIONAL_NULLPTR) = 0;
600
612 virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
613 agora_refptr<rtc::IVideoFrameSender> videoSource, const char* id = OPTIONAL_NULLPTR) = 0;
614
615
628 virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
629 agora_refptr<rtc::IVideoEncodedImageSender> videoSource,
630 const rtc::SenderOptions& options,
631 const char* id = OPTIONAL_NULLPTR) = 0;
632
633 protected:
634 virtual ~IAgoraService() {}
635};
636
637} // namespace base
638} // namespace agora
639
#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 setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario)=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 int setLogFilter(unsigned int filters)=0
virtual agora_refptr< rtc::ILocalVideoTrack > createMixedVideoTrack(agora_refptr< rtc::IVideoMixerSource > videoSource, const char *id=OPTIONAL_NULLPTR)=0
virtual int setLogFile(const char *filePath, unsigned int fileSize)=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:634
virtual agora_refptr< rtc::ILocalAudioTrack > createCustomAudioTrack(agora_refptr< rtc::IAudioEncodedFrameSender > audioSource, TMixMode mixMode)=0
virtual agora_refptr< rtc::IRtcConnection > createRtcConnection(const rtc::RtcConnectionConfiguration &cfg)=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:2634
@ AUDIO_SCENARIO_DEFAULT
Definition: AgoraBase.h:2604
TCcMode
Definition: AgoraBase.h:4974
@ CC_ENABLED
Definition: AgoraBase.h:4978
AUDIO_PROFILE_TYPE
Definition: AgoraBase.h:2599
VIDEO_CODEC_TYPE
Definition: AgoraBase.h:1552
@ VIDEO_CODEC_H264
Definition: AgoraBase.h:1564
@ AREA_CODE_GLOB
Definition: AgoraBase.h:4372
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