MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
ts_stream.h
Go to the documentation of this file.
1 #include "ts_packet.h"
2 #include "adts.h"
3 #include <map>
4 #include <set>
5 #include <deque>
6 #include "h265.h"
7 
8 #include "shared_memory.h"
9 
10 namespace TS {
11  enum codecType {
12  H264 = 0x1B,
13  AAC = 0x0F,
14  AC3 = 0x81,
15  MP3 = 0x03,
16  HEVC = 0x06,
17  H265 = 0x24,
18  ID3 = 0x15
19  };
20 
21  class Stream{
22  public:
23  Stream(bool _threaded = false);
24  void add(char * newPack, unsigned long long bytePos = 0);
25  void add(Packet & newPack, unsigned long long bytePos = 0);
26  void parse(Packet & newPack, unsigned long long bytePos);
27  void parse(char * newPack, unsigned long long bytePos);
28  void parse(unsigned long tid);
29  bool hasPacketOnEachTrack() const;
30  bool hasPacket(unsigned long tid) const;
31  void getPacket(unsigned long tid, DTSC::Packet & pack);
32  void getEarliestPacket(DTSC::Packet & pack);
33  void initializeMetadata(DTSC::Meta & meta, unsigned long tid = 0);
34  void clear();
35  void eraseTrack(unsigned long tid);
36  bool isDataTrack(unsigned long tid);
37  std::set<unsigned long> getActiveTracks();
38  private:
39  unsigned long long lastPAT;
41 
42  std::map<unsigned long, unsigned long long> lastPMT;
43  std::map<unsigned long, ProgramMappingTable> mappingTable;
44 
45  std::map<unsigned long, std::deque<Packet> > pesStreams;
46  std::map<unsigned long, std::deque<unsigned long long> > pesPositions;
47  std::map<unsigned long, std::deque<DTSC::Packet> > outPackets;
48  std::map<unsigned long, unsigned long> pidToCodec;
49  std::map<unsigned long, aac::adts > adtsInfo;
50  std::map<unsigned long, std::string > spsInfo;
51  std::map<unsigned long, std::string > ppsInfo;
52  std::map<unsigned long, h265::initData > hevcInfo;
53  std::map<unsigned long, std::string> metaInit;
54 
55  mutable IPC::semaphore globalSem;
56 
57  bool threaded;
58 
59  std::set<unsigned long> pmtTracks;
60 
61  void parsePES(unsigned long tid);
62  };
63 }
void getEarliestPacket(DTSC::Packet &pack)
Definition: ts_stream.cpp:554
Definition: ts_stream.h:12
std::map< unsigned long, std::string > metaInit
Definition: ts_stream.h:53
codecType
Definition: ts_stream.h:11
void add(char *newPack, unsigned long long bytePos=0)
Definition: ts_stream.cpp:44
void eraseTrack(unsigned long tid)
Definition: ts_stream.cpp:699
bool isDataTrack(unsigned long tid)
Definition: ts_stream.cpp:64
Class for storage of meta data.
Definition: dtsc.h:337
Definition: ts_stream.h:13
void initializeMetadata(DTSC::Meta &meta, unsigned long tid=0)
Definition: ts_stream.cpp:582
Definition: ts_stream.h:15
Definition: ts_stream.h:18
A class used for the abstraction of semaphores.
Definition: shared_memory.h:60
Definition: ts_stream.h:21
std::map< unsigned long, unsigned long long > lastPMT
Definition: ts_stream.h:42
Definition: ts_packet.h:85
bool hasPacketOnEachTrack() const
Definition: ts_stream.cpp:203
std::map< unsigned long, ProgramMappingTable > mappingTable
Definition: ts_stream.h:43
void getPacket(unsigned long tid, DTSC::Packet &pack)
Definition: ts_stream.cpp:507
std::map< unsigned long, std::string > ppsInfo
Definition: ts_stream.h:51
void parse(Packet &newPack, unsigned long long bytePos)
Definition: ts_stream.cpp:196
std::map< unsigned long, unsigned long > pidToCodec
Definition: ts_stream.h:48
std::map< unsigned long, aac::adts > adtsInfo
Definition: ts_stream.h:49
Holds all TS processing related code.
Definition: ts_packet.cpp:20
Definition: ts_stream.h:14
Definition: ts_stream.h:17
void clear()
Definition: ts_stream.cpp:32
std::map< unsigned long, std::string > spsInfo
Definition: ts_stream.h:50
Class for reading and writing TS Streams.
Definition: ts_packet.h:21
unsigned long long lastPAT
Definition: ts_stream.h:39
bool hasPacket(unsigned long tid) const
Definition: ts_stream.cpp:227
std::map< unsigned long, h265::initData > hevcInfo
Definition: ts_stream.h:52
Stream(bool _threaded=false)
Definition: ts_stream.cpp:10
std::map< unsigned long, std::deque< DTSC::Packet > > outPackets
Definition: ts_stream.h:47
ProgramAssociationTable associationTable
Definition: ts_stream.h:40
std::map< unsigned long, std::deque< unsigned long long > > pesPositions
Definition: ts_stream.h:46
IPC::semaphore globalSem
Definition: ts_stream.h:55
void parsePES(unsigned long tid)
Definition: ts_stream.cpp:271
std::set< unsigned long > pmtTracks
Definition: ts_stream.h:59
std::map< unsigned long, std::deque< Packet > > pesStreams
Definition: ts_stream.h:45
Definition: ts_stream.h:16
std::set< unsigned long > getActiveTracks()
Definition: ts_stream.cpp:656
DTSC::Packets can currently be three types: DTSC_HEAD packets are the "DTSC" header string...
Definition: dtsc.h:100
bool threaded
Definition: ts_stream.h:57