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