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