Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement transferSipParticipant #83

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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/gold-flowers-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"server-sdk-kotlin": patch
---

Implement transferSipParticipant
2 changes: 1 addition & 1 deletion protocol
Submodule protocol updated 73 files
+5 −0 .changeset/wet-guests-eat.md
+40 −0 CHANGELOG.md
+1 −0 agent/token.go
+78 −54 auth/grants.go
+12 −11 auth/grants_test.go
+1 −3 go.mod
+2 −6 go.sum
+221 −210 livekit/livekit_analytics.pb.go
+283 −267 livekit/livekit_internal.pb.go
+706 −0 livekit/livekit_metrics.pb.go
+1,376 −619 livekit/livekit_models.pb.go
+386 −361 livekit/livekit_rtc.pb.go
+1,023 −457 livekit/livekit_sip.pb.go
+989 −133 livekit/livekit_sip.twirp.go
+110 −0 livekit/sip.go
+8 −0 livekit/types.go
+0 −2 livekit/types_test
+1 −1 logger/logger.go
+2 −2 logger/slog.go
+2 −0 magefile.go
+1 −1 package.json
+50 −0 packages/javascript/CHANGELOG.md
+3 −3 packages/javascript/package.json
+100 −238 pnpm-lock.yaml
+1 −0 protobufs/livekit_analytics.proto
+2 −0 protobufs/livekit_internal.proto
+84 −0 protobufs/livekit_metrics.proto
+65 −4 protobufs/livekit_models.proto
+3 −0 protobufs/livekit_rtc.proto
+54 −1 protobufs/livekit_sip.proto
+16 −2 protobufs/rpc/io.proto
+36 −0 protobufs/rpc/roommanager.proto
+1 −0 protobufs/rpc/signal.proto
+27 −3 protobufs/rpc/sip.proto
+11 −11 replay/cloud_replay.pb.go
+14 −7 rpc/agent.psrpc.go
+22 −15 rpc/agent_dispatch.psrpc.go
+29 −15 rpc/egress.psrpc.go
+5 −0 rpc/egress_client.go
+29 −15 rpc/ingress.psrpc.go
+5 −0 rpc/ingress_client.go
+239 −161 rpc/io.pb.go
+107 −95 rpc/io.psrpc.go
+9 −2 rpc/keepalive.psrpc.go
+27 −20 rpc/participant.psrpc.go
+23 −16 rpc/room.psrpc.go
+94 −0 rpc/roommanager.pb.go
+162 −0 rpc/roommanager.psrpc.go
+30 −0 rpc/rpcfakes/fake_keepalive_pub_sub.go
+30 −0 rpc/rpcfakes/fake_typed_participant_client.go
+30 −0 rpc/rpcfakes/fake_typed_room_client.go
+7 −7 rpc/signal.pb.go
+47 −24 rpc/signal.psrpc.go
+21 −16 rpc/sip.go
+241 −81 rpc/sip.pb.go
+79 −39 rpc/sip.psrpc.go
+8 −2 rpc/sip_test.go
+35 −6 rpc/typed_api.go
+37 −5 sip/sip.go
+5 −2 sip/sip_test.go
+1 −1 utils/bitmap.go
+14 −0 utils/clock.go
+62 −0 utils/closers.go
+12 −0 utils/error.go
+80 −12 utils/event_emitter.go
+123 −0 utils/event_emitter_test.go
+14 −3 utils/hedge.go
+78 −13 utils/hedge_test.go
+8 −29 utils/math.go
+0 −144 utils/messaging.go
+32 −0 utils/options/options.go
+4 −5 utils/proto.go
+1 −1 utils/protoproxy.go
15 changes: 12 additions & 3 deletions src/main/kotlin/io/livekit/server/SipService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.livekit.server

import com.google.protobuf.Empty
import livekit.LivekitSip
import retrofit2.Call
import retrofit2.http.Body
Expand All @@ -24,19 +25,19 @@ import retrofit2.http.Headers
import retrofit2.http.POST

/**
* Retrofit Interface for accessing the EgressService Apis.
* Retrofit Interface for accessing the SipService Apis.
*/
interface SipService {

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

@Headers("Content-Type: application/protobuf")
@POST("/twirp/livekit.Egress/CreateSIPOutboundTrunk")
@POST("/twirp/livekit.SIP/CreateSIPOutboundTrunk")
fun createSipOutboundTrunk(
@Body request: LivekitSip.CreateSIPOutboundTrunkRequest,
@Header("Authorization") authorization: String
Expand Down Expand Up @@ -90,4 +91,12 @@ interface SipService {
@Body request: LivekitSip.CreateSIPParticipantRequest,
@Header("Authorization") authorization: String
): Call<LivekitSip.SIPParticipantInfo>

@Headers("Content-Type: application/protobuf")
@POST("/twirp/livekit.SIP/TransferSIPParticipant")
fun transferSipParticipant(
@Body request: LivekitSip.TransferSIPParticipantRequest,
@Header("Authorization") authorization: String
): Call<Empty>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Call<Void?> work here? Keeps it consistent with the other empty response service calls.


}
22 changes: 22 additions & 0 deletions src/main/kotlin/io/livekit/server/SipServiceClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import livekit.LivekitSip.SIPDispatchRuleIndividual
import livekit.LivekitSip.SIPDispatchRuleInfo
import livekit.LivekitSip.SIPParticipantInfo
import livekit.LivekitSip.SIPTrunkInfo
import com.google.protobuf.Empty
import okhttp3.OkHttpClient
import retrofit2.Call
import retrofit2.Retrofit
Expand Down Expand Up @@ -251,6 +252,27 @@ class SipServiceClient(
return service.createSipParticipant(request, credentials)
}

/**
* Transfer a LiveKit SIP Participant to a different SIP peer.
*
* See: [SIP Participant](https://docs.livekit.io/sip/sip-participant/)
*/
fun transferSipParticipant(
roomName: String,
participantIdentity: String,
transferTo: String,
): Call<Empty> {
val request = with(LivekitSip.TransferSIPParticipantRequest.newBuilder()) {
this.roomName = roomName
this.participantIdentity = participantIdentity
this.transferTo = transferTo
build()
}

val credentials = authHeader(listOf(RoomAdmin(true), RoomName(roomName)), listOf(SIPCall()))
return service.transferSipParticipant(request, credentials)
}

companion object {
/**
* Create an SipServiceClient.
Expand Down
Loading