-
Notifications
You must be signed in to change notification settings - Fork 95
/
h222_defns.h
218 lines (201 loc) · 9.41 KB
/
h222_defns.h
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
/*
* Datastructures and definitions useful for working with H.222 data,
* whether it be Transport Stream or Program Stream
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the MPEG TS, PS and ES tools.
*
* The Initial Developer of the Original Code is Amino Communications Ltd.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Amino Communications Ltd, Swavesey, Cambridge UK
*
* ***** END LICENSE BLOCK *****
*/
#ifndef _h222_defns
#define _h222_defns
// Include our function definition(s)
// -- this is actually just the function for returning a string
// representing a stream type (according to the following table),
// which *used* to be a macro, defined in this header file.
#include "h222_fns.h"
// ------------------------------------------------------------
// H.222.0 Table 2-29: Stream type assignments, as amended by
// H.222.0 (2000) Amendment 3
//
// Value Description
// ===== ============================
// 00 ITU-T | ISO/IEC Reserved
// 01 ISO/IEC 11172-2 Video
// 02 ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2
// constrained parameter video stream
// 03 ISO/IEC 11172-3 Audio
// 04 ISO/IEC 13818-3 Audio
// 05 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
// 06 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing
// private data -- traditionally DVB Dolby (AC-3)
// 07 ISO/IEC 13522 MHEG
// 08 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM CC
// 09 ITU-T Rec. H.222.1
// 0A ISO/IEC 13818-6 type A
// 0B ISO/IEC 13818-6 type B
// 0C ISO/IEC 13818-6 type C
// 0D ISO/IEC 13818-6 type D
// 0E ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
// 0F ISO/IEC 13818-7 Audio with ADTS transport syntax
// 10 ISO/IEC 14496-2 Visual
// 11 ISO/IEC 14496-3 Audio with the LATM transport syntax as defined
// in ISO/IEC 14496-3 / AMD 1
// 12 ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried
// in PES packets
// 13 ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried
// in ISO/IEC14496_sections.
// 14 ISO/IEC 13818-6 Synchronized Download Protocol
// 15 Metadata carried in PES packets
// 16 Metadata carried in metadata_sections
// 17 Metadata carried in ISO/IEC 13818-6 Data Carousel
// 18 Metadata carried in ISO/IEC 13818-6 Object Carousel
// 19 Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol
// 1A IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
// 1B AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10
// Video
// 1C-7E ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
// 7F IPMP stream
// 80-FF User Private
// 81 Traditionally ATSC Dolby (AC-3)
#define MPEG1_VIDEO_STREAM_TYPE 0x01
#define MPEG2_VIDEO_STREAM_TYPE 0x02 // H.262
#define AVC_VIDEO_STREAM_TYPE 0x1B // MPEG-4 part10 - H.264
#define AVS_VIDEO_STREAM_TYPE 0x42 // AVS -- Chinese standard
#define DVB_DOLBY_AUDIO_STREAM_TYPE 0x06 // [1]
#define ATSC_DOLBY_AUDIO_STREAM_TYPE 0x81 // [1]
#define MPEG2_AUDIO_STREAM_TYPE 0x04
#define MPEG1_AUDIO_STREAM_TYPE 0x03
#define ADTS_AUDIO_STREAM_TYPE 0x0F // AAC ADTS
#define MPEG4_PART2_VIDEO_STREAM_TYPE 0x10
#define LATM_AUDIO_STREAM_TYPE 0x11 // How much do we support this?
#define H265_VIDEO_STREAM_TYPE 0x24
#define DOLBY_DVB_STREAM_TYPE 0x06 // [1]
#define DOLBY_ATSC_STREAM_TYPE 0x81 // [1]
// [1] In DVB (the European transmission standard) Dolby (AC-3) audio is
// carried in stream type 0x06, but in ATSC (the USA standard), stream
// type 0x81 is used. Note that both of these are essentially just saying
// that the data is a private stream, so technically one needs to set
// descriptors in the PMT as well to say we really mean Dolby (AC-3)
// Also, in DVB, other types of stream can be in 0x06.
#define IS_VIDEO_STREAM_TYPE(s) ((s)==MPEG1_VIDEO_STREAM_TYPE || \
(s)==MPEG2_VIDEO_STREAM_TYPE || \
(s)==AVC_VIDEO_STREAM_TYPE || \
(s)==H265_VIDEO_STREAM_TYPE || \
(s)==AVS_VIDEO_STREAM_TYPE || \
(s)==MPEG4_PART2_VIDEO_STREAM_TYPE)
// Although I include Dolby in the "standard" audio types, beware that the
// stream type usage is not specified by H.222 itself - it is "convention"
// (albeit a standardised convention) how private streams are used to transmit
// Dolby. There is a case to be made that, at any one time, we should not
// recognise *both* potential Dolby stream types, but just one or the other
// (see [1] above) according to the standard the user is expecting. On the
// other hand, practice seems to be to use the stream types only in the
// expected manner.
#define IS_DOLBY_STREAM_TYPE(s) ((s)==DOLBY_DVB_STREAM_TYPE || \
(s)==DOLBY_ATSC_STREAM_TYPE)
#define IS_AUDIO_STREAM_TYPE(s) ((s)==MPEG1_AUDIO_STREAM_TYPE || \
(s)==MPEG2_AUDIO_STREAM_TYPE || \
(s)==ADTS_AUDIO_STREAM_TYPE || \
(s)==LATM_AUDIO_STREAM_TYPE || \
IS_DOLBY_STREAM_TYPE((s)))
// ------------------------------------------------------------
// Stream ids, as used in PES headers
// H.222.0 Table 2-18: Stream_id assignments, as amended by
// H.222.0 (2000) Amendment 3
//
// Note Hex stream_id stream coding
// ==== === ========= =============
// 1 BC 1011 1100 program_stream_map
// 2 BD 1011 1101 private_stream_1
// BE 1011 1110 padding_stream
// 3 BF 1011 1111 private_stream_2
// C0-DF 110x xxxx ISO/IEC 13818-3 or ISO/IEC 11172-3 or
// ISO/IEC 13818-7 or ISO/IEC 14496-3 audio stream
// number x xxxx
// Ex 1110 xxxx ITU-T Rec. H.262 | ISO/IEC 13818-2, ISO/IEC 11172-2,
// ISO/IEC 14496-2 or ITU-T Rec. H.264 | ISO/IEC
// 14496-10 video stream number xxxx
// 3 F0 1111 0000 ECM_stream
// F1 1111 0001 EMM_stream
// 5 F2 1111 0010 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or
// ISO/IEC 13818-6_DSMCC_stream
// 2 F3 1111 0011 ISO/IEC_13522_stream
// 6 F4 1111 0100 ITU-T Rec. H.222.1 type A
// 6 F5 1111 0101 ITU-T Rec. H.222.1 type B
// 6 F6 1111 0110 ITU-T Rec. H.222.1 type C
// 6 F7 1111 0111 ITU-T Rec. H.222.1 type D
// 6 F8 1111 1000 ITU-T Rec. H.222.1 type E
// 7 F9 1111 1001 ancillary_stream
// FA 1111 1010 ISO/IEC14496-1_SL-packetized_stream
// FB 1111 1011 ISO/IEC14496-1_FlexMux_stream
// FC 1111 1100 descriptive data stream
// FD 1111 1101 reserved data stream
// FE 1111 1110 reserved data stream
// 4 FF 1111 1111 program_stream_directory
//
// The notation x means that the values '0' or '1' are both permitted and
// results in the same stream type. The stream number is given by the values
// taken by the x's.
//
// NOTES
// 1 PES packets of type program_stream_map have unique syntax specified
// in 2.5.4.1.
// 2 PES packets of type private_stream_1 and ISO/IEC_13552_stream follow
// the same PES packet syntax as those for ITU-T Rec. H.262 | ISO/IEC
// 13818-2 video and ISO/IEC 13818-3 audio streams.
// 3 PES packets of type private_stream_2, ECM_stream and EMM_stream
// are similar to private_stream_1 except no syntax is specified after
// PES_packet_length field.
// 4 PES packets of type program_stream_directory have a unique syntax
// specified in 2.5.5.
// 5 PES packets of type DSM-CC_stream have a unique syntax specified
// in ISO/IEC 13818- 6.
// 6 This stream_id is associated with stream_type 0x09 in Table 2-29.
// 7 This stream_id is only used in PES packets, which carry data from
// a Program Stream or an ISO/IEC 11172-1 System Stream, in a Transport
// Stream (refer to 2.4.3.7).
#define PADDING_STREAM_ID 0xBE
#define PRIVATE1_AUDIO_STREAM_ID 0xBD
#define PRIVATE2_AUDIO_STREAM_ID 0xBF
#define DEFAULT_VIDEO_STREAM_ID 0xE0 // i.e., stream 0
#define DEFAULT_AUDIO_STREAM_ID 0xC0 // i.e., stream 0
#define IS_AUDIO_STREAM_ID(id) ((id)==0xBD || ((id) >= 0xC0 && (id) <= 0xDF))
#define IS_VIDEO_STREAM_ID(id) ((id) >= 0xE0 && (id) <= 0xEF)
// ------------------------------------------------------------
// Timing info (used in reporting on packets). Initialise to all zeroes...
struct timing
{
uint64_t first_pcr;
uint64_t last_pcr;
int first_pcr_packet;
int last_pcr_packet;
int had_first_pcr; // FALSE until we've started
};
typedef struct timing *timing_p;
#endif // _h222_defns
// Local Variables:
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 2
// End:
// vim: set tabstop=8 shiftwidth=2 expandtab: