This topic describes how to construct ingest and streaming URLs for streamers and co-streaming viewers in co-streaming scenarios. It also describes how to construct ingest and streaming URLs for different streamers in streamer challenge scenarios, and CDN playback URLs for regular viewers.
Prerequisites
You have created an ApsaraVideo Real-time Communication application. For more information, see Step 4: Create an ApsaraVideo Real-time Communication application.
You have added a streaming domain name. For more information, see Add an accelerated domain name.
You have associated the streaming domain name with the ingest domain name. For more information, see Associate a streaming domain name with an ingest domain name.
During co-streaming or a streamer challenge, all user IDs, including streamer IDs and co-streaming viewer IDs, must be unique across all channels to prevent conflicts. For example, consider two channels: Channel A (Channel ID: A, Streamer ID: 111, Co-streaming Viewer ID: 222) and Channel B (Channel ID: B, Streamer ID: 222, Co-streaming Viewer ID: 333). If you attempt to start a co-streaming or streamer challenge session between them, a conflict will occur because the co-streaming viewer ID in Channel A (222) is the same as the streamer ID in Channel B (222). This can lead to unexpected service faults.
Ingest and streaming URLs for co-streaming scenarios
Before you manually construct the ingest and streaming URLs for streamers and co-streaming viewers, obtain the following information:
Field Name | Description |
artc:// | The URL prefix for co-streaming mode. Do not change this field. |
live.aliyun.com | A fixed prefix for co-streaming mode URLs. Do not change this field. Note live.aliyun.com is not a real domain name. Do not perform domain name operations on it, such as ping, traceroute, or telnet. |
push | A fixed field that indicates stream ingest. Do not change this field. |
play | A fixed field that indicates stream pulling. Do not change this field. |
roomId | The channel ID. This is user-defined. The streamer and co-streaming viewers must use the same channel ID. It can contain digits, uppercase letters, lowercase letters, hyphens (-), underscores (_), and equal signs (=). The ID must not exceed 64 characters. |
sdkAppId | The ID of the ApsaraVideo Real-time Communication application. This ID is automatically generated after you create an application in the ApsaraVideo Live console. For more information, see Stream mixing. |
userId | Use the streamer ID to construct the streamer's URL. Use the co-streaming viewer's ID to construct the viewer's URL. This is user-defined. Make sure the streamer ID and co-streaming viewer IDs are different within the same live channel. It can contain digits, uppercase letters, lowercase letters, hyphens (-), underscores (_), and equal signs (=). The ID must not exceed 64 characters. |
timestamp | The expiration timestamp for the co-streaming URL, in seconds. The URL expires after this timestamp. The maximum validity period is 24 hours. |
token | The access token generated from roomId, timestamp, userId, sdkAppId, and AppKey. For information about how to generate a token, see Token-based authentication. |
Assume the following:
The roomId (room ID) is
123.The sdkAppId (ApsaraVideo Real-time Communication application ID) is
d14baa88-****-4111-b5b0-3b2f60d2ef80.The userId (streamer ID) is
518.The userId (co-streaming viewer ID) is
520.The timestamp (validity period timestamp) is
1659583716.The token is
2035650c0f7****a53998.
The construction rules and example URLs are as follows:
When you use the URL, replace the placeholders with your actual data.
Address class | Construction rule | Example | |
Streamer | Ingest URL | artc://live.aliyun.com/push/${ChannelID}?sdkAppId=${AppID}&userId=${StreamerID}×tamp=${Timestamp}&token=${Token} | Supports stream ingest in RTC format. RTC: |
Streaming URL | artc://live.aliyun.com/play/${ChannelID}?sdkAppId=${AppID}&userId=${StreamerID}×tamp=${Timestamp}&token=${Token} | Supports stream pulling in RTC format. RTC: | |
Viewer | Ingest URL | artc://live.aliyun.com/push/${ChannelID}?sdkAppId=${AppID}&userId=${CoStreamingViewerID}×tamp=${Timestamp}&token=${Token} | Supports stream ingest in RTC format. RTC: |
Streaming URL | artc://live.aliyun.com/play/${ChannelID}?sdkAppId=${AppID}&userId=${CoStreamingViewerID}×tamp=${Timestamp}&token=${Token} | Supports stream pulling in RTC format. RTC: |
Ingest and streaming URLs for streamer challenge scenarios
Before you manually construct the ingest and streaming URLs for Streamer A and Streamer B in a streamer challenge, obtain the following information:
Field | Description |
artc:// | The URL prefix for co-streaming mode. Do not change this field. |
live.aliyun.com | A fixed field for co-streaming mode URLs. Do not change this field. |
push | A fixed field that indicates stream ingest. Do not change this field. |
play | A fixed field that indicates stream pulling. Do not change this field. |
roomId | The channel ID for the interactive mode. This is defined by the developer. Streamers in a challenge must use different channel IDs. It can contain digits, uppercase letters, lowercase letters, hyphens (-), underscores (_), and equal signs (=). The ID must not exceed 64 characters. |
sdkAppId | The ID of the ApsaraVideo Real-time Communication application. This ID is automatically generated after you create an application in the ApsaraVideo Live console. For more information, see Stream mixing. |
userId | The streamer ID. This is user-defined. Streamers in a challenge must use different streamer IDs. It can contain digits, uppercase letters, lowercase letters, hyphens (-), underscores (_), and equal signs (=). The ID must not exceed 64 characters. |
timestamp | The expiration timestamp for the streamer challenge URL, in seconds. The URL expires after this timestamp. The maximum validity period is 24 hours. |
token | The access token generated from roomId, timestamp, userId, sdkAppId, and AppKey. For information about how to generate a token, see Token-based authentication. |
Assume the following:
The roomId (channel ID) for Streamer A is
111.The roomId (channel ID) for Streamer B is
222.The sdkAppId (ApsaraVideo Real-time Communication application ID) is
d14baa88-****-4111-b5b0-3b2f60d2ef80.The userId (streamer ID) for Streamer A is
125.The userId (streamer ID) for Streamer B is
396.The timestamp (validity period timestamp) is
1659583716.The token is
2035650c0f7****a53998.
The construction rules and example URLs are as follows:
When you use the URL, replace the placeholders with your actual data.
Address class | Construction rule | Example | |
Streamer A | Ingest URL | artc://live.aliyun.com/push/${StreamerA_ChannelID}?sdkAppId=${AppID}&userId=${StreamerA_ID}×tamp=${Timestamp}&token=${Token} | Supports stream ingest in RTC format. RTC: |
Streaming URL | artc://live.aliyun.com/play/${StreamerA_ChannelID}?sdkAppId=${AppID}&userId=${StreamerA_ID}×tamp=${Timestamp}&token=${Token} | Supports stream pulling in RTC format. RTC: | |
Streamer B | Ingest URL | artc://live.aliyun.com/push/${StreamerB_ChannelID}?sdkAppId=${AppID}&userId=${StreamerB_ID}×tamp=${Timestamp}&token=${Token} | Supports stream ingest in RTC format. RTC: |
Streaming URL | artc://live.aliyun.com/play/${StreamerB_ChannelID}?sdkAppId=${AppID}&userId=${StreamerB_ID}×tamp=${Timestamp}&token=${Token} | Supports stream pulling in RTC format. RTC: |
CDN playback URLs for regular viewers
A regular viewer uses the CDN playback URL of the streamer's channel. Each channel has a unique CDN playback URL. When you construct this URL, use the channel ID and streamer ID of the stream that the viewer is watching.
In a streamer challenge, regular viewers of different streamers must use the CDN playback URL of their respective streamer's channel. For example, if Viewer C is a regular viewer of Streamer A, Viewer C must use the CDN playback URL for Streamer A's channel during the challenge.
Before you manually construct the CDN playback URL for a regular viewer (not a co-streaming viewer), obtain the following information:
Field Name | Description |
Protocol prefix | The supported URL formats are RTMP, FLV, M3U8, and RTS. The corresponding protocol prefixes are |
Streaming domain | The playback domain name. This is the streaming domain name configured for the ApsaraVideo Real-time Communication application in the ApsaraVideo Live console. For more information, see Stream mixing. |
AppName | The application name for co-streaming. This is user-defined. It can contain digits, uppercase letters, lowercase letters, hyphens (-), underscores (_), and equal signs (=). The name must not exceed 255 characters. |
StreamId | The StreamId is generated by combining multiple fields from the ingest URL. The construction rules are:
|
auth_key Note This field is required only if URL signing is enabled. | The access token. The access token is an encrypted string generated by an authentication algorithm. You must enable the URL signing feature to generate it. You can enable URL signing and get the access token in the console. For more information, see URL signing. You can also calculate the access token using the MD5 algorithm. For more information, see Components of a signed URL. |
The following input stream types are available for the StreamId field:
camera: A video input stream from a camera.
shareScreen: A video input stream from screen sharing.
audio: An audio input stream from a microphone.
Assume the sdkAppId (ApsaraVideo Real-time Communication application ID) is d14baa88-****-4111-b5b0-3b2f60d2ef80, the roomId (channel ID) is 123, and the userId (streamer ID) is 518.
In a video co-streaming scenario, the constructed StreamId is
d14baa88-****-4111-b5b0-3b2f60d2ef80_123_518_camera.In an audio-only co-streaming scenario, the constructed StreamId is
d14baa88-****-4111-b5b0-3b2f60d2ef80_123_518_audio.
Assume the streaming domain name is example.alivecdn.com and the auth_key access token is 16632272****fd016c6d85f.
In a video co-streaming scenario, the StreamId is
d14baa88-****-4111-b5b0-3b2f60d2ef80_123_518_camera.In an audio-only co-streaming scenario, the StreamId is
d14baa88-****-4111-b5b0-3b2f60d2ef80_123_518_audio.
The construction rules and example URLs are as follows:
Use the HTTP-FLV format for playback.
The data content in RTMP and HTTP-FLV URLs is the same. The only difference is the network protocol used. HTTP is the primary protocol on the Internet. Network infrastructure, such as CDNs, ISPs, and other intermediate devices, is highly optimized for HTTP. The default HTTP ports, 80 and 443, are typically included in whitelists and are unlikely to be blocked. The RTMP protocol is an older protocol. Its default port, 1935, may be blocked by firewalls or other network devices, which can cause playback failures. Therefore, HTTP-FLV provides better stability and performance with less stuttering and lower latency than RTMP in most network environments.
When you use the URL, replace the placeholders with your actual data.
Address Class | Concatenation Rules | Example | |
CDN playback URL | Streaming URL |
| Playback URLs support the RTMP, FLV, M3U8, and RTS formats.
|