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