opentera_webrtc.native_client

Classes

AudioSourceConfiguration

Represents a configuration of an audio source that can be added to a WebRTC call

DataChannelConfiguration

Represents a data channel configuration

SignalingServerConfiguration

Represents a signaling server configuration.

VideoSourceConfiguration

Represents a configuration of a video source that can be added to a WebRTC call.

VideoStreamCodec

Members:

VideoStreamConfiguration

Represents a video stream configuration

WebrtcConfiguration

Represents a WebRTC peer connection configuration.

Client

Represents a peer client.

RoomClient

IceServer

AudioSource

Represent a audio source that can be added to a WebRTC call.

VideoSource

Represents a video source that can be added to a WebRTC call.

WebrtcClient

DataChannelClient

Represents a client for data channel communication.

VideoCodecType

Members:

StreamClient

A signaling client to join a WebRTC room and stream a video source.

class AudioSourceConfiguration

Bases: pybind11_object

Represents a configuration of an audio source that can be added to a WebRTC call

property auto_gain_control

Indicates if the auto gain control is enabled.

Returns:

True if the auto gain control is enabled

static create(*args, **kwargs)

Overloaded function.

  1. create(sound_card_total_delay_ms: int) -> AudioSourceConfiguration

Creates an audio source configuration with default values.

Parameters:

sound_card_total_delay_ms – The sum of the playback and recording delays

Returns:

An audio source configuration with default values

  1. create(sound_card_total_delay_ms: int, echo_cancellation: Optional[bool], auto_gain_control: Optional[bool], noise_suppression: Optional[bool], highpass_filter: Optional[bool], stereo_swapping: Optional[bool], transient_suppression: Optional[bool]) -> AudioSourceConfiguration

Creates an audio source configuration with the specified values.

Parameters:
  • sound_card_total_delay_ms – The sum of the playback and recording delays

  • echo_cancellation – Enable or disable the echo cancellation

  • auto_gain_control – Enable or disable the auto gain control

  • noise_suppression – Enable or disable the noise suppression

  • highpass_filter – Enable or disable the highpass filter

  • stereo_swapping – Enable or disable the stereo swapping

  • transient_suppression – Enable or disable the transient suppression

Returns:

An audio source configuration with the specified values

property echo_cancellation

Indicates if the echo cancellation is enabled.

Returns:

True if the echo cancellation is enabled

property highpass_filter

Indicates if the highpass filter is enabled.

Returns:

True if the highpass filter is enabled

property noise_suppression

Indicates if the noise suppression is enabled.

Returns:

True if the noise suppression is enabled

property sound_card_total_delay_ms

Returns the sum of the playback and recording delays.

Returns:

The sum of the playback and recording delays

property stereo_swapping

Indicates if the stereo swapping is enabled.

Returns:

true if the stereo swapping is enabled

property transient_suppression

Indicates if the transient suppression is enabled.

Returns:

True if the transient suppression is enabled

class DataChannelConfiguration

Bases: pybind11_object

Represents a data channel configuration

static create(*args, **kwargs)

Overloaded function.

  1. create() -> DataChannelConfiguration

Creates a data channel configuration with default values.

Returns:

A data channel configuration with default values

  1. create(ordered: bool) -> DataChannelConfiguration

Creates a data channel configuration with the specified value.

Parameters:

ordered – Indicates if the message order must be preserved

Returns:

A data channel configuration with the specified value

  1. create(ordered: bool, protocol: str) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • ordered – Indicates if the message order must be preserved

  • protocol – The data channel protocol

Returns:

A data channel configuration with the specified values

static create_max_packet_life_time(*args, **kwargs)

Overloaded function.

  1. create_max_packet_life_time(max_packet_life_time: int) -> DataChannelConfiguration

Creates a data channel configuration with the specified value.

Parameters:

max_packet_life_time – Indicates the amount of time a message can be retransmitted (ms)

Returns:

A data channel configuration with the specified value

  1. create_max_packet_life_time(ordered: bool, max_packet_life_time: int) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • ordered – Indicates if the message order must be preserved

  • max_packet_life_time – Indicates the amount of time a message can be retransmitted (ms)

Returns:

A data channel configuration with the specified values

  1. create_max_packet_life_time(max_packet_life_time: int, protocol: str) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • max_packet_life_time – Indicates the amount of time a message can be retransmitted (ms)

  • protocol – The data channel protocol

Returns:

