diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-29 11:29:43 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-29 11:29:43 +0100 |
commit | 21343ab11ca474bd4be5e9a328f1711359776601 (patch) | |
tree | 3de2116746f60b662565c9c009cf458b36f02f7a | |
parent | f93da1ac5da7081b097d1420609b1833663493cd (diff) | |
download | dabmux-21343ab11ca474bd4be5e9a328f1711359776601.tar.gz dabmux-21343ab11ca474bd4be5e9a328f1711359776601.tar.bz2 dabmux-21343ab11ca474bd4be5e9a328f1711359776601.zip |
PTy: add static/dynamic setting to configuration and RC
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | src/ConfigParser.cpp | 16 | ||||
-rw-r--r-- | src/MuxElements.cpp | 55 | ||||
-rw-r--r-- | src/MuxElements.h | 11 | ||||
-rw-r--r-- | src/fig/FIG0_17.cpp | 6 | ||||
-rw-r--r-- | src/utils.cpp | 8 |
6 files changed, 60 insertions, 46 deletions
@@ -42,16 +42,6 @@ Multicast support for the UDP input The current UDP input implementation cannot join a multicast group. -Clarify usage of PTy --------------------- -We currently transmit dynamic PTy in FIG0/17 since it can be changed in -through the remote control. Some receivers might not display the dynamic -PTy, but only the static PTy. Clarify if we need to add both PTy variants -to the configuration and the code. - -Also, check in the latest spec what changed regarding PTy. - - Improvements for inputs ----------------------- Add statistics to UDP input, in a similar way that ZeroMQ offers statistics. diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index c2f286d..17b34ca 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2017 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -589,7 +589,19 @@ void parse_ptree( } service->id = new_service_id; - service->pty = hexparse(pt_service.get("pty", "0")); + service->pty_settings.pty = hexparse(pt_service.get("pty", "0")); + // Default to dynamic for backward compatibility + const string dynamic_no_static_str = pt_service.get("pty-sd", "dynamic"); + if (dynamic_no_static_str == "dynamic") { + service->pty_settings.dynamic_no_static = true; + } + else if (dynamic_no_static_str == "static") { + service->pty_settings.dynamic_no_static = false; + } + else { + throw runtime_error("pty-sd setting for service " + + serviceuid + " is invalid"); + } service->language = hexparse(pt_service.get("language", "0")); allservices[serviceuid] = service; diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index f8a3eb4..cdfcc42 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -443,9 +443,9 @@ bool DabService::isProgramme(const std::shared_ptr<dabEnsemble>& ensemble) const break; default: etiLog.log(error, - "Error, unknown service type: %u\n", + "Error, unknown service type: %u", getType(ensemble)); - throw std::runtime_error("DabService::isProgramme unknown service type"); + throw runtime_error("DabService::isProgramme unknown service type"); } return ret; @@ -462,8 +462,7 @@ unsigned char DabService::nbComponent(const vector<DabComponent*>& components) c return count; } -void DabService::set_parameter(const string& parameter, - const string& value) +void DabService::set_parameter(const string& parameter, const string& value) { if (parameter == "label") { vector<string> fields; @@ -474,29 +473,25 @@ void DabService::set_parameter(const string& parameter, } int success = this->label.setLabel(fields[0], fields[1]); stringstream ss; - switch (success) - { + switch (success) { case 0: break; case -1: - ss << m_name << " short label " << + ss << "Short label " << fields[1] << " is not subset of label '" << fields[0] << "'"; - etiLog.level(warn) << ss.str(); throw ParameterError(ss.str()); case -2: - ss << m_name << " short label " << + ss << "Short label " << fields[1] << " is too long (max 8 characters)"; - etiLog.level(warn) << ss.str(); throw ParameterError(ss.str()); case -3: - ss << m_name << " label " << + ss << "Label " << fields[0] << " is too long (max 16 characters)"; - etiLog.level(warn) << ss.str(); throw ParameterError(ss.str()); default: ss << m_name << " short label definition: program error !"; - etiLog.level(alert) << ss.str(); + etiLog.level(error) << ss.str(); throw ParameterError(ss.str()); } } @@ -504,13 +499,21 @@ void DabService::set_parameter(const string& parameter, int newpty = std::stoi(value); // International code, 5 bits if (newpty >= 0 and newpty < (1<<5)) { - pty = newpty; + pty_settings.pty = newpty; + } + else { + throw ParameterError("PTy value is out of bounds"); + } + } + else if (parameter == "ptysd") { + if (value == "static") { + pty_settings.dynamic_no_static = false; + } + else if (value == "dynamic") { + pty_settings.dynamic_no_static = true; } else { - stringstream ss; - ss << m_name << " pty is out of bounds"; - etiLog.level(warn) << ss.str(); - throw ParameterError(ss.str()); + throw ParameterError("Invalid value for ptysd, use static or dynamic"); } } else { @@ -528,7 +531,10 @@ const string DabService::get_parameter(const string& parameter) const ss << label.long_label() << "," << label.short_label(); } else if (parameter == "pty") { - ss << (int)pty; + ss << (int)pty_settings.pty; + } + else if (parameter == "ptysd") { + ss << (pty_settings.dynamic_no_static ? "dynamic" : "static"); } else { ss << "Parameter '" << parameter << @@ -536,7 +542,6 @@ const string DabService::get_parameter(const string& parameter) const throw ParameterError(ss.str()); } return ss.str(); - } void dabEnsemble::set_parameter(const string& parameter, const string& value) @@ -610,8 +615,7 @@ unsigned short DabSubchannel::getSizeCu() const return (bitrate >> 1); break; default: // Should not happens - etiLog.log(error, "Bad protection level on " - "subchannel\n"); + etiLog.log(error, "Bad protection level on subchannel"); return 0; } break; @@ -630,13 +634,12 @@ unsigned short DabSubchannel::getSizeCu() const return (bitrate * 15) >> 5; break; default: // Should not happens - etiLog.log(error, - "Bad protection level on subchannel\n"); + etiLog.log(error, "Bad protection level on subchannel"); return 0; } break; default: - etiLog.log(error, "Invalid protection option\n"); + etiLog.log(error, "Invalid protection option"); return 0; } } diff --git a/src/MuxElements.h b/src/MuxElements.h index c5a8faa..ba9941f 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2017 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -397,12 +397,19 @@ class DabService : public RemoteControllable { RC_ADD_PARAMETER(label, "Label and shortlabel [label,short]"); RC_ADD_PARAMETER(pty, "Programme Type"); + RC_ADD_PARAMETER(ptysd, "PTy Static/Dynamic [static,dynamic]"); } std::string uid; uint32_t id = 0; - unsigned char pty = 0; + struct pty_settings_t { + uint8_t pty = 0; // 0 means disabled + bool dynamic_no_static = false; + }; + + pty_settings_t pty_settings; + unsigned char language = 0; /* ASu (Announcement support) flags: this 16-bit flag field shall diff --git a/src/fig/FIG0_17.cpp b/src/fig/FIG0_17.cpp index 03d8814..e10130f 100644 --- a/src/fig/FIG0_17.cpp +++ b/src/fig/FIG0_17.cpp @@ -65,7 +65,7 @@ FillStatus FIG0_17::fill(uint8_t *buf, size_t max_size) for (; serviceFIG0_17 != ensemble->services.end(); ++serviceFIG0_17) { - if ((*serviceFIG0_17)->pty == 0) { + if ((*serviceFIG0_17)->pty_settings.pty == 0) { continue; } @@ -92,13 +92,13 @@ FillStatus FIG0_17::fill(uint8_t *buf, size_t max_size) auto fig0_17 = (FIGtype0_17*)buf; fig0_17->SId = htons((*serviceFIG0_17)->id); - fig0_17->SD = 1; // We only transmit dynamic PTy + fig0_17->SD = ((*serviceFIG0_17)->pty_settings.dynamic_no_static ? 1 : 0); fig0_17->rfa1 = 0; fig0_17->rfu1 = 0; fig0_17->rfa2_low = 0; fig0_17->rfa2_high = 0; fig0_17->rfu2 = 0; - fig0_17->IntCode = (*serviceFIG0_17)->pty; + fig0_17->IntCode = (*serviceFIG0_17)->pty_settings.pty; fig0->Length += 4; buf += 4; diff --git a/src/utils.cpp b/src/utils.cpp index 5675b1c..3e4c03b 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2017 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -220,8 +220,10 @@ void printServices(const vector<shared_ptr<DabService> >& services) etiLog.log(info, " id: 0x%lx (%lu)", service->id, service->id); - etiLog.log(info, " pty: 0x%x (%u)", service->pty, - service->pty); + etiLog.log(info, " pty: 0x%x (%u) %s", + service->pty_settings.pty, + service->pty_settings.pty, + service->pty_settings.dynamic_no_static ? "Dynamic" : "Static"); etiLog.log(info, " language: 0x%x (%u)", service->language, service->language); |