Manual ClockTime updates

This commit is contained in:
François Laignel 2021-04-29 00:29:13 +02:00
parent 90bb458e64
commit e31ce9d07b
69 changed files with 399 additions and 314 deletions

View file

@ -141,7 +141,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -98,7 +98,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
// For each frame we produce, we set the timestamp when it should be displayed // For each frame we produce, we set the timestamp when it should be displayed
// (pts = presentation time stamp) // (pts = presentation time stamp)
// The autovideosink will use this information to display the frame at the right time. // The autovideosink will use this information to display the frame at the right time.
buffer.set_pts(i * 500 * gst::MSECOND); buffer.set_pts(i * 500 * gst::ClockTime::MSECOND);
// At this point, buffer is only a reference to an existing memory region somewhere. // At this point, buffer is only a reference to an existing memory region somewhere.
// When we want to access its content, we have to map it while requesting the required // When we want to access its content, we have to map it while requesting the required
@ -150,7 +150,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -264,7 +264,7 @@ fn example_main() {
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
// And run until EOS or an error happened. // And run until EOS or an error happened.
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -46,7 +46,7 @@ fn example_main() {
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -236,7 +236,7 @@ fn example_main() -> Result<(), Error> {
// In the callback ("pad-added" on the decodebin), we sent better error information // In the callback ("pad-added" on the decodebin), we sent better error information
// using a bus message. This is the position where we get those messages and log // using a bus message. This is the position where we get those messages and log
// the contained information. // the contained information.
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -261,7 +261,7 @@ fn example_main() -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -74,12 +74,16 @@ fn main_loop(uri: &str) -> Result<(), glib::BoolError> {
// Retrieve the asset that was automatically used behind the scenes, to // Retrieve the asset that was automatically used behind the scenes, to
// extract the clip from. // extract the clip from.
let asset = clip.asset().unwrap(); let asset = clip.asset().unwrap();
let duration = asset.downcast::<ges::UriClipAsset>().unwrap().duration(); let duration = asset
.downcast::<ges::UriClipAsset>()
.unwrap()
.duration()
.expect("unknown duration");
println!( println!(
"Clip duration: {} - playing file from {} for {}", "Clip duration: {} - playing file from {} for {}",
duration, duration,
duration / 2, duration / 2,
duration / 4 duration / 4,
); );
// The inpoint specifies where in the clip we start, the duration specifies // The inpoint specifies where in the clip we start, the duration specifies
@ -94,7 +98,7 @@ fn main_loop(uri: &str) -> Result<(), glib::BoolError> {
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -91,7 +91,7 @@ fn create_ui(app: &gtk::Application) {
// Query the current playing position from the underlying pipeline. // Query the current playing position from the underlying pipeline.
let position = pipeline.query_position::<gst::ClockTime>(); let position = pipeline.query_position::<gst::ClockTime>();
// Display the playing position in the gui. // Display the playing position in the gui.
label.set_text(&format!("Position: {:.0}", position)); label.set_text(&format!("Position: {:.0}", position.display()));
// Tell the callback to continue calling this closure. // Tell the callback to continue calling this closure.
glib::Continue(true) glib::Continue(true)
}); });

View file

@ -196,7 +196,7 @@ fn create_ui(app: &gtk::Application) {
// Query the current playing position from the underlying pipeline. // Query the current playing position from the underlying pipeline.
let position = pipeline.query_position::<gst::ClockTime>(); let position = pipeline.query_position::<gst::ClockTime>();
// Display the playing position in the gui. // Display the playing position in the gui.
label.set_text(&format!("Position: {:.0}", position)); label.set_text(&format!("Position: {:.0}", position.display()));
// Tell the timeout to continue calling this callback. // Tell the timeout to continue calling this callback.
glib::Continue(true) glib::Continue(true)
}); });

View file

