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