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 * - gst_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gst_pad_load_and_link 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - gstreamer.Element 50 * - gstreamer.MiniObject 51 * - gstreamer.PadTemplate 52 * - gstreamer.Caps 53 * - gstreamer.Buffer 54 * - gstreamer.Event 55 * - gstreamer.Query 56 * - glib.ListG 57 * structWrap: 58 * - GList* -> ListG 59 * - GstBuffer* -> Buffer 60 * - GstCaps* -> Caps 61 * - GstElement* -> Element 62 * - GstEvent* -> Event 63 * - GstMiniObject* -> MiniObject 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 83 private import glib.Str; 84 private import gstreamer.Element; 85 private import gstreamer.MiniObject; 86 private import gstreamer.PadTemplate; 87 private import gstreamer.Caps; 88 private import gstreamer.Buffer; 89 private import gstreamer.Event; 90 private import gstreamer.Query; 91 private import glib.ListG; 92 93 94 95 private import gstreamer.ObjectGst; 96 97 /** 98 * Description 99 * A GstElement is linked to other elements via "pads", which are extremely 100 * light-weight generic link points. 101 * After two pads are retrieved from an element with gst_element_get_pad(), 102 * the pads can be link with gst_pad_link(). (For quick links, 103 * you can also use gst_element_link(), which will make the obvious 104 * link for you if it's straightforward.) 105 * Pads are typically created from a GstPadTemplate with 106 * gst_pad_new_from_template(). 107 * Pads have GstCaps attached to it to describe the media type they are 108 * capable of dealing with. gst_pad_get_caps() and gst_pad_set_caps() are 109 * used to manipulate the caps of the pads. 110 * Pads created from a pad template cannot set capabilities that are 111 * incompatible with the pad template capabilities. 112 * Pads without pad templates can be created with gst_pad_new(), 113 * which takes a direction and a name as an argument. If the name is NULL, 114 * then a guaranteed unique name will be assigned to it. 115 * gst_pad_get_parent() will retrieve the GstElement that owns the pad. 116 * A GstElement creating a pad will typically use the various 117 * gst_pad_set_*_function() calls to register callbacks for various events 118 * on the pads. 119 * GstElements will use gst_pad_push() and gst_pad_pull_range() to push out 120 * or pull in a buffer. 121 * To send a GstEvent on a pad, use gst_pad_send_event() and 122 * gst_pad_push_event(). 123 * Last reviewed on 2006-07-06 (0.10.9) 124 */ 125 public class Pad : ObjectGst 126 { 127 128 /** the main Gtk struct */ 129 protected GstPad* gstPad; 130 131 132 public GstPad* getPadStruct() 133 { 134 return gstPad; 135 } 136 137 138 /** the main Gtk struct as a void* */ 139 protected override void* getStruct() 140 { 141 return cast(void*)gstPad; 142 } 143 144 /** 145 * Sets our main struct and passes it to the parent class 146 */ 147 public this (GstPad* gstPad) 148 { 149 super(cast(GstObject*)gstPad); 150 this.gstPad = gstPad; 151 } 152 153 protected override void setStruct(GObject* obj) 154 { 155 super.setStruct(obj); 156 gstPad = cast(GstPad*)obj; 157 } 158 159 /** 160 * Sets our main struct and passes it to the parent class. 161 * This one is additional to make gstreamer.Element addOnPadAdded() 162 * working without changes. 163 */ 164 public this (GObject* gstPad) 165 { 166 super(cast(GstObject*)gstPad); 167 this.gstPad = cast(GstPad*) gstPad; 168 } 169 170 /** 171 * Queries a pad for the stream position. 172 * This is a convenience function for gstreamerD. 173 * Returns: 174 * The current position in nanoseconds - GstFormat.TIME. 175 */ 176 public long queryPosition() 177 { 178 GstFormat form = GstFormat.TIME; 179 long cur_pos; 180 queryPosition( form, cur_pos ); 181 return cur_pos; 182 } 183 184 /** 185 * Queries a pad for the stream duration. 186 * This is a convenience function for gstreamerD. 187 * Returns: 188 * The duration in nanoseconds - GstFormat.TIME. 189 */ 190 public long queryDuration() 191 { 192 GstFormat form = GstFormat.TIME; 193 long cur_dur; 194 queryDuration( form, cur_dur ); 195 return cur_dur; 196 } 197 198 199 /** 200 */ 201 int[string] connectedSignals; 202 203 bool delegate(MiniObject, Pad)[] onHaveDataListeners; 204 /** 205 * Signals that new data is available on the pad. This signal is used 206 * internally for implementing pad probes. 207 * See gst_pad_add_*_probe functions. 208 */ 209 void addOnHaveData(bool delegate(MiniObject, Pad) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 210 { 211 if ( !("have-data" in connectedSignals) ) 212 { 213 Signals.connectData( 214 getStruct(), 215 "have-data", 216 cast(GCallback)&callBackHaveData, 217 cast(void*)this, 218 null, 219 connectFlags); 220 connectedSignals["have-data"] = 1; 221 } 222 onHaveDataListeners ~= dlg; 223 } 224 extern(C) static gboolean callBackHaveData(GstPad* padStruct, GstMiniObject* miniObj, Pad _pad) 225 { 226 foreach ( bool delegate(MiniObject, Pad) dlg ; _pad.onHaveDataListeners ) 227 { 228 if ( dlg(ObjectG.getDObject!(MiniObject)(miniObj), _pad) ) 229 { 230 return 1; 231 } 232 } 233 234 return 0; 235 } 236 237 void delegate(Pad, Pad)[] onLinkedListeners; 238 /** 239 * Signals that a pad has been linked to the peer pad. 240 */ 241 void addOnLinked(void delegate(Pad, Pad) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 242 { 243 if ( !("linked" in connectedSignals) ) 244 { 245 Signals.connectData( 246 getStruct(), 247 "linked", 248 cast(GCallback)&callBackLinked, 249 cast(void*)this, 250 null, 251 connectFlags); 252 connectedSignals["linked"] = 1; 253 } 254 onLinkedListeners ~= dlg; 255 } 256 extern(C) static void callBackLinked(GstPad* padStruct, GstPad* peer, Pad _pad) 257 { 258 foreach ( void delegate(Pad, Pad) dlg ; _pad.onLinkedListeners ) 259 { 260 dlg(ObjectG.getDObject!(Pad)(peer), _pad); 261 } 262 } 263 264 void delegate(Pad)[] onRequestLinkListeners; 265 /** 266 * Signals that a pad connection has been requested. 267 */ 268 void addOnRequestLink(void delegate(Pad) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 269 { 270 if ( !("request-link" in connectedSignals) ) 271 { 272 Signals.connectData( 273 getStruct(), 274 "request-link", 275 cast(GCallback)&callBackRequestLink, 276 cast(void*)this, 277 null, 278 connectFlags); 279 connectedSignals["request-link"] = 1; 280 } 281 onRequestLinkListeners ~= dlg; 282 } 283 extern(C) static void callBackRequestLink(GstPad* padStruct, Pad _pad) 284 { 285 foreach ( void delegate(Pad) dlg ; _pad.onRequestLinkListeners ) 286 { 287 dlg(_pad); 288 } 289 } 290 291 void delegate(Pad, Pad)[] onUnlinkedListeners; 292 /** 293 * Signals that a pad has been unlinked from the peer pad. 294 * See Also 295 * GstPadTemplate, GstElement, GstEvent 296 */ 297 void addOnUnlinked(void delegate(Pad, Pad) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 298 { 299 if ( !("unlinked" in connectedSignals) ) 300 { 301 Signals.connectData( 302 getStruct(), 303 "unlinked", 304 cast(GCallback)&callBackUnlinked, 305 cast(void*)this, 306 null, 307 connectFlags); 308 connectedSignals["unlinked"] = 1; 309 } 310 onUnlinkedListeners ~= dlg; 311 } 312 extern(C) static void callBackUnlinked(GstPad* padStruct, GstPad* peer, Pad _pad) 313 { 314 foreach ( void delegate(Pad, Pad) dlg ; _pad.onUnlinkedListeners ) 315 { 316 dlg(ObjectG.getDObject!(Pad)(peer), _pad); 317 } 318 } 319 320 321 /** 322 * Gets the direction of the pad. The direction of the pad is 323 * decided at construction time so this function does not take 324 * the LOCK. 325 * Returns: the GstPadDirection of the pad. MT safe. 326 */ 327 public GstPadDirection getDirection() 328 { 329 // GstPadDirection gst_pad_get_direction (GstPad *pad); 330 return gst_pad_get_direction(gstPad); 331 } 332 333 /** 334 * Gets the parent of pad, cast to a GstElement. If a pad has no parent or 335 * its parent is not an element, return NULL. 336 * Returns: The parent of the pad. The caller has a reference on the parent, so unref when you're finished with it. MT safe. 337 */ 338 public Element getParentElement() 339 { 340 // GstElement* gst_pad_get_parent_element (GstPad *pad); 341 auto p = gst_pad_get_parent_element(gstPad); 342 343 if(p is null) 344 { 345 return null; 346 } 347 348 return ObjectG.getDObject!(Element)(cast(GstElement*) p); 349 } 350 351 /** 352 * Gets the template for pad. 353 * Returns: the GstPadTemplate from which this pad was instantiated, or NULL if this pad has no template. FIXME: currently returns an unrefcounted padtemplate. 354 */ 355 public PadTemplate getPadTemplate() 356 { 357 // GstPadTemplate* gst_pad_get_pad_template (GstPad *pad); 358 auto p = gst_pad_get_pad_template(gstPad); 359 360 if(p is null) 361 { 362 return null; 363 } 364 365 return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p); 366 } 367 368 /** 369 * Links the source pad and the sink pad. 370 * Params: 371 * sinkpad = the sink GstPad to link. 372 * Returns: A result code indicating if the connection worked or what went wrong. MT Safe. 373 */ 374 public GstPadLinkReturn link(Pad sinkpad) 375 { 376 // GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad); 377 return gst_pad_link(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct()); 378 } 379 380 /** 381 * Unlinks the source pad from the sink pad. Will emit the "unlinked" signal on 382 * both pads. 383 * Params: 384 * sinkpad = the sink GstPad to unlink. 385 * Returns: TRUE if the pads were unlinked. This function returns FALSE if the pads were not linked together. MT safe. 386 */ 387 public int unlink(Pad sinkpad) 388 { 389 // gboolean gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad); 390 return gst_pad_unlink(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct()); 391 } 392 393 /** 394 * Checks if a pad is linked to another pad or not. 395 * Returns: TRUE if the pad is linked, FALSE otherwise. MT safe. 396 */ 397 public int isLinked() 398 { 399 // gboolean gst_pad_is_linked (GstPad *pad); 400 return gst_pad_is_linked(gstPad); 401 } 402 403 /** 404 * Checks if the source pad and the sink pad can be linked. 405 * Both srcpad and sinkpad must be unlinked. 406 * Params: 407 * sinkpad = the sink GstPad to link. 408 * Returns: TRUE if the pads can be linked, FALSE otherwise. 409 */ 410 public int canLink(Pad sinkpad) 411 { 412 // gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad); 413 return gst_pad_can_link(gstPad, (sinkpad is null) ? null : sinkpad.getPadStruct()); 414 } 415 416 /** 417 * Gets the capabilities this pad can produce or consume. 418 * Note that this method doesn't necessarily return the caps set by 419 * gst_pad_set_caps() - use GST_PAD_CAPS for that instead. 420 * gst_pad_get_caps returns all possible caps a pad can operate with, using 421 * the pad's get_caps function; 422 * this returns the pad template caps if not explicitly set. 423 * Returns: a newly allocated copy of the GstCaps of this pad. MT safe. 424 */ 425 public Caps getCaps() 426 { 427 // GstCaps* gst_pad_get_caps (GstPad *pad); 428 auto p = gst_pad_get_caps(gstPad); 429 430 if(p is null) 431 { 432 return null; 433 } 434 435 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 436 } 437 438 /** 439 * Gets the capabilities of the allowed media types that can flow through 440 * pad and its peer. 441 * The allowed capabilities is calculated as the intersection of the results of 442 * calling gst_pad_get_caps() on pad and its peer. The caller owns a reference 443 * on the resulting caps. 444 * 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. 445 */ 446 public Caps getAllowedCaps() 447 { 448 // GstCaps* gst_pad_get_allowed_caps (GstPad *pad); 449 auto p = gst_pad_get_allowed_caps(gstPad); 450 451 if(p is null) 452 { 453 return null; 454 } 455 456 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 457 } 458 459 /** 460 * Gets the capabilities of the media type that currently flows through pad 461 * and its peer. 462 * This function can be used on both src and sinkpads. Note that srcpads are 463 * always negotiated before sinkpads so it is possible that the negotiated caps 464 * on the srcpad do not match the negotiated caps of the peer. 465 * Returns: the negotiated GstCaps of the pad link. Unref the caps when you no longer need it. This function returns NULL when the pad has no peer or is not negotiated yet. MT safe. 466 */ 467 public Caps getNegotiatedCaps() 468 { 469 // GstCaps* gst_pad_get_negotiated_caps (GstPad *pad); 470 auto p = gst_pad_get_negotiated_caps(gstPad); 471 472 if(p is null) 473 { 474 return null; 475 } 476 477 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 478 } 479 480 /** 481 * Gets the capabilities for pad's template. 482 * Returns: the GstCaps of this pad template. If you intend to keep a reference on the caps, make a copy (see gst_caps_copy()). 483 */ 484 public Caps getPadTemplateCaps() 485 { 486 // const GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); 487 auto p = gst_pad_get_pad_template_caps(gstPad); 488 489 if(p is null) 490 { 491 return null; 492 } 493 494 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 495 } 496 497 /** 498 * Sets the capabilities of this pad. The caps must be fixed. Any previous 499 * caps on the pad will be unreffed. This function refs the caps so you should 500 * unref if as soon as you don't need it anymore. 501 * It is possible to set NULL caps, which will make the pad unnegotiated 502 * again. 503 * Params: 504 * caps = a GstCaps to set. 505 * Returns: TRUE if the caps could be set. FALSE if the caps were not fixed or bad parameters were provided to this function. MT safe. 506 */ 507 public int setCaps(Caps caps) 508 { 509 // gboolean gst_pad_set_caps (GstPad *pad, GstCaps *caps); 510 return gst_pad_set_caps(gstPad, (caps is null) ? null : caps.getCapsStruct()); 511 } 512 513 /** 514 * Gets the peer of pad. This function refs the peer pad so 515 * you need to unref it after use. 516 * Returns: the peer GstPad. Unref after usage. MT safe. 517 */ 518 public Pad getPeer() 519 { 520 // GstPad* gst_pad_get_peer (GstPad *pad); 521 auto p = gst_pad_get_peer(gstPad); 522 523 if(p is null) 524 { 525 return null; 526 } 527 528 return ObjectG.getDObject!(Pad)(cast(GstPad*) p); 529 } 530 531 /** 532 * Gets the capabilities of the peer connected to this pad. 533 * Returns: the GstCaps of the peer pad. This function returns a new caps, so use gst_caps_unref to get rid of it. this function returns NULL if there is no peer pad. 534 */ 535 public Caps peerGetCaps() 536 { 537 // GstCaps* gst_pad_peer_get_caps (GstPad *pad); 538 auto p = gst_pad_peer_get_caps(gstPad); 539 540 if(p is null) 541 { 542 return null; 543 } 544 545 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 546 } 547 548 /** 549 * A helper function you can use that sets the 550 * gst_pad_get_fixed_caps_func as the getcaps function for the 551 * pad. This way the function will always return the negotiated caps 552 * or in case the pad is not negotiated, the padtemplate caps. 553 * Use this function on a pad that, once _set_caps() has been called 554 * on it, cannot be renegotiated to something else. 555 */ 556 public void useFixedCaps() 557 { 558 // void gst_pad_use_fixed_caps (GstPad *pad); 559 gst_pad_use_fixed_caps(gstPad); 560 } 561 562 /** 563 * Query if a pad is active 564 * Returns: TRUE if the pad is active. MT safe. 565 */ 566 public int isActive() 567 { 568 // gboolean gst_pad_is_active (GstPad *pad); 569 return gst_pad_is_active(gstPad); 570 } 571 572 /** 573 * Blocks or unblocks the dataflow on a pad. This function is 574 * a shortcut for gst_pad_set_blocked_async() with a NULL 575 * callback. 576 * Params: 577 * blocked = boolean indicating we should block or unblock 578 * Returns: TRUE if the pad could be blocked. This function can fail if the wrong parameters were passed or the pad was already in the requested state. MT safe. 579 */ 580 public int setBlocked(int blocked) 581 { 582 // gboolean gst_pad_set_blocked (GstPad *pad, gboolean blocked); 583 return gst_pad_set_blocked(gstPad, blocked); 584 } 585 586 /** 587 * Blocks or unblocks the dataflow on a pad. The provided callback 588 * is called when the operation succeeds; this happens right before the next 589 * attempt at pushing a buffer on the pad. 590 * This can take a while as the pad can only become blocked when real dataflow 591 * is happening. 592 * When the pipeline is stalled, for example in PAUSED, this can 593 * take an indeterminate amount of time. 594 * You can pass NULL as the callback to make this call block. Be careful with 595 * this blocking call as it might not return for reasons stated above. 596 * Params: 597 * blocked = boolean indicating whether the pad should be blocked or unblocked 598 * callback = GstPadBlockCallback that will be called when the 599 * operation succeeds 600 * userData = user data passed to the callback 601 * Returns: TRUE if the pad could be blocked. This function can fail if the wrong parameters were passed or the pad was already in the requested state. MT safe. 602 */ 603 public int setBlockedAsync(int blocked, GstPadBlockCallback callback, void* userData) 604 { 605 // gboolean gst_pad_set_blocked_async (GstPad *pad, gboolean blocked, GstPadBlockCallback callback, gpointer user_data); 606 return gst_pad_set_blocked_async(gstPad, blocked, callback, userData); 607 } 608 609 /** 610 * Checks if the pad is blocked or not. This function returns the 611 * last requested state of the pad. It is not certain that the pad 612 * is actually blocking at this point (see gst_pad_is_blocking()). 613 * Returns: TRUE if the pad is blocked. MT safe. 614 */ 615 public int isBlocked() 616 { 617 // gboolean gst_pad_is_blocked (GstPad *pad); 618 return gst_pad_is_blocked(gstPad); 619 } 620 621 /** 622 * Checks if the pad is blocking or not. This is a guaranteed state 623 * of whether the pad is actually blocking on a GstBuffer or a GstEvent. 624 * Returns: TRUE if the pad is blocking. MT safe. Since 0.10.11 625 */ 626 public int isBlocking() 627 { 628 // gboolean gst_pad_is_blocking (GstPad *pad); 629 return gst_pad_is_blocking(gstPad); 630 } 631 632 /** 633 * Adds a "data probe" to a pad. This function will be called whenever data 634 * passes through a pad. In this case data means both events and buffers. The 635 * probe will be called with the data as an argument, meaning handler should 636 * have the same callback signature as the 'have-data' signal of GstPad. 637 * Note that the data will have a reference count greater than 1, so it will 638 * be immutable -- you must not change it. 639 * For source pads, the probe will be called after the blocking function, if any 640 * (see gst_pad_set_blocked_async()), but before looking up the peer to chain 641 * to. For sink pads, the probe function will be called before configuring the 642 * sink with new caps, if any, and before calling the pad's chain function. 643 * Your data probe should return TRUE to let the data continue to flow, or FALSE 644 * to drop it. Dropping data is rarely useful, but occasionally comes in handy 645 * with events. 646 * Although probes are implemented internally by connecting handler to the 647 * have-data signal on the pad, if you want to remove a probe it is insufficient 648 * to only call g_signal_handler_disconnect on the returned handler id. To 649 * remove a probe, use the appropriate function, such as 650 * gst_pad_remove_data_probe(). 651 * Params: 652 * handler = function to call when data is passed over pad 653 * data = data to pass along with the handler 654 * Returns: The handler id. 655 */ 656 public gulong addDataProbe(GCallback handler, void* data) 657 { 658 // gulong gst_pad_add_data_probe (GstPad *pad, GCallback handler, gpointer data); 659 return gst_pad_add_data_probe(gstPad, handler, data); 660 } 661 662 /** 663 * Adds a probe that will be called for all buffers passing through a pad. See 664 * gst_pad_add_data_probe() for more information. 665 * Params: 666 * handler = function to call when data is passed over pad 667 * data = data to pass along with the handler 668 * Returns: The handler id 669 */ 670 public gulong addBufferProbe(GCallback handler, void* data) 671 { 672 // gulong gst_pad_add_buffer_probe (GstPad *pad, GCallback handler, gpointer data); 673 return gst_pad_add_buffer_probe(gstPad, handler, data); 674 } 675 676 /** 677 * Adds a probe that will be called for all events passing through a pad. See 678 * gst_pad_add_data_probe() for more information. 679 * Params: 680 * handler = function to call when data is passed over pad 681 * data = data to pass along with the handler 682 * Returns: The handler id 683 */ 684 public gulong addEventProbe(GCallback handler, void* data) 685 { 686 // gulong gst_pad_add_event_probe (GstPad *pad, GCallback handler, gpointer data); 687 return gst_pad_add_event_probe(gstPad, handler, data); 688 } 689 690 /** 691 * Removes a data probe from pad. 692 * Params: 693 * handlerId = handler id returned from gst_pad_add_data_probe 694 */ 695 public void removeDataProbe(uint handlerId) 696 { 697 // void gst_pad_remove_data_probe (GstPad *pad, guint handler_id); 698 gst_pad_remove_data_probe(gstPad, handlerId); 699 } 700 701 /** 702 * Removes a buffer probe from pad. 703 * Params: 704 * handlerId = handler id returned from gst_pad_add_buffer_probe 705 */ 706 public void removeBufferProbe(uint handlerId) 707 { 708 // void gst_pad_remove_buffer_probe (GstPad *pad, guint handler_id); 709 gst_pad_remove_buffer_probe(gstPad, handlerId); 710 } 711 712 /** 713 * Removes an event probe from pad. 714 * Params: 715 * handlerId = handler id returned from gst_pad_add_event_probe 716 */ 717 public void removeEventProbe(uint handlerId) 718 { 719 // void gst_pad_remove_event_probe (GstPad *pad, guint handler_id); 720 gst_pad_remove_event_probe(gstPad, handlerId); 721 } 722 723 /** 724 * Creates a new pad with the given name in the given direction. 725 * If name is NULL, a guaranteed unique name (across all pads) 726 * will be assigned. 727 * This function makes a copy of the name so you can safely free the name. 728 * Params: 729 * name = the name of the new pad. 730 * direction = the GstPadDirection of the pad. 731 * Throws: ConstructionException GTK+ fails to create the object. 732 */ 733 public this (string name, GstPadDirection direction) 734 { 735 // GstPad* gst_pad_new (const gchar *name, GstPadDirection direction); 736 auto p = gst_pad_new(Str.toStringz(name), direction); 737 if(p is null) 738 { 739 throw new ConstructionException("null returned by gst_pad_new(Str.toStringz(name), direction)"); 740 } 741 this(cast(GstPad*) p); 742 } 743 744 /** 745 * Creates a new pad with the given name from the given template. 746 * If name is NULL, a guaranteed unique name (across all pads) 747 * will be assigned. 748 * This function makes a copy of the name so you can safely free the name. 749 * Params: 750 * templ = the pad template to use 751 * name = the name of the element 752 * Throws: ConstructionException GTK+ fails to create the object. 753 */ 754 public this (PadTemplate templ, string name) 755 { 756 // GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name); 757 auto p = gst_pad_new_from_template((templ is null) ? null : templ.getPadTemplateStruct(), Str.toStringz(name)); 758 if(p is null) 759 { 760 throw new ConstructionException("null returned by gst_pad_new_from_template((templ is null) ? null : templ.getPadTemplateStruct(), Str.toStringz(name))"); 761 } 762 this(cast(GstPad*) p); 763 } 764 765 /** 766 * Creates a new pad with the given name from the given static template. 767 * If name is NULL, a guaranteed unique name (across all pads) 768 * will be assigned. 769 * This function makes a copy of the name so you can safely free the name. 770 * Params: 771 * templ = the GstStaticPadTemplate to use 772 * name = the name of the element 773 * Throws: ConstructionException GTK+ fails to create the object. 774 */ 775 public this (GstStaticPadTemplate* templ, string name) 776 { 777 // GstPad* gst_pad_new_from_static_template (GstStaticPadTemplate *templ, const gchar *name); 778 auto p = gst_pad_new_from_static_template(templ, Str.toStringz(name)); 779 if(p is null) 780 { 781 throw new ConstructionException("null returned by gst_pad_new_from_static_template(templ, Str.toStringz(name))"); 782 } 783 this(cast(GstPad*) p); 784 } 785 786 /** 787 * Allocates a new, empty buffer optimized to push to pad pad. This 788 * function only works if pad is a source pad and has a peer. 789 * A new, empty GstBuffer will be put in the buf argument. 790 * You need to check the caps of the buffer after performing this 791 * function and renegotiate to the format if needed. 792 * Params: 793 * offset = the offset of the new buffer in the stream 794 * size = the size of the new buffer 795 * caps = the caps of the new buffer 796 * buf = a newly allocated buffer 797 * Returns: a result code indicating success of the operation. Any result code other than GST_FLOW_OK is an error and buf should not be used. An error can occur if the pad is not connected or when the downstream peer elements cannot provide an acceptable buffer. MT safe. 798 */ 799 public GstFlowReturn allocBuffer(ulong offset, int size, Caps caps, out Buffer buf) 800 { 801 // GstFlowReturn gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size, GstCaps *caps, GstBuffer **buf); 802 GstBuffer* outbuf = null; 803 804 auto p = gst_pad_alloc_buffer(gstPad, offset, size, (caps is null) ? null : caps.getCapsStruct(), &outbuf); 805 806 buf = ObjectG.getDObject!(Buffer)(outbuf); 807 return p; 808 } 809 810 /** 811 * In addition to the function gst_pad_alloc_buffer(), this function 812 * automatically calls gst_pad_set_caps() when the caps of the 813 * newly allocated buffer are different from the pad caps. 814 * Params: 815 * offset = the offset of the new buffer in the stream 816 * size = the size of the new buffer 817 * caps = the caps of the new buffer 818 * buf = a newly allocated buffer 819 * Returns: a result code indicating success of the operation. Any result code other than GST_FLOW_OK is an error and buf should not be used. An error can occur if the pad is not connected or when the downstream peer elements cannot provide an acceptable buffer. MT safe. 820 */ 821 public GstFlowReturn allocBufferAndSetCaps(ulong offset, int size, Caps caps, out Buffer buf) 822 { 823 // GstFlowReturn gst_pad_alloc_buffer_and_set_caps (GstPad *pad, guint64 offset, gint size, GstCaps *caps, GstBuffer **buf); 824 GstBuffer* outbuf = null; 825 826 auto p = gst_pad_alloc_buffer_and_set_caps(gstPad, offset, size, (caps is null) ? null : caps.getCapsStruct(), &outbuf); 827 828 buf = ObjectG.getDObject!(Buffer)(outbuf); 829 return p; 830 } 831 832 /** 833 * Sets the given bufferalloc function for the pad. Note that the 834 * bufferalloc function can only be set on sinkpads. 835 * Params: 836 * bufalloc = the GstPadBufferAllocFunction to set. 837 */ 838 public void setBufferallocFunction(GstPadBufferAllocFunction bufalloc) 839 { 840 // void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufalloc); 841 gst_pad_set_bufferalloc_function(gstPad, bufalloc); 842 } 843 844 /** 845 * Sets the given chain function for the pad. The chain function is called to 846 * process a GstBuffer input buffer. see GstPadChainFunction for more details. 847 * Params: 848 * chain = the GstPadChainFunction to set. 849 */ 850 public void setChainFunction(GstPadChainFunction chain) 851 { 852 // void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain); 853 gst_pad_set_chain_function(gstPad, chain); 854 } 855 856 /** 857 * Sets the given checkgetrange function for the pad. Implement this function 858 * on a pad if you dynamically support getrange based scheduling on the pad. 859 * Params: 860 * check = the GstPadCheckGetRangeFunction to set. 861 */ 862 public void setCheckgetrangeFunction(GstPadCheckGetRangeFunction check) 863 { 864 // void gst_pad_set_checkgetrange_function (GstPad *pad, GstPadCheckGetRangeFunction check); 865 gst_pad_set_checkgetrange_function(gstPad, check); 866 } 867 868 /** 869 * When pad is flushing this function returns GST_FLOW_WRONG_STATE 870 * immediatly. 871 * Calls the getrange function of pad, see GstPadGetRangeFunction for a 872 * description of a getrange function. If pad has no getrange function 873 * installed (see gst_pad_set_getrange_function()) this function returns 874 * GST_FLOW_NOT_SUPPORTED. 875 * buffer's caps must either be unset or the same as what is already 876 * configured on pad. Renegotiation within a running pull-mode pipeline is not 877 * supported. 878 * This is a lowlevel function. Usualy gst_pad_pull_range() is used. 879 * Params: 880 * offset = The start offset of the buffer 881 * size = The length of the buffer 882 * buffer = a pointer to hold the GstBuffer, returns GST_FLOW_ERROR if NULL. 883 * Returns: a GstFlowReturn from the pad. MT safe. 884 */ 885 public GstFlowReturn getRange(ulong offset, uint size, ref Buffer buffer) 886 { 887 // GstFlowReturn gst_pad_get_range (GstPad *pad, guint64 offset, guint size, GstBuffer **buffer); 888 GstBuffer* outbuffer = (buffer is null) ? null : buffer.getBufferStruct(); 889 890 auto p = gst_pad_get_range(gstPad, offset, size, &outbuffer); 891 892 buffer = ObjectG.getDObject!(Buffer)(outbuffer); 893 return p; 894 } 895 896 /** 897 * Sets the given getrange function for the pad. The getrange function is 898 * called to produce a new GstBuffer to start the processing pipeline. see 899 * GstPadGetRangeFunction for a description of the getrange function. 900 * Params: 901 * get = the GstPadGetRangeFunction to set. 902 */ 903 public void setGetrangeFunction(GstPadGetRangeFunction get) 904 { 905 // void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get); 906 gst_pad_set_getrange_function(gstPad, get); 907 } 908 909 /** 910 * Sets the given event handler for the pad. 911 * Params: 912 * event = the GstPadEventFunction to set. 913 */ 914 public void setEventFunction(GstPadEventFunction event) 915 { 916 // void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event); 917 gst_pad_set_event_function(gstPad, event); 918 } 919 920 /** 921 * Sets the given link function for the pad. It will be called when 922 * the pad is linked with another pad. 923 * The return value GST_PAD_LINK_OK should be used when the connection can be 924 * made. 925 * The return value GST_PAD_LINK_REFUSED should be used when the connection 926 * cannot be made for some reason. 927 * If link is installed on a source pad, it should call the GstPadLinkFunction 928 * of the peer sink pad, if present. 929 * Params: 930 * link = the GstPadLinkFunction to set. 931 */ 932 public void setLinkFunction(GstPadLinkFunction link) 933 { 934 // void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link); 935 gst_pad_set_link_function(gstPad, link); 936 } 937 938 /** 939 * Sets the given unlink function for the pad. It will be called 940 * when the pad is unlinked. 941 * Params: 942 * unlink = the GstPadUnlinkFunction to set. 943 */ 944 public void setUnlinkFunction(GstPadUnlinkFunction unlink) 945 { 946 // void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink); 947 gst_pad_set_unlink_function(gstPad, unlink); 948 } 949 950 /** 951 * Check if the given pad accepts the caps. 952 * Params: 953 * caps = a GstCaps to check on the pad 954 * Returns: TRUE if the pad can accept the caps. 955 */ 956 public int acceptCaps(Caps caps) 957 { 958 // gboolean gst_pad_accept_caps (GstPad *pad, GstCaps *caps); 959 return gst_pad_accept_caps(gstPad, (caps is null) ? null : caps.getCapsStruct()); 960 } 961 962 /** 963 * Sets the given acceptcaps function for the pad. The acceptcaps function 964 * will be called to check if the pad can accept the given caps. Setting the 965 * acceptcaps function to NULL restores the default behaviour of allowing 966 * any caps that matches the caps from gst_pad_get_caps. 967 * Params: 968 * acceptcaps = the GstPadAcceptCapsFunction to set. 969 */ 970 public void setAcceptcapsFunction(GstPadAcceptCapsFunction acceptcaps) 971 { 972 // void gst_pad_set_acceptcaps_function (GstPad *pad, GstPadAcceptCapsFunction acceptcaps); 973 gst_pad_set_acceptcaps_function(gstPad, acceptcaps); 974 } 975 976 /** 977 * Sets the given getcaps function for the pad. getcaps should return the 978 * allowable caps for a pad in the context of the element's state, its link to 979 * other elements, and the devices or files it has opened. These caps must be a 980 * subset of the pad template caps. In the NULL state with no links, getcaps 981 * should ideally return the same caps as the pad template. In rare 982 * circumstances, an object property can affect the caps returned by getcaps, 983 * but this is discouraged. 984 * You do not need to call this function if pad's allowed caps are always the 985 * same as the pad template caps. This can only be true if the padtemplate 986 * has fixed simple caps. 987 * For most filters, the caps returned by getcaps is directly affected by the 988 * allowed caps on other pads. For demuxers and decoders, the caps returned by 989 * the srcpad's getcaps function is directly related to the stream data. Again, 990 * getcaps should return the most specific caps it reasonably can, since this 991 * helps with autoplugging. 992 * Note that the return value from getcaps is owned by the caller, so the 993 * caller should unref the caps after usage. 994 * Params: 995 * getcaps = the GstPadGetCapsFunction to set. 996 */ 997 public void setGetcapsFunction(GstPadGetCapsFunction getcaps) 998 { 999 // void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps); 1000 gst_pad_set_getcaps_function(gstPad, getcaps); 1001 } 1002 1003 /** 1004 * Calls gst_pad_get_allowed_caps() for every other pad belonging to the 1005 * same element as pad, and returns the intersection of the results. 1006 * This function is useful as a default getcaps function for an element 1007 * that can handle any stream format, but requires all its pads to have 1008 * the same caps. Two such elements are tee and aggregator. 1009 * Returns: the intersection of the other pads' allowed caps. 1010 */ 1011 public Caps proxyGetcaps() 1012 { 1013 // GstCaps* gst_pad_proxy_getcaps (GstPad *pad); 1014 auto p = gst_pad_proxy_getcaps(gstPad); 1015 1016 if(p is null) 1017 { 1018 return null; 1019 } 1020 1021 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 1022 } 1023 1024 /** 1025 * Sets the given setcaps function for the pad. The setcaps function 1026 * will be called whenever a buffer with a new media type is pushed or 1027 * pulled from the pad. The pad/element needs to update its internal 1028 * structures to process the new media type. If this new type is not 1029 * acceptable, the setcaps function should return FALSE. 1030 * Params: 1031 * setcaps = the GstPadSetCapsFunction to set. 1032 */ 1033 public void setSetcapsFunction(GstPadSetCapsFunction setcaps) 1034 { 1035 // void gst_pad_set_setcaps_function (GstPad *pad, GstPadSetCapsFunction setcaps); 1036 gst_pad_set_setcaps_function(gstPad, setcaps); 1037 } 1038 1039 /** 1040 * Calls gst_pad_set_caps() for every other pad belonging to the 1041 * same element as pad. If gst_pad_set_caps() fails on any pad, 1042 * the proxy setcaps fails. May be used only during negotiation. 1043 * Params: 1044 * caps = the GstCaps to link with 1045 * Returns: TRUE if sucessful 1046 */ 1047 public int proxySetcaps(Caps caps) 1048 { 1049 // gboolean gst_pad_proxy_setcaps (GstPad *pad, GstCaps *caps); 1050 return gst_pad_proxy_setcaps(gstPad, (caps is null) ? null : caps.getCapsStruct()); 1051 } 1052 1053 /** 1054 * Fixate a caps on the given pad. Modifies the caps in place, so you should 1055 * make sure that the caps are actually writable (see gst_caps_make_writable()). 1056 * Params: 1057 * caps = the GstCaps to fixate 1058 */ 1059 public void fixateCaps(Caps caps) 1060 { 1061 // void gst_pad_fixate_caps (GstPad *pad, GstCaps *caps); 1062 gst_pad_fixate_caps(gstPad, (caps is null) ? null : caps.getCapsStruct()); 1063 } 1064 1065 /** 1066 * Sets the given fixatecaps function for the pad. The fixatecaps function 1067 * will be called whenever the default values for a GstCaps needs to be 1068 * filled in. 1069 * Params: 1070 * fixatecaps = the GstPadFixateCapsFunction to set. 1071 */ 1072 public void setFixatecapsFunction(GstPadFixateCapsFunction fixatecaps) 1073 { 1074 // void gst_pad_set_fixatecaps_function (GstPad *pad, GstPadFixateCapsFunction fixatecaps); 1075 gst_pad_set_fixatecaps_function(gstPad, fixatecaps); 1076 } 1077 1078 /** 1079 * A helper function you can use as a GetCaps function that 1080 * will return the currently negotiated caps or the padtemplate 1081 * when NULL. 1082 * Returns: The currently negotiated caps or the padtemplate. 1083 */ 1084 public Caps getFixedCapsFunc() 1085 { 1086 // GstCaps* gst_pad_get_fixed_caps_func (GstPad *pad); 1087 auto p = gst_pad_get_fixed_caps_func(gstPad); 1088 1089 if(p is null) 1090 { 1091 return null; 1092 } 1093 1094 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 1095 } 1096 1097 /** 1098 * Check if the peer of pad accepts caps. If pad has no peer, this function 1099 * returns TRUE. 1100 * Params: 1101 * caps = a GstCaps to check on the pad 1102 * Returns: TRUE if the peer of pad can accept the caps or pad has no peer. 1103 */ 1104 public int peerAcceptCaps(Caps caps) 1105 { 1106 // gboolean gst_pad_peer_accept_caps (GstPad *pad, GstCaps *caps); 1107 return gst_pad_peer_accept_caps(gstPad, (caps is null) ? null : caps.getCapsStruct()); 1108 } 1109 1110 /** 1111 * Sets the given activate function for pad. The activate function will 1112 * dispatch to gst_pad_activate_push() or gst_pad_activate_pull() to perform 1113 * the actual activation. Only makes sense to set on sink pads. 1114 * Call this function if your sink pad can start a pull-based task. 1115 * Params: 1116 * activate = the GstPadActivateFunction to set. 1117 */ 1118 public void setActivateFunction(GstPadActivateFunction activate) 1119 { 1120 // void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate); 1121 gst_pad_set_activate_function(gstPad, activate); 1122 } 1123 1124 /** 1125 * Sets the given activate_push function for the pad. An activate_push function 1126 * prepares the element for pushing. See XXX part-activation.txt for details. 1127 * Params: 1128 * activatepush = the GstPadActivateModeFunction to set. 1129 */ 1130 public void setActivatepushFunction(GstPadActivateModeFunction activatepush) 1131 { 1132 // void gst_pad_set_activatepush_function (GstPad *pad, GstPadActivateModeFunction activatepush); 1133 gst_pad_set_activatepush_function(gstPad, activatepush); 1134 } 1135 1136 /** 1137 * Sets the given activate_pull function for the pad. An activate_pull function 1138 * prepares the element and any upstream connections for pulling. See XXX 1139 * part-activation.txt for details. 1140 * Params: 1141 * activatepull = the GstPadActivateModeFunction to set. 1142 */ 1143 public void setActivatepullFunction(GstPadActivateModeFunction activatepull) 1144 { 1145 // void gst_pad_set_activatepull_function (GstPad *pad, GstPadActivateModeFunction activatepull); 1146 gst_pad_set_activatepull_function(gstPad, activatepull); 1147 } 1148 1149 /** 1150 * Pushes a buffer to the peer of pad. 1151 * This function will call an installed pad block before triggering any 1152 * installed pad probes. 1153 * If the caps on buffer are different from the currently configured caps on 1154 * pad, this function will call any installed setcaps function on pad (see 1155 * gst_pad_set_setcaps_function()). In case of failure to renegotiate the new 1156 * format, this function returns GST_FLOW_NOT_NEGOTIATED. 1157 * The function proceeds calling gst_pad_chain() on the peer pad and returns 1158 * the value from that function. If pad has no peer, GST_FLOW_NOT_LINKED will 1159 * be returned. 1160 * In all cases, success or failure, the caller loses its reference to buffer 1161 * after calling this function. 1162 * Params: 1163 * buffer = the GstBuffer to push returns GST_FLOW_ERROR if not. 1164 * Returns: a GstFlowReturn from the peer pad. MT safe. 1165 */ 1166 public GstFlowReturn push(Buffer buffer) 1167 { 1168 // GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer); 1169 return gst_pad_push(gstPad, (buffer is null) ? null : buffer.getBufferStruct()); 1170 } 1171 1172 /** 1173 * Sends the event to the peer of the given pad. This function is 1174 * mainly used by elements to send events to their peer 1175 * elements. 1176 * This function takes owership of the provided event so you should 1177 * gst_event_ref() it if you want to reuse the event after this call. 1178 * Params: 1179 * event = the GstEvent to send to the pad. 1180 * Returns: TRUE if the event was handled. MT safe. 1181 */ 1182 public int pushEvent(Event event) 1183 { 1184 // gboolean gst_pad_push_event (GstPad *pad, GstEvent *event); 1185 return gst_pad_push_event(gstPad, (event is null) ? null : event.getEventStruct()); 1186 } 1187 1188 /** 1189 * Checks if a gst_pad_pull_range() can be performed on the peer 1190 * source pad. This function is used by plugins that want to check 1191 * if they can use random access on the peer source pad. 1192 * The peer sourcepad can implement a custom GstPadCheckGetRangeFunction 1193 * if it needs to perform some logic to determine if pull_range is 1194 * possible. 1195 * Returns: a gboolean with the result. MT safe. 1196 */ 1197 public int checkPullRange() 1198 { 1199 // gboolean gst_pad_check_pull_range (GstPad *pad); 1200 return gst_pad_check_pull_range(gstPad); 1201 } 1202 1203 /** 1204 * Pulls a buffer from the peer pad. 1205 * This function will first trigger the pad block signal if it was 1206 * installed. 1207 * When pad is not linked GST_FLOW_NOT_LINKED is returned else this 1208 * function returns the result of gst_pad_get_range() on the peer pad. 1209 * See gst_pad_get_range() for a list of return values and for the 1210 * semantics of the arguments of this function. 1211 * buffer's caps must either be unset or the same as what is already 1212 * configured on pad. Renegotiation within a running pull-mode pipeline is not 1213 * supported. 1214 * Params: 1215 * offset = The start offset of the buffer 1216 * size = The length of the buffer 1217 * buffer = a pointer to hold the GstBuffer, returns GST_FLOW_ERROR if NULL. 1218 * Returns: a GstFlowReturn from the peer pad. When this function returns GST_FLOW_OK, buffer will contain a valid GstBuffer that should be freed with gst_buffer_unref() after usage. buffer may not be used or freed when any other return value than GST_FLOW_OK is returned. MT safe. 1219 */ 1220 public GstFlowReturn pullRange(ulong offset, uint size, ref Buffer buffer) 1221 { 1222 // GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size, GstBuffer **buffer); 1223 GstBuffer* outbuffer = (buffer is null) ? null : buffer.getBufferStruct(); 1224 1225 auto p = gst_pad_pull_range(gstPad, offset, size, &outbuffer); 1226 1227 buffer = ObjectG.getDObject!(Buffer)(outbuffer); 1228 return p; 1229 } 1230 1231 /** 1232 * Activates or deactivates the given pad in pull mode via dispatching to the 1233 * pad's activatepullfunc. For use from within pad activation functions only. 1234 * When called on sink pads, will first proxy the call to the peer pad, which 1235 * is expected to activate its internally linked pads from within its 1236 * activate_pull function. 1237 * If you don't know what this is, you probably don't want to call it. 1238 * Params: 1239 * active = whether or not the pad should be active. 1240 * Returns: TRUE if the operation was successful. MT safe. 1241 */ 1242 public int activatePull(int active) 1243 { 1244 // gboolean gst_pad_activate_pull (GstPad *pad, gboolean active); 1245 return gst_pad_activate_pull(gstPad, active); 1246 } 1247 1248 /** 1249 * Activates or deactivates the given pad in push mode via dispatching to the 1250 * pad's activatepushfunc. For use from within pad activation functions only. 1251 * If you don't know what this is, you probably don't want to call it. 1252 * Params: 1253 * active = whether the pad should be active or not. 1254 * Returns: TRUE if the operation was successful. MT safe. 1255 */ 1256 public int activatePush(int active) 1257 { 1258 // gboolean gst_pad_activate_push (GstPad *pad, gboolean active); 1259 return gst_pad_activate_push(gstPad, active); 1260 } 1261 1262 /** 1263 * Sends the event to the pad. This function can be used 1264 * by applications to send events in the pipeline. 1265 * If pad is a source pad, event should be an upstream event. If pad is a 1266 * sink pad, event should be a downstream event. For example, you would not 1267 * send a GST_EVENT_EOS on a src pad; EOS events only propagate downstream. 1268 * Furthermore, some downstream events have to be serialized with data flow, 1269 * like EOS, while some can travel out-of-band, like GST_EVENT_FLUSH_START. If 1270 * the event needs to be serialized with data flow, this function will take the 1271 * pad's stream lock while calling its event function. 1272 * To find out whether an event type is upstream, downstream, or downstream and 1273 * serialized, see GstEventTypeFlags, gst_event_type_get_flags(), 1274 * GST_EVENT_IS_UPSTREAM, GST_EVENT_IS_DOWNSTREAM, and 1275 * GST_EVENT_IS_SERIALIZED. Note that in practice that an application or 1276 * plugin doesn't need to bother itself with this information; the core handles 1277 * all necessary locks and checks. 1278 * This function takes owership of the provided event so you should 1279 * gst_event_ref() it if you want to reuse the event after this call. 1280 * Params: 1281 * event = the GstEvent to send to the pad. 1282 * Returns: TRUE if the event was handled. 1283 */ 1284 public int sendEvent(Event event) 1285 { 1286 // gboolean gst_pad_send_event (GstPad *pad, GstEvent *event); 1287 return gst_pad_send_event(gstPad, (event is null) ? null : event.getEventStruct()); 1288 } 1289 1290 /** 1291 * Invokes the default event handler for the given pad. End-of-stream and 1292 * discontinuity events are handled specially, and then the event is sent to all 1293 * pads internally linked to pad. Note that if there are many possible sink 1294 * pads that are internally linked to pad, only one will be sent an event. 1295 * Multi-sinkpad elements should implement custom event handlers. 1296 * Params: 1297 * event = the GstEvent to handle. 1298 * Returns: TRUE if the event was sent succesfully. 1299 */ 1300 public int eventDefault(Event event) 1301 { 1302 // gboolean gst_pad_event_default (GstPad *pad, GstEvent *event); 1303 return gst_pad_event_default(gstPad, (event is null) ? null : event.getEventStruct()); 1304 } 1305 1306 /** 1307 * Dispatches a query to a pad. The query should have been allocated by the 1308 * caller via one of the type-specific allocation functions in gstquery.h. The 1309 * element is responsible for filling the query with an appropriate response, 1310 * which should then be parsed with a type-specific query parsing function. 1311 * Again, the caller is responsible for both the allocation and deallocation of 1312 * the query structure. 1313 * Params: 1314 * query = the GstQuery to perform. 1315 * Returns: TRUE if the query could be performed. 1316 */ 1317 public int query(Query query) 1318 { 1319 // gboolean gst_pad_query (GstPad *pad, GstQuery *query); 1320 return gst_pad_query(gstPad, (query is null) ? null : query.getQueryStruct()); 1321 } 1322 1323 /** 1324 * Invokes the default query handler for the given pad. 1325 * The query is sent to all pads internally linked to pad. Note that 1326 * if there are many possible sink pads that are internally linked to 1327 * pad, only one will be sent the query. 1328 * Multi-sinkpad elements should implement custom query handlers. 1329 * Params: 1330 * query = the GstQuery to handle. 1331 * Returns: TRUE if the query was performed succesfully. 1332 */ 1333 public int queryDefault(Query query) 1334 { 1335 // gboolean gst_pad_query_default (GstPad *pad, GstQuery *query); 1336 return gst_pad_query_default(gstPad, (query is null) ? null : query.getQueryStruct()); 1337 } 1338 1339 /** 1340 * Queries a pad for the stream position. 1341 * Params: 1342 * format = a pointer to the GstFormat asked for. 1343 * On return contains the GstFormat used. 1344 * cur = A location in which to store the current position, or NULL. 1345 * Returns: TRUE if the query could be performed. 1346 */ 1347 public int queryPosition(ref GstFormat format, out long cur) 1348 { 1349 // gboolean gst_pad_query_position (GstPad *pad, GstFormat *format, gint64 *cur); 1350 return gst_pad_query_position(gstPad, &format, &cur); 1351 } 1352 1353 /** 1354 * Queries a pad for the total stream duration. 1355 * Params: 1356 * format = a pointer to the GstFormat asked for. 1357 * On return contains the GstFormat used. 1358 * duration = A location in which to store the total duration, or NULL. 1359 * Returns: TRUE if the query could be performed. 1360 */ 1361 public int queryDuration(ref GstFormat format, out long duration) 1362 { 1363 // gboolean gst_pad_query_duration (GstPad *pad, GstFormat *format, gint64 *duration); 1364 return gst_pad_query_duration(gstPad, &format, &duration); 1365 } 1366 1367 /** 1368 * Queries a pad to convert src_val in src_format to dest_format. 1369 * Params: 1370 * srcFormat = a GstFormat to convert from. 1371 * srcVal = a value to convert. 1372 * destFormat = a pointer to the GstFormat to convert to. 1373 * destVal = a pointer to the result. 1374 * Returns: TRUE if the query could be performed. 1375 */ 1376 public int queryConvert(GstFormat srcFormat, long srcVal, ref GstFormat destFormat, out long destVal) 1377 { 1378 // gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val, GstFormat *dest_format, gint64 *dest_val); 1379 return gst_pad_query_convert(gstPad, srcFormat, srcVal, &destFormat, &destVal); 1380 } 1381 1382 /** 1383 * Queries the peer of a given sink pad for the stream position. 1384 * Params: 1385 * format = a pointer to the GstFormat asked for. 1386 * On return contains the GstFormat used. 1387 * cur = A location in which to store the current position, or NULL. 1388 * Returns: TRUE if the query could be performed. 1389 */ 1390 public int queryPeerPosition(ref GstFormat format, out long cur) 1391 { 1392 // gboolean gst_pad_query_peer_position (GstPad *pad, GstFormat *format, gint64 *cur); 1393 return gst_pad_query_peer_position(gstPad, &format, &cur); 1394 } 1395 1396 /** 1397 * Queries the peer pad of a given sink pad for the total stream duration. 1398 * Params: 1399 * format = a pointer to the GstFormat asked for. 1400 * On return contains the GstFormat used. 1401 * duration = A location in which to store the total duration, or NULL. 1402 * Returns: TRUE if the query could be performed. 1403 */ 1404 public int queryPeerDuration(ref GstFormat format, out long duration) 1405 { 1406 // gboolean gst_pad_query_peer_duration (GstPad *pad, GstFormat *format, gint64 *duration); 1407 return gst_pad_query_peer_duration(gstPad, &format, &duration); 1408 } 1409 1410 /** 1411 * Queries the peer pad of a given sink pad to convert src_val in src_format 1412 * to dest_format. 1413 * Params: 1414 * srcFormat = a GstFormat to convert from. 1415 * srcVal = a value to convert. 1416 * destFormat = a pointer to the GstFormat to convert to. 1417 * destVal = a pointer to the result. 1418 * Returns: TRUE if the query could be performed. 1419 */ 1420 public int queryPeerConvert(GstFormat srcFormat, long srcVal, ref GstFormat destFormat, out long destVal) 1421 { 1422 // gboolean gst_pad_query_peer_convert (GstPad *pad, GstFormat src_format, gint64 src_val, GstFormat *dest_format, gint64 *dest_val); 1423 return gst_pad_query_peer_convert(gstPad, srcFormat, srcVal, &destFormat, &destVal); 1424 } 1425 1426 /** 1427 * Set the given query function for the pad. 1428 * Params: 1429 * query = the GstPadQueryFunction to set. 1430 */ 1431 public void setQueryFunction(GstPadQueryFunction query) 1432 { 1433 // void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query); 1434 gst_pad_set_query_function(gstPad, query); 1435 } 1436 1437 /** 1438 * Set the given query type function for the pad. 1439 * Params: 1440 * typeFunc = the GstPadQueryTypeFunction to set. 1441 */ 1442 public void setQueryTypeFunction(GstPadQueryTypeFunction typeFunc) 1443 { 1444 // void gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func); 1445 gst_pad_set_query_type_function(gstPad, typeFunc); 1446 } 1447 1448 /** 1449 * Get an array of supported queries that can be performed 1450 * on this pad. 1451 * Returns: a zero-terminated array of GstQueryType. 1452 */ 1453 public GstQueryType* getQueryTypes() 1454 { 1455 // const GstQueryType* gst_pad_get_query_types (GstPad *pad); 1456 return gst_pad_get_query_types(gstPad); 1457 } 1458 1459 /** 1460 * Invoke the default dispatcher for the query types on 1461 * the pad. 1462 * Returns: an zero-terminated array of GstQueryType, or NULL if none of the internally-linked pads has a query types function. 1463 */ 1464 public GstQueryType* getQueryTypesDefault() 1465 { 1466 // const GstQueryType* gst_pad_get_query_types_default (GstPad *pad); 1467 return gst_pad_get_query_types_default(gstPad); 1468 } 1469 1470 /** 1471 * Sets the given internal link function for the pad. 1472 * Params: 1473 * intlink = the GstPadIntLinkFunction to set. 1474 */ 1475 public void setInternalLinkFunction(GstPadIntLinkFunction intlink) 1476 { 1477 // void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink); 1478 gst_pad_set_internal_link_function(gstPad, intlink); 1479 } 1480 1481 /** 1482 * Gets a list of pads to which the given pad is linked to 1483 * inside of the parent element. 1484 * The caller must free this list after use. 1485 * Returns: a newly allocated GList of pads. Not MT safe. 1486 */ 1487 public ListG getInternalLinks() 1488 { 1489 // GList* gst_pad_get_internal_links (GstPad *pad); 1490 auto p = gst_pad_get_internal_links(gstPad); 1491 1492 if(p is null) 1493 { 1494 return null; 1495 } 1496 1497 return ObjectG.getDObject!(ListG)(cast(GList*) p); 1498 } 1499 1500 /** 1501 * Gets a list of pads to which the given pad is linked to 1502 * inside of the parent element. 1503 * This is the default handler, and thus returns a list of all of the 1504 * pads inside the parent element with opposite direction. 1505 * The caller must free this list after use. 1506 * Returns: a newly allocated GList of pads, or NULL if the pad has no parent. Not MT safe. 1507 */ 1508 public ListG getInternalLinksDefault() 1509 { 1510 // GList* gst_pad_get_internal_links_default (GstPad *pad); 1511 auto p = gst_pad_get_internal_links_default(gstPad); 1512 1513 if(p is null) 1514 { 1515 return null; 1516 } 1517 1518 return ObjectG.getDObject!(ListG)(cast(GList*) p); 1519 } 1520 1521 /** 1522 * Invokes the given dispatcher function on each respective peer of 1523 * all pads that are internally linked to the given pad. 1524 * The GstPadDispatcherFunction should return TRUE when no further pads 1525 * need to be processed. 1526 * Params: 1527 * dispatch = the GstDispatcherFunction to call. 1528 * data = gpointer user data passed to the dispatcher function. 1529 * Returns: TRUE if one of the dispatcher functions returned TRUE. 1530 */ 1531 public int dispatcher(GstPadDispatcherFunction dispatch, void* data) 1532 { 1533 // gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch, gpointer data); 1534 return gst_pad_dispatcher(gstPad, dispatch, data); 1535 } 1536 1537 /** 1538 * Set the given private data gpointer on the pad. 1539 * This function can only be used by the element that owns the pad. 1540 * No locking is performed in this function. 1541 * Params: 1542 * priv = The private data to attach to the pad. 1543 */ 1544 public void setElementPrivate(void* priv) 1545 { 1546 // void gst_pad_set_element_private (GstPad *pad, gpointer priv); 1547 gst_pad_set_element_private(gstPad, priv); 1548 } 1549 1550 /** 1551 * Gets the private data of a pad. 1552 * No locking is performed in this function. 1553 * Returns: a gpointer to the private data. 1554 */ 1555 public void* getElementPrivate() 1556 { 1557 // gpointer gst_pad_get_element_private (GstPad *pad); 1558 return gst_pad_get_element_private(gstPad); 1559 } 1560 1561 /** 1562 * Chain a buffer to pad. 1563 * The function returns GST_FLOW_WRONG_STATE if the pad was flushing. 1564 * If the caps on buffer are different from the current caps on pad, this 1565 * function will call any setcaps function (see gst_pad_set_setcaps_function()) 1566 * installed on pad. If the new caps are not acceptable for pad, this 1567 * function returns GST_FLOW_NOT_NEGOTIATED. 1568 * The function proceeds calling the chain function installed on pad (see 1569 * gst_pad_set_chain_function()) and the return value of that function is 1570 * returned to the caller. GST_FLOW_NOT_SUPPORTED is returned if pad has no 1571 * chain function. 1572 * In all cases, success or failure, the caller loses its reference to buffer 1573 * after calling this function. 1574 * Params: 1575 * buffer = the GstBuffer to send, return GST_FLOW_ERROR if not. 1576 * Returns: a GstFlowReturn from the pad. MT safe. 1577 */ 1578 public GstFlowReturn chain(Buffer buffer) 1579 { 1580 // GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer); 1581 return gst_pad_chain(gstPad, (buffer is null) ? null : buffer.getBufferStruct()); 1582 } 1583 1584 /** 1585 * Starts a task that repeatedly calls func with data. This function 1586 * is mostly used in pad activation functions to start the dataflow. 1587 * The GST_PAD_STREAM_LOCK of pad will automatically be acquired 1588 * before func is called. 1589 * Params: 1590 * func = the task function to call 1591 * data = data passed to the task function 1592 * Returns: a TRUE if the task could be started. 1593 */ 1594 public int startTask(GstTaskFunction func, void* data) 1595 { 1596 // gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func, gpointer data); 1597 return gst_pad_start_task(gstPad, func, data); 1598 } 1599 1600 /** 1601 * Pause the task of pad. This function will also make sure that the 1602 * function executed by the task will effectively stop. 1603 * Returns: a TRUE if the task could be paused or FALSE when the pad has no task. 1604 */ 1605 public int pauseTask() 1606 { 1607 // gboolean gst_pad_pause_task (GstPad *pad); 1608 return gst_pad_pause_task(gstPad); 1609 } 1610 1611 /** 1612 * Stop the task of pad. This function will also make sure that the 1613 * function executed by the task will effectively stop if not called 1614 * from the GstTaskFunction. 1615 * This function will deadlock if called from the GstTaskFunction of 1616 * the task. Use gst_task_pause() instead. 1617 * Regardless of whether the pad has a task, the stream lock is acquired and 1618 * released so as to ensure that streaming through this pad has finished. 1619 * Returns: a TRUE if the task could be stopped or FALSE on error. 1620 */ 1621 public int stopTask() 1622 { 1623 // gboolean gst_pad_stop_task (GstPad *pad); 1624 return gst_pad_stop_task(gstPad); 1625 } 1626 1627 /** 1628 * Activates or deactivates the given pad. 1629 * Normally called from within core state change functions. 1630 * If active, makes sure the pad is active. If it is already active, either in 1631 * push or pull mode, just return. Otherwise dispatches to the pad's activate 1632 * function to perform the actual activation. 1633 * If not active, checks the pad's current mode and calls 1634 * gst_pad_activate_push() or gst_pad_activate_pull(), as appropriate, with a 1635 * FALSE argument. 1636 * Params: 1637 * active = whether or not the pad should be active. 1638 * Returns: TRUE if the operation was successful. MT safe. 1639 */ 1640 public int setActive(int active) 1641 { 1642 // gboolean gst_pad_set_active (GstPad *pad, gboolean active); 1643 return gst_pad_set_active(gstPad, active); 1644 } 1645 }