]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_av] Add support for FFmpeg 6.1 2841/head
authorJakub Karolczyk <jakub.karolczyk@signalwire.com>
Wed, 8 May 2024 11:27:08 +0000 (12:27 +0100)
committerJakub Karolczyk <jakub.karolczyk@signalwire.com>
Fri, 11 Jul 2025 09:08:01 +0000 (10:08 +0100)
src/mod/applications/mod_av/avcodec.c
src/mod/applications/mod_av/avformat.c
src/mod/applications/mod_av/mod_av.h

index 0293b834467b05bb1effa58d2640223c026fe2c7..97bf55b9559b2ea9a9a464b7407f3aa0459ad838 100644 (file)
@@ -1557,7 +1557,11 @@ static switch_status_t switch_h264_encode(switch_codec_t *codec, switch_frame_t
                }
 
                 avframe->pict_type = AV_PICTURE_TYPE_I;
+#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_6_V && LIBAVCODEC_VERSION_MINOR >= LIBAVCODEC_61_V)
+                avframe->flags |= AV_FRAME_FLAG_KEY;
+#else
                 avframe->key_frame = 1;
+#endif
                 context->last_keyframe_request = switch_time_now();
        }
 
@@ -1600,9 +1604,14 @@ GCC_DIAG_ON(deprecated-declarations)
                }
 #endif
 
+#if (LIBAVCODEC_VERSION_MAJOR >= LIBAVCODEC_6_V && LIBAVCODEC_VERSION_MINOR >= LIBAVCODEC_61_V)
+       if (context->need_key_frame && (avframe->flags & AV_FRAME_FLAG_KEY)) {
+               avframe->flags &= ~AV_FRAME_FLAG_KEY;
+#else
        if (context->need_key_frame && avframe->key_frame == 1) {
-               avframe->pict_type = 0;
                avframe->key_frame = 0;
+#endif
+               avframe->pict_type = 0;
                context->need_key_frame = 0;
        }
 
index b5b844ef8aa24a2ec6747cf2cc0f5b59c5790e9b..ac90e87fc5f8199bd8bfc345c81cff3c852d29f3 100644 (file)
@@ -623,8 +623,13 @@ static switch_status_t add_stream(av_file_context_t *context, MediaStream *mst,
                c->rc_initial_buffer_occupancy = buffer_bytes * 8;
 
                if (codec_id == AV_CODEC_ID_H264) {
+#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_6_V && LIBAVFORMAT_VERSION_MINOR >= LIBAVFORMAT_61_V)
+GCC_DIAG_OFF(deprecated-declarations)
+#endif
                        c->ticks_per_frame = 2;
-
+#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_6_V && LIBAVFORMAT_VERSION_MINOR >= LIBAVFORMAT_61_V)
+GCC_DIAG_ON(deprecated-declarations)
+#endif
 
                        c->flags|=AV_CODEC_FLAG_LOOP_FILTER;   // flags=+loop
                        c->me_cmp|= 1;  // cmp=+chroma, where CHROMA = 1
@@ -3212,6 +3217,9 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
 
        if ((c = av_get_codec_context(mst)) && c->time_base.num) {
                cp = av_stream_get_parser(st);
+#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_6_V && LIBAVFORMAT_VERSION_MINOR >= LIBAVFORMAT_61_V)
+GCC_DIAG_OFF(deprecated-declarations)
+#endif
                ticks = cp ? cp->repeat_pict + 1 : c->ticks_per_frame;
                // mst->next_pts += ((int64_t)AV_TIME_BASE * st->codec->time_base.num * ticks) / st->codec->time_base.den;
        }
@@ -3221,6 +3229,9 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
                        context->video_start_time, ticks, c ? c->ticks_per_frame : -1, st->time_base.num, st->time_base.den, c ? c->time_base.num : -1, c ? c->time_base.den : -1,
                        st->start_time, st->duration == AV_NOPTS_VALUE ? context->fc->duration / AV_TIME_BASE * 1000 : st->duration, st->nb_frames, av_q2d(st->time_base));
        }
+#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_6_V && LIBAVFORMAT_VERSION_MINOR >= LIBAVFORMAT_61_V)
+GCC_DIAG_ON(deprecated-declarations)
+#endif
 
  again:
 
index 074a2224825af8f6f5efb432e60f68b9c60f7b89..f73e3eee09a9cc6756d2d21a57218ce858843e5d 100644 (file)
 #ifndef MOD_AV_H
 #define MOD_AV_H
 
-#define LIBAVCODEC_V 59
-#define LIBAVFORMAT_V 59
-#define LIBAVFORMAT_6_V 60
-#define LIBAVUTIL_V 57
+#define LIBAVCODEC_V 59 /* FFmpeg version >= 5.1 */
+#define LIBAVCODEC_6_V 60 /* FFmpeg version >= 6.0 */
+#define LIBAVCODEC_61_V 31 /* FFmpeg version >= 6.1 */
+#define LIBAVFORMAT_V 59 /* FFmpeg version >= 5.1 */
+#define LIBAVFORMAT_6_V 60 /* FFmpeg version >= 6.0 */
+#define LIBAVFORMAT_61_V 16 /* FFmpeg version >= 6.1 */
+#define LIBAVUTIL_V 57 /* FFmpeg version >= 5.1 */
 
 struct mod_av_globals {
        int debug;