Skip to main content

reactor-webrtc (Python)

Python bindings for the reactor-webrtc WebRTC engine, built with PyO3 and distributed as a self-contained wheel — no separate native library required at runtime.

Installation

pip install reactor-webrtc

Requires Python ≥ 3.10.

Quick start

import reactor_webrtc as rw

factory = rw.PeerConnectionFactory()

obs = rw.PeerConnectionObserver()
obs.on_ice_candidate = lambda c: relay_to_peer(c)
obs.on_connection_state_change = lambda s: print("state:", s)

config = rw.RtcConfiguration(ice_servers=[
    rw.IceServer(urls=["stun:stun.l.google.com:19302"])
])
pc = factory.create_peer_connection(config, obs)

offer = pc.create_offer()
pc.set_local_description(offer)

# Exchange offer.sdp with the remote peer via your signaling channel, then:
# pc.set_remote_description(remote_answer)
# pc.add_ice_candidate(candidate)

Audio

# Headless / server: push PCM programmatically (synthetic ADM, default)
factory = rw.PeerConnectionFactory()
factory.push_audio_frame(pcm_bytes, sample_rate=48000, channels=1)

# Desktop client: real mic + AEC3 + noise suppression
factory = rw.PeerConnectionFactory(
    platform_adm=True,
    echo_canceller=True,
    noise_suppression=True,
)

Pre-encoded video

factory, video = rw.PeerConnectionFactory.with_encoded_video_track(
    "camera", width=1280, height=720
)
pc = factory.create_peer_connection(config, obs)
tx = video.add_transceiver(pc, rw.TransceiverDirection.SendOnly)

# From your encoder thread:
video.push_encoded_frame(
    data=h264_annex_b,
    is_key_frame=True,
    width=1280, height=720,
)

Receiving media

obs = rw.PeerConnectionObserver()

def on_track(kind, track):
    if kind == rw.MediaKind.Video:
        track.on_video_frame(lambda bgra, w, h: display(bgra, w, h))
    elif kind == rw.MediaKind.Audio:
        track.on_audio_frame(lambda pcm, sr, ch, n: play(pcm))

obs.on_track = on_track

Stats

report = pc.get_stats()
for pair in report.candidate_pairs:
    print(pair.state, f"{pair.current_round_trip_time_s * 1000:.1f}ms")

API reference

Class Description
PeerConnectionFactory Entry point; creates peer connections and tracks
PeerConnection SDP offer/answer, ICE, tracks, data channels, stats
PeerConnectionObserver Callbacks: state, ICE candidate, track, data channel
RtcConfiguration ICE servers + transport policy
IceServer A STUN or TURN server entry
IceCandidate A trickled ICE candidate
SessionDescription SDP offer or answer (kind, sdp)
Track Local (push frames) or remote (attach sink) media track
EncodedVideoTrack Push pre-encoded video (H.264 Annex-B, VP8, VP9, …)
Transceiver RTP m-section: mid, kind, set_track, set_direction
DataChannel SCTP data channel: send, on_message, on_open, …
StatsReport inbound_rtp, outbound_rtp, candidate_pairs
Enum Values
PeerConnectionState New, Connecting, Connected, Disconnected, Failed, Closed
IceGatheringState New, Gathering, Complete
TransceiverDirection SendRecv, SendOnly, RecvOnly, Inactive
MediaKind Audio, Video
DataChannelState Connecting, Open, Closing, Closed
IceCandidatePairState Waiting, InProgress, Failed, Succeeded, Cancelled

Thread safety

Signaling methods (create_offer, set_local_description, etc.) block for a few milliseconds while the WebRTC engine responds. Wrap in asyncio.to_thread() when calling from an async context. Callbacks fire on WebRTC internal threads with the GIL acquired; keep them fast.

License

Apache-2.0. Upstream WebRTC is BSD-3-Clause + the WebRTC patent grant.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

reactor_webrtc-0.1.0-cp310-abi3-win_amd64.whl (7.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_x86_64.whl (8.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ ARM64

reactor_webrtc-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file reactor_webrtc-0.1.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for reactor_webrtc-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 27b00e93f8eaaf28ce253df91143ac9cf8886237ef34d07303bd8a5230ca305d
MD5 9f8f90cfcc997613df982a64500a1ceb
BLAKE2b-256 6cf84d5ffa11a012980b3a790e37063ceea70867f0a9512df9d50f91872cea8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for reactor_webrtc-0.1.0-cp310-abi3-win_amd64.whl:

Publisher: publish.yml on reactor-team/reactor-webrtc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4bb93a2e76473fd4621df08d863ac8ec31f42bc8b486bd007adc1c124fe7d57e
MD5 df2524662a0eb35f08c370461e3c783a
BLAKE2b-256 0820ac496fe6e5cff03d86b56e067c4e7848ff644b4c0cb3049e19340515cdd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on reactor-team/reactor-webrtc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 123ea0451e0840f4c9fa76640fb11d24618c45d6bff334a0a0df05021454c0cf
MD5 671218cea1d81d7273e31b6dcbd7e9f4
BLAKE2b-256 37afc0536977261e9006720313099ec0a1309d733f0cb20dd82197ad1f72ad66

See more details on using hashes here.

Provenance

The following attestation bundles were made for reactor_webrtc-0.1.0-cp310-abi3-manylinux_2_34_aarch64.whl:

Publisher: publish.yml on reactor-team/reactor-webrtc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reactor_webrtc-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for reactor_webrtc-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 798615d71de3909b6831a935dc5cd76fcab3b7adfa31ecac96938450f2353ae2
MD5 cfd9b2a0681f7c788add5e53effc5b57
BLAKE2b-256 554657834de363ec152b52c6e98f039155a9f98125b2fbd576b104d3c0f1cfd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for reactor_webrtc-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on reactor-team/reactor-webrtc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.14.0

5 files

0.13.0

5 files

0.12.1

5 files

0.12.0

5 files

0.11.0

5 files

0.10.0

5 files

0.9.0

5 files

0.8.0

5 files

0.7.2

5 files

0.7.1

5 files

0.7.0

5 files

0.6.0

5 files

0.5.0

5 files

0.4.2

5 files

0.4.1

5 files

0.4.0

5 files

0.3.0

4 files

0.2.0

4 files

This release

0.1.0 This release

4 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page