libs: sprinkle some G_GNUC_MALLOC
[platform/upstream/gstreamer.git] / libs / gst / base / gstadapter.h
1 /* GStreamer
2  * Copyright (C) 2004 Benjamin Otte <otte@gnome.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 #include <gst/gst.h>
21
22 #ifndef __GST_ADAPTER_H__
23 #define __GST_ADAPTER_H__
24
25 G_BEGIN_DECLS
26
27
28 #define GST_TYPE_ADAPTER \
29   (gst_adapter_get_type())
30 #define GST_ADAPTER(obj) \
31   (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_ADAPTER, GstAdapter))
32 #define GST_ADAPTER_CLASS(klass) \
33   (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_ADAPTER, GstAdapterClass))
34 #define GST_ADAPTER_GET_CLASS(obj) \
35   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ADAPTER, GstAdapterClass))
36 #define GST_IS_ADAPTER(obj) \
37   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_ADAPTER))
38 #define GST_IS_ADAPTER_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_ADAPTER))
40
41 typedef struct _GstAdapter GstAdapter;
42 typedef struct _GstAdapterClass GstAdapterClass;
43 typedef struct _GstAdapterPrivate GstAdapterPrivate;
44
45 /**
46  * GstAdapter:
47  *
48  * The opaque #GstAdapter data structure.
49  */
50 struct _GstAdapter {
51   GObject       object;
52
53   /*< private >*/
54   GSList *      buflist;
55   guint         size;
56   guint         skip;
57
58   /* we keep state of assembled pieces */
59   guint8 *      assembled_data;
60   guint         assembled_size;
61   guint         assembled_len;
62
63   /* ABI added */
64   /* Remember where the end of our buffer list is to
65    * speed up the push */
66   GSList *buflist_end;
67
68   GstAdapterPrivate *priv;
69
70   gpointer _gst_reserved[GST_PADDING - 2];
71 };
72
73 struct _GstAdapterClass {
74   GObjectClass  parent_class;
75
76   /*< private >*/
77   gpointer _gst_reserved[GST_PADDING];
78 };
79
80 GType                   gst_adapter_get_type            (void);
81
82 GstAdapter *            gst_adapter_new                 (void) G_GNUC_MALLOC;
83
84 void                    gst_adapter_clear               (GstAdapter *adapter);
85 void                    gst_adapter_push                (GstAdapter *adapter, GstBuffer* buf);
86 const guint8 *          gst_adapter_peek                (GstAdapter *adapter, guint size);
87 void                    gst_adapter_copy                (GstAdapter *adapter, guint8 *dest,
88                                                          guint offset, guint size);
89 void                    gst_adapter_flush               (GstAdapter *adapter, guint flush);
90 guint8*                 gst_adapter_take                (GstAdapter *adapter, guint nbytes);
91 GstBuffer*              gst_adapter_take_buffer         (GstAdapter *adapter, guint nbytes);
92 GList*                  gst_adapter_take_list           (GstAdapter *adapter, guint nbytes);
93 guint                   gst_adapter_available           (GstAdapter *adapter);
94 guint                   gst_adapter_available_fast      (GstAdapter *adapter);
95
96 GstClockTime            gst_adapter_prev_timestamp      (GstAdapter *adapter, guint64 *distance);
97
98 guint                   gst_adapter_masked_scan_uint32  (GstAdapter * adapter, guint32 mask,
99                                                          guint32 pattern, guint offset, guint size);
100
101 guint                   gst_adapter_masked_scan_uint32_peek  (GstAdapter * adapter, guint32 mask,
102                                                          guint32 pattern, guint offset, guint size, guint32 * value);
103
104 G_END_DECLS
105
106 #endif /* __GST_ADAPTER_H__ */