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

Stream Created Callback


Warning

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

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 parametersTypeDescription
eventStringCallback event, this callback returns stream_create.
appidStringAppId.
timestampStringServer current time when the server callbacks to the customer after the Stream is created, Unix timestamp.
nonceStringRandom number.
signatureStringVerification string, please refer to Callback instructions - Verification instructions.
Business parametersTypeDescription
room_idStringRoom ID, corresponds to the client's RoomID, has the same meaning as channel_id, not exceeding 127 bytes.
room_session_idStringUnique identifier of the Room lifecycle, remains unchanged during the entire lifecycle of the Room.
user_idStringUser ID, has the same meaning as publish_id, not exceeding 255 bytes.
user_nameStringUser nickname, has the same meaning as publish_name, not exceeding 255 bytes.
channel_idStringChannel ID, corresponds to the client's RoomID, not exceeding 127 bytes.
stream_idStringStream ID, corresponds to the client's StreamID, has the same meaning as stream_alias.
stream_sidStringStream server ID, the unique identifier of the Stream, generated by ZEGOCLOUD backend, developers do not need to pay attention.
titleStringTitle, not exceeding 255 bytes.
stream_aliasStringStream name, corresponds to the client's StreamID, not exceeding 255 bytes.
stream_attrString

Stream information. Callback example: {\"cid\":0}, where cid represents the encoding ID of the Stream, values are as follows:

  • 0: H.264.
  • 1: H.264 Scalable Video Coding.
  • 2: VP8 encoding.
  • 3: H.265.
stream_seqStringThe seq of the server Stream list change, increments by 1 each time the Stream changes.
create_timeStringWhen the Stream is created, server current time, Unix timestamp, unit: seconds.
create_time_msStringWhen the Stream is created, server current time, Unix timestamp, unit: milliseconds.
extra_infoStringStream additional information.
recreateString

Whether to re-Publish stream.

  • 1: Indicates that the client re-Published a Stream that already exists on the server.
  • 0: Indicates a new 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_idStringPublisher ID, corresponds to the client's UserID, not exceeding 255 bytes.
publish_nameStringPublisher name, corresponds to the client's UserName, not exceeding 255 bytes.
rtmp_urlArray of StringRTMP Play stream URL, not exceeding 1024 bytes.
hls_urlArray of StringHLS Play stream URL, not exceeding 1024 bytes.
hdl_urlArray of StringHDL Play stream URL, not exceeding 1024 bytes.
pic_urlArray of StringCDN screenshot URL, not exceeding 255 bytes.
Note

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.

Previous

User Logged out Callback

Next

Stream Destroyed Callback

On this page

Back to top