diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-11-05 14:35:25 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-11-05 14:35:25 +0100 |
commit | 5fd4d99aded3677497c6cf5ab31517a5383333cb (patch) | |
tree | f7fc1022ff4550c6e7f97d266564cbffc336581f /src/input/File.h | |
parent | 076b370ddcf6f8d69bd728dd5ae7b18b18a77b23 (diff) | |
download | dabmux-5fd4d99aded3677497c6cf5ab31517a5383333cb.tar.gz dabmux-5fd4d99aded3677497c6cf5ab31517a5383333cb.tar.bz2 dabmux-5fd4d99aded3677497c6cf5ab31517a5383333cb.zip |
Add Packet File input
Diffstat (limited to 'src/input/File.h')
-rw-r--r-- | src/input/File.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/input/File.h b/src/input/File.h index 99e0a87..bf99748 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -26,6 +26,7 @@ #pragma once #include <vector> +#include <array> #include <string> #include <stdint.h> #include "input/inputs.h" @@ -37,7 +38,7 @@ class FileBase : public InputBase { public: virtual int open(const std::string& name); virtual int readFrame(uint8_t* buffer, size_t size) = 0; - virtual int setBitrate(int bitrate) = 0; + virtual int setBitrate(int bitrate); virtual int close(); /* Rewind the file @@ -45,8 +46,13 @@ class FileBase : public InputBase { */ virtual int rewind(); protected: + /* Read len bytes from the file into buf, and return + * the number of bytes read, or -1 in case of error. + */ + virtual ssize_t readFromFile(uint8_t* buf, size_t len); + // We use unix open() instead of fopen() because - // we want to do non-blocking I/O + // we might want to do non-blocking I/O in the future int m_fd = -1; }; @@ -62,7 +68,21 @@ class MPEGFile : public FileBase { class RawFile : public FileBase { public: virtual int readFrame(uint8_t* buffer, size_t size); - virtual int setBitrate(int bitrate); +}; + +class PacketFile : public FileBase { + public: + PacketFile(bool enhancedPacketMode); + virtual int readFrame(uint8_t* buffer, size_t size); + + protected: + std::array<uint8_t,96> m_packetData; + size_t m_packetLength; + + bool m_enhancedPacketEnabled = false; + std::array<std::array<uint8_t, 204>,12> m_enhancedPacketData; + size_t m_enhancedPacketWaiting; + size_t m_enhancedPacketLength; }; }; |