aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dabInput.cpp49
-rw-r--r--src/dabInput.h103
-rw-r--r--src/dabInputDabplusFifo.cpp186
-rw-r--r--src/dabInputDabplusFifo.h54
-rw-r--r--src/dabInputDabplusFile.cpp177
-rw-r--r--src/dabInputDabplusFile.h62
-rw-r--r--src/dabInputEnhancedFifo.cpp64
-rw-r--r--src/dabInputEnhancedFifo.h46
-rw-r--r--src/dabInputEnhancedPacketFile.cpp60
-rw-r--r--src/dabInputEnhancedPacketFile.h47
-rw-r--r--src/dabInputFifo.cpp518
-rw-r--r--src/dabInputFifo.h103
-rw-r--r--src/dabInputFile.cpp104
-rw-r--r--src/dabInputFile.h49
-rw-r--r--src/dabInputMpegFifo.cpp47
-rw-r--r--src/dabInputMpegFifo.h37
-rw-r--r--src/dabInputMpegFile.cpp170
-rw-r--r--src/dabInputMpegFile.h42
-rw-r--r--src/dabInputPacketFile.cpp263
-rw-r--r--src/dabInputPacketFile.h46
-rw-r--r--src/dabInputRawFifo.cpp193
-rw-r--r--src/dabInputRawFifo.h63
-rw-r--r--src/dabInputRawFile.cpp59
-rw-r--r--src/dabInputRawFile.h45
-rw-r--r--src/dabInputUdp.cpp199
-rw-r--r--src/dabInputUdp.h59
26 files changed, 0 insertions, 2845 deletions
diff --git a/src/dabInput.cpp b/src/dabInput.cpp
deleted file mode 100644
index 942e58d..0000000
--- a/src/dabInput.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Copyright (C) 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInput.h"
-#include "Log.h"
-
-#include <string.h>
-
-bool dabInputOperations::operator==(const dabInputOperations& ops)
-{
- return memcmp(this, &ops, sizeof(*this)) == 0;
-}
-
-
-int dabInputSetbuf(void* args, int size)
-{
- return 0;
-}
-
-
-int dabInputSetbitrate(dabInputOperations* ops, void* args, int bitrate)
-{
- if (bitrate <= 0) {
- etiLog.log(error, "Invalid bitrate (%i)\n", bitrate);
- return -1;
- }
- if (ops->setbuf(args, bitrate * 3) == 0) {
- return bitrate;
- }
- return -1;
-}
diff --git a/src/dabInput.h b/src/dabInput.h
deleted file mode 100644
index d2c5f49..0000000
--- a/src/dabInput.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Copyright (C) 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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_H
-#define DAB_INPUT_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "Log.h"
-#include "RemoteControl.h"
-#include <string>
-
-// TODO replace usage of dabInputOperations by a
-// class hierarchy
-struct dabInputOperations {
- int (*init)(void** args);
- int (*open)(void* args, const char* name);
- int (*setbuf)(void* args, int size);
- int (*read)(void* args, void* buffer, int size);
- int (*lock)(void* args);
- int (*unlock)(void* args);
- int (*readFrame)(dabInputOperations* ops, void* args, void* buffer, int size);
- int (*setBitrate)(dabInputOperations* ops, void* args, int bitrate);
- int (*close)(void* args);
- int (*clean)(void** args);
- int (*rewind)(void* args);
- bool operator==(const dabInputOperations&);
-};
-
-/* Wrapper class for old-style dabInputOperations inputs */
-class DabInputCompatible : public DabInputBase {
- public:
- DabInputCompatible(dabInputOperations ops)
- : m_ops(ops)
- { m_ops.init(&args); }
-
- virtual ~DabInputCompatible()
- { m_ops.clean(&args); }
-
- virtual int open(const std::string& name)
- { return m_ops.open(args, name.c_str()); }
-
- virtual int setbuf(int size)
- { return m_ops.setbuf(args, size); }
-
- virtual int readFrame(uint8_t* buffer, size_t size)
- {
- if (m_ops.lock) {
- m_ops.lock(args);
- }
- int result = m_ops.readFrame(&m_ops, args, buffer, size);
- if (m_ops.unlock) {
- m_ops.unlock(args);
- }
- return result;
- }
-
- virtual int setBitrate(int bitrate)
- { return m_ops.setBitrate(&m_ops, args, bitrate); }
-
- virtual int close()
- { return m_ops.close(args); }
-
- virtual int rewind()
- { return m_ops.rewind(args); }
-
- virtual int read(void* buffer, int size)
- { return m_ops.read(args, buffer, size); }
-
- virtual dabInputOperations getOpts() { return m_ops; }
-
- private:
- DabInputCompatible& operator=(const DabInputCompatible& other);
- DabInputCompatible(const DabInputCompatible& other);
-
- dabInputOperations m_ops;
- void* args;
-};
-
-int dabInputSetbuf(void* args, int size);
-int dabInputSetbitrate(dabInputOperations* ops, void* args, int bitrate);
-
-
-#endif // DAB_INPUT_H
diff --git a/src/dabInputDabplusFifo.cpp b/src/dabInputDabplusFifo.cpp
deleted file mode 100644
index 94aec13..0000000
--- a/src/dabInputDabplusFifo.cpp
+++ /dev/null
@@ -1,186 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputDabplusFifo.h"
-#include "dabInputDabplusFile.h"
-#include "dabInputFifo.h"
-#include "dabInput.h"
-
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#ifndef _WIN32
-# define O_BINARY 0
-#endif
-
-
-#ifdef HAVE_FORMAT_DABPLUS
-# ifdef HAVE_INPUT_FILE
-
-
-struct dabInputDabplusFifoData {
- void* fifoData;
- uint8_t* buffer;
- size_t bufferSize;
- size_t bufferIndex;
- size_t bufferOffset;
-};
-
-
-struct dabInputOperations dabInputDabplusFifoOperations = {
- dabInputDabplusFifoInit,
- dabInputDabplusFifoOpen,
- dabInputDabplusFifoSetbuf,
- dabInputDabplusFifoRead,
- dabInputDabplusFifoLock,
- dabInputDabplusFifoUnlock,
- dabInputDabplusFileReadFrame,
- dabInputSetbitrate,
- dabInputDabplusFifoClose,
- dabInputDabplusFifoClean,
- dabInputDabplusFifoRewind
-};
-
-
-int dabInputDabplusFifoInit(void** args)
-{
- dabInputDabplusFifoData* data = new dabInputDabplusFifoData;
-
- dabInputFifoInit(&data->fifoData);
- data->buffer = nullptr;
- data->bufferSize = 0;
- data->bufferIndex = 0;
- data->bufferOffset = 0;
-
- *args = data;
-
- return 0;
-}
-
-
-int dabInputDabplusFifoOpen(void* args, const char* filename)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- return dabInputFifoOpen(data->fifoData, filename);
-}
-
-
-int dabInputDabplusFifoSetbuf(void* args, int size)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- return dabInputFifoSetbuf(data->fifoData, size);
-}
-
-
-int dabInputDabplusFifoRead(void* args, void* buffer, int size)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- if (data->bufferSize != (size_t)size * 5) {
- if (data->buffer != nullptr) {
- delete[] data->buffer;
- }
- data->buffer = new uint8_t[size * 5];
- data->bufferSize = size * 5;
- data->bufferIndex = 0;
- }
-
- if (data->bufferOffset < data->bufferSize) {
- int ret = dabInputFifoRead(data->fifoData,
- &data->buffer[data->bufferOffset],
- data->bufferSize - data->bufferOffset);
- if (ret < 0) {
- return ret;
- }
- data->bufferOffset += ret;
- if (data->bufferOffset != data->bufferSize) {
- etiLog.log(alert, "ERROR: Incomplete DAB+ frame!\n");
- return 0;
- }
- }
-
- memcpy(buffer, &data->buffer[data->bufferIndex], size);
- data->bufferIndex += size;
- if (data->bufferIndex >= data->bufferSize) {
- data->bufferIndex = 0;
- data->bufferOffset = 0;
- }
- return size;
-}
-
-
-int dabInputDabplusFifoLock(void* args)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- return dabInputFifoLock(data->fifoData);
-}
-
-
-int dabInputDabplusFifoUnlock(void* args)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- return dabInputFifoUnlock(data->fifoData);
-}
-
-
-int dabInputDabplusFifoReadFrame(dabInputOperations* ops, void* args,
- void* buffer, int size)
-{
- return ops->read(args, buffer, size);
-}
-
-
-int dabInputDabplusFifoClose(void* args)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- return dabInputFifoClose(data->fifoData);
-}
-
-
-int dabInputDabplusFifoClean(void** args)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- dabInputFifoClean(&data->fifoData);
- delete data;
-
- return 0;
-}
-
-
-int dabInputDabplusFifoRewind(void* args)
-{
- dabInputDabplusFifoData* data = (dabInputDabplusFifoData*)args;
-
- return dabInputFifoRewind(data->fifoData);
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputDabplusFifo.h b/src/dabInputDabplusFifo.h
deleted file mode 100644
index 83368d6..0000000
--- a/src/dabInputDabplusFifo.h
+++ /dev/null
@@ -1,54 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_DABPLUS_FIFO_H
-#define DAB_INPUT_DABPLUS_FIFO_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-
-#ifdef HAVE_FORMAT_DABPLUS
-# ifdef HAVE_INPUT_FIFO
-
-
-extern struct dabInputOperations dabInputDabplusFifoOperations;
-
-
-int dabInputDabplusFifoInit(void** args);
-int dabInputDabplusFifoOpen(void* args, const char* filename);
-int dabInputDabplusFifoSetbuf(void* args, int size);
-int dabInputDabplusFifoRead(void* args, void* buffer, int size);
-int dabInputDabplusFifoLock(void* args);
-int dabInputDabplusFifoUnlock(void* args);
-int dabInputDabplusFifoReadFrame(dabInputOperations* ops, void* args,
- void* buffer, int size);
-int dabInputDabplusFifoClose(void* args);
-int dabInputDabplusFifoClean(void** args);
-int dabInputDabplusFifoRewind(void* args);
-
-
-# endif
-#endif
-
-
-#endif // DAB_INPUT_DABPLUS_FIFO_H
diff --git a/src/dabInputDabplusFile.cpp b/src/dabInputDabplusFile.cpp
deleted file mode 100644
index 64b7f07..0000000
--- a/src/dabInputDabplusFile.cpp
+++ /dev/null
@@ -1,177 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputDabplusFile.h"
-#include "dabInput.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-
-#ifndef _WIN32
-# define O_BINARY 0
-#endif
-
-
-#ifdef HAVE_FORMAT_DABPLUS
-# ifdef HAVE_INPUT_FILE
-
-
-struct dabInputOperations dabInputDabplusFileOperations = {
- dabInputDabplusFileInit,
- dabInputDabplusFileOpen,
- dabInputSetbuf,
- dabInputDabplusFileRead,
- nullptr,
- nullptr,
- dabInputDabplusFileReadFrame,
- dabInputSetbitrate,
- dabInputDabplusFileClose,
- dabInputDabplusFileClean,
- dabInputDabplusFileRewind
-};
-
-
-int dabInputDabplusFileInit(void** args)
-{
- dabInputDabplusFileData* data = new dabInputDabplusFileData;
- data->file = -1;
- data->buffer = nullptr;
- data->bufferSize = 0;
- data->bufferIndex = 0;
-
- *args = data;
- return 0;
-}
-
-
-int dabInputDabplusFileOpen(void* args, const char* filename)
-{
- dabInputDabplusFileData* data = (dabInputDabplusFileData*)args;
- data->file = open(filename, O_RDONLY | O_BINARY);
- if (data->file == -1) {
- perror(filename);
- return -1;
- }
-
- return 0;
-}
-
-
-int dabInputDabplusFileRead(void* args, void* buffer, int size)
-{
- dabInputDabplusFileData* data = (dabInputDabplusFileData*)args;
- if (data->bufferSize != (size_t)size * 5) {
- if (data->buffer == nullptr) {
- delete[] data->buffer;
- }
- data->buffer = new uint8_t[size * 5];
- memset(data->buffer, 0, size * 5);
- data->bufferSize = size * 5;
- data->bufferIndex = 0;
- }
-
- if (data->bufferIndex + size > data->bufferSize) {
- int ret = read(data->file, data->buffer, data->bufferSize);
- if (ret != (int)data->bufferSize) {
- if (ret != 0) {
- etiLog.log(alert, "ERROR: Incomplete DAB+ frame!\n");
- }
- return 0;
- }
- data->bufferIndex = 0;
- }
-
- memcpy(buffer, &data->buffer[data->bufferIndex], size);
- data->bufferIndex += size;
-
- return size;
-}
-
-
-int dabInputDabplusFileReadFrame(dabInputOperations* ops, void* args,
- void* buffer, int size)
-{
- //dabInputDabplusFileData* data = (dabInputDabplusFileData*)args;
- int result;
- uint8_t* dataOut = reinterpret_cast<uint8_t*>(buffer);
-
- result = ops->read(args, dataOut, size);
- if (result == -1) {
- etiLog.log(alert, "ERROR: Can't read file\n");
- perror("");
- return -1;
- }
- if (result < size) {
- int sizeOut = result;
- etiLog.log(info, "reach end of file -> rewinding\n");
- if (ops->rewind(args) == -1) {
- etiLog.log(alert, "ERROR: Can't rewind file\n");
- return -1;
- }
-
- result = ops->read(args, dataOut + sizeOut, size - sizeOut);
- if (result == -1) {
- etiLog.log(alert, "ERROR: Can't read file\n");
- perror("");
- return -1;
- }
-
- if (result < size) {
- etiLog.log(alert, "ERROR: Not enought data in file\n");
- return -1;
- }
- }
-
- return size;
-}
-
-
-int dabInputDabplusFileClose(void* args)
-{
- dabInputDabplusFileData* data = (dabInputDabplusFileData*)args;
- if (data->file != -1) {
- close(data->file);
- }
- return 0;
-}
-
-
-int dabInputDabplusFileClean(void** args)
-{
- dabInputDabplusFileData* data = (dabInputDabplusFileData*)*args;
- if (data->buffer != nullptr) {
- delete[] data->buffer;
- }
- delete data;
- return 0;
-}
-
-
-int dabInputDabplusFileRewind(void* args)
-{
- dabInputDabplusFileData* data = (dabInputDabplusFileData*)args;
- return lseek(data->file, 0, SEEK_SET);
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputDabplusFile.h b/src/dabInputDabplusFile.h
deleted file mode 100644
index 5fe2dec..0000000
--- a/src/dabInputDabplusFile.h
+++ /dev/null
@@ -1,62 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_DABPLUS_FILE_H
-#define DAB_INPUT_DABPLUS_FILE_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdint.h>
-#include <unistd.h>
-
-
-#ifdef HAVE_FORMAT_DABPLUS
-# ifdef HAVE_INPUT_FILE
-
-
-extern struct dabInputOperations dabInputDabplusFileOperations;
-
-
-struct dabInputDabplusFileData {
- int file;
- uint8_t* buffer;
- size_t bufferSize;
- size_t bufferIndex;
-};
-
-
-int dabInputDabplusFileInit(void** args);
-int dabInputDabplusFileOpen(void* args, const char* filename);
-int dabInputDabplusFileRead(void* args, void* buffer, int size);
-int dabInputDabplusFileReadFrame(dabInputOperations* ops, void* args,
- void* buffer, int size);
-int dabInputDabplusFileClose(void* args);
-int dabInputDabplusFileClean(void** args);
-int dabInputDabplusFileRewind(void* args);
-
-
-# endif
-#endif
-
-
-#endif // DAB_INPUT_DABPLUS_FILE_H
diff --git a/src/dabInputEnhancedFifo.cpp b/src/dabInputEnhancedFifo.cpp
deleted file mode 100644
index 3a8a27c..0000000
--- a/src/dabInputEnhancedFifo.cpp
+++ /dev/null
@@ -1,64 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputEnhancedFifo.h"
-#include "dabInputPacketFile.h"
-#include "dabInputFifo.h"
-
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_FORMAT_EPM
-# ifdef HAVE_INPUT_FIFO
-
-
-struct dabInputOperations dabInputEnhancedFifoOperations = {
- dabInputEnhancedFifoInit,
- dabInputFifoOpen,
- dabInputFifoSetbuf,
- dabInputFifoRead,
- dabInputFifoLock,
- dabInputFifoUnlock,
- dabInputPacketFileRead,
- dabInputSetbitrate,
- dabInputFifoClose,
- dabInputFifoClean,
- dabInputFifoRewind
-};
-
-
-int dabInputEnhancedFifoInit(void** args)
-{
- dabInputFifoInit(args);
- dabInputFifoData* data = (dabInputFifoData*)*args;
-
- data->packetData = new unsigned char[96];
- data->enhancedPacketData = new unsigned char*[12];
- for (int i = 0; i < 12; ++i) {
- data->enhancedPacketData[i] = new unsigned char[204];
- }
-
- return 0;
-}
-
-
-# endif
-# endif
-#endif
diff --git a/src/dabInputEnhancedFifo.h b/src/dabInputEnhancedFifo.h
deleted file mode 100644
index 4c87e24..0000000
--- a/src/dabInputEnhancedFifo.h
+++ /dev/null
@@ -1,46 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_ENHANCED_FIFO_H
-#define DAB_INPUT_ENHANCED_FIFO_H
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "dabInput.h"
-
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_FORMAT_EPM
-# ifdef HAVE_INPUT_FIFO
-
-
-extern struct dabInputOperations dabInputEnhancedFifoOperations;
-int dabInputEnhancedFifoInit(void** args);
-
-
-# endif
-# endif
-#endif
-
-
-#endif // DAB_INPUT_ENHANCED_FIFO_H
diff --git a/src/dabInputEnhancedPacketFile.cpp b/src/dabInputEnhancedPacketFile.cpp
deleted file mode 100644
index 5c26188..0000000
--- a/src/dabInputEnhancedPacketFile.cpp
+++ /dev/null
@@ -1,60 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputEnhancedPacketFile.h"
-#include "dabInputPacketFile.h"
-#include "dabInputFile.h"
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_FORMAT_EPM
-# ifdef HAVE_INPUT_FILE
-
-struct dabInputOperations dabInputEnhancedPacketFileOperations = {
- dabInputEnhancedFileInit,
- dabInputFileOpen,
- dabInputSetbuf,
- dabInputFileRead,
- nullptr,
- nullptr,
- dabInputPacketFileRead,
- dabInputSetbitrate,
- dabInputFileClose,
- dabInputFileClean,
- dabInputFileRewind
-};
-
-
-int dabInputEnhancedFileInit(void** args)
-{
- dabInputFileInit(args);
- dabInputFileData* data = (dabInputFileData*)*args;
-
- data->enhancedPacketData = new unsigned char*[12];
- for (int i = 0; i < 12; ++i) {
- data->enhancedPacketData[i] = new unsigned char[204];
- }
-
- return 0;
-}
-
-# endif
-# endif
-#endif
diff --git a/src/dabInputEnhancedPacketFile.h b/src/dabInputEnhancedPacketFile.h
deleted file mode 100644
index 74f59de..0000000
--- a/src/dabInputEnhancedPacketFile.h
+++ /dev/null
@@ -1,47 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_ENHANCED_PACKET_FILE_H
-#define DAB_INPUT_ENHANCED_PACKET_FILE_H
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "dabInput.h"
-
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_FORMAT_EPM
-# ifdef HAVE_INPUT_FILE
-
-
-extern struct dabInputOperations dabInputEnhancedPacketFileOperations;
-
-int dabInputEnhancedFileInit(void** args);
-
-
-# endif
-# endif
-#endif
-
-
-#endif // DAB_INPUT_ENHANCED_PACKET_FILE_H
diff --git a/src/dabInputFifo.cpp b/src/dabInputFifo.cpp
deleted file mode 100644
index 6fa3aad..0000000
--- a/src/dabInputFifo.cpp
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications
- Research Center Canada)
-
- Copyright (C) 2016
- Matthias P. Braendli, matthias.braendli@mpb.li
-
- 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputFifo.h"
-#include "dabInputPacketFile.h"
-#include "dabInput.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_INPUT_FIFO
-
-
-int dabInputFifoData::nb = 0;
-
-
-struct dabInputOperations dabInputFifoOperations = {
- dabInputFifoInit,
- dabInputFifoOpen,
- dabInputFifoSetbuf,
- dabInputFifoRead,
- dabInputFifoLock,
- dabInputFifoUnlock,
- dabInputPacketFileRead,
- dabInputSetbitrate,
- dabInputFifoClose,
- dabInputFifoClean,
- dabInputFifoRewind
-};
-
-
-int dabInputFifoInit(void** args)
-{
- dabInputFifoData* data = new dabInputFifoData;
- memset(data, 0, sizeof(*data));
- data->stats.id = dabInputFifoData::nb++;
- data->maxSize = 0;
- data->curSize = 0;
- data->head = 0;
- data->tail = 0;
- data->buffer = nullptr;
- data->packetData = nullptr;
- data->enhancedPacketData = nullptr;
- data->packetLength = 0;
- data->enhancedPacketLength = 0;
- data->enhancedPacketWaiting = 0;
- data->full = false;
- data->running = true;
- data->thread = (pthread_t)NULL;
-#ifdef _WIN32
- char semName[32];
- sprintf(semName, "semInfo%i", data->stats.id);
- data->semInfo = CreateSemaphore(NULL, 1, 1, semName);
- if (data->semInfo == NULL) {
- fprintf(stderr, "Can't init FIFO data semaphore %s\n", semName);
- return -1;
- }
- sprintf(semName, "semBuffer%i", data->stats.id);
- data->semBuffer = CreateSemaphore(NULL, 1, 1, semName);
- if (data->semBuffer == NULL) {
- fprintf(stderr, "Can't init FIFO buffer semaphore %s\n", semName);
- return -1;
- }
- sprintf(semName, "semFull%i", data->stats.id);
- data->semFull = CreateSemaphore(NULL, 1, 1, semName);
- if (data->semFull == NULL) {
- fprintf(stderr, "Can't init FIFO semaphore %s\n", semName);
- return -1;
- }
-#else
- if (sem_init(&data->semInfo, 0, 1) == -1) {
- perror("Can't init FIFO data semaphore");
- return -1;
- }
- if (sem_init(&data->semBuffer, 0, 0) == -1) {
- perror("Can't init fIFO buffer semaphore");
- return -1;
- }
- if (sem_init(&data->semFull, 0, 0) == -1) {
- perror("Can't init FIFO semaphore");
- return -1;
- }
-#endif
-
- if (data->maxSize > 0) {
-#ifdef _WIN32
- ReleaseSemaphore(data->semBuffer, 1, NULL);
-#else
- sem_post(&data->semBuffer);
-#endif
- }
- *args = data;
- return 0;
-}
-
-
-int dabInputFifoOpen(void* args, const char* filename)
-{
- dabInputFifoData* data = (dabInputFifoData*)args;
- data->file = open(filename, O_RDONLY | O_BINARY | O_NONBLOCK);
- if (data->file == -1) {
- perror(filename);
- return -1;
- }
-#ifdef _WIN32
-#else
- int flags = fcntl(data->file, F_GETFL);
- if (flags == -1) {
- perror(filename);
- return -1;
- }
- if (fcntl(data->file, F_SETFL, flags & ~O_NONBLOCK) == -1) {
- perror(filename);
- return -1;
- }
-#endif
-
-#ifdef _WIN32
- data->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)dabInputFifoThread, data, 0, NULL);
- if (data->thread == NULL) {
- fprintf(stderr, "Can't create FIFO child\n");
- return -1;
- }
-#else
- if (pthread_create(&data->thread, nullptr, dabInputFifoThread, data)) {
- perror("Can't create FIFO child");
- return -1;
- }
-#endif
-
- return 0;
-}
-
-
-int dabInputFifoSetbuf(void* args, int size)
-{
- dabInputFifoData* data = (dabInputFifoData*)args;
-
- if (data->maxSize > 0) {
-#ifdef _WIN32
- WaitForSingleObject(data->semBuffer, INFINITE);
-#else
- sem_wait(&data->semBuffer);
-#endif
- }
- if (data->buffer != nullptr) {
- delete data->buffer;
- }
- if (size == 0) {
- size = 1024;
- }
- data->buffer = new unsigned char[size * 16];
- data->maxSize = size * 16;
-#ifdef _WIN32
- ReleaseSemaphore(data->semBuffer, 1, NULL);
-#else
- sem_post(&data->semBuffer);
-#endif
-
- return 0;
-}
-
-
-int dabInputFifoRead(void* args, void* buffer, int size)
-{
- //fprintf(stderr, "INFO: read %i bytes\n", size);
- dabInputFifoData* data = (dabInputFifoData*)args;
- dabInputFifoStats* stats = &data->stats;
- int head;
- int tail;
- int curSize;
- int maxSize;
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- head = data->head;
- tail = data->tail;
- curSize = data->curSize;
- maxSize = data->maxSize;
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- //fprintf(stderr, "head: %i, tail: %i, curSize: %i\n", head, tail, curSize);
- if (size > curSize) {
- if (curSize == 0) {
- stats->empty = true;
- } else {
- etiLog.log(warn, "Not enough data in FIFO buffer: (%i) %i/%i\n",
- data->stats.id, curSize, size);
- }
- return 0;
- }
- if (head > tail) {
- memcpy(buffer, data->buffer + tail, size);
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- data->tail += size;
- data->curSize -= size;
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- return size;
- } else {
- if (maxSize - tail >= size) {
- memcpy(buffer, data->buffer + tail, size);
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- data->tail += size;
- data->curSize -= size;
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- return size;
- } else {
- memcpy(buffer, data->buffer + tail, maxSize - tail);
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- data->tail = 0;
- data->curSize -= maxSize - tail;
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- return maxSize - tail + dabInputFifoRead(data, (char*)buffer + maxSize - tail, size - (maxSize - tail));
- }
- }
- return -1;
-}
-
-
-int dabInputFifoLock(void* args) {
- dabInputFifoData* data = (dabInputFifoData*)args;
- dabInputFifoStats* stats = &data->stats;
-
- int maxSize;
- int curSize;
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- maxSize = data->maxSize;
- curSize = data->curSize;
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
-
- stats->bufferRecords[stats->bufferCount].curSize = curSize;
- stats->bufferRecords[stats->bufferCount].maxSize = maxSize;
-
- if (++stats->bufferCount == NB_RECORDS) {
- etiLog.log(info, "FIFO buffer state: (%i)", stats->id);
- for (int i = 0; i < stats->bufferCount; ++i) {
- etiLog.log(info, " %i/%i",
- stats->bufferRecords[i].curSize,
- stats->bufferRecords[i].maxSize);
- }
- etiLog.log(info, "\n");
-
- if (stats->full) {
- etiLog.log(warn, "FIFO buffer full: (%i)\n",
- data->stats.id);
- stats->full = false;
- }
- if (stats->empty) {
- etiLog.log(warn, "FIFO buffer empty: (%i)\n",
- data->stats.id);
- stats->empty = false;
- }
- if (stats->error) {
- etiLog.log(error, "FIFO input read error: (%i)\n",
- data->stats.id);
- stats->error = false;
- }
- if (stats->input) {
- etiLog.log(error, "FIFO input not connected: (%i)\n",
- data->stats.id);
- stats->input = false;
- }
-
- stats->bufferCount = 0;
- }
- return 0;
-}
-
-
-int dabInputFifoUnlock(void* args) {
- dabInputFifoData* data = (dabInputFifoData*)args;
- if (data->full) {
-#ifdef _WIN32
- ReleaseSemaphore(data->semFull, 1, NULL);
-#else
- sem_post(&data->semFull);
-#endif
- }
- return 0;
-}
-
-
-int dabInputFifoClose(void* args)
-{
- dabInputFifoData* data = (dabInputFifoData*)args;
- close(data->file);
- return 0;
-}
-
-
-int dabInputFifoClean(void** args)
-{
- dabInputFifoData* data = (dabInputFifoData*)*args;
- data->running = false;
- etiLog.log(debug, "Wait FIFO child...\n");
-#ifdef WIN32
- DWORD status;
- for (int i = 0; i < 5; ++i) {
- if (GetExitCodeThread(data->thread, &status)) {
- break;
- }
- Sleep(100);
- }
- TerminateThread(data->thread, 1);
- if (CloseHandle(data->thread) == 0) {
- etiLog.log(debug, "ERROR: Failed to close FIFO child thread\n");
- }
-#else
- if (data->thread != (pthread_t)NULL) {
- if (pthread_join(data->thread, nullptr)) {
- etiLog.log(debug, "ERROR: FIFO child thread had not exit normally\n");
- }
- }
-#endif
- etiLog.log(debug, "Done\n");
-#ifdef _WIN32
- CloseHandle(data->semInfo);
- CloseHandle(data->semFull);
- CloseHandle(data->semBuffer);
-#else
- sem_destroy(&data->semInfo);
- sem_destroy(&data->semFull);
- sem_destroy(&data->semBuffer);
-#endif
- if (data->packetData != nullptr) {
- delete[] data->packetData;
- }
- if (data->enhancedPacketData != nullptr) {
- for (int i = 0; i < 12; ++i) {
- if (data->enhancedPacketData[i] != nullptr) {
- delete[] data->enhancedPacketData[i];
- }
- }
- delete[] data->enhancedPacketData;
- }
- delete data->buffer;
- delete data;
- return 0;
-}
-
-
-int dabInputFifoRewind(void* args)
-{
- return -1;
-}
-
-
-void* dabInputFifoThread(void* args)
-{
- dabInputFifoData* data = (dabInputFifoData*)args;
- int head;
- int tail;
- int curSize;
- int maxSize;
- int ret;
- while (data->running) {
-#ifdef _WIN32
- WaitForSingleObject(data->semBuffer, INFINITE);
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semBuffer);
- sem_wait(&data->semInfo);
-#endif
- head = data->head;
- tail = data->tail;
- curSize = data->curSize;
- maxSize = data->maxSize;
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- //fprintf(stderr, "thread, head: %i, tail: %i, curSize: %i\n", head, tail, curSize);
-
- if (curSize == maxSize) {
- data->stats.full = true;
- data->full = true;
-#ifdef _WIN32
- WaitForSingleObject(data->semFull, INFINITE);
-#else
- sem_wait(&data->semFull);
-#endif
- } else if (head >= tail) { // 2 blocks
- ret = read(data->file, data->buffer + head, maxSize - head);
- if (ret == 0) {
- data->stats.input = true;
- data->full = true;
-#ifdef _WIN32
- WaitForSingleObject(data->semFull, INFINITE);
-#else
- sem_wait(&data->semFull);
-#endif
- } else if (ret == -1) {
- data->stats.error = true;
- } else {
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- data->head += ret;
- data->curSize += ret;
- if (data->head == maxSize) {
- data->head = 0;
- }
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- }
- } else { // 1 block
- ret = read(data->file, data->buffer + head, tail - head);
- if (ret == 0) {
- data->stats.input = true;
- data->full = true;
-#ifdef _WIN32
- WaitForSingleObject(data->semFull, INFINITE);
-#else
- sem_wait(&data->semFull);
-#endif
- } else if (ret == -1) {
- data->stats.error = true;
- } else {
-#ifdef _WIN32
- WaitForSingleObject(data->semInfo, INFINITE);
-#else
- sem_wait(&data->semInfo);
-#endif
- data->head += ret;
- data->curSize += ret;
- if (data->head == maxSize) {
- data->head = 0;
- }
-#ifdef _WIN32
- ReleaseSemaphore(data->semInfo, 1, NULL);
-#else
- sem_post(&data->semInfo);
-#endif
- }
- }
-#ifdef _WIN32
- ReleaseSemaphore(data->semBuffer, 1, NULL);
-#else
- sem_post(&data->semBuffer);
-#endif
- }
- return nullptr;
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputFifo.h b/src/dabInputFifo.h
deleted file mode 100644
index 99edac6..0000000
--- a/src/dabInputFifo.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications
- Research Center Canada)
-
- Copyright (C) 2016
- Matthias P. Braendli, matthias.braendli@mpb.li
-
- 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 <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "dabInputFile.h"
-#include "Log.h"
-
-
-#ifdef _WIN32
-# include <io.h>
-# define sem_t HANDLE
-# define O_NONBLOCK 0
-#else
-# include <semaphore.h>
-# define O_BINARY 0
-#endif
-
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_INPUT_FIFO
-extern struct dabInputOperations dabInputFifoOperations;
-
-
-struct dabInputFifoStatRecord {
- int curSize;
- int maxSize;
-};
-
-
-#define NB_RECORDS 10
-struct dabInputFifoStats {
- int id;
- bool full;
- bool empty;
- bool error;
- bool input;
- int bufferCount;
- dabInputFifoStatRecord bufferRecords[NB_RECORDS];
- int frameCount;
- dabInputFifoStatRecord frameRecords[NB_RECORDS];
-};
-
-
-struct dabInputFifoData : dabInputFileData {
- static int nb;
- int maxSize;
- int curSize;
- int head;
- int tail;
- dabInputFifoStats stats;
- unsigned char* buffer;
- pthread_t thread;
- sem_t semInfo;
- sem_t semBuffer;
- sem_t semFull;
- bool full;
- bool running;
-};
-
-
-int dabInputFifoInit(void** args);
-int dabInputFifoOpen(void* args, const char* filename);
-int dabInputFifoSetbuf(void* args, int size);
-int dabInputFifoRead(void* args, void* buffer, int size);
-int dabInputFifoLock(void* args);
-int dabInputFifoUnlock(void* args);
-int dabInputFifoClose(void* args);
-int dabInputFifoClean(void** args);
-int dabInputFifoRewind(void* args);
-void* dabInputFifoThread(void* args);
-
-
-# endif
-#endif
-
diff --git a/src/dabInputFile.cpp b/src/dabInputFile.cpp
deleted file mode 100644
index 2847caa..0000000
--- a/src/dabInputFile.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Copyright (C) 2009,2011 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputFile.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#ifndef _WIN32
-# define O_BINARY 0
-#endif
-
-
-int dabInputFileInit(void** args)
-{
- dabInputFileData* data = new dabInputFileData;
- data->file = -1;
- data->parity = false;
- data->packetLength = 0;
- data->packetData = new unsigned char[96];
- data->enhancedPacketData = nullptr;
- data->enhancedPacketLength = 0;
- data->enhancedPacketWaiting = 0;
-
- *args = data;
- return 0;
-}
-
-
-int dabInputFileOpen(void* args, const char* filename)
-{
- dabInputFileData* data = (dabInputFileData*)args;
- data->file = open(filename, O_RDONLY | O_BINARY);
- if (data->file == -1) {
- perror(filename);
- return -1;
- }
- return 0;
-}
-
-
-int dabInputFileRead(void* args, void* buffer, int size)
-{
- dabInputFileData* data = (dabInputFileData*)args;
- return read(data->file, buffer, size);
-}
-
-
-int dabInputFileClose(void* args)
-{
- dabInputFileData* data = (dabInputFileData*)args;
- if (data->file != -1) {
- close(data->file);
- }
- return 0;
-}
-
-
-int dabInputFileClean(void** args)
-{
- dabInputFileData* data = (dabInputFileData*)*args;
- if (data->packetData != nullptr) {
- delete[] data->packetData;
- }
- if (data->enhancedPacketData != nullptr) {
- for (int i = 0; i < 12; ++i) {
- if (data->enhancedPacketData[i] != nullptr) {
- delete[] data->enhancedPacketData[i];
- }
- }
- delete[] data->enhancedPacketData;
- }
- delete data;
- return 0;
-}
-
-
-int dabInputFileRewind(void* args)
-{
- dabInputFileData* data = (dabInputFileData*)args;
- return lseek(data->file, 0, SEEK_SET);
-}
-
-
diff --git a/src/dabInputFile.h b/src/dabInputFile.h
deleted file mode 100644
index e3eaa48..0000000
--- a/src/dabInputFile.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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_FILE_H
-#define DAB_INPUT_FILE_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-
-struct dabInputFileData {
- int file;
- bool parity;
- unsigned packetLength;
- unsigned char* packetData;
- unsigned char** enhancedPacketData;
- unsigned enhancedPacketLength;
- unsigned enhancedPacketWaiting;
-};
-
-
-int dabInputFileInit(void** args);
-int dabInputFileOpen(void* args, const char* filename);
-int dabInputFileRead(void* args, void* buffer, int size);
-int dabInputFileClose(void* args);
-int dabInputFileClean(void** args);
-int dabInputFileRewind(void* args);
-
-
-#endif // DAB_INPUT_FILE_H
diff --git a/src/dabInputMpegFifo.cpp b/src/dabInputMpegFifo.cpp
deleted file mode 100644
index 0f1d3b0..0000000
--- a/src/dabInputMpegFifo.cpp
+++ /dev/null
@@ -1,47 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputMpegFifo.h"
-#include "dabInputFifo.h"
-#include "dabInputMpegFile.h"
-
-
-#ifdef HAVE_FORMAT_MPEG
-# ifdef HAVE_INPUT_FIFO
-
-
-struct dabInputOperations dabInputMpegFifoOperations = {
- dabInputFifoInit,
- dabInputFifoOpen,
- dabInputFifoSetbuf,
- dabInputFifoRead,
- dabInputFifoLock,
- dabInputFifoUnlock,
- dabInputMpegFileRead,
- dabInputSetbitrate,
- dabInputFifoClose,
- dabInputFifoClean,
- dabInputFifoRewind
-};
-
-
-# endif
-#endif
diff --git a/src/dabInputMpegFifo.h b/src/dabInputMpegFifo.h
deleted file mode 100644
index a14ccbd..0000000
--- a/src/dabInputMpegFifo.h
+++ /dev/null
@@ -1,37 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_MPEG_FIFO_H
-#define DAB_INPUT_MPEG_FIFO_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-
-#ifdef HAVE_FORMAT_MPEG
-# ifdef HAVE_INPUT_FIFO
-extern struct dabInputOperations dabInputMpegFifoOperations;
-# endif
-#endif
-
-
-#endif // DAB_INPUT_MPEG_FIFO_H
diff --git a/src/dabInputMpegFile.cpp b/src/dabInputMpegFile.cpp
deleted file mode 100644
index 6f24f32..0000000
--- a/src/dabInputMpegFile.cpp
+++ /dev/null
@@ -1,170 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputMpegFile.h"
-#include "dabInputFile.h"
-#include "mpeg.h"
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-
-
-#ifdef HAVE_FORMAT_MPEG
-# ifdef HAVE_INPUT_FILE
-
-
-struct dabInputOperations dabInputMpegFileOperations = {
- dabInputFileInit,
- dabInputFileOpen,
- dabInputSetbuf,
- dabInputFileRead,
- nullptr,
- nullptr,
- dabInputMpegFileRead,
- dabInputMpegSetbitrate,
- dabInputFileClose,
- dabInputFileClean,
- dabInputFileRewind
-};
-
-
-int dabInputMpegFileRead(dabInputOperations* ops, void* args, void* buffer, int size)
-{
- dabInputFileData* data = (dabInputFileData*)args;
- int result;
- bool rewind = false;
-READ_SUBCHANNEL:
- if (data->parity) {
- result = readData(data->file, buffer, size, 2);
- data->parity = false;
- return 0;
- } else {
- result = readMpegHeader(data->file, buffer, size);
- if (result > 0) {
- result = readMpegFrame(data->file, buffer, size);
- if (result < 0 && getMpegFrequency(buffer) == 24000) {
- data->parity = true;
- result = size;
- }
- }
- }
- switch (result) {
- case MPEG_BUFFER_UNDERFLOW:
- etiLog.log(warn, "data underflow -> frame muted\n");
- goto MUTE_SUBCHANNEL;
- case MPEG_BUFFER_OVERFLOW:
- etiLog.log(warn, "bitrate too high -> frame muted\n");
- goto MUTE_SUBCHANNEL;
- case MPEG_FILE_EMPTY:
- if (rewind) {
- etiLog.log(error, "file rewinded and still empty "
- "-> frame muted\n");
- goto MUTE_SUBCHANNEL;
- } else {
- rewind = true;
- etiLog.log(info, "reach end of file -> rewinding\n");
- lseek(data->file, 0, SEEK_SET);
- goto READ_SUBCHANNEL;
- }
- case MPEG_FILE_ERROR:
- etiLog.log(alert, "can't read file (%i) -> frame muted\n", errno);
- perror("");
- goto MUTE_SUBCHANNEL;
- case MPEG_SYNC_NOT_FOUND:
- etiLog.log(alert, "mpeg sync not found, maybe is not a valid file "
- "-> frame muted\n");
- goto MUTE_SUBCHANNEL;
- case MPEG_INVALID_FRAME:
- etiLog.log(alert, "file is not a valid mpeg file "
- "-> frame muted\n");
- goto MUTE_SUBCHANNEL;
- default:
- if (result < 0) {
- etiLog.log(alert,
- "unknown error (code = %i) -> frame muted\n",
- result);
-MUTE_SUBCHANNEL:
- memset(buffer, 0, size);
- } else {
- if (result < size) {
- etiLog.log(warn, "bitrate too low from file "
- "-> frame padded\n");
- memset((char*)buffer + result, 0, size - result);
- }
- result = checkDabMpegFrame(buffer);
- switch (result) {
- case MPEG_FREQUENCY:
- etiLog.log(error, "file has a frame with an invalid "
- "frequency: %i, should be 48000 or 24000\n",
- getMpegFrequency(buffer));
- break;
- case MPEG_PADDING:
- etiLog.log(warn,
- "file has a frame with padding bit set\n");
- break;
- case MPEG_COPYRIGHT:
- etiLog.log(warn,
- "file has a frame with copyright bit set\n");
- break;
- case MPEG_ORIGINAL:
- etiLog.log(warn,
- "file has a frame with original bit set\n");
- break;
- case MPEG_EMPHASIS:
- etiLog.log(warn,
- "file has a frame with emphasis bits set\n");
- break;
- default:
- if (result < 0) {
- etiLog.log(alert, "mpeg file has an invalid DAB "
- "mpeg frame (unknown reason: %i)\n", result);
- }
- break;
- }
- }
- }
- return result;
-}
-
-
-int dabInputMpegSetbitrate(dabInputOperations* ops, void* args, int bitrate)
-{
- //dabInputFileData* data = (dabInputFileData*)args;
- if (bitrate == 0) {
- char buffer[4];
-
- if (ops->readFrame(ops, args, buffer, 4) == 0) {
- bitrate = getMpegBitrate(buffer);
- } else {
- bitrate = -1;
- }
- ops->rewind(args);
- }
- if (ops->setbuf(args, bitrate * 3) != 0) {
- bitrate = -1;
- }
- return bitrate;
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputMpegFile.h b/src/dabInputMpegFile.h
deleted file mode 100644
index a7dcb76..0000000
--- a/src/dabInputMpegFile.h
+++ /dev/null
@@ -1,42 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_MPEG_FILE_H
-#define DAB_INPUT_MPEG_FILE_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "dabInput.h"
-
-
-#ifdef HAVE_FORMAT_MPEG
-# ifdef HAVE_INPUT_FILE
-extern struct dabInputOperations dabInputMpegFileOperations;
-
-int dabInputMpegFileRead(dabInputOperations* ops, void* args, void* buffer, int size);
-int dabInputMpegSetbitrate(dabInputOperations* ops, void* args, int bitrate);
-int checkDabMpegFrame(void* data);
-# endif
-#endif
-
-
-#endif // DAB_INPUT_MPEG_FILE_H
diff --git a/src/dabInputPacketFile.cpp b/src/dabInputPacketFile.cpp
deleted file mode 100644
index 867d9fc..0000000
--- a/src/dabInputPacketFile.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- Copyright (C) 2009, 2011 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputPacketFile.h"
-#include "dabInputFile.h"
-#include "dabInputFifo.h"
-#include "ReedSolomon.h"
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_INPUT_FILE
-
-
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-
-#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
-;
-
-
-struct dabInputOperations dabInputPacketFileOperations = {
- dabInputFileInit,
- dabInputFileOpen,
- dabInputSetbuf,
- dabInputFileRead,
- nullptr,
- nullptr,
- dabInputPacketFileRead,
- dabInputSetbitrate,
- dabInputFileClose,
- dabInputFileClean,
- dabInputFileRewind
-};
-
-
-int dabInputPacketFileRead(dabInputOperations* ops, void* args, void* buffer,
- int size)
-{
- dabInputFileData* data = (dabInputFileData*)args;
- unsigned char* dataBuffer = (unsigned char*)buffer;
- int written = 0;
- int length;
- packetHeader* header;
- int indexRow;
- int indexCol;
-
- while (written < size) {
- if (data->enhancedPacketWaiting > 0) {
- *dataBuffer = 192 - data->enhancedPacketWaiting;
- *dataBuffer /= 22;
- *dataBuffer <<= 2;
- *(dataBuffer++) |= 0x03;
- *(dataBuffer++) = 0xfe;
- indexCol = 188;
- indexCol += (192 - data->enhancedPacketWaiting) / 12;
- indexRow = 0;
- indexRow += (192 - data->enhancedPacketWaiting) % 12;
- for (int j = 0; j < 22; ++j) {
- if (data->enhancedPacketWaiting == 0) {
- *(dataBuffer++) = 0;
- } else {
- *(dataBuffer++) = data->enhancedPacketData[indexRow][indexCol];
- if (++indexRow == 12) {
- indexRow = 0;
- ++indexCol;
- }
- --data->enhancedPacketWaiting;
- }
- }
- written += 24;
- if (data->enhancedPacketWaiting == 0) {
- data->enhancedPacketLength = 0;
- }
- } else if (data->packetLength != 0) {
- header = (packetHeader*)data->packetData;
- if (written + data->packetLength > (unsigned)size) {
- memset(dataBuffer, 0, 22);
- dataBuffer[22] = 0x60;
- dataBuffer[23] = 0x4b;
- length = 24;
- } else if (data->enhancedPacketData != nullptr) {
- if (data->enhancedPacketLength + data->packetLength
- > (12 * 188)) {
- memset(dataBuffer, 0, 22);
- dataBuffer[22] = 0x60;
- dataBuffer[23] = 0x4b;
- length = 24;
- } else {
- memcpy(dataBuffer, data->packetData, data->packetLength);
- length = data->packetLength;
- data->packetLength = 0;
- }
- } else {
- memcpy(dataBuffer, data->packetData, data->packetLength);
- length = data->packetLength;
- data->packetLength = 0;
- }
- if (data->enhancedPacketData != nullptr) {
- indexCol = data->enhancedPacketLength / 12;
- indexRow = data->enhancedPacketLength % 12; // TODO Check if always 0
- for (int j = 0; j < length; ++j) {
- data->enhancedPacketData[indexRow][indexCol] = dataBuffer[j];
- if (++indexRow == 12) {
- indexRow = 0;
- ++indexCol;
- }
- }
- data->enhancedPacketLength += length;
- if (data->enhancedPacketLength >= (12 * 188)) {
- data->enhancedPacketLength = (12 * 188);
- ReedSolomon encoder(204, 188);
- for (int j = 0; j < 12; ++j) {
- encoder.encode(data->enhancedPacketData[j], 188);
- }
- data->enhancedPacketWaiting = 192;
- }
- }
- written += length;
- dataBuffer += length;
- } else {
- int nbBytes = ops->read(args, dataBuffer, 3);
- header = (packetHeader*)dataBuffer;
- if (nbBytes == -1) {
- if (errno == EAGAIN) goto END_PACKET;
- perror("Packet file");
- return -1;
- } else if (nbBytes == 0) {
- if (ops->rewind(args) == -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;
- }
-
- length = header->packetLength * 24 + 24;
- if (written + length > size) {
- memcpy(data->packetData, header, 3);
- ops->read(args, &data->packetData[3], length - 3);
- data->packetLength = length;
- continue;
- }
- if (data->enhancedPacketData != nullptr) {
- if (data->enhancedPacketLength + length > (12 * 188)) {
- memcpy(data->packetData, header, 3);
- ops->read(args, &data->packetData[3], length - 3);
- data->packetLength = length;
- continue;
- }
- }
- nbBytes = ops->read(args, dataBuffer + 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 (ops->rewind(args) == -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 (data->enhancedPacketData != nullptr) {
- indexCol = data->enhancedPacketLength / 12;
- indexRow = data->enhancedPacketLength % 12; // TODO Check if always 0
- for (int j = 0; j < length; ++j) {
- data->enhancedPacketData[indexRow][indexCol] = dataBuffer[j];
- if (++indexRow == 12) {
- indexRow = 0;
- ++indexCol;
- }
- }
- data->enhancedPacketLength += length;
- if (data->enhancedPacketLength >= (12 * 188)) {
- if (data->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(data->enhancedPacketData[j], 188);
- }
- data->enhancedPacketWaiting = 192;
- }
- }
- written += length;
- dataBuffer += length;
- }
- }
-END_PACKET:
- if (ops->read == dabInputFifoRead) {
- dabInputFifoData* fifoData = (dabInputFifoData*)args;
- dabInputFifoStats* fifoStats = (dabInputFifoStats*)&fifoData->stats;
- fifoStats->frameRecords[fifoStats->frameCount].curSize = written;
- fifoStats->frameRecords[fifoStats->frameCount].maxSize = size;
- if (++fifoStats->frameCount == NB_RECORDS) {
- etiLog.log(info, "Packet subchannel usage: (%i)",
- fifoStats->id);
- for (int i = 0; i < fifoStats->frameCount; ++i) {
- etiLog.log(info, " %i/%i",
- fifoStats->frameRecords[i].curSize,
- fifoStats->frameRecords[i].maxSize);
- }
- etiLog.log(info, "\n");
- fifoStats->frameCount = 0;
- }
- }
- while (written < size) {
- memset(dataBuffer, 0, 22);
- dataBuffer[22] = 0x60;
- dataBuffer[23] = 0x4b;
- dataBuffer += 24;
- written += 24;
- }
- return written;
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputPacketFile.h b/src/dabInputPacketFile.h
deleted file mode 100644
index 77f33a6..0000000
--- a/src/dabInputPacketFile.h
+++ /dev/null
@@ -1,46 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_PACKET_FILE_H
-#define DAB_INPUT_PACKET_FILE_H
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "dabInput.h"
-
-
-#ifdef HAVE_FORMAT_PACKET
-# ifdef HAVE_INPUT_FILE
-
-
-extern struct dabInputOperations dabInputPacketFileOperations;
-
-int dabInputPacketFileRead(dabInputOperations* ops, void* args, void* buffer,
- int size);
-
-
-# endif
-#endif
-
-
-#endif // DAB_INPUT_PACKET_FILE_H
diff --git a/src/dabInputRawFifo.cpp b/src/dabInputRawFifo.cpp
deleted file mode 100644
index cc6268b..0000000
--- a/src/dabInputRawFifo.cpp
+++ /dev/null
@@ -1,193 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputRawFifo.h"
-
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-
-#ifndef _WIN32
-# define O_BINARY 0
-#endif
-
-
-#ifdef HAVE_FORMAT_RAW
-# ifdef HAVE_INPUT_FILE
-
-
-struct dabInputOperations dabInputRawFifoOperations = {
- dabInputRawFifoInit,
- dabInputRawFifoOpen,
- dabInputRawFifoSetbuf,
- dabInputRawFifoRead,
- nullptr,
- nullptr,
- dabInputRawFifoReadFrame,
- dabInputSetbitrate,
- dabInputRawFifoClose,
- dabInputRawFifoClean,
- dabInputRawFifoRewind
-};
-
-
-int dabInputRawFifoInit(void** args)
-{
- dabInputRawFifoData* data = new dabInputRawFifoData;
- data->file = -1;
- data->buffer = nullptr;
- data->bufferSize = 0;
- data->bufferOffset = 0;
-
- *args = data;
- return 0;
-}
-
-
-int dabInputRawFifoOpen(void* args, const char* filename)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)args;
- data->file = open(filename, O_RDONLY | O_BINARY | O_NONBLOCK);
- if (data->file == -1) {
- perror(filename);
- return -1;
- }
-#ifdef _WIN32
-#else
- int flags = fcntl(data->file, F_GETFL);
- if (flags == -1) {
- perror(filename);
- return -1;
- }
- if (fcntl(data->file, F_SETFL, flags & ~O_NONBLOCK) == -1) {
- perror(filename);
- return -1;
- }
-#endif
-
- return 0;
-}
-
-
-int dabInputRawFifoSetbuf(void* args, int size)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)args;
-
- if (size <= 0) {
- return size;
- }
-
- if (data->bufferSize != (size_t)size) {
- if (data->buffer != nullptr) {
- delete[] data->buffer;
- }
- data->buffer = new uint8_t[size];
- data->bufferSize = size;
- data->bufferOffset = 0;
- }
-
- return 0;
-}
-
-
-int dabInputRawFifoRead(void* args, void* buffer, int size)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)args;
-
- return read(data->file, buffer, size);
-}
-
-
-int dabInputRawFifoReadFrame(dabInputOperations* ops, void* args,
- void* buffer, int size)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)args;
- int result;
-
- result = ops->read(args, data->buffer + data->bufferOffset, size - data->bufferOffset);
- if (result == -1) {
- etiLog.log(alert, "ERROR: Can't read fifo\n");
- perror("");
- return -1;
- }
-
- if (result + data->bufferOffset < (size_t)size) {
- data->bufferOffset += result;
-
- etiLog.log(info, "reach end of fifo -> rewinding\n");
- if (ops->rewind(args) == -1) {
- etiLog.log(alert, "ERROR: Can't rewind fifo\n");
- return -1;
- }
-
- result = ops->read(args, data->buffer + data->bufferOffset, size - data->bufferOffset);
- if (result == -1) {
- etiLog.log(alert, "ERROR: Can't read fifo\n");
- perror("");
- return -1;
- }
-
- if (result < size) {
- etiLog.log(alert, "ERROR: Not enought data in fifo\n");
- return 0;
- }
- }
-
- memcpy(buffer, data->buffer, size);
- data->bufferOffset = 0;
-
- return size;
-}
-
-
-int dabInputRawFifoClose(void* args)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)args;
-
- if (data->file != -1) {
- close(data->file);
- data->file = -1;
- }
- return 0;
-}
-
-
-int dabInputRawFifoClean(void** args)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)*args;
- if (data->buffer != nullptr) {
- delete[] data->buffer;
- }
- delete data;
- return 0;
-}
-
-
-int dabInputRawFifoRewind(void* args)
-{
- dabInputRawFifoData* data = (dabInputRawFifoData*)args;
- return lseek(data->file, 0, SEEK_SET);
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputRawFifo.h b/src/dabInputRawFifo.h
deleted file mode 100644
index 7d2a3a0..0000000
--- a/src/dabInputRawFifo.h
+++ /dev/null
@@ -1,63 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_RAW_FIFO_H
-#define DAB_INPUT_RAW_FIFO_H
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "dabInput.h"
-
-#include <stdint.h>
-
-
-#ifdef HAVE_FORMAT_RAW
-# ifdef HAVE_INPUT_FILE
-
-
-extern struct dabInputOperations dabInputRawFifoOperations;
-
-int dabInputRawFifoInit(void** args);
-int dabInputRawFifoOpen(void* args, const char* filename);
-int dabInputRawFifoSetbuf(void* args, int size);
-int dabInputRawFifoRead(void* args, void* buffer, int size);
-int dabInputRawFifoReadFrame(dabInputOperations* ops, void* args,
- void* buffer, int size);
-int dabInputRawFifoClose(void* args);
-int dabInputRawFifoClean(void** args);
-int dabInputRawFifoRewind(void* args);
-
-
-struct dabInputRawFifoData {
- int file;
- uint8_t* buffer;
- size_t bufferSize;
- size_t bufferOffset;
-};
-
-
-# endif
-#endif
-
-#endif // DAB_INPUT_RAW_FIFO_H
diff --git a/src/dabInputRawFile.cpp b/src/dabInputRawFile.cpp
deleted file mode 100644
index be33a45..0000000
--- a/src/dabInputRawFile.cpp
+++ /dev/null
@@ -1,59 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputRawFile.h"
-#include "dabInputFile.h"
-
-
-#ifdef HAVE_FORMAT_RAW
-# ifdef HAVE_INPUT_FILE
-
-
-struct dabInputOperations dabInputRawFileOperations = {
- dabInputFileInit,
- dabInputFileOpen,
- dabInputSetbuf,
- dabInputFileRead,
- nullptr,
- nullptr,
- dabInputRawFileRead,
- dabInputSetbitrate,
- dabInputFileClose,
- dabInputFileClean,
- dabInputFileRewind
-};
-
-
-int dabInputRawFileRead(dabInputOperations* ops, void* args, void* buffer,
- int size)
-{
- int ret = ops->read(args, buffer, size);
- if (ret == 0) {
- etiLog.log(info, "reach end of raw file -> rewinding\n");
- ops->rewind(args);
- ret = ops->read(args, buffer, size);
- }
- return ret;
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputRawFile.h b/src/dabInputRawFile.h
deleted file mode 100644
index 9a4a607..0000000
--- a/src/dabInputRawFile.h
+++ /dev/null
@@ -1,45 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_RAW_FILE_H
-#define DAB_INPUT_RAW_FILE_H
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "dabInput.h"
-
-
-#ifdef HAVE_FORMAT_RAW
-# ifdef HAVE_INPUT_FILE
-
-
-extern struct dabInputOperations dabInputRawFileOperations;
-
-int dabInputRawFileRead(dabInputOperations* ops, void* args, void* buffer,
- int size);
-
-
-# endif
-#endif
-
-#endif // DAB_INPUT_RAW_FILE_H
diff --git a/src/dabInputUdp.cpp b/src/dabInputUdp.cpp
deleted file mode 100644
index 0765599..0000000
--- a/src/dabInputUdp.cpp
+++ /dev/null
@@ -1,199 +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 <http://www.gnu.org/licenses/>.
- */
-
-#include "dabInputUdp.h"
-
-#include <string.h>
-#include <limits.h>
-
-
-#ifdef __MINGW32__
-# define bzero(s, n) memset(s, 0, n)
-#endif
-
-#ifdef HAVE_FORMAT_RAW
-# ifdef HAVE_INPUT_UDP
-
-
-struct dabInputOperations dabInputUdpOperations = {
- dabInputUdpInit,
- dabInputUdpOpen,
- dabInputSetbuf,
- NULL,
- NULL,
- NULL,
- dabInputUdpRead,
- dabInputSetbitrate,
- dabInputUdpClose,
- dabInputUdpClean,
- NULL
-};
-
-
-int dabInputUdpInit(void** args)
-{
- dabInputUdpData* input = new dabInputUdpData;
- memset(&input->stats, 0, sizeof(input->stats));
- input->stats.id = dabInputFifoData::nb++;
- input->socket = new UdpSocket();
- input->packet = new UdpPacket(2048);
- *args = input;
-
- UdpSocket::init();
- return 0;
-}
-
-
-int dabInputUdpOpen(void* args, const char* inputName)
-{
- int returnCode = 0;
- char* address;
- char* ptr;
- long port;
- dabInputUdpData* input = (dabInputUdpData*)args;
-
- // Skip the udp:// part if it is present
- if (strncmp(inputName, "udp://", 6) == 0) {
- address = strdup(inputName + 6);
- }
- else {
- address = strdup(inputName);
- }
-
- ptr = strchr(address, ':');
- if (ptr == NULL) {
- etiLog.log(error,
- "\"%s\" is an invalid format for udp address: "
- "should be [udp://][address]:port - > aborting\n", address);
- returnCode = -1;
- goto udpopen_ptr_null_out;
- }
- *(ptr++) = 0;
- port = strtol(ptr, (char **)NULL, 10);
- if ((port == LONG_MIN) || (port == LONG_MAX)) {
- etiLog.log(error,
- "can't convert port number in udp address %s\n",
- address);
- returnCode = -1;
- }
- if (port == 0) {
- etiLog.log(error, "can't use port number 0 in udp address\n");
- returnCode = -1;
- }
- if (input->socket->create(port) == -1) {
- etiLog.log(error, "can't set port %i on Udp input (%s: %s)\n",
- port, inetErrDesc, inetErrMsg);
- returnCode = -1;
- }
-
- if (*address != 0) {
- if (input->socket->joinGroup(address) == -1) {
- etiLog.log(error,
- "can't join multicast group %s (%s: %s)\n",
- address, inetErrDesc, inetErrMsg);
- returnCode = -1;
- }
- }
-
- if (input->socket->setBlocking(false) == -1) {
- etiLog.log(error, "can't set Udp input socket in blocking mode "
- "(%s: %s)\n", inetErrDesc, inetErrMsg);
- returnCode = -1;
- }
-
-udpopen_ptr_null_out:
- free(address);
- etiLog.log(debug, "check return code of create\n");
- return returnCode;
-}
-
-
-int dabInputUdpRead(dabInputOperations* ops, void* args, void* buffer, int size)
-{
- int nbBytes = 0;
- uint8_t* data = reinterpret_cast<uint8_t*>(buffer);
-
- dabInputUdpData* input = (dabInputUdpData*)args;
- dabInputFifoStats* stats = (dabInputFifoStats*)&input->stats;
-
- input->stats.frameRecords[input->stats.frameCount].curSize = 0;
- input->stats.frameRecords[input->stats.frameCount].maxSize = size;
-
- if (input->packet->getLength() == 0) {
- input->socket->receive(*input->packet);
- }
-
- while (nbBytes < size) {
- unsigned freeSize = size - nbBytes;
- if (input->packet->getLength() > freeSize) {
- // Not enought place in output
- memcpy(&data[nbBytes], input->packet->getData(), freeSize);
- nbBytes = size;
- input->packet->setOffset(input->packet->getOffset() + freeSize);
- } else {
- unsigned length = input->packet->getLength();
- memcpy(&data[nbBytes], input->packet->getData(), length);
- nbBytes += length;
- input->packet->setOffset(0);
- input->socket->receive(*input->packet);
- if (input->packet->getLength() == 0) {
- break;
- }
- }
- }
- input->stats.frameRecords[input->stats.frameCount].curSize = nbBytes;
- bzero(&data[nbBytes], size - nbBytes);
-
- input->stats.frameRecords[input->stats.frameCount].curSize = nbBytes;
- 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 dabInputUdpClose(void* args)
-{
- return 0;
-}
-
-
-int dabInputUdpClean(void** args)
-{
- dabInputUdpData* input = (dabInputUdpData*)(*args);
- delete input->socket;
- delete input->packet;
- delete input;
- return 0;
-}
-
-
-# endif
-#endif
diff --git a/src/dabInputUdp.h b/src/dabInputUdp.h
deleted file mode 100644
index ac9ddb0..0000000
--- a/src/dabInputUdp.h
+++ /dev/null
@@ -1,59 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef DAB_INPUT_UDP_H
-#define DAB_INPUT_UDP_H
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "dabInput.h"
-#include "dabInputFifo.h"
-#include "UdpSocket.h"
-
-
-#ifdef HAVE_FORMAT_RAW
-# ifdef HAVE_INPUT_UDP
-
-
-extern struct dabInputOperations dabInputUdpOperations;
-
-
-struct dabInputUdpData {
- UdpSocket* socket;
- UdpPacket* packet;
- dabInputFifoStats stats;
-};
-
-
-int dabInputUdpInit(void** args);
-int dabInputUdpOpen(void* args, const char* inputName);
-int dabInputUdpRead(dabInputOperations* ops, void* args, void* buffer, int size);
-int dabInputUdpClose(void* args);
-int dabInputUdpClean(void** args);
-
-
-# endif
-#endif
-
-
-#endif // DAB_INPUT_UDP_H