-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use crate::ffi; | ||
use rusty_ffmpeg::ffi::AV_ERROR_MAX_STRING_SIZE; | ||
use std::ffi::{c_int, CStr}; | ||
|
||
/// Return a description of the AVERROR code errnum. | ||
/// | ||
/// Return `Some(description)` on success, a negative value if a description for | ||
/// errnum cannot be found. | ||
pub fn err2str(errnum: c_int) -> Option<String> { | ||
const ERRBUF_SIZE: usize = AV_ERROR_MAX_STRING_SIZE as usize; | ||
let mut errbuf = [0u8; ERRBUF_SIZE]; | ||
if unsafe { ffi::av_strerror(errnum, errbuf.as_mut_ptr() as _, ERRBUF_SIZE) } == 0 { | ||
let result = CStr::from_bytes_until_nul(&errbuf).unwrap(); | ||
Some(result.to_string_lossy().into_owned()) | ||
} else { | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters