Allow null codec
This commit is contained in:
parent
f73dca70b4
commit
f0903fb69b
@ -72,8 +72,9 @@ impl Output {
|
|||||||
|
|
||||||
pub fn add_stream<E: traits::Encoder>(&mut self, codec: E) -> Result<StreamMut, Error> {
|
pub fn add_stream<E: traits::Encoder>(&mut self, codec: E) -> Result<StreamMut, Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let codec = codec.encoder().ok_or(Error::EncoderNotFound)?;
|
let codec = codec.encoder();
|
||||||
let ptr = avformat_new_stream(self.as_mut_ptr(), codec.as_ptr());
|
let codec = codec.map_or(ptr::null(), |c| c.as_ptr());
|
||||||
|
let ptr = avformat_new_stream(self.as_mut_ptr(), codec);
|
||||||
|
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
panic!("out of memory");
|
panic!("out of memory");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user