Skip to content

Commit

Permalink
Remove use-component-socket, cleanup (#2193)
Browse files Browse the repository at this point in the history
* ref: Move BufferPool setup to Main.

* ref: Remove the use-component-socket option.

The option was required, IceTransport unconditionally reads from the
component socket.

* log: Remove endpoint ID from IceMediaStream name.
  • Loading branch information
bgrozev authored Jul 18, 2024
1 parent 1eb3054 commit c618346
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 37 deletions.
16 changes: 0 additions & 16 deletions jvb/src/main/java/org/jitsi/videobridge/Videobridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.jitsi.videobridge;

import kotlin.*;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.*;
import org.jitsi.health.Result;
Expand All @@ -28,7 +27,6 @@
import org.jitsi.videobridge.metrics.*;
import org.jitsi.videobridge.shutdown.*;
import org.jitsi.videobridge.stats.*;
import org.jitsi.videobridge.util.*;
import org.jitsi.videobridge.xmpp.*;
import org.jitsi.xmpp.extensions.colibri2.*;
import org.jitsi.xmpp.extensions.health.*;
Expand Down Expand Up @@ -103,20 +101,6 @@ public class Videobridge

@NotNull private final ShutdownManager shutdownManager;

static
{
org.jitsi.rtp.util.BufferPool.Companion.setGetArray(ByteBufferPool::getBuffer);
org.jitsi.rtp.util.BufferPool.Companion.setReturnArray(buffer -> {
ByteBufferPool.returnBuffer(buffer);
return Unit.INSTANCE;
});
org.jitsi.nlj.util.BufferPool.Companion.setGetBuffer(ByteBufferPool::getBuffer);
org.jitsi.nlj.util.BufferPool.Companion.setReturnBuffer(buffer -> {
ByteBufferPool.returnBuffer(buffer);
return Unit.INSTANCE;
});
}

/**
* Initializes a new <tt>Videobridge</tt> instance.
*/
Expand Down
11 changes: 11 additions & 0 deletions jvb/src/main/kotlin/org/jitsi/videobridge/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.jitsi.videobridge.metrics.Metrics
import org.jitsi.videobridge.metrics.VideobridgePeriodicMetrics
import org.jitsi.videobridge.rest.root.Application
import org.jitsi.videobridge.stats.MucPublisher
import org.jitsi.videobridge.util.ByteBufferPool
import org.jitsi.videobridge.util.TaskPools
import org.jitsi.videobridge.util.UlimitCheck
import org.jitsi.videobridge.version.JvbVersionService
Expand Down Expand Up @@ -78,6 +79,8 @@ fun main() {
UlimitCheck.printUlimits()
startIce4j()

setupBufferPools()

// Initialize, binding on the main ICE port.
Harvesters.init()

Expand Down Expand Up @@ -229,3 +232,11 @@ private fun stopIce4j() {
// Shut down harvesters.
Harvesters.close()
}

/** Configure our libraries to use JVB's global [ByteBufferPool] */
private fun setupBufferPools() {
org.jitsi.rtp.util.BufferPool.getArray = { ByteBufferPool.getBuffer(it) }
org.jitsi.rtp.util.BufferPool.returnArray = { ByteBufferPool.returnBuffer(it) }
org.jitsi.nlj.util.BufferPool.getBuffer = { ByteBufferPool.getBuffer(it) }
org.jitsi.nlj.util.BufferPool.returnBuffer = { ByteBufferPool.returnBuffer(it) }
}
8 changes: 0 additions & 8 deletions jvb/src/main/kotlin/org/jitsi/videobridge/ice/IceConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ class IceConfig private constructor() {
.convertFrom<String> { KeepAliveStrategy.fromString(it) }
}

/**
* Whether the ice4j "component socket" mode is used.
*/
val useComponentSocket: Boolean by config {
"org.jitsi.videobridge.USE_COMPONENT_SOCKET".from(JitsiConfig.legacyConfig)
"videobridge.ice.use-component-socket".from(JitsiConfig.newConfig)
}

val resolveRemoteCandidates: Boolean by config(
"videobridge.ice.resolve-remote-candidates".from(JitsiConfig.newConfig)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,12 @@ class IceTransport @JvmOverloads constructor(
logger.addContext("local_ufrag", it.localUfrag)
}

// TODO: Do we still need the id here now that we have logContext?
private val iceStream = iceAgent.createMediaStream("stream-$id").apply {
private val iceStream = iceAgent.createMediaStream("stream").apply {
addPairChangeListener(iceStreamPairChangedListener)
}

private val iceComponent = iceAgent.createComponent(
iceStream,
IceConfig.config.keepAliveStrategy,
IceConfig.config.useComponentSocket
)

private val iceComponent = iceAgent.createComponent(iceStream, IceConfig.config.keepAliveStrategy, true)
private val packetStats = PacketStats()

val icePassword: String
get() = iceAgent.localPassword

Expand Down Expand Up @@ -267,7 +260,6 @@ class IceTransport @JvmOverloads constructor(
}

fun getDebugState(): OrderedJsonObject = OrderedJsonObject().apply {
put("useComponentSocket", IceConfig.config.useComponentSocket)
put("keepAliveStrategy", IceConfig.config.keepAliveStrategy.toString())
put("nominationStrategy", IceConfig.config.nominationStrategy.toString())
put("advertisePrivateCandidates", IceConfig.config.advertisePrivateCandidates)
Expand Down
3 changes: 0 additions & 3 deletions jvb/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ videobridge {
# "selected_and_tcp", "selected_only", or "all_succeeded".
keep-alive-strategy = "selected_and_tcp"

# Whether to use the "component socket" feature of ice4j.
use-component-socket = true

# Whether to attempt DNS resolution for remote candidates that contain a non-literal address. When set to 'false'
# such candidates will be ignored.
resolve-remote-candidates = false
Expand Down

0 comments on commit c618346

Please sign in to comment.