All Products
Search
Document Center

ApsaraVideo Live:Configure callback settings

Last Updated:Aug 29, 2024

ApsaraVideo Live provides callbacks for stream ingest status, live stream recording, live stream snapshot, and content moderation. This topic describes how to configure these callbacks in the ApsaraVideo Live console.

Usage notes

ApsaraVideo Live supports event notifications by using HTTP and HTTPS callbacks. You must deploy an HTTP service to receive callback messages and configure a callback URL by using the ApsaraVideo Live console or calling an API operation.

  • When stream ingest is initiated or interrupted, ApsaraVideo Live sends an HTTP GET request to the specified callback URL. The specific event content is included in the URL parameters.

  • When other events are triggered, ApsaraVideo Live sends an HTTP POST request to the specified callback URL. The specific event content is included in the JSON-formatted request body.

Scenarios

When an event is triggered during live streaming, Alibaba Cloud sends a request to your server and your server then responds to the request. After the request passes verification, a callback message that contains JSON-formatted data is returned to you.

ApsaraVideo Live supports callbacks for events such as stream ingest status, live stream recording (on-demand recording), live stream snapshot, and content moderation (video moderation and audio moderation). For information about the callback parameters and examples for different callback events, see Manage callbacks.

Limits

  • A callback URL requires no identifier but must be accessible. If no response is returned from the URL within a specific timeout period, ApsaraVideo Live performs retries to access the URL. The current timeout period is 5 seconds. If no response is returned within 5 seconds, ApsaraVideo Live performs retries to access the URL for a maximum of five times at an interval of 1 second.

  • You can configure and modify stream ingest callbacks for only ingest domains. You can configure and modify recording callbacks, snapshot callbacks, video moderation callbacks, and audio moderation callbacks for only streaming domains.

Feature description

Callbacks are divided into stream ingest callbacks and streaming callbacks.

