暫無描述

IAgoraRtcEngine.h 60KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011
  1. //
  2. // Agora Rtc Engine SDK
  3. //
  4. // Created by Sting Feng in 2015-02.
  5. // Copyright (c) 2015 Agora IO. All rights reserved.
  6. //
  7. #ifndef AGORA_RTC_ENGINE_H
  8. #define AGORA_RTC_ENGINE_H
  9. #include <stddef.h>
  10. #include <stdio.h>
  11. #include <stdarg.h>
  12. #if defined(_WIN32)
  13. #define WIN32_LEAN_AND_MEAN
  14. #include <windows.h>
  15. #define AGORA_CALL __cdecl
  16. #if defined(AGORARTC_EXPORT)
  17. #define AGORA_API extern "C" __declspec(dllexport)
  18. #else
  19. #define AGORA_API extern "C" __declspec(dllimport)
  20. #endif
  21. #elif defined(__APPLE__)
  22. #define AGORA_API __attribute__((visibility("default"))) extern "C"
  23. #define AGORA_CALL
  24. #elif defined(__ANDROID__) || defined(__linux__)
  25. #define AGORA_API extern "C" __attribute__((visibility("default")))
  26. #define AGORA_CALL
  27. #else
  28. #define AGORA_API extern "C"
  29. #define AGORA_CALL
  30. #endif
  31. namespace agora {
  32. namespace util {
  33. template<class T>
  34. class AutoPtr {
  35. typedef T value_type;
  36. typedef T* pointer_type;
  37. public:
  38. AutoPtr(pointer_type p=0)
  39. :ptr_(p)
  40. {}
  41. ~AutoPtr() {
  42. if (ptr_)
  43. ptr_->release();
  44. }
  45. operator bool() const { return ptr_ != (pointer_type)0; }
  46. value_type& operator*() const {
  47. return *get();
  48. }
  49. pointer_type operator->() const {
  50. return get();
  51. }
  52. pointer_type get() const {
  53. return ptr_;
  54. }
  55. pointer_type release() {
  56. pointer_type tmp = ptr_;
  57. ptr_ = 0;
  58. return tmp;
  59. }
  60. void reset(pointer_type ptr = 0) {
  61. if (ptr != ptr_ && ptr_)
  62. ptr_->release();
  63. ptr_ = ptr;
  64. }
  65. template<class C1, class C2>
  66. void queryInterface(C1& c, C2 iid) {
  67. pointer_type p;
  68. if (!c.queryInterface(iid, (void**)&p))
  69. reset(p);
  70. }
  71. private:
  72. AutoPtr(const AutoPtr&);
  73. AutoPtr& operator=(const AutoPtr&);
  74. private:
  75. pointer_type ptr_;
  76. };
  77. class IString {
  78. public:
  79. virtual bool empty() const = 0;
  80. virtual const char* c_str() = 0;
  81. virtual const char* data() = 0;
  82. virtual size_t length() = 0;
  83. virtual void release() = 0;
  84. };
  85. typedef AutoPtr<IString> AString;
  86. }//namespace util
  87. namespace rtc {
  88. typedef unsigned int uid_t;
  89. typedef void* view_t;
  90. enum INTERFACE_ID_TYPE
  91. {
  92. AGORA_IID_AUDIO_DEVICE_MANAGER = 1,
  93. AGORA_IID_VIDEO_DEVICE_MANAGER = 2,
  94. AGORA_IID_RTC_ENGINE_PARAMETER = 3,
  95. AGORA_IID_MEDIA_ENGINE = 4,
  96. };
  97. enum WARN_CODE_TYPE
  98. {
  99. WARN_INVALID_VIEW = 8,
  100. WARN_INIT_VIDEO = 16,
  101. WARN_PENDING = 20,
  102. WARN_NO_AVAILABLE_CHANNEL = 103,
  103. WARN_LOOKUP_CHANNEL_TIMEOUT = 104,
  104. WARN_LOOKUP_CHANNEL_REJECTED = 105,
  105. WARN_OPEN_CHANNEL_TIMEOUT = 106,
  106. WARN_OPEN_CHANNEL_REJECTED = 107,
  107. WARN_AUDIO_MIXING_OPEN_ERROR = 701,
  108. WARN_ADM_RUNTIME_PLAYOUT_WARNING = 1014,
  109. WARN_ADM_RUNTIME_RECORDING_WARNING = 1016,
  110. WARN_ADM_RECORD_AUDIO_SILENCE = 1019,
  111. WARN_ADM_PLAYOUT_MALFUNCTION = 1020,
  112. WARN_ADM_RECORD_MALFUNCTION = 1021,
  113. WARN_ADM_RECORD_AUDIO_LOWLEVEL = 1031,
  114. WARN_APM_HOWLING = 1051,
  115. // sdk: 100~1000
  116. WARN_SWITCH_LIVE_VIDEO_TIMEOUT = 111,
  117. WARN_SET_CLIENT_ROLE_TIMEOUT = 118,
  118. WARN_SET_CLIENT_ROLE_NOT_AUTHORIZED = 119,
  119. };
  120. enum ERROR_CODE_TYPE
  121. {
  122. ERR_OK = 0,
  123. //1~1000
  124. ERR_FAILED = 1,
  125. ERR_INVALID_ARGUMENT = 2,
  126. ERR_NOT_READY = 3,
  127. ERR_NOT_SUPPORTED = 4,
  128. ERR_REFUSED = 5,
  129. ERR_BUFFER_TOO_SMALL = 6,
  130. ERR_NOT_INITIALIZED = 7,
  131. ERR_NO_PERMISSION = 9,
  132. ERR_TIMEDOUT = 10,
  133. ERR_CANCELED = 11,
  134. ERR_TOO_OFTEN = 12,
  135. ERR_BIND_SOCKET = 13,
  136. ERR_NET_DOWN = 14,
  137. ERR_NET_NOBUFS = 15,
  138. ERR_JOIN_CHANNEL_REJECTED = 17,
  139. ERR_LEAVE_CHANNEL_REJECTED = 18,
  140. ERR_ALREADY_IN_USE = 19,
  141. ERR_ABORTED = 20,
  142. ERR_INIT_NET_ENGINE = 21,
  143. ERR_INVALID_APP_ID = 101,
  144. ERR_INVALID_CHANNEL_NAME = 102,
  145. ERR_CHANNEL_KEY_EXPIRED = 109,
  146. ERR_INVALID_CHANNEL_KEY = 110,
  147. ERR_CONNECTION_INTERRUPTED = 111, // only used in web sdk
  148. ERR_CONNECTION_LOST = 112, // only used in web sdk
  149. ERR_DECRYPTION_FAILED = 120,
  150. ERR_NOT_IN_CHANNEL = 113,
  151. ERR_SIZE_TOO_LARGE = 114,
  152. ERR_BITRATE_LIMIT = 115,
  153. ERR_TOO_MANY_DATA_STREAMS = 116,
  154. ERR_STREAM_MESSAGE_TIMEOUT = 117,
  155. //1001~2000
  156. ERR_LOAD_MEDIA_ENGINE = 1001,
  157. ERR_START_CALL = 1002,
  158. ERR_START_CAMERA = 1003,
  159. ERR_START_VIDEO_RENDER = 1004,
  160. ERR_ADM_GENERAL_ERROR = 1005,
  161. ERR_ADM_JAVA_RESOURCE = 1006,
  162. ERR_ADM_SAMPLE_RATE = 1007,
  163. ERR_ADM_INIT_PLAYOUT = 1008,
  164. ERR_ADM_START_PLAYOUT = 1009,
  165. ERR_ADM_STOP_PLAYOUT = 1010,
  166. ERR_ADM_INIT_RECORDING = 1011,
  167. ERR_ADM_START_RECORDING = 1012,
  168. ERR_ADM_STOP_RECORDING = 1013,
  169. ERR_ADM_RUNTIME_PLAYOUT_ERROR = 1015,
  170. ERR_ADM_RUNTIME_RECORDING_ERROR = 1017,
  171. ERR_ADM_RECORD_AUDIO_FAILED = 1018,
  172. ERR_ADM_INIT_LOOPBACK = 1022,
  173. ERR_ADM_START_LOOPBACK = 1023,
  174. // 1025, as warning for interruption of adm on ios
  175. // 1026, as warning for route change of adm on ios
  176. // VDM error code starts from 1500
  177. ERR_VDM_CAMERA_NOT_AUTHORIZED = 1501,
  178. // VCM error code starts from 1600
  179. ERR_VCM_UNKNOWN_ERROR = 1600,
  180. ERR_VCM_ENCODER_INIT_ERROR = 1601,
  181. ERR_VCM_ENCODER_ENCODE_ERROR = 1602,
  182. ERR_VCM_ENCODER_SET_ERROR = 1603,
  183. };
  184. enum LOG_FILTER_TYPE
  185. {
  186. LOG_FILTER_OFF = 0,
  187. LOG_FILTER_DEBUG = 0x080f,
  188. LOG_FILTER_INFO = 0x000f,
  189. LOG_FILTER_WARN = 0x000e,
  190. LOG_FILTER_ERROR = 0x000c,
  191. LOG_FILTER_CRITICAL = 0x0008,
  192. LOG_FILTER_MASK = 0x80f,
  193. };
  194. enum MAX_DEVICE_ID_LENGTH_TYPE
  195. {
  196. MAX_DEVICE_ID_LENGTH = 512
  197. };
  198. enum QUALITY_REPORT_FORMAT_TYPE
  199. {
  200. QUALITY_REPORT_JSON = 0,
  201. QUALITY_REPORT_HTML = 1,
  202. };
  203. enum MEDIA_ENGINE_EVENT_CODE_TYPE
  204. {
  205. MEDIA_ENGINE_RECORDING_ERROR = 0,
  206. MEDIA_ENGINE_PLAYOUT_ERROR = 1,
  207. MEDIA_ENGINE_RECORDING_WARNING = 2,
  208. MEDIA_ENGINE_PLAYOUT_WARNING = 3,
  209. MEDIA_ENGINE_AUDIO_FILE_MIX_FINISH = 10,
  210. MEDIA_ENGINE_AUDIO_SAMPLE_RATE_RECONFIG_FINISH = 11,
  211. // media engine role changed
  212. MEDIA_ENGINE_ROLE_BROADCASTER_SOLO = 20,
  213. MEDIA_ENGINE_ROLE_BROADCASTER_INTERACTIVE = 21,
  214. MEDIA_ENGINE_ROLE_AUDIENCE = 22,
  215. MEDIA_ENGINE_ROLE_COMM_PEER = 23,
  216. MEDIA_ENGINE_ROLE_GAME_PEER = 24,
  217. // iOS adm sample rate changed
  218. MEDIA_ENGINE_AUDIO_ADM_REQUIRE_RESTART = 110
  219. };
  220. enum MEDIA_DEVICE_STATE_TYPE
  221. {
  222. MEDIA_DEVICE_STATE_ACTIVE = 1,
  223. MEDIA_DEVICE_STATE_DISABLED = 2,
  224. MEDIA_DEVICE_STATE_NOT_PRESENT = 4,
  225. MEDIA_DEVICE_STATE_UNPLUGGED = 8
  226. };
  227. enum MEDIA_DEVICE_TYPE
  228. {
  229. UNKNOWN_AUDIO_DEVICE = -1,
  230. AUDIO_PLAYOUT_DEVICE = 0,
  231. AUDIO_RECORDING_DEVICE = 1,
  232. VIDEO_RENDER_DEVICE = 2,
  233. VIDEO_CAPTURE_DEVICE = 3,
  234. };
  235. enum QUALITY_TYPE
  236. {
  237. QUALITY_UNKNOWN = 0,
  238. QUALITY_EXCELLENT = 1,
  239. QUALITY_GOOD = 2,
  240. QUALITY_POOR = 3,
  241. QUALITY_BAD = 4,
  242. QUALITY_VBAD = 5,
  243. QUALITY_DOWN = 6,
  244. };
  245. enum RENDER_MODE_TYPE
  246. {
  247. RENDER_MODE_HIDDEN = 1,
  248. RENDER_MODE_FIT = 2,
  249. RENDER_MODE_ADAPTIVE = 3,
  250. };
  251. enum VIDEO_PROFILE_TYPE
  252. { // res fps kbps
  253. VIDEO_PROFILE_120P = 0, // 160x120 15 65
  254. VIDEO_PROFILE_120P_3 = 2, // 120x120 15 50
  255. VIDEO_PROFILE_180P = 10, // 320x180 15 140
  256. VIDEO_PROFILE_180P_3 = 12, // 180x180 15 100
  257. VIDEO_PROFILE_180P_4 = 13, // 240x180 15 120
  258. VIDEO_PROFILE_240P = 20, // 320x240 15 200
  259. VIDEO_PROFILE_240P_3 = 22, // 240x240 15 140
  260. VIDEO_PROFILE_240P_4 = 23, // 424x240 15 220
  261. VIDEO_PROFILE_360P = 30, // 640x360 15 400
  262. VIDEO_PROFILE_360P_3 = 32, // 360x360 15 260
  263. VIDEO_PROFILE_360P_4 = 33, // 640x360 30 600
  264. VIDEO_PROFILE_360P_6 = 35, // 360x360 30 400
  265. VIDEO_PROFILE_360P_7 = 36, // 480x360 15 320
  266. VIDEO_PROFILE_360P_8 = 37, // 480x360 30 490
  267. VIDEO_PROFILE_360P_9 = 38, // 640x360 15 800
  268. VIDEO_PROFILE_360P_10 = 39, // 640x360 24 800
  269. VIDEO_PROFILE_360P_11 = 100, // 640x360 24 1000
  270. VIDEO_PROFILE_480P = 40, // 640x480 15 500
  271. VIDEO_PROFILE_480P_3 = 42, // 480x480 15 400
  272. VIDEO_PROFILE_480P_4 = 43, // 640x480 30 750
  273. VIDEO_PROFILE_480P_6 = 45, // 480x480 30 600
  274. VIDEO_PROFILE_480P_8 = 47, // 848x480 15 610
  275. VIDEO_PROFILE_480P_9 = 48, // 848x480 30 930
  276. VIDEO_PROFILE_480P_10 = 49, // 640x480 10 400
  277. VIDEO_PROFILE_720P = 50, // 1280x720 15 1130
  278. VIDEO_PROFILE_720P_3 = 52, // 1280x720 30 1710
  279. VIDEO_PROFILE_720P_5 = 54, // 960x720 15 910
  280. VIDEO_PROFILE_720P_6 = 55, // 960x720 30 1380
  281. VIDEO_PROFILE_1080P = 60, // 1920x1080 15 2080
  282. VIDEO_PROFILE_1080P_3 = 62, // 1920x1080 30 3150
  283. VIDEO_PROFILE_1080P_5 = 64, // 1920x1080 60 4780
  284. VIDEO_PROFILE_1440P = 66, // 2560x1440 30 4850
  285. VIDEO_PROFILE_1440P_2 = 67, // 2560x1440 60 7350
  286. VIDEO_PROFILE_4K = 70, // 3840x2160 30 8910
  287. VIDEO_PROFILE_4K_3 = 72, // 3840x2160 60 13500
  288. VIDEO_PROFILE_DEFAULT = VIDEO_PROFILE_360P,
  289. };
  290. enum CHANNEL_PROFILE_TYPE
  291. {
  292. CHANNEL_PROFILE_COMMUNICATION = 0,
  293. CHANNEL_PROFILE_LIVE_BROADCASTING = 1,
  294. CHANNEL_PROFILE_GAME = 2,
  295. };
  296. enum CLIENT_ROLE_TYPE
  297. {
  298. CLIENT_ROLE_BROADCASTER = 1,
  299. CLIENT_ROLE_AUDIENCE = 2,
  300. };
  301. enum USER_OFFLINE_REASON_TYPE
  302. {
  303. USER_OFFLINE_QUIT = 0,
  304. USER_OFFLINE_DROPPED = 1,
  305. USER_OFFLINE_BECOME_AUDIENCE = 2,
  306. };
  307. enum REMOTE_VIDEO_STREAM_TYPE
  308. {
  309. REMOTE_VIDEO_STREAM_HIGH = 0,
  310. REMOTE_VIDEO_STREAM_LOW = 1,
  311. };
  312. enum RAW_AUDIO_FRAME_OP_MODE_TYPE
  313. {
  314. RAW_AUDIO_FRAME_OP_MODE_READ_ONLY = 0,
  315. RAW_AUDIO_FRAME_OP_MODE_WRITE_ONLY = 1,
  316. RAW_AUDIO_FRAME_OP_MODE_READ_WRITE = 2,
  317. };
  318. struct AudioVolumeInfo
  319. {
  320. uid_t uid;
  321. unsigned int volume; // [0,255]
  322. };
  323. struct RtcStats
  324. {
  325. unsigned int duration;
  326. unsigned int txBytes;
  327. unsigned int rxBytes;
  328. unsigned short txKBitRate;
  329. unsigned short rxKBitRate;
  330. unsigned short rxAudioKBitRate;
  331. unsigned short txAudioKBitRate;
  332. unsigned short rxVideoKBitRate;
  333. unsigned short txVideoKBitRate;
  334. unsigned int users;
  335. double cpuAppUsage;
  336. double cpuTotalUsage;
  337. };
  338. struct LocalVideoStats
  339. {
  340. int sentBitrate;
  341. int sentFrameRate;
  342. };
  343. struct RemoteVideoStats
  344. {
  345. uid_t uid;
  346. int delay;
  347. int width;
  348. int height;
  349. int receivedBitrate;
  350. int receivedFrameRate;
  351. REMOTE_VIDEO_STREAM_TYPE rxStreamType;
  352. };
  353. struct VideoCompositingLayout
  354. {
  355. struct Region {
  356. uid_t uid;
  357. double x;//[0,1]
  358. double y;//[0,1]
  359. double width;//[0,1]
  360. double height;//[0,1]
  361. int zOrder; //optional, [0, 100] //0 (default): bottom most, 100: top most
  362. // Optional
  363. // [0, 1.0] where 0 denotes throughly transparent, 1.0 opaque
  364. double alpha;
  365. RENDER_MODE_TYPE renderMode;//RENDER_MODE_HIDDEN: Crop, RENDER_MODE_FIT: Zoom to fit
  366. Region()
  367. :uid(0)
  368. , x(0)
  369. , y(0)
  370. , width(0)
  371. , height(0)
  372. , zOrder(0)
  373. , alpha(1.0)
  374. , renderMode(RENDER_MODE_HIDDEN)
  375. {}
  376. };
  377. int canvasWidth;
  378. int canvasHeight;
  379. const char* backgroundColor;//e.g. "#C0C0C0" in RGB
  380. const Region* regions;
  381. int regionCount;
  382. const char* appData;
  383. int appDataLength;
  384. VideoCompositingLayout()
  385. :canvasWidth(0)
  386. ,canvasHeight(0)
  387. ,backgroundColor(NULL)
  388. ,regions(NULL)
  389. , regionCount(0)
  390. , appData(NULL)
  391. , appDataLength(0)
  392. {}
  393. };
  394. #if defined(_WIN32)
  395. enum RTMP_STREAM_LIFE_CYCLE_TYPE
  396. {
  397. RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL = 1,
  398. RTMP_STREAM_LIFE_CYCLE_BIND2OWNER = 2,
  399. };
  400. struct PublisherConfiguration {
  401. int width;
  402. int height;
  403. int framerate;
  404. int bitrate;
  405. int defaultLayout;
  406. int lifecycle;
  407. bool owner;
  408. const char* publishUrl;
  409. const char* rawStreamUrl;
  410. const char* extraInfo;
  411. PublisherConfiguration()
  412. : width(640)
  413. , height(360)
  414. , framerate(15)
  415. , bitrate(500)
  416. , defaultLayout(1)
  417. , lifecycle(RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL)
  418. , owner(true)
  419. , publishUrl(NULL)
  420. , rawStreamUrl(NULL)
  421. , extraInfo(NULL)
  422. {}
  423. };
  424. #endif
  425. #if !defined(__ANDROID__)
  426. struct VideoCanvas
  427. {
  428. view_t view;
  429. int renderMode;
  430. uid_t uid;
  431. void *priv; // private data (underlying video engine denotes it)
  432. VideoCanvas()
  433. : view(NULL)
  434. , renderMode(RENDER_MODE_HIDDEN)
  435. , uid(0)
  436. , priv(NULL)
  437. {}
  438. VideoCanvas(view_t v, int m, uid_t u)
  439. : view(v)
  440. , renderMode(m)
  441. , uid(u)
  442. , priv(NULL)
  443. {}
  444. };
  445. #else
  446. struct VideoCanvas;
  447. #endif
  448. class IPacketObserver
  449. {
  450. public:
  451. struct Packet
  452. {
  453. const unsigned char* buffer;
  454. unsigned int size;
  455. };
  456. /**
  457. * called by sdk before the audio packet is sent to other participants
  458. * @param [in,out] packet
  459. * buffer *buffer points the data to be sent
  460. * size of buffer data to be sent
  461. * @return returns true to send out the packet, returns false to discard the packet
  462. */
  463. virtual bool onSendAudioPacket(Packet& packet) = 0;
  464. /**
  465. * called by sdk before the video packet is sent to other participants
  466. * @param [in,out] packet
  467. * buffer *buffer points the data to be sent
  468. * size of buffer data to be sent
  469. * @return returns true to send out the packet, returns false to discard the packet
  470. */
  471. virtual bool onSendVideoPacket(Packet& packet) = 0;
  472. /**
  473. * called by sdk when the audio packet is received from other participants
  474. * @param [in,out] packet
  475. * buffer *buffer points the data to be sent
  476. * size of buffer data to be sent
  477. * @return returns true to process the packet, returns false to discard the packet
  478. */
  479. virtual bool onReceiveAudioPacket(Packet& packet) = 0;
  480. /**
  481. * called by sdk when the video packet is received from other participants
  482. * @param [in,out] packet
  483. * buffer *buffer points the data to be sent
  484. * size of buffer data to be sent
  485. * @return returns true to process the packet, returns false to discard the packet
  486. */
  487. virtual bool onReceiveVideoPacket(Packet& packet) = 0;
  488. };
  489. /**
  490. * the event call back interface
  491. */
  492. class IRtcEngineEventHandler
  493. {
  494. public:
  495. virtual ~IRtcEngineEventHandler() {}
  496. /**
  497. * when join channel success, the function will be called
  498. * @param [in] channel
  499. * the channel name you have joined
  500. * @param [in] uid
  501. * the UID of you in this channel
  502. * @param [in] elapsed
  503. * the time elapsed in ms from the joinChannel been called to joining completed
  504. */
  505. virtual void onJoinChannelSuccess(const char* channel, uid_t uid, int elapsed) {
  506. (void)channel;
  507. (void)uid;
  508. (void)elapsed;
  509. }
  510. /**
  511. * when join channel success, the function will be called
  512. * @param [in] channel
  513. * the channel name you have joined
  514. * @param [in] uid
  515. * the UID of you in this channel
  516. * @param [in] elapsed
  517. * the time elapsed in ms elapsed
  518. */
  519. virtual void onRejoinChannelSuccess(const char* channel, uid_t uid, int elapsed) {
  520. (void)channel;
  521. (void)uid;
  522. (void)elapsed;
  523. }
  524. /**
  525. * when warning message coming, the function will be called
  526. * @param [in] warn
  527. * warning code
  528. * @param [in] msg
  529. * the warning message
  530. */
  531. virtual void onWarning(int warn, const char* msg) {
  532. (void)warn;
  533. (void)msg;
  534. }
  535. /**
  536. * when error message come, the function will be called
  537. * @param [in] err
  538. * error code
  539. * @param [in] msg
  540. * the error message
  541. */
  542. virtual void onError(int err, const char* msg) {
  543. (void)err;
  544. (void)msg;
  545. }
  546. /**
  547. * when audio quality message come, the function will be called
  548. * @param [in] uid
  549. * the uid of the peer
  550. * @param [in] quality
  551. * the quality of the user, see QUALITY_TYPE for value definition
  552. * @param [in] delay
  553. * the average time of the audio packages delayed
  554. * @param [in] lost
  555. * the rate of the audio packages lost
  556. */
  557. virtual void onAudioQuality(uid_t uid, int quality, unsigned short delay, unsigned short lost) {
  558. (void)uid;
  559. (void)quality;
  560. (void)delay;
  561. (void)lost;
  562. }
  563. /**
  564. * when the audio volume information come, the function will be called
  565. * @param [in] speakers
  566. * the array of the speakers' audio volume information
  567. * @param [in] speakerNumber
  568. * the count of speakers in this array
  569. * @param [in] totalVolume
  570. * the total volume of all users
  571. */
  572. virtual void onAudioVolumeIndication(const AudioVolumeInfo* speakers, unsigned int speakerNumber, int totalVolume) {
  573. (void)speakers;
  574. (void)speakerNumber;
  575. (void)totalVolume;
  576. }
  577. /**
  578. * when the audio volume information come, the function will be called
  579. * @param [in] stats
  580. * the statistics of the call
  581. */
  582. virtual void onLeaveChannel(const RtcStats& stats) {
  583. (void)stats;
  584. }
  585. /**
  586. * when the information of the RTC engine stats come, the function will be called
  587. * @param [in] stats
  588. * the RTC engine stats
  589. */
  590. virtual void onRtcStats(const RtcStats& stats) {
  591. (void)stats;
  592. }
  593. /**
  594. * when the audio device state changed(plugged or removed), the function will be called
  595. * @param [in] deviceId
  596. * the ID of the state changed audio device
  597. * @param [in] deviceType
  598. * the type of the audio device(playout device or record device)
  599. * @param [in] deviceState
  600. * the device is been removed or added
  601. */
  602. virtual void onAudioDeviceStateChanged(const char* deviceId, int deviceType, int deviceState) {
  603. (void)deviceId;
  604. (void)deviceType;
  605. (void)deviceState;
  606. }
  607. /**
  608. * When audio mixing file playback finished, this function will be called
  609. */
  610. virtual void onAudioMixingFinished() {
  611. }
  612. /**
  613. * when the video device state changed(plugged or removed), the function will be called
  614. * @param [in] deviceId
  615. * the ID of the state changed video device
  616. * @param [in] deviceType
  617. * not used
  618. * @param [in] deviceState
  619. * the device is been removed or added
  620. */
  621. virtual void onVideoDeviceStateChanged(const char* deviceId, int deviceType, int deviceState) {
  622. (void)deviceId;
  623. (void)deviceType;
  624. (void)deviceState;
  625. }
  626. /**
  627. * report the network quality
  628. * @param [in] uid
  629. * the UID of the remote user
  630. * @param [in] txQuality
  631. * the score of the send network quality 0~5 the higher the better
  632. * @param [in] rxQuality
  633. * the score of the recv network quality 0~5 the higher the better
  634. */
  635. virtual void onNetworkQuality(uid_t uid, int txQuality, int rxQuality) {
  636. (void)uid;
  637. (void)txQuality;
  638. (void)rxQuality;
  639. }
  640. /**
  641. * report the last-mile test network quality
  642. * @param [in] quality
  643. * the score of the network quality 0~5 the higher the better
  644. */
  645. virtual void onLastmileQuality(int quality) {
  646. (void)quality;
  647. }
  648. /**
  649. * when the first local video frame displayed, the function will be called
  650. * @param [in] width
  651. * the width of the video frame
  652. * @param [in] height
  653. * the height of the video frame
  654. * @param [in] elapsed
  655. * the time elapsed from channel joined in ms
  656. */
  657. virtual void onFirstLocalVideoFrame(int width, int height, int elapsed) {
  658. (void)width;
  659. (void)height;
  660. (void)elapsed;
  661. }
  662. /**
  663. * when the first remote video frame decoded, the function will be called
  664. * @param [in] uid
  665. * the UID of the remote user
  666. * @param [in] width
  667. * the width of the video frame
  668. * @param [in] height
  669. * the height of the video frame
  670. * @param [in] elapsed
  671. * the time elapsed from channel joined in ms
  672. */
  673. virtual void onFirstRemoteVideoDecoded(uid_t uid, int width, int height, int elapsed) {
  674. (void)uid;
  675. (void)width;
  676. (void)height;
  677. (void)elapsed;
  678. }
  679. /**
  680. * when video size changed or rotation changed, the function will be called
  681. * @param [in] uid
  682. * the UID of the remote user or local user (0)
  683. * @param [in] width
  684. * the new width of the video
  685. * @param [in] height
  686. * the new height of the video
  687. * @param [in] rotation
  688. * the rotation of the video
  689. */
  690. virtual void onVideoSizeChanged(uid_t uid, int width, int height, int rotation) {
  691. (void)uid;
  692. (void)width;
  693. (void)height;
  694. (void)rotation;
  695. }
  696. /**
  697. * when the first remote video frame displayed, the function will be called
  698. * @param [in] uid
  699. * the UID of the remote user
  700. * @param [in] width
  701. * the width of the video frame
  702. * @param [in] height
  703. * the height of the video frame
  704. * @param [in] elapsed
  705. * the time elapsed from remote user called joinChannel in ms
  706. */
  707. virtual void onFirstRemoteVideoFrame(uid_t uid, int width, int height, int elapsed) {
  708. (void)uid;
  709. (void)width;
  710. (void)height;
  711. (void)elapsed;
  712. }
  713. /**
  714. * when any other user joined in the same channel, the function will be called
  715. * @param [in] uid
  716. * the UID of the remote user
  717. * @param [in] elapsed
  718. * the time elapsed from remote used called joinChannel to joining completed in ms
  719. */
  720. virtual void onUserJoined(uid_t uid, int elapsed) {
  721. (void)uid;
  722. (void)elapsed;
  723. }
  724. /**
  725. * when user offline(exit channel or offline by accident), the function will be called
  726. * @param [in] uid
  727. * the UID of the remote user
  728. */
  729. virtual void onUserOffline(uid_t uid, USER_OFFLINE_REASON_TYPE reason) {
  730. (void)uid;
  731. (void)reason;
  732. }
  733. /**
  734. * when remote user muted the audio stream, the function will be called
  735. * @param [in] uid
  736. * the UID of the remote user
  737. * @param [in] muted
  738. * true: the remote user muted the audio stream, false: the remote user unmuted the audio stream
  739. */
  740. virtual void onUserMuteAudio(uid_t uid, bool muted) {
  741. (void)uid;
  742. (void)muted;
  743. }
  744. /**
  745. * when remote user muted the video stream, the function will be called
  746. * @param [in] uid
  747. * the UID of the remote user
  748. * @param [in] muted
  749. * true: the remote user muted the video stream, false: the remote user unmuted the video stream
  750. */
  751. virtual void onUserMuteVideo(uid_t uid, bool muted) {
  752. (void)uid;
  753. (void)muted;
  754. }
  755. /**
  756. * when remote user enable video function, the function will be called
  757. * @param [in] uid
  758. * the UID of the remote user
  759. * @param [in] enabled
  760. * true: the remote user has enabled video function, false: the remote user has disabled video function
  761. */
  762. virtual void onUserEnableVideo(uid_t uid, bool enabled) {
  763. (void)uid;
  764. (void)enabled;
  765. }
  766. /**
  767. * when api call executed completely, the function will be called
  768. * @param [in] api
  769. * the api name
  770. * @param [in] error
  771. * error code while 0 means OK
  772. */
  773. virtual void onApiCallExecuted(const char* api, int error) {
  774. (void)api;
  775. (void)error;
  776. }
  777. /**
  778. * reported local video stats
  779. * @param [in] stats
  780. * the latest local video stats
  781. */
  782. virtual void onLocalVideoStats(const LocalVideoStats& stats) {
  783. (void)stats;
  784. }
  785. /**
  786. * reported remote video stats
  787. * @param [in] stats
  788. * the latest remote video stats
  789. */
  790. virtual void onRemoteVideoStats(const RemoteVideoStats& stats) {
  791. (void)stats;
  792. }
  793. /**
  794. * when the camera is ready to work, the function will be called
  795. */
  796. virtual void onCameraReady() {}
  797. /**
  798. * when all video stopped, the function will be called then you can repaint the video windows
  799. */
  800. virtual void onVideoStopped() {}
  801. /**
  802. * when the network can not worked well, the function will be called
  803. */
  804. virtual void onConnectionLost() {}
  805. /**
  806. * when local user disconnected by accident, the function will be called(then SDK will try to reconnect itself)
  807. */
  808. virtual void onConnectionInterrupted() {}
  809. virtual void onRefreshRecordingServiceStatus(int status) {
  810. (void)status;
  811. }
  812. // virtual void onStreamError(int streamId, int code, int parameter, const char* message, size_t length) {}
  813. /**
  814. * when stream message received, the function will be called
  815. * @param [in] uid
  816. * UID of the peer who sends the message
  817. * @param [in] streamId
  818. * APP can create multiple streams for sending messages of different purposes
  819. * @param [in] data
  820. * the message data
  821. * @param [in] length
  822. * the message length, in bytes
  823. * frame rate
  824. */
  825. virtual void onStreamMessage(uid_t uid, int streamId, const char* data, size_t length) {
  826. (void)uid;
  827. (void)streamId;
  828. (void)data;
  829. (void)length;
  830. }
  831. /**
  832. *
  833. */
  834. virtual void onStreamMessageError(uid_t uid, int streamId, int code, int missed, int cached) {
  835. (void)uid;
  836. (void)streamId;
  837. (void)code;
  838. (void)missed;
  839. (void)cached;
  840. }
  841. virtual void onMediaEngineLoadSuccess() {
  842. }
  843. virtual void onMediaEngineStartCallSuccess() {
  844. }
  845. /**
  846. * when channel key is enabled, and specified channel key is invalid or expired, this function will be called.
  847. * APP should generate a new channel key and call renewChannelKey() to refresh the key.
  848. * NOTE: to be compatible with previous version, ERR_CHANNEL_KEY_EXPIRED and ERR_INVALID_CHANNEL_KEY are also reported via onError() callback.
  849. * You should move renew of channel key logic into this callback.
  850. */
  851. virtual void onRequestChannelKey() {
  852. }
  853. /**
  854. * when the first local audio frame generated, the function will be called
  855. * @param [in] elapsed
  856. * the time elapsed from remote user called joinChannel in ms
  857. */
  858. virtual void onFirstLocalAudioFrame(int elapsed) {
  859. (void)elapsed;
  860. }
  861. /**
  862. * when the first remote audio frame arrived, the function will be called
  863. * @param [in] uid
  864. * the UID of the remote user
  865. * @param [in] elapsed
  866. * the time elapsed from remote user called joinChannel in ms
  867. */
  868. virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) {
  869. (void)uid;
  870. (void)elapsed;
  871. }
  872. };
  873. /**
  874. * the video device collection interface
  875. */
  876. class IVideoDeviceCollection
  877. {
  878. public:
  879. /**
  880. * get the audio device count
  881. * @return returns the audio device count
  882. */
  883. virtual int getCount() = 0;
  884. /**
  885. * get audio device information
  886. * @param [in] index
  887. * the index of the device in the device list
  888. * @param [in, out] deviceName
  889. * the device name, UTF8 format
  890. * @param [in, out] deviceId
  891. * the device ID, UTF8 format
  892. * @return return 0 if success or an error code
  893. */
  894. virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  895. /**
  896. * set current active audio device
  897. * @param [in] deviceId
  898. * the deviceId of the device you want to active currently
  899. * @return return 0 if success or an error code
  900. */
  901. virtual int setDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  902. /**
  903. * release the resource
  904. */
  905. virtual void release() = 0;
  906. };
  907. class IVideoDeviceManager
  908. {
  909. public:
  910. /**
  911. * create the IVideoDeviceCollection interface pointer
  912. * @return return the IVideoDeviceCollection interface or nullptr if failed
  913. */
  914. virtual IVideoDeviceCollection* enumerateVideoDevices() = 0;
  915. /**
  916. * active the video device for current using
  917. * @param [in] deviceId
  918. * the deviceId of the device you want to active currently
  919. * @return return 0 if success or the error code.
  920. */
  921. virtual int setDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  922. /**
  923. * get the current active video device
  924. * @param [in, out] deviceId
  925. * the device id of the current active video device
  926. * @return return 0 if success or an error code
  927. */
  928. virtual int getDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  929. /**
  930. * test the video capture device to know whether it can worked well
  931. * @param [in] hwnd
  932. * the HWND of the video-display window
  933. * @return return 0 if success or an error code
  934. */
  935. virtual int startDeviceTest(view_t hwnd) = 0;
  936. /**
  937. * stop the video device testing
  938. * @return return 0 if success or an error code
  939. */
  940. virtual int stopDeviceTest() = 0;
  941. /**
  942. * release the resource
  943. */
  944. virtual void release() = 0;
  945. };
  946. class IAudioDeviceCollection
  947. {
  948. public:
  949. /**
  950. * get the available devices count
  951. * @return return the device count
  952. */
  953. virtual int getCount() = 0;
  954. /**
  955. * get video device information
  956. * @param [in] index
  957. * the index of the device in the device list
  958. * @param [in, out] deviceName
  959. * the device name, UTF8 format
  960. * @param [in, out] deviceId
  961. * the device ID, UTF8 format
  962. * @return return 0 if success or an error code
  963. */
  964. virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  965. /**
  966. * active the device for current using
  967. * @param [in] deviceId
  968. * the deviceId of the device you want to active currently
  969. * @return return 0 if success or the error code.
  970. */
  971. virtual int setDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  972. /**
  973. * release the resource
  974. */
  975. virtual void release() = 0;
  976. };
  977. class IAudioDeviceManager
  978. {
  979. public:
  980. /**
  981. * create the IAudioDeviceCollection interface pointer of the playback devices
  982. * @return return the IVideoDeviceCollection interface or nullptr if failed
  983. */
  984. virtual IAudioDeviceCollection* enumeratePlaybackDevices() = 0;
  985. /**
  986. * create the IAudioDeviceCollection interface pointer of the Recording devices
  987. * @return return the IVideoDeviceCollection interface or nullptr if failed
  988. */
  989. virtual IAudioDeviceCollection* enumerateRecordingDevices() = 0;
  990. /**
  991. * active the playback device for current using
  992. * @param [in] deviceId
  993. * the deviceId of the playback device you want to active currently
  994. * @return return 0 if success or the error code.
  995. */
  996. virtual int setPlaybackDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  997. /**
  998. * get the current active playback device
  999. * @param [in, out] deviceId
  1000. * the device id of the current active video device
  1001. * @return return 0 if success or an error code
  1002. */
  1003. virtual int getPlaybackDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  1004. /**
  1005. * set current playback device volume
  1006. * @param [in] volume
  1007. * the volume you want to set 0-255
  1008. * @return return 0 if success or an error code
  1009. */
  1010. virtual int setPlaybackDeviceVolume(int volume) = 0;
  1011. /**
  1012. * get current playback device volume
  1013. * @param [in, out] volume
  1014. * the current playback device volume 0-255
  1015. * @return return 0 if success or an error code
  1016. */
  1017. virtual int getPlaybackDeviceVolume(int *volume) = 0;
  1018. /**
  1019. * active the recording audio device for current using
  1020. * @param [in] deviceId
  1021. * the deviceId of the recording audio device you want to active currently
  1022. * @return return 0 if success or the error code.
  1023. */
  1024. virtual int setRecordingDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  1025. /**
  1026. * get the current active recording device
  1027. * @param [in, out] deviceId
  1028. * the device id of the current active recording audio device
  1029. * @return return 0 if success or an error code
  1030. */
  1031. virtual int getRecordingDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
  1032. /**
  1033. * set current recording device volume
  1034. * @param [in] volume
  1035. * the volume you want to set 0-255
  1036. * @return return 0 if success or an error code
  1037. */
  1038. virtual int setRecordingDeviceVolume(int volume) = 0;
  1039. /**
  1040. * get current recording device volume
  1041. * @param [in, out] volume
  1042. * the current recording device volume 0-255
  1043. * @return return 0 if success or an error code
  1044. */
  1045. virtual int getRecordingDeviceVolume(int *volume) = 0;
  1046. /**
  1047. * test the playback audio device to know whether it can worked well
  1048. * @param [in] testAudioFilePath
  1049. * the path of the .wav file
  1050. * @return return 0 if success and you can hear the sound of the .wav file or an error code.
  1051. */
  1052. virtual int startPlaybackDeviceTest(const char* testAudioFilePath) = 0;
  1053. /**
  1054. * stop the playback audio device testing
  1055. * @return return 0 if success or an error code
  1056. */
  1057. virtual int stopPlaybackDeviceTest() = 0;
  1058. /**
  1059. * test the recording audio device to know whether it can worked well
  1060. * @param [in] indicationInterval
  1061. * the period in ms of the call back cycle
  1062. * @return return 0 if success or an error code
  1063. */
  1064. virtual int startRecordingDeviceTest(int indicationInterval) = 0;
  1065. /**
  1066. * stop the recording audio device testing
  1067. * @return return 0 if success or an error code
  1068. */
  1069. virtual int stopRecordingDeviceTest() = 0;
  1070. /**
  1071. * release the resource
  1072. */
  1073. virtual void release() = 0;
  1074. };
  1075. struct RtcEngineContext
  1076. {
  1077. IRtcEngineEventHandler* eventHandler;
  1078. const char* appId;
  1079. RtcEngineContext()
  1080. :eventHandler(NULL)
  1081. ,appId(NULL)
  1082. {}
  1083. };
  1084. class IRtcEngine
  1085. {
  1086. public:
  1087. /**
  1088. * release the engine resource
  1089. * @param [in] sync
  1090. * true: release the engine resources and return after all resources have been destroyed.
  1091. * APP should try not to call release(true) in the engine's callbacks, call it this way in a separate thread instead.
  1092. * false: notify engine to release its resources and returns without waiting for resources are really destroyed
  1093. */
  1094. virtual void release(bool sync=false) = 0;
  1095. /**
  1096. * initialize the engine
  1097. * @param [in] context
  1098. * the RTC engine context
  1099. * @return return 0 if success or an error code
  1100. */
  1101. virtual int initialize(const RtcEngineContext& context) = 0;
  1102. /**
  1103. * get the pointer of the device manager object.
  1104. * @param [in] iid
  1105. * the iid of the interface you want to get
  1106. * @param [in, out] inter
  1107. * the pointer of the pointer you want to point to DeviceManager object
  1108. * @return return 0 if success or an error code
  1109. */
  1110. virtual int queryInterface(INTERFACE_ID_TYPE iid, void** inter) = 0;
  1111. /**
  1112. * get the version information of the SDK
  1113. * @param [in, out] build
  1114. * the build number
  1115. * @return return the version number string in char format
  1116. */
  1117. virtual const char* getVersion(int* build) = 0;
  1118. /**
  1119. * get the version information of the SDK
  1120. * @param [in, out] code
  1121. * the build number
  1122. * @return return the version number string in char format
  1123. */
  1124. virtual const char* getErrorDescription(int code) = 0;
  1125. /**
  1126. * join the channel, if the channel have not been created, it will been created automatically
  1127. * @param [in] channelKey
  1128. * the channel key, if you have initialized the engine with an available APP ID, it can be null here. If you enable channel key on the dashboard, specify channel key here
  1129. * @param [in] channelName
  1130. * the channel name
  1131. * @param [in] info
  1132. * the additional information, it can be null here
  1133. * @param [in] uid
  1134. * the uid of you, if 0 the system will automatically allocate one for you
  1135. * @return return 0 if success or an error code
  1136. */
  1137. virtual int joinChannel(const char* channelKey, const char* channelName, const char* info, uid_t uid) = 0;
  1138. /**
  1139. * leave the current channel
  1140. * @return return 0 if success or an error code
  1141. */
  1142. virtual int leaveChannel() = 0;
  1143. /**
  1144. * renew the channel key for the current channel
  1145. * @param [in] channelKey the renewed channel key, if old channel key expired.
  1146. * @return return 0 if success or an error code
  1147. */
  1148. virtual int renewChannelKey(const char* channelKey) = 0;
  1149. virtual int setChannelProfile(CHANNEL_PROFILE_TYPE profile) = 0;
  1150. virtual int setClientRole(CLIENT_ROLE_TYPE role, const char* permissionKey) = 0;
  1151. /**
  1152. * start the echo testing, if every thing goes well you can hear your echo from the server
  1153. * @return return 0 if success or an error code
  1154. */
  1155. virtual int startEchoTest() = 0;
  1156. /**
  1157. * stop the echo testing
  1158. * @return return 0 if success or an error code
  1159. */
  1160. virtual int stopEchoTest() = 0;
  1161. /**
  1162. * start the network testing
  1163. * @return return 0 if success or an error code
  1164. */
  1165. virtual int enableLastmileTest() = 0;
  1166. /**
  1167. * stop the network testing
  1168. * @return return 0 if success or an error code
  1169. */
  1170. virtual int disableLastmileTest() = 0;
  1171. /**
  1172. * enable video function
  1173. * @return return 0 if success or an error code
  1174. */
  1175. virtual int enableVideo() = 0;
  1176. /**
  1177. * disable video function
  1178. * @return return 0 if success or an error code
  1179. */
  1180. virtual int disableVideo() = 0;
  1181. /**
  1182. * start the local video previewing
  1183. * @return return 0 if success or an error code
  1184. */
  1185. virtual int startPreview() = 0;
  1186. /**
  1187. * stop the local video previewing
  1188. * @return return 0 if success or an error code
  1189. */
  1190. virtual int stopPreview() = 0;
  1191. virtual int setVideoProfile(VIDEO_PROFILE_TYPE profile, bool swapWidthAndHeight) = 0;
  1192. /**
  1193. * set the remote video canvas
  1194. * @param [in] canvas
  1195. * the canvas information
  1196. * @return return 0 if success or an error code
  1197. */
  1198. virtual int setupRemoteVideo(const VideoCanvas& canvas) = 0;
  1199. /**
  1200. * set the local video canvas
  1201. * @param [in] canvas
  1202. * the canvas information
  1203. * @return return 0 if success or an error code
  1204. */
  1205. virtual int setupLocalVideo(const VideoCanvas& canvas) = 0;
  1206. /**
  1207. * enable audio function, which is enabled by deault.
  1208. * @return return 0 if success or an error code
  1209. */
  1210. virtual int enableAudio() = 0;
  1211. /**
  1212. * disable audio function
  1213. * @return return 0 if success or an error code
  1214. */
  1215. virtual int disableAudio() = 0;
  1216. /**
  1217. * get self call id in the current channel
  1218. * @param [in, out] callId
  1219. * the self call Id
  1220. * @return return 0 if success or an error code
  1221. */
  1222. virtual int getCallId(agora::util::AString& callId) = 0;
  1223. virtual int rate(const char* callId, int rating, const char* description) = 0; // 0~10
  1224. virtual int complain(const char* callId, const char* description) = 0;
  1225. /**
  1226. * register a packet observer while the packet arrived or ready to be sent, the observer can touch the packet data
  1227. * @param [in] observer
  1228. * the pointer of the observer object
  1229. * @return return 0 if success or an error code
  1230. */
  1231. virtual int registerPacketObserver(IPacketObserver* observer) = 0;
  1232. /**
  1233. * Specify encryption mode of AES encryption algorithm.
  1234. * @param [in] encryptionMode
  1235. * encryption mode of AES algorithm, could be one of the following:
  1236. * "aes-128-xts", "aes-256-xts".
  1237. * The default value is "aes-128-xts". specify NULL value will use default encryption mode.
  1238. * @return return 0 if success or an error code
  1239. */
  1240. virtual int setEncryptionMode(const char* encryptionMode) = 0;
  1241. /**
  1242. * Specify encryption secret enables built-in encryption function. Leaving channel will clear the secret specified in last channel
  1243. * @param [in] secret
  1244. * secret to enable encryption
  1245. * @return return 0 if success or an error code
  1246. */
  1247. virtual int setEncryptionSecret(const char* secret) = 0;
  1248. virtual int createDataStream(int* streamId, bool reliable, bool ordered) = 0;
  1249. virtual int sendStreamMessage(int streamId, const char* data, size_t length) = 0;
  1250. virtual int setVideoCompositingLayout(const VideoCompositingLayout& sei) = 0;
  1251. virtual int clearVideoCompositingLayout() = 0;
  1252. #if defined(_WIN32)
  1253. virtual int configPublisher(const PublisherConfiguration& config) = 0;
  1254. #endif
  1255. };
  1256. class IRtcEngineParameter
  1257. {
  1258. public:
  1259. /**
  1260. * release the resource
  1261. */
  1262. virtual void release() = 0;
  1263. /**
  1264. * set bool value of the json
  1265. * @param [in] key
  1266. * the key name
  1267. * @param [in] value
  1268. * the value
  1269. * @return return 0 if success or an error code
  1270. */
  1271. virtual int setBool(const char* key, bool value) = 0;
  1272. /**
  1273. * set int value of the json
  1274. * @param [in] key
  1275. * the key name
  1276. * @param [in] value
  1277. * the value
  1278. * @return return 0 if success or an error code
  1279. */
  1280. virtual int setInt(const char* key, int value) = 0;
  1281. /**
  1282. * set unsigned int value of the json
  1283. * @param [in] key
  1284. * the key name
  1285. * @param [in] value
  1286. * the value
  1287. * @return return 0 if success or an error code
  1288. */
  1289. virtual int setUInt(const char* key, unsigned int value) = 0;
  1290. /**
  1291. * set double value of the json
  1292. * @param [in] key
  1293. * the key name
  1294. * @param [in] value
  1295. * the value
  1296. * @return return 0 if success or an error code
  1297. */
  1298. virtual int setNumber(const char* key, double value) = 0;
  1299. /**
  1300. * set string value of the json
  1301. * @param [in] key
  1302. * the key name
  1303. * @param [in] value
  1304. * the value
  1305. * @return return 0 if success or an error code
  1306. */
  1307. virtual int setString(const char* key, const char* value) = 0;
  1308. /**
  1309. * set object value of the json
  1310. * @param [in] key
  1311. * the key name
  1312. * @param [in] value
  1313. * the value
  1314. * @return return 0 if success or an error code
  1315. */
  1316. virtual int setObject(const char* key, const char* value) = 0;
  1317. /**
  1318. * get bool value of the json
  1319. * @param [in] key
  1320. * the key name
  1321. * @param [in, out] value
  1322. * the value
  1323. * @return return 0 if success or an error code
  1324. */
  1325. virtual int getBool(const char* key, bool& value) = 0;
  1326. /**
  1327. * get int value of the json
  1328. * @param [in] key
  1329. * the key name
  1330. * @param [in, out] value
  1331. * the value
  1332. * @return return 0 if success or an error code
  1333. */
  1334. virtual int getInt(const char* key, int& value) = 0;
  1335. /**
  1336. * get unsigned int value of the json
  1337. * @param [in] key
  1338. * the key name
  1339. * @param [in, out] value
  1340. * the value
  1341. * @return return 0 if success or an error code
  1342. */
  1343. virtual int getUInt(const char* key, unsigned int& value) = 0;
  1344. /**
  1345. * get double value of the json
  1346. * @param [in] key
  1347. * the key name
  1348. * @param [in, out] value
  1349. * the value
  1350. * @return return 0 if success or an error code
  1351. */
  1352. virtual int getNumber(const char* key, double& value) = 0;
  1353. /**
  1354. * get string value of the json
  1355. * @param [in] key
  1356. * the key name
  1357. * @param [in, out] value
  1358. * the value
  1359. * @return return 0 if success or an error code
  1360. */
  1361. virtual int getString(const char* key, agora::util::AString& value) = 0;
  1362. /**
  1363. * get a child object value of the json
  1364. * @param [in] key
  1365. * the key name
  1366. * @param [in, out] value
  1367. * the value
  1368. * @return return 0 if success or an error code
  1369. */
  1370. virtual int getObject(const char* key, agora::util::AString& value) = 0;
  1371. /**
  1372. * get array value of the json
  1373. * @param [in] key
  1374. * the key name
  1375. * @param [in, out] value
  1376. * the value
  1377. * @return return 0 if success or an error code
  1378. */
  1379. virtual int getArray(const char* key, agora::util::AString& value) = 0;
  1380. /**
  1381. * set parameters of the sdk or engine
  1382. * @param [in] parameters
  1383. * the parameters
  1384. * @return return 0 if success or an error code
  1385. */
  1386. virtual int setParameters(const char* parameters) = 0;
  1387. /**
  1388. * set profile to control the RTC engine
  1389. * @param [in] profile
  1390. * the profile
  1391. * @param [in] merge
  1392. * if merge with the original value
  1393. * @return return 0 if success or an error code
  1394. */
  1395. virtual int setProfile(const char* profile, bool merge) = 0;
  1396. virtual int convertPath(const char* filePath, agora::util::AString& value) = 0;
  1397. };
  1398. class AAudioDeviceManager : public agora::util::AutoPtr<IAudioDeviceManager>
  1399. {
  1400. public:
  1401. AAudioDeviceManager(IRtcEngine& engine)
  1402. {
  1403. queryInterface(engine, AGORA_IID_AUDIO_DEVICE_MANAGER);
  1404. }
  1405. };
  1406. class AVideoDeviceManager : public agora::util::AutoPtr<IVideoDeviceManager>
  1407. {
  1408. public:
  1409. AVideoDeviceManager(IRtcEngine& engine)
  1410. {
  1411. queryInterface(engine, AGORA_IID_VIDEO_DEVICE_MANAGER);
  1412. }
  1413. };
  1414. class AParameter : public agora::util::AutoPtr<IRtcEngineParameter>
  1415. {
  1416. public:
  1417. AParameter(IRtcEngine& engine)
  1418. {
  1419. IRtcEngineParameter* p;
  1420. if (!engine.queryInterface(AGORA_IID_RTC_ENGINE_PARAMETER, (void**)&p))
  1421. reset(p);
  1422. }
  1423. AParameter(IRtcEngineParameter* p)
  1424. :agora::util::AutoPtr<IRtcEngineParameter>(p)
  1425. {}
  1426. };
  1427. class RtcEngineParameters
  1428. {
  1429. public:
  1430. RtcEngineParameters(IRtcEngine& engine)
  1431. :m_parameter(engine){}
  1432. /**
  1433. * mute/unmute the local stream capturing
  1434. * @param [in] mute
  1435. * true: mute
  1436. * false: unmute
  1437. * @return return 0 if success or an error code
  1438. */
  1439. int muteLocalAudioStream(bool mute) {
  1440. return setParameters("{\"rtc.audio.mute_me\":%s,\"che.audio.mute_me\":%s}", mute ? "true" : "false", mute ? "true" : "false");
  1441. }
  1442. // mute/unmute all peers. unmute will clear all muted peers specified mutePeer() interface
  1443. /**
  1444. * mute/unmute all the remote audio stream receiving
  1445. * @param [in] mute
  1446. * true: mute
  1447. * false: unmute
  1448. * @return return 0 if success or an error code
  1449. */
  1450. int muteAllRemoteAudioStreams(bool mute) {
  1451. return m_parameter ? m_parameter->setBool("rtc.audio.mute_peers", mute) : -ERR_NOT_INITIALIZED;
  1452. }
  1453. /**
  1454. * mute/unmute one remote audio stream receiving
  1455. * @param [in] uid
  1456. * the uid of the remote user you want to mute/unmute
  1457. * @param [in] mute
  1458. * true: mute
  1459. * false: unmute
  1460. * @return return 0 if success or an error code
  1461. */
  1462. int muteRemoteAudioStream(uid_t uid, bool mute) {
  1463. return setObject("rtc.audio.mute_peer", "{\"uid\":%u,\"mute\":%s}", uid, mute?"true":"false");
  1464. }
  1465. /**
  1466. * mute/unmute local video stream sending
  1467. * @param [in] mute
  1468. * true: mute
  1469. * false: unmute
  1470. * @return return 0 if success or an error code
  1471. */
  1472. int muteLocalVideoStream(bool mute) {
  1473. return setParameters("{\"rtc.video.mute_me\":%s,\"che.video.local.send\":%s}", mute ? "true" : "false", mute ? "false" : "true");
  1474. }
  1475. int enableLocalVideo(bool enabled) {
  1476. return setParameters("{\"rtc.video.capture\":%s,\"che.video.local.capture\":%s,\"che.video.local.render\":%s,\"che.video.local.send\":%s}", enabled ? "true" : "false", enabled ? "true" : "false", enabled ? "true" : "false", enabled ? "true" : "false");
  1477. }
  1478. /**
  1479. * mute/unmute all the remote video stream receiving
  1480. * @param [in] mute
  1481. * true: mute
  1482. * false: unmute
  1483. * @return return 0 if success or an error code
  1484. */
  1485. int muteAllRemoteVideoStreams(bool mute) {
  1486. return m_parameter ? m_parameter->setBool("rtc.video.mute_peers", mute) : -ERR_NOT_INITIALIZED;
  1487. }
  1488. /**
  1489. * mute/unmute one remote video stream receiving
  1490. * @param [in] uid
  1491. * the uid of the remote user you want to mute/unmute
  1492. * @param [in] mute
  1493. * true: mute
  1494. * false: unmute
  1495. * @return return 0 if success or an error code
  1496. */
  1497. int muteRemoteVideoStream(uid_t uid, bool mute) {
  1498. return setObject("rtc.video.mute_peer", "{\"uid\":%u,\"mute\":%s}", uid, mute ? "true" : "false");
  1499. }
  1500. int setRemoteVideoStreamType(uid_t uid, REMOTE_VIDEO_STREAM_TYPE streamType) {
  1501. return setObject("rtc.video.set_remote_video_stream", "{\"uid\":%u,\"stream\":%d}", uid, streamType);
  1502. }
  1503. /**
  1504. * set play sound volume
  1505. * @param [in] volume
  1506. * the volume 0~255
  1507. * @return return 0 if success or an error code
  1508. */
  1509. int setPlaybackDeviceVolume(int volume) {// [0,255]
  1510. return m_parameter ? m_parameter->setInt("che.audio.output.volume", volume) : -ERR_NOT_INITIALIZED;
  1511. }
  1512. /**
  1513. * enable or disable the audio volume indication
  1514. * @param [in] interval
  1515. * the period of the call back cycle, in ms
  1516. * interval <= 0: disable
  1517. * interval > 0: enable
  1518. * @param [in] smooth
  1519. * the smooth parameter
  1520. * @return return 0 if success or an error code
  1521. */
  1522. int enableAudioVolumeIndication(int interval, int smooth) { // in ms: <= 0: disable, > 0: enable, interval in ms
  1523. if (interval < 0)
  1524. interval = 0;
  1525. return setObject("che.audio.volume_indication", "{\"interval\":%d,\"smooth\":%d}", interval, smooth);
  1526. }
  1527. /**
  1528. * start recording the audio stream
  1529. * @param [in] filePath
  1530. * the .wav file path you want to saved
  1531. * @return return 0 if success or an error code
  1532. */
  1533. int startAudioRecording(const char* filePath) {
  1534. if (!m_parameter) return -ERR_NOT_INITIALIZED;
  1535. #if defined(_WIN32)
  1536. util::AString path;
  1537. if (!m_parameter->convertPath(filePath, path))
  1538. filePath = path->c_str();
  1539. else
  1540. return -ERR_INVALID_ARGUMENT;
  1541. #endif
  1542. return m_parameter->setString("che.audio.start_recording", filePath);
  1543. }
  1544. /**
  1545. * stop recording the audio stream
  1546. * @return return 0 if success or an error code
  1547. */
  1548. int stopAudioRecording() {
  1549. return m_parameter ? m_parameter->setBool("che.audio.stop_recording", true) : -ERR_NOT_INITIALIZED;
  1550. }
  1551. /**
  1552. * mix microphone and local audio file into the audio stream
  1553. * @param [in] filePath
  1554. * specify the path and file name of the audio file to be played
  1555. * @param [in] loopback
  1556. * specify if local and remote participant can hear the audio file.
  1557. * false (default): both local and remote party can hear the the audio file
  1558. * true: only the local party can hear the audio file
  1559. * @param [in] replace
  1560. * false (default): mix the local microphone captured voice with the audio file
  1561. * true: replace the microphone captured voice with the audio file
  1562. * @param [in] cycle
  1563. * specify the number of cycles to play
  1564. * -1, infinite loop playback
  1565. * @return return 0 if success or an error code
  1566. */
  1567. int startAudioMixing(const char* filePath, bool loopback, bool replace, int cycle) {
  1568. if (!m_parameter) return -ERR_NOT_INITIALIZED;
  1569. #if defined(_WIN32)
  1570. util::AString path;
  1571. if (!m_parameter->convertPath(filePath, path))
  1572. filePath = path->c_str();
  1573. else
  1574. return -ERR_INVALID_ARGUMENT;
  1575. #endif
  1576. return setObject("che.audio.start_file_as_playout", "{\"filePath\":\"%s\",\"loopback\":%s,\"replace\":%s,\"cycle\":%d}",
  1577. filePath,
  1578. loopback?"true":"false",
  1579. replace?"true":"false",
  1580. cycle);
  1581. }
  1582. /**
  1583. * stop mixing the local audio stream
  1584. * @return return 0 if success or an error code
  1585. */
  1586. int stopAudioMixing() {
  1587. return m_parameter ? m_parameter->setBool("che.audio.stop_file_as_playout", true) : -ERR_NOT_INITIALIZED;
  1588. }
  1589. int pauseAudioMixing() {
  1590. return m_parameter ? m_parameter->setBool("che.audio.pause_file_as_playout", true) : -ERR_NOT_INITIALIZED;
  1591. }
  1592. int resumeAudioMixing() {
  1593. return m_parameter ? m_parameter->setBool("che.audio.pause_file_as_playout", false) : -ERR_NOT_INITIALIZED;
  1594. }
  1595. int adjustAudioMixingVolume(int volume) {
  1596. return m_parameter ? m_parameter->setInt("che.audio.set_file_as_playout_volume", volume) : -ERR_NOT_INITIALIZED;
  1597. }
  1598. int getAudioMixingDuration() {
  1599. int duration = 0;
  1600. int r = m_parameter ? m_parameter->getInt("che.audio.get_mixing_file_length_ms", duration) : -ERR_NOT_INITIALIZED;
  1601. if (r == 0)
  1602. r = duration;
  1603. return r;
  1604. }
  1605. int getAudioMixingCurrentPosition() {
  1606. if (!m_parameter) return -ERR_NOT_INITIALIZED;
  1607. int pos = 0;
  1608. int r = m_parameter->getInt("che.audio.get_mixing_file_played_ms", pos);
  1609. if (r == 0)
  1610. r = pos;
  1611. return r;
  1612. }
  1613. int setAudioMixingPosition(int pos /*in ms*/) {
  1614. return m_parameter ? m_parameter->setInt("che.audio.mixing.file.position", pos) : -ERR_NOT_INITIALIZED;
  1615. }
  1616. #if defined(__APPLE__)
  1617. /**
  1618. * start screen capture
  1619. * @return return 0 if success or an error code
  1620. */
  1621. int startScreenCapture(unsigned int windowId) {
  1622. return m_parameter ? m_parameter->setUInt("che.video.start_screen_capture", windowId) : -ERR_NOT_INITIALIZED;
  1623. }
  1624. /**
  1625. * specify window id to capture
  1626. * @return return 0 if success or an error code
  1627. */
  1628. int setScreenCaptureWindow(unsigned int windowId) {
  1629. return m_parameter ? m_parameter->setUInt("che.video.set_screen_capture_window", windowId) : -ERR_NOT_INITIALIZED;
  1630. }
  1631. /**
  1632. * stop screen capture
  1633. * @return return 0 if success or an error code
  1634. */
  1635. int stopScreenCapture() {
  1636. return m_parameter ? m_parameter->setBool("che.video.stop_screen_capture", true) : -ERR_NOT_INITIALIZED;
  1637. }
  1638. #elif defined(_WIN32)
  1639. /**
  1640. * start screen capture
  1641. * @return return 0 if success or an error code
  1642. */
  1643. int startScreenCapture(HWND windowId) {
  1644. return m_parameter ? m_parameter->setUInt("che.video.start_screen_capture", (unsigned int)windowId) : -ERR_NOT_INITIALIZED;
  1645. }
  1646. /**
  1647. * specify window id to capture
  1648. * @return return 0 if success or an error code
  1649. */
  1650. int setScreenCaptureWindow(HWND windowId) {
  1651. return m_parameter ? m_parameter->setUInt("che.video.set_screen_capture_window", (unsigned int)windowId) : -ERR_NOT_INITIALIZED;
  1652. }
  1653. /**
  1654. * stop screen capture
  1655. * @return return 0 if success or an error code
  1656. */
  1657. int stopScreenCapture() {
  1658. return m_parameter ? m_parameter->setBool("che.video.stop_screen_capture", true) : -ERR_NOT_INITIALIZED;
  1659. }
  1660. #endif
  1661. /**
  1662. * set path to save the log file
  1663. * @param [in] filePath
  1664. * the .log file path you want to saved
  1665. * @return return 0 if success or an error code
  1666. */
  1667. int setLogFile(const char* filePath) {
  1668. if (!m_parameter) return -ERR_NOT_INITIALIZED;
  1669. #if defined(_WIN32)
  1670. util::AString path;
  1671. if (!m_parameter->convertPath(filePath, path))
  1672. filePath = path->c_str();
  1673. else if (!filePath)
  1674. filePath = "";
  1675. #endif
  1676. return m_parameter->setString("rtc.log_file", filePath);
  1677. }
  1678. /**
  1679. * set the log information filter level
  1680. * @param [in] filter
  1681. * the filter level
  1682. * @return return 0 if success or an error code
  1683. */
  1684. int setLogFilter(unsigned int filter) {
  1685. return m_parameter ? m_parameter->setUInt("rtc.log_filter", filter&LOG_FILTER_MASK) : -ERR_NOT_INITIALIZED;
  1686. }
  1687. /**
  1688. * set local video render mode
  1689. * @param [in] renderMode
  1690. * the render mode
  1691. * @return return 0 if success or an error code
  1692. */
  1693. int setLocalRenderMode(RENDER_MODE_TYPE renderMode) {
  1694. return setRemoteRenderMode(0, renderMode);
  1695. }
  1696. /**
  1697. * set remote video render mode
  1698. * @param [in] renderMode
  1699. * the render mode
  1700. * @return return 0 if success or an error code
  1701. */
  1702. int setRemoteRenderMode(uid_t uid, RENDER_MODE_TYPE renderMode) {
  1703. return setObject("che.video.render_mode", "{\"uid\":%u,\"mode\":%d}", uid, renderMode);
  1704. }
  1705. int startRecordingService(const char* recordingKey) {
  1706. return m_parameter ? m_parameter->setString("rtc.api.start_recording_service", recordingKey) : -ERR_NOT_INITIALIZED;
  1707. }
  1708. int stopRecordingService(const char* recordingKey) {
  1709. return m_parameter ? m_parameter->setString("rtc.api.stop_recording_service", recordingKey) : -ERR_NOT_INITIALIZED;
  1710. }
  1711. int refreshRecordingServiceStatus() {
  1712. return m_parameter ? m_parameter->setBool("rtc.api.query_recording_service_status", true) : -ERR_NOT_INITIALIZED;
  1713. }
  1714. int enableDualStreamMode(bool enabled) {
  1715. return setParameters("{\"rtc.dual_stream_mode\":%s,\"che.video.enableLowBitRateStream\":%s}", enabled ? "true" : "false", enabled ? "true" : "false");
  1716. }
  1717. int setRecordingAudioFrameParameters(int sampleRate, int channel, RAW_AUDIO_FRAME_OP_MODE_TYPE mode, int samplesPerCall) {
  1718. return setObject("che.audio.set_capture_raw_audio_format", "{\"sampleRate\":%d,\"channelCnt\":%d,\"mode\":%d,\"samplesPerCall\":%d}", sampleRate, channel, mode, samplesPerCall);
  1719. }
  1720. int setPlaybackAudioFrameParameters(int sampleRate, int channel, RAW_AUDIO_FRAME_OP_MODE_TYPE mode, int samplesPerCall) {
  1721. return setObject("che.audio.set_render_raw_audio_format", "{\"sampleRate\":%d,\"channelCnt\":%d,\"mode\":%d,\"samplesPerCall\":%d}", sampleRate, channel, mode, samplesPerCall);
  1722. }
  1723. int setMixedAudioFrameParameters(int sampleRate, int samplesPerCall) {
  1724. return setObject("che.audio.set_mixed_raw_audio_format", "{\"sampleRate\":%d,\"samplesPerCall\":%d}", sampleRate, samplesPerCall);
  1725. }
  1726. int adjustRecordingSignalVolume(int volume) {//[0, 400]: e.g. 50~0.5x 100~1x 400~4x
  1727. if (volume < 0)
  1728. volume = 0;
  1729. else if (volume > 400)
  1730. volume = 400;
  1731. return m_parameter ? m_parameter->setInt("che.audio.record.signal.volume", volume) : -ERR_NOT_INITIALIZED;
  1732. }
  1733. int adjustPlaybackSignalVolume(int volume) {//[0, 400]
  1734. if (volume < 0)
  1735. volume = 0;
  1736. else if (volume > 400)
  1737. volume = 400;
  1738. return m_parameter ? m_parameter->setInt("che.audio.playout.signal.volume", volume) : -ERR_NOT_INITIALIZED;
  1739. }
  1740. int setHighQualityAudioParameters(bool fullband, bool stereo, bool fullBitrate) {
  1741. return setObject("che.audio.codec.hq", "{\"fullband\":%s,\"stereo\":%s,\"fullBitrate\":%s}", fullband ? "true" : "false", stereo ? "true" : "false", fullBitrate ? "true" : "false");
  1742. }
  1743. int enableWebSdkInteroperability(bool enabled) {//enable interoperability with zero-plugin web sdk
  1744. return setParameters("{\"rtc.video.web_h264_interop_enable\":%s,\"che.video.web_h264_interop_enable\":%s}", enabled ? "true" : "false", enabled ? "true" : "false");
  1745. }
  1746. //only for live broadcasting
  1747. int setVideoQualityParameters(bool preferFrameRateOverImageQuality) {
  1748. return m_parameter ? m_parameter->setBool("rtc.video.prefer_frame_rate", preferFrameRateOverImageQuality) : -ERR_NOT_INITIALIZED;
  1749. }
  1750. protected:
  1751. AParameter& parameter() {
  1752. return m_parameter;
  1753. }
  1754. int setParameters(const char* format, ...) {
  1755. char buf[512];
  1756. va_list args;
  1757. va_start(args, format);
  1758. vsnprintf(buf, sizeof(buf)-1, format, args);
  1759. va_end(args);
  1760. return m_parameter ? m_parameter->setParameters(buf) : -ERR_NOT_INITIALIZED;
  1761. }
  1762. int setObject(const char* key, const char* format, ...) {
  1763. char buf[512];
  1764. va_list args;
  1765. va_start(args, format);
  1766. vsnprintf(buf, sizeof(buf)-1, format, args);
  1767. va_end(args);
  1768. return m_parameter ? m_parameter->setObject(key, buf) : -ERR_NOT_INITIALIZED;
  1769. }
  1770. int enableLocalVideoCapture(bool enabled) {
  1771. return m_parameter ? m_parameter->setBool("che.video.local.capture", enabled) : -ERR_NOT_INITIALIZED;
  1772. }
  1773. int enableLocalVideoRender(bool enabled) {
  1774. return m_parameter ? m_parameter->setBool("che.video.local.render", enabled) : -ERR_NOT_INITIALIZED;
  1775. }
  1776. int enableLocalVideoSend(bool enabled) {
  1777. return muteLocalVideoStream(!enabled);
  1778. }
  1779. int stopAllRemoteVideo() {
  1780. return m_parameter ? m_parameter->setBool("che.video.peer.stop_render", true) : -ERR_NOT_INITIALIZED;
  1781. }
  1782. private:
  1783. AParameter m_parameter;
  1784. };
  1785. } //namespace rtc
  1786. } // namespace agora
  1787. /**
  1788. * to get the version number of the SDK
  1789. * @param [in, out] build
  1790. * the build number of Agora SDK
  1791. * @return returns the string of the version of the SDK
  1792. */
  1793. AGORA_API const char* AGORA_CALL getAgoraRtcEngineVersion(int* build);
  1794. /**
  1795. * create the RTC engine object and return the pointer
  1796. * @return returns the pointer of the RTC engine object
  1797. */
  1798. AGORA_API agora::rtc::IRtcEngine* AGORA_CALL createAgoraRtcEngine();
  1799. /**
  1800. * create the RTC engine object and return the pointer
  1801. * @param [in] err
  1802. * the error code
  1803. * @return returns the description of the error code
  1804. */
  1805. AGORA_API const char* AGORA_CALL getAgoraRtcEngineErrorDescription(int err);
  1806. AGORA_API int AGORA_CALL setAgoraRtcEngineExternalSymbolLoader(void* (*func)(const char* symname));
  1807. #endif