View Source WebRTC Media Events

This document described all messages exchanged between the WebRTC Endpoint and a client. In general, each media event has to be sent in the form:

{
  type: name,
  data: data
}

where the name of the event is the value of the type field, while data should carry the data shown below for every media event

table-of-contents

Table of contents

Below you can find a summary of all media events defined inside membrane_rtc_engine

generic-webrtc-endpoint-messages

Generic WebRTC Endpoint messages

Messages used by any WebRTC Endpoint plugin

WebRTC Endpoint receives these types of media_events from client:

NameDescription
joinsent when peer join WebRTC Endpoint
leavesent when peer leaves WebRTC Endpoint
updatePeerMetadatacontains new metadata of a peer
updateTrackMetadatacontains new metadata of a track
custommessage forwarded to the endpoint associated with the peer

WebRTC Endpoint sends these types of messages to the client:

NameDescription
tracksPrioritycontains all tracks that will be forwarded to peer until next tracks_priority message
peerDeniedsent if peer was rejected by server when joining to server
peerUpdatedcontains new metadata of a peer
trackUpdatedcontains new metadata of a track
tracksAddedsent when some tracks were added by some peer
tracksRemovedsent when some tracks were removed by some peer
peerJoinedsent after a new peer has joined the WebRTC Endpoint
peerAcceptedsent to a peer after he joins the WebRTC Endpoint
peerLeftsent when some peer lefts the WebRTC Endpoint
peerRemovedsent when peer is forcibly removed by the server
errorNotifies about an error that occurred
customcustom message forwarded from endpoint to client

webrtc-custom-media-events

WebRTC custom media events

WebRTC endpoint receives these types of custom media_events from client:

NameDescription
renegotiateTracksA request from a peer to renegotiate tracks
prioritizeTrackA request to prioritize the track
unprioritizeTrackA request to unprioritize the track
preferedVideoSizesinforms of how many videos in different quality a peer wants to receive
candidateContains client's ICE candidate
sdpOfferContains an SDP offer from a client
setTargetTrackVariantA request from a peer to receive a specific track variant

WebRTC endpoint sends these type of custom messages to client

NameDescription
offerDataSends data needed by the client to create an offer
candidateContains an ICE candidate
sdpAnswerProvides an SDP Answer to the client's offer
encodingSwitchedAn information that a track will be sent with a specific encoding
vadNotificationAn update on Voice Activity Detection

client-webrtc-endpoint

Client -> WebRTC Endpoint

join

join

  • Sent when peer want to join WebRTC Endpoint. It contains only peer's metadata

    {
      "metadata": any
    }

leave

leave

  • Sent when peer leaves WebRTC Endpoint. It contains no data

    {}

updatepeermetadata

updatePeerMetadata

  • Contains new metadata of some peer

    {
      "metadata": any
    }

updatetrackmetadata

updateTrackMetadata

  • Contains new metadata of some track and an id of this track

    {
      "trackId": track_id,
      "trackMetadata": any
    }

custom

custom

  • A black-box for a message that WebRTC Endpoint will forward to the endpoint associated with the peer who sent the message.

    any

webrtc-endpoint-client

WebRTC Endpoint -> Client

trackspriority

tracksPriority

  • Contains all tracks that will be forwarded to peer until the next tracks_priority message. This type of messages is sent only if DisplayManager is spawned

    {
      tracks: tracks
    }

peerdenied

peerDenied

  • Sent if peer was rejected by server when joining to server. It may contain a reason for rejection.

    {
      data: text
    }

peerupdated

peerUpdated

  • Contains information about updated metadata of one of the peers

    {
      peerId: peer_id,
      metadata: any
    }

trackupdated

trackUpdated

  • Contains information about new metadata of one of tracks

    {
      peerId: peer_id,
      trackId: track_id,
      metadata: any
    }

tracksadded

tracksAdded

  • Informs that one of the peers has added one or more tracks. It contains an id of that peer and a map of all tracks with track_ids as keys and track_metadata as value.

    {
      peerId: peer_id,
      trackIdToMetadata: {
        track_id: any
      }
    }

tracksremoved

tracksRemoved

  • Contains a list of tracks which have been removed by some peer and id of that peer

    {
      peerId: peer_id,
      trackIds: track_ids
    }

peerjoined

peerJoined

  • Message sent to all peers in the room after a new peer has joined WebRTC Endpoint. It contains id and metadata of the new peer.

    {
      peer: {
        id: peer.id,
        metadata: peer.metadata
      }
    }

