2 * Copyright (C) 2011 Wim Taymans <wim.taymans@gmail.com>
4 * gstcontext.h: Header for GstContext subsystem
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #ifndef __GST_CONTEXT_H__
24 #define __GST_CONTEXT_H__
26 #include <gst/gstminiobject.h>
27 #include <gst/gstevent.h>
31 #define GST_CONTEXT_TRACE_NAME "GstContext"
33 typedef struct _GstContext GstContext;
35 #define GST_TYPE_CONTEXT (gst_context_get_type())
36 #define GST_IS_CONTEXT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
37 #define GST_CONTEXT(obj) ((GstContext *)(obj))
38 #define GST_CONTEXT_CAST(obj) ((GstContext *)(obj))
42 * gst_context_is_writable:
45 * Tests if you can safely update @ctx with new events.
47 #define gst_context_is_writable(ctx) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (ctx))
50 * gst_context_make_writable:
51 * @ctx: (transfer full): a #GstContext
53 * Makes a writable context from the given context. If the source context is
54 * already writable, this will simply return the same context. A copy will
55 * otherwise be made using gst_context_copy().
57 * Returns: (transfer full): a writable context which may or may not be the
60 #define gst_context_make_writable(ctx) GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (buf)))
63 * gst_context_replace:
64 * @old_ctx: (inout) (transfer full): pointer to a pointer to a #GstContext
66 * @new_ctx: (allow-none) (transfer none): pointer to a #GstContext that will
67 * replace the context pointed to by @old_context.
69 * Modifies a pointer to a #GstContext to point to a different #GstContext. The
70 * modification is done atomically (so this is useful for ensuring thread safety
71 * in some cases), and the reference counts are updated appropriately (the old
72 * context is unreffed, the new one is reffed).
74 * Either @new_context or the #GstContext pointed to by @old_context may be NULL.
76 #define gst_context_replace(old_ctx,new_ctx) \
77 gst_mini_object_replace ((GstMiniObject **)(old_ctx), GST_MINI_OBJECT_CAST (new_ctx))
79 GType gst_context_get_type (void);
84 * @context: The context to refcount
86 * Increase the refcount of this context.
88 * Returns: (transfer full): @context (for convenience when doing assignments)
91 G_INLINE_FUNC GstContext * gst_context_ref (GstContext * context);
94 static inline GstContext *
95 gst_context_ref (GstContext * context)
97 return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context));
102 * @context: (transfer full): the context to refcount
104 * Decrease the refcount of an context, freeing it if the refcount reaches 0.
106 #ifdef _FOOL_GTK_DOC_
107 G_INLINE_FUNC void gst_context_unref (GstContext * context);
111 gst_context_unref (GstContext * context)
113 gst_mini_object_unref (GST_MINI_OBJECT_CAST (context));
119 * @context: The context to copy
121 * Copy the context using the context specific copy function.
123 * Returns: (transfer full): the new context
125 #ifdef _FOOL_GTK_DOC_
126 G_INLINE_FUNC GstContext * gst_context_copy (const GstContext * context);
129 static inline GstContext *
130 gst_context_copy (const GstContext * context)
132 return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
135 GstContext * gst_context_new (void);
137 void gst_context_update (GstContext *context, GstEvent *event);
138 GstEvent * gst_context_get (GstContext *context, GstEventType type);
140 void gst_context_clear (GstContext *context);
144 #endif /* __GST_CONTEXT_H__ */