1pub mod extensions;
2pub mod input;
3pub mod output;
4
5use std::ffi::CStr;
6use std::marker::PhantomData;
7use std::str::from_utf8_unchecked;
8
9use ffi::*;
10
11pub struct Info<'a> {
12 ptr: *mut AVDeviceInfo,
13
14 _marker: PhantomData<&'a ()>,
15}
16
17impl<'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
34impl<'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
46pub fn register_all() {
47 unsafe {
48 avdevice_register_all();
49 }
50}
51
52pub fn version() -> u32 {
53 unsafe { avdevice_version() }
54}
55
56pub fn configuration() -> &'static str {
57 unsafe { from_utf8_unchecked(CStr::from_ptr(avdevice_configuration()).to_bytes()) }
58}
59
60pub fn license() -> &'static str {
61 unsafe { from_utf8_unchecked(CStr::from_ptr(avdevice_license()).to_bytes()) }
62}
63