gst/matroska/matroska-demux.c: Improve debug output everywhere and fix the EOS logic.
[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 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   return TRUE;
60 }
61
62 gboolean
63 gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context)
64 {
65   GstMatroskaTrackAudioContext *audio_context;
66
67   g_assert (p_context != NULL && *p_context != NULL);
68
69   /* already set up? (track info might come before track type) */
70   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_AUDIO)
71     return TRUE;
72
73   /* it better not have been set up as some other track type ... */
74   if ((*p_context)->type != 0) {
75     g_return_val_if_reached (FALSE);
76   }
77
78   audio_context = g_renew (GstMatroskaTrackAudioContext, *p_context, 1);
79   *p_context = (GstMatroskaTrackContext *) audio_context;
80
81   /* defaults */
82   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
83   audio_context->channels = 1;
84   audio_context->samplerate = 8000;
85   return TRUE;
86 }
87
88 gboolean
89 gst_matroska_track_init_subtitle_context (GstMatroskaTrackContext ** p_context)
90 {
91   GstMatroskaTrackSubtitleContext *subtitle_context;
92
93   g_assert (p_context != NULL && *p_context != NULL);
94
95   /* already set up? (track info might come before track type) */
96   if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_SUBTITLE)
97     return TRUE;
98
99   /* it better not have been set up as some other track type ... */
100   if ((*p_context)->type != 0) {
101     g_return_val_if_reached (FALSE);
102   }
103
104   subtitle_context = g_renew (GstMatroskaTrackSubtitleContext, *p_context, 1);
105   *p_context = (GstMatroskaTrackContext *) subtitle_context;
106
107   (*p_context)->type = GST_MATROSKA_TRACK_TYPE_SUBTITLE;
108   subtitle_context->invalid_utf8 = FALSE;
109   return TRUE;
110 }
111
112 void
113 gst_matroska_register_tags (void)
114 {
115   /* FIXME: Remove this when we depend on core 0.10.21 */
116   if (!gst_tag_exists (GST_TAG_ATTACHMENT))
117     gst_tag_register (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
118         "attachment", "file attached to this stream", gst_tag_merge_use_first);
119   /* TODO: register other custom tags */
120 }