util/time: add time helpers
This commit is contained in:
parent
df52ef68d8
commit
883654ebda
@ -13,6 +13,7 @@ pub use util::media;
|
||||
pub use util::picture;
|
||||
pub use util::color;
|
||||
pub use util::chroma;
|
||||
pub use util::time;
|
||||
pub use util::frame::{self, Frame};
|
||||
|
||||
#[cfg(feature = "format")]
|
||||
|
@ -7,6 +7,7 @@ pub mod color;
|
||||
pub mod format;
|
||||
pub mod frame;
|
||||
pub mod chroma;
|
||||
pub mod time;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::str::from_utf8_unchecked;
|
||||
|
29
src/util/time.rs
Normal file
29
src/util/time.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use ffi::*;
|
||||
use ::Error;
|
||||
|
||||
pub fn current() -> i64 {
|
||||
unsafe {
|
||||
av_gettime() as i64
|
||||
}
|
||||
}
|
||||
|
||||
pub fn relative() -> i64 {
|
||||
unsafe {
|
||||
av_gettime_relative() as i64
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_monotonic() -> bool {
|
||||
unsafe {
|
||||
av_gettime_relative_is_monotonic() != 0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sleep(usec: u32) -> Result<(), Error> {
|
||||
unsafe {
|
||||
match av_usleep(usec) {
|
||||
0 => Ok(()),
|
||||
e => Err(Error::from(e))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user