aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-05-19 14:48:39 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-05-19 14:48:39 +0200
commit5ad4acef6721a67b8156cd6f7b45ad59849ca09b (patch)
treeadeedaa825f2ef2aa4f9b30265d007b6e7abe8ef
parentc92c05d1199a2380d8c8c79a89c7e1f3159a2603 (diff)
downloadODR-AudioEnc-5ad4acef6721a67b8156cd6f7b45ad59849ca09b.tar.gz
ODR-AudioEnc-5ad4acef6721a67b8156cd6f7b45ad59849ca09b.tar.bz2
ODR-AudioEnc-5ad4acef6721a67b8156cd6f7b45ad59849ca09b.zip
Common 44ae39c: Make SEQ and PSEQ available on EDI receive and improve error handling
-rw-r--r--contrib/edioutput/AFPacket.cpp18
-rw-r--r--contrib/edioutput/AFPacket.h9
-rw-r--r--contrib/edioutput/EDIConfig.h1
-rw-r--r--contrib/edioutput/PFT.cpp8
-rw-r--r--contrib/edioutput/PFT.h5
-rw-r--r--contrib/edioutput/TagItems.cpp1
-rw-r--r--contrib/edioutput/TagItems.h1
-rw-r--r--contrib/edioutput/TagPacket.cpp1
-rw-r--r--contrib/edioutput/TagPacket.h1
-rw-r--r--contrib/edioutput/Transport.cpp15
-rw-r--r--contrib/edioutput/Transport.h15
11 files changed, 53 insertions, 22 deletions
diff --git a/contrib/edioutput/AFPacket.cpp b/contrib/edioutput/AFPacket.cpp
index b38c38b..323a3b1 100644
--- a/contrib/edioutput/AFPacket.cpp
+++ b/contrib/edioutput/AFPacket.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014
+ Copyright (C) 2021
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -25,7 +25,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
#include "crc.h"
#include "AFPacket.h"
#include "TagItems.h"
@@ -50,7 +49,7 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet)
std::vector<uint8_t> payload = tag_packet.Assemble();
if (m_verbose)
- std::cerr << "Assemble AFPacket " << seq << std::endl;
+ std::cerr << "Assemble AFPacket " << m_seq << std::endl;
std::string pack_data("AF"); // SYNC
std::vector<uint8_t> packet(pack_data.begin(), pack_data.end());
@@ -67,10 +66,10 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet)
packet.push_back(taglength & 0xFF);
// fill rest of header
- packet.push_back(seq >> 8);
- packet.push_back(seq & 0xFF);
- seq++;
- packet.push_back((have_crc ? 0x80 : 0) | AFHEADER_VERSION); // ar_cf: CRC=1
+ packet.push_back(m_seq >> 8);
+ packet.push_back(m_seq & 0xFF);
+ m_seq++;
+ packet.push_back((m_have_crc ? 0x80 : 0) | AFHEADER_VERSION); // ar_cf: CRC=1
packet.push_back(AFHEADER_PT_TAG);
// insert payload, must have a length multiple of 8 bytes
@@ -93,4 +92,9 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet)
return packet;
}
+void AFPacketiser::OverrideSeq(uint16_t seq)
+{
+ m_seq = seq;
+}
+
}
diff --git a/contrib/edioutput/AFPacket.h b/contrib/edioutput/AFPacket.h
index f2c4e35..6e6ec47 100644
--- a/contrib/edioutput/AFPacket.h
+++ b/contrib/edioutput/AFPacket.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014
+ Copyright (C) 2021
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -28,7 +28,6 @@
#pragma once
-#include "config.h"
#include <vector>
#include <cstdint>
#include "TagItems.h"
@@ -49,10 +48,12 @@ class AFPacketiser
AFPacket Assemble(TagPacket tag_packet);
+ void OverrideSeq(uint16_t seq);
+
private:
- static const bool have_crc = true;
+ static const bool m_have_crc = true;
- uint16_t seq = 0; //counter that overflows at 0xFFFF
+ uint16_t m_seq = 0; //counter that overflows at 0xFFFF
bool m_verbose;
};
diff --git a/contrib/edioutput/EDIConfig.h b/contrib/edioutput/EDIConfig.h
index be6c9c4..d57e9ce 100644
--- a/contrib/edioutput/EDIConfig.h
+++ b/contrib/edioutput/EDIConfig.h
@@ -27,7 +27,6 @@
#pragma once
-#include "config.h"
#include <vector>
#include <string>
#include <memory>
diff --git a/contrib/edioutput/PFT.cpp b/contrib/edioutput/PFT.cpp
index b2f07e0..7e0e8e9 100644
--- a/contrib/edioutput/PFT.cpp
+++ b/contrib/edioutput/PFT.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2019
+ Copyright (C) 2021
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -30,7 +30,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
#include <vector>
#include <list>
#include <cstdio>
@@ -320,5 +319,10 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet)
return pft_fragments;
}
+void PFT::OverridePSeq(uint16_t pseq)
+{
+ m_pseq = pseq;
+}
+
}
diff --git a/contrib/edioutput/PFT.h b/contrib/edioutput/PFT.h
index 4d138c5..42569a0 100644
--- a/contrib/edioutput/PFT.h
+++ b/contrib/edioutput/PFT.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2019
+ Copyright (C) 2021
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -32,7 +32,6 @@
#pragma once
-#include "config.h"
#include <vector>
#include <list>
#include <stdexcept>
@@ -65,6 +64,8 @@ class PFT
// Cut a RSBlock into several fragments that can be transmitted
std::vector< std::vector<uint8_t> > ProtectAndFragment(AFPacket af_packet);
+ void OverridePSeq(uint16_t pseq);
+
private:
unsigned int m_k = 207; // length of RS data word
unsigned int m_m = 3; // number of fragments that can be recovered if lost
diff --git a/contrib/edioutput/TagItems.cpp b/contrib/edioutput/TagItems.cpp
index 739adfa..a47d168 100644
--- a/contrib/edioutput/TagItems.cpp
+++ b/contrib/edioutput/TagItems.cpp
@@ -26,7 +26,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
#include "TagItems.h"
#include <vector>
#include <iostream>
diff --git a/contrib/edioutput/TagItems.h b/contrib/edioutput/TagItems.h
index f24dc44..029681c 100644
--- a/contrib/edioutput/TagItems.h
+++ b/contrib/edioutput/TagItems.h
@@ -28,7 +28,6 @@
#pragma once
-#include "config.h"
#include <vector>
#include <array>
#include <chrono>
diff --git a/contrib/edioutput/TagPacket.cpp b/contrib/edioutput/TagPacket.cpp
index ec52ad7..d89fce7 100644
--- a/contrib/edioutput/TagPacket.cpp
+++ b/contrib/edioutput/TagPacket.cpp
@@ -24,7 +24,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
#include "TagPacket.h"
#include "TagItems.h"
#include <vector>
diff --git a/contrib/edioutput/TagPacket.h b/contrib/edioutput/TagPacket.h
index b53b718..ad23530 100644
--- a/contrib/edioutput/TagPacket.h
+++ b/contrib/edioutput/TagPacket.h
@@ -26,7 +26,6 @@
#pragma once
-#include "config.h"
#include "TagItems.h"
#include <vector>
#include <string>
diff --git a/contrib/edioutput/Transport.cpp b/contrib/edioutput/Transport.cpp
index 274f7ec..5d34814 100644
--- a/contrib/edioutput/Transport.cpp
+++ b/contrib/edioutput/Transport.cpp
@@ -126,6 +126,11 @@ void Sender::write(const TagPacket& tagpacket)
// Assemble into one AF Packet
edi::AFPacket af_packet = edi_afPacketiser.Assemble(tagpacket);
+ write(af_packet);
+}
+
+void Sender::write(const AFPacket& af_packet)
+{
if (m_conf.enable_pft) {
// Apply PFT layer to AF Packet (Reed Solomon FEC and Fragmentation)
vector<edi::PFTFragment> edi_fragments = edi_pft.Assemble(af_packet);
@@ -194,6 +199,16 @@ void Sender::write(const TagPacket& tagpacket)
}
}
+void Sender::override_af_sequence(uint16_t seq)
+{
+ edi_afPacketiser.OverrideSeq(seq);
+}
+
+void Sender::override_pft_sequence(uint16_t pseq)
+{
+ edi_pft.OverridePSeq(pseq);
+}
+
void Sender::run()
{
while (m_running) {
diff --git a/contrib/edioutput/Transport.h b/contrib/edioutput/Transport.h
index 3bcc2f4..be93297 100644
--- a/contrib/edioutput/Transport.h
+++ b/contrib/edioutput/Transport.h
@@ -27,7 +27,6 @@
#pragma once
-#include "config.h"
#include "EDIConfig.h"
#include "AFPacket.h"
#include "PFT.h"
@@ -44,7 +43,7 @@
namespace edi {
-/** Configuration for EDI output */
+/** STI sender for EDI output */
class Sender {
public:
@@ -53,8 +52,20 @@ class Sender {
Sender operator=(const Sender&) = delete;
~Sender();
+ // Assemble the tagpacket into an AF packet, and if needed,
+ // apply PFT and then schedule for transmission.
void write(const TagPacket& tagpacket);
+ // Schedule an already assembled AF Packet for transmission,
+ // applying PFT if needed.
+ void write(const AFPacket& af_packet);
+
+ // Set the sequence numbers to be used for the next call to write()
+ // seq is for the AF layer
+ // pseq is for the PFT layer
+ void override_af_sequence(uint16_t seq);
+ void override_pft_sequence(uint16_t pseq);
+
private:
void run();