Zum Hauptinhalt springen

Media

Overview

The media module is responsible for establishing WebRTC sessions between the client and SFU used by OpenTalk. SFU stands for Selective Forwarding Unit and is the redistributor of the media published by each participant.

"Publishing media" means to transmit video and audio to OpenTalk via a WebRTC sendonly session. Depending on the use-case the media module allows for 2 different kinds of publishing sessions:

  • video: (Lower bitrate) Usually low resolution and higher framerate video used for Webcams or similar with more motion
  • screen: (Higher bitrate) Usually high resolution and low framerate ideal for screen share/presentations with text which must be readable

"Subscribing" to a peer in a conference means to receive video and audio via a WebRTC recvonly session. The published media of another participant is stored within the module-specific data in the Participant.

The notion of presenter is used to communicate screen share permissions.

Joining the room

JoinSuccess

When joining a room, the join_success control event contains the module-specific fields described below.

Fields

FieldTypeAlwaysDescription
is_presenterboolyesRepresents if the current participant has permissions for screen share
speakers(ParticipantSpeakingState[])(#ParticipantSpeakingState)yesThe list of current or previous speakers in the meeting
force_muteForceMuteStateyesThe current force mute state
Example
{
"is_presenter": true,
"speakers": [
{
"participant": "6802d547-06ff-493a-bcce-da7f3bc37248",
"is_speaking": false,
"updated_at": "2023-01-13T12:29:01Z"
},
{
"participant": "0605e657-27b8-443e-81de-31d5921e9a42",
"is_speaking": true,
"updated_at": "2023-01-13T12:37:42Z"
},
{
"participant": "69068e53-eb60-4c1d-bfc1-fc31a0dc45a3",
"is_speaking": false,
"updated_at": "2023-01-13T12:22:08Z"
}
],
"force_mute": {
"type": "enabled",
"allow_list": [
"07d32d3e-9510-49bf-82b7-e21fef9db120"
]
}
}

Joined

When joining a room, the joined control event sent to all other participants contains the module-specific fields described below.

Fields

FieldTypeAlwaysDescription
stateParticipantMediaStatenoAn object describing the current availability of media and their current mute status
is_presenterboolyesRepresents if the other participant has permissions for screen share

ParticipantMediaState:

This object represents the available media sessions and encapsulates their mute state.

FieldTypeAlwaysDescription
videoMediaSessionStatenoIf this field is set, the participant is publishing a video, usually a webcam (lower resolution, higher framerate)
screenMediaSessionStatenoIf this field is set, the participant is publishing their screen (usually high resolution, low framerate)
Example

This example shows a participant's state when publishing only their screen without audio enabled.

{
"state": {
"screen": {
"video": true,
"audio": false
}
},
"is_presenter": true
}

Commands

Publish

Create a WebRTC publish session by sending an SDP offer.

Response

A SdpAnswer will return an SDP response.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "publish"
sdpstringyesSDP Offer as a string
targetstringyesSee Target
media_session_typeenumyesSee Target
Example
{
"action": "publish",
"sdp": "v=0,....",
"target": "07d32d3e-9510-49bf-82b7-e21fef9db120",
"media_session_type": "video"
}

PublishComplete

Signal that the WebRTC publish process is complete and set the initial mute status. Other participants will be notified by an Update that the media is now available to be subscribed to and if the audio or video track is muted. If the force-mute state is enabled, the media_session_state.video.audio field must be set to false unless the participant is included in the allow_list.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "publish_complete"
media_session_typeenumyesEither "video" or "screen"
media_session_stateMediaSessionStateyes
Example
{
"action": "publish_complete",
"media_session_type": "video",
"media_session_state": {
"video": {
"video": true,
"audio": false
}
}
}

Unpublish

Remove/stop an existing WebRTC publish session. The WebRTC session will instantly be stopped (if not already) by the SFU when sending this command. Other participants will be notified by an Update that the published media is no longer available.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "unpublish"
media_session_typeenumyesEither "video" or "screen"
Example
{
"action": "unpublish",
"media_session_type": "video"
}

Subscribe

Request an SDP offer for the specified target (a peer participant's published media).

Response

A SdpOffer will return an SDP offer to which the client must respond to with an SdpAnswer.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "subscribe"
targetstringyesSee Target
media_session_typeenumyesSee Target
without_videoboolnoCan be used to opt out of the video stream for the entire WebRTC session
Example
{
"action": "subscribe",
"target": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video",
"without_video": true
}

Resubscribe

Request for a WebRTC subscribe session to be restarted, this will restart the complete negotiation process.

Response

A SdpOffer will return an SDP offer to which the client must respond to with an SdpAnswer.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "resubscribe"
targetstringyesSee Target
media_session_typeenumyesSee Target
Example
{
"action": "resubscribe",
"target": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

SdpAnswer

Complete the initial SDP negotiation of a subscription by sending an SDP answer. The SFU will begin the WebRTC/ICE handshake and notify later via an WebrtcUp if the establishment was successful from it's side.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "sdp_answer"
sdpstringyesSDP Answer as a string
targetstringyesSee Target
media_session_typeenumyesSee Target
Example
{
"action": "sdp_answer",
"sdp": "v=0,...",
"target": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

SdpCandidate

Exchange a ICE trickle candidate with a establishing WebRTC session. This is part of the WebRTC establishment and is forwarded to the SFU.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "sdp_candidate"
candidateTrickleCandidateyesCandidate to send
targetstringyesSee Target
media_session_typeenumyesSee Target
Example
{
"action": "sdp_candidate",
"candidate": {
"sdpMLineIndex": 0,
"candidate": "candidate:..."
},
"target": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

SdpEndOfCandidates

Signal the establishing WebRTC session that there are no more ICE trickle candidates. This is part of the WebRTC establishment and is forwarded to the SFU.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "sdp_end_of_candidates"
targetstringyesSee Target
media_session_typeenumyesSee Target
Example
{
"action": "sdp_end_of_candidates",
"target": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

UpdateMediaSession

Update the mute state for a WebRTC publish session. This information is forwarded to all other participants using inside an Update. If the force-mute state is enabled, the field media_session_state.audio must be set to false unless the participant is included in the allow_list.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "update_media_session"
media_session_typeenumyesEither "video" or "screen"
media_session_stateMediaSessionStateyesThe new state for the session
Example
{
"action": "update_media_session",
"media_session_type": "video",
"media_session_state": {
"video": {
"audio": true,
"video": true,
},
"screen": null
}
}

Configure

Configure a WebRTC subscribe session. The request is forwarded to the SFU which configured the media streams appropriately.

This is used to adjust the quality of a video stream to save on bandwidth.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "configure"
configurationSubscriberConfigurationyes
targetstringyesSee Target
media_session_typeenumyesSee Target

SubscriberConfiguration:

FieldTypeRequiredDescription
videoboolnoIf video transmission should be enabled. This option should be used to turn off videos of participants which are out of view
substreamintnoSelect a different substream if any are available. Substreams are usually the same video with difference in bitrate/quality, where 0 is usually the lowest quality. This options should be used to lower the quality of participants that are displayed in a smaller window.
Example
{
"action": "configure",
"configuration": {
"video": true,
"substream": 0
},
"target": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video",
}

GrantPresenterRole

Grant one or more participants the right to show their screen

Fields

FieldTypeRequiredDescription
actionenumyesMust be "grant_presenter_role"
participant_idsstring[]yesList of participant ids to grant the presenter role
Example
{
"action": "grant_presenter_role",
"participant_ids": [
"84a2c872-94fb-4b41-aca7-13d784c92a72",
"2375602f-c74c-4935-9933-bfd67d4e8ae5"
]
}

RevokePresenterRole

Revoke one or more participants the right to show their screen

Fields

FieldTypeRequiredDescription
actionenumyesMust be "revoke_presenter_role"
participant_idsstring[]yesList of participant ids to revoke their presenter role
Example
{
"action": "revoke_presenter_role",
"participant_ids": [
"84a2c872-94fb-4b41-aca7-13d784c92a72",
"2375602f-c74c-4935-9933-bfd67d4e8ae5"
]
}

ModeratorMute

Request another participant to mute their microphone.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "moderator_mute"
targetsstring or string[]noId of one or more participants to request to be muted. If missing, all participants except the sender of this message will be muted.
forceboolyesWe're not asking you to mute, we're telling!
Example

Mute specific participants:

{
"action": "moderator_mute",
"targets": [
"84a2c872-94fb-4b41-aca7-13d784c92a72",
"2375602f-c74c-4935-9933-bfd67d4e8ae5"
],
"force": true
}

Mute all participants in the room except themselves:

{
"action": "moderator_mute",
"force": true
}

ModeratorEnableForceMute

Enables the force mute state which mutes all participants and disallows enabling the microphone except for participants included in the allow_list.

Fields

FieldTypeRequiredDescription
actionenumyesMust be moderator_enable_force_mute
allow_liststring[]yesThe list of participants that are still allowed to unmute

Example

{
"action": "moderator_enable_force_mute",
"allow_list": [
"84a2c872-94fb-4b41-aca7-13d784c92a72",
"2375602f-c74c-4935-9933-bfd67d4e8ae5"
]
}

ModeratorDisableForceMute

Disables the force-mute state and allows participants to enable their microphones again.

Fields

FieldTypeRequiredDescription
actionenumyesMust be moderator_disable_force_mute

Example

{
"action": "moderator_disable_force_mute"
}

UpdateSpeakingState

Update the client's speaking state. This should be sent to the service by the client when it detects either start or end of a speaking period.

After receiving this message, the service sends out a SpeakerUpdated event to all participants, including the one that changed their state.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "update_speaking_state"
is_speakingboolyesThe flag indicating whether the client states that the participant is currently speaking
Example
{
"action": "update_speaking_state",
"is_speaking": true
}

Events

SdpAnswer

Provides an SDP answer string in response to a Publish command.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "sdp_answer"
sdpstringyesSDP Answer in a string
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "sdp_answer",
"sdp": "v=0,...",
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

SdpOffer

Returns an SDP offer string in response to a Subscribe command.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "sdp_offer"
sdpstringyesSDP Answer in a string
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "sdp_offer",
"sdp": "v=0,...",
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

SdpCandidate

Receive an SDP candidate for the specified WebRTC session.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "sdp_candidate"
candidateTrickleCandidateyes
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "sdp_candidate",
"candidate": {
"sdpMLineIndex": 0,
"candidate": "candidate:..."
},
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

SdpEndOfCandidates

Receive an SDP end-of-candidates signal for the specified WebRTC session.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "sdp_end_of_candidates"
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "sdp_end_of_candidates",
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

WebrtcUp

The SFU reports that the specified WebRTC session has been established.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "webrtc_up"
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "webrtc_up",
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

WebrtcDown

The SFU reports that the specified WebRTC session has broken down.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "webrtc_down"
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "webrtc_down",
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

WebrtcSlow

The SFU reports problems sending/receiving data for the specified WebRTC session

Fields

FieldTypeAlwaysDescription
messageenumyesIs "webrtc_slow"
directionenumyesEither upstream or downstream
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "webrtc_slow",
"direction": "upstream",
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

MediaStatus

The SFU reports an update in the current status of the specified WebRTC session

Fields

FieldTypeAlwaysDescription
messageenumyesIs "media_status"
kindstringyesThe kind of media, so usually either video, audio but might also be application data if the WebRTC sessions are used for that
receivingboolyesReports the status of the media being received, if false the SFU reports that it no longer receives any data.
sourcestringyesSee Source
media_session_typeenumyesSee Source
Example
{
"message": "media_status",
"kind": "audio",
"receiving": true,
"source": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"media_session_type": "video"
}

PresenterGranted

Presenter rights have been granted to the current participant. This message is sent to the affected participants

Fields

FieldTypeAlwaysDescription
messageenumyesIs "presenter_granted"
Example
{
"message": "presenter_granted",
}

PresenterRoleGranted

Presenter rights have been granted to the specified participants. This message is sent to the participant who has executed the grant_presenter_rolecommand

Fields

FieldTypeAlwaysDescription
messageenumyesIs "presenter_role_granted"
participant_idsstring[]yesList of participant ids to grant the presenter role to
Example
{
"message": "presenter_role_granted",
"participant_ids": [
"84a2c872-94fb-4b41-aca7-13d784c92a72",
"2375602f-c74c-4935-9933-bfd67d4e8ae5"
]
}

PresenterRevoked

Presenter rights have been revoked from the current participant. This message is sent to the affected participants

Fields

FieldTypeAlwaysDescription
messageenumyesIs "presenter_revoked"
Example
{
"message": "presenter_revoked",
}

PresenterRoleRevoked

Presenter rights have been revoked from the specified participants. This message is sent to the participant who has executed the revoke_presenter_rolecommand

Fields

FieldTypeAlwaysDescription
messageenumyesIs "presenter_role_revoked"
participant_idsstring[]yesList of participant ids to revoke the presenter role from
Example
{
"message": "presenter_role_revoked",
"participant_ids": [
"84a2c872-94fb-4b41-aca7-13d784c92a72",
"2375602f-c74c-4935-9933-bfd67d4e8ae5"
]
}

RequestMute

You are being asked to mute yourself.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "request_mute"
issuerstringyesId of the participant which asked you to mute yourself
forceboolyesClients should automatically mute when this is set to true
Example
{
"message": "request_mute",
"issuer": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"force": true
}

ForceMuteEnabled

The force-mute state was enabled. Only the participants listed in allow_list are allowed to enable their microphones.

FieldTypeAlwaysDescription
messageenumyesIs "force_mute_enabled"
allow_liststring[]yesList of participants that are still allowed to unmute

ForceMuteDisabled

The force-mute state was disabled. All participants are allowed to enabled their microphones.

FieldTypeAlwaysDescription
messageenumyesIs "force_mute_disabled"

SpeakerUpdated

The speaking state of a participant has been updated because they started or stopped speaking.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "speaker_updated"
participantstringyesId of the participant whose speaking state changed
is_speakingboolyesThe flag indicating whether the client states that the participant is currently speaking
updated_atstringyesTimestamp of the last change of is_speaking for this participant
Example
{
"message": "speaker_updated",
"participant": "84a2c872-94fb-4b41-aca7-13d784c92a72",
"is_speaking": true,
"updated_at": "2023-01-13T12:37:08Z"
}

Error

Something went wrong

Fields

FieldTypeAlwaysDescription
messageenumyesIs "error"
errorenumyesAny of the codes specified below
sourcestringif error is "invalid_request_offer" or "invalid_configure_request"See Source
media_session_typeenumif error is "invalid_request_offer" or "invalid_configure_request"See Source

Error codes:

  • "invalid_sdp_offer"

  • "handle_sdp_answer"

  • "invalid_candidate"

  • "invalid_end_of_candidates"

  • "invalid_request_offer"

  • "invalid_configure_request"

  • "permission_denied": The requester didn't meet the required permissions for the request

Example
{
"message": "error",
"error": "invalid_sdp_offer"
}

Common Types

Source

FieldTypeAlwaysDescription
sourcestringyesParticipantID describing the source WebRTC session of the event. If the WebRTC session is publishing media, the participants own id is used
media_session_typeenumyesEither "video" or "screen"

Target

FieldTypeRequiredDescription
targetstringyesParticipantID describing the target WebRTC session of the command. If the WebRTC session is publishing media, the participants own id must be used
media_session_typeenumyesEither "video" or "screen"

MediaSessionState

This object represent the current mute status of a media session.

FieldTypeAlwaysDescription
videoboolyesVideo is enabled (unmuted)
audioboolyesAudio is enabled (unmuted)

ParticipantSpeakingState

FieldTypeRequiredDescription
participantstringyesThe id of the participant
is_speakingboolyesA flag indicating whether the participant is currently speaking
updated_atstringyesTimestamp of the last change of is_speaking for this participant

TrickleCandidate

FieldTypeRequiredDescription
sdpMLineIndexintyesMDN web docs reference
candidatestringyesMDN web docs reference

ForceMuteState

FieldTypeRequiredDescription
typeenumyesEither enabled if the force-mute state is enabled, otherwise disabled
allow_liststring[]noIf type is enabled, the allow_list contains the list of participants that are still allowed to unmute