diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMultiplexer.cpp | 10 | ||||
-rw-r--r-- | src/DabMultiplexer.h | 4 | ||||
-rw-r--r-- | src/ManagementServer.cpp | 6 | ||||
-rw-r--r-- | src/MuxElements.cpp | 62 | ||||
-rw-r--r-- | src/MuxElements.h | 16 | ||||
-rw-r--r-- | src/dabOutput/dabOutputZMQ.cpp | 1 | ||||
-rw-r--r-- | src/input/Edi.cpp | 21 | ||||
-rw-r--r-- | src/input/Edi.h | 3 | ||||
-rw-r--r-- | src/input/Zmq.cpp | 12 | ||||
-rw-r--r-- | src/input/Zmq.h | 1 |
10 files changed, 121 insertions, 15 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index fb5ec45..908caf9 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2020 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li */ /* @@ -820,3 +820,11 @@ const std::string DabMultiplexer::get_parameter(const std::string& parameter) co } +const json::map_t DabMultiplexer::get_all_values() const +{ + json::map_t map; + map["frames"].v = m_currentFrame; + map["tist_offset"].v = m_tist_offset; + return map; +} + diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h index 3b521ff..90e5767 100644 --- a/src/DabMultiplexer.h +++ b/src/DabMultiplexer.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2019 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li */ /* @@ -76,6 +76,8 @@ class DabMultiplexer : public RemoteControllable { /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; + virtual const json::map_t get_all_values() const; + private: void prepare_subchannels(void); void prepare_services_components(void); diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp index 599d744..568e80e 100644 --- a/src/ManagementServer.cpp +++ b/src/ManagementServer.cpp @@ -280,8 +280,10 @@ void ManagementServer::serverThread() if (pollItems[0].revents & ZMQ_POLLIN) { zmq::message_t zmq_message; - m_zmq_sock.recv(zmq_message); - handle_message(zmq_message); + const auto r = m_zmq_sock.recv(zmq_message); + if (r.has_value()) { + handle_message(zmq_message); + } } } } diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index 71ff270..d17b283 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) 2020 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -86,7 +86,7 @@ bool AnnouncementCluster::is_active() if (*m_deferred_start_time <= now) { m_active = true; - m_deferred_start_time = boost::none; + m_deferred_start_time.reset(); } } @@ -96,7 +96,7 @@ bool AnnouncementCluster::is_active() if (*m_deferred_stop_time <= now) { m_active = false; - m_deferred_stop_time = boost::none; + m_deferred_stop_time.reset(); } } @@ -180,6 +180,34 @@ const string AnnouncementCluster::get_parameter(const string& parameter) const return ss.str(); } +const json::map_t AnnouncementCluster::get_all_values() const +{ + json::map_t map; + + lock_guard<mutex> lock(m_active_mutex); + map["active"].v = m_active; + + using namespace std::chrono; + + if (m_deferred_start_time) { + const auto diff = *m_deferred_start_time - steady_clock::now(); + map["start_in"].v = duration_cast<milliseconds>(diff).count(); + } + else { + map["start_in"].v = nullopt; + } + + if (m_deferred_stop_time) { + const auto diff = *m_deferred_stop_time - steady_clock::now(); + map["stop_in"].v = duration_cast<milliseconds>(diff).count(); + } + else { + map["stop_in"].v = nullopt; + } + + return map; +} + int DabLabel::setLabel(const std::string& label) { @@ -512,6 +540,16 @@ const string DabComponent::get_parameter(const string& parameter) const } +const json::map_t DabComponent::get_all_values() const +{ + json::map_t map; + // It's cleaner to have it separate in JSON, but we + // need the comma separated variant for setting + map["label"].v = label.long_label(); + map["shortlabel"].v = label.short_label(); + return map; +} + subchannel_type_t DabService::getType( const std::shared_ptr<dabEnsemble> ensemble) const { @@ -638,6 +676,16 @@ const string DabService::get_parameter(const string& parameter) const return ss.str(); } +const json::map_t DabService::get_all_values() const +{ + json::map_t map; + map["label"].v = label.long_label(); + map["shortlabel"].v = label.short_label(); + map["pty"].v = (int)pty_settings.pty; + map["ptysd"].v = (pty_settings.dynamic_no_static ? "dynamic" : "static"); + return map; +} + void dabEnsemble::set_parameter(const string& parameter, const string& value) { if (parameter == "localtimeoffset") { @@ -687,6 +735,14 @@ const string dabEnsemble::get_parameter(const string& parameter) const return ss.str(); } +const json::map_t dabEnsemble::get_all_values() const +{ + json::map_t map; + map["localtimeoffset_auto"].v = lto_auto; + map["localtimeoffset"].v = lto; + return map; +} + bool dabEnsemble::validate_linkage_sets() { for (const auto& ls : linkagesets) { diff --git a/src/MuxElements.h b/src/MuxElements.h index 1e9b707..d118df9 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) 2022 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -37,7 +37,7 @@ #include <exception> #include <algorithm> #include <chrono> -#include <boost/optional.hpp> +#include <optional> #include <stdint.h> #include "dabOutput/dabOutput.h" #include "input/inputs.h" @@ -150,10 +150,10 @@ class AnnouncementCluster : public RemoteControllable { private: mutable std::mutex m_active_mutex; bool m_active = false; - boost::optional< + std::optional< std::chrono::time_point< std::chrono::steady_clock> > m_deferred_start_time; - boost::optional< + std::optional< std::chrono::time_point< std::chrono::steady_clock> > m_deferred_stop_time; @@ -163,6 +163,8 @@ class AnnouncementCluster : public RemoteControllable { /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; + + virtual const json::map_t get_all_values() const; }; struct dabOutput { @@ -310,6 +312,8 @@ class dabEnsemble : public RemoteControllable { /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; + virtual const json::map_t get_all_values() const; + /* Check if the Linkage Sets are valid */ bool validate_linkage_sets(void); @@ -483,6 +487,8 @@ class DabComponent : public RemoteControllable /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; + + virtual const json::map_t get_all_values() const; }; class DabService : public RemoteControllable @@ -536,6 +542,8 @@ class DabService : public RemoteControllable /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; + + virtual const json::map_t get_all_values() const; }; /* Represent an entry for FIG0/24 */ diff --git a/src/dabOutput/dabOutputZMQ.cpp b/src/dabOutput/dabOutputZMQ.cpp index 0680f21..9b119f6 100644 --- a/src/dabOutput/dabOutputZMQ.cpp +++ b/src/dabOutput/dabOutputZMQ.cpp @@ -59,7 +59,6 @@ int DabOutputZMQ::Open(const char* endpoint) { // bind to uri string proto_endpoint = zmq_proto_ + "://" + std::string(endpoint); - std::cerr << "ZMQ socket " << proto_endpoint << std::endl; zmq_pub_sock_.bind(proto_endpoint.c_str()); endpoint_ = endpoint; diff --git a/src/input/Edi.cpp b/src/input/Edi.cpp index 692ecb3..3838541 100644 --- a/src/input/Edi.cpp +++ b/src/input/Edi.cpp @@ -2,7 +2,7 @@ Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2019 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -470,7 +470,7 @@ const std::string Edi::get_parameter(const std::string& parameter) const ss << "prebuffering"; break; case Inputs::BufferManagement::Timestamped: - ss << "Timestamped"; + ss << "timestamped"; break; } } @@ -483,4 +483,21 @@ const std::string Edi::get_parameter(const std::string& parameter) const return ss.str(); } +const json::map_t Edi::get_all_values() const +{ + json::map_t map; + map["buffer"].v = m_max_frames_overrun; + map["prebuffering"].v = m_num_frames_prebuffering; + switch (getBufferManagement()) { + case Inputs::BufferManagement::Prebuffering: + map["buffermanagement"].v = "prebuffering"; + break; + case Inputs::BufferManagement::Timestamped: + map["buffermanagement"].v = "timestamped"; + break; + } + map["tistdelay"].v = m_tist_delay.count(); + return map; +} + } diff --git a/src/input/Edi.h b/src/input/Edi.h index cf4c576..3de17a7 100644 --- a/src/input/Edi.h +++ b/src/input/Edi.h @@ -2,7 +2,7 @@ Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2019 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -78,6 +78,7 @@ class Edi : public InputBase, public RemoteControllable { /* Remote control */ virtual void set_parameter(const std::string& parameter, const std::string& value); virtual const std::string get_parameter(const std::string& parameter) const; + virtual const json::map_t get_all_values() const; protected: void m_run(); diff --git a/src/input/Zmq.cpp b/src/input/Zmq.cpp index be3fd1f..d5e722e 100644 --- a/src/input/Zmq.cpp +++ b/src/input/Zmq.cpp @@ -614,7 +614,19 @@ const string ZmqBase::get_parameter(const string& parameter) const throw ParameterError(ss.str()); } return ss.str(); +} +const json::map_t ZmqBase::get_all_values() const +{ + json::map_t map; + map["buffer"].v = m_config.buffer_size; + map["prebuffering"].v = m_config.prebuffering; + map["enable"].v = m_enable_input; + map["encryption"].v = m_config.enable_encryption; + map["secretkey"].v = m_config.curve_secret_keyfile; + map["publickey"].v = m_config.curve_public_keyfile; + map["encoderkey"].v = m_config.curve_encoder_keyfile; + return map; } }; diff --git a/src/input/Zmq.h b/src/input/Zmq.h index c101da0..72fccbd 100644 --- a/src/input/Zmq.h +++ b/src/input/Zmq.h @@ -194,6 +194,7 @@ class ZmqBase : public InputBase, public RemoteControllable { /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const; + virtual const json::map_t get_all_values() const; protected: virtual int readFromSocket(size_t framesize) = 0; |