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