Files
protocol/rpc/participant.psrpc.go
David Zhao 677d114d56 feat: MoveParticipant API (#1051)
* feat: MoveParticipant API

This new API would move a participant from one cloud room to another.
It will support the following use cases:
- warm transfer in voice AI
- fast switching between different live streams
- prejoin room in meetings

* generated protobuf

* add RTC message

* repeat field number

* generated protobuf

* rpc

* generated protobuf

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2025-05-07 10:28:20 +08:00

278 lines
14 KiB
Go

// Code generated by protoc-gen-psrpc v0.6.0, DO NOT EDIT.
// source: rpc/participant.proto
package rpc
import (
"context"
"github.com/livekit/psrpc"
"github.com/livekit/psrpc/pkg/client"
"github.com/livekit/psrpc/pkg/info"
"github.com/livekit/psrpc/pkg/rand"
"github.com/livekit/psrpc/pkg/server"
"github.com/livekit/psrpc/version"
)
import livekit1 "github.com/livekit/protocol/livekit"
import livekit6 "github.com/livekit/protocol/livekit"
var _ = version.PsrpcVersion_0_6
// ============================
// Participant Client Interface
// ============================
type ParticipantClient[ParticipantTopicType ~string] interface {
RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.RemoveParticipantResponse, error)
MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit6.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit6.MuteRoomTrackResponse, error)
UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit1.ParticipantInfo, error)
UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit6.UpdateSubscriptionsResponse, error)
ForwardParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.ForwardParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.ForwardParticipantResponse, error)
MoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.MoveParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.MoveParticipantResponse, error)
// Close immediately, without waiting for pending RPCs
Close()
}
// ================================
// Participant ServerImpl Interface
// ================================
type ParticipantServerImpl interface {
RemoveParticipant(context.Context, *livekit6.RoomParticipantIdentity) (*livekit6.RemoveParticipantResponse, error)
MutePublishedTrack(context.Context, *livekit6.MuteRoomTrackRequest) (*livekit6.MuteRoomTrackResponse, error)
UpdateParticipant(context.Context, *livekit6.UpdateParticipantRequest) (*livekit1.ParticipantInfo, error)
UpdateSubscriptions(context.Context, *livekit6.UpdateSubscriptionsRequest) (*livekit6.UpdateSubscriptionsResponse, error)
ForwardParticipant(context.Context, *livekit6.ForwardParticipantRequest) (*livekit6.ForwardParticipantResponse, error)
MoveParticipant(context.Context, *livekit6.MoveParticipantRequest) (*livekit6.MoveParticipantResponse, error)
}
// ============================
// Participant Server Interface
// ============================
type ParticipantServer[ParticipantTopicType ~string] interface {
RegisterRemoveParticipantTopic(participant ParticipantTopicType) error
DeregisterRemoveParticipantTopic(participant ParticipantTopicType)
RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error
DeregisterMutePublishedTrackTopic(participant ParticipantTopicType)
RegisterUpdateParticipantTopic(participant ParticipantTopicType) error
DeregisterUpdateParticipantTopic(participant ParticipantTopicType)
RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error
DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType)
RegisterForwardParticipantTopic(participant ParticipantTopicType) error
DeregisterForwardParticipantTopic(participant ParticipantTopicType)
RegisterMoveParticipantTopic(participant ParticipantTopicType) error
DeregisterMoveParticipantTopic(participant ParticipantTopicType)
RegisterAllParticipantTopics(participant ParticipantTopicType) error
DeregisterAllParticipantTopics(participant ParticipantTopicType)
// Close and wait for pending RPCs to complete
Shutdown()
// Close immediately, without waiting for pending RPCs
Kill()
}
// ==================
// Participant Client
// ==================
type participantClient[ParticipantTopicType ~string] struct {
client *client.RPCClient
}
// NewParticipantClient creates a psrpc client that implements the ParticipantClient interface.
func NewParticipantClient[ParticipantTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (ParticipantClient[ParticipantTopicType], error) {
sd := &info.ServiceDefinition{
Name: "Participant",
ID: rand.NewClientID(),
}
sd.RegisterMethod("RemoveParticipant", false, false, true, true)
sd.RegisterMethod("MutePublishedTrack", false, false, true, true)
sd.RegisterMethod("UpdateParticipant", false, false, true, true)
sd.RegisterMethod("UpdateSubscriptions", false, false, true, true)
sd.RegisterMethod("ForwardParticipant", false, false, true, true)
sd.RegisterMethod("MoveParticipant", false, false, true, true)
rpcClient, err := client.NewRPCClient(sd, bus, opts...)
if err != nil {
return nil, err
}
return &participantClient[ParticipantTopicType]{
client: rpcClient,
}, nil
}
func (c *participantClient[ParticipantTopicType]) RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.RemoveParticipantResponse, error) {
return client.RequestSingle[*livekit6.RemoveParticipantResponse](ctx, c.client, "RemoveParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit6.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit6.MuteRoomTrackResponse, error) {
return client.RequestSingle[*livekit6.MuteRoomTrackResponse](ctx, c.client, "MutePublishedTrack", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit1.ParticipantInfo, error) {
return client.RequestSingle[*livekit1.ParticipantInfo](ctx, c.client, "UpdateParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit6.UpdateSubscriptionsResponse, error) {
return client.RequestSingle[*livekit6.UpdateSubscriptionsResponse](ctx, c.client, "UpdateSubscriptions", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) ForwardParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.ForwardParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.ForwardParticipantResponse, error) {
return client.RequestSingle[*livekit6.ForwardParticipantResponse](ctx, c.client, "ForwardParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) MoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.MoveParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.MoveParticipantResponse, error) {
return client.RequestSingle[*livekit6.MoveParticipantResponse](ctx, c.client, "MoveParticipant", []string{string(participant)}, req, opts...)
}
func (s *participantClient[ParticipantTopicType]) Close() {
s.client.Close()
}
// ==================
// Participant Server
// ==================
type participantServer[ParticipantTopicType ~string] struct {
svc ParticipantServerImpl
rpc *server.RPCServer
}
// NewParticipantServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewParticipantServer[ParticipantTopicType ~string](svc ParticipantServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (ParticipantServer[ParticipantTopicType], error) {
sd := &info.ServiceDefinition{
Name: "Participant",
ID: rand.NewServerID(),
}
s := server.NewRPCServer(sd, bus, opts...)
sd.RegisterMethod("RemoveParticipant", false, false, true, true)
sd.RegisterMethod("MutePublishedTrack", false, false, true, true)
sd.RegisterMethod("UpdateParticipant", false, false, true, true)
sd.RegisterMethod("UpdateSubscriptions", false, false, true, true)
sd.RegisterMethod("ForwardParticipant", false, false, true, true)
sd.RegisterMethod("MoveParticipant", false, false, true, true)
return &participantServer[ParticipantTopicType]{
svc: svc,
rpc: s,
}, nil
}
func (s *participantServer[ParticipantTopicType]) RegisterRemoveParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "RemoveParticipant", []string{string(participant)}, s.svc.RemoveParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterRemoveParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("RemoveParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "MutePublishedTrack", []string{string(participant)}, s.svc.MutePublishedTrack, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterMutePublishedTrackTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("MutePublishedTrack", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterUpdateParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "UpdateParticipant", []string{string(participant)}, s.svc.UpdateParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterUpdateParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("UpdateParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "UpdateSubscriptions", []string{string(participant)}, s.svc.UpdateSubscriptions, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("UpdateSubscriptions", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterForwardParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "ForwardParticipant", []string{string(participant)}, s.svc.ForwardParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterForwardParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("ForwardParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterMoveParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "MoveParticipant", []string{string(participant)}, s.svc.MoveParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterMoveParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("MoveParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) allParticipantTopicRegisterers() server.RegistererSlice {
return server.RegistererSlice{
server.NewRegisterer(s.RegisterRemoveParticipantTopic, s.DeregisterRemoveParticipantTopic),
server.NewRegisterer(s.RegisterMutePublishedTrackTopic, s.DeregisterMutePublishedTrackTopic),
server.NewRegisterer(s.RegisterUpdateParticipantTopic, s.DeregisterUpdateParticipantTopic),
server.NewRegisterer(s.RegisterUpdateSubscriptionsTopic, s.DeregisterUpdateSubscriptionsTopic),
server.NewRegisterer(s.RegisterForwardParticipantTopic, s.DeregisterForwardParticipantTopic),
server.NewRegisterer(s.RegisterMoveParticipantTopic, s.DeregisterMoveParticipantTopic),
}
}
func (s *participantServer[ParticipantTopicType]) RegisterAllParticipantTopics(participant ParticipantTopicType) error {
return s.allParticipantTopicRegisterers().Register(participant)
}
func (s *participantServer[ParticipantTopicType]) DeregisterAllParticipantTopics(participant ParticipantTopicType) {
s.allParticipantTopicRegisterers().Deregister(participant)
}
func (s *participantServer[ParticipantTopicType]) Shutdown() {
s.rpc.Close(false)
}
func (s *participantServer[ParticipantTopicType]) Kill() {
s.rpc.Close(true)
}
var psrpcFileDescriptor6 = []byte{
// 337 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4f, 0x4b, 0xfb, 0x40,
0x10, 0x25, 0xfc, 0xa0, 0x87, 0x2d, 0x3f, 0xb4, 0xab, 0x42, 0x09, 0x6a, 0xff, 0x9e, 0x13, 0xd0,
0x6f, 0xe0, 0x41, 0xf0, 0x50, 0x28, 0x51, 0x2f, 0x5e, 0x24, 0xd9, 0xac, 0x76, 0x69, 0x92, 0x59,
0x77, 0x27, 0x95, 0x7a, 0xf1, 0x20, 0x08, 0x82, 0x9f, 0xc6, 0x4f, 0x28, 0x4d, 0x9a, 0x64, 0x9b,
0xd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