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