summarylogtreecommitdiffstats
path: root/ffmpeg7-fix.patch
blob: f9fe63b930c6b3cf82ee3ef2e198e3a9781192dc (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
diff -Naur freeswitch-1.10.12-pristine/src/mod/applications/mod_av/avcodec.c freeswitch-1.10.12/src/mod/applications/mod_av/avcodec.c
--- freeswitch-1.10.12-pristine/src/mod/applications/mod_av/avcodec.c	2024-11-06 07:00:42.737612688 +0000
+++ freeswitch-1.10.12/src/mod/applications/mod_av/avcodec.c	2024-11-06 07:02:45.809730676 +0000
@@ -1226,9 +1226,13 @@
 	}
 
 	if (context->encoder_ctx) {
+#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_N)
 		if (avcodec_is_open(context->encoder_ctx)) {
 			avcodec_close(context->encoder_ctx);
 		}
+#else
+		avcodec_free_context(&(context->encoder_ctx));
+#endif
 		av_free(context->encoder_ctx);
 		context->encoder_ctx = NULL;
 	}
@@ -1319,9 +1323,13 @@
 		}
 
 		if (context->encoder_ctx) {
+#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_N)
 			if (avcodec_is_open(context->encoder_ctx)) {
 				avcodec_close(context->encoder_ctx);
 			}
+#else
+			avcodec_free_context(&(context->encoder_ctx));
+#endif
 			av_free(context->encoder_ctx);
 			context->encoder_ctx = NULL;
 		}
@@ -1557,7 +1565,11 @@
 		}
 
 		 avframe->pict_type = AV_PICTURE_TYPE_I;
+#if (LIBAVUTIL_VERSION_MAJOR < LIBAVUTIL_N)
 		 avframe->key_frame = 1;
+#else
+		 avframe->flags |= AV_FRAME_FLAG_KEY;
+#endif
 		 context->last_keyframe_request = switch_time_now();
 	}
 
@@ -1600,9 +1612,14 @@
 		}
 #endif
 
