Documentation
Server_APIs_v2 Server APIs v2
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Server APIs v2
  • Server callbacks
  • Callback on stream created

Callback on stream created

Last updated:2023-04-17 18:27

1 Description

With the related callback setup in place, the ZEGOCLOUD server will send an event notification to the pre-configured server callback URL when your application client starts publishing a stream to the ZEGOCLOUD server. You can use this callback to maintain a list of live streams on your application server.

2 Callback request

  • Request method: POST
    The callback data format is JSON, and you need to perform UrlDecode decoding on it.
  • Request endpoint: The corresponding callback endpoint in the ZEGOCLOUD Admin Console. (Click here to learn how to config the callback endpoint)
  • Transmission protocol: HTTPS/HTTP (HTTPS is recommended).

3 Request parameters

Parameter Type Description
stream_sid
String
The stream's server-side ID, the unique ID of the stream generated by the ZEGO server.
channel_id
String
Channel ID, with a maximum length of 127 bytes. Same as the RoomID on the client side.
title
String
Stream title, with a maximum length of 255 bytes.
stream_alias
String
Stream name, with a maximum length of 255 bytes. Same as the StreamID on the client side.
publish_id
String
Publisher ID, with a maximum length of 255 bytes. Same as the UserID of the stream publisher on the client side.
publish_name
String
Publisher name, with a maximum length of 255 bytes. Same as the UserName of the stream publisher on the client side.
rtmp_url
Array
RTMP playback URL, with a maximum length of 1024 bytes.
hls_url
Array
HLS playback URL, with a maximum length of 1024 bytes.
hdl_url
Array
HDL playback URL, with a maximum length of 1024 bytes.
pic_url
Array
Stream snapshot URL, with a maximum length of 255 bytes.
create_time
String
Creation time,a Unix timestamp.
timestamp
String
The server's current time, a Unix timestamp.
nonce
String
A random number.
signature
String
The signature for request authentication. For more details about the request signature, see Authenticating server-to-server callbacks.
extra_info
String
Extra information.
appid
String
Application ID.
event
String
Event name. For this callback, the event name is "stream_create".
stream_id
String
Stream ID, same as the parameter stream_alias.
stream_seq
String
The sequence number of server stream list updates, with an increment of 1 for each update.
room_id
String
Room ID, with a maximum length of 127 bytes. Same as the parameter channel_id.
recreate
String
Republishing indicator.
  • 1: It's a republishing of a stream that already exists on the server.
  • 0: It's a new stream.
user_id
String
User ID, with a maximum length of 255 bytes. Same as the parameter publish_id.
user_name
String
User name, with a maximum length of 255 bytes. Same as the parameter publish_name.

4 Sample request

Array
(
    [stream_sid] => s-115205137699740000000000104
    [channel_id] => 0xb-0x1
    [stream_alias] => aaaa
    [title] => tile
    [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
        )

    [pic_url] => Array
        (
            [0] => http://pic.wsdemo.zego.im/zegodemo/aaa.jpg
        )

    [publish_id] => publish
    [publish_name] => name
    [create_time] => 1481597358
    [timestamp] => 1481597358
    [nonce] => 158273
    [signature] => signature
    [extra_info] => "extra"
    [appid] => 1
    [event] => stream_create
)

5 Sample response

1

A response "1" means that the request has completed successfully. Other responses indicate a failed request.

6 Retry mechanism

If the ZEGOCLOUD server does not receive a response, or the HTTP status code received by the ZEGOCLOUD server is not 2xx (such as 200), it will retry with intervals of 2s, 4s, 8s, 16s, and 32s respectively. If the retry still fails after an interval of 32s, it will no longer retry.

Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code