Skip to content

Commit

Permalink
Move to Kotlin 1.9.10, and related packages, including updating to kt…
Browse files Browse the repository at this point in the history
…or 2.3.4. (#516)

* Move to Kotlin 1.9.10, and related packages, including updating to ktor 2.3.4.

* Update ktlint version, and apply fixes.
  • Loading branch information
JonathanLennox authored Sep 28, 2023
1 parent af70507 commit 5d483c8
Show file tree
Hide file tree
Showing 39 changed files with 93 additions and 60 deletions.
14 changes: 7 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[*.{kt,kts}]
# Comma-separated list of rules to disable (Since 0.34.0)
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
# by the ruleset identifier.
# intellij currently has no setting to set sort order, and its
# default behavior directly contradicts what this rule wants. see
# https://youtrack.jetbrains.com/issue/KT-10974
disabled_rules=import-ordering
max_line_length=120

# I find trailing commas annoying
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled

# This forbids underscores in package names, which we use
ktlint_standard_package-name = disabled
30 changes: 12 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

<properties>
<selenium.version>3.12.0</selenium.version>
<kotlin.version>1.6.21</kotlin.version>
<kotlin.version>1.9.10</kotlin.version>
<exec.mainClass>org.jitsi.jibri.MainKt</exec.mainClass>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
<jackson.version>2.9.5</jackson.version>
<junit.version>5.8.2</junit.version>
<kotest.version>5.3.0</kotest.version>
<mockk.version>1.10.0</mockk.version>
<ktor.version>2.0.2-jitsi</ktor.version>
<junit.version>5.10.0</junit.version>
<kotest.version>5.7.2</kotest.version>
<mockk.version>1.13.8</mockk.version>
<ktor.version>2.3.4</ktor.version>
<jwt.version>0.11.5</jwt.version>
<jicoco.version>1.1-113-g4e7ea8b</jicoco.version>
<jitsi.utils.version>1.0-119-ga7b23ff</jitsi.utils.version>
<jicoco.version>1.1-127-gf49982f</jicoco.version>
<jitsi.utils.version>1.0-127-g6c65524</jitsi.utils.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -140,7 +140,7 @@
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-server-jetty11-jvm</artifactId>
<artifactId>ktor-server-jetty-jakarta-jvm</artifactId>
<version>${ktor.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -201,13 +201,7 @@
<dependency>
<groupId>org.jitsi</groupId>
<artifactId>jicoco-test-kotlin</artifactId>
<version>1.1-79-g6099be5</version>
<exclusions>
<exclusion>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</exclusion>
</exclusions>
<version>${jicoco.version}</version>
</dependency>
<dependency>
<groupId>io.kotest</groupId>
Expand Down Expand Up @@ -235,7 +229,7 @@
</dependency>
<dependency>
<groupId>io.mockk</groupId>
<artifactId>mockk</artifactId>
<artifactId>mockk-jvm</artifactId>
<version>${mockk.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -259,7 +253,7 @@
<!-- Force ktor-server-test-host to use a compatible jetty version. -->
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-jetty11-jvm</artifactId>
<artifactId>ktor-client-jetty-jakarta-jvm</artifactId>
<version>${ktor.version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -411,7 +405,7 @@
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>
<version>1.13.1</version>
<version>2.0.0</version>
<configuration>
<sourceRoots>
<sourceRoot>${project.basedir}/src/main/kotlin</sourceRoot>
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/jitsi/jibri/JibriManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ data class FileRecordingRequestParams(
class JibriManager : StatusPublisher<Any>() {
private val logger = createLogger()
private var currentActiveService: JibriService? = null

/**
* Store some arbitrary context optionally sent in the start service request so that we can report it in our
* status
*/
var currentEnvironmentContext: EnvironmentContext? = null

/**
* A function which will be executed the next time this Jibri is idle. This can be used to schedule work that
* can't be run while a Jibri session is active
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/jitsi/jibri/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.jitsi.jibri

import io.ktor.server.engine.embeddedServer
import io.ktor.server.jetty11.Jetty
import io.ktor.server.jetty.jakarta.Jetty
import kotlinx.coroutines.CancellationException
import net.sourceforge.argparse4j.ArgumentParsers
import org.jitsi.jibri.api.http.HttpApi
Expand Down
17 changes: 10 additions & 7 deletions src/main/kotlin/org/jitsi/jibri/api/http/HttpApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@

package org.jitsi.jibri.api.http

import io.ktor.http.HttpStatusCode
import io.ktor.serialization.jackson.jackson
import io.ktor.server.application.Application
import io.ktor.server.application.call
import io.ktor.server.application.install
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.http.HttpStatusCode
import io.ktor.serialization.jackson.jackson
import io.ktor.server.request.receive
import io.ktor.server.response.respond
import io.ktor.server.routing.get
import io.ktor.server.routing.post
import io.ktor.server.routing.route
import io.ktor.server.routing.routing
import jakarta.ws.rs.core.Response
import org.jitsi.jibri.FileRecordingRequestParams
import org.jitsi.jibri.JibriBusyException
import org.jitsi.jibri.JibriManager
Expand All @@ -41,15 +42,14 @@ import org.jitsi.jibri.service.ServiceParams
import org.jitsi.jibri.service.impl.SipGatewayServiceParams
import org.jitsi.jibri.service.impl.StreamingParams
import org.jitsi.jibri.sipgateway.SipClientParams
import org.jitsi.jibri.status.JibriSessionStatus
import org.jitsi.jibri.status.ComponentState
import org.jitsi.jibri.status.JibriFailure
import org.jitsi.jibri.status.JibriSessionStatus
import org.jitsi.jibri.status.JibriStatusManager
import org.jitsi.jibri.webhooks.v1.WebhookClient
import org.jitsi.metaconfig.config
import org.jitsi.utils.logging2.createLogger
import org.jitsi.xmpp.extensions.jibri.JibriIq
import jakarta.ws.rs.core.Response

// TODO: this needs to include usageTimeout
data class StartServiceParams(
Expand Down Expand Up @@ -145,7 +145,8 @@ class HttpApi(
serviceState.error
)
val componentSessionStatus = JibriSessionStatus(
serviceParams.sessionId, JibriIq.Status.OFF,
serviceParams.sessionId,
JibriIq.Status.OFF,
serviceParams.sipClientParams?.sipAddress,
failure,
serviceState.error.shouldRetry()
Expand All @@ -158,15 +159,17 @@ class HttpApi(
}
is ComponentState.Finished -> {
val componentSessionStatus = JibriSessionStatus(
serviceParams.sessionId, JibriIq.Status.OFF,
serviceParams.sessionId,
JibriIq.Status.OFF,
serviceParams.sipClientParams?.sipAddress
)
logger.info("Current service finished, sending status off $componentSessionStatus")
webhookClient.updateSessionStatus(componentSessionStatus)
}
is ComponentState.Running -> {
val componentSessionStatus = JibriSessionStatus(
serviceParams.sessionId, JibriIq.Status.ON,
serviceParams.sessionId,
JibriIq.Status.ON,
serviceParams.sipClientParams?.sipAddress
)
logger.info("Current service started up successfully, sending status on $componentSessionStatus")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.jitsi.jibri.api.http.internal

import io.ktor.http.HttpStatusCode
import io.ktor.serialization.jackson.jackson
import io.ktor.server.application.Application
import io.ktor.server.application.ApplicationCall
import io.ktor.server.application.call
import io.ktor.server.application.install
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.http.HttpStatusCode
import io.ktor.serialization.jackson.jackson
import io.ktor.server.response.respond
import io.ktor.server.routing.post
import io.ktor.server.routing.route
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/jitsi/jibri/api/xmpp/JibriStatusExts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*/
package org.jitsi.jibri.api.xmpp

import org.jitsi.xmpp.extensions.health.HealthStatusPacketExt
import org.jitsi.xmpp.extensions.jibri.JibriBusyStatusPacketExt
import org.jitsi.xmpp.extensions.jibri.JibriStatusPacketExt
import org.jitsi.jibri.status.ComponentBusyStatus
import org.jitsi.jibri.status.ComponentHealthStatus
import org.jitsi.jibri.status.JibriStatus
import org.jitsi.xmpp.extensions.health.HealthStatusPacketExt
import org.jitsi.xmpp.extensions.jibri.JibriBusyStatusPacketExt
import org.jitsi.xmpp.extensions.jibri.JibriStatusPacketExt
import java.lang.RuntimeException

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/org/jitsi/jibri/api/xmpp/XmppApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ class XmppApi(
PingManager.setDefaultPingInterval(30)
JibriStatusPacketExt.registerExtensionProvider()
ProviderManager.addIQProvider(
JibriIq.ELEMENT, JibriIq.NAMESPACE, JibriIqProvider()
JibriIq.ELEMENT,
JibriIq.NAMESPACE,
JibriIqProvider()
)
updatePresence(jibriStatusManager.overallStatus)
jibriStatusManager.addStatusHandler(::updatePresence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sealed class FfmpegEvent(val outputLine: String) {
class ErrorLine(val error: JibriError) : FfmpegEvent(error.detail)
class FinishLine(outputLine: String) : FfmpegEvent(outputLine)
class OtherLine(outputLine: String) : FfmpegEvent(outputLine)

/**
* Used any time Ffmpeg has exited, regardless of what [outputLine] contains. However,
* [error] will be set if [outputLine] contains an error, so that we may describe the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ open class FfmpegOutputStatus(val lineType: OutputLineClassification, val detail
* Represents a line of ffmpeg output that indicated there was a warning.
*/
open class FfmpegErrorStatus(val error: JibriError) : FfmpegOutputStatus(OutputLineClassification.ERROR, error.detail)

/**
* Represents a line of ffmpeg output that indicated a bad RTMP URL
*/
Expand Down
12 changes: 9 additions & 3 deletions src/main/kotlin/org/jitsi/jibri/config/JibriConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,25 @@ fun com.typesafe.config.Config.toXmppEnvironment(): XmppEnvironmentConfig =
xmppDomain = getString("xmpp-domain"),
baseUrl = if (hasPath("base-url")) {
getString("base-url")
} else null,
} else {
null
},
controlLogin = getConfig("control-login").toXmppCredentials(),
controlMuc = getConfig("control-muc").toXmppMuc(),
sipControlMuc = if (hasPath("sip-control-muc")) {
getConfig("sip-control-muc").toXmppMuc()
} else null,
} else {
null
},
callLogin = getConfig("call-login").toXmppCredentials(),
stripFromRoomDomain = getString("strip-from-room-domain"),
usageTimeoutMins = getDuration("usage-timeout").toMinutes().toInt(),
trustAllXmppCerts = getBoolean("trust-all-xmpp-certs"),
securityMode = if (hasPath("security-mode")) {
getEnum(ConnectionConfiguration.SecurityMode::class.java, "security-mode")
} else null
} else {
null
}
)

data class JibriConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EmptyCallStatusCheck(
init {
logger.info("Starting empty call check with a timeout of $callEmptyTimeout")
}

// The timestamp at which we last saw the call transition from
// non-empty to empty
private val callWentEmptyTime = StateTransitionTimeTracker(clock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class IceConnectionStatusCheck(
private val clock: Clock = Clock.systemDefaultZone()
) : CallStatusCheck {
private val logger = createChildLogger(parentLogger)

// The last timestamp when ICE was connected. Initialized to give the same timeout for the initial connection.
private var timeOfLastSuccess = clock.instant()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class MediaReceivedStatusCheck(
private val clock: Clock = Clock.systemDefaultZone()
) : CallStatusCheck {
private val logger = createChildLogger(parentLogger)

// The last timestamp where we saw non-zero media. We default with the
// assumption we're receiving media.
private var timeOfLastMedia = clock.instant()

// The timestamp at which we last saw that all clients transitioned to muted
private val clientsAllMutedTransitionTime = StateTransitionTimeTracker(clock)

Expand Down Expand Up @@ -76,6 +78,7 @@ class MediaReceivedStatusCheck(
val noMediaTimeout: Duration by config {
"jibri.call-status-checks.no-media-timeout".from(Config.configSource)
}

/**
* How long we'll stay in the call if all participants are muted
*/
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/org/jitsi/jibri/service/Errors.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ktlint-disable filename


/*
* Copyright @ 2018 - present 8x8, Inc.
Expand All @@ -16,6 +16,8 @@
* limitations under the License.
*/

@file:Suppress("ktlint:standard:filename")

package org.jitsi.jibri.service

import org.jitsi.jibri.error.JibriError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.jitsi.jibri.service.impl

import org.jitsi.xmpp.extensions.jibri.JibriIq
import org.jitsi.jibri.capture.ffmpeg.FfmpegCapturer
import org.jitsi.jibri.config.Config
import org.jitsi.jibri.config.XmppCredentials
Expand All @@ -33,6 +32,7 @@ import org.jitsi.jibri.status.ComponentState
import org.jitsi.jibri.status.ErrorScope
import org.jitsi.jibri.util.whenever
import org.jitsi.metaconfig.config
import org.jitsi.xmpp.extensions.jibri.JibriIq
import java.util.regex.Pattern

const val YOUTUBE_URL = "rtmp://a.rtmp.youtube.com/live2"
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/org/jitsi/jibri/sink/impl/FileSink.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class FileSink(recordingsDirectory: Path, callName: String, extension: String =
override val path: String = file.toString()
override val format: String = extension
override val options: Array<String> = arrayOf(
"-profile:v", "main",
"-level", "3.1"
"-profile:v",
"main",
"-level",
"3.1"
)

companion object {
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/org/jitsi/jibri/sink/impl/StreamSink.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class StreamSink(val url: String, val streamingMaxBitrate: Int, val streamingBuf
override val path: String = url
override val format: String = "flv"
override val options: Array<String> = arrayOf(
"-maxrate", "${streamingMaxBitrate}k",
"-bufsize", "${streamingBufSize}k"
"-maxrate",
"${streamingMaxBitrate}k",
"-bufsize",
"${streamingBufSize}k"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class PjsuaClient(
)
command.add(
"--registrar=$sipScheme:${
pjsuaClientParams.sipClientParams.userName.substringAfter('@')
pjsuaClientParams.sipClientParams.userName.substringAfter('@')
}"
)
command.add("--realm=*")
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/jitsi/jibri/statsd/StatsDEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const val XMPP_RECONNECTION_FAILED = "xmpp-reconnection-failed"
const val XMPP_PING_FAILED = "xmpp-ping-failed"
const val XMPP_CLOSED = "xmpp-closed"
const val XMPP_CLOSED_ON_ERROR = "xmpp-closed-on-error"

// A recording session was stopped because XMPP disconnected.
const val STOPPED_ON_XMPP_CLOSED = "stopped-on-xmpp-closed"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.jitsi.jibri.status
enum class ComponentBusyStatus {
BUSY,
IDLE,

/**
* This Jibri has exhausted its 'use' and needs action
* (e.g. a restart) before it can be used again
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/jitsi/jibri/status/ComponentStates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum class ErrorScope {
* whole 'healthy'
*/
SESSION,

/**
* [SYSTEM] errors are unrecoverable, and will put Jibri in an unhealthy state
*/
Expand Down
Loading

0 comments on commit 5d483c8

Please sign in to comment.