pub struct MediaFrame {
pub pts: i64,
pub dts: i64,
pub duration: Option<u64>,
pub data: Bytes,
pub codec: CodecId,
pub frame_type: FrameType,
pub flags: FrameFlags,
pub track_id: u32,
}Expand description
A single decoded or encoded media sample.
data is always a bytes::Bytes slice — zero-copy cloning is safe and
cheap. The same frame can be fanned-out to many subscribers without
copying the underlying buffer.
Fields§
§pts: i64Presentation timestamp in the stream’s time base (milliseconds).
dts: i64Decode timestamp in the stream’s time base (milliseconds).
duration: Option<u64>Duration of this frame in milliseconds. None = unknown.
data: BytesEncoded / raw payload.
codec: CodecIdCodec that produced this frame.
frame_type: FrameTypeFrame type classification.
flags: FrameFlagsBit flags.
track_id: u32Track index (0 = first video, 1 = first audio, etc.).
Implementations§
Source§impl MediaFrame
impl MediaFrame
Sourcepub fn new_video(
pts: i64,
dts: i64,
data: Bytes,
codec: CodecId,
is_key: bool,
) -> Self
pub fn new_video( pts: i64, dts: i64, data: Bytes, codec: CodecId, is_key: bool, ) -> Self
Build a video frame; is_key selects FrameType::Key vs
FrameType::Delta. Track id defaults to 0.
Sourcepub fn new_audio(pts: i64, data: Bytes, codec: CodecId) -> Self
pub fn new_audio(pts: i64, data: Bytes, codec: CodecId) -> Self
Build an audio frame (dts == pts, FrameType::Audio, track id 1).
Sourcepub fn is_keyframe(&self) -> bool
pub fn is_keyframe(&self) -> bool
Whether this frame is a video keyframe (FrameType::Key).
Sourcepub fn pts_duration(&self) -> Duration
pub fn pts_duration(&self) -> Duration
The presentation timestamp as a Duration (from the absolute pts).
Trait Implementations§
Source§impl Clone for MediaFrame
impl Clone for MediaFrame
Source§fn clone(&self) -> MediaFrame
fn clone(&self) -> MediaFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more