@ -46,7 +46,7 @@ fn example_main() {
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -142,15 +142,15 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
let _overlay = args[0].get::<gst::Element>().unwrap(); let _overlay = args[0].get::<gst::Element>().unwrap();
let sample = args[1].get::<gst::Sample>().unwrap(); let sample = args[1].get::<gst::Sample>().unwrap();
let buffer = sample.buffer().unwrap(); let buffer = sample.buffer().unwrap();
let timestamp = buffer.pts(); let timestamp = buffer.pts().unwrap();
let info = drawer.info.as_ref().unwrap(); let info = drawer.info.as_ref().unwrap();
let layout = drawer.layout.borrow(); let layout = drawer.layout.borrow();
let angle = 2.0 let angle = 2.0
* PI * PI
* ((timestamp % (10 * gst::SECOND)).unwrap() as f64 * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
/ (10.0 * gst::SECOND_VAL as f64)); / (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
/* Create a gst::Buffer for Cairo to draw into */ /* Create a gst::Buffer for Cairo to draw into */
let frame_width = info.width() as usize; let frame_width = info.width() as usize;
@ -296,7 +296,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -77,7 +77,7 @@ fn example_main() {
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -143,10 +143,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
let info = drawer.info.as_ref().unwrap(); let info = drawer.info.as_ref().unwrap();
let layout = drawer.layout.borrow(); let layout = drawer.layout.borrow();
let angle = 2.0 let angle = 2.0 * PI * (timestamp % (10 * gst::ClockTime::SECOND)).nseconds() as f64
* PI / (10.0 * gst::ClockTime::SECOND.nseconds() as f64);
* ((timestamp % (10 * gst::SECOND)).unwrap() as f64
/ (10.0 * gst::SECOND_VAL as f64));
// The image we draw (the text) will be static, but we will change the // The image we draw (the text) will be static, but we will change the
// transformation on the drawing context, which rotates and shifts everything // transformation on the drawing context, which rotates and shifts everything
@ -227,7 +225,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -106,7 +106,7 @@ fn example_main() {
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -58,7 +58,7 @@ fn example_main() {
//let pos = pipeline.query_position(gst::Format::Time).unwrap_or(-1); //let pos = pipeline.query_position(gst::Format::Time).unwrap_or(-1);
//let dur = pipeline.query_duration(gst::Format::Time).unwrap_or(-1); //let dur = pipeline.query_duration(gst::Format::Time).unwrap_or(-1);
let pos: gst::ClockTime = { let pos: Option<gst::ClockTime> = {
// Create a new position query and send it to the pipeline. // Create a new position query and send it to the pipeline.
// This will traverse all elements in the pipeline, until one feels // This will traverse all elements in the pipeline, until one feels
// capable of answering the query. // capable of answering the query.
@ -72,7 +72,7 @@ fn example_main() {
.and_then(|pos| pos.try_into().ok()) .and_then(|pos| pos.try_into().ok())
.unwrap(); .unwrap();
let dur: gst::ClockTime = { let dur: Option<gst::ClockTime> = {
// Create a new duration query and send it to the pipeline. // Create a new duration query and send it to the pipeline.
// This will traverse all elements in the pipeline, until one feels // This will traverse all elements in the pipeline, until one feels
// capable of answering the query. // capable of answering the query.
@ -86,7 +86,7 @@ fn example_main() {
.and_then(|dur| dur.try_into().ok()) .and_then(|dur| dur.try_into().ok())
.unwrap(); .unwrap();
println!("{} / {}", pos, dur); println!("{} / {}", pos.display(), dur.display());
glib::Continue(true) glib::Continue(true)
}); });

View file

@ -248,7 +248,7 @@ fn example_main() -> Result<(), Error> {
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -171,7 +171,7 @@ fn example_main() -> Result<(), Error> {
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -314,7 +314,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -85,7 +85,7 @@ fn example_main() -> Result<(), Error> {
pipeline.set_state(gst::State::Playing)?; pipeline.set_state(gst::State::Playing)?;
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -161,7 +161,7 @@ fn main_loop(pipeline: gst::Pipeline, position: u64) -> Result<(), Error> {
let mut seeked = false; let mut seeked = false;
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {
@ -171,7 +171,7 @@ fn main_loop(pipeline: gst::Pipeline, position: u64) -> Result<(), Error> {
println!("Got AsyncDone message, seeking to {}s", position); println!("Got AsyncDone message, seeking to {}s", position);
if pipeline if pipeline
.seek_simple(gst::SeekFlags::FLUSH, position * gst::SECOND) .seek_simple(gst::SeekFlags::FLUSH, position * gst::ClockTime::SECOND)
.is_err() .is_err()
{ {
println!("Failed to seek, taking first frame"); println!("Failed to seek, taking first frame");

View file

@ -87,7 +87,7 @@ fn example_main() {
// functionality like timeouts or GLib socket notifications, so this is sufficient. // functionality like timeouts or GLib socket notifications, so this is sufficient.
// The bus is manually operated by repeatedly calling timed_pop on the bus with // The bus is manually operated by repeatedly calling timed_pop on the bus with
// the desired timeout for when to stop waiting for new messages. (None = Wait forever) // the desired timeout for when to stop waiting for new messages. (None = Wait forever)
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -146,7 +146,7 @@ fn example_main() -> Result<(), Error> {
.bus() .bus()
.expect("Pipeline without bus. Shouldn't happen!"); .expect("Pipeline without bus. Shouldn't happen!");
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -52,7 +52,7 @@ fn example_main() {
* although in this example the only error we'll hopefully * although in this example the only error we'll hopefully
* get is if the user closes the output window */ * get is if the user closes the output window */
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -311,9 +311,10 @@ impl AppSink {
#[doc(alias = "gst_base_sink_get_processing_deadline")] #[doc(alias = "gst_base_sink_get_processing_deadline")]
pub fn processing_deadline(&self) -> gst::ClockTime { pub fn processing_deadline(&self) -> gst::ClockTime {
unsafe { unsafe {
from_glib(gst_base::ffi::gst_base_sink_get_processing_deadline( try_from_glib(gst_base::ffi::gst_base_sink_get_processing_deadline(
self.as_ptr() as *mut gst_base::ffi::GstBaseSink, self.as_ptr() as *mut gst_base::ffi::GstBaseSink,
)) ))
.expect("undefined processing_deadline")
} }
} }
@ -321,9 +322,10 @@ impl AppSink {
#[doc(alias = "gst_base_sink_get_render_delay")] #[doc(alias = "gst_base_sink_get_render_delay")]
pub fn render_delay(&self) -> gst::ClockTime { pub fn render_delay(&self) -> gst::ClockTime {
unsafe { unsafe {
from_glib(gst_base::ffi::gst_base_sink_get_render_delay( try_from_glib(gst_base::ffi::gst_base_sink_get_render_delay(
self.as_ptr() as *mut gst_base::ffi::GstBaseSink self.as_ptr() as *mut gst_base::ffi::GstBaseSink
)) ))
.expect("undefined render_delay")
} }
} }
@ -958,7 +960,7 @@ impl Stream for AppSinkStream {
}; };
app_sink app_sink
.try_pull_sample(gst::ClockTime::zero()) .try_pull_sample(gst::ClockTime::ZERO)
.map(|sample| Poll::Ready(Some(sample))) .map(|sample| Poll::Ready(Some(sample)))
.unwrap_or_else(|| { .unwrap_or_else(|| {
if app_sink.is_eos() { if app_sink.is_eos() {

View file

@ -266,15 +266,23 @@ impl AppSrc {
} }
#[doc(alias = "gst_app_src_set_latency")] #[doc(alias = "gst_app_src_set_latency")]
pub fn set_latency(&self, min: gst::ClockTime, max: gst::ClockTime) { pub fn set_latency(
&self,
min: impl Into<Option<gst::ClockTime>>,
max: impl Into<Option<gst::ClockTime>>,
) {
unsafe { unsafe {
ffi::gst_app_src_set_latency(self.to_glib_none().0, min.into_glib(), max.into_glib()); ffi::gst_app_src_set_latency(
self.to_glib_none().0,
min.into().into_glib(),
max.into().into_glib(),
);
} }
} }
#[doc(alias = "get_latency")] #[doc(alias = "get_latency")]
#[doc(alias = "gst_app_src_get_latency")] #[doc(alias = "gst_app_src_get_latency")]
pub fn latency(&self) -> (gst::ClockTime, gst::ClockTime) { pub fn latency(&self) -> (Option<gst::ClockTime>, Option<gst::ClockTime>) {
unsafe { unsafe {
let mut min = mem::MaybeUninit::uninit(); let mut min = mem::MaybeUninit::uninit();
let mut max = mem::MaybeUninit::uninit(); let mut max = mem::MaybeUninit::uninit();

View file

@ -23,10 +23,6 @@ pub trait AudioEncoderExtManual: 'static {
#[doc(alias = "get_allocator")] #[doc(alias = "get_allocator")]
#[doc(alias = "gst_audio_encoder_get_allocator")] #[doc(alias = "gst_audio_encoder_get_allocator")]
fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams); fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
#[doc(alias = "get_latency")]
#[doc(alias = "gst_audio_encoder_get_latency")]
fn latency(&self) -> (gst::ClockTime, gst::ClockTime);
} }
impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O { impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
@ -83,19 +79,4 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
(from_glib_full(allocator), params.into()) (from_glib_full(allocator), params.into())
} }
} }
fn latency(&self) -> (gst::ClockTime, gst::ClockTime) {
unsafe {
let mut min = mem::MaybeUninit::uninit();
let mut max = mem::MaybeUninit::uninit();
ffi::gst_audio_encoder_get_latency(
self.as_ref().to_glib_none().0,
min.as_mut_ptr(),
max.as_mut_ptr(),
);
let min = min.assume_init();
let max = max.assume_init();
(from_glib(min), from_glib(max))
}
}
} }

View file

@ -186,7 +186,7 @@ impl AudioInfo {
if from_glib(ffi::gst_audio_info_convert( if from_glib(ffi::gst_audio_info_convert(
&self.0, &self.0,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
U::default_format().into_glib(), U::default_format().into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)) { )) {
@ -210,7 +210,7 @@ impl AudioInfo {
if from_glib(ffi::gst_audio_info_convert( if from_glib(ffi::gst_audio_info_convert(
&self.0, &self.0,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
dest_fmt.into_glib(), dest_fmt.into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)) { )) {

View file

@ -301,17 +301,17 @@ mod tests {
{ {
let cmeta = AudioClippingMeta::add( let cmeta = AudioClippingMeta::add(
buffer.get_mut().unwrap(), buffer.get_mut().unwrap(),
gst::format::Default(Some(1)), gst::format::Default(1),
gst::format::Default(Some(2)), gst::format::Default(2),
); );
assert_eq!(cmeta.start().try_into(), Ok(gst::format::Default(Some(1)))); assert_eq!(cmeta.start().try_into(), Ok(Some(gst::format::Default(1))));
assert_eq!(cmeta.end().try_into(), Ok(gst::format::Default(Some(2)))); assert_eq!(cmeta.end().try_into(), Ok(Some(gst::format::Default(2))));
} }
{ {
let cmeta = buffer.meta::<AudioClippingMeta>().unwrap(); let cmeta = buffer.meta::<AudioClippingMeta>().unwrap();
assert_eq!(cmeta.start().try_into(), Ok(gst::format::Default(Some(1)))); assert_eq!(cmeta.start().try_into(), Ok(Some(gst::format::Default(1))));
assert_eq!(cmeta.end().try_into(), Ok(gst::format::Default(Some(2)))); assert_eq!(cmeta.end().try_into(), Ok(Some(gst::format::Default(2))));
} }
} }

View file

@ -30,8 +30,8 @@ impl AudioStreamAlign {
)); ));
( (
ret, ret,
from_glib(out_timestamp.assume_init()), try_from_glib(out_timestamp.assume_init()).expect("undefined out_timestamp"),
from_glib(out_duration.assume_init()), try_from_glib(out_duration.assume_init()).expect("undefined out_duration"),
out_sample_position.assume_init(), out_sample_position.assume_init(),
) )
} }

View file

@ -40,7 +40,7 @@ pub trait AudioSrcImpl: AudioSrcImplExt + BaseSrcImpl {
&self, &self,
src: &Self::Type, src: &Self::Type,
audio_data: &mut [u8], audio_data: &mut [u8],
) -> Result<(u32, gst::ClockTime), LoggableError> { ) -> Result<(u32, Option<gst::ClockTime>), LoggableError> {
self.parent_read(src, audio_data) self.parent_read(src, audio_data)
} }
@ -63,7 +63,7 @@ pub trait AudioSrcImplExt: ObjectSubclass {
&self, &self,
src: &Self::Type, src: &Self::Type,
audio_data: &mut [u8], audio_data: &mut [u8],
) -> Result<(u32, gst::ClockTime), LoggableError>; ) -> Result<(u32, Option<gst::ClockTime>), LoggableError>;
fn parent_reset(&self, src: &Self::Type); fn parent_reset(&self, src: &Self::Type);
} }
@ -160,13 +160,13 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
&self, &self,
src: &Self::Type, src: &Self::Type,
buffer: &mut [u8], buffer: &mut [u8],
) -> Result<(u32, gst::ClockTime), LoggableError> { ) -> Result<(u32, Option<gst::ClockTime>), LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
let f = match (*parent_class).read { let f = match (*parent_class).read {
Some(f) => f, Some(f) => f,
None => return Ok((0, gst::CLOCK_TIME_NONE)), None => return Ok((0, gst::ClockTime::NONE)),
}; };
let buffer_ptr = buffer.as_mut_ptr() as *mut _; let buffer_ptr = buffer.as_mut_ptr() as *mut _;
let mut timestamp = mem::MaybeUninit::uninit(); let mut timestamp = mem::MaybeUninit::uninit();
@ -319,7 +319,7 @@ unsafe extern "C" fn audiosrc_read<T: AudioSrcImpl>(
gst::panic_to_error!(&wrap, &imp.panicked(), 0, { gst::panic_to_error!(&wrap, &imp.panicked(), 0, {
let (res, timestamp_res) = imp let (res, timestamp_res) = imp
.read(wrap.unsafe_cast_ref(), data_slice) .read(wrap.unsafe_cast_ref(), data_slice)
.unwrap_or((0, gst::CLOCK_TIME_NONE)); .unwrap_or((0, gst::ClockTime::NONE));
*timestamp = timestamp_res.into_glib(); *timestamp = timestamp_res.into_glib();
res res

View file

@ -302,7 +302,7 @@ impl UniqueAdapter {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
pub fn dts_at_discont(&self) -> gst::ClockTime { pub fn dts_at_discont(&self) -> Option<gst::ClockTime> {
self.0.dts_at_discont() self.0.dts_at_discont()
} }
@ -356,11 +356,11 @@ impl UniqueAdapter {
self.0.offset_at_discont() self.0.offset_at_discont()
} }
pub fn prev_dts(&self) -> (gst::ClockTime, u64) { pub fn prev_dts(&self) -> (Option<gst::ClockTime>, u64) {
self.0.prev_dts() self.0.prev_dts()
} }
pub fn prev_dts_at_offset(&self, offset: usize) -> (gst::ClockTime, u64) { pub fn prev_dts_at_offset(&self, offset: usize) -> (Option<gst::ClockTime>, u64) {
self.0.prev_dts_at_offset(offset) self.0.prev_dts_at_offset(offset)
} }
@ -370,17 +370,17 @@ impl UniqueAdapter {
self.0.prev_offset() self.0.prev_offset()
} }
pub fn prev_pts(&self) -> (gst::ClockTime, u64) { pub fn prev_pts(&self) -> (Option<gst::ClockTime>, u64) {
self.0.prev_pts() self.0.prev_pts()
} }
pub fn prev_pts_at_offset(&self, offset: usize) -> (gst::ClockTime, u64) { pub fn prev_pts_at_offset(&self, offset: usize) -> (Option<gst::ClockTime>, u64) {
self.0.prev_pts_at_offset(offset) self.0.prev_pts_at_offset(offset)
} }
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
pub fn pts_at_discont(&self) -> gst::ClockTime { pub fn pts_at_discont(&self) -> Option<gst::ClockTime> {
self.0.pts_at_discont() self.0.pts_at_discont()
} }

View file

@ -55,16 +55,16 @@ pub trait AggregatorExtManual: 'static {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[doc(alias = "gst_aggregator_update_segment")] #[doc(alias = "gst_aggregator_update_segment")]
fn update_segment<F: gst::FormattedValue>(&self, segment: &gst::FormattedSegment<F>); fn update_segment<F: gst::FormattedValueIntrinsic>(&self, segment: &gst::FormattedSegment<F>);
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[doc(alias = "gst_aggregator_selected_samples")] #[doc(alias = "gst_aggregator_selected_samples")]
fn selected_samples( fn selected_samples(
&self, &self,
pts: gst::ClockTime, pts: impl Into<Option<gst::ClockTime>>,
dts: gst::ClockTime, dts: impl Into<Option<gst::ClockTime>>,
duration: gst::ClockTime, duration: impl Into<Option<gst::ClockTime>>,
info: Option<&gst::StructureRef>, info: Option<&gst::StructureRef>,
); );
@ -75,9 +75,9 @@ pub trait AggregatorExtManual: 'static {
F: Fn( F: Fn(
&P, &P,
&gst::Segment, &gst::Segment,
gst::ClockTime, Option<gst::ClockTime>,
gst::ClockTime, Option<gst::ClockTime>,
gst::ClockTime, Option<gst::ClockTime>,
Option<&gst::StructureRef>, Option<&gst::StructureRef>,
) + Send ) + Send
+ 'static, + 'static,
@ -174,7 +174,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
} }
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn update_segment<F: gst::FormattedValue>(&self, segment: &gst::FormattedSegment<F>) { fn update_segment<F: gst::FormattedValueIntrinsic>(&self, segment: &gst::FormattedSegment<F>) {
unsafe { unsafe {
ffi::gst_aggregator_update_segment( ffi::gst_aggregator_update_segment(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
@ -187,17 +187,17 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn selected_samples( fn selected_samples(
&self, &self,
pts: gst::ClockTime, pts: impl Into<Option<gst::ClockTime>>,
dts: gst::ClockTime, dts: impl Into<Option<gst::ClockTime>>,
duration: gst::ClockTime, duration: impl Into<Option<gst::ClockTime>>,
info: Option<&gst::StructureRef>, info: Option<&gst::StructureRef>,
) { ) {
unsafe { unsafe {
ffi::gst_aggregator_selected_samples( ffi::gst_aggregator_selected_samples(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
pts.into_glib(), pts.into().into_glib(),
dts.into_glib(), dts.into().into_glib(),
duration.into_glib(), duration.into().into_glib(),
info.as_ref() info.as_ref()
.map(|s| s.as_ptr() as *mut _) .map(|s| s.as_ptr() as *mut _)
.unwrap_or(ptr::null_mut()), .unwrap_or(ptr::null_mut()),
@ -212,9 +212,9 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
F: Fn( F: Fn(
&P, &P,
&gst::Segment, &gst::Segment,
gst::ClockTime, Option<gst::ClockTime>,
gst::ClockTime, Option<gst::ClockTime>,
gst::ClockTime, Option<gst::ClockTime>,
Option<&gst::StructureRef>, Option<&gst::StructureRef>,
) + Send ) + Send
+ 'static, + 'static,
@ -230,9 +230,9 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
F: Fn( F: Fn(
&P, &P,
&gst::Segment, &gst::Segment,
gst::ClockTime, Option<gst::ClockTime>,
gst::ClockTime, Option<gst::ClockTime>,
gst::ClockTime, Option<gst::ClockTime>,
Option<&gst::StructureRef>, Option<&gst::StructureRef>,
) + Send ) + Send
+ 'static, + 'static,

View file

@ -88,7 +88,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
let ret = from_glib(ffi::gst_base_parse_convert_default( let ret = from_glib(ffi::gst_base_parse_convert_default(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
U::default_format().into_glib(), U::default_format().into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)); ));
@ -111,7 +111,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
let ret = from_glib(ffi::gst_base_parse_convert_default( let ret = from_glib(ffi::gst_base_parse_convert_default(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
dest_format.into_glib(), dest_format.into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)); ));

View file

@ -12,7 +12,7 @@ pub trait BaseSinkExtManual: 'static {
#[doc(alias = "gst_base_sink_query_latency")] #[doc(alias = "gst_base_sink_query_latency")]
fn query_latency( fn query_latency(
&self, &self,
) -> Result<(bool, bool, gst::ClockTime, gst::ClockTime), glib::BoolError>; ) -> Result<(bool, bool, Option<gst::ClockTime>, Option<gst::ClockTime>), glib::BoolError>;
} }
impl<O: IsA<BaseSink>> BaseSinkExtManual for O { impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
@ -26,7 +26,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
fn query_latency( fn query_latency(
&self, &self,
) -> Result<(bool, bool, gst::ClockTime, gst::ClockTime), glib::BoolError> { ) -> Result<(bool, bool, Option<gst::ClockTime>, Option<gst::ClockTime>), glib::BoolError> {
unsafe { unsafe {
let mut live = mem::MaybeUninit::uninit(); let mut live = mem::MaybeUninit::uninit();
let mut upstream_live = mem::MaybeUninit::uninit(); let mut upstream_live = mem::MaybeUninit::uninit();

View file

@ -16,7 +16,9 @@ pub trait BaseSrcExtManual: 'static {
fn segment(&self) -> gst::Segment; fn segment(&self) -> gst::Segment;
#[doc(alias = "gst_base_src_query_latency")] #[doc(alias = "gst_base_src_query_latency")]
fn query_latency(&self) -> Result<(bool, gst::ClockTime, gst::ClockTime), glib::BoolError>; fn query_latency(
&self,
) -> Result<(bool, Option<gst::ClockTime>, Option<gst::ClockTime>), glib::BoolError>;
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
@ -46,7 +48,9 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
} }
} }
fn query_latency(&self) -> Result<(bool, gst::ClockTime, gst::ClockTime), glib::BoolError> { fn query_latency(
&self,
) -> Result<(bool, Option<gst::ClockTime>, Option<gst::ClockTime>), glib::BoolError> {
unsafe { unsafe {
let mut live = mem::MaybeUninit::uninit(); let mut live = mem::MaybeUninit::uninit();
let mut min_latency = mem::MaybeUninit::uninit(); let mut min_latency = mem::MaybeUninit::uninit();

View file

@ -115,7 +115,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
self.parent_stop(aggregator) self.parent_stop(aggregator)
} }
fn next_time(&self, aggregator: &Self::Type) -> gst::ClockTime { fn next_time(&self, aggregator: &Self::Type) -> Option<gst::ClockTime> {
self.parent_next_time(aggregator) self.parent_next_time(aggregator)
} }
@ -243,7 +243,7 @@ pub trait AggregatorImplExt: ObjectSubclass {
fn parent_stop(&self, aggregator: &Self::Type) -> Result<(), gst::ErrorMessage>; fn parent_stop(&self, aggregator: &Self::Type) -> Result<(), gst::ErrorMessage>;
fn parent_next_time(&self, aggregator: &Self::Type) -> gst::ClockTime; fn parent_next_time(&self, aggregator: &Self::Type) -> Option<gst::ClockTime>;
fn parent_create_new_pad( fn parent_create_new_pad(
&self, &self,
@ -557,7 +557,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
} }
} }
fn parent_next_time(&self, aggregator: &Self::Type) -> gst::ClockTime { fn parent_next_time(&self, aggregator: &Self::Type) -> Option<gst::ClockTime> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass;
@ -569,7 +569,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
.to_glib_none() .to_glib_none()
.0)) .0))
}) })
.unwrap_or(gst::CLOCK_TIME_NONE) .unwrap_or(gst::ClockTime::NONE)
} }
} }
@ -987,7 +987,7 @@ unsafe extern "C" fn aggregator_get_next_time<T: AggregatorImpl>(
let imp = instance.impl_(); let imp = instance.impl_();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr); let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst::panic_to_error!(&wrap, &imp.panicked(), gst::CLOCK_TIME_NONE, { gst::panic_to_error!(&wrap, &imp.panicked(), gst::ClockTime::NONE, {
imp.next_time(wrap.unsafe_cast_ref()) imp.next_time(wrap.unsafe_cast_ref())
}) })
.into_glib() .into_glib()

View file

@ -179,7 +179,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
let res = from_glib(f( let res = from_glib(f(
element.unsafe_cast_ref::<BaseParse>().to_glib_none().0, element.unsafe_cast_ref::<BaseParse>().to_glib_none().0,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
dest_format.into_glib(), dest_format.into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)); ));
@ -314,7 +314,7 @@ unsafe extern "C" fn base_parse_convert<T: BaseParseImpl>(
match res { match res {
Some(dest) => { Some(dest) => {
*dest_value = dest.to_raw_value(); *dest_value = dest.into_raw_value();
true true
} }
_ => false, _ => false,

View file

@ -39,7 +39,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl {
&self, &self,
element: &Self::Type, element: &Self::Type,
buffer: &gst::BufferRef, buffer: &gst::BufferRef,
) -> (gst::ClockTime, gst::ClockTime) { ) -> (Option<gst::ClockTime>, Option<gst::ClockTime>) {
self.parent_times(element, buffer) self.parent_times(element, buffer)
} }
@ -122,7 +122,7 @@ pub trait BaseSrcImplExt: ObjectSubclass {
&self, &self,
element: &Self::Type, element: &Self::Type,
buffer: &gst::BufferRef, buffer: &gst::BufferRef,
) -> (gst::ClockTime, gst::ClockTime); ) -> (Option<gst::ClockTime>, Option<gst::ClockTime>);
fn parent_fill( fn parent_fill(
&self, &self,
@ -247,7 +247,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
&self, &self,
element: &Self::Type, element: &Self::Type,
buffer: &gst::BufferRef, buffer: &gst::BufferRef,
) -> (gst::ClockTime, gst::ClockTime) { ) -> (Option<gst::ClockTime>, Option<gst::ClockTime>) {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
@ -267,7 +267,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
from_glib(stop.assume_init()), from_glib(stop.assume_init()),
) )
}) })
.unwrap_or((gst::CLOCK_TIME_NONE, gst::CLOCK_TIME_NONE)) .unwrap_or((gst::ClockTime::NONE, gst::ClockTime::NONE))
} }
} }

View file

@ -243,7 +243,7 @@ impl Harness {
#[doc(alias = "get_last_pushed_timestamp")] #[doc(alias = "get_last_pushed_timestamp")]
#[doc(alias = "gst_harness_get_last_pushed_timestamp")] #[doc(alias = "gst_harness_get_last_pushed_timestamp")]
pub fn last_pushed_timestamp(&self) -> gst::ClockTime { pub fn last_pushed_timestamp(&self) -> Option<gst::ClockTime> {
unsafe { from_glib(ffi::gst_harness_get_last_pushed_timestamp(self.0.as_ptr())) } unsafe { from_glib(ffi::gst_harness_get_last_pushed_timestamp(self.0.as_ptr())) }
} }
@ -346,7 +346,7 @@ impl Harness {
} }
#[doc(alias = "gst_harness_query_latency")] #[doc(alias = "gst_harness_query_latency")]
pub fn query_latency(&self) -> gst::ClockTime { pub fn query_latency(&self) -> Option<gst::ClockTime> {
unsafe { from_glib(ffi::gst_harness_query_latency(self.0.as_ptr())) } unsafe { from_glib(ffi::gst_harness_query_latency(self.0.as_ptr())) }
} }

View file

@ -18,7 +18,7 @@ impl ControlPoint {
pub fn timestamp(&self) -> gst::ClockTime { pub fn timestamp(&self) -> gst::ClockTime {
unsafe { unsafe {
let ptr = self.to_glib_none().0; let ptr = self.to_glib_none().0;
from_glib((*ptr).timestamp) try_from_glib((*ptr).timestamp).expect("undefined timestamp")
} }
} }

View file

@ -31,7 +31,7 @@ impl Discoverer {
value.to_glib_none_mut().0, value.to_glib_none_mut().0,
); );
} }
value.get().expect("Discoverer::get_property_timeout") value.get().expect("undefined timeout")
} }
#[doc(alias = "timeout")] #[doc(alias = "timeout")]

View file

@ -46,7 +46,7 @@ impl Player {
} }
} }
pub fn connect_duration_changed<F: Fn(&Player, gst::ClockTime) + Send + 'static>( pub fn connect_duration_changed<F: Fn(&Player, Option<gst::ClockTime>) + Send + 'static>(
&self, &self,
f: F, f: F,
) -> SignalHandlerId { ) -> SignalHandlerId {
@ -64,7 +64,7 @@ impl Player {
} }
} }
pub fn connect_position_updated<F: Fn(&Player, gst::ClockTime) + Send + 'static>( pub fn connect_position_updated<F: Fn(&Player, Option<gst::ClockTime>) + Send + 'static>(
&self, &self,
f: F, f: F,
) -> SignalHandlerId { ) -> SignalHandlerId {
@ -102,25 +102,25 @@ impl Player {
} }
unsafe extern "C" fn duration_changed_trampoline< unsafe extern "C" fn duration_changed_trampoline<
F: Fn(&Player, gst::ClockTime) + Send + 'static, F: Fn(&Player, Option<gst::ClockTime>) + Send + 'static,
>( >(
this: *mut ffi::GstPlayer, this: *mut ffi::GstPlayer,
object: u64, object: u64,
f: glib::ffi::gpointer, f: glib::ffi::gpointer,
) { ) {
let f: &F = &*(f as *const F); let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), gst::ClockTime(Some(object))) f(&from_glib_borrow(this), FromGlib::from_glib(object))
} }
unsafe extern "C" fn position_updated_trampoline< unsafe extern "C" fn position_updated_trampoline<
F: Fn(&Player, gst::ClockTime) + Send + 'static, F: Fn(&Player, Option<gst::ClockTime>) + Send + 'static,
>( >(
this: *mut ffi::GstPlayer, this: *mut ffi::GstPlayer,
object: u64, object: u64,
f: glib::ffi::gpointer, f: glib::ffi::gpointer,
) { ) {
let f: &F = &*(f as *const F); let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), gst::ClockTime(Some(object))) f(&from_glib_borrow(this), FromGlib::from_glib(object))
} }
unsafe extern "C" fn seek_done_trampoline<F: Fn(&Player, gst::ClockTime) + Send + 'static>( unsafe extern "C" fn seek_done_trampoline<F: Fn(&Player, gst::ClockTime) + Send + 'static>(
@ -129,5 +129,8 @@ unsafe extern "C" fn seek_done_trampoline<F: Fn(&Player, gst::ClockTime) + Send
f: glib::ffi::gpointer, f: glib::ffi::gpointer,
) { ) {
let f: &F = &*(f as *const F); let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), gst::ClockTime(Some(object))) f(
&from_glib_borrow(this),
try_from_glib(object).expect("undefined seek position"),
)
} }

