1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
use std::ffi::CStr; use std::str::from_utf8_unchecked; use ffi::*; pub struct Input { ptr: *mut AVInputFormat, } impl Input { pub unsafe fn wrap(ptr: *mut AVInputFormat) -> Self { Input { ptr } } pub unsafe fn as_ptr(&self) -> *const AVInputFormat { self.ptr as *const _ } pub unsafe fn as_mut_ptr(&mut self) -> *mut AVInputFormat { self.ptr } } impl Input { pub fn name(&self) -> &str { unsafe { from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).name).to_bytes()) } } pub fn description(&self) -> &str { unsafe { from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).long_name).to_bytes()) } } pub fn extensions(&self) -> Vec<&str> { unsafe { let ptr = (*self.as_ptr()).extensions; if ptr.is_null() { Vec::new() } else { from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()) .split(',') .collect() } } } pub fn mime_types(&self) -> Vec<&str> { unsafe { let ptr = (*self.as_ptr()).mime_type; if ptr.is_null() { Vec::new() } else { from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()) .split(',') .collect() } } } }