2 * MPEG-2 transport stream defines
3 * Copyright (c) 2003 Fabrice Bellard
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef AVFORMAT_MPEGTS_H
23 #define AVFORMAT_MPEGTS_H
27 #define TS_FEC_PACKET_SIZE 204
28 #define TS_DVHS_PACKET_SIZE 192
29 #define TS_PACKET_SIZE 188
30 #define TS_MAX_PACKET_SIZE 204
32 #define NB_PID_MAX 8192
33 #define USUAL_SECTION_SIZE 1024 /* except EIT which is limited to 4096 */
34 #define MAX_SECTION_SIZE 4096
37 #define PAT_PID 0x0000 /* Program Association Table */
38 #define CAT_PID 0x0001 /* Conditional Access Table */
39 #define TSDT_PID 0x0002 /* Transport Stream Description Table */
40 #define IPMP_PID 0x0003
41 /* PID from 0x0004 to 0x000F are reserved */
42 #define NIT_PID 0x0010 /* Network Information Table */
43 #define SDT_PID 0x0011 /* Service Description Table */
44 #define BAT_PID 0x0011 /* Bouquet Association Table */
45 #define EIT_PID 0x0012 /* Event Information Table */
46 #define RST_PID 0x0013 /* Running Status Table */
47 #define TDT_PID 0x0014 /* Time and Date Table */
48 #define TOT_PID 0x0014
49 #define NET_SYNC_PID 0x0015
50 #define RNT_PID 0x0016 /* RAR Notification Table */
51 /* PID from 0x0017 to 0x001B are reserved for future use */
52 /* PID value 0x001C allocated to link-local inband signalling shall not be
53 * used on any broadcast signals. It shall only be used between devices in a
54 * controlled environment. */
55 #define LINK_LOCAL_PID 0x001C
56 #define MEASUREMENT_PID 0x001D
57 #define DIT_PID 0x001E /* Discontinuity Information Table */
58 #define SIT_PID 0x001F /* Selection Information Table */
59 /* PID from 0x0020 to 0x1FFA may be assigned as needed to PMT, elementary
60 * streams and other data tables */
61 /* PID 0x1FFB is used by DigiCipher 2/ATSC MGT metadata */
62 /* PID from 0x1FFC to 0x1FFE may be assigned as needed to PMT, elementary
63 * streams and other data tables */
64 #define NULL_PID 0x1FFF /* Null packet (used for fixed bandwidth padding) */
67 #define PAT_TID 0x00 /* Program Association section */
68 #define CAT_TID 0x01 /* Conditional Access section */
69 #define PMT_TID 0x02 /* Program Map section */
70 #define TSDT_TID 0x03 /* Transport Stream Description section */
71 /* TID from 0x04 to 0x3F are reserved */
73 #define NIT_TID 0x40 /* Network Information section - actual network */
74 #define ONIT_TID 0x41 /* Network Information section - other network */
75 #define SDT_TID 0x42 /* Service Description section - actual TS */
76 /* TID from 0x43 to 0x45 are reserved for future use */
77 #define OSDT_TID 0x46 /* Service Descrition section - other TS */
78 /* TID from 0x47 to 0x49 are reserved for future use */
79 #define BAT_TID 0x4A /* Bouquet Association section */
80 #define UNT_TID 0x4B /* Update Notification Table section */
81 #define DFI_TID 0x4C /* Downloadable Font Info section */
82 /* TID 0x4D is reserved for future use */
83 #define EIT_TID 0x4E /* Event Information section - actual TS */
84 #define OEIT_TID 0x4F /* Event Information section - other TS */
85 #define EITS_START_TID 0x50 /* Event Information section schedule - actual TS */
86 #define EITS_END_TID 0x5F /* Event Information section schedule - actual TS */
87 #define OEITS_START_TID 0x60 /* Event Information section schedule - other TS */
88 #define OEITS_END_TID 0x6F /* Event Information section schedule - other TS */
89 #define TDT_TID 0x70 /* Time Date section */
90 #define RST_TID 0x71 /* Running Status section */
91 #define ST_TID 0x72 /* Stuffing section */
92 #define TOT_TID 0x73 /* Time Offset section */
93 #define AIT_TID 0x74 /* Application Inforamtion section */
94 #define CT_TID 0x75 /* Container section */
95 #define RCT_TID 0x76 /* Related Content section */
96 #define CIT_TID 0x77 /* Content Identifier section */
97 #define MPE_FEC_TID 0x78 /* MPE-FEC section */
98 #define RPNT_TID 0x79 /* Resolution Provider Notification section */
99 #define MPE_IFEC_TID 0x7A /* MPE-IFEC section */
100 #define PROTMT_TID 0x7B /* Protection Message section */
101 /* TID from 0x7C to 0x7D are reserved for future use */
102 #define DIT_TID 0x7E /* Discontinuity Information section */
103 #define SIT_TID 0x7F /* Selection Information section */
104 /* TID from 0x80 to 0xFE are user defined */
105 /* TID 0xFF is reserved */
107 #define STREAM_TYPE_VIDEO_MPEG1 0x01
108 #define STREAM_TYPE_VIDEO_MPEG2 0x02
109 #define STREAM_TYPE_AUDIO_MPEG1 0x03
110 #define STREAM_TYPE_AUDIO_MPEG2 0x04
111 #define STREAM_TYPE_PRIVATE_SECTION 0x05
112 #define STREAM_TYPE_PRIVATE_DATA 0x06
113 #define STREAM_TYPE_AUDIO_AAC 0x0f
114 #define STREAM_TYPE_AUDIO_AAC_LATM 0x11
115 #define STREAM_TYPE_VIDEO_MPEG4 0x10
116 #define STREAM_TYPE_METADATA 0x15
117 #define STREAM_TYPE_VIDEO_H264 0x1b
118 #define STREAM_TYPE_VIDEO_HEVC 0x24
119 #define STREAM_TYPE_VIDEO_CAVS 0x42
120 #define STREAM_TYPE_VIDEO_VC1 0xea
121 #define STREAM_TYPE_VIDEO_DIRAC 0xd1
123 #define STREAM_TYPE_AUDIO_AC3 0x81
124 #define STREAM_TYPE_AUDIO_DTS 0x82
125 #define STREAM_TYPE_AUDIO_TRUEHD 0x83
126 #define STREAM_TYPE_AUDIO_EAC3 0x87
128 typedef struct MpegTSContext MpegTSContext;
130 MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s);
131 int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
132 const uint8_t *buf, int len);
133 void avpriv_mpegts_parse_close(MpegTSContext *ts);
135 typedef struct SLConfigDescr {
146 int inst_bitrate_len;
149 int packet_seq_num_len;
152 typedef struct Mp4Descr {
154 int dec_config_descr_len;
155 uint8_t *dec_config_descr;
160 * Parse an MPEG-2 descriptor
161 * @param[in] fc Format context (used for logging only)
163 * @param stream_type STREAM_TYPE_xxx
164 * @param pp Descriptor buffer pointer
165 * @param desc_list_end End of buffer
166 * @return <0 to stop processing
168 int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type,
169 const uint8_t **pp, const uint8_t *desc_list_end,
170 Mp4Descr *mp4_descr, int mp4_descr_count, int pid,
174 * Check presence of H264 startcode
175 * @return <0 to stop processing
177 int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt);
179 #endif /* AVFORMAT_MPEGTS_H */