examples/dmabuf-capture: build fails with ffmpeg 5.0
The dmabuf-capture examples is not compatible with ffmpeg 5.0:
FAILED: examples/dmabuf-capture.p/dmabuf-capture.c.o
cc -Iexamples/dmabuf-capture.p -Iexamples -I../examples -Iprotocol -I/usr/include/x86_64-linux-gnu -I/usr/include/libdrm -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -g -DWLR_USE_UNSTABLE -DWLR_LITTLE_ENDIAN=1 -DWLR_BIG_ENDIAN=0 -Wundef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wstrict-prototypes -Wimplicit-fallthrough=2 -Wendif-labels -Wstrict-aliasing=2 -Woverflow -Wmissing-prototypes -Walloca -Wno-missing-braces -Wno-missing-field-initializers -Wno-unused-parameter -fmacro-prefix-map=../= -DHAS_GBM_BO_GET_FD_FOR_PLANE=1 -DLIBINPUT_HAS_HOLD_GESTURES=1 '-DICONDIR="/usr/local/share/icons"' -DHAS_XCB_ERRORS=0 -pthread -MD -MQ examples/dmabuf-capture.p/dmabuf-capture.c.o -MF examples/dmabuf-capture.p/dmabuf-capture.c.o.d -o examples/dmabuf-capture.p/dmabuf-capture.c.o -c ../examples/dmabuf-capture.c
../examples/dmabuf-capture.c:60:9: error: unknown type name 'AVCodecContext'
60 | AVCodecContext *avctx;
| ^~~~~~~~~~~~~~
../examples/dmabuf-capture.c: In function 'frame_ready':
../examples/dmabuf-capture.c:389:35: error: request for member 'time_base' in something not a structure or union
389 | ctx->avctx->time_base);
| ^~
../examples/dmabuf-capture.c: In function 'vid_encode_thread':
../examples/dmabuf-capture.c:483:23: error: implicit declaration of function 'avcodec_send_frame'; did you mean 'avcodec_get_name'? [-Werror=implicit-function-declaration]
483 | err = avcodec_send_frame(ctx->avctx, f);
| ^~~~~~~~~~~~~~~~~~
| avcodec_get_name
../examples/dmabuf-capture.c:494:35: error: implicit declaration of function 'avcodec_receive_packet' [-Werror=implicit-function-declaration]
494 | int ret = avcodec_receive_packet(ctx->avctx, pkt);
| ^~~~~~~~~~~~~~~~~~~~~~
../examples/dmabuf-capture.c:523:43: error: request for member 'frame_number' in something not a structure or union
523 | ctx->avctx->frame_number, get_fifo_size(&ctx->vid_frames));
| ^~
../examples/dmabuf-capture.c: In function 'set_hwframe_ctx':
../examples/dmabuf-capture.c:579:43: error: request for member 'pix_fmt' in something not a structure or union
579 | frames_ctx->sw_format = ctx->avctx->pix_fmt;
| ^~
../examples/dmabuf-capture.c:580:39: error: request for member 'width' in something not a structure or union
580 | frames_ctx->width = ctx->avctx->width;
| ^~
../examples/dmabuf-capture.c:581:40: error: request for member 'height' in something not a structure or union
581 | frames_ctx->height = ctx->avctx->height;
| ^~
../examples/dmabuf-capture.c:593:27: error: request for member 'pix_fmt' in something not a structure or union
593 | ctx->avctx->pix_fmt = frames_ctx->format;
| ^~
../examples/dmabuf-capture.c:594:27: error: request for member 'hw_frames_ctx' in something not a structure or union
594 | ctx->avctx->hw_frames_ctx = av_buffer_ref(ctx->mapped_frames_ref);
| ^~
../examples/dmabuf-capture.c:595:32: error: request for member 'hw_frames_ctx' in something not a structure or union
595 | if (!ctx->avctx->hw_frames_ctx) {
| ^~
../examples/dmabuf-capture.c: In function 'init_encoding':
../examples/dmabuf-capture.c:622:30: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
622 | AVCodec *out_codec = avcodec_find_encoder_by_name(ctx->encoder_name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../examples/dmabuf-capture.c:627:40: error: assignment of member 'video_codec' in read-only object
627 | ctx->avf->oformat->video_codec = out_codec->id;
| ^
../examples/dmabuf-capture.c:630:22: error: implicit declaration of function 'avcodec_alloc_context3'; did you mean 'avio_alloc_context'? [-Werror=implicit-function-declaration]
630 | ctx->avctx = avcodec_alloc_context3(out_codec);
| ^~~~~~~~~~~~~~~~~~~~~~
| avio_alloc_context
../examples/dmabuf-capture.c:630:20: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
630 | ctx->avctx = avcodec_alloc_context3(out_codec);
| ^
../examples/dmabuf-capture.c:634:19: error: request for member 'opaque' in something not a structure or union
634 | ctx->avctx->opaque = ctx;
| ^~
../examples/dmabuf-capture.c:635:19: error: request for member 'bit_rate' in something not a structure or union
635 | ctx->avctx->bit_rate = (int)ctx->out_bitrate*1000000.0f;
| ^~
../examples/dmabuf-capture.c:636:19: error: request for member 'pix_fmt' in something not a structure or union
636 | ctx->avctx->pix_fmt = ctx->software_format;
| ^~
../examples/dmabuf-capture.c:637:19: error: request for member 'time_base' in something not a structure or union
637 | ctx->avctx->time_base = (AVRational){ 1, 1000 };
| ^~
../examples/dmabuf-capture.c:638:19: error: request for member 'compression_level' in something not a structure or union
638 | ctx->avctx->compression_level = 7;
| ^~
../examples/dmabuf-capture.c:639:19: error: request for member 'width' in something not a structure or union
639 | ctx->avctx->width = find_output(ctx, ctx->target_output, 0)->width;
| ^~
../examples/dmabuf-capture.c:640:19: error: request for member 'height' in something not a structure or union
640 | ctx->avctx->height = find_output(ctx, ctx->target_output, 0)->height;
| ^~
../examples/dmabuf-capture.c:643:27: error: request for member 'flags' in something not a structure or union
643 | ctx->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
| ^~
../examples/dmabuf-capture.c:643:38: error: 'AV_CODEC_FLAG_GLOBAL_HEADER' undeclared (first use in this function)
643 | ctx->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../examples/dmabuf-capture.c:643:38: note: each undeclared identifier is reported only once for each function it appears in
../examples/dmabuf-capture.c:647:35: error: request for member 'time_base' in something not a structure or union
647 | st->time_base = ctx->avctx->time_base;
| ^~
../examples/dmabuf-capture.c:656:15: error: implicit declaration of function 'avcodec_open2'; did you mean 'avio_open2'? [-Werror=implicit-function-declaration]
656 | err = avcodec_open2(ctx->avctx, out_codec, &ctx->encoder_opts);
| ^~~~~~~~~~~~~
| avio_open2
../examples/dmabuf-capture.c:663:13: error: implicit declaration of function 'avcodec_parameters_from_context'; did you mean 'avcodec_parameters_free'? [-Werror=implicit-function-declaration]
663 | if (avcodec_parameters_from_context(st->codecpar, ctx->avctx) < 0) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| avcodec_parameters_free
../examples/dmabuf-capture.c: In function 'uninit':
../examples/dmabuf-capture.c:897:9: error: implicit declaration of function 'avcodec_close'; did you mean 'avio_close'? [-Werror=implicit-function-declaration]
897 | avcodec_close(ctx->avctx);
| ^~~~~~~~~~~~~
| avio_close
cc1: all warnings being treated as errors
The build failures was observed with wlroots 0.14.1 and current master.