typo fix, return Ok(false) if key is not relevant for value read and dump

This commit is contained in:
Muaz Ahmad 2023-10-06 12:18:23 +05:00
parent 5b57ffb3cb
commit 1f5133239c

View file

@ -105,7 +105,7 @@ fn process_metadata(mut data: Vec<u8>) -> Result<util::Metadata, Box<dyn Error>>
}
}
}
return Ok(metadata);
return if metadata.is_valid() {Ok(metadata)} else {Err(Box::new(util::DemuxerError::MetadataValNotSet))};
}
fn handle_relevant_keys(key: String, data: &mut Vec<u8>, marker: &u8, metadata: &mut util::Metadata) -> Result<bool, Box<dyn Error>> {
@ -119,14 +119,15 @@ fn handle_relevant_keys(key: String, data: &mut Vec<u8>, marker: &u8, metadata:
_ => {Err(Box::new(util::DemuxerError::CodecNotImplemented))}
}
},
"stereo" => {metadata.audio.channels = if bool::fetch_amf_val(data) {2} else {1}; Ok(true)},
"stereo" => {metadata.audio.channels = if bool::fetch_amf_val(data) {2u8} else {1u8}; Ok(true)},
"audiosamplerate" => {metadata.audio.samplerate = f64::fetch_amf_val(data) as u32; Ok(true)},
"audiocodecid" => {
match f64::fetch_amf_val(data) as u8 {
10 => {metadata.audio.codec = Some(util::AudioCodec::AAC); Ok(true)},
_ => {Err(Box::new(util::DemuxerError::CodecNotImplemented))}
}
}
},
_ => Ok(false)
}
}