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