1#![allow(deprecated)]
5
6use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GtkMediaStream")]
16 pub struct MediaStream(Object<ffi::GtkMediaStream, ffi::GtkMediaStreamClass>) @implements gdk::Paintable;
17
18 match fn {
19 type_ => || ffi::gtk_media_stream_get_type(),
20 }
21}
22
23impl MediaStream {
24 pub const NONE: Option<&'static MediaStream> = None;
25}
26
27mod sealed {
28 pub trait Sealed {}
29 impl<T: super::IsA<super::MediaStream>> Sealed for T {}
30}
31
32pub trait MediaStreamExt: IsA<MediaStream> + sealed::Sealed + 'static {
33 #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
34 #[allow(deprecated)]
35 #[doc(alias = "gtk_media_stream_ended")]
36 fn ended(&self) {
37 unsafe {
38 ffi::gtk_media_stream_ended(self.as_ref().to_glib_none().0);
39 }
40 }
41
42 #[doc(alias = "gtk_media_stream_get_duration")]
43 #[doc(alias = "get_duration")]
44 fn duration(&self) -> i64 {
45 unsafe { ffi::gtk_media_stream_get_duration(self.as_ref().to_glib_none().0) }
46 }
47
48 #[doc(alias = "gtk_media_stream_get_ended")]
49 #[doc(alias = "get_ended")]
50 #[doc(alias = "ended")]
51 fn is_ended(&self) -> bool {
52 unsafe {
53 from_glib(ffi::gtk_media_stream_get_ended(
54 self.as_ref().to_glib_none().0,
55 ))
56 }
57 }
58
59 #[doc(alias = "gtk_media_stream_get_error")]
60 #[doc(alias = "get_error")]
61 fn error(&self) -> Option<glib::Error> {
62 unsafe {
63 from_glib_none(ffi::gtk_media_stream_get_error(
64 self.as_ref().to_glib_none().0,
65 ))
66 }
67 }
68
69 #[doc(alias = "gtk_media_stream_get_loop")]
70 #[doc(alias = "get_loop")]
71 #[doc(alias = "loop")]
72 fn is_loop(&self) -> bool {
73 unsafe {
74 from_glib(ffi::gtk_media_stream_get_loop(
75 self.as_ref().to_glib_none().0,
76 ))
77 }
78 }
79
80 #[doc(alias = "gtk_media_stream_get_muted")]
81 #[doc(alias = "get_muted")]
82 #[doc(alias = "muted")]
83 fn is_muted(&self) -> bool {
84 unsafe {
85 from_glib(ffi::gtk_media_stream_get_muted(
86 self.as_ref().to_glib_none().0,
87 ))
88 }
89 }
90
91 #[doc(alias = "gtk_media_stream_get_playing")]
92 #[doc(alias = "get_playing")]
93 #[doc(alias = "playing")]
94 fn is_playing(&self) -> bool {
95 unsafe {
96 from_glib(ffi::gtk_media_stream_get_playing(
97 self.as_ref().to_glib_none().0,
98 ))
99 }
100 }
101
102 #[doc(alias = "gtk_media_stream_get_timestamp")]
103 #[doc(alias = "get_timestamp")]
104 fn timestamp(&self) -> i64 {
105 unsafe { ffi::gtk_media_stream_get_timestamp(self.as_ref().to_glib_none().0) }
106 }
107
108 #[doc(alias = "gtk_media_stream_get_volume")]
109 #[doc(alias = "get_volume")]
110 fn volume(&self) -> f64 {
111 unsafe { ffi::gtk_media_stream_get_volume(self.as_ref().to_glib_none().0) }
112 }
113
114 #[doc(alias = "gtk_media_stream_has_audio")]
115 #[doc(alias = "has-audio")]
116 fn has_audio(&self) -> bool {
117 unsafe {
118 from_glib(ffi::gtk_media_stream_has_audio(
119 self.as_ref().to_glib_none().0,
120 ))
121 }
122 }
123
124 #[doc(alias = "gtk_media_stream_has_video")]
125 #[doc(alias = "has-video")]
126 fn has_video(&self) -> bool {
127 unsafe {
128 from_glib(ffi::gtk_media_stream_has_video(
129 self.as_ref().to_glib_none().0,
130 ))
131 }
132 }
133
134 #[doc(alias = "gtk_media_stream_is_prepared")]
135 #[doc(alias = "prepared")]
136 fn is_prepared(&self) -> bool {
137 unsafe {
138 from_glib(ffi::gtk_media_stream_is_prepared(
139 self.as_ref().to_glib_none().0,
140 ))
141 }
142 }
143
144 #[doc(alias = "gtk_media_stream_is_seekable")]
145 #[doc(alias = "seekable")]
146 fn is_seekable(&self) -> bool {
147 unsafe {
148 from_glib(ffi::gtk_media_stream_is_seekable(
149 self.as_ref().to_glib_none().0,
150 ))
151 }
152 }
153
154 #[doc(alias = "gtk_media_stream_is_seeking")]
155 #[doc(alias = "seeking")]
156 fn is_seeking(&self) -> bool {
157 unsafe {
158 from_glib(ffi::gtk_media_stream_is_seeking(
159 self.as_ref().to_glib_none().0,
160 ))
161 }
162 }
163
164 #[doc(alias = "gtk_media_stream_pause")]
165 fn pause(&self) {
166 unsafe {
167 ffi::gtk_media_stream_pause(self.as_ref().to_glib_none().0);
168 }
169 }
170
171 #[doc(alias = "gtk_media_stream_play")]
172 fn play(&self) {
173 unsafe {
174 ffi::gtk_media_stream_play(self.as_ref().to_glib_none().0);
175 }
176 }
177
178 #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
179 #[allow(deprecated)]
180 #[doc(alias = "gtk_media_stream_prepared")]
181 fn prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64) {
182 unsafe {
183 ffi::gtk_media_stream_prepared(
184 self.as_ref().to_glib_none().0,
185 has_audio.into_glib(),
186 has_video.into_glib(),
187 seekable.into_glib(),
188 duration,
189 );
190 }
191 }
192
193 #[doc(alias = "gtk_media_stream_realize")]
194 fn realize(&self, surface: &impl IsA<gdk::Surface>) {
195 unsafe {
196 ffi::gtk_media_stream_realize(
197 self.as_ref().to_glib_none().0,
198 surface.as_ref().to_glib_none().0,
199 );
200 }
201 }
202
203 #[doc(alias = "gtk_media_stream_seek")]
204 fn seek(&self, timestamp: i64) {
205 unsafe {
206 ffi::gtk_media_stream_seek(self.as_ref().to_glib_none().0, timestamp);
207 }
208 }
209
210 #[doc(alias = "gtk_media_stream_seek_failed")]
211 fn seek_failed(&self) {
212 unsafe {
213 ffi::gtk_media_stream_seek_failed(self.as_ref().to_glib_none().0);
214 }
215 }
216
217 #[doc(alias = "gtk_media_stream_seek_success")]
218 fn seek_success(&self) {
219 unsafe {
220 ffi::gtk_media_stream_seek_success(self.as_ref().to_glib_none().0);
221 }
222 }
223
224 #[doc(alias = "gtk_media_stream_set_loop")]
225 #[doc(alias = "loop")]
226 fn set_loop(&self, loop_: bool) {
227 unsafe {
228 ffi::gtk_media_stream_set_loop(self.as_ref().to_glib_none().0, loop_.into_glib());
229 }
230 }
231
232 #[doc(alias = "gtk_media_stream_set_muted")]
233 #[doc(alias = "muted")]
234 fn set_muted(&self, muted: bool) {
235 unsafe {
236 ffi::gtk_media_stream_set_muted(self.as_ref().to_glib_none().0, muted.into_glib());
237 }
238 }
239
240 #[doc(alias = "gtk_media_stream_set_playing")]
241 #[doc(alias = "playing")]
242 fn set_playing(&self, playing: bool) {
243 unsafe {
244 ffi::gtk_media_stream_set_playing(self.as_ref().to_glib_none().0, playing.into_glib());
245 }
246 }
247
248 #[doc(alias = "gtk_media_stream_set_volume")]
249 #[doc(alias = "volume")]
250 fn set_volume(&self, volume: f64) {
251 unsafe {
252 ffi::gtk_media_stream_set_volume(self.as_ref().to_glib_none().0, volume);
253 }
254 }
255
256 #[cfg(feature = "v4_4")]
257 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
258 #[doc(alias = "gtk_media_stream_stream_ended")]
259 fn stream_ended(&self) {
260 unsafe {
261 ffi::gtk_media_stream_stream_ended(self.as_ref().to_glib_none().0);
262 }
263 }
264
265 #[cfg(feature = "v4_4")]
266 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
267 #[doc(alias = "gtk_media_stream_stream_prepared")]
268 fn stream_prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64) {
269 unsafe {
270 ffi::gtk_media_stream_stream_prepared(
271 self.as_ref().to_glib_none().0,
272 has_audio.into_glib(),
273 has_video.into_glib(),
274 seekable.into_glib(),
275 duration,
276 );
277 }
278 }
279
280 #[cfg(feature = "v4_4")]
281 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
282 #[doc(alias = "gtk_media_stream_stream_unprepared")]
283 fn stream_unprepared(&self) {
284 unsafe {
285 ffi::gtk_media_stream_stream_unprepared(self.as_ref().to_glib_none().0);
286 }
287 }
288
289 #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
290 #[allow(deprecated)]
291 #[doc(alias = "gtk_media_stream_unprepared")]
292 fn unprepared(&self) {
293 unsafe {
294 ffi::gtk_media_stream_unprepared(self.as_ref().to_glib_none().0);
295 }
296 }
297
298 #[doc(alias = "gtk_media_stream_unrealize")]
299 fn unrealize(&self, surface: &impl IsA<gdk::Surface>) {
300 unsafe {
301 ffi::gtk_media_stream_unrealize(
302 self.as_ref().to_glib_none().0,
303 surface.as_ref().to_glib_none().0,
304 );
305 }
306 }
307
308 #[doc(alias = "gtk_media_stream_update")]
309 fn update(&self, timestamp: i64) {
310 unsafe {
311 ffi::gtk_media_stream_update(self.as_ref().to_glib_none().0, timestamp);
312 }
313 }
314
315 fn set_prepared(&self, prepared: bool) {
316 ObjectExt::set_property(self.as_ref(), "prepared", prepared)
317 }
318
319 #[doc(alias = "duration")]
320 fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
321 unsafe extern "C" fn notify_duration_trampoline<
322 P: IsA<MediaStream>,
323 F: Fn(&P) + 'static,
324 >(
325 this: *mut ffi::GtkMediaStream,
326 _param_spec: glib::ffi::gpointer,
327 f: glib::ffi::gpointer,
328 ) {
329 let f: &F = &*(f as *const F);
330 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
331 }
332 unsafe {
333 let f: Box_<F> = Box_::new(f);
334 connect_raw(
335 self.as_ptr() as *mut _,
336 b"notify::duration\0".as_ptr() as *const _,
337 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
338 notify_duration_trampoline::<Self, F> as *const (),
339 )),
340 Box_::into_raw(f),
341 )
342 }
343 }
344
345 #[doc(alias = "ended")]
346 fn connect_ended_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
347 unsafe extern "C" fn notify_ended_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
348 this: *mut ffi::GtkMediaStream,
349 _param_spec: glib::ffi::gpointer,
350 f: glib::ffi::gpointer,
351 ) {
352 let f: &F = &*(f as *const F);
353 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
354 }
355 unsafe {
356 let f: Box_<F> = Box_::new(f);
357 connect_raw(
358 self.as_ptr() as *mut _,
359 b"notify::ended\0".as_ptr() as *const _,
360 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
361 notify_ended_trampoline::<Self, F> as *const (),
362 )),
363 Box_::into_raw(f),
364 )
365 }
366 }
367
368 #[doc(alias = "error")]
369 fn connect_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
370 unsafe extern "C" fn notify_error_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
371 this: *mut ffi::GtkMediaStream,
372 _param_spec: glib::ffi::gpointer,
373 f: glib::ffi::gpointer,
374 ) {
375 let f: &F = &*(f as *const F);
376 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
377 }
378 unsafe {
379 let f: Box_<F> = Box_::new(f);
380 connect_raw(
381 self.as_ptr() as *mut _,
382 b"notify::error\0".as_ptr() as *const _,
383 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
384 notify_error_trampoline::<Self, F> as *const (),
385 )),
386 Box_::into_raw(f),
387 )
388 }
389 }
390
391 #[doc(alias = "has-audio")]
392 fn connect_has_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
393 unsafe extern "C" fn notify_has_audio_trampoline<
394 P: IsA<MediaStream>,
395 F: Fn(&P) + 'static,
396 >(
397 this: *mut ffi::GtkMediaStream,
398 _param_spec: glib::ffi::gpointer,
399 f: glib::ffi::gpointer,
400 ) {
401 let f: &F = &*(f as *const F);
402 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
403 }
404 unsafe {
405 let f: Box_<F> = Box_::new(f);
406 connect_raw(
407 self.as_ptr() as *mut _,
408 b"notify::has-audio\0".as_ptr() as *const _,
409 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
410 notify_has_audio_trampoline::<Self, F> as *const (),
411 )),
412 Box_::into_raw(f),
413 )
414 }
415 }
416
417 #[doc(alias = "has-video")]
418 fn connect_has_video_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
419 unsafe extern "C" fn notify_has_video_trampoline<
420 P: IsA<MediaStream>,
421 F: Fn(&P) + 'static,
422 >(
423 this: *mut ffi::GtkMediaStream,
424 _param_spec: glib::ffi::gpointer,
425 f: glib::ffi::gpointer,
426 ) {
427 let f: &F = &*(f as *const F);
428 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
429 }
430 unsafe {
431 let f: Box_<F> = Box_::new(f);
432 connect_raw(
433 self.as_ptr() as *mut _,
434 b"notify::has-video\0".as_ptr() as *const _,
435 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
436 notify_has_video_trampoline::<Self, F> as *const (),
437 )),
438 Box_::into_raw(f),
439 )
440 }
441 }
442
443 #[doc(alias = "loop")]
444 fn connect_loop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
445 unsafe extern "C" fn notify_loop_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
446 this: *mut ffi::GtkMediaStream,
447 _param_spec: glib::ffi::gpointer,
448 f: glib::ffi::gpointer,
449 ) {
450 let f: &F = &*(f as *const F);
451 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
452 }
453 unsafe {
454 let f: Box_<F> = Box_::new(f);
455 connect_raw(
456 self.as_ptr() as *mut _,
457 b"notify::loop\0".as_ptr() as *const _,
458 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
459 notify_loop_trampoline::<Self, F> as *const (),
460 )),
461 Box_::into_raw(f),
462 )
463 }
464 }
465
466 #[doc(alias = "muted")]
467 fn connect_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
468 unsafe extern "C" fn notify_muted_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
469 this: *mut ffi::GtkMediaStream,
470 _param_spec: glib::ffi::gpointer,
471 f: glib::ffi::gpointer,
472 ) {
473 let f: &F = &*(f as *const F);
474 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
475 }
476 unsafe {
477 let f: Box_<F> = Box_::new(f);
478 connect_raw(
479 self.as_ptr() as *mut _,
480 b"notify::muted\0".as_ptr() as *const _,
481 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
482 notify_muted_trampoline::<Self, F> as *const (),
483 )),
484 Box_::into_raw(f),
485 )
486 }
487 }
488
489 #[doc(alias = "playing")]
490 fn connect_playing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
491 unsafe extern "C" fn notify_playing_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
492 this: *mut ffi::GtkMediaStream,
493 _param_spec: glib::ffi::gpointer,
494 f: glib::ffi::gpointer,
495 ) {
496 let f: &F = &*(f as *const F);
497 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
498 }
499 unsafe {
500 let f: Box_<F> = Box_::new(f);
501 connect_raw(
502 self.as_ptr() as *mut _,
503 b"notify::playing\0".as_ptr() as *const _,
504 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
505 notify_playing_trampoline::<Self, F> as *const (),
506 )),
507 Box_::into_raw(f),
508 )
509 }
510 }
511
512 #[doc(alias = "prepared")]
513 fn connect_prepared_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
514 unsafe extern "C" fn notify_prepared_trampoline<
515 P: IsA<MediaStream>,
516 F: Fn(&P) + 'static,
517 >(
518 this: *mut ffi::GtkMediaStream,
519 _param_spec: glib::ffi::gpointer,
520 f: glib::ffi::gpointer,
521 ) {
522 let f: &F = &*(f as *const F);
523 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
524 }
525 unsafe {
526 let f: Box_<F> = Box_::new(f);
527 connect_raw(
528 self.as_ptr() as *mut _,
529 b"notify::prepared\0".as_ptr() as *const _,
530 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
531 notify_prepared_trampoline::<Self, F> as *const (),
532 )),
533 Box_::into_raw(f),
534 )
535 }
536 }
537
538 #[doc(alias = "seekable")]
539 fn connect_seekable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
540 unsafe extern "C" fn notify_seekable_trampoline<
541 P: IsA<MediaStream>,
542 F: Fn(&P) + 'static,
543 >(
544 this: *mut ffi::GtkMediaStream,
545 _param_spec: glib::ffi::gpointer,
546 f: glib::ffi::gpointer,
547 ) {
548 let f: &F = &*(f as *const F);
549 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
550 }
551 unsafe {
552 let f: Box_<F> = Box_::new(f);
553 connect_raw(
554 self.as_ptr() as *mut _,
555 b"notify::seekable\0".as_ptr() as *const _,
556 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
557 notify_seekable_trampoline::<Self, F> as *const (),
558 )),
559 Box_::into_raw(f),
560 )
561 }
562 }
563
564 #[doc(alias = "seeking")]
565 fn connect_seeking_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
566 unsafe extern "C" fn notify_seeking_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
567 this: *mut ffi::GtkMediaStream,
568 _param_spec: glib::ffi::gpointer,
569 f: glib::ffi::gpointer,
570 ) {
571 let f: &F = &*(f as *const F);
572 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
573 }
574 unsafe {
575 let f: Box_<F> = Box_::new(f);
576 connect_raw(
577 self.as_ptr() as *mut _,
578 b"notify::seeking\0".as_ptr() as *const _,
579 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
580 notify_seeking_trampoline::<Self, F> as *const (),
581 )),
582 Box_::into_raw(f),
583 )
584 }
585 }
586
587 #[doc(alias = "timestamp")]
588 fn connect_timestamp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
589 unsafe extern "C" fn notify_timestamp_trampoline<
590 P: IsA<MediaStream>,
591 F: Fn(&P) + 'static,
592 >(
593 this: *mut ffi::GtkMediaStream,
594 _param_spec: glib::ffi::gpointer,
595 f: glib::ffi::gpointer,
596 ) {
597 let f: &F = &*(f as *const F);
598 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
599 }
600 unsafe {
601 let f: Box_<F> = Box_::new(f);
602 connect_raw(
603 self.as_ptr() as *mut _,
604 b"notify::timestamp\0".as_ptr() as *const _,
605 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
606 notify_timestamp_trampoline::<Self, F> as *const (),
607 )),
608 Box_::into_raw(f),
609 )
610 }
611 }
612
613 #[doc(alias = "volume")]
614 fn connect_volume_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
615 unsafe extern "C" fn notify_volume_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
616 this: *mut ffi::GtkMediaStream,
617 _param_spec: glib::ffi::gpointer,
618 f: glib::ffi::gpointer,
619 ) {
620 let f: &F = &*(f as *const F);
621 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
622 }
623 unsafe {
624 let f: Box_<F> = Box_::new(f);
625 connect_raw(
626 self.as_ptr() as *mut _,
627 b"notify::volume\0".as_ptr() as *const _,
628 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
629 notify_volume_trampoline::<Self, F> as *const (),
630 )),
631 Box_::into_raw(f),
632 )
633 }
634 }
635}
636
637impl<O: IsA<MediaStream>> MediaStreamExt for O {}