-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
95 lines (83 loc) · 2.37 KB
/
lib.rs
File metadata and controls
95 lines (83 loc) · 2.37 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#![doc(html_root_url = "https://panicbit.github.io/rust-av/")]
// `error_chain!` can recurse deeply
#![recursion_limit = "1024"]
pub extern crate av_sys as ffi;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate error_chain;
extern crate smallvec;
use std::ffi::CStr;
use std::sync::{Once, ONCE_INIT};
use util::AsCStr;
#[macro_use]
mod util;
pub mod common;
pub mod format;
pub mod video;
pub mod audio;
pub mod generic;
pub mod io;
pub mod codec;
pub mod errors;
pub use self::errors::*;
lazy_static! {
pub static ref AV: LibAV = LibAV::init();
}
pub struct LibAV(());
impl LibAV {
pub fn init() -> LibAV {
unsafe {
static INIT: Once = ONCE_INIT;
INIT.call_once(|| {
// Init avformat
ffi::av_register_all();
});
LibAV(())
}
}
pub fn set_log_level(&self, level: LogLevel) {
unsafe {
ffi::av_log_set_level(level as i32);
}
}
pub fn version(&self) -> &'static CStr {
unsafe {
ffi::av_version_info().as_cstr().unwrap()
}
}
pub fn build_flags(&self) -> &'static CStr {
unsafe {
ffi::avformat_configuration().as_cstr().unwrap()
}
}
}
#[repr(i32)]
pub enum LogLevel {
/// Print no output.
Quiet = ffi::AV_LOG_QUIET as i32,
/// Something went really wrong and we will crash now.
Panic = ffi::AV_LOG_PANIC as i32,
/// Something went wrong and recovery is not possible.
/// For example, no header was found for a format which
/// depends on headers or an illegal combination of parameters
/// is used.
Fatal = ffi::AV_LOG_FATAL as i32,
/// Something went wrong and cannot losslessly be recovered.
/// However, not all future data is affected.
Error = ffi::AV_LOG_ERROR as i32,
/// Something somehow does not look correct.
/// This may or may not lead to problems.
/// An example would be the use of '-vstrict -2'.
Warning = ffi::AV_LOG_WARNING as i32,
/// Standard information.
Info = ffi::AV_LOG_INFO as i32,
/// Detailed information.
Verbose = ffi::AV_LOG_VERBOSE as i32,
/// Stuff which is only useful for libav* developers.
Debug = ffi::AV_LOG_DEBUG as i32,
/// Extremely verbose debugging, useful for libav* development.
Trace = ffi::AV_LOG_TRACE as i32,
}