-allow setting channel_id

This commit is contained in:
twistedddx committed 2020-08-14 23:26:42 +09:30
1 parent 9f3181e2cd
commit e4f67ef3c2
3 files changed
+11 -3

No files matched your search

+2 -2
View File
@@ -244,7 +244,7 @@ impl BcCamera {
Ok(())
}
pub fn start_video(&self, data_out: &mut dyn Write, stream_name: &str) -> Result<Never> {
pub fn start_video(&self, data_out: &mut dyn Write, stream_name: &str, channel_id: u32) -> Result<Never> {
let connection = self
.connection
.as_ref()
@@ -261,7 +261,7 @@ impl BcCamera {
BcXml {
preview: Some(Preview {
version: xml_ver(),
channel_id: 0,
channel_id: channel_id,
handle: 0,
stream_type: stream_name.to_string(),
}),
+8
View File
@@ -71,6 +71,10 @@ pub struct CameraConfig {
pub stream: String,
pub permitted_users: Option<Vec<String>>,
#[validate(range(min = 0, max = 31, message = "Invalid channel", code = "channel_id"))]
#[serde(default = "default_channel_id")]
pub channel_id: u32,
}
#[derive(Debug, Deserialize, Validate, Clone)]
@@ -107,6 +111,10 @@ fn default_tls_client_auth() -> String {
"none".to_string()
}
fn default_channel_id() -> u32 {
0
}
pub static RESERVED_NAMES: &[&str] = &["anyone", "anonymous"];
fn validate_username(name: &str) -> Result<(), ValidationError> {
if name.trim().is_empty() {
+1 -1
View File
@@ -246,7 +246,7 @@ fn camera_main(
"{}: Starting video stream {}",
camera_config.name, stream_name
);
camera.start_video(output, stream_name)
camera.start_video(output, stream_name, camera_config.channel_id)
})()
.map_err(|err| CameraErr { connected, err })
}