1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gstreamer-GstContext.html
27  * outPack = gstreamer
28  * outFile = Context
29  * strct   = GstContext
30  * realStrct=
31  * ctorStrct=
32  * clss    = Context
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_context_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gstreamer.Structure
48  * structWrap:
49  * 	- GstContext* -> Context
50  * 	- GstStructure* -> Structure
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gstreamer.Context;
57 
58 public  import gstreamerc.gstreamertypes;
59 
60 private import gstreamerc.gstreamer;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import glib.Str;
65 private import gstreamer.Structure;
66 
67 
68 
69 /**
70  * GstContext is a container object used to store contexts like a device
71  * context, a display server connection and similar concepts that should
72  * be shared between multiple elements.
73  *
74  * Applications can set a context on a complete pipeline by using
75  * gst_element_set_context(), which will then be propagated to all
76  * child elements. Elements can handle these in GstElement::set_context()
77  * and merge them with the context information they already have.
78  *
79  * When an element needs a context it will do the following actions in this
80  * order until one step succeeds:
81  * 1) Check if the element already has a context
82  * 2) Query downstream with GST_QUERY_CONTEXT for the context
83  * 2) Query upstream with GST_QUERY_CONTEXT for the context
84  * 3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with the required
85  *  context types and afterwards check if a usable context was set now
86  * 4) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message
87  *  on the bus.
88  *
89  * Bins will catch GST_MESSAGE_NEED_CONTEXT messages and will set any previously
90  * known context on the element that asks for it if possible. Otherwise the
91  * application should provide one if it can.
92  */
93 public class Context
94 {
95 	
96 	/** the main Gtk struct */
97 	protected GstContext* gstContext;
98 	
99 	
100 	/** Get the main Gtk struct */
101 	public GstContext* getContextStruct()
102 	{
103 		return gstContext;
104 	}
105 	
106 	
107 	/** the main Gtk struct as a void* */
108 	protected void* getStruct()
109 	{
110 		return cast(void*)gstContext;
111 	}
112 	
113 	/**
114 	 * Sets our main struct and passes it to the parent class
115 	 */
116 	public this (GstContext* gstContext)
117 	{
118 		this.gstContext = gstContext;
119 	}
120 	
121 	/**
122 	 */
123 	
124 	/**
125 	 * Create a new context.
126 	 * Since 1.2
127 	 * Params:
128 	 * persistent = Persistent context
129 	 * Throws: ConstructionException GTK+ fails to create the object.
130 	 */
131 	public this (string contextType, int persistent)
132 	{
133 		// GstContext * gst_context_new (const gchar *context_type,  gboolean persistent);
134 		auto p = gst_context_new(Str.toStringz(contextType), persistent);
135 		if(p is null)
136 		{
137 			throw new ConstructionException("null returned by gst_context_new(Str.toStringz(contextType), persistent)");
138 		}
139 		this(cast(GstContext*) p);
140 	}
141 	
142 	/**
143 	 * Convenience macro to increase the reference count of the context.
144 	 * Returns: context (for convenience when doing assignments)
145 	 */
146 	public Context doref()
147 	{
148 		// GstContext * gst_context_ref (GstContext *context);
149 		auto p = gst_context_ref(gstContext);
150 		
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 		
156 		return ObjectG.getDObject!(Context)(cast(GstContext*) p);
157 	}
158 	
159 	/**
160 	 * Convenience macro to decrease the reference count of the context, possibly
161 	 * freeing it.
162 	 */
163 	public void unref()
164 	{
165 		// void gst_context_unref (GstContext *context);
166 		gst_context_unref(gstContext);
167 	}
168 	
169 	/**
170 	 * Creates a copy of the context. Returns a copy of the context.
171 	 * Returns: a new copy of context. MT safe. [transfer full]
172 	 */
173 	public Context copy()
174 	{
175 		// GstContext * gst_context_copy (const GstContext *context);
176 		auto p = gst_context_copy(gstContext);
177 		
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 		
183 		return ObjectG.getDObject!(Context)(cast(GstContext*) p);
184 	}
185 	
186 	/**
187 	 * Get the type of context.
188 	 * Since 1.2
189 	 * Returns: The type of the context.
190 	 */
191 	public string getContextType()
192 	{
193 		// const gchar * gst_context_get_context_type (const GstContext *context);
194 		return Str.toString(gst_context_get_context_type(gstContext));
195 	}
196 	
197 	/**
198 	 * Checks if context has context_type.
199 	 * Since 1.2
200 	 * Params:
201 	 * context = The GstContext.
202 	 * contextType = Context type to check.
203 	 * Returns: TRUE if context has context_type.
204 	 */
205 	public int hasContextType(string contextType)
206 	{
207 		// gboolean gst_context_has_context_type (const GstContext *context,  const gchar *context_type);
208 		return gst_context_has_context_type(gstContext, Str.toStringz(contextType));
209 	}
210 	
211 	/**
212 	 * Check if context is persistent.
213 	 * Since 1.2
214 	 * Returns: TRUE if the context is persistent.
215 	 */
216 	public int isPersistent()
217 	{
218 		// gboolean gst_context_is_persistent (const GstContext *context);
219 		return gst_context_is_persistent(gstContext);
220 	}
221 	
222 	/**
223 	 * Access the structure of the context.
224 	 * Since 1.2
225 	 * Returns: The structure of the context. The structure is still owned by the context, which means that you should not modify it, free it and that the pointer becomes invalid when you free the context. [transfer none]
226 	 */
227 	public Structure getStructure()
228 	{
229 		// const GstStructure * gst_context_get_structure (const GstContext *context);
230 		auto p = gst_context_get_structure(gstContext);
231 		
232 		if(p is null)
233 		{
234 			return null;
235 		}
236 		
237 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
238 	}
239 	
240 	/**
241 	 * Get a writable version of the structure.
242 	 * Since 1.2
243 	 * Returns: The structure of the context. The structure is still owned by the event, which means that you should not free it and that the pointer becomes invalid when you free the event. This function checks if context is writable.
244 	 */
245 	public Structure writableStructure()
246 	{
247 		// GstStructure * gst_context_writable_structure (GstContext *context);
248 		auto p = gst_context_writable_structure(gstContext);
249 		
250 		if(p is null)
251 		{
252 			return null;
253 		}
254 		
255 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
256 	}
257 	
258 	/**
259 	 * Modifies a pointer to a GstContext to point to a different GstContext. The
260 	 * modification is done atomically (so this is useful for ensuring thread safety
261 	 * in some cases), and the reference counts are updated appropriately (the old
262 	 * context is unreffed, the new one is reffed).
263 	 * Either new_context or the GstContext pointed to by old_context may be NULL.
264 	 * Params:
265 	 * oldContext = pointer to a pointer to a GstContext
266 	 * to be replaced. [inout][transfer full]
267 	 * newContext = pointer to a GstContext that will
268 	 * replace the context pointed to by old_context. [allow-none][transfer none]
269 	 * Returns: TRUE if new_context was different from old_context
270 	 */
271 	public static int replace(ref Context oldContext, Context newContext)
272 	{
273 		// gboolean gst_context_replace (GstContext **old_context,  GstContext *new_context);
274 		GstContext* outoldContext = (oldContext is null) ? null : oldContext.getContextStruct();
275 		
276 		auto p = gst_context_replace(&outoldContext, (newContext is null) ? null : newContext.getContextStruct());
277 		
278 		oldContext = ObjectG.getDObject!(Context)(outoldContext);
279 		return p;
280 	}
281 }