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