aboutsummaryrefslogtreecommitdiffstats
path: root/src/dabOutput
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-06 17:22:58 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-06 17:22:58 +0200
commit3dc74c15f76e999768643ed4381196292d5376bc (patch)
tree0540853e389062d81084f9735a521b8b6e58feaf /src/dabOutput
parent956814cc526bdd245e52c5004bf5661a57d848cc (diff)
downloaddabmux-3dc74c15f76e999768643ed4381196292d5376bc.tar.gz
dabmux-3dc74c15f76e999768643ed4381196292d5376bc.tar.bz2
dabmux-3dc74c15f76e999768643ed4381196292d5376bc.zip
EDI: Implement TCP output
Diffstat (limited to 'src/dabOutput')
-rw-r--r--src/dabOutput/edi/Config.h6
-rw-r--r--src/dabOutput/edi/Transport.cpp20
-rw-r--r--src/dabOutput/edi/Transport.h1
3 files changed, 26 insertions, 1 deletions
diff --git a/src/dabOutput/edi/Config.h b/src/dabOutput/edi/Config.h
index d3678d9..55d5f0f 100644
--- a/src/dabOutput/edi/Config.h
+++ b/src/dabOutput/edi/Config.h
@@ -49,6 +49,12 @@ struct udp_destination_t : public destination_t {
unsigned int ttl = 10;
};
+// TCP server that can accept multiple connections
+struct tcp_destination_t : public destination_t {
+ unsigned int listen_port = 0;
+ size_t max_frames_queued = 1024;
+};
+
struct configuration_t {
unsigned chunk_len = 207; // RSk, data length of each chunk
unsigned fec = 0; // number of fragments that can be recovered
diff --git a/src/dabOutput/edi/Transport.cpp b/src/dabOutput/edi/Transport.cpp
index d433239..d99e987 100644
--- a/src/dabOutput/edi/Transport.cpp
+++ b/src/dabOutput/edi/Transport.cpp
@@ -38,13 +38,17 @@ void configuration_t::print() const
etiLog.level(info) << " verbose " << verbose;
for (auto edi_dest : destinations) {
if (auto udp_dest = dynamic_pointer_cast<edi::udp_destination_t>(edi_dest)) {
- etiLog.level(info) << " to " << udp_dest->dest_addr << ":" << dest_port;
+ etiLog.level(info) << " UDP to " << udp_dest->dest_addr << ":" << dest_port;
if (not udp_dest->source_addr.empty()) {
etiLog.level(info) << " source " << udp_dest->source_addr;
etiLog.level(info) << " ttl " << udp_dest->ttl;
}
etiLog.level(info) << " source port " << udp_dest->source_port;
}
+ else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_destination_t>(edi_dest)) {
+ etiLog.level(info) << " TCP listening on port " << tcp_dest->listen_port;
+ etiLog.level(info) << " max frames queued " << tcp_dest->max_frames_queued;
+ }
else {
throw std::logic_error("EDI destination not implemented");
}
@@ -80,6 +84,14 @@ Sender::Sender(const configuration_t& conf) :
udp_sockets.emplace(udp_dest.get(), udp_socket);
}
+ else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_destination_t>(edi_dest)) {
+ auto dispatcher = make_shared<TCPDataDispatcher>(tcp_dest->max_frames_queued);
+ dispatcher->start(tcp_dest->listen_port, "0.0.0.0");
+ tcp_dispatchers.emplace(tcp_dest.get(), dispatcher);
+ }
+ else {
+ throw std::logic_error("EDI destination not implemented");
+ }
}
if (m_conf.interleaver_enabled()) {
@@ -123,6 +135,9 @@ void Sender::write(const TagPacket& tagpacket)
udp_sockets.at(udp_dest.get())->send(edi_frag, addr);
}
+ else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_destination_t>(dest)) {
+ tcp_dispatchers.at(tcp_dest.get())->write(edi_frag);
+ }
else {
throw std::logic_error("EDI destination not implemented");
}
@@ -149,6 +164,9 @@ void Sender::write(const TagPacket& tagpacket)
udp_sockets.at(udp_dest.get())->send(af_packet, addr);
}
+ else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_destination_t>(dest)) {
+ tcp_dispatchers.at(tcp_dest.get())->write(af_packet);
+ }
else {
throw std::logic_error("EDI destination not implemented");
}
diff --git a/src/dabOutput/edi/Transport.h b/src/dabOutput/edi/Transport.h
index 3c48c96..7b0a0db 100644
--- a/src/dabOutput/edi/Transport.h
+++ b/src/dabOutput/edi/Transport.h
@@ -62,6 +62,7 @@ class Sender {
edi::Interleaver edi_interleaver;
std::unordered_map<udp_destination_t*, std::shared_ptr<UdpSocket>> udp_sockets;
+ std::unordered_map<tcp_destination_t*, std::shared_ptr<TCPDataDispatcher>> tcp_dispatchers;
};
}