1use std::{
4 borrow::Borrow, cmp, ffi::CStr, fmt, mem, num::NonZeroU32, ops::Deref, ops::DerefMut, ptr,
5};
6
7use glib::{translate::*, value::ToSendValue};
8
9use crate::{
10 ClockTime, EventType, ffi,
11 format::{
12 CompatibleFormattedValue, FormattedValue, FormattedValueIntrinsic, GenericFormattedValue,
13 },
14 structure::*,
15};
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub struct Seqnum(pub(crate) NonZeroU32);
19
20impl Seqnum {
21 #[doc(alias = "gst_util_seqnum_next")]
22 #[inline]
23 pub fn next() -> Self {
24 unsafe {
25 let v = ffi::gst_util_seqnum_next();
26 if v == 0 {
27 Seqnum::next()
28 } else {
29 Seqnum(NonZeroU32::new_unchecked(v))
30 }
31 }
32 }
33}
34
35impl IntoGlib for Seqnum {
36 type GlibType = u32;
37
38 #[inline]
39 fn into_glib(self) -> u32 {
40 self.0.get()
41 }
42}
43
44impl cmp::PartialOrd for Seqnum {
45 #[inline]
46 fn partial_cmp(&self, other: &Seqnum) -> Option<cmp::Ordering> {
47 Some(self.cmp(other))
48 }
49}
50
51impl cmp::Ord for Seqnum {
52 #[inline]
53 fn cmp(&self, other: &Seqnum) -> cmp::Ordering {
54 unsafe {
55 let ret = ffi::gst_util_seqnum_compare(self.0.get(), other.0.get());
56 ret.cmp(&0)
57 }
58 }
59}
60
61#[derive(Debug, Clone, Copy, PartialEq, Eq)]
62pub struct GroupId(pub(crate) NonZeroU32);
63
64impl GroupId {
65 #[doc(alias = "gst_util_group_id_next")]
66 #[inline]
67 pub fn next() -> Self {
68 unsafe {
69 let v = ffi::gst_util_group_id_next();
70 if v == 0 {
71 GroupId::next()
72 } else {
73 GroupId(NonZeroU32::new_unchecked(v))
74 }
75 }
76 }
77}
78
79impl EventType {
80 #[doc(alias = "GST_EVENT_IS_UPSTREAM")]
81 #[inline]
82 pub fn is_upstream(self) -> bool {
83 (self.into_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0
84 }
85
86 #[doc(alias = "GST_EVENT_IS_DOWNSTREAM")]
87 #[inline]
88 pub fn is_downstream(self) -> bool {
89 (self.into_glib() as u32) & ffi::GST_EVENT_TYPE_DOWNSTREAM != 0
90 }
91
92 #[doc(alias = "GST_EVENT_IS_SERIALIZED")]
93 #[inline]
94 pub fn is_serialized(self) -> bool {
95 (self.into_glib() as u32) & ffi::GST_EVENT_TYPE_SERIALIZED != 0
96 }
97
98 #[doc(alias = "GST_EVENT_IS_STICKY")]
99 #[inline]
100 pub fn is_sticky(self) -> bool {
101 (self.into_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY != 0
102 }
103
104 #[doc(alias = "GST_EVENT_IS_STICKY_MULTI")]
105 #[inline]
106 pub fn is_sticky_multi(self) -> bool {
107 (self.into_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY_MULTI != 0
108 }
109}
110
111impl PartialOrd for EventType {
112 fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
113 if !self.is_serialized() || !other.is_serialized() {
114 return None;
115 }
116
117 let fixup_event_ordering = |v| match v {
119 ffi::GST_EVENT_INSTANT_RATE_CHANGE => ffi::GST_EVENT_SEGMENT as u32 + 1,
120 _ => v as u32,
121 };
122
123 let v1 = fixup_event_ordering(self.into_glib());
124 let v2 = fixup_event_ordering(other.into_glib());
125
126 let stream_start = ffi::GST_EVENT_STREAM_START as u32;
127 let segment = ffi::GST_EVENT_SEGMENT as u32;
128 let eos = ffi::GST_EVENT_EOS as u32;
129
130 if v1 >= stream_start && v1 <= segment || v2 >= stream_start && v2 <= segment {
133 Some(v1.cmp(&v2))
134 } else if v1 == eos || v2 == eos {
136 if v1 == v2 {
137 Some(cmp::Ordering::Equal)
138 } else if v1 == eos {
139 Some(cmp::Ordering::Greater)
140 } else {
141 Some(cmp::Ordering::Less)
142 }
143 } else {
144 None
145 }
146 }
147}
148
149mini_object_wrapper!(Event, EventRef, ffi::GstEvent, || {
150 ffi::gst_event_get_type()
151});
152
153impl EventRef {
154 #[doc(alias = "get_seqnum")]
155 #[doc(alias = "gst_event_get_seqnum")]
156 pub fn seqnum(&self) -> Seqnum {
157 unsafe {
158 let seqnum = ffi::gst_event_get_seqnum(self.as_mut_ptr());
159 debug_assert_ne!(seqnum, 0);
160 Seqnum(NonZeroU32::new_unchecked(seqnum))
161 }
162 }
163
164 #[doc(alias = "gst_event_set_seqnum")]
165 pub fn set_seqnum(&mut self, seqnum: Seqnum) {
166 unsafe {
167 ffi::gst_event_set_seqnum(self.as_mut_ptr(), seqnum.0.get());
168 }
169 }
170
171 #[doc(alias = "get_running_time_offset")]
172 #[doc(alias = "gst_event_get_running_time_offset")]
173 pub fn running_time_offset(&self) -> i64 {
174 unsafe { ffi::gst_event_get_running_time_offset(self.as_mut_ptr()) }
175 }
176
177 #[doc(alias = "gst_event_set_running_time_offset")]
178 pub fn set_running_time_offset(&mut self, offset: i64) {
179 unsafe { ffi::gst_event_set_running_time_offset(self.as_mut_ptr(), offset) }
180 }
181
182 #[doc(alias = "get_structure")]
183 #[doc(alias = "gst_event_get_structure")]
184 #[inline]
185 pub fn structure(&self) -> Option<&StructureRef> {
186 unsafe {
187 let structure = ffi::gst_event_get_structure(self.as_mut_ptr());
188 if structure.is_null() {
189 None
190 } else {
191 Some(StructureRef::from_glib_borrow(structure))
192 }
193 }
194 }
195
196 #[doc(alias = "gst_event_writable_structure")]
197 #[inline]
198 pub fn structure_mut(&mut self) -> &mut StructureRef {
199 unsafe {
200 StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure(self.as_mut_ptr()))
201 }
202 }
203
204 #[doc(alias = "GST_EVENT_IS_UPSTREAM")]
205 #[inline]
206 pub fn is_upstream(&self) -> bool {
207 self.type_().is_upstream()
208 }
209
210 #[doc(alias = "GST_EVENT_IS_DOWNSTREAM")]
211 #[inline]
212 pub fn is_downstream(&self) -> bool {
213 self.type_().is_downstream()
214 }
215
216 #[doc(alias = "GST_EVENT_IS_SERIALIZED")]
217 #[inline]
218 pub fn is_serialized(&self) -> bool {
219 self.type_().is_serialized()
220 }
221
222 #[doc(alias = "GST_EVENT_IS_STICKY")]
223 #[inline]
224 pub fn is_sticky(&self) -> bool {
225 self.type_().is_sticky()
226 }
227
228 #[doc(alias = "GST_EVENT_IS_STICKY_MULTI")]
229 #[inline]
230 pub fn is_sticky_multi(&self) -> bool {
231 self.type_().is_sticky_multi()
232 }
233
234 #[doc(alias = "get_type")]
235 #[doc(alias = "GST_EVENT_TYPE")]
236 #[inline]
237 pub fn type_(&self) -> EventType {
238 unsafe { from_glib((*self.as_ptr()).type_) }
239 }
240
241 #[doc(alias = "gst_event_has_name")]
242 #[inline]
243 pub fn has_name(&self, name: &str) -> bool {
244 self.structure().is_some_and(|s| s.has_name(name))
245 }
246
247 pub fn view(&self) -> EventView<'_> {
248 unsafe {
249 let type_ = (*self.as_ptr()).type_;
250
251 match type_ {
252 ffi::GST_EVENT_FLUSH_START => FlushStart::view(self),
253 ffi::GST_EVENT_FLUSH_STOP => FlushStop::view(self),
254 ffi::GST_EVENT_STREAM_START => StreamStart::view(self),
255 ffi::GST_EVENT_CAPS => Caps::view(self),
256 ffi::GST_EVENT_SEGMENT => Segment::view(self),
257 ffi::GST_EVENT_STREAM_COLLECTION => StreamCollection::view(self),
258 ffi::GST_EVENT_TAG => Tag::view(self),
259 ffi::GST_EVENT_BUFFERSIZE => Buffersize::view(self),
260 ffi::GST_EVENT_SINK_MESSAGE => SinkMessage::view(self),
261 ffi::GST_EVENT_STREAM_GROUP_DONE => StreamGroupDone::view(self),
262 ffi::GST_EVENT_EOS => Eos::view(self),
263 ffi::GST_EVENT_TOC => Toc::view(self),
264 ffi::GST_EVENT_PROTECTION => Protection::view(self),
265 ffi::GST_EVENT_SEGMENT_DONE => SegmentDone::view(self),
266 ffi::GST_EVENT_GAP => Gap::view(self),
267 #[cfg(feature = "v1_18")]
268 ffi::GST_EVENT_INSTANT_RATE_CHANGE => InstantRateChange::view(self),
269 ffi::GST_EVENT_QOS => Qos::view(self),
270 ffi::GST_EVENT_SEEK => Seek::view(self),
271 ffi::GST_EVENT_NAVIGATION => Navigation::view(self),
272 ffi::GST_EVENT_LATENCY => Latency::view(self),
273 ffi::GST_EVENT_STEP => Step::view(self),
274 ffi::GST_EVENT_RECONFIGURE => Reconfigure::view(self),
275 ffi::GST_EVENT_TOC_SELECT => TocSelect::view(self),
276 ffi::GST_EVENT_SELECT_STREAMS => SelectStreams::view(self),
277 #[cfg(feature = "v1_18")]
278 ffi::GST_EVENT_INSTANT_RATE_SYNC_TIME => InstantRateSyncTime::view(self),
279 ffi::GST_EVENT_CUSTOM_UPSTREAM => CustomUpstream::view(self),
280 ffi::GST_EVENT_CUSTOM_DOWNSTREAM => CustomDownstream::view(self),
281 ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => CustomDownstreamOob::view(self),
282 ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => CustomDownstreamSticky::view(self),
283 ffi::GST_EVENT_CUSTOM_BOTH => CustomBoth::view(self),
284 ffi::GST_EVENT_CUSTOM_BOTH_OOB => CustomBothOob::view(self),
285 _ => Other::view(self),
286 }
287 }
288 }
289
290 pub fn view_mut(&mut self) -> EventViewMut<'_> {
291 unsafe {
292 let type_ = (*self.as_ptr()).type_;
293
294 match type_ {
295 ffi::GST_EVENT_FLUSH_START => FlushStart::view_mut(self),
296 ffi::GST_EVENT_FLUSH_STOP => FlushStop::view_mut(self),
297 ffi::GST_EVENT_STREAM_START => StreamStart::view_mut(self),
298 ffi::GST_EVENT_CAPS => Caps::view_mut(self),
299 ffi::GST_EVENT_SEGMENT => Segment::view_mut(self),
300 ffi::GST_EVENT_STREAM_COLLECTION => StreamCollection::view_mut(self),
301 ffi::GST_EVENT_TAG => Tag::view_mut(self),
302 ffi::GST_EVENT_BUFFERSIZE => Buffersize::view_mut(self),
303 ffi::GST_EVENT_SINK_MESSAGE => SinkMessage::view_mut(self),
304 ffi::GST_EVENT_STREAM_GROUP_DONE => StreamGroupDone::view_mut(self),
305 ffi::GST_EVENT_EOS => Eos::view_mut(self),
306 ffi::GST_EVENT_TOC => Toc::view_mut(self),
307 ffi::GST_EVENT_PROTECTION => Protection::view_mut(self),
308 ffi::GST_EVENT_SEGMENT_DONE => SegmentDone::view_mut(self),
309 ffi::GST_EVENT_GAP => Gap::view_mut(self),
310 #[cfg(feature = "v1_18")]
311 ffi::GST_EVENT_INSTANT_RATE_CHANGE => InstantRateChange::view_mut(self),
312 ffi::GST_EVENT_QOS => Qos::view_mut(self),
313 ffi::GST_EVENT_SEEK => Seek::view_mut(self),
314 ffi::GST_EVENT_NAVIGATION => Navigation::view_mut(self),
315 ffi::GST_EVENT_LATENCY => Latency::view_mut(self),
316 ffi::GST_EVENT_STEP => Step::view_mut(self),
317 ffi::GST_EVENT_RECONFIGURE => Reconfigure::view_mut(self),
318 ffi::GST_EVENT_TOC_SELECT => TocSelect::view_mut(self),
319 ffi::GST_EVENT_SELECT_STREAMS => SelectStreams::view_mut(self),
320 #[cfg(feature = "v1_18")]
321 ffi::GST_EVENT_INSTANT_RATE_SYNC_TIME => InstantRateSyncTime::view_mut(self),
322 ffi::GST_EVENT_CUSTOM_UPSTREAM => CustomUpstream::view_mut(self),
323 ffi::GST_EVENT_CUSTOM_DOWNSTREAM => CustomDownstream::view_mut(self),
324 ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => CustomDownstreamOob::view_mut(self),
325 ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => CustomDownstreamSticky::view_mut(self),
326 ffi::GST_EVENT_CUSTOM_BOTH => CustomBoth::view_mut(self),
327 ffi::GST_EVENT_CUSTOM_BOTH_OOB => CustomBothOob::view_mut(self),
328 _ => Other::view_mut(self),
329 }
330 }
331 }
332}
333
334impl fmt::Debug for Event {
335 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
336 EventRef::fmt(self, f)
337 }
338}
339
340impl fmt::Debug for EventRef {
341 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
342 f.debug_struct("Event")
343 .field("ptr", &self.as_ptr())
344 .field("type", &self.type_().name())
345 .field("seqnum", &self.seqnum())
346 .field("structure", &self.structure())
347 .finish()
348 }
349}
350
351pub trait StickyEventType: ToOwned {
352 const TYPE: EventType;
353
354 unsafe fn from_event(event: Event) -> Self::Owned;
355}
356
357#[derive(Debug)]
358#[non_exhaustive]
359pub enum EventView<'a> {
360 FlushStart(&'a FlushStart),
361 FlushStop(&'a FlushStop),
362 StreamStart(&'a StreamStart),
363 Caps(&'a Caps),
364 Segment(&'a Segment),
365 StreamCollection(&'a StreamCollection),
366 Tag(&'a Tag),
367 Buffersize(&'a Buffersize),
368 SinkMessage(&'a SinkMessage),
369 StreamGroupDone(&'a StreamGroupDone),
370 Eos(&'a Eos),
371 Toc(&'a Toc),
372 Protection(&'a Protection),
373 SegmentDone(&'a SegmentDone),
374 Gap(&'a Gap),
375 #[cfg(feature = "v1_18")]
376 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
377 InstantRateChange(&'a InstantRateChange),
378 Qos(&'a Qos),
379 Seek(&'a Seek),
380 Navigation(&'a Navigation),
381 Latency(&'a Latency),
382 Step(&'a Step),
383 Reconfigure(&'a Reconfigure),
384 TocSelect(&'a TocSelect),
385 SelectStreams(&'a SelectStreams),
386 #[cfg(feature = "v1_18")]
387 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
388 InstantRateSyncTime(&'a InstantRateSyncTime),
389 CustomUpstream(&'a CustomUpstream),
390 CustomDownstream(&'a CustomDownstream),
391 CustomDownstreamOob(&'a CustomDownstreamOob),
392 CustomDownstreamSticky(&'a CustomDownstreamSticky),
393 CustomBoth(&'a CustomBoth),
394 CustomBothOob(&'a CustomBothOob),
395 Other(&'a Other),
396}
397
398#[derive(Debug)]
399#[non_exhaustive]
400pub enum EventViewMut<'a> {
401 FlushStart(&'a mut FlushStart),
402 FlushStop(&'a mut FlushStop),
403 StreamStart(&'a mut StreamStart),
404 Caps(&'a mut Caps),
405 Segment(&'a mut Segment),
406 StreamCollection(&'a mut StreamCollection),
407 Tag(&'a mut Tag),
408 Buffersize(&'a mut Buffersize),
409 SinkMessage(&'a mut SinkMessage),
410 StreamGroupDone(&'a mut StreamGroupDone),
411 Eos(&'a mut Eos),
412 Toc(&'a mut Toc),
413 Protection(&'a mut Protection),
414 SegmentDone(&'a mut SegmentDone),
415 Gap(&'a mut Gap),
416 #[cfg(feature = "v1_18")]
417 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
418 InstantRateChange(&'a mut InstantRateChange),
419 Qos(&'a mut Qos),
420 Seek(&'a mut Seek),
421 Navigation(&'a mut Navigation),
422 Latency(&'a mut Latency),
423 Step(&'a mut Step),
424 Reconfigure(&'a mut Reconfigure),
425 TocSelect(&'a mut TocSelect),
426 SelectStreams(&'a mut SelectStreams),
427 #[cfg(feature = "v1_18")]
428 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
429 InstantRateSyncTime(&'a mut InstantRateSyncTime),
430 CustomUpstream(&'a mut CustomUpstream),
431 CustomDownstream(&'a mut CustomDownstream),
432 CustomDownstreamOob(&'a mut CustomDownstreamOob),
433 CustomDownstreamSticky(&'a mut CustomDownstreamSticky),
434 CustomBoth(&'a mut CustomBoth),
435 CustomBothOob(&'a mut CustomBothOob),
436 Other(&'a mut Other),
437}
438
439macro_rules! declare_concrete_event {
440 (@sticky $name:ident, $param:ident) => {
441 declare_concrete_event!($name, $param);
442
443 impl StickyEventType for $name {
444 const TYPE: EventType = EventType::$name;
445
446 #[inline]
447 unsafe fn from_event(event: Event) -> Self::Owned {
448 $name::<Event>(event)
449 }
450 }
451 };
452 ($name:ident, $param:ident) => {
453 #[repr(transparent)]
454 pub struct $name<$param = EventRef>($param);
455
456 impl $name {
457 #[inline]
458 pub fn event(&self) -> &EventRef {
459 unsafe { &*(self as *const Self as *const EventRef) }
460 }
461
462 #[inline]
463 pub fn event_mut(&mut self) -> &mut EventRef {
464 unsafe { &mut *(self as *mut Self as *mut EventRef) }
465 }
466
467 #[inline]
468 unsafe fn view(event: &EventRef) -> EventView<'_> {
469 unsafe {
470 let event = &*(event as *const EventRef as *const Self);
471 EventView::$name(event)
472 }
473 }
474
475 #[inline]
476 unsafe fn view_mut(event: &mut EventRef) -> EventViewMut<'_> {
477 unsafe {
478 let event = &mut *(event as *mut EventRef as *mut Self);
479 EventViewMut::$name(event)
480 }
481 }
482 }
483
484 impl Deref for $name {
485 type Target = EventRef;
486
487 #[inline]
488 fn deref(&self) -> &Self::Target {
489 self.event()
490 }
491 }
492
493 impl DerefMut for $name {
494 #[inline]
495 fn deref_mut(&mut self) -> &mut Self::Target {
496 self.event_mut()
497 }
498 }
499
500 impl ToOwned for $name {
501 type Owned = $name<Event>;
502
503 #[inline]
504 fn to_owned(&self) -> Self::Owned {
505 $name::<Event>(self.copy())
506 }
507 }
508
509 impl $name<Event> {
510 #[inline]
511 pub fn get_mut(&mut self) -> Option<&mut $name> {
512 self.0
513 .get_mut()
514 .map(|event| unsafe { &mut *(event as *mut EventRef as *mut $name) })
515 }
516 }
517
518 impl Deref for $name<Event> {
519 type Target = $name;
520
521 #[inline]
522 fn deref(&self) -> &Self::Target {
523 unsafe { &*(self.0.as_ptr() as *const Self::Target) }
524 }
525 }
526
527 impl DerefMut for $name<Event> {
528 #[inline]
529 fn deref_mut(&mut self) -> &mut Self::Target {
530 debug_assert!(self.0.is_writable());
531 unsafe { &mut *(self.0.as_mut_ptr() as *mut Self::Target) }
532 }
533 }
534
535 impl Borrow<$name> for $name<Event> {
536 #[inline]
537 fn borrow(&self) -> &$name {
538 &*self
539 }
540 }
541
542 impl From<$name<Event>> for Event {
543 #[inline]
544 fn from(concrete: $name<Event>) -> Self {
545 skip_assert_initialized!();
546 concrete.0
547 }
548 }
549 };
550}
551
552declare_concrete_event!(FlushStart, T);
553impl FlushStart<Event> {
554 #[doc(alias = "gst_event_new_flush_start")]
555 #[allow(clippy::new_ret_no_self)]
556 pub fn new() -> Event {
557 skip_assert_initialized!();
558 Self::builder().build()
559 }
560
561 pub fn builder<'a>() -> FlushStartBuilder<'a> {
562 assert_initialized_main_thread!();
563 FlushStartBuilder::new()
564 }
565}
566
567impl std::fmt::Debug for FlushStart {
568 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
569 f.debug_struct("FlushStart")
570 .field("seqnum", &self.event().seqnum())
571 .field("running-time-offset", &self.event().running_time_offset())
572 .field("structure", &self.event().structure())
573 .finish()
574 }
575}
576
577impl std::fmt::Debug for FlushStart<Event> {
578 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
579 FlushStart::<EventRef>::fmt(self, f)
580 }
581}
582
583declare_concrete_event!(FlushStop, T);
584impl FlushStop<Event> {
585 #[doc(alias = "gst_event_new_flush_stop")]
586 #[allow(clippy::new_ret_no_self)]
587 pub fn new(reset_time: bool) -> Event {
588 skip_assert_initialized!();
589 Self::builder(reset_time).build()
590 }
591
592 pub fn builder<'a>(reset_time: bool) -> FlushStopBuilder<'a> {
593 assert_initialized_main_thread!();
594 FlushStopBuilder::new(reset_time)
595 }
596}
597
598impl FlushStop {
599 #[doc(alias = "get_reset_time")]
600 #[doc(alias = "gst_event_parse_flush_stop")]
601 pub fn resets_time(&self) -> bool {
602 unsafe {
603 let mut reset_time = mem::MaybeUninit::uninit();
604
605 ffi::gst_event_parse_flush_stop(self.as_mut_ptr(), reset_time.as_mut_ptr());
606
607 from_glib(reset_time.assume_init())
608 }
609 }
610}
611
612impl std::fmt::Debug for FlushStop {
613 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
614 f.debug_struct("FlushStop")
615 .field("seqnum", &self.event().seqnum())
616 .field("running-time-offset", &self.event().running_time_offset())
617 .field("structure", &self.event().structure())
618 .field("resets-time", &self.resets_time())
619 .finish()
620 }
621}
622
623impl std::fmt::Debug for FlushStop<Event> {
624 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
625 FlushStop::<EventRef>::fmt(self, f)
626 }
627}
628
629declare_concrete_event!(@sticky StreamStart, T);
630impl StreamStart<Event> {
631 #[doc(alias = "gst_event_new_stream_start")]
632 #[allow(clippy::new_ret_no_self)]
633 pub fn new(stream_id: &str) -> Event {
634 skip_assert_initialized!();
635 Self::builder(stream_id).build()
636 }
637
638 pub fn builder(stream_id: &str) -> StreamStartBuilder<'_> {
639 assert_initialized_main_thread!();
640 StreamStartBuilder::new(stream_id)
641 }
642}
643
644impl StreamStart {
645 #[doc(alias = "get_stream_id")]
646 #[doc(alias = "gst_event_parse_stream_start")]
647 pub fn stream_id(&self) -> &str {
648 unsafe {
649 let mut stream_id = ptr::null();
650
651 ffi::gst_event_parse_stream_start(self.as_mut_ptr(), &mut stream_id);
652 CStr::from_ptr(stream_id).to_str().unwrap()
653 }
654 }
655
656 #[doc(alias = "get_stream_flags")]
657 #[doc(alias = "gst_event_parse_stream_flags")]
658 pub fn stream_flags(&self) -> crate::StreamFlags {
659 unsafe {
660 let mut stream_flags = mem::MaybeUninit::uninit();
661
662 ffi::gst_event_parse_stream_flags(self.as_mut_ptr(), stream_flags.as_mut_ptr());
663
664 from_glib(stream_flags.assume_init())
665 }
666 }
667
668 #[doc(alias = "get_group_id")]
669 #[doc(alias = "gst_event_parse_group_id")]
670 pub fn group_id(&self) -> Option<GroupId> {
671 unsafe {
672 let mut group_id = mem::MaybeUninit::uninit();
673
674 ffi::gst_event_parse_group_id(self.as_mut_ptr(), group_id.as_mut_ptr());
675
676 let group_id = group_id.assume_init();
677 if group_id == 0 {
678 None
679 } else {
680 Some(GroupId(NonZeroU32::new_unchecked(group_id)))
681 }
682 }
683 }
684
685 #[doc(alias = "gst_event_set_group_id")]
686 pub fn set_group_id(&mut self, group_id: GroupId) {
687 unsafe {
688 ffi::gst_event_set_group_id(self.as_mut_ptr(), group_id.0.get());
689 }
690 }
691
692 #[doc(alias = "get_stream")]
693 #[doc(alias = "gst_event_parse_stream")]
694 pub fn stream(&self) -> Option<crate::Stream> {
695 unsafe {
696 let mut stream = ptr::null_mut();
697 ffi::gst_event_parse_stream(self.as_mut_ptr(), &mut stream);
698 from_glib_full(stream)
699 }
700 }
701}
702
703impl std::fmt::Debug for StreamStart {
704 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
705 f.debug_struct("StreamStart")
706 .field("seqnum", &self.event().seqnum())
707 .field("running-time-offset", &self.event().running_time_offset())
708 .field("structure", &self.event().structure())
709 .field("stream-id", &self.stream_id())
710 .field("stream-flags", &self.stream_flags())
711 .field("group-id", &self.group_id())
712 .field("stream", &self.stream())
713 .finish()
714 }
715}
716
717impl std::fmt::Debug for StreamStart<Event> {
718 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
719 StreamStart::<EventRef>::fmt(self, f)
720 }
721}
722
723declare_concrete_event!(@sticky Caps, T);
724impl Caps<Event> {
725 #[doc(alias = "gst_event_new_caps")]
726 #[allow(clippy::new_ret_no_self)]
727 pub fn new(caps: &crate::Caps) -> Event {
728 skip_assert_initialized!();
729 Self::builder(caps).build()
730 }
731
732 pub fn builder(caps: &crate::Caps) -> CapsBuilder<'_> {
733 assert_initialized_main_thread!();
734 CapsBuilder::new(caps)
735 }
736}
737
738impl Caps {
739 #[doc(alias = "get_caps")]
740 #[doc(alias = "gst_event_parse_caps")]
741 pub fn caps(&self) -> &crate::CapsRef {
742 unsafe {
743 let mut caps = ptr::null_mut();
744
745 ffi::gst_event_parse_caps(self.as_mut_ptr(), &mut caps);
746 crate::CapsRef::from_ptr(caps)
747 }
748 }
749
750 #[doc(alias = "get_caps_owned")]
751 #[doc(alias = "gst_event_parse_caps")]
752 pub fn caps_owned(&self) -> crate::Caps {
753 unsafe { from_glib_none(self.caps().as_ptr()) }
754 }
755}
756
757impl std::fmt::Debug for Caps {
758 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
759 f.debug_struct("Caps")
760 .field("seqnum", &self.event().seqnum())
761 .field("running-time-offset", &self.event().running_time_offset())
762 .field("structure", &self.event().structure())
763 .field("caps", &self.caps())
764 .finish()
765 }
766}
767
768impl std::fmt::Debug for Caps<Event> {
769 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
770 Caps::<EventRef>::fmt(self, f)
771 }
772}
773
774declare_concrete_event!(@sticky Segment, T);
775impl Segment<Event> {
776 #[doc(alias = "gst_event_new_segment")]
777 #[allow(clippy::new_ret_no_self)]
778 pub fn new<F: FormattedValueIntrinsic>(segment: &crate::FormattedSegment<F>) -> Event {
779 skip_assert_initialized!();
780 Self::builder(segment).build()
781 }
782
783 pub fn builder<F: FormattedValueIntrinsic>(
784 segment: &crate::FormattedSegment<F>,
785 ) -> SegmentBuilder<'_> {
786 assert_initialized_main_thread!();
787 SegmentBuilder::new(segment.as_ref())
788 }
789}
790
791impl Segment {
792 #[doc(alias = "get_segment")]
793 #[doc(alias = "gst_event_parse_segment")]
794 pub fn segment(&self) -> &crate::Segment {
795 unsafe {
796 let mut segment = ptr::null();
797
798 ffi::gst_event_parse_segment(self.as_mut_ptr(), &mut segment);
799 &*(segment as *mut ffi::GstSegment as *mut crate::Segment)
800 }
801 }
802}
803
804impl std::fmt::Debug for Segment {
805 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
806 f.debug_struct("Segment")
807 .field("seqnum", &self.event().seqnum())
808 .field("running-time-offset", &self.event().running_time_offset())
809 .field("structure", &self.event().structure())
810 .field("segment", &self.segment())
811 .finish()
812 }
813}
814
815impl std::fmt::Debug for Segment<Event> {
816 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
817 Segment::<EventRef>::fmt(self, f)
818 }
819}
820
821declare_concrete_event!(@sticky StreamCollection, T);
822impl StreamCollection<Event> {
823 #[doc(alias = "gst_event_new_stream_collection")]
824 #[allow(clippy::new_ret_no_self)]
825 pub fn new(stream_collection: &crate::StreamCollection) -> Event {
826 skip_assert_initialized!();
827 Self::builder(stream_collection).build()
828 }
829
830 pub fn builder(stream_collection: &crate::StreamCollection) -> StreamCollectionBuilder<'_> {
831 assert_initialized_main_thread!();
832 StreamCollectionBuilder::new(stream_collection)
833 }
834}
835
836impl StreamCollection {
837 #[doc(alias = "get_stream_collection")]
838 #[doc(alias = "gst_event_parse_stream_collection")]
839 pub fn stream_collection(&self) -> crate::StreamCollection {
840 unsafe {
841 let mut stream_collection = ptr::null_mut();
842
843 ffi::gst_event_parse_stream_collection(self.as_mut_ptr(), &mut stream_collection);
844 from_glib_full(stream_collection)
845 }
846 }
847}
848
849impl std::fmt::Debug for StreamCollection {
850 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
851 f.debug_struct("StreamCollection")
852 .field("seqnum", &self.event().seqnum())
853 .field("running-time-offset", &self.event().running_time_offset())
854 .field("structure", &self.event().structure())
855 .field("stream-collection", &self.stream_collection())
856 .finish()
857 }
858}
859
860impl std::fmt::Debug for StreamCollection<Event> {
861 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
862 StreamCollection::<EventRef>::fmt(self, f)
863 }
864}
865
866declare_concrete_event!(@sticky Tag, T);
867impl Tag<Event> {
868 #[doc(alias = "gst_event_new_tag")]
869 #[allow(clippy::new_ret_no_self)]
870 pub fn new(tags: crate::TagList) -> Event {
871 skip_assert_initialized!();
872 Self::builder(tags).build()
873 }
874
875 pub fn builder<'a>(tags: crate::TagList) -> TagBuilder<'a> {
876 assert_initialized_main_thread!();
877 TagBuilder::new(tags)
878 }
879}
880
881impl Tag {
882 #[doc(alias = "get_tag")]
883 #[doc(alias = "gst_event_parse_tag")]
884 pub fn tag(&self) -> &crate::TagListRef {
885 unsafe {
886 let mut tags = ptr::null_mut();
887
888 ffi::gst_event_parse_tag(self.as_mut_ptr(), &mut tags);
889 crate::TagListRef::from_ptr(tags)
890 }
891 }
892
893 #[doc(alias = "get_tag_owned")]
894 #[doc(alias = "gst_event_parse_tag")]
895 pub fn tag_owned(&self) -> crate::TagList {
896 unsafe { from_glib_none(self.tag().as_ptr()) }
897 }
898}
899
900impl std::fmt::Debug for Tag {
901 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
902 f.debug_struct("Tag")
903 .field("seqnum", &self.event().seqnum())
904 .field("running-time-offset", &self.event().running_time_offset())
905 .field("structure", &self.event().structure())
906 .field("tag", &self.tag())
907 .finish()
908 }
909}
910
911impl std::fmt::Debug for Tag<Event> {
912 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
913 Tag::<EventRef>::fmt(self, f)
914 }
915}
916
917declare_concrete_event!(@sticky Buffersize, T);
918impl Buffersize<Event> {
919 #[doc(alias = "gst_event_new_buffer_size")]
920 #[allow(clippy::new_ret_no_self)]
921 pub fn new<V: FormattedValue>(
922 minsize: V,
923 maxsize: impl CompatibleFormattedValue<V>,
924 r#async: bool,
925 ) -> Event {
926 skip_assert_initialized!();
927 Self::builder(minsize, maxsize, r#async).build()
928 }
929
930 pub fn builder<'a, V: FormattedValue>(
931 minsize: V,
932 maxsize: impl CompatibleFormattedValue<V>,
933 r#async: bool,
934 ) -> BuffersizeBuilder<'a> {
935 assert_initialized_main_thread!();
936 let maxsize = maxsize.try_into_checked(minsize).unwrap();
937
938 BuffersizeBuilder::new(minsize.into(), maxsize.into(), r#async)
939 }
940}
941
942impl Buffersize {
943 #[doc(alias = "gst_event_parse_buffer_size")]
944 pub fn get(&self) -> (GenericFormattedValue, GenericFormattedValue, bool) {
945 unsafe {
946 let mut fmt = mem::MaybeUninit::uninit();
947 let mut minsize = mem::MaybeUninit::uninit();
948 let mut maxsize = mem::MaybeUninit::uninit();
949 let mut async_ = mem::MaybeUninit::uninit();
950
951 ffi::gst_event_parse_buffer_size(
952 self.as_mut_ptr(),
953 fmt.as_mut_ptr(),
954 minsize.as_mut_ptr(),
955 maxsize.as_mut_ptr(),
956 async_.as_mut_ptr(),
957 );
958 (
959 GenericFormattedValue::new(from_glib(fmt.assume_init()), minsize.assume_init()),
960 GenericFormattedValue::new(from_glib(fmt.assume_init()), maxsize.assume_init()),
961 from_glib(async_.assume_init()),
962 )
963 }
964 }
965
966 #[doc(alias = "gst_event_parse_buffer_size")]
967 pub fn min_size(&self) -> GenericFormattedValue {
968 self.get().0
969 }
970
971 #[doc(alias = "gst_event_parse_buffer_size")]
972 pub fn max_size(&self) -> GenericFormattedValue {
973 self.get().1
974 }
975
976 #[doc(alias = "gst_event_parse_buffer_size")]
977 pub fn async_(&self) -> bool {
978 self.get().2
979 }
980}
981
982impl std::fmt::Debug for Buffersize {
983 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
984 let (minsize, maxsize, async_) = self.get();
985 f.debug_struct("Buffersize")
986 .field("seqnum", &self.event().seqnum())
987 .field("running-time-offset", &self.event().running_time_offset())
988 .field("structure", &self.event().structure())
989 .field("min-size", &minsize)
990 .field("max-size", &maxsize)
991 .field("async", &async_)
992 .finish()
993 }
994}
995
996impl std::fmt::Debug for Buffersize<Event> {
997 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
998 Buffersize::<EventRef>::fmt(self, f)
999 }
1000}
1001
1002declare_concrete_event!(@sticky SinkMessage, T);
1003impl SinkMessage<Event> {
1004 #[doc(alias = "gst_event_new_sink_message")]
1005 #[allow(clippy::new_ret_no_self)]
1006 pub fn new(name: &str, msg: &crate::Message) -> Event {
1007 skip_assert_initialized!();
1008 Self::builder(name, msg).build()
1009 }
1010
1011 pub fn builder<'a>(name: &'a str, msg: &'a crate::Message) -> SinkMessageBuilder<'a> {
1012 assert_initialized_main_thread!();
1013 SinkMessageBuilder::new(name, msg)
1014 }
1015}
1016
1017impl SinkMessage {
1018 #[doc(alias = "get_message")]
1019 #[doc(alias = "gst_event_parse_sink_message")]
1020 pub fn message(&self) -> crate::Message {
1021 unsafe {
1022 let mut msg = ptr::null_mut();
1023
1024 ffi::gst_event_parse_sink_message(self.as_mut_ptr(), &mut msg);
1025 from_glib_full(msg)
1026 }
1027 }
1028}
1029
1030impl std::fmt::Debug for SinkMessage {
1031 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1032 f.debug_struct("SinkMessage")
1033 .field("seqnum", &self.event().seqnum())
1034 .field("running-time-offset", &self.event().running_time_offset())
1035 .field("structure", &self.event().structure())
1036 .field("message", &self.message())
1037 .finish()
1038 }
1039}
1040
1041impl std::fmt::Debug for SinkMessage<Event> {
1042 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1043 SinkMessage::<EventRef>::fmt(self, f)
1044 }
1045}
1046
1047declare_concrete_event!(@sticky StreamGroupDone, T);
1048impl StreamGroupDone<Event> {
1049 #[doc(alias = "gst_event_new_stream_group_done")]
1050 #[allow(clippy::new_ret_no_self)]
1051 pub fn new(group_id: GroupId) -> Event {
1052 skip_assert_initialized!();
1053 Self::builder(group_id).build()
1054 }
1055
1056 pub fn builder<'a>(group_id: GroupId) -> StreamGroupDoneBuilder<'a> {
1057 assert_initialized_main_thread!();
1058 StreamGroupDoneBuilder::new(group_id)
1059 }
1060}
1061
1062impl StreamGroupDone {
1063 #[doc(alias = "get_group_id")]
1064 #[doc(alias = "gst_event_parse_stream_group_done")]
1065 pub fn group_id(&self) -> GroupId {
1066 unsafe {
1067 let mut group_id = mem::MaybeUninit::uninit();
1068
1069 ffi::gst_event_parse_stream_group_done(self.as_mut_ptr(), group_id.as_mut_ptr());
1070
1071 let group_id = group_id.assume_init();
1072 debug_assert_ne!(group_id, 0);
1073 GroupId(NonZeroU32::new_unchecked(group_id))
1074 }
1075 }
1076}
1077
1078impl std::fmt::Debug for StreamGroupDone {
1079 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1080 f.debug_struct("StreamGroupDone")
1081 .field("seqnum", &self.event().seqnum())
1082 .field("running-time-offset", &self.event().running_time_offset())
1083 .field("structure", &self.event().structure())
1084 .field("group-id", &self.group_id())
1085 .finish()
1086 }
1087}
1088
1089impl std::fmt::Debug for StreamGroupDone<Event> {
1090 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1091 StreamGroupDone::<EventRef>::fmt(self, f)
1092 }
1093}
1094
1095declare_concrete_event!(@sticky Eos, T);
1096impl Eos<Event> {
1097 #[doc(alias = "gst_event_new_eos")]
1098 #[allow(clippy::new_ret_no_self)]
1099 pub fn new() -> Event {
1100 skip_assert_initialized!();
1101 Self::builder().build()
1102 }
1103
1104 pub fn builder<'a>() -> EosBuilder<'a> {
1105 assert_initialized_main_thread!();
1106 EosBuilder::new()
1107 }
1108}
1109
1110impl std::fmt::Debug for Eos {
1111 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1112 f.debug_struct("Eos")
1113 .field("seqnum", &self.event().seqnum())
1114 .field("running-time-offset", &self.event().running_time_offset())
1115 .field("structure", &self.event().structure())
1116 .finish()
1117 }
1118}
1119
1120impl std::fmt::Debug for Eos<Event> {
1121 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1122 Eos::<EventRef>::fmt(self, f)
1123 }
1124}
1125
1126declare_concrete_event!(@sticky Toc, T);
1127impl Toc<Event> {
1128 #[doc(alias = "gst_event_new_toc")]
1131 #[allow(clippy::new_ret_no_self)]
1132 pub fn new(toc: &crate::Toc, updated: bool) -> Event {
1133 skip_assert_initialized!();
1134 Self::builder(toc, updated).build()
1135 }
1136
1137 pub fn builder(toc: &crate::Toc, updated: bool) -> TocBuilder<'_> {
1138 assert_initialized_main_thread!();
1139 TocBuilder::new(toc, updated)
1140 }
1141}
1142
1143impl Toc {
1144 #[doc(alias = "get_toc")]
1145 #[doc(alias = "gst_event_parse_toc")]
1146 pub fn toc(&self) -> (&crate::TocRef, bool) {
1147 unsafe {
1148 let mut toc = ptr::null_mut();
1149 let mut updated = mem::MaybeUninit::uninit();
1150
1151 ffi::gst_event_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr());
1152 (
1153 crate::TocRef::from_ptr(toc),
1154 from_glib(updated.assume_init()),
1155 )
1156 }
1157 }
1158
1159 #[doc(alias = "get_toc_owned")]
1160 #[doc(alias = "gst_event_parse_toc")]
1161 pub fn toc_owned(&self) -> (crate::Toc, bool) {
1162 unsafe {
1163 let (toc, updated) = self.toc();
1164 (from_glib_none(toc.as_ptr()), updated)
1165 }
1166 }
1167
1168 #[doc(alias = "get_toc")]
1169 #[doc(alias = "gst_event_parse_toc")]
1170 pub fn toc_object(&self) -> &crate::TocRef {
1171 self.toc().0
1172 }
1173
1174 #[doc(alias = "get_toc")]
1175 #[doc(alias = "gst_event_parse_toc")]
1176 pub fn updated(&self) -> bool {
1177 self.toc().1
1178 }
1179}
1180
1181impl std::fmt::Debug for Toc {
1182 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1183 f.debug_struct("Toc")
1184 .field("seqnum", &self.event().seqnum())
1185 .field("running-time-offset", &self.event().running_time_offset())
1186 .field("structure", &self.event().structure())
1187 .field("toc", &self.toc())
1188 .finish()
1189 }
1190}
1191
1192impl std::fmt::Debug for Toc<Event> {
1193 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1194 Toc::<EventRef>::fmt(self, f)
1195 }
1196}
1197
1198declare_concrete_event!(@sticky Protection, T);
1199impl Protection<Event> {
1200 #[doc(alias = "gst_event_new_protection")]
1201 #[allow(clippy::new_ret_no_self)]
1202 pub fn new(system_id: &str, data: &crate::Buffer) -> Event {
1203 skip_assert_initialized!();
1204 Self::builder(system_id, data).build()
1205 }
1206
1207 pub fn builder<'a>(system_id: &'a str, data: &'a crate::Buffer) -> ProtectionBuilder<'a> {
1208 assert_initialized_main_thread!();
1209 ProtectionBuilder::new(system_id, data)
1210 }
1211}
1212
1213impl Protection {
1214 #[doc(alias = "gst_event_parse_protection")]
1215 pub fn get(&self) -> (&str, &crate::BufferRef, Option<&str>) {
1216 unsafe {
1217 let mut system_id = ptr::null();
1218 let mut buffer = ptr::null_mut();
1219 let mut origin = ptr::null();
1220
1221 ffi::gst_event_parse_protection(
1222 self.as_mut_ptr(),
1223 &mut system_id,
1224 &mut buffer,
1225 &mut origin,
1226 );
1227
1228 (
1229 CStr::from_ptr(system_id).to_str().unwrap(),
1230 crate::BufferRef::from_ptr(buffer),
1231 if origin.is_null() {
1232 None
1233 } else {
1234 Some(CStr::from_ptr(origin).to_str().unwrap())
1235 },
1236 )
1237 }
1238 }
1239
1240 #[doc(alias = "gst_event_parse_protection")]
1241 pub fn get_owned(&self) -> (&str, crate::Buffer, Option<&str>) {
1242 unsafe {
1243 let (system_id, buffer, origin) = self.get();
1244 (system_id, from_glib_none(buffer.as_ptr()), origin)
1245 }
1246 }
1247
1248 #[doc(alias = "gst_event_parse_protection")]
1249 pub fn system_id(&self) -> &str {
1250 self.get().0
1251 }
1252
1253 #[doc(alias = "gst_event_parse_protection")]
1254 pub fn buffer(&self) -> &crate::BufferRef {
1255 self.get().1
1256 }
1257
1258 #[doc(alias = "gst_event_parse_protection")]
1259 pub fn origin(&self) -> Option<&str> {
1260 self.get().2
1261 }
1262}
1263
1264impl std::fmt::Debug for Protection {
1265 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1266 let (system_id, buffer, origin) = self.get();
1267 f.debug_struct("Protection")
1268 .field("seqnum", &self.event().seqnum())
1269 .field("running-time-offset", &self.event().running_time_offset())
1270 .field("structure", &self.event().structure())
1271 .field("system-id", &system_id)
1272 .field("buffer", &buffer)
1273 .field("origin", &origin)
1274 .finish()
1275 }
1276}
1277
1278impl std::fmt::Debug for Protection<Event> {
1279 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1280 Protection::<EventRef>::fmt(self, f)
1281 }
1282}
1283
1284declare_concrete_event!(SegmentDone, T);
1285impl SegmentDone<Event> {
1286 #[doc(alias = "gst_event_new_segment_done")]
1287 #[allow(clippy::new_ret_no_self)]
1288 pub fn new(position: impl FormattedValue) -> Event {
1289 skip_assert_initialized!();
1290 Self::builder(position).build()
1291 }
1292
1293 pub fn builder<'a>(position: impl FormattedValue) -> SegmentDoneBuilder<'a> {
1294 assert_initialized_main_thread!();
1295 SegmentDoneBuilder::new(position.into())
1296 }
1297}
1298
1299impl SegmentDone {
1300 #[doc(alias = "gst_event_parse_segment_done")]
1301 pub fn get(&self) -> GenericFormattedValue {
1302 unsafe {
1303 let mut fmt = mem::MaybeUninit::uninit();
1304 let mut position = mem::MaybeUninit::uninit();
1305
1306 ffi::gst_event_parse_segment_done(
1307 self.as_mut_ptr(),
1308 fmt.as_mut_ptr(),
1309 position.as_mut_ptr(),
1310 );
1311
1312 GenericFormattedValue::new(from_glib(fmt.assume_init()), position.assume_init())
1313 }
1314 }
1315}
1316
1317impl std::fmt::Debug for SegmentDone {
1318 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1319 f.debug_struct("SegmentDone")
1320 .field("seqnum", &self.event().seqnum())
1321 .field("running-time-offset", &self.event().running_time_offset())
1322 .field("structure", &self.event().structure())
1323 .field("segment", &self.get())
1324 .finish()
1325 }
1326}
1327
1328impl std::fmt::Debug for SegmentDone<Event> {
1329 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1330 SegmentDone::<EventRef>::fmt(self, f)
1331 }
1332}
1333
1334declare_concrete_event!(Gap, T);
1335impl Gap<Event> {
1336 #[doc(alias = "gst_event_new_gap")]
1337 #[allow(clippy::new_ret_no_self)]
1338 pub fn new(timestamp: ClockTime, duration: impl Into<Option<ClockTime>>) -> Event {
1339 skip_assert_initialized!();
1340 Self::builder(timestamp).duration(duration).build()
1341 }
1342
1343 pub fn builder<'a>(timestamp: ClockTime) -> GapBuilder<'a> {
1344 assert_initialized_main_thread!();
1345 GapBuilder::new(timestamp)
1346 }
1347}
1348
1349impl Gap {
1350 #[doc(alias = "gst_event_parse_gap")]
1351 pub fn get(&self) -> (ClockTime, Option<ClockTime>) {
1352 unsafe {
1353 let mut timestamp = mem::MaybeUninit::uninit();
1354 let mut duration = mem::MaybeUninit::uninit();
1355
1356 ffi::gst_event_parse_gap(
1357 self.as_mut_ptr(),
1358 timestamp.as_mut_ptr(),
1359 duration.as_mut_ptr(),
1360 );
1361
1362 (
1363 try_from_glib(timestamp.assume_init()).expect("undefined timestamp"),
1364 from_glib(duration.assume_init()),
1365 )
1366 }
1367 }
1368
1369 #[doc(alias = "gst_event_parse_gap")]
1370 pub fn timestamp(&self) -> ClockTime {
1371 self.get().0
1372 }
1373
1374 #[doc(alias = "gst_event_parse_gap")]
1375 pub fn duration(&self) -> Option<ClockTime> {
1376 self.get().1
1377 }
1378
1379 #[cfg(feature = "v1_20")]
1380 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1381 #[doc(alias = "gst_event_parse_gap_flags")]
1382 pub fn gap_flags(&self) -> crate::GapFlags {
1383 unsafe {
1384 let mut flags = mem::MaybeUninit::uninit();
1385 ffi::gst_event_parse_gap_flags(self.as_mut_ptr(), flags.as_mut_ptr());
1386 from_glib(flags.assume_init())
1387 }
1388 }
1389}
1390
1391impl std::fmt::Debug for Gap {
1392 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1393 let (timestamp, duration) = self.get();
1394 let mut f = f.debug_struct("Gap");
1395 f.field("seqnum", &self.event().seqnum())
1396 .field("running-time-offset", &self.event().running_time_offset())
1397 .field("structure", &self.event().structure())
1398 .field("timestamp", ×tamp)
1399 .field("duration", &duration);
1400 #[cfg(feature = "v1_20")]
1401 f.field("flags", &self.gap_flags());
1402 f.finish()
1403 }
1404}
1405
1406impl std::fmt::Debug for Gap<Event> {
1407 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1408 Gap::<EventRef>::fmt(self, f)
1409 }
1410}
1411
1412#[cfg(feature = "v1_18")]
1413#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1414declare_concrete_event!(@sticky InstantRateChange, T);
1415#[cfg(feature = "v1_18")]
1416#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1417impl InstantRateChange<Event> {
1418 #[doc(alias = "gst_event_new_instant_rate_change")]
1419 #[allow(clippy::new_ret_no_self)]
1420 pub fn new(multiplier: f64, new_flags: crate::SegmentFlags) -> Event {
1421 skip_assert_initialized!();
1422 Self::builder(multiplier, new_flags).build()
1423 }
1424
1425 pub fn builder<'a>(
1426 multiplier: f64,
1427 new_flags: crate::SegmentFlags,
1428 ) -> InstantRateChangeBuilder<'a> {
1429 assert_initialized_main_thread!();
1430 InstantRateChangeBuilder::new(multiplier, new_flags)
1431 }
1432}
1433
1434#[cfg(feature = "v1_18")]
1435#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1436impl InstantRateChange {
1437 #[doc(alias = "gst_event_parse_instant_rate_change")]
1438 pub fn get(&self) -> (f64, crate::SegmentFlags) {
1439 unsafe {
1440 let mut multiplier = mem::MaybeUninit::uninit();
1441 let mut new_flags = mem::MaybeUninit::uninit();
1442
1443 ffi::gst_event_parse_instant_rate_change(
1444 self.as_mut_ptr(),
1445 multiplier.as_mut_ptr(),
1446 new_flags.as_mut_ptr(),
1447 );
1448
1449 (multiplier.assume_init(), from_glib(new_flags.assume_init()))
1450 }
1451 }
1452
1453 #[doc(alias = "gst_event_parse_instant_rate_change")]
1454 pub fn multiplier(&self) -> f64 {
1455 self.get().0
1456 }
1457
1458 #[doc(alias = "gst_event_parse_instant_rate_change")]
1459 pub fn new_flags(&self) -> crate::SegmentFlags {
1460 self.get().1
1461 }
1462}
1463
1464#[cfg(feature = "v1_18")]
1465impl std::fmt::Debug for InstantRateChange {
1466 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1467 let (multiplier, new_flags) = self.get();
1468 f.debug_struct("InstantRateChange")
1469 .field("seqnum", &self.event().seqnum())
1470 .field("running-time-offset", &self.event().running_time_offset())
1471 .field("structure", &self.event().structure())
1472 .field("multiplier", &multiplier)
1473 .field("new-flags", &new_flags)
1474 .finish()
1475 }
1476}
1477
1478#[cfg(feature = "v1_18")]
1479impl std::fmt::Debug for InstantRateChange<Event> {
1480 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1481 InstantRateChange::<EventRef>::fmt(self, f)
1482 }
1483}
1484
1485declare_concrete_event!(Qos, T);
1486impl Qos<Event> {
1487 #[doc(alias = "gst_event_new_qos")]
1488 #[allow(clippy::new_ret_no_self)]
1489 pub fn new(
1490 type_: crate::QOSType,
1491 proportion: f64,
1492 diff: i64,
1493 timestamp: impl Into<Option<ClockTime>>,
1494 ) -> Event {
1495 skip_assert_initialized!();
1496 Self::builder(type_, proportion, diff)
1497 .timestamp(timestamp)
1498 .build()
1499 }
1500
1501 pub fn builder<'a>(type_: crate::QOSType, proportion: f64, diff: i64) -> QosBuilder<'a> {
1502 assert_initialized_main_thread!();
1503 QosBuilder::new(type_, proportion, diff)
1504 }
1505}
1506
1507impl Qos {
1508 #[doc(alias = "gst_event_parse_qos")]
1509 pub fn get(&self) -> (crate::QOSType, f64, i64, Option<ClockTime>) {
1510 unsafe {
1511 let mut type_ = mem::MaybeUninit::uninit();
1512 let mut proportion = mem::MaybeUninit::uninit();
1513 let mut diff = mem::MaybeUninit::uninit();
1514 let mut timestamp = mem::MaybeUninit::uninit();
1515
1516 ffi::gst_event_parse_qos(
1517 self.as_mut_ptr(),
1518 type_.as_mut_ptr(),
1519 proportion.as_mut_ptr(),
1520 diff.as_mut_ptr(),
1521 timestamp.as_mut_ptr(),
1522 );
1523
1524 (
1525 from_glib(type_.assume_init()),
1526 proportion.assume_init(),
1527 diff.assume_init(),
1528 from_glib(timestamp.assume_init()),
1529 )
1530 }
1531 }
1532
1533 #[doc(alias = "gst_event_parse_qos")]
1534 pub fn qos_type(&self) -> crate::QOSType {
1535 self.get().0
1536 }
1537
1538 #[doc(alias = "gst_event_parse_qos")]
1539 pub fn proportion(&self) -> f64 {
1540 self.get().1
1541 }
1542
1543 #[doc(alias = "gst_event_parse_qos")]
1544 pub fn diff(&self) -> i64 {
1545 self.get().2
1546 }
1547
1548 #[doc(alias = "gst_event_parse_qos")]
1549 pub fn timestamp(&self) -> Option<ClockTime> {
1550 self.get().3
1551 }
1552}
1553
1554impl std::fmt::Debug for Qos {
1555 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1556 let (type_, proportion, diff, timestamp) = self.get();
1557 f.debug_struct("Qos")
1558 .field("seqnum", &self.event().seqnum())
1559 .field("running-time-offset", &self.event().running_time_offset())
1560 .field("structure", &self.event().structure())
1561 .field("type", &type_)
1562 .field("proportion", &proportion)
1563 .field("diff", &diff)
1564 .field("timestamp", ×tamp)
1565 .finish()
1566 }
1567}
1568
1569impl std::fmt::Debug for Qos<Event> {
1570 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1571 Qos::<EventRef>::fmt(self, f)
1572 }
1573}
1574
1575declare_concrete_event!(Seek, T);
1576impl Seek<Event> {
1577 #[doc(alias = "gst_event_new_seek")]
1578 #[allow(clippy::new_ret_no_self)]
1579 pub fn new<V: FormattedValue>(
1580 rate: f64,
1581 flags: crate::SeekFlags,
1582 start_type: crate::SeekType,
1583 start: V,
1584 stop_type: crate::SeekType,
1585 stop: impl CompatibleFormattedValue<V>,
1586 ) -> Event {
1587 skip_assert_initialized!();
1588 Self::builder(rate, flags, start_type, start, stop_type, stop).build()
1589 }
1590
1591 pub fn builder<'a, V: FormattedValue>(
1592 rate: f64,
1593 flags: crate::SeekFlags,
1594 start_type: crate::SeekType,
1595 start: V,
1596 stop_type: crate::SeekType,
1597 stop: impl CompatibleFormattedValue<V>,
1598 ) -> SeekBuilder<'a> {
1599 assert_initialized_main_thread!();
1600 let stop = stop.try_into_checked(start).unwrap();
1601
1602 SeekBuilder::new(
1603 rate,
1604 flags,
1605 start_type,
1606 start.into(),
1607 stop_type,
1608 stop.into(),
1609 )
1610 }
1611}
1612
1613impl Seek {
1614 #[doc(alias = "gst_event_parse_seek")]
1615 pub fn get(
1616 &self,
1617 ) -> (
1618 f64,
1619 crate::SeekFlags,
1620 crate::SeekType,
1621 GenericFormattedValue,
1622 crate::SeekType,
1623 GenericFormattedValue,
1624 ) {
1625 unsafe {
1626 let mut rate = mem::MaybeUninit::uninit();
1627 let mut fmt = mem::MaybeUninit::uninit();
1628 let mut flags = mem::MaybeUninit::uninit();
1629 let mut start_type = mem::MaybeUninit::uninit();
1630 let mut start = mem::MaybeUninit::uninit();
1631 let mut stop_type = mem::MaybeUninit::uninit();
1632 let mut stop = mem::MaybeUninit::uninit();
1633
1634 ffi::gst_event_parse_seek(
1635 self.as_mut_ptr(),
1636 rate.as_mut_ptr(),
1637 fmt.as_mut_ptr(),
1638 flags.as_mut_ptr(),
1639 start_type.as_mut_ptr(),
1640 start.as_mut_ptr(),
1641 stop_type.as_mut_ptr(),
1642 stop.as_mut_ptr(),
1643 );
1644
1645 (
1646 rate.assume_init(),
1647 from_glib(flags.assume_init()),
1648 from_glib(start_type.assume_init()),
1649 GenericFormattedValue::new(from_glib(fmt.assume_init()), start.assume_init()),
1650 from_glib(stop_type.assume_init()),
1651 GenericFormattedValue::new(from_glib(fmt.assume_init()), stop.assume_init()),
1652 )
1653 }
1654 }
1655
1656 #[doc(alias = "gst_event_parse_seek")]
1657 pub fn rate(&self) -> f64 {
1658 self.get().0
1659 }
1660
1661 #[doc(alias = "gst_event_parse_seek")]
1662 pub fn flags(&self) -> crate::SeekFlags {
1663 self.get().1
1664 }
1665
1666 #[doc(alias = "gst_event_parse_seek")]
1667 pub fn start_type(&self) -> crate::SeekType {
1668 self.get().2
1669 }
1670
1671 #[doc(alias = "gst_event_parse_seek")]
1672 pub fn start(&self) -> GenericFormattedValue {
1673 self.get().3
1674 }
1675
1676 #[doc(alias = "gst_event_parse_seek")]
1677 pub fn stop_type(&self) -> crate::SeekType {
1678 self.get().4
1679 }
1680
1681 #[doc(alias = "gst_event_parse_seek")]
1682 pub fn stop(&self) -> GenericFormattedValue {
1683 self.get().5
1684 }
1685
1686 #[cfg(feature = "v1_16")]
1687 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
1688 #[doc(alias = "get_trickmode_interval")]
1689 #[doc(alias = "gst_event_parse_seek_trickmode_interval")]
1690 pub fn trickmode_interval(&self) -> Option<ClockTime> {
1691 unsafe {
1692 let mut trickmode_interval = mem::MaybeUninit::uninit();
1693
1694 ffi::gst_event_parse_seek_trickmode_interval(
1695 self.as_mut_ptr(),
1696 trickmode_interval.as_mut_ptr(),
1697 );
1698
1699 from_glib(trickmode_interval.assume_init())
1700 }
1701 }
1702}
1703
1704impl std::fmt::Debug for Seek {
1705 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1706 let (rate, flags, start_type, start, stop_type, stop) = self.get();
1707 f.debug_struct("Seek")
1708 .field("seqnum", &self.event().seqnum())
1709 .field("running-time-offset", &self.event().running_time_offset())
1710 .field("structure", &self.event().structure())
1711 .field("rate", &rate)
1712 .field("flags", &flags)
1713 .field("start-type", &start_type)
1714 .field("start", &start)
1715 .field("stop-type", &stop_type)
1716 .field("stop", &stop)
1717 .finish()
1718 }
1719}
1720
1721impl std::fmt::Debug for Seek<Event> {
1722 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1723 Seek::<EventRef>::fmt(self, f)
1724 }
1725}
1726
1727declare_concrete_event!(Navigation, T);
1728impl Navigation<Event> {
1729 #[doc(alias = "gst_event_new_navigation")]
1730 #[allow(clippy::new_ret_no_self)]
1731 pub fn new(structure: crate::Structure) -> Event {
1732 skip_assert_initialized!();
1733 Self::builder(structure).build()
1734 }
1735
1736 pub fn builder<'a>(structure: crate::Structure) -> NavigationBuilder<'a> {
1737 assert_initialized_main_thread!();
1738 NavigationBuilder::new(structure)
1739 }
1740}
1741
1742impl std::fmt::Debug for Navigation {
1743 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1744 f.debug_struct("Navigation")
1745 .field("seqnum", &self.event().seqnum())
1746 .field("running-time-offset", &self.event().running_time_offset())
1747 .field("structure", &self.event().structure())
1748 .finish()
1749 }
1750}
1751
1752impl std::fmt::Debug for Navigation<Event> {
1753 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1754 Navigation::<EventRef>::fmt(self, f)
1755 }
1756}
1757
1758declare_concrete_event!(Latency, T);
1759impl Latency<Event> {
1760 #[doc(alias = "gst_event_new_latency")]
1761 #[allow(clippy::new_ret_no_self)]
1762 pub fn new(latency: ClockTime) -> Event {
1763 skip_assert_initialized!();
1764 Self::builder(latency).build()
1765 }
1766
1767 pub fn builder<'a>(latency: ClockTime) -> LatencyBuilder<'a> {
1768 assert_initialized_main_thread!();
1769 LatencyBuilder::new(latency)
1770 }
1771}
1772
1773impl Latency {
1774 #[doc(alias = "get_latency")]
1775 #[doc(alias = "gst_event_parse_latency")]
1776 pub fn latency(&self) -> ClockTime {
1777 unsafe {
1778 let mut latency = mem::MaybeUninit::uninit();
1779
1780 ffi::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr());
1781
1782 try_from_glib(latency.assume_init()).expect("undefined latency")
1783 }
1784 }
1785}
1786
1787impl std::fmt::Debug for Latency {
1788 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1789 f.debug_struct("Latency")
1790 .field("seqnum", &self.event().seqnum())
1791 .field("running-time-offset", &self.event().running_time_offset())
1792 .field("structure", &self.event().structure())
1793 .field("latency", &self.latency())
1794 .finish()
1795 }
1796}
1797
1798impl std::fmt::Debug for Latency<Event> {
1799 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1800 Latency::<EventRef>::fmt(self, f)
1801 }
1802}
1803
1804declare_concrete_event!(Step, T);
1805impl Step<Event> {
1806 #[doc(alias = "gst_event_new_step")]
1807 #[allow(clippy::new_ret_no_self)]
1808 pub fn new(amount: impl FormattedValue, rate: f64, flush: bool, intermediate: bool) -> Event {
1809 skip_assert_initialized!();
1810 Self::builder(amount, rate, flush, intermediate).build()
1811 }
1812
1813 pub fn builder<'a>(
1814 amount: impl FormattedValue,
1815 rate: f64,
1816 flush: bool,
1817 intermediate: bool,
1818 ) -> StepBuilder<'a> {
1819 assert_initialized_main_thread!();
1820 StepBuilder::new(amount.into(), rate, flush, intermediate)
1821 }
1822}
1823
1824impl Step {
1825 #[doc(alias = "gst_event_parse_step")]
1826 pub fn get(&self) -> (GenericFormattedValue, f64, bool, bool) {
1827 unsafe {
1828 let mut fmt = mem::MaybeUninit::uninit();
1829 let mut amount = mem::MaybeUninit::uninit();
1830 let mut rate = mem::MaybeUninit::uninit();
1831 let mut flush = mem::MaybeUninit::uninit();
1832 let mut intermediate = mem::MaybeUninit::uninit();
1833
1834 ffi::gst_event_parse_step(
1835 self.as_mut_ptr(),
1836 fmt.as_mut_ptr(),
1837 amount.as_mut_ptr(),
1838 rate.as_mut_ptr(),
1839 flush.as_mut_ptr(),
1840 intermediate.as_mut_ptr(),
1841 );
1842
1843 (
1844 GenericFormattedValue::new(
1845 from_glib(fmt.assume_init()),
1846 amount.assume_init() as i64,
1847 ),
1848 rate.assume_init(),
1849 from_glib(flush.assume_init()),
1850 from_glib(intermediate.assume_init()),
1851 )
1852 }
1853 }
1854
1855 #[doc(alias = "gst_event_parse_step")]
1856 pub fn amount(&self) -> GenericFormattedValue {
1857 self.get().0
1858 }
1859
1860 #[doc(alias = "gst_event_parse_step")]
1861 pub fn rate(&self) -> f64 {
1862 self.get().1
1863 }
1864
1865 #[doc(alias = "gst_event_parse_step")]
1866 pub fn flush(&self) -> bool {
1867 self.get().2
1868 }
1869
1870 #[doc(alias = "gst_event_parse_step")]
1871 pub fn intermediate(&self) -> bool {
1872 self.get().3
1873 }
1874}
1875
1876impl std::fmt::Debug for Step {
1877 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1878 let (amount, rate, flush, intermediate) = self.get();
1879 f.debug_struct("Step")
1880 .field("seqnum", &self.event().seqnum())
1881 .field("running-time-offset", &self.event().running_time_offset())
1882 .field("structure", &self.event().structure())
1883 .field("amount", &amount)
1884 .field("rate", &rate)
1885 .field("flush", &flush)
1886 .field("intermediate", &intermediate)
1887 .finish()
1888 }
1889}
1890
1891impl std::fmt::Debug for Step<Event> {
1892 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1893 Step::<EventRef>::fmt(self, f)
1894 }
1895}
1896
1897declare_concrete_event!(Reconfigure, T);
1898impl Reconfigure<Event> {
1899 #[doc(alias = "gst_event_new_reconfigure")]
1900 #[allow(clippy::new_ret_no_self)]
1901 pub fn new() -> Event {
1902 skip_assert_initialized!();
1903 Self::builder().build()
1904 }
1905
1906 pub fn builder<'a>() -> ReconfigureBuilder<'a> {
1907 assert_initialized_main_thread!();
1908 ReconfigureBuilder::new()
1909 }
1910}
1911
1912impl std::fmt::Debug for Reconfigure {
1913 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1914 f.debug_struct("Reconfigure")
1915 .field("seqnum", &self.event().seqnum())
1916 .field("running-time-offset", &self.event().running_time_offset())
1917 .field("structure", &self.event().structure())
1918 .finish()
1919 }
1920}
1921
1922impl std::fmt::Debug for Reconfigure<Event> {
1923 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1924 Reconfigure::<EventRef>::fmt(self, f)
1925 }
1926}
1927
1928declare_concrete_event!(TocSelect, T);
1929impl TocSelect<Event> {
1930 #[doc(alias = "gst_event_new_toc_select")]
1931 #[allow(clippy::new_ret_no_self)]
1932 pub fn new(uid: &str) -> Event {
1933 skip_assert_initialized!();
1934 Self::builder(uid).build()
1935 }
1936
1937 pub fn builder(uid: &str) -> TocSelectBuilder<'_> {
1938 assert_initialized_main_thread!();
1939 TocSelectBuilder::new(uid)
1940 }
1941}
1942
1943impl TocSelect {
1944 #[doc(alias = "get_uid")]
1945 pub fn uid(&self) -> &str {
1946 unsafe {
1947 let mut uid = ptr::null_mut();
1948
1949 ffi::gst_event_parse_toc_select(self.as_mut_ptr(), &mut uid);
1950
1951 CStr::from_ptr(uid).to_str().unwrap()
1952 }
1953 }
1954}
1955
1956impl std::fmt::Debug for TocSelect {
1957 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1958 f.debug_struct("TocSelect")
1959 .field("seqnum", &self.event().seqnum())
1960 .field("running-time-offset", &self.event().running_time_offset())
1961 .field("structure", &self.event().structure())
1962 .field("uid", &self.uid())
1963 .finish()
1964 }
1965}
1966
1967impl std::fmt::Debug for TocSelect<Event> {
1968 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1969 TocSelect::<EventRef>::fmt(self, f)
1970 }
1971}
1972
1973declare_concrete_event!(SelectStreams, T);
1974impl SelectStreams<Event> {
1975 #[doc(alias = "gst_event_new_select_streams")]
1976 #[allow(clippy::new_ret_no_self)]
1977 pub fn new<'a>(streams: impl IntoIterator<Item = &'a str>) -> Event {
1978 skip_assert_initialized!();
1979 Self::builder(streams).build()
1980 }
1981
1982 pub fn builder<'a>(streams: impl IntoIterator<Item = &'a str>) -> SelectStreamsBuilder<'a> {
1983 assert_initialized_main_thread!();
1984 SelectStreamsBuilder::new(streams)
1985 }
1986}
1987
1988impl SelectStreams {
1989 #[doc(alias = "get_streams")]
1990 #[doc(alias = "gst_event_parse_select_streams")]
1991 pub fn streams(&self) -> glib::collections::List<glib::GStringPtr> {
1992 unsafe {
1993 let mut streams = ptr::null_mut();
1994
1995 ffi::gst_event_parse_select_streams(self.as_mut_ptr(), &mut streams);
1996
1997 glib::collections::List::from_glib_full(streams)
1998 }
1999 }
2000}
2001
2002impl std::fmt::Debug for SelectStreams {
2003 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2004 struct StreamsDebug<'a>(&'a SelectStreams);
2005
2006 impl std::fmt::Debug for StreamsDebug<'_> {
2007 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2008 f.debug_list().entries(self.0.streams()).finish()
2009 }
2010 }
2011
2012 f.debug_struct("SelectStreams")
2013 .field("seqnum", &self.event().seqnum())
2014 .field("running-time-offset", &self.event().running_time_offset())
2015 .field("structure", &self.event().structure())
2016 .field("streams", &StreamsDebug(self))
2017 .finish()
2018 }
2019}
2020
2021impl std::fmt::Debug for SelectStreams<Event> {
2022 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2023 SelectStreams::<EventRef>::fmt(self, f)
2024 }
2025}
2026
2027#[cfg(feature = "v1_18")]
2028#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2029declare_concrete_event!(InstantRateSyncTime, T);
2030#[cfg(feature = "v1_18")]
2031#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2032impl InstantRateSyncTime<Event> {
2033 #[doc(alias = "gst_event_new_instant_rate_sync_time")]
2034 #[allow(clippy::new_ret_no_self)]
2035 pub fn new(
2036 rate_multiplier: f64,
2037 running_time: ClockTime,
2038 upstream_running_time: ClockTime,
2039 ) -> Event {
2040 skip_assert_initialized!();
2041 Self::builder(rate_multiplier, running_time, upstream_running_time).build()
2042 }
2043
2044 pub fn builder<'a>(
2045 rate_multiplier: f64,
2046 running_time: ClockTime,
2047 upstream_running_time: ClockTime,
2048 ) -> InstantRateSyncTimeBuilder<'a> {
2049 assert_initialized_main_thread!();
2050 InstantRateSyncTimeBuilder::new(rate_multiplier, running_time, upstream_running_time)
2051 }
2052}
2053
2054#[cfg(feature = "v1_18")]
2055#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2056impl InstantRateSyncTime {
2057 #[doc(alias = "parse_instant_rate_sync_time")]
2058 #[doc(alias = "gst_event_parse_instant_rate_sync_time")]
2059 pub fn get(&self) -> (f64, ClockTime, ClockTime) {
2060 unsafe {
2061 let mut rate_multiplier = mem::MaybeUninit::uninit();
2062 let mut running_time = mem::MaybeUninit::uninit();
2063 let mut upstream_running_time = mem::MaybeUninit::uninit();
2064
2065 ffi::gst_event_parse_instant_rate_sync_time(
2066 self.as_mut_ptr(),
2067 rate_multiplier.as_mut_ptr(),
2068 running_time.as_mut_ptr(),
2069 upstream_running_time.as_mut_ptr(),
2070 );
2071
2072 (
2073 rate_multiplier.assume_init(),
2074 try_from_glib(running_time.assume_init()).expect("undefined timestamp"),
2075 try_from_glib(upstream_running_time.assume_init()).expect("undefined timestamp"),
2076 )
2077 }
2078 }
2079
2080 #[doc(alias = "parse_instant_rate_sync_time")]
2081 #[doc(alias = "gst_event_parse_instant_rate_sync_time")]
2082 pub fn rate_multiplier(&self) -> f64 {
2083 self.get().0
2084 }
2085
2086 #[doc(alias = "parse_instant_rate_sync_time")]
2087 #[doc(alias = "gst_event_parse_instant_rate_sync_time")]
2088 pub fn running_time(&self) -> ClockTime {
2089 self.get().1
2090 }
2091
2092 #[doc(alias = "parse_instant_rate_sync_time")]
2093 #[doc(alias = "gst_event_parse_instant_rate_sync_time")]
2094 pub fn upstream_running_time(&self) -> ClockTime {
2095 self.get().2
2096 }
2097}
2098
2099#[cfg(feature = "v1_18")]
2100impl std::fmt::Debug for InstantRateSyncTime {
2101 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2102 let (rate_multiplier, running_time, upstream_running_time) = self.get();
2103 f.debug_struct("InstantRateSyncTime")
2104 .field("seqnum", &self.event().seqnum())
2105 .field("running-time-offset", &self.event().running_time_offset())
2106 .field("structure", &self.event().structure())
2107 .field("rate-multiplier", &rate_multiplier)
2108 .field("running-time", &running_time)
2109 .field("upstream-running-time", &upstream_running_time)
2110 .finish()
2111 }
2112}
2113
2114#[cfg(feature = "v1_18")]
2115impl std::fmt::Debug for InstantRateSyncTime<Event> {
2116 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2117 InstantRateSyncTime::<EventRef>::fmt(self, f)
2118 }
2119}
2120
2121declare_concrete_event!(CustomUpstream, T);
2122impl CustomUpstream<Event> {
2123 #[doc(alias = "gst_event_new_custom")]
2124 #[allow(clippy::new_ret_no_self)]
2125 pub fn new(structure: crate::Structure) -> Event {
2126 skip_assert_initialized!();
2127 Self::builder(structure).build()
2128 }
2129
2130 pub fn builder<'a>(structure: crate::Structure) -> CustomUpstreamBuilder<'a> {
2131 assert_initialized_main_thread!();
2132 CustomUpstreamBuilder::new(structure)
2133 }
2134}
2135
2136impl std::fmt::Debug for CustomUpstream {
2137 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2138 f.debug_struct("CustomUpstream")
2139 .field("seqnum", &self.event().seqnum())
2140 .field("running-time-offset", &self.event().running_time_offset())
2141 .field("structure", &self.event().structure())
2142 .finish()
2143 }
2144}
2145
2146impl std::fmt::Debug for CustomUpstream<Event> {
2147 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2148 CustomUpstream::<EventRef>::fmt(self, f)
2149 }
2150}
2151
2152declare_concrete_event!(CustomDownstream, T);
2153impl CustomDownstream<Event> {
2154 #[doc(alias = "gst_event_new_custom")]
2155 #[allow(clippy::new_ret_no_self)]
2156 pub fn new(structure: crate::Structure) -> Event {
2157 skip_assert_initialized!();
2158 Self::builder(structure).build()
2159 }
2160
2161 pub fn builder<'a>(structure: crate::Structure) -> CustomDownstreamBuilder<'a> {
2162 assert_initialized_main_thread!();
2163 CustomDownstreamBuilder::new(structure)
2164 }
2165}
2166
2167impl std::fmt::Debug for CustomDownstream {
2168 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2169 f.debug_struct("CustomDownstream")
2170 .field("seqnum", &self.event().seqnum())
2171 .field("running-time-offset", &self.event().running_time_offset())
2172 .field("structure", &self.event().structure())
2173 .finish()
2174 }
2175}
2176
2177impl std::fmt::Debug for CustomDownstream<Event> {
2178 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2179 CustomDownstream::<EventRef>::fmt(self, f)
2180 }
2181}
2182
2183declare_concrete_event!(CustomDownstreamOob, T);
2184impl CustomDownstreamOob<Event> {
2185 #[doc(alias = "gst_event_new_custom")]
2186 #[allow(clippy::new_ret_no_self)]
2187 pub fn new(structure: crate::Structure) -> Event {
2188 skip_assert_initialized!();
2189 Self::builder(structure).build()
2190 }
2191
2192 pub fn builder<'a>(structure: crate::Structure) -> CustomDownstreamOobBuilder<'a> {
2193 assert_initialized_main_thread!();
2194 CustomDownstreamOobBuilder::new(structure)
2195 }
2196}
2197
2198impl std::fmt::Debug for CustomDownstreamOob {
2199 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2200 f.debug_struct("CustomDownstreamOob")
2201 .field("seqnum", &self.event().seqnum())
2202 .field("running-time-offset", &self.event().running_time_offset())
2203 .field("structure", &self.event().structure())
2204 .finish()
2205 }
2206}
2207
2208impl std::fmt::Debug for CustomDownstreamOob<Event> {
2209 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2210 CustomDownstreamOob::<EventRef>::fmt(self, f)
2211 }
2212}
2213
2214declare_concrete_event!(@sticky CustomDownstreamSticky, T);
2215impl CustomDownstreamSticky<Event> {
2216 #[doc(alias = "gst_event_new_custom")]
2217 #[allow(clippy::new_ret_no_self)]
2218 pub fn new(structure: crate::Structure) -> Event {
2219 skip_assert_initialized!();
2220 Self::builder(structure).build()
2221 }
2222
2223 pub fn builder<'a>(structure: crate::Structure) -> CustomDownstreamStickyBuilder<'a> {
2224 assert_initialized_main_thread!();
2225 CustomDownstreamStickyBuilder::new(structure)
2226 }
2227}
2228
2229impl std::fmt::Debug for CustomDownstreamSticky {
2230 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2231 f.debug_struct("CustomDownstreamSticky")
2232 .field("seqnum", &self.event().seqnum())
2233 .field("running-time-offset", &self.event().running_time_offset())
2234 .field("structure", &self.event().structure())
2235 .finish()
2236 }
2237}
2238
2239impl std::fmt::Debug for CustomDownstreamSticky<Event> {
2240 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2241 CustomDownstreamSticky::<EventRef>::fmt(self, f)
2242 }
2243}
2244
2245declare_concrete_event!(CustomBoth, T);
2246impl CustomBoth<Event> {
2247 #[doc(alias = "gst_event_new_custom")]
2248 #[allow(clippy::new_ret_no_self)]
2249 pub fn new(structure: crate::Structure) -> Event {
2250 skip_assert_initialized!();
2251 Self::builder(structure).build()
2252 }
2253
2254 pub fn builder<'a>(structure: crate::Structure) -> CustomBothBuilder<'a> {
2255 assert_initialized_main_thread!();
2256 CustomBothBuilder::new(structure)
2257 }
2258}
2259
2260impl std::fmt::Debug for CustomBoth {
2261 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2262 f.debug_struct("CustomBoth")
2263 .field("seqnum", &self.event().seqnum())
2264 .field("running-time-offset", &self.event().running_time_offset())
2265 .field("structure", &self.event().structure())
2266 .finish()
2267 }
2268}
2269
2270impl std::fmt::Debug for CustomBoth<Event> {
2271 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2272 CustomBoth::<EventRef>::fmt(self, f)
2273 }
2274}
2275
2276declare_concrete_event!(CustomBothOob, T);
2277impl CustomBothOob<Event> {
2278 #[doc(alias = "gst_event_new_custom")]
2279 #[allow(clippy::new_ret_no_self)]
2280 pub fn new(structure: crate::Structure) -> Event {
2281 skip_assert_initialized!();
2282 Self::builder(structure).build()
2283 }
2284
2285 pub fn builder<'a>(structure: crate::Structure) -> CustomBothOobBuilder<'a> {
2286 assert_initialized_main_thread!();
2287 CustomBothOobBuilder::new(structure)
2288 }
2289}
2290
2291impl std::fmt::Debug for CustomBothOob {
2292 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2293 f.debug_struct("CustomBothOob")
2294 .field("seqnum", &self.event().seqnum())
2295 .field("running-time-offset", &self.event().running_time_offset())
2296 .field("structure", &self.event().structure())
2297 .finish()
2298 }
2299}
2300
2301impl std::fmt::Debug for CustomBothOob<Event> {
2302 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2303 CustomBothOob::<EventRef>::fmt(self, f)
2304 }
2305}
2306
2307declare_concrete_event!(Other, T);
2308
2309impl std::fmt::Debug for Other {
2310 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2311 f.debug_struct("Other")
2312 .field("seqnum", &self.event().seqnum())
2313 .field("running-time-offset", &self.event().running_time_offset())
2314 .field("structure", &self.event().structure())
2315 .finish()
2316 }
2317}
2318
2319impl std::fmt::Debug for Other<Event> {
2320 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2321 Other::<EventRef>::fmt(self, f)
2322 }
2323}
2324
2325struct EventBuilder<'a> {
2326 seqnum: Option<Seqnum>,
2327 running_time_offset: Option<i64>,
2328 other_fields: Vec<(&'a str, glib::SendValue)>,
2329}
2330
2331impl<'a> EventBuilder<'a> {
2332 fn new() -> Self {
2333 Self {
2334 seqnum: None,
2335 running_time_offset: None,
2336 other_fields: Vec::new(),
2337 }
2338 }
2339
2340 fn seqnum(self, seqnum: Seqnum) -> Self {
2341 Self {
2342 seqnum: Some(seqnum),
2343 ..self
2344 }
2345 }
2346
2347 fn running_time_offset(self, running_time_offset: i64) -> Self {
2348 Self {
2349 running_time_offset: Some(running_time_offset),
2350 ..self
2351 }
2352 }
2353
2354 fn other_field(self, name: &'a str, value: impl ToSendValue) -> Self {
2355 let mut other_fields = self.other_fields;
2356 other_fields.push((name, value.to_send_value()));
2357
2358 Self {
2359 other_fields,
2360 ..self
2361 }
2362 }
2363}
2364
2365macro_rules! event_builder_generic_impl {
2366 ($new_fn:expr) => {
2367 #[doc(alias = "gst_event_set_seqnum")]
2368 #[allow(clippy::needless_update)]
2369 pub fn seqnum(self, seqnum: Seqnum) -> Self {
2370 Self {
2371 builder: self.builder.seqnum(seqnum),
2372 ..self
2373 }
2374 }
2375
2376 #[doc(alias = "gst_event_set_seqnum")]
2377 #[allow(clippy::needless_update)]
2378 pub fn seqnum_if(self, seqnum: Seqnum, predicate: bool) -> Self {
2379 if predicate { self.seqnum(seqnum) } else { self }
2380 }
2381
2382 #[doc(alias = "gst_event_set_seqnum")]
2383 #[allow(clippy::needless_update)]
2384 pub fn seqnum_if_some(self, seqnum: Option<Seqnum>) -> Self {
2385 if let Some(seqnum) = seqnum {
2386 self.seqnum(seqnum)
2387 } else {
2388 self
2389 }
2390 }
2391
2392 #[doc(alias = "gst_event_set_running_time_offset")]
2393 #[allow(clippy::needless_update)]
2394 pub fn running_time_offset(self, running_time_offset: i64) -> Self {
2395 Self {
2396 builder: self.builder.running_time_offset(running_time_offset),
2397 ..self
2398 }
2399 }
2400
2401 #[doc(alias = "gst_event_set_running_time_offset")]
2402 #[allow(clippy::needless_update)]
2403 pub fn running_time_offset_if(self, running_time_offset: i64, predicate: bool) -> Self {
2404 if predicate {
2405 self.running_time_offset(running_time_offset)
2406 } else {
2407 self
2408 }
2409 }
2410
2411 #[doc(alias = "gst_event_set_running_time_offset")]
2412 #[allow(clippy::needless_update)]
2413 pub fn running_time_offset_if_some(self, running_time_offset: Option<i64>) -> Self {
2414 if let Some(running_time_offset) = running_time_offset {
2415 self.running_time_offset(running_time_offset)
2416 } else {
2417 self
2418 }
2419 }
2420
2421 #[allow(clippy::needless_update)]
2426 pub fn other_field(self, name: &'a str, value: impl ToSendValue) -> Self {
2427 Self {
2428 builder: self.builder.other_field(name, value),
2429 ..self
2430 }
2431 }
2432
2433 impl_builder_gvalue_extra_setters!(other_field);
2434
2435 #[must_use = "Building the event without using it has no effect"]
2436 #[allow(clippy::redundant_closure_call)]
2437 pub fn build(mut self) -> Event {
2438 unsafe {
2439 let event = $new_fn(&mut self);
2440 if let Some(seqnum) = self.builder.seqnum {
2441 ffi::gst_event_set_seqnum(event, seqnum.0.get());
2442 }
2443
2444 if let Some(running_time_offset) = self.builder.running_time_offset {
2445 ffi::gst_event_set_running_time_offset(event, running_time_offset);
2446 }
2447
2448 if !self.builder.other_fields.is_empty() {
2449 let s = StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure(
2450 event,
2451 ));
2452
2453 for (k, v) in self.builder.other_fields {
2454 s.set_value(k, v);
2455 }
2456 }
2457
2458 from_glib_full(event)
2459 }
2460 }
2461 };
2462}
2463
2464#[must_use = "The builder must be built to be used"]
2465pub struct FlushStartBuilder<'a> {
2466 builder: EventBuilder<'a>,
2467}
2468
2469impl<'a> FlushStartBuilder<'a> {
2470 fn new() -> Self {
2471 skip_assert_initialized!();
2472 Self {
2473 builder: EventBuilder::new(),
2474 }
2475 }
2476
2477 event_builder_generic_impl!(|_| { ffi::gst_event_new_flush_start() });
2478}
2479
2480#[must_use = "The builder must be built to be used"]
2481pub struct FlushStopBuilder<'a> {
2482 builder: EventBuilder<'a>,
2483 reset_time: bool,
2484}
2485impl<'a> FlushStopBuilder<'a> {
2486 fn new(reset_time: bool) -> Self {
2487 skip_assert_initialized!();
2488 Self {
2489 builder: EventBuilder::new(),
2490 reset_time,
2491 }
2492 }
2493
2494 event_builder_generic_impl!(|s: &Self| {
2495 ffi::gst_event_new_flush_stop(s.reset_time.into_glib())
2496 });
2497}
2498
2499#[must_use = "The builder must be built to be used"]
2500pub struct StreamStartBuilder<'a> {
2501 builder: EventBuilder<'a>,
2502 stream_id: &'a str,
2503 flags: Option<crate::StreamFlags>,
2504 group_id: Option<GroupId>,
2505 stream: Option<crate::Stream>,
2506}
2507
2508impl<'a> StreamStartBuilder<'a> {
2509 fn new(stream_id: &'a str) -> Self {
2510 skip_assert_initialized!();
2511 Self {
2512 builder: EventBuilder::new(),
2513 stream_id,
2514 flags: None,
2515 group_id: None,
2516 stream: None,
2517 }
2518 }
2519
2520 pub fn flags(self, flags: crate::StreamFlags) -> Self {
2521 Self {
2522 flags: Some(flags),
2523 ..self
2524 }
2525 }
2526
2527 pub fn flags_if(self, flags: crate::StreamFlags, predicate: bool) -> Self {
2528 if predicate { self.flags(flags) } else { self }
2529 }
2530
2531 pub fn flags_if_some(self, flags: Option<crate::StreamFlags>) -> Self {
2532 if let Some(flags) = flags {
2533 self.flags(flags)
2534 } else {
2535 self
2536 }
2537 }
2538
2539 pub fn group_id(self, group_id: GroupId) -> Self {
2540 Self {
2541 group_id: Some(group_id),
2542 ..self
2543 }
2544 }
2545
2546 pub fn group_id_if(self, group_id: GroupId, predicate: bool) -> Self {
2547 if predicate {
2548 self.group_id(group_id)
2549 } else {
2550 self
2551 }
2552 }
2553
2554 pub fn group_id_if_some(self, group_id: Option<GroupId>) -> Self {
2555 if let Some(group_id) = group_id {
2556 self.group_id(group_id)
2557 } else {
2558 self
2559 }
2560 }
2561
2562 pub fn stream(self, stream: crate::Stream) -> Self {
2563 Self {
2564 stream: Some(stream),
2565 ..self
2566 }
2567 }
2568
2569 pub fn stream_if(self, stream: crate::Stream, predicate: bool) -> Self {
2570 if predicate { self.stream(stream) } else { self }
2571 }
2572
2573 pub fn stream_if_some(self, stream: Option<crate::Stream>) -> Self {
2574 if let Some(stream) = stream {
2575 self.stream(stream)
2576 } else {
2577 self
2578 }
2579 }
2580
2581 event_builder_generic_impl!(|s: &Self| {
2582 let ev = ffi::gst_event_new_stream_start(s.stream_id.to_glib_none().0);
2583 if let Some(flags) = s.flags {
2584 ffi::gst_event_set_stream_flags(ev, flags.into_glib());
2585 }
2586 if let Some(group_id) = s.group_id {
2587 ffi::gst_event_set_group_id(ev, group_id.0.get());
2588 }
2589
2590 if let Some(ref stream) = s.stream {
2591 ffi::gst_event_set_stream(ev, stream.to_glib_none().0);
2592 }
2593
2594 ev
2595 });
2596}
2597
2598#[must_use = "The builder must be built to be used"]
2599pub struct CapsBuilder<'a> {
2600 builder: EventBuilder<'a>,
2601 caps: &'a crate::Caps,
2602}
2603
2604impl<'a> CapsBuilder<'a> {
2605 fn new(caps: &'a crate::Caps) -> Self {
2606 skip_assert_initialized!();
2607 Self {
2608 builder: EventBuilder::new(),
2609 caps,
2610 }
2611 }
2612
2613 event_builder_generic_impl!(|s: &Self| { ffi::gst_event_new_caps(s.caps.as_mut_ptr()) });
2614}
2615
2616#[must_use = "The builder must be built to be used"]
2617pub struct SegmentBuilder<'a> {
2618 builder: EventBuilder<'a>,
2619 segment: &'a crate::Segment,
2620}
2621
2622impl<'a> SegmentBuilder<'a> {
2623 fn new(segment: &'a crate::Segment) -> Self {
2624 skip_assert_initialized!();
2625 Self {
2626 builder: EventBuilder::new(),
2627 segment,
2628 }
2629 }
2630
2631 event_builder_generic_impl!(|s: &Self| {
2632 ffi::gst_event_new_segment(s.segment.to_glib_none().0)
2633 });
2634}
2635
2636#[must_use = "The builder must be built to be used"]
2637pub struct StreamCollectionBuilder<'a> {
2638 builder: EventBuilder<'a>,
2639 stream_collection: &'a crate::StreamCollection,
2640}
2641
2642impl<'a> StreamCollectionBuilder<'a> {
2643 fn new(stream_collection: &'a crate::StreamCollection) -> Self {
2644 skip_assert_initialized!();
2645 Self {
2646 builder: EventBuilder::new(),
2647 stream_collection,
2648 }
2649 }
2650
2651 event_builder_generic_impl!(|s: &Self| {
2652 ffi::gst_event_new_stream_collection(s.stream_collection.to_glib_none().0)
2653 });
2654}
2655
2656#[cfg(feature = "v1_18")]
2657#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2658#[must_use = "The builder must be built to be used"]
2659pub struct InstantRateSyncTimeBuilder<'a> {
2660 builder: EventBuilder<'a>,
2661 rate_multiplier: f64,
2662 running_time: ClockTime,
2663 upstream_running_time: ClockTime,
2664}
2665
2666#[cfg(feature = "v1_18")]
2667#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2668impl<'a> InstantRateSyncTimeBuilder<'a> {
2669 fn new(
2670 rate_multiplier: f64,
2671 running_time: ClockTime,
2672 upstream_running_time: ClockTime,
2673 ) -> Self {
2674 skip_assert_initialized!();
2675 Self {
2676 builder: EventBuilder::new(),
2677 rate_multiplier,
2678 running_time,
2679 upstream_running_time,
2680 }
2681 }
2682
2683 event_builder_generic_impl!(|s: &Self| {
2684 ffi::gst_event_new_instant_rate_sync_time(
2685 s.rate_multiplier,
2686 s.running_time.into_glib(),
2687 s.upstream_running_time.into_glib(),
2688 )
2689 });
2690}
2691
2692#[must_use = "The builder must be built to be used"]
2693pub struct TagBuilder<'a> {
2694 builder: EventBuilder<'a>,
2695 tags: Option<crate::TagList>,
2696}
2697
2698impl<'a> TagBuilder<'a> {
2699 fn new(tags: crate::TagList) -> Self {
2700 skip_assert_initialized!();
2701 Self {
2702 builder: EventBuilder::new(),
2703 tags: Some(tags),
2704 }
2705 }
2706
2707 event_builder_generic_impl!(|s: &mut Self| {
2708 let tags = s.tags.take().unwrap();
2709 ffi::gst_event_new_tag(tags.into_glib_ptr())
2710 });
2711}
2712
2713#[must_use = "The builder must be built to be used"]
2714pub struct BuffersizeBuilder<'a> {
2715 builder: EventBuilder<'a>,
2716 minsize: GenericFormattedValue,
2717 maxsize: GenericFormattedValue,
2718 r#async: bool,
2719}
2720
2721impl<'a> BuffersizeBuilder<'a> {
2722 fn new(minsize: GenericFormattedValue, maxsize: GenericFormattedValue, r#async: bool) -> Self {
2723 skip_assert_initialized!();
2724 Self {
2725 builder: EventBuilder::new(),
2726 minsize,
2727 maxsize,
2728 r#async,
2729 }
2730 }
2731
2732 event_builder_generic_impl!(|s: &Self| {
2733 ffi::gst_event_new_buffer_size(
2734 s.minsize.format().into_glib(),
2735 s.minsize.value(),
2736 s.maxsize.value(),
2737 s.r#async.into_glib(),
2738 )
2739 });
2740}
2741
2742#[must_use = "The builder must be built to be used"]
2743pub struct SinkMessageBuilder<'a> {
2744 builder: EventBuilder<'a>,
2745 name: &'a str,
2746 msg: &'a crate::Message,
2747}
2748
2749impl<'a> SinkMessageBuilder<'a> {
2750 fn new(name: &'a str, msg: &'a crate::Message) -> Self {
2751 skip_assert_initialized!();
2752 Self {
2753 builder: EventBuilder::new(),
2754 name,
2755 msg,
2756 }
2757 }
2758
2759 event_builder_generic_impl!(|s: &Self| {
2760 ffi::gst_event_new_sink_message(s.name.to_glib_none().0, s.msg.as_mut_ptr())
2761 });
2762}
2763
2764#[must_use = "The builder must be built to be used"]
2765pub struct StreamGroupDoneBuilder<'a> {
2766 builder: EventBuilder<'a>,
2767 group_id: GroupId,
2768}
2769
2770impl<'a> StreamGroupDoneBuilder<'a> {
2771 fn new(group_id: GroupId) -> Self {
2772 skip_assert_initialized!();
2773 Self {
2774 builder: EventBuilder::new(),
2775 group_id,
2776 }
2777 }
2778
2779 event_builder_generic_impl!(|s: &Self| {
2780 ffi::gst_event_new_stream_group_done(s.group_id.0.get())
2781 });
2782}
2783
2784#[must_use = "The builder must be built to be used"]
2785pub struct EosBuilder<'a> {
2786 builder: EventBuilder<'a>,
2787}
2788
2789impl<'a> EosBuilder<'a> {
2790 fn new() -> Self {
2791 skip_assert_initialized!();
2792 Self {
2793 builder: EventBuilder::new(),
2794 }
2795 }
2796
2797 event_builder_generic_impl!(|_| ffi::gst_event_new_eos());
2798}
2799
2800#[must_use = "The builder must be built to be used"]
2801pub struct TocBuilder<'a> {
2802 builder: EventBuilder<'a>,
2803 toc: &'a crate::Toc,
2804 updated: bool,
2805}
2806
2807impl<'a> TocBuilder<'a> {
2808 fn new(toc: &'a crate::Toc, updated: bool) -> Self {
2809 skip_assert_initialized!();
2810 Self {
2811 builder: EventBuilder::new(),
2812 toc,
2813 updated,
2814 }
2815 }
2816
2817 event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc(
2818 s.toc.to_glib_none().0,
2819 s.updated.into_glib()
2820 ));
2821}
2822
2823#[must_use = "The builder must be built to be used"]
2824pub struct ProtectionBuilder<'a> {
2825 builder: EventBuilder<'a>,
2826 system_id: &'a str,
2827 data: &'a crate::Buffer,
2828 origin: Option<&'a str>,
2829}
2830
2831impl<'a> ProtectionBuilder<'a> {
2832 fn new(system_id: &'a str, data: &'a crate::Buffer) -> Self {
2833 skip_assert_initialized!();
2834 Self {
2835 builder: EventBuilder::new(),
2836 system_id,
2837 data,
2838 origin: None,
2839 }
2840 }
2841
2842 pub fn origin(self, origin: &'a str) -> Self {
2843 Self {
2844 origin: Some(origin),
2845 ..self
2846 }
2847 }
2848
2849 pub fn origin_if(self, origin: &'a str, predicate: bool) -> Self {
2850 if predicate { self.origin(origin) } else { self }
2851 }
2852
2853 pub fn origin_if_some(self, origin: Option<&'a str>) -> Self {
2854 if let Some(origin) = origin {
2855 self.origin(origin)
2856 } else {
2857 self
2858 }
2859 }
2860
2861 event_builder_generic_impl!(|s: &Self| {
2862 ffi::gst_event_new_protection(
2863 s.system_id.to_glib_none().0,
2864 s.data.as_mut_ptr(),
2865 s.origin.to_glib_none().0,
2866 )
2867 });
2868}
2869
2870#[must_use = "The builder must be built to be used"]
2871pub struct SegmentDoneBuilder<'a> {
2872 builder: EventBuilder<'a>,
2873 position: GenericFormattedValue,
2874}
2875
2876impl<'a> SegmentDoneBuilder<'a> {
2877 fn new(position: GenericFormattedValue) -> Self {
2878 skip_assert_initialized!();
2879 Self {
2880 builder: EventBuilder::new(),
2881 position,
2882 }
2883 }
2884
2885 event_builder_generic_impl!(|s: &Self| {
2886 ffi::gst_event_new_segment_done(s.position.format().into_glib(), s.position.value())
2887 });
2888}
2889
2890#[must_use = "The builder must be built to be used"]
2891pub struct GapBuilder<'a> {
2892 builder: EventBuilder<'a>,
2893 timestamp: ClockTime,
2894 duration: Option<ClockTime>,
2895 #[cfg(feature = "v1_20")]
2896 gap_flags: Option<crate::GapFlags>,
2897}
2898
2899impl<'a> GapBuilder<'a> {
2900 fn new(timestamp: ClockTime) -> Self {
2901 skip_assert_initialized!();
2902 Self {
2903 builder: EventBuilder::new(),
2904 timestamp,
2905 duration: None,
2906 #[cfg(feature = "v1_20")]
2907 gap_flags: None,
2908 }
2909 }
2910
2911 #[cfg(feature = "v1_20")]
2912 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
2913 pub fn gap_flags(mut self, flags: crate::GapFlags) -> Self {
2914 self.gap_flags = Some(flags);
2915 self
2916 }
2917
2918 #[cfg(feature = "v1_20")]
2919 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
2920 pub fn gap_flags_if(self, flags: crate::GapFlags, predicate: bool) -> Self {
2921 if predicate {
2922 self.gap_flags(flags)
2923 } else {
2924 self
2925 }
2926 }
2927
2928 #[cfg(feature = "v1_20")]
2929 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
2930 pub fn gap_flags_if_some(self, flags: Option<crate::GapFlags>) -> Self {
2931 if let Some(flags) = flags {
2932 self.gap_flags(flags)
2933 } else {
2934 self
2935 }
2936 }
2937
2938 pub fn duration(mut self, duration: impl Into<Option<ClockTime>>) -> Self {
2939 self.duration = duration.into();
2940 self
2941 }
2942
2943 pub fn duration_if(self, duration: ClockTime, predicate: bool) -> Self {
2944 if predicate {
2945 self.duration(duration)
2946 } else {
2947 self
2948 }
2949 }
2950
2951 pub fn duration_if_some(self, duration: Option<ClockTime>) -> Self {
2952 if let Some(duration) = duration {
2953 self.duration(duration)
2954 } else {
2955 self
2956 }
2957 }
2958
2959 event_builder_generic_impl!(|s: &Self| {
2960 #[allow(clippy::let_and_return)]
2961 let ev = ffi::gst_event_new_gap(s.timestamp.into_glib(), s.duration.into_glib());
2962
2963 #[cfg(feature = "v1_20")]
2964 if let Some(ref flags) = s.gap_flags {
2965 ffi::gst_event_set_gap_flags(ev, flags.into_glib());
2966 }
2967
2968 ev
2969 });
2970}
2971
2972#[cfg(feature = "v1_18")]
2973#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2974#[must_use = "The builder must be built to be used"]
2975pub struct InstantRateChangeBuilder<'a> {
2976 builder: EventBuilder<'a>,
2977 multiplier: f64,
2978 new_flags: crate::SegmentFlags,
2979}
2980
2981#[cfg(feature = "v1_18")]
2982#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2983impl<'a> InstantRateChangeBuilder<'a> {
2984 fn new(multiplier: f64, new_flags: crate::SegmentFlags) -> Self {
2985 skip_assert_initialized!();
2986 Self {
2987 builder: EventBuilder::new(),
2988 multiplier,
2989 new_flags,
2990 }
2991 }
2992
2993 event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_instant_rate_change(
2994 s.multiplier,
2995 s.new_flags.into_glib()
2996 ));
2997}
2998
2999#[must_use = "The builder must be built to be used"]
3000pub struct QosBuilder<'a> {
3001 builder: EventBuilder<'a>,
3002 type_: crate::QOSType,
3003 proportion: f64,
3004 diff: i64,
3005 timestamp: Option<ClockTime>,
3006}
3007
3008impl<'a> QosBuilder<'a> {
3009 fn new(type_: crate::QOSType, proportion: f64, diff: i64) -> Self {
3010 skip_assert_initialized!();
3011 Self {
3012 builder: EventBuilder::new(),
3013 type_,
3014 proportion,
3015 diff,
3016 timestamp: None,
3017 }
3018 }
3019
3020 pub fn timestamp(mut self, timestamp: impl Into<Option<ClockTime>>) -> Self {
3021 self.timestamp = timestamp.into();
3022 self
3023 }
3024
3025 pub fn timestamp_if(self, timestamp: ClockTime, predicate: bool) -> Self {
3026 if predicate {
3027 self.timestamp(timestamp)
3028 } else {
3029 self
3030 }
3031 }
3032
3033 pub fn timestamp_if_some(self, timestamp: Option<ClockTime>) -> Self {
3034 if let Some(timestamp) = timestamp {
3035 self.timestamp(timestamp)
3036 } else {
3037 self
3038 }
3039 }
3040
3041 event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(
3042 s.type_.into_glib(),
3043 s.proportion,
3044 s.diff,
3045 s.timestamp.into_glib(),
3046 ));
3047}
3048
3049#[must_use = "The builder must be built to be used"]
3050pub struct SeekBuilder<'a> {
3051 builder: EventBuilder<'a>,
3052 rate: f64,
3053 flags: crate::SeekFlags,
3054 start_type: crate::SeekType,
3055 start: GenericFormattedValue,
3056 stop_type: crate::SeekType,
3057 stop: GenericFormattedValue,
3058 #[allow(unused)]
3059 trickmode_interval: Option<ClockTime>,
3060}
3061
3062impl<'a> SeekBuilder<'a> {
3063 fn new(
3064 rate: f64,
3065 flags: crate::SeekFlags,
3066 start_type: crate::SeekType,
3067 start: GenericFormattedValue,
3068 stop_type: crate::SeekType,
3069 stop: GenericFormattedValue,
3070 ) -> Self {
3071 skip_assert_initialized!();
3072 Self {
3073 builder: EventBuilder::new(),
3074 rate,
3075 flags,
3076 start_type,
3077 start,
3078 stop_type,
3079 stop,
3080 trickmode_interval: None,
3081 }
3082 }
3083
3084 pub fn trickmode_interval(mut self, trickmode_interval: impl Into<Option<ClockTime>>) -> Self {
3085 self.trickmode_interval = trickmode_interval.into();
3086 self
3087 }
3088
3089 event_builder_generic_impl!(|s: &Self| {
3090 #[allow(clippy::let_and_return)]
3091 {
3092 let ev = ffi::gst_event_new_seek(
3093 s.rate,
3094 s.start.format().into_glib(),
3095 s.flags.into_glib(),
3096 s.start_type.into_glib(),
3097 s.start.value(),
3098 s.stop_type.into_glib(),
3099 s.stop.value(),
3100 );
3101
3102 #[cfg(feature = "v1_16")]
3103 if let Some(trickmode_interval) = s.trickmode_interval {
3104 ffi::gst_event_set_seek_trickmode_interval(ev, trickmode_interval.into_glib());
3105 }
3106
3107 ev
3108 }
3109 });
3110}
3111
3112#[must_use = "The builder must be built to be used"]
3113pub struct NavigationBuilder<'a> {
3114 builder: EventBuilder<'a>,
3115 structure: Option<Structure>,
3116}
3117
3118impl<'a> NavigationBuilder<'a> {
3119 fn new(structure: Structure) -> Self {
3120 skip_assert_initialized!();
3121 Self {
3122 builder: EventBuilder::new(),
3123 structure: Some(structure),
3124 }
3125 }
3126
3127 event_builder_generic_impl!(|s: &mut Self| {
3128 let structure = s.structure.take().unwrap();
3129 ffi::gst_event_new_navigation(structure.into_glib_ptr())
3130 });
3131}
3132
3133#[must_use = "The builder must be built to be used"]
3134pub struct LatencyBuilder<'a> {
3135 builder: EventBuilder<'a>,
3136 latency: ClockTime,
3137}
3138
3139impl<'a> LatencyBuilder<'a> {
3140 fn new(latency: ClockTime) -> Self {
3141 skip_assert_initialized!();
3142 Self {
3143 builder: EventBuilder::new(),
3144 latency,
3145 }
3146 }
3147
3148 event_builder_generic_impl!(|s: &Self| { ffi::gst_event_new_latency(s.latency.into_glib()) });
3149}
3150
3151#[must_use = "The builder must be built to be used"]
3152pub struct StepBuilder<'a> {
3153 builder: EventBuilder<'a>,
3154 amount: GenericFormattedValue,
3155 rate: f64,
3156 flush: bool,
3157 intermediate: bool,
3158}
3159
3160impl<'a> StepBuilder<'a> {
3161 fn new(amount: GenericFormattedValue, rate: f64, flush: bool, intermediate: bool) -> Self {
3162 skip_assert_initialized!();
3163 Self {
3164 builder: EventBuilder::new(),
3165 amount,
3166 rate,
3167 flush,
3168 intermediate,
3169 }
3170 }
3171
3172 event_builder_generic_impl!(|s: &Self| {
3173 ffi::gst_event_new_step(
3174 s.amount.format().into_glib(),
3175 s.amount.value() as u64,
3176 s.rate,
3177 s.flush.into_glib(),
3178 s.intermediate.into_glib(),
3179 )
3180 });
3181}
3182
3183#[must_use = "The builder must be built to be used"]
3184pub struct ReconfigureBuilder<'a> {
3185 builder: EventBuilder<'a>,
3186}
3187
3188impl<'a> ReconfigureBuilder<'a> {
3189 fn new() -> Self {
3190 skip_assert_initialized!();
3191 Self {
3192 builder: EventBuilder::new(),
3193 }
3194 }
3195
3196 event_builder_generic_impl!(|_| { ffi::gst_event_new_reconfigure() });
3197}
3198
3199#[must_use = "The builder must be built to be used"]
3200pub struct TocSelectBuilder<'a> {
3201 builder: EventBuilder<'a>,
3202 uid: &'a str,
3203}
3204
3205impl<'a> TocSelectBuilder<'a> {
3206 fn new(uid: &'a str) -> Self {
3207 skip_assert_initialized!();
3208 Self {
3209 builder: EventBuilder::new(),
3210 uid,
3211 }
3212 }
3213
3214 event_builder_generic_impl!(|s: &Self| {
3215 ffi::gst_event_new_toc_select(s.uid.to_glib_none().0)
3216 });
3217}
3218
3219#[must_use = "The builder must be built to be used"]
3220pub struct SelectStreamsBuilder<'a> {
3221 builder: EventBuilder<'a>,
3222 streams: glib::collections::List<glib::GStringPtr>,
3223}
3224
3225impl<'a> SelectStreamsBuilder<'a> {
3226 fn new(streams: impl IntoIterator<Item = &'a str>) -> Self {
3227 skip_assert_initialized!();
3228 Self {
3229 builder: EventBuilder::new(),
3230 streams: streams.into_iter().map(glib::GStringPtr::from).collect(),
3231 }
3232 }
3233
3234 event_builder_generic_impl!(|s: &Self| {
3235 ffi::gst_event_new_select_streams(mut_override(s.streams.as_ptr()))
3236 });
3237}
3238
3239#[must_use = "The builder must be built to be used"]
3240pub struct CustomUpstreamBuilder<'a> {
3241 builder: EventBuilder<'a>,
3242 structure: Option<Structure>,
3243}
3244
3245impl<'a> CustomUpstreamBuilder<'a> {
3246 fn new(structure: Structure) -> Self {
3247 skip_assert_initialized!();
3248 Self {
3249 builder: EventBuilder::new(),
3250 structure: Some(structure),
3251 }
3252 }
3253
3254 event_builder_generic_impl!(|s: &mut Self| {
3255 let structure = s.structure.take().unwrap();
3256 ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.into_glib_ptr())
3257 });
3258}
3259
3260#[must_use = "The builder must be built to be used"]
3261pub struct CustomDownstreamBuilder<'a> {
3262 builder: EventBuilder<'a>,
3263 structure: Option<Structure>,
3264}
3265
3266impl<'a> CustomDownstreamBuilder<'a> {
3267 fn new(structure: Structure) -> Self {
3268 skip_assert_initialized!();
3269 Self {
3270 builder: EventBuilder::new(),
3271 structure: Some(structure),
3272 }
3273 }
3274
3275 event_builder_generic_impl!(|s: &mut Self| {
3276 let structure = s.structure.take().unwrap();
3277 ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_glib_ptr())
3278 });
3279}
3280
3281#[must_use = "The builder must be built to be used"]
3282pub struct CustomDownstreamOobBuilder<'a> {
3283 builder: EventBuilder<'a>,
3284 structure: Option<Structure>,
3285}
3286
3287impl<'a> CustomDownstreamOobBuilder<'a> {
3288 fn new(structure: Structure) -> Self {
3289 skip_assert_initialized!();
3290 Self {
3291 builder: EventBuilder::new(),
3292 structure: Some(structure),
3293 }
3294 }
3295
3296 event_builder_generic_impl!(|s: &mut Self| {
3297 let structure = s.structure.take().unwrap();
3298 ffi::gst_event_new_custom(
3299 ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB,
3300 structure.into_glib_ptr(),
3301 )
3302 });
3303}
3304
3305#[must_use = "The builder must be built to be used"]
3306pub struct CustomDownstreamStickyBuilder<'a> {
3307 builder: EventBuilder<'a>,
3308 structure: Option<Structure>,
3309}
3310
3311impl<'a> CustomDownstreamStickyBuilder<'a> {
3312 fn new(structure: Structure) -> Self {
3313 skip_assert_initialized!();
3314 Self {
3315 builder: EventBuilder::new(),
3316 structure: Some(structure),
3317 }
3318 }
3319
3320 event_builder_generic_impl!(|s: &mut Self| {
3321 let structure = s.structure.take().unwrap();
3322 ffi::gst_event_new_custom(
3323 ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY,
3324 structure.into_glib_ptr(),
3325 )
3326 });
3327}
3328
3329#[must_use = "The builder must be built to be used"]
3330pub struct CustomBothBuilder<'a> {
3331 builder: EventBuilder<'a>,
3332 structure: Option<Structure>,
3333}
3334
3335impl<'a> CustomBothBuilder<'a> {
3336 fn new(structure: Structure) -> Self {
3337 skip_assert_initialized!();
3338 Self {
3339 builder: EventBuilder::new(),
3340 structure: Some(structure),
3341 }
3342 }
3343
3344 event_builder_generic_impl!(|s: &mut Self| {
3345 let structure = s.structure.take().unwrap();
3346 ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH, structure.into_glib_ptr())
3347 });
3348}
3349
3350#[must_use = "The builder must be built to be used"]
3351pub struct CustomBothOobBuilder<'a> {
3352 builder: EventBuilder<'a>,
3353 structure: Option<Structure>,
3354}
3355
3356impl<'a> CustomBothOobBuilder<'a> {
3357 fn new(structure: Structure) -> Self {
3358 skip_assert_initialized!();
3359 Self {
3360 builder: EventBuilder::new(),
3361 structure: Some(structure),
3362 }
3363 }
3364
3365 event_builder_generic_impl!(|s: &mut Self| {
3366 let structure = s.structure.take().unwrap();
3367 ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_glib_ptr())
3368 });
3369}
3370
3371#[cfg(test)]
3372mod tests {
3373 use super::*;
3374
3375 #[test]
3376 #[allow(deprecated)]
3377 fn test_simple() {
3378 crate::init().unwrap();
3379
3380 let flush_start_evt = FlushStart::new();
3382 match flush_start_evt.view() {
3383 EventView::FlushStart(flush_start_evt) => {
3384 assert!(!flush_start_evt.is_sticky());
3385 assert!(flush_start_evt.structure().is_none());
3386 }
3387 _ => panic!("flush_start_evt.view() is not an EventView::FlushStart(_)"),
3388 }
3389
3390 let flush_start_evt = FlushStart::builder()
3391 .other_field("extra-field", true)
3392 .build();
3393 match flush_start_evt.view() {
3394 EventView::FlushStart(flush_start_evt) => {
3395 assert!(flush_start_evt.structure().is_some());
3396 if let Some(other_fields) = flush_start_evt.structure() {
3397 assert!(other_fields.has_field("extra-field"));
3398 }
3399 }
3400 _ => panic!("flush_start_evt.view() is not an EventView::FlushStart(_)"),
3401 }
3402
3403 let flush_stop_evt = FlushStop::builder(true)
3405 .other_field("extra-field", true)
3406 .build();
3407 match flush_stop_evt.view() {
3408 EventView::FlushStop(flush_stop_evt) => {
3409 assert!(flush_stop_evt.resets_time());
3410 assert!(flush_stop_evt.structure().is_some());
3411 if let Some(other_fields) = flush_stop_evt.structure() {
3412 assert!(other_fields.has_field("extra-field"));
3413 }
3414 }
3415 _ => panic!("flush_stop_evt.view() is not an EventView::FlushStop(_)"),
3416 }
3417 }
3418
3419 #[test]
3420 fn test_get_structure_mut() {
3421 crate::init().unwrap();
3422
3423 let mut flush_start_evt = FlushStart::new();
3424
3425 {
3426 let flush_start_evt = flush_start_evt.get_mut().unwrap();
3427 let structure = flush_start_evt.structure_mut();
3428 structure.set("test", 42u32);
3429 }
3430
3431 let structure = flush_start_evt.structure().unwrap();
3432 assert_eq!(structure.get("test"), Ok(42u32));
3433 }
3434
3435 #[test]
3436 fn test_view_lifetimes() {
3437 crate::init().unwrap();
3438
3439 let caps = crate::Caps::builder("some/x-caps").build();
3440 let event = crate::event::Caps::new(&caps);
3441
3442 let caps2 = match event.view() {
3443 EventView::Caps(caps) => caps.caps(),
3444 _ => unreachable!(),
3445 };
3446
3447 assert_eq!(&*caps, caps2);
3448 }
3449
3450 #[test]
3451 fn test_select_streams() {
3452 crate::init().unwrap();
3453
3454 let s = ["foo", "bar"].to_vec();
3455 let event = crate::event::SelectStreams::new(s.iter().copied());
3456 let streams = match event.view() {
3457 EventView::SelectStreams(streams) => streams.streams(),
3458 _ => unreachable!(),
3459 };
3460 assert_eq!(streams.iter().collect::<Vec<_>>(), s);
3461 }
3462}