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