redact URLs within stream.rs; fixes #13
This commit is contained in:
parent
d7a0cb9a7c
commit
579150c9d5
|
@ -1,3 +1,5 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "MacTypes-sys"
|
name = "MacTypes-sys"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
|
|
@ -102,7 +102,10 @@ fn press_edit(siv: &mut Cursive, db: &Arc<db::Database>, id: Option<i32>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn press_test_inner(url: &str) -> Result<String, Error> {
|
fn press_test_inner(url: &str) -> Result<String, Error> {
|
||||||
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()?;
|
let extra_data = stream.get_extra_data()?;
|
||||||
Ok(format!("{}x{} video stream", extra_data.width, extra_data.height))
|
Ok(format!("{}x{} video stream", extra_data.width, extra_data.height))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1812,7 +1812,7 @@ mod tests {
|
||||||
pkt.is_key()).unwrap();
|
pkt.is_key()).unwrap();
|
||||||
end_pts = Some(pts + pkt.duration() as i64);
|
end_pts = Some(pts + pkt.duration() as i64);
|
||||||
}
|
}
|
||||||
output.close(end_pts);
|
output.close(end_pts).unwrap();
|
||||||
db.syncer_channel.flush();
|
db.syncer_channel.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,15 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Source<'a> {
|
pub enum Source<'a> {
|
||||||
|
/// A filename, for testing.
|
||||||
#[cfg(test)]
|
#[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<S : Stream> : Sync {
|
pub trait Opener<S : Stream> : Sync {
|
||||||
|
@ -98,7 +103,7 @@ impl Opener<FfmpegStream> for Ffmpeg {
|
||||||
}
|
}
|
||||||
(i, false)
|
(i, false)
|
||||||
}
|
}
|
||||||
Source::Rtsp(url) => {
|
Source::Rtsp{url, redacted_url} => {
|
||||||
let mut open_options = ffmpeg::Dictionary::new();
|
let mut open_options = ffmpeg::Dictionary::new();
|
||||||
open_options.set(c_str!("rtsp_transport"), c_str!("tcp")).unwrap();
|
open_options.set(c_str!("rtsp_transport"), c_str!("tcp")).unwrap();
|
||||||
open_options.set(c_str!("user-agent"), c_str!("moonfire-nvr")).unwrap();
|
open_options.set(c_str!("user-agent"), c_str!("moonfire-nvr")).unwrap();
|
||||||
|
@ -112,7 +117,7 @@ impl Opener<FfmpegStream> for Ffmpeg {
|
||||||
let i = InputFormatContext::open(&CString::new(url).unwrap(), &mut open_options)?;
|
let i = InputFormatContext::open(&CString::new(url).unwrap(), &mut open_options)?;
|
||||||
if !open_options.empty() {
|
if !open_options.empty() {
|
||||||
warn!("While opening URL {}, some options were not understood: {}",
|
warn!("While opening URL {}, some options were not understood: {}",
|
||||||
url, open_options);
|
redacted_url, open_options);
|
||||||
}
|
}
|
||||||
(i, true)
|
(i, true)
|
||||||
},
|
},
|
||||||
|
|
|
@ -103,7 +103,10 @@ impl<'a, C, S> Streamer<'a, C, S> where C: 'a + Clocks + Clone, S: 'a + stream::
|
||||||
|
|
||||||
let mut stream = {
|
let mut stream = {
|
||||||
let _t = TimerGuard::new(&clocks, || format!("opening {}", self.redacted_url));
|
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();
|
let realtime_offset = self.db.clocks().realtime() - clocks.monotonic();
|
||||||
// TODO: verify width/height.
|
// TODO: verify width/height.
|
||||||
|
@ -275,7 +278,7 @@ mod tests {
|
||||||
impl<'a> stream::Opener<ProxyingStream<'a>> for MockOpener<'a> {
|
impl<'a> stream::Opener<ProxyingStream<'a>> for MockOpener<'a> {
|
||||||
fn open(&self, src: stream::Source) -> Result<ProxyingStream<'a>, Error> {
|
fn open(&self, src: stream::Source) -> Result<ProxyingStream<'a>, Error> {
|
||||||
match src {
|
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"),
|
stream::Source::File(_) => panic!("expected rtsp url"),
|
||||||
};
|
};
|
||||||
let mut l = self.streams.lock();
|
let mut l = self.streams.lock();
|
||||||
|
|
Loading…
Reference in New Issue