From 318b6a572e0e866554c5aa5a2ed8c4d0d774a5dc Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 14 Jun 2021 09:07:49 +0200 Subject: [PATCH] Allocate AVPacket for local stream packet From FFmpeg/doc/APIchanges: 2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will no longer be a part of the public ABI. Refs #2302 --- app/src/stream.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/stream.c b/app/src/stream.c index 86f5d87a..d1b8b9f3 100644 --- a/app/src/stream.c +++ b/app/src/stream.c @@ -220,16 +220,21 @@ run_stream(void *data) { // It's more complicated, but this allows to reduce the latency by 1 frame! stream->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; + AVPacket *packet = av_packet_alloc(); + if (!packet) { + LOGE("Could not allocate packet"); + goto finally_close_parser; + } + for (;;) { - AVPacket packet; - bool ok = stream_recv_packet(stream, &packet); + bool ok = stream_recv_packet(stream, packet); if (!ok) { // end of stream break; } - ok = stream_push_packet(stream, &packet); - av_packet_unref(&packet); + ok = stream_push_packet(stream, packet); + av_packet_unref(packet); if (!ok) { // cannot process packet (error already logged) break; @@ -243,6 +248,8 @@ run_stream(void *data) { av_packet_free(&stream->pending); } + av_packet_free(&packet); +finally_close_parser: av_parser_close(stream->parser); finally_close_sinks: stream_close_sinks(stream);