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 | |
29 | G_BEGIN_DECLS |
30 | |
31 | typedef struct _GstContext GstContext; |
32 | |
33 | #include <gst/gstminiobject.h> |
34 | #include <gst/gststructure.h> |
35 | |
36 | GST_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 | |
45 | GST_API |
46 | GType gst_context_get_type (void); |
47 | |
48 | #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS |
49 | /* refcounting */ |
50 | static inline GstContext * |
51 | gst_context_ref (GstContext * context) |
52 | { |
53 | return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context)); |
54 | } |
55 | |
56 | static inline void |
57 | gst_context_unref (GstContext * context) |
58 | { |
59 | gst_mini_object_unref (GST_MINI_OBJECT_CAST (context)); |
60 | } |
61 | |
62 | /* copy context */ |
63 | static inline GstContext * |
64 | gst_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 */ |
69 | GST_API |
70 | GstContext * gst_context_ref (GstContext * context); |
71 | |
72 | GST_API |
73 | void gst_context_unref (GstContext * context); |
74 | |
75 | GST_API |
76 | GstContext * 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 |
101 | static inline gboolean |
102 | gst_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 */ |
107 | GST_API |
108 | gboolean gst_context_replace (GstContext ** old_context, |
109 | GstContext * new_context); |
110 | #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ |
111 | |
112 | GST_API |
113 | GstContext * gst_context_new (const gchar * context_type, |
114 | gboolean persistent) G_GNUC_MALLOC; |
115 | GST_API |
116 | const gchar * gst_context_get_context_type (const GstContext * context); |
117 | |
118 | GST_API |
119 | gboolean gst_context_has_context_type (const GstContext * context, const gchar * context_type); |
120 | |
121 | GST_API |
122 | const GstStructure * gst_context_get_structure (const GstContext * context); |
123 | |
124 | GST_API |
125 | GstStructure * gst_context_writable_structure (GstContext * context); |
126 | |
127 | GST_API |
128 | gboolean gst_context_is_persistent (const GstContext * context); |
129 | |
130 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstContext, gst_context_unref) |
131 | |
132 | G_END_DECLS |
133 | |
134 | #endif /* __GST_CONTEXT_H__ */ |
135 | |