View file

@ -253,7 +253,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
{ {
None None
} else { } else {
Some(from_glib(position.assume_init() as u64)) from_glib(position.assume_init() as u64)
} }
} else { } else {
None None
@ -276,7 +276,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
{ {
None None
} else { } else {
Some(from_glib(stop.assume_init() as u64)) from_glib(stop.assume_init() as u64)
} }
} else { } else {
None None

View file

@ -34,7 +34,7 @@ pub fn convert_sample(
pub fn convert_sample_async<F>( pub fn convert_sample_async<F>(
sample: &gst::Sample, sample: &gst::Sample,
caps: &gst::Caps, caps: &gst::Caps,
timeout: gst::ClockTime, timeout: Option<gst::ClockTime>,
func: F, func: F,
) where ) where
F: FnOnce(Result<gst::Sample, glib::Error>) + Send + 'static, F: FnOnce(Result<gst::Sample, glib::Error>) + Send + 'static,
@ -46,7 +46,7 @@ pub fn convert_sample_async<F>(
pub fn convert_sample_async_local<F>( pub fn convert_sample_async_local<F>(
sample: &gst::Sample, sample: &gst::Sample,
caps: &gst::Caps, caps: &gst::Caps,
timeout: gst::ClockTime, timeout: Option<gst::ClockTime>,
func: F, func: F,
) where ) where
F: FnOnce(Result<gst::Sample, glib::Error>) + Send + 'static, F: FnOnce(Result<gst::Sample, glib::Error>) + Send + 'static,
@ -61,7 +61,7 @@ pub fn convert_sample_async_local<F>(
unsafe fn convert_sample_async_unsafe<F>( unsafe fn convert_sample_async_unsafe<F>(
sample: &gst::Sample, sample: &gst::Sample,
caps: &gst::Caps, caps: &gst::Caps,
timeout: gst::ClockTime, timeout: Option<gst::ClockTime>,
func: F, func: F,
) where ) where
F: FnOnce(Result<gst::Sample, glib::Error>) + 'static, F: FnOnce(Result<gst::Sample, glib::Error>) + 'static,
@ -104,7 +104,7 @@ unsafe fn convert_sample_async_unsafe<F>(
pub fn convert_sample_future( pub fn convert_sample_future(
sample: &gst::Sample, sample: &gst::Sample,
caps: &gst::Caps, caps: &gst::Caps,
timeout: gst::ClockTime, timeout: Option<gst::ClockTime>,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<gst::Sample, glib::Error>> + 'static>> ) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<gst::Sample, glib::Error>> + 'static>>
{ {
skip_assert_initialized!(); skip_assert_initialized!();
@ -256,7 +256,7 @@ mod tests {
let l_clone = l.clone(); let l_clone = l.clone();
let res_store = Arc::new(Mutex::new(None)); let res_store = Arc::new(Mutex::new(None));
let res_store_clone = res_store.clone(); let res_store_clone = res_store.clone();
convert_sample_async(&sample, &out_caps, gst::CLOCK_TIME_NONE, move |res| { convert_sample_async(&sample, &out_caps, gst::ClockTime::NONE, move |res| {
*res_store_clone.lock().unwrap() = Some(res); *res_store_clone.lock().unwrap() = Some(res);
l_clone.quit(); l_clone.quit();
}); });

View file

@ -91,35 +91,35 @@ impl<'a> VideoCodecFrame<'a> {
} }
#[doc(alias = "get_dts")] #[doc(alias = "get_dts")]
pub fn dts(&self) -> gst::ClockTime { pub fn dts(&self) -> Option<gst::ClockTime> {
unsafe { from_glib((*self.to_glib_none().0).dts) } unsafe { from_glib((*self.to_glib_none().0).dts) }
} }
pub fn set_dts(&mut self, dts: gst::ClockTime) { pub fn set_dts(&mut self, dts: impl Into<Option<gst::ClockTime>>) {
unsafe { unsafe {
(*self.to_glib_none().0).dts = dts.into_glib(); (*self.to_glib_none().0).dts = dts.into().into_glib();
} }
} }
#[doc(alias = "get_pts")] #[doc(alias = "get_pts")]
pub fn pts(&self) -> gst::ClockTime { pub fn pts(&self) -> Option<gst::ClockTime> {
unsafe { from_glib((*self.to_glib_none().0).pts) } unsafe { from_glib((*self.to_glib_none().0).pts) }
} }
pub fn set_pts(&mut self, pts: gst::ClockTime) { pub fn set_pts(&mut self, pts: impl Into<Option<gst::ClockTime>>) {
unsafe { unsafe {
(*self.to_glib_none().0).pts = pts.into_glib(); (*self.to_glib_none().0).pts = pts.into().into_glib();
} }
} }
#[doc(alias = "get_duration")] #[doc(alias = "get_duration")]
pub fn duration(&self) -> gst::ClockTime { pub fn duration(&self) -> Option<gst::ClockTime> {
unsafe { from_glib((*self.to_glib_none().0).duration) } unsafe { from_glib((*self.to_glib_none().0).duration) }
} }
pub fn set_duration(&mut self, duration: gst::ClockTime) { pub fn set_duration(&mut self, duration: impl Into<Option<gst::ClockTime>>) {
unsafe { unsafe {
(*self.to_glib_none().0).duration = duration.into_glib(); (*self.to_glib_none().0).duration = duration.into().into_glib();
} }
} }
@ -188,7 +188,7 @@ impl<'a> VideoCodecFrame<'a> {
} }
#[doc(alias = "get_deadline")] #[doc(alias = "get_deadline")]
pub fn deadline(&self) -> gst::ClockTime { pub fn deadline(&self) -> Option<gst::ClockTime> {
unsafe { from_glib((*self.to_glib_none().0).deadline) } unsafe { from_glib((*self.to_glib_none().0).deadline) }
} }

View file

@ -51,8 +51,12 @@ pub trait VideoDecoderExtManual: 'static {
fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>; fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>;
#[doc(alias = "get_latency")] #[doc(alias = "get_latency")]
fn latency(&self) -> (gst::ClockTime, gst::ClockTime); fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>);
fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime); fn set_latency(
&self,
min_latency: gst::ClockTime,
max_latency: impl Into<Option<gst::ClockTime>>,
);
#[doc(alias = "get_output_state")] #[doc(alias = "get_output_state")]
fn output_state(&self) -> Option<VideoCodecState<'static, Readable>>; fn output_state(&self) -> Option<VideoCodecState<'static, Readable>>;
@ -152,7 +156,7 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
} }
#[doc(alias = "gst_video_decoder_get_latency")] #[doc(alias = "gst_video_decoder_get_latency")]
fn latency(&self) -> (gst::ClockTime, gst::ClockTime) { fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE; let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE;
let mut max_latency = gst::ffi::GST_CLOCK_TIME_NONE; let mut max_latency = gst::ffi::GST_CLOCK_TIME_NONE;
@ -163,17 +167,24 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
&mut max_latency, &mut max_latency,
); );
(from_glib(min_latency), from_glib(max_latency)) (
try_from_glib(min_latency).expect("undefined min_latency"),
from_glib(max_latency),
)
} }
} }
#[doc(alias = "gst_video_decoder_set_latency")] #[doc(alias = "gst_video_decoder_set_latency")]
fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime) { fn set_latency(
&self,
min_latency: gst::ClockTime,
max_latency: impl Into<Option<gst::ClockTime>>,
) {
unsafe { unsafe {
ffi::gst_video_decoder_set_latency( ffi::gst_video_decoder_set_latency(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
min_latency.into_glib(), min_latency.into_glib(),
max_latency.into_glib(), max_latency.into().into_glib(),
); );
} }
} }

