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