Server APIs v2
  • Server APIs overview
  • Accessing Server APIs
  • Room signaling
  • Stream mixing
  • Streaming moderation
  • Streaming control
  • CDN recording
  • Server callbacks
  • Return codes
  • API testing
  • FAQ
  • Documentation
  • Server APIs v2
  • Server callbacks
  • Callback on stream mixing started

Callback on stream mixing started

Last updated:2022-03-22 13:07

1 Description

For your app server to receive callbacks from the ZEGO server, you need to set up server-to-server callbacks first.

When a stream mixing task on a stream mixing server starts, the stream mixing server notifies your app server by sending a POST request to the pre-configured callback endpoint.

2 Callback request

  • Request method: POST/FORM(Form values need to be decoded using urldecode
  • Request endpoint: the callback address provided by you, which is maintained in the ZEGO Admin Console.
  • Transmission protocol: HTTPS

3 Callback parameters

Parameter Type Description
appid
Uint
App identifier.
event
String
Event name. For this callback, the event name is "mix_start".
seq
Int
The sequence number of the stream mixing request, which guarantees the requests to be executed in the correct order. It increases by one each time.
task_id
String
Task ID of the stream mixing task. If you specify the task_id in the request that starts the stream mixing task, ZEGO adds your AppID as a prefix to the task_id to form a new task ID. If you don't specify the task_id in the request, ZEGO generates a task ID by concatenating other parameters, such as mix_url and others.
channel_id
String
Channel ID, with a maximum length of 255 bytes. It's equivalent to the Room ID on the client side.
publish_id
String
Publisher ID, with a maximum length of 255 bytes. It's equivalent to the User ID on the client side.
mix_url
String
The final output URL (for RTMP streaming), with a maximum length of 255 bytes.
mix_stream_alias
String
The final output stream ID, with a maximum length of 255 bytes.
rtmp_urls
Array
RTMP playback URL, with a maximum length of 1024 bytes.
hls_urls
Array
HLS playback URL, with a maximum length of 1024 bytes.
hdl_urls
Array
HDL playback URL, with a maximum length of 1024 bytes.
stream_alias
String
Stream ID of the output stream, with a maximum length of 255 bytes. It's equivalent to the StreamID on the client side.
timestamp
Int
The current time of the server, a Unix timestamp.
nonce
String
Random number.
signature
String
Signature string for authentication. For more details about the request signature, see Authenticating server-to-server callbacks.

4 Sample request data

Array
(
    [appid] => 111111
    [event]  => mix_start
    [seq]   => 1234
    [task_id] => aaa
    [channel_id] => 0xb-0x1
    [publish_id] => publish
    [mix_url] => mix_url
    [mix_stream_alias] => aaaa
    [rtmp_url] => Array
        (
            [0] => rtmp://rtmp.wsdemo.zego.im/zegodemo/aaa
            [1] => rtmp://testplay.aliyun.zego.im/livestream/aaa
        )

    [hls_url] => Array
        (
            [0] => http://hls.wsdemo.zego.im/zegodemo/aaa/playlist.m3u8
            [1] => http://testplay.aliyun.zego.im/livestream/aaa.m3u8
        )

    [hdl_url] => Array
        (
            [0] => http://hdl.wsdemo.zego.im/zegodemo/aaa.flv
            [1] => http://testplay.aliyun.zego.im/livestream/aaa.flv
        )
    [stream_alias] => aaaa
    [timestamp] => 1481597358
    [nonce] => 158273
    [signature] => signature
)

5 Response

1

The return value 1 indicates success; other values indicate failure.

Page Directory