pub struct OggPacket {
pub version: u8,
pub packet_type: OggPacketType,
pub granule_position: u64,
pub stream_id: u32,
pub packet_index: u32,
pub checksum: u32,
pub segment_table: Vec<u8>,
pub data: Vec<u8>,
}
Expand description
- An ogg packet as a stream container
Fields§
§version: u8
Ogg Version must be zero
packet_type: OggPacketType
- The first packet should be
OggPacketType::BeginOfStream
- The last packet should be
OggPacketType::EndOfStream
- The others should be
OggPacketType::Continuation
granule_position: u64
- For vorbis, this field indicates when you had decoded from the first packet to this packet, and you had finished decoding this packet, how many of the audio frames you should get.
stream_id: u32
- The identifier for the streams. Every Ogg packet belonging to a stream should have the same
stream_id
.
packet_index: u32
- The index of the packet, beginning from zero.
checksum: u32
- The checksum of the packet.
segment_table: Vec<u8>
- A table indicates each segment’s size, the max is 255. And the size of the table also couldn’t exceed 255.
data: Vec<u8>
- The data encapsulated in the Ogg Stream
Implementations§
Source§impl OggPacket
impl OggPacket
Sourcepub fn new(
stream_id: u32,
packet_type: OggPacketType,
packet_index: u32,
) -> Self
pub fn new( stream_id: u32, packet_type: OggPacketType, packet_index: u32, ) -> Self
Create a new Ogg packet
Sourcepub fn write(&mut self, data: &[u8]) -> usize
pub fn write(&mut self, data: &[u8]) -> usize
Write some data to the packet, returns the actual written bytes.
Sourcepub fn get_segments(&self) -> Vec<Vec<u8>>
pub fn get_segments(&self) -> Vec<Vec<u8>>
Read all of the data as segments from the packet
Sourcepub fn get_inner_data_size(&self) -> usize
pub fn get_inner_data_size(&self) -> usize
Get inner data size
Sourcepub fn get_inner_data(&self) -> Vec<u8> ⓘ
pub fn get_inner_data(&self) -> Vec<u8> ⓘ
Read all of the data as a flattened Vec<u8>
Sourcepub fn into_inner(self) -> Vec<u8> ⓘ
pub fn into_inner(self) -> Vec<u8> ⓘ
Read all of the data as a flattened Vec<u8>
and consume self
pub fn get_checksum(ogg_packet: &[u8]) -> Result<u32>
Sourcepub fn fill_checksum_field(ogg_packet: &mut [u8]) -> Result<()>
pub fn fill_checksum_field(ogg_packet: &mut [u8]) -> Result<()>
Set the checksum for the Ogg packet
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Serialize the packet to bytes. Only in the bytes form can calculate the checksum.
Sourcepub fn get_length(ogg_packet: &[u8]) -> Result<usize>
pub fn get_length(ogg_packet: &[u8]) -> Result<usize>
Retrieve the packet length in bytes
Sourcepub fn from_bytes(ogg_packet: &[u8], packet_length: &mut usize) -> Result<Self>
pub fn from_bytes(ogg_packet: &[u8], packet_length: &mut usize) -> Result<Self>
Deserialize the packet
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OggPacket
impl RefUnwindSafe for OggPacket
impl Send for OggPacket
impl Sync for OggPacket
impl Unpin for OggPacket
impl UnwindSafe for OggPacket
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