Pack_Header_Def.h
5.8 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
writer:Kevin.liu
Date:2010-08-06
*/
#ifndef __HEADER_PACK_HEADER_DEF_H__
#define __HEADER_PACK_HEADER_DEF_H__
#include <stdint.h>
typedef struct PS_HEADER_tag
{
unsigned char pack_start_code[4]; //'0x000001BA'
unsigned char system_clock_reference_base21:2;
unsigned char marker_bit:1;
unsigned char system_clock_reference_base1:3;
unsigned char fix_bit:2; //'01'
unsigned char system_clock_reference_base22;
unsigned char system_clock_reference_base31:2;
unsigned char marker_bit1:1;
unsigned char system_clock_reference_base23:5;
unsigned char system_clock_reference_base32;
unsigned char system_clock_reference_extension1:2;
unsigned char marker_bit2:1;
unsigned char system_clock_reference_base33:5; //system_clock_reference_base 33bit
unsigned char marker_bit3:1;
unsigned char system_clock_reference_extension2:7; //system_clock_reference_extension 9bit
unsigned char program_mux_rate1;
unsigned char program_mux_rate2;
unsigned char marker_bit5:1;
unsigned char marker_bit4:1;
unsigned char program_mux_rate3:6;
unsigned char pack_stuffing_length:3;
unsigned char reserved:5;
PS_HEADER_tag()
{
pack_start_code[0] = 0x00;
pack_start_code[1] = 0x00;
pack_start_code[2] = 0x01;
pack_start_code[3] = 0xBA;
fix_bit = 0x01;
marker_bit = 0x01;
marker_bit1 = 0x01;
marker_bit2 = 0x01;
marker_bit3 = 0x01;
marker_bit4 = 0x01;
marker_bit5 = 0x01;
reserved = 0x1F;
pack_stuffing_length = 0x00;
system_clock_reference_extension1 = 0;
system_clock_reference_extension2 = 0;
}
void getSystem_clock_reference_base(uint64_t &_ui64SCR)
{
_ui64SCR = (system_clock_reference_base1 << 30) | (system_clock_reference_base21 << 28)
| (system_clock_reference_base22 << 20) | (system_clock_reference_base23 << 15)
| (system_clock_reference_base31 << 13) | (system_clock_reference_base32 << 5)
| (system_clock_reference_base33);
}
void setSystem_clock_reference_base(uint64_t _ui64SCR)
{
system_clock_reference_base1 = (_ui64SCR >> 30) & 0x07;
system_clock_reference_base21 = (_ui64SCR >> 28) & 0x03;
system_clock_reference_base22 = (_ui64SCR >> 20) & 0xFF;
system_clock_reference_base23 = (_ui64SCR >> 15) & 0x1F;
system_clock_reference_base31 = (_ui64SCR >> 13) & 0x03;
system_clock_reference_base32 = (_ui64SCR >> 5) & 0xFF;
system_clock_reference_base33 = _ui64SCR & 0x1F;
}
void getProgram_mux_rate(unsigned int &_uiMux_rate)
{
_uiMux_rate = (program_mux_rate1 << 14) | (program_mux_rate2 << 6) | program_mux_rate3;
}
void setProgram_mux_rate(unsigned int _uiMux_rate)
{
program_mux_rate1 = (_uiMux_rate >> 14) & 0xFF;
program_mux_rate2 = (_uiMux_rate >> 6) & 0xFF;
program_mux_rate3 = _uiMux_rate & 0x3F;
}
}*pPS_HEADER_tag;
typedef struct PES_HEADER_tag
{
unsigned char packet_start_code_prefix[3];
unsigned char stream_id;
unsigned char PES_packet_length[2];
unsigned char original_or_copy:1;
unsigned char copyright:1;
unsigned char data_alignment_indicator:1;
unsigned char PES_priority:1;
unsigned char PES_scrambling_control:2;
unsigned char fix_bit:2;
unsigned char PES_extension_flag:1;
unsigned char PES_CRC_flag:1;
unsigned char additional_copy_info_flag:1;
unsigned char DSM_trick_mode_flag:1;
unsigned char ES_rate_flag:1;
unsigned char ESCR_flag:1;
unsigned char PTS_DTS_flags:2;
unsigned char PES_header_data_length;
PES_HEADER_tag()
{
packet_start_code_prefix[0] = 0x00;
packet_start_code_prefix[1] = 0x00;
packet_start_code_prefix[2] = 0x01;
PES_packet_length[0] = 0x00;
PES_packet_length[1] = 0x00;
stream_id = 0xE0;
fix_bit = 0x02;
}
}*pPES_HEADER_tag;
typedef struct PTS_tag
{
unsigned char marker_bit:1;
unsigned char PTS1:3;
unsigned char fix_bit:4;
unsigned char PTS21;
unsigned char marker_bit1:1;
unsigned char PTS22:7;
unsigned char PTS31;
unsigned char marker_bit2:1;
unsigned char PTS32:7;
PTS_tag()
{
fix_bit = 0x02;
marker_bit = 0x01;
marker_bit1 = 0x01;
marker_bit2 = 0x01;
}
void getPTS(uint64_t &_ui64PTS)
{
_ui64PTS = (PTS1 << 30) | (PTS21 << 22)
| (PTS22 << 15) | (PTS31 << 7) | (PTS32);
}
void setPTS(uint64_t _ui64PTS)
{
PTS1 = (_ui64PTS >> 30) & 0x07;
PTS21 = (_ui64PTS >> 22) & 0xFF;
PTS22 = (_ui64PTS >> 15) & 0x7F;
PTS31 = (_ui64PTS >> 7) & 0xFF;
PTS32 = _ui64PTS & 0x7F;
}
}*pPTS_tag;
typedef struct PSM_tag
{
unsigned char packet_start_code_prefix[3];
unsigned char map_stream_id;
unsigned char program_stream_map_length[2];
unsigned char program_stream_map_version:5;
unsigned char reserved1:2;
unsigned char current_next_indicator:1;
unsigned char marker_bit:1;
unsigned char reserved2:7;
unsigned char program_stream_info_length[2];
unsigned char elementary_stream_map_length[2];
unsigned char stream_type;
unsigned char elementary_stream_id;
unsigned char elementary_stream_info_length[2];
unsigned char CRC_32[4];
PSM_tag()
{
packet_start_code_prefix[0] = 0x00;
packet_start_code_prefix[1] = 0x00;
packet_start_code_prefix[2] = 0x01;
map_stream_id = 0xBC;
program_stream_map_length[0] = 0x00;
program_stream_map_length[1] = 0x0E;
program_stream_map_version = 0x00;
current_next_indicator = 0x01;
reserved1 = 0x03;
program_stream_map_version = 0x00;
reserved2 = 0x7F;
marker_bit = 0x01;
program_stream_info_length[0] = 0x00;
program_stream_info_length[1] = 0x00;
elementary_stream_map_length[0] = 0x00;
elementary_stream_map_length[1] = 0x04;
stream_type = 0x1B;
elementary_stream_id = 0xE0;
elementary_stream_info_length[0] = 0x00;
elementary_stream_info_length[1] = 0x00;
CRC_32[3] = 0x45;
CRC_32[2] = 0xBD;
CRC_32[1] = 0xDC;
CRC_32[0] = 0xF4;
}
}*pPSM_tag;
#endif