summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-07-03 08:51:42 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-07-03 08:51:42 +0200
commit85853c4ae5e48359feac44370b4c0f05fbb23147 (patch)
treec8f72bf013f6a9b687c5c5d0f4622f24a3cff983
parent93cb9dc6d1492ac2ed58c24a016b579813177a13 (diff)
downloaddabmux-85853c4ae5e48359feac44370b4c0f05fbb23147.tar.gz
dabmux-85853c4ae5e48359feac44370b4c0f05fbb23147.tar.bz2
dabmux-85853c4ae5e48359feac44370b4c0f05fbb23147.zip
Move some EDI things around
-rw-r--r--src/ConfigParser.cpp3
-rw-r--r--src/ConfigParser.h3
-rw-r--r--src/DabMultiplexer.cpp48
-rw-r--r--src/DabMultiplexer.h13
-rw-r--r--src/DabMux.cpp45
-rw-r--r--src/dabOutput/edi/AFPacket.h2
-rw-r--r--src/dabOutput/edi/PFT.h8
7 files changed, 72 insertions, 50 deletions
diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp
index b210ac0..89f6d87 100644
--- a/src/ConfigParser.cpp
+++ b/src/ConfigParser.cpp
@@ -126,8 +126,7 @@ int hexparse(std::string input)
void parse_ptree(boost::property_tree::ptree& pt,
boost::shared_ptr<dabEnsemble> ensemble,
- boost::shared_ptr<BaseRemoteController> rc,
- edi_configuration_t* edi
+ boost::shared_ptr<BaseRemoteController> rc
)
{
using boost::property_tree::ptree;
diff --git a/src/ConfigParser.h b/src/ConfigParser.h
index e2dc6ce..1eec783 100644
--- a/src/ConfigParser.h
+++ b/src/ConfigParser.h
@@ -40,8 +40,7 @@
void parse_ptree(boost::property_tree::ptree& pt,
boost::shared_ptr<dabEnsemble> ensemble,
- boost::shared_ptr<BaseRemoteController> rc,
- edi_configuration_t* edi);
+ boost::shared_ptr<BaseRemoteController> rc);
void setup_subchannel_from_ptree(dabSubchannel* subchan,
boost::property_tree::ptree &pt,
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index 71a8b4b..4ca93aa 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -128,13 +128,45 @@ void DabMultiplexer::update_config(boost::property_tree::ptree pt)
void DabMultiplexer::reconfigure()
{
- parse_ptree(m_pt_next, ensemble_next, m_rc, &edi_conf);
+ parse_ptree(m_pt_next, ensemble_next, m_rc);
}
+void DabMultiplexer::set_edi_config(const edi_configuration_t& new_edi_conf)
+{
+ edi_conf = new_edi_conf;
+
+#if HAVE_OUTPUT_EDI
+ if (edi_conf.verbose) {
+ etiLog.log(info, "Setup EDI");
+ }
+
+ if (edi_conf.dump) {
+ edi_debug_file.open("./edi.debug");
+ }
+
+ if (edi_conf.enabled) {
+ edi_output.create(edi_conf.source_port);
+ }
+
+ if (edi_conf.verbose) {
+ etiLog.log(info, "EDI set up");
+ }
+
+ // The TagPacket will then be placed into an AFPacket
+ AFPacketiser afPacketiser;
+ edi_afPacketiser = afPacketiser;
+
+ // The AF Packet will be protected with reed-solomon and split in fragments
+ PFT pft(207, 3, edi_conf);
+ edi_pft = pft;
+#endif
+}
+
+
// Run a set of checks on the configuration
void DabMultiplexer::prepare()
{
- parse_ptree(m_pt, ensemble, m_rc, &edi_conf);
+ parse_ptree(m_pt, ensemble, m_rc);
ensemble->enrol_at(m_rc);
@@ -180,18 +212,6 @@ void DabMultiplexer::prepare()
* synchronisation is preserved.
*/
gettimeofday(&mnsc_time, NULL);
-
-#if HAVE_OUTPUT_EDI
- // Defaults for edi
- edi_conf.enabled = db.get_numeric("output.edi.enabled", 0) == 1;
- if (edi_conf.enabled) {
- edi_conf.dest_addr = db.get("output.edi.dest_addr");
- edi_conf.dest_port = db.get_numeric("output.edi.dest_port");
- edi_conf.source_port = db.get_numeric("output.edi.source_port");
- edi_conf.dump = db.get_numeric("output.edi.dump") == 1;
- edi_conf.enable_pft = db.get_numeric("output.edi.enable_pft") == 1;
- }
-#endif // HAVE_OUTPUT_EDI
}
diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h
index 9761ef9..27cc063 100644
--- a/src/DabMultiplexer.h
+++ b/src/DabMultiplexer.h
@@ -77,6 +77,8 @@ class DabMultiplexer {
void update_config(boost::property_tree::ptree pt);
+ void set_edi_config(const edi_configuration_t& new_edi_conf);
+
private:
void prepare_watermark(void);
void prepare_subchannels(void);
@@ -123,6 +125,17 @@ class DabMultiplexer {
// Multiplex reconfiguration requires two sets of configurations
boost::property_tree::ptree m_pt_next;
boost::shared_ptr<dabEnsemble> ensemble_next;
+
+#if HAVE_OUTPUT_EDI
+ std::ofstream edi_debug_file;
+ UdpSocket edi_output;
+
+ // The TagPacket will then be placed into an AFPacket
+ AFPacketiser edi_afPacketiser;
+
+ // The AF Packet will be protected with reed-solomon and split in fragments
+ PFT edi_pft;
+#endif // HAVE_OUTPUT_EDI
};
// DAB Mode
diff --git a/src/DabMux.cpp b/src/DabMux.cpp
index a8f674b..20dc31d 100644
--- a/src/DabMux.cpp
+++ b/src/DabMux.cpp
@@ -299,6 +299,8 @@ int main(int argc, char *argv[])
" starting up";
+ edi_configuration_t edi_conf;
+
/******************** READ OUTPUT PARAMETERS ***************/
set<string> all_output_names;
ptree pt_outputs = pt.get_child("outputs");
@@ -319,15 +321,19 @@ int main(int argc, char *argv[])
#if HAVE_OUTPUT_EDI
ptree pt_edi = pt_outputs.get_child("edi");
- edi->enabled = true;
+ edi_conf.enabled = true;
+
+ edi_conf.dest_addr = pt_edi.get<string>("destination");
+ edi_conf.dest_port = pt_edi.get<unsigned int>("port");
+ edi_conf.source_port = pt_edi.get<unsigned int>("sourceport");
- edi->dest_addr = pt_edi.get<string>("destination");
- edi->dest_port = pt_edi.get<unsigned int>("port");
- edi->source_port = pt_edi.get<unsigned int>("sourceport");
+ edi_conf.dump = pt_edi.get<bool>("dump");
+ edi_conf.enable_pft = pt_edi.get<bool>("enable_pft");
+ edi_conf.verbose = pt_edi.get<bool>("verbose");
- edi->dump = pt_edi.get<bool>("dump");
- edi->enable_pft = pt_edi.get<bool>("enable_pft");
- edi->verbose = pt_edi.get<bool>("verbose");
+ mux.set_edi_config(edi_conf);
+#else
+ throw runtime_error("EDI output not compiled in");
#endif
}
else {
@@ -424,31 +430,6 @@ int main(int argc, char *argv[])
etiLog.level(info) << "source port " << edi_conf.source_port;
etiLog.level(info) << "verbose " << edi_conf.verbose;
}
-
-
- if (edi_conf.verbose) {
- etiLog.log(info, "Setup EDI debug");
- }
- std::ofstream edi_debug_file;
-
- if (edi_conf.dump) {
- edi_debug_file.open("./edi.debug");
- }
- UdpSocket edi_output;
-
- if (edi_conf.enabled) {
- edi_output.create(edi_conf.source_port);
- }
-
- if (edi_conf.verbose) {
- etiLog.log(info, "EDI debug set up");
- }
-
- // The TagPacket will then be placed into an AFPacket
- AFPacketiser edi_afPacketiser(edi_conf.verbose);
-
- // The AF Packet will be protected with reed-solomon and split in fragments
- PFT edi_pft(207, 3, edi_conf);
#endif
size_t limit = pt.get("general.nbframes", 0);
diff --git a/src/dabOutput/edi/AFPacket.h b/src/dabOutput/edi/AFPacket.h
index 5f62456..9b189b8 100644
--- a/src/dabOutput/edi/AFPacket.h
+++ b/src/dabOutput/edi/AFPacket.h
@@ -39,6 +39,8 @@ typedef std::vector<uint8_t> AFPacket;
class AFPacketiser
{
public:
+ AFPacketiser() :
+ m_verbose(false) {};
AFPacketiser(bool verbose) :
m_verbose(verbose) {};
diff --git a/src/dabOutput/edi/PFT.h b/src/dabOutput/edi/PFT.h
index 4aae817..9c6f7bd 100644
--- a/src/dabOutput/edi/PFT.h
+++ b/src/dabOutput/edi/PFT.h
@@ -49,6 +49,14 @@ class PFT
public:
static const int ParityBytes = 48;
+ PFT() :
+ m_k(207),
+ m_m(3),
+ m_dest_port(12000),
+ m_pseq(0),
+ m_verbose(false)
+ { }
+
PFT(unsigned int RSDataWordLength,
unsigned int NumRecoverableFragments,
const edi_configuration_t &conf) :