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 <https://github.com/Genymobile/scrcpy/issues/2302>
This commit is contained in:
parent
e8b053ad2f
commit
318b6a572e
1 changed files with 11 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue