return AVFormatContextWithCloser(format_ctx);
}
+AVFormatContextWithCloser avformat_open_input_unique(
+ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
+ void *opaque, AVInputFormat *fmt, AVDictionary **options,
+ const AVIOInterruptCB &interrupt_cb)
+{
+ AVFormatContext *format_ctx = avformat_alloc_context();
+ format_ctx->interrupt_callback = interrupt_cb;
+ constexpr size_t buf_size = 4096;
+ 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);
+ if (avformat_open_input(&format_ctx, "", fmt, options) != 0) {
+ format_ctx = nullptr;
+ }
+ return AVFormatContextWithCloser(format_ctx);
+}
+
// AVCodecContext
void avcodec_free_context_unique::operator() (AVCodecContext *codec_ctx) const