Format RTSP paths exclusively in one place

This commit is contained in:
George Hilliard committed 2020-07-04 12:26:06 -05:00
1 parent 085c59d355
commit fc86e04861
2 files changed
+8 -5

No files matched your search

+3 -3
View File
@@ -32,7 +32,7 @@ impl RtspServer {
}
}
pub fn add_stream(&self, names: &[&str], stream_format: &StreamFormat) -> Result<MaybeAppSrc> {
pub fn add_stream(&self, paths: &[&str], stream_format: &StreamFormat) -> Result<MaybeAppSrc> {
let mounts = self
.server
.get_mount_points()
@@ -77,8 +77,8 @@ impl RtspServer {
let _ = tx.send(app_src); // Receiver may be dropped, don't panic if so
});
for name in names {
mounts.add_factory(&format!("/{}", name), &factory);
for path in paths {
mounts.add_factory(path, &factory);
}
Ok(maybe_app_src)
+5 -2
View File
@@ -74,13 +74,16 @@ fn main() -> Result<(), Error> {
// Set up each main and substream according to all the RTSP mount paths we support
if arc_cam.stream == "both" || arc_cam.stream == "mainStream" {
let paths = &[&arc_cam.name, &*format!("{}/mainStream", arc_cam.name)];
let paths = &[
&*format!("/{}", arc_cam.name),
&*format!("/{}/mainStream", arc_cam.name),
];
let mut output = rtsp.add_stream(paths, &stream_format).unwrap();
let main_camera = arc_cam.clone();
s.spawn(move |_| camera_loop(&*main_camera, "mainStream", &mut output));
}
if arc_cam.stream == "both" || arc_cam.stream == "subStream" {
let paths = &[&*format!("{}/subStream", arc_cam.name)];
let paths = &[&*format!("/{}/subStream", arc_cam.name)];
let mut output = rtsp.add_stream(paths, &substream_format).unwrap();
let sub_camera = arc_cam.clone();
s.spawn(move |_| camera_loop(&*sub_camera, "subStream", &mut output));