summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-06 15:52:21 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-06 15:52:21 +0200
commit6db7ccca948f94570b86b82970afeb4ed7be718f (patch)
tree7213dcc2ec5d48f6c1476861c1ed18d58141f22e
parentb9afad6f157ca35dada1ee48e0239bcb04b6ec4b (diff)
downloaddabmux-6db7ccca948f94570b86b82970afeb4ed7be718f.tar.gz
dabmux-6db7ccca948f94570b86b82970afeb4ed7be718f.tar.bz2
dabmux-6db7ccca948f94570b86b82970afeb4ed7be718f.zip
zmq2edi: Add option to drop late packets
-rw-r--r--src/zmq2edi/EDISender.cpp12
-rw-r--r--src/zmq2edi/EDISender.h6
-rw-r--r--src/zmq2edi/zmq2edi.cpp12
3 files changed, 22 insertions, 8 deletions
diff --git a/src/zmq2edi/EDISender.cpp b/src/zmq2edi/EDISender.cpp
index 9cd84c7..236222c 100644
--- a/src/zmq2edi/EDISender.cpp
+++ b/src/zmq2edi/EDISender.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
@@ -47,10 +47,12 @@ EDISender::~EDISender()
}
}
-void EDISender::start(const edi_configuration_t& conf, int delay_ms)
+void EDISender::start(const edi_configuration_t& conf,
+ int delay_ms, bool drop_late_packets)
{
edi_conf = conf;
tist_delay_ms = delay_ms;
+ drop_late = drop_late_packets;
if (edi_conf.verbose) {
etiLog.log(info, "Setup EDI");
@@ -242,10 +244,14 @@ void EDISender::send_eti_frame(uint8_t* p, metadata_t metadata)
*/
const auto wait_time = t_release - t_now;
+ wait_times.push_back(duration_cast<microseconds>(wait_time).count());
+
if (t_release > t_now) {
std::this_thread::sleep_for(wait_time);
}
- wait_times.push_back(duration_cast<microseconds>(wait_time).count());
+ else if (drop_late) {
+ return;
+ }
edi_tagDETI.tsta = tist;
edi_tagDETI.atstf = 1;
diff --git a/src/zmq2edi/EDISender.h b/src/zmq2edi/EDISender.h
index f5959b9..4c2af54 100644
--- a/src/zmq2edi/EDISender.h
+++ b/src/zmq2edi/EDISender.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
@@ -55,7 +55,8 @@ class EDISender {
EDISender(const EDISender& other) = delete;
EDISender& operator=(const EDISender& other) = delete;
~EDISender();
- void start(const edi_configuration_t& conf, int delay_ms);
+ void start(const edi_configuration_t& conf,
+ int delay_ms, bool drop_late_packets);
void push_frame(const frame_t& frame);
void print_configuration(void);
@@ -64,6 +65,7 @@ class EDISender {
void process(void);
int tist_delay_ms;
+ bool drop_late;
std::atomic<bool> running;
std::thread process_thread;
edi_configuration_t edi_conf;
diff --git a/src/zmq2edi/zmq2edi.cpp b/src/zmq2edi/zmq2edi.cpp
index b2c20f4..3364faa 100644
--- a/src/zmq2edi/zmq2edi.cpp
+++ b/src/zmq2edi/zmq2edi.cpp
@@ -55,6 +55,7 @@ void usage(void)
cerr << "The following options can be given only once:" << endl;
cerr << " <source> is a ZMQ URL that points to a ODR-DabMux ZMQ output." << endl;
cerr << " -w <delay> Keep every ETI frame until TIST is <delay> milliseconds after current system time." << endl;
+ cerr << " -x Drop frames where for which the wait time would be negative, i.e. frames that arrived too late." << endl;
cerr << " -p <destination port> sets the destination port." << endl;
cerr << " -P Disable PFT and send AFPackets." << endl;
cerr << " -f <fec> sets the FEC." << endl;
@@ -223,10 +224,11 @@ int start(int argc, char **argv)
}
int delay_ms = 500;
+ bool drop_late_packets = false;
int ch = 0;
while (ch != -1) {
- ch = getopt(argc, argv, "d:p:s:S:t:Pf:i:Dva:w:");
+ ch = getopt(argc, argv, "d:p:s:S:t:Pf:i:Dva:w:x");
switch (ch) {
case -1:
break;
@@ -274,6 +276,9 @@ int start(int argc, char **argv)
case 'w':
delay_ms = std::stoi(optarg);
break;
+ case 'x':
+ drop_late_packets = true;
+ break;
case 'h':
default:
usage();
@@ -298,8 +303,9 @@ int start(int argc, char **argv)
return 1;
}
- etiLog.level(info) << "Setting up EDI Sender with delay " << delay_ms << " ms";
- edisender.start(edi_conf, delay_ms);
+ etiLog.level(info) << "Setting up EDI Sender with delay " << delay_ms << " ms. " <<
+ (drop_late_packets ? "Will" : "Will not") << " drop late packets";
+ edisender.start(edi_conf, delay_ms, drop_late_packets);
edisender.print_configuration();
const char* source_url = argv[optind];