All Products
Search
Document Center

ApsaraVideo Live:Format of stream ingest callbacks

Last Updated:Jan 08, 2025

If you configure callbacks for stream ingest status, you can receive callback notifications about successful or interrupted stream ingest in a timely manner.

How it works

ApsaraVideo Live sends an HTTP GET request to your server to notify you of the successful or interrupted stream ingest in real time. The server then responds with the HTTP status code 200, which indicates that the callback is successful.

Usage notes

  • A callback URL requires no identifier but must be accessible. The URL response complies with the following requirements:

    If access to the callback URL times out, ApsaraVideo Live retries to access the URL. The timeout period is 5 seconds. ApsaraVideo Live performs up to five retries at intervals of 1 second.

  • Callback logic

    1. During stream ingest over Real-Time Messaging Protocol (RTMP), ApsaraVideo Live checks whether the stream ingest client closes the connection within 2 seconds after ApsaraVideo Live receives an OnPublish message. If the stream ingest client does not close the connection, ApsaraVideo Live sends a callback notification about the successful stream ingest.

    2. Assume that you have Ingest Domain A and Streaming Domain B that are associated with each other, and you configure regular stream pulling and triggered stream pulling for Streaming Domain B. If you want to receive callback notifications about the stream pulling status, configure stream ingest callbacks for Ingest Domain A. After the configuration, the same callback logic as the preceding applies to stream pulling under Streaming Domain B. By default, stream pulling is considered successful if the client does not close the connection within 2 seconds.

    Note
    • We recommend that you issue the streaming URL after you confirm that the stream ingest or pulling is successful based on callback notifications and the response to your call of the DescribeLiveStreamsOnlineList operation.

    • ApsaraVideo Live automatically terminates stream ingest when no streaming data is pushed to the live center for 10 seconds.

  • Stream ingest callback logic

    By default, authentication for stream ingest callbacks is disabled. You can enable the feature when you specify the stream ingest callback URL. After you enable the feature, the following authentication logic applies:

    1. When ApsaraVideo Live initiates a callback request, it includes the ALI-LIVE-TIMESTAMP and ALI-LIVE-SIGNATURE headers in the HTTP or HTTPS request so that the callback message receiving server can authenticate the signature. The value of ALI-LIVE-SIGNATURE is calculated based on the following formula:

      ALI-LIVE-SIGNATURE = MD5SUM (MD5CONTENT)

      MD5CONTENT = Domain name|ALI-LIVE-TIMESTAMP value|Cryptographic key

      Note

      Domain name is the ingest domain for which you configure the callback URL. Cryptographic key is the cryptographic key that you specify for the callback URL.

    2. After receiving a callback message, the callback message receiving server concatenates the domain name of the callback, value of the ALI-LIVE-TIMESTAMP header, and cryptographic key in the preceding format. The server calculates the MD5 value of the string to obtain an encrypted string. Then, the server compares the encrypted string with the value of the ALI-LIVE-SIGNATURE header in the HTTP or HTTPS request initiated by ApsaraVideo Live. If the two values are different, the request is invalid.

Example

Sample callback:

http://1.1.1.1?action=publish&ip=192.168.XX.XX&id=world&app=example.aliyundoc.com&appname=liveApp****&time=1609220385&usrargs={Custom parameters}&
node=cdnvideocenter01020711****.cm3&height=720&width=1280

Parameter

Description

action

The event. Valid values:

  • publish: stream ingest

  • publish_done: stream interruption

ip

The IP address of the stream ingest client.

id

The name of the ingested stream.

app

The ingest domain. The default value is a custom ingest domain. If no ingest domain is available, a streaming domain is used.

appname

The name of the application that ingests the stream.

time

The UNIX timestamp. Unit: seconds.

usrargs

The custom parameters that are used to ingest the stream.

node

The name of the CDN point of presence (POP) or the host that receives the stream.

height

The height of the resolution. Unit: pixels.

Note

The height and width of the resolution are returned only when the callback is invoked for the first time.

width

The width of the resolution. Unit: pixels.