core: Add g_autoptr() support to all types
[platform/upstream/gstreamer.git] / gst / gstsample.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstsample.h: Header for GstSample 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., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23
24 #ifndef __GST_SAMPLE_H__
25 #define __GST_SAMPLE_H__
26
27 #include <gst/gstbuffer.h>
28 #include <gst/gstbufferlist.h>
29 #include <gst/gstcaps.h>
30 #include <gst/gstsegment.h>
31
32 G_BEGIN_DECLS
33
34 GST_EXPORT GType _gst_sample_type;
35
36 #define GST_TYPE_SAMPLE      (_gst_sample_type)
37 #define GST_IS_SAMPLE(obj)   (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_SAMPLE))
38 #define GST_SAMPLE_CAST(obj) ((GstSample *)obj)
39 #define GST_SAMPLE(obj)      (GST_SAMPLE_CAST(obj))
40
41 /**
42  * GstSample:
43  *
44  * The opaque structure of a #GstSample. A sample contains a typed memory
45  * block and the associated timing information. It is mainly used to
46  * exchange buffers with an application.
47  */
48 typedef struct _GstSample GstSample;
49
50 GType gst_sample_get_type            (void);
51
52 /* allocation */
53 GstSample *          gst_sample_new           (GstBuffer          *buffer,
54                                                GstCaps            *caps,
55                                                const GstSegment   *segment,
56                                                GstStructure       *info);
57
58 GstBuffer *          gst_sample_get_buffer    (GstSample *sample);
59 GstCaps *            gst_sample_get_caps      (GstSample *sample);
60 GstSegment *         gst_sample_get_segment   (GstSample *sample);
61 const GstStructure * gst_sample_get_info      (GstSample *sample);
62 GstBufferList *      gst_sample_get_buffer_list (GstSample *sample);
63 void                 gst_sample_set_buffer_list (GstSample *sample, GstBufferList *buffer_list);
64
65 /* refcounting */
66 /**
67  * gst_sample_ref:
68  * @sample: a #GstSample
69  *
70  * Increases the refcount of the given sample by one.
71  *
72  * Returns: (transfer full): @sample
73  */
74 static inline GstSample *
75 gst_sample_ref (GstSample * sample)
76 {
77   return GST_SAMPLE_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
78       sample)));
79 }
80
81 /**
82  * gst_sample_unref:
83  * @sample: (transfer full): a #GstSample
84  *
85  * Decreases the refcount of the sample. If the refcount reaches 0, the
86  * sample will be freed.
87  */
88 static inline void
89 gst_sample_unref (GstSample * sample)
90 {
91   gst_mini_object_unref (GST_MINI_OBJECT_CAST (sample));
92 }
93
94 /* copy sample */
95 /**
96  * gst_sample_copy:
97  * @buf: a #GstSample.
98  *
99  * Create a copy of the given sample. This will also make a newly allocated
100  * copy of the data the source sample contains.
101  *
102  * Returns: (transfer full): a new copy of @buf.
103  *
104  * Since: 1.2
105  */
106 static inline GstSample *
107 gst_sample_copy (const GstSample * buf)
108 {
109   return GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (buf)));
110 }
111
112 /**
113  * gst_value_set_sample:
114  * @v: a #GValue to receive the data
115  * @b: (transfer none): a #GstSample to assign to the GstValue
116  *
117  * Sets @b as the value of @v.  Caller retains reference to sample.
118  */
119 #define         gst_value_set_sample(v,b)       g_value_set_boxed((v),(b))
120 /**
121  * gst_value_take_sample:
122  * @v: a #GValue to receive the data
123  * @b: (transfer full): a #GstSample to assign to the GstValue
124  *
125  * Sets @b as the value of @v.  Caller gives away reference to sample.
126  */
127 #define         gst_value_take_sample(v,b)      g_value_take_boxed(v,(b))
128 /**
129  * gst_value_get_sample:
130  * @v: a #GValue to query
131  *
132  * Receives a #GstSample as the value of @v. Does not return a reference to
133  * the sample, so the pointer is only valid for as long as the caller owns
134  * a reference to @v.
135  *
136  * Returns: (transfer none): sample
137  */
138 #define         gst_value_get_sample(v)         GST_SAMPLE_CAST (g_value_get_boxed(v))
139
140 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
141 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSample, gst_sample_unref)
142 #endif
143
144 G_END_DECLS
145
146 #endif /* __GST_SAMPLE_H__ */