Skip to content

Commit

Permalink
Add config to tell JVBs to use SCTP datachannels for relay-to-relay b…
Browse files Browse the repository at this point in the history
…ridge channels. (#1051)
  • Loading branch information
JonathanLennox authored Mar 16, 2023
1 parent 8db6cd1 commit 103c02b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions jicofo-common/src/main/kotlin/org/jitsi/jicofo/OctoConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class OctoConfig {
"jicofo.octo.allow-mixed-versions".from(newConfig)
}

val sctpDatachannels: Boolean by config {
"jicofo.octo.sctp-datachannels".from(newConfig)
}

companion object {
@JvmField
val config = OctoConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.jitsi.jicofo.bridge.colibri

import org.jitsi.jicofo.OctoConfig
import org.jitsi.jicofo.bridge.Bridge
import org.jitsi.jicofo.bridge.CascadeLink
import org.jitsi.jicofo.bridge.CascadeNode
Expand Down Expand Up @@ -332,7 +333,8 @@ class Colibri2Session(
private val useUniquePort = initiator
private val iceControlling = initiator
private val dtlsSetup = if (initiator) "active" else "passive"
private val websocketActive = initiator
private val bridgeChannelActive = initiator
private val sctpBridgeChannel = OctoConfig.config.sctpDatachannels

private val logger = createChildLogger(this@Colibri2Session.logger).apply { addContext("relay", relayId) }

Expand Down Expand Up @@ -388,10 +390,11 @@ class Colibri2Session(
logger.info("Setting setup=$dtlsSetup for $relayId")
it.setup = dtlsSetup
}
// We always expect the bridge to advertise a websocket, but we want only one side to act as a client.
// The bridge always advertises a websocket if we're not using SCTP, but we want only one side to act as a
// client.
// The bridge will always act as a client if the signaled transport includes a websocket, so here we make
// sure it is only included to one of the sides.
if (!websocketActive) {
if (sctpBridgeChannel || !bridgeChannelActive) {
transport.getChildExtensionsOfType(WebSocketPacketExtension::class.java).forEach {
transport.removeChildExtension(it)
}
Expand All @@ -413,7 +416,8 @@ class Colibri2Session(
put("use_unique_port", useUniquePort)
put("ice_controlling", iceControlling)
put("dtls_setup", dtlsSetup)
put("websocket_active", websocketActive)
put("bridge_channel_active", bridgeChannelActive)
put("sctp_bridge_channel", sctpBridgeChannel)
meshId?.let { put("mesh_id", it) }
}

Expand Down Expand Up @@ -490,6 +494,11 @@ class Colibri2Session(
Transport.getBuilder().apply {
setUseUniquePort(useUniquePort)
setIceControlling(iceControlling)
if (sctpBridgeChannel) {
val sctp = Sctp.Builder()
sctp.setRole(if (bridgeChannelActive) Sctp.Role.CLIENT else Sctp.Role.SERVER)
setSctp(sctp.build())
}
}.build()
)

Expand Down
3 changes: 3 additions & 0 deletions jicofo-selector/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ jicofo {

// Whether to allow bridges with different versions to be used in the same conference. Intended only for testing.
allow-mixed-versions = false

// Whether bridge-to-bridge communication should use SCTP datachannels (as opposed to websockets)
sctp-datachannels = false
}

rest {
Expand Down

0 comments on commit 103c02b

Please sign in to comment.