summaryrefslogtreecommitdiffstats
path: root/src/dabOutput
diff options
context:
space:
mode:
Diffstat (limited to 'src/dabOutput')
-rw-r--r--src/dabOutput/dabOutput.h42
-rw-r--r--src/dabOutput/dabOutputFifo.cpp1
-rw-r--r--src/dabOutput/dabOutputFile.cpp1
-rw-r--r--src/dabOutput/edi/AFPacket.cpp3
-rw-r--r--src/dabOutput/edi/AFPacket.h2
-rw-r--r--src/dabOutput/edi/PFT.cpp2
-rw-r--r--src/dabOutput/edi/PFT.h16
-rw-r--r--src/dabOutput/edi/TagPacket.cpp7
8 files changed, 61 insertions, 13 deletions
diff --git a/src/dabOutput/dabOutput.h b/src/dabOutput/dabOutput.h
index 18f3848..c8ce9f2 100644
--- a/src/dabOutput/dabOutput.h
+++ b/src/dabOutput/dabOutput.h
@@ -55,6 +55,8 @@
// Configuration for EDI output
struct edi_configuration_t {
+ unsigned chunk_len; // RSk, data length of each chunk
+ unsigned fec; // number of fragments that can be recovered
bool enabled;
unsigned int source_port;
bool dump;
@@ -78,6 +80,8 @@ class DabOutput
virtual int Close() = 0;
virtual ~DabOutput() {}
+
+ virtual std::string get_info() = 0;
};
// ----- used in File and Fifo outputs
@@ -111,7 +115,12 @@ class DabOutputFile : public DabOutput
int Write(void* buffer, int size);
int Close();
+ std::string get_info() {
+ return "file://" + filename_;
+ }
+
protected:
+ std::string filename_;
int file_;
EtiFileType type_;
unsigned long nbFrames_;
@@ -126,6 +135,11 @@ class DabOutputFifo : public DabOutputFile
~DabOutputFifo() {}
int Write(void* buffer, int size);
+
+ std::string get_info() {
+ return "fifo://" + filename_;
+ }
+
};
// -------------- RAW socket -----------
@@ -162,7 +176,12 @@ class DabOutputRaw : public DabOutput
int Open(const char* name);
int Write(void* buffer, int size);
int Close();
+
+ std::string get_info() {
+ return "raw://" + filename_;
+ }
private:
+ std::string filename_;
#ifdef _WIN32
HANDLE socket_;
#else
@@ -197,7 +216,11 @@ class DabOutputUdp : public DabOutput
int Write(void* buffer, int size);
int Close() { return 0; }
+ std::string get_info() {
+ return "udp://" + uri_;
+ }
private:
+ std::string uri_;
UdpSocket* socket_;
UdpPacket* packet_;
};
@@ -230,9 +253,14 @@ class DabOutputTcp : public DabOutput
int Write(void* buffer, int size);
int Close();
+ std::string get_info() {
+ return "tcp://" + uri_;
+ }
+
TcpServer* server;
TcpSocket* client;
private:
+ std::string uri_;
pthread_t thread_;
};
@@ -252,7 +280,12 @@ class DabOutputSimul : public DabOutput
int Open(const char* name);
int Write(void* buffer, int size);
int Close() { return 0; }
+
+ std::string get_info() {
+ return "simul://" + name_;
+ }
private:
+ std::string name_;
#ifdef _WIN32
DWORD startTime_;
#else
@@ -304,6 +337,7 @@ class DabOutputZMQ : public DabOutput
{
public:
DabOutputZMQ() :
+ endpoint_(""),
zmq_proto_(""), zmq_context_(1),
zmq_pub_sock_(zmq_context_, ZMQ_PUB),
zmq_message_ix(0)
@@ -312,6 +346,7 @@ class DabOutputZMQ : public DabOutput
}
DabOutputZMQ(std::string zmq_proto) :
+ endpoint_(""),
zmq_proto_(zmq_proto), zmq_context_(1),
zmq_pub_sock_(zmq_context_, ZMQ_PUB),
zmq_message_ix(0)
@@ -323,7 +358,11 @@ class DabOutputZMQ : public DabOutput
zmq_pub_sock_.close();
}
- int Open(const char* name);
+ std::string get_info() {
+ return "zmq: " + zmq_proto_ + "://" + endpoint_;
+ }
+
+ int Open(const char* endpoint);
int Write(void* buffer, int size);
int Close();
private:
@@ -334,6 +373,7 @@ class DabOutputZMQ : public DabOutput
/* Forbid copy constructor */
}
+ std::string endpoint_;
std::string zmq_proto_;
zmq::context_t zmq_context_; // handle for the zmq context
zmq::socket_t zmq_pub_sock_; // handle for the zmq publisher socket
diff --git a/src/dabOutput/dabOutputFifo.cpp b/src/dabOutput/dabOutputFifo.cpp
index de9579e..6b1c016 100644
--- a/src/dabOutput/dabOutputFifo.cpp
+++ b/src/dabOutput/dabOutputFifo.cpp
@@ -59,6 +59,7 @@ int DabOutputFifo::Write(void* buffer, int size)
if (write(this->file_, padding, 6144 - size) == -1)
goto FIFO_WRITE_ERROR;
break;
+ case ETI_FILE_TYPE_NONE:
default:
etiLog.log(error, "File type is not supported.\n");
return -1;
diff --git a/src/dabOutput/dabOutputFile.cpp b/src/dabOutput/dabOutputFile.cpp
index f26ddfd..d7fd5c7 100644
--- a/src/dabOutput/dabOutputFile.cpp
+++ b/src/dabOutput/dabOutputFile.cpp
@@ -112,6 +112,7 @@ int DabOutputFile::Write(void* buffer, int size)
memset(padding, 0x55, 6144 - size);
if (write(this->file_, padding, 6144 - size) == -1) goto FILE_WRITE_ERROR;
break;
+ case ETI_FILE_TYPE_NONE:
default:
etiLog.log(error, "File type is not supported.\n");
return -1;
diff --git a/src/dabOutput/edi/AFPacket.cpp b/src/dabOutput/edi/AFPacket.cpp
index 3b69f1c..a1d39b9 100644
--- a/src/dabOutput/edi/AFPacket.cpp
+++ b/src/dabOutput/edi/AFPacket.cpp
@@ -39,7 +39,7 @@
#define AFHEADER_PT_TAG 'T'
// AF Packet Major (3 bits) and Minor (4 bits) version
-#define AFHEADER_VERSION 0x8 // MAJ=1, MIN=0
+#define AFHEADER_VERSION 0x10 // MAJ=1, MIN=0
AFPacket AFPacketiser::Assemble(TagPacket tag_packet)
{
@@ -65,6 +65,7 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet)
// 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(AFHEADER_PT_TAG);
diff --git a/src/dabOutput/edi/AFPacket.h b/src/dabOutput/edi/AFPacket.h
index 5f62456..9b189b8 100644
--- a/src/dabOutput/edi/AFPacket.h
+++ b/src/dabOutput/edi/AFPacket.h
@@ -39,6 +39,8 @@ typedef std::vector<uint8_t> AFPacket;
class AFPacketiser
{
public:
+ AFPacketiser() :
+ m_verbose(false) {};
AFPacketiser(bool verbose) :
m_verbose(verbose) {};
diff --git a/src/dabOutput/edi/PFT.cpp b/src/dabOutput/edi/PFT.cpp
index e1c8249..7f463cc 100644
--- a/src/dabOutput/edi/PFT.cpp
+++ b/src/dabOutput/edi/PFT.cpp
@@ -52,7 +52,7 @@ RSBlock PFT::Protect(AFPacket af_packet)
// number of chunks is ceil(afpacketsize / m_k)
// TS 102 821 7.2.2: c = ceil(l / k_max)
- m_num_chunks = CEIL_DIV(af_packet.size(), 207);
+ m_num_chunks = CEIL_DIV(af_packet.size(), m_k);
if (m_verbose) {
fprintf(stderr, "Protect %zu chunks of size %zu\n",
diff --git a/src/dabOutput/edi/PFT.h b/src/dabOutput/edi/PFT.h
index 4aae817..e17d282 100644
--- a/src/dabOutput/edi/PFT.h
+++ b/src/dabOutput/edi/PFT.h
@@ -49,11 +49,17 @@ class PFT
public:
static const int ParityBytes = 48;
- PFT(unsigned int RSDataWordLength,
- unsigned int NumRecoverableFragments,
- const edi_configuration_t &conf) :
- m_k(RSDataWordLength),
- m_m(NumRecoverableFragments),
+ PFT() :
+ m_k(207),
+ m_m(3),
+ m_dest_port(12000),
+ m_pseq(0),
+ m_verbose(false)
+ { }
+
+ PFT(const edi_configuration_t &conf) :
+ m_k(conf.chunk_len),
+ m_m(conf.fec),
m_dest_port(conf.dest_port),
m_pseq(0),
m_verbose(conf.verbose)
diff --git a/src/dabOutput/edi/TagPacket.cpp b/src/dabOutput/edi/TagPacket.cpp
index fbb0f8b..aa4f23b 100644
--- a/src/dabOutput/edi/TagPacket.cpp
+++ b/src/dabOutput/edi/TagPacket.cpp
@@ -31,6 +31,7 @@
#include <string>
#include <list>
#include <stdint.h>
+#include <cassert>
std::vector<uint8_t> TagPacket::Assemble()
@@ -41,21 +42,17 @@ std::vector<uint8_t> TagPacket::Assemble()
//std::cerr << "Assemble TAGPacket" << std::endl;
- size_t packet_length = 0;
for (tag = tag_items.begin(); tag != tag_items.end(); ++tag) {
std::vector<uint8_t> tag_data = (*tag)->Assemble();
packet.insert(packet.end(), tag_data.begin(), tag_data.end());
- packet_length += tag_data.size();
-
//std::cerr << " Add TAGItem of length " << tag_data.size() << std::endl;
}
// Add padding
- while (packet_length % 8 > 0)
+ while (packet.size() % 8 > 0)
{
packet.push_back(0); // TS 102 821, 5.1, "padding shall be undefined"
- packet_length++;
}
return packet;