2 * Copyright (C) 2013 Collabora Ltd.
3 * Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
5 * gstcontext.h: Header for GstContext subsystem
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.
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.
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.
23 #ifndef __GST_CONTEXT_H__
24 #define __GST_CONTEXT_H__
28 typedef struct _GstContext GstContext;
30 #include <gst/gstminiobject.h>
31 #include <gst/gststructure.h>
33 #define GST_TYPE_CONTEXT (gst_context_get_type())
34 #define GST_IS_CONTEXT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
35 #define GST_CONTEXT_CAST(obj) ((GstContext*)(obj))
36 #define GST_CONTEXT(obj) (GST_CONTEXT_CAST(obj))
40 GType gst_context_get_type (void);
46 * @context: the context to ref
48 * Convenience macro to increase the reference count of the context.
50 * Returns: @context (for convenience when doing assignments)
53 G_INLINE_FUNC GstContext * gst_context_ref (GstContext * context);
56 static inline GstContext *
57 gst_context_ref (GstContext * context)
59 return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context));
64 * @context: the context to unref
66 * Convenience macro to decrease the reference count of the context, possibly
70 G_INLINE_FUNC void gst_context_unref (GstContext * context);
74 gst_context_unref (GstContext * context)
76 gst_mini_object_unref (GST_MINI_OBJECT_CAST (context));
82 * @context: the context to copy
84 * Creates a copy of the context. Returns a copy of the context.
86 * Returns: (transfer full): a new copy of @context.
91 G_INLINE_FUNC GstContext * gst_context_copy (const GstContext * context);
94 static inline GstContext *
95 gst_context_copy (const GstContext * context)
97 return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
101 * gst_context_is_writable:
102 * @context: a #GstContext
104 * Tests if you can safely write into a context's structure or validly
105 * modify the seqnum and timestamp fields.
107 #define gst_context_is_writable(context) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (context))
109 * gst_context_make_writable:
110 * @context: (transfer full): the context to make writable
112 * Checks if a context is writable. If not, a writable copy is made and
115 * Returns: (transfer full): a context (possibly a duplicate) that is writable.
119 #define gst_context_make_writable(context) GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (context)))
121 * gst_context_replace:
122 * @old_context: (inout) (transfer full): pointer to a pointer to a #GstContext
124 * @new_context: (allow-none) (transfer none): pointer to a #GstContext that will
125 * replace the context pointed to by @old_context.
127 * Modifies a pointer to a #GstContext to point to a different #GstContext. The
128 * modification is done atomically (so this is useful for ensuring thread safety
129 * in some cases), and the reference counts are updated appropriately (the old
130 * context is unreffed, the new one is reffed).
132 * Either @new_context or the #GstContext pointed to by @old_context may be NULL.
134 * Returns: TRUE if @new_context was different from @old_context
136 #ifdef _FOOL_GTK_DOC_
137 G_INLINE_FUNC gboolean gst_context_replace (GstContext **old_context, GstContext *new_context);
140 static inline gboolean
141 gst_context_replace (GstContext **old_context, GstContext *new_context)
143 return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
146 GstContext * gst_context_new (void) G_GNUC_MALLOC;
148 GstStructure * gst_context_get_structure (GstContext *context);
152 #endif /* __GST_CONTEXT_H__ */