### 编译 RTSA SDK 示例项目 (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/get-started/run-example 此命令用于编译 RTSA SDK 包中的示例项目。首先切换到 SDK 解压后的 `example` 目录,然后执行 `build-x86_64.sh` 脚本。编译成功后,将在 `out/x86_64` 目录下生成可执行文件 `hello_rtsa` 和 `hello_rtm`。 ```shell # 切换到示例项目目录 cd agora_rtc_sdk/example # 构建示例项目 ./build-x86_64.sh ``` -------------------------------- ### Example Code Location (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/data-stream Locates the complete example code for sending and receiving data streams within the RTSA SDK download package. ```Shell ├── agora_rtsa_sdk # Agora SDK library files and header files └── example # Example code └── hello_stream_message └── hello_stream_message.c # Use data stream functionality in a single channel ``` -------------------------------- ### Initialize and Join RTC Channel (C) Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/data-stream Initializes the Agora RTC SDK and joins an RTC channel. Requires App ID and event handler setup. Returns an error code if initialization or joining fails. ```C // Set App ID const char *appid= "YOUR OWN APPID"; // Register relevant callbacks agora_rtc_event_handler_t event_handler = {xxx}; // Set relevant global service parameters rtc_service_option_t service_opt = {xxx}; int ret = 0; connection_id_t conn_id = 0; // Initialize ret = agora_rtc_init(appid, &event_handler, &service_opt); if (ret != 0) { printf("error info: %s", agora_rtc_err_2_str(ret)); return -1; } // Create Connection ret = agora_rtc_create_connection(&conn_id); if (ret != 0) { printf("error info: %s", agora_rtc_err_2_str(ret)); ``` -------------------------------- ### Set Video Codec in RTC Web SDK Source: https://doc.shengwang.cn/doc/rtsa/c/best-practices/interoperate-rtc This example shows how to set the video codec format to H.264 when initializing the RTC Web SDK. The default video codec is VP8, and H.264 can be specified during the `createClient` call. ```javascript AgoraRTC.createClient({mode: "live", codec: "h264"}); ``` -------------------------------- ### 运行媒体流示例项目 (发送 H.264 视频和 PCM 音频) (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/get-started/run-example 此命令用于运行 `hello_rtsa` 示例项目,开始发送 H.264 视频和 PCM 音频流。你需要将 `YOUR_APP_ID` 和 `YOUR_RTC_TOKEN` 替换为你的实际 App ID 和 RTC 临时 Token。该命令会将你加入名为 `demo_channel` 的频道,并使用默认参数发送音视频流。 ```shell cd out/x86_64 ./hello_rtsa -i YOUR_APP_ID -c demo_channel --token YOUR_RTC_TOKEN ``` -------------------------------- ### GET /dabiz/license/v3/projects/{appId}/renewals Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/license 查询指定 App ID 下所有的 License 续期订单,方便用户根据剩余数量和有效期等信息,确定使用哪一个 `renewId` 进行续期。 ```APIDOC ## GET /dabiz/license/v3/projects/{appId}/renewals ### Description 查询指定 App ID 下所有的 License 续期订单,方便用户根据剩余数量和有效期等信息,确定使用哪一个 `renewId` 进行续期。 ### Method GET ### Endpoint https://api.sd-rtn.com/dabiz/license/v3/projects/{appId}/renewals ### Parameters #### Path Parameters - **appId** (String) - Required - 声网分配给每个项目的唯一标识。 #### Query Parameters - **pid** (String) - Optional - (可选)由 SKU、有效期、品类定义的 License 激活标识。需要和 `activate` 接口中传入的 `pid` 一致。 - **page** (Int) - Optional - 页码。默认值为 1。 - **size** (Int) - Optional - 每页查询的 License 数量。默认值为 100,最大值为 100。 ### Request Example ```shell curl --location 'https://api.sd-rtn.com/dabiz/license/v3/projects/{appId}/renewals?size=10&page=1' \ --header 'Authorization: Basic ' ``` ### Response #### Success Response (200) - **count** (Int) - 续期订单数量。 - **list** (Array) - 由多组续期订单信息组成的数组,包含如下字段: - **renewId** (String) - 续期 ID。 - **pid** (String) - 由 SKU、有效期、品类定义的 License 激活标识。和你在请求中填入的 `pid` 一致。 - **type** (Int) - License 类型: * `1`: 整个 CID 下所有 App ID 均可使用。 * `2`: 仅指定 App ID 可用。 - **duration** (Int) - 有效期。单位根据你的 `pid` 类型而定: * 如果 `pid` 为测试类型,则有效期的单位为天。 * 如果 `pid` 为正式类型,则有效期的单位为年。 - **totalCount** (Int) - 续期次数。 - **allocateCount** (Int) - 已经使用的次数。 - **createTime** (String) - 续期创建的时间,RFC3339 格式。 #### Response Example ```json { "code": 200, "data": { "count": 2, "list": [ { "renewId": "xxxx", "pid": "xxxx", "type": 2, "duration": 50, "totalCount": 20, "allocateCount": 0, "createTime": "2024-12-02T08:32:12Z" }, { "renewId": "xxxx", "pid": "xxxx", "type": 1, "duration": 30, "totalCount": 100 } ] } } ``` ``` -------------------------------- ### Initialize with String User ID (C) Source: https://doc.shengwang.cn/doc/rtsa/c/overview/release-notes This snippet shows how to initialize the Agora RTSA C SDK using a string-based user ID. The `agora_rtc_init_with_name` function allows developers to use custom string identifiers for users instead of numerical IDs, enhancing flexibility. ```c #include void initialize_with_string_uid(const char* app_id, const char* user_id) { // Initialize the SDK with a string user ID agora_rtc_init_with_name(app_id, user_id); // Further SDK setup and joining channel can follow } int main() { const char* app_id = "YOUR_APP_ID"; const char* user_id = "user_12345"; initialize_with_string_uid(app_id, user_id); return 0; } ``` -------------------------------- ### Version 1.9.1 Release Notes Source: https://doc.shengwang.cn/doc/rtsa/c/overview/release-notes Details for version 1.9.1, released on July 11, 2023. Highlights include changes to video frame rate handling, introduction of media stream encryption, regional access control, audio encoding format updates, improvements to connection status callbacks, real-time messaging enhancements, and bug fixes. ```APIDOC ## Version 1.9.1 **Release Date:** July 11, 2023 ### Key Changes: * **Video Frame Rate:** The `frame_rate` member in the `video_frame_info_t` structure has been changed from an enum to an integer, allowing frame rates between 1 and 60. The `video_frame_rate_e` enum has been removed. * **Media Stream Encryption:** Added `crypto_opt` member to `rtc_channel_options_t` and removed `enable_aut_encryption`. This allows setting encryption mode, key, and salt when joining a channel. Note: All users in the same channel must use the same encryption settings. * **Regional Access Control:** Supports limiting user access to specific regions (Hong Kong/Macau, US, Russia) via the `area_code_e` enum (`AREA_CODE_HKMC`, `AREA_CODE_US`, `AREA_CODE_RU`). * **Audio Encoding Format:** Added `AUDIO_DATA_TYPE_AACLC_16K` to `audio_data_type_e` for encoding AAC-LC audio data at a 16000 Hz sample rate, improving efficiency on low-performance devices. * **SDK Connection Status & User Join/Leave Callbacks:** Introduced `on_reconnecting` callback. Modified `on_connection_lost`, `on_user_joined`, and `on_user_offline` callbacks for clearer distinction between connection states and user events. * **Real-Time Messaging:** Improved `agora_rtc_send_rtm_data` by making `msg_id` an output parameter. Added `rtm_uid` to `on_send_rtm_data_result` to identify the recipient. Enhanced login success rate under poor network conditions. ### Bug Fixes: * Users could not receive H.265 video frames. * Audio-video desynchronization when sending AAC audio data. * Rare issue where `on_user_joined` was triggered before `on_join_channel_successful` when a local user joined under poor network conditions. * `on_audio_data` callback was triggered for a remote user even after being muted using `agora_rtc_mute_remote_audio`. * Addressed occasional crashes. ``` -------------------------------- ### RTSA SDK 示例代码结构 (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/string-uid RTSA SDK 提供了完整的 String 型 UID 示例代码,位于 SDK 下载包的 `example/hello_rtsa/hello_rtsa.c` 文件中。该示例展示了如何使用 String 型 UID 加入频道。 ```Shell ├── agora_rtsa_sdk # 声网的 SDK 库文件和头文件 └── example # 示例代码 └── hello_rtsa └── hello_rtsa.c # 使用 String 型 UID 加入频道 ``` -------------------------------- ### 开启/关闭云代理 Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/cloud-proxy 在加入频道前,调用 `agora_rtc_set_cloud_proxy` 方法来开启或关闭云代理服务。设置 `type` 参数为 `CLOUD_PROXY_UDP(1)` 开启,为 `CLOUD_PROXY_NONE(0)` 关闭。 ```APIDOC ## agora_rtc_set_cloud_proxy ### Description Enables or disables the cloud proxy service before joining a channel. ### Method Not applicable (this is a function call, not an HTTP request) ### Endpoint Not applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **type** (int) - Required - Specifies whether to enable or disable the cloud proxy. - `1` (CLOUD_PROXY_UDP): Enable cloud proxy. - `0` (CLOUD_PROXY_NONE): Disable cloud proxy. ### Request Example ```c // Enable cloud proxy api_call_agora_rtc_set_cloud_proxy(CLOUD_PROXY_UDP); // Disable cloud proxy api_call_agora_rtc_set_cloud_proxy(CLOUD_PROXY_NONE); ``` ### Response #### Success Response (0) - **0** (int) - Indicates success. #### Response Example ```json { "status": 0 } ``` #### Error Response - **-1** (int) - Indicates an error occurred. ``` -------------------------------- ### Monitor RDT Channel State Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/send-message-through-rdt-channel Listen to the `on_rdt_state` callback to get the status of the RDT channel. This status is crucial for determining if RDT messages can be sent or received. Possible states include `RDT_STATE_CLOSED`, `RDT_STATE_OPENED`, `RDT_STATE_BLOCKED`, `RDT_STATE_PENDING`, and `RDT_STATE_BROKEN`. ```APIDOC ## Event: on_rdt_state ### Description Callback triggered when the state of the RDT channel changes. This allows you to monitor the connection status and react accordingly. ### Method Callback ### Endpoint `__on_rdt_state` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c rdt_state_e g_rdt_state_for_uid_xxx = RDT_STATE_CLOSED; void __on_rdt_state(connection_id_t conn_id, uint32_t uid, rdt_state_e state) { g_rdt_state_for_uid_xxx = state; // Handle state changes, e.g., enable/disable sending based on state printf("RDT state changed for uid %u to %d\n", uid, state); } ``` ### Response #### Success Response None (Callback function) #### Response Example None ``` -------------------------------- ### Activate License API Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/license 调用 activate 接口激活 License。此接口用于将设备 License 激活,以便在设备上使用声网服务。 ```APIDOC ## POST /dabiz/license/v2/active ### Description 调用 `activate` 接口激活 License。此接口用于将设备 License 激活,以便在设备上使用声网服务。 ### Method POST ### Endpoint https://api.sd-rtn.com/dabiz/license/v2/active ### Parameters #### Query Parameters - **pid** (String) - Required - 由 SKU、有效期、品类定义的 License 激活标识。 - **licenseKey** (String) - Required - 设备的唯一标识。例如设备的 SN 号、Mac 地址等。字符串长度需小于 64 字节。请注意区分大小写。只有在白名单中的 `licenseKey` 才能通过校验激活 License。 - **appid** (String) - Required - App ID,声网分配给每个项目的唯一标识。 ### Request Example ```shell curl --location 'https://api.sd-rtn.com/dabiz/license/v2/active?pid=02F5xxxxxxxxxxxxxxxxxxxxxxxxEC30&licenseKey=xxxx&appid=a6d6xxxxxxxxxxxxxxxxxxxxxxxxf75e' \ --header 'Authorization: Basic ' ``` ### Response #### Success Response (200) - **pid** (String) - 由 SKU、有效期、品类定义的 License 激活标识。 - **license** (String) - 激活的 License 的值。你需要自行保存该值,以便后续进行续期等操作。 - **licenseKey** (String) - 设备的唯一标识。和你在 `activate` 接口中传入的 `licenseKey` 一致。 - **expireTime** (String) - License 的过期时间。 - **activationTime** (String) - License 的激活时间。 - **skuView** (Array) - SKU 能力集,包含如下字段: - **product** (Integer) - 1: RTC, 2: RTSA #### Response Example ```json { "code": 200, "data": { "pid": "E4D6xxxxxxxxxxxxxxxxxxxxxxxx7E79", "license": "1D65xxxxxxxxxxxxxxxxxxxxxxxx6016", "licenseKey": "1234xxxxxxxxxxx1234", "expireTime": 17xxxxxxxx, "activationTime": 17xxxxxxxx, "skuView": { "product": 1 } } } ``` ``` -------------------------------- ### Initialize RTSA SDK Source: https://doc.shengwang.cn/doc/rtsa/c/get-started/implement-transmission Initializes the RTSA SDK with the App ID and sets up RTC event handlers and service options. This is a one-time operation required before starting media or signaling transmission. The App ID ensures applications can communicate within the same channel. RTC event handlers are crucial for receiving SDK events. ```c agora_rtc_event_handler_t rtc_event_handler = { 0 }; rtc_service_option_t service_options = { 0 }; agora_rtc_init(appid, &rtc_event_handler, &service_options); ``` -------------------------------- ### 运行信令示例项目 (命令行工具 1) (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/get-started/run-example 此命令用于运行 `hello_rtm` 示例项目,作为信令通信的第一个命令行工具。你需要替换 `YOUR_APP_ID`、`user1`、`user2` 和 `RTM_TOKEN_1` 为你的实际值。该命令配置为向 `user2` 发送消息。 ```shell # 命令行工具 1 cd out/x86_64 ./hello_rtm --appId YOUR_APP_ID --rtmUid user1 --peerUid user2 --token RTM_TOKEN_1 ``` -------------------------------- ### 运行信令示例项目 (命令行工具 2) (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/get-started/run-example 此命令用于运行 `hello_rtm` 示例项目,作为信令通信的第二个命令行工具。你需要替换 `YOUR_APPID`、`user2`、`user1` 和 `RTM_TOKEN_2` 为你的实际值。该命令配置为向 `user1` 发送消息,实现双向通信。 ```shell # 命令行工具 2 cd out/x86_64 ./hello_rtm --appId YOUR_APPID --rtmUid user2 --peerUid user1 --token RTM_TOKEN_2 ``` -------------------------------- ### 使用 User Account 加入 RTC 频道 (C) Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/string-uid 通过调用 `agora_rtc_create_connection` 创建连接,然后使用 `agora_rtc_join_channel_with_user_account` 函数,并传入 User Account 来加入 RTC 频道。首次使用新的 User Account 加入频道可能会有轻微延迟。 ```C connection_id_t conn_id = 0; const char *user_account = "xxxx"; // 创建connection ret = agora_rtc_create_connection(&conn_id); if (ret != 0) { printf("error info: %s", agora_rtc_err_2_str(ret)); return -1; } // 加入频道 rtc_channel_options_t channel_opt = {xxx}; ret = agora_rtc_join_channel_with_user_account(conn_id, "channel-xxx", user_account, token, &channel_opt); if (ret != 0) { printf("error info: %s", agora_rtc_err_2_str(ret)); return -1; } ``` -------------------------------- ### Version 1.9.0 Release Notes Source: https://doc.shengwang.cn/doc/rtsa/c/overview/release-notes Details for version 1.9.0, released on January 4, 2023. Key features include automatic license validation, video rotation support, domain limiting for IoT SIM cards, audio processing options, and enhanced logging capabilities. ```APIDOC ## Version 1.9.0 **Release Date:** January 4, 2023 ### New Features: * **License Auto-Validation:** SDK now automatically validates licenses upon channel join. `on_license_validation_failure` callback is triggered on failure. `agora_rtc_license_gen_credential` and `agora_rtc_license_verify` are deprecated. * **Video Rotation:** Added `rotation` parameter to `video_frame_info_t` to set the rotation angle for encoded video frames. * **IoT SIM Domain Limiting:** Added `domain_limit` parameter to `rtc_service_option_t`. Enables SDK to connect only to specified domains when using dedicated IoT SIM cards. * *Contact:* sales@shengwang.cn for usage. * **Audio Processing Options:** Added `audio_process_opt` parameter to `rtc_channel_options_t` to enable/disable features like echo cancellation and noise reduction. * *Contact:* sales@shengwang.cn for usage. * **Log Printing:** Added `log_tag` and `log_printf` parameters to `log_config_t` for custom log tags and printing functions. ### Improvements: * Improved audio and video experience in poor network conditions. ### Bug Fixes: * Resolved several issues. ``` -------------------------------- ### C - 初始化 SDK 时设置限定访问区域 Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/region-limit 此代码示例演示了如何在调用 `agora_rtc_init` 方法初始化声网 RTSA SDK 时,通过设置 `option` 参数中的 `area_code` 来指定访问区域为北美。该功能从 SDK v1.5.0 起支持,用于限制音视频和消息数据仅访问指定区域以外的服务器。 ```c // 设置区域为北美 rtc_service_option_t service_opt; service_opt.area_code = AREA_CODE_NA; ... // 初始化 SDK rval = agora_rtc_init(appid, &event_handler, &service_opt); ``` -------------------------------- ### 激活 License API 请求示例 (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/license 使用 curl 命令调用声网 License 激活接口,展示了如何传递 `pid`, `licenseKey`, 和 `appid` 参数。 ```shell curl --location 'https://api.sd-rtn.com/dabiz/license/v2/active?pid=02F5xxxxxxxxxxxxxxxxxxxxxxxxEC30&licenseKey=xxxx&appid=a6d6xxxxxxxxxxxxxxxxxxxxxxxxf75e' \ --header 'Authorization: Basic ' ``` -------------------------------- ### 配置 SDK 内置编解码器 (C) Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/audio-codec 配置 `agora_rtc_join_channel` 方法以使用 SDK 内置的 Opus 音频编解码器。设置音频编码类型、采样率和声道数。适用于需要 SDK 自动处理音频编码的场景。 ```c // 以 Opus 为例 rtc_channel_options_t channel_options = { 0 }; channel_options.audio_codec_opt.audio_codec_type = AUDIO_CODEC_TYPE_OPUS; channel_options.audio_codec_opt.pcm_sample_rate = 16000; channel_options.audio_codec_opt.pcm_channel_num = 1; ``` -------------------------------- ### Query Expiring Licenses API Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/license 调用 `expiringLicense` 接口查询即将到期的 License 列表。此接口用于监控 License 的有效期,及时进行续期操作。 ```APIDOC ## GET /dabiz/license/v3/projects/{appId}/pids/{pid}/expiringLicenses ### Description 调用 `expiringLicense` 接口查询即将到期的 License 列表。此接口用于监控 License 的有效期,及时进行续期操作。 ### Method GET ### Endpoint https://api.sd-rtn.com/dabiz/license/v3/projects/{appId}/pids/{pid}/expiringLicenses ### Parameters #### Path Parameters - **appId** (String) - Required - 声网分配给每个项目的唯一标识。 - **pid** (String) - Required - 由 SKU、有效期、品类定义的 License 激活标识。需要和 `activate` 接口中传入的 `pid` 一致。 #### Query Parameters - **page** (Int) - Optional - 分页页码。默认值为 1。 - **size** (Int) - Optional - 每页查询的 License 数量。默认值为 100,最大值为 100。 - **expiringLicenses** (Int) - Required - 将要过期的天数,可设为 60 或 90。服务器会返回即将在设置的天数内过期的 License 信息。不会返回已经过期的 License 信息。 ### Request Example ```shell curl --location 'https://api.sd-rtn.com/dabiz/license/v3/projects/{appId}/pids/{pid}/expiringLicenses?expiringDay=90&size=10&page=1' \ --header 'Authorization: Basic ' ``` ### Response #### Success Response (200) - **count** (Int) - 即将过期的 License 数量。 - **licenseInfos** (Array) - 由多组 Lisence 信息组成的数组,包含如下字段: - **licenseKey** (String) - 设备的唯一标识。和你在 `activate` 接口中传入的 `licenseKey` 一致。 - **license** (String) - 即将过期的 License 的值。 - **activeTime** (String) - License 的激活时间,RFC3339 格式。 - **expireTime** (String) - License 的过期时间,RFC3339 格式。 #### Response Example ```json { "count": 10, "licenseInfos": [ { "licenseKey": "1234xxxxxxxxxxx1234", "license": "1D65xxxxxxxxxxxxxxxxxxxxxxxx6016", "activeTime": "2023-01-01T10:00:00Z", "expireTime": "2024-01-01T10:00:00Z" } ] } ``` ``` -------------------------------- ### 下载和解压 RTSA SDK 包 (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/get-started/run-example 此命令用于从指定的 URL 下载 RTSA SDK 的 Linux x86_64 版本压缩包,并将其解压缩。请将 `x.y.z` 替换为实际的 SDK 版本号。此操作是获取示例项目和 SDK 库的前提。 ```shell # 将 x.y.z 替换为具体的 SDK 版本号,如 1.9.1 # 可通过发版说明获取最新版本号 # 获取 SDK wget https://download.agora.io/rtsasdk/release/Agora-RTSALite-RmAcAjCP-x86_64-linux-gnu-vx.y.z.tgz # 解压缩 tar xvf Agora-RTSALite-RmAcAjCP-x86_64-linux-gnu-vx.y.z.tgz ``` -------------------------------- ### Configure BWE and Handle Bitrate Changes Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/bitrate-adaption This section details how to configure Bandwidth Estimation (BWE) parameters before joining an RTC channel and how to handle real-time bitrate adjustments triggered by network changes. ```APIDOC ## POST /websites/doc_shengwang_cn_doc_rtsa_c ### Description Configure Bandwidth Estimation (BWE) parameters to set the minimum, maximum, and starting sending bitrate before joining an RTC channel. The SDK will trigger an `on_target_bitrate_changed` callback when network conditions change, providing a suggested bitrate for the application to adjust its sending rate accordingly. ### Method POST ### Endpoint /websites/doc_shengwang_cn_doc_rtsa_c ### Parameters #### Query Parameters - **min_bps** (uint32_t) - Required - The minimum sending bitrate in bits per second. - **max_bps** (uint32_t) - Required - The maximum sending bitrate in bits per second. - **start_bps** (uint32_t) - Required - The starting sending bitrate in bits per second. ### Request Example ```c // Configure BWE uint32_t min_bps = 400000; uint32_t max_bps = 4200000; uint32_t start_bps = 500000; agora_rtc_set_bwe_param(min_bps, max_bps, start_bps); ``` ### Response #### Success Response (200) This endpoint does not return a specific response body, but the configuration is applied internally by the SDK. #### Callback Handling When the network bandwidth changes, the SDK triggers the `on_target_bitrate_changed` callback. ```c static void __on_target_bitrate_changed(const char *channel, uint32_t target_bps) { // Current bitrate is quantized in 100 K segments, rounded down curTargetBitrate = target_bps/100000 * 100; diffTargetBitrate = abs(curTargetBitRate - lastTargetBitrate); // If the detected bandwidth differs from the set encoding bitrate by more than 100 K, re-adjust encoding parameters if ( (diffTargetBitrate >= 100 ) && (lowBitrateL1 < curTargetBitrate < highBitrateL3) ) { if (lowBitrateL1 < curTargetBitrate < highBitrateL1) { curResolutionLevel = L1; } // ... other resolution level adjustments ... } } ``` ### Notes - The `agora_rtc_set_bwe_param` function must be called *before* `agora_rtc_join_channel` for the configuration to be effective. - The `on_target_bitrate_changed` callback returns bitrate in bps (bits per second). Be careful not to confuse it with kbps or Bps. ``` -------------------------------- ### POST /dabiz/license/v2/renew Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/license 为现有的 License 申请续期。在 License 到期前,可以通过此接口申请续期以继续使用声网服务。 ```APIDOC ## POST /dabiz/license/v2/renew ### Description 为现有的 License 申请续期。在 License 到期前,可以通过此接口申请续期以继续使用声网服务。 ### Method POST ### Endpoint https://api.sd-rtn.com/dabiz/license/v2/renew ### Parameters #### Query Parameters - **appid** (String) - Required - 声网分配给每个项目的唯一标识。 - **renewId** (String) - Optional - (可选)由 SKU、有效期、品类定义的 License 续期标识。联系 sales@shengwang.cn 获取。如果不填,则声网会按照项目级别、公司级别从高到低优先选择最早生成的 `renewId` 来执行续期操作。 - **license** (String) - Required - 需要续期的 License 值。你可以在激活接口的 `license` 响应参数中获取。注意请注意区分大小写。 ### Request Example ```shell curl --location 'https://api.sd-rtn.com/dabiz/license/v2/renew?appid=a6d6xxxxxxxxxxxxxxxxxxxxxxxxf75e&renewId=4750xxxxxxxxxxxxxxxxxxxxxxxx6270&license=85B3xxxxxxxxxxxxxxxxxxxxxxxx656F' \ --header 'Authorization: Basic ' ``` ### Response #### Success Response (200) - **licenseKey** (String) - 设备的唯一标识。 - **license** (String) - 续期的 License。 - **renewTimes** (Int) - 续期次数。 - **lastRenewTime** (Int) - 上次续期的时间戳。 - **activationTime** (Int) - License 激活的时间戳。 - **expireTime** (Int) - License 过期的时间戳。 #### Response Example ```json { "code": 200, "message": "license续期成功", "data": { "licenseKey": "xxxx", "license": "85B3xxxxxxxxxxxxxxxxxxxxxxxx656F", "renewTimes": 1, "lastRenewTime": 1700644272, "activationTime": 1700642665, "expireTime": 1705913065 } } ``` ``` -------------------------------- ### 启用媒体流加密 (C) Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/encryption 在 C 语言中配置 `agora_rtc_join_channel` 函数以启用媒体流加密。需要设置加密模式(推荐 AES_128_GCM2 或 AES_256_GCM2),并传入从服务端获取的密钥和 Base64 编码的盐。盐需要先从 Base64 解码为 uint8_t 数组。 ```c rtc_channel_options_t channel_options = { 0 }; // 开启加密 channel_options.crypto_opt.enable = true; // 设置加密模式 channel_options.crypto_opt.mode = AES_128_GCM2; // 传入密钥 sprintf(channel_options.crypto_opt.key, "%s", key_str); // 传入盐 uint8_t *salt_bytes = NULL; uint32_t salt_bytes_len = 0; salt_bytes = util_base64_decode(salt_base64_str, strlen(salt_base64_str), &salt_bytes_len); memcpy(channel_options.crypto_opt.salt, salt_bytes, salt_bytes_len); free(salt_bytes); // 加入频道 agora_rtc_join_channel(conn_id, channel_name, uid, token, &channel_options); ``` -------------------------------- ### Configure Audio Codec in RTC Web SDK (v4.9.0+) Source: https://doc.shengwang.cn/doc/rtsa/c/best-practices/interoperate-rtc This snippet demonstrates how to set specific audio codec formats (G711 PCMA, G711 PCMU, G722) when creating a client in the RTC Web SDK, provided the SDK version is 4.9.0 or higher. It requires the `AgoraRTC.createClient` method with the `audioCodec` option. ```javascript AgoraRTC.createClient({mode: "live", codec: "h264", audioCodec: "pcma"}); // G711 (PCMA) AgoraRTC.createClient({mode: "live", codec: "h264", audioCodec: "pcmu"}); // G711 (PCMU) AgoraRTC.createClient({mode: "live", codec: "h264", audioCodec: "g722"}); // G722 ``` -------------------------------- ### Version 1.7.3 Release Notes Source: https://doc.shengwang.cn/doc/rtsa/c/overview/release-notes Details for version 1.7.3, released on May 19, 2022. This version adds support for new encryption modes, enhances salt encoding, improves SDK performance, and introduces IP address anonymization in logs. ```APIDOC ## Version 1.7.3 **Release Date:** May 19, 2022 ### New Features: * **Encryption Modes:** Added support for `aes-128-ecb`, `aes-128-xts`, and `aes-256-xts`. * **Salt Encoding:** Added support for Base64 encoding for salt. ### Improvements: * Enhanced SDK performance and fixed issues. * Added IP address anonymization feature to SDK logs. ``` -------------------------------- ### Version 1.8.0 Release Notes Source: https://doc.shengwang.cn/doc/rtsa/c/overview/release-notes Details for version 1.8.0, released on August 1, 2022. This version introduces a Connection ID mechanism, deprecates string user IDs, and includes bug fixes. ```APIDOC ## Version 1.8.0 **Release Date:** August 1, 2022 ### Key Changes: * **API Overhaul:** Most APIs have been changed or redesigned compared to version 1.7.3. Re-integration of the SDK is required. * **String User ID Deprecation:** SDK no longer supports String type user IDs. Related interfaces have been removed. * **Connection ID Mechanism:** Introduced Connection ID for connecting to RTC channels. Each Connection has a unique ID and can be associated with multiple RTC channels. APIs related to Connection ID include: * `agora_rtc_create_connection` * `agora_rtc_destroy_connection` * `agora_rtc_get_connection_info` * `channel_name` parameters in most APIs are now `connection_id` (except `agora_rtc_join_channel`). * Enables multi-channel streaming and single-channel multi-stream scenarios. ### Bug Fixes: * Fixed various SDK issues. ``` -------------------------------- ### 查询即将到期 License API 请求示例 (Shell) Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/license 使用 curl 命令调用声网查询即将到期 License 的接口,展示了如何传递 `appId`, `pid`, `expiringDay`, `size`, 和 `page` 参数。 ```shell curl --location 'https://api.sd-rtn.com/dabiz/license/v3/projects/{appId}/pids/{pid}/expiringLicenses?expiringDay=90&size=10&page=1' \ --header 'Authorization: Basic ' ``` -------------------------------- ### 禁用 SDK 音频编解码器 (C) Source: https://doc.shengwang.cn/doc/rtsa/c/basic-features/audio-codec 配置 `agora_rtc_join_channel` 方法以禁用 SDK 的内置音频编解码器,允许用户自行处理音频编码。设置 `audio_codec_type` 为 `AUDIO_CODEC_DISABLED`。 ```c channel_options.audio_codec_opt.audio_codec_type = AUDIO_CODEC_DISABLED; ``` -------------------------------- ### Join RTC Channel and Establish RDT Connection Source: https://doc.shengwang.cn/doc/rtsa/c/advanced-features/send-message-through-rdt-channel This section details how to join an RTC channel and configure RDT connection behavior. For SDK versions v1.9.4 and later, `enable_rdt` should be set to `true` in `rtc_channel_options_t` when joining the channel. The `auto_connect_rdt` parameter controls whether the SDK actively establishes RDT connections upon user joins and disconnects them upon user leaves. ```APIDOC ## POST /rtc/joinChannel ### Description Joins an RTC channel and configures RDT connection behavior. For SDKs v1.9.4+, set `enable_rdt` to `true` in `rtc_channel_options_t`. `auto_connect_rdt` determines if the SDK actively initiates RDT connections. ### Method C ### Endpoint `agora_rtc_join_channel` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **conn_id** (connection_id_t) - The connection ID obtained from `agora_rtc_create_connection`. - **channelName** (const char *) - The name of the channel to join. - **uid** (uint32_t) - The user ID. - **token** (const char *) - The authentication token. - **channel_opt** (rtc_channel_options_t *) - Channel options, including `auto_connect_rdt` and `enable_rdt`. - **auto_connect_rdt** (bool) - Set to `true` to actively establish RDT connections, `false` to only accept invitations. - **enable_rdt** (bool) - Set to `true` to enable RDT functionality (required for v1.9.4+). ### Request Example ```c int ret = 0; connection_id_t conn_id = 0; ret = agora_rtc_create_connection(&conn_id); if (ret != 0) { printf("error info: %s\n", agora_rtc_err_2_str(ret)); return -1; } rtc_channel_options_t channel_opt = {0}; // Set to actively establish RDT connection. true: actively establish; false: do not actively establish channel_opt.auto_connect_rdt = true; // For SDKs v1.9.4+, enable RDT functionality channel_opt.enable_rdt = true; ret = agora_rtc_join_channel(conn_id, "channel-xxx", uid, token, &channel_opt); if (ret != 0) { printf("error info: %s\n", agora_rtc_err_2_str(ret)); return -1; } ``` ### Response #### Success Response (0) Indicates successful channel join and RDT connection setup. #### Response Example None (return value indicates success or failure) ```