X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg_raii.cpp;h=746e03d19122da0cd11ad70735670b9b9d318af5;hb=ffd68fbfb90242069af957f2a28908f0559f8348;hp=a11075f81d0d8b84e6c17380e15c82683e476d41;hpb=cfcfe8010a40cae1050005637ea1780226cac9cf;p=nageru diff --git a/ffmpeg_raii.cpp b/ffmpeg_raii.cpp index a11075f..746e03d 100644 --- a/ffmpeg_raii.cpp +++ b/ffmpeg_raii.cpp @@ -18,16 +18,25 @@ void avformat_close_input_unique::operator() (AVFormatContext *format_ctx) const } AVFormatContextWithCloser avformat_open_input_unique( - const char *pathname, AVInputFormat *fmt, AVDictionary **options) + const char *pathname, AVInputFormat *fmt, + AVDictionary **options) { - AVFormatContext *format_ctx = nullptr; + return avformat_open_input_unique(pathname, fmt, options, AVIOInterruptCB{ nullptr, nullptr }); +} + +AVFormatContextWithCloser avformat_open_input_unique( + const char *pathname, AVInputFormat *fmt, + AVDictionary **options, + const AVIOInterruptCB &interrupt_cb) +{ + AVFormatContext *format_ctx = avformat_alloc_context(); + format_ctx->interrupt_callback = interrupt_cb; if (avformat_open_input(&format_ctx, pathname, fmt, options) != 0) { format_ctx = nullptr; } return AVFormatContextWithCloser(format_ctx); } - // AVCodecContext void avcodec_free_context_unique::operator() (AVCodecContext *codec_ctx) const