mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-04-01 10:13:43 -04:00
add camera name to rtp packet loss messages
This commit is contained in:
parent
5be69baaa6
commit
a50625e769
@ -125,11 +125,14 @@ fn press_test_inner(
|
|||||||
username: Option<String>,
|
username: Option<String>,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
) -> Result<String, Error> {
|
) -> Result<String, Error> {
|
||||||
let (extra_data, _stream) = stream::FFMPEG.open(stream::Source::Rtsp {
|
let (extra_data, _stream) = stream::FFMPEG.open(
|
||||||
url,
|
"test stream".to_owned(),
|
||||||
username,
|
stream::Source::Rtsp {
|
||||||
password,
|
url,
|
||||||
})?;
|
username,
|
||||||
|
password,
|
||||||
|
},
|
||||||
|
)?;
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"{}x{} video stream",
|
"{}x{} video stream",
|
||||||
extra_data.entry.width, extra_data.entry.height
|
extra_data.entry.width, extra_data.entry.height
|
||||||
|
@ -2256,7 +2256,10 @@ mod tests {
|
|||||||
|
|
||||||
fn copy_mp4_to_db(db: &TestDb<RealClocks>) {
|
fn copy_mp4_to_db(db: &TestDb<RealClocks>) {
|
||||||
let (extra_data, mut input) = stream::FFMPEG
|
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();
|
.unwrap();
|
||||||
|
|
||||||
// 2015-04-26 00:00:00 UTC.
|
// 2015-04-26 00:00:00 UTC.
|
||||||
@ -2367,10 +2370,13 @@ mod tests {
|
|||||||
|
|
||||||
fn compare_mp4s(new_filename: &str, pts_offset: i64, shorten: i64) {
|
fn compare_mp4s(new_filename: &str, pts_offset: i64, shorten: i64) {
|
||||||
let (orig_extra_data, mut orig) = stream::FFMPEG
|
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();
|
.unwrap();
|
||||||
let (new_extra_data, mut new) = stream::FFMPEG
|
let (new_extra_data, mut new) = stream::FFMPEG
|
||||||
.open(stream::Source::File(new_filename))
|
.open("test".to_owned(), stream::Source::File(new_filename))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(orig_extra_data, new_extra_data);
|
assert_eq!(orig_extra_data, new_extra_data);
|
||||||
let mut final_durations = None;
|
let mut final_durations = None;
|
||||||
|
@ -75,7 +75,8 @@ pub enum Source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait Opener: Send + Sync {
|
pub trait Opener: Send + Sync {
|
||||||
fn open(&self, src: Source) -> Result<(h264::ExtraData, Box<dyn Stream>), Error>;
|
fn open(&self, label: String, src: Source)
|
||||||
|
-> Result<(h264::ExtraData, Box<dyn Stream>), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct VideoFrame<'a> {
|
pub struct VideoFrame<'a> {
|
||||||
@ -105,7 +106,11 @@ impl Ffmpeg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Opener for Ffmpeg {
|
impl Opener for Ffmpeg {
|
||||||
fn open(&self, src: Source) -> Result<(h264::ExtraData, Box<dyn Stream>), Error> {
|
fn open(
|
||||||
|
&self,
|
||||||
|
label: String,
|
||||||
|
src: Source,
|
||||||
|
) -> Result<(h264::ExtraData, Box<dyn Stream>), Error> {
|
||||||
use ffmpeg::avformat::InputFormatContext;
|
use ffmpeg::avformat::InputFormatContext;
|
||||||
let mut input = match src {
|
let mut input = match src {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -123,8 +128,8 @@ impl Opener for Ffmpeg {
|
|||||||
)?;
|
)?;
|
||||||
if !open_options.empty() {
|
if !open_options.empty() {
|
||||||
warn!(
|
warn!(
|
||||||
"While opening URL {}, some options were not understood: {}",
|
"{}: While opening URL {}, some options were not understood: {}",
|
||||||
url, open_options
|
&label, url, open_options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
i
|
i
|
||||||
@ -174,8 +179,8 @@ impl Opener for Ffmpeg {
|
|||||||
)?;
|
)?;
|
||||||
if !open_options.empty() {
|
if !open_options.empty() {
|
||||||
warn!(
|
warn!(
|
||||||
"While opening URL {}, some options were not understood: {}",
|
"{}: While opening URL {}, some options were not understood: {}",
|
||||||
url, open_options
|
&label, url, open_options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
i
|
i
|
||||||
@ -271,7 +276,11 @@ pub struct RetinaOpener {}
|
|||||||
pub const RETINA: RetinaOpener = RetinaOpener {};
|
pub const RETINA: RetinaOpener = RetinaOpener {};
|
||||||
|
|
||||||
impl Opener for RetinaOpener {
|
impl Opener for RetinaOpener {
|
||||||
fn open(&self, src: Source) -> Result<(h264::ExtraData, Box<dyn Stream>), Error> {
|
fn open(
|
||||||
|
&self,
|
||||||
|
label: String,
|
||||||
|
src: Source,
|
||||||
|
) -> Result<(h264::ExtraData, Box<dyn Stream>), Error> {
|
||||||
let (startup_tx, startup_rx) = tokio::sync::oneshot::channel();
|
let (startup_tx, startup_rx) = tokio::sync::oneshot::channel();
|
||||||
let (frame_tx, frame_rx) = tokio::sync::mpsc::channel(1);
|
let (frame_tx, frame_rx) = tokio::sync::mpsc::channel(1);
|
||||||
let handle = tokio::runtime::Handle::current();
|
let handle = tokio::runtime::Handle::current();
|
||||||
@ -323,7 +332,12 @@ impl Opener for RetinaOpener {
|
|||||||
Some(Ok(CodecItem::VideoFrame(v))) => {
|
Some(Ok(CodecItem::VideoFrame(v))) => {
|
||||||
deadline = tokio::time::Instant::now() + RETINA_TIMEOUT;
|
deadline = tokio::time::Instant::now() + RETINA_TIMEOUT;
|
||||||
if v.loss > 0 {
|
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() {
|
if frame_tx.send(Ok(v)).await.is_err() {
|
||||||
return; // other end died.
|
return; // other end died.
|
||||||
|
@ -109,11 +109,14 @@ where
|
|||||||
|
|
||||||
let (extra_data, mut stream) = {
|
let (extra_data, mut stream) = {
|
||||||
let _t = TimerGuard::new(&clocks, || format!("opening {}", self.url.as_str()));
|
let _t = TimerGuard::new(&clocks, || format!("opening {}", self.url.as_str()));
|
||||||
self.opener.open(stream::Source::Rtsp {
|
self.opener.open(
|
||||||
url: self.url.clone(),
|
self.short_name.clone(),
|
||||||
username: self.username.clone(),
|
stream::Source::Rtsp {
|
||||||
password: self.password.clone(),
|
url: self.url.clone(),
|
||||||
})?
|
username: self.username.clone(),
|
||||||
|
password: self.password.clone(),
|
||||||
|
},
|
||||||
|
)?
|
||||||
};
|
};
|
||||||
let realtime_offset = self.db.clocks().realtime() - clocks.monotonic();
|
let realtime_offset = self.db.clocks().realtime() - clocks.monotonic();
|
||||||
let video_sample_entry_id = {
|
let video_sample_entry_id = {
|
||||||
@ -285,6 +288,7 @@ mod tests {
|
|||||||
impl stream::Opener for MockOpener {
|
impl stream::Opener for MockOpener {
|
||||||
fn open(
|
fn open(
|
||||||
&self,
|
&self,
|
||||||
|
_label: String,
|
||||||
src: stream::Source,
|
src: stream::Source,
|
||||||
) -> Result<(h264::ExtraData, Box<dyn stream::Stream>), Error> {
|
) -> Result<(h264::ExtraData, Box<dyn stream::Stream>), Error> {
|
||||||
match src {
|
match src {
|
||||||
@ -337,7 +341,10 @@ mod tests {
|
|||||||
clocks.sleep(time::Duration::seconds(86400)); // to 2015-04-26 00:00:00 UTC
|
clocks.sleep(time::Duration::seconds(86400)); // to 2015-04-26 00:00:00 UTC
|
||||||
|
|
||||||
let (extra_data, stream) = stream::FFMPEG
|
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();
|
.unwrap();
|
||||||
let mut stream = ProxyingStream::new(clocks.clone(), time::Duration::seconds(2), stream);
|
let mut stream = ProxyingStream::new(clocks.clone(), time::Duration::seconds(2), stream);
|
||||||
stream.ts_offset = 123456; // starting pts of the input should be irrelevant
|
stream.ts_offset = 123456; // starting pts of the input should be irrelevant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user