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