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.Element; 26 27 private import glib.ErrorG; 28 private import glib.GException; 29 private import glib.ListG; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gobject.Type; 34 private import gobject.c.functions; 35 private import gstreamer.Bus; 36 private import gstreamer.Caps; 37 private import gstreamer.Clock; 38 private import gstreamer.Context; 39 private import gstreamer.ElementFactory; 40 private import gstreamer.Event; 41 private import gstreamer.Iterator; 42 private import gstreamer.Message; 43 private import gstreamer.ObjectGst; 44 private import gstreamer.Pad; 45 private import gstreamer.PadTemplate; 46 private import gstreamer.Plugin; 47 private import gstreamer.Query; 48 private import gstreamer.Structure; 49 private import gstreamer.c.functions; 50 public import gstreamer.c.types; 51 public import gstreamerc.gstreamertypes; 52 private import std.algorithm; 53 54 55 /** 56 * GstElement is the abstract base class needed to construct an element that 57 * can be used in a GStreamer pipeline. Please refer to the plugin writers 58 * guide for more information on creating #GstElement subclasses. 59 * 60 * The name of a #GstElement can be get with gst_element_get_name() and set with 61 * gst_element_set_name(). For speed, GST_ELEMENT_NAME() can be used in the 62 * core when using the appropriate locking. Do not use this in plug-ins or 63 * applications in order to retain ABI compatibility. 64 * 65 * Elements can have pads (of the type #GstPad). These pads link to pads on 66 * other elements. #GstBuffer flow between these linked pads. 67 * A #GstElement has a #GList of #GstPad structures for all their input (or sink) 68 * and output (or source) pads. 69 * Core and plug-in writers can add and remove pads with gst_element_add_pad() 70 * and gst_element_remove_pad(). 71 * 72 * An existing pad of an element can be retrieved by name with 73 * gst_element_get_static_pad(). A new dynamic pad can be created using 74 * gst_element_request_pad() with a #GstPadTemplate. 75 * An iterator of all pads can be retrieved with gst_element_iterate_pads(). 76 * 77 * Elements can be linked through their pads. 78 * If the link is straightforward, use the gst_element_link() 79 * convenience function to link two elements, or gst_element_link_many() 80 * for more elements in a row. 81 * Use gst_element_link_filtered() to link two elements constrained by 82 * a specified set of #GstCaps. 83 * For finer control, use gst_element_link_pads() and 84 * gst_element_link_pads_filtered() to specify the pads to link on 85 * each element by name. 86 * 87 * Each element has a state (see #GstState). You can get and set the state 88 * of an element with gst_element_get_state() and gst_element_set_state(). 89 * Setting a state triggers a #GstStateChange. To get a string representation 90 * of a #GstState, use gst_element_state_get_name(). 91 * 92 * You can get and set a #GstClock on an element using gst_element_get_clock() 93 * and gst_element_set_clock(). 94 * Some elements can provide a clock for the pipeline if 95 * the #GST_ELEMENT_FLAG_PROVIDE_CLOCK flag is set. With the 96 * gst_element_provide_clock() method one can retrieve the clock provided by 97 * such an element. 98 * Not all elements require a clock to operate correctly. If the 99 * #GST_ELEMENT_FLAG_REQUIRE_CLOCK() flag is set, a clock should be set on the 100 * element with gst_element_set_clock(). 101 * 102 * Note that clock selection and distribution is normally handled by the 103 * toplevel #GstPipeline so the clock functions are only to be used in very 104 * specific situations. 105 */ 106 public class Element : ObjectGst 107 { 108 /** the main Gtk struct */ 109 protected GstElement* gstElement; 110 111 /** Get the main Gtk struct */ 112 public GstElement* getElementStruct(bool transferOwnership = false) 113 { 114 if (transferOwnership) 115 ownedRef = false; 116 return gstElement; 117 } 118 119 /** the main Gtk struct as a void* */ 120 protected override void* getStruct() 121 { 122 return cast(void*)gstElement; 123 } 124 125 protected override void setStruct(GObject* obj) 126 { 127 gstElement = cast(GstElement*)obj; 128 super.setStruct(obj); 129 } 130 131 /** 132 * Sets our main struct and passes it to the parent class. 133 */ 134 public this (GstElement* gstElement, bool ownedRef = false) 135 { 136 this.gstElement = gstElement; 137 super(cast(GstObject*)gstElement, ownedRef); 138 } 139 140 /** 141 * Queries an element for the stream position. 142 * This is a convenience function for gstreamerD. 143 * Returns: 144 * The current position in nanoseconds - GstFormat.TIME. 145 */ 146 public long queryPosition() 147 { 148 GstFormat form = GstFormat.TIME; 149 long cur_pos; 150 queryPosition( form, cur_pos ); 151 return cur_pos; 152 } 153 154 /** 155 * Queries an element for the stream duration. 156 * This is a convenience function for gstreamerD. 157 * Returns: 158 * The duration in nanoseconds - GstFormat.TIME. 159 */ 160 public long queryDuration() 161 { 162 GstFormat form = GstFormat.TIME; 163 long cur_dur; 164 queryDuration( form, cur_dur ); 165 return cur_dur; 166 } 167 168 /** 169 * This set's the filename for a filesrc element. 170 */ 171 public void location( string set ) 172 { 173 //g_object_set( G_OBJECT(getElementStruct()), "location", set, NULL); 174 setProperty("location", set); 175 } 176 177 /** 178 * Set the caps property of an Element. 179 */ 180 void caps( Caps cp ) 181 { 182 g_object_set( getElementStruct(), Str.toStringz("caps"), cp.getCapsStruct(), null ); 183 } 184 185 /** 186 * For your convenience in gstreamerD: you can seek to the 187 * position of the pipeline measured in time_nanoseconds. 188 */ 189 public int seek( long time_nanoseconds ) //gint64 190 { 191 return seek( 1.0, GstFormat.TIME, GstSeekFlags.FLUSH, 192 GstSeekType.SET, time_nanoseconds, 193 GstSeekType.NONE, GST_CLOCK_TIME_NONE); 194 } 195 196 /** 197 * Get's all the pads from an element in a Pad[]. 198 */ 199 public Pad[] pads() 200 { 201 Pad[] result; 202 GValue* pad = g_value_init(new GValue(), Pad.getType()); 203 GstIterator* iter = gst_element_iterate_pads(gstElement); 204 205 while ( gst_iterator_next(iter, pad) == GstIteratorResult.OK ) 206 { 207 result ~= ObjectG.getDObject!(Pad)(cast(GstPad*)g_value_get_object(pad)); 208 g_value_reset(pad); 209 } 210 211 g_value_unset(pad); 212 213 return result; 214 } 215 216 /** 217 */ 218 219 /** */ 220 public static GType getType() 221 { 222 return gst_element_get_type(); 223 } 224 225 /** 226 * Creates an element for handling the given URI. 227 * 228 * Params: 229 * type = Whether to create a source or a sink 230 * uri = URI to create an element for 231 * elementname = Name of created element, can be %NULL. 232 * 233 * Returns: a new element or %NULL if none could be created 234 * 235 * Throws: GException on failure. 236 */ 237 public static Element makeFromUri(GstURIType type, string uri, string elementname) 238 { 239 GError* err = null; 240 241 auto p = gst_element_make_from_uri(type, Str.toStringz(uri), Str.toStringz(elementname), &err); 242 243 if (err !is null) 244 { 245 throw new GException( new ErrorG(err) ); 246 } 247 248 if(p is null) 249 { 250 return null; 251 } 252 253 return ObjectG.getDObject!(Element)(cast(GstElement*) p); 254 } 255 256 /** 257 * Create a new elementfactory capable of instantiating objects of the 258 * @type and add the factory to @plugin. 259 * 260 * Params: 261 * plugin = #GstPlugin to register the element with, or %NULL for 262 * a static element. 263 * name = name of elements of this type 264 * rank = rank of element (higher rank means more importance when autoplugging) 265 * type = GType of element to register 266 * 267 * Returns: %TRUE, if the registering succeeded, %FALSE on error 268 */ 269 public static bool register(Plugin plugin, string name, uint rank, GType type) 270 { 271 return gst_element_register((plugin is null) ? null : plugin.getPluginStruct(), Str.toStringz(name), rank, type) != 0; 272 } 273 274 /** 275 * Gets a string representing the given state change result. 276 * 277 * Params: 278 * stateRet = a #GstStateChangeReturn to get the name of. 279 * 280 * Returns: a string with the name of the state 281 * result. 282 */ 283 public static string stateChangeReturnGetName(GstStateChangeReturn stateRet) 284 { 285 return Str.toString(gst_element_state_change_return_get_name(stateRet)); 286 } 287 288 /** 289 * Gets a string representing the given state. 290 * 291 * Params: 292 * state = a #GstState to get the name of. 293 * 294 * Returns: a string with the name of the state. 295 */ 296 public static string stateGetName(GstState state) 297 { 298 return Str.toString(gst_element_state_get_name(state)); 299 } 300 301 /** 302 * Abort the state change of the element. This function is used 303 * by elements that do asynchronous state changes and find out 304 * something is wrong. 305 * 306 * This function should be called with the STATE_LOCK held. 307 * 308 * MT safe. 309 */ 310 public void abortState() 311 { 312 gst_element_abort_state(gstElement); 313 } 314 315 /** 316 * Adds a pad (link point) to @element. @pad's parent will be set to @element; 317 * see gst_object_set_parent() for refcounting information. 318 * 319 * Pads are not automatically activated so elements should perform the needed 320 * steps to activate the pad in case this pad is added in the PAUSED or PLAYING 321 * state. See gst_pad_set_active() for more information about activating pads. 322 * 323 * The pad and the element should be unlocked when calling this function. 324 * 325 * This function will emit the #GstElement::pad-added signal on the element. 326 * 327 * Params: 328 * pad = the #GstPad to add to the element. 329 * 330 * Returns: %TRUE if the pad could be added. This function can fail when 331 * a pad with the same name already existed or the pad already had another 332 * parent. 333 * 334 * MT safe. 335 */ 336 public bool addPad(Pad pad) 337 { 338 return gst_element_add_pad(gstElement, (pad is null) ? null : pad.getPadStruct()) != 0; 339 } 340 341 /** 342 * 343 * Params: 344 * propertyName = name of property to watch for changes, or 345 * NULL to watch all properties 346 * includeValue = whether to include the new property value in the message 347 * Returns: a watch id, which can be used in connection with 348 * gst_element_remove_property_notify_watch() to remove the watch again. 349 * 350 * Since: 1.10 351 */ 352 public gulong addPropertyDeepNotifyWatch(string propertyName, bool includeValue) 353 { 354 return gst_element_add_property_deep_notify_watch(gstElement, Str.toStringz(propertyName), includeValue); 355 } 356 357 /** 358 * 359 * Params: 360 * propertyName = name of property to watch for changes, or 361 * NULL to watch all properties 362 * includeValue = whether to include the new property value in the message 363 * Returns: a watch id, which can be used in connection with 364 * gst_element_remove_property_notify_watch() to remove the watch again. 365 * 366 * Since: 1.10 367 */ 368 public gulong addPropertyNotifyWatch(string propertyName, bool includeValue) 369 { 370 return gst_element_add_property_notify_watch(gstElement, Str.toStringz(propertyName), includeValue); 371 } 372 373 /** 374 * Calls @func from another thread and passes @user_data to it. This is to be 375 * used for cases when a state change has to be performed from a streaming 376 * thread, directly via gst_element_set_state() or indirectly e.g. via SEEK 377 * events. 378 * 379 * Calling those functions directly from the streaming thread will cause 380 * deadlocks in many situations, as they might involve waiting for the 381 * streaming thread to shut down from this very streaming thread. 382 * 383 * MT safe. 384 * 385 * Params: 386 * func = Function to call asynchronously from another thread 387 * userData = Data to pass to @func 388 * destroyNotify = GDestroyNotify for @user_data 389 * 390 * Since: 1.10 391 */ 392 public void callAsync(GstElementCallAsyncFunc func, void* userData, GDestroyNotify destroyNotify) 393 { 394 gst_element_call_async(gstElement, func, userData, destroyNotify); 395 } 396 397 /** 398 * Perform @transition on @element. 399 * 400 * This function must be called with STATE_LOCK held and is mainly used 401 * internally. 402 * 403 * Params: 404 * transition = the requested transition 405 * 406 * Returns: the #GstStateChangeReturn of the state transition. 407 */ 408 public GstStateChangeReturn changeState(GstStateChange transition) 409 { 410 return gst_element_change_state(gstElement, transition); 411 } 412 413 /** 414 * Commit the state change of the element and proceed to the next 415 * pending state if any. This function is used 416 * by elements that do asynchronous state changes. 417 * The core will normally call this method automatically when an 418 * element returned %GST_STATE_CHANGE_SUCCESS from the state change function. 419 * 420 * If after calling this method the element still has not reached 421 * the pending state, the next state change is performed. 422 * 423 * This method is used internally and should normally not be called by plugins 424 * or applications. 425 * 426 * Params: 427 * ret = The previous state return value 428 * 429 * Returns: The result of the commit state change. 430 * 431 * MT safe. 432 */ 433 public GstStateChangeReturn continueState(GstStateChangeReturn ret) 434 { 435 return gst_element_continue_state(gstElement, ret); 436 } 437 438 /** 439 * Creates a pad for each pad template that is always available. 440 * This function is only useful during object initialization of 441 * subclasses of #GstElement. 442 */ 443 public void createAllPads() 444 { 445 gst_element_create_all_pads(gstElement); 446 } 447 448 /** 449 * Returns the base time of the element. The base time is the 450 * absolute time of the clock when this element was last put to 451 * PLAYING. Subtracting the base time from the clock time gives 452 * the running time of the element. 453 * 454 * Returns: the base time of the element. 455 * 456 * MT safe. 457 */ 458 public GstClockTime getBaseTime() 459 { 460 return gst_element_get_base_time(gstElement); 461 } 462 463 /** 464 * Returns the bus of the element. Note that only a #GstPipeline will provide a 465 * bus for the application. 466 * 467 * Returns: the element's #GstBus. unref after usage. 468 * 469 * MT safe. 470 */ 471 public Bus getBus() 472 { 473 auto p = gst_element_get_bus(gstElement); 474 475 if(p is null) 476 { 477 return null; 478 } 479 480 return ObjectG.getDObject!(Bus)(cast(GstBus*) p, true); 481 } 482 483 /** 484 * Gets the currently configured clock of the element. This is the clock as was 485 * last set with gst_element_set_clock(). 486 * 487 * Elements in a pipeline will only have their clock set when the 488 * pipeline is in the PLAYING state. 489 * 490 * Returns: the #GstClock of the element. unref after usage. 491 * 492 * MT safe. 493 */ 494 public Clock getClock() 495 { 496 auto p = gst_element_get_clock(gstElement); 497 498 if(p is null) 499 { 500 return null; 501 } 502 503 return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true); 504 } 505 506 /** 507 * Looks for an unlinked pad to which the given pad can link. It is not 508 * guaranteed that linking the pads will work, though it should work in most 509 * cases. 510 * 511 * This function will first attempt to find a compatible unlinked ALWAYS pad, 512 * and if none can be found, it will request a compatible REQUEST pad by looking 513 * at the templates of @element. 514 * 515 * Params: 516 * pad = the #GstPad to find a compatible one for. 517 * caps = the #GstCaps to use as a filter. 518 * 519 * Returns: the #GstPad to which a link 520 * can be made, or %NULL if one cannot be found. gst_object_unref() 521 * after usage. 522 */ 523 public Pad getCompatiblePad(Pad pad, Caps caps) 524 { 525 auto p = gst_element_get_compatible_pad(gstElement, (pad is null) ? null : pad.getPadStruct(), (caps is null) ? null : caps.getCapsStruct()); 526 527 if(p is null) 528 { 529 return null; 530 } 531 532 return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true); 533 } 534 535 /** 536 * Retrieves a pad template from @element that is compatible with @compattempl. 537 * Pads from compatible templates can be linked together. 538 * 539 * Params: 540 * compattempl = the #GstPadTemplate to find a compatible 541 * template for 542 * 543 * Returns: a compatible #GstPadTemplate, 544 * or %NULL if none was found. No unreferencing is necessary. 545 */ 546 public PadTemplate getCompatiblePadTemplate(PadTemplate compattempl) 547 { 548 auto p = gst_element_get_compatible_pad_template(gstElement, (compattempl is null) ? null : compattempl.getPadTemplateStruct()); 549 550 if(p is null) 551 { 552 return null; 553 } 554 555 return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p); 556 } 557 558 /** 559 * Gets the context with @context_type set on the element or NULL. 560 * 561 * MT safe. 562 * 563 * Params: 564 * contextType = a name of a context to retrieve 565 * 566 * Returns: A #GstContext or NULL 567 * 568 * Since: 1.8 569 */ 570 public Context getContext(string contextType) 571 { 572 auto p = gst_element_get_context(gstElement, Str.toStringz(contextType)); 573 574 if(p is null) 575 { 576 return null; 577 } 578 579 return ObjectG.getDObject!(Context)(cast(GstContext*) p, true); 580 } 581 582 /** 583 * Gets the context with @context_type set on the element or NULL. 584 * 585 * Params: 586 * contextType = a name of a context to retrieve 587 * 588 * Returns: A #GstContext or NULL 589 * 590 * Since: 1.8 591 */ 592 public Context getContextUnlocked(string contextType) 593 { 594 auto p = gst_element_get_context_unlocked(gstElement, Str.toStringz(contextType)); 595 596 if(p is null) 597 { 598 return null; 599 } 600 601 return ObjectG.getDObject!(Context)(cast(GstContext*) p, true); 602 } 603 604 /** 605 * Gets the contexts set on the element. 606 * 607 * MT safe. 608 * 609 * Returns: List of #GstContext 610 * 611 * Since: 1.8 612 */ 613 public ListG getContexts() 614 { 615 auto p = gst_element_get_contexts(gstElement); 616 617 if(p is null) 618 { 619 return null; 620 } 621 622 return new ListG(cast(GList*) p, true); 623 } 624 625 /** 626 * Retrieves the factory that was used to create this element. 627 * 628 * Returns: the #GstElementFactory used for creating this 629 * element. no refcounting is needed. 630 */ 631 public ElementFactory getFactory() 632 { 633 auto p = gst_element_get_factory(gstElement); 634 635 if(p is null) 636 { 637 return null; 638 } 639 640 return ObjectG.getDObject!(ElementFactory)(cast(GstElementFactory*) p); 641 } 642 643 /** 644 * Retrieves a pad from the element by name (e.g. "src_\%d"). This version only 645 * retrieves request pads. The pad should be released with 646 * gst_element_release_request_pad(). 647 * 648 * This method is slower than manually getting the pad template and calling 649 * gst_element_request_pad() if the pads should have a specific name (e.g. 650 * @name is "src_1" instead of "src_\%u"). 651 * 652 * Params: 653 * name = the name of the request #GstPad to retrieve. 654 * 655 * Returns: requested #GstPad if found, 656 * otherwise %NULL. Release after usage. 657 */ 658 public Pad getRequestPad(string name) 659 { 660 auto p = gst_element_get_request_pad(gstElement, Str.toStringz(name)); 661 662 if(p is null) 663 { 664 return null; 665 } 666 667 return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true); 668 } 669 670 /** 671 * Returns the start time of the element. The start time is the 672 * running time of the clock when this element was last put to PAUSED. 673 * 674 * Usually the start_time is managed by a toplevel element such as 675 * #GstPipeline. 676 * 677 * MT safe. 678 * 679 * Returns: the start time of the element. 680 */ 681 public GstClockTime getStartTime() 682 { 683 return gst_element_get_start_time(gstElement); 684 } 685 686 /** 687 * Gets the state of the element. 688 * 689 * For elements that performed an ASYNC state change, as reported by 690 * gst_element_set_state(), this function will block up to the 691 * specified timeout value for the state change to complete. 692 * If the element completes the state change or goes into 693 * an error, this function returns immediately with a return value of 694 * %GST_STATE_CHANGE_SUCCESS or %GST_STATE_CHANGE_FAILURE respectively. 695 * 696 * For elements that did not return %GST_STATE_CHANGE_ASYNC, this function 697 * returns the current and pending state immediately. 698 * 699 * This function returns %GST_STATE_CHANGE_NO_PREROLL if the element 700 * successfully changed its state but is not able to provide data yet. 701 * This mostly happens for live sources that only produce data in 702 * %GST_STATE_PLAYING. While the state change return is equivalent to 703 * %GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that 704 * some sink elements might not be able to complete their state change because 705 * an element is not producing data to complete the preroll. When setting the 706 * element to playing, the preroll will complete and playback will start. 707 * 708 * Params: 709 * state = a pointer to #GstState to hold the state. 710 * Can be %NULL. 711 * pending = a pointer to #GstState to hold the pending 712 * state. Can be %NULL. 713 * timeout = a #GstClockTime to specify the timeout for an async 714 * state change or %GST_CLOCK_TIME_NONE for infinite timeout. 715 * 716 * Returns: %GST_STATE_CHANGE_SUCCESS if the element has no more pending state 717 * and the last state change succeeded, %GST_STATE_CHANGE_ASYNC if the 718 * element is still performing a state change or 719 * %GST_STATE_CHANGE_FAILURE if the last state change failed. 720 * 721 * MT safe. 722 */ 723 public GstStateChangeReturn getState(out GstState state, out GstState pending, GstClockTime timeout) 724 { 725 return gst_element_get_state(gstElement, &state, &pending, timeout); 726 } 727 728 /** 729 * Retrieves a pad from @element by name. This version only retrieves 730 * already-existing (i.e. 'static') pads. 731 * 732 * Params: 733 * name = the name of the static #GstPad to retrieve. 734 * 735 * Returns: the requested #GstPad if 736 * found, otherwise %NULL. unref after usage. 737 * 738 * MT safe. 739 */ 740 public Pad getStaticPad(string name) 741 { 742 auto p = gst_element_get_static_pad(gstElement, Str.toStringz(name)); 743 744 if(p is null) 745 { 746 return null; 747 } 748 749 return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true); 750 } 751 752 /** 753 * Checks if the state of an element is locked. 754 * If the state of an element is locked, state changes of the parent don't 755 * affect the element. 756 * This way you can leave currently unused elements inside bins. Just lock their 757 * state before changing the state from #GST_STATE_NULL. 758 * 759 * MT safe. 760 * 761 * Returns: %TRUE, if the element's state is locked. 762 */ 763 public bool isLockedState() 764 { 765 return gst_element_is_locked_state(gstElement) != 0; 766 } 767 768 /** 769 * Retrieves an iterator of @element's pads. The iterator should 770 * be freed after usage. Also more specialized iterators exists such as 771 * gst_element_iterate_src_pads() or gst_element_iterate_sink_pads(). 772 * 773 * The order of pads returned by the iterator will be the order in which 774 * the pads were added to the element. 775 * 776 * Returns: the #GstIterator of #GstPad. 777 * 778 * MT safe. 779 */ 780 public Iterator iteratePads() 781 { 782 auto p = gst_element_iterate_pads(gstElement); 783 784 if(p is null) 785 { 786 return null; 787 } 788 789 return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true); 790 } 791 792 /** 793 * Retrieves an iterator of @element's sink pads. 794 * 795 * The order of pads returned by the iterator will be the order in which 796 * the pads were added to the element. 797 * 798 * Returns: the #GstIterator of #GstPad. 799 * 800 * MT safe. 801 */ 802 public Iterator iterateSinkPads() 803 { 804 auto p = gst_element_iterate_sink_pads(gstElement); 805 806 if(p is null) 807 { 808 return null; 809 } 810 811 return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true); 812 } 813 814 /** 815 * Retrieves an iterator of @element's source pads. 816 * 817 * The order of pads returned by the iterator will be the order in which 818 * the pads were added to the element. 819 * 820 * Returns: the #GstIterator of #GstPad. 821 * 822 * MT safe. 823 */ 824 public Iterator iterateSrcPads() 825 { 826 auto p = gst_element_iterate_src_pads(gstElement); 827 828 if(p is null) 829 { 830 return null; 831 } 832 833 return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p, true); 834 } 835 836 /** 837 * Links @src to @dest. The link must be from source to 838 * destination; the other direction will not be tried. The function looks for 839 * existing pads that aren't linked yet. It will request new pads if necessary. 840 * Such pads need to be released manually when unlinking. 841 * If multiple links are possible, only one is established. 842 * 843 * Make sure you have added your elements to a bin or pipeline with 844 * gst_bin_add() before trying to link them. 845 * 846 * Params: 847 * dest = the #GstElement containing the destination pad. 848 * 849 * Returns: %TRUE if the elements could be linked, %FALSE otherwise. 850 */ 851 public bool link(Element dest) 852 { 853 return gst_element_link(gstElement, (dest is null) ? null : dest.getElementStruct()) != 0; 854 } 855 856 /** 857 * Links @src to @dest using the given caps as filtercaps. 858 * The link must be from source to 859 * destination; the other direction will not be tried. The function looks for 860 * existing pads that aren't linked yet. It will request new pads if necessary. 861 * If multiple links are possible, only one is established. 862 * 863 * Make sure you have added your elements to a bin or pipeline with 864 * gst_bin_add() before trying to link them. 865 * 866 * Params: 867 * dest = the #GstElement containing the destination pad. 868 * filter = the #GstCaps to filter the link, 869 * or %NULL for no filter. 870 * 871 * Returns: %TRUE if the pads could be linked, %FALSE otherwise. 872 */ 873 public bool linkFiltered(Element dest, Caps filter) 874 { 875 return gst_element_link_filtered(gstElement, (dest is null) ? null : dest.getElementStruct(), (filter is null) ? null : filter.getCapsStruct()) != 0; 876 } 877 878 /** 879 * Links the two named pads of the source and destination elements. 880 * Side effect is that if one of the pads has no parent, it becomes a 881 * child of the parent of the other element. If they have different 882 * parents, the link fails. 883 * 884 * Params: 885 * srcpadname = the name of the #GstPad in source element 886 * or %NULL for any pad. 887 * dest = the #GstElement containing the destination pad. 888 * destpadname = the name of the #GstPad in destination element, 889 * or %NULL for any pad. 890 * 891 * Returns: %TRUE if the pads could be linked, %FALSE otherwise. 892 */ 893 public bool linkPads(string srcpadname, Element dest, string destpadname) 894 { 895 return gst_element_link_pads(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname)) != 0; 896 } 897 898 /** 899 * Links the two named pads of the source and destination elements. Side effect 900 * is that if one of the pads has no parent, it becomes a child of the parent of 901 * the other element. If they have different parents, the link fails. If @caps 902 * is not %NULL, makes sure that the caps of the link is a subset of @caps. 903 * 904 * Params: 905 * srcpadname = the name of the #GstPad in source element 906 * or %NULL for any pad. 907 * dest = the #GstElement containing the destination pad. 908 * destpadname = the name of the #GstPad in destination element 909 * or %NULL for any pad. 910 * filter = the #GstCaps to filter the link, 911 * or %NULL for no filter. 912 * 913 * Returns: %TRUE if the pads could be linked, %FALSE otherwise. 914 */ 915 public bool linkPadsFiltered(string srcpadname, Element dest, string destpadname, Caps filter) 916 { 917 return gst_element_link_pads_filtered(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname), (filter is null) ? null : filter.getCapsStruct()) != 0; 918 } 919 920 /** 921 * Links the two named pads of the source and destination elements. 922 * Side effect is that if one of the pads has no parent, it becomes a 923 * child of the parent of the other element. If they have different 924 * parents, the link fails. 925 * 926 * Calling gst_element_link_pads_full() with @flags == %GST_PAD_LINK_CHECK_DEFAULT 927 * is the same as calling gst_element_link_pads() and the recommended way of 928 * linking pads with safety checks applied. 929 * 930 * This is a convenience function for gst_pad_link_full(). 931 * 932 * Params: 933 * srcpadname = the name of the #GstPad in source element 934 * or %NULL for any pad. 935 * dest = the #GstElement containing the destination pad. 936 * destpadname = the name of the #GstPad in destination element, 937 * or %NULL for any pad. 938 * flags = the #GstPadLinkCheck to be performed when linking pads. 939 * 940 * Returns: %TRUE if the pads could be linked, %FALSE otherwise. 941 */ 942 public bool linkPadsFull(string srcpadname, Element dest, string destpadname, GstPadLinkCheck flags) 943 { 944 return gst_element_link_pads_full(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname), flags) != 0; 945 } 946 947 /** 948 * Brings the element to the lost state. The current state of the 949 * element is copied to the pending state so that any call to 950 * gst_element_get_state() will return %GST_STATE_CHANGE_ASYNC. 951 * 952 * An ASYNC_START message is posted. If the element was PLAYING, it will 953 * go to PAUSED. The element will be restored to its PLAYING state by 954 * the parent pipeline when it prerolls again. 955 * 956 * This is mostly used for elements that lost their preroll buffer 957 * in the %GST_STATE_PAUSED or %GST_STATE_PLAYING state after a flush, 958 * they will go to their pending state again when a new preroll buffer is 959 * queued. This function can only be called when the element is currently 960 * not in error or an async state change. 961 * 962 * This function is used internally and should normally not be called from 963 * plugins or applications. 964 */ 965 public void lostState() 966 { 967 gst_element_lost_state(gstElement); 968 } 969 970 /** 971 * Post an error, warning or info message on the bus from inside an element. 972 * 973 * @type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or 974 * #GST_MESSAGE_INFO. 975 * 976 * MT safe. 977 * 978 * Params: 979 * type = the #GstMessageType 980 * domain = the GStreamer GError domain this message belongs to 981 * code = the GError code belonging to the domain 982 * text = an allocated text string to be used 983 * as a replacement for the default message connected to code, 984 * or %NULL 985 * dbg = an allocated debug message to be 986 * used as a replacement for the default debugging information, 987 * or %NULL 988 * file = the source code file where the error was generated 989 * funct = the source code function where the error was generated 990 * line = the source code line where the error was generated 991 */ 992 public void messageFull(GstMessageType type, GQuark domain, int code, string text, string dbg, string file, string funct, int line) 993 { 994 gst_element_message_full(gstElement, type, domain, code, Str.toStringz(text), Str.toStringz(dbg), Str.toStringz(file), Str.toStringz(funct), line); 995 } 996 997 /** 998 * Post an error, warning or info message on the bus from inside an element. 999 * 1000 * @type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or 1001 * #GST_MESSAGE_INFO. 1002 * 1003 * Params: 1004 * type = the #GstMessageType 1005 * domain = the GStreamer GError domain this message belongs to 1006 * code = the GError code belonging to the domain 1007 * text = an allocated text string to be used 1008 * as a replacement for the default message connected to code, 1009 * or %NULL 1010 * dbg = an allocated debug message to be 1011 * used as a replacement for the default debugging information, 1012 * or %NULL 1013 * file = the source code file where the error was generated 1014 * funct = the source code function where the error was generated 1015 * line = the source code line where the error was generated 1016 * structure = optional details structure 1017 * 1018 * Since: 1.10 1019 */ 1020 public void messageFullWithDetails(GstMessageType type, GQuark domain, int code, string text, string dbg, string file, string funct, int line, Structure structure) 1021 { 1022 gst_element_message_full_with_details(gstElement, type, domain, code, Str.toStringz(text), Str.toStringz(dbg), Str.toStringz(file), Str.toStringz(funct), line, (structure is null) ? null : structure.getStructureStruct(true)); 1023 } 1024 1025 /** 1026 * Use this function to signal that the element does not expect any more pads 1027 * to show up in the current pipeline. This function should be called whenever 1028 * pads have been added by the element itself. Elements with #GST_PAD_SOMETIMES 1029 * pad templates use this in combination with autopluggers to figure out that 1030 * the element is done initializing its pads. 1031 * 1032 * This function emits the #GstElement::no-more-pads signal. 1033 * 1034 * MT safe. 1035 */ 1036 public void noMorePads() 1037 { 1038 gst_element_no_more_pads(gstElement); 1039 } 1040 1041 /** 1042 * Post a message on the element's #GstBus. This function takes ownership of the 1043 * message; if you want to access the message after this call, you should add an 1044 * additional reference before calling. 1045 * 1046 * Params: 1047 * message = a #GstMessage to post 1048 * 1049 * Returns: %TRUE if the message was successfully posted. The function returns 1050 * %FALSE if the element did not have a bus. 1051 * 1052 * MT safe. 1053 */ 1054 public bool postMessage(Message message) 1055 { 1056 return gst_element_post_message(gstElement, (message is null) ? null : message.getMessageStruct()) != 0; 1057 } 1058 1059 /** 1060 * Get the clock provided by the given element. 1061 * > An element is only required to provide a clock in the PAUSED 1062 * > state. Some elements can provide a clock in other states. 1063 * 1064 * Returns: the GstClock provided by the 1065 * element or %NULL if no clock could be provided. Unref after usage. 1066 * 1067 * MT safe. 1068 */ 1069 public Clock provideClock() 1070 { 1071 auto p = gst_element_provide_clock(gstElement); 1072 1073 if(p is null) 1074 { 1075 return null; 1076 } 1077 1078 return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true); 1079 } 1080 1081 /** 1082 * Performs a query on the given element. 1083 * 1084 * For elements that don't implement a query handler, this function 1085 * forwards the query to a random srcpad or to the peer of a 1086 * random linked sinkpad of this element. 1087 * 1088 * Please note that some queries might need a running pipeline to work. 1089 * 1090 * Params: 1091 * query = the #GstQuery. 1092 * 1093 * Returns: %TRUE if the query could be performed. 1094 * 1095 * MT safe. 1096 */ 1097 public bool query(Query query) 1098 { 1099 return gst_element_query(gstElement, (query is null) ? null : query.getQueryStruct()) != 0; 1100 } 1101 1102 /** 1103 * Queries an element to convert @src_val in @src_format to @dest_format. 1104 * 1105 * Params: 1106 * srcFormat = a #GstFormat to convert from. 1107 * srcVal = a value to convert. 1108 * destFormat = the #GstFormat to convert to. 1109 * destVal = a pointer to the result. 1110 * 1111 * Returns: %TRUE if the query could be performed. 1112 */ 1113 public bool queryConvert(GstFormat srcFormat, long srcVal, GstFormat destFormat, out long destVal) 1114 { 1115 return gst_element_query_convert(gstElement, srcFormat, srcVal, destFormat, &destVal) != 0; 1116 } 1117 1118 /** 1119 * Queries an element (usually top-level pipeline or playbin element) for the 1120 * total stream duration in nanoseconds. This query will only work once the 1121 * pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application 1122 * will receive an ASYNC_DONE message on the pipeline bus when that is the case. 1123 * 1124 * If the duration changes for some reason, you will get a DURATION_CHANGED 1125 * message on the pipeline bus, in which case you should re-query the duration 1126 * using this function. 1127 * 1128 * Params: 1129 * format = the #GstFormat requested 1130 * duration = A location in which to store the total duration, or %NULL. 1131 * 1132 * Returns: %TRUE if the query could be performed. 1133 */ 1134 public bool queryDuration(GstFormat format, out long duration) 1135 { 1136 return gst_element_query_duration(gstElement, format, &duration) != 0; 1137 } 1138 1139 /** 1140 * Queries an element (usually top-level pipeline or playbin element) for the 1141 * stream position in nanoseconds. This will be a value between 0 and the 1142 * stream duration (if the stream duration is known). This query will usually 1143 * only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING 1144 * state). The application will receive an ASYNC_DONE message on the pipeline 1145 * bus when that is the case. 1146 * 1147 * If one repeatedly calls this function one can also create a query and reuse 1148 * it in gst_element_query(). 1149 * 1150 * Params: 1151 * format = the #GstFormat requested 1152 * cur = a location in which to store the current 1153 * position, or %NULL. 1154 * 1155 * Returns: %TRUE if the query could be performed. 1156 */ 1157 public bool queryPosition(GstFormat format, out long cur) 1158 { 1159 return gst_element_query_position(gstElement, format, &cur) != 0; 1160 } 1161 1162 /** 1163 * Makes the element free the previously requested pad as obtained 1164 * with gst_element_request_pad(). 1165 * 1166 * This does not unref the pad. If the pad was created by using 1167 * gst_element_request_pad(), gst_element_release_request_pad() needs to be 1168 * followed by gst_object_unref() to free the @pad. 1169 * 1170 * MT safe. 1171 * 1172 * Params: 1173 * pad = the #GstPad to release. 1174 */ 1175 public void releaseRequestPad(Pad pad) 1176 { 1177 gst_element_release_request_pad(gstElement, (pad is null) ? null : pad.getPadStruct()); 1178 } 1179 1180 /** 1181 * Removes @pad from @element. @pad will be destroyed if it has not been 1182 * referenced elsewhere using gst_object_unparent(). 1183 * 1184 * This function is used by plugin developers and should not be used 1185 * by applications. Pads that were dynamically requested from elements 1186 * with gst_element_request_pad() should be released with the 1187 * gst_element_release_request_pad() function instead. 1188 * 1189 * Pads are not automatically deactivated so elements should perform the needed 1190 * steps to deactivate the pad in case this pad is removed in the PAUSED or 1191 * PLAYING state. See gst_pad_set_active() for more information about 1192 * deactivating pads. 1193 * 1194 * The pad and the element should be unlocked when calling this function. 1195 * 1196 * This function will emit the #GstElement::pad-removed signal on the element. 1197 * 1198 * Params: 1199 * pad = the #GstPad to remove from the element. 1200 * 1201 * Returns: %TRUE if the pad could be removed. Can return %FALSE if the 1202 * pad does not belong to the provided element. 1203 * 1204 * MT safe. 1205 */ 1206 public bool removePad(Pad pad) 1207 { 1208 return gst_element_remove_pad(gstElement, (pad is null) ? null : pad.getPadStruct()) != 0; 1209 } 1210 1211 /** */ 1212 public void removePropertyNotifyWatch(gulong watchId) 1213 { 1214 gst_element_remove_property_notify_watch(gstElement, watchId); 1215 } 1216 1217 /** 1218 * Retrieves a request pad from the element according to the provided template. 1219 * Pad templates can be looked up using 1220 * gst_element_factory_get_static_pad_templates(). 1221 * 1222 * The pad should be released with gst_element_release_request_pad(). 1223 * 1224 * Params: 1225 * templ = a #GstPadTemplate of which we want a pad of. 1226 * name = the name of the request #GstPad 1227 * to retrieve. Can be %NULL. 1228 * caps = the caps of the pad we want to 1229 * request. Can be %NULL. 1230 * 1231 * Returns: requested #GstPad if found, 1232 * otherwise %NULL. Release after usage. 1233 */ 1234 public Pad requestPad(PadTemplate templ, string name, Caps caps) 1235 { 1236 auto p = gst_element_request_pad(gstElement, (templ is null) ? null : templ.getPadTemplateStruct(), Str.toStringz(name), (caps is null) ? null : caps.getCapsStruct()); 1237 1238 if(p is null) 1239 { 1240 return null; 1241 } 1242 1243 return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true); 1244 } 1245 1246 /** 1247 * Sends a seek event to an element. See gst_event_new_seek() for the details of 1248 * the parameters. The seek event is sent to the element using 1249 * gst_element_send_event(). 1250 * 1251 * MT safe. 1252 * 1253 * Params: 1254 * rate = The new playback rate 1255 * format = The format of the seek values 1256 * flags = The optional seek flags. 1257 * startType = The type and flags for the new start position 1258 * start = The value of the new start position 1259 * stopType = The type and flags for the new stop position 1260 * stop = The value of the new stop position 1261 * 1262 * Returns: %TRUE if the event was handled. Flushing seeks will trigger a 1263 * preroll, which will emit %GST_MESSAGE_ASYNC_DONE. 1264 */ 1265 public bool seek(double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop) 1266 { 1267 return gst_element_seek(gstElement, rate, format, flags, startType, start, stopType, stop) != 0; 1268 } 1269 1270 /** 1271 * Simple API to perform a seek on the given element, meaning it just seeks 1272 * to the given position relative to the start of the stream. For more complex 1273 * operations like segment seeks (e.g. for looping) or changing the playback 1274 * rate or seeking relative to the last configured playback segment you should 1275 * use gst_element_seek(). 1276 * 1277 * In a completely prerolled PAUSED or PLAYING pipeline, seeking is always 1278 * guaranteed to return %TRUE on a seekable media type or %FALSE when the media 1279 * type is certainly not seekable (such as a live stream). 1280 * 1281 * Some elements allow for seeking in the READY state, in this 1282 * case they will store the seek event and execute it when they are put to 1283 * PAUSED. If the element supports seek in READY, it will always return %TRUE when 1284 * it receives the event in the READY state. 1285 * 1286 * Params: 1287 * format = a #GstFormat to execute the seek in, such as #GST_FORMAT_TIME 1288 * seekFlags = seek options; playback applications will usually want to use 1289 * GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here 1290 * seekPos = position to seek to (relative to the start); if you are doing 1291 * a seek in #GST_FORMAT_TIME this value is in nanoseconds - 1292 * multiply with #GST_SECOND to convert seconds to nanoseconds or 1293 * with #GST_MSECOND to convert milliseconds to nanoseconds. 1294 * 1295 * Returns: %TRUE if the seek operation succeeded. Flushing seeks will trigger a 1296 * preroll, which will emit %GST_MESSAGE_ASYNC_DONE. 1297 */ 1298 public bool seekSimple(GstFormat format, GstSeekFlags seekFlags, long seekPos) 1299 { 1300 return gst_element_seek_simple(gstElement, format, seekFlags, seekPos) != 0; 1301 } 1302 1303 /** 1304 * Sends an event to an element. If the element doesn't implement an 1305 * event handler, the event will be pushed on a random linked sink pad for 1306 * downstream events or a random linked source pad for upstream events. 1307 * 1308 * This function takes ownership of the provided event so you should 1309 * gst_event_ref() it if you want to reuse the event after this call. 1310 * 1311 * MT safe. 1312 * 1313 * Params: 1314 * event = the #GstEvent to send to the element. 1315 * 1316 * Returns: %TRUE if the event was handled. Events that trigger a preroll (such 1317 * as flushing seeks and steps) will emit %GST_MESSAGE_ASYNC_DONE. 1318 */ 1319 public bool sendEvent(Event event) 1320 { 1321 return gst_element_send_event(gstElement, (event is null) ? null : event.getEventStruct()) != 0; 1322 } 1323 1324 /** 1325 * Set the base time of an element. See gst_element_get_base_time(). 1326 * 1327 * MT safe. 1328 * 1329 * Params: 1330 * time = the base time to set. 1331 */ 1332 public void setBaseTime(GstClockTime time) 1333 { 1334 gst_element_set_base_time(gstElement, time); 1335 } 1336 1337 /** 1338 * Sets the bus of the element. Increases the refcount on the bus. 1339 * For internal use only, unless you're testing elements. 1340 * 1341 * MT safe. 1342 * 1343 * Params: 1344 * bus = the #GstBus to set. 1345 */ 1346 public void setBus(Bus bus) 1347 { 1348 gst_element_set_bus(gstElement, (bus is null) ? null : bus.getBusStruct()); 1349 } 1350 1351 /** 1352 * Sets the clock for the element. This function increases the 1353 * refcount on the clock. Any previously set clock on the object 1354 * is unreffed. 1355 * 1356 * Params: 1357 * clock = the #GstClock to set for the element. 1358 * 1359 * Returns: %TRUE if the element accepted the clock. An element can refuse a 1360 * clock when it, for example, is not able to slave its internal clock to the 1361 * @clock or when it requires a specific clock to operate. 1362 * 1363 * MT safe. 1364 */ 1365 public bool setClock(Clock clock) 1366 { 1367 return gst_element_set_clock(gstElement, (clock is null) ? null : clock.getClockStruct()) != 0; 1368 } 1369 1370 /** 1371 * Sets the context of the element. Increases the refcount of the context. 1372 * 1373 * MT safe. 1374 * 1375 * Params: 1376 * context = the #GstContext to set. 1377 */ 1378 public void setContext(Context context) 1379 { 1380 gst_element_set_context(gstElement, (context is null) ? null : context.getContextStruct()); 1381 } 1382 1383 /** 1384 * Locks the state of an element, so state changes of the parent don't affect 1385 * this element anymore. 1386 * 1387 * MT safe. 1388 * 1389 * Params: 1390 * lockedState = %TRUE to lock the element's state 1391 * 1392 * Returns: %TRUE if the state was changed, %FALSE if bad parameters were given 1393 * or the elements state-locking needed no change. 1394 */ 1395 public bool setLockedState(bool lockedState) 1396 { 1397 return gst_element_set_locked_state(gstElement, lockedState) != 0; 1398 } 1399 1400 /** 1401 * Set the start time of an element. The start time of the element is the 1402 * running time of the element when it last went to the PAUSED state. In READY 1403 * or after a flushing seek, it is set to 0. 1404 * 1405 * Toplevel elements like #GstPipeline will manage the start_time and 1406 * base_time on its children. Setting the start_time to #GST_CLOCK_TIME_NONE 1407 * on such a toplevel element will disable the distribution of the base_time to 1408 * the children and can be useful if the application manages the base_time 1409 * itself, for example if you want to synchronize capture from multiple 1410 * pipelines, and you can also ensure that the pipelines have the same clock. 1411 * 1412 * MT safe. 1413 * 1414 * Params: 1415 * time = the base time to set. 1416 */ 1417 public void setStartTime(GstClockTime time) 1418 { 1419 gst_element_set_start_time(gstElement, time); 1420 } 1421 1422 /** 1423 * Sets the state of the element. This function will try to set the 1424 * requested state by going through all the intermediary states and calling 1425 * the class's state change function for each. 1426 * 1427 * This function can return #GST_STATE_CHANGE_ASYNC, in which case the 1428 * element will perform the remainder of the state change asynchronously in 1429 * another thread. 1430 * An application can use gst_element_get_state() to wait for the completion 1431 * of the state change or it can wait for a %GST_MESSAGE_ASYNC_DONE or 1432 * %GST_MESSAGE_STATE_CHANGED on the bus. 1433 * 1434 * State changes to %GST_STATE_READY or %GST_STATE_NULL never return 1435 * #GST_STATE_CHANGE_ASYNC. 1436 * 1437 * Params: 1438 * state = the element's new #GstState. 1439 * 1440 * Returns: Result of the state change using #GstStateChangeReturn. 1441 * 1442 * MT safe. 1443 */ 1444 public GstStateChangeReturn setState(GstState state) 1445 { 1446 return gst_element_set_state(gstElement, state); 1447 } 1448 1449 /** 1450 * Tries to change the state of the element to the same as its parent. 1451 * If this function returns %FALSE, the state of element is undefined. 1452 * 1453 * Returns: %TRUE, if the element's state could be synced to the parent's state. 1454 * 1455 * MT safe. 1456 */ 1457 public bool syncStateWithParent() 1458 { 1459 return gst_element_sync_state_with_parent(gstElement) != 0; 1460 } 1461 1462 /** 1463 * Unlinks all source pads of the source element with all sink pads 1464 * of the sink element to which they are linked. 1465 * 1466 * If the link has been made using gst_element_link(), it could have created an 1467 * requestpad, which has to be released using gst_element_release_request_pad(). 1468 * 1469 * Params: 1470 * dest = the sink #GstElement to unlink. 1471 */ 1472 public void unlink(Element dest) 1473 { 1474 gst_element_unlink(gstElement, (dest is null) ? null : dest.getElementStruct()); 1475 } 1476 1477 /** 1478 * Unlinks the two named pads of the source and destination elements. 1479 * 1480 * This is a convenience function for gst_pad_unlink(). 1481 * 1482 * Params: 1483 * srcpadname = the name of the #GstPad in source element. 1484 * dest = a #GstElement containing the destination pad. 1485 * destpadname = the name of the #GstPad in destination element. 1486 */ 1487 public void unlinkPads(string srcpadname, Element dest, string destpadname) 1488 { 1489 gst_element_unlink_pads(gstElement, Str.toStringz(srcpadname), (dest is null) ? null : dest.getElementStruct(), Str.toStringz(destpadname)); 1490 } 1491 1492 protected class OnNoMorePadsDelegateWrapper 1493 { 1494 void delegate(Element) dlg; 1495 gulong handlerId; 1496 1497 this(void delegate(Element) dlg) 1498 { 1499 this.dlg = dlg; 1500 onNoMorePadsListeners ~= this; 1501 } 1502 1503 void remove(OnNoMorePadsDelegateWrapper source) 1504 { 1505 foreach(index, wrapper; onNoMorePadsListeners) 1506 { 1507 if (wrapper.handlerId == source.handlerId) 1508 { 1509 onNoMorePadsListeners[index] = null; 1510 onNoMorePadsListeners = std.algorithm.remove(onNoMorePadsListeners, index); 1511 break; 1512 } 1513 } 1514 } 1515 } 1516 OnNoMorePadsDelegateWrapper[] onNoMorePadsListeners; 1517 1518 /** 1519 * This signals that the element will not generate more dynamic pads. 1520 * Note that this signal will usually be emitted from the context of 1521 * the streaming thread. 1522 */ 1523 gulong addOnNoMorePads(void delegate(Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1524 { 1525 auto wrapper = new OnNoMorePadsDelegateWrapper(dlg); 1526 wrapper.handlerId = Signals.connectData( 1527 this, 1528 "no-more-pads", 1529 cast(GCallback)&callBackNoMorePads, 1530 cast(void*)wrapper, 1531 cast(GClosureNotify)&callBackNoMorePadsDestroy, 1532 connectFlags); 1533 return wrapper.handlerId; 1534 } 1535 1536 extern(C) static void callBackNoMorePads(GstElement* elementStruct, OnNoMorePadsDelegateWrapper wrapper) 1537 { 1538 wrapper.dlg(wrapper.outer); 1539 } 1540 1541 extern(C) static void callBackNoMorePadsDestroy(OnNoMorePadsDelegateWrapper wrapper, GClosure* closure) 1542 { 1543 wrapper.remove(wrapper); 1544 } 1545 1546 protected class OnPadAddedDelegateWrapper 1547 { 1548 void delegate(Pad, Element) dlg; 1549 gulong handlerId; 1550 1551 this(void delegate(Pad, Element) dlg) 1552 { 1553 this.dlg = dlg; 1554 onPadAddedListeners ~= this; 1555 } 1556 1557 void remove(OnPadAddedDelegateWrapper source) 1558 { 1559 foreach(index, wrapper; onPadAddedListeners) 1560 { 1561 if (wrapper.handlerId == source.handlerId) 1562 { 1563 onPadAddedListeners[index] = null; 1564 onPadAddedListeners = std.algorithm.remove(onPadAddedListeners, index); 1565 break; 1566 } 1567 } 1568 } 1569 } 1570 OnPadAddedDelegateWrapper[] onPadAddedListeners; 1571 1572 /** 1573 * a new #GstPad has been added to the element. Note that this signal will 1574 * usually be emitted from the context of the streaming thread. Also keep in 1575 * mind that if you add new elements to the pipeline in the signal handler 1576 * you will need to set them to the desired target state with 1577 * gst_element_set_state() or gst_element_sync_state_with_parent(). 1578 * 1579 * Params: 1580 * newPad = the pad that has been added 1581 */ 1582 gulong addOnPadAdded(void delegate(Pad, Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1583 { 1584 auto wrapper = new OnPadAddedDelegateWrapper(dlg); 1585 wrapper.handlerId = Signals.connectData( 1586 this, 1587 "pad-added", 1588 cast(GCallback)&callBackPadAdded, 1589 cast(void*)wrapper, 1590 cast(GClosureNotify)&callBackPadAddedDestroy, 1591 connectFlags); 1592 return wrapper.handlerId; 1593 } 1594 1595 extern(C) static void callBackPadAdded(GstElement* elementStruct, GstPad* newPad, OnPadAddedDelegateWrapper wrapper) 1596 { 1597 wrapper.dlg(ObjectG.getDObject!(Pad)(newPad), wrapper.outer); 1598 } 1599 1600 extern(C) static void callBackPadAddedDestroy(OnPadAddedDelegateWrapper wrapper, GClosure* closure) 1601 { 1602 wrapper.remove(wrapper); 1603 } 1604 1605 protected class OnPadRemovedDelegateWrapper 1606 { 1607 void delegate(Pad, Element) dlg; 1608 gulong handlerId; 1609 1610 this(void delegate(Pad, Element) dlg) 1611 { 1612 this.dlg = dlg; 1613 onPadRemovedListeners ~= this; 1614 } 1615 1616 void remove(OnPadRemovedDelegateWrapper source) 1617 { 1618 foreach(index, wrapper; onPadRemovedListeners) 1619 { 1620 if (wrapper.handlerId == source.handlerId) 1621 { 1622 onPadRemovedListeners[index] = null; 1623 onPadRemovedListeners = std.algorithm.remove(onPadRemovedListeners, index); 1624 break; 1625 } 1626 } 1627 } 1628 } 1629 OnPadRemovedDelegateWrapper[] onPadRemovedListeners; 1630 1631 /** 1632 * a #GstPad has been removed from the element 1633 * 1634 * Params: 1635 * oldPad = the pad that has been removed 1636 */ 1637 gulong addOnPadRemoved(void delegate(Pad, Element) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1638 { 1639 auto wrapper = new OnPadRemovedDelegateWrapper(dlg); 1640 wrapper.handlerId = Signals.connectData( 1641 this, 1642 "pad-removed", 1643 cast(GCallback)&callBackPadRemoved, 1644 cast(void*)wrapper, 1645 cast(GClosureNotify)&callBackPadRemovedDestroy, 1646 connectFlags); 1647 return wrapper.handlerId; 1648 } 1649 1650 extern(C) static void callBackPadRemoved(GstElement* elementStruct, GstPad* oldPad, OnPadRemovedDelegateWrapper wrapper) 1651 { 1652 wrapper.dlg(ObjectG.getDObject!(Pad)(oldPad), wrapper.outer); 1653 } 1654 1655 extern(C) static void callBackPadRemovedDestroy(OnPadRemovedDelegateWrapper wrapper, GClosure* closure) 1656 { 1657 wrapper.remove(wrapper); 1658 } 1659 }