pub(crate) struct MediaTransport {
workers: Arc<[RtcWorker]>,
profile: Arc<RtpProfile>,
metrics: Arc<RuntimeMetrics>,
source_policy_signal: SourcePolicySignal,
}Expand description
Opaque runtime media transport handle.
MediaTransport is the handle server code and crate::prelude::SfuCore
should hold.
It hides the production RTC worker topology. Callers express intent through
inherent methods and must not branch on concrete worker internals.
The handle also centralizes warning logs for failed transport effects. Inner backends return typed errors, while this boundary adds stable diagnostic context such as session keys, media ids and SDP lengths.
Fields§
§workers: Arc<[RtcWorker]>§profile: Arc<RtpProfile>§metrics: Arc<RuntimeMetrics>§source_policy_signal: SourcePolicySignalImplementations§
Source§impl MediaTransport
impl MediaTransport
Sourcepub fn build(
config: MediaTransportConfig,
deps: MediaTransportDeps,
) -> Result<MediaTransport, MediaTransportBuildError>
pub fn build( config: MediaTransportConfig, deps: MediaTransportDeps, ) -> Result<MediaTransport, MediaTransportBuildError>
builds the runtime media transport from owner configuration and process services
validation completes before worker startup and every worker has a bound socket when this function returns
§Errors
returns MediaTransportBuildError when worker topology or the
code-controlled RTP profile is invalid, the selected UDP backend is
unavailable or a worker cannot start
Source§impl MediaTransport
impl MediaTransport
Sourcepub fn transport_bitrate_snapshot(
&self,
session_keys: &[TransportSessionKey],
) -> TransportBitrateSnapshot
pub fn transport_bitrate_snapshot( &self, session_keys: &[TransportSessionKey], ) -> TransportBitrateSnapshot
Returns the latest bitrate estimates for the requested sessions.
Missing sessions are omitted from the snapshot. Estimates are suitable for diagnostics and policy input, not for accounting.
Sourcepub fn receiver_bandwidth_snapshot(
&self,
session_keys: &[TransportSessionKey],
) -> ReceiverBandwidthSnapshot
pub fn receiver_bandwidth_snapshot( &self, session_keys: &[TransportSessionKey], ) -> ReceiverBandwidthSnapshot
Returns receiver-side bandwidth estimates for the requested sessions.
Room policy may use these estimates as source-selection input. They are best-effort observations from the transport backend.
Sourcepub fn transport_quality_snapshot(
&self,
session_keys: &[TransportSessionKey],
) -> BTreeMap<TransportSessionKey, TransportQualitySample>
pub fn transport_quality_snapshot( &self, session_keys: &[TransportSessionKey], ) -> BTreeMap<TransportSessionKey, TransportQualitySample>
Returns sampled transport-quality observations for the requested sessions.
Sourcepub fn transport_health_snapshot(
&self,
session_keys: &[TransportSessionKey],
) -> BTreeMap<TransportSessionKey, TransportSessionHealth>
pub fn transport_health_snapshot( &self, session_keys: &[TransportSessionKey], ) -> BTreeMap<TransportSessionKey, TransportSessionHealth>
Returns transport health for the requested sessions with one lock per worker.
Missing sessions and unavailable worker snapshots contribute no facts
Sourcepub async fn source_diagnostics_snapshot(
&self,
sources: &[TransportSourceKey],
) -> TransportSourceDiagnosticsSnapshot
pub async fn source_diagnostics_snapshot( &self, sources: &[TransportSourceKey], ) -> TransportSourceDiagnosticsSnapshot
Returns source activity and active-speaker facts with one command per worker.
Missing sources and worker dispatch failures contribute no facts
Sourcepub fn worker_pressure_snapshots(&self) -> Vec<TransportWorkerPressureSnapshot>
pub fn worker_pressure_snapshots(&self) -> Vec<TransportWorkerPressureSnapshot>
Returns transport pressure for every media worker.
Sourcepub async fn active_speaker_source_snapshot(&self) -> Vec<ActiveSpeakerSource>
pub async fn active_speaker_source_snapshot(&self) -> Vec<ActiveSpeakerSource>
Returns each media source’s newest active-speaker observation in recency order, preferring its strongest audio level on timestamp ties.
Sourcepub fn session_transport_health(
&self,
session_key: &TransportSessionKey,
) -> Option<TransportSessionHealth>
pub fn session_transport_health( &self, session_key: &TransportSessionKey, ) -> Option<TransportSessionHealth>
Returns the latest known transport health for one session.
Health is connectivity evidence only. It should not be used as the source of truth for whether a participant belongs to a room.
Source§impl MediaTransport
impl MediaTransport
Sourcepub fn router_rtp_capabilities(&self) -> MediaCapabilities
pub fn router_rtp_capabilities(&self) -> MediaCapabilities
returns the router capability snapshot compiled from the RTC wire profile
Sourcepub async fn create_initial_session_offer(
&self,
room_id: &str,
session_key: &TransportSessionKey,
) -> Result<SessionOffer, TransportAdapterError>
pub async fn create_initial_session_offer( &self, room_id: &str, session_key: &TransportSessionKey, ) -> Result<SessionOffer, TransportAdapterError>
Creates the first SDP offer for a transport session.
The session must already be assigned to a transport worker by its
TransportSessionKey. The returned offer is transport state that
callers should send to the browser unchanged.
§Errors
Returns TransportAdapterError when the session cannot be addressed or
the active backend cannot create the offer.
Sourcepub async fn create_session_renegotiation_offer(
&self,
session_key: &TransportSessionKey,
) -> Result<SessionOffer, TransportAdapterError>
pub async fn create_session_renegotiation_offer( &self, session_key: &TransportSessionKey, ) -> Result<SessionOffer, TransportAdapterError>
Creates a new SDP offer after transport media state changed.
Backends reject sessions that cannot renegotiate in their current state. Callers should treat the returned offer as replacing any older pending transport offer for the same session.
§Errors
Returns TransportAdapterError when the session cannot be addressed or
the active backend cannot create a renegotiation offer.
Sourcepub async fn apply_session_answer(
&self,
session_key: &TransportSessionKey,
answer_sdp: &str,
) -> Result<AppliedSessionAnswer, TransportAdapterError>
pub async fn apply_session_answer( &self, session_key: &TransportSessionKey, answer_sdp: &str, ) -> Result<AppliedSessionAnswer, TransportAdapterError>
Applies a browser SDP answer to a pending transport offer.
The answer can reveal transport-derived producer facts such as mapped RTP parameters. Those facts are returned so room code can commit staged media using values observed by the transport.
§Errors
Returns TransportAdapterError when the session cannot be addressed,
the answer is invalid or the active backend cannot apply it.
Sourcepub async fn publish_media(
&self,
session_key: &TransportSessionKey,
media_kind: MediaKind,
rtp_parameters: &MediaStream,
) -> Result<TransportMediaId, TransportAdapterError>
pub async fn publish_media( &self, session_key: &TransportSessionKey, media_kind: MediaKind, rtp_parameters: &MediaStream, ) -> Result<TransportMediaId, TransportAdapterError>
Declares a new producer on a transport session.
rtp_parameters must come from router media state accepted by the core.
The returned TransportMediaId addresses the backend-local producer
for later route, activity and cleanup operations.
§Errors
Returns TransportAdapterError when the session cannot be addressed,
the RTP parameters are invalid or the active backend cannot create the
producer.
Sourcepub async fn consume_media(
&self,
consumer_session_key: &TransportSessionKey,
media_kind: MediaKind,
source_session_key: &TransportSessionKey,
source_media_id: TransportMediaId,
consumer_rtp_parameters: &MediaStream,
initial_activity: ConsumerActivity,
) -> Result<TransportMediaId, TransportAdapterError>
pub async fn consume_media( &self, consumer_session_key: &TransportSessionKey, media_kind: MediaKind, source_session_key: &TransportSessionKey, source_media_id: TransportMediaId, consumer_rtp_parameters: &MediaStream, initial_activity: ConsumerActivity, ) -> Result<TransportMediaId, TransportAdapterError>
Declares a new consumer route from a source session to a consumer session.
The source and consumer sessions must belong to the same room instance. Cross-worker routing is an implementation detail hidden behind this method. The initial activity controls whether the packet loop can forward packets before later room policy updates arrive.
§Errors
Returns TransportAdapterError when either session cannot be
addressed, the source media id is unknown or the active backend cannot
create the consumer.
Sourcepub fn source_policy_subscription(&self) -> SourcePolicyUpdateSubscription
pub fn source_policy_subscription(&self) -> SourcePolicyUpdateSubscription
Subscribes to source-policy invalidation signals emitted by transport workers.
Trait Implementations§
Source§impl Clone for MediaTransport
impl Clone for MediaTransport
Source§fn clone(&self) -> MediaTransport
fn clone(&self) -> MediaTransport
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MediaTransport
impl !RefUnwindSafe for MediaTransport
impl Send for MediaTransport
impl Sync for MediaTransport
impl Unpin for MediaTransport
impl UnsafeUnpin for MediaTransport
impl !UnwindSafe for MediaTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more