decoder/ffmpeg: simplify mpd_ffmpeg_open_input()
This commit is contained in:
parent
543296b5ba
commit
62f7375804
@ -54,23 +54,19 @@ extern "C" {
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/**
|
static AVFormatContext *
|
||||||
* API compatibility wrapper for av_open_input_stream() and
|
FfmpegOpenInput(AVIOContext *pb,
|
||||||
* avformat_open_input().
|
const char *filename,
|
||||||
*/
|
AVInputFormat *fmt)
|
||||||
static int
|
|
||||||
mpd_ffmpeg_open_input(AVFormatContext **ic_ptr,
|
|
||||||
AVIOContext *pb,
|
|
||||||
const char *filename,
|
|
||||||
AVInputFormat *fmt)
|
|
||||||
{
|
{
|
||||||
AVFormatContext *context = avformat_alloc_context();
|
AVFormatContext *context = avformat_alloc_context();
|
||||||
if (context == nullptr)
|
if (context == nullptr)
|
||||||
return AVERROR(ENOMEM);
|
return nullptr;
|
||||||
|
|
||||||
context->pb = pb;
|
context->pb = pb;
|
||||||
*ic_ptr = context;
|
|
||||||
return avformat_open_input(ic_ptr, filename, fmt, nullptr);
|
avformat_open_input(&context, filename, fmt, nullptr);
|
||||||
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -384,10 +380,9 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVFormatContext *format_context = nullptr;
|
AVFormatContext *format_context =
|
||||||
if (mpd_ffmpeg_open_input(&format_context, stream.io,
|
FfmpegOpenInput(stream.io, input.GetURI(), input_format);
|
||||||
input.GetURI(),
|
if (format_context == nullptr) {
|
||||||
input_format) != 0) {
|
|
||||||
LogError(ffmpeg_domain, "Open failed");
|
LogError(ffmpeg_domain, "Open failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -553,9 +548,9 @@ ffmpeg_scan_stream(InputStream &is,
|
|||||||
if (!stream.Open())
|
if (!stream.Open())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AVFormatContext *f = nullptr;
|
AVFormatContext *f =
|
||||||
if (mpd_ffmpeg_open_input(&f, stream.io, is.GetURI(),
|
FfmpegOpenInput(stream.io, is.GetURI(), input_format);
|
||||||
input_format) != 0)
|
if (f == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const int find_result =
|
const int find_result =
|
||||||
|
Loading…
Reference in New Issue
Block a user