diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 98 | ||||
| -rw-r--r-- | src/main.rs | 3 | ||||
| -rw-r--r-- | src/ui.rs | 8 |
3 files changed, 101 insertions, 8 deletions
diff --git a/src/config.rs b/src/config.rs index 54f94dd..64f3c09 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,11 +1,13 @@ -use std::fs; +use std::{collections::HashMap, fs}; use anyhow::Context; use serde::{Deserialize, Serialize}; +use serde_json::json; type Protection = u8; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Service { + pub unique_id: String, pub sid: u32, pub ecc: u8, pub label: String, @@ -23,6 +25,30 @@ impl Service { pub fn ecc_hex(&self) -> String { format!("{:02X}", self.ecc) } + + pub fn dump_to_service_json(&self) -> serde_json::Value { + json!({ + "id": self.sid, + "ecc": self.ecc, + "label": self.label, + "shortlabel": self.shortlabel, + }) + } + + pub fn dump_to_subchannel_json(&self, id: u32) -> serde_json::Value { + json!({ + "type": "dabplus", + "bitrate": self.bitrate, + "id": id, + "protection": self.protection, + + "inputproto": "edi", + "inputuri": format!("tcp://127.0.0.1:{}", self.input_port), + "buffer-management": "prebuffering", + "buffer": 40, + "prebuffering": 20 + }) + } } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -62,6 +88,7 @@ impl Default for Config { output_edi_port: 8951, services: vec