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