special EOF error to denote input file ending correctly
This commit is contained in:
parent
6c2553f82a
commit
ba47cd1b3b
2 changed files with 7 additions and 1 deletions
|
@ -48,7 +48,11 @@ impl FLVReader {
|
|||
|
||||
fn read_packet(&mut self) -> Result<(FLVTagType, Vec<u8>), Box<dyn Error + Send + Sync>> {
|
||||
let mut tag_head = [0u8; 11];
|
||||
self.stdin.read_exact(&mut tag_head)?;
|
||||
match self.stdin.read_exact(&mut tag_head) {
|
||||
Ok(_) => (),
|
||||
Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => return Err(Box::new(util::DemuxerError::EOF)),
|
||||
Err(err) => return Err(Box::new(err))
|
||||
};
|
||||
let tag_type = FLVTagType::try_from(tag_head[0])?;
|
||||
let tag_data_len = (u32::from_be_bytes(tag_head[..4].try_into()?) & 0xffffff) as usize;
|
||||
let mut packet_data = vec![0u8; tag_data_len];
|
||||
|
|
|
@ -98,6 +98,7 @@ pub enum DemuxerError {
|
|||
FLVUnexpectedTag,
|
||||
MetadataValNotSet,
|
||||
CodecNotImplemented,
|
||||
EOF,
|
||||
}
|
||||
|
||||
impl Error for DemuxerError {}
|
||||
|
@ -115,6 +116,7 @@ impl fmt::Debug for DemuxerError {
|
|||
DemuxerError::CodecNotImplemented => write!(f, "Input file has unrecognized codec"),
|
||||
DemuxerError::MetadataValNotSet => write!(f, "One or more metadata values failed to init"),
|
||||
DemuxerError::FLVUnexpectedTag => write!(f, "Expected data tag, found metadata"),
|
||||
DemuxerError::EOF => write!(f, "Failed to read tag header, expected EOF"),
|
||||
_ => write!(f, "Error not described yet")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue