Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / app / gstappbuffer.c
1 /* GStreamer
2  * Copyright (C) 2007 David Schleef <ds@schleef.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <gst/gst.h>
25 #include <gst/base/gstpushsrc.h>
26
27 #include <string.h>
28
29 #include "gstappbuffer.h"
30
31 static void gst_app_buffer_init (GstAppBuffer * buffer, gpointer g_class);
32 static void gst_app_buffer_class_init (gpointer g_class, gpointer class_data);
33 static void gst_app_buffer_finalize (GstAppBuffer * buffer);
34
35 static GstBufferClass *parent_class;
36
37 GType
38 gst_app_buffer_get_type (void)
39 {
40   static volatile gsize app_buffer_type = 0;
41
42   if (g_once_init_enter (&app_buffer_type)) {
43     static const GTypeInfo app_buffer_info = {
44       sizeof (GstBufferClass),
45       NULL,
46       NULL,
47       gst_app_buffer_class_init,
48       NULL,
49       NULL,
50       sizeof (GstAppBuffer),
51       0,
52       (GInstanceInitFunc) gst_app_buffer_init,
53       NULL
54     };
55     GType tmp = g_type_register_static (GST_TYPE_BUFFER, "GstAppBuffer",
56         &app_buffer_info, 0);
57     g_once_init_leave (&app_buffer_type, tmp);
58   }
59
60   return (GType) app_buffer_type;
61 }
62
63 static void
64 gst_app_buffer_init (GstAppBuffer * buffer, gpointer g_class)
65 {
66
67 }
68
69 static void
70 gst_app_buffer_class_init (gpointer g_class, gpointer class_data)
71 {
72   GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
73
74   mini_object_class->finalize =
75       (GstMiniObjectFinalizeFunction) gst_app_buffer_finalize;
76
77   parent_class = g_type_class_peek_parent (g_class);
78 }
79
80 static void
81 gst_app_buffer_finalize (GstAppBuffer * buffer)
82 {
83   g_return_if_fail (buffer != NULL);
84   g_return_if_fail (GST_IS_APP_BUFFER (buffer));
85
86   if (buffer->finalize) {
87     buffer->finalize (buffer->priv);
88   }
89
90   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (buffer));
91 }
92
93 GstBuffer *
94 gst_app_buffer_new (void *data, int length,
95     GstAppBufferFinalizeFunc finalize, void *priv)
96 {
97   GstAppBuffer *buffer;
98
99   buffer = (GstAppBuffer *) gst_mini_object_new (GST_TYPE_APP_BUFFER);
100
101   GST_BUFFER_DATA (buffer) = data;
102   GST_BUFFER_SIZE (buffer) = length;
103
104   buffer->finalize = finalize;
105   buffer->priv = priv;
106
107   return GST_BUFFER (buffer);
108 }