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