aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--decoder/ETIDecoder.cpp (renamed from decoder/EDIDecoder.cpp)25
-rw-r--r--decoder/ETIDecoder.hpp (renamed from decoder/EDIDecoder.hpp)8
-rw-r--r--decoder/ETIWriter.cpp5
-rw-r--r--decoder/ETIWriter.hpp3
-rw-r--r--decoder/PFT.cpp4
-rw-r--r--decoder/PFT.hpp3
-rw-r--r--decoder/buffer_unpack.hpp3
-rw-r--r--decoder/eti.cpp4
-rw-r--r--decoder/eti.hpp4
-rw-r--r--test/main.cpp6
11 files changed, 49 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ca090c..3bfdc4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,7 +42,7 @@ include_directories(".")
list(APPEND edilib_cpp_sources
ReedSolomon.cpp
- decoder/EDIDecoder.cpp
+ decoder/ETIDecoder.cpp
decoder/ETIWriter.cpp
decoder/PFT.cpp
decoder/eti.cpp
diff --git a/decoder/EDIDecoder.cpp b/decoder/ETIDecoder.cpp
index 4e1c832..cd01893 100644
--- a/decoder/EDIDecoder.cpp
+++ b/decoder/ETIDecoder.cpp
@@ -18,24 +18,26 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "EDIDecoder.hpp"
+#include "ETIDecoder.hpp"
#include "buffer_unpack.hpp"
#include "crc.h"
#include <stdio.h>
#include <cassert>
#include <sstream>
+namespace EdiDecoder {
+
using namespace std;
#define debug(fmt, args...) //fprintf (stderr, fmt "\n" , ## args)
#define warning(fmt, args...) fprintf (stderr, fmt "\n" , ## args)
-EDIDecoder::EDIDecoder(ETIWriter& eti_writer) :
+ETIDecoder::ETIDecoder(ETIWriter& eti_writer) :
m_eti_writer(eti_writer)
{
}
-void EDIDecoder::push_bytes(const vector<uint8_t> &buf)
+void ETIDecoder::push_bytes(const vector<uint8_t> &buf)
{
copy(buf.begin(), buf.end(), back_inserter(m_input_data));
@@ -97,7 +99,7 @@ void EDIDecoder::push_bytes(const vector<uint8_t> &buf)
}
}
-void EDIDecoder::push_packet(const vector<uint8_t> &buf)
+void ETIDecoder::push_packet(const vector<uint8_t> &buf)
{
if (buf.size() < 2) {
throw std::invalid_argument("Not enough bytes to read EDI packet header");
@@ -137,14 +139,14 @@ void EDIDecoder::push_packet(const vector<uint8_t> &buf)
}
}
-void EDIDecoder::setMaxDelay(int num_af_packets)
+void ETIDecoder::setMaxDelay(int num_af_packets)
{
m_pft.setMaxDelay(num_af_packets);
}
#define AFPACKET_HEADER_LEN 10 // includes SYNC
-decode_state_t EDIDecoder::decode_afpacket(
+decode_state_t ETIDecoder::decode_afpacket(
const std::vector<uint8_t> &input_data)
{
if (input_data.size() < AFPACKET_HEADER_LEN) {
@@ -198,7 +200,7 @@ decode_state_t EDIDecoder::decode_afpacket(
}
}
-bool EDIDecoder::decode_tagpacket(const vector<uint8_t> &payload)
+bool ETIDecoder::decode_tagpacket(const vector<uint8_t> &payload)
{
size_t length = 0;
@@ -255,7 +257,7 @@ bool EDIDecoder::decode_tagpacket(const vector<uint8_t> &payload)
return success;
}
-bool EDIDecoder::decode_starptr(const vector<uint8_t> &value)
+bool ETIDecoder::decode_starptr(const vector<uint8_t> &value)
{
if (value.size() != 0x40 / 8) {
warning("Incorrect length %02lx for *PTR", value.size());
@@ -278,7 +280,7 @@ bool EDIDecoder::decode_starptr(const vector<uint8_t> &value)
return true;
}
-bool EDIDecoder::decode_deti(const vector<uint8_t> &value)
+bool ETIDecoder::decode_deti(const vector<uint8_t> &value)
{
/*
uint16_t detiHeader = fct | (fcth << 8) | (rfudf << 13) | (ficf << 14) | (atstf << 15);
@@ -376,7 +378,7 @@ bool EDIDecoder::decode_deti(const vector<uint8_t> &value)
return true;
}
-bool EDIDecoder::decode_estn(const vector<uint8_t> &value, uint8_t n)
+bool ETIDecoder::decode_estn(const vector<uint8_t> &value, uint8_t n)
{
uint32_t sstc = read_24b(value.begin());
@@ -399,10 +401,11 @@ bool EDIDecoder::decode_estn(const vector<uint8_t> &value, uint8_t n)
return true;
}
-bool EDIDecoder::decode_stardmy(const vector<uint8_t> &value)
+bool ETIDecoder::decode_stardmy(const vector<uint8_t> &value)
{
debug("*DMY len=%zu", value.size());
return true;
}
+}
diff --git a/decoder/EDIDecoder.hpp b/decoder/ETIDecoder.hpp
index ae1a5a8..e0c7218 100644
--- a/decoder/EDIDecoder.hpp
+++ b/decoder/ETIDecoder.hpp
@@ -27,6 +27,8 @@
#include "ETIWriter.hpp"
#include "PFT.hpp"
+namespace EdiDecoder {
+
struct decode_state_t {
decode_state_t(bool _complete, size_t _num_bytes_consumed) :
complete(_complete), num_bytes_consumed(_num_bytes_consumed) {}
@@ -34,9 +36,9 @@ struct decode_state_t {
size_t num_bytes_consumed;
};
-class EDIDecoder {
+class ETIDecoder {
public:
- EDIDecoder(ETIWriter& eti_writer);
+ ETIDecoder(ETIWriter& eti_writer);
/* Push bytes into the decoder. The buf can contain more
* than a single packet. This is useful when reading from streams
@@ -68,3 +70,5 @@ class EDIDecoder {
std::vector<uint8_t> m_input_data;
};
+
+}
diff --git a/decoder/ETIWriter.cpp b/decoder/ETIWriter.cpp
index 716d453..593224a 100644
--- a/decoder/ETIWriter.cpp
+++ b/decoder/ETIWriter.cpp
@@ -25,6 +25,8 @@
#include <stdexcept>
#include <sstream>
+namespace EdiDecoder {
+
using namespace std;
#define debug(fmt, args...) fprintf (stderr, fmt "\n" , ## args)
@@ -266,3 +268,6 @@ void ETIWriter::enable_write_to_file(FILE* fd)
{
m_fd = fd;
}
+
+}
+
diff --git a/decoder/ETIWriter.hpp b/decoder/ETIWriter.hpp
index 78bb218..8b129f3 100644
--- a/decoder/ETIWriter.hpp
+++ b/decoder/ETIWriter.hpp
@@ -26,6 +26,8 @@
#include <list>
#include "eti.hpp"
+namespace EdiDecoder {
+
// Information for Frame Characterisation available in
// EDI.
//
@@ -108,3 +110,4 @@ class ETIWriter {
FILE* m_fd = nullptr;
};
+}
diff --git a/decoder/PFT.cpp b/decoder/PFT.cpp
index 981b8d9..fdbb58d 100644
--- a/decoder/PFT.cpp
+++ b/decoder/PFT.cpp
@@ -33,6 +33,8 @@ extern "C" {
#include "fec/fec.h"
}
+namespace EdiDecoder {
+
namespace PFT {
using namespace std;
@@ -548,3 +550,5 @@ void PFT::incrementNextPseq()
}
}
+
+}
diff --git a/decoder/PFT.hpp b/decoder/PFT.hpp
index 9be0426..9ab14ae 100644
--- a/decoder/PFT.hpp
+++ b/decoder/PFT.hpp
@@ -27,6 +27,7 @@
#include <map>
#include <stdint.h>
+namespace EdiDecoder {
namespace PFT {
using pseq_t = uint16_t;
@@ -149,3 +150,5 @@ class PFT
};
}
+
+}
diff --git a/decoder/buffer_unpack.hpp b/decoder/buffer_unpack.hpp
index b32376c..05a1534 100644
--- a/decoder/buffer_unpack.hpp
+++ b/decoder/buffer_unpack.hpp
@@ -22,6 +22,8 @@
#pragma once
#include <stdint.h>
+namespace EdiDecoder {
+
template<class T>
uint16_t read_16b(T buf)
{
@@ -57,3 +59,4 @@ inline uint32_t unpack1bit(uint8_t byte, int bitpos)
return (byte & 1 << (7-bitpos)) > (7-bitpos);
}
+}
diff --git a/decoder/eti.cpp b/decoder/eti.cpp
index 91f6954..3fc99ef 100644
--- a/decoder/eti.cpp
+++ b/decoder/eti.cpp
@@ -24,6 +24,8 @@
#include "eti.hpp"
+namespace EdiDecoder {
+
//definitions des structures des champs du ETI(NI, G703)
uint16_t eti_FC::getFrameLength()
@@ -58,3 +60,5 @@ uint16_t eti_STC::getStartAddress()
{
return (uint16_t)((startAddress_high << 8) + startAddress_low);
}
+
+}
diff --git a/decoder/eti.hpp b/decoder/eti.hpp
index e3346eb..451ca48 100644
--- a/decoder/eti.hpp
+++ b/decoder/eti.hpp
@@ -29,6 +29,8 @@
#include <time.h>
+namespace EdiDecoder {
+
struct eti_SYNC {
uint32_t ERR:8;
uint32_t FSYNC:24;
@@ -109,4 +111,4 @@ struct eti_extension_TIME {
uint32_t TIME_SECONDS;
} PACKED;
-
+}
diff --git a/test/main.cpp b/test/main.cpp
index bc50fc2..0a8bad5 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -26,7 +26,7 @@
#include <string>
#include <regex>
-#include "EDIDecoder.hpp"
+#include "ETIDecoder.hpp"
#include "UdpSocket.h"
struct options_t {
@@ -106,12 +106,12 @@ int main(int argc, char **argv)
fd_eti = fopen(options.eti_file.c_str(), "w");
}
- ETIWriter writer;
+ EdiDecoder::ETIWriter writer;
if (fd_eti) {
writer.enable_write_to_file(fd_eti);
}
- EDIDecoder decoder(writer);
+ EdiDecoder::ETIDecoder decoder(writer);
if (options.max_delay) {
decoder.setMaxDelay(options.max_delay);