Expand description
reactor-webrtc — a safe, idiomatic Rust API over an owned build of Google’s
WebRTC engine (see the reactor-webrtc-sys crate and ../../webrtc-build).
§Shape
PeerConnectionFactory → PeerConnection (with a closure-based
PeerConnectionObserver) → SDP offer/answer, ICE, Tracks (audio +
video send/receive) and DataChannels. RAII throughout: dropping a handle
releases the native object.
ICE credentials are libwebrtc’s to generate, and it exposes no setter. When an
application needs to choose its ufrag — so that a fronting layer can route on
it — SessionDescription::with_ice_credentials substitutes them in the
description before it is set locally, which is where libwebrtc reads the
transport’s ICE parameters from.
Per-frame metadata (metadata) rides in a trailer appended to the encoded
payload, which only works if the peer strips it again. That is negotiated for
you: every PeerConnection::create_offer advertises the capability as a
session-level a=x-reactor-frame-metadata,
PeerConnection::create_answer mirrors an offer that asked for
it, and PeerConnection::set_remote_description arms a
FrameMetadataGate from what the remote declared, and installs the metadata
steps on the video transceivers. Callers pass user_data when it is meaningful
and never have to ask what the far end supports — a trailer reaches the wire only
when the peer said it strips them. Set
RtcConfiguration::frame_metadata to false to keep the whole thing out of a
connection.
A FrameTransform of your own composes with that rather than displacing it:
the crate owns libwebrtc’s single transformer slot per sender/receiver and runs
both, so encoded-frame access and per-frame metadata work on one transceiver.
Building a real binary or test requires a native libwebrtc; set
REACTOR_WEBRTC_LIB_DIR or REACTOR_WEBRTC_PREBUILT_URL. cargo check
works without one.
Re-exports§
pub use metadata::FrameMetadata;pub use metadata::FrameMetadataGate;pub use metadata::FRAME_METADATA_ATTRIBUTE;pub use metadata::FRAME_METADATA_VERSION;
Modules§
- metadata
- Frame metadata — protobuf-encoded trailer appended to encoded video payloads.
- platform
- Platform bootstrap. On Android, libwebrtc needs the
JavaVM(and, for the platform ADM, the applicationContext) before a peer connection is built.
Structs§
- ApmConfig
- Audio Processing Module configuration passed to
PeerConnectionFactory. - Audio
Frame - A chunk of decoded audio, borrowed for the duration of the callback:
interleaved signed 16-bit PCM (
frames * channelssamples). - Audio
Track - An audio
Track— local or remote.on_framereceives decoded PCM;push_framefamily feeds a localAudioTrackSource::LocalPushtrack (Erron a remote track; no-op semantics on ADM-backed locals match the native ADM). - Audio
Track Options - Options for
[
PeerConnectionFactory::create_audio_track_with_options]. - Chunking
Stats - Running totals of a chunked channel’s messages, since it opened.
- Data
Channel - A data channel — either locally created or handed to
on_data_channelby the remote peer. Dropping releases the native handle. - Data
Channel Stats - One data channel’s counters (
RTCDataChannelStats). - DcChunking
- Settings for chunked data channels, set on a factory with
PeerConnectionFactoryBuilder::with_dc_chunking. - DcChunking
Params - What a peer declares in
a=x-reactor-dc-chunking(seeSessionDescription::with_dc_chunking). What one side declares. - Encoded
Frame - A borrowed encoded media frame.
dataandmime_typeare valid only for the duration of the callback — copy them to retain. - Encoded
Video Frame - An encoded video frame, produced by an inline encoder callback or pushed
to an
EncodedVideoTrack. - Encoded
Video Track - A video track that accepts pre-encoded frames directly, bypassing the libwebrtc software encoder pipeline entirely.
- Frame
Transform - A callback over encoded frames, to be attached to a transceiver’s sender/receiver; see the module docs.
- IceCandidate
- A trickled ICE candidate.
- IceCandidate
Pair Stats RTCIceCandidatePairStatssubset.- IceServer
- A single ICE (STUN/TURN) server.
- Inbound
RtpStats RTCInboundRtpStreamStatssubset.- Outbound
RtpStats RTCOutboundRtpStreamStatssubset.- Peer
Connection - An
RTCPeerConnection. - Peer
Connection Factory - Entry point: creates peer connections and tracks, and owns the audio device
module (synthetic by default, or the platform device). Construct it with
PeerConnectionFactory::builder. - Peer
Connection Factory Builder - Builds a
PeerConnectionFactoryknob by knob — the single entry point that replaced the old mutually-exclusive constructors (they could not compose: custom encode used to force the synthetic ADM, OpenH264 could not share a factory with a custom encoder, and so on). - Peer
Connection Observer - Builder for the closures invoked over a peer connection’s lifetime. Unset callbacks are simply not delivered.
- Playout
Delay - Bounds on how long a video receiver holds a frame before rendering it — the
playout-delay RTP header extension
(
http://www.webrtc.org/experiments/rtp-hdrext/playout-delay). - PreEncoded
Options - Geometry for a pre-encoded video track
(
TrackVideoEncoder::PreEncoded). - RawVideo
Frame - Raw I420 video frame delivered to an inline encoder callback
(
TrackVideoEncoder::Inline). - RtcConfiguration
- Configuration passed to
crate::PeerConnectionFactory::create_peer_connection. - Sctp
Stats - The SCTP association that carries a connection’s data channels, as dcsctp tracks it.
- Session
Description - A session description (offer/answer).
- Stats
Report - A snapshot of the stats delivered by
PeerConnection::get_stats. - Timing
Frame Info - One frame libwebrtc stamped at each stage of its trip, as reported by the
receiver (
goog_timing_frame_info). - Timing
Frame Receiver Timestamps - The timestamps the receiver (this side) took for a
TimingFrameInfo. - Timing
Frame Sender Timestamps - The timestamps the sender took for a
TimingFrameInfo. - Track
- A media track (local or remote). Dropping it detaches any sink and releases the native track.
- Transceiver
- A transceiver: one bidirectional media “slot” in the peer connection. Its
mid(available afterset_local_description) maps it to an SDP m-section. - Video
Frame - A decoded video frame, borrowed for the duration of the callback. The buffer
is BGRA (
width*height*4, B-G-R-A); copy it if you need to keep it. - Video
Sink Timings - How long a remote video track’s sink took to hand its decoded frames on,
added up since the sink was attached (
VideoTrack::sink_timings). - Video
Track - A video
Track— local (raw) or remote.on_framereceives decoded video;push_framefamily feeds a local track (Erron a remote track). - Video
Track Options - Options for [
PeerConnectionFactory::create_video_track_with_options].
Enums§
- AdmMode
- Which audio device module a
PeerConnectionFactoryuses. - Audio
Track Source - Where an audio track’s samples come from
(
create_audio_track_with_options). - Bundle
Policy - How m-sections are bundled onto a single transport.
- Continual
Gathering Policy - When ICE candidates are gathered.
- Data
Channel State - Data channel readiness state.
- DcSend
Error - Why a chunked data channel refused a message (
Error::DataChannel). Whypushrefused a message. Nothing of it was queued. - Encoder
Feedback - Feedback from the BWE / rate-control machinery for a custom-encoded
(
TrackVideoEncoder) track’s encoder instance. The builtin encoder pipeline consumes the same signals internally; custom encoders hear them here through [VideoTrack::on_encoder_feedback] /EncodedVideoTrack::on_encoder_feedback. - Error
- Errors surfaced by the WebRTC engine.
- Frame
Action - What to do with a frame after the callback returns.
- Frame
Direction - Which side of the pipeline an
EncodedFramecame from. - H264
Backend - Which H.264 backend a raw video track encodes with.
- IceCandidate
Pair State - State of an ICE candidate pair (
RTCIceCandidatePairStats::state). - IceCandidate
Type - Type of an ICE candidate (
RTCIceCandidateStats::candidate_type). - IceGathering
State - ICE gathering state (delivered to
PeerConnectionObserver::on_ice_gathering_change). - IceTransports
Type - Which ICE candidate types are allowed.
- Local
Video Track - One video track created by
[
PeerConnectionFactory::create_video_track_with_options]. - Media
Kind - Audio vs. video.
- Peer
Connection State - Aggregate connection state.
- Relay
Protocol - Transport a relayed candidate uses to reach its TURN server
(
RTCIceCandidateStats::relay_protocol). - Remote
Track - A track delivered by [
PeerConnectionObserver::on_track] — media-typed, soRemoteTrack::Video(v).on_frame(...)andRemoteTrack::Audio(a) .on_frame(...)each take the matching frame type and nothing else. - SdpType
- SDP description kind.
- Stream
Kind - Media kind of an RTP stream (
RTCRtpStreamStats::kind). - TcpCandidate
Policy - Whether libwebrtc may gather TCP ICE candidates.
- Track
Video Encoder - How a video track produces its encoded bitstream, replacing libwebrtc’s builtin encoder for that track only.
- Transceiver
Direction - Direction of a transceiver / track.
- Video
Codec - Which video codec was negotiated for the session.
Functions§
- native_
abi_ version - The ABI version of the linked native build. Used to assert that the safe
crate and the prebuilt
libwebrtcagree. - time_
micros - The engine’s monotonic clock, in microseconds.
Type Aliases§
- Inline
Encoder Callback - The boxed encoder callback a
TrackVideoEncoder::Inlinetrack hands the factory — called synchronously with every raw I420 frame on the encoder thread; returnSome(encoded)to forward,Noneto drop. - Result