View file

@ -46,9 +46,13 @@ pub trait VideoEncoderExtManual: 'static {
#[doc(alias = "get_latency")] #[doc(alias = "get_latency")]
#[doc(alias = "gst_video_encoder_get_latency")] #[doc(alias = "gst_video_encoder_get_latency")]
fn latency(&self) -> (gst::ClockTime, gst::ClockTime); fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>);
#[doc(alias = "gst_video_encoder_set_latency")] #[doc(alias = "gst_video_encoder_set_latency")]
fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime); fn set_latency(
&self,
min_latency: gst::ClockTime,
max_latency: impl Into<Option<gst::ClockTime>>,
);
#[doc(alias = "get_output_state")] #[doc(alias = "get_output_state")]
#[doc(alias = "gst_video_encoder_get_output_state")] #[doc(alias = "gst_video_encoder_get_output_state")]
@ -120,7 +124,7 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
} }
} }
fn latency(&self) -> (gst::ClockTime, gst::ClockTime) { fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE; let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE;
let mut max_latency = gst::ffi::GST_CLOCK_TIME_NONE; let mut max_latency = gst::ffi::GST_CLOCK_TIME_NONE;
@ -131,16 +135,23 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
&mut max_latency, &mut max_latency,
); );
(from_glib(min_latency), from_glib(max_latency)) (
try_from_glib(min_latency).expect("undefined min_latency"),
from_glib(max_latency),
)
} }
} }
fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime) { fn set_latency(
&self,
min_latency: gst::ClockTime,
max_latency: impl Into<Option<gst::ClockTime>>,
) {
unsafe { unsafe {
ffi::gst_video_encoder_set_latency( ffi::gst_video_encoder_set_latency(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
min_latency.into_glib(), min_latency.into_glib(),
max_latency.into_glib(), max_latency.into().into_glib(),
); );
} }
} }

