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.Event; 26 27 private import glib.ConstructionException; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gstreamer.Buffer; 32 private import gstreamer.Caps; 33 private import gstreamer.Message; 34 private import gstreamer.Segment; 35 private import gstreamer.Stream; 36 private import gstreamer.StreamCollection; 37 private import gstreamer.Structure; 38 private import gstreamer.TagList; 39 private import gstreamer.Toc; 40 private import gstreamer.c.functions; 41 public import gstreamer.c.types; 42 public import gstreamerc.gstreamertypes; 43 44 45 /** 46 * The event class provides factory methods to construct events for sending 47 * and functions to query (parse) received events. 48 * 49 * Events are usually created with gst_event_new_*() which takes event-type 50 * specific parameters as arguments. 51 * To send an event application will usually use gst_element_send_event() and 52 * elements will use gst_pad_send_event() or gst_pad_push_event(). 53 * The event should be unreffed with gst_event_unref() if it has not been sent. 54 * 55 * Events that have been received can be parsed with their respective 56 * gst_event_parse_*() functions. It is valid to pass %NULL for unwanted details. 57 * 58 * Events are passed between elements in parallel to the data stream. Some events 59 * are serialized with buffers, others are not. Some events only travel downstream, 60 * others only upstream. Some events can travel both upstream and downstream. 61 * 62 * The events are used to signal special conditions in the datastream such as 63 * EOS (end of stream) or the start of a new stream-segment. 64 * Events are also used to flush the pipeline of any pending data. 65 * 66 * Most of the event API is used inside plugins. Applications usually only 67 * construct and use seek events. 68 * To do that gst_event_new_seek() is used to create a seek event. It takes 69 * the needed parameters to specify seeking time and mode. 70 * |[<!-- language="C" --> 71 * GstEvent *event; 72 * gboolean result; 73 * ... 74 * // construct a seek event to play the media from second 2 to 5, flush 75 * // the pipeline to decrease latency. 76 * event = gst_event_new_seek (1.0, 77 * GST_FORMAT_TIME, 78 * GST_SEEK_FLAG_FLUSH, 79 * GST_SEEK_TYPE_SET, 2 * GST_SECOND, 80 * GST_SEEK_TYPE_SET, 5 * GST_SECOND); 81 * ... 82 * result = gst_element_send_event (pipeline, event); 83 * if (!result) 84 * g_warning ("seek failed"); 85 * ... 86 * ]| 87 */ 88 public class Event 89 { 90 /** the main Gtk struct */ 91 protected GstEvent* gstEvent; 92 protected bool ownedRef; 93 94 /** Get the main Gtk struct */ 95 public GstEvent* getEventStruct(bool transferOwnership = false) 96 { 97 if (transferOwnership) 98 ownedRef = false; 99 return gstEvent; 100 } 101 102 /** the main Gtk struct as a void* */ 103 protected void* getStruct() 104 { 105 return cast(void*)gstEvent; 106 } 107 108 /** 109 * Sets our main struct and passes it to the parent class. 110 */ 111 public this (GstEvent* gstEvent, bool ownedRef = false) 112 { 113 this.gstEvent = gstEvent; 114 this.ownedRef = ownedRef; 115 } 116 117 /** 118 * Create a new EOS event. The eos event can only travel downstream 119 * synchronized with the buffer flow. Elements that receive the EOS 120 * event on a pad can return UNEXPECTED as a GstFlowReturn when data 121 * after the EOS event arrives. 122 * The EOS event will travel down to the sink elements in the pipeline 123 * which will then post the GST_MESSAGE_EOS on the bus after they have 124 * finished playing any buffered data. 125 * When all sinks have posted an EOS message, the EOS message is 126 * forwarded to the application. 127 * Returns: 128 * The new EOS event. 129 */ 130 public static Event newEOS() 131 { 132 // GstEvent* gst_event_new_eos (void); 133 auto p = gst_event_new_eos(); 134 135 if(p is null) 136 { 137 throw new ConstructionException("null returned by gst_event_new_eos"); 138 } 139 140 return new Event(cast(GstEvent*)p ); 141 } 142 143 /** 144 * Allocate a new flush start event. The flush start event can be send 145 * upstream and downstream and travels out-of-bounds with the dataflow. 146 * It marks pads as being in a WRONG_STATE to process more data. 147 * Elements unlock and blocking functions and exit their streaming functions 148 * as fast as possible. 149 * This event is typically generated after a seek to minimize the latency 150 * after the seek. 151 * Returns: 152 * A new flush start event. 153 */ 154 public static Event newFlushStart() 155 { 156 // GstEvent* gst_event_new_flush_start (void); 157 auto p = gst_event_new_flush_start(); 158 159 if(p is null) 160 { 161 throw new ConstructionException("null returned by gst_event_new_flush_start"); 162 } 163 164 return new Event(cast(GstEvent*)p ); 165 } 166 167 /** 168 * Generate a TOC select event with the given uid. The purpose of the 169 * TOC select event is to start playback based on the TOC's entry with 170 * the given uid. 171 */ 172 public static Event newTocSelect(string uid) 173 { 174 // GstEvent* gst_event_new_toc_select (const gchar *uid); 175 auto p = gst_event_new_toc_select(cast(char*)uid.ptr); 176 177 if(p is null) 178 { 179 throw new ConstructionException("null returned by gst_event_new_toc_select"); 180 } 181 182 return new Event(cast(GstEvent*)p ); 183 } 184 185 /** 186 */ 187 188 /** */ 189 public static GType getType() 190 { 191 return gst_event_get_type(); 192 } 193 194 /** 195 * Create a new buffersize event. The event is sent downstream and notifies 196 * elements that they should provide a buffer of the specified dimensions. 197 * 198 * When the @async flag is set, a thread boundary is preferred. 199 * 200 * Params: 201 * format = buffer format 202 * minsize = minimum buffer size 203 * maxsize = maximum buffer size 204 * async = thread behavior 205 * 206 * Returns: a new #GstEvent 207 * 208 * Throws: ConstructionException GTK+ fails to create the object. 209 */ 210 public this(GstFormat format, long minsize, long maxsize, bool async) 211 { 212 auto p = gst_event_new_buffer_size(format, minsize, maxsize, async); 213 214 if(p is null) 215 { 216 throw new ConstructionException("null returned by new_buffer_size"); 217 } 218 219 this(cast(GstEvent*) p); 220 } 221 222 /** 223 * Create a new CAPS event for @caps. The caps event can only travel downstream 224 * synchronized with the buffer flow and contains the format of the buffers 225 * that will follow after the event. 226 * 227 * Params: 228 * caps = a #GstCaps 229 * 230 * Returns: the new CAPS event. 231 * 232 * Throws: ConstructionException GTK+ fails to create the object. 233 */ 234 public this(Caps caps) 235 { 236 auto p = gst_event_new_caps((caps is null) ? null : caps.getCapsStruct()); 237 238 if(p is null) 239 { 240 throw new ConstructionException("null returned by new_caps"); 241 } 242 243 this(cast(GstEvent*) p); 244 } 245 246 /** 247 * Create a new custom-typed event. This can be used for anything not 248 * handled by other event-specific functions to pass an event to another 249 * element. 250 * 251 * Make sure to allocate an event type with the #GST_EVENT_MAKE_TYPE macro, 252 * assigning a free number and filling in the correct direction and 253 * serialization flags. 254 * 255 * New custom events can also be created by subclassing the event type if 256 * needed. 257 * 258 * Params: 259 * type = The type of the new event 260 * structure = the structure for the event. The event will 261 * take ownership of the structure. 262 * 263 * Returns: the new custom event. 264 * 265 * Throws: ConstructionException GTK+ fails to create the object. 266 */ 267 public this(GstEventType type, Structure structure) 268 { 269 auto p = gst_event_new_custom(type, (structure is null) ? null : structure.getStructureStruct(true)); 270 271 if(p is null) 272 { 273 throw new ConstructionException("null returned by new_custom"); 274 } 275 276 this(cast(GstEvent*) p); 277 } 278 279 /** 280 * Allocate a new flush stop event. The flush stop event can be sent 281 * upstream and downstream and travels serialized with the dataflow. 282 * It is typically sent after sending a FLUSH_START event to make the 283 * pads accept data again. 284 * 285 * Elements can process this event synchronized with the dataflow since 286 * the preceding FLUSH_START event stopped the dataflow. 287 * 288 * This event is typically generated to complete a seek and to resume 289 * dataflow. 290 * 291 * Params: 292 * resetTime = if time should be reset 293 * 294 * Returns: a new flush stop event. 295 * 296 * Throws: ConstructionException GTK+ fails to create the object. 297 */ 298 public this(bool resetTime) 299 { 300 auto p = gst_event_new_flush_stop(resetTime); 301 302 if(p is null) 303 { 304 throw new ConstructionException("null returned by new_flush_stop"); 305 } 306 307 this(cast(GstEvent*) p); 308 } 309 310 /** 311 * Create a new GAP event. A gap event can be thought of as conceptually 312 * equivalent to a buffer to signal that there is no data for a certain 313 * amount of time. This is useful to signal a gap to downstream elements 314 * which may wait for data, such as muxers or mixers or overlays, especially 315 * for sparse streams such as subtitle streams. 316 * 317 * Params: 318 * timestamp = the start time (pts) of the gap 319 * duration = the duration of the gap 320 * 321 * Returns: the new GAP event. 322 * 323 * Throws: ConstructionException GTK+ fails to create the object. 324 */ 325 public this(GstClockTime timestamp, GstClockTime duration) 326 { 327 auto p = gst_event_new_gap(timestamp, duration); 328 329 if(p is null) 330 { 331 throw new ConstructionException("null returned by new_gap"); 332 } 333 334 this(cast(GstEvent*) p); 335 } 336 337 /** 338 * Create a new latency event. The event is sent upstream from the sinks and 339 * notifies elements that they should add an additional @latency to the 340 * running time before synchronising against the clock. 341 * 342 * The latency is mostly used in live sinks and is always expressed in 343 * the time format. 344 * 345 * Params: 346 * latency = the new latency value 347 * 348 * Returns: a new #GstEvent 349 * 350 * Throws: ConstructionException GTK+ fails to create the object. 351 */ 352 public this(GstClockTime latency) 353 { 354 auto p = gst_event_new_latency(latency); 355 356 if(p is null) 357 { 358 throw new ConstructionException("null returned by new_latency"); 359 } 360 361 this(cast(GstEvent*) p); 362 } 363 364 /** 365 * Create a new navigation event from the given description. 366 * 367 * Params: 368 * structure = description of the event. The event will take 369 * ownership of the structure. 370 * 371 * Returns: a new #GstEvent 372 * 373 * Throws: ConstructionException GTK+ fails to create the object. 374 */ 375 public this(Structure structure) 376 { 377 auto p = gst_event_new_navigation((structure is null) ? null : structure.getStructureStruct(true)); 378 379 if(p is null) 380 { 381 throw new ConstructionException("null returned by new_navigation"); 382 } 383 384 this(cast(GstEvent*) p); 385 } 386 387 /** 388 * Creates a new event containing information specific to a particular 389 * protection system (uniquely identified by @system_id), by which that 390 * protection system can acquire key(s) to decrypt a protected stream. 391 * 392 * In order for a decryption element to decrypt media 393 * protected using a specific system, it first needs all the 394 * protection system specific information necessary to acquire the decryption 395 * key(s) for that stream. The functions defined here enable this information 396 * to be passed in events from elements that extract it 397 * (e.g., ISOBMFF demuxers, MPEG DASH demuxers) to protection decrypter 398 * elements that use it. 399 * 400 * Events containing protection system specific information are created using 401 * #gst_event_new_protection, and they can be parsed by downstream elements 402 * using #gst_event_parse_protection. 403 * 404 * In Common Encryption, protection system specific information may be located 405 * within ISOBMFF files, both in movie (moov) boxes and movie fragment (moof) 406 * boxes; it may also be contained in ContentProtection elements within MPEG 407 * DASH MPDs. The events created by #gst_event_new_protection contain data 408 * identifying from which of these locations the encapsulated protection system 409 * specific information originated. This origin information is required as 410 * some protection systems use different encodings depending upon where the 411 * information originates. 412 * 413 * The events returned by gst_event_new_protection() are implemented 414 * in such a way as to ensure that the most recently-pushed protection info 415 * event of a particular @origin and @system_id will 416 * be stuck to the output pad of the sending element. 417 * 418 * Params: 419 * systemId = a string holding a UUID that uniquely 420 * identifies a protection system. 421 * data = a #GstBuffer holding protection system specific 422 * information. The reference count of the buffer will be incremented by one. 423 * origin = a string indicating where the protection 424 * information carried in the event was extracted from. The allowed values 425 * of this string will depend upon the protection scheme. 426 * 427 * Returns: a #GST_EVENT_PROTECTION event, if successful; %NULL 428 * if unsuccessful. 429 * 430 * Since: 1.6 431 * 432 * Throws: ConstructionException GTK+ fails to create the object. 433 */ 434 public this(string systemId, Buffer data, string origin) 435 { 436 auto p = gst_event_new_protection(Str.toStringz(systemId), (data is null) ? null : data.getBufferStruct(), Str.toStringz(origin)); 437 438 if(p is null) 439 { 440 throw new ConstructionException("null returned by new_protection"); 441 } 442 443 this(cast(GstEvent*) p); 444 } 445 446 /** 447 * Allocate a new qos event with the given values. 448 * The QOS event is generated in an element that wants an upstream 449 * element to either reduce or increase its rate because of 450 * high/low CPU load or other resource usage such as network performance or 451 * throttling. Typically sinks generate these events for each buffer 452 * they receive. 453 * 454 * @type indicates the reason for the QoS event. #GST_QOS_TYPE_OVERFLOW is 455 * used when a buffer arrived in time or when the sink cannot keep up with 456 * the upstream datarate. #GST_QOS_TYPE_UNDERFLOW is when the sink is not 457 * receiving buffers fast enough and thus has to drop late buffers. 458 * #GST_QOS_TYPE_THROTTLE is used when the datarate is artificially limited 459 * by the application, for example to reduce power consumption. 460 * 461 * @proportion indicates the real-time performance of the streaming in the 462 * element that generated the QoS event (usually the sink). The value is 463 * generally computed based on more long term statistics about the streams 464 * timestamps compared to the clock. 465 * A value < 1.0 indicates that the upstream element is producing data faster 466 * than real-time. A value > 1.0 indicates that the upstream element is not 467 * producing data fast enough. 1.0 is the ideal @proportion value. The 468 * proportion value can safely be used to lower or increase the quality of 469 * the element. 470 * 471 * @diff is the difference against the clock in running time of the last 472 * buffer that caused the element to generate the QOS event. A negative value 473 * means that the buffer with @timestamp arrived in time. A positive value 474 * indicates how late the buffer with @timestamp was. When throttling is 475 * enabled, @diff will be set to the requested throttling interval. 476 * 477 * @timestamp is the timestamp of the last buffer that cause the element 478 * to generate the QOS event. It is expressed in running time and thus an ever 479 * increasing value. 480 * 481 * The upstream element can use the @diff and @timestamp values to decide 482 * whether to process more buffers. For positive @diff, all buffers with 483 * timestamp <= @timestamp + @diff will certainly arrive late in the sink 484 * as well. A (negative) @diff value so that @timestamp + @diff would yield a 485 * result smaller than 0 is not allowed. 486 * 487 * The application can use general event probes to intercept the QoS 488 * event and implement custom application specific QoS handling. 489 * 490 * Params: 491 * type = the QoS type 492 * proportion = the proportion of the qos message 493 * diff = The time difference of the last Clock sync 494 * timestamp = The timestamp of the buffer 495 * 496 * Returns: a new QOS event. 497 * 498 * Throws: ConstructionException GTK+ fails to create the object. 499 */ 500 public this(GstQOSType type, double proportion, GstClockTimeDiff diff, GstClockTime timestamp) 501 { 502 auto p = gst_event_new_qos(type, proportion, diff, timestamp); 503 504 if(p is null) 505 { 506 throw new ConstructionException("null returned by new_qos"); 507 } 508 509 this(cast(GstEvent*) p); 510 } 511 512 /** 513 * Create a new reconfigure event. The purpose of the reconfigure event is 514 * to travel upstream and make elements renegotiate their caps or reconfigure 515 * their buffer pools. This is useful when changing properties on elements 516 * or changing the topology of the pipeline. 517 * 518 * Returns: a new #GstEvent 519 * 520 * Throws: ConstructionException GTK+ fails to create the object. 521 */ 522 public this() 523 { 524 auto p = gst_event_new_reconfigure(); 525 526 if(p is null) 527 { 528 throw new ConstructionException("null returned by new_reconfigure"); 529 } 530 531 this(cast(GstEvent*) p); 532 } 533 534 /** 535 * Allocate a new seek event with the given parameters. 536 * 537 * The seek event configures playback of the pipeline between @start to @stop 538 * at the speed given in @rate, also called a playback segment. 539 * The @start and @stop values are expressed in @format. 540 * 541 * A @rate of 1.0 means normal playback rate, 2.0 means double speed. 542 * Negatives values means backwards playback. A value of 0.0 for the 543 * rate is not allowed and should be accomplished instead by PAUSING the 544 * pipeline. 545 * 546 * A pipeline has a default playback segment configured with a start 547 * position of 0, a stop position of -1 and a rate of 1.0. The currently 548 * configured playback segment can be queried with #GST_QUERY_SEGMENT. 549 * 550 * @start_type and @stop_type specify how to adjust the currently configured 551 * start and stop fields in playback segment. Adjustments can be made relative 552 * or absolute to the last configured values. A type of #GST_SEEK_TYPE_NONE 553 * means that the position should not be updated. 554 * 555 * When the rate is positive and @start has been updated, playback will start 556 * from the newly configured start position. 557 * 558 * For negative rates, playback will start from the newly configured stop 559 * position (if any). If the stop position is updated, it must be different from 560 * -1 (#GST_CLOCK_TIME_NONE) for negative rates. 561 * 562 * It is not possible to seek relative to the current playback position, to do 563 * this, PAUSE the pipeline, query the current playback position with 564 * #GST_QUERY_POSITION and update the playback segment current position with a 565 * #GST_SEEK_TYPE_SET to the desired position. 566 * 567 * Params: 568 * rate = The new playback rate 569 * format = The format of the seek values 570 * flags = The optional seek flags 571 * startType = The type and flags for the new start position 572 * start = The value of the new start position 573 * stopType = The type and flags for the new stop position 574 * stop = The value of the new stop position 575 * 576 * Returns: a new seek event. 577 * 578 * Throws: ConstructionException GTK+ fails to create the object. 579 */ 580 public this(double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop) 581 { 582 auto p = gst_event_new_seek(rate, format, flags, startType, start, stopType, stop); 583 584 if(p is null) 585 { 586 throw new ConstructionException("null returned by new_seek"); 587 } 588 589 this(cast(GstEvent*) p); 590 } 591 592 /** 593 * Create a new SEGMENT event for @segment. The segment event can only travel 594 * downstream synchronized with the buffer flow and contains timing information 595 * and playback properties for the buffers that will follow. 596 * 597 * The segment event marks the range of buffers to be processed. All 598 * data not within the segment range is not to be processed. This can be 599 * used intelligently by plugins to apply more efficient methods of skipping 600 * unneeded data. The valid range is expressed with the @start and @stop 601 * values. 602 * 603 * The time value of the segment is used in conjunction with the start 604 * value to convert the buffer timestamps into the stream time. This is 605 * usually done in sinks to report the current stream_time. 606 * @time represents the stream_time of a buffer carrying a timestamp of 607 * @start. @time cannot be -1. 608 * 609 * @start cannot be -1, @stop can be -1. If there 610 * is a valid @stop given, it must be greater or equal the @start, including 611 * when the indicated playback @rate is < 0. 612 * 613 * The @applied_rate value provides information about any rate adjustment that 614 * has already been made to the timestamps and content on the buffers of the 615 * stream. (@rate * @applied_rate) should always equal the rate that has been 616 * requested for playback. For example, if an element has an input segment 617 * with intended playback @rate of 2.0 and applied_rate of 1.0, it can adjust 618 * incoming timestamps and buffer content by half and output a segment event 619 * with @rate of 1.0 and @applied_rate of 2.0 620 * 621 * After a segment event, the buffer stream time is calculated with: 622 * 623 * time + (TIMESTAMP(buf) - start) * ABS (rate * applied_rate) 624 * 625 * Params: 626 * segment = a #GstSegment 627 * 628 * Returns: the new SEGMENT event. 629 * 630 * Throws: ConstructionException GTK+ fails to create the object. 631 */ 632 public this(Segment segment) 633 { 634 auto p = gst_event_new_segment((segment is null) ? null : segment.getSegmentStruct()); 635 636 if(p is null) 637 { 638 throw new ConstructionException("null returned by new_segment"); 639 } 640 641 this(cast(GstEvent*) p); 642 } 643 644 /** 645 * Create a new segment-done event. This event is sent by elements that 646 * finish playback of a segment as a result of a segment seek. 647 * 648 * Params: 649 * format = The format of the position being done 650 * position = The position of the segment being done 651 * 652 * Returns: a new #GstEvent 653 * 654 * Throws: ConstructionException GTK+ fails to create the object. 655 */ 656 public this(GstFormat format, long position) 657 { 658 auto p = gst_event_new_segment_done(format, position); 659 660 if(p is null) 661 { 662 throw new ConstructionException("null returned by new_segment_done"); 663 } 664 665 this(cast(GstEvent*) p); 666 } 667 668 /** 669 * Allocate a new select-streams event. 670 * 671 * The select-streams event requests the specified @streams to be activated. 672 * 673 * The list of @streams corresponds to the "Stream ID" of each stream to be 674 * activated. Those ID can be obtained via the #GstStream objects present 675 * in #GST_EVENT_STREAM_START, #GST_EVENT_STREAM_COLLECTION or 676 * #GST_MESSAGE_STREAM_COLLECTION. 677 * 678 * Note: The list of @streams can not be empty. 679 * 680 * Params: 681 * streams = the list of streams to 682 * activate 683 * 684 * Returns: a new select-streams event or %NULL in case of 685 * an error (like an empty streams list). 686 * 687 * Since: 1.10 688 * 689 * Throws: ConstructionException GTK+ fails to create the object. 690 */ 691 public this(ListG streams) 692 { 693 auto p = gst_event_new_select_streams((streams is null) ? null : streams.getListGStruct()); 694 695 if(p is null) 696 { 697 throw new ConstructionException("null returned by new_select_streams"); 698 } 699 700 this(cast(GstEvent*) p); 701 } 702 703 /** 704 * Create a new sink-message event. The purpose of the sink-message event is 705 * to instruct a sink to post the message contained in the event synchronized 706 * with the stream. 707 * 708 * @name is used to store multiple sticky events on one pad. 709 * 710 * Params: 711 * name = a name for the event 712 * msg = the #GstMessage to be posted 713 * 714 * Returns: a new #GstEvent 715 * 716 * Throws: ConstructionException GTK+ fails to create the object. 717 */ 718 public this(string name, Message msg) 719 { 720 auto p = gst_event_new_sink_message(Str.toStringz(name), (msg is null) ? null : msg.getMessageStruct()); 721 722 if(p is null) 723 { 724 throw new ConstructionException("null returned by new_sink_message"); 725 } 726 727 this(cast(GstEvent*) p); 728 } 729 730 /** 731 * Create a new step event. The purpose of the step event is to instruct a sink 732 * to skip @amount (expressed in @format) of media. It can be used to implement 733 * stepping through the video frame by frame or for doing fast trick modes. 734 * 735 * A rate of <= 0.0 is not allowed. Pause the pipeline, for the effect of rate 736 * = 0.0 or first reverse the direction of playback using a seek event to get 737 * the same effect as rate < 0.0. 738 * 739 * The @flush flag will clear any pending data in the pipeline before starting 740 * the step operation. 741 * 742 * The @intermediate flag instructs the pipeline that this step operation is 743 * part of a larger step operation. 744 * 745 * Params: 746 * format = the format of @amount 747 * amount = the amount of data to step 748 * rate = the step rate 749 * flush = flushing steps 750 * intermediate = intermediate steps 751 * 752 * Returns: a new #GstEvent 753 * 754 * Throws: ConstructionException GTK+ fails to create the object. 755 */ 756 public this(GstFormat format, ulong amount, double rate, bool flush, bool intermediate) 757 { 758 auto p = gst_event_new_step(format, amount, rate, flush, intermediate); 759 760 if(p is null) 761 { 762 throw new ConstructionException("null returned by new_step"); 763 } 764 765 this(cast(GstEvent*) p); 766 } 767 768 /** 769 * Create a new STREAM_COLLECTION event. The stream collection event can only 770 * travel downstream synchronized with the buffer flow. 771 * 772 * Source elements, demuxers and other elements that manage collections 773 * of streams and post #GstStreamCollection messages on the bus also send 774 * this event downstream on each pad involved in the collection, so that 775 * activation of a new collection can be tracked through the downstream 776 * data flow. 777 * 778 * Params: 779 * collection = Active collection for this data flow 780 * 781 * Returns: the new STREAM_COLLECTION event. 782 * 783 * Since: 1.10 784 * 785 * Throws: ConstructionException GTK+ fails to create the object. 786 */ 787 public this(StreamCollection collection) 788 { 789 auto p = gst_event_new_stream_collection((collection is null) ? null : collection.getStreamCollectionStruct()); 790 791 if(p is null) 792 { 793 throw new ConstructionException("null returned by new_stream_collection"); 794 } 795 796 this(cast(GstEvent*) p); 797 } 798 799 /** 800 * Create a new Stream Group Done event. The stream-group-done event can 801 * only travel downstream synchronized with the buffer flow. Elements 802 * that receive the event on a pad should handle it mostly like EOS, 803 * and emit any data or pending buffers that would depend on more data 804 * arriving and unblock, since there won't be any more data. 805 * 806 * This event is followed by EOS at some point in the future, and is 807 * generally used when switching pads - to unblock downstream so that 808 * new pads can be exposed before sending EOS on the existing pads. 809 * 810 * Params: 811 * groupId = the group id of the stream group which is ending 812 * 813 * Returns: the new stream-group-done event. 814 * 815 * Since: 1.10 816 * 817 * Throws: ConstructionException GTK+ fails to create the object. 818 */ 819 public this(uint groupId) 820 { 821 auto p = gst_event_new_stream_group_done(groupId); 822 823 if(p is null) 824 { 825 throw new ConstructionException("null returned by new_stream_group_done"); 826 } 827 828 this(cast(GstEvent*) p); 829 } 830 831 /** 832 * Create a new STREAM_START event. The stream start event can only 833 * travel downstream synchronized with the buffer flow. It is expected 834 * to be the first event that is sent for a new stream. 835 * 836 * Source elements, demuxers and other elements that create new streams 837 * are supposed to send this event as the first event of a new stream. It 838 * should not be sent after a flushing seek or in similar situations 839 * and is used to mark the beginning of a new logical stream. Elements 840 * combining multiple streams must ensure that this event is only forwarded 841 * downstream once and not for every single input stream. 842 * 843 * The @stream_id should be a unique string that consists of the upstream 844 * stream-id, / as separator and a unique stream-id for this specific 845 * stream. A new stream-id should only be created for a stream if the upstream 846 * stream is split into (potentially) multiple new streams, e.g. in a demuxer, 847 * but not for every single element in the pipeline. 848 * gst_pad_create_stream_id() or gst_pad_create_stream_id_printf() can be 849 * used to create a stream-id. There are no particular semantics for the 850 * stream-id, though it should be deterministic (to support stream matching) 851 * and it might be used to order streams (besides any information conveyed by 852 * stream flags). 853 * 854 * Params: 855 * streamId = Identifier for this stream 856 * 857 * Returns: the new STREAM_START event. 858 * 859 * Throws: ConstructionException GTK+ fails to create the object. 860 */ 861 public this(string streamId) 862 { 863 auto p = gst_event_new_stream_start(Str.toStringz(streamId)); 864 865 if(p is null) 866 { 867 throw new ConstructionException("null returned by new_stream_start"); 868 } 869 870 this(cast(GstEvent*) p); 871 } 872 873 /** 874 * Generates a metadata tag event from the given @taglist. 875 * 876 * The scope of the taglist specifies if the taglist applies to the 877 * complete medium or only to this specific stream. As the tag event 878 * is a sticky event, elements should merge tags received from 879 * upstream with a given scope with their own tags with the same 880 * scope and create a new tag event from it. 881 * 882 * Params: 883 * taglist = metadata list. The event will take ownership 884 * of the taglist. 885 * 886 * Returns: a new #GstEvent 887 * 888 * Throws: ConstructionException GTK+ fails to create the object. 889 */ 890 public this(TagList taglist) 891 { 892 auto p = gst_event_new_tag((taglist is null) ? null : taglist.getTagListStruct()); 893 894 if(p is null) 895 { 896 throw new ConstructionException("null returned by new_tag"); 897 } 898 899 this(cast(GstEvent*) p); 900 } 901 902 /** 903 * Generate a TOC event from the given @toc. The purpose of the TOC event is to 904 * inform elements that some kind of the TOC was found. 905 * 906 * Params: 907 * toc = #GstToc structure. 908 * updated = whether @toc was updated or not. 909 * 910 * Returns: a new #GstEvent. 911 * 912 * Throws: ConstructionException GTK+ fails to create the object. 913 */ 914 public this(Toc toc, bool updated) 915 { 916 auto p = gst_event_new_toc((toc is null) ? null : toc.getTocStruct(), updated); 917 918 if(p is null) 919 { 920 throw new ConstructionException("null returned by new_toc"); 921 } 922 923 this(cast(GstEvent*) p); 924 } 925 926 /** 927 * Parses a segment @event and copies the #GstSegment into the location 928 * given by @segment. 929 * 930 * Params: 931 * segment = a pointer to a #GstSegment 932 */ 933 public void copySegment(Segment segment) 934 { 935 gst_event_copy_segment(gstEvent, (segment is null) ? null : segment.getSegmentStruct()); 936 } 937 938 /** 939 * Retrieve the accumulated running time offset of the event. 940 * 941 * Events passing through #GstPads that have a running time 942 * offset set via gst_pad_set_offset() will get their offset 943 * adjusted according to the pad's offset. 944 * 945 * If the event contains any information that related to the 946 * running time, this information will need to be updated 947 * before usage with this offset. 948 * 949 * Returns: The event's running time offset 950 * 951 * MT safe. 952 * 953 * Since: 1.4 954 */ 955 public long getRunningTimeOffset() 956 { 957 return gst_event_get_running_time_offset(gstEvent); 958 } 959 960 /** 961 * Retrieve the sequence number of a event. 962 * 963 * Events have ever-incrementing sequence numbers, which may also be set 964 * explicitly via gst_event_set_seqnum(). Sequence numbers are typically used to 965 * indicate that a event corresponds to some other set of events or messages, 966 * for example an EOS event corresponding to a SEEK event. It is considered good 967 * practice to make this correspondence when possible, though it is not 968 * required. 969 * 970 * Note that events and messages share the same sequence number incrementor; 971 * two events or messages will never have the same sequence number unless 972 * that correspondence was made explicitly. 973 * 974 * Returns: The event's sequence number. 975 * 976 * MT safe. 977 */ 978 public uint getSeqnum() 979 { 980 return gst_event_get_seqnum(gstEvent); 981 } 982 983 /** 984 * Access the structure of the event. 985 * 986 * Returns: The structure of the event. The 987 * structure is still owned by the event, which means that you should not free 988 * it and that the pointer becomes invalid when you free the event. 989 * 990 * MT safe. 991 */ 992 public Structure getStructure() 993 { 994 auto p = gst_event_get_structure(gstEvent); 995 996 if(p is null) 997 { 998 return null; 999 } 1000 1001 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 1002 } 1003 1004 /** 1005 * Checks if @event has the given @name. This function is usually used to 1006 * check the name of a custom event. 1007 * 1008 * Params: 1009 * name = name to check 1010 * 1011 * Returns: %TRUE if @name matches the name of the event structure. 1012 */ 1013 public bool hasName(string name) 1014 { 1015 return gst_event_has_name(gstEvent, Str.toStringz(name)) != 0; 1016 } 1017 1018 /** 1019 * Get the format, minsize, maxsize and async-flag in the buffersize event. 1020 * 1021 * Params: 1022 * format = A pointer to store the format in 1023 * minsize = A pointer to store the minsize in 1024 * maxsize = A pointer to store the maxsize in 1025 * async = A pointer to store the async-flag in 1026 */ 1027 public void parseBufferSize(out GstFormat format, out long minsize, out long maxsize, out bool async) 1028 { 1029 int outasync; 1030 1031 gst_event_parse_buffer_size(gstEvent, &format, &minsize, &maxsize, &outasync); 1032 1033 async = (outasync == 1); 1034 } 1035 1036 /** 1037 * Get the caps from @event. The caps remains valid as long as @event remains 1038 * valid. 1039 * 1040 * Params: 1041 * caps = A pointer to the caps 1042 */ 1043 public void parseCaps(out Caps caps) 1044 { 1045 GstCaps* outcaps = null; 1046 1047 gst_event_parse_caps(gstEvent, &outcaps); 1048 1049 caps = ObjectG.getDObject!(Caps)(outcaps); 1050 } 1051 1052 /** 1053 * Parse the FLUSH_STOP event and retrieve the @reset_time member. 1054 * 1055 * Params: 1056 * resetTime = if time should be reset 1057 */ 1058 public void parseFlushStop(out bool resetTime) 1059 { 1060 int outresetTime; 1061 1062 gst_event_parse_flush_stop(gstEvent, &outresetTime); 1063 1064 resetTime = (outresetTime == 1); 1065 } 1066 1067 /** 1068 * Extract timestamp and duration from a new GAP event. 1069 * 1070 * Params: 1071 * timestamp = location where to store the 1072 * start time (pts) of the gap, or %NULL 1073 * duration = location where to store the duration of 1074 * the gap, or %NULL 1075 */ 1076 public void parseGap(out GstClockTime timestamp, out GstClockTime duration) 1077 { 1078 gst_event_parse_gap(gstEvent, ×tamp, &duration); 1079 } 1080 1081 /** 1082 * 1083 * Params: 1084 * groupId = address of variable where to store the group id 1085 * Returns: %TRUE if a group id was set on the event and could be parsed, 1086 * %FALSE otherwise. 1087 * 1088 * Since: 1.2 1089 */ 1090 public bool parseGroupId(out uint groupId) 1091 { 1092 return gst_event_parse_group_id(gstEvent, &groupId) != 0; 1093 } 1094 1095 /** 1096 * Get the latency in the latency event. 1097 * 1098 * Params: 1099 * latency = A pointer to store the latency in. 1100 */ 1101 public void parseLatency(out GstClockTime latency) 1102 { 1103 gst_event_parse_latency(gstEvent, &latency); 1104 } 1105 1106 /** 1107 * Parses an event containing protection system specific information and stores 1108 * the results in @system_id, @data and @origin. The data stored in @system_id, 1109 * @origin and @data are valid until @event is released. 1110 * 1111 * Params: 1112 * systemId = pointer to store the UUID 1113 * string uniquely identifying a content protection system. 1114 * data = pointer to store a #GstBuffer 1115 * holding protection system specific information. 1116 * origin = pointer to store a value that 1117 * indicates where the protection information carried by @event was extracted 1118 * from. 1119 * 1120 * Since: 1.6 1121 */ 1122 public void parseProtection(out string systemId, out Buffer data, out string origin) 1123 { 1124 char* outsystemId = null; 1125 GstBuffer* outdata = null; 1126 char* outorigin = null; 1127 1128 gst_event_parse_protection(gstEvent, &outsystemId, &outdata, &outorigin); 1129 1130 systemId = Str.toString(outsystemId); 1131 data = ObjectG.getDObject!(Buffer)(outdata); 1132 origin = Str.toString(outorigin); 1133 } 1134 1135 /** 1136 * Get the type, proportion, diff and timestamp in the qos event. See 1137 * gst_event_new_qos() for more information about the different QoS values. 1138 * 1139 * @timestamp will be adjusted for any pad offsets of pads it was passing through. 1140 * 1141 * Params: 1142 * type = A pointer to store the QoS type in 1143 * proportion = A pointer to store the proportion in 1144 * diff = A pointer to store the diff in 1145 * timestamp = A pointer to store the timestamp in 1146 */ 1147 public void parseQos(out GstQOSType type, out double proportion, out GstClockTimeDiff diff, out GstClockTime timestamp) 1148 { 1149 gst_event_parse_qos(gstEvent, &type, &proportion, &diff, ×tamp); 1150 } 1151 1152 /** 1153 * Parses a seek @event and stores the results in the given result locations. 1154 * 1155 * Params: 1156 * rate = result location for the rate 1157 * format = result location for the stream format 1158 * flags = result location for the #GstSeekFlags 1159 * startType = result location for the #GstSeekType of the start position 1160 * start = result location for the start position expressed in @format 1161 * stopType = result location for the #GstSeekType of the stop position 1162 * stop = result location for the stop position expressed in @format 1163 */ 1164 public void parseSeek(out double rate, out GstFormat format, out GstSeekFlags flags, out GstSeekType startType, out long start, out GstSeekType stopType, out long stop) 1165 { 1166 gst_event_parse_seek(gstEvent, &rate, &format, &flags, &startType, &start, &stopType, &stop); 1167 } 1168 1169 /** 1170 * Parses a segment @event and stores the result in the given @segment location. 1171 * @segment remains valid only until the @event is freed. Don't modify the segment 1172 * and make a copy if you want to modify it or store it for later use. 1173 * 1174 * Params: 1175 * segment = a pointer to a #GstSegment 1176 */ 1177 public void parseSegment(out Segment segment) 1178 { 1179 GstSegment* outsegment = null; 1180 1181 gst_event_parse_segment(gstEvent, &outsegment); 1182 1183 segment = ObjectG.getDObject!(Segment)(outsegment); 1184 } 1185 1186 /** 1187 * Extracts the position and format from the segment done message. 1188 * 1189 * Params: 1190 * format = Result location for the format, or %NULL 1191 * position = Result location for the position, or %NULL 1192 */ 1193 public void parseSegmentDone(out GstFormat format, out long position) 1194 { 1195 gst_event_parse_segment_done(gstEvent, &format, &position); 1196 } 1197 1198 /** 1199 * Parse the SELECT_STREAMS event and retrieve the contained streams. 1200 * 1201 * Params: 1202 * streams = the streams 1203 * 1204 * Since: 1.10 1205 */ 1206 public void parseSelectStreams(out ListG streams) 1207 { 1208 GList* outstreams = null; 1209 1210 gst_event_parse_select_streams(gstEvent, &outstreams); 1211 1212 streams = new ListG(outstreams); 1213 } 1214 1215 /** 1216 * Parse the sink-message event. Unref @msg after usage. 1217 * 1218 * Params: 1219 * msg = a pointer to store the #GstMessage in. 1220 */ 1221 public void parseSinkMessage(out Message msg) 1222 { 1223 GstMessage* outmsg = null; 1224 1225 gst_event_parse_sink_message(gstEvent, &outmsg); 1226 1227 msg = ObjectG.getDObject!(Message)(outmsg); 1228 } 1229 1230 /** 1231 * Parse the step event. 1232 * 1233 * Params: 1234 * format = a pointer to store the format in 1235 * amount = a pointer to store the amount in 1236 * rate = a pointer to store the rate in 1237 * flush = a pointer to store the flush boolean in 1238 * intermediate = a pointer to store the intermediate 1239 * boolean in 1240 */ 1241 public void parseStep(out GstFormat format, out ulong amount, out double rate, out bool flush, out bool intermediate) 1242 { 1243 int outflush; 1244 int outintermediate; 1245 1246 gst_event_parse_step(gstEvent, &format, &amount, &rate, &outflush, &outintermediate); 1247 1248 flush = (outflush == 1); 1249 intermediate = (outintermediate == 1); 1250 } 1251 1252 /** 1253 * Parse a stream-start @event and extract the #GstStream from it. 1254 * 1255 * Params: 1256 * stream = adress of variable to store the stream 1257 * 1258 * Since: 1.10 1259 */ 1260 public void parseStream(out Stream stream) 1261 { 1262 GstStream* outstream = null; 1263 1264 gst_event_parse_stream(gstEvent, &outstream); 1265 1266 stream = ObjectG.getDObject!(Stream)(outstream); 1267 } 1268 1269 /** 1270 * Retrieve new #GstStreamCollection from STREAM_COLLECTION event @event. 1271 * 1272 * Params: 1273 * collection = pointer to store the collection 1274 * 1275 * Since: 1.10 1276 */ 1277 public void parseStreamCollection(out StreamCollection collection) 1278 { 1279 GstStreamCollection* outcollection = null; 1280 1281 gst_event_parse_stream_collection(gstEvent, &outcollection); 1282 1283 collection = ObjectG.getDObject!(StreamCollection)(outcollection); 1284 } 1285 1286 /** */ 1287 public void parseStreamFlags(out GstStreamFlags flags) 1288 { 1289 gst_event_parse_stream_flags(gstEvent, &flags); 1290 } 1291 1292 /** 1293 * Parse a stream-group-done @event and store the result in the given 1294 * @group_id location. 1295 * 1296 * Params: 1297 * groupId = address of variable to store the group id into 1298 * 1299 * Since: 1.10 1300 */ 1301 public void parseStreamGroupDone(out uint groupId) 1302 { 1303 gst_event_parse_stream_group_done(gstEvent, &groupId); 1304 } 1305 1306 /** 1307 * Parse a stream-id @event and store the result in the given @stream_id 1308 * location. The string stored in @stream_id must not be modified and will 1309 * remain valid only until @event gets freed. Make a copy if you want to 1310 * modify it or store it for later use. 1311 * 1312 * Params: 1313 * streamId = pointer to store the stream-id 1314 */ 1315 public void parseStreamStart(out string streamId) 1316 { 1317 char* outstreamId = null; 1318 1319 gst_event_parse_stream_start(gstEvent, &outstreamId); 1320 1321 streamId = Str.toString(outstreamId); 1322 } 1323 1324 /** 1325 * Parses a tag @event and stores the results in the given @taglist location. 1326 * No reference to the taglist will be returned, it remains valid only until 1327 * the @event is freed. Don't modify or free the taglist, make a copy if you 1328 * want to modify it or store it for later use. 1329 * 1330 * Params: 1331 * taglist = pointer to metadata list 1332 */ 1333 public void parseTag(out TagList taglist) 1334 { 1335 GstTagList* outtaglist = null; 1336 1337 gst_event_parse_tag(gstEvent, &outtaglist); 1338 1339 taglist = ObjectG.getDObject!(TagList)(outtaglist); 1340 } 1341 1342 /** 1343 * Parse a TOC @event and store the results in the given @toc and @updated locations. 1344 * 1345 * Params: 1346 * toc = pointer to #GstToc structure. 1347 * updated = pointer to store TOC updated flag. 1348 */ 1349 public void parseToc(out Toc toc, out bool updated) 1350 { 1351 GstToc* outtoc = null; 1352 int outupdated; 1353 1354 gst_event_parse_toc(gstEvent, &outtoc, &outupdated); 1355 1356 toc = ObjectG.getDObject!(Toc)(outtoc); 1357 updated = (outupdated == 1); 1358 } 1359 1360 /** 1361 * Parse a TOC select @event and store the results in the given @uid location. 1362 * 1363 * Params: 1364 * uid = storage for the selection UID. 1365 */ 1366 public void parseTocSelect(out string uid) 1367 { 1368 char* outuid = null; 1369 1370 gst_event_parse_toc_select(gstEvent, &outuid); 1371 1372 uid = Str.toString(outuid); 1373 } 1374 1375 /** 1376 * All streams that have the same group id are supposed to be played 1377 * together, i.e. all streams inside a container file should have the 1378 * same group id but different stream ids. The group id should change 1379 * each time the stream is started, resulting in different group ids 1380 * each time a file is played for example. 1381 * 1382 * Use gst_util_group_id_next() to get a new group id. 1383 * 1384 * Params: 1385 * groupId = the group id to set 1386 * 1387 * Since: 1.2 1388 */ 1389 public void setGroupId(uint groupId) 1390 { 1391 gst_event_set_group_id(gstEvent, groupId); 1392 } 1393 1394 /** 1395 * Set the running time offset of a event. See 1396 * gst_event_get_running_time_offset() for more information. 1397 * 1398 * MT safe. 1399 * 1400 * Params: 1401 * offset = A the new running time offset 1402 * 1403 * Since: 1.4 1404 */ 1405 public void setRunningTimeOffset(long offset) 1406 { 1407 gst_event_set_running_time_offset(gstEvent, offset); 1408 } 1409 1410 /** 1411 * Set the sequence number of a event. 1412 * 1413 * This function might be called by the creator of a event to indicate that the 1414 * event relates to other events or messages. See gst_event_get_seqnum() for 1415 * more information. 1416 * 1417 * MT safe. 1418 * 1419 * Params: 1420 * seqnum = A sequence number. 1421 */ 1422 public void setSeqnum(uint seqnum) 1423 { 1424 gst_event_set_seqnum(gstEvent, seqnum); 1425 } 1426 1427 /** 1428 * Set the @stream on the stream-start @event 1429 * 1430 * Params: 1431 * stream = the stream object to set 1432 * 1433 * Since: 1.10 1434 */ 1435 public void setStream(Stream stream) 1436 { 1437 gst_event_set_stream(gstEvent, (stream is null) ? null : stream.getStreamStruct()); 1438 } 1439 1440 /** */ 1441 public void setStreamFlags(GstStreamFlags flags) 1442 { 1443 gst_event_set_stream_flags(gstEvent, flags); 1444 } 1445 1446 /** 1447 * Get a writable version of the structure. 1448 * 1449 * Returns: The structure of the event. The structure 1450 * is still owned by the event, which means that you should not free 1451 * it and that the pointer becomes invalid when you free the event. 1452 * This function checks if @event is writable and will never return 1453 * %NULL. 1454 * 1455 * MT safe. 1456 */ 1457 public Structure writableStructure() 1458 { 1459 auto p = gst_event_writable_structure(gstEvent); 1460 1461 if(p is null) 1462 { 1463 return null; 1464 } 1465 1466 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 1467 } 1468 1469 /** 1470 * Gets the #GstEventTypeFlags associated with @type. 1471 * 1472 * Params: 1473 * type = a #GstEventType 1474 * 1475 * Returns: a #GstEventTypeFlags. 1476 */ 1477 public static GstEventTypeFlags typeGetFlags(GstEventType type) 1478 { 1479 return gst_event_type_get_flags(type); 1480 } 1481 1482 /** 1483 * Get a printable name for the given event type. Do not modify or free. 1484 * 1485 * Params: 1486 * type = the event type 1487 * 1488 * Returns: a reference to the static name of the event. 1489 */ 1490 public static string typeGetName(GstEventType type) 1491 { 1492 return Str.toString(gst_event_type_get_name(type)); 1493 } 1494 1495 /** 1496 * Get the unique quark for the given event type. 1497 * 1498 * Params: 1499 * type = the event type 1500 * 1501 * Returns: the quark associated with the event type 1502 */ 1503 public static GQuark typeToQuark(GstEventType type) 1504 { 1505 return gst_event_type_to_quark(type); 1506 } 1507 }