Struct webrtc_media::io::sample_builder::SampleBuilder
source · pub struct SampleBuilder<T: Depacketizer> { /* private fields */ }
Expand description
SampleBuilder buffers packets until media frames are complete.
Implementations§
source§impl<T: Depacketizer> SampleBuilder<T>
impl<T: Depacketizer> SampleBuilder<T>
sourcepub fn new(max_late: u16, depacketizer: T, sample_rate: u32) -> Self
pub fn new(max_late: u16, depacketizer: T, sample_rate: u32) -> Self
Constructs a new SampleBuilder.
max_late
is how long to wait until we can construct a completed Sample
.
max_late
is measured in RTP packet sequence numbers.
A large max_late will result in less packet loss but higher latency.
The depacketizer extracts media samples from RTP packets.
Several depacketizers are available in package github.com/pion/rtp/codecs.
pub fn with_max_time_delay(self, max_late_duration: Duration) -> Self
sourcepub fn push(&mut self, p: Packet)
pub fn push(&mut self, p: Packet)
Adds an RTP Packet to self’s buffer.
Push does not copy the input. If you wish to reuse this memory make sure to copy before calling push
sourcepub fn pop(&mut self) -> Option<Sample>
pub fn pop(&mut self) -> Option<Sample>
Compiles pushed RTP packets into media samples and then returns the next valid sample (or None if no sample is compiled).
sourcepub fn pop_with_timestamp(&mut self) -> Option<(Sample, u32)>
pub fn pop_with_timestamp(&mut self) -> Option<(Sample, u32)>
Compiles pushed RTP packets into media samples and then
returns the next valid sample with its associated RTP timestamp (or None
if
no sample is compiled).