logo
Voice Call
Server API
Stream Mixing and Transcoding APIs
On this page

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.
Note

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

ParameterTypeDescription
appidStringApp identifier.
eventStringCallback event. This callback returns mix_start.
seqStringSequence number of the stream mixing request, ensuring the order in which stream mixing requests are executed, auto-incrementing and unique.
task_idStringStream 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_idStringChannel ID, corresponds to the client's RoomID, not exceeding 255 bytes.
publish_idStringPublisher ID, corresponds to the client's UserID, not exceeding 255 bytes.
mix_urlStringThe final output URL of the stream mixing, RTMP protocol URL, not exceeding 255 bytes.
mix_stream_aliasStringThe final output stream name of the stream mixing, not exceeding 255 bytes.
rtmp_urlsArrayRTMP play URLs, not exceeding 1024 bytes.
hls_urlsArrayHLS play URLs, not exceeding 1024 bytes.
hdl_urlsArrayHDL play URLs, not exceeding 1024 bytes.
stream_aliasStringStream name, corresponds to the client's StreamID, not exceeding 255 bytes.
timestampStringServer current time, Unix timestamp.
nonceStringRandom number.
signatureStringVerification string. For details, see Callback instructions - Verification instructions.
Note

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.

Previous

Stream Destroyed Callback

Next

Stream Mixing Stopped Callback

On this page

Back to top