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