decoder/ffmpeg: FfmpegOpenInput() returns Error

This commit is contained in:
Max Kellermann 2016-07-29 19:25:02 +02:00
parent 245f41bb7e
commit 7456dccd3a

View File

@ -58,11 +58,14 @@ extern "C" {
static AVFormatContext *
FfmpegOpenInput(AVIOContext *pb,
const char *filename,
AVInputFormat *fmt)
AVInputFormat *fmt,
Error &error)
{
AVFormatContext *context = avformat_alloc_context();
if (context == nullptr)
if (context == nullptr) {
error.Set(ffmpeg_domain, "Out of memory");
return nullptr;
}
context->pb = pb;
@ -666,10 +669,11 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
return;
}
Error error;
AVFormatContext *format_context =
FfmpegOpenInput(stream.io, input.GetURI(), input_format);
FfmpegOpenInput(stream.io, input.GetURI(), input_format, error);
if (format_context == nullptr) {
LogError(ffmpeg_domain, "Open failed");
LogError(error);
return;
}
@ -718,7 +722,8 @@ ffmpeg_scan_stream(InputStream &is,
return false;
AVFormatContext *f =
FfmpegOpenInput(stream.io, is.GetURI(), input_format);
FfmpegOpenInput(stream.io, is.GetURI(), input_format,
IgnoreError());
if (f == nullptr)
return false;