Skip to main content

Sample

Struct Sample 

Source
pub struct Sample {
    pub data: Bytes,
    pub timestamp: Instant,
    pub duration: Duration,
    pub packet_timestamp: u32,
    pub prev_dropped_packets: u16,
    pub prev_padding_packets: u16,
}
Expand description

A Sample contains encoded media and timing information

Fields§

§data: Bytes

The assembled data in the sample, as a bitstream.

The format is Codec dependant, but is always a bitstream format rather than the packetized format used when carried over RTP.

See: rtp::packetizer::Depacketizer and implementations of it for more details.

§timestamp: Instant

The time when this sample was generated.

§duration: Duration

The duration of this sample

§packet_timestamp: u32

The RTP packet timestamp of this sample.

For all RTP packets that contributed to a single sample the timestamp is the same.

§prev_dropped_packets: u16

The number of packets that were dropped prior to building this sample.

Packets being dropped doesn’t necessarily indicate something wrong, e.g., packets are sometimes dropped because they aren’t relevant for sample building.

§prev_padding_packets: u16

The number of packets that were identified as padding prior to building this sample.

Some implementations, notably libWebRTC, send padding packets to keep the send rate steady. These packets don’t carry media and aren’t useful for building samples.

This field can be combined with Sample::prev_dropped_packets to determine if any dropped packets are likely to have detrimental impact on the steadiness of the RTP stream.

§Example adjustment

let adjusted_dropped =
sample.prev_dropped_packets.saturating_sub(sample.prev_padding_packets);

Implementations§

Source§

impl Sample

Source

pub fn new(now: Instant) -> Self

An empty sample stamped at now.

This replaces Default: the timestamp is a real-world observation the caller supplies, not something the constructor may reach for.

Trait Implementations§

Source§

impl Debug for Sample

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Sample

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !Freeze for Sample

§

impl Forget for Sample

§

impl Move for Sample

§

impl RefUnwindSafe for Sample

§

impl Send for Sample
where Bytes: Send,

§

impl Sync for Sample
where Bytes: Sync,

§

impl Unpin for Sample
where *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin,

§

impl UnsafeUnpin for Sample
where *const u8: UnsafeUnpin, Align8<*mut ()>: UnsafeUnpin, &'static Vtable: UnsafeUnpin,

§

impl UnwindSafe for Sample
where *const u8: UnwindSafe, Align8<*mut ()>: UnwindSafe, &'static Vtable: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.