pub struct TrackLocalStaticSample { /* private fields */ }
Expand description

TrackLocalStaticSample is a TrackLocal that has a pre-set codec and accepts Samples. If you wish to send a RTP Packet use TrackLocalStaticRTP

Implementations

returns a TrackLocalStaticSample

codec gets the Codec of the track

write_sample writes a Sample to the TrackLocalStaticSample If one PeerConnection fails the packets will still be sent to all PeerConnections. The error message will contain the ID of the failed PeerConnections so you can remove them

Write a sample with provided RTP extensions.

Alternatively to this method TrackLocalStaticSample::sample_writer can be used instead.

See TrackLocalStaticSample::write_sample for further details.

Create a builder for writing samples with additional data.

Example
use rtp::extension::audio_level_extension::AudioLevelExtension;
use std::time::Duration;
use webrtc::api::media_engine::MIME_TYPE_VP8;
use webrtc::rtp_transceiver::rtp_codec::RTCRtpCodecCapability;
use webrtc::track::track_local::track_local_static_sample::TrackLocalStaticSample;

#[tokio::main]
async fn main() {
    let track = TrackLocalStaticSample::new(
       RTCRtpCodecCapability {
           mime_type: MIME_TYPE_VP8.to_owned(),
           ..Default::default()
       },
       "video".to_owned(),
       "webrtc-rs".to_owned(),
    );
    let result = track
        .sample_writer()
        .with_audio_level(AudioLevelExtension {
            level: 10,
            voice: true,
        })
        .write_sample(&media::Sample{
             data: bytes::Bytes::new(),
             duration: Duration::from_secs(1),
             ..Default::default()
        })
        .await;
}

Trait Implementations

Formats the value using the given formatter. Read more

Bind is called by the PeerConnection after negotiation is complete This asserts that the code requested is supported by the remote peer. If so it setups all the state (SSRC and PayloadType) to have a call

unbind implements the teardown logic when the track is no longer needed. This happens because a track has been stopped.

id is the unique identifier for this Track. This should be unique for the stream, but doesn’t have to globally unique. A common example would be ‘audio’ or ‘video’ and StreamID would be ‘desktop’ or ‘webcam’

stream_id is the group this track belongs too. This must be unique

kind controls if this TrackLocal is audio or video

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.