From 804fe1979f9ed7bef7badaf0aa08e35e09874772 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 30 Oct 2016 16:28:27 +0100 Subject: Add rudimentary file input No nonblock support yet --- src/input/File.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/input/File.h (limited to 'src/input/File.h') diff --git a/src/input/File.h b/src/input/File.h new file mode 100644 index 0000000..61be8b1 --- /dev/null +++ b/src/input/File.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications + Research Center Canada) + + Copyright (C) 2016 Matthias P. Braendli + http://www.opendigitalradio.org + + */ +/* + 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 . + */ + +#pragma once + +#include +#include +#include +#include "input/inputs.h" +#include "ManagementServer.h" + +namespace Inputs { + +class FileBase : public InputBase { + public: + virtual int open(const std::string& name); + virtual int readFrame(void* buffer, int size) = 0; + virtual int setBitrate(int bitrate) = 0; + virtual int close(); + + /* Rewind the file + * Returns -1 on failure, 0 on success + */ + virtual int rewind(); + protected: + // We use unix open() instead of fopen() because + // we want to do non-blocking I/O + int m_fd = -1; +}; + +class MPEGFile : public FileBase { + public: + virtual int readFrame(void* buffer, int size); + virtual int setBitrate(int bitrate); + + private: + bool m_parity = false; +}; + +class DABPlusFile : public FileBase { + public: + virtual int readFrame(void* buffer, int size); + virtual int setBitrate(int bitrate); +}; + + +}; -- cgit v1.2.3 From 8db328c61832a92bf3f7641061b68767141104f3 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 4 Nov 2016 14:49:11 +0100 Subject: Change readFrame argument types --- src/dabInput.h | 2 +- src/input/File.cpp | 18 ++++++++---------- src/input/File.h | 6 +++--- src/input/Prbs.cpp | 8 +++----- src/input/Prbs.h | 2 +- src/input/Udp.cpp | 2 +- src/input/Udp.h | 2 +- src/input/Zmq.cpp | 2 +- src/input/Zmq.h | 2 +- src/input/inputs.h | 2 +- 10 files changed, 21 insertions(+), 25 deletions(-) (limited to 'src/input/File.h') diff --git a/src/dabInput.h b/src/dabInput.h index 0accddb..d2c5f49 100644 --- a/src/dabInput.h +++ b/src/dabInput.h @@ -62,7 +62,7 @@ class DabInputCompatible : public DabInputBase { virtual int setbuf(int size) { return m_ops.setbuf(args, size); } - virtual int readFrame(void* buffer, int size) + virtual int readFrame(uint8_t* buffer, size_t size) { if (m_ops.lock) { m_ops.lock(args); diff --git a/src/input/File.cpp b/src/input/File.cpp index 9721b97..eb26136 100644 --- a/src/input/File.cpp +++ b/src/input/File.cpp @@ -64,7 +64,7 @@ int FileBase::rewind() return ::lseek(m_fd, 0, SEEK_SET); } -int MPEGFile::readFrame(void* buffer, int size) +int MPEGFile::readFrame(uint8_t* buffer, size_t size) { int result; bool do_rewind = false; @@ -122,7 +122,7 @@ MUTE_SUBCHANNEL: memset(buffer, 0, size); } else { - if (result < size) { + if (result < (ssize_t)size) { etiLog.log(warn, "bitrate too low from file " "-> frame padded\n"); memset((char*)buffer + result, 0, size - result); @@ -164,7 +164,7 @@ MUTE_SUBCHANNEL: int MPEGFile::setBitrate(int bitrate) { if (bitrate == 0) { - char buffer[4]; + uint8_t buffer[4]; if (readFrame(buffer, 4) == 0) { bitrate = getMpegBitrate(buffer); @@ -178,11 +178,9 @@ int MPEGFile::setBitrate(int bitrate) } -int DABPlusFile::readFrame(void* buffer, int size) +int DABPlusFile::readFrame(uint8_t* buffer, size_t size) { - uint8_t* dataOut = reinterpret_cast(buffer); - - ssize_t ret = read(m_fd, dataOut, size); + ssize_t ret = read(m_fd, buffer, size); if (ret == -1) { etiLog.log(alert, "ERROR: Can't read file\n"); @@ -190,7 +188,7 @@ int DABPlusFile::readFrame(void* buffer, int size) return -1; } - if (ret < size) { + if (ret < (ssize_t)size) { ssize_t sizeOut = ret; etiLog.log(info, "reach end of file -> rewinding\n"); if (rewind() == -1) { @@ -198,14 +196,14 @@ int DABPlusFile::readFrame(void* buffer, int size) return -1; } - ret = read(m_fd, dataOut + sizeOut, size - sizeOut); + ret = read(m_fd, buffer + sizeOut, size - sizeOut); if (ret == -1) { etiLog.log(alert, "ERROR: Can't read file\n"); perror(""); return -1; } - if (ret < size) { + if (ret < (ssize_t)size) { etiLog.log(alert, "ERROR: Not enough data in file\n"); return -1; } diff --git a/src/input/File.h b/src/input/File.h index 61be8b1..01f4f21 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -36,7 +36,7 @@ namespace Inputs { class FileBase : public InputBase { public: virtual int open(const std::string& name); - virtual int readFrame(void* buffer, int size) = 0; + virtual int readFrame(uint8_t* buffer, size_t size) = 0; virtual int setBitrate(int bitrate) = 0; virtual int close(); @@ -52,7 +52,7 @@ class FileBase : public InputBase { class MPEGFile : public FileBase { public: - virtual int readFrame(void* buffer, int size); + virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); private: @@ -61,7 +61,7 @@ class MPEGFile : public FileBase { class DABPlusFile : public FileBase { public: - virtual int readFrame(void* buffer, int size); + virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); }; diff --git a/src/input/Prbs.cpp b/src/input/Prbs.cpp index 8e5a9ae..607ce9f 100644 --- a/src/input/Prbs.cpp +++ b/src/input/Prbs.cpp @@ -77,12 +77,10 @@ int Prbs::open(const string& name) return 0; } -int Prbs::readFrame(void* buffer, int size) +int Prbs::readFrame(uint8_t* buffer, size_t size) { - unsigned char* cbuffer = reinterpret_cast(buffer); - - for (int i = 0; i < size; ++i) { - cbuffer[i] = m_prbs.step(); + for (size_t i = 0; i < size; ++i) { + buffer[i] = m_prbs.step(); } return size; diff --git a/src/input/Prbs.h b/src/input/Prbs.h index 1ad5047..3b2b7d4 100644 --- a/src/input/Prbs.h +++ b/src/input/Prbs.h @@ -38,7 +38,7 @@ namespace Inputs { class Prbs : public InputBase { public: virtual int open(const std::string& name); - virtual int readFrame(void* buffer, int size); + virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/Udp.cpp b/src/input/Udp.cpp index e534a06..a238d9b 100644 --- a/src/input/Udp.cpp +++ b/src/input/Udp.cpp @@ -87,7 +87,7 @@ int Udp::open(const std::string& name) return 0; } -int Udp::readFrame(void* buffer, int size) +int Udp::readFrame(uint8_t* buffer, size_t size) { uint8_t* data = reinterpret_cast(buffer); diff --git a/src/input/Udp.h b/src/input/Udp.h index b6705e9..379dbf3 100644 --- a/src/input/Udp.h +++ b/src/input/Udp.h @@ -36,7 +36,7 @@ namespace Inputs { class Udp : public InputBase { public: virtual int open(const std::string& name); - virtual int readFrame(void* buffer, int size); + virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/Zmq.cpp b/src/input/Zmq.cpp index 985fad3..a5601fa 100644 --- a/src/input/Zmq.cpp +++ b/src/input/Zmq.cpp @@ -246,7 +246,7 @@ int ZmqBase::setBitrate(int bitrate) } // size corresponds to a frame size. It is constant for a given bitrate -int ZmqBase::readFrame(void* buffer, int size) +int ZmqBase::readFrame(uint8_t* buffer, size_t size) { int rc; diff --git a/src/input/Zmq.h b/src/input/Zmq.h index 02fce3a..8d729e0 100644 --- a/src/input/Zmq.h +++ b/src/input/Zmq.h @@ -181,7 +181,7 @@ class ZmqBase : public InputBase, public RemoteControllable { } virtual int open(const std::string& inputUri); - virtual int readFrame(void* buffer, int size); + virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); virtual int close(); diff --git a/src/input/inputs.h b/src/input/inputs.h index 3bc1fa4..bfb1fb6 100644 --- a/src/input/inputs.h +++ b/src/input/inputs.h @@ -39,7 +39,7 @@ namespace Inputs { class InputBase { public: virtual int open(const std::string& name) = 0; - virtual int readFrame(void* buffer, int size) = 0; + virtual int readFrame(uint8_t* buffer, size_t size) = 0; virtual int setBitrate(int bitrate) = 0; virtual int close() = 0; -- cgit v1.2.3 From 7405d574963abb37732de8a90dd9e42174e0410f Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 4 Nov 2016 14:57:16 +0100 Subject: Use RawFile for DAB+ and for data --- src/ConfigParser.cpp | 8 +++----- src/input/File.cpp | 4 ++-- src/input/File.h | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/input/File.h') diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index ddcb9ed..a311d63 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -936,7 +936,7 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, subchan->input = make_shared(); } else if (type == "dabplus") { - subchan->input = make_shared(); + subchan->input = make_shared(); } else { throw logic_error("Incomplete handling of file input"); @@ -982,10 +982,8 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, else if (type == "data") { if (proto == "udp") { subchan->input = make_shared(); - } else if (proto == "file") { - // TODO - } else if (proto == "fifo") { - // TODO + } else if (proto == "file" or proto == "fifo") { + subchan->input = make_shared(); } else { stringstream ss; ss << "Subchannel with uid " << subchanuid << diff --git a/src/input/File.cpp b/src/input/File.cpp index eb26136..732f2a2 100644 --- a/src/input/File.cpp +++ b/src/input/File.cpp @@ -178,7 +178,7 @@ int MPEGFile::setBitrate(int bitrate) } -int DABPlusFile::readFrame(uint8_t* buffer, size_t size) +int RawFile::readFrame(uint8_t* buffer, size_t size) { ssize_t ret = read(m_fd, buffer, size); @@ -212,7 +212,7 @@ int DABPlusFile::readFrame(uint8_t* buffer, size_t size) return size; } -int DABPlusFile::setBitrate(int bitrate) +int RawFile::setBitrate(int bitrate) { if (bitrate <= 0) { etiLog.log(error, "Invalid bitrate (%i)\n", bitrate); diff --git a/src/input/File.h b/src/input/File.h index 01f4f21..99e0a87 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -59,11 +59,10 @@ class MPEGFile : public FileBase { bool m_parity = false; }; -class DABPlusFile : public FileBase { +class RawFile : public FileBase { public: virtual int readFrame(uint8_t* buffer, size_t size); virtual int setBitrate(int bitrate); }; - }; -- cgit v1.2.3 From 5fd4d99aded3677497c6cf5ab31517a5383333cb Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 5 Nov 2016 14:35:25 +0100 Subject: Add Packet File input --- src/ConfigParser.cpp | 7 ++ src/input/File.cpp | 282 +++++++++++++++++++++++++++++++++++++++++++++------ src/input/File.h | 26 ++++- 3 files changed, 280 insertions(+), 35 deletions(-) (limited to 'src/input/File.h') diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 3167d49..1ed1bac 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -1003,6 +1003,13 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, etiLog.level(warn) << "uid " << subchanuid << " of type Dmb uses RAW input"; } } + else if (type == "packet" or type == "enhancedpacket") { + subchan->type = subchannel_type_t::Packet; + subchan->bitrate = DEFAULT_PACKET_BITRATE; + + bool enhanced = (type == "enhancedpacket"); + subchan->input = make_shared(enhanced); + } else { stringstream ss; ss << "Subchannel with uid " << subchanuid << " has unknown type!"; diff --git a/src/input/File.cpp b/src/input/File.cpp index 732f2a2..5c61fd4 100644 --- a/src/input/File.cpp +++ b/src/input/File.cpp @@ -35,9 +35,31 @@ #include "input/File.h" #include "mpeg.h" +#include "ReedSolomon.h" namespace Inputs { +#ifdef _WIN32 +# pragma pack(push, 1) +#endif +struct packetHeader { + unsigned char addressHigh:2; + unsigned char last:1; + unsigned char first:1; + unsigned char continuityIndex:2; + unsigned char packetLength:2; + unsigned char addressLow; + unsigned char dataLength:7; + unsigned char command; +} +#ifdef _WIN32 +# pragma pack(pop) +#else +__attribute((packed)) +#endif +; + + int FileBase::open(const std::string& name) { m_fd = ::open(name.c_str(), O_RDONLY | O_BINARY); @@ -50,6 +72,17 @@ int FileBase::open(const std::string& name) return 0; } +int FileBase::setBitrate(int bitrate) +{ + if (bitrate <= 0) { + etiLog.log(error, "Invalid bitrate (%i)\n", bitrate); + return -1; + } + + return bitrate; +} + + int FileBase::close() { if (m_fd != -1) { @@ -64,6 +97,40 @@ int FileBase::rewind() return ::lseek(m_fd, 0, SEEK_SET); } +ssize_t FileBase::readFromFile(uint8_t* buffer, size_t size) +{ + ssize_t ret = read(m_fd, buffer, size); + + if (ret == -1) { + etiLog.log(alert, "ERROR: Can't read file\n"); + perror(""); + return -1; + } + + if (ret < (ssize_t)size) { + ssize_t sizeOut = ret; + etiLog.log(info, "reach end of file -> rewinding\n"); + if (rewind() == -1) { + etiLog.log(alert, "ERROR: Can't rewind file\n"); + return -1; + } + + ret = read(m_fd, buffer + sizeOut, size - sizeOut); + if (ret == -1) { + etiLog.log(alert, "ERROR: Can't read file\n"); + perror(""); + return -1; + } + + if (ret < (ssize_t)size) { + etiLog.log(alert, "ERROR: Not enough data in file\n"); + return -1; + } + } + + return size; +} + int MPEGFile::readFrame(uint8_t* buffer, size_t size) { int result; @@ -177,49 +244,200 @@ int MPEGFile::setBitrate(int bitrate) return bitrate; } - int RawFile::readFrame(uint8_t* buffer, size_t size) { - ssize_t ret = read(m_fd, buffer, size); + return readFromFile(buffer, size); +} - if (ret == -1) { - etiLog.log(alert, "ERROR: Can't read file\n"); - perror(""); - return -1; - } +PacketFile::PacketFile(bool enhancedPacketMode) +{ + m_enhancedPacketEnabled = enhancedPacketMode; +} - if (ret < (ssize_t)size) { - ssize_t sizeOut = ret; - etiLog.log(info, "reach end of file -> rewinding\n"); - if (rewind() == -1) { - etiLog.log(alert, "ERROR: Can't rewind file\n"); - return -1; - } +int PacketFile::readFrame(uint8_t* buffer, size_t size) +{ + size_t written = 0; + int length; + packetHeader* header; + int indexRow; + int indexCol; - ret = read(m_fd, buffer + sizeOut, size - sizeOut); - if (ret == -1) { - etiLog.log(alert, "ERROR: Can't read file\n"); - perror(""); - return -1; + while (written < size) { + if (m_enhancedPacketWaiting > 0) { + *buffer = 192 - m_enhancedPacketWaiting; + *buffer /= 22; + *buffer <<= 2; + *(buffer++) |= 0x03; + *(buffer++) = 0xfe; + indexCol = 188; + indexCol += (192 - m_enhancedPacketWaiting) / 12; + indexRow = 0; + indexRow += (192 - m_enhancedPacketWaiting) % 12; + for (int j = 0; j < 22; ++j) { + if (m_enhancedPacketWaiting == 0) { + *(buffer++) = 0; + } + else { + *(buffer++) = m_enhancedPacketData[indexRow][indexCol]; + if (++indexRow == 12) { + indexRow = 0; + ++indexCol; + } + --m_enhancedPacketWaiting; + } + } + written += 24; + if (m_enhancedPacketWaiting == 0) { + m_enhancedPacketLength = 0; + } } + else if (m_packetLength != 0) { + header = (packetHeader*)(&m_packetData[0]); + if (written + m_packetLength > (unsigned)size) { + memset(buffer, 0, 22); + buffer[22] = 0x60; + buffer[23] = 0x4b; + length = 24; + } + else if (m_enhancedPacketEnabled) { + if (m_enhancedPacketLength + m_packetLength > (12 * 188)) { + memset(buffer, 0, 22); + buffer[22] = 0x60; + buffer[23] = 0x4b; + length = 24; + } + else { + std::copy(m_packetData.begin(), + m_packetData.begin() + m_packetLength, + buffer); + length = m_packetLength; + m_packetLength = 0; + } + } + else { + std::copy(m_packetData.begin(), + m_packetData.begin() + m_packetLength, + buffer); + length = m_packetLength; + m_packetLength = 0; + } - if (ret < (ssize_t)size) { - etiLog.log(alert, "ERROR: Not enough data in file\n"); - return -1; + if (m_enhancedPacketEnabled) { + indexCol = m_enhancedPacketLength / 12; + indexRow = m_enhancedPacketLength % 12; // TODO Check if always 0 + for (int j = 0; j < length; ++j) { + m_enhancedPacketData[indexRow][indexCol] = buffer[j]; + if (++indexRow == 12) { + indexRow = 0; + ++indexCol; + } + } + m_enhancedPacketLength += length; + if (m_enhancedPacketLength >= (12 * 188)) { + m_enhancedPacketLength = (12 * 188); + ReedSolomon encoder(204, 188); + for (int j = 0; j < 12; ++j) { + encoder.encode(&m_enhancedPacketData[j][0], 188); + } + m_enhancedPacketWaiting = 192; + } + } + written += length; + buffer += length; } - } + else { + int nbBytes = readFromFile(buffer, 3); + header = (packetHeader*)buffer; + if (nbBytes == -1) { + if (errno == EAGAIN) goto END_PACKET; + perror("Packet file"); + return -1; + } + else if (nbBytes == 0) { + if (rewind() == -1) { + goto END_PACKET; + } + continue; + } + else if (nbBytes < 3) { + etiLog.log(error, + "Error while reading file for packet header; " + "read %i out of 3 bytes\n", nbBytes); + break; + } - return size; -} + length = header->packetLength * 24 + 24; + if (written + length > size) { + memcpy(&m_packetData[0], header, 3); + readFromFile(&m_packetData[3], length - 3); + m_packetLength = length; + continue; + } -int RawFile::setBitrate(int bitrate) -{ - if (bitrate <= 0) { - etiLog.log(error, "Invalid bitrate (%i)\n", bitrate); - return -1; - } + if (m_enhancedPacketEnabled) { + if (m_enhancedPacketLength + length > (12 * 188)) { + memcpy(&m_packetData[0], header, 3); + readFromFile(&m_packetData[3], length - 3); + m_packetLength = length; + continue; + } + } - return bitrate; + nbBytes = readFromFile(buffer + 3, length - 3); + if (nbBytes == -1) { + perror("Packet file"); + return -1; + } + else if (nbBytes == 0) { + etiLog.log(info, + "Packet header read, but no data!\n"); + if (rewind() == -1) { + goto END_PACKET; + } + continue; + } + else if (nbBytes < length - 3) { + etiLog.log(error, "Error while reading packet file; " + "read %i out of %i bytes\n", nbBytes, length - 3); + break; + } + + if (m_enhancedPacketEnabled) { + indexCol = m_enhancedPacketLength / 12; + indexRow = m_enhancedPacketLength % 12; // TODO Check if always 0 + for (int j = 0; j < length; ++j) { + m_enhancedPacketData[indexRow][indexCol] = buffer[j]; + if (++indexRow == 12) { + indexRow = 0; + ++indexCol; + } + } + m_enhancedPacketLength += length; + if (m_enhancedPacketLength >= (12 * 188)) { + if (m_enhancedPacketLength > (12 * 188)) { + etiLog.log(error, + "Error, too much enhanced packet data!\n"); + } + ReedSolomon encoder(204, 188); + for (int j = 0; j < 12; ++j) { + encoder.encode(&m_enhancedPacketData[j][0], 188); + } + m_enhancedPacketWaiting = 192; + } + } + written += length; + buffer += length; + } + } +END_PACKET: + while (written < size) { + memset(buffer, 0, 22); + buffer[22] = 0x60; + buffer[23] = 0x4b; + buffer += 24; + written += 24; + } + return written; } }; diff --git a/src/input/File.h b/src/input/File.h index 99e0a87..bf99748 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -26,6 +26,7 @@ #pragma once #include +#include #include #include #include "input/inputs.h" @@ -37,7 +38,7 @@ class FileBase : public InputBase { public: virtual int open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size) = 0; - virtual int setBitrate(int bitrate) = 0; + virtual int setBitrate(int bitrate); virtual int close(); /* Rewind the file @@ -45,8 +46,13 @@ class FileBase : public InputBase { */ virtual int rewind(); protected: + /* Read len bytes from the file into buf, and return + * the number of bytes read, or -1 in case of error. + */ + virtual ssize_t readFromFile(uint8_t* buf, size_t len); + // We use unix open() instead of fopen() because - // we want to do non-blocking I/O + // we might want to do non-blocking I/O in the future int m_fd = -1; }; @@ -62,7 +68,21 @@ class MPEGFile : public FileBase { class RawFile : public FileBase { public: virtual int readFrame(uint8_t* buffer, size_t size); - virtual int setBitrate(int bitrate); +}; + +class PacketFile : public FileBase { + public: + PacketFile(bool enhancedPacketMode); + virtual int readFrame(uint8_t* buffer, size_t size); + + protected: + std::array m_packetData; + size_t m_packetLength; + + bool m_enhancedPacketEnabled = false; + std::array,12> m_enhancedPacketData; + size_t m_enhancedPacketWaiting; + size_t m_enhancedPacketLength; }; }; -- cgit v1.2.3 From 1e1e43d9bfa006049bde3d210030e5f0b2d38ca3 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 5 Nov 2016 16:34:40 +0100 Subject: Describe inputs a bit better in advanced.mux --- doc/advanced.mux | 32 ++++++++++++++++++++++++++++++-- src/input/File.h | 3 +++ 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src/input/File.h') diff --git a/doc/advanced.mux b/doc/advanced.mux index 8d460d2..41a3446 100644 --- a/doc/advanced.mux +++ b/doc/advanced.mux @@ -130,8 +130,17 @@ services { } ; The subchannels are defined in the corresponding section. -; supported types are : audio, bridge, data, enhancedpacket, -; dabplus, dmb, packet, test +; supported types are : audio, data, enhancedpacket, +; dabplus, packet +; +; Type 'packet' expects to receive data in the format described +; in EN 300 401 Clause 3.5.2. +; +; 'enhancedpacket' mode will calculate FEC for MSC packet mode +; as described in EN 300 401 Clause 5.3.5. +; +; 'data' will read from the source and write it unmodified into +; the MSC. subchannels { sub-fu { type audio @@ -235,6 +244,25 @@ subchannels { zmq-buffer 40 zmq-prebuffering 20 } + + ; 'prbs' will generate a pseudorandom bit sequence according to + ; ETS 300 799 Clause G.2.1. This is useful for testing purposes and + ; measurement of bit error rate. + sub-prbs { + type data + + ; Use the default PRBS polynomial. + inputfile "prbs://" + + ; To use another polynomial, set it in the url as hexadecimal + ; The default polynomial is G(x) = x^20 + x^17 + 1, represented as + ; (1 << 20) + (1 << 17) + (1 << 0) = 0x120001 + ;inputuri "prbs://:0x120001 + + bitrate 16 + id 5 + protection 3 + } } ; For now, each component links one service to one subchannel diff --git a/src/input/File.h b/src/input/File.h index bf99748..080d6b5 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -79,6 +79,9 @@ class PacketFile : public FileBase { std::array m_packetData; size_t m_packetLength; + /* Enhanced packet mode enables FEC for MSC packet mode + * as described in EN 300 401 Clause 5.3.5 + */ bool m_enhancedPacketEnabled = false; std::array,12> m_enhancedPacketData; size_t m_enhancedPacketWaiting; -- cgit v1.2.3