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