Implement AppSrc get/set_latency() manually

These are gst::ClockTime, not u64
This commit is contained in:
Sebastian Dröge 2017-12-16 14:04:36 +02:00
parent 70688fd6a9
commit bd817c03d2
3 changed files with 27 additions and 15 deletions

View file

@ -86,6 +86,16 @@ trait = false
# Action signal
ignore = true
[[object.function]]
name = "set_latency"
# ClockTime
ignore = true
[[object.function]]
name = "get_latency"
# ClockTime
ignore = true
[[object.function]]
name = "set_caps"
[[object.function.parameter]]

View file

@ -13,6 +13,7 @@ use gst;
use glib::source::CallbackGuard;
use glib_ffi::{gboolean, gpointer};
use std::ptr;
use std::mem;
pub struct AppSrcCallbacks {
need_data: Option<Box<Fn(&AppSrc, u32) + Send + Sync + 'static>>,
@ -149,4 +150,20 @@ impl AppSrc {
);
}
}
pub fn set_latency(&self, min: gst::ClockTime, max: gst::ClockTime) {
unsafe {
ffi::gst_app_src_set_latency(self.to_glib_none().0, min.to_glib(), max.to_glib());
}
}
pub fn get_latency(&self) -> (gst::ClockTime, gst::ClockTime) {
unsafe {
let mut min = mem::uninitialized();
let mut max = mem::uninitialized();
ffi::gst_app_src_get_latency(self.to_glib_none().0, &mut min, &mut max);
(from_glib(min), from_glib(max))
}
}
}

View file

@ -65,15 +65,6 @@ impl AppSrc {
}
}
pub fn get_latency(&self) -> (u64, u64) {
unsafe {
let mut min = mem::uninitialized();
let mut max = mem::uninitialized();
ffi::gst_app_src_get_latency(self.to_glib_none().0, &mut min, &mut max);
(min, max)
}
}
pub fn get_max_bytes(&self) -> u64 {
unsafe {
ffi::gst_app_src_get_max_bytes(self.to_glib_none().0)
@ -123,12 +114,6 @@ impl AppSrc {
}
}
pub fn set_latency(&self, min: u64, max: u64) {
unsafe {
ffi::gst_app_src_set_latency(self.to_glib_none().0, min, max);
}
}
pub fn set_max_bytes(&self, max: u64) {
unsafe {
ffi::gst_app_src_set_max_bytes(self.to_glib_none().0, max);