A data channel configuration with the specified values

  1. create_max_packet_life_time(ordered: bool, max_packet_life_time: int, protocol: str) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • ordered – Indicates if the message order must be preserved

  • max_packet_life_time – Indicates the amount of time a message can be retransmitted (ms)

  • protocol – The data channel protocol

Returns:

A data channel configuration with the specified values

static create_max_retransmits(*args, **kwargs)

Overloaded function.

  1. create_max_retransmits(max_retransmits: int) -> DataChannelConfiguration

Creates a data channel configuration with the specified value.

Parameters:

max_retransmits – Indicates the maximum number of time a message can be retransmitted

Returns:

A data channel configuration with the specified value

  1. create_max_retransmits(ordered: bool, max_retransmits: int) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • ordered – Indicates if the message order must be preserved

  • max_retransmits – Indicates the maximum number of time a message can be retransmitted

Returns:

A data channel configuration with the specified values

  1. create_max_retransmits(max_retransmits: int, protocol: str) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • max_retransmits – Indicates the maximum number of time a message can be retransmitted

  • protocol – The data channel protocol

Returns:

A data channel configuration with the specified values

  1. create_max_retransmits(ordered: bool, max_retransmits: int, protocol: str) -> DataChannelConfiguration

Creates a data channel configuration with the specified values.

Parameters:
  • ordered – Indicates if the message order must be preserved

  • max_retransmits – Indicates the maximum number of time a message can be retransmitted

  • protocol – The data channel protocol

Returns:

A data channel configuration with the specified values

static create_protocol(protocol: str) DataChannelConfiguration

Creates a data channel configuration with the specified value.

Parameters:

protocol – The data channel protocol

Returns:

A data channel configuration with the specified value

property max_packet_life_time

Returns the maximum number of time a message can be retransmitted.

Returns:

The maximum number of time a message can be retransmitted

property max_retransmits

Returns the maximum number of time a message can be retransmitted.

Returns:

The maximum number of time a message can be retransmitted

property ordered

Indicates if the message order must be preserved.

Returns:

True if the message order must be preserved

property protocol

Returns the data channel protocol.

Returns:

The data channel protocol

class SignalingServerConfiguration

Bases: pybind11_object

Represents a signaling server configuration.

property client_data

Returns the client data.

Returns:

The client data

property client_name

Returns the client name.

Returns:

The client name

static create(*args, **kwargs)

Overloaded function.

  1. create(url: str, client_name: str, room: str) -> SignalingServerConfiguration

Creates an signaling server configuration with the specified values.

Parameters:
  • url – The signaling server URL

  • client_name – The client name

  • room – The room name

Returns:

A signaling server configuration with the specified values

  1. create(url: str, client_name: str, room: str, password: str) -> SignalingServerConfiguration

Creates an signaling server configuration with the specified values.

Parameters:
  • url – The signaling server URL

  • client_name – The client name

  • room – The room name

  • password – The signaling server password

Returns:

A signaling server configuration with the specified values

static create_with_data(*args, **kwargs)

Overloaded function.

  1. create_with_data(url: str, client_name: str, client_data: object, room: str) -> SignalingServerConfiguration

Creates an signaling server configuration with the specified values.

Parameters:
  • url – The signaling server URL

  • client_name – The client name

  • client_data – The client data

  • room – The room name

Returns:

A signaling server configuration with the specified values

  1. create_with_data(url: str, client_name: str, client_data: object, room: str, password: str) -> SignalingServerConfiguration

Creates an signaling server configuration with the specified values.

Parameters:
  • url – The signaling server URL

  • client_name – The client name

  • client_data – The client data

  • room – The room name

  • password – The signaling server password

Returns:

A signaling server configuration with the specified values

property password

Returns the signaling server password.

Returns:

The signaling server password

property room

Returns the room name.

Returns:

The room name

property url

Returns the signaling server URL.

Returns:

The signaling server URL

class VideoSourceConfiguration

Bases: pybind11_object

Represents a configuration of a video source that can be added to a WebRTC call.

static create(needs_denoising: bool, is_screencast: bool) VideoSourceConfiguration

Creates a video source configuration with the specified values.

Parameters:
  • needs_denoising – Indicates if this source needs denoising

  • is_screencast – Indicates if this source is screencast

Returns:

A video source configuration with the specified values

property is_screencast

Indicates if this source is screencast.

Returns:

True if this source is a screencast

property needs_denoising

Indicates if this source needs denoising.

Returns:

True if this source needs denoising

class VideoStreamCodec

