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