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.Pad;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gstreamer.Buffer;
32 private import gstreamer.BufferList;
33 private import gstreamer.Caps;
34 private import gstreamer.Element;
35 private import gstreamer.Event;
36 private import gstreamer.Iterator;
37 private import gstreamer.ObjectGst;
38 private import gstreamer.PadTemplate;
39 private import gstreamer.Query;
40 private import gstreamer.StaticPadTemplate;
41 private import gstreamerc.gstreamer;
42 public  import gstreamerc.gstreamertypes;
43 public  import gtkc.gdktypes;
44 
45 
46 /**
47  * A #GstElement is linked to other elements via "pads", which are extremely
48  * light-weight generic link points.
49  * 
50  * Pads have a #GstPadDirection, source pads produce data, sink pads consume
51  * data.
52  * 
53  * Pads are typically created from a #GstPadTemplate with
54  * gst_pad_new_from_template() and are then added to a #GstElement. This usually
55  * happens when the element is created but it can also happen dynamically based
56  * on the data that the element is processing or based on the pads that the
57  * application requests.
58  * 
59  * Pads without pad templates can be created with gst_pad_new(),
60  * which takes a direction and a name as an argument.  If the name is %NULL,
61  * then a guaranteed unique name will be assigned to it.
62  * 
63  * A #GstElement creating a pad will typically use the various
64  * gst_pad_set_*_function() calls to register callbacks for events, queries or
65  * dataflow on the pads.
66  * 
67  * gst_pad_get_parent() will retrieve the #GstElement that owns the pad.
68  * 
69  * After two pads are retrieved from an element by gst_element_get_static_pad(),
70  * the pads can be linked with gst_pad_link(). (For quick links,
71  * you can also use gst_element_link(), which will make the obvious
72  * link for you if it's straightforward.). Pads can be unlinked again with
73  * gst_pad_unlink(). gst_pad_get_peer() can be used to check what the pad is
74  * linked to.
75  * 
76  * Before dataflow is possible on the pads, they need to be activated with
77  * gst_pad_set_active().
78  * 
79  * gst_pad_query() and gst_pad_peer_query() can be used to query various
80  * properties of the pad and the stream.
81  * 
82  * To send a #GstEvent on a pad, use gst_pad_send_event() and
83  * gst_pad_push_event(). Some events will be sticky on the pad, meaning that
84  * after they pass on the pad they can be queried later with
85  * gst_pad_get_sticky_event() and gst_pad_sticky_events_foreach().
86  * gst_pad_get_current_caps() and gst_pad_has_current_caps() are convenience
87  * functions to query the current sticky CAPS event on a pad.
88  * 
89  * GstElements will use gst_pad_push() and gst_pad_pull_range() to push out
90  * or pull in a buffer.
91  * 
92  * The dataflow, events and queries that happen on a pad can be monitored with
93  * probes that can be installed with gst_pad_add_probe(). gst_pad_is_blocked()
94  * can be used to check if a block probe is installed on the pad.
95  * gst_pad_is_blocking() checks if the blocking probe is currently blocking the
96  * pad. gst_pad_remove_probe() is used to remove a previously installed probe
97  * and unblock blocking probes if any.
98  * 
99  * Pad have an offset that can be retrieved with gst_pad_get_offset(). This
100  * offset will be applied to the running_time of all data passing over the pad.
101  * gst_pad_set_offset() can be used to change the offset.
102  * 
103  * Convenience functions exist to start, pause and stop the task on a pad with
104  * gst_pad_start_task(), gst_pad_pause_task() and gst_pad_stop_task()
105  * respectively.
106  */
107 public class Pad : ObjectGst
108 {
109 	/** the main Gtk struct */
110 	protected GstPad* gstPad;
111 
112 	/** Get the main Gtk struct */
113 	public GstPad* getPadStruct()
114 	{
115 		return gstPad;
116 	}
117 
118 	/** the main Gtk struct as a void* */
119 	protected override void* getStruct()
120 	{
121 		return cast(void*)gstPad;
122 	}
123 
124 	protected override void setStruct(GObject* obj)
125 	{
126 		gstPad = cast(GstPad*)obj;
127 		super.setStruct(obj);
128 	}
129 
130 	/**
131 	 * Sets our main struct and passes it to the parent class.
132 	 */
133 	public this (GstPad* gstPad, bool ownedRef = false)
134 	{
135 		this.gstPad = gstPad;
136 		super(cast(GstObject*)gstPad, ownedRef);
137 	}
138 
139 	/*
140 	 * Sets our main struct and passes it to the parent class.
141 	 * This one is additional to make gstreamer.Element addOnPadAdded()
142 	 * working without changes.
143 	 */
144 	public this (GObject* gstPad)
145 	{
146 		super(cast(GstObject*)gstPad);
147 		this.gstPad = cast(GstPad*) gstPad;
148 	}
149 	
150 	/**
151 	 * Queries a pad for the stream position.
152 	 * This is a convenience function for gstreamerD.
153 	 * Returns:
154 	 *  The current position in nanoseconds - GstFormat.TIME.
155 	 */
156 	public long queryPosition()
157 	{
158 		long cur_pos;
159 		queryPosition( GstFormat.TIME, cur_pos );
160 		return cur_pos;
161 	}
162 	
163 	/**
164 	 * Queries a pad for the stream duration.
165 	 * This is a convenience function for gstreamerD.
166 	 * Returns:
167 	 *  The duration in nanoseconds - GstFormat.TIME.
168 	 */
169 	public long queryDuration()
170 	{
171 		long cur_dur;
172 		queryDuration( GstFormat.TIME, cur_dur );
173 		return cur_dur;
174 	}
175 
176 	/**
177 	 */
178 
179 	public static GType getType()
180 	{
181 		return gst_pad_get_type();
182 	}
183 
184 	/**
185 	 * Creates a new pad with the given name in the given direction.
186 	 * If name is %NULL, a guaranteed unique name (across all pads)
187 	 * will be assigned.
188 	 * This function makes a copy of the name so you can safely free the name.
189 	 *
190 	 * Params:
191 	 *     name = the name of the new pad.
192 	 *     direction = the #GstPadDirection of the pad.
193 	 *
194 	 * Return: a new #GstPad, or %NULL in
195 	 *     case of an error.
196 	 *
197 	 *     MT safe.
198 	 *
199 	 * Throws: ConstructionException GTK+ fails to create the object.
200 	 */
201 	public this(string name, GstPadDirection direction)
202 	{
203 		auto p = gst_pad_new(Str.toStringz(name), direction);
204 		
205 		if(p is null)
206 		{
207 			throw new ConstructionException("null returned by new");
208 		}
209 		
210 		this(cast(GstPad*) p);
211 	}
212 
213 	/**
214 	 * Creates a new pad with the given name from the given static template.
215 	 * If name is %NULL, a guaranteed unique name (across all pads)
216 	 * will be assigned.
217 	 * This function makes a copy of the name so you can safely free the name.
218 	 *
219 	 * Params:
220 	 *     templ = the #GstStaticPadTemplate to use
221 	 *     name = the name of the element
222 	 *
223 	 * Return: a new #GstPad, or %NULL in
224 	 *     case of an error.
225 	 *
226 	 * Throws: ConstructionException GTK+ fails to create the object.
227 	 */
228 	public this(StaticPadTemplate templ, string name)
229 	{
230 		auto p = gst_pad_new_from_static_template((templ is null) ? null : templ.getStaticPadTemplateStruct(), Str.toStringz(name));
231 		
232 		if(p is null)
233 		{
234 			throw new ConstructionException("null returned by new_from_static_template");
235 		}
236 		
237 		this(cast(GstPad*) p);
238 	}
239 
240 	/**
241 	 * Creates a new pad with the given name from the given template.
242 	 * If name is %NULL, a guaranteed unique name (across all pads)
243 	 * will be assigned.
244 	 * This function makes a copy of the name so you can safely free the name.
245 	 *
246 	 * Params:
247 	 *     templ = the pad template to use
248 	 *     name = the name of the element
249 	 *
250 	 * Return: a new #GstPad, or %NULL in
251 	 *     case of an error.
252 	 *
253 	 * Throws: ConstructionException GTK+ fails to create the object.
254 	 */
255 	public this(PadTemplate templ, string name)
256 	{
257 		auto p = gst_pad_new_from_template((templ is null) ? null : templ.getPadTemplateStruct(), Str.toStringz(name));
258 		
259 		if(p is null)
260 		{
261 			throw new ConstructionException("null returned by new_from_template");
262 		}
263 		
264 		this(cast(GstPad*) p);
265 	}
266 
267 	/**
268 	 * Gets a string representing the given pad-link return.
269 	 *
270 	 * Params:
271 	 *     ret = a #GstPadLinkReturn to get the name of.
272 	 *
273 	 * Return: a static string with the name of the pad-link return.
274 	 *
275 	 * Since: 1.4
276 	 */
277 	public static string linkGetName(GstPadLinkReturn ret)
278 	{
279 		return Str.toString(gst_pad_link_get_name(ret));
280 	}
281 
282 	/**
283 	 * Activates or deactivates the given pad in @mode via dispatching to the
284 	 * pad's activatemodefunc. For use from within pad activation functions only.
285 	 *
286 	 * If you don't know what this is, you probably don't want to call it.
287 	 *
288 	 * Params:
289 	 *     mode = the requested activation mode
290 	 *     active = whether or not the pad should be active.
291 	 *
292 	 * Return: %TRUE if the operation was successful.
293 	 *
294 	 *     MT safe.
295 	 */
296 	public bool activateMode(GstPadMode mode, bool active)
297 	{
298 		return gst_pad_activate_mode(gstPad, mode, active) != 0;
299 	}
300 
301 	/**
302 	 * Be notified of different states of pads. The provided callback is called for
303 	 * every state that matches @mask.
304 	 *
305 	 * Params:
306 	 *     mask = the probe mask
307 	 *     callback = #GstPadProbeCallback that will be called with notifications of
308 	 *         the pad state
309 	 *     userData = user data passed to the callback
310 	 *     destroyData = #GDestroyNotify for user_data
311 	 *
312 	 * Return: an id or 0 if no probe is pending. The id can be used to remove the
313 	 *     probe with gst_pad_remove_probe(). When using GST_PAD_PROBE_TYPE_IDLE it can
314 	 *     happend that the probe can be run immediately and if the probe returns
315 	 *     GST_PAD_PROBE_REMOVE this functions returns 0.
316 	 *
317 	 *     MT safe.
318 	 */
319 	public gulong addProbe(GstPadProbeType mask, GstPadProbeCallback callback, void* userData, GDestroyNotify destroyData)
320 	{
321 		return gst_pad_add_probe(gstPad, mask, callback, userData, destroyData);
322 	}
323 
324 	/**
325 	 * Checks if the source pad and the sink pad are compatible so they can be
326 	 * linked.
327 	 *
328 	 * Params:
329 	 *     sinkpad = the sink #GstPad.
330 	 *
331 	 * Return: %TRUE if the pads can be linked.
332 	 */
333 	public bool canLink(Pad sinkpad)
334 	{
335 		return gst_pad_can_link(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct()) != 0;
336 	}
337 
338 	/**
339 	 * Chain a buffer to @pad.
340 	 *
341 	 * The function returns #GST_FLOW_FLUSHING if the pad was flushing.
342 	 *
343 	 * If the buffer type is not acceptable for @pad (as negotiated with a
344 	 * preceding GST_EVENT_CAPS event), this function returns
345 	 * #GST_FLOW_NOT_NEGOTIATED.
346 	 *
347 	 * The function proceeds calling the chain function installed on @pad (see
348 	 * gst_pad_set_chain_function()) and the return value of that function is
349 	 * returned to the caller. #GST_FLOW_NOT_SUPPORTED is returned if @pad has no
350 	 * chain function.
351 	 *
352 	 * In all cases, success or failure, the caller loses its reference to @buffer
353 	 * after calling this function.
354 	 *
355 	 * Params:
356 	 *     buffer = the #GstBuffer to send, return GST_FLOW_ERROR
357 	 *         if not.
358 	 *
359 	 * Return: a #GstFlowReturn from the pad.
360 	 *
361 	 *     MT safe.
362 	 */
363 	public GstFlowReturn chain(Buffer buffer)
364 	{
365 		return gst_pad_chain(gstPad, (buffer is null) ? null : buffer.getBufferStruct());
366 	}
367 
368 	/**
369 	 * Chain a bufferlist to @pad.
370 	 *
371 	 * The function returns #GST_FLOW_FLUSHING if the pad was flushing.
372 	 *
373 	 * If @pad was not negotiated properly with a CAPS event, this function
374 	 * returns #GST_FLOW_NOT_NEGOTIATED.
375 	 *
376 	 * The function proceeds calling the chainlist function installed on @pad (see
377 	 * gst_pad_set_chain_list_function()) and the return value of that function is
378 	 * returned to the caller. #GST_FLOW_NOT_SUPPORTED is returned if @pad has no
379 	 * chainlist function.
380 	 *
381 	 * In all cases, success or failure, the caller loses its reference to @list
382 	 * after calling this function.
383 	 *
384 	 * MT safe.
385 	 *
386 	 * Params:
387 	 *     list = the #GstBufferList to send, return GST_FLOW_ERROR
388 	 *         if not.
389 	 *
390 	 * Return: a #GstFlowReturn from the pad.
391 	 */
392 	public GstFlowReturn chainList(BufferList list)
393 	{
394 		return gst_pad_chain_list(gstPad, (list is null) ? null : list.getBufferListStruct());
395 	}
396 
397 	/**
398 	 * Check and clear the #GST_PAD_FLAG_NEED_RECONFIGURE flag on @pad and return %TRUE
399 	 * if the flag was set.
400 	 *
401 	 * Return: %TRUE is the GST_PAD_FLAG_NEED_RECONFIGURE flag was set on @pad.
402 	 */
403 	public bool checkReconfigure()
404 	{
405 		return gst_pad_check_reconfigure(gstPad) != 0;
406 	}
407 
408 	/**
409 	 * Creates a stream-id for the source #GstPad @pad by combining the
410 	 * upstream information with the optional @stream_id of the stream
411 	 * of @pad. @pad must have a parent #GstElement and which must have zero
412 	 * or one sinkpad. @stream_id can only be %NULL if the parent element
413 	 * of @pad has only a single source pad.
414 	 *
415 	 * This function generates an unique stream-id by getting the upstream
416 	 * stream-start event stream ID and appending @stream_id to it. If the
417 	 * element has no sinkpad it will generate an upstream stream-id by
418 	 * doing an URI query on the element and in the worst case just uses
419 	 * a random number. Source elements that don't implement the URI
420 	 * handler interface should ideally generate a unique, deterministic
421 	 * stream-id manually instead.
422 	 *
423 	 * Since stream IDs are sorted alphabetically, any numbers in the
424 	 * stream ID should be printed with a fixed number of characters,
425 	 * preceded by 0's, such as by using the format \%03u instead of \%u.
426 	 *
427 	 * Params:
428 	 *     parent = Parent #GstElement of @pad
429 	 *     streamId = The stream-id
430 	 *
431 	 * Return: A stream-id for @pad. g_free() after usage.
432 	 */
433 	public string createStreamId(Element parent, string streamId)
434 	{
435 		return Str.toString(gst_pad_create_stream_id(gstPad, (parent is null) ? null : parent.getElementStruct(), Str.toStringz(streamId)));
436 	}
437 
438 	/**
439 	 * Creates a stream-id for the source #GstPad @pad by combining the
440 	 * upstream information with the optional @stream_id of the stream
441 	 * of @pad. @pad must have a parent #GstElement and which must have zero
442 	 * or one sinkpad. @stream_id can only be %NULL if the parent element
443 	 * of @pad has only a single source pad.
444 	 *
445 	 * This function generates an unique stream-id by getting the upstream
446 	 * stream-start event stream ID and appending @stream_id to it. If the
447 	 * element has no sinkpad it will generate an upstream stream-id by
448 	 * doing an URI query on the element and in the worst case just uses
449 	 * a random number. Source elements that don't implement the URI
450 	 * handler interface should ideally generate a unique, deterministic
451 	 * stream-id manually instead.
452 	 *
453 	 * Params:
454 	 *     parent = Parent #GstElement of @pad
455 	 *     streamId = The stream-id
456 	 *     varArgs = parameters for the @stream_id format string
457 	 *
458 	 * Return: A stream-id for @pad. g_free() after usage.
459 	 */
460 	public string createStreamIdPrintfValist(Element parent, string streamId, void* varArgs)
461 	{
462 		return Str.toString(gst_pad_create_stream_id_printf_valist(gstPad, (parent is null) ? null : parent.getElementStruct(), Str.toStringz(streamId), varArgs));
463 	}
464 
465 	/**
466 	 * Invokes the default event handler for the given pad.
467 	 *
468 	 * The EOS event will pause the task associated with @pad before it is forwarded
469 	 * to all internally linked pads,
470 	 *
471 	 * The the event is sent to all pads internally linked to @pad. This function
472 	 * takes ownership of @event.
473 	 *
474 	 * Params:
475 	 *     parent = the parent of @pad or %NULL
476 	 *     event = the #GstEvent to handle.
477 	 *
478 	 * Return: %TRUE if the event was sent successfully.
479 	 */
480 	public bool eventDefault(ObjectGst parent, Event event)
481 	{
482 		return gst_pad_event_default(gstPad, (parent is null) ? null : parent.getObjectGstStruct(), (event is null) ? null : event.getEventStruct()) != 0;
483 	}
484 
485 	/**
486 	 * Calls @forward for all internally linked pads of @pad. This function deals with
487 	 * dynamically changing internal pads and will make sure that the @forward
488 	 * function is only called once for each pad.
489 	 *
490 	 * When @forward returns %TRUE, no further pads will be processed.
491 	 *
492 	 * Params:
493 	 *     forward = a #GstPadForwardFunction
494 	 *     userData = user data passed to @forward
495 	 *
496 	 * Return: %TRUE if one of the dispatcher functions returned %TRUE.
497 	 */
498 	public bool forward(GstPadForwardFunction forward, void* userData)
499 	{
500 		return gst_pad_forward(gstPad, forward, userData) != 0;
501 	}
502 
503 	/**
504 	 * Gets the capabilities of the allowed media types that can flow through
505 	 * @pad and its peer.
506 	 *
507 	 * The allowed capabilities is calculated as the intersection of the results of
508 	 * calling gst_pad_query_caps() on @pad and its peer. The caller owns a reference
509 	 * on the resulting caps.
510 	 *
511 	 * Return: the allowed #GstCaps of the
512 	 *     pad link. Unref the caps when you no longer need it. This
513 	 *     function returns %NULL when @pad has no peer.
514 	 *
515 	 *     MT safe.
516 	 */
517 	public Caps getAllowedCaps()
518 	{
519 		auto p = gst_pad_get_allowed_caps(gstPad);
520 		
521 		if(p is null)
522 		{
523 			return null;
524 		}
525 		
526 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
527 	}
528 
529 	/**
530 	 * Gets the capabilities currently configured on @pad with the last
531 	 * #GST_EVENT_CAPS event.
532 	 *
533 	 * Return: the current caps of the pad with incremented ref-count.
534 	 */
535 	public Caps getCurrentCaps()
536 	{
537 		auto p = gst_pad_get_current_caps(gstPad);
538 		
539 		if(p is null)
540 		{
541 			return null;
542 		}
543 		
544 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
545 	}
546 
547 	/**
548 	 * Gets the direction of the pad. The direction of the pad is
549 	 * decided at construction time so this function does not take
550 	 * the LOCK.
551 	 *
552 	 * Return: the #GstPadDirection of the pad.
553 	 *
554 	 *     MT safe.
555 	 */
556 	public GstPadDirection getDirection()
557 	{
558 		return gst_pad_get_direction(gstPad);
559 	}
560 
561 	/**
562 	 * Gets the private data of a pad.
563 	 * No locking is performed in this function.
564 	 *
565 	 * Return: a #gpointer to the private data.
566 	 */
567 	public void* getElementPrivate()
568 	{
569 		return gst_pad_get_element_private(gstPad);
570 	}
571 
572 	/**
573 	 * Gets the #GstFlowReturn return from the last data passed by this pad.
574 	 *
575 	 * Since: 1.4
576 	 */
577 	public GstFlowReturn getLastFlowReturn()
578 	{
579 		return gst_pad_get_last_flow_return(gstPad);
580 	}
581 
582 	/**
583 	 * Get the offset applied to the running time of @pad. @pad has to be a source
584 	 * pad.
585 	 *
586 	 * Return: the offset.
587 	 */
588 	public long getOffset()
589 	{
590 		return gst_pad_get_offset(gstPad);
591 	}
592 
593 	/**
594 	 * Gets the template for @pad.
595 	 *
596 	 * Return: the #GstPadTemplate from which
597 	 *     this pad was instantiated, or %NULL if this pad has no
598 	 *     template. Unref after usage.
599 	 */
600 	public PadTemplate getPadTemplate()
601 	{
602 		auto p = gst_pad_get_pad_template(gstPad);
603 		
604 		if(p is null)
605 		{
606 			return null;
607 		}
608 		
609 		return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p, true);
610 	}
611 
612 	/**
613 	 * Gets the capabilities for @pad's template.
614 	 *
615 	 * Return: the #GstCaps of this pad template.
616 	 *     Unref after usage.
617 	 */
618 	public Caps getPadTemplateCaps()
619 	{
620 		auto p = gst_pad_get_pad_template_caps(gstPad);
621 		
622 		if(p is null)
623 		{
624 			return null;
625 		}
626 		
627 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
628 	}
629 
630 	/**
631 	 * Gets the parent of @pad, cast to a #GstElement. If a @pad has no parent or
632 	 * its parent is not an element, return %NULL.
633 	 *
634 	 * Return: the parent of the pad. The
635 	 *     caller has a reference on the parent, so unref when you're finished
636 	 *     with it.
637 	 *
638 	 *     MT safe.
639 	 */
640 	public Element getParentElement()
641 	{
642 		auto p = gst_pad_get_parent_element(gstPad);
643 		
644 		if(p is null)
645 		{
646 			return null;
647 		}
648 		
649 		return ObjectG.getDObject!(Element)(cast(GstElement*) p, true);
650 	}
651 
652 	/**
653 	 * Gets the peer of @pad. This function refs the peer pad so
654 	 * you need to unref it after use.
655 	 *
656 	 * Return: the peer #GstPad. Unref after usage.
657 	 *
658 	 *     MT safe.
659 	 */
660 	public Pad getPeer()
661 	{
662 		auto p = gst_pad_get_peer(gstPad);
663 		
664 		if(p is null)
665 		{
666 			return null;
667 		}
668 		
669 		return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
670 	}
671 
672 	/**
673 	 * When @pad is flushing this function returns #GST_FLOW_FLUSHING
674 	 * immediately and @buffer is %NULL.
675 	 *
676 	 * Calls the getrange function of @pad, see #GstPadGetRangeFunction for a
677 	 * description of a getrange function. If @pad has no getrange function
678 	 * installed (see gst_pad_set_getrange_function()) this function returns
679 	 * #GST_FLOW_NOT_SUPPORTED.
680 	 *
681 	 * If @buffer points to a variable holding %NULL, a valid new #GstBuffer will be
682 	 * placed in @buffer when this function returns #GST_FLOW_OK. The new buffer
683 	 * must be freed with gst_buffer_unref() after usage.
684 	 *
685 	 * When @buffer points to a variable that points to a valid #GstBuffer, the
686 	 * buffer will be filled with the result data when this function returns
687 	 * #GST_FLOW_OK. If the provided buffer is larger than @size, only
688 	 * @size bytes will be filled in the result buffer and its size will be updated
689 	 * accordingly.
690 	 *
691 	 * Note that less than @size bytes can be returned in @buffer when, for example,
692 	 * an EOS condition is near or when @buffer is not large enough to hold @size
693 	 * bytes. The caller should check the result buffer size to get the result size.
694 	 *
695 	 * When this function returns any other result value than #GST_FLOW_OK, @buffer
696 	 * will be unchanged.
697 	 *
698 	 * This is a lowlevel function. Usually gst_pad_pull_range() is used.
699 	 *
700 	 * Params:
701 	 *     offset = The start offset of the buffer
702 	 *     size = The length of the buffer
703 	 *     buffer = a pointer to hold the #GstBuffer,
704 	 *         returns #GST_FLOW_ERROR if %NULL.
705 	 *
706 	 * Return: a #GstFlowReturn from the pad.
707 	 *
708 	 *     MT safe.
709 	 */
710 	public GstFlowReturn getRange(ulong offset, uint size, out Buffer buffer)
711 	{
712 		GstBuffer* outbuffer = null;
713 		
714 		auto p = gst_pad_get_range(gstPad, offset, size, &outbuffer);
715 		
716 		buffer = ObjectG.getDObject!(Buffer)(outbuffer);
717 		
718 		return p;
719 	}
720 
721 	/**
722 	 * Returns a new reference of the sticky event of type @event_type
723 	 * from the event.
724 	 *
725 	 * Params:
726 	 *     eventType = the #GstEventType that should be retrieved.
727 	 *     idx = the index of the event
728 	 *
729 	 * Return: a #GstEvent of type
730 	 *     @event_type or %NULL when no event of @event_type was on
731 	 *     @pad. Unref after usage.
732 	 */
733 	public Event getStickyEvent(GstEventType eventType, uint idx)
734 	{
735 		auto p = gst_pad_get_sticky_event(gstPad, eventType, idx);
736 		
737 		if(p is null)
738 		{
739 			return null;
740 		}
741 		
742 		return ObjectG.getDObject!(Event)(cast(GstEvent*) p);
743 	}
744 
745 	/**
746 	 * Returns the current stream-id for the @pad, or %NULL if none has been
747 	 * set yet, i.e. the pad has not received a stream-start event yet.
748 	 *
749 	 * This is a convenience wrapper around gst_pad_get_sticky_event() and
750 	 * gst_event_parse_stream_start().
751 	 *
752 	 * The returned stream-id string should be treated as an opaque string, its
753 	 * contents should not be interpreted.
754 	 *
755 	 * Return: a newly-allocated copy of the stream-id for
756 	 *     @pad, or %NULL.  g_free() the returned string when no longer
757 	 *     needed.
758 	 *
759 	 * Since: 1.2
760 	 */
761 	public string getStreamId()
762 	{
763 		return Str.toString(gst_pad_get_stream_id(gstPad));
764 	}
765 
766 	/**
767 	 * Check if @pad has caps set on it with a #GST_EVENT_CAPS event.
768 	 *
769 	 * Return: %TRUE when @pad has caps associated with it.
770 	 */
771 	public bool hasCurrentCaps()
772 	{
773 		return gst_pad_has_current_caps(gstPad) != 0;
774 	}
775 
776 	/**
777 	 * Query if a pad is active
778 	 *
779 	 * Return: %TRUE if the pad is active.
780 	 *
781 	 *     MT safe.
782 	 */
783 	public bool isActive()
784 	{
785 		return gst_pad_is_active(gstPad) != 0;
786 	}
787 
788 	/**
789 	 * Checks if the pad is blocked or not. This function returns the
790 	 * last requested state of the pad. It is not certain that the pad
791 	 * is actually blocking at this point (see gst_pad_is_blocking()).
792 	 *
793 	 * Return: %TRUE if the pad is blocked.
794 	 *
795 	 *     MT safe.
796 	 */
797 	public bool isBlocked()
798 	{
799 		return gst_pad_is_blocked(gstPad) != 0;
800 	}
801 
802 	/**
803 	 * Checks if the pad is blocking or not. This is a guaranteed state
804 	 * of whether the pad is actually blocking on a #GstBuffer or a #GstEvent.
805 	 *
806 	 * Return: %TRUE if the pad is blocking.
807 	 *
808 	 *     MT safe.
809 	 */
810 	public bool isBlocking()
811 	{
812 		return gst_pad_is_blocking(gstPad) != 0;
813 	}
814 
815 	/**
816 	 * Checks if a @pad is linked to another pad or not.
817 	 *
818 	 * Return: %TRUE if the pad is linked, %FALSE otherwise.
819 	 *
820 	 *     MT safe.
821 	 */
822 	public bool isLinked()
823 	{
824 		return gst_pad_is_linked(gstPad) != 0;
825 	}
826 
827 	/**
828 	 * Gets an iterator for the pads to which the given pad is linked to inside
829 	 * of the parent element.
830 	 *
831 	 * Each #GstPad element yielded by the iterator will have its refcount increased,
832 	 * so unref after use.
833 	 *
834 	 * Free-function: gst_iterator_free
835 	 *
836 	 * Return: a new #GstIterator of #GstPad
837 	 *     or %NULL when the pad does not have an iterator function
838 	 *     configured. Use gst_iterator_free() after usage.
839 	 */
840 	public Iterator iterateInternalLinks()
841 	{
842 		auto p = gst_pad_iterate_internal_links(gstPad);
843 		
844 		if(p is null)
845 		{
846 			return null;
847 		}
848 		
849 		return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p);
850 	}
851 
852 	/**
853 	 * Iterate the list of pads to which the given pad is linked to inside of
854 	 * the parent element.
855 	 * This is the default handler, and thus returns an iterator of all of the
856 	 * pads inside the parent element with opposite direction.
857 	 *
858 	 * The caller must free this iterator after use with gst_iterator_free().
859 	 *
860 	 * Params:
861 	 *     parent = the parent of @pad or %NULL
862 	 *
863 	 * Return: a #GstIterator of #GstPad, or %NULL if @pad
864 	 *     has no parent. Unref each returned pad with gst_object_unref().
865 	 */
866 	public Iterator iterateInternalLinksDefault(ObjectGst parent)
867 	{
868 		auto p = gst_pad_iterate_internal_links_default(gstPad, (parent is null) ? null : parent.getObjectGstStruct());
869 		
870 		if(p is null)
871 		{
872 			return null;
873 		}
874 		
875 		return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p);
876 	}
877 
878 	/**
879 	 * Links the source pad and the sink pad.
880 	 *
881 	 * Params:
882 	 *     sinkpad = the sink #GstPad to link.
883 	 *
884 	 * Return: A result code indicating if the connection worked or
885 	 *     what went wrong.
886 	 *
887 	 *     MT Safe.
888 	 */
889 	public GstPadLinkReturn link(Pad sinkpad)
890 	{
891 		return gst_pad_link(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct());
892 	}
893 
894 	/**
895 	 * Links the source pad and the sink pad.
896 	 *
897 	 * This variant of #gst_pad_link provides a more granular control on the
898 	 * checks being done when linking. While providing some considerable speedups
899 	 * the caller of this method must be aware that wrong usage of those flags
900 	 * can cause severe issues. Refer to the documentation of #GstPadLinkCheck
901 	 * for more information.
902 	 *
903 	 * MT Safe.
904 	 *
905 	 * Params:
906 	 *     sinkpad = the sink #GstPad to link.
907 	 *     flags = the checks to validate when linking
908 	 *
909 	 * Return: A result code indicating if the connection worked or
910 	 *     what went wrong.
911 	 */
912 	public GstPadLinkReturn linkFull(Pad sinkpad, GstPadLinkCheck flags)
913 	{
914 		return gst_pad_link_full(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct(), flags);
915 	}
916 
917 	/**
918 	 * Mark a pad for needing reconfiguration. The next call to
919 	 * gst_pad_check_reconfigure() will return %TRUE after this call.
920 	 */
921 	public void markReconfigure()
922 	{
923 		gst_pad_mark_reconfigure(gstPad);
924 	}
925 
926 	/**
927 	 * Check the #GST_PAD_FLAG_NEED_RECONFIGURE flag on @pad and return %TRUE
928 	 * if the flag was set.
929 	 *
930 	 * Return: %TRUE is the GST_PAD_FLAG_NEED_RECONFIGURE flag is set on @pad.
931 	 */
932 	public bool needsReconfigure()
933 	{
934 		return gst_pad_needs_reconfigure(gstPad) != 0;
935 	}
936 
937 	/**
938 	 * Pause the task of @pad. This function will also wait until the
939 	 * function executed by the task is finished if this function is not
940 	 * called from the task function.
941 	 *
942 	 * Return: a %TRUE if the task could be paused or %FALSE when the pad
943 	 *     has no task.
944 	 */
945 	public bool pauseTask()
946 	{
947 		return gst_pad_pause_task(gstPad) != 0;
948 	}
949 
950 	/**
951 	 * Performs gst_pad_query() on the peer of @pad.
952 	 *
953 	 * The caller is responsible for both the allocation and deallocation of
954 	 * the query structure.
955 	 *
956 	 * Params:
957 	 *     query = the #GstQuery to perform.
958 	 *
959 	 * Return: %TRUE if the query could be performed. This function returns %FALSE
960 	 *     if @pad has no peer.
961 	 */
962 	public bool peerQuery(Query query)
963 	{
964 		return gst_pad_peer_query(gstPad, (query is null) ? null : query.getQueryStruct()) != 0;
965 	}
966 
967 	/**
968 	 * Check if the peer of @pad accepts @caps. If @pad has no peer, this function
969 	 * returns %TRUE.
970 	 *
971 	 * Params:
972 	 *     caps = a #GstCaps to check on the pad
973 	 *
974 	 * Return: %TRUE if the peer of @pad can accept the caps or @pad has no peer.
975 	 */
976 	public bool peerQueryAcceptCaps(Caps caps)
977 	{
978 		return gst_pad_peer_query_accept_caps(gstPad, (caps is null) ? null : caps.getCapsStruct()) != 0;
979 	}
980 
981 	/**
982 	 * Gets the capabilities of the peer connected to this pad. Similar to
983 	 * gst_pad_query_caps().
984 	 *
985 	 * When called on srcpads @filter contains the caps that
986 	 * upstream could produce in the order preferred by upstream. When
987 	 * called on sinkpads @filter contains the caps accepted by
988 	 * downstream in the preferred order. @filter might be %NULL but
989 	 * if it is not %NULL the returned caps will be a subset of @filter.
990 	 *
991 	 * Params:
992 	 *     filter = a #GstCaps filter, or %NULL.
993 	 *
994 	 * Return: the caps of the peer pad with incremented ref-count. When there is
995 	 *     no peer pad, this function returns @filter or, when @filter is %NULL, ANY
996 	 *     caps.
997 	 */
998 	public Caps peerQueryCaps(Caps filter)
999 	{
1000 		auto p = gst_pad_peer_query_caps(gstPad, (filter is null) ? null : filter.getCapsStruct());
1001 		
1002 		if(p is null)
1003 		{
1004 			return null;
1005 		}
1006 		
1007 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
1008 	}
1009 
1010 	/**
1011 	 * Queries the peer pad of a given sink pad to convert @src_val in @src_format
1012 	 * to @dest_format.
1013 	 *
1014 	 * Params:
1015 	 *     srcFormat = a #GstFormat to convert from.
1016 	 *     srcVal = a value to convert.
1017 	 *     destFormat = the #GstFormat to convert to.
1018 	 *     destVal = a pointer to the result.
1019 	 *
1020 	 * Return: %TRUE if the query could be performed.
1021 	 */
1022 	public bool peerQueryConvert(GstFormat srcFormat, long srcVal, GstFormat destFormat, out long destVal)
1023 	{
1024 		return gst_pad_peer_query_convert(gstPad, srcFormat, srcVal, destFormat, &destVal) != 0;
1025 	}
1026 
1027 	/**
1028 	 * Queries the peer pad of a given sink pad for the total stream duration.
1029 	 *
1030 	 * Params:
1031 	 *     format = the #GstFormat requested
1032 	 *     duration = a location in which to store the total
1033 	 *         duration, or %NULL.
1034 	 *
1035 	 * Return: %TRUE if the query could be performed.
1036 	 */
1037 	public bool peerQueryDuration(GstFormat format, out long duration)
1038 	{
1039 		return gst_pad_peer_query_duration(gstPad, format, &duration) != 0;
1040 	}
1041 
1042 	/**
1043 	 * Queries the peer of a given sink pad for the stream position.
1044 	 *
1045 	 * Params:
1046 	 *     format = the #GstFormat requested
1047 	 *     cur = a location in which to store the current
1048 	 *         position, or %NULL.
1049 	 *
1050 	 * Return: %TRUE if the query could be performed.
1051 	 */
1052 	public bool peerQueryPosition(GstFormat format, out long cur)
1053 	{
1054 		return gst_pad_peer_query_position(gstPad, format, &cur) != 0;
1055 	}
1056 
1057 	/**
1058 	 * Checks if all internally linked pads of @pad accepts the caps in @query and
1059 	 * returns the intersection of the results.
1060 	 *
1061 	 * This function is useful as a default accept caps query function for an element
1062 	 * that can handle any stream format, but requires caps that are acceptable for
1063 	 * all opposite pads.
1064 	 *
1065 	 * Params:
1066 	 *     query = an ACCEPT_CAPS #GstQuery.
1067 	 *
1068 	 * Return: %TRUE if @query could be executed
1069 	 */
1070 	public bool proxyQueryAcceptCaps(Query query)
1071 	{
1072 		return gst_pad_proxy_query_accept_caps(gstPad, (query is null) ? null : query.getQueryStruct()) != 0;
1073 	}
1074 
1075 	/**
1076 	 * Calls gst_pad_query_caps() for all internally linked pads of @pad and returns
1077 	 * the intersection of the results.
1078 	 *
1079 	 * This function is useful as a default caps query function for an element
1080 	 * that can handle any stream format, but requires all its pads to have
1081 	 * the same caps.  Two such elements are tee and adder.
1082 	 *
1083 	 * Params:
1084 	 *     query = a CAPS #GstQuery.
1085 	 *
1086 	 * Return: %TRUE if @query could be executed
1087 	 */
1088 	public bool proxyQueryCaps(Query query)
1089 	{
1090 		return gst_pad_proxy_query_caps(gstPad, (query is null) ? null : query.getQueryStruct()) != 0;
1091 	}
1092 
1093 	/**
1094 	 * Pulls a @buffer from the peer pad or fills up a provided buffer.
1095 	 *
1096 	 * This function will first trigger the pad block signal if it was
1097 	 * installed.
1098 	 *
1099 	 * When @pad is not linked #GST_FLOW_NOT_LINKED is returned else this
1100 	 * function returns the result of gst_pad_get_range() on the peer pad.
1101 	 * See gst_pad_get_range() for a list of return values and for the
1102 	 * semantics of the arguments of this function.
1103 	 *
1104 	 * If @buffer points to a variable holding %NULL, a valid new #GstBuffer will be
1105 	 * placed in @buffer when this function returns #GST_FLOW_OK. The new buffer
1106 	 * must be freed with gst_buffer_unref() after usage. When this function
1107 	 * returns any other result value, @buffer will still point to %NULL.
1108 	 *
1109 	 * When @buffer points to a variable that points to a valid #GstBuffer, the
1110 	 * buffer will be filled with the result data when this function returns
1111 	 * #GST_FLOW_OK. When this function returns any other result value,
1112 	 * @buffer will be unchanged. If the provided buffer is larger than @size, only
1113 	 * @size bytes will be filled in the result buffer and its size will be updated
1114 	 * accordingly.
1115 	 *
1116 	 * Note that less than @size bytes can be returned in @buffer when, for example,
1117 	 * an EOS condition is near or when @buffer is not large enough to hold @size
1118 	 * bytes. The caller should check the result buffer size to get the result size.
1119 	 *
1120 	 * Params:
1121 	 *     offset = The start offset of the buffer
1122 	 *     size = The length of the buffer
1123 	 *     buffer = a pointer to hold the #GstBuffer, returns
1124 	 *         GST_FLOW_ERROR if %NULL.
1125 	 *
1126 	 * Return: a #GstFlowReturn from the peer pad.
1127 	 *
1128 	 *     MT safe.
1129 	 */
1130 	public GstFlowReturn pullRange(ulong offset, uint size, out Buffer buffer)
1131 	{
1132 		GstBuffer* outbuffer = null;
1133 		
1134 		auto p = gst_pad_pull_range(gstPad, offset, size, &outbuffer);
1135 		
1136 		buffer = ObjectG.getDObject!(Buffer)(outbuffer);
1137 		
1138 		return p;
1139 	}
1140 
1141 	/**
1142 	 * Pushes a buffer to the peer of @pad.
1143 	 *
1144 	 * This function will call installed block probes before triggering any
1145 	 * installed data probes.
1146 	 *
1147 	 * The function proceeds calling gst_pad_chain() on the peer pad and returns
1148 	 * the value from that function. If @pad has no peer, #GST_FLOW_NOT_LINKED will
1149 	 * be returned.
1150 	 *
1151 	 * In all cases, success or failure, the caller loses its reference to @buffer
1152 	 * after calling this function.
1153 	 *
1154 	 * Params:
1155 	 *     buffer = the #GstBuffer to push returns GST_FLOW_ERROR
1156 	 *         if not.
1157 	 *
1158 	 * Return: a #GstFlowReturn from the peer pad.
1159 	 *
1160 	 *     MT safe.
1161 	 */
1162 	public GstFlowReturn push(Buffer buffer)
1163 	{
1164 		return gst_pad_push(gstPad, (buffer is null) ? null : buffer.getBufferStruct());
1165 	}
1166 
1167 	/**
1168 	 * Sends the event to the peer of the given pad. This function is
1169 	 * mainly used by elements to send events to their peer
1170 	 * elements.
1171 	 *
1172 	 * This function takes ownership of the provided event so you should
1173 	 * gst_event_ref() it if you want to reuse the event after this call.
1174 	 *
1175 	 * Params:
1176 	 *     event = the #GstEvent to send to the pad.
1177 	 *
1178 	 * Return: %TRUE if the event was handled.
1179 	 *
1180 	 *     MT safe.
1181 	 */
1182 	public bool pushEvent(Event event)
1183 	{
1184 		return gst_pad_push_event(gstPad, (event is null) ? null : event.getEventStruct()) != 0;
1185 	}
1186 
1187 	/**
1188 	 * Pushes a buffer list to the peer of @pad.
1189 	 *
1190 	 * This function will call installed block probes before triggering any
1191 	 * installed data probes.
1192 	 *
1193 	 * The function proceeds calling the chain function on the peer pad and returns
1194 	 * the value from that function. If @pad has no peer, #GST_FLOW_NOT_LINKED will
1195 	 * be returned. If the peer pad does not have any installed chainlist function
1196 	 * every group buffer of the list will be merged into a normal #GstBuffer and
1197 	 * chained via gst_pad_chain().
1198 	 *
1199 	 * In all cases, success or failure, the caller loses its reference to @list
1200 	 * after calling this function.
1201 	 *
1202 	 * Params:
1203 	 *     list = the #GstBufferList to push returns GST_FLOW_ERROR
1204 	 *         if not.
1205 	 *
1206 	 * Return: a #GstFlowReturn from the peer pad.
1207 	 *
1208 	 *     MT safe.
1209 	 */
1210 	public GstFlowReturn pushList(BufferList list)
1211 	{
1212 		return gst_pad_push_list(gstPad, (list is null) ? null : list.getBufferListStruct());
1213 	}
1214 
1215 	/**
1216 	 * Dispatches a query to a pad. The query should have been allocated by the
1217 	 * caller via one of the type-specific allocation functions. The element that
1218 	 * the pad belongs to is responsible for filling the query with an appropriate
1219 	 * response, which should then be parsed with a type-specific query parsing
1220 	 * function.
1221 	 *
1222 	 * Again, the caller is responsible for both the allocation and deallocation of
1223 	 * the query structure.
1224 	 *
1225 	 * Please also note that some queries might need a running pipeline to work.
1226 	 *
1227 	 * Params:
1228 	 *     query = the #GstQuery to perform.
1229 	 *
1230 	 * Return: %TRUE if the query could be performed.
1231 	 */
1232 	public bool query(Query query)
1233 	{
1234 		return gst_pad_query(gstPad, (query is null) ? null : query.getQueryStruct()) != 0;
1235 	}
1236 
1237 	/**
1238 	 * Check if the given pad accepts the caps.
1239 	 *
1240 	 * Params:
1241 	 *     caps = a #GstCaps to check on the pad
1242 	 *
1243 	 * Return: %TRUE if the pad can accept the caps.
1244 	 */
1245 	public bool queryAcceptCaps(Caps caps)
1246 	{
1247 		return gst_pad_query_accept_caps(gstPad, (caps is null) ? null : caps.getCapsStruct()) != 0;
1248 	}
1249 
1250 	/**
1251 	 * Gets the capabilities this pad can produce or consume.
1252 	 * Note that this method doesn't necessarily return the caps set by sending a
1253 	 * gst_event_new_caps() - use gst_pad_get_current_caps() for that instead.
1254 	 * gst_pad_query_caps returns all possible caps a pad can operate with, using
1255 	 * the pad's CAPS query function, If the query fails, this function will return
1256 	 * @filter, if not %NULL, otherwise ANY.
1257 	 *
1258 	 * When called on sinkpads @filter contains the caps that
1259 	 * upstream could produce in the order preferred by upstream. When
1260 	 * called on srcpads @filter contains the caps accepted by
1261 	 * downstream in the preferred order. @filter might be %NULL but
1262 	 * if it is not %NULL the returned caps will be a subset of @filter.
1263 	 *
1264 	 * Note that this function does not return writable #GstCaps, use
1265 	 * gst_caps_make_writable() before modifying the caps.
1266 	 *
1267 	 * Params:
1268 	 *     filter = suggested #GstCaps, or %NULL
1269 	 *
1270 	 * Return: the caps of the pad with incremented ref-count.
1271 	 */
1272 	public Caps queryCaps(Caps filter)
1273 	{
1274 		auto p = gst_pad_query_caps(gstPad, (filter is null) ? null : filter.getCapsStruct());
1275 		
1276 		if(p is null)
1277 		{
1278 			return null;
1279 		}
1280 		
1281 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
1282 	}
1283 
1284 	/**
1285 	 * Queries a pad to convert @src_val in @src_format to @dest_format.
1286 	 *
1287 	 * Params:
1288 	 *     srcFormat = a #GstFormat to convert from.
1289 	 *     srcVal = a value to convert.
1290 	 *     destFormat = the #GstFormat to convert to.
1291 	 *     destVal = a pointer to the result.
1292 	 *
1293 	 * Return: %TRUE if the query could be performed.
1294 	 */
1295 	public bool queryConvert(GstFormat srcFormat, long srcVal, GstFormat destFormat, out long destVal)
1296 	{
1297 		return gst_pad_query_convert(gstPad, srcFormat, srcVal, destFormat, &destVal) != 0;
1298 	}
1299 
1300 	/**
1301 	 * Invokes the default query handler for the given pad.
1302 	 * The query is sent to all pads internally linked to @pad. Note that
1303 	 * if there are many possible sink pads that are internally linked to
1304 	 * @pad, only one will be sent the query.
1305 	 * Multi-sinkpad elements should implement custom query handlers.
1306 	 *
1307 	 * Params:
1308 	 *     parent = the parent of @pad or %NULL
1309 	 *     query = the #GstQuery to handle.
1310 	 *
1311 	 * Return: %TRUE if the query was performed successfully.
1312 	 */
1313 	public bool queryDefault(ObjectGst parent, Query query)
1314 	{
1315 		return gst_pad_query_default(gstPad, (parent is null) ? null : parent.getObjectGstStruct(), (query is null) ? null : query.getQueryStruct()) != 0;
1316 	}
1317 
1318 	/**
1319 	 * Queries a pad for the total stream duration.
1320 	 *
1321 	 * Params:
1322 	 *     format = the #GstFormat requested
1323 	 *     duration = a location in which to store the total
1324 	 *         duration, or %NULL.
1325 	 *
1326 	 * Return: %TRUE if the query could be performed.
1327 	 */
1328 	public bool queryDuration(GstFormat format, out long duration)
1329 	{
1330 		return gst_pad_query_duration(gstPad, format, &duration) != 0;
1331 	}
1332 
1333 	/**
1334 	 * Queries a pad for the stream position.
1335 	 *
1336 	 * Params:
1337 	 *     format = the #GstFormat requested
1338 	 *     cur = A location in which to store the current position, or %NULL.
1339 	 *
1340 	 * Return: %TRUE if the query could be performed.
1341 	 */
1342 	public bool queryPosition(GstFormat format, out long cur)
1343 	{
1344 		return gst_pad_query_position(gstPad, format, &cur) != 0;
1345 	}
1346 
1347 	/**
1348 	 * Remove the probe with @id from @pad.
1349 	 *
1350 	 * MT safe.
1351 	 *
1352 	 * Params:
1353 	 *     id = the probe id to remove
1354 	 */
1355 	public void removeProbe(gulong id)
1356 	{
1357 		gst_pad_remove_probe(gstPad, id);
1358 	}
1359 
1360 	/**
1361 	 * Sends the event to the pad. This function can be used
1362 	 * by applications to send events in the pipeline.
1363 	 *
1364 	 * If @pad is a source pad, @event should be an upstream event. If @pad is a
1365 	 * sink pad, @event should be a downstream event. For example, you would not
1366 	 * send a #GST_EVENT_EOS on a src pad; EOS events only propagate downstream.
1367 	 * Furthermore, some downstream events have to be serialized with data flow,
1368 	 * like EOS, while some can travel out-of-band, like #GST_EVENT_FLUSH_START. If
1369 	 * the event needs to be serialized with data flow, this function will take the
1370 	 * pad's stream lock while calling its event function.
1371 	 *
1372 	 * To find out whether an event type is upstream, downstream, or downstream and
1373 	 * serialized, see #GstEventTypeFlags, gst_event_type_get_flags(),
1374 	 * #GST_EVENT_IS_UPSTREAM, #GST_EVENT_IS_DOWNSTREAM, and
1375 	 * #GST_EVENT_IS_SERIALIZED. Note that in practice that an application or
1376 	 * plugin doesn't need to bother itself with this information; the core handles
1377 	 * all necessary locks and checks.
1378 	 *
1379 	 * This function takes ownership of the provided event so you should
1380 	 * gst_event_ref() it if you want to reuse the event after this call.
1381 	 *
1382 	 * Params:
1383 	 *     event = the #GstEvent to send to the pad.
1384 	 *
1385 	 * Return: %TRUE if the event was handled.
1386 	 */
1387 	public bool sendEvent(Event event)
1388 	{
1389 		return gst_pad_send_event(gstPad, (event is null) ? null : event.getEventStruct()) != 0;
1390 	}
1391 
1392 	/**
1393 	 * Sets the given activate function for @pad. The activate function will
1394 	 * dispatch to gst_pad_activate_mode() to perform the actual activation.
1395 	 * Only makes sense to set on sink pads.
1396 	 *
1397 	 * Call this function if your sink pad can start a pull-based task.
1398 	 *
1399 	 * Params:
1400 	 *     activate = the #GstPadActivateFunction to set.
1401 	 *     userData = user_data passed to @notify
1402 	 *     notify = notify called when @activate will not be used anymore.
1403 	 */
1404 	public void setActivateFunctionFull(GstPadActivateFunction activate, void* userData, GDestroyNotify notify)
1405 	{
1406 		gst_pad_set_activate_function_full(gstPad, activate, userData, notify);
1407 	}
1408 
1409 	/**
1410 	 * Sets the given activate_mode function for the pad. An activate_mode function
1411 	 * prepares the element for data passing.
1412 	 *
1413 	 * Params:
1414 	 *     activatemode = the #GstPadActivateModeFunction to set.
1415 	 *     userData = user_data passed to @notify
1416 	 *     notify = notify called when @activatemode will not be used anymore.
1417 	 */
1418 	public void setActivatemodeFunctionFull(GstPadActivateModeFunction activatemode, void* userData, GDestroyNotify notify)
1419 	{
1420 		gst_pad_set_activatemode_function_full(gstPad, activatemode, userData, notify);
1421 	}
1422 
1423 	/**
1424 	 * Activates or deactivates the given pad.
1425 	 * Normally called from within core state change functions.
1426 	 *
1427 	 * If @active, makes sure the pad is active. If it is already active, either in
1428 	 * push or pull mode, just return. Otherwise dispatches to the pad's activate
1429 	 * function to perform the actual activation.
1430 	 *
1431 	 * If not @active, calls gst_pad_activate_mode() with the pad's current mode
1432 	 * and a %FALSE argument.
1433 	 *
1434 	 * Params:
1435 	 *     active = whether or not the pad should be active.
1436 	 *
1437 	 * Return: %TRUE if the operation was successful.
1438 	 *
1439 	 *     MT safe.
1440 	 */
1441 	public bool setActive(bool active)
1442 	{
1443 		return gst_pad_set_active(gstPad, active) != 0;
1444 	}
1445 
1446 	/**
1447 	 * Sets the given chain function for the pad. The chain function is called to
1448 	 * process a #GstBuffer input buffer. see #GstPadChainFunction for more details.
1449 	 *
1450 	 * Params:
1451 	 *     chain = the #GstPadChainFunction to set.
1452 	 *     userData = user_data passed to @notify
1453 	 *     notify = notify called when @chain will not be used anymore.
1454 	 */
1455 	public void setChainFunctionFull(GstPadChainFunction chain, void* userData, GDestroyNotify notify)
1456 	{
1457 		gst_pad_set_chain_function_full(gstPad, chain, userData, notify);
1458 	}
1459 
1460 	/**
1461 	 * Sets the given chain list function for the pad. The chainlist function is
1462 	 * called to process a #GstBufferList input buffer list. See
1463 	 * #GstPadChainListFunction for more details.
1464 	 *
1465 	 * Params:
1466 	 *     chainlist = the #GstPadChainListFunction to set.
1467 	 *     userData = user_data passed to @notify
1468 	 *     notify = notify called when @chainlist will not be used anymore.
1469 	 */
1470 	public void setChainListFunctionFull(GstPadChainListFunction chainlist, void* userData, GDestroyNotify notify)
1471 	{
1472 		gst_pad_set_chain_list_function_full(gstPad, chainlist, userData, notify);
1473 	}
1474 
1475 	/**
1476 	 * Set the given private data gpointer on the pad.
1477 	 * This function can only be used by the element that owns the pad.
1478 	 * No locking is performed in this function.
1479 	 *
1480 	 * Params:
1481 	 *     priv = The private data to attach to the pad.
1482 	 */
1483 	public void setElementPrivate(void* priv)
1484 	{
1485 		gst_pad_set_element_private(gstPad, priv);
1486 	}
1487 
1488 	/**
1489 	 * Sets the given event handler for the pad.
1490 	 *
1491 	 * Params:
1492 	 *     event = the #GstPadEventFunction to set.
1493 	 *     userData = user_data passed to @notify
1494 	 *     notify = notify called when @event will not be used anymore.
1495 	 */
1496 	public void setEventFunctionFull(GstPadEventFunction event, void* userData, GDestroyNotify notify)
1497 	{
1498 		gst_pad_set_event_function_full(gstPad, event, userData, notify);
1499 	}
1500 
1501 	/**
1502 	 * Sets the given getrange function for the pad. The getrange function is
1503 	 * called to produce a new #GstBuffer to start the processing pipeline. see
1504 	 * #GstPadGetRangeFunction for a description of the getrange function.
1505 	 *
1506 	 * Params:
1507 	 *     get = the #GstPadGetRangeFunction to set.
1508 	 *     userData = user_data passed to @notify
1509 	 *     notify = notify called when @get will not be used anymore.
1510 	 */
1511 	public void setGetrangeFunctionFull(GstPadGetRangeFunction get, void* userData, GDestroyNotify notify)
1512 	{
1513 		gst_pad_set_getrange_function_full(gstPad, get, userData, notify);
1514 	}
1515 
1516 	/**
1517 	 * Sets the given internal link iterator function for the pad.
1518 	 *
1519 	 * Params:
1520 	 *     iterintlink = the #GstPadIterIntLinkFunction to set.
1521 	 *     userData = user_data passed to @notify
1522 	 *     notify = notify called when @iterintlink will not be used anymore.
1523 	 */
1524 	public void setIterateInternalLinksFunctionFull(GstPadIterIntLinkFunction iterintlink, void* userData, GDestroyNotify notify)
1525 	{
1526 		gst_pad_set_iterate_internal_links_function_full(gstPad, iterintlink, userData, notify);
1527 	}
1528 
1529 	/**
1530 	 * Sets the given link function for the pad. It will be called when
1531 	 * the pad is linked with another pad.
1532 	 *
1533 	 * The return value #GST_PAD_LINK_OK should be used when the connection can be
1534 	 * made.
1535 	 *
1536 	 * The return value #GST_PAD_LINK_REFUSED should be used when the connection
1537 	 * cannot be made for some reason.
1538 	 *
1539 	 * If @link is installed on a source pad, it should call the #GstPadLinkFunction
1540 	 * of the peer sink pad, if present.
1541 	 *
1542 	 * Params:
1543 	 *     link = the #GstPadLinkFunction to set.
1544 	 *     userData = user_data passed to @notify
1545 	 *     notify = notify called when @link will not be used anymore.
1546 	 */
1547 	public void setLinkFunctionFull(GstPadLinkFunction link, void* userData, GDestroyNotify notify)
1548 	{
1549 		gst_pad_set_link_function_full(gstPad, link, userData, notify);
1550 	}
1551 
1552 	/**
1553 	 * Set the offset that will be applied to the running time of @pad.
1554 	 *
1555 	 * Params:
1556 	 *     offset = the offset
1557 	 */
1558 	public void setOffset(long offset)
1559 	{
1560 		gst_pad_set_offset(gstPad, offset);
1561 	}
1562 
1563 	/**
1564 	 * Set the given query function for the pad.
1565 	 *
1566 	 * Params:
1567 	 *     query = the #GstPadQueryFunction to set.
1568 	 *     userData = user_data passed to @notify
1569 	 *     notify = notify called when @query will not be used anymore.
1570 	 */
1571 	public void setQueryFunctionFull(GstPadQueryFunction query, void* userData, GDestroyNotify notify)
1572 	{
1573 		gst_pad_set_query_function_full(gstPad, query, userData, notify);
1574 	}
1575 
1576 	/**
1577 	 * Sets the given unlink function for the pad. It will be called
1578 	 * when the pad is unlinked.
1579 	 *
1580 	 * Params:
1581 	 *     unlink = the #GstPadUnlinkFunction to set.
1582 	 *     userData = user_data passed to @notify
1583 	 *     notify = notify called when @unlink will not be used anymore.
1584 	 */
1585 	public void setUnlinkFunctionFull(GstPadUnlinkFunction unlink, void* userData, GDestroyNotify notify)
1586 	{
1587 		gst_pad_set_unlink_function_full(gstPad, unlink, userData, notify);
1588 	}
1589 
1590 	/**
1591 	 * Starts a task that repeatedly calls @func with @user_data. This function
1592 	 * is mostly used in pad activation functions to start the dataflow.
1593 	 * The #GST_PAD_STREAM_LOCK of @pad will automatically be acquired
1594 	 * before @func is called.
1595 	 *
1596 	 * Params:
1597 	 *     func = the task function to call
1598 	 *     userData = user data passed to the task function
1599 	 *     notify = called when @user_data is no longer referenced
1600 	 *
1601 	 * Return: a %TRUE if the task could be started.
1602 	 */
1603 	public bool startTask(GstTaskFunction func, void* userData, GDestroyNotify notify)
1604 	{
1605 		return gst_pad_start_task(gstPad, func, userData, notify) != 0;
1606 	}
1607 
1608 	/**
1609 	 * Iterates all sticky events on @pad and calls @foreach_func for every
1610 	 * event. If @foreach_func returns %FALSE the iteration is immediately stopped.
1611 	 *
1612 	 * Params:
1613 	 *     foreachFunc = the #GstPadStickyEventsForeachFunction that
1614 	 *         should be called for every event.
1615 	 *     userData = the optional user data.
1616 	 */
1617 	public void stickyEventsForeach(GstPadStickyEventsForeachFunction foreachFunc, void* userData)
1618 	{
1619 		gst_pad_sticky_events_foreach(gstPad, foreachFunc, userData);
1620 	}
1621 
1622 	/**
1623 	 * Stop the task of @pad. This function will also make sure that the
1624 	 * function executed by the task will effectively stop if not called
1625 	 * from the GstTaskFunction.
1626 	 *
1627 	 * This function will deadlock if called from the GstTaskFunction of
1628 	 * the task. Use gst_task_pause() instead.
1629 	 *
1630 	 * Regardless of whether the pad has a task, the stream lock is acquired and
1631 	 * released so as to ensure that streaming through this pad has finished.
1632 	 *
1633 	 * Return: a %TRUE if the task could be stopped or %FALSE on error.
1634 	 */
1635 	public bool stopTask()
1636 	{
1637 		return gst_pad_stop_task(gstPad) != 0;
1638 	}
1639 
1640 	/**
1641 	 * Store the sticky @event on @pad
1642 	 *
1643 	 * Params:
1644 	 *     event = a #GstEvent
1645 	 *
1646 	 * Return: #GST_FLOW_OK on success, #GST_FLOW_FLUSHING when the pad
1647 	 *     was flushing or #GST_FLOW_EOS when the pad was EOS.
1648 	 *
1649 	 * Since: 1.2
1650 	 */
1651 	public GstFlowReturn storeStickyEvent(Event event)
1652 	{
1653 		return gst_pad_store_sticky_event(gstPad, (event is null) ? null : event.getEventStruct());
1654 	}
1655 
1656 	/**
1657 	 * Unlinks the source pad from the sink pad. Will emit the #GstPad::unlinked
1658 	 * signal on both pads.
1659 	 *
1660 	 * Params:
1661 	 *     sinkpad = the sink #GstPad to unlink.
1662 	 *
1663 	 * Return: %TRUE if the pads were unlinked. This function returns %FALSE if
1664 	 *     the pads were not linked together.
1665 	 *
1666 	 *     MT safe.
1667 	 */
1668 	public bool unlink(Pad sinkpad)
1669 	{
1670 		return gst_pad_unlink(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct()) != 0;
1671 	}
1672 
1673 	/**
1674 	 * A helper function you can use that sets the FIXED_CAPS flag
1675 	 * This way the default CAPS query will always return the negotiated caps
1676 	 * or in case the pad is not negotiated, the padtemplate caps.
1677 	 *
1678 	 * The negotiated caps are the caps of the last CAPS event that passed on the
1679 	 * pad. Use this function on a pad that, once it negotiated to a CAPS, cannot
1680 	 * be renegotiated to something else.
1681 	 */
1682 	public void useFixedCaps()
1683 	{
1684 		gst_pad_use_fixed_caps(gstPad);
1685 	}
1686 
1687 	int[string] connectedSignals;
1688 
1689 	void delegate(Pad, Pad)[] onLinkedListeners;
1690 	/**
1691 	 * Signals that a pad has been linked to the peer pad.
1692 	 *
1693 	 * Params:
1694 	 *     peer = the peer pad that has been connected
1695 	 */
1696 	void addOnLinked(void delegate(Pad, Pad) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1697 	{
1698 		if ( "linked" !in connectedSignals )
1699 		{
1700 			Signals.connectData(
1701 				this,
1702 				"linked",
1703 				cast(GCallback)&callBackLinked,
1704 				cast(void*)this,
1705 				null,
1706 				connectFlags);
1707 			connectedSignals["linked"] = 1;
1708 		}
1709 		onLinkedListeners ~= dlg;
1710 	}
1711 	extern(C) static void callBackLinked(GstPad* padStruct, GstPad* peer, Pad _pad)
1712 	{
1713 		foreach ( void delegate(Pad, Pad) dlg; _pad.onLinkedListeners )
1714 		{
1715 			dlg(ObjectG.getDObject!(Pad)(peer), _pad);
1716 		}
1717 	}
1718 
1719 	void delegate(Pad, Pad)[] onUnlinkedListeners;
1720 	/**
1721 	 * Signals that a pad has been unlinked from the peer pad.
1722 	 *
1723 	 * Params:
1724 	 *     peer = the peer pad that has been disconnected
1725 	 */
1726 	void addOnUnlinked(void delegate(Pad, Pad) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1727 	{
1728 		if ( "unlinked" !in connectedSignals )
1729 		{
1730 			Signals.connectData(
1731 				this,
1732 				"unlinked",
1733 				cast(GCallback)&callBackUnlinked,
1734 				cast(void*)this,
1735 				null,
1736 				connectFlags);
1737 			connectedSignals["unlinked"] = 1;
1738 		}
1739 		onUnlinkedListeners ~= dlg;
1740 	}
1741 	extern(C) static void callBackUnlinked(GstPad* padStruct, GstPad* peer, Pad _pad)
1742 	{
1743 		foreach ( void delegate(Pad, Pad) dlg; _pad.onUnlinkedListeners )
1744 		{
1745 			dlg(ObjectG.getDObject!(Pad)(peer), _pad);
1746 		}
1747 	}
1748 
1749 	/**
1750 	 * Gets a string representing the given flow return.
1751 	 *
1752 	 * Params:
1753 	 *     ret = a #GstFlowReturn to get the name of.
1754 	 *
1755 	 * Return: a static string with the name of the flow return.
1756 	 */
1757 	public static string flowGetName(GstFlowReturn ret)
1758 	{
1759 		return Str.toString(gst_flow_get_name(ret));
1760 	}
1761 
1762 	/**
1763 	 * Get the unique quark for the given GstFlowReturn.
1764 	 *
1765 	 * Params:
1766 	 *     ret = a #GstFlowReturn to get the quark of.
1767 	 *
1768 	 * Return: the quark associated with the flow return or 0 if an
1769 	 *     invalid return was specified.
1770 	 */
1771 	public static GQuark flowToQuark(GstFlowReturn ret)
1772 	{
1773 		return gst_flow_to_quark(ret);
1774 	}
1775 
1776 	/**
1777 	 * Return the name of a pad mode, for use in debug messages mostly.
1778 	 *
1779 	 * Params:
1780 	 *     mode = the pad mode
1781 	 *
1782 	 * Return: short mnemonic for pad mode @mode
1783 	 */
1784 	public static string modeGetName(GstPadMode mode)
1785 	{
1786 		return Str.toString(gst_pad_mode_get_name(mode));
1787 	}
1788 }