1use crate::{PlayMediaInfo, ffi};
7use glib::{GStr, prelude::*, translate::*};
8
9#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
10#[non_exhaustive]
11#[doc(alias = "GstPlayColorBalanceType")]
12pub enum PlayColorBalanceType {
13 #[doc(alias = "GST_PLAY_COLOR_BALANCE_HUE")]
15 Hue,
16 #[doc(alias = "GST_PLAY_COLOR_BALANCE_BRIGHTNESS")]
18 Brightness,
19 #[doc(alias = "GST_PLAY_COLOR_BALANCE_SATURATION")]
22 Saturation,
23 #[doc(alias = "GST_PLAY_COLOR_BALANCE_CONTRAST")]
25 Contrast,
26 #[doc(hidden)]
27 __Unknown(i32),
28}
29
30impl PlayColorBalanceType {
31 pub fn name<'a>(self) -> &'a GStr {
32 unsafe {
33 GStr::from_ptr(
34 ffi::gst_play_color_balance_type_get_name(self.into_glib())
35 .as_ref()
36 .expect("gst_play_color_balance_type_get_name returned NULL"),
37 )
38 }
39 }
40}
41
42impl std::fmt::Display for PlayColorBalanceType {
43 #[inline]
44 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
45 f.write_str(&self.name())
46 }
47}
48
49#[doc(hidden)]
50impl IntoGlib for PlayColorBalanceType {
51 type GlibType = ffi::GstPlayColorBalanceType;
52
53 #[inline]
54 fn into_glib(self) -> ffi::GstPlayColorBalanceType {
55 match self {
56 Self::Hue => ffi::GST_PLAY_COLOR_BALANCE_HUE,
57 Self::Brightness => ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS,
58 Self::Saturation => ffi::GST_PLAY_COLOR_BALANCE_SATURATION,
59 Self::Contrast => ffi::GST_PLAY_COLOR_BALANCE_CONTRAST,
60 Self::__Unknown(value) => value,
61 }
62 }
63}
64
65#[doc(hidden)]
66impl FromGlib<ffi::GstPlayColorBalanceType> for PlayColorBalanceType {
67 #[inline]
68 unsafe fn from_glib(value: ffi::GstPlayColorBalanceType) -> Self {
69 skip_assert_initialized!();
70
71 match value {
72 ffi::GST_PLAY_COLOR_BALANCE_HUE => Self::Hue,
73 ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS => Self::Brightness,
74 ffi::GST_PLAY_COLOR_BALANCE_SATURATION => Self::Saturation,
75 ffi::GST_PLAY_COLOR_BALANCE_CONTRAST => Self::Contrast,
76 value => Self::__Unknown(value),
77 }
78 }
79}
80
81impl StaticType for PlayColorBalanceType {
82 #[inline]
83 #[doc(alias = "gst_play_color_balance_type_get_type")]
84 fn static_type() -> glib::Type {
85 unsafe { from_glib(ffi::gst_play_color_balance_type_get_type()) }
86 }
87}
88
89impl glib::HasParamSpec for PlayColorBalanceType {
90 type ParamSpec = glib::ParamSpecEnum;
91 type SetValue = Self;
92 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
93
94 fn param_spec_builder() -> Self::BuilderFn {
95 Self::ParamSpec::builder_with_default
96 }
97}
98
99impl glib::value::ValueType for PlayColorBalanceType {
100 type Type = Self;
101}
102
103unsafe impl<'a> glib::value::FromValue<'a> for PlayColorBalanceType {
104 type Checker = glib::value::GenericValueTypeChecker<Self>;
105
106 #[inline]
107 unsafe fn from_value(value: &'a glib::Value) -> Self {
108 skip_assert_initialized!();
109 unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
110 }
111}
112
113impl ToValue for PlayColorBalanceType {
114 #[inline]
115 fn to_value(&self) -> glib::Value {
116 let mut value = glib::Value::for_value_type::<Self>();
117 unsafe {
118 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
119 }
120 value
121 }
122
123 #[inline]
124 fn value_type(&self) -> glib::Type {
125 Self::static_type()
126 }
127}
128
129impl From<PlayColorBalanceType> for glib::Value {
130 #[inline]
131 fn from(v: PlayColorBalanceType) -> Self {
132 skip_assert_initialized!();
133 ToValue::to_value(&v)
134 }
135}
136
137#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
138#[non_exhaustive]
139#[doc(alias = "GstPlayError")]
140pub enum PlayError {
141 #[doc(alias = "GST_PLAY_ERROR_FAILED")]
143 Failed,
144 #[doc(hidden)]
145 __Unknown(i32),
146}
147
148impl PlayError {
149 pub fn name<'a>(self) -> &'a GStr {
150 unsafe {
151 GStr::from_ptr(
152 ffi::gst_play_error_get_name(self.into_glib())
153 .as_ref()
154 .expect("gst_play_error_get_name returned NULL"),
155 )
156 }
157 }
158}
159
160impl std::fmt::Display for PlayError {
161 #[inline]
162 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163 f.write_str(&self.name())
164 }
165}
166
167#[doc(hidden)]
168impl IntoGlib for PlayError {
169 type GlibType = ffi::GstPlayError;
170
171 #[inline]
172 fn into_glib(self) -> ffi::GstPlayError {
173 match self {
174 Self::Failed => ffi::GST_PLAY_ERROR_FAILED,
175 Self::__Unknown(value) => value,
176 }
177 }
178}
179
180#[doc(hidden)]
181impl FromGlib<ffi::GstPlayError> for PlayError {
182 #[inline]
183 unsafe fn from_glib(value: ffi::GstPlayError) -> Self {
184 skip_assert_initialized!();
185
186 match value {
187 ffi::GST_PLAY_ERROR_FAILED => Self::Failed,
188 value => Self::__Unknown(value),
189 }
190 }
191}
192
193impl glib::error::ErrorDomain for PlayError {
194 #[inline]
195 fn domain() -> glib::Quark {
196 skip_assert_initialized!();
197
198 unsafe { from_glib(ffi::gst_play_error_quark()) }
199 }
200
201 #[inline]
202 fn code(self) -> i32 {
203 self.into_glib()
204 }
205
206 #[inline]
207 #[allow(clippy::match_single_binding)]
208 fn from(code: i32) -> Option<Self> {
209 skip_assert_initialized!();
210 match unsafe { from_glib(code) } {
211 Self::__Unknown(_) => Some(Self::Failed),
212 value => Some(value),
213 }
214 }
215}
216
217impl StaticType for PlayError {
218 #[inline]
219 #[doc(alias = "gst_play_error_get_type")]
220 fn static_type() -> glib::Type {
221 unsafe { from_glib(ffi::gst_play_error_get_type()) }
222 }
223}
224
225impl glib::HasParamSpec for PlayError {
226 type ParamSpec = glib::ParamSpecEnum;
227 type SetValue = Self;
228 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
229
230 fn param_spec_builder() -> Self::BuilderFn {
231 Self::ParamSpec::builder_with_default
232 }
233}
234
235impl glib::value::ValueType for PlayError {
236 type Type = Self;
237}
238
239unsafe impl<'a> glib::value::FromValue<'a> for PlayError {
240 type Checker = glib::value::GenericValueTypeChecker<Self>;
241
242 #[inline]
243 unsafe fn from_value(value: &'a glib::Value) -> Self {
244 skip_assert_initialized!();
245 unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
246 }
247}
248
249impl ToValue for PlayError {
250 #[inline]
251 fn to_value(&self) -> glib::Value {
252 let mut value = glib::Value::for_value_type::<Self>();
253 unsafe {
254 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
255 }
256 value
257 }
258
259 #[inline]
260 fn value_type(&self) -> glib::Type {
261 Self::static_type()
262 }
263}
264
265impl From<PlayError> for glib::Value {
266 #[inline]
267 fn from(v: PlayError) -> Self {
268 skip_assert_initialized!();
269 ToValue::to_value(&v)
270 }
271}
272
273#[cfg(feature = "v1_28")]
274#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
275#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
276#[non_exhaustive]
277#[doc(alias = "GstPlayLoop")]
278pub enum PlayLoop {
279 #[doc(alias = "GST_PLAY_LOOP_NONE")]
281 None,
282 #[doc(alias = "GST_PLAY_LOOP_TRACK")]
284 Track,
285 #[doc(hidden)]
286 __Unknown(i32),
287}
288
289#[cfg(feature = "v1_28")]
290#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
291impl PlayLoop {
292 pub fn name<'a>(self) -> &'a GStr {
293 unsafe {
294 GStr::from_ptr(
295 ffi::gst_play_loop_get_name(self.into_glib())
296 .as_ref()
297 .expect("gst_play_loop_get_name returned NULL"),
298 )
299 }
300 }
301}
302
303#[cfg(feature = "v1_28")]
304#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
305impl std::fmt::Display for PlayLoop {
306 #[inline]
307 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
308 f.write_str(&self.name())
309 }
310}
311
312#[cfg(feature = "v1_28")]
313#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
314#[doc(hidden)]
315impl IntoGlib for PlayLoop {
316 type GlibType = ffi::GstPlayLoop;
317
318 #[inline]
319 fn into_glib(self) -> ffi::GstPlayLoop {
320 match self {
321 Self::None => ffi::GST_PLAY_LOOP_NONE,
322 Self::Track => ffi::GST_PLAY_LOOP_TRACK,
323 Self::__Unknown(value) => value,
324 }
325 }
326}
327
328#[cfg(feature = "v1_28")]
329#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
330#[doc(hidden)]
331impl FromGlib<ffi::GstPlayLoop> for PlayLoop {
332 #[inline]
333 unsafe fn from_glib(value: ffi::GstPlayLoop) -> Self {
334 skip_assert_initialized!();
335
336 match value {
337 ffi::GST_PLAY_LOOP_NONE => Self::None,
338 ffi::GST_PLAY_LOOP_TRACK => Self::Track,
339 value => Self::__Unknown(value),
340 }
341 }
342}
343
344#[cfg(feature = "v1_28")]
345#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
346impl StaticType for PlayLoop {
347 #[inline]
348 #[doc(alias = "gst_play_loop_get_type")]
349 fn static_type() -> glib::Type {
350 unsafe { from_glib(ffi::gst_play_loop_get_type()) }
351 }
352}
353
354#[cfg(feature = "v1_28")]
355#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
356impl glib::HasParamSpec for PlayLoop {
357 type ParamSpec = glib::ParamSpecEnum;
358 type SetValue = Self;
359 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
360
361 fn param_spec_builder() -> Self::BuilderFn {
362 Self::ParamSpec::builder_with_default
363 }
364}
365
366#[cfg(feature = "v1_28")]
367#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
368impl glib::value::ValueType for PlayLoop {
369 type Type = Self;
370}
371
372#[cfg(feature = "v1_28")]
373#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
374unsafe impl<'a> glib::value::FromValue<'a> for PlayLoop {
375 type Checker = glib::value::GenericValueTypeChecker<Self>;
376
377 #[inline]
378 unsafe fn from_value(value: &'a glib::Value) -> Self {
379 skip_assert_initialized!();
380 unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
381 }
382}
383
384#[cfg(feature = "v1_28")]
385#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
386impl ToValue for PlayLoop {
387 #[inline]
388 fn to_value(&self) -> glib::Value {
389 let mut value = glib::Value::for_value_type::<Self>();
390 unsafe {
391 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
392 }
393 value
394 }
395
396 #[inline]
397 fn value_type(&self) -> glib::Type {
398 Self::static_type()
399 }
400}
401
402#[cfg(feature = "v1_28")]
403#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
404impl From<PlayLoop> for glib::Value {
405 #[inline]
406 fn from(v: PlayLoop) -> Self {
407 skip_assert_initialized!();
408 ToValue::to_value(&v)
409 }
410}
411
412#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
413#[non_exhaustive]
414#[doc(alias = "GstPlayMessage")]
415pub(crate) enum PlayMessage {
416 #[doc(alias = "GST_PLAY_MESSAGE_URI_LOADED")]
418 UriLoaded,
419 #[doc(alias = "GST_PLAY_MESSAGE_POSITION_UPDATED")]
421 PositionUpdated,
422 #[doc(alias = "GST_PLAY_MESSAGE_DURATION_CHANGED")]
424 DurationChanged,
425 #[doc(alias = "GST_PLAY_MESSAGE_STATE_CHANGED")]
427 StateChanged,
428 #[doc(alias = "GST_PLAY_MESSAGE_BUFFERING")]
430 Buffering,
431 #[doc(alias = "GST_PLAY_MESSAGE_END_OF_STREAM")]
433 EndOfStream,
434 #[doc(alias = "GST_PLAY_MESSAGE_ERROR")]
436 Error,
437 #[doc(alias = "GST_PLAY_MESSAGE_WARNING")]
439 Warning,
440 #[doc(alias = "GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED")]
442 VideoDimensionsChanged,
443 #[doc(alias = "GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED")]
445 MediaInfoUpdated,
446 #[doc(alias = "GST_PLAY_MESSAGE_VOLUME_CHANGED")]
448 VolumeChanged,
449 #[doc(alias = "GST_PLAY_MESSAGE_MUTE_CHANGED")]
451 MuteChanged,
452 #[doc(alias = "GST_PLAY_MESSAGE_SEEK_DONE")]
454 SeekDone,
455 #[cfg(feature = "v1_30")]
457 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
458 #[doc(alias = "GST_PLAY_MESSAGE_TRACKS_SELECTED")]
459 TracksSelected,
460 #[doc(hidden)]
461 __Unknown(i32),
462}
463
464impl PlayMessage {
465 pub fn name<'a>(self) -> &'a GStr {
466 unsafe {
467 GStr::from_ptr(
468 ffi::gst_play_message_get_name(self.into_glib())
469 .as_ref()
470 .expect("gst_play_message_get_name returned NULL"),
471 )
472 }
473 }
474
475 #[cfg(feature = "v1_26")]
476 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
477 #[doc(alias = "gst_play_message_parse_buffering")]
478 pub fn parse_buffering(msg: &gst::Message) -> u32 {
479 assert_initialized_main_thread!();
480 unsafe {
481 let mut percent = std::mem::MaybeUninit::uninit();
482 ffi::gst_play_message_parse_buffering(msg.to_glib_none().0, percent.as_mut_ptr());
483 percent.assume_init()
484 }
485 }
486
487 #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
488 #[allow(deprecated)]
489 #[doc(alias = "gst_play_message_parse_buffering_percent")]
490 pub fn parse_buffering_percent(msg: &gst::Message) -> u32 {
491 assert_initialized_main_thread!();
492 unsafe {
493 let mut percent = std::mem::MaybeUninit::uninit();
494 ffi::gst_play_message_parse_buffering_percent(
495 msg.to_glib_none().0,
496 percent.as_mut_ptr(),
497 );
498 percent.assume_init()
499 }
500 }
501
502 #[cfg(feature = "v1_26")]
503 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
504 #[doc(alias = "gst_play_message_parse_duration_changed")]
505 pub fn parse_duration_changed(msg: &gst::Message) -> Option<gst::ClockTime> {
506 assert_initialized_main_thread!();
507 unsafe {
508 let mut duration = std::mem::MaybeUninit::uninit();
509 ffi::gst_play_message_parse_duration_changed(
510 msg.to_glib_none().0,
511 duration.as_mut_ptr(),
512 );
513 from_glib(duration.assume_init())
514 }
515 }
516
517 #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
518 #[allow(deprecated)]
519 #[doc(alias = "gst_play_message_parse_duration_updated")]
520 pub fn parse_duration_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
521 assert_initialized_main_thread!();
522 unsafe {
523 let mut duration = std::mem::MaybeUninit::uninit();
524 ffi::gst_play_message_parse_duration_updated(
525 msg.to_glib_none().0,
526 duration.as_mut_ptr(),
527 );
528 from_glib(duration.assume_init())
529 }
530 }
531
532 #[doc(alias = "gst_play_message_parse_error")]
533 pub fn parse_error(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
534 assert_initialized_main_thread!();
535 unsafe {
536 let mut error = std::ptr::null_mut();
537 let mut details = std::ptr::null_mut();
538 ffi::gst_play_message_parse_error(msg.to_glib_none().0, &mut error, &mut details);
539 (from_glib_full(error), from_glib_full(details))
540 }
541 }
542
543 #[doc(alias = "gst_play_message_parse_media_info_updated")]
544 pub fn parse_media_info_updated(msg: &gst::Message) -> PlayMediaInfo {
545 assert_initialized_main_thread!();
546 unsafe {
547 let mut info = std::ptr::null_mut();
548 ffi::gst_play_message_parse_media_info_updated(msg.to_glib_none().0, &mut info);
549 from_glib_full(info)
550 }
551 }
552
553 #[doc(alias = "gst_play_message_parse_muted_changed")]
554 pub fn parse_muted_changed(msg: &gst::Message) -> bool {
555 assert_initialized_main_thread!();
556 unsafe {
557 let mut muted = std::mem::MaybeUninit::uninit();
558 ffi::gst_play_message_parse_muted_changed(msg.to_glib_none().0, muted.as_mut_ptr());
559 from_glib(muted.assume_init())
560 }
561 }
562
563 #[doc(alias = "gst_play_message_parse_position_updated")]
564 pub fn parse_position_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
565 assert_initialized_main_thread!();
566 unsafe {
567 let mut position = std::mem::MaybeUninit::uninit();
568 ffi::gst_play_message_parse_position_updated(
569 msg.to_glib_none().0,
570 position.as_mut_ptr(),
571 );
572 from_glib(position.assume_init())
573 }
574 }
575
576 #[cfg(feature = "v1_26")]
577 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
578 #[doc(alias = "gst_play_message_parse_seek_done")]
579 pub fn parse_seek_done(msg: &gst::Message) -> Option<gst::ClockTime> {
580 assert_initialized_main_thread!();
581 unsafe {
582 let mut position = std::mem::MaybeUninit::uninit();
583 ffi::gst_play_message_parse_seek_done(msg.to_glib_none().0, position.as_mut_ptr());
584 from_glib(position.assume_init())
585 }
586 }
587
588 #[doc(alias = "gst_play_message_parse_state_changed")]
589 pub fn parse_state_changed(msg: &gst::Message) -> PlayState {
590 assert_initialized_main_thread!();
591 unsafe {
592 let mut state = std::mem::MaybeUninit::uninit();
593 ffi::gst_play_message_parse_state_changed(msg.to_glib_none().0, state.as_mut_ptr());
594 from_glib(state.assume_init())
595 }
596 }
597
598 #[doc(alias = "gst_play_message_parse_type")]
599 pub fn parse_type(msg: &gst::Message) -> PlayMessage {
600 assert_initialized_main_thread!();
601 unsafe {
602 let mut type_ = std::mem::MaybeUninit::uninit();
603 ffi::gst_play_message_parse_type(msg.to_glib_none().0, type_.as_mut_ptr());
604 from_glib(type_.assume_init())
605 }
606 }
607
608 #[cfg(feature = "v1_26")]
609 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
610 #[doc(alias = "gst_play_message_parse_uri_loaded")]
611 pub fn parse_uri_loaded(msg: &gst::Message) -> glib::GString {
612 assert_initialized_main_thread!();
613 unsafe {
614 let mut uri = std::ptr::null_mut();
615 ffi::gst_play_message_parse_uri_loaded(msg.to_glib_none().0, &mut uri);
616 from_glib_full(uri)
617 }
618 }
619
620 #[doc(alias = "gst_play_message_parse_video_dimensions_changed")]
621 pub fn parse_video_dimensions_changed(msg: &gst::Message) -> (u32, u32) {
622 assert_initialized_main_thread!();
623 unsafe {
624 let mut width = std::mem::MaybeUninit::uninit();
625 let mut height = std::mem::MaybeUninit::uninit();
626 ffi::gst_play_message_parse_video_dimensions_changed(
627 msg.to_glib_none().0,
628 width.as_mut_ptr(),
629 height.as_mut_ptr(),
630 );
631 (width.assume_init(), height.assume_init())
632 }
633 }
634
635 #[doc(alias = "gst_play_message_parse_volume_changed")]
636 pub fn parse_volume_changed(msg: &gst::Message) -> f64 {
637 assert_initialized_main_thread!();
638 unsafe {
639 let mut volume = std::mem::MaybeUninit::uninit();
640 ffi::gst_play_message_parse_volume_changed(msg.to_glib_none().0, volume.as_mut_ptr());
641 volume.assume_init()
642 }
643 }
644
645 #[doc(alias = "gst_play_message_parse_warning")]
646 pub fn parse_warning(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
647 assert_initialized_main_thread!();
648 unsafe {
649 let mut error = std::ptr::null_mut();
650 let mut details = std::ptr::null_mut();
651 ffi::gst_play_message_parse_warning(msg.to_glib_none().0, &mut error, &mut details);
652 (from_glib_full(error), from_glib_full(details))
653 }
654 }
655}
656
657impl std::fmt::Display for PlayMessage {
658 #[inline]
659 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
660 f.write_str(&self.name())
661 }
662}
663
664#[doc(hidden)]
665impl IntoGlib for PlayMessage {
666 type GlibType = ffi::GstPlayMessage;
667
668 fn into_glib(self) -> ffi::GstPlayMessage {
669 match self {
670 Self::UriLoaded => ffi::GST_PLAY_MESSAGE_URI_LOADED,
671 Self::PositionUpdated => ffi::GST_PLAY_MESSAGE_POSITION_UPDATED,
672 Self::DurationChanged => ffi::GST_PLAY_MESSAGE_DURATION_CHANGED,
673 Self::StateChanged => ffi::GST_PLAY_MESSAGE_STATE_CHANGED,
674 Self::Buffering => ffi::GST_PLAY_MESSAGE_BUFFERING,
675 Self::EndOfStream => ffi::GST_PLAY_MESSAGE_END_OF_STREAM,
676 Self::Error => ffi::GST_PLAY_MESSAGE_ERROR,
677 Self::Warning => ffi::GST_PLAY_MESSAGE_WARNING,
678 Self::VideoDimensionsChanged => ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED,
679 Self::MediaInfoUpdated => ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED,
680 Self::VolumeChanged => ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED,
681 Self::MuteChanged => ffi::GST_PLAY_MESSAGE_MUTE_CHANGED,
682 Self::SeekDone => ffi::GST_PLAY_MESSAGE_SEEK_DONE,
683 #[cfg(feature = "v1_30")]
684 Self::TracksSelected => ffi::GST_PLAY_MESSAGE_TRACKS_SELECTED,
685 Self::__Unknown(value) => value,
686 }
687 }
688}
689
690#[doc(hidden)]
691impl FromGlib<ffi::GstPlayMessage> for PlayMessage {
692 unsafe fn from_glib(value: ffi::GstPlayMessage) -> Self {
693 skip_assert_initialized!();
694
695 match value {
696 ffi::GST_PLAY_MESSAGE_URI_LOADED => Self::UriLoaded,
697 ffi::GST_PLAY_MESSAGE_POSITION_UPDATED => Self::PositionUpdated,
698 ffi::GST_PLAY_MESSAGE_DURATION_CHANGED => Self::DurationChanged,
699 ffi::GST_PLAY_MESSAGE_STATE_CHANGED => Self::StateChanged,
700 ffi::GST_PLAY_MESSAGE_BUFFERING => Self::Buffering,
701 ffi::GST_PLAY_MESSAGE_END_OF_STREAM => Self::EndOfStream,
702 ffi::GST_PLAY_MESSAGE_ERROR => Self::Error,
703 ffi::GST_PLAY_MESSAGE_WARNING => Self::Warning,
704 ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED => Self::VideoDimensionsChanged,
705 ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED => Self::MediaInfoUpdated,
706 ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED => Self::VolumeChanged,
707 ffi::GST_PLAY_MESSAGE_MUTE_CHANGED => Self::MuteChanged,
708 ffi::GST_PLAY_MESSAGE_SEEK_DONE => Self::SeekDone,
709 #[cfg(feature = "v1_30")]
710 ffi::GST_PLAY_MESSAGE_TRACKS_SELECTED => Self::TracksSelected,
711 value => Self::__Unknown(value),
712 }
713 }
714}
715
716impl StaticType for PlayMessage {
717 #[inline]
718 #[doc(alias = "gst_play_message_get_type")]
719 fn static_type() -> glib::Type {
720 unsafe { from_glib(ffi::gst_play_message_get_type()) }
721 }
722}
723
724impl glib::HasParamSpec for PlayMessage {
725 type ParamSpec = glib::ParamSpecEnum;
726 type SetValue = Self;
727 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
728
729 fn param_spec_builder() -> Self::BuilderFn {
730 Self::ParamSpec::builder_with_default
731 }
732}
733
734impl glib::value::ValueType for PlayMessage {
735 type Type = Self;
736}
737
738unsafe impl<'a> glib::value::FromValue<'a> for PlayMessage {
739 type Checker = glib::value::GenericValueTypeChecker<Self>;
740
741 #[inline]
742 unsafe fn from_value(value: &'a glib::Value) -> Self {
743 skip_assert_initialized!();
744 unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
745 }
746}
747
748impl ToValue for PlayMessage {
749 #[inline]
750 fn to_value(&self) -> glib::Value {
751 let mut value = glib::Value::for_value_type::<Self>();
752 unsafe {
753 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
754 }
755 value
756 }
757
758 #[inline]
759 fn value_type(&self) -> glib::Type {
760 Self::static_type()
761 }
762}
763
764impl From<PlayMessage> for glib::Value {
765 #[inline]
766 fn from(v: PlayMessage) -> Self {
767 skip_assert_initialized!();
768 ToValue::to_value(&v)
769 }
770}
771
772#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
773#[non_exhaustive]
774#[doc(alias = "GstPlaySnapshotFormat")]
775pub enum PlaySnapshotFormat {
776 #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_NATIVE")]
778 RawNative,
779 #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_xRGB")]
781 RawXrgb,
782 #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_BGRx")]
784 RawBgrx,
785 #[doc(alias = "GST_PLAY_THUMBNAIL_JPG")]
787 Jpg,
788 #[doc(alias = "GST_PLAY_THUMBNAIL_PNG")]
790 Png,
791 #[doc(hidden)]
792 __Unknown(i32),
793}
794
795#[doc(hidden)]
796impl IntoGlib for PlaySnapshotFormat {
797 type GlibType = ffi::GstPlaySnapshotFormat;
798
799 #[inline]
800 fn into_glib(self) -> ffi::GstPlaySnapshotFormat {
801 match self {
802 Self::RawNative => ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE,
803 Self::RawXrgb => ffi::GST_PLAY_THUMBNAIL_RAW_xRGB,
804 Self::RawBgrx => ffi::GST_PLAY_THUMBNAIL_RAW_BGRx,
805 Self::Jpg => ffi::GST_PLAY_THUMBNAIL_JPG,
806 Self::Png => ffi::GST_PLAY_THUMBNAIL_PNG,
807 Self::__Unknown(value) => value,
808 }
809 }
810}
811
812#[doc(hidden)]
813impl FromGlib<ffi::GstPlaySnapshotFormat> for PlaySnapshotFormat {
814 #[inline]
815 unsafe fn from_glib(value: ffi::GstPlaySnapshotFormat) -> Self {
816 skip_assert_initialized!();
817
818 match value {
819 ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE => Self::RawNative,
820 ffi::GST_PLAY_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
821 ffi::GST_PLAY_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
822 ffi::GST_PLAY_THUMBNAIL_JPG => Self::Jpg,
823 ffi::GST_PLAY_THUMBNAIL_PNG => Self::Png,
824 value => Self::__Unknown(value),
825 }
826 }
827}
828
829#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
830#[non_exhaustive]
831#[doc(alias = "GstPlayState")]
832pub enum PlayState {
833 #[doc(alias = "GST_PLAY_STATE_STOPPED")]
835 Stopped,
836 #[doc(alias = "GST_PLAY_STATE_BUFFERING")]
838 Buffering,
839 #[doc(alias = "GST_PLAY_STATE_PAUSED")]
841 Paused,
842 #[doc(alias = "GST_PLAY_STATE_PLAYING")]
845 Playing,
846 #[doc(hidden)]
847 __Unknown(i32),
848}
849
850impl PlayState {
851 pub fn name<'a>(self) -> &'a GStr {
852 unsafe {
853 GStr::from_ptr(
854 ffi::gst_play_state_get_name(self.into_glib())
855 .as_ref()
856 .expect("gst_play_state_get_name returned NULL"),
857 )
858 }
859 }
860}
861
862impl std::fmt::Display for PlayState {
863 #[inline]
864 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
865 f.write_str(&self.name())
866 }
867}
868
869#[doc(hidden)]
870impl IntoGlib for PlayState {
871 type GlibType = ffi::GstPlayState;
872
873 #[inline]
874 fn into_glib(self) -> ffi::GstPlayState {
875 match self {
876 Self::Stopped => ffi::GST_PLAY_STATE_STOPPED,
877 Self::Buffering => ffi::GST_PLAY_STATE_BUFFERING,
878 Self::Paused => ffi::GST_PLAY_STATE_PAUSED,
879 Self::Playing => ffi::GST_PLAY_STATE_PLAYING,
880 Self::__Unknown(value) => value,
881 }
882 }
883}
884
885#[doc(hidden)]
886impl FromGlib<ffi::GstPlayState> for PlayState {
887 #[inline]
888 unsafe fn from_glib(value: ffi::GstPlayState) -> Self {
889 skip_assert_initialized!();
890
891 match value {
892 ffi::GST_PLAY_STATE_STOPPED => Self::Stopped,
893 ffi::GST_PLAY_STATE_BUFFERING => Self::Buffering,
894 ffi::GST_PLAY_STATE_PAUSED => Self::Paused,
895 ffi::GST_PLAY_STATE_PLAYING => Self::Playing,
896 value => Self::__Unknown(value),
897 }
898 }
899}
900
901impl StaticType for PlayState {
902 #[inline]
903 #[doc(alias = "gst_play_state_get_type")]
904 fn static_type() -> glib::Type {
905 unsafe { from_glib(ffi::gst_play_state_get_type()) }
906 }
907}
908
909impl glib::HasParamSpec for PlayState {
910 type ParamSpec = glib::ParamSpecEnum;
911 type SetValue = Self;
912 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
913
914 fn param_spec_builder() -> Self::BuilderFn {
915 Self::ParamSpec::builder_with_default
916 }
917}
918
919impl glib::value::ValueType for PlayState {
920 type Type = Self;
921}
922
923unsafe impl<'a> glib::value::FromValue<'a> for PlayState {
924 type Checker = glib::value::GenericValueTypeChecker<Self>;
925
926 #[inline]
927 unsafe fn from_value(value: &'a glib::Value) -> Self {
928 skip_assert_initialized!();
929 unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
930 }
931}
932
933impl ToValue for PlayState {
934 #[inline]
935 fn to_value(&self) -> glib::Value {
936 let mut value = glib::Value::for_value_type::<Self>();
937 unsafe {
938 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
939 }
940 value
941 }
942
943 #[inline]
944 fn value_type(&self) -> glib::Type {
945 Self::static_type()
946 }
947}
948
949impl From<PlayState> for glib::Value {
950 #[inline]
951 fn from(v: PlayState) -> Self {
952 skip_assert_initialized!();
953 ToValue::to_value(&v)
954 }
955}