summaryrefslogtreecommitdiffstats
path: root/net/freeswitch/patches/066-04-mod_av-Add-support-for-FFmpeg-7.1.patch
blob: 9b84fb2a6e522c90947b28fb4d2a9cb2fdc0300e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 066b92c5894b07a4879a26a9f6a1cdcf59e016ea Mon Sep 17 00:00:00 2001
From: Andrey Volk <andywolk@gmail.com>
Date: Fri, 11 Jul 2025 13:39:48 +0300
Subject: [PATCH 4/4] [mod_av] Add support for FFmpeg 7.1

---
 src/mod/applications/mod_av/avformat.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- a/src/mod/applications/mod_av/avformat.c
+++ b/src/mod/applications/mod_av/avformat.c
@@ -557,7 +557,21 @@ static switch_status_t add_stream(av_fil
 
 	switch ((*codec)->type) {
 	case AVMEDIA_TYPE_AUDIO:
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100)
+		/*
+		   Changelog says 61.12.100 but commit changes version actually to 61.13.100
+		   https://github.com/FFmpeg/FFmpeg/commit/3305767560a6303f474fffa3afb10c500059b455
+		 */
+		{
+			const enum AVSampleFormat *sample_fmts = NULL;
+			int fmts_count = 0;
+			int ret = avcodec_get_supported_config(c, *codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void**)&sample_fmts, &fmts_count);
+
+			c->sample_fmt = (ret >= 0 && fmts_count && sample_fmts) ? sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
+		}
+#else
 		c->sample_fmt  = (*codec)->sample_fmts ? (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
+#endif
 		c->bit_rate    = 128000;
 		c->sample_rate = mst->sample_rate = context->handle->samplerate;
 #if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_V)