Stream Created Callback
Starting Stream Mixing will not trigger this callback. For Stream Mixing related callbacks, please refer to Stream Mixing Started Callback.
Description
When developers need to maintain a live list, when the APP has a Stream created on the streaming media server, it will make a POST request to the callback URL.
Callback instructions
- Request method: POST。
The callback data format is JSON, you need to decode it with UrlDecode.
- Request URL: Please configure the callback URL in the ZEGOCLOUD console.
- Transfer protocol: HTTPS/HTTP, HTTPS is recommended.
Callback parameters
| Common parameters | Type | Description |
|---|---|---|
| event | String | Callback event, this callback returns stream_create. |
| appid | String | AppId. |
| timestamp | String | Server current time when the server callbacks to the customer after the Stream is created, Unix timestamp. |
| nonce | String | Random number. |
| signature | String | Verification string, please refer to Callback instructions - Verification instructions. |
| Business parameters | Type | Description |
| room_id | String | Room ID, corresponds to the client's RoomID, has the same meaning as channel_id, not exceeding 127 bytes. |
| room_session_id | String | Unique identifier of the Room lifecycle, remains unchanged during the entire lifecycle of the Room. |
| user_id | String | User ID, has the same meaning as publish_id, not exceeding 255 bytes. |
| user_name | String | User nickname, has the same meaning as publish_name, not exceeding 255 bytes. |
| channel_id | String | Channel ID, corresponds to the client's RoomID, not exceeding 127 bytes. |
| stream_id | String | Stream ID, corresponds to the client's StreamID, has the same meaning as stream_alias. |
| stream_sid | String | Stream server ID, the unique identifier of the Stream, generated by ZEGOCLOUD backend, developers do not need to pay attention. |
| title | String | Title, not exceeding 255 bytes. |
| stream_alias | String | Stream name, corresponds to the client's StreamID, not exceeding 255 bytes. |
| stream_attr | String | Stream information. Callback example:
|
| stream_seq | String | The seq of the server Stream list change, increments by 1 each time the Stream changes. |
| create_time | String | When the Stream is created, server current time, Unix timestamp, unit: seconds. |
| create_time_ms | String | When the Stream is created, server current time, Unix timestamp, unit: milliseconds. |
| extra_info | String | Stream additional information. |
| recreate | String | Whether to re-Publish stream.
Note If a network exception occurs and the SDK retry succeeds within 90 seconds, the server will continue to push the existing old Stream, recreate is 1. After 90 seconds, if the SDK retries, force kills the App to re-Publish stream, or ends Publishing stream / leaves the Room and re-Publishes, the server will push a new Stream, recreate is 0. |
| publish_id | String | Publisher ID, corresponds to the client's UserID, not exceeding 255 bytes. |
| publish_name | String | Publisher name, corresponds to the client's UserName, not exceeding 255 bytes. |
| rtmp_url | Array of String | RTMP Play stream URL, not exceeding 1024 bytes. |
| hls_url | Array of String | HLS Play stream URL, not exceeding 1024 bytes. |
| hdl_url | Array of String | HDL Play stream URL, not exceeding 1024 bytes. |
| pic_url | Array of String | CDN screenshot URL, not exceeding 255 bytes. |
It is recommended to convert some parameters to Int for logical processing. Related fields include create_time, create_time_ms, stream_seq, recreate, room_session_id.
Data example
{
"event": "stream_create",
"appid": "1",
"timestamp": "1687981272",
"nonce": "7254119327986670314",
"signature": "xxx",
"room_id": "room1",
"room_session_id": "1234567",
"user_id": "user1",
"user_name": "user1_name",
"channel_id": "0xb-0x1",
"stream_id": "stream_id",
"stream_sid": "s-115205136669740000000000104",
"title": "title",
"stream_alias": "aaa",
"stream_attr": "{\"cid\":0}",
"stream_seq": "01",
"create_time": "1687981272",
"create_time_ms": "1687981272742",
"extra_info": "extra",
"recreate": "0",
"publish_id": "publish",
"publish_name": "publish_name",
"rtmp_url": [
"rtmp://rtmp.wsdemo.zego.im/zegodemo/aaa",
"rtmp://testplay.aliyun.zego.im/livestream/aaa"
],
"hls_url": [
"http://hls.wsdemo.zego.im/zegodemo/aaa/playlist.m3u8",
"http://testplay.aliyun.zego.im/livestream/aaa.m3u8"
],
"hdl_url": [
"http://hdl.wsdemo.zego.im/zegodemo/aaa.flv",
"http://testplay.aliyun.zego.im/livestream/aaa.flv"
],
"pic_url": [
"http://pic.wsdemo.zego.im/zegodemo/aaa.jpg"
]
}Return response
Returning HTTP status code 2XX (e.g. 200) indicates success, other responses indicate failure.
Callback retry strategy
If ZEGOCLOUD server does not receive a response, or the received HTTP status code is not 2XX (e.g. 200), it will try to retry, up to 5 retries. The interval between each retry request and the previous request is 2s, 4s, 8s, 16s, 32s respectively. If the 5th retry still fails, no more retries will be made and the callback will be lost.
