Stream Mixing Started Callback
Description
When developers need to know the stream mixing status of the current App, they can first configure callbacks. When there is a stream mixing started on the stream mixing server of the App, a POST request will be made to the callback URL.
Callback instructions
- Request method: POST.
The callback data format is JSON. You need to perform UrlDecode decoding on it.
- Request URL: Please contact ZEGOCLOUD Technical Support to configure the callback URL.
- Transfer protocol: HTTPS/HTTP. HTTPS is recommended.
Callback parameters
| Parameter | Type | Description |
|---|---|---|
| appid | String | App identifier. |
| event | String | Callback event. This callback returns mix_start. |
| seq | String | Sequence number of the stream mixing request, ensuring the order in which stream mixing requests are executed, auto-incrementing and unique. |
| task_id | String | Stream mixing ID. If the task_id parameter is included in the stream mixing start request, ZEGO will add the appid prefix to form a new stream mixing ID. Otherwise, the stream mixing ID will be formed by splicing other parameters such as mix_url. |
| channel_id | String | Channel ID, corresponds to the client's RoomID, not exceeding 255 bytes. |
| publish_id | String | Publisher ID, corresponds to the client's UserID, not exceeding 255 bytes. |
| mix_url | String | The final output URL of the stream mixing, RTMP protocol URL, not exceeding 255 bytes. |
| mix_stream_alias | String | The final output stream name of the stream mixing, not exceeding 255 bytes. |
| rtmp_urls | Array | RTMP play URLs, not exceeding 1024 bytes. |
| hls_urls | Array | HLS play URLs, not exceeding 1024 bytes. |
| hdl_urls | Array | HDL play URLs, not exceeding 1024 bytes. |
| stream_alias | String | Stream name, corresponds to the client's StreamID, not exceeding 255 bytes. |
| timestamp | String | Server current time, Unix timestamp. |
| nonce | String | Random number. |
| signature | String | Verification string. For details, see Callback instructions - Verification instructions. |
It is recommended that you convert some parameters to Int for logical processing. Related fields include appid, seq, and timestamp.
Data example
{
"appid": "111111",
"channel_id": "2222",
"event": "mix_start",
"hdl_url": "http://hdl.wsdemo.zego.im/zegodemo/aaa.flv",
"hdl_urls": [
"http://hdl.wsdemo.zego.im/zegodemo/aaa.flv",
"http://testplay.aliyun.zego.im/livestream/aaa.flv"
],
"hls_url": "http://hls.wsdemo.zego.im/zegodemo/aaa/playlist.m3u8",
"hls_urls": [
"http://hls.wsdemo.zego.im/zegodemo/aaa/playlist.m3u8",
"http://testplay.aliyun.zego.im/livestream/aaa.m3u8"
],
"mix_stream_alias": "aaa",
"mix_url": "rtmp://rtmp.wsdemo.zego.im/zegodemo/aaa",
"nonce": "7257784982359218206",
"publish_id": "abc",
"rtmp_url": "rtmp://rtmp.wsdemo.zego.im/zegodemo/aaa",
"rtmp_urls": [
"rtmp://rtmp.wsdemo.zego.im/zegodemo/aaa",
"rtmp://testplay.aliyun.zego.im/livestream/aaa"
],
"seq": "123",
"signature": "aa2f0a33831a35b65f64fdc0520b1758e491eb48",
"stream_alias": "aaa",
"task_id": "111111:1111",
"timestamp": "1689834748"
}Return response
Return HTTP status code 2XX (e.g., 200) indicates success, and other responses indicate failure.
Callback retry strategy
If the ZEGO server does not receive a response, or the received HTTP status code is not 2XX (e.g., 200), it will attempt to retry, up to 5 retries. The interval between each retry request and the previous request is 2s, 4s, 8s, 16s, and 32s respectively. If the 5th retry still fails, no more retries will be made, and the callback will be lost.
