format/context/input: add seek() method

This commit is contained in:
lummax
2015-10-14 16:22:28 +02:00
committed by meh
parent ef3f821c6f
commit a736c8b438
3 changed files with 49 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use ffi::*;
use ::{Error, Codec, Stream, Packet, format};
use super::common::Context;
use super::destructor;
use util::range::Range;
pub struct Input {
ptr: *mut AVFormatContext,
@ -115,6 +116,18 @@ impl Input {
}
}
}
pub fn seek<R: Range<i64>>(&mut self, ts: i64, range: R) -> Result<(), Error> {
unsafe {
match avformat_seek_file(self.as_mut_ptr(), -1,
range.start().map(|v| *v).unwrap_or(i64::min_value()), ts,
range.end().map(|v| *v).unwrap_or(i64::max_value()), 0)
{
s if s >= 0 => Ok(()),
e => Err(Error::from(e)),
}
}
}
}
impl Deref for Input {