Event objects

The event objects that webrtc.EventTarget handlers are called with, and their init dictionaries.

class webrtc.models.events.Event(type)

An event of a WebRTC object. Events that carry nothing but their name are of this class.

See MDN: Event.

Parameters:

type (str) – The name of the event, like 'signalingstatechange'.

type

The name of the event. See MDN: Event/type.

Type:

str

target

The object that emitted the event, or None until it’s dispatched. See MDN: Event/target.

Type:

webrtc.EventTarget, optional

class webrtc.models.events.RTCPeerConnectionIceEventInit(candidate=None, url=None)

The members of an RTCPeerConnectionIceEvent.

See MDN: RTCPeerConnectionIceEvent/RTCPeerConnectionIceEvent.

Parameters:
  • candidate (webrtc.RTCIceCandidate, optional) – The gathered candidate, or None when gathering has ended.

  • url (str, optional) – The address of the STUN or TURN server that found the candidate.

class webrtc.models.events.RTCPeerConnectionIceEvent(type, event_init_dict=None)

An icecandidate event of webrtc.RTCPeerConnection or webrtc.RTCIceTransport.

It’s fired when a candidate is gathered and should be sent to the remote peer. The last event has no candidate and marks the end of gathering.

See MDN: RTCPeerConnectionIceEvent.

Parameters:
candidate: webrtc.RTCIceCandidate | None

The gathered candidate, or None when gathering has ended. See MDN: RTCPeerConnectionIceEvent/candidate.

Type:

webrtc.RTCIceCandidate, optional

url: str | None

The address of the STUN or TURN server that found the candidate. Events of an webrtc.RTCIceTransport don’t set it. See MDN: RTCPeerConnectionIceEvent/url.

Type:

str, optional

class webrtc.models.events.RTCPeerConnectionIceErrorEventInit(error_code, address=None, port=None, url='', error_text='')

The members of an RTCPeerConnectionIceErrorEvent.

See MDN: RTCPeerConnectionIceErrorEvent/RTCPeerConnectionIceErrorEvent.

Parameters:
  • error_code (int) – The STUN or TURN error code, or 701 if the server couldn’t be reached.

  • address (str, optional) – The local address the server was contacted from.

  • port (int, optional) – The local port the server was contacted from.

  • url (str, optional) – The URL of the server.

  • error_text (str, optional) – The reason text of the server’s response.

class webrtc.models.events.RTCPeerConnectionIceErrorEvent(type, event_init_dict)

An icecandidateerror event of webrtc.RTCPeerConnection.

It’s fired when gathering from a STUN or TURN server fails. Gathering goes on with the other servers and interfaces.

See MDN: RTCPeerConnectionIceErrorEvent.

Parameters:
address: str | None

The local address the server was contacted from, or None if it isn’t known. See MDN: RTCPeerConnectionIceErrorEvent/address.

Type:

str, optional

port: int | None

The local port the server was contacted from, or None if it isn’t known. See MDN: RTCPeerConnectionIceErrorEvent/port.

Type:

int, optional

url: str

The URL of the server. See MDN: RTCPeerConnectionIceErrorEvent/url.

Type:

str

error_code: int

The STUN or TURN error code, or 701 if the server couldn’t be reached. See MDN: RTCPeerConnectionIceErrorEvent/errorCode.

Type:

int

error_text: str

The reason text of the server’s response. See MDN: RTCPeerConnectionIceErrorEvent/errorText.

Type:

str

class webrtc.models.events.MessageEvent(type, data)

A message event of webrtc.RTCDataChannel, fired when a message is received.

See MDN: MessageEvent.

Parameters:
data: str | bytes | webrtc.Blob

The message. It’s a str if it was sent as text. Otherwise it’s bytes, or a webrtc.Blob with the blob binary type. See MDN: MessageEvent/data.

Type:

str, bytes or webrtc.Blob

class webrtc.models.events.RTCDataChannelEventInit(channel)

The members of an RTCDataChannelEvent.

See MDN: RTCDataChannelEvent/RTCDataChannelEvent.

Parameters:

channel (webrtc.RTCDataChannel) – The channel the remote peer created.

class webrtc.models.events.RTCDataChannelEvent(type, event_init_dict)

A datachannel event of webrtc.RTCPeerConnection, fired when the remote peer creates a channel.

See MDN: RTCDataChannelEvent.

Parameters:
channel: webrtc.RTCDataChannel

The channel the remote peer created. See MDN: RTCDataChannelEvent/channel.

Type:

webrtc.RTCDataChannel

class webrtc.models.events.MediaStreamTrackEventInit(track)

The members of a MediaStreamTrackEvent.

See MDN: MediaStreamTrackEvent/MediaStreamTrackEvent.

Parameters:

track (webrtc.MediaStreamTrack) – The track added to or removed from the stream.

class webrtc.models.events.MediaStreamTrackEvent(type, event_init_dict)

An addtrack or removetrack event of webrtc.MediaStream.

It’s fired when the remote peer changes the tracks of the stream.

See MDN: MediaStreamTrackEvent.

Parameters:
track: webrtc.MediaStreamTrack

The track added to or removed from the stream. See MDN: MediaStreamTrackEvent/track.

Type:

webrtc.MediaStreamTrack

class webrtc.models.events.RTCDTMFToneChangeEventInit(tone='')

The members of an RTCDTMFToneChangeEvent.

