nalu packet type now requires codec information
This commit is contained in:
parent
642ddc2dcd
commit
71a3ef569a
3 changed files with 8 additions and 6 deletions
|
@ -86,11 +86,11 @@ impl input::FileReader for FLVReader {
|
||||||
let (packet_type, mut data) = self.read_packet()?;
|
let (packet_type, mut data) = self.read_packet()?;
|
||||||
return match packet_type {
|
return match packet_type {
|
||||||
FLVTagType::Audio => Ok(util::NALUPacket {
|
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),
|
packet_data: nalu::prepend_a(data, &metadata),
|
||||||
}),
|
}),
|
||||||
FLVTagType::Video => Ok(util::NALUPacket {
|
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),
|
packet_data: nalu::prepend_v(data, &metadata),
|
||||||
}),
|
}),
|
||||||
_ => Err(Box::new(util::DemuxerError::FLVUnexpectedTag))
|
_ => Err(Box::new(util::DemuxerError::FLVUnexpectedTag))
|
||||||
|
|
|
@ -31,13 +31,13 @@ pub trait FileReader {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match nalu.packet_type {
|
match nalu.packet_type {
|
||||||
util::NALUPacketType::Audio => {
|
util::NALUPacketType::Audio(_) => {
|
||||||
match a_in.send(nalu) {
|
match a_in.send(nalu) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {util::thread_freeze(err_in, Box::new(err)); return}
|
Err(err) => {util::thread_freeze(err_in, Box::new(err)); return}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
util::NALUPacketType::Video => {
|
util::NALUPacketType::Video(_) => {
|
||||||
match v_in.send(nalu) {
|
match v_in.send(nalu) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => {util::thread_freeze(err_in, Box::new(err)); return}
|
Err(err) => {util::thread_freeze(err_in, Box::new(err)); return}
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub struct VideoMetadata {
|
||||||
pub codec: Option<VideoCodec>,
|
pub codec: Option<VideoCodec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum VideoCodec {
|
pub enum VideoCodec {
|
||||||
H264,
|
H264,
|
||||||
VP9,
|
VP9,
|
||||||
|
@ -25,6 +26,7 @@ pub struct AudioMetadata {
|
||||||
pub codec: Option<AudioCodec>,
|
pub codec: Option<AudioCodec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum AudioCodec {
|
pub enum AudioCodec {
|
||||||
AAC,
|
AAC,
|
||||||
OPUS,
|
OPUS,
|
||||||
|
@ -52,8 +54,8 @@ impl Metadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum NALUPacketType {
|
pub enum NALUPacketType {
|
||||||
Audio,
|
Audio(AudioCodec),
|
||||||
Video,
|
Video(VideoCodec),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NALUPacket {
|
pub struct NALUPacket {
|
||||||
|
|
Loading…
Reference in a new issue