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 /// s through [`source-buffers`][struct@crate::MediaSource#source-buffers] as well as
17 /// informing clients which of the Source Buffers are active through
18 /// [`active-source-buffers`][struct@crate::MediaSource#active-source-buffers].
19 ///
20 /// ## Properties
21 ///
22 ///
23 /// #### `length`
24 /// s contained by this structure
25 ///
26 /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-sourcebufferlist-length)
27 ///
28 /// Readable
29 /// <details><summary><h4>Object</h4></summary>
30 ///
31 ///
32 /// #### `name`
33 /// Readable | Writable | Construct
34 ///
35 ///
36 /// #### `parent`
37 /// The parent of the object. Please note, that when changing the 'parent'
38 /// property, we don't emit `GObject::notify` and [`deep-notify`][struct@crate::gst::Object#deep-notify]
39 /// signals due to locking issues. In some cases one can use
40 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
41 /// achieve a similar effect.
42 ///
43 /// Readable | Writable
44 /// </details>
45 ///
46 /// ## Signals
47 ///
48 ///
49 /// #### `on-sourcebuffer-added`
50 /// Emitted when a [`SourceBuffer`][crate::SourceBuffer] has been added to this list.
51 ///
52 /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-sourcebufferlist-onaddsourcebuffer)
53 ///
54 ///
55 ///
56 ///
57 /// #### `on-sourcebuffer-removed`
58 /// Emitted when a [`SourceBuffer`][crate::SourceBuffer] has been removed from this list.
59 ///
60 /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-sourcebufferlist-onremovesourcebuffer)
61 ///
62 ///
63 /// <details><summary><h4>Object</h4></summary>
64 ///
65 ///
66 /// #### `deep-notify`
67 /// The deep notify signal is used to be notified of property changes. It is
68 /// typically attached to the toplevel bin to receive notifications from all
69 /// the elements contained in that bin.
70 ///
71 /// Detailed
72 /// </details>
73 ///
74 /// # Implements
75 ///
76 /// [`trait@gst::prelude::ObjectExt`]
77 #[doc(alias = "GstSourceBufferList")]
78 pub struct SourceBufferList(Object<ffi::GstSourceBufferList, ffi::GstSourceBufferListClass>) @extends gst::Object;
79
80 match fn {
81 type_ => || ffi::gst_source_buffer_list_get_type(),
82 }
83}
84
85impl SourceBufferList {
86 /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-sourcebufferlist-length)
87 ///
88 /// # Returns
89 ///
90 /// The number of [`SourceBuffer`][crate::SourceBuffer] objects in the list
91 #[doc(alias = "gst_source_buffer_list_get_length")]
92 #[doc(alias = "get_length")]
93 pub fn length(&self) -> u32 {
94 unsafe { ffi::gst_source_buffer_list_get_length(self.to_glib_none().0) }
95 }
96
97 /// Retrieves the [`SourceBuffer`][crate::SourceBuffer] at `index` from `self`. If `index` is greater than
98 /// the highest index in the list, it will return `NULL`.
99 ///
100 /// [Specification](https://www.w3.org/TR/media-source-2/`dfn`-sourcebufferlist-getter)
101 /// ## `index`
102 /// index of requested Source Buffer
103 ///
104 /// # Returns
105 ///
106 /// The requested [`SourceBuffer`][crate::SourceBuffer] or `NULL`
107 #[doc(alias = "gst_source_buffer_list_index")]
108 pub fn index(&self, index: u32) -> Option<SourceBuffer> {
109 unsafe {
110 from_glib_full(ffi::gst_source_buffer_list_index(
111 self.to_glib_none().0,
112 index,
113 ))
114 }
115 }
116
117 /// Emitted when a [`SourceBuffer`][crate::SourceBuffer] has been added to this list.
118 ///
119 /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-sourcebufferlist-onaddsourcebuffer)
120 #[doc(alias = "on-sourcebuffer-added")]
121 pub fn connect_on_sourcebuffer_added<F: Fn(&Self) + Send + Sync + 'static>(
122 &self,
123 f: F,
124 ) -> SignalHandlerId {
125 unsafe extern "C" fn on_sourcebuffer_added_trampoline<
126 F: Fn(&SourceBufferList) + Send + Sync + 'static,
127 >(
128 this: *mut ffi::GstSourceBufferList,
129 f: glib::ffi::gpointer,
130 ) {
131 unsafe {
132 let f: &F = &*(f as *const F);
133 f(&from_glib_borrow(this))
134 }
135 }
136 unsafe {
137 let f: Box_<F> = Box_::new(f);
138 connect_raw(
139 self.as_ptr() as *mut _,
140 c"on-sourcebuffer-added".as_ptr(),
141 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
142 on_sourcebuffer_added_trampoline::<F> as *const (),
143 )),
144 Box_::into_raw(f),
145 )
146 }
147 }
148
149 /// Emitted when a [`SourceBuffer`][crate::SourceBuffer] has been removed from this list.
150 ///
151 /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-sourcebufferlist-onremovesourcebuffer)
152 #[doc(alias = "on-sourcebuffer-removed")]
153 pub fn connect_on_sourcebuffer_removed<F: Fn(&Self) + Send + Sync + 'static>(
154 &self,
155 f: F,
156 ) -> SignalHandlerId {
157 unsafe extern "C" fn on_sourcebuffer_removed_trampoline<
158 F: Fn(&SourceBufferList) + Send + Sync + 'static,
159 >(
160 this: *mut ffi::GstSourceBufferList,
161 f: glib::ffi::gpointer,
162 ) {
163 unsafe {
164 let f: &F = &*(f as *const F);
165 f(&from_glib_borrow(this))
166 }
167 }
168 unsafe {
169 let f: Box_<F> = Box_::new(f);
170 connect_raw(
171 self.as_ptr() as *mut _,
172 c"on-sourcebuffer-removed".as_ptr(),
173 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
174 on_sourcebuffer_removed_trampoline::<F> as *const (),
175 )),
176 Box_::into_raw(f),
177 )
178 }
179 }
180
181 #[doc(alias = "length")]
182 pub fn connect_length_notify<F: Fn(&Self) + Send + Sync + 'static>(
183 &self,
184 f: F,
185 ) -> SignalHandlerId {
186 unsafe extern "C" fn notify_length_trampoline<
187 F: Fn(&SourceBufferList) + Send + Sync + 'static,
188 >(
189 this: *mut ffi::GstSourceBufferList,
190 _param_spec: glib::ffi::gpointer,
191 f: glib::ffi::gpointer,
192 ) {
193 unsafe {
194 let f: &F = &*(f as *const F);
195 f(&from_glib_borrow(this))
196 }
197 }
198 unsafe {
199 let f: Box_<F> = Box_::new(f);
200 connect_raw(
201 self.as_ptr() as *mut _,
202 c"notify::length".as_ptr(),
203 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
204 notify_length_trampoline::<F> as *const (),
205 )),
206 Box_::into_raw(f),
207 )
208 }
209 }
210}
211
212unsafe impl Send for SourceBufferList {}
213unsafe impl Sync for SourceBufferList {}