X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-registry%2Fsrc%2Fdetect.rs;h=92bb920e0e36555840d067f7c20a22242b2a62dc;hb=c82fed396735d41118b41672ebc28ed27e186959;hp=7d0633a7630d4f2ee4db12ef34cd955539b3dc10;hpb=31cf33aceca7798294e1ce5c01702ef5e6ef7adc;p=nihav.git diff --git a/nihav-registry/src/detect.rs b/nihav-registry/src/detect.rs index 7d0633a..92bb920 100644 --- a/nihav-registry/src/detect.rs +++ b/nihav-registry/src/detect.rs @@ -198,6 +198,13 @@ const DETECTORS: &[DetectConditions] = &[ &CC::Str(b"ON2fLIST")) }, ] }, + DetectConditions { + demux_name: "wav", + extensions: ".wav", + conditions: &[CheckItem{offs: 0, cond: &CC::Str(b"RIFF") }, + CheckItem{offs: 8, cond: &CC::Str(b"WAVEfmt ") } + ] + }, DetectConditions { demux_name: "mov", extensions: ".mov", @@ -325,6 +332,22 @@ pub fn detect_format(name: &str, src: &mut ByteReader) -> Option<(&'static str, result } +/// Tries to detect container format for provided file name. +pub fn detect_format_by_name(name: &str) -> Option<(&'static str)> { + if name.is_empty() { + return None; + } + let lname = name.to_lowercase(); + for detector in DETECTORS { + for ext in detector.extensions.split(',') { + if lname.ends_with(ext) { + return Some(detector.demux_name); + } + } + } + None +} + #[cfg(test)] mod test { use super::*;