From 2d51f5d03f09b379546939ee39d0fd169ac69acf Mon Sep 17 00:00:00 2001 From: Jonathan Lennox Date: Tue, 28 Sep 2021 10:45:28 -0400 Subject: [PATCH] Log when the height of a VP8 encoding changes from what was signaled. Use setEncodingLayers to ensure that the layer cache is updated properly. --- .../kotlin/org/jitsi/nlj/rtp/codec/vp8/Vp8Parser.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/jitsi/nlj/rtp/codec/vp8/Vp8Parser.kt b/src/main/kotlin/org/jitsi/nlj/rtp/codec/vp8/Vp8Parser.kt index aa2a06eff..9213ed987 100644 --- a/src/main/kotlin/org/jitsi/nlj/rtp/codec/vp8/Vp8Parser.kt +++ b/src/main/kotlin/org/jitsi/nlj/rtp/codec/vp8/Vp8Parser.kt @@ -45,9 +45,15 @@ class Vp8Parser( if (vp8Packet.height > -1) { // TODO: handle case where new height is from a packet older than the // latest height we've seen. - findRtpEncodingDesc(vp8Packet)?.let { enc -> - val newLayers = enc.layers.map { layer -> layer.copy(height = vp8Packet.height) } - enc.layers = newLayers.toTypedArray() + findSourceDescAndRtpEncodingDesc(vp8Packet)?.let { (src, enc) -> + if (enc.layers.getOrNull(0)?.height != vp8Packet.height) { + logger.info { + "Changing height of encoding ${vp8Packet.ssrc} " + + "from ${enc.layers.getOrNull(0)?.height} to ${vp8Packet.height}" + } + val newLayers = enc.layers.map { layer -> layer.copy(height = vp8Packet.height) }.toTypedArray() + src.setEncodingLayers(newLayers, vp8Packet.ssrc) + } } }