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;
|
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;
|
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();
|
AVPacket *packet = av_packet_alloc();
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
|
@ -205,11 +212,13 @@ run_demuxer(void *data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend any config packet to the next media packet
|
if (must_merge_config_packet) {
|
||||||
ok = sc_packet_merger_merge(&merger, packet);
|
// Prepend any config packet to the next media packet
|
||||||
if (!ok) {
|
ok = sc_packet_merger_merge(&merger, packet);
|
||||||
av_packet_unref(packet);
|
if (!ok) {
|
||||||
break;
|
av_packet_unref(packet);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = sc_demuxer_push_packet(demuxer, packet);
|
ok = sc_demuxer_push_packet(demuxer, packet);
|
||||||
|
@ -222,7 +231,9 @@ run_demuxer(void *data) {
|
||||||
|
|
||||||
LOGD("Demuxer '%s': end of frames", demuxer->name);
|
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);
|
av_packet_free(&packet);
|
||||||
finally_close_sinks:
|
finally_close_sinks:
|
||||||
|
|
Loading…
Reference in a new issue