Media Gateway event types

Updated

Event types returned by Media Gateway channel event callbacks.

After you enable the Agora message notification service, Agora sends channel event notifications to your server through HTTPS POST callbacks. When the callback request body contains product_id: 10, the event belongs to Media Gateway.

This page describes the Media Gateway event types returned in channel event callbacks.

live_stream_connected

The gateway has received the RTMP or SRT stream and successfully entered the channel.

{
  "sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
  "region": "na",
  "domain": "rtls-ingress-prod-na.agoramdn.com",
  "streamKey": "7B***Qbs",
  "rtcInfo": {
    "channel": "123",
    "uid": "1234"
  },
  "transcoding": {
    "audio": {
      "enabled": true,
      "profile": 5
    },
    "video": {
      "enabled": true,
      "bitrate": 3800,
      "fps": 30,
      "height": 1080,
      "width": 1920
    }
  },
  "beginAt": "2023-11-21T02:27:31Z"
}
FieldTypeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe streaming key used by the stream.
rtcInfoObjectRTC information, including channel and uid. When channel or uid is empty or 0 in the streaming key, this field stores the generated value used for this stream.
transcodingObjectTranscoding configuration information used for streaming.
beginAtStringThe streaming start time in RFC 3339 format.

This event is followed by a corresponding live_stream_disconnected event.

live_stream_disconnected

The gateway has actively or passively disconnected and left the channel.

{
  "sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
  "region": "na",
  "streamKey": "7B***Qbs",
  "domain": "rtls-ingress-prod-na.agoramdn.com:1935",
  "rtcInfo": {
    "channel": "123",
    "uid": "1234"
  },
  "streamStats": {
    "inputAudioBytes": 281799,
    "inputVideoBytes": 9244544,
    "outputAudioBytes": 130000,
    "outputVideoBytes": 6656704
  },
  "beginAt": "2023-11-21T02:27:31Z",
  "endAt": "2023-11-21T03:27:31Z"
}
FieldTypeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe streaming key used by the stream.
rtcInfoObjectRTC information, including channel and uid.
streamStatsObjectStream statistics, including inputAudioBytes, inputVideoBytes, outputAudioBytes, and outputVideoBytes.
beginAtStringThe streaming start time in RFC 3339 format.
endAtStringThe streaming end time in RFC 3339 format.

live_stream_aborted

The gateway has received an RTMP or SRT stream but terminated it for some reason. This event may be sent individually or between live_stream_connected and live_stream_disconnected.

{
  "sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
  "region": "na",
  "domain": "rtls-ingress-prod-na.agoramdn.com",
  "streamKey": "7B***Qbs",
  "rtcInfo": {
    "channel": "123",
    "uid": "1234"
  },
  "beginAt": "2023-11-21T02:27:31Z",
  "errorCode": 100,
  "reason": "invalid"
}
FieldTypeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
domainStringThe domain used for streaming.
streamKeyStringThe streaming key used by the stream.
rtcInfoObjectRTC information, including channel and uid.
beginAtStringThe streaming start time in RFC 3339 format.
errorCodeNumberThe stream termination error code.
reasonStringThe error message.
errorCodeDescriptionRecommended action
1Illegal streamKey, for example an empty channelName or unsupported characters.Check the streamKey format, especially for locally generated keys.
2Invalid streamKey, such as an expired or deleted key.Create a new streamKey and try again.
3No permission to use this streamKey, for example when the custom domain and app ID do not match.Check whether the streamKey matches the domain name used for the push.
4Number of concurrent streams exceeds the limit.Wait and retry.
5Conflict detected, for example pushing to the same channel at the same time.If the streams are not being pushed at the same time, try again after 5 to 10 seconds.
6Stream attribute exceeds the limit. Currently, this applies to bitrate only.Check the streaming software configuration and lower the target bitrate.
7Streaming without audio or video data for more than 10 seconds.Check whether the last push exited abnormally, and then try again.
8Failed to join the channel.The reason field provides the specific error reason, for example connect to rtc failed, reason:$N.
9Disconnected from the main network.Try again several times. If the problem persists, contact technical support to confirm whether the app certificate provided during activation is valid.
10Unknown internal service error.Try again several times. If the problem persists, contact technical support.

live_profile_updated

Stream properties have been updated. For example, the first audio or video frame has been received, or the audio or video profile has changed.

{
  "sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
  "region": "na",
  "domain": "rtls-ingress-prod-na.agoramdn.com",
  "streamKey": "7B***Qbs",
  "rtcInfo": {
    "channel": "123",
    "uid": "1234"
  },
  "videoProfile": {
    "codec": "H.264",
    "width": 1920,
    "height": 1080,
    "gop": 2000
  },
  "audioProfile": {
    "sampleRate": 48000,
    "channels": 2
  },
  "beginAt": "2023-11-21T02:27:31Z"
}
FieldTypeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe streaming key used by the stream.
rtcInfoObjectRTC information, including channel and uid.
videoProfileObjectVideo properties. Not applicable for audio-only streams. Includes codec, width, height, and gop.
audioProfileObjectAudio properties, including sampleRate and channels.
beginAtStringThe streaming start time in RFC 3339 format.