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#include <glib.h>
28
29G_BEGIN_DECLS
30
31typedef struct _GstContext GstContext;
32
33#include <gst/gstminiobject.h>
34#include <gst/gststructure.h>
35
36GST_API GType _gst_context_type;
37
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))
42
43
44
45GST_API
46GType gst_context_get_type (void);
47
48#ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
49/* refcounting */
50static inline GstContext *
51gst_context_ref (GstContext * context)
52{
53 return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context));
54}
55
56static inline void
57gst_context_unref (GstContext * context)
58{
59 gst_mini_object_unref (GST_MINI_OBJECT_CAST (context));
60}
61
62/* copy context */
63static inline GstContext *
64gst_context_copy (const GstContext * context)
65{
66 return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
67}
68#else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
69GST_API
70GstContext * gst_context_ref (GstContext * context);
71
72GST_API
73void gst_context_unref (GstContext * context);
74
75GST_API
76GstContext * gst_context_copy (const GstContext * context);
77#endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
78
79/**
80 * gst_context_is_writable:
81 * @context: a #GstContext
82 *
83 * Tests if you can safely write into a context's structure or validly
84 * modify the seqnum and timestamp fields.
85 */
86#define gst_context_is_writable(context) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (context))
87/**
88 * gst_context_make_writable:
89 * @context: (transfer full): the context to make writable
90 *
91 * Checks if a context is writable. If not, a writable copy is made and
92 * returned.
93 *
94 * Returns: (transfer full): a context (possibly a duplicate) that is writable.
95 *
96 * MT safe
97 */
98#define gst_context_make_writable(context) GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (context)))
99
100#ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
101static inline gboolean
102gst_context_replace (GstContext **old_context, GstContext *new_context)
103{
104 return gst_mini_object_replace (olddata: (GstMiniObject **) old_context, newdata: (GstMiniObject *) new_context);
105}
106#else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
107GST_API
108gboolean gst_context_replace (GstContext ** old_context,
109 GstContext * new_context);
110#endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
111
112GST_API
113GstContext * gst_context_new (const gchar * context_type,
114 gboolean persistent) G_GNUC_MALLOC;
115GST_API
116const gchar * gst_context_get_context_type (const GstContext * context);
117
118GST_API
119gboolean gst_context_has_context_type (const GstContext * context, const gchar * context_type);
120
121GST_API
122const GstStructure * gst_context_get_structure (const GstContext * context);
123
124GST_API
125GstStructure * gst_context_writable_structure (GstContext * context);
126
127GST_API
128gboolean gst_context_is_persistent (const GstContext * context);
129
130G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstContext, gst_context_unref)
131
132G_END_DECLS
133
134#endif /* __GST_CONTEXT_H__ */
135

source code of include/gstreamer-1.0/gst/gstcontext.h