This interface can be used to add a stream to a specified room. It is commonly used in scenarios where multiple users watch together, such as adding a live stream from a CDN to a specified room, allowing users in the room to access the stream ID and control the live content of the room.
This interface is only used to notify the addition of a stream in the room and does not perform the actual streaming operation. Developers need to call the startPublishingStream
interface from their own client to start streaming (or use other streaming methods) so that the added stream can be pulled by the startPlayingStream
interface.
On the client side, the ZEGO Express SDK will trigger the following callback to notify the client of the event:
Platform | ZEGO Express SDK callback |
---|---|
iOS/macOS | onRoomStreamUpdate |
Android | onRoomStreamUpdate |
Windows | onRoomStreamUpdate |
Web | roomStreamUpdate |
Listed below are the parameters specific to this request and part of the public request parameters. For the complete list of public request parameters, see Server APIs public request parameters.
Parameter | Type | Required | Description |
---|---|---|---|
RoomId |
String |
Yes |
Room ID. |
UserId |
String |
Yes |
User ID of the user who performs this operation. |
UserName |
String |
No |
User name of the user who performs this operation. |
StreamId |
String |
Yes |
Stream ID of the stream to be added. |
StreamTitle |
String |
No |
Stream title, with a maximum length of 127 bytes. |
ExtraInfo |
String |
No |
Extra stream information, with a maximum length of 1024 bytes. |
CensorFlag |
Int32 |
No |
Flag indicating whether censorship is allowed. When reviewing a list of room streams, indicates whether the current stream is allowed to be reviewed:
|
When calling this server-side API:
https://rtc-api.zego.im/?Action=AddStream
&RoomId=room1
&UserId=user1
&UserName=userName
&StreamId=streamId1
&StreamTitle=%E6%B5%81%E6%A0%87%E9%A2%98
&ExtraInfo=%E9%99%84%E5%8A%A0%E4%BF%A1%E6%81%AF
&CensorFlag=0
&<Public Request Parameters>
Parameter | Type | Description |
---|---|---|
Code |
Int32 |
Return code. |
Message |
String |
Description of the request execution result. |
RequestId |
String |
Request ID. |
{
"Code":0,
"Message":"success",
"RequestId":"4443515903608307334"
}
Listed below are the return codes related to this API. For the complete list of return codes, see Return codes.
Return Code | Description | Suggested Action |
---|---|---|
123 | Failed to set stream information. | Please try again or contact ZEGOCLOUD technical support for assistance. |
1012 | Multiple users operating on the same stream. | Please check the logic. |