playa_ffmpeg/device/
mod.rs

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