diff --git a/src/media/libav_deps.h b/src/media/libav_deps.h index 0e5eb3253c211b3b25843dbfae07073def6d4112..0f16c788873743bd35a50f5e73352bbf51b8a788 100644 --- a/src/media/libav_deps.h +++ b/src/media/libav_deps.h @@ -39,6 +39,11 @@ extern "C" { #include <libavutil/intreadwrite.h> #include <libavutil/log.h> #include <libavutil/samplefmt.h> + +#if LIBAVUTIL_VERSION_MAJOR < 56 +AVFrameSideData* +av_frame_new_side_data_from_buf(AVFrame* frame, enum AVFrameSideDataType type, AVBufferRef* buf); +#endif } #include "libav_utils.h" diff --git a/src/media/libav_utils.cpp b/src/media/libav_utils.cpp index 50f6fbea760c5f03a796140ffd48ad9836adcb5f..aade9712002f95256014a1eee0222072e60fc707 100644 --- a/src/media/libav_utils.cpp +++ b/src/media/libav_utils.cpp @@ -23,7 +23,9 @@ #include "libav_deps.h" // MUST BE INCLUDED FIRST +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "video/video_base.h" #include "logger.h" @@ -36,6 +38,20 @@ #include <exception> #include <ciso646> // fix windows compiler bug +extern "C" { +#if LIBAVUTIL_VERSION_MAJOR < 56 +AVFrameSideData* +av_frame_new_side_data_from_buf(AVFrame* frame, enum AVFrameSideDataType type, AVBufferRef* buf) +{ + auto side_data = av_frame_new_side_data(frame, type, 0); + av_buffer_unref(&side_data->buf); + side_data->buf = buf; + side_data->data = side_data->buf->data; + side_data->size = side_data->buf->size; +} +#endif +} + namespace ring { namespace libav_utils { #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)