tools: Count argc after parsing GOption on Windows
[platform/upstream/gstreamer.git] / subprojects / gstreamer / 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_API 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 GST_API
51 GType                gst_sample_get_type      (void);
52
53 /* allocation */
54
55 GST_API
56 GstSample *          gst_sample_new           (GstBuffer          *buffer,
57                                                GstCaps            *caps,
58                                                const GstSegment   *segment,
59                                                GstStructure       *info);
60 GST_API
61 GstBuffer *          gst_sample_get_buffer    (GstSample *sample);
62
63 GST_API
64 GstCaps *            gst_sample_get_caps      (GstSample *sample);
65
66 GST_API
67 GstSegment *         gst_sample_get_segment   (GstSample *sample);
68
69 GST_API
70 const GstStructure * gst_sample_get_info      (GstSample *sample);
71
72 GST_API
73 GstBufferList *      gst_sample_get_buffer_list (GstSample *sample);
74
75 GST_API
76 void                 gst_sample_set_buffer_list (GstSample *sample, GstBufferList *buffer_list);
77
78 GST_API
79 void                 gst_sample_set_buffer    (GstSample *sample, GstBuffer *buffer);
80
81 GST_API
82 void                 gst_sample_set_caps      (GstSample *sample, GstCaps *caps);
83
84 GST_API
85 void                 gst_sample_set_segment   (GstSample * sample, const GstSegment *segment);
86
87 GST_API
88 gboolean             gst_sample_set_info      (GstSample *sample, GstStructure *info);
89
90 #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
91 /* refcounting */
92 static inline GstSample *
93 gst_sample_ref (GstSample * sample)
94 {
95   return GST_SAMPLE_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
96       sample)));
97 }
98
99 static inline void
100 gst_sample_unref (GstSample * sample)
101 {
102   gst_mini_object_unref (GST_MINI_OBJECT_CAST (sample));
103 }
104 #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
105 GST_API
106 GstSample * gst_sample_ref    (GstSample * sample);
107
108 GST_API
109 void        gst_sample_unref  (GstSample * sample);
110 #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
111
112 /**
113  * gst_sample_is_writable:
114  * @sample: A #GstSample
115  *
116  * Tests if you can safely set the buffer and / or buffer list of @sample.
117  *
118  * Since: 1.16
119  */
120 #define         gst_sample_is_writable(sample)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (sample))
121
122 /**
123  * gst_sample_make_writable:
124  * @sample: (transfer full): A #GstSample
125  *
126  * Returns a writable copy of @sample. If the source sample is
127  * already writable, this will simply return the same sample.
128  *
129  * Use this function to ensure that a sample can be safely modified before
130  * making changes to it, for example before calling gst_sample_set_buffer()
131  *
132  * If the reference count of the source sample @sample is exactly one, the caller
133  * is the sole owner and this function will return the sample object unchanged.
134  *
135  * If there is more than one reference on the object, a copy will be made using
136  * gst_sample_copy(). The passed-in @sample will be unreffed in that case, and the
137  * caller will now own a reference to the new returned sample object.
138  *
139  * In short, this function unrefs the sample in the argument and refs the sample
140  * that it returns. Don't access the argument after calling this function unless
141  * you have an additional reference to it.
142  *
143  * Returns: (transfer full): a writable sample which may or may not be the
144  *     same as @sample
145  *
146  * Since: 1.16
147  */
148 #define         gst_sample_make_writable(sample)   GST_SAMPLE_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (sample)))
149
150 #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
151 /* copy sample */
152 static inline GstSample *
153 gst_sample_copy (const GstSample * buf)
154 {
155   return GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (buf)));
156 }
157 #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
158 GST_API
159 GstSample *   gst_sample_copy(const GstSample * buf);
160 #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
161
162 /**
163  * gst_value_set_sample:
164  * @v: a #GValue to receive the data
165  * @b: (transfer none): a #GstSample to assign to the GstValue
166  *
167  * Sets @b as the value of @v.  Caller retains reference to sample.
168  */
169 #define         gst_value_set_sample(v,b)       g_value_set_boxed((v),(b))
170 /**
171  * gst_value_take_sample:
172  * @v: a #GValue to receive the data
173  * @b: (transfer full): a #GstSample to assign to the GstValue
174  *
175  * Sets @b as the value of @v.  Caller gives away reference to sample.
176  */
177 #define         gst_value_take_sample(v,b)      g_value_take_boxed(v,(b))
178 /**
179  * gst_value_get_sample:
180  * @v: a #GValue to query
181  *
182  * Receives a #GstSample as the value of @v. Does not return a reference to
183  * the sample, so the pointer is only valid for as long as the caller owns
184  * a reference to @v.
185  *
186  * Returns: (transfer none): sample
187  */
188 #define         gst_value_get_sample(v)         GST_SAMPLE_CAST (g_value_get_boxed(v))
189
190 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSample, gst_sample_unref)
191
192 G_END_DECLS
193
194 #endif /* __GST_SAMPLE_H__ */