Merge branch 'master' into srtp
This commit is contained in:
4 files changed
+41
-47
No files matched your search
@@ -1,6 +1,6 @@
|
||||
name: CI
|
||||
|
||||
on: [push]
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
ubuntu:
|
||||
|
||||
@@ -17,12 +17,12 @@ Neolink intends to support all Reolink cameras that do not provide native RTSP.
|
||||
Currently it has been tested on the following cameras:
|
||||
|
||||
- B800/D800
|
||||
- E1
|
||||
|
||||
It *should* support the following cameras, but this has not yet been tested.
|
||||
Please test if you have them, and [open an issue](https://github.com/thirtythreeforty/neolink/issues/new/choose) if you encounter problems:
|
||||
|
||||
- B400/D400
|
||||
- E1
|
||||
- Lumus
|
||||
|
||||
Neolink does not support other cameras such as the RLC-420, since they already [provide native RTSP](https://support.reolink.com/hc/en-us/articles/360007010473-How-to-Live-View-Reolink-Cameras-via-VLC-Media-Player).
|
||||
@@ -63,9 +63,12 @@ Copy and modify the `sample_config.toml` to specify the address, username, and p
|
||||
Each `[[cameras]]` block creates a new camera; the `name` determines the RTSP path you should connect your client to.
|
||||
Currently Neolink cannot auto-detect cameras like the official clients do; you must specify their IP addresses directly.
|
||||
|
||||
By default the h265 streaming format is used. Some cameras, for example E1, provide h264 streams, to use these you must specify `format = "h264"` in the `[[cameras]]` config.
|
||||
By default the H265 video format is used. Some cameras, for example E1, provide H264 streams. To use these you must specify `format = "h264"` in the `[[cameras]]` config.
|
||||
Soon this will be auto-detected, and you will not have to know or care about the format.
|
||||
|
||||
By default the HD stream is mounted at `name` and at `name/mainStream` and the SD stream is mounted at `name/subStream`. You can specify mounting only one by adding `stream = "subStream"` to the `[[cameras]]` config. You may also need to use `h264` format while using the SD stream.
|
||||
By default, the HD stream is available at the RTSP path `/name` or `/name/mainStream`, and the SD stream is available at `/name/subStream`.
|
||||
You can disable the HD stream by adding `stream = "subStream"` to the `[[cameras]]` config.
|
||||
You may also need to use `h264` format while using the SD stream.
|
||||
|
||||
By default Neolink serves on all IP addresses on port 8554.
|
||||
You can modify this by changing the `bind` and the `bind_port` parameter.
|
||||
@@ -90,14 +93,11 @@ export RUST_LOG=debug
|
||||
|
||||
Connect your RTSP client to the stream with the name you provided in the configuration file.
|
||||
Again, the default URL is `rtsp://127.0.0.1:8554/your_camera_name` if you're running it on the same computer as the client.
|
||||
The smaller SD video is `rtsp://127.0.0.1:8554/your_camera_name/subStream`.
|
||||
|
||||
4K cameras send large video "key frames" once every few seconds and the client must have a receive buffer large enough to store the entire frame.
|
||||
If your client's buffer size is configurable (like Blue Iris), ensure it's set to 20MB, which should ensure plenty of headroom.
|
||||
|
||||
Note that some RTSP clients, especially VLC, have trouble handling the stream.
|
||||
Currently this seems to be related to receive buffer sizes but the exact cause remains unclear.
|
||||
Blue Iris is known to work well.
|
||||
|
||||
## Stability
|
||||
|
||||
Neolink has had minimal testing, but it seems to be very reliable in multiple users' testing.
|
||||
|
||||
+4
-2
@@ -35,7 +35,7 @@ impl RtspServer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_stream(&self, name: &str, stream_format: &StreamFormat) -> Result<MaybeAppSrc> {
|
||||
pub fn add_stream(&self, names: &[&str], stream_format: &StreamFormat) -> Result<MaybeAppSrc> {
|
||||
let mounts = self
|
||||
.server
|
||||
.get_mount_points()
|
||||
@@ -91,7 +91,9 @@ impl RtspServer {
|
||||
let _ = tx.send(app_src); // Receiver may be dropped, don't panic if so
|
||||
});
|
||||
|
||||
mounts.add_factory(&format!("/{}", name), &factory);
|
||||
for name in names {
|
||||
mounts.add_factory(&format!("/{}", name), &factory);
|
||||
}
|
||||
|
||||
Ok(maybe_app_src)
|
||||
}
|
||||
|
||||
+29
-37
@@ -9,6 +9,7 @@ use neolink::gst::{MaybeAppSrc, RtspServer, StreamFormat};
|
||||
use neolink::Never;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use structopt::StructOpt;
|
||||
use validator::Validate;
|
||||
@@ -42,39 +43,13 @@ fn main() -> Result<(), Error> {
|
||||
);
|
||||
|
||||
let opt = Opt::from_args();
|
||||
let mut config: Config = toml::from_str(&fs::read_to_string(opt.config)?)?;
|
||||
let config: Config = toml::from_str(&fs::read_to_string(opt.config)?)?;
|
||||
|
||||
match config.validate() {
|
||||
Ok(_) => (),
|
||||
Err(e) => return Err(Error::ValidationError(e)),
|
||||
};
|
||||
|
||||
// Setup auto sub streams, we do this by looping the cameras
|
||||
// If the stream type is both we clone the config
|
||||
// On one of the clones we set stream_source to "mainStream" on the other "subStream"
|
||||
// We also change the mount name by appending "/mainStream" or "/subStream"
|
||||
// On the original uncloned config we change the stream from "both" to "mainStream" and leave the mount name unchanged
|
||||
let mut new_cam_configs = vec![];
|
||||
|
||||
for camera_config in &mut config.cameras {
|
||||
if camera_config.stream == "both" {
|
||||
let mut main_camera_config = camera_config.clone();
|
||||
let mut sub_camera_config = camera_config.clone();
|
||||
|
||||
camera_config.stream = "mainStream".to_string();
|
||||
|
||||
main_camera_config.stream = "mainStream".to_string();
|
||||
main_camera_config.name = format!("{}/{}", main_camera_config.name, main_camera_config.stream);
|
||||
new_cam_configs.push(main_camera_config);
|
||||
|
||||
sub_camera_config.stream = "subStream".to_string();
|
||||
sub_camera_config.name = format!("{}/{}", sub_camera_config.name, sub_camera_config.stream);
|
||||
sub_camera_config.format = "h264".to_string(); // Assuming always H264 on subStream: TODO: Autodetect
|
||||
new_cam_configs.push(sub_camera_config);
|
||||
}
|
||||
}
|
||||
config.cameras.append(&mut new_cam_configs);
|
||||
|
||||
let rtsp = &RtspServer::new();
|
||||
|
||||
let tls_client_auth = match &config.tls_client_auth as &str {
|
||||
@@ -89,16 +64,33 @@ fn main() -> Result<(), Error> {
|
||||
|
||||
crossbeam::scope(|s| {
|
||||
for camera in config.cameras {
|
||||
s.spawn(move |_| {
|
||||
// TODO handle these errors
|
||||
let stream_format = match &camera.format as &str {
|
||||
"h264"|"H264" => StreamFormat::H264,
|
||||
"h265"|"H265" => StreamFormat::H265,
|
||||
custom_format @ _ => StreamFormat::Custom(custom_format.to_string())
|
||||
};
|
||||
let mut output = rtsp.add_stream(&camera.name, &stream_format).unwrap();
|
||||
camera_loop(&camera, &mut output)
|
||||
});
|
||||
let stream_format = match &*camera.format {
|
||||
"h264"|"H264" => StreamFormat::H264,
|
||||
"h265"|"H265" => StreamFormat::H265,
|
||||
custom_format @ _ => StreamFormat::Custom(custom_format.to_string())
|
||||
};
|
||||
|
||||
// Let subthreads share the camera object; in principle I think they could share
|
||||
// the object as it sits in the config.cameras block, but I have not figured out the
|
||||
// syntax for that.
|
||||
let arc_cam = Arc::new(camera);
|
||||
|
||||
// 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 mut output = rtsp.add_stream(paths, &stream_format).unwrap();
|
||||
let main_camera = arc_cam.clone();
|
||||
s.spawn(move |_| camera_loop(&*main_camera, &mut output));
|
||||
}
|
||||
if arc_cam.stream == "both" || arc_cam.stream == "subStream" {
|
||||
let paths = &[&*format!("{}/subStream", arc_cam.name)];
|
||||
let mut output = rtsp.add_stream(paths, &stream_format).unwrap();
|
||||
let sub_camera = arc_cam.clone();
|
||||
s.spawn(move |_| camera_loop(&*sub_camera, &mut output));
|
||||
}
|
||||
}
|
||||
|
||||
rtsp.run(&config.bind_addr, config.bind_port);
|
||||
|
||||
Reference in new issue
Block a user