gstfunnel: avoid access of freed pad
[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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_SAMPLE_H__
25 #define __GST_SAMPLE_H__
26
27 #include <gst/gstbuffer.h>
28 #include <gst/gstcaps.h>
29 #include <gst/gstsegment.h>
30
31 G_BEGIN_DECLS
32
33 GST_EXPORT GType _gst_sample_type;
34
35 #define GST_TYPE_SAMPLE      (_gst_sample_type)
36 #define GST_IS_SAMPLE(obj)   (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_SAMPLE))
37 #define GST_SAMPLE_CAST(obj) ((GstSample *)obj)
38 #define GST_SAMPLE(obj)      (GST_SAMPLE_CAST(obj))
39
40 /**
41  * GstSample:
42  *
43  * The opaque structure of a #GstSample. A sample contains a typed memory
44  * block and the associated timing information. It is mainly used to
45  * exchange buffers with and application.
46  */
47 typedef struct _GstSample GstSample;
48
49 GType gst_sample_get_type            (void);
50
51 /* allocation */
52 GstSample *          gst_sample_new           (GstBuffer          *buffer,
53                                                GstCaps            *caps,
54                                                const GstSegment   *segment,
55                                                GstStructure       *info);
56
57 GstBuffer *          gst_sample_get_buffer    (GstSample *sample);
58 GstCaps *            gst_sample_get_caps      (GstSample *sample);
59 GstSegment *         gst_sample_get_segment   (GstSample *sample);
60 const GstStructure * gst_sample_get_info      (GstSample *sample);
61
62 /* refcounting */
63 /**
64  * gst_sample_ref:
65  * @sample: a #GstSample
66  *
67  * Increases the refcount of the given sample by one.
68  *
69  * Returns: (transfer full): @sample
70  */
71 #ifdef _FOOL_GTK_DOC_
72 G_INLINE_FUNC GstSample * gst_sample_ref (GstSample * sample);
73 #endif
74
75 static inline GstSample *
76 gst_sample_ref (GstSample * sample)
77 {
78   return GST_SAMPLE_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
79       sample)));
80 }
81
82 /**
83  * gst_sample_unref:
84  * @sample: (transfer full): a #GstSample
85  *
86  * Decreases the refcount of the sample. If the refcount reaches 0, the
87  * sample will be freed.
88  */
89 #ifdef _FOOL_GTK_DOC_
90 G_INLINE_FUNC void gst_sample_unref (GstSample * sample);
91 #endif
92
93 static inline void
94 gst_sample_unref (GstSample * sample)
95 {
96   gst_mini_object_unref (GST_MINI_OBJECT_CAST (sample));
97 }
98
99 /**
100  * gst_value_set_sample:
101  * @v: a #GValue to receive the data
102  * @b: (transfer none): a #GstSample to assign to the GstValue
103  *
104  * Sets @b as the value of @v.  Caller retains reference to sample.
105  */
106 #define         gst_value_set_sample(v,b)       g_value_set_boxed((v),(b))
107 /**
108  * gst_value_take_sample:
109  * @v: a #GValue to receive the data
110  * @b: (transfer full): a #GstSample to assign to the GstValue
111  *
112  * Sets @b as the value of @v.  Caller gives away reference to sample.
113  */
114 #define         gst_value_take_sample(v,b)      g_value_take_boxed(v,(b))
115 /**
116  * gst_value_get_sample:
117  * @v: a #GValue to query
118  *
119  * Receives a #GstSample as the value of @v. Does not return a reference to
120  * the sample, so the pointer is only valid for as long as the caller owns
121  * a reference to @v.
122  *
123  * Returns: (transfer none): sample
124  */
125 #define         gst_value_get_sample(v)         GST_SAMPLE_CAST (g_value_get_boxed(v))
126
127 G_END_DECLS
128
129 #endif /* __GST_SAMPLE_H__ */