This topic describes how to configure callbacks for live stream recording and provides sample callbacks.

Callback configuration method

You can configure callbacks for live stream recording in the ApsaraVideo Live console or by calling an API operation.
  • For more information about how to configure callbacks for live stream recording in the ApsaraVideo Live console, see Configure recording callbacks.
  • For more information about how to configure callbacks for live stream recording by calling an API operation, see AddLiveRecordNotifyConfig.

Sample callbacks

The callbacks for live stream recording include recording status callbacks and recording generation callbacks.
  • Recording status callbacks: invoked when recording starts and ends. The callback message notifies you that recording starts or ends.
  • Recording generation callbacks: invoked when recordings are generated. The callback message contains the name, start time, end time, and duration of a recording.

The callback content in the JSON format is included in the request body of an HTTP POST request and sent to the callback URL. The callback URL is specified by the NotifyUrl parameter in the configurations of callbacks for live streaming recording. The receiver can parse the request body and obtain the callback content.

  • Recording status callbacks

    Note

    You can call an API operation to configure recording status callbacks. The callback content can be generated if the NeedStatusNotify parameter is set to true.

    The NeedStatusNotify parameter is an request parameter of the AddLiveRecordNotifyConfig operation. This parameter specifies whether to enable recording status callbacks.

    Table 1. Parameters
    Parameter Description
    domain The streaming domain.
    app The name of the application.
    stream The name of the live stream.
    event The name of the event. Valid values:
    • record_started: Recording is started.
    • record_paused: Recording is paused.
    • record_resumed: Recording is resumed.
    Sample callback for the start of recording:
    {
    "domain": "gs_domain",
    "app": "gs_app",
    "stream": "gs_stream",
    "event": "record_started"
    }
                        
  • Recording generation callbacks

    Table 2. Parameters
    Parameter Description
    domain The streaming domain.
    app The name of the application.
    stream The name of the live stream.
    uri The storage path of the recording in the specified Object Storage Service (OSS) bucket.
    duration The duration of the recording. Unit: seconds.
    start_time The start time of the recording. The time is a UNIX timestamp. Unit: seconds.
    stop_time The end time of the recording. The time is a UNIX timestamp. Unit: seconds.
    push_args The stream ingest parameters that are prefixed with callback_, such as callback_arg1 and callback_myid.
    Note
    • The sample callback is applicable if you have no custom callback templates.
    • Each parameter supports only one value. If you pass multiple values to a parameter, the callback returns only the first value that is passed to the parameter. For example, if you pass value1 and then value2 to the callback_args1 parameter, the callback returns only "callback_args1": "value1".
    Sample callback for the generation of a recording:
    {
      "domain": "demo.aliyundoc.com",
      "app": "liveApp****",
      "stream": "liveStream****",
      "uri": "liveApp****/liveStream****/0_2017-03-08-23:09:46_2017-03-08-23:10:40.flv",
      "duration": 69.403,
      "start_time": 1488985786,
      "stop_time": 1488985840,
      "push_args": {
        "callback_args1": "value1",
        "callback_myid": "1231389741"
      }
    }

References

For more information, see Manage callbacks.