diff --git a/server/src/cmds/config/cameras.rs b/server/src/cmds/config/cameras.rs index cd853ff..368df52 100644 --- a/server/src/cmds/config/cameras.rs +++ b/server/src/cmds/config/cameras.rs @@ -125,11 +125,14 @@ fn press_test_inner( username: Option, password: Option, ) -> Result { - let (extra_data, _stream) = stream::FFMPEG.open(stream::Source::Rtsp { - url, - username, - password, - })?; + let (extra_data, _stream) = stream::FFMPEG.open( + "test stream".to_owned(), + stream::Source::Rtsp { + url, + username, + password, + }, + )?; Ok(format!( "{}x{} video stream", extra_data.entry.width, extra_data.entry.height diff --git a/server/src/mp4.rs b/server/src/mp4.rs index b508011..6a49f49 100644 --- a/server/src/mp4.rs +++ b/server/src/mp4.rs @@ -2256,7 +2256,10 @@ mod tests { fn copy_mp4_to_db(db: &TestDb) { let (extra_data, mut input) = stream::FFMPEG - .open(stream::Source::File("src/testdata/clip.mp4")) + .open( + "test".to_owned(), + stream::Source::File("src/testdata/clip.mp4"), + ) .unwrap(); // 2015-04-26 00:00:00 UTC. @@ -2367,10 +2370,13 @@ mod tests { fn compare_mp4s(new_filename: &str, pts_offset: i64, shorten: i64) { let (orig_extra_data, mut orig) = stream::FFMPEG - .open(stream::Source::File("src/testdata/clip.mp4")) + .open( + "test".to_owned(), + stream::Source::File("src/testdata/clip.mp4"), + ) .unwrap(); let (new_extra_data, mut new) = stream::FFMPEG - .open(stream::Source::File(new_filename)) + .open("test".to_owned(), stream::Source::File(new_filename)) .unwrap(); assert_eq!(orig_extra_data, new_extra_data); let mut final_durations = None; diff --git a/server/src/stream.rs b/server/src/stream.rs index 9d8c3ea..cdaa617 100644 --- a/server/src/stream.rs +++ b/server/src/stream.rs @@ -75,7 +75,8 @@ pub enum Source { } pub trait Opener: Send + Sync { - fn open(&self, src: Source) -> Result<(h264::ExtraData, Box), Error>; + fn open(&self, label: String, src: Source) + -> Result<(h264::ExtraData, Box), Error>; } pub struct VideoFrame<'a> { @@ -105,7 +106,11 @@ impl Ffmpeg { } impl Opener for Ffmpeg { - fn open(&self, src: Source) -> Result<(h264::ExtraData, Box), Error> { + fn open( + &self, + label: String, + src: Source, + ) -> Result<(h264::ExtraData, Box), Error> { use ffmpeg::avformat::InputFormatContext; let mut input = match src { #[cfg(test)] @@ -123,8 +128,8 @@ impl Opener for Ffmpeg { )?; if !open_options.empty() { warn!( - "While opening URL {}, some options were not understood: {}", - url, open_options + "{}: While opening URL {}, some options were not understood: {}", + &label, url, open_options ); } i @@ -174,8 +179,8 @@ impl Opener for Ffmpeg { )?; if !open_options.empty() { warn!( - "While opening URL {}, some options were not understood: {}", - url, open_options + "{}: While opening URL {}, some options were not understood: {}", + &label, url, open_options ); } i @@ -271,7 +276,11 @@ pub struct RetinaOpener {} pub const RETINA: RetinaOpener = RetinaOpener {}; impl Opener for RetinaOpener { - fn open(&self, src: Source) -> Result<(h264::ExtraData, Box), Error> { + fn open( + &self, + label: String, + src: Source, + ) -> Result<(h264::ExtraData, Box), Error> { let (startup_tx, startup_rx) = tokio::sync::oneshot::channel(); let (frame_tx, frame_rx) = tokio::sync::mpsc::channel(1); let handle = tokio::runtime::Handle::current(); @@ -323,7 +332,12 @@ impl Opener for RetinaOpener { Some(Ok(CodecItem::VideoFrame(v))) => { deadline = tokio::time::Instant::now() + RETINA_TIMEOUT; if v.loss > 0 { - log::warn!("lost {} RTP packets @ {:?}", v.loss, v.start_ctx()); + log::warn!( + "{}: lost {} RTP packets @ {:?}", + &label, + v.loss, + v.start_ctx() + ); } if frame_tx.send(Ok(v)).await.is_err() { return; // other end died. diff --git a/server/src/streamer.rs b/server/src/streamer.rs index 03bdb85..ee5bf69 100644 --- a/server/src/streamer.rs +++ b/server/src/streamer.rs @@ -109,11 +109,14 @@ where let (extra_data, mut stream) = { let _t = TimerGuard::new(&clocks, || format!("opening {}", self.url.as_str())); - self.opener.open(stream::Source::Rtsp { - url: self.url.clone(), - username: self.username.clone(), - password: self.password.clone(), - })? + self.opener.open( + self.short_name.clone(), + stream::Source::Rtsp { + url: self.url.clone(), + username: self.username.clone(), + password: self.password.clone(), + }, + )? }; let realtime_offset = self.db.clocks().realtime() - clocks.monotonic(); let video_sample_entry_id = { @@ -285,6 +288,7 @@ mod tests { impl stream::Opener for MockOpener { fn open( &self, + _label: String, src: stream::Source, ) -> Result<(h264::ExtraData, Box), Error> { match src { @@ -337,7 +341,10 @@ mod tests { clocks.sleep(time::Duration::seconds(86400)); // to 2015-04-26 00:00:00 UTC let (extra_data, stream) = stream::FFMPEG - .open(stream::Source::File("src/testdata/clip.mp4")) + .open( + "test".to_owned(), + stream::Source::File("src/testdata/clip.mp4"), + ) .unwrap(); let mut stream = ProxyingStream::new(clocks.clone(), time::Duration::seconds(2), stream); stream.ts_offset = 123456; // starting pts of the input should be irrelevant