Add constants for SECOND, MSECOND, USECOND, NSECOND

And use them in the examples.
This commit is contained in:
Sebastian Dröge 2017-08-29 11:07:59 +03:00
parent 083a6b6eeb
commit 8013169e09
3 changed files with 8 additions and 3 deletions

View file

@ -58,7 +58,7 @@ fn main_loop() -> Result<(), utils::ExampleError> {
let mut buffer = gst::Buffer::with_size(WIDTH * HEIGHT * 4).unwrap();
{
let buffer = buffer.get_mut().unwrap();
buffer.set_pts(i * 500_000_000);
buffer.set_pts(i * 500 * gst::MSECOND);
let mut data = buffer.map_writable().unwrap();

View file

@ -62,7 +62,7 @@ fn create_ui(app: &gtk::Application) {
let position = pipeline.query_position(gst::Format::Time);
if let Some(position) = position {
let mut seconds = position / 1_000_000_000;
let mut seconds = position / gst::SECOND;
let mut minutes = seconds / 60;
let hours = minutes / 60;

View file

@ -142,7 +142,12 @@ pub fn init() -> Result<(), glib::Error> {
}
pub const BUFFER_OFFSET_NONE: u64 = ffi::GST_BUFFER_OFFSET_NONE;
pub const CLOCK_TIME_NONE: u64 = ffi::GST_CLOCK_TIME_NONE;
pub const CLOCK_TIME_NONE: ClockTime = ffi::GST_CLOCK_TIME_NONE;
pub const SECOND: ClockTime = 1_000_000_000;
pub const MSECOND: ClockTime = 1_000_000;
pub const USECOND: ClockTime = 1_000;
pub const NSECOND: ClockTime = 1;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts