Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.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 gboolean
30 gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context)
31 {
32   GstMatroskaTrackVideoContext *video_context;
33
34   g_assert (p_context != NULL && *p_context != NULL);
35
36   /* already set up? (track info might come before track type) */
37   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_VIDEO) {
38     GST_LOG ("video context already set up");
39     return TRUE;
40   }
41
42   /* it better not have been set up as some other track type ... */
43   if ((*p_context)->type != 0) {
44     g_return_val_if_reached (FALSE);
45   }
46
47   video_context = g_renew (GstMatroskaTrackVideoContext, *p_context, 1);
48   *p_context = (GstMatroskaTrackContext *) video_context;
49
50   /* defaults */
51   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_VIDEO;
52   video_context->display_width = 0;
53   video_context->display_height = 0;
54   video_context->pixel_width = 0;
55   video_context->pixel_height = 0;
56   video_context->asr_mode = 0;
57   video_context->fourcc = 0;
58   video_context->default_fps = 0.0;
59   video_context->earliest_time = GST_CLOCK_TIME_NONE;
60   return TRUE;
61 }
62
63 gboolean
64 gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context)
65 {
66   GstMatroskaTrackAudioContext *audio_context;
67
68   g_assert (p_context != NULL && *p_context != NULL);
69
70   /* already set up? (track info might come before track type) */
71   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_AUDIO)
72     return TRUE;
73
74   /* it better not have been set up as some other track type ... */
75   if ((*p_context)->type != 0) {
76     g_return_val_if_reached (FALSE);
77   }
78
79   audio_context = g_renew (GstMatroskaTrackAudioContext, *p_context, 1);
80   *p_context = (GstMatroskaTrackContext *) audio_context;
81
82   /* defaults */
83   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
84   audio_context->channels = 1;
85   audio_context->samplerate = 8000;
86   return TRUE;
87 }
88
89 gboolean
90 gst_matroska_track_init_subtitle_context (GstMatroskaTrackContext ** p_context)
91 {
92   GstMatroskaTrackSubtitleContext *subtitle_context;
93
94   g_assert (p_context != NULL && *p_context != NULL);
95
96   /* already set up? (track info might come before track type) */
97   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_SUBTITLE)
98     return TRUE;
99
100   /* it better not have been set up as some other track type ... */
101   if ((*p_context)->type != 0) {
102     g_return_val_if_reached (FALSE);
103   }
104
105   subtitle_context = g_renew (GstMatroskaTrackSubtitleContext, *p_context, 1);
106   *p_context = (GstMatroskaTrackContext *) subtitle_context;
107
108   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_SUBTITLE;
109   subtitle_context->invalid_utf8 = FALSE;
110   subtitle_context->seen_markup_tag = FALSE;
111   return TRUE;
112 }
113
114 void
115 gst_matroska_register_tags (void)
116 {
117   /* TODO: register other custom tags */
118 }