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 
65 private import glib.Str;
66 private import gstreamer.Structure;
67 
68 
69 
70 
71 /**
72  * GstContext is a container object used to store contexts like a device
73  * context, a display server connection and similar concepts that should
74  * be shared between multiple elements.
75  *
76  * Applications can set a context on a complete pipeline by using
77  * gst_element_set_context(), which will then be propagated to all
78  * child elements. Elements can handle these in GstElement::set_context()
79  * and merge them with the context information they already have.
80  *
81  * When an element needs a context it will do the following actions in this
82  * order until one step succeeds:
83  * 1) Check if the element already has a context
84  * 2) Query downstream with GST_QUERY_CONTEXT for the context
85  * 2) Query upstream with GST_QUERY_CONTEXT for the context
86  * 3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with the required
87  *  context types and afterwards check if a usable context was set now
88  * 4) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message
89  *  on the bus.
90  *
91  * Bins will catch GST_MESSAGE_NEED_CONTEXT messages and will set any previously
92  * known context on the element that asks for it if possible. Otherwise the
93  * application should provide one if it can.
94  */
95 public class Context
96 {
97 	
98 	/** the main Gtk struct */
99 	protected GstContext* gstContext;
100 	
101 	
102 	public GstContext* getContextStruct()
103 	{
104 		return gstContext;
105 	}
106 	
107 	
108 	/** the main Gtk struct as a void* */
109 	protected void* getStruct()
110 	{
111 		return cast(void*)gstContext;
112 	}
113 	
114 	/**
115 	 * Sets our main struct and passes it to the parent class
116 	 */
117 	public this (GstContext* gstContext)
118 	{
119 		this.gstContext = gstContext;
120 	}
121 	
122 	/**
123 	 */
124 	
125 	/**
126 	 * Create a new context.
127 	 * Since 1.2
128 	 * Params:
129 	 * persistent = Persistent context
130 	 * Throws: ConstructionException GTK+ fails to create the object.
131 	 */
132 	public this (string contextType, int persistent)
133 	{
134 		// GstContext * gst_context_new (const gchar *context_type,  gboolean persistent);
135 		auto p = gst_context_new(Str.toStringz(contextType), persistent);
136 		if(p is null)
137 		{
138 			throw new ConstructionException("null returned by gst_context_new(Str.toStringz(contextType), persistent)");
139 		}
140 		this(cast(GstContext*) p);
141 	}
142 	
143 	/**
144 	 * Convenience macro to increase the reference count of the context.
145 	 * Returns: context (for convenience when doing assignments)
146 	 */
147 	public Context doref()
148 	{
149 		// GstContext * gst_context_ref (GstContext *context);
150 		auto p = gst_context_ref(gstContext);
151 		
152 		if(p is null)
153 		{
154 			return null;
155 		}
156 		
157 		return ObjectG.getDObject!(Context)(cast(GstContext*) p);
158 	}
159 	
160 	/**
161 	 * Convenience macro to decrease the reference count of the context, possibly
162 	 * freeing it.
163 	 */
164 	public void unref()
165 	{
166 		// void gst_context_unref (GstContext *context);
167 		gst_context_unref(gstContext);
168 	}
169 	
170 	/**
171 	 * Creates a copy of the context. Returns a copy of the context.
172 	 * Returns: a new copy of context. MT safe. [transfer full]
173 	 */
174 	public Context copy()
175 	{
176 		// GstContext * gst_context_copy (const GstContext *context);
177 		auto p = gst_context_copy(gstContext);
178 		
179 		if(p is null)
180 		{
181 			return null;
182 		}
183 		
184 		return ObjectG.getDObject!(Context)(cast(GstContext*) p);
185 	}
186 	
187 	/**
188 	 * Get the type of context.
189 	 * Since 1.2
190 	 * Returns: The type of the context.
191 	 */
192 	public string getContextType()
193 	{
194 		// const gchar * gst_context_get_context_type (const GstContext *context);
195 		return Str.toString(gst_context_get_context_type(gstContext));
196 	}
197 	
198 	/**
199 	 * Checks if context has context_type.
200 	 * Since 1.2
201 	 * Params:
202 	 * context = The GstContext.
203 	 * contextType = Context type to check.
204 	 * Returns: TRUE if context has context_type.
205 	 */
206 	public int hasContextType(string contextType)
207 	{
208 		// gboolean gst_context_has_context_type (const GstContext *context,  const gchar *context_type);
209 		return gst_context_has_context_type(gstContext, Str.toStringz(contextType));
210 	}
211 	
212 	/**
213 	 * Check if context is persistent.
214 	 * Since 1.2
215 	 * Returns: TRUE if the context is persistent.
216 	 */
217 	public int isPersistent()
218 	{
219 		// gboolean gst_context_is_persistent (const GstContext *context);
220 		return gst_context_is_persistent(gstContext);
221 	}
222 	
223 	/**
224 	 * Access the structure of the context.
225 	 * Since 1.2
226 	 * 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]
227 	 */
228 	public Structure getStructure()
229 	{
230 		// const GstStructure * gst_context_get_structure (const GstContext *context);
231 		auto p = gst_context_get_structure(gstContext);
232 		
233 		if(p is null)
234 		{
235 			return null;
236 		}
237 		
238 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
239 	}
240 	
241 	/**
242 	 * Get a writable version of the structure.
243 	 * Since 1.2
244 	 * 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.
245 	 */
246 	public Structure writableStructure()
247 	{
248 		// GstStructure * gst_context_writable_structure (GstContext *context);
249 		auto p = gst_context_writable_structure(gstContext);
250 		
251 		if(p is null)
252 		{
253 			return null;
254 		}
255 		
256 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
257 	}
258 	
259 	/**
260 	 * Modifies a pointer to a GstContext to point to a different GstContext. The
261 	 * modification is done atomically (so this is useful for ensuring thread safety
262 	 * in some cases), and the reference counts are updated appropriately (the old
263 	 * context is unreffed, the new one is reffed).
264 	 * Either new_context or the GstContext pointed to by old_context may be NULL.
265 	 * Params:
266 	 * oldContext = pointer to a pointer to a GstContext
267 	 * to be replaced. [inout][transfer full]
268 	 * newContext = pointer to a GstContext that will
269 	 * replace the context pointed to by old_context. [allow-none][transfer none]
270 	 * Returns: TRUE if new_context was different from old_context
271 	 */
272 	public static int replace(ref Context oldContext, Context newContext)
273 	{
274 		// gboolean gst_context_replace (GstContext **old_context,  GstContext *new_context);
275 		GstContext* outoldContext = (oldContext is null) ? null : oldContext.getContextStruct();
276 		
277 		auto p = gst_context_replace(&outoldContext, (newContext is null) ? null : newContext.getContextStruct());
278 		
279 		oldContext = ObjectG.getDObject!(Context)(outoldContext);
280 		return p;
281 	}
282 }