Bases: pybind11_object

Members:

VP8

VP9

H264

H264 = <VideoStreamCodec.H264: 2>
VP8 = <VideoStreamCodec.VP8: 0>
VP9 = <VideoStreamCodec.VP9: 1>
property name
property value
class VideoStreamConfiguration

Bases: pybind11_object

Represents a video stream configuration

static create(*args, **kwargs)

Overloaded function.

  1. create() -> VideoStreamConfiguration

Creates a stream configuration with default values.

Returns:

A stream configuration with default values

  1. create(forced_codecs: set[VideoStreamCodec]) -> VideoStreamConfiguration

Creates a video stream configuration with the specified value.

Parameters:

forced_codecs – Indicates the codecs that must be used. An empty set means all codecs.

Returns:

A video stream configuration with the specified value

  1. create(forced_codecs: set[VideoStreamCodec], force_gstreamer_hardware_acceleration: bool, use_gstreamer_software_encoder_decoder: bool) -> VideoStreamConfiguration

Creates a video stream configuration with the specified values.

Parameters:
  • forced_codecs – Indicates the codecs that must be used. An empty set means all codecs.

  • force_gstreamer_hardware_acceleration – Indicates that hardware accelerated codecs must be used. It has no effect when the library is not built with GStreamer.

  • use_gstreamer_software_encoder_decoder – Indicates to use GStreamer software codecs instead of WebRTC ones. It has no effect when the library is not built with GStreamer.

Returns:

A video stream configuration with the specified values

property force_gstreamer_hardware_acceleration

Indicates that hardware accelerated codecs must be used.

Returns:

True if only hardware accelerated codecs can be used.

property forced_codecs

Returns the codecs that must be used. An empty set means all codecs.

Returns:

The codecs that must be used

property use_gstreamer_software_encoder_decoder

Indicates to use GStreamer software codecs instead of WebRTC ones.

Returns:

True if GStreamer software codecs must be used instead of WebRTC ones

class WebrtcConfiguration

Bases: pybind11_object

Represents a WebRTC peer connection configuration.

static create(*args, **kwargs)

Overloaded function.

  1. create() -> WebrtcConfiguration

Creates a WebRTC peer connection configuration with default values.

Returns:

A WebRTC peer connection configuration with default values

  1. create(ice_servers: list[IceServer]) -> WebrtcConfiguration

Creates a WebRTC peer connection configuration with the specified value.

Parameters:

ice_servers – The ice servers

Returns:

A WebRTC peer connection configuration with the specified value

property ice_servers

Returns the ice servers.

Returns:

The ice servers

class Client

Bases: pybind11_object

Represents a peer client.

property data

Returns the client data.

Returns:

The client data

property id

Returns the client id.

Returns:

The client id

property name

Returns the client name.

Returns:

The client name

class RoomClient

Bases: pybind11_object

property data

Returns the client data.

Returns:

The client data

property id

Returns the client id.

Returns:

The client id

property is_connected

Indicates if the client is connected (RTCPeerConnection).

Returns:

True if the client is connected (RTCPeerConnection)

property name

Returns the client name.

Returns:

The client name

class IceServer

Bases: pybind11_object

property credential

Returns the ice server credential.

Returns:

The ice server credential

static fetch_from_server(*args, **kwargs)

Overloaded function.

  1. fetch_from_server(url: str, password: str) -> list[IceServer]

Fetches the ice servers from the signaling server.

Parameters:
  • url – The signaling server url

  • password – The signaling server username

Returns:

The fetched ice servers

  1. fetch_from_server(url: str, password: str, verify_certificate: bool) -> list[IceServer]

Fetches the ice servers from the signaling server.

Parameters:
  • url – The signaling server url

  • password – The signaling server username

  • verify_certificate – Indicates to verify the certificate or not

Returns:

The fetched ice servers

static from_json(json: str) list[IceServer]

Gets ice servers from a JSON

Parameters:

json – The JSON to parse

:return The parsed ice servers

property urls

Returns the ice server urls.

Returns:

The ice server urls

property username

Returns the ice server username.

Returns:

The ice server username

class AudioSource

Bases: pybind11_object

Represent a audio source that can be added to a WebRTC call.

Pass an instance of this to the StreamClient and call sendFrame for each of your audio frame.

send_frame(*args, **kwargs)

Overloaded function.

  1. send_frame(self: AudioSource, frame: numpy.ndarray[numpy.int8]) -> None

Send an audio frame

