With the interactive streaming feature, you can create an interactive streaming application to implement capabilities such as calling, voice chat, and conferencing. This topic describes how to create an interactive streaming application.
Create an interactive streaming application
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Interactive Streaming > Applications.
Click Create Application.
On the page that appears, enter a custom name in the Instance Name field, select Terms of Service, and then click Buy Now.
After the application is created, refresh the Applications page to view the application.
NoteYou are charged for co-streaming based on the pay-as-you-go billing method. No fees are incurred when you create an application.
Configure stream relay
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Interactive Streaming > Applications. On the Applications page, find the application that you want to manage and click Manage in the Actions column.
Click Stream Relay. You can use one of the following methods to configure stream relay:
Method 1: Specify streams to relay
You can call API operations on the server side to configure stream relay for a specific channel in real time. This way, the streams can be relayed to ApsaraVideo Live or a third-party platform. This requires a small amount of development on the server side.
Method 2: Configure global stream relay to ApsaraVideo Live
After you enable the stream relay feature, audio and video streams are relayed to the origin server of ApsaraVideo Live. You can configure features such as transcoding, recording, and snapshot based on streaming domains. You can also pull live streams to watch.
Turn on Stream Relay.
Configure the stream relay parameters.
Parameter
Configuration
Description
Stream Relay
Select an option.
After you enable single-stream relay, all audio and video streams are relayed to ApsaraVideo Live by default. You can still update the layout of a mixed stream by using the SDK or server API.
Streaming Domain
Example: play.example.com
The streaming domain that is relayed for standard streaming. You can play live streams, configure transcoding and recording settings, and perform other operations based on the streaming domain.
NoteIf you do not have a streaming domain, add one on the Domain Management page.
Do not enable RTS 2.0 for the streaming domain. Otherwise, stream relay fails.
AppName
The name can be up to 255 characters in length and can contain digits, letters, hyphens (-), underscores (_), and equal signs (=).
Default value: live. You can specify a custom value.
The application name in the streaming URL after stream relay. For more information, see Generate ingest and streaming URLs.
NoteIf you need to configure templates such as transcoding, recording, and snapshot templates for the relayed stream, you must specify an application name that is the same as the application name specified in the templates. Otherwise, the templates do not take effect.
SEI Insertion
Insert SEI at Regular Intervals: This option lets you insert supplemental enhancement information (SEI) at a specified interval from 1,000 to 5,000 ms.
Insert SEI in I-frames: This option lets you insert SEI in I-frames of a video stream.
SEI: You can use SEI to insert basic user information such as the UID and mixed-stream layout parameters into streams. This way, in co-streaming scenarios, when the layout for stream mixing and relay changes, the app that viewers use to watch streams can parse the layout information from SEI in real time. This helps facilitate the adjustment of interaction styles. For more information, see SEI format.
NoteIf no streaming domain exists on the Domain Management page, you need to add a domain name. For more information, see Add a domain name.
Do not enable RTS 2.0 for the streaming domain. Otherwise, relayed stream pulling fails.
SEI format
Data type | Parameter | Description |
Video stream information | stream | The information about the streamer. uid: the user ID of the streamer. |
The layout information of the area where the streamer is streaming. Take note of the following layout parameters:
|
If the stream of a user with UID 111 and the stream of a user with UID 222 are mixed, the following sample code provides an example of the SEI message:
{"stream":[{"uid":"111","paneid":0,"zorder":1,"x":0,"y":0.25,"w":0.5,"h":0.5,"type":0,"ms":0,"vol":1,"vad":119},{"uid":"222","paneid":1,"zorder":1,"x":0.5018382,"y":0.25,"w":0.5,"h":0.5,"type":0,"ms":0,"vol":60,"vad":123}]}
Callbacks
The interactive streaming feature provides channel and user callbacks. The following section describes how to configure these callbacks in the ApsaraVideo Live console.
Overview
After you configure channel and user callbacks, your business server can receive channel and user status changes of interactive streaming in real time.
Channel callbacks: Notifications about events such as creating a channel and closing a channel are sent.
User callbacks: Notifications about events related to users are sent. For example, when a user joins or leaves a channel, a user switches the role, or a user ingests or pulls a stream.
For more information about the callback content, see CreateEventSub.
Create a callback task
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Interactive Streaming > Applications.
Find the application for which you want to create a callback task and click Manage in the Actions column. The application management page appears.
Click Callbacks. On the Callback Tasks tab, click Create Task.
Configure the callback parameters. The following table describes the parameters.
Parameter
Description
Callback URL
The URL that is used to receive the callbacks. Supported protocols include HTTP and HTTPS. We recommend that you use HTTPS.
Event Scope
The callback events include user events and channel events.
User events include the following events:
Join the channel
Start to ingest a screen-sharing stream
Leave the channel
Stop ingesting a video stream
Switch the role
Stop ingesting an audio stream
Start to ingest a video stream
Stop ingesting a screen-sharing stream
Start to ingest an audio stream
Channel events include the following events:
Start the channel
End the channel
Specified Channel
Optional. If you do not specify a channel, callbacks are generated for all channels by default. If you specify a channel, callbacks are generated for only the channel.
Specified User
Optional. This parameter takes effect only for user events. If you specify a user, you must also specify a channel. You can specify up to 20 users. Separate multiple user IDs with commas (,).
Click OK.
Edit or delete a callback task
After you create a callback task, you can edit the task or delete the task.
On the Callbacks page, find the task that you want to edit or delete.
Click Edit or Delete in the Actions column of the task to edit or delete the task.
View callback records
After you create a callback task and the task takes effect, callback records are generated if related events occur. You can view the details of a callback on the Callback Records tab.