This repository was archived by the owner on Aug 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.h
More file actions
110 lines (91 loc) · 2.88 KB
/
Program.h
File metadata and controls
110 lines (91 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include <vector>
#include <map>
namespace com{
namespace cloume{
namespace cap{ namespace streaming{
class Program
{
public:
class Stream{
public:
enum EnumStreamType{
StreamType_Video = 0,
StreamType_Audio,
StreamType_Subtitle,
StreamType_PCR,
};
enum EnumStreamSubtype{
STREAMSUBTYPE_H264_VIDEO = 0x1b,
STREAMSUBTYPE_ISO_IEC_13818_3_AUDIO = 0x04, //MPEG-II
STREAMSUBTYPE_ISO_IEC_11172_3_AUDIO = 0x03, //MPEG-I
STREAMSUBTYPE_PCR = 0xFF,
};
public:
EnumStreamType Type(){ return mType; }
EnumStreamSubtype SubType(){ return mSubtype; }
unsigned short ElementaryPID(){ return mElementaryPID; }
//index in Program's stream list
unsigned char Index(){ return mIndex; }
void SetIndex(unsigned char index){ mIndex = index; }
unsigned int LastFrameTimestamp(){ return mLastFrameTimestamp; }
void LastFrameTimestamp(unsigned int ts){ mLastFrameTimestamp = ts; }
protected:
Stream(EnumStreamType type, EnumStreamSubtype Subtype, unsigned short ElementaryPID)
: mLastFrameTimestamp(0)
{
this->mType = type;
this->mSubtype = Subtype;
this->mElementaryPID = ElementaryPID;
}
private:
EnumStreamType mType;
EnumStreamSubtype mSubtype;
unsigned short mElementaryPID;
unsigned char mIndex;
unsigned int mLastFrameTimestamp;
};
class StreamVideo : public Stream{
public:
StreamVideo(EnumStreamSubtype Subtype, unsigned short ElementaryPID)
: Stream(StreamType_Video, Subtype, ElementaryPID){
}
};
class StreamAudio : public Stream{
public:
StreamAudio(EnumStreamSubtype Subtype, unsigned short ElementaryPID)
: Stream(StreamType_Audio, Subtype, ElementaryPID){
}
};
class StreamPCR : public Stream{
public:
StreamPCR(unsigned short ElementaryPID)
: Stream(StreamType_Audio, Stream::STREAMSUBTYPE_PCR, ElementaryPID){
}
};
typedef std::vector<Stream*> StreamVector;
typedef std::pair<Stream::EnumStreamType, unsigned char> StreamCounterPair;
typedef std::map<Stream::EnumStreamType, unsigned char> StreamCounterMap;
public:
//@number: program number in PAT, @pid PMT's PID in PAT
//pid 0x0010 in PAT is for NIT, program number 0x0000 is for NIT
Program(unsigned short number = 1, unsigned short pid = 0x20);
virtual ~Program(void);
public:
//void AddStream(Stream::EnumStreamType type, unsigned char SubType, unsigned short ElementaryPID);
void AddStream(Stream*);
unsigned short Number(){ return mNumber; }
unsigned short PMTPID(){ return mPMTPID; }
unsigned short PCRPID(){ return mPCRPID; }
void PCRPID(unsigned short pid){ mPCRPID = pid; }
StreamVector &Streams(){ return mStreams; }
private:
StreamVector mStreams;
StreamCounterMap mStreamsCounter; //stream count for each stream type
unsigned short mNumber, mPMTPID, mPCRPID;
};
typedef std::vector<Program*> ProgramVector;
}
}
}
}