Parameters:

frame – The audio frame

  1. send_frame(self: AudioSource, frame: numpy.ndarray[numpy.int16]) -> None

Send an audio frame

Parameters:

frame – The audio frame

  1. send_frame(self: AudioSource, frame: numpy.ndarray[numpy.int32]) -> None

Send an audio frame

Parameters:

frame – The audio frame

  1. send_frame(self: AudioSource, frame: numpy.ndarray[numpy.int8], is_typing: bool) -> None

Parameters:

is_typing – Indicates if the frame contains typing sound.This is only useful with the typing detection option.

  1. send_frame(self: AudioSource, frame: numpy.ndarray[numpy.int16], is_typing: bool) -> None

Send an audio frame

Parameters:
  • frame – The audio frame

  • is_typing – Indicates if the frame contains typing sound.This is only useful with the typing detection option.

  1. send_frame(self: AudioSource, frame: numpy.ndarray[numpy.int32], is_typing: bool) -> None

Send an audio frame

Parameters:
  • frame – The audio frame

  • is_typing – Indicates if the frame contains typing sound.This is only useful with the typing detection option.

class VideoSource

Bases: pybind11_object

Represents a video source that can be added to a WebRTC call.

Pass an instance of this to the StreamClient and call sendFrame for each of your frame.

send_frame(self: VideoSource, bgr_img: numpy.ndarray[numpy.uint8], timestamp_us: int) None

Sends a frame to the WebRTC transport layer

The frame may or may not be sent depending of the transport layer state Frame will be resized to match the transport layer request

Parameters:
  • bgr_img – BGR8 encoded frame data

  • timestamp_us – Frame timestamp in microseconds

class WebrtcClient

Bases: pybind11_object

property call_acceptor

Sets the callback that is used to accept or reject a call.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client the call is from

Callback return value:
  • True to accept the call, False to reject the call

Parameters:

callback – The callback

call_all(self: WebrtcClient) None

Calls all room clients.

call_ids(self: WebrtcClient, ids: list[str]) None

Calls the specified clients.

close(self: WebrtcClient) None

Closes all client connections (asynchronous).

close_all_room_peer_connections(self: WebrtcClient) None

Closes all room peer connections.

close_sync(self: WebrtcClient) None

Closes all client connections (synchronous).

connect(self: WebrtcClient) None

Connects the client the signaling server.

property connected_room_client_ids

Returns the connected room client ids.

Returns:

The connected room client ids

get_room_client(self: WebrtcClient, id: str) RoomClient

Returns the room client that matches with the specified id. If no room client matches with the id, a default room client is returned.

Parameters:

id – The room client id

Returns:

The room client that matches with the specified id

hang_up_all(self: WebrtcClient) None

Hangs up all clients.

property id

Returns the client id.

Returns:

The client id

property is_connected

Indicates if the client is connected to the signaling server.

Returns:

True if the client is connected to the signaling server

property is_rtc_connected

Indicates if the client is connected to a least one client (RTCPeerConnection).

Returns:

True if the client is connected to a least one client (RTCPeerConnection)

property logger

Sets the callback that is used to log information.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • message: The message

Parameters:

callback – The callback

property on_call_rejected

Sets the callback that is called when a call is rejected.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client that rejects the call

Parameters:

callback – The callback

property on_client_connected

Sets the callback that is called when a client peer connection opens.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client that is connected

Parameters:

callback – The callback

property on_client_connection_failed

Sets the callback that is called when a client peer connection fails.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client that has a connection failure

Parameters:

callback – The callback

property on_client_disconnected

Sets the callback that is called when a client peer connection closes.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client that is disconnected

Parameters:

callback – The callback

property on_error

Sets the callback that is called when an error occurs.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • error: The error message

Parameters:

callback – The callback

property on_room_clients_changed

Sets the callback that is called when the room client changes.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • room_clients: The room clients

Parameters:

callback – The callback

property on_signaling_connection_closed

Sets the callback that is called when the signaling connection closes.

The callback is called from the internal client thread. The callback should not block.

Parameters:

callback – The callback

property on_signaling_connection_error

Sets the callback that is called when a signaling connection error occurs.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • error: The error message

Parameters:

callback – The callback

property on_signaling_connection_opened

Sets the callback that is called when the signaling connection opens.

The callback is called from the internal client thread. The callback should not block.

Parameters:

callback – The callback

property room_clients

Returns the room clients

Returns:

The room clients

property tls_verification_enabled

