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