source: trunk/third/gstreamer/gst/gstbuffer.h @ 21448

Revision 21448, 6.8 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21447, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 *                    2000 Wim Taymans <wtay@chello.be>
4 *
5 * gstbuffer.h: Header for GstBuffer object
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
24#ifndef __GST_BUFFER_H__
25#define __GST_BUFFER_H__
26
27#include <gst/gstdata.h>
28#include <gst/gstclock.h>
29
30G_BEGIN_DECLS
31
32typedef struct _GstBuffer GstBuffer;
33
34typedef void (*GstBufferFreeDataFunc) (GstBuffer *buffer);
35
36#define GST_BUFFER_TRACE_NAME           "GstBuffer"
37
38extern GType _gst_buffer_type;
39
40#define GST_TYPE_BUFFER                         (gst_buffer_get_type())
41
42#define GST_BUFFER(buf)                         ((GstBuffer *)(buf))
43#define GST_IS_BUFFER(buf)                      (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER)
44
45#define GST_BUFFER_REFCOUNT(buf)                GST_DATA_REFCOUNT(buf)
46#define GST_BUFFER_REFCOUNT_VALUE(buf)          GST_DATA_REFCOUNT_VALUE(buf)
47#ifndef GST_DISABLE_DEPRECATED
48#define GST_BUFFER_COPY_FUNC(buf)               GST_DATA_COPY_FUNC(buf)
49#define GST_BUFFER_FREE_FUNC(buf)               GST_DATA_FREE_FUNC(buf)
50#endif
51
52#define GST_BUFFER_FLAGS(buf)                   GST_DATA_FLAGS(buf)
53#define GST_BUFFER_FLAG_IS_SET(buf,flag)        GST_DATA_FLAG_IS_SET (buf, flag)
54#define GST_BUFFER_FLAG_SET(buf,flag)           GST_DATA_FLAG_SET (buf, flag)
55#define GST_BUFFER_FLAG_UNSET(buf,flag)         GST_DATA_FLAG_UNSET (buf, flag)
56
57#define GST_BUFFER_DATA(buf)                    (GST_BUFFER(buf)->data)
58#define GST_BUFFER_SIZE(buf)                    (GST_BUFFER(buf)->size)
59#define GST_BUFFER_MAXSIZE(buf)                 (GST_BUFFER(buf)->maxsize)
60#define GST_BUFFER_TIMESTAMP(buf)               (GST_BUFFER(buf)->timestamp)
61#define GST_BUFFER_DURATION(buf)                (GST_BUFFER(buf)->duration)
62#define GST_BUFFER_OFFSET(buf)                  (GST_BUFFER(buf)->offset)
63#define GST_BUFFER_OFFSET_END(buf)              (GST_BUFFER(buf)->offset_end)
64#define GST_BUFFER_FREE_DATA_FUNC(buf)          (GST_BUFFER(buf)->free_data)
65#define GST_BUFFER_PRIVATE(buf)                 (GST_BUFFER(buf)->buffer_private)
66
67#define GST_BUFFER_OFFSET_NONE  ((guint64)-1)
68#define GST_BUFFER_MAXSIZE_NONE ((guint)0)
69
70#define GST_BUFFER_DURATION_IS_VALID(buffer)    (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer)))
71#define GST_BUFFER_TIMESTAMP_IS_VALID(buffer)   (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)))
72#define GST_BUFFER_OFFSET_IS_VALID(buffer)      (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE)
73#define GST_BUFFER_OFFSET_END_IS_VALID(buffer)  (GST_BUFFER_OFFSET_END (buffer) != GST_BUFFER_OFFSET_NONE)
74#define GST_BUFFER_MAXSIZE_IS_VALID(buffer)     (GST_BUFFER_MAXSIZE (buffer) != GST_BUFFER_MAXSIZE_NONE)
75
76/**
77 * GstBufferFlag:
78 * @GST_BUFFER_READONLY: the buffer is read-only.
79 * @GST_BUFFER_SUBBUFFER: the buffer is a subbuffer, the parent buffer can be
80 * found with the GST_BUFFER_POOL_PRIVATE() macro.
81 * @GST_BUFFER_ORIGINAL: buffer is not a copy of another buffer.
82 * @GST_BUFFER_DONTFREE: do not try to free the data when this buffer is
83 * unreferenced.
84 * @GST_BUFFER_KEY_UNIT: the buffer holds a key unit, a unit that can be
85 * decoded independently of other buffers.
86 * This flag has been deprecated, see #GST_BUFFER_DELTA_UNIT.
87 * @GST_BUFFER_DONTKEEP: the buffer should not be ref()ed, but copied instead
88 * before doing anything with it (for specially allocated hw buffers and such)
89 * @GST_BUFFER_IN_CAPS: the buffer has been added as a field in a #GstCaps.
90 * @GST_BUFFER_DELTA_UNIT: this unit cannot be decoded independently.
91 * Since 0.8.5
92 * @GST_BUFFER_FLAG_LAST: additional flags can be added starting from this flag.
93 *
94 * A set of buffer flags used to describe properties of a #GstBuffer.
95 */
96typedef enum {
97  GST_BUFFER_READONLY   = GST_DATA_READONLY,
98  GST_BUFFER_SUBBUFFER  = GST_DATA_FLAG_LAST,
99  GST_BUFFER_ORIGINAL,
100  GST_BUFFER_DONTFREE,
101  GST_BUFFER_KEY_UNIT,          /* deprecated, use reverse DELTA_UNIT */
102  GST_BUFFER_DONTKEEP,    /* FIXME: is this deprecated ? there is no reference in gstreamer, gst-plugins */
103  GST_BUFFER_IN_CAPS,
104  GST_BUFFER_DELTA_UNIT,        /* this unit depends on a previous unit */
105  GST_BUFFER_FLAG_LAST  = GST_DATA_FLAG_LAST + 8
106} GstBufferFlag;
107
108struct _GstBuffer {
109  GstData                data_type;
110
111  /* pointer to data and its size */
112  guint8                *data;                  /* pointer to buffer data */
113  guint                  size;                  /* size of buffer data */
114  guint                  maxsize;               /* max size of this buffer */
115
116  /* timestamp */
117  GstClockTime           timestamp;
118  GstClockTime           duration;
119
120  /* media specific offset
121   * for video frames, this could be the number of frames,
122   * for audio data, this could be the number of audio samples,
123   * for file data or compressed data, this could be the number of bytes
124   * offset_end is the last offset contained in the buffer. The format specifies
125   * the meaning of both of them exactly.
126   */
127  guint64                offset;
128  guint64                offset_end;
129
130  GstBufferFreeDataFunc  free_data;
131  gpointer               buffer_private;
132
133  gpointer _gst_reserved[GST_PADDING];
134};
135
136/* allocation */
137GType           gst_buffer_get_type             (void);
138GstBuffer*      gst_buffer_new                  (void);
139GstBuffer*      gst_buffer_new_and_alloc        (guint size);
140
141#define         gst_buffer_set_data(buf, data, size)    \
142G_STMT_START {                                          \
143  GST_BUFFER_DATA (buf) = data;                         \
144  GST_BUFFER_SIZE (buf) = size;                         \
145} G_STMT_END
146
147/* refcounting */
148#define         gst_buffer_ref(buf)             GST_BUFFER (gst_data_ref (GST_DATA (buf)))
149#define         gst_buffer_ref_by_count(buf,c)  GST_BUFFER (gst_data_ref_by_count (GST_DATA (buf), c))
150#define         gst_buffer_unref(buf)           gst_data_unref (GST_DATA (buf))
151/* copy buffer */
152void            gst_buffer_stamp                (GstBuffer *dest, const GstBuffer *src);
153#define         gst_buffer_copy(buf)            GST_BUFFER (gst_data_copy (GST_DATA (buf)))
154#define         gst_buffer_is_writable(buf)     gst_data_is_writable (GST_DATA (buf))
155#define         gst_buffer_copy_on_write(buf)   GST_BUFFER (gst_data_copy_on_write (GST_DATA (buf)))
156
157/* creating a subbuffer */
158GstBuffer*      gst_buffer_create_sub           (GstBuffer *parent, guint offset, guint size);
159
160/* merge, span, or append two buffers, intelligently */
161GstBuffer*      gst_buffer_merge                (GstBuffer *buf1, GstBuffer *buf2);
162GstBuffer*      gst_buffer_join                 (GstBuffer *buf1, GstBuffer *buf2);
163gboolean        gst_buffer_is_span_fast         (GstBuffer *buf1, GstBuffer *buf2);
164GstBuffer*      gst_buffer_span                 (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len);
165
166/* --- private --- */
167void            _gst_buffer_initialize          (void);
168
169void            gst_buffer_default_free         (GstBuffer *buffer);
170GstBuffer*      gst_buffer_default_copy         (GstBuffer *buffer);
171
172G_END_DECLS
173
174#endif /* __GST_BUFFER_H__ */
Note: See TracBrowser for help on using the repository browser.