See MDN: RTCDTMFToneChangeEvent/RTCDTMFToneChangeEvent.

Parameters:

tone (str, optional) – The tone that started playing, or empty when the queue ran out.

class webrtc.models.events.RTCDTMFToneChangeEvent(type, event_init_dict=None)

A tonechange event of webrtc.RTCDTMFSender, fired when a tone starts playing or the queue runs out.

See MDN: RTCDTMFToneChangeEvent.

Parameters:
tone: str

The tone that started playing, like '1', or ',' for a pause. It’s empty when the queue ran out. See MDN: RTCDTMFToneChangeEvent/tone.

Type:

str

class webrtc.models.events.DeviceChangeEventInit(devices=<factory>)

The members of a DeviceChangeEvent.

Parameters:

devices (list of webrtc.MediaDeviceInfo, optional) – The devices after the change.

class webrtc.models.events.DeviceChangeEvent(type, event_init_dict=None)

A devicechange event of webrtc.MediaDevices.

It’s never fired, because the devices of this library are fixed.

See MDN: MediaDevices/devicechange_event.

Parameters:
devices: list[webrtc.MediaDeviceInfo]

The devices after the change.

Type:

list of webrtc.MediaDeviceInfo

user_inserted_devices: list[webrtc.MediaDeviceInfo]

The devices the user connected. It’s always empty.

Type:

list of webrtc.MediaDeviceInfo

class webrtc.models.events.RTCErrorEventInit(error)

The members of an RTCErrorEvent.

See MDN: RTCErrorEvent/RTCErrorEvent.

Parameters:

error (webrtc.RTCError) – The error that occurred.

class webrtc.models.events.RTCErrorEvent(type, event_init_dict)

An error event of webrtc.RTCDataChannel or webrtc.RTCDtlsTransport.

See MDN: RTCErrorEvent.

Parameters:
  • type (str) – The name of the event.

  • event_init_dict (RTCErrorEventInit) – The members of the event.

error: webrtc.RTCError

The error that occurred, with its detail. See MDN: RTCErrorEvent/error.

Type:

webrtc.RTCError

class webrtc.models.events.RTCTrackEventInit(receiver, track, transceiver, streams=<factory>)

The members of an RTCTrackEvent.

See MDN: RTCTrackEvent/RTCTrackEvent.

Parameters:
class webrtc.models.events.RTCTrackEvent(type, event_init_dict)

A track event of webrtc.RTCPeerConnection, fired when a remote description adds a track to receive.

See MDN: RTCTrackEvent.

Parameters:
  • type (str) – The name of the event.

  • event_init_dict (RTCTrackEventInit) – The members of the event.

receiver: webrtc.RTCRtpReceiver

The receiver of the track. See MDN: RTCTrackEvent/receiver.

Type:

webrtc.RTCRtpReceiver

track: webrtc.MediaStreamTrack

The remote track. See MDN: RTCTrackEvent/track.

Type:

webrtc.MediaStreamTrack

streams: list[webrtc.MediaStream]

The remote streams the track is in. See MDN: RTCTrackEvent/streams.

Type:

list of webrtc.MediaStream

transceiver: webrtc.RTCRtpTransceiver

The transceiver of the receiver. See MDN: RTCTrackEvent/transceiver.

Type:

webrtc.RTCRtpTransceiver

class webrtc.models.events.RTCTransformEvent(type, transformer)

The rtctransform event the worker of a webrtc.RTCRtpScriptTransform is called with.

The worker is a Python callable that runs on the event loop. There is no worker script.

See MDN: RTCTransformEvent.

Parameters:
transformer: webrtc.RTCRtpScriptTransformer

The transformer, with the streams of frames to transform. See MDN: RTCTransformEvent/transformer.

Type:

webrtc.RTCRtpScriptTransformer

class webrtc.models.events.KeyFrameRequestEvent(type, rid=None)

A keyframerequest event of webrtc.RTCRtpScriptTransformer.

It’s fired when the remote peer asks for a key frame.

Parameters:
  • type (str) – The name of the event.

  • rid (str, optional) – The rid of the layer the key frame is asked for, or None for any layer.

rid: str | None

The rid of the layer the key frame is asked for, or None for any layer.

Type:

str, optional

class webrtc.models.events.SFrameTransformErrorEventInit(error_type, frame, key_id=None)

The members of an SFrameTransformErrorEvent.

Parameters:
Raises:

ValueError – If the error type isn’t a member of webrtc.SFrameTransformErrorEventType.

class webrtc.models.events.SFrameTransformErrorEvent(type, event_init_dict)

An error event of an SFrame decryptor, fired when a frame doesn’t decrypt and is dropped.

It’s an event of webrtc.RTCRtpSFrameDecryptor and webrtc.SFrameDecryptorStream.

Parameters:
error_type: SFrameTransformErrorEventType

Why the frame didn’t decrypt.

Type:

webrtc.SFrameTransformErrorEventType

key_id: int | None

The unknown key id for a keyID error, or None otherwise.

Type:

int, optional

frame: webrtc.RTCEncodedVideoFrame | webrtc.RTCEncodedAudioFrame | bytes

The dropped frame. For a buffer written to an webrtc.SFrameDecryptorStream, it’s the chunk.

Type:

webrtc.RTCEncodedVideoFrame, webrtc.RTCEncodedAudioFrame or bytes