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:
- target
The object that emitted the event, or
Noneuntil 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, orNonewhen 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
icecandidateevent ofwebrtc.RTCPeerConnectionorwebrtc.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:
type (
str) – The name of the event.event_init_dict (
RTCPeerConnectionIceEventInit, optional) – The members of the event.
- candidate: webrtc.RTCIceCandidate | None
The gathered candidate, or
Nonewhen 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.RTCIceTransportdon’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
icecandidateerrorevent ofwebrtc.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:
type (
str) – The name of the event.event_init_dict (
RTCPeerConnectionIceErrorEventInit) – The members of the event.
- address: str | None
The local address the server was contacted from, or
Noneif it isn’t known. See MDN: RTCPeerConnectionIceErrorEvent/address.- Type:
str, optional
- port: int | None
The local port the server was contacted from, or
Noneif it isn’t known. See MDN: RTCPeerConnectionIceErrorEvent/port.- Type:
int, optional
- url: str
The URL of the server. See MDN: RTCPeerConnectionIceErrorEvent/url.
- Type:
- error_code: int
The STUN or TURN error code, or 701 if the server couldn’t be reached. See MDN: RTCPeerConnectionIceErrorEvent/errorCode.
- Type:
- error_text: str
The reason text of the server’s response. See MDN: RTCPeerConnectionIceErrorEvent/errorText.
- Type:
- class webrtc.models.events.MessageEvent(type, data)
A
messageevent ofwebrtc.RTCDataChannel, fired when a message is received.See MDN: MessageEvent.
- Parameters:
type (
str) – The name of the event.data (
str,bytesorwebrtc.Blob) – The message.
- data: str | bytes | webrtc.Blob
The message. It’s a
strif it was sent as text. Otherwise it’sbytes, or awebrtc.Blobwith theblobbinary type. See MDN: MessageEvent/data.- Type:
str,bytesorwebrtc.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
datachannelevent ofwebrtc.RTCPeerConnection, fired when the remote peer creates a channel.- Parameters:
type (
str) – The name of the event.event_init_dict (
RTCDataChannelEventInit) – The members of the event.
- channel: webrtc.RTCDataChannel
The channel the remote peer created. See MDN: RTCDataChannelEvent/channel.
- Type:
- 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
addtrackorremovetrackevent ofwebrtc.MediaStream.It’s fired when the remote peer changes the tracks of the stream.
See MDN: MediaStreamTrackEvent.
- Parameters:
type (
str) – The name of the event.event_init_dict (
MediaStreamTrackEventInit) – The members of the event.
- track: webrtc.MediaStreamTrack
The track added to or removed from the stream. See MDN: MediaStreamTrackEvent/track.
- Type:
- 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
tonechangeevent ofwebrtc.RTCDTMFSender, fired when a tone starts playing or the queue runs out.See MDN: RTCDTMFToneChangeEvent.
- Parameters:
type (
str) – The name of the event.event_init_dict (
RTCDTMFToneChangeEventInit, optional) – The members of the event.
- 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:
- class webrtc.models.events.DeviceChangeEventInit(devices=<factory>)
The members of a
DeviceChangeEvent.- Parameters:
devices (
listofwebrtc.MediaDeviceInfo, optional) – The devices after the change.
- class webrtc.models.events.DeviceChangeEvent(type, event_init_dict=None)
A
devicechangeevent ofwebrtc.MediaDevices.It’s never fired, because the devices of this library are fixed.
See MDN: MediaDevices/devicechange_event.
- Parameters:
type (
str) – The name of the event.event_init_dict (
DeviceChangeEventInit, optional) – The members of the event.
- devices: list[webrtc.MediaDeviceInfo]
The devices after the change.
- Type:
- user_inserted_devices: list[webrtc.MediaDeviceInfo]
The devices the user connected. It’s always empty.
- Type:
- 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
errorevent ofwebrtc.RTCDataChannelorwebrtc.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:
- class webrtc.models.events.RTCTrackEventInit(receiver, track, transceiver, streams=<factory>)
The members of an
RTCTrackEvent.See MDN: RTCTrackEvent/RTCTrackEvent.
- Parameters:
receiver (
webrtc.RTCRtpReceiver) – The receiver of the track.track (
webrtc.MediaStreamTrack) – The remote track.transceiver (
webrtc.RTCRtpTransceiver) – The transceiver of the receiver.streams (
listofwebrtc.MediaStream, optional) – The remote streams the track is in.
- class webrtc.models.events.RTCTrackEvent(type, event_init_dict)
A
trackevent ofwebrtc.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:
- track: webrtc.MediaStreamTrack
The remote track. See MDN: RTCTrackEvent/track.
- Type:
- streams: list[webrtc.MediaStream]
The remote streams the track is in. See MDN: RTCTrackEvent/streams.
- Type:
- transceiver: webrtc.RTCRtpTransceiver
The transceiver of the receiver. See MDN: RTCTrackEvent/transceiver.
- Type:
- class webrtc.models.events.RTCTransformEvent(type, transformer)
The
rtctransformevent the worker of awebrtc.RTCRtpScriptTransformis called with.The worker is a Python callable that runs on the event loop. There is no worker script.
- Parameters:
type (
str) – The name of the event.transformer (
webrtc.RTCRtpScriptTransformer) – The transformer of the transform.
- transformer: webrtc.RTCRtpScriptTransformer
The transformer, with the streams of frames to transform. See MDN: RTCTransformEvent/transformer.
- class webrtc.models.events.KeyFrameRequestEvent(type, rid=None)
A
keyframerequestevent ofwebrtc.RTCRtpScriptTransformer.It’s fired when the remote peer asks for a key frame.
- Parameters:
- class webrtc.models.events.SFrameTransformErrorEventInit(error_type, frame, key_id=None)
The members of an
SFrameTransformErrorEvent.- Parameters:
error_type (
webrtc.SFrameTransformErrorEventType) – Why the frame didn’t decrypt, as a member or its string value.frame (
webrtc.RTCEncodedVideoFrame,webrtc.RTCEncodedAudioFrameorbytes) – The frame that didn’t decrypt. For a buffer written to anwebrtc.SFrameDecryptorStream, it’s the chunk.key_id (
int, optional) – The unknown key id, for akeyIDerror.
- Raises:
ValueError – If the error type isn’t a member of
webrtc.SFrameTransformErrorEventType.
- class webrtc.models.events.SFrameTransformErrorEvent(type, event_init_dict)
An
errorevent of an SFrame decryptor, fired when a frame doesn’t decrypt and is dropped.It’s an event of
webrtc.RTCRtpSFrameDecryptorandwebrtc.SFrameDecryptorStream.- Parameters:
type (
str) – The name of the event.event_init_dict (
SFrameTransformErrorEventInit) – The members of the event.
- error_type: SFrameTransformErrorEventType
Why the frame didn’t decrypt.
- frame: webrtc.RTCEncodedVideoFrame | webrtc.RTCEncodedAudioFrame | bytes
The dropped frame. For a buffer written to an
webrtc.SFrameDecryptorStream, it’s the chunk.