View file

@ -68,9 +68,9 @@ pub struct DownstreamForceKeyUnitEventBuilder<'a> {
seqnum: Option<gst::Seqnum>, seqnum: Option<gst::Seqnum>,
running_time_offset: Option<i64>, running_time_offset: Option<i64>,
other_fields: Vec<(&'a str, &'a (dyn ToSendValue + Sync))>, other_fields: Vec<(&'a str, &'a (dyn ToSendValue + Sync))>,
timestamp: gst::ClockTime, timestamp: Option<gst::ClockTime>,
stream_time: gst::ClockTime, stream_time: Option<gst::ClockTime>,
running_time: gst::ClockTime, running_time: Option<gst::ClockTime>,
all_headers: bool, all_headers: bool,
count: u32, count: u32,
} }
@ -82,28 +82,31 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
seqnum: None, seqnum: None,
running_time_offset: None, running_time_offset: None,
other_fields: Vec::new(), other_fields: Vec::new(),
timestamp: gst::CLOCK_TIME_NONE, timestamp: gst::ClockTime::NONE,
stream_time: gst::CLOCK_TIME_NONE, stream_time: gst::ClockTime::NONE,
running_time: gst::CLOCK_TIME_NONE, running_time: gst::ClockTime::NONE,
all_headers: true, all_headers: true,
count: 0, count: 0,
} }
} }
pub fn timestamp(self, timestamp: gst::ClockTime) -> Self { pub fn timestamp(self, timestamp: impl Into<Option<gst::ClockTime>>) -> Self {
Self { timestamp, ..self }
}
pub fn stream_time(self, stream_time: gst::ClockTime) -> Self {
Self { Self {
stream_time, timestamp: timestamp.into(),
..self ..self
} }
} }
pub fn running_time(self, running_time: gst::ClockTime) -> Self { pub fn stream_time(self, stream_time: impl Into<Option<gst::ClockTime>>) -> Self {
Self { Self {
running_time, stream_time: stream_time.into(),
..self
}
}
pub fn running_time(self, running_time: impl Into<Option<gst::ClockTime>>) -> Self {
Self {
running_time: running_time.into(),
..self ..self
} }
} }
@ -132,9 +135,9 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub struct DownstreamForceKeyUnitEvent { pub struct DownstreamForceKeyUnitEvent {
pub timestamp: gst::ClockTime, pub timestamp: Option<gst::ClockTime>,
pub stream_time: gst::ClockTime, pub stream_time: Option<gst::ClockTime>,
pub running_time: gst::ClockTime, pub running_time: Option<gst::ClockTime>,
pub all_headers: bool, pub all_headers: bool,
pub count: u32, pub count: u32,
} }
@ -181,7 +184,7 @@ pub struct UpstreamForceKeyUnitEventBuilder<'a> {
seqnum: Option<gst::Seqnum>, seqnum: Option<gst::Seqnum>,
running_time_offset: Option<i64>, running_time_offset: Option<i64>,
other_fields: Vec<(&'a str, &'a (dyn ToSendValue + Sync))>, other_fields: Vec<(&'a str, &'a (dyn ToSendValue + Sync))>,
running_time: gst::ClockTime, running_time: Option<gst::ClockTime>,
all_headers: bool, all_headers: bool,
count: u32, count: u32,
} }
@ -193,15 +196,15 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
seqnum: None, seqnum: None,
running_time_offset: None, running_time_offset: None,
other_fields: Vec::new(), other_fields: Vec::new(),
running_time: gst::CLOCK_TIME_NONE, running_time: gst::ClockTime::NONE,
all_headers: true, all_headers: true,
count: 0, count: 0,
} }
} }
pub fn running_time(self, running_time: gst::ClockTime) -> Self { pub fn running_time(self, running_time: impl Into<Option<gst::ClockTime>>) -> Self {
Self { Self {
running_time, running_time: running_time.into(),
..self ..self
} }
} }
@ -228,7 +231,7 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub struct UpstreamForceKeyUnitEvent { pub struct UpstreamForceKeyUnitEvent {
pub running_time: gst::ClockTime, pub running_time: Option<gst::ClockTime>,
pub all_headers: bool, pub all_headers: bool,
pub count: u32, pub count: u32,
} }

View file

@ -761,7 +761,7 @@ impl VideoInfo {
if from_glib(ffi::gst_video_info_convert( if from_glib(ffi::gst_video_info_convert(
&self.0 as *const _ as *mut _, &self.0 as *const _ as *mut _,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
U::default_format().into_glib(), U::default_format().into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)) { )) {
@ -785,7 +785,7 @@ impl VideoInfo {
if from_glib(ffi::gst_video_info_convert( if from_glib(ffi::gst_video_info_convert(
&self.0 as *const _ as *mut _, &self.0 as *const _ as *mut _,
src_val.format().into_glib(), src_val.format().into_glib(),
src_val.to_raw_value(), src_val.into_raw_value(),
dest_fmt.into_glib(), dest_fmt.into_glib(),
dest_val.as_mut_ptr(), dest_val.as_mut_ptr(),
)) { )) {

View file

@ -1352,10 +1352,7 @@ mod tests {
true true
}); });
assert_eq!( assert_eq!(&[ClockTime::ZERO, ClockTime::SECOND][..], &res[..]);
&[Some(ClockTime::ZERO), Some(ClockTime::SECOND)][..],
&res[..]
);
} }
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(feature = "v1_14", feature = "dox"))]
@ -1387,17 +1384,14 @@ mod tests {
.downcast_ref::<crate::ReferenceTimestampMeta>() .downcast_ref::<crate::ReferenceTimestampMeta>()
.unwrap(); .unwrap();
res.push(meta.timestamp()); res.push(meta.timestamp());
if let Some(ClockTime::SECOND) = meta.timestamp() { if meta.timestamp() == ClockTime::SECOND {
Ok(false) Ok(false)
} else { } else {
Ok(true) Ok(true)
} }
}); });
assert_eq!( assert_eq!(&[ClockTime::ZERO, ClockTime::SECOND][..], &res[..]);
&[Some(ClockTime::ZERO), Some(ClockTime::SECOND)][..],
&res[..]
);
let mut res = vec![]; let mut res = vec![];
buffer.foreach_meta(|meta| { buffer.foreach_meta(|meta| {
@ -1408,6 +1402,6 @@ mod tests {
true true
}); });
assert_eq!(&[Some(ClockTime::ZERO)][..], &res[..]); assert_eq!(&[ClockTime::ZERO][..], &res[..]);
} }
} }

View file

