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>
6 * gstcontext.h: Header for GstContext subsystem
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.
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.
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.
24 #ifndef __GST_CONTEXT_H__
25 #define __GST_CONTEXT_H__
31 typedef struct _GstContext GstContext;
33 #include <gst/gstminiobject.h>
34 #include <gst/gststructure.h>
36 GST_API GType _gst_context_type;
38 #define GST_TYPE_CONTEXT (_gst_context_type)
39 #define GST_IS_CONTEXT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
40 #define GST_CONTEXT_CAST(obj) ((GstContext*)(obj))
41 #define GST_CONTEXT(obj) (GST_CONTEXT_CAST(obj))
46 GType gst_context_get_type (void);
48 #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
50 static inline GstContext *
51 gst_context_ref (GstContext * context)
53 return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context));
57 gst_context_unref (GstContext * context)
59 gst_mini_object_unref (GST_MINI_OBJECT_CAST (context));
63 static inline GstContext *
64 gst_context_copy (const GstContext * context)
66 return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
68 #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
70 GstContext * gst_context_ref (GstContext * context);
73 void gst_context_unref (GstContext * context);
76 GstContext * gst_context_copy (const GstContext * context);
77 #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
80 * gst_context_is_writable:
81 * @context: a #GstContext
83 * Tests if you can safely write into a context's structure or validly
84 * modify the seqnum and timestamp fields.
86 #define gst_context_is_writable(context) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (context))
88 * gst_context_make_writable:
89 * @context: (transfer full): the context to make writable
91 * Checks if a context is writable. If not, a writable copy is made and
94 * Returns: (transfer full): a context (possibly a duplicate) that is writable.
98 #define gst_context_make_writable(context) GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (context)))
100 #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
101 static inline gboolean
102 gst_context_replace (GstContext **old_context, GstContext *new_context)
104 return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
106 #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
108 gboolean gst_context_replace (GstContext ** old_context,
109 GstContext * new_context);
110 #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
113 GstContext * gst_context_new (const gchar * context_type,
114 gboolean persistent) G_GNUC_MALLOC;
116 const gchar * gst_context_get_context_type (const GstContext * context);
119 gboolean gst_context_has_context_type (const GstContext * context, const gchar * context_type);
122 const GstStructure * gst_context_get_structure (const GstContext * context);
125 GstStructure * gst_context_writable_structure (GstContext * context);
128 gboolean gst_context_is_persistent (const GstContext * context);
130 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstContext, gst_context_unref)
134 #endif /* __GST_CONTEXT_H__ */