Added port specification
This commit is contained in:
4 files changed
+17
-5
No files matched your search
@@ -68,7 +68,7 @@ By default the h265 streaming format is used. Some cameras, for example E1, prov
|
||||
By default the HD stream is used. To swap to the SD stream add `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` parameter.
|
||||
You can modify this by changing the `bind` and the `bind_port` parameter.
|
||||
|
||||
You can change the Neolink log level by setting the `RUST_LOG` environment variable (not in the configuration file) to one of `error`, `warn`, `info`, `debug`, or `trace`:
|
||||
|
||||
|
||||
+9
-1
@@ -9,12 +9,16 @@ lazy_static! {
|
||||
static ref RE_STREAM_SRC: Regex = Regex::new(r"^(mainStream|subStream)$").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Validate)]
|
||||
pub struct Config {
|
||||
pub cameras: Vec<CameraConfig>,
|
||||
|
||||
#[serde(rename = "bind", default = "default_bind_addr")]
|
||||
pub bind_addr: String,
|
||||
|
||||
#[validate(range(min = 0, max = 65535, message = "Invalid port", code = "bind_port"))]
|
||||
#[serde(default = "default_bind_port")]
|
||||
pub bind_port: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Validate)]
|
||||
@@ -42,6 +46,10 @@ fn default_bind_addr() -> String {
|
||||
"0.0.0.0".to_string()
|
||||
}
|
||||
|
||||
fn default_bind_port() -> u16 {
|
||||
8554
|
||||
}
|
||||
|
||||
fn default_format() -> String {
|
||||
"h265".to_string()
|
||||
}
|
||||
|
||||
+2
-2
@@ -100,9 +100,9 @@ impl RtspServer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run(&self, bind_addr: &str) {
|
||||
pub fn run(&self, bind_addr: &str, bind_port: u16) {
|
||||
self.server.set_address(bind_addr);
|
||||
|
||||
self.server.set_service(&format!("{}", bind_port));
|
||||
// Attach server to default Glib context
|
||||
self.server.attach(None);
|
||||
|
||||
|
||||
+5
-1
@@ -43,6 +43,10 @@ fn main() -> Result<(), Error> {
|
||||
let opt = Opt::from_args();
|
||||
let config: Config = toml::from_str(&fs::read_to_string(opt.config)?)?;
|
||||
|
||||
match config.validate() {
|
||||
Ok(_) => (),
|
||||
Err(e) => return Err(Error::ValidationError(e)),
|
||||
};
|
||||
for camera in &config.cameras {
|
||||
match camera.validate() {
|
||||
Ok(_) => (),
|
||||
@@ -67,7 +71,7 @@ fn main() -> Result<(), Error> {
|
||||
});
|
||||
}
|
||||
|
||||
rtsp.run(&config.bind_addr);
|
||||
rtsp.run(&config.bind_addr, config.bind_port);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
||||
Reference in new issue
Block a user