diff --git a/src/codec/h264.rs b/src/codec/h264.rs index 1f69ca8..d60fce8 100644 --- a/src/codec/h264.rs +++ b/src/codec/h264.rs @@ -578,10 +578,11 @@ impl InternalParameters { .map(|(h, v)| (u32::from(h), (u32::from(v)))); // TODO: study H.264, (E-34). This quick'n'dirty calculation isn't always right. - frame_rate = vui - .timing_info - .as_ref() - .and_then(|t| t.num_units_in_tick.checked_mul(2).map(|doubled| (doubled, t.time_scale))); + frame_rate = vui.timing_info.as_ref().and_then(|t| { + t.num_units_in_tick + .checked_mul(2) + .map(|doubled| (doubled, t.time_scale)) + }); } None => { pixel_aspect_ratio = None; diff --git a/src/codec/mod.rs b/src/codec/mod.rs index 77810b1..8ac284b 100644 --- a/src/codec/mod.rs +++ b/src/codec/mod.rs @@ -343,7 +343,6 @@ impl bytes::Buf for VideoFrame { #[derive(Debug)] pub struct Depacketizer(DepacketizerInner); - #[derive(Debug)] #[allow(clippy::clippy::large_enum_variant)] enum DepacketizerInner { @@ -376,40 +375,40 @@ impl Depacketizer { channels, format_specific_params, )?), - ("audio", "g726-16") => DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new( - clock_rate, 2, - )), - ("audio", "g726-24") => DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new( - clock_rate, 3, - )), - ("audio", "dvi4") | ("audio", "g726-32") => DepacketizerInner::SimpleAudio( - simple_audio::Depacketizer::new(clock_rate, 4), - ), - ("audio", "g726-40") => DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new( - clock_rate, 5, - )), - ("audio", "pcma") | ("audio", "pcmu") | ("audio", "u8") | ("audio", "g722") => ( - DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 8)) - ), - ("audio", "l16") => DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new( - clock_rate, 16, - )), + ("audio", "g726-16") => { + DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 2)) + } + ("audio", "g726-24") => { + DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 3)) + } + ("audio", "dvi4") | ("audio", "g726-32") => { + DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 4)) + } + ("audio", "g726-40") => { + DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 5)) + } + ("audio", "pcma") | ("audio", "pcmu") | ("audio", "u8") | ("audio", "g722") => { + (DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 8))) + } + ("audio", "l16") => { + DepacketizerInner::SimpleAudio(simple_audio::Depacketizer::new(clock_rate, 16)) + } // Dahua cameras when configured with G723 send packets with a // non-standard encoding-name "G723.1" and length 40, which doesn't // make sense. Don't try to depacketize these. ("audio", "g723") => DepacketizerInner::G723(g723::Depacketizer::new(clock_rate)?), - ("application", "vnd.onvif.metadata") => DepacketizerInner::Onvif( - onvif::Depacketizer::new(CompressionType::Uncompressed), - ), - ("application", "vnd.onvif.metadata.gzip") => DepacketizerInner::Onvif( - onvif::Depacketizer::new(CompressionType::GzipCompressed), - ), - ("application", "vnd.onvif.metadata.exi.onvif") => DepacketizerInner::Onvif( - onvif::Depacketizer::new(CompressionType::ExiDefault), - ), - ("application", "vnd.onvif.metadata.exi.ext") => DepacketizerInner::Onvif( - onvif::Depacketizer::new(CompressionType::ExiInBand), - ), + ("application", "vnd.onvif.metadata") => { + DepacketizerInner::Onvif(onvif::Depacketizer::new(CompressionType::Uncompressed)) + } + ("application", "vnd.onvif.metadata.gzip") => { + DepacketizerInner::Onvif(onvif::Depacketizer::new(CompressionType::GzipCompressed)) + } + ("application", "vnd.onvif.metadata.exi.onvif") => { + DepacketizerInner::Onvif(onvif::Depacketizer::new(CompressionType::ExiDefault)) + } + ("application", "vnd.onvif.metadata.exi.ext") => { + DepacketizerInner::Onvif(onvif::Depacketizer::new(CompressionType::ExiInBand)) + } (_, _) => { log::info!( "no depacketizer for media/encoding_name {}/{}", diff --git a/src/lib.rs b/src/lib.rs index c715a7c..b3b6f1d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,7 @@ impl Timestamp { timestamp, clock_rate, start, - }) + }), } } @@ -182,7 +182,7 @@ pub struct Context { impl Context { #[doc(hidden)] pub fn dummy() -> Self { - use std::net::{Ipv4Addr, IpAddr, SocketAddr}; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0); Self { conn_local_addr: addr,