playa_ffmpeg/codec/decoder/
mod.rs1pub mod decoder;
2pub use self::decoder::Decoder;
3
4pub mod video;
5pub use self::video::Video;
6
7pub mod audio;
8pub use self::audio::Audio;
9
10pub mod subtitle;
11pub use self::subtitle::Subtitle;
12
13pub mod slice;
14
15pub mod conceal;
16pub use self::conceal::Conceal;
17
18pub mod check;
19pub use self::check::Check;
20
21pub mod opened;
22pub use self::opened::Opened;
23
24use std::ffi::CString;
25
26use crate::{
27 Codec,
28 codec::{Context, Id},
29 ffi::*,
30};
31
32pub fn new() -> Decoder {
33 Context::new().decoder()
34}
35
36pub fn find(id: Id) -> Option<Codec> {
37 unsafe {
38 #[allow(clippy::unnecessary_cast)]
40 let ptr = avcodec_find_decoder(id.into()) as *mut AVCodec;
41
42 if ptr.is_null() { None } else { Some(Codec::wrap(ptr)) }
43 }
44}
45
46pub fn find_by_name(name: &str) -> Option<Codec> {
47 unsafe {
48 let name = CString::new(name).unwrap();
49 #[allow(clippy::unnecessary_cast)]
50 let ptr = avcodec_find_decoder_by_name(name.as_ptr()) as *mut AVCodec;
51
52 if ptr.is_null() { None } else { Some(Codec::wrap(ptr)) }
53 }
54}