1 /* 2 * Datastructures and definitions useful for working with H.222 data, 3 * whether it be Transport Stream or Program Stream 4 * 5 * ***** BEGIN LICENSE BLOCK ***** 6 * Version: MPL 1.1 7 * 8 * The contents of this file are subject to the Mozilla Public License Version 9 * 1.1 (the "License"); you may not use this file except in compliance with 10 * the License. You may obtain a copy of the License at 11 * http://www.mozilla.org/MPL/ 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 15 * for the specific language governing rights and limitations under the 16 * License. 17 * 18 * The Original Code is the MPEG TS, PS and ES tools. 19 * 20 * The Initial Developer of the Original Code is Amino Communications Ltd. 21 * Portions created by the Initial Developer are Copyright (C) 2008 22 * the Initial Developer. All Rights Reserved. 23 * 24 * Contributor(s): 25 * Amino Communications Ltd, Swavesey, Cambridge UK 26 * 27 * ***** END LICENSE BLOCK ***** 28 */ 29 30 #ifndef _h222_defns 31 #define _h222_defns 32 33 // Include our function definition(s) 34 // -- this is actually just the function for returning a string 35 // representing a stream type (according to the following table), 36 // which *used* to be a macro, defined in this header file. 37 #include "h222_fns.h" 38 39 // ------------------------------------------------------------ 40 // H.222.0 Table 2-29: Stream type assignments, as amended by 41 // H.222.0 (2000) Amendment 3 42 // 43 // Value Description 44 // ===== ============================ 45 // 00 ITU-T | ISO/IEC Reserved 46 // 01 ISO/IEC 11172-2 Video 47 // 02 ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 48 // constrained parameter video stream 49 // 03 ISO/IEC 11172-3 Audio 50 // 04 ISO/IEC 13818-3 Audio 51 // 05 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections 52 // 06 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing 53 // private data -- traditionally DVB Dolby (AC-3) 54 // 07 ISO/IEC 13522 MHEG 55 // 08 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM CC 56 // 09 ITU-T Rec. H.222.1 57 // 0A ISO/IEC 13818-6 type A 58 // 0B ISO/IEC 13818-6 type B 59 // 0C ISO/IEC 13818-6 type C 60 // 0D ISO/IEC 13818-6 type D 61 // 0E ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary 62 // 0F ISO/IEC 13818-7 Audio with ADTS transport syntax 63 // 10 ISO/IEC 14496-2 Visual 64 // 11 ISO/IEC 14496-3 Audio with the LATM transport syntax as defined 65 // in ISO/IEC 14496-3 / AMD 1 66 // 12 ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried 67 // in PES packets 68 // 13 ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried 69 // in ISO/IEC14496_sections. 70 // 14 ISO/IEC 13818-6 Synchronized Download Protocol 71 // 15 Metadata carried in PES packets 72 // 16 Metadata carried in metadata_sections 73 // 17 Metadata carried in ISO/IEC 13818-6 Data Carousel 74 // 18 Metadata carried in ISO/IEC 13818-6 Object Carousel 75 // 19 Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol 76 // 1A IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP) 77 // 1B AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10 78 // Video 79 // 1C-7E ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved 80 // 7F IPMP stream 81 // 80-FF User Private 82 // 81 Traditionally ATSC Dolby (AC-3) 83 84 #define MPEG1_VIDEO_STREAM_TYPE 0x01 85 #define MPEG2_VIDEO_STREAM_TYPE 0x02 // H.262 86 #define AVC_VIDEO_STREAM_TYPE 0x1B // MPEG-4 part10 - H.264 87 #define AVS_VIDEO_STREAM_TYPE 0x42 // AVS -- Chinese standard 88 #define DVB_DOLBY_AUDIO_STREAM_TYPE 0x06 // [1] 89 #define ATSC_DOLBY_AUDIO_STREAM_TYPE 0x81 // [1] 90 #define MPEG2_AUDIO_STREAM_TYPE 0x04 91 #define MPEG1_AUDIO_STREAM_TYPE 0x03 92 #define ADTS_AUDIO_STREAM_TYPE 0x0F // AAC ADTS 93 #define MPEG4_PART2_VIDEO_STREAM_TYPE 0x10 94 #define LATM_AUDIO_STREAM_TYPE 0x11 // How much do we support this? 95 96 #define DOLBY_DVB_STREAM_TYPE 0x06 // [1] 97 #define DOLBY_ATSC_STREAM_TYPE 0x81 // [1] 98 99 // [1] In DVB (the European transmission standard) Dolby (AC-3) audio is 100 // carried in stream type 0x06, but in ATSC (the USA standard), stream 101 // type 0x81 is used. Note that both of these are essentially just saying 102 // that the data is a private stream, so technically one needs to set 103 // descriptors in the PMT as well to say we really mean Dolby (AC-3) 104 // Also, in DVB, other types of stream can be in 0x06. 105 106 #define IS_VIDEO_STREAM_TYPE(s) ((s)==MPEG1_VIDEO_STREAM_TYPE || \ 107 (s)==MPEG2_VIDEO_STREAM_TYPE || \ 108 (s)==AVC_VIDEO_STREAM_TYPE || \ 109 (s)==AVS_VIDEO_STREAM_TYPE || \ 110 (s)==MPEG4_PART2_VIDEO_STREAM_TYPE) 111 112 // Although I include Dolby in the "standard" audio types, beware that the 113 // stream type usage is not specified by H.222 itself - it is "convention" 114 // (albeit a standardised convention) how private streams are used to transmit 115 // Dolby. There is a case to be made that, at any one time, we should not 116 // recognise *both* potential Dolby stream types, but just one or the other 117 // (see [1] above) according to the standard the user is expecting. On the 118 // other hand, practice seems to be to use the stream types only in the 119 // expected manner. 120 121 #define IS_DOLBY_STREAM_TYPE(s) ((s)==DOLBY_DVB_STREAM_TYPE || \ 122 (s)==DOLBY_ATSC_STREAM_TYPE) 123 124 #define IS_AUDIO_STREAM_TYPE(s) ((s)==MPEG1_AUDIO_STREAM_TYPE || \ 125 (s)==MPEG2_AUDIO_STREAM_TYPE || \ 126 (s)==ADTS_AUDIO_STREAM_TYPE || \ 127 (s)==LATM_AUDIO_STREAM_TYPE || \ 128 IS_DOLBY_STREAM_TYPE((s))) 129 130 // ------------------------------------------------------------ 131 // Stream ids, as used in PES headers 132 // H.222.0 Table 2-18: Stream_id assignments, as amended by 133 // H.222.0 (2000) Amendment 3 134 // 135 // Note Hex stream_id stream coding 136 // ==== === ========= ============= 137 // 1 BC 1011 1100 program_stream_map 138 // 2 BD 1011 1101 private_stream_1 139 // BE 1011 1110 padding_stream 140 // 3 BF 1011 1111 private_stream_2 141 // C0-DF 110x xxxx ISO/IEC 13818-3 or ISO/IEC 11172-3 or 142 // ISO/IEC 13818-7 or ISO/IEC 14496-3 audio stream 143 // number x xxxx 144 // Ex 1110 xxxx ITU-T Rec. H.262 | ISO/IEC 13818-2, ISO/IEC 11172-2, 145 // ISO/IEC 14496-2 or ITU-T Rec. H.264 | ISO/IEC 146 // 14496-10 video stream number xxxx 147 // 3 F0 1111 0000 ECM_stream 148 // F1 1111 0001 EMM_stream 149 // 5 F2 1111 0010 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or 150 // ISO/IEC 13818-6_DSMCC_stream 151 // 2 F3 1111 0011 ISO/IEC_13522_stream 152 // 6 F4 1111 0100 ITU-T Rec. H.222.1 type A 153 // 6 F5 1111 0101 ITU-T Rec. H.222.1 type B 154 // 6 F6 1111 0110 ITU-T Rec. H.222.1 type C 155 // 6 F7 1111 0111 ITU-T Rec. H.222.1 type D 156 // 6 F8 1111 1000 ITU-T Rec. H.222.1 type E 157 // 7 F9 1111 1001 ancillary_stream 158 // FA 1111 1010 ISO/IEC14496-1_SL-packetized_stream 159 // FB 1111 1011 ISO/IEC14496-1_FlexMux_stream 160 // FC 1111 1100 descriptive data stream 161 // FD 1111 1101 reserved data stream 162 // FE 1111 1110 reserved data stream 163 // 4 FF 1111 1111 program_stream_directory 164 // 165 // The notation x means that the values '0' or '1' are both permitted and 166 // results in the same stream type. The stream number is given by the values 167 // taken by the x's. 168 // 169 // NOTES 170 // 1 PES packets of type program_stream_map have unique syntax specified 171 // in 2.5.4.1. 172 // 2 PES packets of type private_stream_1 and ISO/IEC_13552_stream follow 173 // the same PES packet syntax as those for ITU-T Rec. H.262 | ISO/IEC 174 // 13818-2 video and ISO/IEC 13818-3 audio streams. 175 // 3 PES packets of type private_stream_2, ECM_stream and EMM_stream 176 // are similar to private_stream_1 except no syntax is specified after 177 // PES_packet_length field. 178 // 4 PES packets of type program_stream_directory have a unique syntax 179 // specified in 2.5.5. 180 // 5 PES packets of type DSM-CC_stream have a unique syntax specified 181 // in ISO/IEC 13818- 6. 182 // 6 This stream_id is associated with stream_type 0x09 in Table 2-29. 183 // 7 This stream_id is only used in PES packets, which carry data from 184 // a Program Stream or an ISO/IEC 11172-1 System Stream, in a Transport 185 // Stream (refer to 2.4.3.7). 186 187 #define PADDING_STREAM_ID 0xBE 188 #define PRIVATE1_AUDIO_STREAM_ID 0xBD 189 #define PRIVATE2_AUDIO_STREAM_ID 0xBF 190 #define DEFAULT_VIDEO_STREAM_ID 0xE0 // i.e., stream 0 191 #define DEFAULT_AUDIO_STREAM_ID 0xC0 // i.e., stream 0 192 193 #define IS_AUDIO_STREAM_ID(id) ((id)==0xBD || ((id) >= 0xC0 && (id) <= 0xDF)) 194 #define IS_VIDEO_STREAM_ID(id) ((id) >= 0xE0 && (id) <= 0xEF) 195 196 197 // ------------------------------------------------------------ 198 // Timing info (used in reporting on packets). Initialise to all zeroes... 199 struct timing 200 { 201 uint64_t first_pcr; 202 uint64_t last_pcr; 203 int first_pcr_packet; 204 int last_pcr_packet; 205 int had_first_pcr; // FALSE until we've started 206 }; 207 typedef struct timing *timing_p; 208 209 #endif // _h222_defns 210 211 // Local Variables: 212 // tab-width: 8 213 // indent-tabs-mode: nil 214 // c-basic-offset: 2 215 // End: 216 // vim: set tabstop=8 shiftwidth=2 expandtab: 217