mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
Fix empty names
This commit is contained in:
+9
-1
@@ -39,7 +39,15 @@ impl Codec {
|
||||
}
|
||||
|
||||
pub fn description(&self) -> &str {
|
||||
unsafe { from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).long_name).to_bytes()) }
|
||||
unsafe {
|
||||
let long_name = (*self.as_ptr()).long_name;
|
||||
if long_name.is_null() {
|
||||
""
|
||||
}
|
||||
else {
|
||||
from_utf8_unchecked(CStr::from_ptr(long_name).to_bytes())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn medium(&self) -> media::Type {
|
||||
|
||||
@@ -2,7 +2,6 @@ use std::{
|
||||
ffi::CString,
|
||||
mem,
|
||||
ops::{Deref, DerefMut},
|
||||
ptr,
|
||||
};
|
||||
|
||||
use super::{common::Context, destructor};
|
||||
@@ -199,7 +198,7 @@ pub fn dump(ctx: &Input, index: i32, url: Option<&str>) {
|
||||
av_dump_format(
|
||||
ctx.as_ptr() as *mut _,
|
||||
index,
|
||||
url.map(|u| u.as_ptr()).unwrap_or(ptr::null()),
|
||||
url.unwrap_or_else(|| CString::new("").unwrap()).as_ptr(),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ pub fn dump(ctx: &Output, index: i32, url: Option<&str>) {
|
||||
av_dump_format(
|
||||
ctx.as_ptr() as *mut _,
|
||||
index,
|
||||
url.map(|u| u.as_ptr()).unwrap_or(ptr::null()),
|
||||
url.unwrap_or_else(|| CString::new("").unwrap()).as_ptr(),
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user