mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-19 05:44:42 +00:00
Do not merge config audio packets
For video streams (at least H.264 and H.265), the config packet containing SPS/PPS must be prepended to the next packet (the following keyframe). For audio streams (at least OPUS), they must not be merged. PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
This commit is contained in:
parent
de430bc4aa
commit
609b098a97
@ -188,8 +188,15 @@ run_demuxer(void *data) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Config packets must be merged with the next non-config packet only for
|
||||
// video streams
|
||||
bool must_merge_config_packet = codec->type == AVMEDIA_TYPE_VIDEO;
|
||||
|
||||
struct sc_packet_merger merger;
|
||||
sc_packet_merger_init(&merger);
|
||||
|
||||
if (must_merge_config_packet) {
|
||||
sc_packet_merger_init(&merger);
|
||||
}
|
||||
|
||||
AVPacket *packet = av_packet_alloc();
|
||||
if (!packet) {
|
||||
@ -205,11 +212,13 @@ run_demuxer(void *data) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Prepend any config packet to the next media packet
|
||||
ok = sc_packet_merger_merge(&merger, packet);
|
||||
if (!ok) {
|
||||
av_packet_unref(packet);
|
||||
break;
|
||||
if (must_merge_config_packet) {
|
||||
// Prepend any config packet to the next media packet
|
||||
ok = sc_packet_merger_merge(&merger, packet);
|
||||
if (!ok) {
|
||||
av_packet_unref(packet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ok = sc_demuxer_push_packet(demuxer, packet);
|
||||
@ -222,7 +231,9 @@ run_demuxer(void *data) {
|
||||
|
||||
LOGD("Demuxer '%s': end of frames", demuxer->name);
|
||||
|
||||
sc_packet_merger_destroy(&merger);
|
||||
if (must_merge_config_packet) {
|
||||
sc_packet_merger_destroy(&merger);
|
||||
}
|
||||
|
||||
av_packet_free(&packet);
|
||||
finally_close_sinks:
|
||||
|
Loading…
Reference in New Issue
Block a user