Skip to main content

gstreamer_mse/auto/
source_buffer_list.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{SourceBuffer, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstSourceBufferList")]
17    pub struct SourceBufferList(Object<ffi::GstSourceBufferList, ffi::GstSourceBufferListClass>) @extends gst::Object;
18
19    match fn {
20        type_ => || ffi::gst_source_buffer_list_get_type(),
21    }
22}
23
24impl SourceBufferList {
25    #[doc(alias = "gst_source_buffer_list_get_length")]
26    #[doc(alias = "get_length")]
27    pub fn length(&self) -> u32 {
28        unsafe { ffi::gst_source_buffer_list_get_length(self.to_glib_none().0) }
29    }
30
31    #[doc(alias = "gst_source_buffer_list_index")]
32    pub fn index(&self, index: u32) -> Option<SourceBuffer> {
33        unsafe {
34            from_glib_full(ffi::gst_source_buffer_list_index(
35                self.to_glib_none().0,
36                index,
37            ))
38        }
39    }
40
41    #[doc(alias = "on-sourcebuffer-added")]
42    pub fn connect_on_sourcebuffer_added<F: Fn(&Self) + Send + Sync + 'static>(
43        &self,
44        f: F,
45    ) -> SignalHandlerId {
46        unsafe extern "C" fn on_sourcebuffer_added_trampoline<
47            F: Fn(&SourceBufferList) + Send + Sync + 'static,
48        >(
49            this: *mut ffi::GstSourceBufferList,
50            f: glib::ffi::gpointer,
51        ) {
52            unsafe {
53                let f: &F = &*(f as *const F);
54                f(&from_glib_borrow(this))
55            }
56        }
57        unsafe {
58            let f: Box_<F> = Box_::new(f);
59            connect_raw(
60                self.as_ptr() as *mut _,
61                c"on-sourcebuffer-added".as_ptr(),
62                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
63                    on_sourcebuffer_added_trampoline::<F> as *const (),
64                )),
65                Box_::into_raw(f),
66            )
67        }
68    }
69
70    #[doc(alias = "on-sourcebuffer-removed")]
71    pub fn connect_on_sourcebuffer_removed<F: Fn(&Self) + Send + Sync + 'static>(
72        &self,
73        f: F,
74    ) -> SignalHandlerId {
75        unsafe extern "C" fn on_sourcebuffer_removed_trampoline<
76            F: Fn(&SourceBufferList) + Send + Sync + 'static,
77        >(
78            this: *mut ffi::GstSourceBufferList,
79            f: glib::ffi::gpointer,
80        ) {
81            unsafe {
82                let f: &F = &*(f as *const F);
83                f(&from_glib_borrow(this))
84            }
85        }
86        unsafe {
87            let f: Box_<F> = Box_::new(f);
88            connect_raw(
89                self.as_ptr() as *mut _,
90                c"on-sourcebuffer-removed".as_ptr(),
91                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
92                    on_sourcebuffer_removed_trampoline::<F> as *const (),
93                )),
94                Box_::into_raw(f),
95            )
96        }
97    }
98
99    #[doc(alias = "length")]
100    pub fn connect_length_notify<F: Fn(&Self) + Send + Sync + 'static>(
101        &self,
102        f: F,
103    ) -> SignalHandlerId {
104        unsafe extern "C" fn notify_length_trampoline<
105            F: Fn(&SourceBufferList) + Send + Sync + 'static,
106        >(
107            this: *mut ffi::GstSourceBufferList,
108            _param_spec: glib::ffi::gpointer,
109            f: glib::ffi::gpointer,
110        ) {
111            unsafe {
112                let f: &F = &*(f as *const F);
113                f(&from_glib_borrow(this))
114            }
115        }
116        unsafe {
117            let f: Box_<F> = Box_::new(f);
118            connect_raw(
119                self.as_ptr() as *mut _,
120                c"notify::length".as_ptr(),
121                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
122                    notify_length_trampoline::<F> as *const (),
123                )),
124                Box_::into_raw(f),
125            )
126        }
127    }
128}
129
130unsafe impl Send for SourceBufferList {}
131unsafe impl Sync for SourceBufferList {}