X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fffmpeg_raii.cpp;h=0e087c27b063a03ef80e909f22ec1d2c9516fbde;hb=8781ee96803331bbfc6d5e4d8d006a215261baea;hp=a1028f844b9cbe3dc8299a7fdbc3d518590d6309;hpb=4df45e479ddbc8e2247be8aab7f2bab5ddaa1b74;p=nageru diff --git a/shared/ffmpeg_raii.cpp b/shared/ffmpeg_raii.cpp index a1028f8..0e087c2 100644 --- a/shared/ffmpeg_raii.cpp +++ b/shared/ffmpeg_raii.cpp @@ -18,20 +18,24 @@ void avformat_close_input_unique::operator() (AVFormatContext *format_ctx) const } AVFormatContextWithCloser avformat_open_input_unique( - const char *pathname, AVInputFormat *fmt, + const char *pathname, const AVInputFormat *fmt, AVDictionary **options) { return avformat_open_input_unique(pathname, fmt, options, AVIOInterruptCB{ nullptr, nullptr }); } AVFormatContextWithCloser avformat_open_input_unique( - const char *pathname, AVInputFormat *fmt, + const char *pathname, const AVInputFormat *fmt, AVDictionary **options, const AVIOInterruptCB &interrupt_cb) { AVFormatContext *format_ctx = avformat_alloc_context(); format_ctx->interrupt_callback = interrupt_cb; +#ifdef ff_const59 + if (avformat_open_input(&format_ctx, pathname, const_cast(fmt), options) != 0) { +#else if (avformat_open_input(&format_ctx, pathname, fmt, options) != 0) { +#endif format_ctx = nullptr; } return AVFormatContextWithCloser(format_ctx); @@ -39,7 +43,7 @@ AVFormatContextWithCloser avformat_open_input_unique( AVFormatContextWithCloser avformat_open_input_unique( int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), - void *opaque, AVInputFormat *fmt, AVDictionary **options, + void *opaque, const AVInputFormat *fmt, AVDictionary **options, const AVIOInterruptCB &interrupt_cb) { AVFormatContext *format_ctx = avformat_alloc_context(); @@ -48,7 +52,11 @@ AVFormatContextWithCloser avformat_open_input_unique( unsigned char *buf = (unsigned char *)av_malloc(buf_size); format_ctx->pb = avio_alloc_context(buf, buf_size, /*write_flag=*/false, opaque, read_packet, /*write_packet=*/nullptr, /*seek=*/nullptr); +#ifdef ff_const59 + if (avformat_open_input(&format_ctx, "", const_cast(fmt), options) != 0) { +#else if (avformat_open_input(&format_ctx, "", fmt, options) != 0) { +#endif format_ctx = nullptr; } return AVFormatContextWithCloser(format_ctx);