IoT SDK for Linux v1.8.0
agora_rtc_api.h
Go to the documentation of this file.
1/*************************************************************
2 *
3 * This is a part of the Agora RTC Service SDK.
4 * Copyright (C) 2020 Agora IO
5 * All rights reserved.
6 *
7 *************************************************************/
8
9#ifndef __AGORA_RTC_API_H__
10#define __AGORA_RTC_API_H__
11
12#include <stdint.h>
13#include <stddef.h>
14#include <stdbool.h>
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif
20
21#if defined(_MSC_VER)
22#if defined(__BUILDING_AGORA_SDK__)
23#define __agora_api__ __declspec(dllexport)
24#else
25#define __agora_api__ __declspec(dllimport)
26#endif
27#else
28#define __agora_api__
29#endif
30
31#define AGORA_RTC_CHANNEL_NAME_MAX_LEN (64)
32#define AGORA_RTC_USER_ID_MAX_LEN (255)
33#define AGORA_RTC_PRODUCT_ID_MAX_LEN (63)
34#define AGORA_RTM_UID_MAX_LEN 64
35#define AGORA_RTM_DATA_MAX_LEN (32 * 1024)
36#define AGORA_CREDENTIAL_MAX_LEN 256
37#define AGORA_CERTIFICATE_MAX_LEN 1024
38#define AGORA_LICENSE_VALUE_LEN 32
39
41 typedef enum
42 {
47
52
57
63
68
73
78
83
88
93
98
103
108
113
118
123
128
133
138
144
148 typedef enum
149 {
159
163 typedef enum
164 {
186
190 typedef enum
191 {
205
209 typedef enum
210 {
226
230 typedef enum
231 {
241
245 typedef struct
246 {
264
268 typedef enum
269 {
291
295 typedef enum
296 {
334
338 typedef struct
339 {
345
349 typedef enum
350 {
354 RTC_LOG_DEFAULT = 0, // the same as RTC_LOG_NOTICE
362 RTC_LOG_ALERT, // action must be taken immediately
366 RTC_LOG_CRIT, // critical conditions
370 RTC_LOG_ERROR, // error conditions
374 RTC_LOG_WARNING, // warning conditions
378 RTC_LOG_NOTICE, // normal but significant condition, default level
382 RTC_LOG_INFO, // informational
386 RTC_LOG_DEBUG, // debug-level messages
388
392 typedef enum
393 {
397 AREA_CODE_DEFAULT = 0x00000000,
399 AREA_CODE_CN = 0x00000001,
401 AREA_CODE_NA = 0x00000002,
403 AREA_CODE_EU = 0x00000004,
405 AREA_CODE_AS = 0x00000008,
407 AREA_CODE_JP = 0x00000010,
409 AREA_CODE_IN = 0x00000020,
411 AREA_CODE_OC = 0x00000040,
413 AREA_CODE_SA = 0x00000080,
415 AREA_CODE_AF = 0x00000100,
417 AREA_CODE_KR = 0x00000200,
419 AREA_CODE_OVS = 0xFFFFFFFE,
421 AREA_CODE_GLOB = (0xFFFFFFFF),
422 } area_code_e;
423
427 typedef struct
428 {
448 const char *log_path;
449 } log_config_t;
450
454 typedef struct
455 {
460 uint32_t area_code;
464 char product_id[AGORA_RTC_PRODUCT_ID_MAX_LEN + 1];
473 char license_value[AGORA_LICENSE_VALUE_LEN + 1];
475
479 typedef struct
480 {
499
503 typedef struct
504 {
546
550 typedef enum
551 {
569
573 typedef enum
574 {
588
592 typedef uint32_t connection_id_t;
593
597#define CONNECTION_ID_ALL ((connection_id_t)0)
601#define CONNECTION_ID_INVALID ((connection_id_t)-1)
602
606 typedef struct
607 {
608 // Connection ID.
610 // User ID.
611 uint32_t uid;
612 // RTC channel name.
613 char channel_name[AGORA_RTC_CHANNEL_NAME_MAX_LEN + 1];
615
619 typedef struct
620 {
628 void (*on_join_channel_success)(connection_id_t conn_id, uint32_t uid, int elapsed_ms);
629
635 void (*on_connection_lost)(connection_id_t conn_id);
636
646 void (*on_rejoin_channel_success)(connection_id_t conn_id, uint32_t uid, int elapsed_ms);
647
657 void (*on_error)(connection_id_t conn_id, int code, const char *msg);
658
666 void (*on_user_joined)(connection_id_t conn_id, uint32_t uid, int elapsed_ms);
667
675 void (*on_user_offline)(connection_id_t conn_id, uint32_t uid, int reason);
676
686 void (*on_user_mute_audio)(connection_id_t conn_id, uint32_t uid, bool muted);
687
688#ifndef CONFIG_AUDIO_ONLY
698 void (*on_user_mute_video)(connection_id_t conn_id, uint32_t uid, bool muted);
699
700#endif
711 void (*on_audio_data)(connection_id_t conn_id, uint32_t uid, uint16_t sent_ts, const void *data_ptr, size_t data_len,
712 const audio_frame_info_t *info_ptr);
713
722 void (*on_mixed_audio_data)(connection_id_t conn_id, const void *data_ptr, size_t data_len,
723 const audio_frame_info_t *info_ptr);
724
725#ifndef CONFIG_AUDIO_ONLY
736 void (*on_video_data)(connection_id_t conn_id, uint32_t uid, uint16_t sent_ts, const void *data_ptr, size_t data_len,
737 const video_frame_info_t *info_ptr);
738
745 void (*on_target_bitrate_changed)(connection_id_t conn_id, uint32_t target_bps);
746
756 void (*on_key_frame_gen_req)(connection_id_t conn_id, uint32_t uid, video_stream_type_e stream_type);
757
758#endif
759
760#ifdef CONFIG_RTC_STRING_UID
767 void (*on_local_user_registered)(const char *uname, uint32_t uid);
768
775 void (*on_remote_user_registered)(const char *uname, uint32_t uid);
776#endif // End of CONFIG_RTC_STRING_UID
777
787 void (*on_token_privilege_will_expire)(connection_id_t conn_id, const char *token);
788
789#ifdef CONFIG_RTCM
798 void (*on_media_ctrl_receive)(connection_id_t conn_id, uint32_t uid, const void *payload, size_t length);
799#endif
801
806 extern const char *agora_rtc_get_version(void);
807
814 extern __agora_api__ const char *agora_rtc_err_2_str(int err);
815
816#ifdef CONFIG_LICENSE
817
818 extern __agora_api__ int agora_rtc_license_gen_credential(char *credential, unsigned int *credential_len);
819
820 extern __agora_api__ int agora_rtc_license_verify(const char *certificate, int certificate_len, const char *credential,
821 int credential_len);
822
823#endif // End CONFIG_LICENSE
837 extern __agora_api__ int agora_rtc_init(const char *app_id, const agora_rtc_event_handler_t *event_handler,
838 rtc_service_option_t *option);
846
855
864 extern __agora_api__ int agora_rtc_config_log(int size_per_file, int max_file_count);
865
874
883
893
915 extern __agora_api__ int agora_rtc_join_channel(connection_id_t conn_id, const char *channel_name, uint32_t uid,
916 const char *token, rtc_channel_options_t *options);
917
927
937 extern __agora_api__ int agora_rtc_renew_token(connection_id_t conn_id, const char *token);
938
948
961
962#ifndef CONFIG_AUDIO_ONLY
975#endif
988 extern __agora_api__ int agora_rtc_mute_remote_audio(connection_id_t conn_id, uint32_t remote_uid, bool mute);
989
990#ifndef CONFIG_AUDIO_ONLY
1003 extern __agora_api__ int agora_rtc_mute_remote_video(connection_id_t conn_id, uint32_t remote_uid, bool mute);
1004
1015 extern __agora_api__ int agora_rtc_request_video_key_frame(connection_id_t conn_id, uint32_t remote_uid,
1016 video_stream_type_e stream_type);
1017#endif
1029 extern __agora_api__ int agora_rtc_send_audio_data(connection_id_t conn_id, const void *data_ptr, size_t data_len,
1030 audio_frame_info_t *info_ptr);
1031
1032#ifndef CONFIG_AUDIO_ONLY
1044 extern __agora_api__ int agora_rtc_send_video_data(connection_id_t conn_id, const void *data_ptr, size_t data_len,
1045 video_frame_info_t *info_ptr);
1058 extern __agora_api__ int agora_rtc_set_bwe_param(connection_id_t conn_id, uint32_t min_bps, uint32_t max_bps,
1059 uint32_t start_bps);
1060
1061#endif // End CONFIG_AUDIO_ONLY
1062
1063#ifdef CONFIG_RTC_PROXY
1072#endif // End CONFIG_RTC_PROXY
1073
1085 extern __agora_api__ int agora_rtc_set_params(const char *params);
1086
1087#ifdef CONFIG_RTCM
1107 extern __agora_api__ int agora_rtc_send_media_ctrl_msg(connection_id_t conn_id, uint32_t remote_uid,
1108 const void *payload, size_t length);
1109#endif // End of CONFIG_RTCM
1110
1111#ifdef CONFIG_RTM
1117 typedef enum
1118 {
1132
1133 typedef enum
1134 {
1156
1160 typedef struct
1161 {
1169 void (*on_rtm_data)(const char *rtm_uid, const void *msg, size_t msg_len);
1177 void (*on_rtm_event)(const char *rtm_uid, rtm_event_type_e event_type, rtm_err_code_e err_code);
1185 void (*on_send_rtm_data_result)(uint32_t msg_id, rtm_err_code_e error_code);
1187
1208 extern __agora_api__ int agora_rtc_login_rtm(const char *rtm_uid, const char *rtm_token,
1209 const agora_rtm_handler_t *handler);
1210
1219
1234 extern __agora_api__ int agora_rtc_send_rtm_data(const char *rtm_uid, uint32_t msg_id, const void *msg, size_t msg_len);
1235#endif // End CONFIG_RTM
1236
1237#ifdef __cplusplus
1238}
1239#endif
1240
1241#endif /* __AGORA_RTC_API_H__ */
__agora_api__ int agora_rtc_send_video_data(connection_id_t conn_id, const void *data_ptr, size_t data_len, video_frame_info_t *info_ptr)
__agora_api__ int agora_rtc_fini(void)
__agora_api__ int agora_rtc_send_audio_data(connection_id_t conn_id, const void *data_ptr, size_t data_len, audio_frame_info_t *info_ptr)
cloud_proxy_type_e
Definition: agora_rtc_api.h:551
@ CLOUD_PROXY_AUTO
Definition: agora_rtc_api.h:567
@ CLOUD_PROXY_NONE
Definition: agora_rtc_api.h:555
@ CLOUD_PROXY_TCP
Definition: agora_rtc_api.h:563
@ CLOUD_PROXY_UDP
Definition: agora_rtc_api.h:559
area_code_e
Definition: agora_rtc_api.h:393
@ AREA_CODE_JP
Definition: agora_rtc_api.h:407
@ AREA_CODE_GLOB
Definition: agora_rtc_api.h:421
@ AREA_CODE_EU
Definition: agora_rtc_api.h:403
@ AREA_CODE_CN
Definition: agora_rtc_api.h:399
@ AREA_CODE_KR
Definition: agora_rtc_api.h:417
@ AREA_CODE_IN
Definition: agora_rtc_api.h:409
@ AREA_CODE_AS
Definition: agora_rtc_api.h:405
@ AREA_CODE_SA
Definition: agora_rtc_api.h:413
@ AREA_CODE_OVS
Definition: agora_rtc_api.h:419
@ AREA_CODE_OC
Definition: agora_rtc_api.h:411
@ AREA_CODE_NA
Definition: agora_rtc_api.h:401
@ AREA_CODE_AF
Definition: agora_rtc_api.h:415
@ AREA_CODE_DEFAULT
Definition: agora_rtc_api.h:397
video_data_type_e
Definition: agora_rtc_api.h:164
@ VIDEO_DATA_TYPE_YUV420
Definition: agora_rtc_api.h:168
@ VIDEO_DATA_TYPE_H264
Definition: agora_rtc_api.h:172
@ VIDEO_DATA_TYPE_H265
Definition: agora_rtc_api.h:176
@ VIDEO_DATA_TYPE_GENERIC_JPEG
Definition: agora_rtc_api.h:184
@ VIDEO_DATA_TYPE_GENERIC
Definition: agora_rtc_api.h:180
__agora_api__ int agora_rtc_mute_local_audio(connection_id_t conn_id, bool mute)
audio_codec_type_e
Definition: agora_rtc_api.h:269
@ AUDIO_CODEC_TYPE_G722
Definition: agora_rtc_api.h:281
@ AUDIO_CODEC_TYPE_OPUS
Definition: agora_rtc_api.h:277
@ AUDIO_CODEC_TYPE_G711U
Definition: agora_rtc_api.h:289
@ AUDIO_CODEC_DISABLED
Definition: agora_rtc_api.h:273
@ AUDIO_CODEC_TYPE_G711A
Definition: agora_rtc_api.h:285
#define AGORA_RTC_PRODUCT_ID_MAX_LEN
Definition: agora_rtc_api.h:33
__agora_api__ int agora_rtc_config_log(int size_per_file, int max_file_count)
network_event_type_e
Definition: agora_rtc_api.h:574
@ NETWORK_EVENT_DOWN
Definition: agora_rtc_api.h:578
@ NETWORK_EVENT_UP
Definition: agora_rtc_api.h:582
@ NETWORK_EVENT_CHANGE
Definition: agora_rtc_api.h:586
__agora_api__ int agora_rtc_mute_local_video(connection_id_t conn_id, bool mute)
__agora_api__ const char * agora_rtc_err_2_str(int err)
__agora_api__ int agora_rtc_set_cloud_proxy(cloud_proxy_type_e type)
__agora_api__ int agora_rtc_login_rtm(const char *rtm_uid, const char *rtm_token, const agora_rtm_handler_t *handler)
audio_data_type_e
Definition: agora_rtc_api.h:296
@ AUDIO_DATA_TYPE_OPUS
Definition: agora_rtc_api.h:300
@ AUDIO_DATA_TYPE_PCMA
Definition: agora_rtc_api.h:308
@ AUDIO_DATA_TYPE_GENERIC
Definition: agora_rtc_api.h:332
@ AUDIO_DATA_TYPE_PCM
Definition: agora_rtc_api.h:328
@ AUDIO_DATA_TYPE_HEAAC
Definition: agora_rtc_api.h:324
@ AUDIO_DATA_TYPE_G722
Definition: agora_rtc_api.h:316
@ AUDIO_DATA_TYPE_PCMU
Definition: agora_rtc_api.h:312
@ AUDIO_DATA_TYPE_AACLC
Definition: agora_rtc_api.h:320
@ AUDIO_DATA_TYPE_OPUSFB
Definition: agora_rtc_api.h:304
video_frame_type_e
Definition: agora_rtc_api.h:191
@ VIDEO_FRAME_KEY
Definition: agora_rtc_api.h:199
@ VIDEO_FRAME_AUTO_DETECT
Definition: agora_rtc_api.h:195
@ VIDEO_FRAME_DELTA
Definition: agora_rtc_api.h:203
video_stream_type_e
Definition: agora_rtc_api.h:231
@ VIDEO_STREAM_HIGH
Definition: agora_rtc_api.h:235
@ VIDEO_STREAM_LOW
Definition: agora_rtc_api.h:239
__agora_api__ int agora_rtc_set_log_level(rtc_log_level_e level)
rtm_err_code_e
Definition: agora_rtc_api.h:1134
@ ERR_RTM_INVALID_RTM_UID
Definition: agora_rtc_api.h:1142
@ ERR_RTM_TOKEN_EXPIRED
Definition: agora_rtc_api.h:1152
@ ERR_RTM_LOGIN_INVALID_TOKEN
Definition: agora_rtc_api.h:1144
@ ERR_RTM_INVALID_APP_ID
Definition: agora_rtc_api.h:1148
@ ERR_RTM_INVALID_TOKEN
Definition: agora_rtc_api.h:1154
@ ERR_RTM_LOGIN_REJECTED
Definition: agora_rtc_api.h:1140
@ ERR_RTM_FAILED
Definition: agora_rtc_api.h:1138
@ WARN_RTM_LOOKUP_CHANNEL_REJECTED
Definition: agora_rtc_api.h:1150
@ ERR_RTM_LOGIN_NOT_AUTHORIZED
Definition: agora_rtc_api.h:1146
@ ERR_RTM_OK
Definition: agora_rtc_api.h:1136
#define AGORA_LICENSE_VALUE_LEN
Definition: agora_rtc_api.h:38
__agora_api__ int agora_rtc_join_channel(connection_id_t conn_id, const char *channel_name, uint32_t uid, const char *token, rtc_channel_options_t *options)
__agora_api__ int agora_rtc_send_rtm_data(const char *rtm_uid, uint32_t msg_id, const void *msg, size_t msg_len)
__agora_api__ int agora_rtc_license_gen_credential(char *credential, unsigned int *credential_len)
__agora_api__ int agora_rtc_request_video_key_frame(connection_id_t conn_id, uint32_t remote_uid, video_stream_type_e stream_type)
__agora_api__ int agora_rtc_renew_token(connection_id_t conn_id, const char *token)
__agora_api__ int agora_rtc_mute_remote_video(connection_id_t conn_id, uint32_t remote_uid, bool mute)
#define AGORA_RTC_CHANNEL_NAME_MAX_LEN
Definition: agora_rtc_api.h:31
__agora_api__ int agora_rtc_mute_remote_audio(connection_id_t conn_id, uint32_t remote_uid, bool mute)
__agora_api__ int agora_rtc_license_verify(const char *certificate, int certificate_len, const char *credential, int credential_len)
__agora_api__ int agora_rtc_leave_channel(connection_id_t conn_id)
__agora_api__ int agora_rtc_notify_network_event(network_event_type_e event)
__agora_api__ int agora_rtc_get_connection_info(connection_id_t conn_id, connection_info_t *conn_info)
user_offline_reason_e
Definition: agora_rtc_api.h:149
@ USER_OFFLINE_DROPPED
Definition: agora_rtc_api.h:157
@ USER_OFFLINE_QUIT
Definition: agora_rtc_api.h:153
rtm_event_type_e
Definition: agora_rtc_api.h:1118
@ RTM_EVENT_TYPE_KICKOFF
Definition: agora_rtc_api.h:1126
@ RTM_EVENT_TYPE_EXIT
Definition: agora_rtc_api.h:1130
@ RTM_EVENT_TYPE_LOGIN
Definition: agora_rtc_api.h:1122
__agora_api__ int agora_rtc_logout_rtm(void)
rtc_log_level_e
Definition: agora_rtc_api.h:350
@ RTC_LOG_DEFAULT
Definition: agora_rtc_api.h:354
@ RTC_LOG_ALERT
Definition: agora_rtc_api.h:362
@ RTC_LOG_WARNING
Definition: agora_rtc_api.h:374
@ RTC_LOG_EMERG
Definition: agora_rtc_api.h:358
@ RTC_LOG_DEBUG
Definition: agora_rtc_api.h:386
@ RTC_LOG_ERROR
Definition: agora_rtc_api.h:370
@ RTC_LOG_INFO
Definition: agora_rtc_api.h:382
@ RTC_LOG_NOTICE
Definition: agora_rtc_api.h:378
@ RTC_LOG_CRIT
Definition: agora_rtc_api.h:366
__agora_api__ int agora_rtc_destroy_connection(connection_id_t conn_id)
const char * agora_rtc_get_version(void)
#define __agora_api__
Definition: agora_rtc_api.h:28
uint32_t connection_id_t
Definition: agora_rtc_api.h:592
__agora_api__ int agora_rtc_create_connection(connection_id_t *conn_id)
__agora_api__ int agora_rtc_set_params(const char *params)
__agora_api__ int agora_rtc_set_bwe_param(connection_id_t conn_id, uint32_t min_bps, uint32_t max_bps, uint32_t start_bps)
video_frame_rate_e
Definition: agora_rtc_api.h:210
@ VIDEO_FRAME_RATE_FPS_24
Definition: agora_rtc_api.h:220
@ VIDEO_FRAME_RATE_FPS_10
Definition: agora_rtc_api.h:216
@ VIDEO_FRAME_RATE_FPS_15
Definition: agora_rtc_api.h:218
@ VIDEO_FRAME_RATE_FPS_7
Definition: agora_rtc_api.h:214
@ VIDEO_FRAME_RATE_FPS_30
Definition: agora_rtc_api.h:222
@ VIDEO_FRAME_RATE_FPS_60
Definition: agora_rtc_api.h:224
@ VIDEO_FRAME_RATE_FPS_1
Definition: agora_rtc_api.h:212
agora_err_code_e
Definition: agora_rtc_api.h:42
@ ERR_SEND_VIDEO_OVER_BANDWIDTH_LIMIT
Definition: agora_rtc_api.h:132
@ ERR_OPEN_CHANNEL_TRY_NEXT_VOS
Definition: agora_rtc_api.h:122
@ ERR_INVALID_TOKEN
Definition: agora_rtc_api.h:97
@ ERR_INVALID_APP_ID
Definition: agora_rtc_api.h:67
@ ERR_JOIN_CHANNEL_REJECTED
Definition: agora_rtc_api.h:62
@ ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED
Definition: agora_rtc_api.h:107
@ ERR_FAILED
Definition: agora_rtc_api.h:51
@ ERR_DECRYPTION_FAILED
Definition: agora_rtc_api.h:112
@ ERR_TOKEN_EXPIRED
Definition: agora_rtc_api.h:92
@ ERR_OPEN_CHANNEL_REJECTED
Definition: agora_rtc_api.h:87
@ ERR_AUDIO_DECODER_NOT_MATCH_AUDIO_FRAME
Definition: agora_rtc_api.h:137
@ ERR_OKAY
Definition: agora_rtc_api.h:46
@ ERR_OPEN_CHANNEL_INVALID_TICKET
Definition: agora_rtc_api.h:117
@ ERR_INVALID_CHANNEL_NAME
Definition: agora_rtc_api.h:72
@ ERR_NO_SERVER_RESOURCES
Definition: agora_rtc_api.h:77
@ ERR_DYNAMIC_TOKEN_BUT_USE_STATIC_KEY
Definition: agora_rtc_api.h:102
@ ERR_LOOKUP_CHANNEL_REJECTED
Definition: agora_rtc_api.h:82
@ ERR_NET_DOWN
Definition: agora_rtc_api.h:56
@ ERR_NO_AUDIO_DECODER_TO_HANDLE_AUDIO_FRAME
Definition: agora_rtc_api.h:142
@ ERR_CLIENT_IS_BANNED_BY_SERVER
Definition: agora_rtc_api.h:127
Definition: agora_rtc_api.h:620
Definition: agora_rtc_api.h:1161
Definition: agora_rtc_api.h:480
int pcm_channel_num
Definition: agora_rtc_api.h:497
int pcm_sample_rate
Definition: agora_rtc_api.h:491
audio_codec_type_e audio_codec_type
Definition: agora_rtc_api.h:484
Definition: agora_rtc_api.h:339
audio_data_type_e data_type
Definition: agora_rtc_api.h:343
Definition: agora_rtc_api.h:607
connection_id_t conn_id
Definition: agora_rtc_api.h:609
uint32_t uid
Definition: agora_rtc_api.h:611
Definition: agora_rtc_api.h:428
bool log_disable_desensitize
Definition: agora_rtc_api.h:440
const char * log_path
Definition: agora_rtc_api.h:448
bool log_disable
Definition: agora_rtc_api.h:434
rtc_log_level_e log_level
Definition: agora_rtc_api.h:444
Definition: agora_rtc_api.h:504
bool auto_subscribe_video
Definition: agora_rtc_api.h:516
bool auto_subscribe_audio
Definition: agora_rtc_api.h:510
audio_codec_option_t audio_codec_opt
Definition: agora_rtc_api.h:538
bool enable_audio_mixer
Definition: agora_rtc_api.h:534
bool enable_aut_encryption
Definition: agora_rtc_api.h:544
bool enable_audio_jitter_buffer
Definition: agora_rtc_api.h:528
bool subscribe_local_user
Definition: agora_rtc_api.h:522
Definition: agora_rtc_api.h:455
uint32_t area_code
Definition: agora_rtc_api.h:460
log_config_t log_cfg
Definition: agora_rtc_api.h:468
Definition: agora_rtc_api.h:246
video_frame_type_e frame_type
Definition: agora_rtc_api.h:258
video_frame_rate_e frame_rate
Definition: agora_rtc_api.h:262
video_stream_type_e stream_type
Definition: agora_rtc_api.h:254
video_data_type_e data_type
Definition: agora_rtc_api.h:250