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