From f21352094c0949b643721ee5387fefae0cdab507 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 30 Oct 2016 11:31:56 +0100 Subject: Move hexparse to utils and add default PRBS poly --- src/utils.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/utils.cpp') diff --git a/src/utils.cpp b/src/utils.cpp index 9976e88..f0df772 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -426,3 +426,29 @@ void printEnsemble(const shared_ptr ensemble) } } +long hexparse(const std::string& input) +{ + long value = 0; + errno = 0; + + // Do not use strtol's base=0 because + // we do not want to accept octal. + if (input.find("0x") == 0) { + value = strtol(input.c_str() + 2, nullptr, 16); + } + else { + value = strtol(input.c_str(), nullptr, 10); + } + + if ((value == LONG_MIN or value == LONG_MAX) and errno == ERANGE) { + throw out_of_range("hexparse: value out of range"); + } + else if (value == 0 and errno != 0) { + stringstream ss; + ss << "hexparse: " << strerror(errno); + throw invalid_argument(ss.str()); + } + + return value; +} + -- cgit v1.2.3 From 5aa8118d99b104402bf044e57c473a7156dc2314 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 30 Oct 2016 12:08:29 +0100 Subject: Remove bridge format and input --- configure.ac | 8 +- src/ConfigParser.cpp | 11 - src/DabMux.cpp | 1 - src/Makefile.am | 2 - src/bridge.c | 515 ---------------------------------------------- src/bridge.h | 112 ---------- src/dabInputBridgeUdp.cpp | 129 ------------ src/dabInputBridgeUdp.h | 49 ----- src/utils.cpp | 3 - 9 files changed, 1 insertion(+), 829 deletions(-) delete mode 100644 src/bridge.c delete mode 100644 src/bridge.h delete mode 100644 src/dabInputBridgeUdp.cpp delete mode 100644 src/dabInputBridgeUdp.h (limited to 'src/utils.cpp') diff --git a/configure.ac b/configure.ac index 39d3f19..06a2249 100644 --- a/configure.ac +++ b/configure.ac @@ -198,12 +198,6 @@ AC_ARG_ENABLE([format_raw], [], [enable_format_raw=yes]) AS_IF([test "x$enable_format_raw" = "xyes"], [AC_DEFINE(HAVE_FORMAT_RAW, [1], [Define if RAW format is enabled])]) -# BRIDGE -AC_ARG_ENABLE([format_bridge], - [AS_HELP_STRING([--enable-format-bridge], [Enable BRIDGE format])], - [], [enable_format_bridge=no]) -AS_IF([test "x$enable_format_bridge" = "xno"], - [AC_DEFINE(HAVE_FORMAT_BRIDGE, [1], [Define if BRIDGE format is enabled])]) # MPEG AC_ARG_ENABLE([format_mpeg], [AS_HELP_STRING([--disable-format-mpeg], [Disable MPEG format])], @@ -266,7 +260,7 @@ echo echo "Formats:" enabled="" disabled="" -for format in raw bridge mpeg packet dabplus dmb epm +for format in raw mpeg packet dabplus dmb epm do eval var=\$enable_format_$format AS_IF([test "x$var" = "xyes"], diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index e68f98f..aee86fc 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -60,7 +60,6 @@ #include "dabInputEnhancedPacketFile.h" #include "dabInputEnhancedFifo.h" #include "dabInputUdp.h" -#include "dabInputBridgeUdp.h" #include "dabInputTest.h" #include "dabInputPrbs.h" #include "dabInputRawFile.h" @@ -714,16 +713,6 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, throw runtime_error(ss.str()); } #endif // defined(HAVE_FORMAT_DABPLUS) - } else if (type == "bridge") { - // TODO default proto should be udp:// - if (0) { -#if defined(HAVE_FORMAT_BRIDGE) -#if defined(HAVE_INPUT_UDP) - } else if (proto == "udp") { - operations = dabInputBridgeUdpOperations; -#endif // defined(HAVE_INPUT_UDP) -#endif // defined(HAVE_FORMAT_BRIDGE) - } } else if (type == "data" and proto == "prbs") { input_is_old_style = false; diff --git a/src/DabMux.cpp b/src/DabMux.cpp index f72ea8d..a4605e7 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -104,7 +104,6 @@ typedef DWORD32 uint32_t; #include "dabInputEnhancedPacketFile.h" #include "dabInputEnhancedFifo.h" #include "dabInputUdp.h" -#include "dabInputBridgeUdp.h" #include "dabInputTest.h" #include "dabInputPrbs.h" #include "dabInputRawFile.h" diff --git a/src/Makefile.am b/src/Makefile.am index dfcdb12..b23e71c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,7 +48,6 @@ odr_dabmux_LDADD =$(ZMQ_LIBS) $(CURL_LIBS) \ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \ DabMultiplexer.cpp DabMultiplexer.h \ dabInput.h dabInput.cpp \ - dabInputBridgeUdp.h dabInputBridgeUdp.cpp \ dabInputDabplusFifo.h dabInputDabplusFifo.cpp \ dabInputDabplusFile.h dabInputDabplusFile.cpp \ dabInputDmbFile.h dabInputDmbFile.cpp \ @@ -93,7 +92,6 @@ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \ TcpSocket.h TcpSocket.cpp \ UdpSocket.h UdpSocket.cpp \ ThreadsafeQueue.h \ - bridge.h bridge.c \ crc.h crc.c \ fig/FIG.h fig/FIG.cpp \ fig/FIG0.h fig/FIG0structs.h \ diff --git a/src/bridge.c b/src/bridge.c deleted file mode 100644 index d66a7b2..0000000 --- a/src/bridge.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the - Queen in Right of Canada (Communications Research Center Canada) - */ -/* - 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 . - */ - -#include -#ifdef _WIN32 -# include -#else -# include -#endif // _WIN32 -#include -#include "bridge.h" -#include "crc.h" - -#include -#include "PcDebug.h" - -#ifdef _WIN32 -# ifdef _DEBUG - int bridgeVerbosity = 0; -# endif -#else -# ifdef DEBUG - int bridgeVerbosity = 0; -# endif -#endif - -void printStats(struct bridgeInfo* info, FILE* out) -{ - struct bridgeStats stats = getStats(info); - fprintf(out, "frames : %lu\n", stats.frames); - fprintf(out, " valids : %lu\n", stats.valids); - fprintf(out, " invalids : %lu\n", stats.invalids); - fprintf(out, " bytes : %lu\n", stats.bytes); - fprintf(out, " packets : %lu\n", stats.packets); - fprintf(out, " errors : %lu\n", stats.errors); - fprintf(out, " missings : %lu\n", stats.missings); - fprintf(out, " dropped : %lu\n", stats.dropped); - fprintf(out, " crc : %lu\n", stats.crc); - fprintf(out, " overruns : %lu\n", stats.overruns); -} - - -void resetStats(struct bridgeInfo* info) -{ - memset(&info->stats, 0, sizeof(info->stats)); -} - - -struct bridgeStats getStats(struct bridgeInfo* info) -{ - return info->stats; -} - - -void bridgeInitInfo(struct bridgeInfo* info) -{ - memset(info, 0, sizeof(*info)); - info->transmitted = -8; -}; - - -int writePacket(void* dataIn, int sizeIn, void* dataOut, int sizeOut, - struct bridgeInfo* info) -{ - static struct bridgeHdr header = { 0 }; - - PDEBUG4_VERBOSE(1, bridgeVerbosity, "writePacket\n sizeIn: %i, sizeOut: %i, " - "offset: %i, transmitted: %i\n", - sizeIn, sizeOut, info->offset, info->transmitted); - - assert(info->transmitted < sizeIn); - - if ((info->offset == 0) && (sizeIn > 0)) { - ((unsigned short*)dataOut)[0] = 0xb486; - info->offset = 2; - } - if (sizeIn == 0) { - memset((unsigned char*)dataOut + info->offset, 0, sizeOut - info->offset); - info->offset = 0; - info->transmitted = -8; - PDEBUG1_VERBOSE(1, bridgeVerbosity, " return %i (sizeIn == 0)\n", - sizeOut); - return 0; - } - - while (info->offset < sizeOut) { - switch (info->transmitted) { - case (-8): - ((unsigned char*)dataOut)[info->offset++] = 0xcb; - ++info->transmitted; - break; - case (-7): - ((unsigned char*)dataOut)[info->offset++] = 0x28; - ++info->transmitted; - break; - case (-6): - header.size = htons((unsigned short)sizeIn); - header.crc = htons((unsigned short)(crc16(0xffff, &header, 4) ^ 0xffff)); - ((unsigned char*)dataOut)[info->offset++] = ((char*)&header)[0]; - ++info->transmitted; - break; - case (-5): - ((unsigned char*)dataOut)[info->offset++] = ((char*)&header)[1]; - ++info->transmitted; - break; - case (-4): - ((unsigned char*)dataOut)[info->offset++] = ((char*)&header)[2]; - ++info->transmitted; - break; - case (-3): - ((unsigned char*)dataOut)[info->offset++] = ((char*)&header)[3]; - ++info->transmitted; - break; - case (-2): - ((unsigned char*)dataOut)[info->offset++] = ((char*)&header)[4]; - ++info->transmitted; - break; - case (-1): - ((unsigned char*)dataOut)[info->offset++] = ((char*)&header)[5]; - ++info->transmitted; - header.seqNb = htons((unsigned short)(ntohs(header.seqNb) + 1)); - break; - default: - ((unsigned char*)dataOut)[info->offset++] = - ((unsigned char*)dataIn)[info->transmitted++]; - if (info->transmitted == sizeIn) { - PDEBUG2_VERBOSE(1, bridgeVerbosity, - " Packet done, %i bytes at offset %i\n", - info->transmitted, info->offset); - PDEBUG1_VERBOSE(1, bridgeVerbosity, - " return %i (sizeIn == transmitted)\n", info->offset); - info->transmitted = -8; - return info->offset; - } - } - } - - PDEBUG1_VERBOSE(1, bridgeVerbosity, " return %i (offset >= sizeOut)\n", - info->offset); - info->offset = 0; - return 0; -} - - -int getPacket(void* dataIn, int sizeIn, void* dataOut, int sizeOut, - struct bridgeInfo* info, char async) -{ - unsigned char* in = (unsigned char*)dataIn; - unsigned char* out = (unsigned char*)dataOut; - unsigned char ch; - unsigned short crc; - unsigned short diff; - - PDEBUG3_VERBOSE(1, bridgeVerbosity, - "getPacket\n pos\t%i\n state\t%i\n received\t%i\n", - info->pos, info->state, info->received); - - if (info->pos == 0) { - ++info->stats.frames; - if (((unsigned short*)dataIn)[0] != 0xb486) { - if (((unsigned short*)dataIn)[0] != 0) { - ++info->stats.invalids; - printf("WARNING: processing frame with invalid magic " - "number!\n"); - } else { - PDEBUG0_VERBOSE(1, bridgeVerbosity, - "getPacket: not a valid frame\n"); - return 0; - } - } else { - PDEBUG0_VERBOSE(2, bridgeVerbosity, "Valid frame\n"); - info->pos += 2; - ++info->stats.valids; - } - info->stats.bytes += sizeIn; - } - while (info->pos < sizeIn) { - ch = in[info->pos++]; - switch (info->state) { - case 0: // sync search - info->sync <<= 8; - info->sync |= ch; - if (info->sync == 0xcb28) { - PDEBUG0_VERBOSE(2, bridgeVerbosity, "Sync found\n"); - ++info->stats.packets; - info->received = 0; - info->state = 1; - } - if (info->sync == 0) { // Padding - info->pos = 0; - return 0; - } - break; - case 1: // header search - ((char*)&info->header)[info->received++] = ch; - if (info->received == sizeof(struct bridgeHdr)) { - PDEBUG0_VERBOSE(2, bridgeVerbosity, "Header found\n"); - out = (unsigned char*)dataOut; - info->received = 0; - info->state = 2; - crc = crc16(0xffff, &info->header, 4); - crc ^= 0xffff; - info->header.size = ntohs(info->header.size); - info->header.seqNb = ntohs(info->header.seqNb); - info->header.crc = ntohs(info->header.crc); - PDEBUG4_VERBOSE(2, bridgeVerbosity, - " size\t%i\n seq\t%i\n crc\t0x%.4x (0x%.4x)\n", - info->header.size, info->header.seqNb, - info->header.crc, crc); - if (crc != info->header.crc) { - PDEBUG0_VERBOSE(2, bridgeVerbosity, "CRC error\n"); - ++info->stats.errors; - ++info->stats.crc; - info->state = 0; - if (info->pos < sizeof(struct bridgeHdr) + 2 + 2) { - info->pos = 2; - } - } else { - if (!info->initSeq) { - info->lastSeq = info->header.seqNb; - info->initSeq = 1; - } else { - if (info->header.seqNb > info->lastSeq) { - diff = (info->header.seqNb - info->lastSeq) - 1; - } else { - diff = ((short)info->lastSeq - - (short)info->header.seqNb) - 1; - } - info->stats.errors += diff; - info->stats.missings += diff; - info->lastSeq = info->header.seqNb; - } - } - } - break; - case 2: // data - out[info->received++] = ch; - if (info->received == info->header.size) { - PDEBUG0_VERBOSE(2, bridgeVerbosity, "data found\n"); - info->state = 0; - return info->received; - } - if (info->received == sizeOut) { - PDEBUG1_VERBOSE(1, bridgeVerbosity, "To much data: %i\n", - info->received); - ++info->stats.errors; - ++info->stats.overruns; - info->sync = 0; - info->state = 0; - return -1; - } - break; - case 3: // Padding or sync - if (ch == 0) { // Padding - info->pos = 0; - return 0; - } - if (ch != 0xcb) { // error - info->sync = ch; - info->state = 0; - } else { - info->state = 4; - } - break; - case 4: // Low byte sync - if (ch != 28) { // error - info->sync <<= 8; - info->sync |= ch; - info->state = 0; - } else { - info->state = 2; - } - break; - } - } - info->pos = 0; - return 0; -} - - -void dump(void* data, int size, FILE* stream) -{ - int i; - fprintf(stream, "%i bytes\n", size); - for (i = 0; i < size; ++i) { - fprintf(stream, " 0x%.2x", ((unsigned char*)data)[i]); - if (i % 8 == 7) - fprintf(stream, "\n"); - } - fprintf(stream, "\n"); -} - - -#ifdef BRIDGE_TEST -#include - - -int test(const unsigned char* data) -{ - unsigned char bridgeSize = data[0]; - unsigned char nbInput = data[1]; - unsigned char nbBridge = 1; - struct bridgeInfo info; - - int i, j; - int index = 0; - int max = 0; - int nbBytes; - - unsigned char** inputData; - unsigned char** bridgeData; - unsigned char* outputData; - - inputData = malloc(nbInput * 4); - bridgeData = malloc(nbBridge * 4); - for (i = 0; i < nbInput; ++i) { - if (data[i + 2] > 0) - inputData[i] = malloc(data[i + 2]); - if (data[i + 2] > max) { - max = data[i + 2]; - } - for (j = 0; j < data[i + 2]; ++j) { - inputData[i][j] = index++; - } - } - bridgeData[0] = malloc(bridgeSize); - memset(bridgeData[0], 0, bridgeSize); - outputData = malloc(max); - bridgeInitInfo(&info); - - // Write packets - index = 0; - while (1) { - if (data[index + 2] == 0) { - if (++index == nbInput) - break; - } - while ((nbBytes = writePacket(inputData[index], data[index + 2], - bridgeData[nbBridge - 1], bridgeSize, &info)) - != 0) { - if (++index == nbInput) { - break; - } - } - if (index == nbInput) - break; - // TODO check null - bridgeData = realloc(bridgeData, (++nbBridge) * 4); - bridgeData[nbBridge - 1] = malloc(bridgeSize); - memset(bridgeData[nbBridge - 1], 0, bridgeSize); - } -// if (nbBytes != bridgeSize) { - writePacket(NULL, 0, bridgeData[nbBridge - 1], bridgeSize, &info); -// } - - // read packets - index = 0; - for (i = 0; i < nbBridge; ++i) { - while ((nbBytes = getPacket(bridgeData[i], bridgeSize, outputData, max, - &info, 0)) != 0) { - while (data[index + 2] == 0) { - ++index; - } - if (nbBytes != data[index + 2]) { - printf("FAILED\n"); - printf("Invalid size at bridge %i, data %i: %i != %i\n", - i, index, nbBytes, data[index + 2]); - for (i = 0; i < nbInput; ++i) { - printf("Input %i: ", i); - dump(inputData[i], data[i + 2], stdout); - } - for (i = 0; i < nbBridge; ++i) { - printf("Bridge %i: ", i); - dump(bridgeData[i], bridgeSize, stdout); - } - printf("Output %i: ", index); - dump(outputData, nbBytes, stdout); - return -1; - } - if (memcmp(outputData, inputData[index], data[index + 2]) != 0) { - printf("FAILED\n"); - printf("output != input\n"); - for (i = 0; i < nbInput; ++i) { - printf("Input %i: ", i); - dump(inputData[i], data[i + 2], stdout); - } - for (i = 0; i < nbBridge; ++i) { - printf("Bridge %i: ", i); - dump(bridgeData[i], bridgeSize, stdout); - } - printf("Output %i: ", index); - dump(outputData, nbBytes, stdout); - } - ++index; - } - } - - printf("SUCCESS\n"); - - for (i = 0; i < nbInput; ++i) { - if (data[i + 2] > 0) - free(inputData[i]); - } - free(inputData); - free(outputData); - for (i = 0; i < nbBridge; ++i) { - free(bridgeData[i]); - } - free(bridgeData); - - return -1; -} - - -int main(int argc, char* argv[]) -{ - int i; - // test: bridgesize, nbinput [, input1, input2, ... ] - const unsigned char complete[] = { 32, 1, 16 }; - const unsigned char split[] = { 32, 1, 48 }; - const unsigned char twice[] = {32, 2, 8, 4 }; - const unsigned char secondSplit[] = { 32, 2, 16, 16 }; - const unsigned char headerSplit[][4] = { - { 32, 2, 23, 16 }, - { 32, 2, 22, 16 }, - { 32, 2, 21, 16 }, - { 32, 2, 20, 16 }, - { 32, 2, 19, 16 }, - { 32, 2, 18, 16 }, - { 32, 2, 17, 16 } - }; - const unsigned char two[] = { 32, 3, 16, 0, 16 }; - const unsigned char doubleSplit[] = { 32, 2, 32, 32 }; - const unsigned char full[] = { 32, 2, 24, 12 }; - const unsigned char empty[] = { 32, 3, 0, 0, 5 }; - -#ifdef _WIN32 - #ifdef _DEBUG - bridgeVerbosity = argc - 1; - #endif // DEBUG -#else - #ifdef DEBUG - bridgeVerbosity = argc - 1; - #endif // DEBUG -#endif // _WIN32 - - printf("Complete: "); - test(complete); - // printStats(stdout); - fflush(stdout); - - printf("split: "); - test(split); - // printStats(stdout); - fflush(stdout); - - printf("twice: "); - test(twice); - // printStats(stdout); - fflush(stdout); - - printf("second split: "); - test(secondSplit); - // printStats(stdout); - fflush(stdout); - - for (i = 0; i < sizeof(headerSplit) / sizeof(headerSplit[0]); ++i) { - printf("headerSplit%i: ", i); - test(headerSplit[i]); - // printStats(stdout); - fflush(stdout); - } - - printf("two: "); - test(two); - // printStats(stdout); - fflush(stdout); - - printf("doubleSplit: "); - test(doubleSplit); - // printStats(stdout); - fflush(stdout); - - printf("full: "); - test(full); - // printStats(stdout); - fflush(stdout); - - printf("empty: "); - test(empty); - // printStats(stdout); - fflush(stdout); - - return 0; -} - -#endif // BRIDGE_TEST diff --git a/src/bridge.h b/src/bridge.h deleted file mode 100644 index 0bae007..0000000 --- a/src/bridge.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the - Queen in Right of Canada (Communications Research Center Canada) - */ -/* - 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 . - */ - -#ifndef _BRIDGE -#define _BRIDGE - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 -# ifdef _DEBUG - extern int bridgeVerbosity; -# endif // _DEBUG -#else -# ifndef DEBUG -# ifndef NDEBUG -# define NDEBUG -# endif -# else - extern int bridgeVerbosity; -# endif // DEBUG -#endif // _WIN32 - -struct bridgeStats { - unsigned long frames; // Number of frames analyzed - unsigned long valids; // Nb of frames with a good magic number - unsigned long invalids; // Nb of frames with a good magic number - unsigned long bytes; // Nb of data bytes - unsigned long packets; // Nb of packets found - unsigned long errors; - unsigned long missings; - unsigned long dropped; - unsigned long crc; // Nb of crc errors - unsigned long overruns; // Nb of packet too big -}; - - -struct bridgeHdr { - unsigned short size; - unsigned short seqNb; - unsigned short crc; -}; - - -struct bridgeInfo { - // Tx - int transmitted; // Nb bytes written - int offset; // Offset of the next byte to write - // Rx - int received; - int pos; - int state; - unsigned short lastSeq; - unsigned short sync; - char initSeq; - // General - struct bridgeHdr header; - struct bridgeStats stats; -}; - - - -void dump(void* data, int size, FILE* stream); - -/* - * Example of usae: - * if (data.length == 0) - * read(data) - * while (writePacket() != 0) - * read(read) - * ... - */ -int writePacket(void* dataIn, int sizeIn, void* dataOut, int sizeOut, struct bridgeInfo* info); - -int getPacket(void* dataIn, int sizeIn, void* dataOut, int sizeOut, struct bridgeInfo* info, char async); - -void bridgeInitInfo(struct bridgeInfo* info); -struct bridgeStats getStats(struct bridgeInfo* info); -void resetStats(struct bridgeInfo* info); -void printStats(struct bridgeInfo* info, FILE* out); - -#ifdef __cplusplus -} -#endif - -#endif // _BRIDGE diff --git a/src/dabInputBridgeUdp.cpp b/src/dabInputBridgeUdp.cpp deleted file mode 100644 index fdf3d1f..0000000 --- a/src/dabInputBridgeUdp.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications - Research Center Canada) - */ -/* - 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 . - */ - -#include "dabInputBridgeUdp.h" -#include "dabInputUdp.h" -#include "bridge.h" - -#ifdef HAVE_FORMAT_BRIDGE -# ifdef HAVE_INPUT_UDP - -struct dabInputBridgeUdpData { - dabInputUdpData* udpData; - bridgeInfo* info; -}; - - -struct dabInputOperations dabInputBridgeUdpOperations = { - dabInputBridgeUdpInit, - dabInputBridgeUdpOpen, - dabInputSetbuf, - NULL, - NULL, - NULL, - dabInputBridgeUdpRead, - dabInputSetbitrate, - dabInputBridgeUdpClose, - dabInputBridgeUdpClean, - NULL -}; - - -int dabInputBridgeUdpInit(void** args) -{ - dabInputBridgeUdpData* input = new dabInputBridgeUdpData; - dabInputUdpInit((void**)&input->udpData); - input->info = new bridgeInfo; - bridgeInitInfo(input->info); - *args = input; - - return 0; -} - - -int dabInputBridgeUdpOpen(void* args, const char* inputName) -{ - dabInputBridgeUdpData* input = (dabInputBridgeUdpData*)args; - - return dabInputUdpOpen(input->udpData, inputName); -} - - -int dabInputBridgeUdpRead(dabInputOperations* ops, void* args, void* buffer, int size) -{ - int nbBytes = 0; - dabInputBridgeUdpData* input = (dabInputBridgeUdpData*)args; - dabInputFifoStats* stats = (dabInputFifoStats*)&input->udpData->stats; - - stats->frameRecords[stats->frameCount].curSize = 0; - stats->frameRecords[stats->frameCount].maxSize = size; - - if (input->udpData->packet->getSize() == 0) { - input->udpData->socket->receive(*input->udpData->packet); - } - while ((nbBytes = writePacket(input->udpData->packet->getData(), - input->udpData->packet->getSize(), buffer, size, - input->info)) - != 0) { - stats->frameRecords[stats->frameCount].curSize = nbBytes; - input->udpData->socket->receive(*input->udpData->packet); - } - - if (input->udpData->packet->getSize() != 0) { - stats->frameRecords[stats->frameCount].curSize = size; - } - - if (++stats->frameCount == NB_RECORDS) { - etiLog.log(info, "Data subchannel usage: (%i)", - stats->id); - for (int i = 0; i < stats->frameCount; ++i) { - etiLog.log(info, " %i/%i", - stats->frameRecords[i].curSize, - stats->frameRecords[i].maxSize); - } - etiLog.log(info, "\n"); - stats->frameCount = 0; - } - return size; -} - - -int dabInputBridgeUdpClose(void* args) -{ - dabInputBridgeUdpData* input = (dabInputBridgeUdpData*)args; - - return dabInputUdpClose(input->udpData); -} - - -int dabInputBridgeUdpClean(void** args) -{ - dabInputBridgeUdpData* input = (dabInputBridgeUdpData*)(*args); - dabInputUdpClean((void**)&input->udpData); - delete input->info; - delete input; - return 0; -} - - -# endif // HAVE_INPUT_UDP -#endif // HAVE_FORMAT_BRIDGE - diff --git a/src/dabInputBridgeUdp.h b/src/dabInputBridgeUdp.h deleted file mode 100644 index ed00952..0000000 --- a/src/dabInputBridgeUdp.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications - Research Center Canada) - */ -/* - 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 . - */ - -#ifndef DAB_INPUT_BRIDGE_UDP_H -#define DAB_INPUT_BRIDGE_UDP_H - - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include "dabInput.h" - - -#ifdef HAVE_FORMAT_BRIDGE -# ifdef HAVE_INPUT_UDP - - -extern struct dabInputOperations dabInputBridgeUdpOperations; - -int dabInputBridgeUdpInit(void** args); -int dabInputBridgeUdpOpen(void* args, const char* inputName); -int dabInputBridgeUdpRead(dabInputOperations* ops, void* args, void* buffer, int size); -int dabInputBridgeUdpClose(void* args); -int dabInputBridgeUdpClean(void** args); - - -# endif -#endif - - -#endif // DAB_INPUT_BRIDGE_UDP_H diff --git a/src/utils.cpp b/src/utils.cpp index f0df772..5e7cf7a 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -124,9 +124,6 @@ void header_message() #if defined(HAVE_FORMAT_RAW) " raw" << #endif -#if defined(HAVE_FORMAT_BRIDGE) - " bridge" << -#endif #if defined(HAVE_FORMAT_MPEG) " mpeg" << #endif -- cgit v1.2.3 From 7ab5c97051108d9d752896798efe0886573e730e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 30 Oct 2016 12:18:30 +0100 Subject: Remove dabInputTest --- configure.ac | 14 ++----- src/ConfigParser.cpp | 7 ---- src/DabMux.cpp | 1 - src/Makefile.am | 1 - src/dabInputTest.cpp | 105 --------------------------------------------------- src/dabInputTest.h | 50 ------------------------ src/utils.cpp | 3 -- 7 files changed, 4 insertions(+), 177 deletions(-) delete mode 100644 src/dabInputTest.cpp delete mode 100644 src/dabInputTest.h (limited to 'src/utils.cpp') diff --git a/configure.ac b/configure.ac index 06a2249..47523de 100644 --- a/configure.ac +++ b/configure.ac @@ -115,12 +115,6 @@ AC_ARG_ENABLE([input_file], AS_IF([test "x$enable_input_file" = "xyes"], [AC_DEFINE(HAVE_INPUT_FILE, [1], [Define if FILE input is enabled])]) -# TEST -AC_ARG_ENABLE([input_test], - [AS_HELP_STRING([--enable-input-test], [Enable TEST input])], - [], [enable_input_test=no]) -AS_IF([test "x$enable_input_test" = "xyes"], - [AC_DEFINE(HAVE_INPUT_TEST, [1], [Define if TEST input is enabled])]) # UDP AC_ARG_ENABLE([input_udp], [AS_HELP_STRING([--enable-input-udp], [Enable UDP input])], @@ -246,12 +240,12 @@ echo echo "Inputs:" enabled="prbs" disabled="" -for output in test udp fifo file +for input in udp fifo file do - eval var=\$enable_input_$output + eval var=\$enable_input_$input AS_IF([test "x$var" = "xyes"], - [enabled="$enabled $output"], - [disabled="$disabled $output"]) + [enabled="$enabled $input"], + [disabled="$disabled $input"]) done echo " Enabled: $enabled" echo " Disabled: $disabled" diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index aee86fc..d5c55ae 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -60,7 +60,6 @@ #include "dabInputEnhancedPacketFile.h" #include "dabInputEnhancedFifo.h" #include "dabInputUdp.h" -#include "dabInputTest.h" #include "dabInputPrbs.h" #include "dabInputRawFile.h" #include "dabInputRawFifo.h" @@ -742,12 +741,6 @@ static void setup_subchannel_from_ptree(DabSubchannel* subchan, subchan->type = subchannel_type_t::DataDmb; subchan->bitrate = DEFAULT_DATA_BITRATE; -#if defined(HAVE_INPUT_TEST) && defined(HAVE_FORMAT_RAW) - } else if (type == "test") { - subchan->type = subchannel_type_t::DataDmb; - subchan->bitrate = DEFAULT_DATA_BITRATE; - operations = dabInputTestOperations; -#endif // defined(HAVE_INPUT_TEST)) && defined(HAVE_FORMAT_RAW) #ifdef HAVE_FORMAT_PACKET } else if (type == "packet") { subchan->type = subchannel_type_t::Packet; diff --git a/src/DabMux.cpp b/src/DabMux.cpp index a4605e7..79a8573 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -104,7 +104,6 @@ typedef DWORD32 uint32_t; #include "dabInputEnhancedPacketFile.h" #include "dabInputEnhancedFifo.h" #include "dabInputUdp.h" -#include "dabInputTest.h" #include "dabInputPrbs.h" #include "dabInputRawFile.h" #include "dabInputRawFifo.h" diff --git a/src/Makefile.am b/src/Makefile.am index b23e71c..408c86e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,6 @@ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \ dabInputPrbs.h dabInputPrbs.cpp \ dabInputRawFile.h dabInputRawFile.cpp \ dabInputRawFifo.h dabInputRawFifo.cpp \ - dabInputTest.h dabInputTest.cpp \ dabInputUdp.h dabInputUdp.cpp \ dabInputZmq.h dabInputZmq.cpp \ dabOutput/dabOutput.h \ diff --git a/src/dabInputTest.cpp b/src/dabInputTest.cpp deleted file mode 100644 index fd4fc59..0000000 --- a/src/dabInputTest.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications - Research Center Canada) - */ -/* - 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 . - */ - -#include "dabInputTest.h" - -#include -#ifdef _WIN32 -#else -# include -#endif - - -#ifdef HAVE_FORMAT_RAW -# ifdef HAVE_INPUT_TEST - - -struct dabInputTestData { - unsigned long counter; -}; - - -struct dabInputOperations dabInputTestOperations = { - dabInputTestInit, - dabInputTestOpen, - NULL, - NULL, - NULL, - NULL, - dabInputTestRead, - dabInputTestSetbitrate, - dabInputTestClose, - dabInputTestClean, - NULL -}; - - -int dabInputTestInit(void** args) -{ - dabInputTestData* input = new dabInputTestData; - memset(input, 0, sizeof(*input)); - input->counter = 0; - *args = input; - return 0; -} - - -int dabInputTestOpen(void* args, const char* inputName) -{ - return 0; -} - - -int dabInputTestRead(dabInputOperations* ops, void* args, void* buffer, int size) -{ - dabInputTestData* input = (dabInputTestData*)args; - char* data = (char*)buffer; - - *((long*)buffer) = htonl(input->counter++); - for (int i = sizeof(input->counter); i < size; ++i) { - data[i] = i; - } - return size; -} - - -int dabInputTestSetbitrate(dabInputOperations* ops, void* args, int bitrate) -{ - return bitrate; -} - - -int dabInputTestClose(void* args) -{ - return 0; -} - - -int dabInputTestClean(void** args) -{ - dabInputTestData* input = (dabInputTestData*)(*args); - delete input; - return 0; -} - - -# endif -#endif diff --git a/src/dabInputTest.h b/src/dabInputTest.h deleted file mode 100644 index 34ebc05..0000000 --- a/src/dabInputTest.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications - Research Center Canada) - */ -/* - 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 . - */ - -#ifndef DAB_INPUT_TEST_H -#define DAB_INPUT_TEST_H - - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include "dabInput.h" - - -#ifdef HAVE_FORMAT_RAW -# ifdef HAVE_INPUT_TEST - - -extern struct dabInputOperations dabInputTestOperations; - -int dabInputTestInit(void** args); -int dabInputTestOpen(void* args, const char* inputName); -int dabInputTestRead(dabInputOperations* ops, void* args, void* buffer, int size); -int dabInputTestSetbitrate(dabInputOperations* ops, void* args, int bitrate); -int dabInputTestClose(void* args); -int dabInputTestClean(void** args); - - -# endif -#endif - - -#endif // DAB_INPUT_TEST_H diff --git a/src/utils.cpp b/src/utils.cpp index 5e7cf7a..e26389d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -103,9 +103,6 @@ void header_message() std::cerr << "Input URLs supported:" << std::endl << " prbs" << -#if defined(HAVE_INPUT_TEST) - " test" << -#endif #if defined(HAVE_INPUT_UDP) " udp" << #endif -- cgit v1.2.3 From 2527834ec17d9c9a9aa2880ecc735ecdb64e3e82 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 5 Nov 2016 16:36:45 +0100 Subject: Remove #if HAVE_{INPUT,FORMAT} in utils --- src/utils.cpp | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/utils.cpp') diff --git a/src/utils.cpp b/src/utils.cpp index e26389d..cf57170 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -103,36 +103,16 @@ void header_message() std::cerr << "Input URLs supported:" << std::endl << " prbs" << -#if defined(HAVE_INPUT_UDP) " udp" << -#endif -#if defined(HAVE_INPUT_FIFO) - " fifo" << -#endif -#if defined(HAVE_INPUT_FILE) " file" << -#endif -#if defined(HAVE_INPUT_ZEROMQ) " zmq" << -#endif std::endl; std::cerr << "Inputs format supported:" << std::endl << -#if defined(HAVE_FORMAT_RAW) " raw" << -#endif -#if defined(HAVE_FORMAT_MPEG) " mpeg" << -#endif -#if defined(HAVE_FORMAT_PACKET) " packet" << -#endif -#if defined(HAVE_FORMAT_DMB) - " dmb" << -#endif -#if defined(HAVE_FORMAT_EPM) " epm" << -#endif std::endl; std::cerr << "Output URLs supported:" << std::endl << -- cgit v1.2.3