Style enforcement
This commit is contained in:
parent
6811b54186
commit
56c21b5ba6
4 changed files with 939 additions and 1151 deletions
1132
lib/ts_stream.cpp
1132
lib/ts_stream.cpp
File diff suppressed because it is too large
Load diff
154
lib/ts_stream.h
154
lib/ts_stream.h
|
@ -1,94 +1,92 @@
|
|||
#include "ts_packet.h"
|
||||
#include "adts.h"
|
||||
#include "h265.h"
|
||||
#include "ts_packet.h"
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <deque>
|
||||
#include "h265.h"
|
||||
|
||||
#include "shared_memory.h"
|
||||
|
||||
namespace TS {
|
||||
enum codecType {
|
||||
H264 = 0x1B,
|
||||
AAC = 0x0F,
|
||||
AC3 = 0x81,
|
||||
MP3 = 0x03,
|
||||
H265 = 0x24,
|
||||
ID3 = 0x15
|
||||
};
|
||||
|
||||
namespace TS{
|
||||
enum codecType{H264 = 0x1B, AAC = 0x0F, AC3 = 0x81, MP3 = 0x03, H265 = 0x24, ID3 = 0x15};
|
||||
|
||||
class ADTSRemainder{
|
||||
private:
|
||||
char * data;
|
||||
uint32_t max;
|
||||
uint32_t now;
|
||||
uint32_t len;
|
||||
uint32_t bpos;
|
||||
public:
|
||||
void setRemainder(const aac::adts & p, const void * source, const uint32_t avail, const uint32_t bPos);
|
||||
|
||||
ADTSRemainder();
|
||||
~ADTSRemainder();
|
||||
uint32_t getLength();
|
||||
uint32_t getBpos();
|
||||
uint32_t getTodo();
|
||||
char* getData();
|
||||
|
||||
void append(const char *p,uint32_t pLen);
|
||||
bool isComplete();
|
||||
void clear();
|
||||
private:
|
||||
char *data;
|
||||
uint32_t max;
|
||||
uint32_t now;
|
||||
uint32_t len;
|
||||
uint32_t bpos;
|
||||
|
||||
public:
|
||||
void setRemainder(const aac::adts &p, const void *source, const uint32_t avail,
|
||||
const uint32_t bPos);
|
||||
|
||||
ADTSRemainder();
|
||||
~ADTSRemainder();
|
||||
uint32_t getLength();
|
||||
uint32_t getBpos();
|
||||
uint32_t getTodo();
|
||||
char *getData();
|
||||
|
||||
void append(const char *p, uint32_t pLen);
|
||||
bool isComplete();
|
||||
void clear();
|
||||
};
|
||||
|
||||
class Stream{
|
||||
public:
|
||||
Stream(bool _threaded = false);
|
||||
~Stream();
|
||||
void add(char * newPack, unsigned long long bytePos = 0);
|
||||
void add(Packet & newPack, unsigned long long bytePos = 0);
|
||||
void parse(Packet & newPack, unsigned long long bytePos);
|
||||
void parse(char * newPack, unsigned long long bytePos);
|
||||
void parse(unsigned long tid);
|
||||
void parseNal(uint32_t tid, const char *pesPayload, const char * packetPtr, bool &isKeyFrame);
|
||||
bool hasPacketOnEachTrack() const;
|
||||
bool hasPacket(unsigned long tid) const;
|
||||
bool hasPacket() const;
|
||||
void getPacket(unsigned long tid, DTSC::Packet & pack);
|
||||
void getEarliestPacket(DTSC::Packet & pack);
|
||||
void initializeMetadata(DTSC::Meta & meta, unsigned long tid = 0, unsigned long mappingId = 0);
|
||||
void partialClear();
|
||||
void clear();
|
||||
void finish();
|
||||
void eraseTrack(unsigned long tid);
|
||||
bool isDataTrack(unsigned long tid);
|
||||
void parseBitstream(uint32_t tid, const char * pesPayload, uint32_t realPayloadSize,uint64_t timeStamp, int64_t timeOffset, uint64_t bPos);
|
||||
std::set<unsigned long> getActiveTracks();
|
||||
private:
|
||||
unsigned long long lastPAT;
|
||||
ProgramAssociationTable associationTable;
|
||||
std::map<unsigned long, ADTSRemainder> remainders;
|
||||
|
||||
bool firstPacketFound;
|
||||
std::map<unsigned long, unsigned long long> lastPMT;
|
||||
std::map<unsigned long, ProgramMappingTable> mappingTable;
|
||||
public:
|
||||
Stream(bool _threaded = false);
|
||||
~Stream();
|
||||
void add(char *newPack, unsigned long long bytePos = 0);
|
||||
void add(Packet &newPack, unsigned long long bytePos = 0);
|
||||
void parse(Packet &newPack, unsigned long long bytePos);
|
||||
void parse(char *newPack, unsigned long long bytePos);
|
||||
void parse(unsigned long tid);
|
||||
void parseNal(uint32_t tid, const char *pesPayload, const char *packetPtr, bool &isKeyFrame);
|
||||
bool hasPacketOnEachTrack() const;
|
||||
bool hasPacket(unsigned long tid) const;
|
||||
bool hasPacket() const;
|
||||
void getPacket(unsigned long tid, DTSC::Packet &pack);
|
||||
void getEarliestPacket(DTSC::Packet &pack);
|
||||
void initializeMetadata(DTSC::Meta &meta, unsigned long tid = 0, unsigned long mappingId = 0);
|
||||
void partialClear();
|
||||
void clear();
|
||||
void finish();
|
||||
void eraseTrack(unsigned long tid);
|
||||
bool isDataTrack(unsigned long tid);
|
||||
void parseBitstream(uint32_t tid, const char *pesPayload, uint32_t realPayloadSize,
|
||||
uint64_t timeStamp, int64_t timeOffset, uint64_t bPos);
|
||||
std::set<unsigned long> getActiveTracks();
|
||||
|
||||
std::map<unsigned long, std::deque<Packet> > pesStreams;
|
||||
std::map<unsigned long, std::deque<unsigned long long> > pesPositions;
|
||||
std::map<unsigned long, std::deque<DTSC::Packet> > outPackets;
|
||||
std::map<unsigned long, DTSC::Packet> buildPacket;
|
||||
std::map<unsigned long, unsigned long> pidToCodec;
|
||||
std::map<unsigned long, aac::adts > adtsInfo;
|
||||
std::map<unsigned long, std::string > spsInfo;
|
||||
std::map<unsigned long, std::string > ppsInfo;
|
||||
std::map<unsigned long, h265::initData > hevcInfo;
|
||||
std::map<unsigned long, std::string> metaInit;
|
||||
std::map<unsigned long, std::string> descriptors;
|
||||
std::map<unsigned long, std::string> partialBuffer;
|
||||
mutable IPC::semaphore globalSem;
|
||||
private:
|
||||
unsigned long long lastPAT;
|
||||
ProgramAssociationTable associationTable;
|
||||
std::map<unsigned long, ADTSRemainder> remainders;
|
||||
|
||||
bool threaded;
|
||||
bool firstPacketFound;
|
||||
std::map<unsigned long, unsigned long long> lastPMT;
|
||||
std::map<unsigned long, ProgramMappingTable> mappingTable;
|
||||
|
||||
std::set<unsigned long> pmtTracks;
|
||||
std::map<unsigned long, std::deque<Packet>> pesStreams;
|
||||
std::map<unsigned long, std::deque<unsigned long long>> pesPositions;
|
||||
std::map<unsigned long, std::deque<DTSC::Packet>> outPackets;
|
||||
std::map<unsigned long, DTSC::Packet> buildPacket;
|
||||
std::map<unsigned long, unsigned long> pidToCodec;
|
||||
std::map<unsigned long, aac::adts> adtsInfo;
|
||||
std::map<unsigned long, std::string> spsInfo;
|
||||
std::map<unsigned long, std::string> ppsInfo;
|
||||
std::map<unsigned long, h265::initData> hevcInfo;
|
||||
std::map<unsigned long, std::string> metaInit;
|
||||
std::map<unsigned long, std::string> descriptors;
|
||||
std::map<unsigned long, std::string> partialBuffer;
|
||||
mutable IPC::semaphore globalSem;
|
||||
|
||||
void parsePES(unsigned long tid, bool finished = false);
|
||||
bool threaded;
|
||||
|
||||
std::set<unsigned long> pmtTracks;
|
||||
|
||||
void parsePES(unsigned long tid, bool finished = false);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,22 @@
|
|||
#pragma once
|
||||
#include "input.h"
|
||||
#include <fstream>
|
||||
#include <mist/dtsc.h>
|
||||
#include <mist/nal.h>
|
||||
#include <mist/ts_packet.h>
|
||||
#include <mist/ts_stream.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
//#include <stdint.h>
|
||||
|
||||
#define BUFFERTIME 10
|
||||
|
||||
namespace Mist {
|
||||
namespace Mist{
|
||||
|
||||
enum PlaylistType { VOD, LIVE, EVENT };
|
||||
enum PlaylistType{VOD, LIVE, EVENT};
|
||||
|
||||
|
||||
struct playListEntries
|
||||
{
|
||||
struct playListEntries{
|
||||
std::string filename;
|
||||
uint64_t bytePos;
|
||||
float duration;
|
||||
|
@ -26,105 +24,103 @@ namespace Mist {
|
|||
unsigned int wait;
|
||||
};
|
||||
|
||||
class Playlist {
|
||||
public:
|
||||
Playlist(const std::string & uriSrc = "");
|
||||
bool atEnd() const;
|
||||
bool isUrl() const;
|
||||
bool reload();
|
||||
void addEntry(const std::string & filename, float duration, uint64_t & totalBytes);
|
||||
bool loadURL(const std::string & loadUrl);
|
||||
class Playlist{
|
||||
public:
|
||||
Playlist(const std::string &uriSrc = "");
|
||||
bool atEnd() const;
|
||||
bool isUrl() const;
|
||||
bool reload();
|
||||
void addEntry(const std::string &filename, float duration, uint64_t &totalBytes);
|
||||
bool loadURL(const std::string &loadUrl);
|
||||
|
||||
std::string uri;
|
||||
std::string uri_root;
|
||||
std::string uri;
|
||||
std::string uri_root;
|
||||
|
||||
std::string source;
|
||||
const char *packetPtr;
|
||||
std::string source;
|
||||
const char *packetPtr;
|
||||
|
||||
int id;
|
||||
bool initDone;
|
||||
bool playlistEnd;
|
||||
int noChangeCount;
|
||||
int version;
|
||||
uint64_t media_sequence;
|
||||
int lastFileIndex;
|
||||
int id;
|
||||
bool initDone;
|
||||
bool playlistEnd;
|
||||
int noChangeCount;
|
||||
int version;
|
||||
uint64_t media_sequence;
|
||||
int lastFileIndex;
|
||||
|
||||
|
||||
int waitTime;
|
||||
PlaylistType playlistType;
|
||||
std::deque<playListEntries> entries;
|
||||
int entryCount;
|
||||
unsigned int lastTimestamp;
|
||||
unsigned int startTime;
|
||||
int waitTime;
|
||||
PlaylistType playlistType;
|
||||
std::deque<playListEntries> entries;
|
||||
int entryCount;
|
||||
unsigned int lastTimestamp;
|
||||
unsigned int startTime;
|
||||
};
|
||||
|
||||
|
||||
struct entryBuffer
|
||||
{
|
||||
struct entryBuffer{
|
||||
int timestamp;
|
||||
playListEntries entry;
|
||||
int playlistIndex;
|
||||
};
|
||||
|
||||
class inputHLS : public Input {
|
||||
public:
|
||||
inputHLS(Util::Config * cfg);
|
||||
~inputHLS();
|
||||
bool needsLock();
|
||||
bool openStreamSource();
|
||||
protected:
|
||||
//Private Functions
|
||||
|
||||
unsigned int startTime;
|
||||
PlaylistType playlistType;
|
||||
int version;
|
||||
int targetDuration;
|
||||
int media_sequence;
|
||||
bool endPlaylist;
|
||||
int currentPlaylist;
|
||||
class inputHLS : public Input{
|
||||
public:
|
||||
inputHLS(Util::Config *cfg);
|
||||
~inputHLS();
|
||||
bool needsLock();
|
||||
bool openStreamSource();
|
||||
|
||||
//std::vector<playListEntries> entries;
|
||||
std::vector<Playlist> playlists;
|
||||
//std::vector<int> pidMapping;
|
||||
std::map<int,int> pidMapping;
|
||||
std::map<int,int> pidMappingR;
|
||||
protected:
|
||||
// Private Functions
|
||||
|
||||
std::vector<int> reloadNext;
|
||||
unsigned int startTime;
|
||||
PlaylistType playlistType;
|
||||
int version;
|
||||
int targetDuration;
|
||||
int media_sequence;
|
||||
bool endPlaylist;
|
||||
int currentPlaylist;
|
||||
|
||||
int currentIndex;
|
||||
std::string currentFile;
|
||||
std::ifstream in;
|
||||
// std::vector<playListEntries> entries;
|
||||
std::vector<Playlist> playlists;
|
||||
// std::vector<int> pidMapping;
|
||||
std::map<int, int> pidMapping;
|
||||
std::map<int, int> pidMappingR;
|
||||
|
||||
TS::Stream tsStream;///<Used for parsing the incoming ts stream
|
||||
std::vector<int> reloadNext;
|
||||
|
||||
Socket::Connection conn;
|
||||
TS::Packet tsBuf;
|
||||
int currentIndex;
|
||||
std::string currentFile;
|
||||
std::ifstream in;
|
||||
|
||||
int getFirstPlaylistToReload();
|
||||
TS::Stream tsStream; ///<Used for parsing the incoming ts stream
|
||||
|
||||
int firstSegment();
|
||||
void waitForNextSegment();
|
||||
void readPMT();
|
||||
bool setup();
|
||||
bool preSetup();
|
||||
bool readHeader();
|
||||
void getNext(bool smart = true);
|
||||
void seek(int seekTime);
|
||||
void trackSelect(std::string trackSpec);
|
||||
FILE * inFile;
|
||||
FILE * tsFile;
|
||||
Socket::Connection conn;
|
||||
TS::Packet tsBuf;
|
||||
|
||||
bool readIndex();
|
||||
bool initPlaylist(const std::string & uri);
|
||||
bool readPlaylist(const std::string & uri);
|
||||
bool readNextFile();
|
||||
int getFirstPlaylistToReload();
|
||||
|
||||
void parseStreamHeader();
|
||||
int firstSegment();
|
||||
void waitForNextSegment();
|
||||
void readPMT();
|
||||
bool setup();
|
||||
bool preSetup();
|
||||
bool readHeader();
|
||||
void getNext(bool smart = true);
|
||||
void seek(int seekTime);
|
||||
void trackSelect(std::string trackSpec);
|
||||
FILE *inFile;
|
||||
FILE *tsFile;
|
||||
|
||||
int getMappedTrackId(int id);
|
||||
int getMappedTrackPlaylist(int id);
|
||||
int getOriginalTrackId(int playlistId, int id);
|
||||
int getEntryId(int playlistId, uint64_t bytePos);
|
||||
bool readIndex();
|
||||
bool initPlaylist(const std::string &uri);
|
||||
bool readPlaylist(const std::string &uri);
|
||||
bool readNextFile();
|
||||
|
||||
void parseStreamHeader();
|
||||
|
||||
int getMappedTrackId(int id);
|
||||
int getMappedTrackPlaylist(int id);
|
||||
int getOriginalTrackId(int playlistId, int id);
|
||||
int getEntryId(int playlistId, uint64_t bytePos);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue