Skip to content

Commit

Permalink
Fix(SSRC rewriting): Catch exceptions rewriting SSRCs in the SSRC cac…
Browse files Browse the repository at this point in the history
…he. (#2192)
  • Loading branch information
JonathanLennox authored Jul 18, 2024
1 parent 97e03bb commit 1eb3054
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions jvb/src/main/kotlin/org/jitsi/videobridge/SsrcCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -411,23 +411,28 @@ abstract class SsrcCache(val size: Int, val ep: SsrcRewriter, val parentLogger:
val remappings = mutableListOf<SendSource>()
var send = false

synchronized(sendSources) {
var rs = receivedSsrcs[packet.ssrc]
if (rs == null) {
val props = findSourceProps(packet.ssrc) ?: return false
rs = ReceiveSsrc(props)
receivedSsrcs[packet.ssrc] = rs
logger.debug { "Added receive SSRC: ${packet.ssrc}" }
}
try {
synchronized(sendSources) {
var rs = receivedSsrcs[packet.ssrc]
if (rs == null) {
val props = findSourceProps(packet.ssrc) ?: return false
rs = ReceiveSsrc(props)
receivedSsrcs[packet.ssrc] = rs
logger.debug { "Added receive SSRC: ${packet.ssrc}" }
}

val ss = getSendSource(rs.props.ssrc1, rs.props, allowCreateOnPacket, remappings)
if (ss != null) {
send = ss.rewriteRtp(packet, start, rs)
val ss = getSendSource(rs.props.ssrc1, rs.props, allowCreateOnPacket, remappings)
if (ss != null) {
send = ss.rewriteRtp(packet, start, rs)
}
}
}

if (remappings.isNotEmpty()) {
notifyMappings(remappings)
if (remappings.isNotEmpty()) {
notifyMappings(remappings)
}
} catch (e: Exception) {
logger.error("Error rewriting SSRC", e)
send = false
}

return send
Expand Down

0 comments on commit 1eb3054

Please sign in to comment.