1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::{borrow::Borrow, ffi::CStr, fmt, mem, num::NonZeroU32, ops::Deref, ptr};
4
5use glib::translate::*;
6
7use crate::{
8 format::{CompatibleFormattedValue, FormattedValue},
9 prelude::*,
10 structure::*,
11 GenericFormattedValue, GroupId, MessageType, Object, Seqnum, TagList,
12};
13
14mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || {
15 ffi::gst_message_get_type()
16});
17
18impl MessageRef {
19 #[doc(alias = "get_src")]
20 #[inline]
21 pub fn src(&self) -> Option<&Object> {
22 unsafe {
23 if (*self.as_ptr()).src.is_null() {
24 None
25 } else {
26 Some(&*(&(*self.as_ptr()).src as *const *mut ffi::GstObject as *const Object))
27 }
28 }
29 }
30
31 #[doc(alias = "get_seqnum")]
32 #[doc(alias = "gst_message_get_seqnum")]
33 pub fn seqnum(&self) -> Seqnum {
34 unsafe {
35 let seqnum = ffi::gst_message_get_seqnum(self.as_mut_ptr());
36
37 if seqnum == 0 {
38 // seqnum for this message is invalid. This can happen with buggy elements
39 // overriding the seqnum with GST_SEQNUM_INVALID instead of the expected seqnum.
40 // As a workaround, let's generate an unused valid seqnum.
41 let next = Seqnum::next();
42
43 crate::warning!(
44 crate::CAT_RUST,
45 "get_seqnum detected invalid seqnum, returning next {:?}",
46 next
47 );
48
49 return next;
50 }
51
52 Seqnum(NonZeroU32::new_unchecked(seqnum))
53 }
54 }
55
56 #[doc(alias = "get_structure")]
57 #[doc(alias = "gst_message_get_structure")]
58 #[inline]
59 pub fn structure(&self) -> Option<&StructureRef> {
60 unsafe {
61 let structure = ffi::gst_message_get_structure(self.as_mut_ptr());
62 if structure.is_null() {
63 None
64 } else {
65 Some(StructureRef::from_glib_borrow(structure))
66 }
67 }
68 }
69
70 #[doc(alias = "gst_message_writable_structure")]
71 #[inline]
72 pub fn structure_mut(&mut self) -> &mut StructureRef {
73 unsafe {
74 StructureRef::from_glib_borrow_mut(ffi::gst_message_writable_structure(
75 self.as_mut_ptr(),
76 ))
77 }
78 }
79
80 #[doc(alias = "gst_message_has_name")]
81 #[inline]
82 pub fn has_name(&self, name: &str) -> bool {
83 self.structure().map_or(false, |s| s.has_name(name))
84 }
85
86 pub fn view(&self) -> MessageView {
87 unsafe {
88 let type_ = (*self.as_ptr()).type_;
89
90 match type_ {
91 ffi::GST_MESSAGE_EOS => Eos::view(self),
92 ffi::GST_MESSAGE_ERROR => Error::view(self),
93 ffi::GST_MESSAGE_WARNING => Warning::view(self),
94 ffi::GST_MESSAGE_INFO => Info::view(self),
95 ffi::GST_MESSAGE_TAG => Tag::view(self),
96 ffi::GST_MESSAGE_BUFFERING => Buffering::view(self),
97 ffi::GST_MESSAGE_STATE_CHANGED => StateChanged::view(self),
98 ffi::GST_MESSAGE_STATE_DIRTY => StateDirty::view(self),
99 ffi::GST_MESSAGE_STEP_DONE => StepDone::view(self),
100 ffi::GST_MESSAGE_CLOCK_PROVIDE => ClockProvide::view(self),
101 ffi::GST_MESSAGE_CLOCK_LOST => ClockLost::view(self),
102 ffi::GST_MESSAGE_NEW_CLOCK => NewClock::view(self),
103 ffi::GST_MESSAGE_STRUCTURE_CHANGE => StructureChange::view(self),
104 ffi::GST_MESSAGE_STREAM_STATUS => StreamStatus::view(self),
105 ffi::GST_MESSAGE_APPLICATION => Application::view(self),
106 ffi::GST_MESSAGE_ELEMENT => Element::view(self),
107 ffi::GST_MESSAGE_SEGMENT_START => SegmentStart::view(self),
108 ffi::GST_MESSAGE_SEGMENT_DONE => SegmentDone::view(self),
109 ffi::GST_MESSAGE_DURATION_CHANGED => DurationChanged::view(self),
110 ffi::GST_MESSAGE_LATENCY => Latency::view(self),
111 ffi::GST_MESSAGE_ASYNC_START => AsyncStart::view(self),
112 ffi::GST_MESSAGE_ASYNC_DONE => AsyncDone::view(self),
113 ffi::GST_MESSAGE_REQUEST_STATE => RequestState::view(self),
114 ffi::GST_MESSAGE_STEP_START => StepStart::view(self),
115 ffi::GST_MESSAGE_QOS => Qos::view(self),
116 ffi::GST_MESSAGE_PROGRESS => Progress::view(self),
117 ffi::GST_MESSAGE_TOC => Toc::view(self),
118 ffi::GST_MESSAGE_RESET_TIME => ResetTime::view(self),
119 ffi::GST_MESSAGE_STREAM_START => StreamStart::view(self),
120 ffi::GST_MESSAGE_NEED_CONTEXT => NeedContext::view(self),
121 ffi::GST_MESSAGE_HAVE_CONTEXT => HaveContext::view(self),
122 ffi::GST_MESSAGE_DEVICE_ADDED => DeviceAdded::view(self),
123 ffi::GST_MESSAGE_DEVICE_REMOVED => DeviceRemoved::view(self),
124 ffi::GST_MESSAGE_REDIRECT => Redirect::view(self),
125 ffi::GST_MESSAGE_PROPERTY_NOTIFY => PropertyNotify::view(self),
126 ffi::GST_MESSAGE_STREAM_COLLECTION => StreamCollection::view(self),
127 ffi::GST_MESSAGE_STREAMS_SELECTED => StreamsSelected::view(self),
128 #[cfg(feature = "v1_16")]
129 ffi::GST_MESSAGE_DEVICE_CHANGED => DeviceChanged::view(self),
130 #[cfg(feature = "v1_18")]
131 ffi::GST_MESSAGE_INSTANT_RATE_REQUEST => InstantRateRequest::view(self),
132 _ => MessageView::Other,
133 }
134 }
135 }
136
137 #[doc(alias = "get_type")]
138 #[inline]
139 pub fn type_(&self) -> MessageType {
140 unsafe { from_glib((*self.as_ptr()).type_) }
141 }
142}
143
144impl fmt::Debug for Message {
145 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
146 MessageRef::fmt(self, f)
147 }
148}
149
150impl fmt::Debug for MessageRef {
151 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
152 // Don't retrieve `seqnum` using `MessageRef::get_seqnum`
153 // because it would generate a new seqnum if a buggy `Element`
154 // emitted a `Message` with an invalid `seqnum`.
155 // We want to help the user find out there is something wrong here,
156 // so they can investigate the origin.
157 let seqnum = unsafe { ffi::gst_message_get_seqnum(self.as_mut_ptr()) };
158 let seqnum = if seqnum != 0 {
159 &seqnum as &dyn fmt::Debug
160 } else {
161 &"INVALID (0)" as &dyn fmt::Debug
162 };
163
164 f.debug_struct("Message")
165 .field("ptr", &self.as_ptr())
166 .field("type", &unsafe {
167 let type_ = ffi::gst_message_type_get_name((*self.as_ptr()).type_);
168 CStr::from_ptr(type_).to_str().unwrap()
169 })
170 .field("seqnum", seqnum)
171 .field(
172 "src",
173 &self
174 .src()
175 .map(|s| s.name())
176 .as_ref()
177 .map(glib::GString::as_str),
178 )
179 .field("structure", &self.structure())
180 .finish()
181 }
182}
183
184#[derive(Debug)]
185#[non_exhaustive]
186pub enum MessageView<'a> {
187 Eos(&'a Eos),
188 Error(&'a Error),
189 Warning(&'a Warning),
190 Info(&'a Info),
191 Tag(&'a Tag),
192 Buffering(&'a Buffering),
193 StateChanged(&'a StateChanged),
194 StateDirty(&'a StateDirty),
195 StepDone(&'a StepDone),
196 ClockProvide(&'a ClockProvide),
197 ClockLost(&'a ClockLost),
198 NewClock(&'a NewClock),
199 StructureChange(&'a StructureChange),
200 StreamStatus(&'a StreamStatus),
201 Application(&'a Application),
202 Element(&'a Element),
203 SegmentStart(&'a SegmentStart),
204 SegmentDone(&'a SegmentDone),
205 DurationChanged(&'a DurationChanged),
206 Latency(&'a Latency),
207 AsyncStart(&'a AsyncStart),
208 AsyncDone(&'a AsyncDone),
209 RequestState(&'a RequestState),
210 StepStart(&'a StepStart),
211 Qos(&'a Qos),
212 Progress(&'a Progress),
213 Toc(&'a Toc),
214 ResetTime(&'a ResetTime),
215 StreamStart(&'a StreamStart),
216 NeedContext(&'a NeedContext),
217 HaveContext(&'a HaveContext),
218 DeviceAdded(&'a DeviceAdded),
219 DeviceRemoved(&'a DeviceRemoved),
220 PropertyNotify(&'a PropertyNotify),
221 StreamCollection(&'a StreamCollection),
222 StreamsSelected(&'a StreamsSelected),
223 Redirect(&'a Redirect),
224 #[cfg(feature = "v1_16")]
225 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
226 DeviceChanged(&'a DeviceChanged),
227 #[cfg(feature = "v1_18")]
228 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
229 InstantRateRequest(&'a InstantRateRequest),
230 Other,
231}
232
233macro_rules! declare_concrete_message(
234 ($name:ident, $param:ident) => {
235 #[repr(transparent)]
236 pub struct $name<$param = MessageRef>($param);
237
238 impl $name {
239 #[inline]
240 pub fn message(&self) -> &MessageRef {
241 unsafe { &*(self as *const Self as *const MessageRef) }
242 }
243
244 #[inline]
245 unsafe fn view(message: &MessageRef) -> MessageView<'_> {
246 let message = &*(message as *const MessageRef as *const Self);
247 MessageView::$name(message)
248 }
249 }
250
251 impl Deref for $name {
252 type Target = MessageRef;
253
254 #[inline]
255 fn deref(&self) -> &Self::Target {
256 unsafe {
257 &*(self as *const Self as *const Self::Target)
258 }
259 }
260 }
261
262 impl ToOwned for $name {
263 type Owned = $name<Message>;
264
265 #[inline]
266 fn to_owned(&self) -> Self::Owned {
267 $name::<Message>(self.copy())
268 }
269 }
270
271 impl $name<Message> {
272 #[inline]
273 pub fn get_mut(&mut self) -> Option<&mut $name> {
274 self.0.get_mut().map(|message| unsafe {
275 &mut *(message as *mut MessageRef as *mut $name)
276 })
277 }
278 }
279
280 impl Deref for $name<Message> {
281 type Target = $name;
282
283 #[inline]
284 fn deref(&self) -> &Self::Target {
285 unsafe { &*(self.0.as_ptr() as *const Self::Target) }
286 }
287 }
288
289 impl Borrow<$name> for $name<Message> {
290 #[inline]
291 fn borrow(&self) -> &$name {
292 &*self
293 }
294 }
295
296 impl From<$name<Message>> for Message {
297 #[inline]
298 fn from(concrete: $name<Message>) -> Self {
299 skip_assert_initialized!();
300 concrete.0
301 }
302 }
303 }
304);
305
306declare_concrete_message!(Eos, T);
307impl Eos {
308 #[doc(alias = "gst_message_new_eos")]
309 #[allow(clippy::new_ret_no_self)]
310 pub fn new() -> Message {
311 skip_assert_initialized!();
312 Self::builder().build()
313 }
314
315 pub fn builder<'a>() -> EosBuilder<'a> {
316 assert_initialized_main_thread!();
317 EosBuilder::new()
318 }
319}
320
321impl std::fmt::Debug for Eos {
322 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
323 f&mut DebugStruct<'_, '_>.debug_struct("Eos")
324 .field("structure", &self.message().structure())
325 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
326 .finish()
327 }
328}
329
330impl std::fmt::Debug for Eos<Message> {
331 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
332 Eos::<MessageRef>::fmt(self, f)
333 }
334}
335
336declare_concrete_message!(Error, T);
337impl Error {
338 #[doc(alias = "gst_message_new_error")]
339 #[allow(clippy::new_ret_no_self)]
340 pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message {
341 skip_assert_initialized!();
342 Self::builder(error, message).build()
343 }
344
345 pub fn builder<T: MessageErrorDomain>(error: T, message: &str) -> ErrorBuilder {
346 assert_initialized_main_thread!();
347 ErrorBuilder::new(glib::Error::new(error, message))
348 }
349
350 pub fn builder_from_error<'a>(error: glib::Error) -> ErrorBuilder<'a> {
351 assert_initialized_main_thread!();
352
353 use glib::error::ErrorDomain;
354 assert!([
355 crate::CoreError::domain(),
356 crate::ResourceError::domain(),
357 crate::StreamError::domain(),
358 crate::LibraryError::domain(),
359 ]
360 .contains(&error.domain()));
361 ErrorBuilder::new(error)
362 }
363
364 #[doc(alias = "get_error")]
365 #[doc(alias = "gst_message_parse_error")]
366 pub fn error(&self) -> glib::Error {
367 unsafe {
368 let mut error = ptr::null_mut();
369
370 ffi::gst_message_parse_error(self.as_mut_ptr(), &mut error, ptr::null_mut());
371
372 from_glib_full(error)
373 }
374 }
375
376 #[doc(alias = "get_debug")]
377 #[doc(alias = "gst_message_parse_error")]
378 pub fn debug(&self) -> Option<glib::GString> {
379 unsafe {
380 let mut debug = ptr::null_mut();
381
382 ffi::gst_message_parse_error(self.as_mut_ptr(), ptr::null_mut(), &mut debug);
383
384 from_glib_full(debug)
385 }
386 }
387
388 #[doc(alias = "get_details")]
389 #[doc(alias = "gst_message_parse_error_details")]
390 pub fn details(&self) -> Option<&StructureRef> {
391 unsafe {
392 let mut details = ptr::null();
393
394 ffi::gst_message_parse_error_details(self.as_mut_ptr(), &mut details);
395
396 if details.is_null() {
397 None
398 } else {
399 Some(StructureRef::from_glib_borrow(details))
400 }
401 }
402 }
403}
404
405impl std::fmt::Display for Error {
406 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
407 write!(f, "{}", self.error())
408 }
409}
410
411impl std::fmt::Debug for Error {
412 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
413 f&mut DebugStruct<'_, '_>.debug_struct("Error")
414 .field("structure", &self.message().structure())
415 .field("source", &self.src().map(|obj| (obj, obj.name())))
416 .field("error", &self.error())
417 .field("debug", &self.debug())
418 .field(name:"details", &self.details())
419 .finish()
420 }
421}
422
423impl std::fmt::Debug for Error<Message> {
424 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
425 Error::<MessageRef>::fmt(self, f)
426 }
427}
428
429declare_concrete_message!(Warning, T);
430impl Warning {
431 #[doc(alias = "gst_message_new_warning")]
432 #[allow(clippy::new_ret_no_self)]
433 pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message {
434 skip_assert_initialized!();
435 Self::builder(error, message).build()
436 }
437
438 pub fn builder<T: MessageErrorDomain>(error: T, message: &str) -> WarningBuilder {
439 assert_initialized_main_thread!();
440 WarningBuilder::new(glib::Error::new(error, message))
441 }
442
443 pub fn builder_from_error<'a>(error: glib::Error) -> WarningBuilder<'a> {
444 assert_initialized_main_thread!();
445
446 use glib::error::ErrorDomain;
447
448 assert!([
449 crate::CoreError::domain(),
450 crate::ResourceError::domain(),
451 crate::StreamError::domain(),
452 crate::LibraryError::domain(),
453 ]
454 .contains(&error.domain()));
455 WarningBuilder::new(error)
456 }
457
458 #[doc(alias = "get_error")]
459 #[doc(alias = "gst_message_parse_warning")]
460 pub fn error(&self) -> glib::Error {
461 unsafe {
462 let mut error = ptr::null_mut();
463
464 ffi::gst_message_parse_warning(self.as_mut_ptr(), &mut error, ptr::null_mut());
465
466 from_glib_full(error)
467 }
468 }
469
470 #[doc(alias = "get_debug")]
471 #[doc(alias = "gst_message_parse_warning")]
472 pub fn debug(&self) -> Option<glib::GString> {
473 unsafe {
474 let mut debug = ptr::null_mut();
475
476 ffi::gst_message_parse_warning(self.as_mut_ptr(), ptr::null_mut(), &mut debug);
477
478 from_glib_full(debug)
479 }
480 }
481
482 #[doc(alias = "get_details")]
483 #[doc(alias = "gst_message_parse_warning_details")]
484 pub fn details(&self) -> Option<&StructureRef> {
485 unsafe {
486 let mut details = ptr::null();
487
488 ffi::gst_message_parse_warning_details(self.as_mut_ptr(), &mut details);
489
490 if details.is_null() {
491 None
492 } else {
493 Some(StructureRef::from_glib_borrow(details))
494 }
495 }
496 }
497}
498
499impl std::fmt::Display for Warning {
500 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
501 write!(f, "{}", self.error())
502 }
503}
504
505impl std::fmt::Debug for Warning {
506 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
507 f&mut DebugStruct<'_, '_>.debug_struct("Warning")
508 .field("structure", &self.message().structure())
509 .field("source", &self.src().map(|obj| (obj, obj.name())))
510 .field("error", &self.error())
511 .field("debug", &self.debug())
512 .field(name:"details", &self.details())
513 .finish()
514 }
515}
516
517impl std::fmt::Debug for Warning<Message> {
518 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
519 Warning::<MessageRef>::fmt(self, f)
520 }
521}
522
523declare_concrete_message!(Info, T);
524impl Info {
525 #[doc(alias = "gst_message_new_info")]
526 #[allow(clippy::new_ret_no_self)]
527 pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message {
528 skip_assert_initialized!();
529 Self::builder(error, message).build()
530 }
531
532 pub fn builder<T: MessageErrorDomain>(error: T, message: &str) -> InfoBuilder {
533 assert_initialized_main_thread!();
534 InfoBuilder::new(glib::Error::new(error, message))
535 }
536
537 pub fn builder_from_error<'a>(error: glib::Error) -> InfoBuilder<'a> {
538 assert_initialized_main_thread!();
539
540 use glib::error::ErrorDomain;
541
542 assert!([
543 crate::CoreError::domain(),
544 crate::ResourceError::domain(),
545 crate::StreamError::domain(),
546 crate::LibraryError::domain(),
547 ]
548 .contains(&error.domain()));
549 InfoBuilder::new(error)
550 }
551
552 #[doc(alias = "get_error")]
553 #[doc(alias = "gst_message_parse_info")]
554 pub fn error(&self) -> glib::Error {
555 unsafe {
556 let mut error = ptr::null_mut();
557
558 ffi::gst_message_parse_info(self.as_mut_ptr(), &mut error, ptr::null_mut());
559
560 from_glib_full(error)
561 }
562 }
563
564 #[doc(alias = "get_debug")]
565 #[doc(alias = "gst_message_parse_info")]
566 pub fn debug(&self) -> Option<glib::GString> {
567 unsafe {
568 let mut debug = ptr::null_mut();
569
570 ffi::gst_message_parse_info(self.as_mut_ptr(), ptr::null_mut(), &mut debug);
571
572 from_glib_full(debug)
573 }
574 }
575
576 #[doc(alias = "get_details")]
577 #[doc(alias = "gst_message_parse_info_details")]
578 pub fn details(&self) -> Option<&StructureRef> {
579 unsafe {
580 let mut details = ptr::null();
581
582 ffi::gst_message_parse_info_details(self.as_mut_ptr(), &mut details);
583
584 if details.is_null() {
585 None
586 } else {
587 Some(StructureRef::from_glib_borrow(details))
588 }
589 }
590 }
591}
592
593impl std::fmt::Display for Info {
594 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
595 write!(f, "{}", self.error())
596 }
597}
598
599impl std::fmt::Debug for Info {
600 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
601 f&mut DebugStruct<'_, '_>.debug_struct("Info")
602 .field("structure", &self.message().structure())
603 .field("source", &self.src().map(|obj| (obj, obj.name())))
604 .field("error", &self.error())
605 .field("debug", &self.debug())
606 .field(name:"details", &self.details())
607 .finish()
608 }
609}
610
611impl std::fmt::Debug for Info<Message> {
612 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
613 Info::<MessageRef>::fmt(self, f)
614 }
615}
616
617declare_concrete_message!(Tag, T);
618impl Tag {
619 #[doc(alias = "gst_message_new_tag")]
620 #[allow(clippy::new_ret_no_self)]
621 pub fn new(tags: &TagList) -> Message {
622 skip_assert_initialized!();
623 Self::builder(tags).build()
624 }
625
626 pub fn builder(tags: &TagList) -> TagBuilder {
627 assert_initialized_main_thread!();
628 TagBuilder::new(tags)
629 }
630
631 #[doc(alias = "get_tags")]
632 #[doc(alias = "gst_message_parse_tag")]
633 pub fn tags(&self) -> TagList {
634 unsafe {
635 let mut tags: *mut GstTagList = ptr::null_mut();
636 ffi::gst_message_parse_tag(self.as_mut_ptr(), &mut tags);
637 from_glib_full(ptr:tags)
638 }
639 }
640}
641
642impl std::fmt::Debug for Tag {
643 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
644 f&mut DebugStruct<'_, '_>.debug_struct("Tag")
645 .field("structure", &self.message().structure())
646 .field("source", &self.src().map(|obj| (obj, obj.name())))
647 .field(name:"tags", &self.tags())
648 .finish()
649 }
650}
651
652impl std::fmt::Debug for Tag<Message> {
653 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
654 Tag::<MessageRef>::fmt(self, f)
655 }
656}
657
658declare_concrete_message!(Buffering, T);
659impl Buffering {
660 #[doc(alias = "gst_message_new_buffering")]
661 #[allow(clippy::new_ret_no_self)]
662 pub fn new(percent: i32) -> Message {
663 skip_assert_initialized!();
664 Self::builder(percent).build()
665 }
666
667 pub fn builder<'a>(percent: i32) -> BufferingBuilder<'a> {
668 assert_initialized_main_thread!();
669 BufferingBuilder::new(percent)
670 }
671
672 #[doc(alias = "get_percent")]
673 #[doc(alias = "gst_message_parse_buffering")]
674 pub fn percent(&self) -> i32 {
675 unsafe {
676 let mut p = mem::MaybeUninit::uninit();
677 ffi::gst_message_parse_buffering(self.as_mut_ptr(), p.as_mut_ptr());
678 p.assume_init()
679 }
680 }
681
682 #[doc(alias = "get_buffering_stats")]
683 #[doc(alias = "gst_message_parse_buffering_stats")]
684 pub fn buffering_stats(&self) -> (crate::BufferingMode, i32, i32, i64) {
685 unsafe {
686 let mut mode = mem::MaybeUninit::uninit();
687 let mut avg_in = mem::MaybeUninit::uninit();
688 let mut avg_out = mem::MaybeUninit::uninit();
689 let mut buffering_left = mem::MaybeUninit::uninit();
690
691 ffi::gst_message_parse_buffering_stats(
692 self.as_mut_ptr(),
693 mode.as_mut_ptr(),
694 avg_in.as_mut_ptr(),
695 avg_out.as_mut_ptr(),
696 buffering_left.as_mut_ptr(),
697 );
698
699 (
700 from_glib(mode.assume_init()),
701 avg_in.assume_init(),
702 avg_out.assume_init(),
703 buffering_left.assume_init(),
704 )
705 }
706 }
707}
708
709impl std::fmt::Debug for Buffering {
710 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
711 f&mut DebugStruct<'_, '_>.debug_struct("Buffering")
712 .field("structure", &self.message().structure())
713 .field("source", &self.src().map(|obj| (obj, obj.name())))
714 .field("percent", &self.percent())
715 .field(name:"buffering-stats", &self.buffering_stats())
716 .finish()
717 }
718}
719
720impl std::fmt::Debug for Buffering<Message> {
721 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
722 Buffering::<MessageRef>::fmt(self, f)
723 }
724}
725
726declare_concrete_message!(StateChanged, T);
727impl StateChanged {
728 #[doc(alias = "gst_message_new_state_changed")]
729 #[allow(clippy::new_ret_no_self)]
730 pub fn new(old: crate::State, new: crate::State, pending: crate::State) -> Message {
731 skip_assert_initialized!();
732 Self::builder(old, new, pending).build()
733 }
734
735 pub fn builder<'a>(
736 old: crate::State,
737 new: crate::State,
738 pending: crate::State,
739 ) -> StateChangedBuilder<'a> {
740 assert_initialized_main_thread!();
741 StateChangedBuilder::new(old, new, pending)
742 }
743
744 #[doc(alias = "get_old")]
745 #[doc(alias = "gst_message_parse_state_changed")]
746 pub fn old(&self) -> crate::State {
747 unsafe {
748 let mut state = mem::MaybeUninit::uninit();
749
750 ffi::gst_message_parse_state_changed(
751 self.as_mut_ptr(),
752 state.as_mut_ptr(),
753 ptr::null_mut(),
754 ptr::null_mut(),
755 );
756
757 from_glib(state.assume_init())
758 }
759 }
760
761 #[doc(alias = "get_current")]
762 #[doc(alias = "gst_message_parse_state_changed")]
763 pub fn current(&self) -> crate::State {
764 unsafe {
765 let mut state = mem::MaybeUninit::uninit();
766
767 ffi::gst_message_parse_state_changed(
768 self.as_mut_ptr(),
769 ptr::null_mut(),
770 state.as_mut_ptr(),
771 ptr::null_mut(),
772 );
773
774 from_glib(state.assume_init())
775 }
776 }
777
778 #[doc(alias = "get_pending")]
779 #[doc(alias = "gst_message_parse_state_changed")]
780 pub fn pending(&self) -> crate::State {
781 unsafe {
782 let mut state = mem::MaybeUninit::uninit();
783
784 ffi::gst_message_parse_state_changed(
785 self.as_mut_ptr(),
786 ptr::null_mut(),
787 ptr::null_mut(),
788 state.as_mut_ptr(),
789 );
790
791 from_glib(state.assume_init())
792 }
793 }
794}
795
796impl std::fmt::Debug for StateChanged {
797 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
798 f&mut DebugStruct<'_, '_>.debug_struct("StateChanged")
799 .field("structure", &self.message().structure())
800 .field("source", &self.src().map(|obj| (obj, obj.name())))
801 .field("old", &self.old())
802 .field("current", &self.current())
803 .field(name:"pending", &self.pending())
804 .finish()
805 }
806}
807
808impl std::fmt::Debug for StateChanged<Message> {
809 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
810 StateChanged::<MessageRef>::fmt(self, f)
811 }
812}
813
814declare_concrete_message!(StateDirty, T);
815impl StateDirty {
816 #[doc(alias = "gst_message_new_state_dirty")]
817 #[allow(clippy::new_ret_no_self)]
818 pub fn new() -> Message {
819 skip_assert_initialized!();
820 Self::builder().build()
821 }
822
823 pub fn builder<'a>() -> StateDirtyBuilder<'a> {
824 assert_initialized_main_thread!();
825 StateDirtyBuilder::new()
826 }
827}
828
829impl std::fmt::Debug for StateDirty {
830 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
831 f&mut DebugStruct<'_, '_>.debug_struct("StateDirty")
832 .field("structure", &self.message().structure())
833 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
834 .finish()
835 }
836}
837
838impl std::fmt::Debug for StateDirty<Message> {
839 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
840 StateDirty::<MessageRef>::fmt(self, f)
841 }
842}
843
844declare_concrete_message!(StepDone, T);
845impl StepDone {
846 #[doc(alias = "gst_message_new_step_done")]
847 #[allow(clippy::new_ret_no_self)]
848 pub fn new(
849 amount: impl FormattedValue,
850 rate: f64,
851 flush: bool,
852 intermediate: bool,
853 duration: impl Into<Option<crate::ClockTime>>,
854 eos: bool,
855 ) -> Message {
856 skip_assert_initialized!();
857 Self::builder(amount, rate, flush, intermediate, duration, eos).build()
858 }
859
860 pub fn builder<'a>(
861 amount: impl FormattedValue,
862 rate: f64,
863 flush: bool,
864 intermediate: bool,
865 duration: impl Into<Option<crate::ClockTime>>,
866 eos: bool,
867 ) -> StepDoneBuilder<'a> {
868 assert_initialized_main_thread!();
869 StepDoneBuilder::new(
870 amount.into(),
871 rate,
872 flush,
873 intermediate,
874 duration.into(),
875 eos,
876 )
877 }
878
879 #[doc(alias = "gst_message_parse_step_done")]
880 pub fn get(
881 &self,
882 ) -> (
883 GenericFormattedValue,
884 f64,
885 bool,
886 bool,
887 Option<crate::ClockTime>,
888 bool,
889 ) {
890 unsafe {
891 let mut format = mem::MaybeUninit::uninit();
892 let mut amount = mem::MaybeUninit::uninit();
893 let mut rate = mem::MaybeUninit::uninit();
894 let mut flush = mem::MaybeUninit::uninit();
895 let mut intermediate = mem::MaybeUninit::uninit();
896 let mut duration = mem::MaybeUninit::uninit();
897 let mut eos = mem::MaybeUninit::uninit();
898
899 ffi::gst_message_parse_step_done(
900 self.as_mut_ptr(),
901 format.as_mut_ptr(),
902 amount.as_mut_ptr(),
903 rate.as_mut_ptr(),
904 flush.as_mut_ptr(),
905 intermediate.as_mut_ptr(),
906 duration.as_mut_ptr(),
907 eos.as_mut_ptr(),
908 );
909
910 (
911 GenericFormattedValue::new(
912 from_glib(format.assume_init()),
913 amount.assume_init() as i64,
914 ),
915 rate.assume_init(),
916 from_glib(flush.assume_init()),
917 from_glib(intermediate.assume_init()),
918 from_glib(duration.assume_init()),
919 from_glib(eos.assume_init()),
920 )
921 }
922 }
923}
924
925impl std::fmt::Debug for StepDone {
926 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
927 let (format: GenericFormattedValue, rate: f64, flush: bool, intermediate: bool, duration: Option, eos: bool) = self.get();
928 f&mut DebugStruct<'_, '_>.debug_struct("StepDone")
929 .field("structure", &self.message().structure())
930 .field("source", &self.src().map(|obj| (obj, obj.name())))
931 .field("format", &format)
932 .field("rate", &rate)
933 .field("flush", &flush)
934 .field("intermediate", &intermediate)
935 .field("duration", &duration)
936 .field(name:"eos", &eos)
937 .finish()
938 }
939}
940
941impl std::fmt::Debug for StepDone<Message> {
942 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
943 StepDone::<MessageRef>::fmt(self, f)
944 }
945}
946
947declare_concrete_message!(ClockProvide, T);
948impl ClockProvide {
949 #[doc(alias = "gst_message_new_clock_provide")]
950 #[allow(clippy::new_ret_no_self)]
951 pub fn new(clock: &crate::Clock, ready: bool) -> Message {
952 skip_assert_initialized!();
953 Self::builder(clock, ready).build()
954 }
955
956 pub fn builder(clock: &crate::Clock, ready: bool) -> ClockProvideBuilder {
957 assert_initialized_main_thread!();
958 ClockProvideBuilder::new(clock, ready)
959 }
960
961 #[doc(alias = "get_clock")]
962 #[doc(alias = "gst_message_parse_clock_provide")]
963 pub fn clock(&self) -> Option<crate::Clock> {
964 let mut clock = ptr::null_mut();
965
966 unsafe {
967 ffi::gst_message_parse_clock_provide(self.as_mut_ptr(), &mut clock, ptr::null_mut());
968
969 from_glib_none(clock)
970 }
971 }
972
973 #[doc(alias = "get_ready")]
974 #[doc(alias = "gst_message_parse_clock_provide")]
975 pub fn is_ready(&self) -> bool {
976 unsafe {
977 let mut ready = mem::MaybeUninit::uninit();
978
979 ffi::gst_message_parse_clock_provide(
980 self.as_mut_ptr(),
981 ptr::null_mut(),
982 ready.as_mut_ptr(),
983 );
984
985 from_glib(ready.assume_init())
986 }
987 }
988}
989
990impl std::fmt::Debug for ClockProvide {
991 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
992 f&mut DebugStruct<'_, '_>.debug_struct("ClockProvide")
993 .field("structure", &self.message().structure())
994 .field("source", &self.src().map(|obj| (obj, obj.name())))
995 .field("clock", &self.clock())
996 .field(name:"is-ready", &self.is_ready())
997 .finish()
998 }
999}
1000
1001impl std::fmt::Debug for ClockProvide<Message> {
1002 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1003 ClockProvide::<MessageRef>::fmt(self, f)
1004 }
1005}
1006
1007declare_concrete_message!(ClockLost, T);
1008impl ClockLost {
1009 #[doc(alias = "gst_message_new_clock_lost")]
1010 #[allow(clippy::new_ret_no_self)]
1011 pub fn new(clock: &crate::Clock) -> Message {
1012 skip_assert_initialized!();
1013 Self::builder(clock).build()
1014 }
1015
1016 pub fn builder(clock: &crate::Clock) -> ClockLostBuilder {
1017 assert_initialized_main_thread!();
1018 ClockLostBuilder::new(clock)
1019 }
1020
1021 #[doc(alias = "get_clock")]
1022 #[doc(alias = "gst_message_parse_clock_lost")]
1023 pub fn clock(&self) -> Option<crate::Clock> {
1024 let mut clock = ptr::null_mut();
1025
1026 unsafe {
1027 ffi::gst_message_parse_clock_lost(self.as_mut_ptr(), &mut clock);
1028
1029 from_glib_none(clock)
1030 }
1031 }
1032}
1033
1034impl std::fmt::Debug for ClockLost {
1035 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1036 f&mut DebugStruct<'_, '_>.debug_struct("ClockLost")
1037 .field("structure", &self.message().structure())
1038 .field("source", &self.src().map(|obj| (obj, obj.name())))
1039 .field(name:"clock", &self.clock())
1040 .finish()
1041 }
1042}
1043
1044impl std::fmt::Debug for ClockLost<Message> {
1045 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1046 ClockLost::<MessageRef>::fmt(self, f)
1047 }
1048}
1049
1050declare_concrete_message!(NewClock, T);
1051impl NewClock {
1052 #[doc(alias = "gst_message_new_new_clock")]
1053 #[allow(clippy::new_ret_no_self)]
1054 pub fn new(clock: &crate::Clock) -> Message {
1055 skip_assert_initialized!();
1056 Self::builder(clock).build()
1057 }
1058
1059 pub fn builder(clock: &crate::Clock) -> NewClockBuilder {
1060 assert_initialized_main_thread!();
1061 NewClockBuilder::new(clock)
1062 }
1063
1064 #[doc(alias = "get_clock")]
1065 #[doc(alias = "gst_message_parse_new_clock")]
1066 pub fn clock(&self) -> Option<crate::Clock> {
1067 let mut clock = ptr::null_mut();
1068
1069 unsafe {
1070 ffi::gst_message_parse_new_clock(self.as_mut_ptr(), &mut clock);
1071
1072 from_glib_none(clock)
1073 }
1074 }
1075}
1076
1077impl std::fmt::Debug for NewClock {
1078 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1079 f&mut DebugStruct<'_, '_>.debug_struct("NewClock")
1080 .field("structure", &self.message().structure())
1081 .field("source", &self.src().map(|obj| (obj, obj.name())))
1082 .field(name:"clock", &self.clock())
1083 .finish()
1084 }
1085}
1086
1087impl std::fmt::Debug for NewClock<Message> {
1088 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1089 NewClock::<MessageRef>::fmt(self, f)
1090 }
1091}
1092
1093declare_concrete_message!(StructureChange, T);
1094impl StructureChange {
1095 #[doc(alias = "gst_message_new_structure_change")]
1096 #[allow(clippy::new_ret_no_self)]
1097 pub fn new(type_: crate::StructureChangeType, owner: &crate::Element, busy: bool) -> Message {
1098 skip_assert_initialized!();
1099 Self::builder(type_, owner, busy).build()
1100 }
1101
1102 pub fn builder(
1103 type_: crate::StructureChangeType,
1104 owner: &crate::Element,
1105 busy: bool,
1106 ) -> StructureChangeBuilder {
1107 assert_initialized_main_thread!();
1108 StructureChangeBuilder::new(type_, owner, busy)
1109 }
1110
1111 #[doc(alias = "gst_message_parse_structure_change")]
1112 pub fn get(&self) -> (crate::StructureChangeType, crate::Element, bool) {
1113 unsafe {
1114 let mut type_ = mem::MaybeUninit::uninit();
1115 let mut owner = ptr::null_mut();
1116 let mut busy = mem::MaybeUninit::uninit();
1117
1118 ffi::gst_message_parse_structure_change(
1119 self.as_mut_ptr(),
1120 type_.as_mut_ptr(),
1121 &mut owner,
1122 busy.as_mut_ptr(),
1123 );
1124
1125 (
1126 from_glib(type_.assume_init()),
1127 from_glib_none(owner),
1128 from_glib(busy.assume_init()),
1129 )
1130 }
1131 }
1132}
1133
1134impl std::fmt::Debug for StructureChange {
1135 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1136 let (type_: StructureChangeType, owner: Element, busy: bool) = self.get();
1137
1138 f&mut DebugStruct<'_, '_>.debug_struct("StructureChange")
1139 .field("structure", &self.message().structure())
1140 .field("source", &self.src().map(|obj| (obj, obj.name())))
1141 .field("type", &type_)
1142 .field("owner", &owner)
1143 .field(name:"busy", &busy)
1144 .finish()
1145 }
1146}
1147
1148impl std::fmt::Debug for StructureChange<Message> {
1149 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1150 StructureChange::<MessageRef>::fmt(self, f)
1151 }
1152}
1153
1154declare_concrete_message!(StreamStatus, T);
1155impl StreamStatus {
1156 #[doc(alias = "gst_message_new_stream_status")]
1157 #[allow(clippy::new_ret_no_self)]
1158 pub fn new(type_: crate::StreamStatusType, owner: &crate::Element) -> Message {
1159 skip_assert_initialized!();
1160 Self::builder(type_, owner).build()
1161 }
1162
1163 pub fn builder(type_: crate::StreamStatusType, owner: &crate::Element) -> StreamStatusBuilder {
1164 assert_initialized_main_thread!();
1165 StreamStatusBuilder::new(type_, owner)
1166 }
1167
1168 #[doc(alias = "gst_message_parse_stream_status")]
1169 pub fn get(&self) -> (crate::StreamStatusType, crate::Element) {
1170 unsafe {
1171 let mut type_ = mem::MaybeUninit::uninit();
1172 let mut owner = ptr::null_mut();
1173
1174 ffi::gst_message_parse_stream_status(self.as_mut_ptr(), type_.as_mut_ptr(), &mut owner);
1175
1176 (from_glib(type_.assume_init()), from_glib_none(owner))
1177 }
1178 }
1179
1180 #[doc(alias = "get_stream_status_object")]
1181 #[doc(alias = "gst_message_get_stream_status_object")]
1182 pub fn stream_status_object(&self) -> Option<glib::Value> {
1183 unsafe {
1184 let value = ffi::gst_message_get_stream_status_object(self.as_mut_ptr());
1185
1186 from_glib_none(value)
1187 }
1188 }
1189}
1190
1191impl std::fmt::Debug for StreamStatus {
1192 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1193 f&mut DebugStruct<'_, '_>.debug_struct("StreamStatus")
1194 .field("structure", &self.message().structure())
1195 .field("source", &self.src().map(|obj| (obj, obj.name())))
1196 .field(name:"status", &self.stream_status_object())
1197 .finish()
1198 }
1199}
1200
1201impl std::fmt::Debug for StreamStatus<Message> {
1202 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1203 StreamStatus::<MessageRef>::fmt(self, f)
1204 }
1205}
1206
1207declare_concrete_message!(Application, T);
1208impl Application {
1209 #[doc(alias = "gst_message_new_application")]
1210 #[allow(clippy::new_ret_no_self)]
1211 pub fn new(structure: crate::Structure) -> Message {
1212 skip_assert_initialized!();
1213 Self::builder(structure).build()
1214 }
1215
1216 pub fn builder<'a>(structure: crate::Structure) -> ApplicationBuilder<'a> {
1217 assert_initialized_main_thread!();
1218 ApplicationBuilder::new(structure)
1219 }
1220}
1221
1222impl std::fmt::Debug for Application {
1223 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1224 f&mut DebugStruct<'_, '_>.debug_struct("Application")
1225 .field("structure", &self.message().structure())
1226 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
1227 .finish()
1228 }
1229}
1230
1231impl std::fmt::Debug for Application<Message> {
1232 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1233 Application::<MessageRef>::fmt(self, f)
1234 }
1235}
1236
1237declare_concrete_message!(Element, T);
1238impl Element {
1239 #[doc(alias = "gst_message_new_element")]
1240 #[allow(clippy::new_ret_no_self)]
1241 pub fn new(structure: crate::Structure) -> Message {
1242 skip_assert_initialized!();
1243 Self::builder(structure).build()
1244 }
1245
1246 pub fn builder<'a>(structure: crate::Structure) -> ElementBuilder<'a> {
1247 assert_initialized_main_thread!();
1248 ElementBuilder::new(structure)
1249 }
1250}
1251
1252impl std::fmt::Debug for Element {
1253 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1254 f&mut DebugStruct<'_, '_>.debug_struct("Element")
1255 .field("structure", &self.message().structure())
1256 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
1257 .finish()
1258 }
1259}
1260
1261impl std::fmt::Debug for Element<Message> {
1262 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1263 Element::<MessageRef>::fmt(self, f)
1264 }
1265}
1266
1267declare_concrete_message!(SegmentStart, T);
1268impl SegmentStart {
1269 #[doc(alias = "gst_message_new_segment_start")]
1270 #[allow(clippy::new_ret_no_self)]
1271 pub fn new(position: impl FormattedValue) -> Message {
1272 skip_assert_initialized!();
1273 Self::builder(position).build()
1274 }
1275
1276 pub fn builder<'a>(position: impl FormattedValue) -> SegmentStartBuilder<'a> {
1277 assert_initialized_main_thread!();
1278 SegmentStartBuilder::new(position.into())
1279 }
1280
1281 #[doc(alias = "gst_message_parse_segment_start")]
1282 pub fn get(&self) -> GenericFormattedValue {
1283 unsafe {
1284 let mut format = mem::MaybeUninit::uninit();
1285 let mut position = mem::MaybeUninit::uninit();
1286
1287 ffi::gst_message_parse_segment_start(
1288 self.as_mut_ptr(),
1289 format.as_mut_ptr(),
1290 position.as_mut_ptr(),
1291 );
1292
1293 GenericFormattedValue::new(from_glib(format.assume_init()), position.assume_init())
1294 }
1295 }
1296}
1297
1298impl std::fmt::Debug for SegmentStart {
1299 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1300 f&mut DebugStruct<'_, '_>.debug_struct("SegmentStart")
1301 .field("structure", &self.message().structure())
1302 .field("source", &self.src().map(|obj| (obj, obj.name())))
1303 .field(name:"segment", &self.get())
1304 .finish()
1305 }
1306}
1307
1308impl std::fmt::Debug for SegmentStart<Message> {
1309 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1310 SegmentStart::<MessageRef>::fmt(self, f)
1311 }
1312}
1313
1314declare_concrete_message!(SegmentDone, T);
1315impl SegmentDone {
1316 #[doc(alias = "gst_message_new_segment_done")]
1317 #[allow(clippy::new_ret_no_self)]
1318 pub fn new(position: impl FormattedValue) -> Message {
1319 skip_assert_initialized!();
1320 Self::builder(position).build()
1321 }
1322
1323 pub fn builder<'a>(position: impl FormattedValue) -> SegmentDoneBuilder<'a> {
1324 assert_initialized_main_thread!();
1325 SegmentDoneBuilder::new(position.into())
1326 }
1327
1328 #[doc(alias = "gst_message_parse_segment_done")]
1329 pub fn get(&self) -> GenericFormattedValue {
1330 unsafe {
1331 let mut format = mem::MaybeUninit::uninit();
1332 let mut position = mem::MaybeUninit::uninit();
1333
1334 ffi::gst_message_parse_segment_done(
1335 self.as_mut_ptr(),
1336 format.as_mut_ptr(),
1337 position.as_mut_ptr(),
1338 );
1339
1340 GenericFormattedValue::new(from_glib(format.assume_init()), position.assume_init())
1341 }
1342 }
1343}
1344
1345impl std::fmt::Debug for SegmentDone {
1346 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1347 f&mut DebugStruct<'_, '_>.debug_struct("SegmentDone")
1348 .field("structure", &self.message().structure())
1349 .field("source", &self.src().map(|obj| (obj, obj.name())))
1350 .field(name:"segment", &self.get())
1351 .finish()
1352 }
1353}
1354
1355impl std::fmt::Debug for SegmentDone<Message> {
1356 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1357 SegmentDone::<MessageRef>::fmt(self, f)
1358 }
1359}
1360
1361declare_concrete_message!(DurationChanged, T);
1362impl DurationChanged {
1363 #[doc(alias = "gst_message_new_duration_changed")]
1364 #[allow(clippy::new_ret_no_self)]
1365 pub fn new() -> Message {
1366 skip_assert_initialized!();
1367 Self::builder().build()
1368 }
1369
1370 pub fn builder<'a>() -> DurationChangedBuilder<'a> {
1371 assert_initialized_main_thread!();
1372 DurationChangedBuilder::new()
1373 }
1374}
1375
1376impl std::fmt::Debug for DurationChanged {
1377 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1378 f&mut DebugStruct<'_, '_>.debug_struct("DurationChanged")
1379 .field("structure", &self.message().structure())
1380 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
1381 .finish()
1382 }
1383}
1384
1385impl std::fmt::Debug for DurationChanged<Message> {
1386 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1387 DurationChanged::<MessageRef>::fmt(self, f)
1388 }
1389}
1390
1391declare_concrete_message!(Latency, T);
1392impl Latency {
1393 #[doc(alias = "gst_message_new_latency")]
1394 #[allow(clippy::new_ret_no_self)]
1395 pub fn new() -> Message {
1396 skip_assert_initialized!();
1397 Self::builder().build()
1398 }
1399
1400 pub fn builder<'a>() -> LatencyBuilder<'a> {
1401 assert_initialized_main_thread!();
1402 LatencyBuilder::new()
1403 }
1404}
1405
1406impl std::fmt::Debug for Latency {
1407 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1408 f&mut DebugStruct<'_, '_>.debug_struct("Latency")
1409 .field("structure", &self.message().structure())
1410 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
1411 .finish()
1412 }
1413}
1414
1415impl std::fmt::Debug for Latency<Message> {
1416 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1417 Latency::<MessageRef>::fmt(self, f)
1418 }
1419}
1420
1421declare_concrete_message!(AsyncStart, T);
1422impl AsyncStart {
1423 #[doc(alias = "gst_message_new_async_start")]
1424 #[allow(clippy::new_ret_no_self)]
1425 pub fn new() -> Message {
1426 skip_assert_initialized!();
1427 Self::builder().build()
1428 }
1429
1430 pub fn builder<'a>() -> AsyncStartBuilder<'a> {
1431 assert_initialized_main_thread!();
1432 AsyncStartBuilder::new()
1433 }
1434}
1435
1436impl std::fmt::Debug for AsyncStart {
1437 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1438 f&mut DebugStruct<'_, '_>.debug_struct("AsyncStart")
1439 .field("structure", &self.message().structure())
1440 .field(name:"source", &self.src().map(|obj: &Object| (obj, obj.name())))
1441 .finish()
1442 }
1443}
1444
1445impl std::fmt::Debug for AsyncStart<Message> {
1446 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1447 AsyncStart::<MessageRef>::fmt(self, f)
1448 }
1449}
1450
1451declare_concrete_message!(AsyncDone, T);
1452impl AsyncDone {
1453 #[doc(alias = "gst_message_new_async_done")]
1454 #[allow(clippy::new_ret_no_self)]
1455 pub fn new(running_time: impl Into<Option<crate::ClockTime>>) -> Message {
1456 skip_assert_initialized!();
1457 Self::builder().running_time(running_time).build()
1458 }
1459
1460 pub fn builder<'a>() -> AsyncDoneBuilder<'a> {
1461 assert_initialized_main_thread!();
1462 AsyncDoneBuilder::new()
1463 }
1464
1465 #[doc(alias = "get_running_time")]
1466 #[doc(alias = "gst_message_parse_async_done")]
1467 pub fn running_time(&self) -> Option<crate::ClockTime> {
1468 unsafe {
1469 let mut running_time = mem::MaybeUninit::uninit();
1470
1471 ffi::gst_message_parse_async_done(self.as_mut_ptr(), running_time.as_mut_ptr());
1472
1473 from_glib(running_time.assume_init())
1474 }
1475 }
1476}
1477
1478impl std::fmt::Debug for AsyncDone {
1479 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1480 f&mut DebugStruct<'_, '_>.debug_struct("AsyncDone")
1481 .field("structure", &self.message().structure())
1482 .field("source", &self.src().map(|obj| (obj, obj.name())))
1483 .field(name:"running-time", &self.running_time())
1484 .finish()
1485 }
1486}
1487
1488impl std::fmt::Debug for AsyncDone<Message> {
1489 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1490 AsyncDone::<MessageRef>::fmt(self, f)
1491 }
1492}
1493
1494declare_concrete_message!(RequestState, T);
1495impl RequestState {
1496 #[doc(alias = "gst_message_new_request_state")]
1497 #[allow(clippy::new_ret_no_self)]
1498 pub fn new(state: crate::State) -> Message {
1499 skip_assert_initialized!();
1500 Self::builder(state).build()
1501 }
1502
1503 pub fn builder<'a>(state: crate::State) -> RequestStateBuilder<'a> {
1504 assert_initialized_main_thread!();
1505 RequestStateBuilder::new(state)
1506 }
1507
1508 #[doc(alias = "get_requested_state")]
1509 #[doc(alias = "gst_message_parse_request_state")]
1510 pub fn requested_state(&self) -> crate::State {
1511 unsafe {
1512 let mut state = mem::MaybeUninit::uninit();
1513
1514 ffi::gst_message_parse_request_state(self.as_mut_ptr(), state.as_mut_ptr());
1515
1516 from_glib(state.assume_init())
1517 }
1518 }
1519}
1520
1521impl std::fmt::Debug for RequestState {
1522 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1523 f&mut DebugStruct<'_, '_>.debug_struct("RequestState")
1524 .field("structure", &self.message().structure())
1525 .field("source", &self.src().map(|obj| (obj, obj.name())))
1526 .field(name:"requested-state", &self.requested_state())
1527 .finish()
1528 }
1529}
1530
1531impl std::fmt::Debug for RequestState<Message> {
1532 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1533 RequestState::<MessageRef>::fmt(self, f)
1534 }
1535}
1536
1537declare_concrete_message!(StepStart, T);
1538impl StepStart {
1539 #[doc(alias = "gst_message_new_step_start")]
1540 #[allow(clippy::new_ret_no_self)]
1541 pub fn new(
1542 active: bool,
1543 amount: impl FormattedValue,
1544 rate: f64,
1545 flush: bool,
1546 intermediate: bool,
1547 ) -> Message {
1548 skip_assert_initialized!();
1549 Self::builder(active, amount, rate, flush, intermediate).build()
1550 }
1551
1552 pub fn builder<'a>(
1553 active: bool,
1554 amount: impl FormattedValue,
1555 rate: f64,
1556 flush: bool,
1557 intermediate: bool,
1558 ) -> StepStartBuilder<'a> {
1559 assert_initialized_main_thread!();
1560 StepStartBuilder::new(active, amount.into(), rate, flush, intermediate)
1561 }
1562
1563 #[doc(alias = "gst_message_parse_step_start")]
1564 pub fn get(&self) -> (bool, GenericFormattedValue, f64, bool, bool) {
1565 unsafe {
1566 let mut active = mem::MaybeUninit::uninit();
1567 let mut format = mem::MaybeUninit::uninit();
1568 let mut amount = mem::MaybeUninit::uninit();
1569 let mut rate = mem::MaybeUninit::uninit();
1570 let mut flush = mem::MaybeUninit::uninit();
1571 let mut intermediate = mem::MaybeUninit::uninit();
1572
1573 ffi::gst_message_parse_step_start(
1574 self.as_mut_ptr(),
1575 active.as_mut_ptr(),
1576 format.as_mut_ptr(),
1577 amount.as_mut_ptr(),
1578 rate.as_mut_ptr(),
1579 flush.as_mut_ptr(),
1580 intermediate.as_mut_ptr(),
1581 );
1582
1583 (
1584 from_glib(active.assume_init()),
1585 GenericFormattedValue::new(
1586 from_glib(format.assume_init()),
1587 amount.assume_init() as i64,
1588 ),
1589 rate.assume_init(),
1590 from_glib(flush.assume_init()),
1591 from_glib(intermediate.assume_init()),
1592 )
1593 }
1594 }
1595}
1596
1597impl std::fmt::Debug for StepStart {
1598 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1599 let (active: bool, amount: GenericFormattedValue, rate: f64, flush: bool, intermediate: bool) = self.get();
1600 f&mut DebugStruct<'_, '_>.debug_struct("StepStart")
1601 .field("structure", &self.message().structure())
1602 .field("source", &self.src().map(|obj| (obj, obj.name())))
1603 .field("active", &active)
1604 .field("amount", &amount)
1605 .field("rate", &rate)
1606 .field("flush", &flush)
1607 .field(name:"intermediate", &intermediate)
1608 .finish()
1609 }
1610}
1611
1612impl std::fmt::Debug for StepStart<Message> {
1613 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1614 StepStart::<MessageRef>::fmt(self, f)
1615 }
1616}
1617
1618declare_concrete_message!(Qos, T);
1619impl Qos {
1620 #[doc(alias = "gst_message_new_qos")]
1621 #[allow(clippy::new_ret_no_self)]
1622 pub fn new(
1623 live: bool,
1624 running_time: impl Into<Option<crate::ClockTime>>,
1625 stream_time: impl Into<Option<crate::ClockTime>>,
1626 timestamp: impl Into<Option<crate::ClockTime>>,
1627 duration: impl Into<Option<crate::ClockTime>>,
1628 ) -> Message {
1629 skip_assert_initialized!();
1630 Self::builder(live)
1631 .running_time(running_time)
1632 .stream_time(stream_time)
1633 .timestamp(timestamp)
1634 .duration(duration)
1635 .build()
1636 }
1637
1638 pub fn builder<'a>(live: bool) -> QosBuilder<'a> {
1639 assert_initialized_main_thread!();
1640 QosBuilder::new(live)
1641 }
1642
1643 #[doc(alias = "gst_message_parse_qos")]
1644 pub fn get(
1645 &self,
1646 ) -> (
1647 bool,
1648 Option<crate::ClockTime>,
1649 Option<crate::ClockTime>,
1650 Option<crate::ClockTime>,
1651 Option<crate::ClockTime>,
1652 ) {
1653 unsafe {
1654 let mut live = mem::MaybeUninit::uninit();
1655 let mut running_time = mem::MaybeUninit::uninit();
1656 let mut stream_time = mem::MaybeUninit::uninit();
1657 let mut timestamp = mem::MaybeUninit::uninit();
1658 let mut duration = mem::MaybeUninit::uninit();
1659
1660 ffi::gst_message_parse_qos(
1661 self.as_mut_ptr(),
1662 live.as_mut_ptr(),
1663 running_time.as_mut_ptr(),
1664 stream_time.as_mut_ptr(),
1665 timestamp.as_mut_ptr(),
1666 duration.as_mut_ptr(),
1667 );
1668
1669 (
1670 from_glib(live.assume_init()),
1671 from_glib(running_time.assume_init()),
1672 from_glib(stream_time.assume_init()),
1673 from_glib(timestamp.assume_init()),
1674 from_glib(duration.assume_init()),
1675 )
1676 }
1677 }
1678
1679 #[doc(alias = "get_values")]
1680 #[doc(alias = "gst_message_parse_qos_values")]
1681 pub fn values(&self) -> (i64, f64, i32) {
1682 unsafe {
1683 let mut jitter = mem::MaybeUninit::uninit();
1684 let mut proportion = mem::MaybeUninit::uninit();
1685 let mut quality = mem::MaybeUninit::uninit();
1686
1687 ffi::gst_message_parse_qos_values(
1688 self.as_mut_ptr(),
1689 jitter.as_mut_ptr(),
1690 proportion.as_mut_ptr(),
1691 quality.as_mut_ptr(),
1692 );
1693
1694 (
1695 jitter.assume_init(),
1696 proportion.assume_init(),
1697 quality.assume_init(),
1698 )
1699 }
1700 }
1701
1702 #[doc(alias = "get_stats")]
1703 #[doc(alias = "gst_message_parse_qos_stats")]
1704 pub fn stats(&self) -> (GenericFormattedValue, GenericFormattedValue) {
1705 unsafe {
1706 let mut format = mem::MaybeUninit::uninit();
1707 let mut processed = mem::MaybeUninit::uninit();
1708 let mut dropped = mem::MaybeUninit::uninit();
1709
1710 ffi::gst_message_parse_qos_stats(
1711 self.as_mut_ptr(),
1712 format.as_mut_ptr(),
1713 processed.as_mut_ptr(),
1714 dropped.as_mut_ptr(),
1715 );
1716
1717 (
1718 GenericFormattedValue::new(
1719 from_glib(format.assume_init()),
1720 processed.assume_init() as i64,
1721 ),
1722 GenericFormattedValue::new(
1723 from_glib(format.assume_init()),
1724 dropped.assume_init() as i64,
1725 ),
1726 )
1727 }
1728 }
1729}
1730
1731impl std::fmt::Debug for Qos {
1732 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1733 let (live: bool, running_time: Option, stream_time: Option, timestamp: Option, duration: Option) = self.get();
1734 let (jitter: i64, proportion: f64, quality: i32) = self.values();
1735 let (processed: GenericFormattedValue, dropped: GenericFormattedValue) = self.stats();
1736
1737 f&mut DebugStruct<'_, '_>.debug_struct("Qos")
1738 .field("structure", &self.message().structure())
1739 .field("source", &self.src().map(|obj| (obj, obj.name())))
1740 .field("live", &live)
1741 .field("running-time", &running_time)
1742 .field("stream-time", &stream_time)
1743 .field("timestamp", &timestamp)
1744 .field("duration", &duration)
1745 .field("jitter", &jitter)
1746 .field("proportion", &proportion)
1747 .field("quality", &quality)
1748 .field("processed", &processed)
1749 .field(name:"dropped", &dropped)
1750 .finish()
1751 }
1752}
1753
1754impl std::fmt::Debug for Qos<Message> {
1755 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1756 Qos::<MessageRef>::fmt(self, f)
1757 }
1758}
1759
1760declare_concrete_message!(Progress, T);
1761impl Progress {
1762 #[doc(alias = "gst_message_new_progress")]
1763 #[allow(clippy::new_ret_no_self)]
1764 pub fn new(type_: crate::ProgressType, code: &str, text: &str) -> Message {
1765 skip_assert_initialized!();
1766 Self::builder(type_, code, text).build()
1767 }
1768
1769 pub fn builder<'a>(
1770 type_: crate::ProgressType,
1771 code: &'a str,
1772 text: &'a str,
1773 ) -> ProgressBuilder<'a> {
1774 assert_initialized_main_thread!();
1775 ProgressBuilder::new(type_, code, text)
1776 }
1777
1778 #[doc(alias = "gst_message_parse_progress")]
1779 pub fn get(&self) -> (crate::ProgressType, &str, &str) {
1780 unsafe {
1781 let mut type_ = mem::MaybeUninit::uninit();
1782 let mut code = ptr::null_mut();
1783 let mut text = ptr::null_mut();
1784
1785 ffi::gst_message_parse_progress(
1786 self.as_mut_ptr(),
1787 type_.as_mut_ptr(),
1788 &mut code,
1789 &mut text,
1790 );
1791
1792 let code = CStr::from_ptr(code).to_str().unwrap();
1793 let text = CStr::from_ptr(text).to_str().unwrap();
1794
1795 (from_glib(type_.assume_init()), code, text)
1796 }
1797 }
1798}
1799
1800impl std::fmt::Debug for Progress {
1801 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1802 let (type_: ProgressType, code: &str, text: &str) = self.get();
1803 f&mut DebugStruct<'_, '_>.debug_struct("Progress")
1804 .field("structure", &self.message().structure())
1805 .field("source", &self.src().map(|obj| (obj, obj.name())))
1806 .field("type", &type_)
1807 .field("code", &code)
1808 .field(name:"text", &text)
1809 .finish()
1810 }
1811}
1812
1813impl std::fmt::Debug for Progress<Message> {
1814 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1815 Progress::<MessageRef>::fmt(self, f)
1816 }
1817}
1818
1819declare_concrete_message!(Toc, T);
1820impl Toc {
1821 // FIXME could use false for updated as default
1822 // Even better: use an enum for updated so that it is more explicit than true / false
1823 #[doc(alias = "gst_message_new_toc")]
1824 #[allow(clippy::new_ret_no_self)]
1825 pub fn new(toc: &crate::Toc, updated: bool) -> Message {
1826 skip_assert_initialized!();
1827 Self::builder(toc, updated).build()
1828 }
1829
1830 pub fn builder(toc: &crate::Toc, updated: bool) -> TocBuilder {
1831 assert_initialized_main_thread!();
1832 TocBuilder::new(toc, updated)
1833 }
1834
1835 #[doc(alias = "get_toc")]
1836 #[doc(alias = "gst_message_parse_toc")]
1837 pub fn toc(&self) -> (crate::Toc, bool) {
1838 unsafe {
1839 let mut toc = ptr::null_mut();
1840 let mut updated = mem::MaybeUninit::uninit();
1841 ffi::gst_message_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr());
1842 (from_glib_full(toc), from_glib(updated.assume_init()))
1843 }
1844 }
1845}
1846
1847impl std::fmt::Debug for Toc {
1848 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1849 f&mut DebugStruct<'_, '_>.debug_struct("Toc")
1850 .field("structure", &self.message().structure())
1851 .field("source", &self.src().map(|obj| (obj, obj.name())))
1852 .field(name:"toc", &self.toc())
1853 .finish()
1854 }
1855}
1856
1857impl std::fmt::Debug for Toc<Message> {
1858 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1859 Toc::<MessageRef>::fmt(self, f)
1860 }
1861}
1862
1863declare_concrete_message!(ResetTime, T);
1864impl ResetTime {
1865 #[doc(alias = "gst_message_new_reset_time")]
1866 #[allow(clippy::new_ret_no_self)]
1867 pub fn new(running_time: crate::ClockTime) -> Message {
1868 skip_assert_initialized!();
1869 Self::builder(running_time).build()
1870 }
1871
1872 pub fn builder<'a>(running_time: crate::ClockTime) -> ResetTimeBuilder<'a> {
1873 assert_initialized_main_thread!();
1874 ResetTimeBuilder::new(running_time)
1875 }
1876
1877 #[doc(alias = "get_running_time")]
1878 #[doc(alias = "gst_message_parse_reset_time")]
1879 pub fn running_time(&self) -> crate::ClockTime {
1880 unsafe {
1881 let mut running_time = mem::MaybeUninit::uninit();
1882
1883 ffi::gst_message_parse_reset_time(self.as_mut_ptr(), running_time.as_mut_ptr());
1884
1885 try_from_glib(running_time.assume_init()).expect("undefined running_time")
1886 }
1887 }
1888}
1889
1890impl std::fmt::Debug for ResetTime {
1891 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1892 f&mut DebugStruct<'_, '_>.debug_struct("ResetTime")
1893 .field("structure", &self.message().structure())
1894 .field("source", &self.src().map(|obj| (obj, obj.name())))
1895 .field(name:"running-time", &self.running_time())
1896 .finish()
1897 }
1898}
1899
1900impl std::fmt::Debug for ResetTime<Message> {
1901 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1902 ResetTime::<MessageRef>::fmt(self, f)
1903 }
1904}
1905
1906declare_concrete_message!(StreamStart, T);
1907impl StreamStart {
1908 #[doc(alias = "gst_message_new_stream_start")]
1909 #[allow(clippy::new_ret_no_self)]
1910 pub fn new() -> Message {
1911 skip_assert_initialized!();
1912 Self::builder().build()
1913 }
1914
1915 pub fn builder<'a>() -> StreamStartBuilder<'a> {
1916 assert_initialized_main_thread!();
1917 StreamStartBuilder::new()
1918 }
1919
1920 #[doc(alias = "get_group_id")]
1921 #[doc(alias = "gst_message_parse_group_id")]
1922 pub fn group_id(&self) -> Option<GroupId> {
1923 unsafe {
1924 let mut group_id = mem::MaybeUninit::uninit();
1925
1926 if from_glib(ffi::gst_message_parse_group_id(
1927 self.as_mut_ptr(),
1928 group_id.as_mut_ptr(),
1929 )) {
1930 let group_id = group_id.assume_init();
1931 if group_id == 0 {
1932 None
1933 } else {
1934 Some(GroupId(NonZeroU32::new_unchecked(group_id)))
1935 }
1936 } else {
1937 None
1938 }
1939 }
1940 }
1941}
1942
1943impl std::fmt::Debug for StreamStart {
1944 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1945 f&mut DebugStruct<'_, '_>.debug_struct("StreamStart")
1946 .field("structure", &self.message().structure())
1947 .field("source", &self.src().map(|obj| (obj, obj.name())))
1948 .field(name:"group-id", &self.group_id())
1949 .finish()
1950 }
1951}
1952
1953impl std::fmt::Debug for StreamStart<Message> {
1954 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1955 StreamStart::<MessageRef>::fmt(self, f)
1956 }
1957}
1958
1959declare_concrete_message!(NeedContext, T);
1960impl NeedContext {
1961 #[doc(alias = "gst_message_new_need_context")]
1962 #[allow(clippy::new_ret_no_self)]
1963 pub fn new(context_type: &str) -> Message {
1964 skip_assert_initialized!();
1965 Self::builder(context_type).build()
1966 }
1967
1968 pub fn builder(context_type: &str) -> NeedContextBuilder {
1969 assert_initialized_main_thread!();
1970 NeedContextBuilder::new(context_type)
1971 }
1972
1973 #[doc(alias = "get_context_type")]
1974 #[doc(alias = "gst_message_parse_context_type")]
1975 pub fn context_type(&self) -> &str {
1976 unsafe {
1977 let mut context_type = ptr::null();
1978
1979 ffi::gst_message_parse_context_type(self.as_mut_ptr(), &mut context_type);
1980
1981 CStr::from_ptr(context_type).to_str().unwrap()
1982 }
1983 }
1984}
1985
1986impl std::fmt::Debug for NeedContext {
1987 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1988 f&mut DebugStruct<'_, '_>.debug_struct("NeedContext")
1989 .field("structure", &self.message().structure())
1990 .field("source", &self.src().map(|obj| (obj, obj.name())))
1991 .field(name:"context-type", &self.context_type())
1992 .finish()
1993 }
1994}
1995
1996impl std::fmt::Debug for NeedContext<Message> {
1997 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1998 NeedContext::<MessageRef>::fmt(self, f)
1999 }
2000}
2001
2002declare_concrete_message!(HaveContext, T);
2003impl HaveContext {
2004 #[doc(alias = "gst_message_new_have_context")]
2005 #[allow(clippy::new_ret_no_self)]
2006 pub fn new(context: crate::Context) -> Message {
2007 skip_assert_initialized!();
2008 Self::builder(context).build()
2009 }
2010
2011 pub fn builder<'a>(context: crate::Context) -> HaveContextBuilder<'a> {
2012 assert_initialized_main_thread!();
2013 HaveContextBuilder::new(context)
2014 }
2015
2016 #[doc(alias = "get_context")]
2017 #[doc(alias = "gst_message_parse_have_context")]
2018 pub fn context(&self) -> crate::Context {
2019 unsafe {
2020 let mut context: *mut GstContext = ptr::null_mut();
2021 ffi::gst_message_parse_have_context(self.as_mut_ptr(), &mut context);
2022 from_glib_full(ptr:context)
2023 }
2024 }
2025}
2026
2027impl std::fmt::Debug for HaveContext {
2028 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2029 f&mut DebugStruct<'_, '_>.debug_struct("HaveContext")
2030 .field("structure", &self.message().structure())
2031 .field("source", &self.src().map(|obj| (obj, obj.name())))
2032 .field(name:"context", &self.context())
2033 .finish()
2034 }
2035}
2036
2037impl std::fmt::Debug for HaveContext<Message> {
2038 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2039 HaveContext::<MessageRef>::fmt(self, f)
2040 }
2041}
2042
2043declare_concrete_message!(DeviceAdded, T);
2044impl DeviceAdded {
2045 #[doc(alias = "gst_message_new_device_added")]
2046 #[allow(clippy::new_ret_no_self)]
2047 pub fn new(device: &crate::Device) -> Message {
2048 skip_assert_initialized!();
2049 Self::builder(device).build()
2050 }
2051
2052 pub fn builder(device: &crate::Device) -> DeviceAddedBuilder {
2053 assert_initialized_main_thread!();
2054 DeviceAddedBuilder::new(device)
2055 }
2056
2057 #[doc(alias = "get_device")]
2058 #[doc(alias = "gst_message_parse_device_added")]
2059 pub fn device(&self) -> crate::Device {
2060 unsafe {
2061 let mut device = ptr::null_mut();
2062
2063 ffi::gst_message_parse_device_added(self.as_mut_ptr(), &mut device);
2064
2065 from_glib_full(device)
2066 }
2067 }
2068}
2069
2070impl std::fmt::Debug for DeviceAdded {
2071 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2072 f&mut DebugStruct<'_, '_>.debug_struct("DeviceAdded")
2073 .field("structure", &self.message().structure())
2074 .field("source", &self.src().map(|obj| (obj, obj.name())))
2075 .field(name:"device", &self.device())
2076 .finish()
2077 }
2078}
2079
2080impl std::fmt::Debug for DeviceAdded<Message> {
2081 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2082 DeviceAdded::<MessageRef>::fmt(self, f)
2083 }
2084}
2085
2086declare_concrete_message!(DeviceRemoved, T);
2087impl DeviceRemoved {
2088 #[doc(alias = "gst_message_new_device_removed")]
2089 #[allow(clippy::new_ret_no_self)]
2090 pub fn new(device: &crate::Device) -> Message {
2091 skip_assert_initialized!();
2092 Self::builder(device).build()
2093 }
2094
2095 pub fn builder(device: &crate::Device) -> DeviceRemovedBuilder {
2096 assert_initialized_main_thread!();
2097 DeviceRemovedBuilder::new(device)
2098 }
2099
2100 #[doc(alias = "get_device")]
2101 #[doc(alias = "gst_message_parse_device_removed")]
2102 pub fn device(&self) -> crate::Device {
2103 unsafe {
2104 let mut device = ptr::null_mut();
2105
2106 ffi::gst_message_parse_device_removed(self.as_mut_ptr(), &mut device);
2107
2108 from_glib_full(device)
2109 }
2110 }
2111}
2112
2113impl std::fmt::Debug for DeviceRemoved {
2114 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2115 f&mut DebugStruct<'_, '_>.debug_struct("DeviceRemoved")
2116 .field("structure", &self.message().structure())
2117 .field("source", &self.src().map(|obj| (obj, obj.name())))
2118 .field(name:"device", &self.device())
2119 .finish()
2120 }
2121}
2122
2123impl std::fmt::Debug for DeviceRemoved<Message> {
2124 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2125 DeviceRemoved::<MessageRef>::fmt(self, f)
2126 }
2127}
2128
2129declare_concrete_message!(PropertyNotify, T);
2130impl PropertyNotify {
2131 #[doc(alias = "gst_message_new_property_notify")]
2132 #[allow(clippy::new_ret_no_self)]
2133 pub fn new(object: &impl IsA<crate::Object>, property_name: &str) -> Message {
2134 skip_assert_initialized!();
2135 Self::builder(object, property_name).build()
2136 }
2137
2138 pub fn builder<'a>(
2139 object: &'a impl IsA<crate::Object>,
2140 property_name: &'a str,
2141 ) -> PropertyNotifyBuilder<'a> {
2142 assert_initialized_main_thread!();
2143 PropertyNotifyBuilder::new(property_name).src(object)
2144 }
2145
2146 #[doc(alias = "gst_message_parse_property_notify")]
2147 pub fn get(&self) -> (Object, &str, Option<&glib::Value>) {
2148 unsafe {
2149 let mut object = ptr::null_mut();
2150 let mut property_name = ptr::null();
2151 let mut value = ptr::null();
2152
2153 ffi::gst_message_parse_property_notify(
2154 self.as_mut_ptr(),
2155 &mut object,
2156 &mut property_name,
2157 &mut value,
2158 );
2159
2160 (
2161 from_glib_none(object),
2162 CStr::from_ptr(property_name).to_str().unwrap(),
2163 if value.is_null() {
2164 None
2165 } else {
2166 Some(&*(value as *const glib::Value))
2167 },
2168 )
2169 }
2170 }
2171}
2172
2173impl std::fmt::Debug for PropertyNotify {
2174 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2175 let (object: Object, property_name: &str, value: Option<&Value>) = self.get();
2176 f&mut DebugStruct<'_, '_>.debug_struct("PropertyNotify")
2177 .field("structure", &self.message().structure())
2178 .field("source", &self.src().map(|obj| (obj, obj.name())))
2179 .field("object", &object)
2180 .field("property-name", &property_name)
2181 .field(name:"value", &value)
2182 .finish()
2183 }
2184}
2185
2186impl std::fmt::Debug for PropertyNotify<Message> {
2187 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2188 PropertyNotify::<MessageRef>::fmt(self, f)
2189 }
2190}
2191
2192declare_concrete_message!(StreamCollection, T);
2193impl StreamCollection {
2194 #[doc(alias = "gst_message_new_stream_collection")]
2195 #[allow(clippy::new_ret_no_self)]
2196 pub fn new(collection: &crate::StreamCollection) -> Message {
2197 skip_assert_initialized!();
2198 Self::builder(collection).build()
2199 }
2200
2201 pub fn builder(collection: &crate::StreamCollection) -> StreamCollectionBuilder {
2202 assert_initialized_main_thread!();
2203 StreamCollectionBuilder::new(collection)
2204 }
2205
2206 #[doc(alias = "get_stream_collection")]
2207 #[doc(alias = "gst_message_parse_stream_collection")]
2208 pub fn stream_collection(&self) -> crate::StreamCollection {
2209 unsafe {
2210 let mut collection = ptr::null_mut();
2211
2212 ffi::gst_message_parse_stream_collection(self.as_mut_ptr(), &mut collection);
2213
2214 from_glib_full(collection)
2215 }
2216 }
2217}
2218
2219impl std::fmt::Debug for StreamCollection {
2220 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2221 f&mut DebugStruct<'_, '_>.debug_struct("StreamCollection")
2222 .field("structure", &self.message().structure())
2223 .field("source", &self.src().map(|obj| (obj, obj.name())))
2224 .field(name:"stream-collection", &self.stream_collection())
2225 .finish()
2226 }
2227}
2228
2229impl std::fmt::Debug for StreamCollection<Message> {
2230 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2231 StreamCollection::<MessageRef>::fmt(self, f)
2232 }
2233}
2234
2235declare_concrete_message!(StreamsSelected, T);
2236impl StreamsSelected {
2237 #[doc(alias = "gst_message_new_streams_selected")]
2238 #[allow(clippy::new_ret_no_self)]
2239 pub fn new(collection: &crate::StreamCollection) -> Message {
2240 skip_assert_initialized!();
2241 Self::builder(collection).build()
2242 }
2243
2244 pub fn builder(collection: &crate::StreamCollection) -> StreamsSelectedBuilder {
2245 assert_initialized_main_thread!();
2246 StreamsSelectedBuilder::new(collection)
2247 }
2248
2249 #[doc(alias = "get_stream_collection")]
2250 #[doc(alias = "gst_message_parse_streams_selected")]
2251 pub fn stream_collection(&self) -> crate::StreamCollection {
2252 unsafe {
2253 let mut collection = ptr::null_mut();
2254
2255 ffi::gst_message_parse_streams_selected(self.as_mut_ptr(), &mut collection);
2256
2257 from_glib_full(collection)
2258 }
2259 }
2260
2261 #[doc(alias = "get_streams")]
2262 #[doc(alias = "gst_message_streams_selected_get_size")]
2263 #[doc(alias = "gst_message_streams_selected_get_stream")]
2264 pub fn streams(&self) -> Vec<crate::Stream> {
2265 unsafe {
2266 let n = ffi::gst_message_streams_selected_get_size(self.as_mut_ptr());
2267
2268 (0..n)
2269 .map(|i| {
2270 from_glib_full(ffi::gst_message_streams_selected_get_stream(
2271 self.as_mut_ptr(),
2272 i,
2273 ))
2274 })
2275 .collect()
2276 }
2277 }
2278}
2279
2280impl std::fmt::Debug for StreamsSelected {
2281 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2282 f&mut DebugStruct<'_, '_>.debug_struct("StreamsSelected")
2283 .field("structure", &self.message().structure())
2284 .field("source", &self.src().map(|obj| (obj, obj.name())))
2285 .field("stream-collection", &self.stream_collection())
2286 .field(name:"streams", &self.streams())
2287 .finish()
2288 }
2289}
2290
2291impl std::fmt::Debug for StreamsSelected<Message> {
2292 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2293 StreamsSelected::<MessageRef>::fmt(self, f)
2294 }
2295}
2296
2297declare_concrete_message!(Redirect, T);
2298impl Redirect {
2299 #[doc(alias = "gst_message_new_redirect")]
2300 #[allow(clippy::new_ret_no_self)]
2301 pub fn new(location: &str) -> Message {
2302 skip_assert_initialized!();
2303 Self::builder(location).build()
2304 }
2305
2306 pub fn builder(location: &str) -> RedirectBuilder {
2307 assert_initialized_main_thread!();
2308 RedirectBuilder::new(location)
2309 }
2310
2311 #[doc(alias = "get_entries")]
2312 #[doc(alias = "gst_message_get_num_redirect_entries")]
2313 #[doc(alias = "gst_message_parse_redirect_entry")]
2314 pub fn entries(&self) -> Vec<(&str, Option<TagList>, Option<&StructureRef>)> {
2315 unsafe {
2316 let n = ffi::gst_message_get_num_redirect_entries(self.as_mut_ptr());
2317
2318 (0..n)
2319 .map(|i| {
2320 let mut location = ptr::null();
2321 let mut tags = ptr::null_mut();
2322 let mut structure = ptr::null();
2323
2324 ffi::gst_message_parse_redirect_entry(
2325 self.as_mut_ptr(),
2326 i,
2327 &mut location,
2328 &mut tags,
2329 &mut structure,
2330 );
2331
2332 let structure = if structure.is_null() {
2333 None
2334 } else {
2335 Some(StructureRef::from_glib_borrow(structure))
2336 };
2337
2338 (
2339 CStr::from_ptr(location).to_str().unwrap(),
2340 from_glib_none(tags),
2341 structure,
2342 )
2343 })
2344 .collect()
2345 }
2346 }
2347}
2348
2349impl std::fmt::Debug for Redirect {
2350 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2351 f&mut DebugStruct<'_, '_>.debug_struct("Redirect")
2352 .field("structure", &self.message().structure())
2353 .field("source", &self.src().map(|obj| (obj, obj.name())))
2354 .field(name:"entries", &self.entries())
2355 .finish()
2356 }
2357}
2358
2359impl std::fmt::Debug for Redirect<Message> {
2360 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2361 Redirect::<MessageRef>::fmt(self, f)
2362 }
2363}
2364
2365#[cfg(feature = "v1_16")]
2366#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
2367declare_concrete_message!(DeviceChanged, T);
2368#[cfg(feature = "v1_16")]
2369#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
2370impl DeviceChanged {
2371 #[doc(alias = "gst_message_new_device_changed")]
2372 #[allow(clippy::new_ret_no_self)]
2373 pub fn new(device: &crate::Device, changed_device: &crate::Device) -> Message {
2374 skip_assert_initialized!();
2375 Self::builder(device, changed_device).build()
2376 }
2377
2378 pub fn builder<'a>(
2379 device: &'a crate::Device,
2380 changed_device: &'a crate::Device,
2381 ) -> DeviceChangedBuilder<'a> {
2382 assert_initialized_main_thread!();
2383 DeviceChangedBuilder::new(device, changed_device)
2384 }
2385
2386 #[doc(alias = "get_device_changed")]
2387 #[doc(alias = "gst_message_parse_device_changed")]
2388 pub fn device_changed(&self) -> (crate::Device, crate::Device) {
2389 unsafe {
2390 let mut device = ptr::null_mut();
2391 let mut changed_device = ptr::null_mut();
2392
2393 ffi::gst_message_parse_device_changed(
2394 self.as_mut_ptr(),
2395 &mut device,
2396 &mut changed_device,
2397 );
2398
2399 (from_glib_full(device), from_glib_full(changed_device))
2400 }
2401 }
2402}
2403
2404#[cfg(feature = "v1_16")]
2405impl std::fmt::Debug for DeviceChanged {
2406 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2407 f.debug_struct("DeviceChanged")
2408 .field("structure", &self.message().structure())
2409 .field("source", &self.src().map(|obj| (obj, obj.name())))
2410 .field("device-changed", &self.device_changed())
2411 .finish()
2412 }
2413}
2414
2415#[cfg(feature = "v1_16")]
2416impl std::fmt::Debug for DeviceChanged<Message> {
2417 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2418 DeviceChanged::<MessageRef>::fmt(self, f)
2419 }
2420}
2421
2422#[cfg(feature = "v1_18")]
2423#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2424declare_concrete_message!(InstantRateRequest, T);
2425#[cfg(feature = "v1_18")]
2426#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2427impl InstantRateRequest {
2428 #[doc(alias = "gst_message_new_instant_rate_request")]
2429 #[allow(clippy::new_ret_no_self)]
2430 pub fn new(rate_multiplier: f64) -> Message {
2431 skip_assert_initialized!();
2432 Self::builder(rate_multiplier).build()
2433 }
2434
2435 pub fn builder<'a>(rate_multiplier: f64) -> InstantRateRequestBuilder<'a> {
2436 assert_initialized_main_thread!();
2437 InstantRateRequestBuilder::new(rate_multiplier)
2438 }
2439
2440 #[doc(alias = "parse_instant_rate_request")]
2441 #[doc(alias = "gst_message_parse_instant_rate_request")]
2442 pub fn rate_multiplier(&self) -> f64 {
2443 unsafe {
2444 let mut rate_multiplier = mem::MaybeUninit::uninit();
2445
2446 ffi::gst_message_parse_instant_rate_request(
2447 self.as_mut_ptr(),
2448 rate_multiplier.as_mut_ptr(),
2449 );
2450
2451 rate_multiplier.assume_init()
2452 }
2453 }
2454}
2455
2456#[cfg(feature = "v1_18")]
2457impl std::fmt::Debug for InstantRateRequest {
2458 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2459 f.debug_struct("InstantRateRequest")
2460 .field("structure", &self.message().structure())
2461 .field("source", &self.src().map(|obj| (obj, obj.name())))
2462 .field("rate-multiplier", &self.rate_multiplier())
2463 .finish()
2464 }
2465}
2466
2467#[cfg(feature = "v1_18")]
2468impl std::fmt::Debug for InstantRateRequest<Message> {
2469 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2470 InstantRateRequest::<MessageRef>::fmt(self, f)
2471 }
2472}
2473
2474struct MessageBuilder<'a> {
2475 src: Option<Object>,
2476 seqnum: Option<Seqnum>,
2477 #[allow(unused)]
2478 other_fields: Vec<(&'a str, &'a (dyn ToSendValue + Sync))>,
2479}
2480
2481impl<'a> MessageBuilder<'a> {
2482 fn new() -> Self {
2483 Self {
2484 src: None,
2485 seqnum: None,
2486 other_fields: Vec::new(),
2487 }
2488 }
2489
2490 pub fn src<O: IsA<Object> + Cast + Clone>(self, src: &O) -> Self {
2491 Self {
2492 src: Some(src.clone().upcast::<Object>()),
2493 ..self
2494 }
2495 }
2496
2497 fn seqnum(self, seqnum: Seqnum) -> Self {
2498 Self {
2499 seqnum: Some(seqnum),
2500 ..self
2501 }
2502 }
2503
2504 fn other_fields(self, other_fields: &[(&'a str, &'a (dyn ToSendValue + Sync))]) -> Self {
2505 Self {
2506 other_fields: self
2507 .other_fields
2508 .iter()
2509 .cloned()
2510 .chain(other_fields.iter().cloned())
2511 .collect(),
2512 ..self
2513 }
2514 }
2515}
2516
2517macro_rules! message_builder_generic_impl {
2518 ($new_fn:expr) => {
2519 #[allow(clippy::needless_update)]
2520 pub fn src<O: IsA<Object> + Cast + Clone>(self, src: &O) -> Self {
2521 Self {
2522 builder: self.builder.src(src),
2523 ..self
2524 }
2525 }
2526
2527 #[doc(alias = "gst_message_set_seqnum")]
2528 #[allow(clippy::needless_update)]
2529 pub fn seqnum(self, seqnum: Seqnum) -> Self {
2530 Self {
2531 builder: self.builder.seqnum(seqnum),
2532 ..self
2533 }
2534 }
2535
2536 #[allow(clippy::needless_update)]
2537 pub fn other_fields(
2538 self,
2539 other_fields: &[(&'a str, &'a (dyn ToSendValue + Sync))],
2540 ) -> Self {
2541 Self {
2542 builder: self.builder.other_fields(other_fields),
2543 ..self
2544 }
2545 }
2546
2547 #[must_use = "Building the message without using it has no effect"]
2548 #[allow(clippy::redundant_closure_call)]
2549 pub fn build(mut self) -> Message {
2550 unsafe {
2551 let src = self.builder.src.to_glib_none().0;
2552 let msg = $new_fn(&mut self, src);
2553 if let Some(seqnum) = self.builder.seqnum {
2554 ffi::gst_message_set_seqnum(msg, seqnum.0.get());
2555 }
2556
2557 if !self.builder.other_fields.is_empty() {
2558 let structure = ffi::gst_message_writable_structure(msg);
2559
2560 if !structure.is_null() {
2561 let structure = StructureRef::from_glib_borrow_mut(structure as *mut _);
2562
2563 for (k, v) in self.builder.other_fields {
2564 structure.set_value(k, v.to_send_value());
2565 }
2566 }
2567 }
2568
2569 from_glib_full(msg)
2570 }
2571 }
2572 };
2573}
2574
2575#[must_use = "The builder must be built to be used"]
2576pub struct EosBuilder<'a> {
2577 builder: MessageBuilder<'a>,
2578}
2579
2580impl<'a> EosBuilder<'a> {
2581 fn new() -> Self {
2582 skip_assert_initialized!();
2583 Self {
2584 builder: MessageBuilder::new(),
2585 }
2586 }
2587
2588 message_builder_generic_impl!(|_, src| ffi::gst_message_new_eos(src));
2589}
2590
2591pub trait MessageErrorDomain: glib::error::ErrorDomain {}
2592
2593impl MessageErrorDomain for crate::CoreError {}
2594impl MessageErrorDomain for crate::ResourceError {}
2595impl MessageErrorDomain for crate::StreamError {}
2596impl MessageErrorDomain for crate::LibraryError {}
2597
2598#[must_use = "The builder must be built to be used"]
2599pub struct ErrorBuilder<'a> {
2600 builder: MessageBuilder<'a>,
2601 error: glib::Error,
2602 debug: Option<&'a str>,
2603 #[allow(unused)]
2604 details: Option<Structure>,
2605}
2606
2607impl<'a> ErrorBuilder<'a> {
2608 fn new(error: glib::Error) -> Self {
2609 skip_assert_initialized!();
2610 Self {
2611 builder: MessageBuilder::new(),
2612 error,
2613 debug: None,
2614 details: None,
2615 }
2616 }
2617
2618 pub fn debug(self, debug: &'a str) -> Self {
2619 Self {
2620 debug: Some(debug),
2621 ..self
2622 }
2623 }
2624
2625 pub fn details(self, details: Structure) -> Self {
2626 Self {
2627 details: Some(details),
2628 ..self
2629 }
2630 }
2631
2632 message_builder_generic_impl!(|s: &mut Self, src| {
2633 let details = match s.details.take() {
2634 None => ptr::null_mut(),
2635 Some(details) => details.into_glib_ptr(),
2636 };
2637
2638 ffi::gst_message_new_error_with_details(
2639 src,
2640 mut_override(s.error.to_glib_none().0),
2641 s.debug.to_glib_none().0,
2642 details,
2643 )
2644 });
2645}
2646
2647#[must_use = "The builder must be built to be used"]
2648pub struct WarningBuilder<'a> {
2649 builder: MessageBuilder<'a>,
2650 error: glib::Error,
2651 debug: Option<&'a str>,
2652 #[allow(unused)]
2653 details: Option<Structure>,
2654}
2655
2656impl<'a> WarningBuilder<'a> {
2657 fn new(error: glib::Error) -> Self {
2658 skip_assert_initialized!();
2659 Self {
2660 builder: MessageBuilder::new(),
2661 error,
2662 debug: None,
2663 details: None,
2664 }
2665 }
2666
2667 pub fn debug(self, debug: &'a str) -> Self {
2668 Self {
2669 debug: Some(debug),
2670 ..self
2671 }
2672 }
2673
2674 pub fn details(self, details: Structure) -> Self {
2675 Self {
2676 details: Some(details),
2677 ..self
2678 }
2679 }
2680
2681 message_builder_generic_impl!(|s: &mut Self, src| {
2682 let details = match s.details.take() {
2683 None => ptr::null_mut(),
2684 Some(details) => details.into_glib_ptr(),
2685 };
2686
2687 ffi::gst_message_new_warning_with_details(
2688 src,
2689 mut_override(s.error.to_glib_none().0),
2690 s.debug.to_glib_none().0,
2691 details,
2692 )
2693 });
2694}
2695
2696#[must_use = "The builder must be built to be used"]
2697pub struct InfoBuilder<'a> {
2698 builder: MessageBuilder<'a>,
2699 error: glib::Error,
2700 debug: Option<&'a str>,
2701 #[allow(unused)]
2702 details: Option<Structure>,
2703}
2704
2705impl<'a> InfoBuilder<'a> {
2706 fn new(error: glib::Error) -> Self {
2707 skip_assert_initialized!();
2708 Self {
2709 builder: MessageBuilder::new(),
2710 error,
2711 debug: None,
2712 details: None,
2713 }
2714 }
2715
2716 pub fn debug(self, debug: &'a str) -> Self {
2717 Self {
2718 debug: Some(debug),
2719 ..self
2720 }
2721 }
2722
2723 pub fn details(self, details: Structure) -> Self {
2724 Self {
2725 details: Some(details),
2726 ..self
2727 }
2728 }
2729
2730 message_builder_generic_impl!(|s: &mut Self, src| {
2731 let details = match s.details.take() {
2732 None => ptr::null_mut(),
2733 Some(details) => details.into_glib_ptr(),
2734 };
2735
2736 ffi::gst_message_new_info_with_details(
2737 src,
2738 mut_override(s.error.to_glib_none().0),
2739 s.debug.to_glib_none().0,
2740 details,
2741 )
2742 });
2743}
2744
2745#[must_use = "The builder must be built to be used"]
2746pub struct TagBuilder<'a> {
2747 builder: MessageBuilder<'a>,
2748 tags: &'a TagList,
2749}
2750
2751impl<'a> TagBuilder<'a> {
2752 fn new(tags: &'a TagList) -> Self {
2753 skip_assert_initialized!();
2754 Self {
2755 builder: MessageBuilder::new(),
2756 tags,
2757 }
2758 }
2759
2760 message_builder_generic_impl!(|s: &Self, src| ffi::gst_message_new_tag(
2761 src,
2762 s.tags.to_glib_full()
2763 ));
2764}
2765
2766#[must_use = "The builder must be built to be used"]
2767pub struct BufferingBuilder<'a> {
2768 builder: MessageBuilder<'a>,
2769 percent: i32,
2770 stats: Option<(crate::BufferingMode, i32, i32, i64)>,
2771}
2772
2773impl<'a> BufferingBuilder<'a> {
2774 fn new(percent: i32) -> Self {
2775 skip_assert_initialized!();
2776 Self {
2777 builder: MessageBuilder::new(),
2778 percent,
2779 stats: None,
2780 }
2781 }
2782
2783 pub fn stats(
2784 self,
2785 mode: crate::BufferingMode,
2786 avg_in: i32,
2787 avg_out: i32,
2788 buffering_left: i64,
2789 ) -> Self {
2790 skip_assert_initialized!();
2791 Self {
2792 stats: Some((mode, avg_in, avg_out, buffering_left)),
2793 ..self
2794 }
2795 }
2796
2797 message_builder_generic_impl!(|s: &mut Self, src| {
2798 let msg = ffi::gst_message_new_buffering(src, s.percent);
2799
2800 if let Some((mode, avg_in, avg_out, buffering_left)) = s.stats {
2801 ffi::gst_message_set_buffering_stats(
2802 msg,
2803 mode.into_glib(),
2804 avg_in,
2805 avg_out,
2806 buffering_left,
2807 );
2808 }
2809
2810 msg
2811 });
2812}
2813
2814#[must_use = "The builder must be built to be used"]
2815pub struct StateChangedBuilder<'a> {
2816 builder: MessageBuilder<'a>,
2817 old: crate::State,
2818 new: crate::State,
2819 pending: crate::State,
2820}
2821
2822impl<'a> StateChangedBuilder<'a> {
2823 fn new(old: crate::State, new: crate::State, pending: crate::State) -> Self {
2824 skip_assert_initialized!();
2825 Self {
2826 builder: MessageBuilder::new(),
2827 old,
2828 new,
2829 pending,
2830 }
2831 }
2832
2833 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_state_changed(
2834 src,
2835 s.old.into_glib(),
2836 s.new.into_glib(),
2837 s.pending.into_glib(),
2838 ));
2839}
2840
2841#[must_use = "The builder must be built to be used"]
2842pub struct StateDirtyBuilder<'a> {
2843 builder: MessageBuilder<'a>,
2844}
2845
2846impl<'a> StateDirtyBuilder<'a> {
2847 fn new() -> Self {
2848 skip_assert_initialized!();
2849 Self {
2850 builder: MessageBuilder::new(),
2851 }
2852 }
2853
2854 message_builder_generic_impl!(|_, src| ffi::gst_message_new_state_dirty(src));
2855}
2856
2857#[must_use = "The builder must be built to be used"]
2858pub struct StepDoneBuilder<'a> {
2859 builder: MessageBuilder<'a>,
2860 amount: GenericFormattedValue,
2861 rate: f64,
2862 flush: bool,
2863 intermediate: bool,
2864 duration: Option<crate::ClockTime>,
2865 eos: bool,
2866}
2867
2868impl<'a> StepDoneBuilder<'a> {
2869 fn new(
2870 amount: GenericFormattedValue,
2871 rate: f64,
2872 flush: bool,
2873 intermediate: bool,
2874 duration: Option<crate::ClockTime>,
2875 eos: bool,
2876 ) -> Self {
2877 skip_assert_initialized!();
2878 assert_eq!(amount.format(), duration.format());
2879 Self {
2880 builder: MessageBuilder::new(),
2881 amount,
2882 rate,
2883 flush,
2884 intermediate,
2885 duration,
2886 eos,
2887 }
2888 }
2889
2890 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_step_done(
2891 src,
2892 s.amount.format().into_glib(),
2893 s.amount.value() as u64,
2894 s.rate,
2895 s.flush.into_glib(),
2896 s.intermediate.into_glib(),
2897 s.duration.into_raw_value() as u64,
2898 s.eos.into_glib(),
2899 ));
2900}
2901
2902#[must_use = "The builder must be built to be used"]
2903pub struct ClockProvideBuilder<'a> {
2904 builder: MessageBuilder<'a>,
2905 clock: &'a crate::Clock,
2906 ready: bool,
2907}
2908
2909impl<'a> ClockProvideBuilder<'a> {
2910 fn new(clock: &'a crate::Clock, ready: bool) -> Self {
2911 skip_assert_initialized!();
2912 Self {
2913 builder: MessageBuilder::new(),
2914 clock,
2915 ready,
2916 }
2917 }
2918
2919 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_clock_provide(
2920 src,
2921 s.clock.to_glib_none().0,
2922 s.ready.into_glib()
2923 ));
2924}
2925
2926#[must_use = "The builder must be built to be used"]
2927pub struct ClockLostBuilder<'a> {
2928 builder: MessageBuilder<'a>,
2929 clock: &'a crate::Clock,
2930}
2931
2932impl<'a> ClockLostBuilder<'a> {
2933 fn new(clock: &'a crate::Clock) -> Self {
2934 skip_assert_initialized!();
2935 Self {
2936 builder: MessageBuilder::new(),
2937 clock,
2938 }
2939 }
2940
2941 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_clock_lost(
2942 src,
2943 s.clock.to_glib_none().0
2944 ));
2945}
2946
2947#[must_use = "The builder must be built to be used"]
2948pub struct NewClockBuilder<'a> {
2949 builder: MessageBuilder<'a>,
2950 clock: &'a crate::Clock,
2951}
2952
2953impl<'a> NewClockBuilder<'a> {
2954 fn new(clock: &'a crate::Clock) -> Self {
2955 skip_assert_initialized!();
2956 Self {
2957 builder: MessageBuilder::new(),
2958 clock,
2959 }
2960 }
2961
2962 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_new_clock(
2963 src,
2964 s.clock.to_glib_none().0
2965 ));
2966}
2967
2968#[must_use = "The builder must be built to be used"]
2969pub struct StructureChangeBuilder<'a> {
2970 builder: MessageBuilder<'a>,
2971 type_: crate::StructureChangeType,
2972 owner: &'a crate::Element,
2973 busy: bool,
2974}
2975
2976impl<'a> StructureChangeBuilder<'a> {
2977 fn new(type_: crate::StructureChangeType, owner: &'a crate::Element, busy: bool) -> Self {
2978 skip_assert_initialized!();
2979 Self {
2980 builder: MessageBuilder::new(),
2981 type_,
2982 owner,
2983 busy,
2984 }
2985 }
2986
2987 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_structure_change(
2988 src,
2989 s.type_.into_glib(),
2990 s.owner.to_glib_none().0,
2991 s.busy.into_glib(),
2992 ));
2993}
2994
2995#[must_use = "The builder must be built to be used"]
2996pub struct StreamStatusBuilder<'a> {
2997 builder: MessageBuilder<'a>,
2998 type_: crate::StreamStatusType,
2999 owner: &'a crate::Element,
3000 status_object: Option<&'a (dyn glib::ToSendValue + Sync)>,
3001}
3002
3003impl<'a> StreamStatusBuilder<'a> {
3004 fn new(type_: crate::StreamStatusType, owner: &'a crate::Element) -> Self {
3005 skip_assert_initialized!();
3006 Self {
3007 builder: MessageBuilder::new(),
3008 type_,
3009 owner,
3010 status_object: None,
3011 }
3012 }
3013
3014 pub fn status_object(self, status_object: &'a (dyn glib::ToSendValue + Sync)) -> Self {
3015 Self {
3016 status_object: Some(status_object),
3017 ..self
3018 }
3019 }
3020
3021 message_builder_generic_impl!(|s: &mut Self, src| {
3022 let msg =
3023 ffi::gst_message_new_stream_status(src, s.type_.into_glib(), s.owner.to_glib_none().0);
3024 if let Some(status_object) = s.status_object {
3025 ffi::gst_message_set_stream_status_object(
3026 msg,
3027 status_object.to_send_value().to_glib_none().0,
3028 );
3029 }
3030 msg
3031 });
3032}
3033
3034#[must_use = "The builder must be built to be used"]
3035pub struct ApplicationBuilder<'a> {
3036 builder: MessageBuilder<'a>,
3037 structure: Option<crate::Structure>,
3038}
3039
3040impl<'a> ApplicationBuilder<'a> {
3041 fn new(structure: crate::Structure) -> Self {
3042 skip_assert_initialized!();
3043 Self {
3044 builder: MessageBuilder::new(),
3045 structure: Some(structure),
3046 }
3047 }
3048
3049 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_application(
3050 src,
3051 s.structure.take().unwrap().into_glib_ptr()
3052 ));
3053}
3054
3055#[must_use = "The builder must be built to be used"]
3056pub struct ElementBuilder<'a> {
3057 builder: MessageBuilder<'a>,
3058 structure: Option<crate::Structure>,
3059}
3060
3061impl<'a> ElementBuilder<'a> {
3062 fn new(structure: crate::Structure) -> Self {
3063 skip_assert_initialized!();
3064 Self {
3065 builder: MessageBuilder::new(),
3066 structure: Some(structure),
3067 }
3068 }
3069
3070 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_element(
3071 src,
3072 s.structure.take().unwrap().into_glib_ptr()
3073 ));
3074}
3075
3076#[must_use = "The builder must be built to be used"]
3077pub struct SegmentStartBuilder<'a> {
3078 builder: MessageBuilder<'a>,
3079 position: GenericFormattedValue,
3080}
3081
3082impl<'a> SegmentStartBuilder<'a> {
3083 fn new(position: GenericFormattedValue) -> Self {
3084 skip_assert_initialized!();
3085 Self {
3086 builder: MessageBuilder::new(),
3087 position,
3088 }
3089 }
3090
3091 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_segment_start(
3092 src,
3093 s.position.format().into_glib(),
3094 s.position.value(),
3095 ));
3096}
3097
3098#[must_use = "The builder must be built to be used"]
3099pub struct SegmentDoneBuilder<'a> {
3100 builder: MessageBuilder<'a>,
3101 position: GenericFormattedValue,
3102}
3103
3104impl<'a> SegmentDoneBuilder<'a> {
3105 fn new(position: GenericFormattedValue) -> Self {
3106 skip_assert_initialized!();
3107 Self {
3108 builder: MessageBuilder::new(),
3109 position,
3110 }
3111 }
3112
3113 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_segment_done(
3114 src,
3115 s.position.format().into_glib(),
3116 s.position.value(),
3117 ));
3118}
3119
3120#[must_use = "The builder must be built to be used"]
3121pub struct DurationChangedBuilder<'a> {
3122 builder: MessageBuilder<'a>,
3123}
3124
3125impl<'a> DurationChangedBuilder<'a> {
3126 fn new() -> Self {
3127 skip_assert_initialized!();
3128 Self {
3129 builder: MessageBuilder::new(),
3130 }
3131 }
3132
3133 message_builder_generic_impl!(|_, src| ffi::gst_message_new_duration_changed(src));
3134}
3135
3136#[must_use = "The builder must be built to be used"]
3137pub struct LatencyBuilder<'a> {
3138 builder: MessageBuilder<'a>,
3139}
3140
3141impl<'a> LatencyBuilder<'a> {
3142 fn new() -> Self {
3143 skip_assert_initialized!();
3144 Self {
3145 builder: MessageBuilder::new(),
3146 }
3147 }
3148
3149 message_builder_generic_impl!(|_, src| ffi::gst_message_new_latency(src));
3150}
3151
3152#[must_use = "The builder must be built to be used"]
3153pub struct AsyncStartBuilder<'a> {
3154 builder: MessageBuilder<'a>,
3155}
3156
3157impl<'a> AsyncStartBuilder<'a> {
3158 fn new() -> Self {
3159 skip_assert_initialized!();
3160 Self {
3161 builder: MessageBuilder::new(),
3162 }
3163 }
3164
3165 message_builder_generic_impl!(|_, src| ffi::gst_message_new_async_start(src));
3166}
3167
3168#[must_use = "The builder must be built to be used"]
3169pub struct AsyncDoneBuilder<'a> {
3170 builder: MessageBuilder<'a>,
3171 running_time: Option<crate::ClockTime>,
3172}
3173
3174impl<'a> AsyncDoneBuilder<'a> {
3175 fn new() -> Self {
3176 skip_assert_initialized!();
3177 Self {
3178 builder: MessageBuilder::new(),
3179 running_time: None,
3180 }
3181 }
3182
3183 pub fn running_time(mut self, running_time: impl Into<Option<crate::ClockTime>>) -> Self {
3184 self.running_time = running_time.into();
3185 self
3186 }
3187
3188 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done(
3189 src,
3190 s.running_time.into_glib()
3191 ));
3192}
3193
3194#[must_use = "The builder must be built to be used"]
3195pub struct RequestStateBuilder<'a> {
3196 builder: MessageBuilder<'a>,
3197 state: crate::State,
3198}
3199
3200impl<'a> RequestStateBuilder<'a> {
3201 fn new(state: crate::State) -> Self {
3202 skip_assert_initialized!();
3203 Self {
3204 builder: MessageBuilder::new(),
3205 state,
3206 }
3207 }
3208
3209 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_request_state(
3210 src,
3211 s.state.into_glib()
3212 ));
3213}
3214
3215#[must_use = "The builder must be built to be used"]
3216pub struct StepStartBuilder<'a> {
3217 builder: MessageBuilder<'a>,
3218 active: bool,
3219 amount: GenericFormattedValue,
3220 rate: f64,
3221 flush: bool,
3222 intermediate: bool,
3223}
3224
3225impl<'a> StepStartBuilder<'a> {
3226 fn new(
3227 active: bool,
3228 amount: GenericFormattedValue,
3229 rate: f64,
3230 flush: bool,
3231 intermediate: bool,
3232 ) -> Self {
3233 skip_assert_initialized!();
3234 Self {
3235 builder: MessageBuilder::new(),
3236 active,
3237 amount,
3238 rate,
3239 flush,
3240 intermediate,
3241 }
3242 }
3243
3244 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_step_start(
3245 src,
3246 s.active.into_glib(),
3247 s.amount.format().into_glib(),
3248 s.amount.value() as u64,
3249 s.rate,
3250 s.flush.into_glib(),
3251 s.intermediate.into_glib(),
3252 ));
3253}
3254
3255#[must_use = "The builder must be built to be used"]
3256pub struct QosBuilder<'a> {
3257 builder: MessageBuilder<'a>,
3258 live: bool,
3259 running_time: Option<crate::ClockTime>,
3260 stream_time: Option<crate::ClockTime>,
3261 timestamp: Option<crate::ClockTime>,
3262 duration: Option<crate::ClockTime>,
3263 values: Option<(i64, f64, i32)>,
3264 stats: Option<(GenericFormattedValue, GenericFormattedValue)>,
3265}
3266
3267impl<'a> QosBuilder<'a> {
3268 fn new(live: bool) -> Self {
3269 skip_assert_initialized!();
3270 Self {
3271 builder: MessageBuilder::new(),
3272 live,
3273 running_time: None,
3274 stream_time: None,
3275 timestamp: None,
3276 duration: None,
3277 values: None,
3278 stats: None,
3279 }
3280 }
3281
3282 pub fn running_time(mut self, running_time: impl Into<Option<crate::ClockTime>>) -> Self {
3283 self.running_time = running_time.into();
3284 self
3285 }
3286
3287 pub fn stream_time(mut self, stream_time: impl Into<Option<crate::ClockTime>>) -> Self {
3288 self.stream_time = stream_time.into();
3289 self
3290 }
3291
3292 pub fn timestamp(mut self, timestamp: impl Into<Option<crate::ClockTime>>) -> Self {
3293 self.timestamp = timestamp.into();
3294 self
3295 }
3296
3297 pub fn duration(mut self, duration: impl Into<Option<crate::ClockTime>>) -> Self {
3298 self.duration = duration.into();
3299 self
3300 }
3301
3302 pub fn values(self, jitter: i64, proportion: f64, quality: i32) -> Self {
3303 Self {
3304 values: Some((jitter, proportion, quality)),
3305 ..self
3306 }
3307 }
3308
3309 pub fn stats<V: FormattedValue>(
3310 self,
3311 processed: V,
3312 dropped: impl CompatibleFormattedValue<V>,
3313 ) -> Self {
3314 let dropped = dropped.try_into_checked(processed).unwrap();
3315 Self {
3316 stats: Some((processed.into(), dropped.into())),
3317 ..self
3318 }
3319 }
3320
3321 message_builder_generic_impl!(|s: &mut Self, src| {
3322 let msg = ffi::gst_message_new_qos(
3323 src,
3324 s.live.into_glib(),
3325 s.running_time.into_glib(),
3326 s.stream_time.into_glib(),
3327 s.timestamp.into_glib(),
3328 s.duration.into_glib(),
3329 );
3330 if let Some((jitter, proportion, quality)) = s.values {
3331 ffi::gst_message_set_qos_values(msg, jitter, proportion, quality);
3332 }
3333 if let Some((processed, dropped)) = s.stats {
3334 ffi::gst_message_set_qos_stats(
3335 msg,
3336 processed.format().into_glib(),
3337 processed.value() as u64,
3338 dropped.value() as u64,
3339 );
3340 }
3341 msg
3342 });
3343}
3344
3345#[must_use = "The builder must be built to be used"]
3346pub struct ProgressBuilder<'a> {
3347 builder: MessageBuilder<'a>,
3348 type_: crate::ProgressType,
3349 code: &'a str,
3350 text: &'a str,
3351}
3352
3353impl<'a> ProgressBuilder<'a> {
3354 fn new(type_: crate::ProgressType, code: &'a str, text: &'a str) -> Self {
3355 skip_assert_initialized!();
3356 Self {
3357 builder: MessageBuilder::new(),
3358 type_,
3359 code,
3360 text,
3361 }
3362 }
3363
3364 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_progress(
3365 src,
3366 s.type_.into_glib(),
3367 s.code.to_glib_none().0,
3368 s.text.to_glib_none().0,
3369 ));
3370}
3371
3372#[must_use = "The builder must be built to be used"]
3373pub struct TocBuilder<'a> {
3374 builder: MessageBuilder<'a>,
3375 toc: &'a crate::Toc,
3376 updated: bool,
3377}
3378
3379impl<'a> TocBuilder<'a> {
3380 fn new(toc: &'a crate::Toc, updated: bool) -> Self {
3381 skip_assert_initialized!();
3382 Self {
3383 builder: MessageBuilder::new(),
3384 toc,
3385 updated,
3386 }
3387 }
3388
3389 message_builder_generic_impl!(|s: &Self, src| ffi::gst_message_new_toc(
3390 src,
3391 s.toc.to_glib_none().0,
3392 s.updated.into_glib()
3393 ));
3394}
3395
3396#[must_use = "The builder must be built to be used"]
3397pub struct ResetTimeBuilder<'a> {
3398 builder: MessageBuilder<'a>,
3399 running_time: crate::ClockTime,
3400}
3401
3402impl<'a> ResetTimeBuilder<'a> {
3403 fn new(running_time: crate::ClockTime) -> Self {
3404 skip_assert_initialized!();
3405 Self {
3406 builder: MessageBuilder::new(),
3407 running_time,
3408 }
3409 }
3410
3411 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_reset_time(
3412 src,
3413 s.running_time.into_glib()
3414 ));
3415}
3416
3417#[must_use = "The builder must be built to be used"]
3418pub struct StreamStartBuilder<'a> {
3419 builder: MessageBuilder<'a>,
3420 group_id: Option<GroupId>,
3421}
3422
3423impl<'a> StreamStartBuilder<'a> {
3424 fn new() -> Self {
3425 skip_assert_initialized!();
3426 Self {
3427 builder: MessageBuilder::new(),
3428 group_id: None,
3429 }
3430 }
3431
3432 pub fn group_id(self, group_id: GroupId) -> Self {
3433 Self {
3434 group_id: Some(group_id),
3435 ..self
3436 }
3437 }
3438
3439 message_builder_generic_impl!(|s: &mut Self, src| {
3440 let msg = ffi::gst_message_new_stream_start(src);
3441 if let Some(group_id) = s.group_id {
3442 ffi::gst_message_set_group_id(msg, group_id.0.get());
3443 }
3444 msg
3445 });
3446}
3447
3448#[must_use = "The builder must be built to be used"]
3449pub struct NeedContextBuilder<'a> {
3450 builder: MessageBuilder<'a>,
3451 context_type: &'a str,
3452}
3453
3454impl<'a> NeedContextBuilder<'a> {
3455 fn new(context_type: &'a str) -> Self {
3456 skip_assert_initialized!();
3457 Self {
3458 builder: MessageBuilder::new(),
3459 context_type,
3460 }
3461 }
3462
3463 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_need_context(
3464 src,
3465 s.context_type.to_glib_none().0
3466 ));
3467}
3468
3469#[must_use = "The builder must be built to be used"]
3470pub struct HaveContextBuilder<'a> {
3471 builder: MessageBuilder<'a>,
3472 context: Option<crate::Context>,
3473}
3474
3475impl<'a> HaveContextBuilder<'a> {
3476 fn new(context: crate::Context) -> Self {
3477 skip_assert_initialized!();
3478 Self {
3479 builder: MessageBuilder::new(),
3480 context: Some(context),
3481 }
3482 }
3483
3484 message_builder_generic_impl!(|s: &mut Self, src| {
3485 let context = s.context.take().unwrap();
3486 ffi::gst_message_new_have_context(src, context.into_glib_ptr())
3487 });
3488}
3489
3490#[must_use = "The builder must be built to be used"]
3491pub struct DeviceAddedBuilder<'a> {
3492 builder: MessageBuilder<'a>,
3493 device: &'a crate::Device,
3494}
3495
3496impl<'a> DeviceAddedBuilder<'a> {
3497 fn new(device: &'a crate::Device) -> Self {
3498 skip_assert_initialized!();
3499 Self {
3500 builder: MessageBuilder::new(),
3501 device,
3502 }
3503 }
3504
3505 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_added(
3506 src,
3507 s.device.to_glib_none().0
3508 ));
3509}
3510
3511#[must_use = "The builder must be built to be used"]
3512pub struct DeviceRemovedBuilder<'a> {
3513 builder: MessageBuilder<'a>,
3514 device: &'a crate::Device,
3515}
3516
3517impl<'a> DeviceRemovedBuilder<'a> {
3518 fn new(device: &'a crate::Device) -> Self {
3519 skip_assert_initialized!();
3520 Self {
3521 builder: MessageBuilder::new(),
3522 device,
3523 }
3524 }
3525
3526 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_removed(
3527 src,
3528 s.device.to_glib_none().0
3529 ));
3530}
3531
3532#[must_use = "The builder must be built to be used"]
3533pub struct PropertyNotifyBuilder<'a> {
3534 builder: MessageBuilder<'a>,
3535 property_name: &'a str,
3536 value: Option<&'a (dyn glib::ToSendValue + Sync)>,
3537}
3538
3539impl<'a> PropertyNotifyBuilder<'a> {
3540 fn new(property_name: &'a str) -> Self {
3541 skip_assert_initialized!();
3542 Self {
3543 builder: MessageBuilder::new(),
3544 property_name,
3545 value: None,
3546 }
3547 }
3548
3549 pub fn value(self, value: &'a (dyn glib::ToSendValue + Sync)) -> Self {
3550 Self {
3551 value: Some(value),
3552 ..self
3553 }
3554 }
3555
3556 message_builder_generic_impl!(|s: &mut Self, src| {
3557 let val = s.value.map(|v| v.to_send_value());
3558 ffi::gst_message_new_property_notify(
3559 src,
3560 s.property_name.to_glib_none().0,
3561 mut_override(
3562 val.as_ref()
3563 .map(|v| v.to_glib_none().0)
3564 .unwrap_or(ptr::null()),
3565 ),
3566 )
3567 });
3568}
3569
3570#[must_use = "The builder must be built to be used"]
3571pub struct StreamCollectionBuilder<'a> {
3572 builder: MessageBuilder<'a>,
3573 collection: &'a crate::StreamCollection,
3574}
3575
3576impl<'a> StreamCollectionBuilder<'a> {
3577 fn new(collection: &'a crate::StreamCollection) -> Self {
3578 skip_assert_initialized!();
3579 Self {
3580 builder: MessageBuilder::new(),
3581 collection,
3582 }
3583 }
3584
3585 message_builder_generic_impl!(|s: &mut Self, src| {
3586 ffi::gst_message_new_stream_collection(src, s.collection.to_glib_none().0)
3587 });
3588}
3589
3590#[must_use = "The builder must be built to be used"]
3591pub struct StreamsSelectedBuilder<'a> {
3592 builder: MessageBuilder<'a>,
3593 collection: &'a crate::StreamCollection,
3594 streams: Option<Vec<crate::Stream>>,
3595}
3596
3597impl<'a> StreamsSelectedBuilder<'a> {
3598 fn new(collection: &'a crate::StreamCollection) -> Self {
3599 skip_assert_initialized!();
3600 Self {
3601 builder: MessageBuilder::new(),
3602 collection,
3603 streams: None,
3604 }
3605 }
3606
3607 pub fn streams(
3608 self,
3609 streams: impl IntoIterator<Item = impl std::borrow::Borrow<crate::Stream>>,
3610 ) -> Self {
3611 Self {
3612 streams: Some(
3613 streams
3614 .into_iter()
3615 .map(|s| s.borrow().clone())
3616 .collect::<Vec<_>>(),
3617 ),
3618 ..self
3619 }
3620 }
3621
3622 message_builder_generic_impl!(|s: &mut Self, src| {
3623 let msg = ffi::gst_message_new_streams_selected(src, s.collection.to_glib_none().0);
3624 if let Some(ref streams) = s.streams {
3625 for stream in streams {
3626 ffi::gst_message_streams_selected_add(msg, stream.to_glib_none().0);
3627 }
3628 }
3629 msg
3630 });
3631}
3632
3633#[must_use = "The builder must be built to be used"]
3634pub struct RedirectBuilder<'a> {
3635 builder: MessageBuilder<'a>,
3636 location: &'a str,
3637 tag_list: Option<&'a TagList>,
3638 entry_struct: Option<Structure>,
3639 #[allow(clippy::type_complexity)]
3640 entries: Option<&'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)]>,
3641}
3642
3643impl<'a> RedirectBuilder<'a> {
3644 fn new(location: &'a str) -> Self {
3645 skip_assert_initialized!();
3646 Self {
3647 builder: MessageBuilder::new(),
3648 location,
3649 tag_list: None,
3650 entry_struct: None,
3651 entries: None,
3652 }
3653 }
3654
3655 pub fn tag_list(self, tag_list: &'a TagList) -> Self {
3656 Self {
3657 tag_list: Some(tag_list),
3658 ..self
3659 }
3660 }
3661
3662 pub fn entry_struct(self, entry_struct: Structure) -> Self {
3663 Self {
3664 entry_struct: Some(entry_struct),
3665 ..self
3666 }
3667 }
3668
3669 pub fn entries(
3670 self,
3671 entries: &'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)],
3672 ) -> Self {
3673 skip_assert_initialized!();
3674 Self {
3675 entries: Some(entries),
3676 ..self
3677 }
3678 }
3679
3680 message_builder_generic_impl!(|s: &mut Self, src| {
3681 let entry_struct = s.entry_struct.take();
3682 let entry_struct_ptr = if let Some(entry_struct) = entry_struct {
3683 entry_struct.into_glib_ptr()
3684 } else {
3685 ptr::null_mut()
3686 };
3687
3688 let msg = ffi::gst_message_new_redirect(
3689 src,
3690 s.location.to_glib_none().0,
3691 s.tag_list.to_glib_full(),
3692 entry_struct_ptr,
3693 );
3694 if let Some(entries) = s.entries {
3695 for &(location, tag_list, entry_struct) in entries {
3696 let entry_struct = entry_struct.cloned();
3697 let entry_struct_ptr = if let Some(entry_struct) = entry_struct {
3698 entry_struct.into_glib_ptr()
3699 } else {
3700 ptr::null_mut()
3701 };
3702 ffi::gst_message_add_redirect_entry(
3703 msg,
3704 location.to_glib_none().0,
3705 tag_list.to_glib_full(),
3706 entry_struct_ptr,
3707 );
3708 }
3709 }
3710 msg
3711 });
3712}
3713
3714#[cfg(feature = "v1_16")]
3715#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
3716#[must_use = "The builder must be built to be used"]
3717pub struct DeviceChangedBuilder<'a> {
3718 builder: MessageBuilder<'a>,
3719 device: &'a crate::Device,
3720 changed_device: &'a crate::Device,
3721}
3722
3723#[cfg(feature = "v1_16")]
3724#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
3725impl<'a> DeviceChangedBuilder<'a> {
3726 fn new(device: &'a crate::Device, changed_device: &'a crate::Device) -> Self {
3727 skip_assert_initialized!();
3728 Self {
3729 builder: MessageBuilder::new(),
3730 device,
3731 changed_device,
3732 }
3733 }
3734
3735 message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_device_changed(
3736 src,
3737 s.device.to_glib_none().0,
3738 s.changed_device.to_glib_none().0,
3739 ));
3740}
3741
3742#[cfg(feature = "v1_18")]
3743#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
3744#[must_use = "The builder must be built to be used"]
3745pub struct InstantRateRequestBuilder<'a> {
3746 builder: MessageBuilder<'a>,
3747 rate_multiplier: f64,
3748}
3749
3750#[cfg(feature = "v1_18")]
3751#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
3752impl<'a> InstantRateRequestBuilder<'a> {
3753 fn new(rate_multiplier: f64) -> Self {
3754 skip_assert_initialized!();
3755 Self {
3756 builder: MessageBuilder::new(),
3757 rate_multiplier,
3758 }
3759 }
3760
3761 message_builder_generic_impl!(
3762 |s: &mut Self, src| ffi::gst_message_new_instant_rate_request(src, s.rate_multiplier,)
3763 );
3764}
3765
3766#[cfg(test)]
3767mod tests {
3768 use super::*;
3769
3770 #[test]
3771 fn test_simple() {
3772 crate::init().unwrap();
3773
3774 // Message without arguments
3775 let seqnum = Seqnum::next();
3776 let eos_msg = Eos::builder().seqnum(seqnum).build();
3777 match eos_msg.view() {
3778 MessageView::Eos(eos_msg) => {
3779 assert_eq!(eos_msg.seqnum(), seqnum);
3780 assert!(eos_msg.structure().is_none());
3781 }
3782 _ => panic!("eos_msg.view() is not a MessageView::Eos(_)"),
3783 }
3784
3785 // Message with arguments
3786 let buffering_msg = Buffering::new(42);
3787 match buffering_msg.view() {
3788 MessageView::Buffering(buffering_msg) => {
3789 assert_eq!(buffering_msg.percent(), 42);
3790 }
3791 _ => panic!("buffering_msg.view() is not a MessageView::Buffering(_)"),
3792 }
3793 }
3794
3795 #[test]
3796 fn test_other_fields() {
3797 crate::init().unwrap();
3798
3799 let seqnum = Seqnum::next();
3800 let eos_msg = Eos::builder()
3801 .other_fields(&[("extra-field", &true)])
3802 .seqnum(seqnum)
3803 .build();
3804 match eos_msg.view() {
3805 MessageView::Eos(eos_msg) => {
3806 assert_eq!(eos_msg.seqnum(), seqnum);
3807 if let Some(other_fields) = eos_msg.structure() {
3808 assert!(other_fields.has_field("extra-field"));
3809 }
3810 }
3811 _ => panic!("eos_msg.view() is not a MessageView::Eos(_)"),
3812 }
3813
3814 let buffering_msg = Buffering::builder(42)
3815 .other_fields(&[("extra-field", &true)])
3816 .build();
3817 match buffering_msg.view() {
3818 MessageView::Buffering(buffering_msg) => {
3819 assert_eq!(buffering_msg.percent(), 42);
3820 if let Some(other_fields) = buffering_msg.structure() {
3821 assert!(other_fields.has_field("extra-field"));
3822 }
3823 }
3824 _ => panic!("buffering_msg.view() is not a MessageView::Buffering(_)"),
3825 }
3826 }
3827
3828 #[test]
3829 fn test_get_seqnum_valid() {
3830 crate::init().unwrap();
3831
3832 let msg = StreamStart::new();
3833 let seqnum = Seqnum(
3834 NonZeroU32::new(unsafe { ffi::gst_message_get_seqnum(msg.as_mut_ptr()) }).unwrap(),
3835 );
3836
3837 match msg.view() {
3838 MessageView::StreamStart(stream_start) => assert_eq!(seqnum, stream_start.seqnum()),
3839 _ => panic!(),
3840 }
3841 }
3842
3843 #[test]
3844 fn test_get_seqnum_invalid() {
3845 crate::init().unwrap();
3846
3847 let msg = StreamStart::new();
3848 let seqnum_init = msg.seqnum();
3849
3850 // Invalid the seqnum
3851 unsafe {
3852 (*msg.as_mut_ptr()).seqnum = ffi::GST_SEQNUM_INVALID as u32;
3853 assert_eq!(0, (*msg.as_ptr()).seqnum);
3854 };
3855
3856 match msg.view() {
3857 MessageView::StreamStart(stream_start) => {
3858 // get_seqnum is expected to return a new Seqnum,
3859 // further in the sequence than the last known seqnum.
3860 assert!(seqnum_init < stream_start.seqnum());
3861 }
3862 _ => panic!(),
3863 }
3864 }
3865}
3866