1use crate::ffi;
7use glib::{prelude::*, translate::*, GStr};
8
9#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
10#[non_exhaustive]
11#[doc(alias = "GstPlayerColorBalanceType")]
12pub enum PlayerColorBalanceType {
13 #[doc(alias = "GST_PLAYER_COLOR_BALANCE_HUE")]
14 Hue,
15 #[doc(alias = "GST_PLAYER_COLOR_BALANCE_BRIGHTNESS")]
16 Brightness,
17 #[doc(alias = "GST_PLAYER_COLOR_BALANCE_SATURATION")]
18 Saturation,
19 #[doc(alias = "GST_PLAYER_COLOR_BALANCE_CONTRAST")]
20 Contrast,
21 #[doc(hidden)]
22 __Unknown(i32),
23}
24
25impl PlayerColorBalanceType {
26 pub fn name<'a>(self) -> &'a GStr {
27 unsafe {
28 GStr::from_ptr(
29 ffi::gst_player_color_balance_type_get_name(self.into_glib())
30 .as_ref()
31 .expect("gst_player_color_balance_type_get_name returned NULL"),
32 )
33 }
34 }
35}
36
37impl std::fmt::Display for PlayerColorBalanceType {
38 #[inline]
39 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
40 f.write_str(&self.name())
41 }
42}
43
44#[doc(hidden)]
45impl IntoGlib for PlayerColorBalanceType {
46 type GlibType = ffi::GstPlayerColorBalanceType;
47
48 #[inline]
49 fn into_glib(self) -> ffi::GstPlayerColorBalanceType {
50 match self {
51 Self::Hue => ffi::GST_PLAYER_COLOR_BALANCE_HUE,
52 Self::Brightness => ffi::GST_PLAYER_COLOR_BALANCE_BRIGHTNESS,
53 Self::Saturation => ffi::GST_PLAYER_COLOR_BALANCE_SATURATION,
54 Self::Contrast => ffi::GST_PLAYER_COLOR_BALANCE_CONTRAST,
55 Self::__Unknown(value) => value,
56 }
57 }
58}
59
60#[doc(hidden)]
61impl FromGlib<ffi::GstPlayerColorBalanceType> for PlayerColorBalanceType {
62 #[inline]
63 unsafe fn from_glib(value: ffi::GstPlayerColorBalanceType) -> Self {
64 skip_assert_initialized!();
65
66 match value {
67 ffi::GST_PLAYER_COLOR_BALANCE_HUE => Self::Hue,
68 ffi::GST_PLAYER_COLOR_BALANCE_BRIGHTNESS => Self::Brightness,
69 ffi::GST_PLAYER_COLOR_BALANCE_SATURATION => Self::Saturation,
70 ffi::GST_PLAYER_COLOR_BALANCE_CONTRAST => Self::Contrast,
71 value => Self::__Unknown(value),
72 }
73 }
74}
75
76impl StaticType for PlayerColorBalanceType {
77 #[inline]
78 #[doc(alias = "gst_player_color_balance_type_get_type")]
79 fn static_type() -> glib::Type {
80 unsafe { from_glib(ffi::gst_player_color_balance_type_get_type()) }
81 }
82}
83
84impl glib::HasParamSpec for PlayerColorBalanceType {
85 type ParamSpec = glib::ParamSpecEnum;
86 type SetValue = Self;
87 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
88
89 fn param_spec_builder() -> Self::BuilderFn {
90 Self::ParamSpec::builder_with_default
91 }
92}
93
94impl glib::value::ValueType for PlayerColorBalanceType {
95 type Type = Self;
96}
97
98unsafe impl<'a> glib::value::FromValue<'a> for PlayerColorBalanceType {
99 type Checker = glib::value::GenericValueTypeChecker<Self>;
100
101 #[inline]
102 unsafe fn from_value(value: &'a glib::Value) -> Self {
103 skip_assert_initialized!();
104 from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
105 }
106}
107
108impl ToValue for PlayerColorBalanceType {
109 #[inline]
110 fn to_value(&self) -> glib::Value {
111 let mut value = glib::Value::for_value_type::<Self>();
112 unsafe {
113 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
114 }
115 value
116 }
117
118 #[inline]
119 fn value_type(&self) -> glib::Type {
120 Self::static_type()
121 }
122}
123
124impl From<PlayerColorBalanceType> for glib::Value {
125 #[inline]
126 fn from(v: PlayerColorBalanceType) -> Self {
127 skip_assert_initialized!();
128 ToValue::to_value(&v)
129 }
130}
131
132#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
133#[non_exhaustive]
134#[doc(alias = "GstPlayerError")]
135pub enum PlayerError {
136 #[doc(alias = "GST_PLAYER_ERROR_FAILED")]
137 Failed,
138 #[doc(hidden)]
139 __Unknown(i32),
140}
141
142impl PlayerError {
143 pub fn name<'a>(self) -> &'a GStr {
144 unsafe {
145 GStr::from_ptr(
146 ffi::gst_player_error_get_name(self.into_glib())
147 .as_ref()
148 .expect("gst_player_error_get_name returned NULL"),
149 )
150 }
151 }
152}
153
154impl std::fmt::Display for PlayerError {
155 #[inline]
156 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
157 f.write_str(&self.name())
158 }
159}
160
161#[doc(hidden)]
162impl IntoGlib for PlayerError {
163 type GlibType = ffi::GstPlayerError;
164
165 #[inline]
166 fn into_glib(self) -> ffi::GstPlayerError {
167 match self {
168 Self::Failed => ffi::GST_PLAYER_ERROR_FAILED,
169 Self::__Unknown(value) => value,
170 }
171 }
172}
173
174#[doc(hidden)]
175impl FromGlib<ffi::GstPlayerError> for PlayerError {
176 #[inline]
177 unsafe fn from_glib(value: ffi::GstPlayerError) -> Self {
178 skip_assert_initialized!();
179
180 match value {
181 ffi::GST_PLAYER_ERROR_FAILED => Self::Failed,
182 value => Self::__Unknown(value),
183 }
184 }
185}
186
187impl glib::error::ErrorDomain for PlayerError {
188 #[inline]
189 fn domain() -> glib::Quark {
190 skip_assert_initialized!();
191
192 unsafe { from_glib(ffi::gst_player_error_quark()) }
193 }
194
195 #[inline]
196 fn code(self) -> i32 {
197 self.into_glib()
198 }
199
200 #[inline]
201 #[allow(clippy::match_single_binding)]
202 fn from(code: i32) -> Option<Self> {
203 skip_assert_initialized!();
204 match unsafe { from_glib(code) } {
205 Self::__Unknown(_) => Some(Self::Failed),
206 value => Some(value),
207 }
208 }
209}
210
211impl StaticType for PlayerError {
212 #[inline]
213 #[doc(alias = "gst_player_error_get_type")]
214 fn static_type() -> glib::Type {
215 unsafe { from_glib(ffi::gst_player_error_get_type()) }
216 }
217}
218
219impl glib::HasParamSpec for PlayerError {
220 type ParamSpec = glib::ParamSpecEnum;
221 type SetValue = Self;
222 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
223
224 fn param_spec_builder() -> Self::BuilderFn {
225 Self::ParamSpec::builder_with_default
226 }
227}
228
229impl glib::value::ValueType for PlayerError {
230 type Type = Self;
231}
232
233unsafe impl<'a> glib::value::FromValue<'a> for PlayerError {
234 type Checker = glib::value::GenericValueTypeChecker<Self>;
235
236 #[inline]
237 unsafe fn from_value(value: &'a glib::Value) -> Self {
238 skip_assert_initialized!();
239 from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
240 }
241}
242
243impl ToValue for PlayerError {
244 #[inline]
245 fn to_value(&self) -> glib::Value {
246 let mut value = glib::Value::for_value_type::<Self>();
247 unsafe {
248 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
249 }
250 value
251 }
252
253 #[inline]
254 fn value_type(&self) -> glib::Type {
255 Self::static_type()
256 }
257}
258
259impl From<PlayerError> for glib::Value {
260 #[inline]
261 fn from(v: PlayerError) -> Self {
262 skip_assert_initialized!();
263 ToValue::to_value(&v)
264 }
265}
266
267#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
268#[non_exhaustive]
269#[doc(alias = "GstPlayerSnapshotFormat")]
270pub enum PlayerSnapshotFormat {
271 #[doc(alias = "GST_PLAYER_THUMBNAIL_RAW_NATIVE")]
272 RawNative,
273 #[doc(alias = "GST_PLAYER_THUMBNAIL_RAW_xRGB")]
274 RawXrgb,
275 #[doc(alias = "GST_PLAYER_THUMBNAIL_RAW_BGRx")]
276 RawBgrx,
277 #[doc(alias = "GST_PLAYER_THUMBNAIL_JPG")]
278 Jpg,
279 #[doc(alias = "GST_PLAYER_THUMBNAIL_PNG")]
280 Png,
281 #[doc(hidden)]
282 __Unknown(i32),
283}
284
285#[doc(hidden)]
286impl IntoGlib for PlayerSnapshotFormat {
287 type GlibType = ffi::GstPlayerSnapshotFormat;
288
289 #[inline]
290 fn into_glib(self) -> ffi::GstPlayerSnapshotFormat {
291 match self {
292 Self::RawNative => ffi::GST_PLAYER_THUMBNAIL_RAW_NATIVE,
293 Self::RawXrgb => ffi::GST_PLAYER_THUMBNAIL_RAW_xRGB,
294 Self::RawBgrx => ffi::GST_PLAYER_THUMBNAIL_RAW_BGRx,
295 Self::Jpg => ffi::GST_PLAYER_THUMBNAIL_JPG,
296 Self::Png => ffi::GST_PLAYER_THUMBNAIL_PNG,
297 Self::__Unknown(value) => value,
298 }
299 }
300}
301
302#[doc(hidden)]
303impl FromGlib<ffi::GstPlayerSnapshotFormat> for PlayerSnapshotFormat {
304 #[inline]
305 unsafe fn from_glib(value: ffi::GstPlayerSnapshotFormat) -> Self {
306 skip_assert_initialized!();
307
308 match value {
309 ffi::GST_PLAYER_THUMBNAIL_RAW_NATIVE => Self::RawNative,
310 ffi::GST_PLAYER_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
311 ffi::GST_PLAYER_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
312 ffi::GST_PLAYER_THUMBNAIL_JPG => Self::Jpg,
313 ffi::GST_PLAYER_THUMBNAIL_PNG => Self::Png,
314 value => Self::__Unknown(value),
315 }
316 }
317}
318
319#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
320#[non_exhaustive]
321#[doc(alias = "GstPlayerState")]
322pub enum PlayerState {
323 #[doc(alias = "GST_PLAYER_STATE_STOPPED")]
324 Stopped,
325 #[doc(alias = "GST_PLAYER_STATE_BUFFERING")]
326 Buffering,
327 #[doc(alias = "GST_PLAYER_STATE_PAUSED")]
328 Paused,
329 #[doc(alias = "GST_PLAYER_STATE_PLAYING")]
330 Playing,
331 #[doc(hidden)]
332 __Unknown(i32),
333}
334
335impl PlayerState {
336 pub fn name<'a>(self) -> &'a GStr {
337 unsafe {
338 GStr::from_ptr(
339 ffi::gst_player_state_get_name(self.into_glib())
340 .as_ref()
341 .expect("gst_player_state_get_name returned NULL"),
342 )
343 }
344 }
345}
346
347impl std::fmt::Display for PlayerState {
348 #[inline]
349 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
350 f.write_str(&self.name())
351 }
352}
353
354#[doc(hidden)]
355impl IntoGlib for PlayerState {
356 type GlibType = ffi::GstPlayerState;
357
358 #[inline]
359 fn into_glib(self) -> ffi::GstPlayerState {
360 match self {
361 Self::Stopped => ffi::GST_PLAYER_STATE_STOPPED,
362 Self::Buffering => ffi::GST_PLAYER_STATE_BUFFERING,
363 Self::Paused => ffi::GST_PLAYER_STATE_PAUSED,
364 Self::Playing => ffi::GST_PLAYER_STATE_PLAYING,
365 Self::__Unknown(value) => value,
366 }
367 }
368}
369
370#[doc(hidden)]
371impl FromGlib<ffi::GstPlayerState> for PlayerState {
372 #[inline]
373 unsafe fn from_glib(value: ffi::GstPlayerState) -> Self {
374 skip_assert_initialized!();
375
376 match value {
377 ffi::GST_PLAYER_STATE_STOPPED => Self::Stopped,
378 ffi::GST_PLAYER_STATE_BUFFERING => Self::Buffering,
379 ffi::GST_PLAYER_STATE_PAUSED => Self::Paused,
380 ffi::GST_PLAYER_STATE_PLAYING => Self::Playing,
381 value => Self::__Unknown(value),
382 }
383 }
384}
385
386impl StaticType for PlayerState {
387 #[inline]
388 #[doc(alias = "gst_player_state_get_type")]
389 fn static_type() -> glib::Type {
390 unsafe { from_glib(ffi::gst_player_state_get_type()) }
391 }
392}
393
394impl glib::HasParamSpec for PlayerState {
395 type ParamSpec = glib::ParamSpecEnum;
396 type SetValue = Self;
397 type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
398
399 fn param_spec_builder() -> Self::BuilderFn {
400 Self::ParamSpec::builder_with_default
401 }
402}
403
404impl glib::value::ValueType for PlayerState {
405 type Type = Self;
406}
407
408unsafe impl<'a> glib::value::FromValue<'a> for PlayerState {
409 type Checker = glib::value::GenericValueTypeChecker<Self>;
410
411 #[inline]
412 unsafe fn from_value(value: &'a glib::Value) -> Self {
413 skip_assert_initialized!();
414 from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
415 }
416}
417
418impl ToValue for PlayerState {
419 #[inline]
420 fn to_value(&self) -> glib::Value {
421 let mut value = glib::Value::for_value_type::<Self>();
422 unsafe {
423 glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
424 }
425 value
426 }
427
428 #[inline]
429 fn value_type(&self) -> glib::Type {
430 Self::static_type()
431 }
432}
433
434impl From<PlayerState> for glib::Value {
435 #[inline]
436 fn from(v: PlayerState) -> Self {
437 skip_assert_initialized!();
438 ToValue::to_value(&v)
439 }
440}