Skip to main content

Server-Side CDN Relay Streaming

CDN relay streaming: Converts RC's real-time audio and video streams into RTMP protocol and pushes them to CDN services.

Business Flow

After the host joins the room and successfully publishes resources, your application server can call RC's RTC Server API to configure the CDN address for relay streaming.

Prerequisites

The following conditions must be met when configuring CDN relay streaming:

  • RTC and live streaming services must be activated.
  • The room must be in live streaming mode.
  • The configured CDN address format must be valid.

Request Method

POST: https://Data Center Domain/rtc/mcu/config.json

Signature Rules: All requests to RC's server APIs require signature verification. For details, see API Request Signature.

Request Body Parameters

The HTTP request body contains a JSON object with the following structure:

ParameterTypeDescription
sessionIdString(Required) The live session ID to be configured. Obtain this sessionId through RC's server callback. See Room Status Callback.
configStringObject format data; allows setting layout-related parameters
config.versionNumber(Required) The version number for CDN relay streaming configuration. Default is 1.
config.outputObjectDefines the mixed media output
config.output.cdnArrayThe list of CDN push URLs. Must provide the complete list. Multiple calls will use the latest configuration.
config.output.cdn[i].pushurlStringThe complete CDN push URL. Do not use CDN pull URLs.
Note
  • Currently, a maximum of 5 CDN push URLs are supported for the same room's live streaming.
  • The config.output.cdn list parameter must be provided in full each time. Multiple calls will use the latest configuration. If the same URL is set multiple times, the API will return success directly.
  • If the CDN push URL is invalid or lacks permissions, push failures will be notified to your app server via CDN push callbacks.
  • CDN services distinguish between push and pull URLs. This API requires push URLs—do not confuse them.

Request Example

POST /rtc/mcu/config.json HTTP/1.1
Host: api.rong-api.com
App-Key: uwd1c0sxdlx2
Timestamp: 1585127132438
Nonce: 14314
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Room-Id: room1
Content-Type: application/json

{
"sessionId":"session1",
"config":{
"version":1,
"output":{
"cdn":[
{
"pushurl":"rtmp://your.test.cdn/room1"
},
{
"pushurl":"rtmp://your.test.cdn2/room1"
}
]
}
}
}

Response

The HTTP response body contains a JSON object with the following structure:

  • code: The business status code in the HTTP response body. 200 indicates success.

Response Example

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"code":200
}

Status Code Definitions

See Status Codes.