FFmpeg: libavformat/mpegts.h Source File

FFmpeg
mpegts.h
Go to the documentation of this file.
1 /*
2  * MPEG-2 transport stream defines
3  * Copyright (c) 2003 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 #ifndef AVFORMAT_MPEGTS_H
23 #define AVFORMAT_MPEGTS_H
24 
25 #include "avformat.h"
26 
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
31 
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
35 
36 /* pids */
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  #define FIRST_OTHER_PID 0x0020
62  #define LAST_OTHER_PID 0x1FFA
63 /* PID 0x1FFB is used by DigiCipher 2/ATSC MGT metadata */
64 /* PID from 0x1FFC to 0x1FFE may be assigned as needed to PMT, elementary
65  * streams and other data tables */
66  #define NULL_PID 0x1FFF /* Null packet (used for fixed bandwidth padding) */
67 
68 /* m2ts pids */
69  #define M2TS_PMT_PID 0x0100
70  #define M2TS_PCR_PID 0x1001
71  #define M2TS_VIDEO_PID 0x1011
72  #define M2TS_AUDIO_START_PID 0x1100
73  #define M2TS_PGSSUB_START_PID 0x1200
74  #define M2TS_TEXTSUB_PID 0x1800
75  #define M2TS_SECONDARY_AUDIO_START_PID 0x1A00
76  #define M2TS_SECONDARY_VIDEO_START_PID 0x1B00
77 
78 /* table ids */
79  #define PAT_TID 0x00 /* Program Association section */
80  #define CAT_TID 0x01 /* Conditional Access section */
81  #define PMT_TID 0x02 /* Program Map section */
82  #define TSDT_TID 0x03 /* Transport Stream Description section */
83 /* TID from 0x04 to 0x3F are reserved */
84  #define M4OD_TID 0x05
85  #define NIT_TID 0x40 /* Network Information section - actual network */
86  #define ONIT_TID 0x41 /* Network Information section - other network */
87  #define SDT_TID 0x42 /* Service Description section - actual TS */
88 /* TID from 0x43 to 0x45 are reserved for future use */
89  #define OSDT_TID 0x46 /* Service Descrition section - other TS */
90 /* TID from 0x47 to 0x49 are reserved for future use */
91  #define BAT_TID 0x4A /* Bouquet Association section */
92  #define UNT_TID 0x4B /* Update Notification Table section */
93  #define DFI_TID 0x4C /* Downloadable Font Info section */
94 /* TID 0x4D is reserved for future use */
95  #define EIT_TID 0x4E /* Event Information section - actual TS */
96  #define OEIT_TID 0x4F /* Event Information section - other TS */
97  #define EITS_START_TID 0x50 /* Event Information section schedule - actual TS */
98  #define EITS_END_TID 0x5F /* Event Information section schedule - actual TS */
99  #define OEITS_START_TID 0x60 /* Event Information section schedule - other TS */
100  #define OEITS_END_TID 0x6F /* Event Information section schedule - other TS */
101  #define TDT_TID 0x70 /* Time Date section */
102  #define RST_TID 0x71 /* Running Status section */
103  #define ST_TID 0x72 /* Stuffing section */
104  #define TOT_TID 0x73 /* Time Offset section */
105  #define AIT_TID 0x74 /* Application Inforamtion section */
106  #define CT_TID 0x75 /* Container section */
107  #define RCT_TID 0x76 /* Related Content section */
108  #define CIT_TID 0x77 /* Content Identifier section */
109  #define MPE_FEC_TID 0x78 /* MPE-FEC section */
110  #define RPNT_TID 0x79 /* Resolution Provider Notification section */
111  #define MPE_IFEC_TID 0x7A /* MPE-IFEC section */
112  #define PROTMT_TID 0x7B /* Protection Message section */
113 /* TID from 0x7C to 0x7D are reserved for future use */
114  #define DIT_TID 0x7E /* Discontinuity Information section */
115  #define SIT_TID 0x7F /* Selection Information section */
116 /* TID from 0x80 to 0xFE are user defined */
117 /* TID 0xFF is reserved */
118 
119  #define STREAM_TYPE_VIDEO_MPEG1 0x01
120  #define STREAM_TYPE_VIDEO_MPEG2 0x02
121  #define STREAM_TYPE_AUDIO_MPEG1 0x03
122  #define STREAM_TYPE_AUDIO_MPEG2 0x04
123  #define STREAM_TYPE_PRIVATE_SECTION 0x05
124  #define STREAM_TYPE_PRIVATE_DATA 0x06
125  #define STREAM_TYPE_AUDIO_AAC 0x0f
126  #define STREAM_TYPE_AUDIO_AAC_LATM 0x11
127  #define STREAM_TYPE_VIDEO_MPEG4 0x10
128  #define STREAM_TYPE_METADATA 0x15
129  #define STREAM_TYPE_VIDEO_H264 0x1b
130  #define STREAM_TYPE_VIDEO_HEVC 0x24
131  #define STREAM_TYPE_VIDEO_CAVS 0x42
132  #define STREAM_TYPE_VIDEO_AVS2 0xd2
133  #define STREAM_TYPE_VIDEO_AVS3 0xd4
134  #define STREAM_TYPE_VIDEO_VC1 0xea
135  #define STREAM_TYPE_VIDEO_DIRAC 0xd1
136 
137  #define STREAM_TYPE_AUDIO_AC3 0x81
138  #define STREAM_TYPE_AUDIO_DTS 0x82
139  #define STREAM_TYPE_AUDIO_TRUEHD 0x83
140  #define STREAM_TYPE_AUDIO_EAC3 0x87
141 
142 /* ISO/IEC 13818-1 Table 2-22 */
143  #define STREAM_ID_PROGRAM_STREAM_MAP 0xbc
144  #define STREAM_ID_PRIVATE_STREAM_1 0xbd
145  #define STREAM_ID_PADDING_STREAM 0xbe
146  #define STREAM_ID_PRIVATE_STREAM_2 0xbf
147  #define STREAM_ID_AUDIO_STREAM_0 0xc0
148  #define STREAM_ID_VIDEO_STREAM_0 0xe0
149  #define STREAM_ID_ECM_STREAM 0xf0
150  #define STREAM_ID_EMM_STREAM 0xf1
151  #define STREAM_ID_DSMCC_STREAM 0xf2
152  #define STREAM_ID_TYPE_E_STREAM 0xf8
153  #define STREAM_ID_METADATA_STREAM 0xfc
154  #define STREAM_ID_EXTENDED_STREAM_ID 0xfd
155  #define STREAM_ID_PROGRAM_STREAM_DIRECTORY 0xff
156 
157 /* ISO/IEC 13818-1 Table 2-45 */
158  #define VIDEO_STREAM_DESCRIPTOR 0x02
159  #define REGISTRATION_DESCRIPTOR 0x05
160  #define ISO_639_LANGUAGE_DESCRIPTOR 0x0a
161  #define IOD_DESCRIPTOR 0x1d
162  #define SL_DESCRIPTOR 0x1e
163  #define FMC_DESCRIPTOR 0x1f
164  #define METADATA_DESCRIPTOR 0x26
165  #define METADATA_STD_DESCRIPTOR 0x27
166 
167 typedef struct MpegTSContext MpegTSContext;
168 
169 MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext *s);
170 int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
171  const uint8_t *buf, int len);
172 void avpriv_mpegts_parse_close(MpegTSContext *ts);
173 
174  typedef struct SLConfigDescr {
175   int use_au_start;
176   int use_au_end;
177   int use_rand_acc_pt;
178   int use_padding;
179   int use_timestamps;
180   int use_idle;
181   int timestamp_res;
182   int timestamp_len;
183   int ocr_len;
184   int au_len;
185   int inst_bitrate_len;
186   int degr_prior_len;
187   int au_seq_num_len;
188   int packet_seq_num_len;
189 } SLConfigDescr;
190 
191  typedef struct Mp4Descr {
192   int es_id;
193   int dec_config_descr_len;
194   uint8_t *dec_config_descr;
195   SLConfigDescr sl;
196 } Mp4Descr;
197 
198 /*
199  * ETSI 300 468 descriptor 0x6A(AC-3)
200  * Refer to: ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
201  */
202  typedef struct DVBAC3Descriptor {
203   uint8_t component_type_flag;
204   uint8_t bsid_flag;
205   uint8_t mainid_flag;
206   uint8_t asvc_flag;
207   uint8_t reserved_flags;
208   uint8_t component_type;
209   uint8_t bsid;
210   uint8_t mainid;
211   uint8_t asvc;
212 } DVBAC3Descriptor;
213 
214 /**
215  * Parse an MPEG-2 descriptor
216  * @param[in] fc Format context (used for logging only)
217  * @param st Stream
218  * @param stream_type STREAM_TYPE_xxx
219  * @param pp Descriptor buffer pointer
220  * @param desc_list_end End of buffer
221  * @return <0 to stop processing
222  */
223 int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type,
224  const uint8_t **pp, const uint8_t *desc_list_end,
225  Mp4Descr *mp4_descr, int mp4_descr_count, int pid,
226  MpegTSContext *ts);
227 
228 /**
229  * Check presence of H264 startcode
230  * @return <0 to stop processing
231  */
232 int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt);
233 
234 #endif /* AVFORMAT_MPEGTS_H */
SLConfigDescr::au_seq_num_len
int au_seq_num_len
Definition: mpegts.h:187
DVBAC3Descriptor::component_type
uint8_t component_type
Definition: mpegts.h:208
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:551
DVBAC3Descriptor::reserved_flags
uint8_t reserved_flags
Definition: mpegts.h:207
SLConfigDescr::use_idle
int use_idle
Definition: mpegts.h:180
SLConfigDescr::inst_bitrate_len
int inst_bitrate_len
Definition: mpegts.h:185
avpriv_mpegts_parse_open
MpegTSContext * avpriv_mpegts_parse_open(AVFormatContext *s)
Definition: mpegts.c:3375
SLConfigDescr::use_padding
int use_padding
Definition: mpegts.h:178
DVBAC3Descriptor::asvc_flag
uint8_t asvc_flag
Definition: mpegts.h:206
SLConfigDescr::use_rand_acc_pt
int use_rand_acc_pt
Definition: mpegts.h:177
SLConfigDescr::timestamp_len
int timestamp_len
Definition: mpegts.h:182
avpriv_mpegts_parse_packet
int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
Definition: mpegts.c:3397
pkt
AVPacket * pkt
Definition: movenc.c:59
Mp4Descr::sl
SLConfigDescr sl
Definition: mpegts.h:195
s
#define s(width, name)
Definition: cbs_vp9.c:256
SLConfigDescr::degr_prior_len
int degr_prior_len
Definition: mpegts.h:186
DVBAC3Descriptor::component_type_flag
uint8_t component_type_flag
Definition: mpegts.h:203
AVFormatContext
Format I/O context.
Definition: avformat.h:1104
Mp4Descr::es_id
int es_id
Definition: mpegts.h:192
Mp4Descr::dec_config_descr_len
int dec_config_descr_len
Definition: mpegts.h:193
SLConfigDescr::ocr_len
int ocr_len
Definition: mpegts.h:183
SLConfigDescr::packet_seq_num_len
int packet_seq_num_len
Definition: mpegts.h:188
SLConfigDescr::use_au_start
int use_au_start
Definition: mpegts.h:175
avpriv_mpegts_parse_close
void avpriv_mpegts_parse_close(MpegTSContext *ts)
Definition: mpegts.c:3422
DVBAC3Descriptor::bsid_flag
uint8_t bsid_flag
Definition: mpegts.h:204
MpegTSContext
Definition: mpegts.c:130
SLConfigDescr::use_au_end
int use_au_end
Definition: mpegts.h:176
len
int len
Definition: vorbis_enc_data.h:426
DVBAC3Descriptor::asvc
uint8_t asvc
Definition: mpegts.h:211
SLConfigDescr::au_len
int au_len
Definition: mpegts.h:184
ff_check_h264_startcode
int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
Check presence of H264 startcode.
Definition: mpegtsenc.c:1756
AVStream
Stream structure.
Definition: avformat.h:838
Mp4Descr::dec_config_descr
uint8_t * dec_config_descr
Definition: mpegts.h:194
SLConfigDescr::use_timestamps
int use_timestamps
Definition: mpegts.h:179
avformat.h
DVBAC3Descriptor
Definition: mpegts.h:202
SLConfigDescr::timestamp_res
int timestamp_res
Definition: mpegts.h:181
DVBAC3Descriptor::mainid
uint8_t mainid
Definition: mpegts.h:210
DVBAC3Descriptor::bsid
uint8_t bsid
Definition: mpegts.h:209
AVPacket
This structure stores compressed data.
Definition: packet.h:351
ff_parse_mpeg2_descriptor
int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type, const uint8_t **pp, const uint8_t *desc_list_end, Mp4Descr *mp4_descr, int mp4_descr_count, int pid, MpegTSContext *ts)
Parse an MPEG-2 descriptor.
Definition: mpegts.c:1810
Mp4Descr
Definition: mpegts.h:191
SLConfigDescr
Definition: mpegts.h:174
DVBAC3Descriptor::mainid_flag
uint8_t mainid_flag
Definition: mpegts.h:205

Generated on Tue Feb 28 2023 21:34:07 for FFmpeg by   doxygen 1.8.17

AltStyle によって変換されたページ (->オリジナル) /