peeraccepted

peerAccepted

  • Message sent to the peer after he's joined the WebRTC Endpoint. It contains his id and a list of information about peers in the Engine (id, metadata and a trackIdToMetadata like seen in tracksAdded)

    {
      id: peer_id,
      peersInRoom: peers
    }

peerleft

peerLeft

  • Sent to all remaining peers in the room after some peer has left. It contains an id of the peer who left.

    {
      peerId: peer_id
    }

peerremoved

peerRemoved

  • Sent to the peer that has been forcibly removed by the server

    {
      peerId: peer_id,
      reason: any
    }

error

error

  • Informs that an error occurred on the server providing a message to show

    {
      message: any()
    }

custom-1

custom

  • WARNING!! This type of media event is deprecated - will soon be removed.

  • A black-box for a message that the WebRTC Endpoint will forward to the client.

    any

client-webrtc-enpoint

Client -> WebRTC Enpoint

renegotiatetracks

renegotiateTracks

  • Informs that a peer wants to renegotiate connection due to adding a track or removing a track

    {}

prioritizetrack

prioritizeTrack

  • Contains an id of the track that the peer wants to prioritize

    {
      trackId: trackId
    }

unprioritizetrack

unprioritizeTrack

  • Contains an id of the track that the peer want to unprioritize.

    {
      trackId: trackId
    }

preferedvideosizes

preferedVideoSizes

  • Contains information of how many videos in different quality (high, medium, small) the peer would like to receive. allSameSize flag which indicates that all videos should be in the same quality.

    {
      bigScreens: Int,
      mediumScreens: Int,
      smallScreens: Int,
      allSameSize: boolean
    }

candidate

candidate

  • Contains an ICE candidate that is forwarded to the WebRTC Endpoint

    {
      candidate: candidate,
      sdpMLineIndex: Int
    }

sdpoffer

sdpOffer

  • Contains an SDP offer, a mapping between track_id and track_metadata, and a mapping between mid and track_id. Both maps contain only information about current peer sendonly tracks.

    {
      sdpOffer: {
        type: "offer",
        sdp: sdp_offer
      },
      trackIdToTrackMetadata: {
        trackId: any
      }
      midToTrackId: mid_to_track_id
    }

settargettrackvariant

setTargetTrackVariant

  • Informs that a peer wants to receive a specific track variant. The track variant will be sent whenever it is available. If choosen variant is unavailable, some other variant will be sent until choosen variant becomes active again.

    {
      trackId => track_id,
      variant => variant
    }

webrtc-enpoint-client

WebRTC Enpoint -> Client

offerdata

offerData

  • Contains information about the number of audio and video tracks that will be sent from the engine to the peer and information regarding the integrated TURN server.

    {
      tracksTypes: {
        audio: Int,
        video: Int
      },
      integratedTurnServers: [{
        serverAddr: addr,
        serverPort: Int,
        transport: string,
        password: string,
        username: string
      }]
    }

candidate-1

candidate

  • Contains information about an ICE candidate which will be sent to the client

    {
      candidate: candidate,
      sdpMLineIndex: sdp_m_line_index,
      sdpMid: nil,
      usernameFragment: nil
    }

sdpanswer

sdpAnswer

  • Contains an SDP answer and mapping between mid and track_id for all tracks (active, inactive, inbound and outbound)

    {
      type: "answer",
      sdp: sdp_answer,
      midToTrackId: mid_to_track_id
    }

encodingswitched

encodingSwitched

  • Informs that track with id trackId belonging to peer with id peerId will be sent in encoding encoding now. The meaning is as follows:

  • "low_bandwidth" - we no longer have enough bandwidth to maintain current track quality

  • "encoding_inactive" - encoding became inactive

  • "other" - it was hard to determine exact reason of encoding switch

    {
      peerId: peer_id,
      trackId: track_id,
      encoding: encoding,
      reason: "low_bandwidth" | "encoding_inactive" | "other"
    }

vadnotification

vadNotification

  • Informs that the track denoted by trackId has changed their voice actiivty
  • For this notification to work, the server must be configured to use VAD extension and the sender must support it.
{
  trackId: track_id,
  status: "silence" | "speech"
}

bandwidthestimation

bandwidthEstimation

  • Informs about client's available incoming bitrate (a.k.a. download) estimated by the server. It is measured in bits per second.
  • For this notification to work, the server must be configured to use TWCC extension and the sender must support it.
{
  estimation: estimation,
}