diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2025-03-23 23:05:14 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2025-03-23 23:05:14 +0100 |
commit | ef6ea5ab6b927fcf9e5152fbf44f72646848d2c9 (patch) | |
tree | bc438ec3094b00eeee973766074e55e56f47cfd2 /src | |
parent | d57e0e9635a18f226394b9f41feef1658a2e051c (diff) | |
download | dabmux-next.tar.gz dabmux-next.tar.bz2 dabmux-next.zip |
Common b23da85: make PFT per-output configurablenext
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMux.cpp | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 1a367da..bf525c1 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -327,6 +327,38 @@ int main(int argc, char *argv[]) if (outputuid == "edi") { ptree pt_edi = pt_outputs.get_child("edi"); + bool default_enable_pft = pt_edi.get<bool>("enable_pft", false); + edi_conf.verbose = pt_edi.get<bool>("verbose", false); + + unsigned int default_fec = pt_edi.get<unsigned int>("fec", 3); + unsigned int default_chunk_len = pt_edi.get<unsigned int>("chunk_len", 207); + + auto check_spreading_factor = [](int percent) { + if (percent < 0) { + throw std::runtime_error("EDI output: negative packet_spread value is invalid."); + } + double factor = (double)percent / 100.0; + if (factor > 30000) { + throw std::runtime_error("EDI output: interleaving set for more than 30 seconds!"); + } + return factor; + }; + + double default_spreading_factor = check_spreading_factor(pt_edi.get<int>("packet_spread", 95)); + + using pt_t = boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char>>; + auto handle_overrides = [&](edi::pft_settings_t& pft_settings, pt_t pt) { + pft_settings.chunk_len = pt.get<unsigned int>("chunk_len", default_chunk_len); + pft_settings.enable_pft = pt.get<bool>("enable_pft", default_enable_pft); + pft_settings.fec = pt.get<unsigned int>("fec", default_fec); + pft_settings.fragment_spreading_factor = default_spreading_factor; + auto override_spread_percent = pt.get_optional<int>("packet_spread"); + if (override_spread_percent) { + pft_settings.fragment_spreading_factor = check_spreading_factor(*override_spread_percent); + } + pft_settings.verbose = pt.get<bool>("verbose", edi_conf.verbose); + }; + for (auto pt_edi_dest : pt_edi.get_child("destinations")) { const auto proto = pt_edi_dest.second.get<string>("protocol", "udp"); if (proto == "udp") { @@ -346,6 +378,8 @@ int main(int argc, char *argv[]) dest->dest_port = pt_edi.get<unsigned int>("port"); } + handle_overrides(dest->pft_settings, pt_edi_dest.second); + edi_conf.destinations.push_back(dest); } else if (proto == "tcp") { @@ -355,6 +389,8 @@ int main(int argc, char *argv[]) double preroll = pt_edi_dest.second.get<double>("preroll-burst", 0.0); dest->tcp_server_preroll_buffers = ceil(preroll / 24e-3); + handle_overrides(dest->pft_settings, pt_edi_dest.second); + edi_conf.destinations.push_back(dest); } else { @@ -362,22 +398,6 @@ int main(int argc, char *argv[]) } } - edi_conf.dump = pt_edi.get<bool>("dump", false); - edi_conf.enable_pft = pt_edi.get<bool>("enable_pft", false); - edi_conf.verbose = pt_edi.get<bool>("verbose", false); - - edi_conf.fec = pt_edi.get<unsigned int>("fec", 3); - edi_conf.chunk_len = pt_edi.get<unsigned int>("chunk_len", 207); - - int spread_percent = pt_edi.get<int>("packet_spread", 95); - if (spread_percent < 0) { - throw std::runtime_error("EDI output: negative packet_spread value is invalid."); - } - edi_conf.fragment_spreading_factor = (double)spread_percent / 100.0; - if (edi_conf.fragment_spreading_factor > 30000) { - throw std::runtime_error("EDI output: interleaving set for more than 30 seconds!"); - } - edi_conf.tagpacket_alignment = pt_edi.get<unsigned int>("tagpacket_alignment", 8); mux.set_edi_config(edi_conf); |