matroskamux: Support "webm" DocType
[platform/upstream/gst-plugins-good.git] / gst / matroska / matroska-ids.c
1 /* GStreamer Matroska muxer/demuxer
2  * (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  * (C) 2006 Tim-Philipp Müller <tim centricular net>
4  *
5  * matroska-ids.c: matroska track context utility functions
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library 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  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include "matroska-ids.h"
28
29 GType
30 gst_matroska_doctype_get_type (void)
31 {
32   static GType doctype_type = 0;
33
34   static const GEnumValue doctype_types[] = {
35     {GST_MATROSKA_DOCTYPE_MATROSKA, "Matroska", "matroska"},
36     {GST_MATROSKA_DOCTYPE_WEBM, "WebM", "webm"},
37     {0, NULL, NULL}
38   };
39
40   if (!doctype_type) {
41     doctype_type = g_enum_register_static ("GstMatroskaDoctype", doctype_types);
42   }
43   return doctype_type;
44 }
45
46 gboolean
47 gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context)
48 {
49   GstMatroskaTrackVideoContext *video_context;
50
51   g_assert (p_context != NULL && *p_context != NULL);
52
53   /* already set up? (track info might come before track type) */
54   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_VIDEO) {
55     GST_LOG ("video context already set up");
56     return TRUE;
57   }
58
59   /* it better not have been set up as some other track type ... */
60   if ((*p_context)->type != 0) {
61     g_return_val_if_reached (FALSE);
62   }
63
64   video_context = g_renew (GstMatroskaTrackVideoContext, *p_context, 1);
65   *p_context = (GstMatroskaTrackContext *) video_context;
66
67   /* defaults */
68   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_VIDEO;
69   video_context->display_width = 0;
70   video_context->display_height = 0;
71   video_context->pixel_width = 0;
72   video_context->pixel_height = 0;
73   video_context->asr_mode = 0;
74   video_context->fourcc = 0;
75   video_context->default_fps = 0.0;
76   return TRUE;
77 }
78
79 gboolean
80 gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context)
81 {
82   GstMatroskaTrackAudioContext *audio_context;
83
84   g_assert (p_context != NULL && *p_context != NULL);
85
86   /* already set up? (track info might come before track type) */
87   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_AUDIO)
88     return TRUE;
89
90   /* it better not have been set up as some other track type ... */
91   if ((*p_context)->type != 0) {
92     g_return_val_if_reached (FALSE);
93   }
94
95   audio_context = g_renew (GstMatroskaTrackAudioContext, *p_context, 1);
96   *p_context = (GstMatroskaTrackContext *) audio_context;
97
98   /* defaults */
99   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
100   audio_context->channels = 1;
101   audio_context->samplerate = 8000;
102   return TRUE;
103 }
104
105 gboolean
106 gst_matroska_track_init_subtitle_context (GstMatroskaTrackContext ** p_context)
107 {
108   GstMatroskaTrackSubtitleContext *subtitle_context;
109
110   g_assert (p_context != NULL && *p_context != NULL);
111
112   /* already set up? (track info might come before track type) */
113   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_SUBTITLE)
114     return TRUE;
115
116   /* it better not have been set up as some other track type ... */
117   if ((*p_context)->type != 0) {
118     g_return_val_if_reached (FALSE);
119   }
120
121   subtitle_context = g_renew (GstMatroskaTrackSubtitleContext, *p_context, 1);
122   *p_context = (GstMatroskaTrackContext *) subtitle_context;
123
124   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_SUBTITLE;
125   subtitle_context->invalid_utf8 = FALSE;
126   return TRUE;
127 }
128
129 void
130 gst_matroska_register_tags (void)
131 {
132   /* TODO: register other custom tags */
133 }