Commit c39c0c72 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Implement ClockTime as ClockTime(Option<u64>)

And also implement a FormatValue type that holds a value together with
its format to make usage of the positions/durations/seek positions/etc
more convenient and safe.

Fixes https://github.com/sdroege/gstreamer-rs/issues/3
parent bdcf0246
......@@ -14,7 +14,6 @@ external_libraries = [
]
generate = [
"Gst.ClockTime",
"Gst.ClockTimeDiff",
"Gst.Pipeline",
"Gst.State",
......@@ -83,6 +82,11 @@ manual = [
"Gst.StaticPadTemplate",
]
[[object]]
name = "Gst.ClockTime"
status = "manual"
conversion_type = "scalar"
[[object]]
name = "Gst.Bin"
status = "generate"
......@@ -312,6 +316,31 @@ status = "generate"
# ulong
ignore = true
[[object.function]]
name = "query_duration"
# formatted value
ignore = true
[[object.function]]
name = "query_position"
# formatted value
ignore = true
[[object.function]]
name = "query_convert"
# formatted value
ignore = true
[[object.function]]
name = "seek"
# formatted value
ignore = true
[[object.function]]
name = "seek_simple"
# formatted value
ignore = true
[[object]]
name = "Gst.ElementFactory"
status = "generate"
......
......@@ -24,7 +24,6 @@ manual = [
"Gst.Object",
"Gst.Element",
"Gst.URIHandler",
"Gst.ClockTime",
"Gst.FlowReturn",
"Gst.Format",
"GstBase.BaseSrc",
......@@ -100,3 +99,8 @@ ref_mode = "ref"
name = "Gst.Sample"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.ClockTime"
status = "manual"
conversion_type = "scalar"
......@@ -26,7 +26,6 @@ manual = [
"GLib.Bytes",
"Gst.Object",
"Gst.Element",
"Gst.ClockTime",
"Gst.ClockTimeDiff",
"Gst.ClockReturn",
"Gst.FlowReturn",
......@@ -96,3 +95,8 @@ ref_mode = "ref"
name = "Gst.Sample"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.ClockTime"
status = "manual"
conversion_type = "scalar"
......@@ -28,7 +28,6 @@ manual = [
"GLib.Error",
"GLib.MainContext",
"GObject.Object",
"Gst.ClockTime",
"Gst.Element",
]
......@@ -158,3 +157,8 @@ trait = false
name = "new"
# Wrong return value
ignore = true
[[object]]
name = "Gst.ClockTime"
status = "manual"
conversion_type = "scalar"
......@@ -59,25 +59,14 @@ fn create_ui(app: &gtk::Application) {
let pipeline_clone = pipeline.clone();
gtk::timeout_add(500, move || {
let pipeline = &pipeline_clone;
let position = pipeline.query_position(gst::Format::Time);
if let Some(position) = position {
let mut seconds = (position as gst::ClockTime) / gst::SECOND;
let mut minutes = seconds / 60;
let hours = minutes / 60;
seconds %= 60;
minutes %= 60;
label.set_text(&format!(
"Position: {:02}:{:02}:{:02}",
hours,
minutes,
seconds
));
let position = if let Some(gst::FormatValue::Time(position)) =
pipeline.query_position(gst::Format::Time)
{
position
} else {
label.set_text("Position: 00:00:00");
}
0.into()
};
label.set_text(&format!("Position: {:.0}", position));
glib::Continue(true)
});
......
......@@ -129,25 +129,14 @@ fn create_ui(app: &gtk::Application) {
let pipeline_clone = pipeline.clone();
gtk::timeout_add(500, move || {
let pipeline = &pipeline_clone;
let position = pipeline.query_position(gst::Format::Time);
if let Some(position) = position {
let mut seconds = (position as gst::ClockTime) / gst::SECOND;
let mut minutes = seconds / 60;
let hours = minutes / 60;
seconds %= 60;
minutes %= 60;
label.set_text(&format!(
"Position: {:02}:{:02}:{:02}",
hours,
minutes,
seconds
));
let position = if let Some(gst::FormatValue::Time(position)) =
pipeline.query_position(gst::Format::Time)
{
position
} else {
label.set_text("Position: 00:00:00");
}
0.into()
};
label.set_text(&format!("Position: {:.0}", position));
glib::Continue(true)
});
......
......@@ -30,21 +30,29 @@ fn main() {
//let dur = pipeline.query_duration(gst::Format::Time).unwrap_or(-1);
let pos = {
let mut q = gst::Query::new_position(gst::Format::Time);
pipeline.query(q.get_mut().unwrap());
match q.view() {
QueryView::Position(ref p) => p.get().1,
_ => unreachable!(),
if pipeline.query(q.get_mut().unwrap()) {
match q.view() {
QueryView::Position(ref p) => Some(p.get()),
_ => None,
}
} else {
None
}
};
}.and_then(|pos| pos.try_to_time())
.unwrap();
let dur = {
let mut q = gst::Query::new_duration(gst::Format::Time);
pipeline.query(q.get_mut().unwrap());
match q.view() {
QueryView::Duration(ref p) => p.get().1,
_ => unreachable!(),
if pipeline.query(q.get_mut().unwrap()) {
match q.view() {
QueryView::Duration(ref p) => Some(p.get()),
_ => None,
}
} else {
None
}
};
}.and_then(|dur| dur.try_to_time())
.unwrap();
println!("{} / {}", pos, dur);
......
......@@ -130,14 +130,14 @@ impl AppSink {
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn try_pull_preroll(&self, timeout: gst::ClockTime) -> Option<gst::Sample> {
unsafe {
from_glib_full(ffi::gst_app_sink_try_pull_preroll(self.to_glib_none().0, timeout))
from_glib_full(ffi::gst_app_sink_try_pull_preroll(self.to_glib_none().0, timeout.to_glib()))
}
}
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn try_pull_sample(&self, timeout: gst::ClockTime) -> Option<gst::Sample> {
unsafe {
from_glib_full(ffi::gst_app_sink_try_pull_sample(self.to_glib_none().0, timeout))
from_glib_full(ffi::gst_app_sink_try_pull_sample(self.to_glib_none().0, timeout.to_glib()))
}
}
......
......@@ -54,7 +54,7 @@ impl AppSrc {
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn get_duration(&self) -> gst::ClockTime {
unsafe {
ffi::gst_app_src_get_duration(self.to_glib_none().0)
from_glib(ffi::gst_app_src_get_duration(self.to_glib_none().0))
}
}
......@@ -110,7 +110,7 @@ impl AppSrc {
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn set_duration(&self, duration: gst::ClockTime) {
unsafe {
ffi::gst_app_src_set_duration(self.to_glib_none().0, duration);
ffi::gst_app_src_set_duration(self.to_glib_none().0, duration.to_glib());
}
}
......
......@@ -42,12 +42,13 @@ impl<'a> AudioInfoBuilder<'a> {
return None;
}
let positions: [ffi::GstAudioChannelPosition; 64] =
array_init::array_init_copy(|i| if i >= self.channels as usize {
let positions: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(
|i| if i >= self.channels as usize {
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
} else {
p[i].to_glib()
});
},
);
let valid: bool = from_glib(ffi::gst_audio_check_valid_channel_positions(
positions.as_ptr() as *mut _,
......@@ -156,22 +157,21 @@ impl AudioInfo {
pub fn convert(
&self,
src_fmt: gst::Format,
src_val: i64,
src_val: gst::FormatValue,
dest_fmt: gst::Format,
) -> Option<i64> {
) -> Option<gst::FormatValue> {
assert_initialized_main_thread!();
unsafe {
let mut dest_val = mem::uninitialized();
if from_glib(ffi::gst_audio_info_convert(
&self.0,
src_fmt.to_glib(),
src_val,
src_val.to_format().to_glib(),
src_val.to_value(),
dest_fmt.to_glib(),
&mut dest_val,
)) {
Some(dest_val)
Some(gst::FormatValue::new(dest_fmt, dest_val))
} else {
None
}
......
......@@ -59,7 +59,7 @@ impl Adapter {
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn dts_at_discont(&self) -> gst::ClockTime {
unsafe {
ffi::gst_adapter_dts_at_discont(self.to_glib_none().0)
from_glib(ffi::gst_adapter_dts_at_discont(self.to_glib_none().0))
}
}
......@@ -117,7 +117,7 @@ impl Adapter {
pub fn prev_dts(&self) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_dts(self.to_glib_none().0, &mut distance);
let ret = from_glib(ffi::gst_adapter_prev_dts(self.to_glib_none().0, &mut distance));
(ret, distance)
}
}
......@@ -125,7 +125,7 @@ impl Adapter {
pub fn prev_dts_at_offset(&self, offset: usize) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_dts_at_offset(self.to_glib_none().0, offset, &mut distance);
let ret = from_glib(ffi::gst_adapter_prev_dts_at_offset(self.to_glib_none().0, offset, &mut distance));
(ret, distance)
}
}
......@@ -142,7 +142,7 @@ impl Adapter {
pub fn prev_pts(&self) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_pts(self.to_glib_none().0, &mut distance);
let ret = from_glib(ffi::gst_adapter_prev_pts(self.to_glib_none().0, &mut distance));
(ret, distance)
}
}
......@@ -150,7 +150,7 @@ impl Adapter {
pub fn prev_pts_at_offset(&self, offset: usize) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_pts_at_offset(self.to_glib_none().0, offset, &mut distance);
let ret = from_glib(ffi::gst_adapter_prev_pts_at_offset(self.to_glib_none().0, offset, &mut distance));
(ret, distance)
}
}
......@@ -158,7 +158,7 @@ impl Adapter {
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn pts_at_discont(&self) -> gst::ClockTime {
unsafe {
ffi::gst_adapter_pts_at_discont(self.to_glib_none().0)
from_glib(ffi::gst_adapter_pts_at_discont(self.to_glib_none().0))
}
}
......
......@@ -154,7 +154,7 @@ impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
fn get_latency(&self) -> gst::ClockTime {
unsafe {
ffi::gst_base_sink_get_latency(self.to_glib_none().0)
from_glib(ffi::gst_base_sink_get_latency(self.to_glib_none().0))
}
}
......@@ -172,7 +172,7 @@ impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
fn get_render_delay(&self) -> gst::ClockTime {
unsafe {
ffi::gst_base_sink_get_render_delay(self.to_glib_none().0)
from_glib(ffi::gst_base_sink_get_render_delay(self.to_glib_none().0))
}
}
......@@ -219,7 +219,7 @@ impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
let mut min_latency = mem::uninitialized();
let mut max_latency = mem::uninitialized();
let ret = from_glib(ffi::gst_base_sink_query_latency(self.to_glib_none().0, &mut live, &mut upstream_live, &mut min_latency, &mut max_latency));
if ret { Some((from_glib(live), from_glib(upstream_live), min_latency, max_latency)) } else { None }
if ret { Some((from_glib(live), from_glib(upstream_live), from_glib(min_latency), from_glib(max_latency))) } else { None }
}
}
......@@ -268,7 +268,7 @@ impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
fn set_render_delay(&self, delay: gst::ClockTime) {
unsafe {
ffi::gst_base_sink_set_render_delay(self.to_glib_none().0, delay);
ffi::gst_base_sink_set_render_delay(self.to_glib_none().0, delay.to_glib());
}
}
......@@ -293,7 +293,7 @@ impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
fn wait(&self, time: gst::ClockTime) -> (gst::FlowReturn, gst::ClockTimeDiff) {
unsafe {
let mut jitter = mem::uninitialized();
let ret = from_glib(ffi::gst_base_sink_wait(self.to_glib_none().0, time, &mut jitter));
let ret = from_glib(ffi::gst_base_sink_wait(self.to_glib_none().0, time.to_glib(), &mut jitter));
(ret, jitter)
}
}
......@@ -301,7 +301,7 @@ impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
fn wait_clock(&self, time: gst::ClockTime) -> (gst::ClockReturn, gst::ClockTimeDiff) {
unsafe {
let mut jitter = mem::uninitialized();
let ret = from_glib(ffi::gst_base_sink_wait_clock(self.to_glib_none().0, time, &mut jitter));
let ret = from_glib(ffi::gst_base_sink_wait_clock(self.to_glib_none().0, time.to_glib(), &mut jitter));
(ret, jitter)
}
}
......
......@@ -133,7 +133,7 @@ impl<O: IsA<BaseSrc> + IsA<glib::object::Object>> BaseSrcExt for O {
let mut min_latency = mem::uninitialized();
let mut max_latency = mem::uninitialized();
let ret = from_glib(ffi::gst_base_src_query_latency(self.to_glib_none().0, &mut live, &mut min_latency, &mut max_latency));
if ret { Some((from_glib(live), min_latency, max_latency)) } else { None }
if ret { Some((from_glib(live), from_glib(min_latency), from_glib(max_latency))) } else { None }
}
}
......
......@@ -139,7 +139,7 @@ impl<O: IsA<BaseTransform> + IsA<glib::object::Object>> BaseTransformExt for O {
fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime) {
unsafe {
ffi::gst_base_transform_update_qos(self.to_glib_none().0, proportion, diff, timestamp);
ffi::gst_base_transform_update_qos(self.to_glib_none().0, proportion, diff, timestamp.to_glib());
}
}
......
......@@ -83,7 +83,7 @@ impl Player {
pub fn get_duration(&self) -> gst::ClockTime {
unsafe {
ffi::gst_player_get_duration(self.to_glib_none().0)
from_glib(ffi::gst_player_get_duration(self.to_glib_none().0))
}
}
......@@ -115,7 +115,7 @@ impl Player {
pub fn get_position(&self) -> gst::ClockTime {
unsafe {
ffi::gst_player_get_position(self.to_glib_none().0)
from_glib(ffi::gst_player_get_position(self.to_glib_none().0))
}
}
......@@ -171,7 +171,7 @@ impl Player {
pub fn seek(&self, position: gst::ClockTime) {
unsafe {
ffi::gst_player_seek(self.to_glib_none().0, position);
ffi::gst_player_seek(self.to_glib_none().0, position.to_glib());
}
}
......
......@@ -36,7 +36,7 @@ impl PlayerMediaInfo {
pub fn get_duration(&self) -> gst::ClockTime {
unsafe {
ffi::gst_player_media_info_get_duration(self.to_glib_none().0)
from_glib(ffi::gst_player_media_info_get_duration(self.to_glib_none().0))
}
}
......
......@@ -545,24 +545,25 @@ impl VideoInfo {
self.format_info().n_components()
}
pub fn convert(
pub fn convert<V: Into<gst::FormatValue>>(
&self,
src_fmt: gst::Format,
src_val: i64,
src_val: V,
dest_fmt: gst::Format,
) -> Option<i64> {
) -> Option<gst::FormatValue> {
skip_assert_initialized!();
let src_val = src_val.into();
unsafe {
let mut dest_val = mem::uninitialized();
if from_glib(ffi::gst_video_info_convert(
&self.0 as *const _ as *mut _,
src_fmt.to_glib(),
src_val,
src_val.to_format().to_glib(),
src_val.to_value(),
dest_fmt.to_glib(),
&mut dest_val,
)) {
Some(dest_val)
Some(gst::FormatValue::new(dest_fmt, dest_val))
} else {
None
}
......
......@@ -22,6 +22,7 @@ glib = { git = "https://github.com/gtk-rs/glib" }
num-rational = { version = "0.1.38", default-features = false, features = [] }
lazy_static = "0.2"
futures = { version = "0.1", optional = true }
muldiv = "0.1.1"
[build-dependencies.rustdoc-stripper]
version = "0.1"
......
......@@ -4,6 +4,5 @@
#[allow(unused_imports)]
use auto::*;
pub type ClockTime = u64;
pub type ClockTimeDiff = i64;
pub type ElementFactoryListType = u64;
......@@ -113,7 +113,7 @@ impl Bus {
pub fn timed_pop(&self, timeout: ClockTime) -> Option<Message> {
unsafe {
from_glib_full(ffi::gst_bus_timed_pop(self.to_glib_none().0, timeout))
from_glib_full(ffi::gst_bus_timed_pop(self.to_glib_none().0, timeout.to_glib()))
}
}
......
......@@ -127,7 +127,7 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
fn add_observation(&self, slave: ClockTime, master: ClockTime) -> Option<f64> {
unsafe {
let mut r_squared = mem::uninitialized();
let ret = from_glib(ffi::gst_clock_add_observation(self.to_glib_none().0, slave, master, &mut r_squared));
let ret = from_glib(ffi::gst_clock_add_observation(self.to_glib_none().0, slave.to_glib(), master.to_glib(), &mut r_squared));
if ret { Some(r_squared) } else { None }
}
}
......@@ -139,20 +139,20 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
let mut external = mem::uninitialized();
let mut rate_num = mem::uninitialized();
let mut rate_denom = mem::uninitialized();
let ret = from_glib(ffi::gst_clock_add_observation_unapplied(self.to_glib_none().0, slave, master, &mut r_squared, &mut internal, &mut external, &mut rate_num, &mut rate_denom));
if ret { Some((r_squared, internal, external, rate_num, rate_denom)) } else { None }
let ret = from_glib(ffi::gst_clock_add_observation_unapplied(self.to_glib_none().0, slave.to_glib(), master.to_glib(), &mut r_squared, &mut internal, &mut external, &mut rate_num, &mut rate_denom));
if ret { Some((r_squared, from_glib(internal), from_glib(external), from_glib(rate_num), from_glib(rate_denom))) } else { None }
}
}
fn adjust_unlocked(&self, internal: ClockTime) -> ClockTime {
unsafe {
ffi::gst_clock_adjust_unlocked(self.to_glib_none().0, internal)
from_glib(ffi::gst_clock_adjust_unlocked(self.to_glib_none().0, internal.to_glib()))
}
}
fn adjust_with_calibration(&self, internal_target: ClockTime, cinternal: ClockTime, cexternal: ClockTime, cnum: ClockTime, cdenom: ClockTime) -> ClockTime {
unsafe {
ffi::gst_clock_adjust_with_calibration(self.to_glib_none().0, internal_target, cinternal, cexternal, cnum, cdenom)
from_glib(ffi::gst_clock_adjust_with_calibration(self.to_glib_none().0, internal_target.to_glib(), cinternal.to_glib(), cexternal.to_glib(), cnum.to_glib(), cdenom.to_glib()))
}
}
......@@ -163,13 +163,13 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
let mut rate_num = mem::uninitialized();
let mut rate_denom = mem::uninitialized();
ffi::gst_clock_get_calibration(self.to_glib_none().0, &mut internal, &mut external, &mut rate_num, &mut rate_denom);
(internal, external, rate_num, rate_denom)
(from_glib(internal), from_glib(external), from_glib(rate_num), from_glib(rate_denom))
}
}
fn get_internal_time(&self) -> ClockTime {
unsafe {
ffi::gst_clock_get_internal_time(self.to_glib_none().0)
from_glib(ffi::gst_clock_get_internal_time(self.to_glib_none().0))
}
}
......@@ -181,19 +181,19 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
fn get_resolution(&self) -> ClockTime {
unsafe {
ffi::gst_clock_get_resolution(self.to_glib_none().0)
from_glib(ffi::gst_clock_get_resolution(self.to_glib_none().0))
}
}
fn get_time(&self) -> ClockTime {
unsafe {
ffi::gst_clock_get_time(self.to_glib_none().0)
from_glib(ffi::gst_clock_get_time(self.to_glib_none().0))
}
}
fn get_timeout(&self) -> ClockTime {
unsafe {
ffi::gst_clock_get_timeout(self.to_glib_none().0)
from_glib(ffi::gst_clock_get_timeout(self.to_glib_none().0))
}
}
......@@ -217,7 +217,7 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
fn set_calibration(&self, internal: ClockTime, external: ClockTime, rate_num: ClockTime, rate_denom: ClockTime) {
unsafe {
ffi::gst_clock_set_calibration(self.to_glib_none().0, internal, external, rate_num, rate_denom);
ffi::gst_clock_set_calibration(self.to_glib_none().0, internal.to_glib(), external.to_glib(), rate_num.to_glib(), rate_denom.to_glib());
}
}
......@@ -231,7 +231,7 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
fn set_resolution(&self, resolution: ClockTime) -> ClockTime {
unsafe {
ffi::gst_clock_set_resolution(self.to_glib_none().0, resolution)
from_glib(ffi::gst_clock_set_resolution(self.to_glib_none().0, resolution.to_glib()))
}
}
......@@ -243,7 +243,7 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
fn set_timeout(&self, timeout: ClockTime) {
unsafe {
ffi::gst_clock_set_timeout(self.to_glib_none().0, timeout);
ffi::gst_clock_set_timeout(self.to_glib_none().0, timeout.to_glib());
}
}
......@@ -253,19 +253,19 @@ impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExt for O {
fn unadjust_unlocked(&self, external: ClockTime) -> ClockTime {
unsafe {
ffi::gst_clock_unadjust_unlocked(self.to_glib_none().0, external)
from_glib(ffi::gst_clock_unadjust_unlocked(self.to_glib_none().0, external.to_glib()))
}
}
fn unadjust_with_calibration(&self, external_target: ClockTime, cinternal: ClockTime, cexternal: ClockTime, cnum: ClockTime, cdenom: ClockTime) -> ClockTime {
unsafe {
ffi::gst_clock_unadjust_with_calibration(self.to_glib_none().0, external_target, cinternal, cexternal, cnum, cdenom)
from_glib(ffi::gst_clock_unadjust_with_calibration(self.to_glib_none().0, external_target.to_glib(), cinternal.to_glib(), cexternal.to_glib(), cnum.to_glib(), cdenom.to_glib()))
}
}
fn wait_for_sync(&self, timeout: ClockTime) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_clock_wait_for_sync(self.to_glib_none().0, timeout), "Timed out waiting for sync")
glib::error::BoolError::from_glib(ffi::gst_clock_wait_for_sync(self.to_glib_none().0, timeout.to_glib()), "Timed out waiting for sync")
}
}
......
......@@ -8,15 +8,12 @@ use ClockTime;
use Context;
use ElementFactory;
use Error;
use Format;
use Message;
use Object;
use Pad;
use PadLinkCheck;
use PadTemplate;
use Plugin;
use SeekFlags;
use SeekType;
use State;
use StateChange;
use StateChangeReturn;
......@@ -153,22 +150,12 @@ pub trait ElementExt {
fn provide_clock(&self) -> Option<Clock>;
fn query_convert(&self, src_format: Format, src_val: i64, dest_format: Format) -> Option<i64>;
fn query_duration(&self, format: Format) -> Option<i64>;
fn query_position(&self, format: Format) -> Option<i64>;
fn release_request_pad<P: IsA<Pad>>(&self, pad: &P);
fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>;
fn request_pad<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b Caps>>>(&self, templ: &PadTemplate, name: P, caps: Q) -> Option<Pad>;
fn seek(&self, rate: f64, format: Format, flags: SeekFlags, start_type: SeekType, start: i64, stop_type: SeekType, stop: i64) -> Result<(), glib::error::BoolError>;
fn seek_simple(&self, format: Format, seek_flags: SeekFlags, seek_pos: i64) -> Result<(), glib::error::BoolError>;
fn set_base_time(&self, time: ClockTime);
fn set_bus(&self, bus: &Bus);
......@@ -236,7 +223,7 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
fn get_base_time(&self) -> ClockTime {
unsafe {
ffi::gst_element_get_base_time(self.to_glib_none().0)
from_glib(ffi::gst_element_get_base_time(self.to_glib_none().0))
}
}
......@@ -292,7 +279,7 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
fn get_start_time(&self) -> ClockTime {
unsafe {
ffi::gst_element_get_start_time(self.to_glib_none().0)
from_glib(ffi::gst_element_get_start_time(self.to_glib_none().0))
}
}
......@@ -300,7 +287,7 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
unsafe {