diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-03-15 15:41:05 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-03-15 15:41:05 +0100 | 
| commit | 02c751e4e714b1aa4b4c93699b992d522fd3e9ca (patch) | |
| tree | a123af41aba0bc3ef381b7bc9f14c9fd080e9dc5 | |
| parent | cdeded18deb9ef2a12bf5206757f235e3925c848 (diff) | |
| download | ODR-SourceCompanion-02c751e4e714b1aa4b4c93699b992d522fd3e9ca.tar.gz ODR-SourceCompanion-02c751e4e714b1aa4b4c93699b992d522fd3e9ca.tar.bz2 ODR-SourceCompanion-02c751e4e714b1aa4b4c93699b992d522fd3e9ca.zip | |
Common c90e505: Fix EDI UDP packet spreading set to 0
| -rw-r--r-- | Makefile.am | 1 | ||||
| -rw-r--r-- | lib/edioutput/Interleaver.cpp | 122 | ||||
| -rw-r--r-- | lib/edioutput/Interleaver.h | 75 | ||||
| -rw-r--r-- | lib/edioutput/Transport.cpp | 13 | 
4 files changed, 8 insertions, 203 deletions
| diff --git a/Makefile.am b/Makefile.am index dd412ef..2eb2cc1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,7 +38,6 @@ odr_sourcecompanion_SOURCES     = src/odr-sourcecompanion.cpp \  								  lib/crc.h lib/crc.c \  								  lib/edioutput/AFPacket.h lib/edioutput/AFPacket.cpp \  								  lib/edioutput/EDIConfig.h \ -								  lib/edioutput/Interleaver.h lib/edioutput/Interleaver.cpp \  								  lib/edioutput/PFT.h lib/edioutput/PFT.cpp \  								  lib/edioutput/TagItems.h lib/edioutput/TagItems.cpp \  								  lib/edioutput/TagPacket.h lib/edioutput/TagPacket.cpp \ diff --git a/lib/edioutput/Interleaver.cpp b/lib/edioutput/Interleaver.cpp deleted file mode 100644 index f26a50e..0000000 --- a/lib/edioutput/Interleaver.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -   Copyright (C) 2017 -   Matthias P. Braendli, matthias.braendli@mpb.li - -    http://www.opendigitalradio.org - -   EDI output, -   Interleaving of PFT fragments to increase robustness against -   burst packet loss. - -   This is possible because EDI has to assume that fragments may reach -   the receiver out of order. - -   */ -/* -   This file is part of ODR-DabMux. - -   ODR-DabMux is free software: you can redistribute it and/or modify -   it under the terms of the GNU General Public License as -   published by the Free Software Foundation, either version 3 of the -   License, or (at your option) any later version. - -   ODR-DabMux is distributed in the hope that it will be useful, -   but WITHOUT ANY WARRANTY; without even the implied warranty of -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -   GNU General Public License for more details. - -   You should have received a copy of the GNU General Public License -   along with ODR-DabMux.  If not, see <http://www.gnu.org/licenses/>. -   */ - -#include "Interleaver.h" -#include <cassert> - -namespace edi { - -void Interleaver::SetLatency(size_t latency_frames) -{ -    m_latency = latency_frames; -} - -Interleaver::fragment_vec Interleaver::Interleave(fragment_vec &fragments) -{ -    m_fragment_count = fragments.size(); - -    // Create vectors containing Fcount*latency fragments in total -    // and store them into the deque -    if (m_buffer.empty()) { -        m_buffer.emplace_back(); -    } - -    auto& last_buffer = m_buffer.back(); - -    for (auto& fragment : fragments) { -        const bool last_buffer_is_complete = -                (last_buffer.size() >= m_fragment_count * m_latency); - -        if (last_buffer_is_complete) { -            m_buffer.emplace_back(); -            last_buffer = m_buffer.back(); -        } - -        last_buffer.push_back(std::move(fragment)); -    } - -    fragments.clear(); - -    while ( not m_buffer.empty() and -            (m_buffer.front().size() >= m_fragment_count * m_latency)) { - -        auto& first_buffer = m_buffer.front(); - -        assert(first_buffer.size() == m_fragment_count * m_latency); - -        /* Assume we have 5 fragments per AF frame, and latency of 3. -         * This will give the following strides: -         *    0        1     2 -         * +-------+-------+---+ -         * | 0   1 | 2   3 | 4 | -         * |       |   +---+   | -         * | 5   6 | 7 | 8   9 | -         * |   +---+   |       | -         * |10 |11  12 |13  14 | -         * +---+-------+-------+ -         * -         * ix will be 0, 5, 10, 1, 6 in the first loop -         */ - -        for (size_t i = 0; i < m_fragment_count; i++) { -            const size_t ix = m_interleave_offset + m_fragment_count * m_stride; -            m_interleaved_fragments.push_back(first_buffer.at(ix)); - -            m_stride += 1; -            if (m_stride >= m_latency) { -                m_interleave_offset++; -                m_stride = 0; -            } -        } - -        if (m_interleave_offset >= m_fragment_count) { -            m_interleave_offset = 0; -            m_stride = 0; -            m_buffer.pop_front(); -        } -    } - -    std::vector<PFTFragment> interleaved_frags; - -    const size_t n = std::min(m_fragment_count, m_interleaved_fragments.size()); -    std::move(m_interleaved_fragments.begin(), -              m_interleaved_fragments.begin() + n, -              std::back_inserter(interleaved_frags)); -    m_interleaved_fragments.erase( -              m_interleaved_fragments.begin(), -              m_interleaved_fragments.begin() + n); - -    return interleaved_frags; -} - -} - - diff --git a/lib/edioutput/Interleaver.h b/lib/edioutput/Interleaver.h deleted file mode 100644 index 3029d5d..0000000 --- a/lib/edioutput/Interleaver.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -   Copyright (C) 2017 -   Matthias P. Braendli, matthias.braendli@mpb.li - -    http://www.opendigitalradio.org - -   EDI output, -   Interleaving of PFT fragments to increase robustness against -   burst packet loss. - -   This is possible because EDI has to assume that fragments may reach -   the receiver out of order. - -   */ -/* -   This file is part of the ODR-mmbTools. - -   This program is free software: you can redistribute it and/or modify -   it under the terms of the GNU General Public License as -   published by the Free Software Foundation, either version 3 of the -   License, or (at your option) any later version. - -   This program is distributed in the hope that it will be useful, -   but WITHOUT ANY WARRANTY; without even the implied warranty of -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -   GNU General Public License for more details. - -   You should have received a copy of the GNU General Public License -   along with this program.  If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "config.h" -#include <vector> -#include <deque> -#include <stdexcept> -#include <cstdint> -#include "Log.h" -#include "PFT.h" - -namespace edi { - -class Interleaver { -    public: -        using fragment_vec = std::vector<PFTFragment>; - -        /* Configure the interleaver to use latency_frames number of AF -         * packets for interleaving. Total delay through the interleaver -         * will be latency_frames * 24ms -         */ -        void SetLatency(size_t latency_frames); - -        /* Move the fragments for an AF Packet into the interleaver and -         * return interleaved fragments to be transmitted. -         */ -        fragment_vec Interleave(fragment_vec &fragments); - -    private: -        size_t m_latency = 0; -        size_t m_fragment_count = 0; -        size_t m_interleave_offset = 0; -        size_t m_stride = 0; - -        /* Buffer that accumulates enough fragments to interleave */ -        std::deque<fragment_vec> m_buffer; - -        /* Buffer that contains fragments that have been interleaved, -         * to avoid that the interleaver output is too bursty -         */ -        std::deque<PFTFragment> m_interleaved_fragments; -}; - -} - diff --git a/lib/edioutput/Transport.cpp b/lib/edioutput/Transport.cpp index 136c71c..274f7ec 100644 --- a/lib/edioutput/Transport.cpp +++ b/lib/edioutput/Transport.cpp @@ -135,14 +135,17 @@ void Sender::write(const TagPacket& tagpacket)                      edi_fragments.size());          } -        /* Spread out the transmission of all fragments over 25% of the 24ms AF packet duration +        /* Spread out the transmission of all fragments over part of the 24ms AF packet duration           * to reduce the risk of losing a burst of fragments because of congestion. */          using namespace std::chrono; -        auto inter_fragment_wait_time = microseconds(0); +        auto inter_fragment_wait_time = microseconds(1);          if (edi_fragments.size() > 1) { -            inter_fragment_wait_time = microseconds( -                    llrint(m_conf.fragment_spreading_factor * 24000.0 / edi_fragments.size()) -                    ); +            if (m_conf.fragment_spreading_factor > 0) { +                inter_fragment_wait_time = +                    microseconds( +                            llrint(m_conf.fragment_spreading_factor * 24000.0 / edi_fragments.size()) +                            ); +            }          }          /* Separate insertion into map and transmission so as to make spreading possible */ | 