+#if (LIBAVUTIL_VERSION_MAJOR < LIBAVUTIL_N)
 	if (context->need_key_frame && avframe->key_frame == 1) {
-		avframe->pict_type = 0;
 		avframe->key_frame = 0;
+#else
+	if (context->need_key_frame && avframe->flags & AV_FRAME_FLAG_KEY) {
+		avframe->flags ^= AV_FRAME_FLAG_KEY;
+#endif
+		avframe->pict_type = 0;
 		context->need_key_frame = 0;
 	}
 
@@ -1862,14 +1879,22 @@
 
 	switch_buffer_destroy(&context->nalu_buffer);
 	if (context->decoder_ctx) {
+#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_N)
 		if (avcodec_is_open(context->decoder_ctx)) avcodec_close(context->decoder_ctx);
+#else
+		avcodec_free_context(&(context->decoder_ctx));
+#endif
 		av_free(context->decoder_ctx);
 	}
 
 	switch_img_free(&context->img);
 
 	if (context->encoder_ctx) {
+#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_N)
 		if (avcodec_is_open(context->encoder_ctx)) avcodec_close(context->encoder_ctx);
+#else
+		avcodec_free_context(&(context->encoder_ctx));
+#endif
 		av_free(context->encoder_ctx);
 	}
 
diff -Naur freeswitch-1.10.12-pristine/src/mod/applications/mod_av/avformat.c freeswitch-1.10.12/src/mod/applications/mod_av/avformat.c
--- freeswitch-1.10.12-pristine/src/mod/applications/mod_av/avformat.c	2024-11-06 07:00:42.737612688 +0000
+++ freeswitch-1.10.12/src/mod/applications/mod_av/avformat.c	2024-11-06 07:07:14.001020789 +0000
@@ -184,6 +184,16 @@
 
 typedef struct av_file_context av_file_context_t;
 
+#if (LIBAVFORMAT_VERSION_MAJOR >= LIBAVFORMAT_N)
+typedef struct FFOutputFormat {
+	int priv_data_size;
+} FFOutputFormat;
+
+static inline int priv_data_size(const AVOutputFormat *fmt)
+{
+    return ((const struct FFOutputFormat*)fmt)->priv_data_size;
+}
+#endif
 
 /**
  * Fill the provided buffer with a string containing a timestamp
@@ -455,8 +465,13 @@
 	}
 
 	s->oformat = oformat;
+#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_N)
 	if (s->oformat->priv_data_size > 0) {
 		s->priv_data = av_mallocz(s->oformat->priv_data_size);
+#else
+	if (priv_data_size(s->oformat) > 0) {
+		s->priv_data = av_mallocz(priv_data_size(s->oformat));
+#endif
 		if (!s->priv_data) {
 			goto nomem;
 		}
@@ -621,7 +636,9 @@
 		c->rc_initial_buffer_occupancy = buffer_bytes * 8;
 
 		if (codec_id == AV_CODEC_ID_H264) {
+#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_N)
 			c->ticks_per_frame = 2;
+#endif
 
 
 			c->flags|=AV_CODEC_FLAG_LOOP_FILTER;   // flags=+loop
@@ -1410,8 +1427,10 @@
 		switch_goto_status(SWITCH_STATUS_FALSE, err);
 	}
 
+#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_N)
 	handle->seekable = context->fc->iformat->read_seek2 ? 1 : (context->fc->iformat->read_seek ? 1 : 0);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "file %s is %sseekable\n", filename, handle->seekable ? "" : "not ");
+#endif
 
 	/** Get information on the input file (number of streams etc.). */
 	if ((error = avformat_find_stream_info(context->fc, opts ? &opts : NULL)) < 0) {
@@ -1502,7 +1521,11 @@
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open input audio codec channel 2 (error '%s')\n", get_error_text(error, ebuf, sizeof(ebuf)));
 		if ((cc = av_get_codec_context(&context->audio_st[0]))) {
+#if (LIBAVCODEC_VERSION_MAJOR < LIBAVCODEC_N)
 			avcodec_close(cc);
+#else
+			avcodec_free_context(&cc);
+#endif
 		}
 
 		context->has_audio = 0;
@@ -3084,14 +3107,11 @@
 	void *pop;
 	MediaStream *mst = &context->video_st;
 	AVStream *st = mst->st;
-	int ticks = 0;
 	int64_t max_delta = 1 * AV_TIME_BASE; // 1 second
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	double fl_to = 0.02;
 	int do_fl = 0;
 	int smaller_ts = context->read_fps;
-	AVCodecContext *c = NULL;
-	AVCodecParserContext *cp = NULL;
 
 	if (!context->has_video) return SWITCH_STATUS_FALSE;
 
@@ -3199,6 +3219,10 @@
 	}
 #endif
 
+#if (LIBAVFORMAT_VERSION_MAJOR < LIBAVFORMAT_N)
+	int ticks = 0;
+	AVCodecContext *c = NULL;
+	AVCodecParserContext *cp = NULL;
 	if ((c = av_get_codec_context(mst)) && c->time_base.num) {
 		cp = av_stream_get_parser(st);
 		ticks = cp ? cp->repeat_pict + 1 : c->ticks_per_frame;
@@ -3210,6 +3234,7 @@
 			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));
 	}
+#endif
 
  again:
 
diff -Naur freeswitch-1.10.12-pristine/src/mod/applications/mod_av/mod_av.h freeswitch-1.10.12/src/mod/applications/mod_av/mod_av.h
--- freeswitch-1.10.12-pristine/src/mod/applications/mod_av/mod_av.h	2024-11-06 07:00:42.737612688 +0000
+++ freeswitch-1.10.12/src/mod/applications/mod_av/mod_av.h	2024-11-06 07:02:45.809730676 +0000
@@ -42,7 +42,10 @@
 
 #define LIBAVCODEC_V 59
 #define LIBAVFORMAT_V 59
+#define LIBAVCODEC_N 60
+#define LIBAVFORMAT_N 60
 #define LIBAVUTIL_V 57
+#define LIBAVUTIL_N 59
 
 struct mod_av_globals {
 	int debug;