@ -206,8 +206,11 @@ impl Bus {
self.iter_timed(Some(crate::ClockTime::ZERO)) self.iter_timed(Some(crate::ClockTime::ZERO))
} }
pub fn iter_timed(&self, timeout: Option<crate::ClockTime>) -> Iter { pub fn iter_timed(&self, timeout: impl Into<Option<crate::ClockTime>>) -> Iter {
Iter { bus: self, timeout } Iter {
bus: self,
timeout: timeout.into(),
}
} }
pub fn iter_filtered<'a>( pub fn iter_filtered<'a>(
@ -219,7 +222,7 @@ impl Bus {
pub fn iter_timed_filtered<'a>( pub fn iter_timed_filtered<'a>(
&'a self, &'a self,
timeout: Option<crate::ClockTime>, timeout: impl Into<Option<crate::ClockTime>>,
msg_types: &'a [MessageType], msg_types: &'a [MessageType],
) -> impl Iterator<Item = Message> + 'a { ) -> impl Iterator<Item = Message> + 'a {
self.iter_timed(timeout) self.iter_timed(timeout)
@ -228,11 +231,11 @@ impl Bus {
pub fn timed_pop_filtered( pub fn timed_pop_filtered(
&self, &self,
timeout: Option<crate::ClockTime>, timeout: impl Into<Option<crate::ClockTime>> + Clone,
msg_types: &[MessageType], msg_types: &[MessageType],
) -> Option<Message> { ) -> Option<Message> {
loop { loop {
let msg = self.timed_pop(timeout)?; let msg = self.timed_pop(timeout.clone())?;
if msg_types.contains(&msg.type_()) { if msg_types.contains(&msg.type_()) {
return Some(msg); return Some(msg);
} }

View file

@ -35,8 +35,11 @@ glib::wrapper! {
impl ClockId { impl ClockId {
#[doc(alias = "get_time")] #[doc(alias = "get_time")]
#[doc(alias = "gst_clock_id_get_time")] #[doc(alias = "gst_clock_id_get_time")]
pub fn time(&self) -> Option<ClockTime> { pub fn time(&self) -> ClockTime {
unsafe { from_glib(ffi::gst_clock_id_get_time(self.to_glib_none().0)) } unsafe {
try_from_glib(ffi::gst_clock_id_get_time(self.to_glib_none().0))
.expect("undefined time")
}
} }
#[doc(alias = "gst_clock_id_unschedule")] #[doc(alias = "gst_clock_id_unschedule")]
@ -242,7 +245,7 @@ impl PeriodicClockId {
pub fn interval(&self) -> ClockTime { pub fn interval(&self) -> ClockTime {
unsafe { unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _; let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _;
Option::<_>::from_glib((*ptr).interval).expect("undefined interval") try_from_glib((*ptr).interval).expect("undefined interval")
} }
} }
@ -360,10 +363,10 @@ impl Clock {
cexternal: ClockTime, cexternal: ClockTime,
cnum: ClockTime, cnum: ClockTime,
cdenom: ClockTime, cdenom: ClockTime,
) -> Option<ClockTime> { ) -> ClockTime {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
from_glib(ffi::gst_clock_adjust_with_calibration( try_from_glib(ffi::gst_clock_adjust_with_calibration(
ptr::null_mut(), ptr::null_mut(),
internal_target.into_glib(), internal_target.into_glib(),
cinternal.into_glib(), cinternal.into_glib(),
@ -371,6 +374,7 @@ impl Clock {
cnum.into_glib(), cnum.into_glib(),
cdenom.into_glib(), cdenom.into_glib(),
)) ))
.expect("undefined ClockTime")
} }
} }
@ -381,10 +385,10 @@ impl Clock {
cexternal: ClockTime, cexternal: ClockTime,
cnum: ClockTime, cnum: ClockTime,
cdenom: ClockTime, cdenom: ClockTime,
) -> Option<ClockTime> { ) -> ClockTime {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
from_glib(ffi::gst_clock_unadjust_with_calibration( try_from_glib(ffi::gst_clock_unadjust_with_calibration(
ptr::null_mut(), ptr::null_mut(),
external_target.into_glib(), external_target.into_glib(),
cinternal.into_glib(), cinternal.into_glib(),
@ -392,6 +396,7 @@ impl Clock {
cnum.into_glib(), cnum.into_glib(),
cdenom.into_glib(), cdenom.into_glib(),
)) ))
.expect("undefined ClockTime")
} }
} }
} }

View file

@ -784,7 +784,9 @@ impl<O: IsA<Element>> ElementExtManual for O {
let base_time = self.base_time(); let base_time = self.base_time();
let clock_time = self.current_clock_time(); let clock_time = self.current_clock_time();
clock_time.zip(base_time).map(|(ct, bt)| ct - bt) clock_time
.zip(base_time)
.and_then(|(ct, bt)| ct.checked_sub(bt))
} }
fn current_clock_time(&self) -> Option<crate::ClockTime> { fn current_clock_time(&self) -> Option<crate::ClockTime> {

View file

@ -11,7 +11,9 @@ use std::num::NonZeroU32;
use std::ops::Deref; use std::ops::Deref;
use std::ptr; use std::ptr;
use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlib, ToGlibPtr}; use glib::translate::{
from_glib, from_glib_full, from_glib_none, try_from_glib, IntoGlib, ToGlibPtr,
};
use glib::value::ToSendValue; use glib::value::ToSendValue;
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -766,17 +768,20 @@ impl<'a> SegmentDone<'a> {
declare_concrete_event!(Gap); declare_concrete_event!(Gap);
impl<'a> Gap<'a> { impl<'a> Gap<'a> {
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(timestamp: crate::ClockTime, duration: crate::ClockTime) -> Event { pub fn new(
timestamp: crate::ClockTime,
duration: impl Into<Option<crate::ClockTime>>,
) -> Event {
skip_assert_initialized!(); skip_assert_initialized!();
Self::builder(timestamp, duration).build() Self::builder(timestamp).duration(duration).build()
} }
pub fn builder(timestamp: crate::ClockTime, duration: crate::ClockTime) -> GapBuilder<'a> { pub fn builder(timestamp: crate::ClockTime) -> GapBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
GapBuilder::new(timestamp, duration) GapBuilder::new(timestamp)
} }
pub fn get(&self) -> (Option<crate::ClockTime>, Option<crate::ClockTime>) { pub fn get(&self) -> (crate::ClockTime, Option<crate::ClockTime>) {
unsafe { unsafe {
let mut timestamp = mem::MaybeUninit::uninit(); let mut timestamp = mem::MaybeUninit::uninit();
let mut duration = mem::MaybeUninit::uninit(); let mut duration = mem::MaybeUninit::uninit();
@ -788,7 +793,7 @@ impl<'a> Gap<'a> {
); );
( (
from_glib(timestamp.assume_init()), try_from_glib(timestamp.assume_init()).expect("undefined timestamp"),
from_glib(duration.assume_init()), from_glib(duration.assume_init()),
) )
} }
@ -802,20 +807,17 @@ impl<'a> Qos<'a> {
type_: crate::QOSType, type_: crate::QOSType,
proportion: f64, proportion: f64,
diff: i64, diff: i64,
timestamp: crate::ClockTime, timestamp: impl Into<Option<crate::ClockTime>>,
) -> Event { ) -> Event {
skip_assert_initialized!(); skip_assert_initialized!();
Self::builder(type_, proportion, diff, timestamp).build() Self::builder(type_, proportion, diff)
.timestamp(timestamp)
.build()
} }
pub fn builder( pub fn builder(type_: crate::QOSType, proportion: f64, diff: i64) -> QosBuilder<'a> {
type_: crate::QOSType,
proportion: f64,
diff: i64,
timestamp: crate::ClockTime,
) -> QosBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
QosBuilder::new(type_, proportion, diff, timestamp) QosBuilder::new(type_, proportion, diff)
} }
pub fn get(&self) -> (crate::QOSType, f64, i64, Option<crate::ClockTime>) { pub fn get(&self) -> (crate::QOSType, f64, i64, Option<crate::ClockTime>) {
@ -962,13 +964,13 @@ impl<'a> Latency<'a> {
#[doc(alias = "get_latency")] #[doc(alias = "get_latency")]
#[doc(alias = "gst_event_parse_latency")] #[doc(alias = "gst_event_parse_latency")]
pub fn latency(&self) -> Option<crate::ClockTime> { pub fn latency(&self) -> crate::ClockTime {
unsafe { unsafe {
let mut latency = mem::MaybeUninit::uninit(); let mut latency = mem::MaybeUninit::uninit();
ffi::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr()); ffi::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr());
from_glib(latency.assume_init()) try_from_glib(latency.assume_init()).expect("undefined latency")
} }
} }
} }
@ -1616,19 +1618,24 @@ impl<'a> SegmentDoneBuilder<'a> {
pub struct GapBuilder<'a> { pub struct GapBuilder<'a> {
builder: EventBuilder<'a>, builder: EventBuilder<'a>,
timestamp: crate::ClockTime, timestamp: crate::ClockTime,
duration: crate::ClockTime, duration: Option<crate::ClockTime>,
} }
impl<'a> GapBuilder<'a> { impl<'a> GapBuilder<'a> {
fn new(timestamp: crate::ClockTime, duration: crate::ClockTime) -> Self { fn new(timestamp: crate::ClockTime) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
Self { Self {
builder: EventBuilder::new(), builder: EventBuilder::new(),
timestamp, timestamp,
duration, duration: None,
} }
} }
pub fn duration(mut self, duration: impl Into<Option<crate::ClockTime>>) -> Self {
self.duration = duration.into();
self
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_gap( event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_gap(
s.timestamp.into_glib(), s.timestamp.into_glib(),
s.duration.into_glib() s.duration.into_glib()
@ -1640,21 +1647,26 @@ pub struct QosBuilder<'a> {
type_: crate::QOSType, type_: crate::QOSType,
proportion: f64, proportion: f64,
diff: i64, diff: i64,
timestamp: crate::ClockTime, timestamp: Option<crate::ClockTime>,
} }
impl<'a> QosBuilder<'a> { impl<'a> QosBuilder<'a> {
fn new(type_: crate::QOSType, proportion: f64, diff: i64, timestamp: crate::ClockTime) -> Self { fn new(type_: crate::QOSType, proportion: f64, diff: i64) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
Self { Self {
builder: EventBuilder::new(), builder: EventBuilder::new(),
type_, type_,
proportion, proportion,
diff, diff,
timestamp, timestamp: None,
} }
} }
pub fn timestamp(mut self, timestamp: impl Into<Option<crate::ClockTime>>) -> Self {
self.timestamp = timestamp.into();
self
}
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos( event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(
s.type_.into_glib(), s.type_.into_glib(),
s.proportion, s.proportion,
@ -1697,6 +1709,14 @@ impl<'a> SeekBuilder<'a> {
} }
} }
pub fn trickmode_interval(
mut self,
trickmode_interval: impl Into<Option<crate::ClockTime>>,
) -> Self {
self.trickmode_interval = trickmode_interval.into();
self
}
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| {
#[allow(clippy::let_and_return)] #[allow(clippy::let_and_return)]
{ {

View file

@ -17,7 +17,7 @@ use std::ops::Deref;
use std::ptr; use std::ptr;
use glib::translate::{ use glib::translate::{
from_glib, from_glib_full, from_glib_none, mut_override, IntoGlib, ToGlibPtr, from_glib, from_glib_full, from_glib_none, mut_override, try_from_glib, IntoGlib, ToGlibPtr,
}; };
mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || { mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || {
@ -945,14 +945,14 @@ impl<'a> AsyncStart<'a> {
declare_concrete_message!(AsyncDone); declare_concrete_message!(AsyncDone);
impl<'a> AsyncDone<'a> { impl<'a> AsyncDone<'a> {
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(running_time: crate::ClockTime) -> Message { pub fn new(running_time: impl Into<Option<crate::ClockTime>>) -> Message {
skip_assert_initialized!(); skip_assert_initialized!();
Self::builder(running_time).build() Self::builder().running_time(running_time).build()
} }
pub fn builder(running_time: crate::ClockTime) -> AsyncDoneBuilder<'a> { pub fn builder() -> AsyncDoneBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
AsyncDoneBuilder::new(running_time) AsyncDoneBuilder::new()
} }
#[doc(alias = "get_running_time")] #[doc(alias = "get_running_time")]
@ -1055,24 +1055,23 @@ impl<'a> Qos<'a> {
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new( pub fn new(
live: bool, live: bool,
running_time: crate::ClockTime, running_time: impl Into<Option<crate::ClockTime>>,
stream_time: crate::ClockTime, stream_time: impl Into<Option<crate::ClockTime>>,
timestamp: crate::ClockTime, timestamp: impl Into<Option<crate::ClockTime>>,
duration: crate::ClockTime, duration: impl Into<Option<crate::ClockTime>>,
) -> Message { ) -> Message {
skip_assert_initialized!(); skip_assert_initialized!();
Self::builder(live, running_time, stream_time, timestamp, duration).build() Self::builder(live)
.running_time(running_time)
.stream_time(stream_time)
.timestamp(timestamp)
.duration(duration)
.build()
} }
pub fn builder( pub fn builder(live: bool) -> QosBuilder<'a> {
live: bool,
running_time: crate::ClockTime,
stream_time: crate::ClockTime,
timestamp: crate::ClockTime,
duration: crate::ClockTime,
) -> QosBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
QosBuilder::new(live, running_time, stream_time, timestamp, duration) QosBuilder::new(live)
} }
pub fn get( pub fn get(
@ -1241,13 +1240,13 @@ impl<'a> ResetTime<'a> {
} }
#[doc(alias = "get_running_time")] #[doc(alias = "get_running_time")]
pub fn running_time(&self) -> Option<crate::ClockTime> { pub fn running_time(&self) -> crate::ClockTime {
unsafe { unsafe {
let mut running_time = mem::MaybeUninit::uninit(); let mut running_time = mem::MaybeUninit::uninit();
ffi::gst_message_parse_reset_time(self.as_mut_ptr(), running_time.as_mut_ptr()); ffi::gst_message_parse_reset_time(self.as_mut_ptr(), running_time.as_mut_ptr());
from_glib(running_time.assume_init()) try_from_glib(running_time.assume_init()).expect("undefined running_time")
} }
} }
} }
@ -2346,18 +2345,23 @@ impl<'a> AsyncStartBuilder<'a> {
pub struct AsyncDoneBuilder<'a> { pub struct AsyncDoneBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
running_time: crate::ClockTime, running_time: Option<crate::ClockTime>,
} }
impl<'a> AsyncDoneBuilder<'a> { impl<'a> AsyncDoneBuilder<'a> {
fn new(running_time: crate::ClockTime) -> Self { fn new() -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
Self { Self {
builder: MessageBuilder::new(), builder: MessageBuilder::new(),
running_time, running_time: None,
} }
} }
pub fn running_time(mut self, running_time: impl Into<Option<crate::ClockTime>>) -> Self {
self.running_time = running_time.into();
self
}
message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done( message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done(
src, src,
s.running_time.into_glib() s.running_time.into_glib()
@ -2426,35 +2430,49 @@ impl<'a> StepStartBuilder<'a> {
pub struct QosBuilder<'a> { pub struct QosBuilder<'a> {
builder: MessageBuilder<'a>, builder: MessageBuilder<'a>,
live: bool, live: bool,
running_time: crate::ClockTime, running_time: Option<crate::ClockTime>,
stream_time: crate::ClockTime, stream_time: Option<crate::ClockTime>,
timestamp: crate::ClockTime, timestamp: Option<crate::ClockTime>,
duration: crate::ClockTime, duration: Option<crate::ClockTime>,
values: Option<(i64, f64, i32)>, values: Option<(i64, f64, i32)>,
stats: Option<(GenericFormattedValue, GenericFormattedValue)>, stats: Option<(GenericFormattedValue, GenericFormattedValue)>,
} }
impl<'a> QosBuilder<'a> { impl<'a> QosBuilder<'a> {
fn new( fn new(live: bool) -> Self {
live: bool,
running_time: crate::ClockTime,
stream_time: crate::ClockTime,
timestamp: crate::ClockTime,
duration: crate::ClockTime,
) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
Self { Self {
builder: MessageBuilder::new(), builder: MessageBuilder::new(),
live, live,
running_time, running_time: None,
stream_time, stream_time: None,
timestamp, timestamp: None,
duration, duration: None,
values: None, values: None,
stats: None, stats: None,
} }
} }
pub fn running_time(mut self, running_time: impl Into<Option<crate::ClockTime>>) -> Self {
self.running_time = running_time.into();
self
}
pub fn stream_time(mut self, stream_time: impl Into<Option<crate::ClockTime>>) -> Self {
self.stream_time = stream_time.into();
self
}
pub fn timestamp(mut self, timestamp: impl Into<Option<crate::ClockTime>>) -> Self {
self.timestamp = timestamp.into();
self
}
pub fn duration(mut self, duration: impl Into<Option<crate::ClockTime>>) -> Self {
self.duration = duration.into();
self
}
pub fn values(self, jitter: i64, proportion: f64, quality: i32) -> Self { pub fn values(self, jitter: i64, proportion: f64, quality: i32) -> Self {
Self { Self {
values: Some((jitter, proportion, quality)), values: Some((jitter, proportion, quality)),

View file

@ -16,10 +16,10 @@ use crate::CapsRef;
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
use crate::ClockTime; use crate::ClockTime;
use glib::translate::{from_glib, from_glib_none, FromGlib, ToGlibPtr};
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
use glib::translate::IntoGlib; use glib::translate::{try_from_glib, IntoGlib};
use glib::translate::{from_glib, from_glib_none, FromGlib, ToGlibPtr};
pub unsafe trait MetaAPI: Sync + Send + Sized { pub unsafe trait MetaAPI: Sync + Send + Sized {
type GstType; type GstType;
@ -403,8 +403,8 @@ impl ReferenceTimestampMeta {
} }
#[doc(alias = "get_timestamp")] #[doc(alias = "get_timestamp")]
pub fn timestamp(&self) -> Option<ClockTime> { pub fn timestamp(&self) -> ClockTime {
unsafe { from_glib(self.0.timestamp) } unsafe { try_from_glib(self.0.timestamp).expect("undefined timestamp") }
} }
#[doc(alias = "get_duration")] #[doc(alias = "get_duration")]

View file

@ -324,7 +324,7 @@ impl Default for Latency<Query> {
impl<T: AsPtr> Latency<T> { impl<T: AsPtr> Latency<T> {
#[doc(alias = "get_result")] #[doc(alias = "get_result")]
pub fn result(&self) -> (bool, Option<crate::ClockTime>, Option<crate::ClockTime>) { pub fn result(&self) -> (bool, crate::ClockTime, Option<crate::ClockTime>) {
unsafe { unsafe {
let mut live = mem::MaybeUninit::uninit(); let mut live = mem::MaybeUninit::uninit();
let mut min = mem::MaybeUninit::uninit(); let mut min = mem::MaybeUninit::uninit();
@ -339,7 +339,7 @@ impl<T: AsPtr> Latency<T> {
( (
from_glib(live.assume_init()), from_glib(live.assume_init()),
from_glib(min.assume_init()), try_from_glib(min.assume_init()).expect("undefined min latency"),
from_glib(max.assume_init()), from_glib(max.assume_init()),
) )
} }
@ -348,13 +348,18 @@ impl<T: AsPtr> Latency<T> {
impl<T: AsMutPtr> Latency<T> { impl<T: AsMutPtr> Latency<T> {
#[doc(alias = "gst_query_set_latency")] #[doc(alias = "gst_query_set_latency")]
pub fn set(&mut self, live: bool, min: crate::ClockTime, max: crate::ClockTime) { pub fn set(
&mut self,
live: bool,
min: crate::ClockTime,
max: impl Into<Option<crate::ClockTime>>,
) {
unsafe { unsafe {
ffi::gst_query_set_latency( ffi::gst_query_set_latency(
self.0.as_mut_ptr(), self.0.as_mut_ptr(),
live.into_glib(), live.into_glib(),
min.into_glib(), min.into_glib(),
max.into_glib(), max.into().into_glib(),
); );
} }
} }

View file

@ -18,15 +18,15 @@ pub trait ClockImpl: ClockImplExt + ObjectImpl + Send + Sync {
clock: &Self::Type, clock: &Self::Type,
old_resolution: ClockTime, old_resolution: ClockTime,
new_resolution: ClockTime, new_resolution: ClockTime,
) -> Option<ClockTime> { ) -> ClockTime {
self.parent_change_resolution(clock, old_resolution, new_resolution) self.parent_change_resolution(clock, old_resolution, new_resolution)
} }
fn resolution(&self, clock: &Self::Type) -> Option<ClockTime> { fn resolution(&self, clock: &Self::Type) -> ClockTime {
self.parent_resolution(clock) self.parent_resolution(clock)
} }
fn internal_time(&self, clock: &Self::Type) -> Option<ClockTime> { fn internal_time(&self, clock: &Self::Type) -> ClockTime {
self.parent_internal_time(clock) self.parent_internal_time(clock)
} }
@ -53,11 +53,11 @@ pub trait ClockImplExt: ObjectSubclass {
clock: &Self::Type, clock: &Self::Type,
old_resolution: ClockTime, old_resolution: ClockTime,
new_resolution: ClockTime, new_resolution: ClockTime,
) -> Option<ClockTime>; ) -> ClockTime;
fn parent_resolution(&self, clock: &Self::Type) -> Option<ClockTime>; fn parent_resolution(&self, clock: &Self::Type) -> ClockTime;
fn parent_internal_time(&self, clock: &Self::Type) -> Option<ClockTime>; fn parent_internal_time(&self, clock: &Self::Type) -> ClockTime;
fn parent_wait( fn parent_wait(
&self, &self,
@ -85,48 +85,51 @@ impl<T: ClockImpl> ClockImplExt for T {
clock: &Self::Type, clock: &Self::Type,
old_resolution: ClockTime, old_resolution: ClockTime,
new_resolution: ClockTime, new_resolution: ClockTime,
) -> Option<ClockTime> { ) -> ClockTime {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
if let Some(func) = (*parent_class).change_resolution { if let Some(func) = (*parent_class).change_resolution {
from_glib(func( try_from_glib(func(
clock.unsafe_cast_ref::<Clock>().to_glib_none().0, clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
old_resolution.into_glib(), old_resolution.into_glib(),
new_resolution.into_glib(), new_resolution.into_glib(),
)) ))
.expect("undefined resolution")
} else { } else {
self.resolution(clock) self.resolution(clock)
} }
} }
} }
fn parent_resolution(&self, clock: &Self::Type) -> Option<ClockTime> { fn parent_resolution(&self, clock: &Self::Type) -> ClockTime {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
from_glib( try_from_glib(
(*parent_class) (*parent_class)
.get_resolution .get_resolution
.map(|f| f(clock.unsafe_cast_ref::<Clock>().to_glib_none().0)) .map(|f| f(clock.unsafe_cast_ref::<Clock>().to_glib_none().0))
.unwrap_or(1), .unwrap_or(1),
) )
.expect("undefined resolution")
} }
} }
fn parent_internal_time(&self, clock: &Self::Type) -> Option<ClockTime> { fn parent_internal_time(&self, clock: &Self::Type) -> ClockTime {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
from_glib( try_from_glib(
(*parent_class) (*parent_class)
.get_internal_time .get_internal_time
.map(|f| f(clock.unsafe_cast_ref::<Clock>().to_glib_none().0)) .map(|f| f(clock.unsafe_cast_ref::<Clock>().to_glib_none().0))
.unwrap_or(0), .unwrap_or(0),
) )
.expect("undefined internal_time")
} }
} }

View file

@ -19,7 +19,7 @@ fn tutorial_main() {
// Wait until error or EOS // Wait until error or EOS
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -181,7 +181,7 @@ USAGE: Choose one of the following options, then press enter:
.get::<Option<Element>>() .get::<Option<Element>>()
{ {
// Send the event // Send the event
let step = Step::new(gst::format::Buffers(Some(1)), rate.abs(), true, false); let step = Step::new(gst::format::Buffers(1), rate.abs(), true, false);
video_sink.send_event(step); video_sink.send_event(step);
println!("Stepping one frame\r"); println!("Stepping one frame\r");
} }

View file

@ -30,7 +30,7 @@ fn tutorial_main() {
// Wait until error or EOS // Wait until error or EOS
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -78,7 +78,7 @@ fn tutorial_main() {
// Wait until error or EOS // Wait until error or EOS
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -6,12 +6,18 @@ use std::io::Write;
mod tutorials_common; mod tutorials_common;
struct CustomData { struct CustomData {
playbin: gst::Element, // Our one and only element /// Our one and only element
playing: bool, // Are we in the PLAYING state? playbin: gst::Element,
terminate: bool, // Should we terminate execution? /// Are we in the PLAYING state?
seek_enabled: bool, // Is seeking enabled for this media? playing: bool,
seek_done: bool, // Have we performed the seek already? /// Should we terminate execution?
duration: gst::ClockTime, // How long does this media last, in nanoseconds terminate: bool,
/// Is seeking enabled for this media?
seek_enabled: bool,
/// Have we performed the seek already?
seek_done: bool,
/// How long does this media last, in nanoseconds
duration: Option<gst::ClockTime>,
} }
fn tutorial_main() { fn tutorial_main() {
@ -42,11 +48,11 @@ fn tutorial_main() {
terminate: false, terminate: false,
seek_enabled: false, seek_enabled: false,
seek_done: false, seek_done: false,
duration: gst::CLOCK_TIME_NONE, duration: gst::ClockTime::NONE,
}; };
while !custom_data.terminate { while !custom_data.terminate {
let msg = bus.timed_pop(100 * gst::MSECOND); let msg = bus.timed_pop(100 * gst::ClockTime::MSECOND);
match msg { match msg {
Some(msg) => { Some(msg) => {
@ -65,7 +71,11 @@ fn tutorial_main() {
} }
// Print current position and total duration // Print current position and total duration
print!("\rPosition {} / {}", position, custom_data.duration); print!(
"\rPosition {} / {}",
position,
custom_data.duration.display()
);
io::stdout().flush().unwrap(); io::stdout().flush().unwrap();
if custom_data.seek_enabled if custom_data.seek_enabled
@ -77,7 +87,7 @@ fn tutorial_main() {
.playbin .playbin
.seek_simple( .seek_simple(
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT, gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
30 * gst::SECOND, 30 * gst::ClockTime::SECOND,
) )
.expect("Failed to seek."); .expect("Failed to seek.");
custom_data.seek_done = true; custom_data.seek_done = true;
@ -113,7 +123,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
} }
MessageView::DurationChanged(_) => { MessageView::DurationChanged(_) => {
// The duration has changed, mark the current one as invalid // The duration has changed, mark the current one as invalid
custom_data.duration = gst::CLOCK_TIME_NONE; custom_data.duration = gst::ClockTime::NONE;
} }
MessageView::StateChanged(state_changed) => { MessageView::StateChanged(state_changed) => {
if state_changed if state_changed
@ -136,7 +146,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
let (seekable, start, end) = seeking.result(); let (seekable, start, end) = seeking.result();
custom_data.seek_enabled = seekable; custom_data.seek_enabled = seekable;
if seekable { if seekable {
println!("Seeking is ENABLED from {:?} to {:?}", start, end) println!("Seeking is ENABLED from {} to {}", start, end)
} else { } else {
println!("Seeking is DISABLED for this stream.") println!("Seeking is DISABLED for this stream.")
} }

View file

@ -123,7 +123,7 @@ mod tutorial5 {
if pipeline if pipeline
.seek_simple( .seek_simple(
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT, gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
value * gst::SECOND, value * gst::ClockTime::SECOND,
) )
.is_err() .is_err()
{ {

View file

@ -117,7 +117,7 @@ fn tutorial_main() {
// Wait until error, EOS or State Change // Wait until error, EOS or State Change
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -67,7 +67,7 @@ fn tutorial_main() {
.set_state(gst::State::Playing) .set_state(gst::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state"); .expect("Unable to set the pipeline to the `Playing` state");
let bus = pipeline.bus().unwrap(); let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) { for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {

View file

@ -160,10 +160,10 @@ fn main() {
let mut data = data.lock().unwrap(); let mut data = data.lock().unwrap();
let mut buffer = gst::Buffer::with_size(CHUNK_SIZE).unwrap(); let mut buffer = gst::Buffer::with_size(CHUNK_SIZE).unwrap();
let num_samples = CHUNK_SIZE / 2; /* Each sample is 16 bits */ let num_samples = CHUNK_SIZE / 2; /* Each sample is 16 bits */
let pts = gst::SECOND let pts = gst::ClockTime::SECOND
.mul_div_floor(data.num_samples, u64::from(SAMPLE_RATE)) .mul_div_floor(data.num_samples, u64::from(SAMPLE_RATE))
.expect("u64 overflow"); .expect("u64 overflow");
let duration = gst::SECOND let duration = gst::ClockTime::SECOND
.mul_div_floor(num_samples as u64, u64::from(SAMPLE_RATE)) .mul_div_floor(num_samples as u64, u64::from(SAMPLE_RATE))
.expect("u64 overflow"); .expect("u64 overflow");

View file

@ -150,7 +150,7 @@ fn run_discoverer() -> Result<(), Error> {
println!("Discovering {}", uri); println!("Discovering {}", uri);
let loop_ = glib::MainLoop::new(None, false); let loop_ = glib::MainLoop::new(None, false);
let timeout = 5 * gst::SECOND; let timeout = 5 * gst::ClockTime::SECOND;
let discoverer = gst_pbutils::Discoverer::new(timeout)?; let discoverer = gst_pbutils::Discoverer::new(timeout)?;
discoverer.connect_discovered(on_discovered); discoverer.connect_discovered(on_discovered);
let loop_clone = loop_.clone(); let loop_clone = loop_.clone();

View file

@ -130,15 +130,15 @@ fn tutorial_main() -> Result<(), Error> {
let start = range.0; let start = range.0;
let stop = range.1; let stop = range.1;
let start = if let Percent(start) = start { let start = if let Percent(start) = start {
start.unwrap() *start.unwrap()
} else { } else {
0 0
} / gst::FORMAT_PERCENT_MAX; } / gst::format::Percent::MAX;
let stop = if let Percent(stop) = stop { let stop = if let Percent(stop) = stop {
stop.unwrap() *stop.unwrap()
} else { } else {
0 0
} / gst::FORMAT_PERCENT_MAX; } / gst::format::Percent::MAX;
if start == 0 && stop == 0 { if start == 0 && stop == 0 {
continue; continue;
} }