diff --git a/src/util/mod.rs b/src/util/mod.rs index 73caebc..c5eba22 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -32,6 +32,21 @@ pub struct Metadata { pub audio: AudioMetadata, } +impl Metadata { + pub fn is_valid(&self) -> bool { + match self { + x if x.video.width == u32::default() => false, + x if x.video.height == u32::default() => false, + x if x.video.framerate == f32::default() => false, + x if x.video.codec.is_none() => false, + x if x.audio.channels == u8::default() => false, + x if x.audio.samplerate == u32::default() => false, + x if x.audio.codec.is_none() => false, + _ => true, + } + } +} + pub enum FileType { FLV, MPEGTS, @@ -66,6 +81,7 @@ pub enum DemuxerError { FLVPacketNotMetadata, FLVMetadataSyncFail, FLVMetadataAMFMarkerError, + MetadataValNotSet, CodecNotImplemented, } @@ -81,6 +97,7 @@ impl fmt::Debug for DemuxerError { DemuxerError::FLVMetadataSyncFail => write!(f, "ECMA array not where expected"), DemuxerError::FLVMetadataAMFMarkerError => write!(f, "Marker value not recognized/implemented"), DemuxerError::CodecNotImplemented => write!(f, "Input file has unrecognized codec"), + DemuxerError::MetadataValNotSet => write!(f, "One or more metadata values failed to init"), _ => write!(f, "Error not described yet") } }