Enable or disable the TLS verification. By default, the TLS verification is enabled.

Param:

is_enabled

class DataChannelClient

Bases: WebrtcClient

Represents a client for data channel communication.

property on_data_channel_closed

Sets the callback that is called when a data channel closes.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the data channel that closes

Parameters:

callback – The callback

property on_data_channel_error

Sets the callback that is called when a data channel error occurs.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the data channel error

  • error: The error message

Parameters:

callback – The callback

property on_data_channel_message_binary

Sets the callback that is called when binary data are received.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client the binary data are from

  • bytes: The binary data

Parameters:

callback – The callback

property on_data_channel_message_string

Sets the callback that is called when a string message is received.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client the binary data is from

  • message: The string message

Parameters:

callback – The callback

property on_data_channel_opened

Sets the callback that is called when a data channel opens.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the data channel that opens

Parameters:

callback – The callback

send_to(*args, **kwargs)

Overloaded function.

  1. send_to(self: DataChannelClient, bytes: bytes, ids: list[str]) -> None

Sends binary data to the specified clients.

Parameters:
  • bytes – The binary data

  • ids – The client ids

  1. send_to(self: DataChannelClient, message: str, ids: list[str]) -> bool

Sends a string message to the specified clients.

Parameters:
  • message – The string message

  • ids – The client ids

send_to_all(*args, **kwargs)

Overloaded function.

  1. send_to_all(self: DataChannelClient, bytes: bytes) -> None

Sends binary data to all clients.

Parameters:

bytes – The binary data (bytes)

  1. send_to_all(self: DataChannelClient, message: str) -> bool

Sends a string message to all clients.

Parameters:

message – The string message

class VideoCodecType

Bases: pybind11_object

Members:

GENERIC

VP8

VP9

AV1

H264

MULTIPLEX

AV1 = <VideoCodecType.AV1: 3>
GENERIC = <VideoCodecType.GENERIC: 0>
H264 = <VideoCodecType.H264: 4>
MULTIPLEX = <VideoCodecType.MULTIPLEX: 5>
VP8 = <VideoCodecType.VP8: 1>
VP9 = <VideoCodecType.VP9: 2>
property name
property value
class StreamClient

Bases: WebrtcClient

A signaling client to join a WebRTC room and stream a video source.

property is_local_audio_muted

Indicates if the local audio is muted.

property is_local_video_muted

Indicates if the local video is muted.

property is_remote_audio_muted

Indicates if the remote audio is muted.

mute_local_audio(self: StreamClient) None

Mutes the local audio.

mute_local_video(self: StreamClient) None

Mutes the local video.

mute_remote_audio(self: StreamClient) None

Mutes the remote audio.

property on_add_remote_stream

Sets the callback that is called when a stream is added.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the stream

Parameters:

callback – The callback

property on_audio_frame_received

Sets the callback that is called when an audio stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • client: The client of the stream frame

  • audio_data: The audio data (numpy.array[int8], numpy.array[int16] or numpy.array[int32])

  • sample_rate: The audio stream sample rate

  • number_of_channels: The audio stream channel count

  • number_of_frames: The number of frames

Parameters:

callback – The callback

property on_encoded_video_frame_received

Sets the callback that is called when an encoded video stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • client: The client of the stream frame

  • data: The binary data (bytes)

  • codec_type: The codec type

  • is_key_frame: Indicates if it is a key frame

  • width: The frame width if it is a key frame

  • height: The frame height if it is a key frame

  • timestamp_us The timestamp in microseconds

Parameters:

callback – The callback

property on_mixed_audio_frame_received

Sets the callback that is called when a mixed audio stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • audio_data: The audio data (numpy.array[int8], numpy.array[int16] or numpy.array[int32])

  • sample_rate: The audio stream sample rate

  • number_of_channels: The audio stream channel count

  • number_of_frames: The number of frames

Parameters:

callback – The callback

property on_remove_remote_stream

Sets the callback that is called when a stream is removed.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the stream

Parameters:

callback – The callback

property on_video_frame_received

Sets the callback that is called when a video stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • client: The client of the stream frame

  • bgr_img: The BGR frame image (numpy.array[uint8])

  • timestamp_us The timestamp in microseconds

Parameters:

callback – The callback

unmute_local_audio(self: StreamClient) None

Unmutes the local audio.

unmute_local_video(self: StreamClient) None

Unmutes the local video.

unmute_remote_audio(self: StreamClient) None

Unmutes the remote audio.