gstreamer_controller/
timed_value_control_source.rs1use glib::{prelude::*, translate::*};
4
5use crate::{ffi, TimedValueControlSource};
6
7pub trait TimedValueControlSourceExtManual: IsA<TimedValueControlSource> + 'static {
8 #[doc(alias = "gst_timed_value_control_source_list_control_points")]
17 fn list_control_points(&self) -> glib::collections::Slice<gst::TimedValue> {
18 #[cfg(feature = "v1_28")]
19 unsafe {
20 let mut n_control_points = std::mem::MaybeUninit::uninit();
21 let ptr = ffi::gst_timed_value_control_source_list_control_points(
22 self.as_ref().to_glib_none().0,
23 n_control_points.as_mut_ptr(),
24 );
25 let len = n_control_points.assume_init() as usize;
26 FromGlibContainer::from_glib_full_num(ptr, len)
27 }
28 #[cfg(not(feature = "v1_28"))]
29 unsafe {
30 use std::mem;
32 use std::ptr;
33
34 let glist_head =
35 ffi::gst_timed_value_control_source_get_all(self.as_ref().to_glib_none().0);
36 let len = glib::ffi::g_list_length(glist_head) as usize;
37 let result = glib::ffi::g_malloc(
38 mem::size_of::<gst::ffi::GstTimedValue>()
39 .checked_mul(len)
40 .unwrap(),
41 ) as *mut gst::ffi::GstTimedValue;
42
43 let mut glist_ptr = glist_head;
44 for i in 0..len {
45 let cp_ptr = (*glist_ptr).data as *const gst::ffi::GstTimedValue;
46 *result.add(i) = ptr::read(cp_ptr);
47 glist_ptr = (*glist_ptr).next;
48 }
49 glib::ffi::g_list_free(glist_head);
50
51 FromGlibContainer::from_glib_full_num(result, len)
52 }
53 }
54}
55
56impl<O: IsA<TimedValueControlSource>> TimedValueControlSourceExtManual for O {}