| 1 | pub mod extensions; |
| 2 | pub mod input; |
| 3 | pub mod output; |
| 4 | |
| 5 | use std::ffi::CStr; |
| 6 | use std::marker::PhantomData; |
| 7 | use std::str::from_utf8_unchecked; |
| 8 | |
| 9 | use ffi::*; |
| 10 | |
| 11 | pub struct Info<'a> { |
| 12 | ptr: *mut AVDeviceInfo, |
| 13 | |
| 14 | _marker: PhantomData<&'a ()>, |
| 15 | } |
| 16 | |
| 17 | impl<'a> Info<'a> { |
| 18 | pub unsafe fn wrap(ptr: *mut AVDeviceInfo) -> Self { |
| 19 | Info { |
| 20 | ptr, |
| 21 | _marker: PhantomData, |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | pub unsafe fn as_ptr(&self) -> *const AVDeviceInfo { |
| 26 | self.ptr as *const _ |
| 27 | } |
| 28 | |
| 29 | pub unsafe fn as_mut_ptr(&mut self) -> *mut AVDeviceInfo { |
| 30 | self.ptr |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | impl<'a> Info<'a> { |
| 35 | pub fn name(&self) -> &str { |
| 36 | unsafe { from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).device_name).to_bytes()) } |
| 37 | } |
| 38 | |
| 39 | pub fn description(&self) -> &str { |
| 40 | unsafe { |
| 41 | from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).device_description).to_bytes()) |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | pub fn register_all() { |
| 47 | unsafe { |
| 48 | avdevice_register_all(); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | pub fn version() -> u32 { |
| 53 | unsafe { avdevice_version() } |
| 54 | } |
| 55 | |
| 56 | pub fn configuration() -> &'static str { |
| 57 | unsafe { from_utf8_unchecked(CStr::from_ptr(avdevice_configuration()).to_bytes()) } |
| 58 | } |
| 59 | |
| 60 | pub fn license() -> &'static str { |
| 61 | unsafe { from_utf8_unchecked(CStr::from_ptr(avdevice_license()).to_bytes()) } |
| 62 | } |
| 63 | |