nalu packet type now requires codec information

This commit is contained in:
Muaz Ahmad 2023-10-16 12:36:12 +05:00
parent 642ddc2dcd
commit 71a3ef569a
3 changed files with 8 additions and 6 deletions

View file

@ -86,11 +86,11 @@ impl input::FileReader for FLVReader {
let (packet_type, mut data) = self.read_packet()?;
return match packet_type {
FLVTagType::Audio => Ok(util::NALUPacket {
packet_type: util::NALUPacketType::Audio,
packet_type: util::NALUPacketType::Audio(*metadata.audio.codec.as_ref().unwrap()),
packet_data: nalu::prepend_a(data, &metadata),
}),
FLVTagType::Video => Ok(util::NALUPacket {
packet_type: util::NALUPacketType::Video,
packet_type: util::NALUPacketType::Video(*metadata.video.codec.as_ref().unwrap()),
packet_data: nalu::prepend_v(data, &metadata),
}),
_ => Err(Box::new(util::DemuxerError::FLVUnexpectedTag))

View file

@ -31,13 +31,13 @@ pub trait FileReader {
}
};
match nalu.packet_type {
util::NALUPacketType::Audio => {
util::NALUPacketType::Audio(_) => {
match a_in.send(nalu) {
Ok(_) => (),
Err(err) => {util::thread_freeze(err_in, Box::new(err)); return}
}
}
util::NALUPacketType::Video => {
util::NALUPacketType::Video(_) => {
match v_in.send(nalu) {
Ok(_) => (),
Err(err) => {util::thread_freeze(err_in, Box::new(err)); return}

View file

@ -13,6 +13,7 @@ pub struct VideoMetadata {
pub codec: Option<VideoCodec>,
}
#[derive(Copy, Clone)]
pub enum VideoCodec {
H264,
VP9,
@ -25,6 +26,7 @@ pub struct AudioMetadata {
pub codec: Option<AudioCodec>,
}
#[derive(Copy, Clone)]
pub enum AudioCodec {
AAC,
OPUS,
@ -52,8 +54,8 @@ impl Metadata {
}
pub enum NALUPacketType {
Audio,
Video,
Audio(AudioCodec),
Video(VideoCodec),
}
pub struct NALUPacket {