gst_plugins_base/gst-libs/gst/app/gstappbuffer.c
changeset 0 0e761a78d257
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     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 EXPORT_C GType
       
    38 gst_app_buffer_get_type (void)
       
    39 {
       
    40   static GType _gst_app_buffer_type;
       
    41 
       
    42   if (G_UNLIKELY (_gst_app_buffer_type == 0)) {
       
    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     _gst_app_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
       
    56         "GstAppBuffer", &app_buffer_info, 0);
       
    57   }
       
    58   return _gst_app_buffer_type;
       
    59 }
       
    60 
       
    61 static void
       
    62 gst_app_buffer_init (GstAppBuffer * buffer, gpointer g_class)
       
    63 {
       
    64 
       
    65 }
       
    66 
       
    67 static void
       
    68 gst_app_buffer_class_init (gpointer g_class, gpointer class_data)
       
    69 {
       
    70   GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
       
    71 
       
    72   mini_object_class->finalize =
       
    73       (GstMiniObjectFinalizeFunction) gst_app_buffer_finalize;
       
    74 
       
    75   parent_class = g_type_class_peek_parent (g_class);
       
    76 }
       
    77 
       
    78 static void
       
    79 gst_app_buffer_finalize (GstAppBuffer * buffer)
       
    80 {
       
    81   g_return_if_fail (buffer != NULL);
       
    82   g_return_if_fail (GST_IS_APP_BUFFER (buffer));
       
    83 
       
    84   if (buffer->finalize) {
       
    85     buffer->finalize (buffer->priv);
       
    86   }
       
    87 
       
    88   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (buffer));
       
    89 }
       
    90 
       
    91 EXPORT_C GstBuffer *
       
    92 gst_app_buffer_new (void *data, int length,
       
    93     GstAppBufferFinalizeFunc finalize, void *priv)
       
    94 {
       
    95   GstAppBuffer *buffer;
       
    96 
       
    97   buffer = (GstAppBuffer *) gst_mini_object_new (GST_TYPE_APP_BUFFER);
       
    98 
       
    99   GST_BUFFER_DATA (buffer) = data;
       
   100   GST_BUFFER_SIZE (buffer) = length;
       
   101 
       
   102   buffer->finalize = finalize;
       
   103   buffer->priv = priv;
       
   104 
       
   105   return GST_BUFFER (buffer);
       
   106 }