diff --git a/Cargo.lock b/Cargo.lock index 181b5ed..64ef8d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "MacTypes-sys" version = "1.3.0" diff --git a/src/cmds/config/cameras.rs b/src/cmds/config/cameras.rs index 12bddc1..78c9f24 100644 --- a/src/cmds/config/cameras.rs +++ b/src/cmds/config/cameras.rs @@ -102,7 +102,10 @@ fn press_edit(siv: &mut Cursive, db: &Arc, id: Option) { } fn press_test_inner(url: &str) -> Result { - let stream = stream::FFMPEG.open(stream::Source::Rtsp(url))?; + let stream = stream::FFMPEG.open(stream::Source::Rtsp { + url, + redacted_url: url, + })?; let extra_data = stream.get_extra_data()?; Ok(format!("{}x{} video stream", extra_data.width, extra_data.height)) } diff --git a/src/mp4.rs b/src/mp4.rs index 0370559..698f21a 100644 --- a/src/mp4.rs +++ b/src/mp4.rs @@ -1812,7 +1812,7 @@ mod tests { pkt.is_key()).unwrap(); end_pts = Some(pts + pkt.duration() as i64); } - output.close(end_pts); + output.close(end_pts).unwrap(); db.syncer_channel.flush(); } diff --git a/src/stream.rs b/src/stream.rs index 41d4c47..2e2a9b1 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -45,10 +45,15 @@ lazy_static! { } pub enum Source<'a> { + /// A filename, for testing. #[cfg(test)] - File(&'a str), // filename, for testing. + File(&'a str), - Rtsp(&'a str), // url, for production use. + /// An RTSP stream, for production use. + Rtsp { + url: &'a str, + redacted_url: &'a str + }, } pub trait Opener : Sync { @@ -98,7 +103,7 @@ impl Opener for Ffmpeg { } (i, false) } - Source::Rtsp(url) => { + Source::Rtsp{url, redacted_url} => { let mut open_options = ffmpeg::Dictionary::new(); open_options.set(c_str!("rtsp_transport"), c_str!("tcp")).unwrap(); open_options.set(c_str!("user-agent"), c_str!("moonfire-nvr")).unwrap(); @@ -112,7 +117,7 @@ impl Opener for Ffmpeg { let i = InputFormatContext::open(&CString::new(url).unwrap(), &mut open_options)?; if !open_options.empty() { warn!("While opening URL {}, some options were not understood: {}", - url, open_options); + redacted_url, open_options); } (i, true) }, diff --git a/src/streamer.rs b/src/streamer.rs index e6e08a0..f853969 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -103,7 +103,10 @@ impl<'a, C, S> Streamer<'a, C, S> where C: 'a + Clocks + Clone, S: 'a + stream:: let mut stream = { let _t = TimerGuard::new(&clocks, || format!("opening {}", self.redacted_url)); - self.opener.open(stream::Source::Rtsp(&self.url))? + self.opener.open(stream::Source::Rtsp { + url: &self.url, + redacted_url: &self.redacted_url, + })? }; let realtime_offset = self.db.clocks().realtime() - clocks.monotonic(); // TODO: verify width/height. @@ -275,7 +278,7 @@ mod tests { impl<'a> stream::Opener> for MockOpener<'a> { fn open(&self, src: stream::Source) -> Result, Error> { match src { - stream::Source::Rtsp(url) => assert_eq!(url, &self.expected_url), + stream::Source::Rtsp{url, ..} => assert_eq!(url, &self.expected_url), stream::Source::File(_) => panic!("expected rtsp url"), }; let mut l = self.streams.lock();