Procedure

  1. Log on to the ApsaraVideo Live console.
  2. In the left-side navigation pane, choose Feature Management > Callbacks. The Callbacks page appears.

  3. Select the ingest domain or streaming domain that you want to configure. An ingest domain supports stream ingest callbacks, while a streaming domain supports recording callbacks, snapshot callbacks, video moderation callbacks, and audio moderation callbacks.

  4. On the Callback Settings tab, configure the callbacks.image

  5. For an ingest domain

    Stream ingest callbacks

    Note

    You can also call the SetLiveStreamsNotifyUrlConfig operation to configure stream ingest callbacks. For more information, see SetLiveStreamsNotifyUrlConfig. For information about the callback methods and parameters, see Callbacks for stream ingest status.

    1. Turn on Stream Ingest Callbacks.

    2. Configure callback parameters.

      Parameter

      Description

      Callback URL

      The callback URL is a URL of your own. When a stream is ingested or interrupted, ApsaraVideo Live sends an HTTP GET request to this URL. The specific content is delivered by using URL parameters.

      Callback Authentication

      Specifies whether to enable authentication for the callback URL. To enable authentication, turn on the switch and specify Authentication Key.

    3. Click OK.

    For a streaming domain

    • Recording callbacks

      Note

      You can also call the AddLiveRecordNotifyConfig operation to configure recording callbacks for a domain name. For more information, see AddLiveRecordNotifyConfig. For information about the callback methods and parameters, see Callbacks for live stream recording.

      1. Turn on Recording Callbacks.

      2. Configure callback parameters.

        Parameter

        Description

        Callback URL

        The callback URL is a URL of your own. When a recording event occurs, ApsaraVideo Live sends an HTTP POST request to this URL. The specific content is delivered by using a JSON body.

        Triggering Event

        • File Generation: A callback is fired when a recording file is generated.

        • File Generation and Recording Status: A callback is fired when a recording file is generated or when recording starts, pauses, or resumes.

        On-demand Callback URL

        If on-demand recording is configured, ApsaraVideo Live sends an HTTP callback to the specified on-demand callback URL when you start to ingest a live stream. The response to the callback determines whether to record the live stream. By default, the value of this parameter is *, which specifies that on-demand recording is disabled.

        Note

        Before you specify an on-demand callback URL, you need to call the AddLiveAppRecordConfig operation to configure a recording rule. In the rule, the OnDemand parameter is set to 1, which indicates that on-demand recording is enabled by using the HTTP callback method.

      3. Click OK.

    • Snapshot callbacks

      Note

      You can also call the AddLiveSnapshotNotifyConfig operation to configure snapshot callbacks for a domain name. For more information, see AddLiveSnapshotNotifyConfig. For information about the callback methods and parameters, see Callbacks for live stream snapshot.

      1. Turn on Snapshot Callbacks.

      2. Configure callback parameters.

        Parameter

        Description

        Callback URL

        The callback URL is a URL of your own. When a snapshot event occurs, ApsaraVideo Live sends an HTTP POST request to this URL. The specific content is delivered by using a JSON body.

        Callback Authentication

        Specifies whether to enable authentication for the callback URL. To enable authentication, turn on the switch and specify Authentication Key.

    • Video moderation callbacks

      Note
      • You can also call the AddLiveDetectNotifyConfig operation to configure video moderation callbacks. For more information, see AddLiveDetectNotifyConfig. For information about the callback methods and parameters, see Callbacks for content moderation.

      • Only some live centers support the content moderation feature. For more information, see Supported regions.

      • Video moderation callback notifications are returned for only videos that are in question. The notification content includes the moderation information and storage information of relevant video snapshots. You can view the callback information on your callback server. For more information about the format and examples of the callback information, see Callbacks for content moderation.

      • Search for the identified violations in OSS. You can search for specific violations in the OSS console based on the moderation callback information.

        • Search for specific violations based on the application name and stream name.

        • Search for specific violations based on the stream ingest date.

      1. Turn on Video Moderation Callbacks.

      2. Specify the callback URL.

        The callback URL is a URL of your own. When a video moderation event occurs, ApsaraVideo Live sends an HTTP POST request to this URL. The specific content is delivered by using a JSON body.

      3. Click OK.

    • Audio moderation callbacks

      Note
      • You can also call the AddLiveAudioAuditNotifyConfig operation to configure audio moderation callbacks. For more information, see AddLiveAudioAuditNotifyConfig. For information about the callback methods and parameters, see Callbacks for content moderation.

      • Audio moderation callback notifications are returned for only audio that is in question. The notification content includes the text information of the audio and the context in the last 1 minute. You can view the callback information on your callback server. For more information about the format and examples of the callback information, see Callbacks for content moderation.

      • Search for the identified violations in OSS. You can search for specific violations in the OSS console based on the moderation callback information.

        • Search for specific violations based on the application name and stream name.

        • Search for specific violations based on the stream ingest date.

      1. Turn on Audio Moderation Callbacks.

      2. Specify the callback URL.

        The callback URL is a URL of your own. When an audio moderation event occurs, ApsaraVideo Live sends an HTTP POST request to this URL. The specific content is delivered by using a JSON body.

      3. Click OK.

Stream ingest callback logic

Callback logic for stream ingest status:

  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. For example, you have Ingest Domain A and Streaming Domain B. You can 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, ApsaraVideo Live uses the same callback logic as that for stream ingest status to send callback notifications about the stream pulling status under Streaming Domain B. By default, ApsaraVideo Live sends a callback notification about successful stream pulling if the stream pulling client does not close the connection within 2 seconds after the connection is established. In this case, live streaming data is received.

Note

We recommend that you deliver the streaming URL only after you determine that the stream ingest or pulling is successful based on callback notifications and the list of active streams.

Callback authentication

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, the ALI-LIVE-TIMESTAMP and ALI-LIVE-SIGNATURE fields are included in the HTTP(S) request header. The callback message receiving server authenticates and signs the fields. 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.