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 gst.base.Base;
26 
27 private import glib.Str;
28 private import gobject.ObjectG;
29 private import gst.base.c.functions;
30 public  import gst.base.c.types;
31 private import gstreamer.Buffer;
32 private import gstreamer.Caps;
33 private import gstreamer.ObjectGst;
34 private import gstreamer.Pad;
35 
36 
37 /** */
38 public struct Base
39 {
40 
41 	/**
42 	 * Tries to find what type of data is flowing from the given source #GstPad.
43 	 *
44 	 * Free-function: gst_caps_unref
45 	 *
46 	 * Params:
47 	 *     src = A source #GstPad
48 	 *     size = The length in bytes
49 	 *
50 	 * Returns: the #GstCaps corresponding to the data
51 	 *     stream.  Returns %NULL if no #GstCaps matches the data stream.
52 	 */
53 	public static Caps typeFindHelper(Pad src, ulong size)
54 	{
55 		auto __p = gst_type_find_helper((src is null) ? null : src.getPadStruct(), size);
56 
57 		if(__p is null)
58 		{
59 			return null;
60 		}
61 
62 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
63 	}
64 
65 	/**
66 	 * Tries to find what type of data is contained in the given #GstBuffer, the
67 	 * assumption being that the buffer represents the beginning of the stream or
68 	 * file.
69 	 *
70 	 * All available typefinders will be called on the data in order of rank. If
71 	 * a typefinding function returns a probability of %GST_TYPE_FIND_MAXIMUM,
72 	 * typefinding is stopped immediately and the found caps will be returned
73 	 * right away. Otherwise, all available typefind functions will the tried,
74 	 * and the caps with the highest probability will be returned, or %NULL if
75 	 * the content of the buffer could not be identified.
76 	 *
77 	 * Free-function: gst_caps_unref
78 	 *
79 	 * Params:
80 	 *     obj = object doing the typefinding, or %NULL (used for logging)
81 	 *     buf = a #GstBuffer with data to typefind
82 	 *     prob = location to store the probability of the found
83 	 *         caps, or %NULL
84 	 *
85 	 * Returns: the #GstCaps corresponding to the data,
86 	 *     or %NULL if no type could be found. The caller should free the caps
87 	 *     returned with gst_caps_unref().
88 	 */
89 	public static Caps typeFindHelperForBuffer(ObjectGst obj, Buffer buf, out GstTypeFindProbability prob)
90 	{
91 		auto __p = gst_type_find_helper_for_buffer((obj is null) ? null : obj.getObjectGstStruct(), (buf is null) ? null : buf.getBufferStruct(), &prob);
92 
93 		if(__p is null)
94 		{
95 			return null;
96 		}
97 
98 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
99 	}
100 
101 	/**
102 	 * Tries to find what type of data is contained in the given @data, the
103 	 * assumption being that the data represents the beginning of the stream or
104 	 * file.
105 	 *
106 	 * All available typefinders will be called on the data in order of rank. If
107 	 * a typefinding function returns a probability of %GST_TYPE_FIND_MAXIMUM,
108 	 * typefinding is stopped immediately and the found caps will be returned
109 	 * right away. Otherwise, all available typefind functions will the tried,
110 	 * and the caps with the highest probability will be returned, or %NULL if
111 	 * the content of @data could not be identified.
112 	 *
113 	 * Free-function: gst_caps_unref
114 	 *
115 	 * Params:
116 	 *     obj = object doing the typefinding, or %NULL (used for logging)
117 	 *     data = * a pointer with data to typefind
118 	 *     prob = location to store the probability of the found
119 	 *         caps, or %NULL
120 	 *
121 	 * Returns: the #GstCaps corresponding to the data,
122 	 *     or %NULL if no type could be found. The caller should free the caps
123 	 *     returned with gst_caps_unref().
124 	 */
125 	public static Caps typeFindHelperForData(ObjectGst obj, ubyte[] data, out GstTypeFindProbability prob)
126 	{
127 		auto __p = gst_type_find_helper_for_data((obj is null) ? null : obj.getObjectGstStruct(), data.ptr, cast(size_t)data.length, &prob);
128 
129 		if(__p is null)
130 		{
131 			return null;
132 		}
133 
134 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
135 	}
136 
137 	/**
138 	 * Tries to find the best #GstCaps associated with @extension.
139 	 *
140 	 * All available typefinders will be checked against the extension in order
141 	 * of rank. The caps of the first typefinder that can handle @extension will be
142 	 * returned.
143 	 *
144 	 * Free-function: gst_caps_unref
145 	 *
146 	 * Params:
147 	 *     obj = object doing the typefinding, or %NULL (used for logging)
148 	 *     extension = an extension
149 	 *
150 	 * Returns: the #GstCaps corresponding to
151 	 *     @extension, or %NULL if no type could be found. The caller should free
152 	 *     the caps returned with gst_caps_unref().
153 	 */
154 	public static Caps typeFindHelperForExtension(ObjectGst obj, string extension)
155 	{
156 		auto __p = gst_type_find_helper_for_extension((obj is null) ? null : obj.getObjectGstStruct(), Str.toStringz(extension));
157 
158 		if(__p is null)
159 		{
160 			return null;
161 		}
162 
163 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
164 	}
165 
166 	/**
167 	 * Utility function to do pull-based typefinding. Unlike gst_type_find_helper()
168 	 * however, this function will use the specified function @func to obtain the
169 	 * data needed by the typefind functions, rather than operating on a given
170 	 * source pad. This is useful mostly for elements like tag demuxers which
171 	 * strip off data at the beginning and/or end of a file and want to typefind
172 	 * the stripped data stream before adding their own source pad (the specified
173 	 * callback can then call the upstream peer pad with offsets adjusted for the
174 	 * tag size, for example).
175 	 *
176 	 * When @extension is not %NULL, this function will first try the typefind
177 	 * functions for the given extension, which might speed up the typefinding
178 	 * in many cases.
179 	 *
180 	 * Free-function: gst_caps_unref
181 	 *
182 	 * Params:
183 	 *     obj = A #GstObject that will be passed as first argument to @func
184 	 *     parent = the parent of @obj or %NULL
185 	 *     func = A generic #GstTypeFindHelperGetRangeFunction that will
186 	 *         be used to access data at random offsets when doing the typefinding
187 	 *     size = The length in bytes
188 	 *     extension = extension of the media, or %NULL
189 	 *     prob = location to store the probability of the found
190 	 *         caps, or %NULL
191 	 *
192 	 * Returns: the #GstCaps corresponding to the data
193 	 *     stream.  Returns %NULL if no #GstCaps matches the data stream.
194 	 */
195 	public static Caps typeFindHelperGetRange(ObjectGst obj, ObjectGst parent, GstTypeFindHelperGetRangeFunction func, ulong size, string extension, out GstTypeFindProbability prob)
196 	{
197 		auto __p = gst_type_find_helper_get_range((obj is null) ? null : obj.getObjectGstStruct(), (parent is null) ? null : parent.getObjectGstStruct(), func, size, Str.toStringz(extension), &prob);
198 
199 		if(__p is null)
200 		{
201 			return null;
202 		}
203 
204 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
205 	}
206 
207 	/**
208 	 * Tries to find what type of data is contained in the given #GstBuffer, the
209 	 * assumption being that the buffer represents the beginning of the stream or
210 	 * file.
211 	 *
212 	 * All available typefinders will be called on the data in order of rank. If
213 	 * a typefinding function returns a probability of %GST_TYPE_FIND_MAXIMUM,
214 	 * typefinding is stopped immediately and the found caps will be returned
215 	 * right away. Otherwise, all available typefind functions will the tried,
216 	 * and the caps with the highest probability will be returned, or %NULL if
217 	 * the content of the buffer could not be identified.
218 	 *
219 	 * When @extension is not %NULL, this function will first try the typefind
220 	 * functions for the given extension, which might speed up the typefinding
221 	 * in many cases.
222 	 *
223 	 * Free-function: gst_caps_unref
224 	 *
225 	 * Params:
226 	 *     obj = object doing the typefinding, or %NULL (used for logging)
227 	 *     buf = a #GstBuffer with data to typefind
228 	 *     extension = extension of the media, or %NULL
229 	 *     prob = location to store the probability of the found
230 	 *         caps, or %NULL
231 	 *
232 	 * Returns: the #GstCaps corresponding to the data,
233 	 *     or %NULL if no type could be found. The caller should free the caps
234 	 *     returned with gst_caps_unref().
235 	 *
236 	 * Since: 1.16
237 	 */
238 	public static Caps typeFindHelperForBufferWithExtension(ObjectGst obj, Buffer buf, string extension, out GstTypeFindProbability prob)
239 	{
240 		auto __p = gst_type_find_helper_for_buffer_with_extension((obj is null) ? null : obj.getObjectGstStruct(), (buf is null) ? null : buf.getBufferStruct(), Str.toStringz(extension), &prob);
241 
242 		if(__p is null)
243 		{
244 			return null;
245 		}
246 
247 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
248 	}
249 
250 	/**
251 	 * Tries to find what type of data is contained in the given @data, the
252 	 * assumption being that the data represents the beginning of the stream or
253 	 * file.
254 	 *
255 	 * All available typefinders will be called on the data in order of rank. If
256 	 * a typefinding function returns a probability of %GST_TYPE_FIND_MAXIMUM,
257 	 * typefinding is stopped immediately and the found caps will be returned
258 	 * right away. Otherwise, all available typefind functions will the tried,
259 	 * and the caps with the highest probability will be returned, or %NULL if
260 	 * the content of @data could not be identified.
261 	 *
262 	 * When @extension is not %NULL, this function will first try the typefind
263 	 * functions for the given extension, which might speed up the typefinding
264 	 * in many cases.
265 	 *
266 	 * Free-function: gst_caps_unref
267 	 *
268 	 * Params:
269 	 *     obj = object doing the typefinding, or %NULL (used for logging)
270 	 *     data = * a pointer with data to typefind
271 	 *     extension = extension of the media, or %NULL
272 	 *     prob = location to store the probability of the found
273 	 *         caps, or %NULL
274 	 *
275 	 * Returns: the #GstCaps corresponding to the data,
276 	 *     or %NULL if no type could be found. The caller should free the caps
277 	 *     returned with gst_caps_unref().
278 	 *
279 	 * Since: 1.16
280 	 */
281 	public static Caps typeFindHelperForDataWithExtension(ObjectGst obj, ubyte[] data, string extension, out GstTypeFindProbability prob)
282 	{
283 		auto __p = gst_type_find_helper_for_data_with_extension((obj is null) ? null : obj.getObjectGstStruct(), data.ptr, cast(size_t)data.length, Str.toStringz(extension), &prob);
284 
285 		if(__p is null)
286 		{
287 			return null;
288 		}
289 
290 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true);
291 	}
292 
293 	/**
294 	 * Utility function to do pull-based typefinding. Unlike gst_type_find_helper()
295 	 * however, this function will use the specified function @func to obtain the
296 	 * data needed by the typefind functions, rather than operating on a given
297 	 * source pad. This is useful mostly for elements like tag demuxers which
298 	 * strip off data at the beginning and/or end of a file and want to typefind
299 	 * the stripped data stream before adding their own source pad (the specified
300 	 * callback can then call the upstream peer pad with offsets adjusted for the
301 	 * tag size, for example).
302 	 *
303 	 * When @extension is not %NULL, this function will first try the typefind
304 	 * functions for the given extension, which might speed up the typefinding
305 	 * in many cases.
306 	 *
307 	 * Params:
308 	 *     obj = A #GstObject that will be passed as first argument to @func
309 	 *     parent = the parent of @obj or %NULL
310 	 *     func = A generic #GstTypeFindHelperGetRangeFunction that will
311 	 *         be used to access data at random offsets when doing the typefinding
312 	 *     size = The length in bytes
313 	 *     extension = extension of the media, or %NULL
314 	 *     caps = returned caps
315 	 *     prob = location to store the probability of the found
316 	 *         caps, or %NULL
317 	 *
318 	 * Returns: the last %GstFlowReturn from pulling a buffer or %GST_FLOW_OK if
319 	 *     typefinding was successful.
320 	 *
321 	 * Since: 1.14.3
322 	 */
323 	public static GstFlowReturn typeFindHelperGetRangeFull(ObjectGst obj, ObjectGst parent, GstTypeFindHelperGetRangeFunction func, ulong size, string extension, out Caps caps, out GstTypeFindProbability prob)
324 	{
325 		GstCaps* outcaps = null;
326 
327 		auto __p = gst_type_find_helper_get_range_full((obj is null) ? null : obj.getObjectGstStruct(), (parent is null) ? null : parent.getObjectGstStruct(), func, size, Str.toStringz(extension), &outcaps, &prob);
328 
329 		caps = ObjectG.getDObject!(Caps)(outcaps);
330 
331 		return __p;
332 	}
333 }