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