diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2022-08-19 17:12:54 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2022-08-19 17:18:09 +0200 |
commit | 913cd43139d7b5d6eac166a01ac09a754f2bd013 (patch) | |
tree | 98a7bb16c4a05bd7da8aa0fcd25d7620723b999d /lib/edioutput | |
parent | 7bfb88a7446e7faaee6e297e915a2bf95a699109 (diff) | |
download | dabmux-913cd43139d7b5d6eac166a01ac09a754f2bd013.tar.gz dabmux-913cd43139d7b5d6eac166a01ac09a754f2bd013.tar.bz2 dabmux-913cd43139d7b5d6eac166a01ac09a754f2bd013.zip |
Support EDI TCP server pre-roll on client connect
Includes common code changes: socket changes for keepalive and preroll
Diffstat (limited to 'lib/edioutput')
-rw-r--r-- | lib/edioutput/EDIConfig.h | 3 | ||||
-rw-r--r-- | lib/edioutput/Transport.cpp | 13 | ||||
-rw-r--r-- | lib/edioutput/Transport.h | 4 |
3 files changed, 14 insertions, 6 deletions
diff --git a/lib/edioutput/EDIConfig.h b/lib/edioutput/EDIConfig.h index d57e9ce..a7225a7 100644 --- a/lib/edioutput/EDIConfig.h +++ b/lib/edioutput/EDIConfig.h @@ -74,6 +74,9 @@ struct configuration_t { // Spread transmission of fragments in time. 1.0 = 100% means spreading over the whole duration of a frame (24ms) // Above 100% means that the fragments are spread over several 24ms periods, interleaving the AF packets. + // TCP Server output can preroll a fixed number of previous buffers each time a new client connects. + size_t tcp_server_preroll_buffers = 0; + bool enabled() const { return destinations.size() > 0; } void print() const; diff --git a/lib/edioutput/Transport.cpp b/lib/edioutput/Transport.cpp index 5d34814..a870aa0 100644 --- a/lib/edioutput/Transport.cpp +++ b/lib/edioutput/Transport.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 + Copyright (C) 2022 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -66,7 +66,7 @@ Sender::Sender(const configuration_t& conf) : edi_pft(m_conf) { if (m_conf.verbose) { - etiLog.log(info, "Setup EDI Output"); + etiLog.level(info) << "Setup EDI Output, TCP output preroll " << m_conf.tcp_server_preroll_buffers; } for (const auto& edi_dest : m_conf.destinations) { @@ -81,7 +81,9 @@ Sender::Sender(const configuration_t& conf) : udp_sockets.emplace(udp_dest.get(), udp_socket); } else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_server_t>(edi_dest)) { - auto dispatcher = make_shared<Socket::TCPDataDispatcher>(tcp_dest->max_frames_queued); + auto dispatcher = make_shared<Socket::TCPDataDispatcher>( + tcp_dest->max_frames_queued, m_conf.tcp_server_preroll_buffers); + dispatcher->start(tcp_dest->listen_port, "0.0.0.0"); tcp_dispatchers.emplace(tcp_dest.get(), dispatcher); } @@ -135,9 +137,10 @@ void Sender::write(const AFPacket& af_packet) // Apply PFT layer to AF Packet (Reed Solomon FEC and Fragmentation) vector<edi::PFTFragment> edi_fragments = edi_pft.Assemble(af_packet); - if (m_conf.verbose) { - fprintf(stderr, "EDI Output: Number of PFT fragments %zu\n", + if (m_conf.verbose and m_last_num_pft_fragments != edi_fragments.size()) { + etiLog.log(debug, "EDI Output: Number of PFT fragments %zu\n", edi_fragments.size()); + m_last_num_pft_fragments = edi_fragments.size(); } /* Spread out the transmission of all fragments over part of the 24ms AF packet duration diff --git a/lib/edioutput/Transport.h b/lib/edioutput/Transport.h index be93297..6a3f229 100644 --- a/lib/edioutput/Transport.h +++ b/lib/edioutput/Transport.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 + Copyright (C) 2022 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -90,6 +90,8 @@ class Sender { std::mutex m_mutex; bool m_running = false; std::map<std::chrono::steady_clock::time_point, edi::PFTFragment> m_pending_frames; + + size_t m_last_num_pft_fragments = 0; }; } |