pub struct Sample {
pub is_sync: bool,
pub sample_idx: usize,
pub frame_nr: usize,
pub decode_timestamp: Time,
pub presentation_timestamp: Time,
pub duration: Time,
pub byte_offset: u32,
pub byte_length: u32,
}
Expand description
A single sample in a video.
This is equivalent to MP4’s definition of a single sample. Note that in MP4, each sample is forms a single access unit, see 3.1.1 ISO_IEC_14496-14:
3.1.1 Elementary Stream Data To maintain the goals of streaming protocol independence, the media data is stored in its most ‘natural’ format, and not fragmented. This enables easy local manipulation of the media data. Therefore media-data is stored as access units, a range of contiguous bytes for each access unit (a single access unit is the definition of a ‘sample’ for an MPEG-4 media stream).
Access units in H.264/H.265 are always yielding a single frame upon decoding, see https://en.wikipedia.org/wiki/Network_Abstraction_Layer#Access_Units/:
A set of NAL units in a specified form is referred to as an access unit. The decoding of each access unit results in one decoded picture.
Fields§
§is_sync: bool
Is this the start of a new GroupOfPictures
?
This probably means this is a keyframe, and that and entire frame can be decoded from only this one sample (though I’m not 100% sure).
sample_idx: usize
Which sample is this in the video?
This is the order of which the samples appear in the container,
which is usually ordered by Self::decode_timestamp
.
frame_nr: usize
Which frame does this sample belong to?
This is on the assumption that each sample produces a single frame, which is true for MP4.
This is the index of samples ordered by Self::presentation_timestamp
.
decode_timestamp: Time
Time at which this sample appears in the decoded bitstream, in time units.
Samples should be decoded in this order.
decode_timestamp <= presentation_timestamp
presentation_timestamp: Time
Time at which this sample appears in the frame stream, in time units.
Often synonymous with presentation_timestamp
.
The frame should be shown at this time.
decode_timestamp <= presentation_timestamp
duration: Time
Duration of the sample, in time units.
byte_offset: u32
Offset into the video data.
byte_length: u32
Length of sample starting at Sample::byte_offset
.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sample
impl RefUnwindSafe for Sample
impl Send for Sample
impl Sync for Sample
impl Unpin for Sample
impl UnwindSafe for Sample
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request