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 module gstreamer.Parse;
26 
27 private import glib.ErrorG;
28 private import glib.GException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gstreamer.Bin;
32 private import gstreamer.Element;
33 private import gstreamer.ParseContext;
34 private import gstreamer.c.functions;
35 public  import gstreamer.c.types;
36 public  import gstreamerc.gstreamertypes;
37 
38 
39 /** */
40 public struct Parse
41 {
42 
43 	/**
44 	 * This is a convenience wrapper around gst_parse_launch() to create a
45 	 * #GstBin from a gst-launch-style pipeline description. See
46 	 * gst_parse_launch() and the gst-launch man page for details about the
47 	 * syntax. Ghost pads on the bin for unlinked source or sink pads
48 	 * within the bin can automatically be created (but only a maximum of
49 	 * one ghost pad for each direction will be created; if you expect
50 	 * multiple unlinked source pads or multiple unlinked sink pads
51 	 * and want them all ghosted, you will have to create the ghost pads
52 	 * yourself).
53 	 *
54 	 * Params:
55 	 *     binDescription = command line describing the bin
56 	 *     ghostUnlinkedPads = whether to automatically create ghost pads
57 	 *         for unlinked source or sink pads within the bin
58 	 *
59 	 * Returns: a
60 	 *     newly-created bin, or %NULL if an error occurred.
61 	 *
62 	 * Throws: GException on failure.
63 	 */
64 	public static Bin binFromDescription(string binDescription, bool ghostUnlinkedPads)
65 	{
66 		GError* err = null;
67 
68 		auto p = gst_parse_bin_from_description(Str.toStringz(binDescription), ghostUnlinkedPads, &err);
69 
70 		if (err !is null)
71 		{
72 			throw new GException( new ErrorG(err) );
73 		}
74 
75 		if(p is null)
76 		{
77 			return null;
78 		}
79 
80 		return ObjectG.getDObject!(Bin)(cast(GstBin*) p);
81 	}
82 
83 	/**
84 	 * This is a convenience wrapper around gst_parse_launch() to create a
85 	 * #GstBin from a gst-launch-style pipeline description. See
86 	 * gst_parse_launch() and the gst-launch man page for details about the
87 	 * syntax. Ghost pads on the bin for unlinked source or sink pads
88 	 * within the bin can automatically be created (but only a maximum of
89 	 * one ghost pad for each direction will be created; if you expect
90 	 * multiple unlinked source pads or multiple unlinked sink pads
91 	 * and want them all ghosted, you will have to create the ghost pads
92 	 * yourself).
93 	 *
94 	 * Params:
95 	 *     binDescription = command line describing the bin
96 	 *     ghostUnlinkedPads = whether to automatically create ghost pads
97 	 *         for unlinked source or sink pads within the bin
98 	 *     context = a parse context allocated with
99 	 *         gst_parse_context_new(), or %NULL
100 	 *     flags = parsing options, or #GST_PARSE_FLAG_NONE
101 	 *
102 	 * Returns: a newly-created
103 	 *     element, which is guaranteed to be a bin unless
104 	 *     GST_FLAG_NO_SINGLE_ELEMENT_BINS was passed, or %NULL if an error
105 	 *     occurred.
106 	 *
107 	 * Throws: GException on failure.
108 	 */
109 	public static Element binFromDescriptionFull(string binDescription, bool ghostUnlinkedPads, ParseContext context, GstParseFlags flags)
110 	{
111 		GError* err = null;
112 
113 		auto p = gst_parse_bin_from_description_full(Str.toStringz(binDescription), ghostUnlinkedPads, (context is null) ? null : context.getParseContextStruct(), flags, &err);
114 
115 		if (err !is null)
116 		{
117 			throw new GException( new ErrorG(err) );
118 		}
119 
120 		if(p is null)
121 		{
122 			return null;
123 		}
124 
125 		return ObjectG.getDObject!(Element)(cast(GstElement*) p);
126 	}
127 
128 	/**
129 	 * Get the error quark used by the parsing subsystem.
130 	 *
131 	 * Returns: the quark of the parse errors.
132 	 */
133 	public static GQuark errorQuark()
134 	{
135 		return gst_parse_error_quark();
136 	}
137 
138 	/**
139 	 * Create a new pipeline based on command line syntax.
140 	 * Please note that you might get a return value that is not %NULL even though
141 	 * the @error is set. In this case there was a recoverable parsing error and you
142 	 * can try to play the pipeline.
143 	 *
144 	 * Params:
145 	 *     pipelineDescription = the command line describing the pipeline
146 	 *
147 	 * Returns: a new element on success, %NULL on
148 	 *     failure. If more than one toplevel element is specified by the
149 	 *     @pipeline_description, all elements are put into a #GstPipeline, which
150 	 *     than is returned.
151 	 *
152 	 * Throws: GException on failure.
153 	 */
154 	public static Element launch(string pipelineDescription)
155 	{
156 		GError* err = null;
157 
158 		auto p = gst_parse_launch(Str.toStringz(pipelineDescription), &err);
159 
160 		if (err !is null)
161 		{
162 			throw new GException( new ErrorG(err) );
163 		}
164 
165 		if(p is null)
166 		{
167 			return null;
168 		}
169 
170 		return ObjectG.getDObject!(Element)(cast(GstElement*) p);
171 	}
172 
173 	/**
174 	 * Create a new pipeline based on command line syntax.
175 	 * Please note that you might get a return value that is not %NULL even though
176 	 * the @error is set. In this case there was a recoverable parsing error and you
177 	 * can try to play the pipeline.
178 	 *
179 	 * Params:
180 	 *     pipelineDescription = the command line describing the pipeline
181 	 *     context = a parse context allocated with
182 	 *         gst_parse_context_new(), or %NULL
183 	 *     flags = parsing options, or #GST_PARSE_FLAG_NONE
184 	 *
185 	 * Returns: a new element on success, %NULL on
186 	 *     failure. If more than one toplevel element is specified by the
187 	 *     @pipeline_description, all elements are put into a #GstPipeline, which
188 	 *     then is returned (unless the GST_PARSE_FLAG_PLACE_IN_BIN flag is set, in
189 	 *     which case they are put in a #GstBin instead).
190 	 *
191 	 * Throws: GException on failure.
192 	 */
193 	public static Element launchFull(string pipelineDescription, ParseContext context, GstParseFlags flags)
194 	{
195 		GError* err = null;
196 
197 		auto p = gst_parse_launch_full(Str.toStringz(pipelineDescription), (context is null) ? null : context.getParseContextStruct(), flags, &err);
198 
199 		if (err !is null)
200 		{
201 			throw new GException( new ErrorG(err) );
202 		}
203 
204 		if(p is null)
205 		{
206 			return null;
207 		}
208 
209 		return ObjectG.getDObject!(Element)(cast(GstElement*) p);
210 	}
211 
212 	/**
213 	 * Create a new element based on command line syntax.
214 	 * @error will contain an error message if an erroneous pipeline is specified.
215 	 * An error does not mean that the pipeline could not be constructed.
216 	 *
217 	 * Params:
218 	 *     argv = null-terminated array of arguments
219 	 *
220 	 * Returns: a new element on success and %NULL
221 	 *     on failure.
222 	 *
223 	 * Throws: GException on failure.
224 	 */
225 	public static Element launchv(string[] argv)
226 	{
227 		GError* err = null;
228 
229 		auto p = gst_parse_launchv(Str.toStringzArray(argv), &err);
230 
231 		if (err !is null)
232 		{
233 			throw new GException( new ErrorG(err) );
234 		}
235 
236 		if(p is null)
237 		{
238 			return null;
239 		}
240 
241 		return ObjectG.getDObject!(Element)(cast(GstElement*) p);
242 	}
243 
244 	/**
245 	 * Create a new element based on command line syntax.
246 	 * @error will contain an error message if an erroneous pipeline is specified.
247 	 * An error does not mean that the pipeline could not be constructed.
248 	 *
249 	 * Params:
250 	 *     argv = null-terminated array of arguments
251 	 *     context = a parse context allocated with
252 	 *         gst_parse_context_new(), or %NULL
253 	 *     flags = parsing options, or #GST_PARSE_FLAG_NONE
254 	 *
255 	 * Returns: a new element on success; on
256 	 *     failure, either %NULL or a partially-constructed bin or element will be
257 	 *     returned and @error will be set (unless you passed
258 	 *     #GST_PARSE_FLAG_FATAL_ERRORS in @flags, then %NULL will always be returned
259 	 *     on failure)
260 	 *
261 	 * Throws: GException on failure.
262 	 */
263 	public static Element launchvFull(string[] argv, ParseContext context, GstParseFlags flags)
264 	{
265 		GError* err = null;
266 
267 		auto p = gst_parse_launchv_full(Str.toStringzArray(argv), (context is null) ? null : context.getParseContextStruct(), flags, &err);
268 
269 		if (err !is null)
270 		{
271 			throw new GException( new ErrorG(err) );
272 		}
273 
274 		if(p is null)
275 		{
276 			return null;
277 		}
278 
279 		return ObjectG.getDObject!(Element)(cast(GstElement*) p);
280 	}
281 }