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
1 changed files with 18 additions and 7 deletions
|
@ -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;
|
||||
|
||||
if (must_merge_config_packet) {
|
||||
sc_packet_merger_init(&merger);
|
||||
}
|
||||
|
||||
AVPacket *packet = av_packet_alloc();
|
||||
if (!packet) {
|
||||
|
@ -205,12 +212,14 @@ run_demuxer(void *data) {
|
|||
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);
|
||||
av_packet_unref(packet);
|
||||
|
@ -222,7 +231,9 @@ run_demuxer(void *data) {
|
|||
|
||||
LOGD("Demuxer '%s': end of frames", demuxer->name);
|
||||
|
||||
if (must_merge_config_packet) {
|
||||
sc_packet_merger_destroy(&merger);
|
||||
}
|
||||
|
||||
av_packet_free(&packet);
|
||||
finally_close_sinks:
|
||||
|
|
Loading…
Reference in a new issue