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 * Conversion parameters: 26 * inFile = gstreamer-GstEvent.html 27 * outPack = gstreamer 28 * outFile = Event 29 * strct = GstEvent 30 * realStrct= 31 * ctorStrct= 32 * clss = Event 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_event_ 41 * - gst_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gst_event_new_buffer_size 46 * - gst_event_new_eos 47 * - gst_event_new_flush_start 48 * - gst_event_new_flush_stop 49 * - gst_event_new_navigation 50 * omit signals: 51 * imports: 52 * - glib.Str 53 * - gstreamer.Structure 54 * - gstreamer.TagList 55 * - gstreamer.MiniObject 56 * structWrap: 57 * - GstEvent* -> Event 58 * - GstMiniObject -> MiniObject 59 * - GstMiniObject* -> MiniObject 60 * - GstStructure* -> Structure 61 * - GstTagList* -> TagList 62 * module aliases: 63 * local aliases: 64 * overrides: 65 */ 66 67 module gstreamer.Event; 68 69 public import gstreamerc.gstreamertypes; 70 71 private import gstreamerc.gstreamer; 72 private import glib.ConstructionException; 73 private import gobject.ObjectG; 74 75 76 private import glib.Str; 77 private import gstreamer.Structure; 78 private import gstreamer.TagList; 79 private import gstreamer.MiniObject; 80 81 82 83 84 /** 85 * Description 86 * The event class provides factory methods to construct and functions query 87 * (parse) events. 88 * Events are usually created with gst_event_new_*() which takes event-type 89 * specific parameters as arguments. 90 * To send an event application will usually use gst_element_send_event() and 91 * elements will use gst_pad_send_event() or gst_pad_push_event(). 92 * The event should be unreffed with gst_event_unref() if it has not been sent. 93 * Events that have been received can be parsed with their respective 94 * gst_event_parse_*() functions. 95 * Events are passed between elements in parallel to the data stream. Some events 96 * are serialized with buffers, others are not. Some events only travel downstream, 97 * others only upstream. Some events can travel both upstream and downstream. 98 * The events are used to signal special conditions in the datastream such as 99 * EOS (end of stream) or the start of a new stream-segment. 100 * Events are also used to flush the pipeline of any pending data. 101 * Most of the event API is used inside plugins. Applications usually only 102 * construct and use seek events. 103 * To do that gst_event_new_seek() is used to create a seek event. It takes 104 * the needed parameters to specity seeking time and mode. 105 * $(DDOC_COMMENT example) 106 * Last reviewed on 2006-09-6 (0.10.10) 107 */ 108 public class Event 109 { 110 111 /** the main Gtk struct */ 112 protected GstEvent* gstEvent; 113 114 115 public GstEvent* getEventStruct() 116 { 117 return gstEvent; 118 } 119 120 121 /** the main Gtk struct as a void* */ 122 protected void* getStruct() 123 { 124 return cast(void*)gstEvent; 125 } 126 127 /** 128 * Sets our main struct and passes it to the parent class 129 */ 130 public this (GstEvent* gstEvent) 131 { 132 this.gstEvent = gstEvent; 133 } 134 135 /** 136 * Create a new buffersize event. The event is sent downstream and notifies 137 * elements that they should provide a buffer of the specified dimensions. 138 * When the async flag is set, a thread boundary is prefered. 139 * Params: 140 * format = buffer format 141 * minsize = minimum buffer size 142 * maxsize = maximum buffer size 143 * async = thread behavior 144 * Returns: 145 * a new GstEvent 146 */ 147 public static Event newBufferSize(GstFormat format, long minsize, long maxsize, int async) 148 { 149 // GstEvent* gst_event_new_buffer_size (GstFormat format, gint64 minsize, gint64 maxsize, gboolean async); 150 return new Event(cast(GstEvent*)gst_event_new_buffer_size(format, minsize, maxsize, async) ); 151 } /** 152 * Create a new EOS event. The eos event can only travel downstream 153 * synchronized with the buffer flow. Elements that receive the EOS 154 * event on a pad can return UNEXPECTED as a GstFlowReturn when data 155 * after the EOS event arrives. 156 * The EOS event will travel down to the sink elements in the pipeline 157 * which will then post the GST_MESSAGE_EOS on the bus after they have 158 * finished playing any buffered data. 159 * When all sinks have posted an EOS message, the EOS message is 160 * forwarded to the application. 161 * Returns: 162 * The new EOS event. 163 */ 164 public static Event newEOS() 165 { 166 // GstEvent* gst_event_new_eos (void); 167 return new Event(cast(GstEvent*)gst_event_new_eos() ); 168 } /** 169 * Allocate a new flush start event. The flush start event can be send 170 * upstream and downstream and travels out-of-bounds with the dataflow. 171 * It marks pads as being in a WRONG_STATE to process more data. 172 * Elements unlock and blocking functions and exit their streaming functions 173 * as fast as possible. 174 * This event is typically generated after a seek to minimize the latency 175 * after the seek. 176 * Returns: 177 * A new flush start event. 178 */ 179 public static Event newFlushStart() 180 { 181 // GstEvent* gst_event_new_flush_start (void); 182 return new Event(cast(GstEvent*)gst_event_new_flush_start() ); 183 } /** 184 * Allocate a new flush stop event. The flush start event can be send 185 * upstream and downstream and travels out-of-bounds with the dataflow. 186 * It is typically send after sending a FLUSH_START event to make the 187 * pads accept data again. 188 * Elements can process this event synchronized with the dataflow since 189 * the preceeding FLUSH_START event stopped the dataflow. 190 * This event is typically generated to complete a seek and to resume 191 * dataflow. 192 * Returns: 193 * A new flush stop event. 194 */ 195 public static Event newFlushStop() 196 { 197 // GstEvent* gst_event_new_flush_stop (void); 198 return new Event(cast(GstEvent*)gst_event_new_flush_stop() ); 199 }/** 200 * Create a new navigation event from the given description. 201 * Params: 202 * structure = description of the event 203 * Returns: 204 * a new GstEvent 205 */ 206 public static Event newNavigation(Structure structure) 207 { 208 // GstEvent* gst_event_new_navigation (GstStructure *structure); 209 return new Event(cast(GstEvent*)gst_event_new_navigation((structure is null) ? null : structure.getStructureStruct()) ); 210 } 211 212 /** 213 */ 214 215 /** 216 * Access the structure of the event. 217 * Returns: The structure of the event. The structure is still owned by the event, which means that you should not free it and that the pointer becomes invalid when you free the event. MT safe. 218 */ 219 public Structure getStructure() 220 { 221 // const GstStructure* gst_event_get_structure (GstEvent *event); 222 auto p = gst_event_get_structure(gstEvent); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 230 } 231 232 /** 233 * Create a new custom-typed event. This can be used for anything not 234 * handled by other event-specific functions to pass an event to another 235 * element. 236 * Make sure to allocate an event type with the GST_EVENT_MAKE_TYPE macro, 237 * assigning a free number and filling in the correct direction and 238 * serialization flags. 239 * New custom events can also be created by subclassing the event type if 240 * needed. 241 * Params: 242 * type = The type of the new event 243 * structure = The structure for the event. The event will take ownership of 244 * the structure. 245 * Throws: ConstructionException GTK+ fails to create the object. 246 */ 247 public this (GstEventType type, Structure structure) 248 { 249 // GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure); 250 auto p = gst_event_new_custom(type, (structure is null) ? null : structure.getStructureStruct()); 251 if(p is null) 252 { 253 throw new ConstructionException("null returned by gst_event_new_custom(type, (structure is null) ? null : structure.getStructureStruct())"); 254 } 255 this(cast(GstEvent*) p); 256 } 257 258 /** 259 * Create a new latency event. The event is sent upstream from the sinks and 260 * notifies elements that they should add an additional latency to the 261 * timestamps before synchronising against the clock. 262 * The latency is mostly used in live sinks and is always expressed in 263 * the time format. 264 * Params: 265 * latency = the new latency value 266 * Throws: ConstructionException GTK+ fails to create the object. 267 */ 268 public this (GstClockTime latency) 269 { 270 // GstEvent* gst_event_new_latency (GstClockTime latency); 271 auto p = gst_event_new_latency(latency); 272 if(p is null) 273 { 274 throw new ConstructionException("null returned by gst_event_new_latency(latency)"); 275 } 276 this(cast(GstEvent*) p); 277 } 278 279 /** 280 * Allocate a new newsegment event with the given format/values tripplets 281 * This method calls gst_event_new_new_segment_full() passing a default 282 * value of 1.0 for applied_rate 283 * Params: 284 * update = is this segment an update to a previous one 285 * rate = a new rate for playback 286 * format = The format of the segment values 287 * start = the start value of the segment 288 * stop = the stop value of the segment 289 * position = stream position 290 * Throws: ConstructionException GTK+ fails to create the object. 291 */ 292 public this (int update, double rate, GstFormat format, long start, long stop, long position) 293 { 294 // GstEvent* gst_event_new_new_segment (gboolean update, gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position); 295 auto p = gst_event_new_new_segment(update, rate, format, start, stop, position); 296 if(p is null) 297 { 298 throw new ConstructionException("null returned by gst_event_new_new_segment(update, rate, format, start, stop, position)"); 299 } 300 this(cast(GstEvent*) p); 301 } 302 303 /** 304 * Allocate a new newsegment event with the given format/values triplets. 305 * The newsegment event marks the range of buffers to be processed. All 306 * data not within the segment range is not to be processed. This can be 307 * used intelligently by plugins to apply more efficient methods of skipping 308 * unneeded data. 309 * The position value of the segment is used in conjunction with the start 310 * value to convert the buffer timestamps into the stream time. This is 311 * usually done in sinks to report the current stream_time. 312 * position represents the stream_time of a buffer carrying a timestamp of 313 * start. position cannot be -1. 314 * start cannot be -1, stop can be -1. If there 315 * is a valid stop given, it must be greater or equal the start, including 316 * when the indicated playback rate is < 0. 317 * The applied_rate value provides information about any rate adjustment that 318 * has already been made to the timestamps and content on the buffers of the 319 * stream. (rate * applied_rate) should always equal the rate that has been 320 * requested for playback. For example, if an element has an input segment 321 * with intended playback rate of 2.0 and applied_rate of 1.0, it can adjust 322 * incoming timestamps and buffer content by half and output a newsegment event 323 * with rate of 1.0 and applied_rate of 2.0 324 * Params: 325 * update = Whether this segment is an update to a previous one 326 * rate = A new rate for playback 327 * appliedRate = The rate factor which has already been applied 328 * format = The format of the segment values 329 * start = The start value of the segment 330 * stop = The stop value of the segment 331 * position = stream position 332 * Throws: ConstructionException GTK+ fails to create the object. 333 */ 334 public this (int update, double rate, double appliedRate, GstFormat format, long start, long stop, long position) 335 { 336 // GstEvent* gst_event_new_new_segment_full (gboolean update, gdouble rate, gdouble applied_rate, GstFormat format, gint64 start, gint64 stop, gint64 position); 337 auto p = gst_event_new_new_segment_full(update, rate, appliedRate, format, start, stop, position); 338 if(p is null) 339 { 340 throw new ConstructionException("null returned by gst_event_new_new_segment_full(update, rate, appliedRate, format, start, stop, position)"); 341 } 342 this(cast(GstEvent*) p); 343 } 344 345 /** 346 * Allocate a new qos event with the given values. 347 * The QOS event is generated in an element that wants an upstream 348 * element to either reduce or increase its rate because of 349 * high/low CPU load or other resource usage such as network performance. 350 * Typically sinks generate these events for each buffer they receive. 351 * proportion indicates the real-time performance of the streaming in the 352 * element that generated the QoS event (usually the sink). The value is 353 * generally computed based on more long term statistics about the streams 354 * timestamps compared to the clock. 355 * A value < 1.0 indicates that the upstream element is producing data faster 356 * than real-time. A value > 1.0 indicates that the upstream element is not 357 * producing data fast enough. 1.0 is the ideal proportion value. The 358 * proportion value can safely be used to lower or increase the quality of 359 * the element. 360 * diff is the difference against the clock in running time of the last 361 * buffer that caused the element to generate the QOS event. A negative value 362 * means that the buffer with timestamp arrived in time. A positive value 363 * indicates how late the buffer with timestamp was. 364 * timestamp is the timestamp of the last buffer that cause the element 365 * to generate the QOS event. It is expressed in running time and thus an ever 366 * increasing value. 367 * The upstream element can use the diff and timestamp values to decide 368 * whether to process more buffers. For possitive diff, all buffers with 369 * timestamp <= timestamp + diff will certainly arrive late in the sink 370 * as well. 371 * The application can use general event probes to intercept the QoS 372 * event and implement custom application specific QoS handling. 373 * Params: 374 * proportion = the proportion of the qos message 375 * diff = The time difference of the last Clock sync 376 * timestamp = The timestamp of the buffer 377 * Throws: ConstructionException GTK+ fails to create the object. 378 */ 379 public this (double proportion, GstClockTimeDiff diff, GstClockTime timestamp) 380 { 381 // GstEvent* gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp); 382 auto p = gst_event_new_qos(proportion, diff, timestamp); 383 if(p is null) 384 { 385 throw new ConstructionException("null returned by gst_event_new_qos(proportion, diff, timestamp)"); 386 } 387 this(cast(GstEvent*) p); 388 } 389 390 /** 391 * Allocate a new seek event with the given parameters. 392 * The seek event configures playback of the pipeline between start to stop 393 * at the speed given in rate, also called a playback segment. 394 * The start and stop values are expressed in format. 395 * A rate of 1.0 means normal playback rate, 2.0 means double speed. 396 * Negatives values means backwards playback. A value of 0.0 for the 397 * rate is not allowed and should be accomplished instead by PAUSING the 398 * pipeline. 399 * A pipeline has a default playback segment configured with a start 400 * position of 0, a stop position of -1 and a rate of 1.0. The currently 401 * configured playback segment can be queried with GST_QUERY_SEGMENT. 402 * start_type and stop_type specify how to adjust the currently configured 403 * start and stop fields in segment. Adjustments can be made relative or 404 * absolute to the last configured values. A type of GST_SEEK_TYPE_NONE means 405 * that the position should not be updated. 406 * When the rate is positive and start has been updated, playback will start 407 * from the newly configured start position. 408 * For negative rates, playback will start from the newly configured stop 409 * position (if any). If the stop position if updated, it must be different from 410 * -1 for negative rates. 411 * It is not possible to seek relative to the current playback position, to do 412 * this, PAUSE the pipeline, query the current playback position with 413 * GST_QUERY_POSITION and update the playback segment current position with a 414 * GST_SEEK_TYPE_SET to the desired position. 415 * Params: 416 * rate = The new playback rate 417 * format = The format of the seek values 418 * flags = The optional seek flags 419 * startType = The type and flags for the new start position 420 * start = The value of the new start position 421 * stopType = The type and flags for the new stop position 422 * stop = The value of the new stop position 423 * Throws: ConstructionException GTK+ fails to create the object. 424 */ 425 public this (double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop) 426 { 427 // GstEvent* gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags, GstSeekType start_type, gint64 start, GstSeekType stop_type, gint64 stop); 428 auto p = gst_event_new_seek(rate, format, flags, startType, start, stopType, stop); 429 if(p is null) 430 { 431 throw new ConstructionException("null returned by gst_event_new_seek(rate, format, flags, startType, start, stopType, stop)"); 432 } 433 this(cast(GstEvent*) p); 434 } 435 436 /** 437 * Generates a metadata tag event from the given taglist. 438 * Params: 439 * taglist = metadata list 440 * Throws: ConstructionException GTK+ fails to create the object. 441 */ 442 public this (TagList taglist) 443 { 444 // GstEvent* gst_event_new_tag (GstTagList *taglist); 445 auto p = gst_event_new_tag((taglist is null) ? null : taglist.getTagListStruct()); 446 if(p is null) 447 { 448 throw new ConstructionException("null returned by gst_event_new_tag((taglist is null) ? null : taglist.getTagListStruct())"); 449 } 450 this(cast(GstEvent*) p); 451 } 452 453 /** 454 * Get the format, minsize, maxsize and async-flag in the buffersize event. 455 * Params: 456 * format = A pointer to store the format in 457 * minsize = A pointer to store the minsize in 458 * maxsize = A pointer to store the maxsize in 459 * async = A pointer to store the async-flag in 460 */ 461 public void parseBufferSize(out GstFormat format, out long minsize, out long maxsize, out int async) 462 { 463 // void gst_event_parse_buffer_size (GstEvent *event, GstFormat *format, gint64 *minsize, gint64 *maxsize, gboolean *async); 464 gst_event_parse_buffer_size(gstEvent, &format, &minsize, &maxsize, &async); 465 } 466 467 /** 468 * Get the latency in the latency event. 469 * Params: 470 * latency = A pointer to store the latency in. 471 * Since 0.10.12 472 */ 473 public void parseLatency(ref GstClockTime latency) 474 { 475 // void gst_event_parse_latency (GstEvent *event, GstClockTime *latency); 476 gst_event_parse_latency(gstEvent, &latency); 477 } 478 479 /** 480 * Get the update flag, rate, format, start, stop and position in the 481 * newsegment event. In general, gst_event_parse_new_segment_full() should 482 * be used instead of this, to also retrieve the applied_rate value of the 483 * segment. See gst_event_new_new_segment_full() for a full description 484 * of the newsegment event. 485 * Params: 486 * update = A pointer to the update flag of the segment 487 * rate = A pointer to the rate of the segment 488 * format = A pointer to the format of the newsegment values 489 * start = A pointer to store the start value in 490 * stop = A pointer to store the stop value in 491 * position = A pointer to store the stream time in 492 */ 493 public void parseNewSegment(ref int update, ref double rate, ref GstFormat format, out long start, out long stop, out long position) 494 { 495 // void gst_event_parse_new_segment (GstEvent *event, gboolean *update, gdouble *rate, GstFormat *format, gint64 *start, gint64 *stop, gint64 *position); 496 gst_event_parse_new_segment(gstEvent, &update, &rate, &format, &start, &stop, &position); 497 } 498 499 /** 500 * Get the update, rate, applied_rate, format, start, stop and 501 * position in the newsegment event. See gst_event_new_new_segment_full() 502 * for a full description of the newsegment event. 503 * Params: 504 * update = A pointer to the update flag of the segment 505 * rate = A pointer to the rate of the segment 506 * appliedRate = A pointer to the applied_rate of the segment 507 * format = A pointer to the format of the newsegment values 508 * start = A pointer to store the start value in 509 * stop = A pointer to store the stop value in 510 * position = A pointer to store the stream time in 511 * Since 0.10.6 512 */ 513 public void parseNewSegmentFull(ref int update, ref double rate, ref double appliedRate, ref GstFormat format, out long start, out long stop, out long position) 514 { 515 // void gst_event_parse_new_segment_full (GstEvent *event, gboolean *update, gdouble *rate, gdouble *applied_rate, GstFormat *format, gint64 *start, gint64 *stop, gint64 *position); 516 gst_event_parse_new_segment_full(gstEvent, &update, &rate, &appliedRate, &format, &start, &stop, &position); 517 } 518 519 /** 520 * Get the proportion, diff and timestamp in the qos event. See 521 * gst_event_new_qos() for more information about the different QoS values. 522 * Params: 523 * proportion = A pointer to store the proportion in 524 * diff = A pointer to store the diff in 525 * timestamp = A pointer to store the timestamp in 526 */ 527 public void parseQos(out double proportion, out GstClockTimeDiff diff, out GstClockTime timestamp) 528 { 529 // void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff, GstClockTime *timestamp); 530 gst_event_parse_qos(gstEvent, &proportion, &diff, ×tamp); 531 } 532 533 /** 534 * Parses a seek event and stores the results in the given result locations. 535 * Params: 536 * rate = result location for the rate 537 * format = result location for the stream format 538 * flags = result location for the GstSeekFlags 539 * startType = result location for the GstSeekType of the start position 540 * start = result location for the start postion expressed in format 541 * stopType = result location for the GstSeekType of the stop position 542 * stop = result location for the stop postion expressed in format 543 */ 544 public void parseSeek(out double rate, out GstFormat format, out GstSeekFlags flags, out GstSeekType startType, out long start, out GstSeekType stopType, out long stop) 545 { 546 // void gst_event_parse_seek (GstEvent *event, gdouble *rate, GstFormat *format, GstSeekFlags *flags, GstSeekType *start_type, gint64 *start, GstSeekType *stop_type, gint64 *stop); 547 gst_event_parse_seek(gstEvent, &rate, &format, &flags, &startType, &start, &stopType, &stop); 548 } 549 550 /** 551 * Parses a tag event and stores the results in the given taglist location. 552 * Params: 553 * taglist = pointer to metadata list 554 */ 555 public void parseTag(out TagList taglist) 556 { 557 // void gst_event_parse_tag (GstEvent *event, GstTagList **taglist); 558 GstTagList* outtaglist = null; 559 560 gst_event_parse_tag(gstEvent, &outtaglist); 561 562 taglist = ObjectG.getDObject!(TagList)(outtaglist); 563 } 564 565 /** 566 * Increase the refcount of this event. 567 * Returns: event (for convenience when doing assignments) 568 */ 569 public Event doref() 570 { 571 // GstEvent* gst_event_ref (GstEvent *event); 572 auto p = gst_event_ref(gstEvent); 573 574 if(p is null) 575 { 576 return null; 577 } 578 579 return ObjectG.getDObject!(Event)(cast(GstEvent*) p); 580 } 581 582 /** 583 * Gets the GstEventTypeFlags associated with type. 584 * Params: 585 * type = a GstEventType 586 * Returns: a GstEventTypeFlags. 587 */ 588 public static GstEventTypeFlags typeGetFlags(GstEventType type) 589 { 590 // GstEventTypeFlags gst_event_type_get_flags (GstEventType type); 591 return gst_event_type_get_flags(type); 592 } 593 594 /** 595 * Get a printable name for the given event type. Do not modify or free. 596 * Params: 597 * type = the event type 598 * Returns: a reference to the static name of the event. 599 */ 600 public static string typeGetName(GstEventType type) 601 { 602 // const gchar* gst_event_type_get_name (GstEventType type); 603 return Str.toString(gst_event_type_get_name(type)); 604 } 605 606 /** 607 * Get the unique quark for the given event type. 608 * Params: 609 * type = the event type 610 * Returns: the quark associated with the event type 611 */ 612 public static GQuark typeToQuark(GstEventType type) 613 { 614 // GQuark gst_event_type_to_quark (GstEventType type); 615 return gst_event_type_to_quark(type); 616 } 617 }