codec: add profiles getter
This commit is contained in:
parent
e8db20c86b
commit
a373d9bf3f
@ -3,7 +3,7 @@ use std::ffi::CStr;
|
|||||||
use std::str::from_utf8_unchecked;
|
use std::str::from_utf8_unchecked;
|
||||||
|
|
||||||
use ffi::*;
|
use ffi::*;
|
||||||
use super::{Id, Context, Video, Audio, Capabilities};
|
use super::{Id, Context, Video, Audio, Capabilities, Profile};
|
||||||
use ::{Error, media};
|
use ::{Error, media};
|
||||||
use ::codec::context::Opened;
|
use ::codec::context::Opened;
|
||||||
|
|
||||||
@ -101,4 +101,46 @@ impl<'a> Codec<'a> {
|
|||||||
Capabilities::from_bits_truncate((*self.as_ptr()).capabilities as u32)
|
Capabilities::from_bits_truncate((*self.as_ptr()).capabilities as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn profiles(&self) -> Option<ProfileIter> {
|
||||||
|
unsafe {
|
||||||
|
if (*self.as_ptr()).profiles.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Some(ProfileIter::new(self.id(), (*self.as_ptr()).profiles))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ProfileIter<'a> {
|
||||||
|
id: Id,
|
||||||
|
ptr: *const AVProfile,
|
||||||
|
|
||||||
|
_marker: PhantomData<&'a ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ProfileIter<'a> {
|
||||||
|
pub fn new(id: Id, ptr: *const AVProfile) -> Self {
|
||||||
|
ProfileIter { id: id, ptr: ptr, _marker: PhantomData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Iterator for ProfileIter<'a> {
|
||||||
|
type Item = Profile;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
|
||||||
|
unsafe {
|
||||||
|
if (*self.ptr).profile != FF_PROFILE_UNKNOWN && !(*self.ptr).name.is_null() {
|
||||||
|
let profile = Profile::from((self.id, (*self.ptr).profile));
|
||||||
|
self.ptr = self.ptr.offset(1);
|
||||||
|
|
||||||
|
Some(profile)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user