diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-06-12 14:46:50 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-06-24 09:32:13 +0200 |
commit | 2c41070f6691ed98a93b245b4ecb17fd898002ab (patch) | |
tree | bec929230e7dd88f7ab9f90bfcdd6b9b21b0b088 /contrib/edi/Interleaver.h | |
parent | 7102f830e01c3d4d695c0d36608cb09064e4aedc (diff) | |
download | ODR-AudioEnc-2c41070f6691ed98a93b245b4ecb17fd898002ab.tar.gz ODR-AudioEnc-2c41070f6691ed98a93b245b4ecb17fd898002ab.tar.bz2 ODR-AudioEnc-2c41070f6691ed98a93b245b4ecb17fd898002ab.zip |
Add EDI output and rework odr-audioenc.cpp
Diffstat (limited to 'contrib/edi/Interleaver.h')
-rw-r--r-- | contrib/edi/Interleaver.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/contrib/edi/Interleaver.h b/contrib/edi/Interleaver.h new file mode 100644 index 0000000..23aebf8 --- /dev/null +++ b/contrib/edi/Interleaver.h @@ -0,0 +1,74 @@ +/* + 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/>. + */ + +#pragma once + +#include "config.h" +#include <vector> +#include <deque> +#include <stdexcept> +#include <stdint.h> +#include "edi/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; +}; + +} + |