Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-points-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"server-sdk-kotlin": minor
---

SIP Update APIs, Sync mode, Egress audio mixing
48 changes: 36 additions & 12 deletions src/main/kotlin/io/livekit/server/EgressServiceClient.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 LiveKit, Inc.
* Copyright 2024-2025 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,12 @@ data class EncodedOutputs(
val imageOutput: LivekitEgress.ImageOutput?,
)

enum class AudioMixing {
DEFAULT_MIXING,
DUAL_CHANNEL_AGENT,
DUAL_CHANNEL_ALTERNATE
}

/**
* A client for interacting with the Egress service.
*
Expand All @@ -53,7 +59,8 @@ class EgressServiceClient(
optionsAdvanced: LivekitEgress.EncodingOptions? = null,
audioOnly: Boolean = false,
videoOnly: Boolean = false,
customBaseUrl: String = ""
customBaseUrl: String = "",
audioMixing: AudioMixing = AudioMixing.DEFAULT_MIXING
): Call<LivekitEgress.EgressInfo> {
@Suppress("DEPRECATION")
val requestBuilder = LivekitEgress.RoomCompositeEgressRequest.newBuilder()
Expand All @@ -67,7 +74,8 @@ class EgressServiceClient(
optionsAdvanced,
audioOnly,
videoOnly,
customBaseUrl
customBaseUrl,
audioMixing
)
}

Expand All @@ -80,7 +88,8 @@ class EgressServiceClient(
optionsAdvanced: LivekitEgress.EncodingOptions? = null,
audioOnly: Boolean = false,
videoOnly: Boolean = false,
customBaseUrl: String = ""
customBaseUrl: String = "",
audioMixing: AudioMixing = AudioMixing.DEFAULT_MIXING
): Call<LivekitEgress.EgressInfo> {
@Suppress("DEPRECATION")
val requestBuilder = LivekitEgress.RoomCompositeEgressRequest.newBuilder()
Expand All @@ -94,7 +103,8 @@ class EgressServiceClient(
optionsAdvanced,
audioOnly,
videoOnly,
customBaseUrl
customBaseUrl,
audioMixing
)
}

Expand All @@ -107,7 +117,8 @@ class EgressServiceClient(
optionsAdvanced: LivekitEgress.EncodingOptions? = null,
audioOnly: Boolean = false,
videoOnly: Boolean = false,
customBaseUrl: String = ""
customBaseUrl: String = "",
audioMixing: AudioMixing = AudioMixing.DEFAULT_MIXING
): Call<LivekitEgress.EgressInfo> {
@Suppress("DEPRECATION")
val requestBuilder = LivekitEgress.RoomCompositeEgressRequest.newBuilder()
Expand All @@ -121,7 +132,8 @@ class EgressServiceClient(
optionsAdvanced,
audioOnly,
videoOnly,
customBaseUrl
customBaseUrl,
audioMixing
)
}

Expand All @@ -134,7 +146,8 @@ class EgressServiceClient(
optionsAdvanced: LivekitEgress.EncodingOptions? = null,
audioOnly: Boolean = false,
videoOnly: Boolean = false,
customBaseUrl: String = ""
customBaseUrl: String = "",
audioMixing: AudioMixing = AudioMixing.DEFAULT_MIXING,
): Call<LivekitEgress.EgressInfo> {
@Suppress("DEPRECATION")
val requestBuilder = LivekitEgress.RoomCompositeEgressRequest.newBuilder()
Expand All @@ -147,7 +160,8 @@ class EgressServiceClient(
optionsAdvanced,
audioOnly,
videoOnly,
customBaseUrl
customBaseUrl,
audioMixing
)
}

Expand All @@ -160,7 +174,8 @@ class EgressServiceClient(
optionsAdvanced: LivekitEgress.EncodingOptions? = null,
audioOnly: Boolean = false,
videoOnly: Boolean = false,
customBaseUrl: String = ""
customBaseUrl: String = "",
audioMixing: AudioMixing = AudioMixing.DEFAULT_MIXING,
): Call<LivekitEgress.EgressInfo> {
val requestBuilder = LivekitEgress.RoomCompositeEgressRequest.newBuilder()
if (output.fileOutput != null) {
Expand All @@ -184,7 +199,8 @@ class EgressServiceClient(
optionsAdvanced,
audioOnly,
videoOnly,
customBaseUrl
customBaseUrl,
audioMixing
)
}

Expand All @@ -196,8 +212,15 @@ class EgressServiceClient(
optionsAdvanced: LivekitEgress.EncodingOptions?,
audioOnly: Boolean,
videoOnly: Boolean,
customBaseUrl: String
customBaseUrl: String,
audioMixing: AudioMixing
): Call<LivekitEgress.EgressInfo> {
val protoAudioMixing = when (audioMixing) {
AudioMixing.DEFAULT_MIXING -> LivekitEgress.AudioMixing.DEFAULT_MIXING
AudioMixing.DUAL_CHANNEL_AGENT -> LivekitEgress.AudioMixing.DUAL_CHANNEL_AGENT
AudioMixing.DUAL_CHANNEL_ALTERNATE -> LivekitEgress.AudioMixing.DUAL_CHANNEL_ALTERNATE
}

val request = with(requestBuilder) {
this.roomName = roomName
this.layout = layout
Expand All @@ -209,6 +232,7 @@ class EgressServiceClient(
this.audioOnly = audioOnly
this.videoOnly = videoOnly
this.customBaseUrl = customBaseUrl
this.audioMixing = protoAudioMixing
build()
}
val credentials = authHeader(RoomRecord(true))
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/io/livekit/server/RoomServiceClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ class RoomServiceClient(
return service.removeParticipant(request, credentials)
}

/**
* Forward a participant's track(s) to another room. Requires `roomAdmin` and `destinationRoom`. The forwarding will
* stop when the participant leaves the room or `RemoveParticipant` has been called in the destination room.
* A participant can be forwarded to multiple rooms. The destination room will be created if it does not exist.
* @param roomName
* @param identity
* @param destinationRoomName
*/
fun forwardParticipant(roomName: String, identity: String, destinationRoomName: String): Call<LivekitRoom.ForwardParticipantResponse> {
val request = LivekitRoom.ForwardParticipantRequest.newBuilder()
.setRoom(roomName)
Expand All @@ -198,6 +206,7 @@ class RoomServiceClient(
val credentials = authHeader(
RoomAdmin(true),
RoomName(roomName),
DestinationRoomName(destinationRoomName),
)
return service.forwardParticipant(request, credentials)
}
Expand Down
22 changes: 21 additions & 1 deletion src/main/kotlin/io/livekit/server/SipService.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 LiveKit, Inc.
* Copyright 2024-2025 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,6 +42,20 @@ interface SipService {
@Header("Authorization") authorization: String
): Call<LivekitSip.SIPOutboundTrunkInfo>

@Headers("Content-Type: application/protobuf")
@POST("/twirp/livekit.SIP/UpdateSIPInboundTrunk")
fun updateSipInboundTrunk(
@Body request: LivekitSip.UpdateSIPInboundTrunkRequest,
@Header("Authorization") authorization: String
): Call<LivekitSip.SIPInboundTrunkInfo>

@Headers("Content-Type: application/protobuf")
@POST("/twirp/livekit.SIP/UpdateSIPOutboundTrunk")
fun updateSipOutboundTrunk(
@Body request: LivekitSip.UpdateSIPOutboundTrunkRequest,
@Header("Authorization") authorization: String
): Call<LivekitSip.SIPOutboundTrunkInfo>

@Headers("Content-Type: application/protobuf")
@POST("/twirp/livekit.SIP/ListSIPInboundTrunk")
fun listSIPInboundTrunk(
Expand Down Expand Up @@ -70,6 +84,12 @@ interface SipService {
@Header("Authorization") authorization: String
): Call<LivekitSip.SIPDispatchRuleInfo>

@POST("/twirp/livekit.SIP/UpdateSIPDispatchRule")
fun updateSipDispatchRule(
@Body request: LivekitSip.UpdateSIPDispatchRuleRequest,
@Header("Authorization") authorization: String
): Call<LivekitSip.SIPDispatchRuleInfo>

@Headers("Content-Type: application/protobuf")
@POST("/twirp/livekit.SIP/ListSIPDispatchRule")
fun listSipDispatchRule(
Expand Down
Loading