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