gstreamer_editing_services/auto/
marker_list.rs
1#[cfg(feature = "v1_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
8use crate::MarkerFlags;
9use crate::{ffi, Marker};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "GESMarkerList")]
53 pub struct MarkerList(Object<ffi::GESMarkerList, ffi::GESMarkerListClass>);
54
55 match fn {
56 type_ => || ffi::ges_marker_list_get_type(),
57 }
58}
59
60impl MarkerList {
61 #[doc(alias = "ges_marker_list_new")]
67 pub fn new() -> MarkerList {
68 assert_initialized_main_thread!();
69 unsafe { from_glib_full(ffi::ges_marker_list_new()) }
70 }
71
72 #[doc(alias = "ges_marker_list_add")]
80 pub fn add(&self, position: impl Into<Option<gst::ClockTime>>) -> Marker {
81 unsafe {
82 from_glib_none(ffi::ges_marker_list_add(
83 self.to_glib_none().0,
84 position.into().into_glib(),
85 ))
86 }
87 }
88
89 #[doc(alias = "ges_marker_list_get_markers")]
96 #[doc(alias = "get_markers")]
97 pub fn markers(&self) -> Vec<Marker> {
98 unsafe {
99 FromGlibPtrContainer::from_glib_full(ffi::ges_marker_list_get_markers(
100 self.to_glib_none().0,
101 ))
102 }
103 }
104
105 #[doc(alias = "ges_marker_list_move")]
112 #[doc(alias = "move")]
113 pub fn move_(&self, marker: &Marker, position: impl Into<Option<gst::ClockTime>>) -> bool {
114 unsafe {
115 from_glib(ffi::ges_marker_list_move(
116 self.to_glib_none().0,
117 marker.to_glib_none().0,
118 position.into().into_glib(),
119 ))
120 }
121 }
122
123 #[doc(alias = "ges_marker_list_remove")]
131 pub fn remove(&self, marker: &Marker) -> bool {
132 unsafe {
133 from_glib(ffi::ges_marker_list_remove(
134 self.to_glib_none().0,
135 marker.to_glib_none().0,
136 ))
137 }
138 }
139
140 #[doc(alias = "ges_marker_list_size")]
145 pub fn size(&self) -> u32 {
146 unsafe { ffi::ges_marker_list_size(self.to_glib_none().0) }
147 }
148
149 #[cfg(feature = "v1_20")]
151 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
152 pub fn flags(&self) -> MarkerFlags {
153 ObjectExt::property(self, "flags")
154 }
155
156 #[cfg(feature = "v1_20")]
158 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
159 pub fn set_flags(&self, flags: MarkerFlags) {
160 ObjectExt::set_property(self, "flags", flags)
161 }
162
163 #[cfg(feature = "v1_18")]
169 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
170 #[doc(alias = "marker-added")]
171 pub fn connect_marker_added<F: Fn(&Self, u64, &Marker) + 'static>(
172 &self,
173 f: F,
174 ) -> SignalHandlerId {
175 unsafe extern "C" fn marker_added_trampoline<F: Fn(&MarkerList, u64, &Marker) + 'static>(
176 this: *mut ffi::GESMarkerList,
177 position: u64,
178 marker: *mut ffi::GESMarker,
179 f: glib::ffi::gpointer,
180 ) {
181 let f: &F = &*(f as *const F);
182 f(&from_glib_borrow(this), position, &from_glib_borrow(marker))
183 }
184 unsafe {
185 let f: Box_<F> = Box_::new(f);
186 connect_raw(
187 self.as_ptr() as *mut _,
188 c"marker-added".as_ptr() as *const _,
189 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
190 marker_added_trampoline::<F> as *const (),
191 )),
192 Box_::into_raw(f),
193 )
194 }
195 }
196
197 #[cfg(feature = "v1_18")]
205 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
206 #[doc(alias = "marker-moved")]
207 pub fn connect_marker_moved<F: Fn(&Self, u64, u64, &Marker) + 'static>(
208 &self,
209 f: F,
210 ) -> SignalHandlerId {
211 unsafe extern "C" fn marker_moved_trampoline<
212 F: Fn(&MarkerList, u64, u64, &Marker) + 'static,
213 >(
214 this: *mut ffi::GESMarkerList,
215 previous_position: u64,
216 new_position: u64,
217 marker: *mut ffi::GESMarker,
218 f: glib::ffi::gpointer,
219 ) {
220 let f: &F = &*(f as *const F);
221 f(
222 &from_glib_borrow(this),
223 previous_position,
224 new_position,
225 &from_glib_borrow(marker),
226 )
227 }
228 unsafe {
229 let f: Box_<F> = Box_::new(f);
230 connect_raw(
231 self.as_ptr() as *mut _,
232 c"marker-moved".as_ptr() as *const _,
233 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
234 marker_moved_trampoline::<F> as *const (),
235 )),
236 Box_::into_raw(f),
237 )
238 }
239 }
240
241 #[cfg(feature = "v1_18")]
245 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
246 #[doc(alias = "marker-removed")]
247 pub fn connect_marker_removed<F: Fn(&Self, &Marker) + 'static>(&self, f: F) -> SignalHandlerId {
248 unsafe extern "C" fn marker_removed_trampoline<F: Fn(&MarkerList, &Marker) + 'static>(
249 this: *mut ffi::GESMarkerList,
250 marker: *mut ffi::GESMarker,
251 f: glib::ffi::gpointer,
252 ) {
253 let f: &F = &*(f as *const F);
254 f(&from_glib_borrow(this), &from_glib_borrow(marker))
255 }
256 unsafe {
257 let f: Box_<F> = Box_::new(f);
258 connect_raw(
259 self.as_ptr() as *mut _,
260 c"marker-removed".as_ptr() as *const _,
261 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
262 marker_removed_trampoline::<F> as *const (),
263 )),
264 Box_::into_raw(f),
265 )
266 }
267 }
268
269 #[cfg(feature = "v1_20")]
270 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
271 #[doc(alias = "flags")]
272 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
273 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&MarkerList) + 'static>(
274 this: *mut ffi::GESMarkerList,
275 _param_spec: glib::ffi::gpointer,
276 f: glib::ffi::gpointer,
277 ) {
278 let f: &F = &*(f as *const F);
279 f(&from_glib_borrow(this))
280 }
281 unsafe {
282 let f: Box_<F> = Box_::new(f);
283 connect_raw(
284 self.as_ptr() as *mut _,
285 c"notify::flags".as_ptr() as *const _,
286 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287 notify_flags_trampoline::<F> as *const (),
288 )),
289 Box_::into_raw(f),
290 )
291 }
292 }
293}
294
295#[cfg(feature = "v1_18")]
296#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
297impl Default for MarkerList {
298 fn default() -> Self {
299 Self::new()
300 }
301}