mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-19 19:14:53 +00:00
feat: add application and tcp_only to wivrn config
This commit is contained in:
parent
adbeffaba1
commit
92c7be52d1
3 changed files with 49 additions and 2 deletions
|
@ -108,6 +108,15 @@ impl Default for WivrnConfEncoder {
|
|||
}
|
||||
}
|
||||
|
||||
/// An application to start when connection with the headset is established,
|
||||
/// can be a string or an array of strings if parameters need to be provided.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub enum WivrnConfigApplication {
|
||||
Str(String),
|
||||
StrArr(Vec<String>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct WivrnConfig {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -115,6 +124,10 @@ pub struct WivrnConfig {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub bitrate: Option<u32>,
|
||||
pub encoders: Vec<WivrnConfEncoder>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub application: Option<WivrnConfigApplication>,
|
||||
#[serde(default)]
|
||||
pub tcp_only: bool,
|
||||
}
|
||||
|
||||
impl Default for WivrnConfig {
|
||||
|
@ -123,6 +136,8 @@ impl Default for WivrnConfig {
|
|||
scale: Some([0.8, 0.8]),
|
||||
bitrate: Some(50000000),
|
||||
encoders: vec![WivrnConfEncoder::default()],
|
||||
application: None,
|
||||
tcp_only: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +167,7 @@ pub fn dump_wivrn_config(config: &WivrnConfig) {
|
|||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::file_builders::wivrn_config::{Codec, Encoder};
|
||||
use crate::file_builders::wivrn_config::{Codec, Encoder, WivrnConfigApplication};
|
||||
|
||||
use super::get_wivrn_config_from_path;
|
||||
|
||||
|
@ -169,5 +184,20 @@ mod tests {
|
|||
assert_eq!(conf.encoders.first().unwrap().height, Some(1.0));
|
||||
assert_eq!(conf.encoders.first().unwrap().offset_x, Some(0.0));
|
||||
assert_eq!(conf.encoders.first().unwrap().offset_y, Some(0.0));
|
||||
assert_eq!(
|
||||
conf.application,
|
||||
Some(WivrnConfigApplication::Str("foobar".into()))
|
||||
);
|
||||
assert!(!conf.tcp_only);
|
||||
let conf = get_wivrn_config_from_path(Path::new("./test/files/wivrn_config2.json"))
|
||||
.expect("Couln't find wivrn config 2");
|
||||
assert_eq!(
|
||||
conf.application,
|
||||
Some(WivrnConfigApplication::StrArr(vec![
|
||||
"foobar".into(),
|
||||
"baz".into()
|
||||
]))
|
||||
);
|
||||
assert!(conf.tcp_only);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,5 +10,6 @@
|
|||
"offset_x": 0.0,
|
||||
"offset_y": 0.0
|
||||
}
|
||||
]
|
||||
],
|
||||
"application": "foobar"
|
||||
}
|
||||
|
|
16
test/files/wivrn_config2.json
Normal file
16
test/files/wivrn_config2.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"scale": [0.8, 0.8],
|
||||
"bitrate": 100000000,
|
||||
"encoders": [
|
||||
{
|
||||
"encoder": "x264",
|
||||
"codec": "h264",
|
||||
"width": 1.0,
|
||||
"height": 1.0,
|
||||
"offset_x": 0.0,
|
||||
"offset_y": 0.0
|
||||
}
|
||||
],
|
||||
"application": ["foobar", "baz"],
|
||||
"tcp_only": true
|
||||
}
|
Loading…
Add table
Reference in a new issue