baseparse: Don't override gst_segment_do_seek()
[platform/upstream/gstreamer.git] / gst / gstcontext.h
1 /* GStreamer
2  * Copyright (C) 2013 Collabora Ltd.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
4  * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
5  *
6  * gstcontext.h: Header for GstContext subsystem
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef __GST_CONTEXT_H__
25 #define __GST_CONTEXT_H__
26
27 G_BEGIN_DECLS
28
29 typedef struct _GstContext GstContext;
30
31 #include <gst/gstminiobject.h>
32 #include <gst/gststructure.h>
33
34 GST_EXPORT GType _gst_context_type;
35
36 #define GST_TYPE_CONTEXT                         (_gst_context_type)
37 #define GST_IS_CONTEXT(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
38 #define GST_CONTEXT_CAST(obj)                    ((GstContext*)(obj))
39 #define GST_CONTEXT(obj)                         (GST_CONTEXT_CAST(obj))
40
41
42
43 GType           gst_context_get_type            (void);
44
45
46 /* refcounting */
47 /**
48  * gst_context_ref:
49  * @context: the context to ref
50  *
51  * Convenience macro to increase the reference count of the context.
52  *
53  * Returns: @context (for convenience when doing assignments)
54  */
55 #ifdef _FOOL_GTK_DOC_
56 G_INLINE_FUNC GstContext * gst_context_ref (GstContext * context);
57 #endif
58
59 static inline GstContext *
60 gst_context_ref (GstContext * context)
61 {
62   return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context));
63 }
64
65 /**
66  * gst_context_unref:
67  * @context: the context to unref
68  *
69  * Convenience macro to decrease the reference count of the context, possibly
70  * freeing it.
71  */
72 #ifdef _FOOL_GTK_DOC_
73 G_INLINE_FUNC void gst_context_unref (GstContext * context);
74 #endif
75
76 static inline void
77 gst_context_unref (GstContext * context)
78 {
79   gst_mini_object_unref (GST_MINI_OBJECT_CAST (context));
80 }
81
82 /* copy context */
83 /**
84  * gst_context_copy:
85  * @context: the context to copy
86  *
87  * Creates a copy of the context. Returns a copy of the context.
88  *
89  * Returns: (transfer full): a new copy of @context.
90  *
91  * MT safe
92  */
93 #ifdef _FOOL_GTK_DOC_
94 G_INLINE_FUNC GstContext * gst_context_copy (const GstContext * context);
95 #endif
96
97 static inline GstContext *
98 gst_context_copy (const GstContext * context)
99 {
100   return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
101 }
102
103 /**
104  * gst_context_is_writable:
105  * @context: a #GstContext
106  *
107  * Tests if you can safely write into a context's structure or validly
108  * modify the seqnum and timestamp fields.
109  */
110 #define         gst_context_is_writable(context)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (context))
111 /**
112  * gst_context_make_writable:
113  * @context: (transfer full): the context to make writable
114  *
115  * Checks if a context is writable. If not, a writable copy is made and
116  * returned.
117  *
118  * Returns: (transfer full): a context (possibly a duplicate) that is writable.
119  *
120  * MT safe
121  */
122 #define         gst_context_make_writable(context)  GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (context)))
123 /**
124  * gst_context_replace:
125  * @old_context: (inout) (transfer full): pointer to a pointer to a #GstContext
126  *     to be replaced.
127  * @new_context: (allow-none) (transfer none): pointer to a #GstContext that will
128  *     replace the context pointed to by @old_context.
129  *
130  * Modifies a pointer to a #GstContext to point to a different #GstContext. The
131  * modification is done atomically (so this is useful for ensuring thread safety
132  * in some cases), and the reference counts are updated appropriately (the old
133  * context is unreffed, the new one is reffed).
134  *
135  * Either @new_context or the #GstContext pointed to by @old_context may be %NULL.
136  *
137  * Returns: %TRUE if @new_context was different from @old_context
138  */
139 #ifdef _FOOL_GTK_DOC_
140 G_INLINE_FUNC gboolean gst_context_replace (GstContext **old_context, GstContext *new_context);
141 #endif
142
143 static inline gboolean
144 gst_context_replace (GstContext **old_context, GstContext *new_context)
145 {
146   return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
147 }
148
149 GstContext *          gst_context_new                      (const gchar * context_type,
150                                                             gboolean persistent) G_GNUC_MALLOC;
151
152 const gchar *         gst_context_get_context_type         (const GstContext * context);
153 gboolean              gst_context_has_context_type         (const GstContext * context, const gchar * context_type);
154 const GstStructure *  gst_context_get_structure            (const GstContext * context);
155 GstStructure *        gst_context_writable_structure       (GstContext * context);
156
157 gboolean              gst_context_is_persistent            (const GstContext * context);
158
159 G_END_DECLS
160
161 #endif /* __GST_CONTEXT_H__ */