/usr/include/d/gtkd-3/gstreamer/Bin.d is in libgstreamerd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gstreamer.Bin;
private import glib.ConstructionException;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
private import gstreamer.ChildProxyIF;
private import gstreamer.ChildProxyT;
private import gstreamer.Element;
private import gstreamer.Iterator;
private import gstreamer.Pad;
private import gstreamer.c.functions;
public import gstreamer.c.types;
public import gstreamerc.gstreamertypes;
private import std.algorithm;
/**
* #GstBin is an element that can contain other #GstElement, allowing them to be
* managed as a group.
* Pads from the child elements can be ghosted to the bin, see #GstGhostPad.
* This makes the bin look like any other elements and enables creation of
* higher-level abstraction elements.
*
* A new #GstBin is created with gst_bin_new(). Use a #GstPipeline instead if you
* want to create a toplevel bin because a normal bin doesn't have a bus or
* handle clock distribution of its own.
*
* After the bin has been created you will typically add elements to it with
* gst_bin_add(). You can remove elements with gst_bin_remove().
*
* An element can be retrieved from a bin with gst_bin_get_by_name(), using the
* elements name. gst_bin_get_by_name_recurse_up() is mainly used for internal
* purposes and will query the parent bins when the element is not found in the
* current bin.
*
* An iterator of elements in a bin can be retrieved with
* gst_bin_iterate_elements(). Various other iterators exist to retrieve the
* elements in a bin.
*
* gst_object_unref() is used to drop your reference to the bin.
*
* The #GstBin::element-added signal is fired whenever a new element is added to
* the bin. Likewise the #GstBin::element-removed signal is fired whenever an
* element is removed from the bin.
*
* ## Notes
*
* A #GstBin internally intercepts every #GstMessage posted by its children and
* implements the following default behaviour for each of them:
*
* * GST_MESSAGE_EOS: This message is only posted by sinks in the PLAYING
* state. If all sinks posted the EOS message, this bin will post and EOS
* message upwards.
*
* * GST_MESSAGE_SEGMENT_START: Just collected and never forwarded upwards.
* The messages are used to decide when all elements have completed playback
* of their segment.
*
* * GST_MESSAGE_SEGMENT_DONE: Is posted by #GstBin when all elements that posted
* a SEGMENT_START have posted a SEGMENT_DONE.
*
* * GST_MESSAGE_DURATION_CHANGED: Is posted by an element that detected a change
* in the stream duration. The default bin behaviour is to clear any
* cached duration values so that the next duration query will perform
* a full duration recalculation. The duration change is posted to the
* application so that it can refetch the new duration with a duration
* query. Note that these messages can be posted before the bin is
* prerolled, in which case the duration query might fail.
*
* * GST_MESSAGE_CLOCK_LOST: This message is posted by an element when it
* can no longer provide a clock. The default bin behaviour is to
* check if the lost clock was the one provided by the bin. If so and
* the bin is currently in the PLAYING state, the message is forwarded to
* the bin parent.
* This message is also generated when a clock provider is removed from
* the bin. If this message is received by the application, it should
* PAUSE the pipeline and set it back to PLAYING to force a new clock
* distribution.
*
* * GST_MESSAGE_CLOCK_PROVIDE: This message is generated when an element
* can provide a clock. This mostly happens when a new clock
* provider is added to the bin. The default behaviour of the bin is to
* mark the currently selected clock as dirty, which will perform a clock
* recalculation the next time the bin is asked to provide a clock.
* This message is never sent tot the application but is forwarded to
* the parent of the bin.
*
* * OTHERS: posted upwards.
*
* A #GstBin implements the following default behaviour for answering to a
* #GstQuery:
*
* * GST_QUERY_DURATION:If the query has been asked before with the same format
* and the bin is a toplevel bin (ie. has no parent),
* use the cached previous value. If no previous value was cached, the
* query is sent to all sink elements in the bin and the MAXIMUM of all
* values is returned. If the bin is a toplevel bin the value is cached.
* If no sinks are available in the bin, the query fails.
*
* * GST_QUERY_POSITION:The query is sent to all sink elements in the bin and the
* MAXIMUM of all values is returned. If no sinks are available in the bin,
* the query fails.
*
* * OTHERS:the query is forwarded to all sink elements, the result
* of the first sink that answers the query successfully is returned. If no
* sink is in the bin, the query fails.
*
* A #GstBin will by default forward any event sent to it to all sink
* (#GST_EVENT_TYPE_DOWNSTREAM) or source (#GST_EVENT_TYPE_UPSTREAM) elements
* depending on the event type.
* If all the elements return %TRUE, the bin will also return %TRUE, else %FALSE
* is returned. If no elements of the required type are in the bin, the event
* handler will return %TRUE.
*/
public class Bin : Element, ChildProxyIF
{
/** the main Gtk struct */
protected GstBin* gstBin;
/** Get the main Gtk struct */
public GstBin* getBinStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gstBin;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gstBin;
}
protected override void setStruct(GObject* obj)
{
gstBin = cast(GstBin*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GstBin* gstBin, bool ownedRef = false)
{
this.gstBin = gstBin;
super(cast(GstElement*)gstBin, ownedRef);
}
// add the ChildProxy capabilities
mixin ChildProxyT!(GstBin);
/** */
public this(Element elem)
{
super( elem.getElementStruct(), true );
this.gstBin = cast(GstBin*)elem.getElementStruct();
}
/**
* Adds a list of elements to a bin.
* This function is equivalent to calling add() for each member of the list.
* The return value of each add() is ignored.
*/
public void addMany( Element[] elems... )
{
foreach( e; elems ) add( e );
}
/**
* Remove a list of elements from a bin.
* This function is equivalent to calling remove() with each member of the list.
*/
public void removeMany( Element[] elems... )
{
foreach( e; elems ) remove( e );
}
/**
*/
/** */
public static GType getType()
{
return gst_bin_get_type();
}
/**
* Creates a new bin with the given name.
*
* Params:
* name = the name of the new bin
*
* Returns: a new #GstBin
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(string name)
{
auto p = gst_bin_new(Str.toStringz(name));
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GstBin*) p);
}
/**
* Adds the given element to the bin. Sets the element's parent, and thus
* takes ownership of the element. An element can only be added to one bin.
*
* If the element's pads are linked to other pads, the pads will be unlinked
* before the element is added to the bin.
*
* > When you add an element to an already-running pipeline, you will have to
* > take care to set the state of the newly-added element to the desired
* > state (usually PLAYING or PAUSED, same you set the pipeline to originally)
* > with gst_element_set_state(), or use gst_element_sync_state_with_parent().
* > The bin or pipeline will not take care of this for you.
*
* MT safe.
*
* Params:
* element = the #GstElement to add
*
* Returns: %TRUE if the element could be added, %FALSE if
* the bin does not want to accept the element.
*/
public bool add(Element element)
{
return gst_bin_add(gstBin, (element is null) ? null : element.getElementStruct()) != 0;
}
/**
* Recursively looks for elements with an unlinked pad of the given
* direction within the specified bin and returns an unlinked pad
* if one is found, or %NULL otherwise. If a pad is found, the caller
* owns a reference to it and should use gst_object_unref() on the
* pad when it is not needed any longer.
*
* Params:
* direction = whether to look for an unlinked source or sink pad
*
* Returns: unlinked pad of the given
* direction, %NULL.
*/
public Pad findUnlinkedPad(GstPadDirection direction)
{
auto p = gst_bin_find_unlinked_pad(gstBin, direction);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true);
}
/**
* Looks for an element inside the bin that implements the given
* interface. If such an element is found, it returns the element.
* You can cast this element to the given interface afterwards. If you want
* all elements that implement the interface, use
* gst_bin_iterate_all_by_interface(). This function recurses into child bins.
*
* MT safe. Caller owns returned reference.
*
* Params:
* iface = the #GType of an interface
*
* Returns: A #GstElement inside the bin implementing the interface
*/
public Element getByInterface(GType iface)
{
auto p = gst_bin_get_by_interface(gstBin, iface);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Element)(cast(GstElement*) p, true);
}
/**
* Gets the element with the given name from a bin. This
* function recurses into child bins.
*
* Returns %NULL if no element with the given name is found in the bin.
*
* MT safe. Caller owns returned reference.
*
* Params:
* name = the element name to search for
*
* Returns: the #GstElement with the given
* name, or %NULL
*/
public Element getByName(string name)
{
auto p = gst_bin_get_by_name(gstBin, Str.toStringz(name));
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Element)(cast(GstElement*) p, true);
}
/**
* Gets the element with the given name from this bin. If the
* element is not found, a recursion is performed on the parent bin.
*
* Returns %NULL if:
* - no element with the given name is found in the bin
*
* MT safe. Caller owns returned reference.
*
* Params:
* name = the element name to search for
*
* Returns: the #GstElement with the given
* name, or %NULL
*/
public Element getByNameRecurseUp(string name)
{
auto p = gst_bin_get_by_name_recurse_up(gstBin, Str.toStringz(name));
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Element)(cast(GstElement*) p, true);
}
/**
* Return the suppressed flags of the bin.
*
* MT safe.
*
* Returns: the bin's suppressed #GstElementFlags.
*
* Since: 1.10
*/
public GstElementFlags getSuppressedFlags()
{
return gst_bin_get_suppressed_flags(gstBin);
}
/**
* Looks for all elements inside the bin that implements the given
* interface. You can safely cast all returned elements to the given interface.
* The function recurses inside child bins. The iterator will yield a series
* of #GstElement that should be unreffed after use.
*
* MT safe. Caller owns returned value.
*
* Params:
* iface = the #GType of an interface
*
* Returns: a #GstIterator of #GstElement
* for all elements in the bin implementing the given interface,
* or %NULL
*/
public Iterator iterateAllByInterface(GType iface)
{
auto p = gst_bin_iterate_all_by_interface(gstBin, iface);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
}
/**
* Gets an iterator for the elements in this bin.
*
* MT safe. Caller owns returned value.
*
* Returns: a #GstIterator of #GstElement,
* or %NULL
*/
public Iterator iterateElements()
{
auto p = gst_bin_iterate_elements(gstBin);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
}
/**
* Gets an iterator for the elements in this bin.
* This iterator recurses into GstBin children.
*
* MT safe. Caller owns returned value.
*
* Returns: a #GstIterator of #GstElement,
* or %NULL
*/
public Iterator iterateRecurse()
{
auto p = gst_bin_iterate_recurse(gstBin);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
}
/**
* Gets an iterator for all elements in the bin that have the
* #GST_ELEMENT_FLAG_SINK flag set.
*
* MT safe. Caller owns returned value.
*
* Returns: a #GstIterator of #GstElement,
* or %NULL
*/
public Iterator iterateSinks()
{
auto p = gst_bin_iterate_sinks(gstBin);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
}
/**
* Gets an iterator for the elements in this bin in topologically
* sorted order. This means that the elements are returned from
* the most downstream elements (sinks) to the sources.
*
* This function is used internally to perform the state changes
* of the bin elements and for clock selection.
*
* MT safe. Caller owns returned value.
*
* Returns: a #GstIterator of #GstElement,
* or %NULL
*/
public Iterator iterateSorted()
{
auto p = gst_bin_iterate_sorted(gstBin);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
}
/**
* Gets an iterator for all elements in the bin that have the
* #GST_ELEMENT_FLAG_SOURCE flag set.
*
* MT safe. Caller owns returned value.
*
* Returns: a #GstIterator of #GstElement,
* or %NULL
*/
public Iterator iterateSources()
{
auto p = gst_bin_iterate_sources(gstBin);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true);
}
/**
* Query @bin for the current latency using and reconfigures this latency to all the
* elements with a LATENCY event.
*
* This method is typically called on the pipeline when a #GST_MESSAGE_LATENCY
* is posted on the bus.
*
* This function simply emits the 'do-latency' signal so any custom latency
* calculations will be performed.
*
* Returns: %TRUE if the latency could be queried and reconfigured.
*/
public bool recalculateLatency()
{
return gst_bin_recalculate_latency(gstBin) != 0;
}
/**
* Removes the element from the bin, unparenting it as well.
* Unparenting the element means that the element will be dereferenced,
* so if the bin holds the only reference to the element, the element
* will be freed in the process of removing it from the bin. If you
* want the element to still exist after removing, you need to call
* gst_object_ref() before removing it from the bin.
*
* If the element's pads are linked to other pads, the pads will be unlinked
* before the element is removed from the bin.
*
* MT safe.
*
* Params:
* element = the #GstElement to remove
*
* Returns: %TRUE if the element could be removed, %FALSE if
* the bin does not want to remove the element.
*/
public bool remove(Element element)
{
return gst_bin_remove(gstBin, (element is null) ? null : element.getElementStruct()) != 0;
}
/**
* Suppress the given flags on the bin. #GstElementFlags of a
* child element are propagated when it is added to the bin.
* When suppressed flags are set, those specified flags will
* not be propagated to the bin.
*
* MT safe.
*
* Params:
* flags = the #GstElementFlags to suppress
*
* Since: 1.10
*/
public void setSuppressedFlags(GstElementFlags flags)
{
gst_bin_set_suppressed_flags(gstBin, flags);
}
/**
* Synchronizes the state of every child of @bin with the state
* of @bin. See also gst_element_sync_state_with_parent().
*
* Returns: %TRUE if syncing the state was successful for all children,
* otherwise %FALSE.
*
* Since: 1.6
*/
public bool syncChildrenStates()
{
return gst_bin_sync_children_states(gstBin) != 0;
}
protected class OnDeepElementAddedDelegateWrapper
{
void delegate(Bin, Element, Bin) dlg;
gulong handlerId;
this(void delegate(Bin, Element, Bin) dlg)
{
this.dlg = dlg;
onDeepElementAddedListeners ~= this;
}
void remove(OnDeepElementAddedDelegateWrapper source)
{
foreach(index, wrapper; onDeepElementAddedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onDeepElementAddedListeners[index] = null;
onDeepElementAddedListeners = std.algorithm.remove(onDeepElementAddedListeners, index);
break;
}
}
}
}
OnDeepElementAddedDelegateWrapper[] onDeepElementAddedListeners;
/**
* Will be emitted after the element was added to sub_bin.
*
* Params:
* subBin = the #GstBin the element was added to
* element = the #GstElement that was added to @sub_bin
*
* Since: 1.10
*/
gulong addOnDeepElementAdded(void delegate(Bin, Element, Bin) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnDeepElementAddedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"deep-element-added",
cast(GCallback)&callBackDeepElementAdded,
cast(void*)wrapper,
cast(GClosureNotify)&callBackDeepElementAddedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackDeepElementAdded(GstBin* binStruct, GstBin* subBin, GstElement* element, OnDeepElementAddedDelegateWrapper wrapper)
{
wrapper.dlg(ObjectG.getDObject!(Bin)(subBin), ObjectG.getDObject!(Element)(element), wrapper.outer);
}
extern(C) static void callBackDeepElementAddedDestroy(OnDeepElementAddedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnDeepElementRemovedDelegateWrapper
{
void delegate(Bin, Element, Bin) dlg;
gulong handlerId;
this(void delegate(Bin, Element, Bin) dlg)
{
this.dlg = dlg;
onDeepElementRemovedListeners ~= this;
}
void remove(OnDeepElementRemovedDelegateWrapper source)
{
foreach(index, wrapper; onDeepElementRemovedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onDeepElementRemovedListeners[index] = null;
onDeepElementRemovedListeners = std.algorithm.remove(onDeepElementRemovedListeners, index);
break;
}
}
}
}
OnDeepElementRemovedDelegateWrapper[] onDeepElementRemovedListeners;
/**
* Will be emitted after the element was removed from sub_bin.
*
* Params:
* subBin = the #GstBin the element was removed from
* element = the #GstElement that was removed from @sub_bin
*
* Since: 1.10
*/
gulong addOnDeepElementRemoved(void delegate(Bin, Element, Bin) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnDeepElementRemovedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"deep-element-removed",
cast(GCallback)&callBackDeepElementRemoved,
cast(void*)wrapper,
cast(GClosureNotify)&callBackDeepElementRemovedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackDeepElementRemoved(GstBin* binStruct, GstBin* subBin, GstElement* element, OnDeepElementRemovedDelegateWrapper wrapper)
{
wrapper.dlg(ObjectG.getDObject!(Bin)(subBin), ObjectG.getDObject!(Element)(element), wrapper.outer);
}
extern(C) static void callBackDeepElementRemovedDestroy(OnDeepElementRemovedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnDoLatencyDelegateWrapper
{
bool delegate(Bin) dlg;
gulong handlerId;
this(bool delegate(Bin) dlg)
{
this.dlg = dlg;
onDoLatencyListeners ~= this;
}
void remove(OnDoLatencyDelegateWrapper source)
{
foreach(index, wrapper; onDoLatencyListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onDoLatencyListeners[index] = null;
onDoLatencyListeners = std.algorithm.remove(onDoLatencyListeners, index);
break;
}
}
}
}
OnDoLatencyDelegateWrapper[] onDoLatencyListeners;
/**
* Will be emitted when the bin needs to perform latency calculations. This
* signal is only emitted for toplevel bins or when async-handling is
* enabled.
*
* Only one signal handler is invoked. If no signals are connected, the
* default handler is invoked, which will query and distribute the lowest
* possible latency to all sinks.
*
* Connect to this signal if the default latency calculations are not
* sufficient, like when you need different latencies for different sinks in
* the same pipeline.
*/
gulong addOnDoLatency(bool delegate(Bin) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnDoLatencyDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"do-latency",
cast(GCallback)&callBackDoLatency,
cast(void*)wrapper,
cast(GClosureNotify)&callBackDoLatencyDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static int callBackDoLatency(GstBin* binStruct, OnDoLatencyDelegateWrapper wrapper)
{
return wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackDoLatencyDestroy(OnDoLatencyDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnElementAddedDelegateWrapper
{
void delegate(Element, Bin) dlg;
gulong handlerId;
this(void delegate(Element, Bin) dlg)
{
this.dlg = dlg;
onElementAddedListeners ~= this;
}
void remove(OnElementAddedDelegateWrapper source)
{
foreach(index, wrapper; onElementAddedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onElementAddedListeners[index] = null;
onElementAddedListeners = std.algorithm.remove(onElementAddedListeners, index);
break;
}
}
}
}
OnElementAddedDelegateWrapper[] onElementAddedListeners;
/**
* Will be emitted after the element was added to the bin.
*
* Params:
* element = the #GstElement that was added to the bin
*/
gulong addOnElementAdded(void delegate(Element, Bin) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnElementAddedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"element-added",
cast(GCallback)&callBackElementAdded,
cast(void*)wrapper,
cast(GClosureNotify)&callBackElementAddedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackElementAdded(GstBin* binStruct, GstElement* element, OnElementAddedDelegateWrapper wrapper)
{
wrapper.dlg(ObjectG.getDObject!(Element)(element), wrapper.outer);
}
extern(C) static void callBackElementAddedDestroy(OnElementAddedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnElementRemovedDelegateWrapper
{
void delegate(Element, Bin) dlg;
gulong handlerId;
this(void delegate(Element, Bin) dlg)
{
this.dlg = dlg;
onElementRemovedListeners ~= this;
}
void remove(OnElementRemovedDelegateWrapper source)
{
foreach(index, wrapper; onElementRemovedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onElementRemovedListeners[index] = null;
onElementRemovedListeners = std.algorithm.remove(onElementRemovedListeners, index);
break;
}
}
}
}
OnElementRemovedDelegateWrapper[] onElementRemovedListeners;
/**
* Will be emitted after the element was removed from the bin.
*
* Params:
* element = the #GstElement that was removed from the bin
*/
gulong addOnElementRemoved(void delegate(Element, Bin) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnElementRemovedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"element-removed",
cast(GCallback)&callBackElementRemoved,
cast(void*)wrapper,
cast(GClosureNotify)&callBackElementRemovedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackElementRemoved(GstBin* binStruct, GstElement* element, OnElementRemovedDelegateWrapper wrapper)
{
wrapper.dlg(ObjectG.getDObject!(Element)(element), wrapper.outer);
}
extern(C) static void callBackElementRemovedDestroy(OnElementRemovedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|