1 /* GStreamer Matroska muxer/demuxer
2 * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * matroska-ids.h: matroska file/stream data IDs
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef __GST_MATROSKA_IDS_H__
23 #define __GST_MATROSKA_IDS_H__
30 * Matroska element IDs. max. 32-bit.
33 /* toplevel segment */
34 #define GST_MATROSKA_ID_SEGMENT 0x18538067
36 /* matroska top-level master IDs */
37 #define GST_MATROSKA_ID_INFO 0x1549A966
38 #define GST_MATROSKA_ID_TRACKS 0x1654AE6B
39 #define GST_MATROSKA_ID_CUES 0x1C53BB6B
40 #define GST_MATROSKA_ID_TAGS 0x1254C367
41 #define GST_MATROSKA_ID_SEEKHEAD 0x114D9B74
42 #define GST_MATROSKA_ID_CLUSTER 0x1F43B675
44 /* IDs in the info master */
45 #define GST_MATROSKA_ID_TIMECODESCALE 0x2AD7B1
46 #define GST_MATROSKA_ID_DURATION 0x4489
47 #define GST_MATROSKA_ID_WRITINGAPP 0x5741
48 #define GST_MATROSKA_ID_MUXINGAPP 0x4D80
49 #define GST_MATROSKA_ID_DATEUTC 0x4461
50 #define GST_MATROSKA_ID_SEGMENTUID 0x73A4
52 /* ID in the tracks master */
53 #define GST_MATROSKA_ID_TRACKENTRY 0xAE
55 /* IDs in the trackentry master */
56 #define GST_MATROSKA_ID_TRACKNUMBER 0xD7
57 #define GST_MATROSKA_ID_TRACKUID 0x73C5
58 #define GST_MATROSKA_ID_TRACKTYPE 0x83
59 #define GST_MATROSKA_ID_TRACKAUDIO 0xE1
60 #define GST_MATROSKA_ID_TRACKVIDEO 0xE0
61 #define GST_MATROSKA_ID_CODECID 0x86
62 #define GST_MATROSKA_ID_CODECPRIVATE 0x63A2
63 #define GST_MATROSKA_ID_CODECNAME 0x258688
64 #define GST_MATROSKA_ID_CODECINFOURL 0x3B4040
65 #define GST_MATROSKA_ID_CODECDOWNLOADURL 0x26B240
66 #define GST_MATROSKA_ID_TRACKNAME 0x536E
67 #define GST_MATROSKA_ID_TRACKLANGUAGE 0x22B59C
68 #define GST_MATROSKA_ID_TRACKFLAGENABLED 0xB9
69 #define GST_MATROSKA_ID_TRACKFLAGDEFAULT 0x88
70 #define GST_MATROSKA_ID_TRACKFLAGLACING 0x9C
71 #define GST_MATROSKA_ID_TRACKMINCACHE 0x6DE7
72 #define GST_MATROSKA_ID_TRACKMAXCACHE 0x6DF8
73 #define GST_MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383
74 #define GST_MATROSKA_ID_CONTENTENCODINGS 0x6D80
76 /* IDs in the trackvideo master */
77 #define GST_MATROSKA_ID_VIDEOFRAMERATE 0x2383E3
78 #define GST_MATROSKA_ID_VIDEODISPLAYWIDTH 0x54B0
79 #define GST_MATROSKA_ID_VIDEODISPLAYHEIGHT 0x54BA
80 #define GST_MATROSKA_ID_VIDEOPIXELWIDTH 0xB0
81 #define GST_MATROSKA_ID_VIDEOPIXELHEIGHT 0xBA
82 #define GST_MATROSKA_ID_VIDEOFLAGINTERLACED 0x9A
83 #define GST_MATROSKA_ID_VIDEOSTEREOMODE 0x53B9
84 #define GST_MATROSKA_ID_VIDEOASPECTRATIO 0x54B3
85 #define GST_MATROSKA_ID_VIDEOCOLOURSPACE 0x2EB524
87 /* IDs in the trackaudio master */
88 #define GST_MATROSKA_ID_AUDIOSAMPLINGFREQ 0xB5
89 #define GST_MATROSKA_ID_AUDIOBITDEPTH 0x6264
90 #define GST_MATROSKA_ID_AUDIOCHANNELS 0x9F
92 /* ID in the cues master */
93 #define GST_MATROSKA_ID_POINTENTRY 0xBB
95 /* IDs in the pointentry master */
96 #define GST_MATROSKA_ID_CUETIME 0xB3
97 #define GST_MATROSKA_ID_CUETRACKPOSITION 0xB7
99 /* IDs in the cuetrackposition master */
100 #define GST_MATROSKA_ID_CUETRACK 0xF7
101 #define GST_MATROSKA_ID_CUECLUSTERPOSITION 0xF1
103 /* IDs in the tags master */
104 #define GST_MATROSKA_ID_TAG 0x7373
106 /* in the tag master */
107 #define GST_MATROSKA_ID_SIMPLETAG 0x67C8
109 /* in the simpletag master */
110 #define GST_MATROSKA_ID_TAGNAME 0x45A3
111 #define GST_MATROSKA_ID_TAGSTRING 0x4487
113 /* IDs in the seekhead master */
114 #define GST_MATROSKA_ID_SEEKENTRY 0x4DBB
116 /* IDs in the seekpoint master */
117 #define GST_MATROSKA_ID_SEEKID 0x53AB
118 #define GST_MATROSKA_ID_SEEKPOSITION 0x53AC
120 /* IDs in the cluster master */
121 #define GST_MATROSKA_ID_CLUSTERTIMECODE 0xE7
122 #define GST_MATROSKA_ID_BLOCKGROUP 0xA0
123 #define GST_MATROSKA_ID_SIMPLEBLOCK 0xA3
124 #define GST_MATROSKA_ID_REFERENCEBLOCK 0xFB
126 /* IDs in the blockgroup master */
127 #define GST_MATROSKA_ID_BLOCK 0xA1
128 #define GST_MATROSKA_ID_BLOCKDURATION 0x9B
130 /* IDs in the contentencodings master */
131 #define GST_MATROSKA_ID_CONTENTENCODING 0x6240
133 /* IDS IN THE CONTENTENCODING MASTER */
134 #define GST_MATROSKA_ID_CONTENTENCODINGORDER 0X5031
135 #define GST_MATROSKA_ID_CONTENTENCODINGSCOPE 0X5032
136 #define GST_MATROSKA_ID_CONTENTENCODINGTYPE 0X5033
137 #define GST_MATROSKA_ID_CONTENTCOMPRESSION 0X5034
138 #define GST_MATROSKA_ID_CONTENTENCRYPTION 0X5035
140 /* IDS IN THE CONTENTCOMPRESSION MASTER */
141 #define GST_MATROSKA_ID_CONTENTCOMPALGO 0X4254
142 #define GST_MATROSKA_ID_CONTENTCOMPSETTINGS 0X4255
146 * Matroska Codec IDs. Strings.
149 #define GST_MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC "V_MS/VFW/FOURCC"
150 #define GST_MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED "V_UNCOMPRESSED"
151 #define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_SP "V_MPEG4/ISO/SP"
152 #define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP "V_MPEG4/ISO/ASP"
153 #define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AP "V_MPEG4/ISO/AP"
154 #define GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AVC "V_MPEG4/ISO/AVC"
155 #define GST_MATROSKA_CODEC_ID_VIDEO_MSMPEG4V3 "V_MPEG4/MS/V3"
156 #define GST_MATROSKA_CODEC_ID_VIDEO_MPEG1 "V_MPEG1"
157 #define GST_MATROSKA_CODEC_ID_VIDEO_MPEG2 "V_MPEG2"
158 #define GST_MATROSKA_CODEC_ID_VIDEO_MJPEG "V_MJPEG"
159 #define GST_MATROSKA_CODEC_ID_VIDEO_REALVIDEO1 "V_REAL/RV10"
160 #define GST_MATROSKA_CODEC_ID_VIDEO_REALVIDEO2 "V_REAL/RV20"
161 #define GST_MATROSKA_CODEC_ID_VIDEO_REALVIDEO3 "V_REAL/RV30"
162 #define GST_MATROSKA_CODEC_ID_VIDEO_REALVIDEO4 "V_REAL/RV40"
163 #define GST_MATROSKA_CODEC_ID_VIDEO_THEORA "V_THEORA"
164 #define GST_MATROSKA_CODEC_ID_VIDEO_DIRAC "V_DIRAC"
165 /* TODO: Quicktime */
167 #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG1_L1 "A_MPEG/L1"
168 #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG1_L2 "A_MPEG/L2"
169 #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG1_L3 "A_MPEG/L3"
170 #define GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE "A_PCM/INT/BIG"
171 #define GST_MATROSKA_CODEC_ID_AUDIO_PCM_INT_LE "A_PCM/INT/LIT"
172 #define GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT "A_PCM/FLOAT/IEEE"
173 #define GST_MATROSKA_CODEC_ID_AUDIO_AC3 "A_AC3"
174 #define GST_MATROSKA_CODEC_ID_AUDIO_DTS "A_DTS"
175 #define GST_MATROSKA_CODEC_ID_AUDIO_VORBIS "A_VORBIS"
176 #define GST_MATROSKA_CODEC_ID_AUDIO_FLAC "A_FLAC"
177 #define GST_MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
178 #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG2 "A_AAC/MPEG2/"
179 #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG4 "A_AAC/MPEG4/"
180 #define GST_MATROSKA_CODEC_ID_AUDIO_TTA "A_TTA1"
181 #define GST_MATROSKA_CODEC_ID_AUDIO_WAVPACK4 "A_WAVPACK4"
182 #define GST_MATROSKA_CODEC_ID_AUDIO_REAL_14_4 "A_REAL/28_8"
183 #define GST_MATROSKA_CODEC_ID_AUDIO_REAL_28_8 "A_REAL/28_8"
184 #define GST_MATROSKA_CODEC_ID_AUDIO_REAL_COOK "A_REAL/COOK"
185 #define GST_MATROSKA_CODEC_ID_AUDIO_REAL_SIPR "A_REAL/SIPR"
186 #define GST_MATROSKA_CODEC_ID_AUDIO_REAL_RALF "A_REAL/RALF"
187 #define GST_MATROSKA_CODEC_ID_AUDIO_REAL_ATRC "A_REAL/ATRC"
189 /* TODO: AC3-9/10 (?), Musepack, Quicktime */
191 #define GST_MATROSKA_CODEC_ID_SUBTITLE_UTF8 "S_TEXT/UTF8"
192 #define GST_MATROSKA_CODEC_ID_SUBTITLE_SSA "S_TEXT/SSA"
193 #define GST_MATROSKA_CODEC_ID_SUBTITLE_ASS "S_TEXT/ASS"
194 #define GST_MATROSKA_CODEC_ID_SUBTITLE_USF "S_TEXT/USF"
195 #define GST_MATROSKA_CODEC_ID_SUBTITLE_VOBSUB "S_VOBSUB"
198 * Matrodka tags. Strings.
201 #define GST_MATROSKA_TAG_ID_TITLE "TITLE"
202 #define GST_MATROSKA_TAG_ID_AUTHOR "AUTHOR"
203 #define GST_MATROSKA_TAG_ID_ALBUM "ALBUM"
204 #define GST_MATROSKA_TAG_ID_COMMENTS "COMMENTS"
205 #define GST_MATROSKA_TAG_ID_BITSPS "BITSPS"
206 #define GST_MATROSKA_TAG_ID_ENCODER "ENCODER"
207 #define GST_MATROSKA_TAG_ID_DATE "DATE"
208 #define GST_MATROSKA_TAG_ID_ISRC "ISRC"
209 #define GST_MATROSKA_TAG_ID_COPYRIGHT "COPYRIGHT"
212 * Enumerations for various types (mapping from binary
213 * value to what it actually means).
217 GST_MATROSKA_TRACK_TYPE_VIDEO = 0x1,
218 GST_MATROSKA_TRACK_TYPE_AUDIO = 0x2,
219 GST_MATROSKA_TRACK_TYPE_COMPLEX = 0x3,
220 GST_MATROSKA_TRACK_TYPE_LOGO = 0x10,
221 GST_MATROSKA_TRACK_TYPE_SUBTITLE = 0x11,
222 GST_MATROSKA_TRACK_TYPE_CONTROL = 0x20,
223 } GstMatroskaTrackType;
226 GST_MATROSKA_EYE_MODE_MONO = 0x0,
227 GST_MATROSKA_EYE_MODE_RIGHT = 0x1,
228 GST_MATROSKA_EYE_MODE_LEFT = 0x2,
229 GST_MATROSKA_EYE_MODE_BOTH = 0x3,
230 } GstMatroskaEyeMode;
233 GST_MATROSKA_ASPECT_RATIO_MODE_FREE = 0x0,
234 GST_MATROSKA_ASPECT_RATIO_MODE_KEEP = 0x1,
235 GST_MATROSKA_ASPECT_RATIO_MODE_FIXED = 0x2,
236 } GstMatroskaAspectRatioMode;
239 * These aren't in any way "matroska-form" things,
240 * it's just something I use in the muxer/demuxer.
244 GST_MATROSKA_TRACK_ENABLED = (1<<0),
245 GST_MATROSKA_TRACK_DEFAULT = (1<<1),
246 GST_MATROSKA_TRACK_LACING = (1<<2),
247 GST_MATROSKA_TRACK_SHIFT = (1<<16)
248 } GstMatroskaTrackFlags;
251 GST_MATROSKA_VIDEOTRACK_INTERLACED = (GST_MATROSKA_TRACK_SHIFT<<0)
252 } GstMatroskaVideoTrackFlags;
254 typedef struct _GstMatroskaTrackContext {
258 GstFlowReturn last_flow;
260 /* some often-used info */
261 gchar *codec_id, *codec_name, *name, *language;
263 guint codec_priv_size;
264 GstMatroskaTrackType type;
266 GstMatroskaTrackFlags flags;
267 guint64 default_duration;
270 gboolean set_discont; /* TRUE = set DISCONT flag on next buffer */
272 /* Special flag for Vorbis and Theora, for which we need to send
273 * codec_priv first before sending any data, and just testing
274 * for time == 0 is not enough to detect that. Used by demuxer */
275 gboolean send_xiph_headers;
277 /* Special flag for Flac, for which we need to reconstruct the header
278 * buffer from the codec_priv data before sending any data, and just
279 * testing for time == 0 is not enough to detect that. Used by demuxer */
280 gboolean send_flac_headers;
282 /* Special flag for VobSub, for which we have to send colour table info
283 * (if available) first before sending any data, and just testing
284 * for time == 0 is not enough to detect that. Used by demuxer */
285 gboolean send_dvd_event;
287 /* Special counter for muxer to skip the first N vorbis/theora headers -
288 * they are put into codec private data, not muxed into the stream */
289 guint xiph_headers_to_skip;
291 /* Tags to send after newsegment event */
292 GstTagList *pending_tags;
294 /* A GArray of GstMatroskaTrackEncoding structures which contain the
295 * encoding (compression/encryption) settings for this track, if any */
297 } GstMatroskaTrackContext;
299 typedef struct _GstMatroskaTrackVideoContext {
300 GstMatroskaTrackContext parent;
302 guint pixel_width, pixel_height;
303 guint display_width, display_height;
305 GstMatroskaEyeMode eye_mode;
306 GstMatroskaAspectRatioMode asr_mode;
308 } GstMatroskaTrackVideoContext;
310 typedef struct _GstMatroskaTrackAudioContext {
311 GstMatroskaTrackContext parent;
313 guint samplerate, channels, bitdepth;
314 } GstMatroskaTrackAudioContext;
316 typedef struct _GstMatroskaTrackComplexContext {
317 GstMatroskaTrackContext parent;
319 /* nothing special goes here, apparently */
320 } GstMatroskaTrackComplexContext;
322 typedef struct _GstMatroskaTrackSubtitleContext {
323 GstMatroskaTrackContext parent;
325 gboolean check_utf8; /* buffers should be valid UTF-8 */
326 gboolean invalid_utf8; /* work around broken files */
327 } GstMatroskaTrackSubtitleContext;
329 typedef struct _GstMatroskaIndex {
330 guint64 pos; /* of the corresponding *cluster*! */
331 guint16 track; /* reference to 'num' */
332 guint64 time; /* in nanoseconds */
335 typedef struct _Wavpack4Header {
336 guchar ck_id [4]; /* "wvpk" */
337 guint32 ck_size; /* size of entire frame (minus 8, of course) */
338 guint16 version; /* 0x403 for now */
339 guint8 track_no; /* track number (0 if not used, like now) */
340 guint8 index_no; /* remember these? (0 if not used, like now) */
341 guint32 total_samples; /* for entire file (-1 if unknown) */
342 guint32 block_index; /* index of first sample in block (to file begin) */
343 guint32 block_samples; /* # samples in this block */
344 guint32 flags; /* various flags for id and decoding */
345 guint32 crc; /* crc for actual decoded data */
348 typedef struct _GstMatroskaTrackEncoding {
353 guint8 *comp_settings;
354 guint comp_settings_length;
355 } GstMatroskaTrackEncoding;
357 gboolean gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context);
358 gboolean gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context);
359 gboolean gst_matroska_track_init_subtitle_context (GstMatroskaTrackContext ** p_context);
360 gboolean gst_matroska_track_init_complex_context (GstMatroskaTrackContext ** p_context);
362 #endif /* __GST_MATROSKA_IDS_H__ */