pub struct Packet {
pub stream_index: usize,
pub data: Bytes,
pub timestamp: Timestamp,
pub flags: PacketFlags,
}Expand description
A compressed media packet from a container.
Packets are the fundamental unit of compressed data in a container. Each packet typically contains one or more compressed frames from a single stream.
§Examples
use oximedia_container::{Packet, PacketFlags};
use oximedia_core::{Timestamp, Rational};
use bytes::Bytes;
let packet = Packet::new(
0,
Bytes::from_static(&[0, 1, 2, 3]),
Timestamp::new(1000, Rational::new(1, 1000)),
PacketFlags::KEYFRAME,
);
assert!(packet.is_keyframe());
assert_eq!(packet.size(), 4);Fields§
§stream_index: usizeIndex of the stream this packet belongs to.
data: BytesCompressed packet data.
timestamp: TimestampPresentation and decode timestamps.
flags: PacketFlagsPacket flags.
Implementations§
Source§impl Packet
impl Packet
Sourcepub const fn new(
stream_index: usize,
data: Bytes,
timestamp: Timestamp,
flags: PacketFlags,
) -> Self
pub const fn new( stream_index: usize, data: Bytes, timestamp: Timestamp, flags: PacketFlags, ) -> Self
Creates a new packet.
§Arguments
stream_index- Index of the stream this packet belongs todata- Compressed packet datatimestamp- Presentation/decode timestampsflags- Packet flags (keyframe, corrupt, etc.)
Sourcepub const fn is_keyframe(&self) -> bool
pub const fn is_keyframe(&self) -> bool
Returns true if this packet is a keyframe.
Keyframes can be decoded independently without reference to other frames in the stream.
Sourcepub const fn is_corrupt(&self) -> bool
pub const fn is_corrupt(&self) -> bool
Returns true if this packet may be corrupt.
Sourcepub const fn should_discard(&self) -> bool
pub const fn should_discard(&self) -> bool
Returns true if this packet should be discarded.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnsafeUnpin for Packet
impl UnwindSafe for Packet
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
Mutably borrows from an owned value. Read more