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