Bug#1081652: fix compilation of baresip against ffmpeg 7
Nicola Ferralis
feranick at hotmail.com
Fri Sep 13 15:52:54 BST 2024
package: baresip
Version: 1.1.0-1
The source code of baresip is incompatible with the current version of FFmpeg 7, leading to a crash when trying to compile against it.
The attached patch (from upstream) fixes the issues, allowing successful compilation.
I am using Ubuntu 24.04 and Debian Unstable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-voip-maintainers/attachments/20240913/54ba16b8/attachment.htm>
-------------- next part --------------
diff -Nru baresip-1.1.0.orig/modules/avcodec/decode.c baresip-1.1.0/modules/avcodec/decode.c
--- baresip-1.1.0.orig/modules/avcodec/decode.c 2024-09-12 17:59:08.067564052 -0400
+++ baresip-1.1.0/modules/avcodec/decode.c 2024-09-13 10:38:11.763692796 -0400
@@ -267,8 +267,8 @@
if (got_picture) {
-#if LIBAVUTIL_VERSION_MAJOR >= 56
if (hw_frame) {
+ av_frame_unref(st->pict); /* cleanup old frame */
/* retrieve data from GPU to CPU */
ret = av_hwframe_transfer_data(st->pict, hw_frame, 0);
if (ret < 0) {
@@ -276,11 +276,14 @@
" the data to system memory\n");
goto out;
}
-
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 29, 100)
+ st->pict->flags = hw_frame->flags;
+#else
st->pict->key_frame = hw_frame->key_frame;
- }
#endif
+ }
+
frame->fmt = avpixfmt_to_vidfmt(st->pict->format);
if (frame->fmt == (enum vidfmt)-1) {
warning("avcodec: decode: bad pixel format"
@@ -297,7 +300,11 @@
frame->size.w = st->ctx->width;
frame->size.h = st->ctx->height;
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 29, 100)
+ if (st->pict->flags & AV_FRAME_FLAG_KEY) {
+#else
if (st->pict->key_frame) {
+#endif
*intra = true;
st->got_keyframe = true;
diff -Nru baresip-1.1.0.orig/modules/avcodec/encode.c baresip-1.1.0/modules/avcodec/encode.c
--- baresip-1.1.0.orig/modules/avcodec/encode.c 2024-09-12 17:59:08.067564052 -0400
+++ baresip-1.1.0/modules/avcodec/encode.c 2024-09-13 10:41:16.252176798 -0400
@@ -544,7 +544,11 @@
if (update) {
debug("avcodec: encoder picture update\n");
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 29, 100)
+ pict->flags |= AV_FRAME_FLAG_KEY;
+#else
pict->key_frame = 1;
+#endif
pict->pict_type = AV_PICTURE_TYPE_I;
}
diff -Nru baresip-1.1.0.orig/modules/avformat/audio.c baresip-1.1.0/modules/avformat/audio.c
--- baresip-1.1.0.orig/modules/avformat/audio.c 2024-09-12 17:59:08.067564052 -0400
+++ baresip-1.1.0/modules/avformat/audio.c 2024-09-13 10:45:45.022881711 -0400
@@ -100,8 +100,14 @@
avformat_shared_set_audio(st->shared, st);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 37, 100)
+ int channels = sh->au.ctx->ch_layout.nb_channels;
+#else
+ int channels = sh->au.ctx->channels;
+#endif
+
info("avformat: audio: converting %u/%u %s -> %u/%u %s\n",
- sh->au.ctx->sample_rate, sh->au.ctx->channels,
+ sh->au.ctx->sample_rate, channels,
av_get_sample_fmt_name(sh->au.ctx->sample_fmt),
prm->srate, prm->ch, aufmt_name(prm->fmt));
@@ -154,13 +160,19 @@
const AVRational tb = st->au.time_base;
struct auframe af;
+ int channels = st->ausrc_st->prm.ch;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 37, 100)
+ av_channel_layout_default(&frame2.ch_layout, channels);
+#else
frame.channel_layout =
av_get_default_channel_layout(frame.channels);
- frame2.channels = st->ausrc_st->prm.ch;
+ frame2.channels = channels;
frame2.channel_layout =
av_get_default_channel_layout(st->ausrc_st->prm.ch);
+#endif
+
frame2.sample_rate = st->ausrc_st->prm.srate;
frame2.format =
aufmt_to_avsampleformat(st->ausrc_st->prm.fmt);
@@ -173,7 +185,7 @@
}
auframe_init(&af, st->ausrc_st->prm.fmt, frame2.data[0],
- frame2.nb_samples * frame2.channels);
+ frame2.nb_samples * channels);
af.timestamp = frame.pts * AUDIO_TIMEBASE * tb.num / tb.den;
st->ausrc_st->readh(&af, st->ausrc_st->arg);
diff -Nru baresip-1.1.0.orig/modules/avformat/avformat.c baresip-1.1.0/modules/avformat/avformat.c
--- baresip-1.1.0.orig/modules/avformat/avformat.c 2024-09-12 17:59:08.067564052 -0400
+++ baresip-1.1.0/modules/avformat/avformat.c 2024-09-13 10:46:07.842941552 -0400
@@ -44,7 +44,7 @@
static enum AVHWDeviceType avformat_hwdevice = AV_HWDEVICE_TYPE_NONE;
#endif
static char avformat_inputformat[64];
-static AVCodec *avformat_decoder;
+static const AVCodec *avformat_decoder;
static void shared_destructor(void *arg)
{
@@ -56,12 +56,10 @@
}
if (st->au.ctx) {
- avcodec_close(st->au.ctx);
avcodec_free_context(&st->au.ctx);
}
if (st->vid.ctx) {
- avcodec_close(st->vid.ctx);
avcodec_free_context(&st->vid.ctx);
}
@@ -170,7 +168,7 @@
static int open_codec(struct stream *s, const struct AVStream *strm, int i,
AVCodecContext *ctx)
{
- AVCodec *codec = avformat_decoder;
+ const AVCodec *codec = avformat_decoder;
int ret;
if (s->idx >= 0 || s->ctx)
@@ -226,7 +224,11 @@
struct shared *st;
struct pl pl_fmt, pl_dev;
char *device = NULL;
+#if LIBAVUTIL_VERSION_MAJOR >= 57
+ const AVInputFormat *input_format = NULL;
+#else
AVInputFormat *input_format = NULL;
+#endif
AVDictionary *format_opts = NULL;
char buf[16];
unsigned i;
More information about the Pkg-voip-maintainers
mailing list