diff --git a/go.mod b/go.mod index 04d05ed99..c17cc85d2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/livekit/livekit-server -go 1.23.4 +go 1.24.0 toolchain go1.24.6 @@ -23,8 +23,8 @@ require ( github.com/jxskiss/base62 v1.1.0 github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade - github.com/livekit/protocol v1.40.1-0.20250826073447-c714707269e5 - github.com/livekit/psrpc v0.6.1-0.20250726180611-3915e005e741 + github.com/livekit/protocol v1.41.1-0.20250902155548-e46b3f58f6a7 + github.com/livekit/psrpc v0.6.1-0.20250828235857-3fafdbbcbe55 github.com/mackerelio/go-osstat v0.2.6 github.com/magefile/mage v1.15.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.11.3 @@ -38,7 +38,7 @@ require ( github.com/pion/rtcp v1.2.15 github.com/pion/rtp v1.8.21 github.com/pion/sctp v1.8.39 - github.com/pion/sdp/v3 v3.0.15 + github.com/pion/sdp/v3 v3.0.16 github.com/pion/transport/v3 v3.0.7 github.com/pion/turn/v4 v4.1.1 github.com/pion/webrtc/v4 v4.1.5-0.20250828044558-c376d0edf977 @@ -63,8 +63,13 @@ require ( ) require ( + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/moby/sys/user v0.3.0 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel v1.37.0 // indirect + go.opentelemetry.io/otel/metric v1.37.0 // indirect + go.opentelemetry.io/otel/trace v1.37.0 // indirect ) require ( @@ -92,7 +97,7 @@ require ( github.com/go-jose/go-jose/v3 v3.0.4 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/cel-go v0.26.0 // indirect + github.com/google/cel-go v0.26.1 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/subcommands v1.2.0 // indirect @@ -139,8 +144,8 @@ require ( golang.org/x/sys v0.35.0 // indirect golang.org/x/text v0.28.0 // indirect golang.org/x/tools v0.36.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250826171959-ef028d996bc1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 // indirect google.golang.org/grpc v1.75.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 06d9e517f..81b1b289a 100644 --- a/go.sum +++ b/go.sum @@ -79,6 +79,7 @@ github.com/gammazero/workerpool v1.1.3 h1:WixN4xzukFoN0XSeXF6puqEqFTl2mECI9S6W44 github.com/gammazero/workerpool v1.1.3/go.mod h1:wPjyBLDbyKnUn2XwwyD3EEwo9dHutia9/fwNmSHWACc= github.com/go-jose/go-jose/v3 v3.0.4 h1:Wp5HA7bLQcKnf6YYao/4kpRpVMp/yf6+pJKV8WFSaNY= github.com/go-jose/go-jose/v3 v3.0.4/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -91,8 +92,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI= -github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= +github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ= +github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -170,10 +171,10 @@ github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5AT github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ= github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade h1:lpxPcglwzUWNB4J0S2qZuyMehzmR7vW9whzSwV4IGoI= github.com/livekit/mediatransportutil v0.0.0-20250825135402-7bc31f107ade/go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A= -github.com/livekit/protocol v1.40.1-0.20250826073447-c714707269e5 h1:aBqHlrgCI3qzVUAoOx7n5Kt8GQ8g7UbNp69fUt2gO8I= -github.com/livekit/protocol v1.40.1-0.20250826073447-c714707269e5/go.mod h1:YlgUxAegtU8jZ0tVXoIV/4fHeHqqLvS+6JnPKDbpFPU= -github.com/livekit/psrpc v0.6.1-0.20250726180611-3915e005e741 h1:KKL1u94l6dF9u4cBwnnfozk27GH1txWy2SlvkfgmzoY= -github.com/livekit/psrpc v0.6.1-0.20250726180611-3915e005e741/go.mod h1:AuDC5uOoEjQJEc69v4Li3t77Ocz0e0NdjQEuFfO+vfk= +github.com/livekit/protocol v1.41.1-0.20250902155548-e46b3f58f6a7 h1:61Guoe3mkqaWRteFiNkAcaXVca9PqUijq8xEjSfoifI= +github.com/livekit/protocol v1.41.1-0.20250902155548-e46b3f58f6a7/go.mod h1:Scx8arfj5y65w6EYA3ZIKJafoN2xBuV8pauvyrvI4eg= +github.com/livekit/psrpc v0.6.1-0.20250828235857-3fafdbbcbe55 h1:6/iy4APnZZDmtDOxoqv3/eo5hxhpaA/M0ND75XqL7aA= +github.com/livekit/psrpc v0.6.1-0.20250828235857-3fafdbbcbe55/go.mod h1:AuDC5uOoEjQJEc69v4Li3t77Ocz0e0NdjQEuFfO+vfk= github.com/mackerelio/go-osstat v0.2.6 h1:gs4U8BZeS1tjrL08tt5VUliVvSWP26Ai2Ob8Lr7f2i0= github.com/mackerelio/go-osstat v0.2.6/go.mod h1:lRy8V9ZuHpuRVZh+vyTkODeDPl3/d5MgXHtLSaqG8bA= github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= @@ -253,8 +254,8 @@ github.com/pion/rtp v1.8.21 h1:3yrOwmZFyUpcIosNcWRpQaU+UXIJ6yxLuJ8Bx0mw37Y= github.com/pion/rtp v1.8.21/go.mod h1:bAu2UFKScgzyFqvUKmbvzSdPr+NGbZtv6UB2hesqXBk= github.com/pion/sctp v1.8.39 h1:PJma40vRHa3UTO3C4MyeJDQ+KIobVYRZQZ0Nt7SjQnE= github.com/pion/sctp v1.8.39/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE= -github.com/pion/sdp/v3 v3.0.15 h1:F0I1zds+K/+37ZrzdADmx2Q44OFDOPRLhPnNTaUX9hk= -github.com/pion/sdp/v3 v3.0.15/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E= +github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo= +github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo= github.com/pion/srtp/v3 v3.0.7 h1:QUElw0A/FUg3MP8/KNMZB3i0m8F9XeMnTum86F7S4bs= github.com/pion/srtp/v3 v3.0.7/go.mod h1:qvnHeqbhT7kDdB+OGB05KA/P067G3mm7XBfLaLiaNF0= github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw= @@ -282,8 +283,8 @@ github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPK github.com/redis/go-redis/v9 v9.12.1 h1:k5iquqv27aBtnTm2tIkROUDp8JBXhXZIVu1InSgvovg= github.com/redis/go-redis/v9 v9.12.1/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= @@ -476,10 +477,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY= -google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5/go.mod h1:j3QtIyytwqGr1JUDtYXwtMXWPKsEa5LtzIFN1Wn5WvE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc= +google.golang.org/genproto/googleapis/api v0.0.0-20250826171959-ef028d996bc1 h1:APHvLLYBhtZvsbnpkfknDZ7NyH4z5+ub/I0u8L3Oz6g= +google.golang.org/genproto/googleapis/api v0.0.0-20250826171959-ef028d996bc1/go.mod h1:xUjFWUnWDpZ/C0Gu0qloASKFb6f8/QXiiXhSPFsD668= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 h1:pmJpJEvT846VzausCQ5d7KreSROcDqmO388w5YbnltA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1/go.mod h1:GmFNa4BdJZ2a8G+wCe9Bg3wwThLrJun751XstdJt5Og= google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4= google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= diff --git a/pkg/rtc/clientinfo.go b/pkg/rtc/clientinfo.go index 463e32db7..52b179684 100644 --- a/pkg/rtc/clientinfo.go +++ b/pkg/rtc/clientinfo.go @@ -49,7 +49,7 @@ func (c ClientInfo) SupportsAudioRED() bool { return !c.isFirefox() && !c.isSafari() } -func (c ClientInfo) SupportPrflxOverRelay() bool { +func (c ClientInfo) SupportsPrflxOverRelay() bool { return !c.isFirefox() } @@ -97,15 +97,15 @@ func (c ClientInfo) ComplyWithCodecOrderInSDPAnswer() bool { } // Rust SDK can't decode unknown signal message (TrackSubscribed and ErrorResponse) -func (c ClientInfo) SupportTrackSubscribedEvent() bool { +func (c ClientInfo) SupportsTrackSubscribedEvent() bool { return !(c.ClientInfo.GetSdk() == livekit.ClientInfo_RUST && c.ClientInfo.GetProtocol() < 10) } -func (c ClientInfo) SupportErrorResponse() bool { - return c.SupportTrackSubscribedEvent() +func (c ClientInfo) SupportsRequestResponse() bool { + return c.SupportsTrackSubscribedEvent() } -func (c ClientInfo) SupportSctpZeroChecksum() bool { +func (c ClientInfo) SupportsSctpZeroChecksum() bool { return !(c.ClientInfo.GetSdk() == livekit.ClientInfo_UNKNOWN || (c.isGo() && c.compareVersion("2.4.0") < 0)) } diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 1a97db1ae..378e1b430 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -40,7 +40,8 @@ import ( "github.com/livekit/protocol/logger" "github.com/livekit/protocol/observability" "github.com/livekit/protocol/observability/roomobs" - sdpHelper "github.com/livekit/protocol/sdp" + protosdp "github.com/livekit/protocol/sdp" + protosignalling "github.com/livekit/protocol/signalling" "github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils/guid" "github.com/livekit/protocol/utils/pointer" @@ -63,6 +64,8 @@ import ( sutils "github.com/livekit/livekit-server/pkg/utils" ) +var _ types.LocalParticipant = (*ParticipantImpl)(nil) + const ( sdBatchSize = 30 rttUpdateInterval = 5 * time.Second @@ -549,8 +552,8 @@ func (p *ParticipantImpl) GetBufferFactory() *buffer.Factory { return p.params.Config.BufferFactory } -// CheckMetadataLimits check if name/metadata/attributes of a participant is within configured limits -func (p *ParticipantImpl) CheckMetadataLimits( +// checkMetadataLimits check if name/metadata/attributes of a participant is within configured limits +func (p *ParticipantImpl) checkMetadataLimits( name string, metadata string, attributes map[string]string, @@ -570,6 +573,64 @@ func (p *ParticipantImpl) CheckMetadataLimits( return nil } +func (p *ParticipantImpl) UpdateMetadata(update *livekit.UpdateParticipantMetadata, fromAdmin bool) error { + lgr := p.params.Logger.WithUnlikelyValues( + "update", logger.Proto(update), + "fromAdmin", fromAdmin, + ) + lgr.Debugw("updating participant metadata") + + var err error + requestResponse := &livekit.RequestResponse{} + sendRequestResponse := func() error { + if !fromAdmin || (update.RequestId != 0 || err != nil) { + requestResponse.Request = &livekit.RequestResponse_UpdateMetadata{ + UpdateMetadata: utils.CloneProto(update), + } + p.sendRequestResponse(requestResponse) + } + if err != nil { + lgr.Warnw("could not update metadata", err) + } + return err + } + + if !fromAdmin && !p.ClaimGrants().Video.GetCanUpdateOwnMetadata() { + requestResponse.Reason = livekit.RequestResponse_NOT_ALLOWED + requestResponse.Message = "does not have permission to update own metadata" + err = signalling.ErrUpdateOwnMetadataNotAllowed + return sendRequestResponse() + } + + if err = p.checkMetadataLimits(update.Name, update.Metadata, update.Attributes); err != nil { + switch err { + case signalling.ErrNameExceedsLimits: + requestResponse.Reason = livekit.RequestResponse_LIMIT_EXCEEDED + requestResponse.Message = "exceeds name length limit" + + case signalling.ErrMetadataExceedsLimits: + requestResponse.Reason = livekit.RequestResponse_LIMIT_EXCEEDED + requestResponse.Message = "exceeds metadata size limit" + + case signalling.ErrAttributesExceedsLimits: + requestResponse.Reason = livekit.RequestResponse_LIMIT_EXCEEDED + requestResponse.Message = "exceeds attributes size limit" + } + return sendRequestResponse() + } + + if update.Name != "" { + p.SetName(update.Name) + } + if update.Metadata != "" { + p.SetMetadata(update.Metadata) + } + if update.Attributes != nil { + p.SetAttributes(update.Attributes) + } + return sendRequestResponse() +} + // SetName attaches name to the participant func (p *ParticipantImpl) SetName(name string) { p.lock.Lock() @@ -1018,12 +1079,12 @@ func (p *ParticipantImpl) synthesizeAddTrackRequests(parsedOffer *sdp.SessionDes continue } - cid := sdpHelper.GetMediaStreamTrack(m) + cid := protosdp.GetMediaStreamTrack(m) if cid == "" { cid = guid.New(utils.TrackPrefix) } - rids, ridsOk := sdpHelper.GetSimulcastRids(m) + rids, ridsOk := protosdp.GetSimulcastRids(m) var ( name string @@ -1072,14 +1133,14 @@ func (p *ParticipantImpl) updateRidsFromSDP(parsed *sdp.SessionDescription, unma continue } - mst := sdpHelper.GetMediaStreamTrack(m) + mst := protosdp.GetMediaStreamTrack(m) if mst == "" { continue } getRids := func(inRids buffer.VideoLayersRid) buffer.VideoLayersRid { var outRids buffer.VideoLayersRid - rids, ok := sdpHelper.GetSimulcastRids(m) + rids, ok := protosdp.GetSimulcastRids(m) if ok { n := min(len(rids), len(inRids)) for i := 0; i < n; i++ { @@ -1149,28 +1210,43 @@ func (p *ParticipantImpl) updateRidsFromSDP(parsed *sdp.SessionDescription, unma } } +func (p *ParticipantImpl) HandleICETrickle(trickleRequest *livekit.TrickleRequest) { + candidateInit, err := protosignalling.FromProtoTrickle(trickleRequest) + if err != nil { + p.params.Logger.Warnw("could not decode trickle", err) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_UNCLASSIFIED_ERROR, + Message: err.Error(), + Request: &livekit.RequestResponse_Trickle{ + Trickle: utils.CloneProto(trickleRequest), + }, + }) + return + } + + p.TransportManager.AddICECandidate(candidateInit, trickleRequest.Target) +} + // HandleOffer an offer from remote participant, used when clients make the initial connection -func (p *ParticipantImpl) HandleOffer(offer webrtc.SessionDescription, offerId uint32) error { - p.pubLogger.Debugw( - "received offer", +func (p *ParticipantImpl) HandleOffer(sd *livekit.SessionDescription) error { + offer, offerId := protosignalling.FromProtoSessionDescription(sd) + lgr := p.pubLogger.WithUnlikelyValues( "transport", livekit.SignalTarget_PUBLISHER, "offer", offer, "offerId", offerId, ) + lgr.Debugw("received offer") + parsedOffer, err := offer.Unmarshal() if err != nil { - p.pubLogger.Warnw( - "could not parse offer", err, - "transport", livekit.SignalTarget_PUBLISHER, - "offer", offer, - "offerId", offerId, - ) + lgr.Warnw("could not parse offer", err) return err } if p.params.UseOneShotSignallingMode { if err := p.synthesizeAddTrackRequests(parsedOffer); err != nil { + lgr.Warnw("could not synthesize add track requests", err) return err } } @@ -1182,7 +1258,7 @@ func (p *ParticipantImpl) HandleOffer(offer webrtc.SessionDescription, offerId u // put together munged offer after setting codec preferences bytes, err := parsedOffer.Marshal() if err != nil { - p.pubLogger.Errorw("failed to marshal offer", err) + lgr.Errorw("failed to marshal offer", err, "parsedOffer", parsedOffer) return err } @@ -1193,6 +1269,7 @@ func (p *ParticipantImpl) HandleOffer(offer webrtc.SessionDescription, offerId u err = p.TransportManager.HandleOffer(offer, offerId, p.MigrateState() == types.MigrateStateInit) if err != nil { + lgr.Warnw("could not handle offer", err, "mungedOffer", offer) return err } @@ -1203,7 +1280,7 @@ func (p *ParticipantImpl) HandleOffer(offer webrtc.SessionDescription, offerId u } p.handlePendingRemoteTracks() - return err + return nil } func (p *ParticipantImpl) onPublisherAnswer(answer webrtc.SessionDescription, answerId uint32) error { @@ -1243,7 +1320,8 @@ func (p *ParticipantImpl) GetAnswer() (webrtc.SessionDescription, uint32, error) // HandleAnswer handles a client answer response, with subscriber PC, server initiates the // offer and client answers -func (p *ParticipantImpl) HandleAnswer(answer webrtc.SessionDescription, answerId uint32) { +func (p *ParticipantImpl) HandleAnswer(sd *livekit.SessionDescription) { + answer, answerId := protosignalling.FromProtoSessionDescription(sd) p.subLogger.Debugw( "received answer", "transport", livekit.SignalTarget_SUBSCRIBER, @@ -1307,11 +1385,23 @@ func (p *ParticipantImpl) AddTrack(req *livekit.AddTrackRequest) { p.params.Logger.Debugw("add track request", "trackID", req.Cid, "request", logger.Proto(req)) if !p.CanPublishSource(req.Source) { p.pubLogger.Warnw("no permission to publish track", nil, "trackID", req.Sid, "kind", req.Type) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_NOT_ALLOWED, + Request: &livekit.RequestResponse_AddTrack{ + AddTrack: utils.CloneProto(req), + }, + }) return } if req.Type != livekit.TrackType_AUDIO && req.Type != livekit.TrackType_VIDEO { p.pubLogger.Warnw("unsupported track type", nil, "trackID", req.Sid, "kind", req.Type) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_UNSUPPORTED_TYPE, + Request: &livekit.RequestResponse_AddTrack{ + AddTrack: utils.CloneProto(req), + }, + }) return } @@ -2290,9 +2380,13 @@ func (p *ParticipantImpl) onReceivedDataMessage(kind livekit.DataPacket_Kind, da // waiting time out, handle all cached messages cachedMsgs := migrationCache.Get() if len(cachedMsgs) == 0 { - p.pubLogger.Warnw("migration data cache timed out, no cached messages received", nil, "lastPubReliableSeq", p.params.LastPubReliableSeq) + p.pubLogger.Warnw( + "migration data cache timed out, no cached messages received", nil, + "lastPubReliableSeq", p.params.LastPubReliableSeq, + ) } else { - p.pubLogger.Warnw("migration data cache timed out, handling cached messages", nil, + p.pubLogger.Warnw( + "migration data cache timed out, handling cached messages", nil, "cachedFirstSeq", cachedMsgs[0].Sequence, "cachedLastSeq", cachedMsgs[len(cachedMsgs)-1].Sequence, "lastPubReliableSeq", p.params.LastPubReliableSeq, @@ -2316,7 +2410,11 @@ func (p *ParticipantImpl) onReceivedDataMessage(kind livekit.DataPacket_Kind, da func (p *ParticipantImpl) handleReceivedDataMessage(kind livekit.DataPacket_Kind, dp *livekit.DataPacket) { if kind == livekit.DataPacket_RELIABLE && dp.Sequence > 0 { if p.reliableDataInfo.lastPubReliableSeq.Load() >= dp.Sequence { - p.params.Logger.Infow("received out of order reliable data packet", "lastPubReliableSeq", p.reliableDataInfo.lastPubReliableSeq.Load(), "dpSequence", dp.Sequence) + p.params.Logger.Infow( + "received out of order reliable data packet", + "lastPubReliableSeq", p.reliableDataInfo.lastPubReliableSeq.Load(), + "dpSequence", dp.Sequence, + ) return } @@ -2694,6 +2792,12 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l track := p.GetPublishedTrack(livekit.TrackID(req.Sid)) if track == nil { p.pubLogger.Infow("could not find existing track for multi-codec simulcast", "trackID", req.Sid) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_NOT_FOUND, + Request: &livekit.RequestResponse_AddTrack{ + AddTrack: utils.CloneProto(req), + }, + }) return nil } @@ -2873,6 +2977,12 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l "request", logger.Proto(req), "pendingTrack", p.pendingTracks[req.Cid], ) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_QUEUED, + Request: &livekit.RequestResponse_AddTrack{ + AddTrack: utils.CloneProto(req), + }, + }) return nil } @@ -2910,22 +3020,23 @@ func (p *ParticipantImpl) HasConnected() bool { return p.TransportManager.HasSubscriberEverConnected() || p.TransportManager.HasPublisherEverConnected() } -func (p *ParticipantImpl) SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool) *livekit.TrackInfo { +func (p *ParticipantImpl) SetTrackMuted(mute *livekit.MuteTrackRequest, fromAdmin bool) *livekit.TrackInfo { // when request is coming from admin, send message to current participant if fromAdmin { - p.sendTrackMuted(trackID, muted) + p.sendTrackMuted(livekit.TrackID(mute.Sid), mute.Muted) } - return p.setTrackMuted(trackID, muted) + return p.setTrackMuted(mute, fromAdmin) } -func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) *livekit.TrackInfo { +func (p *ParticipantImpl) setTrackMuted(mute *livekit.MuteTrackRequest, fromAdmin bool) *livekit.TrackInfo { + trackID := livekit.TrackID(mute.Sid) p.dirty.Store(true) if p.supervisor != nil { - p.supervisor.SetPublicationMute(trackID, muted) + p.supervisor.SetPublicationMute(trackID, mute.Muted) } - track, changed := p.UpTrackManager.SetPublishedTrackMuted(trackID, muted) + track, changed := p.UpTrackManager.SetPublishedTrackMuted(trackID, mute.Muted) var trackInfo *livekit.TrackInfo if track != nil { trackInfo = track.ToProto() @@ -2937,8 +3048,8 @@ func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) *li for i, ti := range pti.trackInfos { if livekit.TrackID(ti.Sid) == trackID { ti = utils.CloneProto(ti) - changed = changed || ti.Muted != muted - ti.Muted = muted + changed = changed || ti.Muted != mute.Muted + ti.Muted = mute.Muted pti.trackInfos[i] = ti if trackInfo == nil { trackInfo = ti @@ -2949,13 +3060,22 @@ func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) *li p.pendingTracksLock.RUnlock() if trackInfo != nil && changed { - if muted { + if mute.Muted { p.params.Telemetry.TrackMuted(context.Background(), p.ID(), trackInfo) } else { p.params.Telemetry.TrackUnmuted(context.Background(), p.ID(), trackInfo) } } + if trackInfo == nil && !fromAdmin { + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_NOT_FOUND, + Request: &livekit.RequestResponse_Mute{ + Mute: utils.CloneProto(mute), + }, + }) + } + return trackInfo } @@ -3602,7 +3722,7 @@ func (p *ParticipantImpl) GetPlayoutDelayConfig() *livekit.PlayoutDelay { } func (p *ParticipantImpl) SupportsSyncStreamID() bool { - return p.ProtocolVersion().SupportSyncStreamID() && !p.params.ClientInfo.isFirefox() && p.params.SyncStreams + return p.ProtocolVersion().SupportsSyncStreamID() && !p.params.ClientInfo.isFirefox() && p.params.SyncStreams } func (p *ParticipantImpl) SupportsTransceiverReuse() bool { @@ -3779,6 +3899,12 @@ func (p *ParticipantImpl) UpdateAudioTrack(update *livekit.UpdateLocalAudioTrack } p.pubLogger.Debugw("could not locate track", "trackID", update.TrackSid) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_NOT_FOUND, + Request: &livekit.RequestResponse_UpdateAudioTrack{ + UpdateAudioTrack: utils.CloneProto(update), + }, + }) return errors.New("could not find track") } @@ -3805,6 +3931,12 @@ func (p *ParticipantImpl) UpdateVideoTrack(update *livekit.UpdateLocalVideoTrack } p.pubLogger.Debugw("could not locate track", "trackID", update.TrackSid) + p.sendRequestResponse(&livekit.RequestResponse{ + Reason: livekit.RequestResponse_NOT_FOUND, + Request: &livekit.RequestResponse_UpdateVideoTrack{ + UpdateVideoTrack: utils.CloneProto(update), + }, + }) return errors.New("could not find track") } diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index b5dc5064b..ea1201777 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -132,7 +132,8 @@ func TestTrackPublishing(t *testing.T) { Type: livekit.TrackType_AUDIO, }) - require.Equal(t, 1, sink.WriteMessageCallCount()) + // error response on duplicate adds a message + require.Equal(t, 2, sink.WriteMessageCallCount()) }) t.Run("should queue adding of duplicate tracks if already published by client id in signalling", func(t *testing.T) { @@ -150,7 +151,8 @@ func TestTrackPublishing(t *testing.T) { Name: "webcam", Type: livekit.TrackType_VIDEO, }) - require.Equal(t, 0, sink.WriteMessageCallCount()) + // `queued` `RequestResponse` should add a message + require.Equal(t, 1, sink.WriteMessageCallCount()) require.Equal(t, 1, len(p.pendingTracks["cid"].trackInfos)) // add again - it should be added to the queue @@ -159,7 +161,8 @@ func TestTrackPublishing(t *testing.T) { Name: "webcam", Type: livekit.TrackType_VIDEO, }) - require.Equal(t, 0, sink.WriteMessageCallCount()) + // `queued` `RequestResponse`s should have been sent for duplicate additions + require.Equal(t, 2, sink.WriteMessageCallCount()) require.Equal(t, 2, len(p.pendingTracks["cid"].trackInfos)) // check SID is the same @@ -181,7 +184,8 @@ func TestTrackPublishing(t *testing.T) { Name: "webcam", Type: livekit.TrackType_VIDEO, }) - require.Equal(t, 0, sink.WriteMessageCallCount()) + // `queued` `RequestResponse` should add a message + require.Equal(t, 1, sink.WriteMessageCallCount()) require.Equal(t, 1, len(p.pendingTracks["cid"].trackInfos)) // add again - it should be added to the queue @@ -190,7 +194,8 @@ func TestTrackPublishing(t *testing.T) { Name: "webcam", Type: livekit.TrackType_VIDEO, }) - require.Equal(t, 0, sink.WriteMessageCallCount()) + // `queued` `RequestResponse`s should have been sent for duplicate additions + require.Equal(t, 2, sink.WriteMessageCallCount()) require.Equal(t, 2, len(p.pendingTracks["cid"].trackInfos)) // check SID is the same @@ -220,7 +225,8 @@ func TestTrackPublishing(t *testing.T) { Type: livekit.TrackType_AUDIO, Source: livekit.TrackSource_MICROPHONE, }) - require.Equal(t, 1, sink.WriteMessageCallCount()) + // an error response for disallowed source should send a `RequestResponse`. + require.Equal(t, 2, sink.WriteMessageCallCount()) }) } @@ -278,7 +284,10 @@ func TestMuteSetting(t *testing.T) { ti := &livekit.TrackInfo{Sid: "testTrack"} p.pendingTracks["cid"] = &pendingTrackInfo{trackInfos: []*livekit.TrackInfo{ti}} - p.SetTrackMuted(livekit.TrackID(ti.Sid), true, false) + p.SetTrackMuted(&livekit.MuteTrackRequest{ + Sid: ti.Sid, + Muted: true, + }, false) require.True(t, p.pendingTracks["cid"].trackInfos[0].Muted) }) @@ -384,7 +393,11 @@ func TestDisableCodecs(t *testing.T) { } return nil }) - participant.HandleOffer(sdp, offerId) + participant.HandleOffer(&livekit.SessionDescription{ + Type: webrtc.SDPTypeOffer.String(), + Sdp: sdp.SDP, + Id: offerId, + }) testutils.WithTimeout(t, func() string { if answerReceived.Load() && answerIdReceived.Load() == offerId { @@ -573,7 +586,11 @@ func TestPreferMediaCodecForPublisher(t *testing.T) { } return nil }) - participant.HandleOffer(sdp, offerId) + participant.HandleOffer(&livekit.SessionDescription{ + Type: webrtc.SDPTypeOffer.String(), + Sdp: sdp.SDP, + Id: offerId, + }) require.Eventually(t, func() bool { return answerReceived.Load() && answerIdReceived.Load() == offerId }, 5*time.Second, 10*time.Millisecond) @@ -660,7 +677,11 @@ func TestPreferAudioCodecForRed(t *testing.T) { } return nil }) - participant.HandleOffer(sdp, offerId) + participant.HandleOffer(&livekit.SessionDescription{ + Type: webrtc.SDPTypeOffer.String(), + Sdp: sdp.SDP, + Id: offerId, + }) require.Eventually(t, func() bool { return answerReceived.Load() && answerIdReceived.Load() == offerId }, 5*time.Second, 10*time.Millisecond) diff --git a/pkg/rtc/participant_signal.go b/pkg/rtc/participant_signal.go index 52792e8d9..72bd1cd35 100644 --- a/pkg/rtc/participant_signal.go +++ b/pkg/rtc/participant_signal.go @@ -157,8 +157,8 @@ func (p *ParticipantImpl) SendRefreshToken(token string) error { return p.signaller.WriteMessage(p.signalling.SignalRefreshToken(token)) } -func (p *ParticipantImpl) SendRequestResponse(requestResponse *livekit.RequestResponse) error { - if requestResponse.RequestId == 0 || !p.params.ClientInfo.SupportErrorResponse() { +func (p *ParticipantImpl) sendRequestResponse(requestResponse *livekit.RequestResponse) error { + if !p.params.ClientInfo.SupportsRequestResponse() { return nil } @@ -183,7 +183,7 @@ func (p *ParticipantImpl) HandleReconnectAndSendResponse(reconnectReason livekit return err } - if p.params.ProtocolVersion.SupportHandlesDisconnectedUpdate() { + if p.params.ProtocolVersion.SupportsDisconnectedUpdate() { return p.sendDisconnectUpdatesForReconnect() } @@ -248,7 +248,7 @@ func (p *ParticipantImpl) sendTrackUnpublished(trackID livekit.TrackID) { } func (p *ParticipantImpl) sendTrackHasBeenSubscribed(trackID livekit.TrackID) { - if !p.params.ClientInfo.SupportTrackSubscribedEvent() { + if !p.params.ClientInfo.SupportsTrackSubscribedEvent() { return } _ = p.signaller.WriteMessage(p.signalling.SignalTrackSubscribed(&livekit.TrackSubscribed{ diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 092f8a246..03b4835c0 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -179,7 +179,7 @@ func TestParticipantUpdate(t *testing.T) { "track mutes are sent to everyone", true, func(p types.LocalParticipant) { - p.SetTrackMuted("", true, false) + p.SetTrackMuted(&livekit.MuteTrackRequest{Muted: true}, false) }, }, { diff --git a/pkg/rtc/signalling/errors.go b/pkg/rtc/signalling/errors.go index 048b11732..c78a4c308 100644 --- a/pkg/rtc/signalling/errors.go +++ b/pkg/rtc/signalling/errors.go @@ -19,8 +19,9 @@ import ( ) var ( - ErrInvalidMessageType = errors.New("invalid message type") - ErrNameExceedsLimits = errors.New("name length exceeds limits") - ErrMetadataExceedsLimits = errors.New("metadata size exceeds limits") - ErrAttributesExceedsLimits = errors.New("attributes size exceeds limits") + ErrInvalidMessageType = errors.New("invalid message type") + ErrNameExceedsLimits = errors.New("name length exceeds limits") + ErrMetadataExceedsLimits = errors.New("metadata size exceeds limits") + ErrAttributesExceedsLimits = errors.New("attributes size exceeds limits") + ErrUpdateOwnMetadataNotAllowed = errors.New("update own metadata not allowed") ) diff --git a/pkg/rtc/signalling/signalhandler.go b/pkg/rtc/signalling/signalhandler.go index 5052165f4..9c9ef8881 100644 --- a/pkg/rtc/signalling/signalhandler.go +++ b/pkg/rtc/signalling/signalhandler.go @@ -19,7 +19,6 @@ import ( "github.com/livekit/protocol/livekit" "github.com/livekit/protocol/logger" - protosignalling "github.com/livekit/protocol/signalling" "google.golang.org/protobuf/proto" "github.com/livekit/livekit-server/pkg/rtc/types" @@ -58,24 +57,19 @@ func (s *signalhandler) HandleMessage(msg proto.Message) error { s.params.Logger.Debugw("handling signal request", "request", logger.Proto(req)) switch msg := req.GetMessage().(type) { case *livekit.SignalRequest_Offer: - s.params.Participant.HandleOffer(protosignalling.FromProtoSessionDescription(msg.Offer)) + s.params.Participant.HandleOffer(msg.Offer) case *livekit.SignalRequest_Answer: - s.params.Participant.HandleAnswer(protosignalling.FromProtoSessionDescription(msg.Answer)) + s.params.Participant.HandleAnswer(msg.Answer) case *livekit.SignalRequest_Trickle: - candidateInit, err := protosignalling.FromProtoTrickle(msg.Trickle) - if err != nil { - s.params.Logger.Warnw("could not decode trickle", err) - return err - } - s.params.Participant.AddICECandidate(candidateInit, msg.Trickle.Target) + s.params.Participant.HandleICETrickle(msg.Trickle) case *livekit.SignalRequest_AddTrack: s.params.Participant.AddTrack(msg.AddTrack) case *livekit.SignalRequest_Mute: - s.params.Participant.SetTrackMuted(livekit.TrackID(msg.Mute.Sid), msg.Mute.Muted, false) + s.params.Participant.SetTrackMuted(msg.Mute, false) case *livekit.SignalRequest_Subscription: // allow participant to indicate their interest in the subscription @@ -137,48 +131,7 @@ func (s *signalhandler) HandleMessage(msg proto.Message) error { } case *livekit.SignalRequest_UpdateMetadata: - requestResponse := &livekit.RequestResponse{ - RequestId: msg.UpdateMetadata.RequestId, - Reason: livekit.RequestResponse_OK, - } - if s.params.Participant.ClaimGrants().Video.GetCanUpdateOwnMetadata() { - if err := s.params.Participant.CheckMetadataLimits( - msg.UpdateMetadata.Name, - msg.UpdateMetadata.Metadata, - msg.UpdateMetadata.Attributes, - ); err == nil { - if msg.UpdateMetadata.Name != "" { - s.params.Participant.SetName(msg.UpdateMetadata.Name) - } - if msg.UpdateMetadata.Metadata != "" { - s.params.Participant.SetMetadata(msg.UpdateMetadata.Metadata) - } - if msg.UpdateMetadata.Attributes != nil { - s.params.Participant.SetAttributes(msg.UpdateMetadata.Attributes) - } - } else { - s.params.Logger.Warnw("could not update metadata", err) - - switch err { - case ErrNameExceedsLimits: - requestResponse.Reason = livekit.RequestResponse_LIMIT_EXCEEDED - requestResponse.Message = "exceeds name length limit" - - case ErrMetadataExceedsLimits: - requestResponse.Reason = livekit.RequestResponse_LIMIT_EXCEEDED - requestResponse.Message = "exceeds metadata size limit" - - case ErrAttributesExceedsLimits: - requestResponse.Reason = livekit.RequestResponse_LIMIT_EXCEEDED - requestResponse.Message = "exceeds attributes size limit" - } - - } - } else { - requestResponse.Reason = livekit.RequestResponse_NOT_ALLOWED - requestResponse.Message = "does not have permission to update own metadata" - } - s.params.Participant.SendRequestResponse(requestResponse) + s.params.Participant.UpdateMetadata(msg.UpdateMetadata, false) case *livekit.SignalRequest_UpdateAudioTrack: if err := s.params.Participant.UpdateAudioTrack(msg.UpdateAudioTrack); err != nil { diff --git a/pkg/rtc/testutils.go b/pkg/rtc/testutils.go index 88893f188..213175fcb 100644 --- a/pkg/rtc/testutils.go +++ b/pkg/rtc/testutils.go @@ -68,7 +68,7 @@ func NewMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro } } - p.SetTrackMutedCalls(func(sid livekit.TrackID, muted bool, fromServer bool) *livekit.TrackInfo { + p.SetTrackMutedCalls(func(mute *livekit.MuteTrackRequest, fromServer bool) *livekit.TrackInfo { updateTrack() return nil }) diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index 195003bb8..43c32d09a 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -329,7 +329,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat se.SetFireOnTrackBeforeFirstRTP(true) } - if params.ClientInfo.SupportSctpZeroChecksum() { + if params.ClientInfo.SupportsSctpZeroChecksum() { se.EnableSCTPZeroChecksum(true) } @@ -352,7 +352,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat // se.DisableSRTPReplayProtection(true) se.DisableSRTCPReplayProtection(true) - if !params.ProtocolVersion.SupportsICELite() || !params.ClientInfo.SupportPrflxOverRelay() { + if !params.ProtocolVersion.SupportsICELite() || !params.ClientInfo.SupportsPrflxOverRelay() { // if client don't support prflx over relay which is only Firefox, disable ICE Lite to ensure that // aggressive nomination is handled properly. Firefox does aggressive nomination even if peer is // ICE Lite (see comment as to historical reasons: https://github.com/pion/ice/pull/739#issuecomment-2452245066). @@ -366,7 +366,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat se.SetICETimeouts(iceDisconnectedTimeout, iceFailedTimeout, iceKeepaliveInterval) // if client don't support prflx over relay, we should not expose private address to it, use single external ip as host candidate - if !params.ClientInfo.SupportPrflxOverRelay() && len(params.Config.NAT1To1IPs) > 0 { + if !params.ClientInfo.SupportsPrflxOverRelay() && len(params.Config.NAT1To1IPs) > 0 { var nat1to1Ips []string var includeIps []string for _, mapping := range params.Config.NAT1To1IPs { @@ -2600,7 +2600,7 @@ func (t *PCTransport) handleRemoteOfferReceived(sd *webrtc.SessionDescription, o parsed, err := sd.Unmarshal() if err != nil { - return nil + return err } t.lock.Lock() @@ -2661,7 +2661,11 @@ func (t *PCTransport) handleRemoteOfferReceived(sd *webrtc.SessionDescription, o func (t *PCTransport) handleRemoteAnswerReceived(sd *webrtc.SessionDescription, answerId uint32) error { t.params.Logger.Debugw("processing answer", "answerId", answerId) if answerId != 0 && answerId != t.localOfferId.Load() { - t.params.Logger.Warnw("sdp state: answer id mismatch", nil, "expected", t.localOfferId.Load(), "got", answerId) + t.params.Logger.Warnw( + "sdp state: answer id mismatch", nil, + "expected", t.localOfferId.Load(), + "got", answerId, + ) } t.remoteAnswerId.Store(answerId) diff --git a/pkg/rtc/types/interfaces.go b/pkg/rtc/types/interfaces.go index eacf95f15..f22018d50 100644 --- a/pkg/rtc/types/interfaces.go +++ b/pkg/rtc/types/interfaces.go @@ -387,7 +387,7 @@ type LocalParticipant interface { HandleSignalSourceClose() // updates - CheckMetadataLimits(name string, metadata string, attributes map[string]string) error + UpdateMetadata(update *livekit.UpdateParticipantMetadata, fromAdmin bool) error SetName(name string) SetMetadata(metadata string) SetAttributes(attributes map[string]string) @@ -403,15 +403,15 @@ type LocalParticipant interface { CanPublishData() bool // PeerConnection - AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) - HandleOffer(sdp webrtc.SessionDescription, offerId uint32) error + HandleICETrickle(trickleRequest *livekit.TrickleRequest) + HandleOffer(sd *livekit.SessionDescription) error GetAnswer() (webrtc.SessionDescription, uint32, error) HandleICETrickleSDPFragment(sdpFragment string) error HandleICERestartSDPFragment(sdpFragment string) (string, error) AddTrack(req *livekit.AddTrackRequest) - SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool) *livekit.TrackInfo + SetTrackMuted(mute *livekit.MuteTrackRequest, fromAdmin bool) *livekit.TrackInfo - HandleAnswer(sdp webrtc.SessionDescription, answerId uint32) + HandleAnswer(sd *livekit.SessionDescription) Negotiate(force bool) ICERestart(iceConfig *livekit.ICEConfig) AddTrackLocal(trackLocal webrtc.TrackLocal, params AddTrackParams) (*webrtc.RTPSender, *webrtc.RTPTransceiver, error) @@ -450,7 +450,7 @@ type LocalParticipant interface { SendConnectionQualityUpdate(update *livekit.ConnectionQualityUpdate) error SendSubscriptionPermissionUpdate(publisherID livekit.ParticipantID, trackID livekit.TrackID, allowed bool) error SendRefreshToken(token string) error - SendRequestResponse(requestResponse *livekit.RequestResponse) error + // RAJA-REMOVE SendRequestResponse(requestResponse *livekit.RequestResponse) error HandleReconnectAndSendResponse(reconnectReason livekit.ReconnectReason, reconnectResponse *livekit.ReconnectResponse) error IssueFullReconnect(reason ParticipantCloseReason) SendRoomMovedResponse(moved *livekit.RoomMovedResponse) error diff --git a/pkg/rtc/types/protocol_version.go b/pkg/rtc/types/protocol_version.go index f1c54a7cb..e7f569854 100644 --- a/pkg/rtc/types/protocol_version.go +++ b/pkg/rtc/types/protocol_version.go @@ -68,11 +68,11 @@ func (v ProtocolVersion) SupportFastStart() bool { return v > 7 } -func (v ProtocolVersion) SupportHandlesDisconnectedUpdate() bool { +func (v ProtocolVersion) SupportsDisconnectedUpdate() bool { return v > 8 } -func (v ProtocolVersion) SupportSyncStreamID() bool { +func (v ProtocolVersion) SupportsSyncStreamID() bool { return v > 9 } diff --git a/pkg/rtc/types/typesfakes/fake_local_participant.go b/pkg/rtc/types/typesfakes/fake_local_participant.go index d4c19d8d3..3abdd99b3 100644 --- a/pkg/rtc/types/typesfakes/fake_local_participant.go +++ b/pkg/rtc/types/typesfakes/fake_local_participant.go @@ -21,12 +21,6 @@ import ( ) type FakeLocalParticipant struct { - AddICECandidateStub func(webrtc.ICECandidateInit, livekit.SignalTarget) - addICECandidateMutex sync.RWMutex - addICECandidateArgsForCall []struct { - arg1 webrtc.ICECandidateInit - arg2 livekit.SignalTarget - } AddTrackStub func(*livekit.AddTrackRequest) addTrackMutex sync.RWMutex addTrackArgsForCall []struct { @@ -122,19 +116,6 @@ type FakeLocalParticipant struct { canSubscribeReturnsOnCall map[int]struct { result1 bool } - CheckMetadataLimitsStub func(string, string, map[string]string) error - checkMetadataLimitsMutex sync.RWMutex - checkMetadataLimitsArgsForCall []struct { - arg1 string - arg2 string - arg3 map[string]string - } - checkMetadataLimitsReturns struct { - result1 error - } - checkMetadataLimitsReturnsOnCall map[int]struct { - result1 error - } ClaimGrantsStub func() *auth.ClaimGrants claimGrantsMutex sync.RWMutex claimGrantsArgsForCall []struct { @@ -497,11 +478,10 @@ type FakeLocalParticipant struct { getTrailerReturnsOnCall map[int]struct { result1 []byte } - HandleAnswerStub func(webrtc.SessionDescription, uint32) + HandleAnswerStub func(*livekit.SessionDescription) handleAnswerMutex sync.RWMutex handleAnswerArgsForCall []struct { - arg1 webrtc.SessionDescription - arg2 uint32 + arg1 *livekit.SessionDescription } HandleICERestartSDPFragmentStub func(string) (string, error) handleICERestartSDPFragmentMutex sync.RWMutex @@ -516,6 +496,11 @@ type FakeLocalParticipant struct { result1 string result2 error } + HandleICETrickleStub func(*livekit.TrickleRequest) + handleICETrickleMutex sync.RWMutex + handleICETrickleArgsForCall []struct { + arg1 *livekit.TrickleRequest + } HandleICETrickleSDPFragmentStub func(string) error handleICETrickleSDPFragmentMutex sync.RWMutex handleICETrickleSDPFragmentArgsForCall []struct { @@ -544,11 +529,10 @@ type FakeLocalParticipant struct { handleMetricsReturnsOnCall map[int]struct { result1 error } - HandleOfferStub func(webrtc.SessionDescription, uint32) error + HandleOfferStub func(*livekit.SessionDescription) error handleOfferMutex sync.RWMutex handleOfferArgsForCall []struct { - arg1 webrtc.SessionDescription - arg2 uint32 + arg1 *livekit.SessionDescription } handleOfferReturns struct { result1 error @@ -1053,17 +1037,6 @@ type FakeLocalParticipant struct { sendRefreshTokenReturnsOnCall map[int]struct { result1 error } - SendRequestResponseStub func(*livekit.RequestResponse) error - sendRequestResponseMutex sync.RWMutex - sendRequestResponseArgsForCall []struct { - arg1 *livekit.RequestResponse - } - sendRequestResponseReturns struct { - result1 error - } - sendRequestResponseReturnsOnCall map[int]struct { - result1 error - } SendRoomMovedResponseStub func(*livekit.RoomMovedResponse) error sendRoomMovedResponseMutex sync.RWMutex sendRoomMovedResponseArgsForCall []struct { @@ -1176,12 +1149,11 @@ type FakeLocalParticipant struct { setSubscriberChannelCapacityArgsForCall []struct { arg1 int64 } - SetTrackMutedStub func(livekit.TrackID, bool, bool) *livekit.TrackInfo + SetTrackMutedStub func(*livekit.MuteTrackRequest, bool) *livekit.TrackInfo setTrackMutedMutex sync.RWMutex setTrackMutedArgsForCall []struct { - arg1 livekit.TrackID + arg1 *livekit.MuteTrackRequest arg2 bool - arg3 bool } setTrackMutedReturns struct { result1 *livekit.TrackInfo @@ -1342,6 +1314,18 @@ type FakeLocalParticipant struct { updateMediaRTTArgsForCall []struct { arg1 uint32 } + UpdateMetadataStub func(*livekit.UpdateParticipantMetadata, bool) error + updateMetadataMutex sync.RWMutex + updateMetadataArgsForCall []struct { + arg1 *livekit.UpdateParticipantMetadata + arg2 bool + } + updateMetadataReturns struct { + result1 error + } + updateMetadataReturnsOnCall map[int]struct { + result1 error + } UpdateSignalingRTTStub func(uint32) updateSignalingRTTMutex sync.RWMutex updateSignalingRTTArgsForCall []struct { @@ -1442,39 +1426,6 @@ type FakeLocalParticipant struct { invocationsMutex sync.RWMutex } -func (fake *FakeLocalParticipant) AddICECandidate(arg1 webrtc.ICECandidateInit, arg2 livekit.SignalTarget) { - fake.addICECandidateMutex.Lock() - fake.addICECandidateArgsForCall = append(fake.addICECandidateArgsForCall, struct { - arg1 webrtc.ICECandidateInit - arg2 livekit.SignalTarget - }{arg1, arg2}) - stub := fake.AddICECandidateStub - fake.recordInvocation("AddICECandidate", []interface{}{arg1, arg2}) - fake.addICECandidateMutex.Unlock() - if stub != nil { - fake.AddICECandidateStub(arg1, arg2) - } -} - -func (fake *FakeLocalParticipant) AddICECandidateCallCount() int { - fake.addICECandidateMutex.RLock() - defer fake.addICECandidateMutex.RUnlock() - return len(fake.addICECandidateArgsForCall) -} - -func (fake *FakeLocalParticipant) AddICECandidateCalls(stub func(webrtc.ICECandidateInit, livekit.SignalTarget)) { - fake.addICECandidateMutex.Lock() - defer fake.addICECandidateMutex.Unlock() - fake.AddICECandidateStub = stub -} - -func (fake *FakeLocalParticipant) AddICECandidateArgsForCall(i int) (webrtc.ICECandidateInit, livekit.SignalTarget) { - fake.addICECandidateMutex.RLock() - defer fake.addICECandidateMutex.RUnlock() - argsForCall := fake.addICECandidateArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 -} - func (fake *FakeLocalParticipant) AddTrack(arg1 *livekit.AddTrackRequest) { fake.addTrackMutex.Lock() fake.addTrackArgsForCall = append(fake.addTrackArgsForCall, struct { @@ -1950,69 +1901,6 @@ func (fake *FakeLocalParticipant) CanSubscribeReturnsOnCall(i int, result1 bool) }{result1} } -func (fake *FakeLocalParticipant) CheckMetadataLimits(arg1 string, arg2 string, arg3 map[string]string) error { - fake.checkMetadataLimitsMutex.Lock() - ret, specificReturn := fake.checkMetadataLimitsReturnsOnCall[len(fake.checkMetadataLimitsArgsForCall)] - fake.checkMetadataLimitsArgsForCall = append(fake.checkMetadataLimitsArgsForCall, struct { - arg1 string - arg2 string - arg3 map[string]string - }{arg1, arg2, arg3}) - stub := fake.CheckMetadataLimitsStub - fakeReturns := fake.checkMetadataLimitsReturns - fake.recordInvocation("CheckMetadataLimits", []interface{}{arg1, arg2, arg3}) - fake.checkMetadataLimitsMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeLocalParticipant) CheckMetadataLimitsCallCount() int { - fake.checkMetadataLimitsMutex.RLock() - defer fake.checkMetadataLimitsMutex.RUnlock() - return len(fake.checkMetadataLimitsArgsForCall) -} - -func (fake *FakeLocalParticipant) CheckMetadataLimitsCalls(stub func(string, string, map[string]string) error) { - fake.checkMetadataLimitsMutex.Lock() - defer fake.checkMetadataLimitsMutex.Unlock() - fake.CheckMetadataLimitsStub = stub -} - -func (fake *FakeLocalParticipant) CheckMetadataLimitsArgsForCall(i int) (string, string, map[string]string) { - fake.checkMetadataLimitsMutex.RLock() - defer fake.checkMetadataLimitsMutex.RUnlock() - argsForCall := fake.checkMetadataLimitsArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeLocalParticipant) CheckMetadataLimitsReturns(result1 error) { - fake.checkMetadataLimitsMutex.Lock() - defer fake.checkMetadataLimitsMutex.Unlock() - fake.CheckMetadataLimitsStub = nil - fake.checkMetadataLimitsReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeLocalParticipant) CheckMetadataLimitsReturnsOnCall(i int, result1 error) { - fake.checkMetadataLimitsMutex.Lock() - defer fake.checkMetadataLimitsMutex.Unlock() - fake.CheckMetadataLimitsStub = nil - if fake.checkMetadataLimitsReturnsOnCall == nil { - fake.checkMetadataLimitsReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.checkMetadataLimitsReturnsOnCall[i] = struct { - result1 error - }{result1} -} - func (fake *FakeLocalParticipant) ClaimGrants() *auth.ClaimGrants { fake.claimGrantsMutex.Lock() ret, specificReturn := fake.claimGrantsReturnsOnCall[len(fake.claimGrantsArgsForCall)] @@ -3904,17 +3792,16 @@ func (fake *FakeLocalParticipant) GetTrailerReturnsOnCall(i int, result1 []byte) }{result1} } -func (fake *FakeLocalParticipant) HandleAnswer(arg1 webrtc.SessionDescription, arg2 uint32) { +func (fake *FakeLocalParticipant) HandleAnswer(arg1 *livekit.SessionDescription) { fake.handleAnswerMutex.Lock() fake.handleAnswerArgsForCall = append(fake.handleAnswerArgsForCall, struct { - arg1 webrtc.SessionDescription - arg2 uint32 - }{arg1, arg2}) + arg1 *livekit.SessionDescription + }{arg1}) stub := fake.HandleAnswerStub - fake.recordInvocation("HandleAnswer", []interface{}{arg1, arg2}) + fake.recordInvocation("HandleAnswer", []interface{}{arg1}) fake.handleAnswerMutex.Unlock() if stub != nil { - fake.HandleAnswerStub(arg1, arg2) + fake.HandleAnswerStub(arg1) } } @@ -3924,17 +3811,17 @@ func (fake *FakeLocalParticipant) HandleAnswerCallCount() int { return len(fake.handleAnswerArgsForCall) } -func (fake *FakeLocalParticipant) HandleAnswerCalls(stub func(webrtc.SessionDescription, uint32)) { +func (fake *FakeLocalParticipant) HandleAnswerCalls(stub func(*livekit.SessionDescription)) { fake.handleAnswerMutex.Lock() defer fake.handleAnswerMutex.Unlock() fake.HandleAnswerStub = stub } -func (fake *FakeLocalParticipant) HandleAnswerArgsForCall(i int) (webrtc.SessionDescription, uint32) { +func (fake *FakeLocalParticipant) HandleAnswerArgsForCall(i int) *livekit.SessionDescription { fake.handleAnswerMutex.RLock() defer fake.handleAnswerMutex.RUnlock() argsForCall := fake.handleAnswerArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1 } func (fake *FakeLocalParticipant) HandleICERestartSDPFragment(arg1 string) (string, error) { @@ -4001,6 +3888,38 @@ func (fake *FakeLocalParticipant) HandleICERestartSDPFragmentReturnsOnCall(i int }{result1, result2} } +func (fake *FakeLocalParticipant) HandleICETrickle(arg1 *livekit.TrickleRequest) { + fake.handleICETrickleMutex.Lock() + fake.handleICETrickleArgsForCall = append(fake.handleICETrickleArgsForCall, struct { + arg1 *livekit.TrickleRequest + }{arg1}) + stub := fake.HandleICETrickleStub + fake.recordInvocation("HandleICETrickle", []interface{}{arg1}) + fake.handleICETrickleMutex.Unlock() + if stub != nil { + fake.HandleICETrickleStub(arg1) + } +} + +func (fake *FakeLocalParticipant) HandleICETrickleCallCount() int { + fake.handleICETrickleMutex.RLock() + defer fake.handleICETrickleMutex.RUnlock() + return len(fake.handleICETrickleArgsForCall) +} + +func (fake *FakeLocalParticipant) HandleICETrickleCalls(stub func(*livekit.TrickleRequest)) { + fake.handleICETrickleMutex.Lock() + defer fake.handleICETrickleMutex.Unlock() + fake.HandleICETrickleStub = stub +} + +func (fake *FakeLocalParticipant) HandleICETrickleArgsForCall(i int) *livekit.TrickleRequest { + fake.handleICETrickleMutex.RLock() + defer fake.handleICETrickleMutex.RUnlock() + argsForCall := fake.handleICETrickleArgsForCall[i] + return argsForCall.arg1 +} + func (fake *FakeLocalParticipant) HandleICETrickleSDPFragment(arg1 string) error { fake.handleICETrickleSDPFragmentMutex.Lock() ret, specificReturn := fake.handleICETrickleSDPFragmentReturnsOnCall[len(fake.handleICETrickleSDPFragmentArgsForCall)] @@ -4156,19 +4075,18 @@ func (fake *FakeLocalParticipant) HandleMetricsReturnsOnCall(i int, result1 erro }{result1} } -func (fake *FakeLocalParticipant) HandleOffer(arg1 webrtc.SessionDescription, arg2 uint32) error { +func (fake *FakeLocalParticipant) HandleOffer(arg1 *livekit.SessionDescription) error { fake.handleOfferMutex.Lock() ret, specificReturn := fake.handleOfferReturnsOnCall[len(fake.handleOfferArgsForCall)] fake.handleOfferArgsForCall = append(fake.handleOfferArgsForCall, struct { - arg1 webrtc.SessionDescription - arg2 uint32 - }{arg1, arg2}) + arg1 *livekit.SessionDescription + }{arg1}) stub := fake.HandleOfferStub fakeReturns := fake.handleOfferReturns - fake.recordInvocation("HandleOffer", []interface{}{arg1, arg2}) + fake.recordInvocation("HandleOffer", []interface{}{arg1}) fake.handleOfferMutex.Unlock() if stub != nil { - return stub(arg1, arg2) + return stub(arg1) } if specificReturn { return ret.result1 @@ -4182,17 +4100,17 @@ func (fake *FakeLocalParticipant) HandleOfferCallCount() int { return len(fake.handleOfferArgsForCall) } -func (fake *FakeLocalParticipant) HandleOfferCalls(stub func(webrtc.SessionDescription, uint32) error) { +func (fake *FakeLocalParticipant) HandleOfferCalls(stub func(*livekit.SessionDescription) error) { fake.handleOfferMutex.Lock() defer fake.handleOfferMutex.Unlock() fake.HandleOfferStub = stub } -func (fake *FakeLocalParticipant) HandleOfferArgsForCall(i int) (webrtc.SessionDescription, uint32) { +func (fake *FakeLocalParticipant) HandleOfferArgsForCall(i int) *livekit.SessionDescription { fake.handleOfferMutex.RLock() defer fake.handleOfferMutex.RUnlock() argsForCall := fake.handleOfferArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2 + return argsForCall.arg1 } func (fake *FakeLocalParticipant) HandleOfferReturns(result1 error) { @@ -7013,67 +6931,6 @@ func (fake *FakeLocalParticipant) SendRefreshTokenReturnsOnCall(i int, result1 e }{result1} } -func (fake *FakeLocalParticipant) SendRequestResponse(arg1 *livekit.RequestResponse) error { - fake.sendRequestResponseMutex.Lock() - ret, specificReturn := fake.sendRequestResponseReturnsOnCall[len(fake.sendRequestResponseArgsForCall)] - fake.sendRequestResponseArgsForCall = append(fake.sendRequestResponseArgsForCall, struct { - arg1 *livekit.RequestResponse - }{arg1}) - stub := fake.SendRequestResponseStub - fakeReturns := fake.sendRequestResponseReturns - fake.recordInvocation("SendRequestResponse", []interface{}{arg1}) - fake.sendRequestResponseMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeLocalParticipant) SendRequestResponseCallCount() int { - fake.sendRequestResponseMutex.RLock() - defer fake.sendRequestResponseMutex.RUnlock() - return len(fake.sendRequestResponseArgsForCall) -} - -func (fake *FakeLocalParticipant) SendRequestResponseCalls(stub func(*livekit.RequestResponse) error) { - fake.sendRequestResponseMutex.Lock() - defer fake.sendRequestResponseMutex.Unlock() - fake.SendRequestResponseStub = stub -} - -func (fake *FakeLocalParticipant) SendRequestResponseArgsForCall(i int) *livekit.RequestResponse { - fake.sendRequestResponseMutex.RLock() - defer fake.sendRequestResponseMutex.RUnlock() - argsForCall := fake.sendRequestResponseArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) SendRequestResponseReturns(result1 error) { - fake.sendRequestResponseMutex.Lock() - defer fake.sendRequestResponseMutex.Unlock() - fake.SendRequestResponseStub = nil - fake.sendRequestResponseReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeLocalParticipant) SendRequestResponseReturnsOnCall(i int, result1 error) { - fake.sendRequestResponseMutex.Lock() - defer fake.sendRequestResponseMutex.Unlock() - fake.SendRequestResponseStub = nil - if fake.sendRequestResponseReturnsOnCall == nil { - fake.sendRequestResponseReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.sendRequestResponseReturnsOnCall[i] = struct { - result1 error - }{result1} -} - func (fake *FakeLocalParticipant) SendRoomMovedResponse(arg1 *livekit.RoomMovedResponse) error { fake.sendRoomMovedResponseMutex.Lock() ret, specificReturn := fake.sendRoomMovedResponseReturnsOnCall[len(fake.sendRoomMovedResponseArgsForCall)] @@ -7726,20 +7583,19 @@ func (fake *FakeLocalParticipant) SetSubscriberChannelCapacityArgsForCall(i int) return argsForCall.arg1 } -func (fake *FakeLocalParticipant) SetTrackMuted(arg1 livekit.TrackID, arg2 bool, arg3 bool) *livekit.TrackInfo { +func (fake *FakeLocalParticipant) SetTrackMuted(arg1 *livekit.MuteTrackRequest, arg2 bool) *livekit.TrackInfo { fake.setTrackMutedMutex.Lock() ret, specificReturn := fake.setTrackMutedReturnsOnCall[len(fake.setTrackMutedArgsForCall)] fake.setTrackMutedArgsForCall = append(fake.setTrackMutedArgsForCall, struct { - arg1 livekit.TrackID + arg1 *livekit.MuteTrackRequest arg2 bool - arg3 bool - }{arg1, arg2, arg3}) + }{arg1, arg2}) stub := fake.SetTrackMutedStub fakeReturns := fake.setTrackMutedReturns - fake.recordInvocation("SetTrackMuted", []interface{}{arg1, arg2, arg3}) + fake.recordInvocation("SetTrackMuted", []interface{}{arg1, arg2}) fake.setTrackMutedMutex.Unlock() if stub != nil { - return stub(arg1, arg2, arg3) + return stub(arg1, arg2) } if specificReturn { return ret.result1 @@ -7753,17 +7609,17 @@ func (fake *FakeLocalParticipant) SetTrackMutedCallCount() int { return len(fake.setTrackMutedArgsForCall) } -func (fake *FakeLocalParticipant) SetTrackMutedCalls(stub func(livekit.TrackID, bool, bool) *livekit.TrackInfo) { +func (fake *FakeLocalParticipant) SetTrackMutedCalls(stub func(*livekit.MuteTrackRequest, bool) *livekit.TrackInfo) { fake.setTrackMutedMutex.Lock() defer fake.setTrackMutedMutex.Unlock() fake.SetTrackMutedStub = stub } -func (fake *FakeLocalParticipant) SetTrackMutedArgsForCall(i int) (livekit.TrackID, bool, bool) { +func (fake *FakeLocalParticipant) SetTrackMutedArgsForCall(i int) (*livekit.MuteTrackRequest, bool) { fake.setTrackMutedMutex.RLock() defer fake.setTrackMutedMutex.RUnlock() argsForCall := fake.setTrackMutedArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeLocalParticipant) SetTrackMutedReturns(result1 *livekit.TrackInfo) { @@ -8602,6 +8458,68 @@ func (fake *FakeLocalParticipant) UpdateMediaRTTArgsForCall(i int) uint32 { return argsForCall.arg1 } +func (fake *FakeLocalParticipant) UpdateMetadata(arg1 *livekit.UpdateParticipantMetadata, arg2 bool) error { + fake.updateMetadataMutex.Lock() + ret, specificReturn := fake.updateMetadataReturnsOnCall[len(fake.updateMetadataArgsForCall)] + fake.updateMetadataArgsForCall = append(fake.updateMetadataArgsForCall, struct { + arg1 *livekit.UpdateParticipantMetadata + arg2 bool + }{arg1, arg2}) + stub := fake.UpdateMetadataStub + fakeReturns := fake.updateMetadataReturns + fake.recordInvocation("UpdateMetadata", []interface{}{arg1, arg2}) + fake.updateMetadataMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeLocalParticipant) UpdateMetadataCallCount() int { + fake.updateMetadataMutex.RLock() + defer fake.updateMetadataMutex.RUnlock() + return len(fake.updateMetadataArgsForCall) +} + +func (fake *FakeLocalParticipant) UpdateMetadataCalls(stub func(*livekit.UpdateParticipantMetadata, bool) error) { + fake.updateMetadataMutex.Lock() + defer fake.updateMetadataMutex.Unlock() + fake.UpdateMetadataStub = stub +} + +func (fake *FakeLocalParticipant) UpdateMetadataArgsForCall(i int) (*livekit.UpdateParticipantMetadata, bool) { + fake.updateMetadataMutex.RLock() + defer fake.updateMetadataMutex.RUnlock() + argsForCall := fake.updateMetadataArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipant) UpdateMetadataReturns(result1 error) { + fake.updateMetadataMutex.Lock() + defer fake.updateMetadataMutex.Unlock() + fake.UpdateMetadataStub = nil + fake.updateMetadataReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipant) UpdateMetadataReturnsOnCall(i int, result1 error) { + fake.updateMetadataMutex.Lock() + defer fake.updateMetadataMutex.Unlock() + fake.UpdateMetadataStub = nil + if fake.updateMetadataReturnsOnCall == nil { + fake.updateMetadataReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.updateMetadataReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeLocalParticipant) UpdateSignalingRTT(arg1 uint32) { fake.updateSignalingRTTMutex.Lock() fake.updateSignalingRTTArgsForCall = append(fake.updateSignalingRTTArgsForCall, struct { diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 3901d3b78..52c269e4c 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -34,7 +34,6 @@ import ( "github.com/livekit/protocol/observability" "github.com/livekit/protocol/observability/roomobs" "github.com/livekit/protocol/rpc" - "github.com/livekit/protocol/signalling" "github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils/guid" "github.com/livekit/protocol/utils/must" @@ -577,7 +576,7 @@ func (r *RoomManager) StartSession( participant.AddTrack(addTrackRequest) } if pi.PublisherOffer != nil { - participant.HandleOffer(signalling.FromProtoSessionDescription(pi.PublisherOffer)) + participant.HandleOffer(pi.PublisherOffer) } go r.rtcSessionWorker(room, participant, requestSource) @@ -779,7 +778,10 @@ func (r *RoomManager) MutePublishedTrack(ctx context.Context, req *livekit.MuteR participant.GetLogger().Errorw("cannot unmute track, remote unmute is disabled", nil) return nil, ErrRemoteUnmuteNoteEnabled } - track := participant.SetTrackMuted(livekit.TrackID(req.TrackSid), req.Muted, true) + track := participant.SetTrackMuted(&livekit.MuteTrackRequest{ + Sid: req.TrackSid, + Muted: req.Muted, + }, true) return &livekit.MuteRoomTrackResponse{Track: track}, nil } @@ -789,28 +791,23 @@ func (r *RoomManager) UpdateParticipant(ctx context.Context, req *livekit.Update return nil, err } - participant.GetLogger().Debugw("updating participant", - "metadata", req.Metadata, - "permission", req.Permission, - "attributes", req.Attributes, - ) - if err = participant.CheckMetadataLimits(req.Name, req.Metadata, req.Attributes); err != nil { + if err = participant.UpdateMetadata(&livekit.UpdateParticipantMetadata{ + Name: req.Name, + Metadata: req.Metadata, + Attributes: req.Attributes, + }, true); err != nil { return nil, err } - if req.Name != "" { - participant.SetName(req.Name) - } - if req.Metadata != "" { - participant.SetMetadata(req.Metadata) - } - if req.Attributes != nil { - participant.SetAttributes(req.Attributes) - } - if req.Permission != nil { + participant.GetLogger().Debugw( + "updating participant permission", + "permission", req.Permission, + ) + participant.SetPermission(req.Permission) } + return participant.ToProto(), nil } diff --git a/pkg/service/roommanager_service.go b/pkg/service/roommanager_service.go index f10812f32..1e91e8bac 100644 --- a/pkg/service/roommanager_service.go +++ b/pkg/service/roommanager_service.go @@ -53,7 +53,11 @@ func (s whipService) Create(ctx context.Context, req *rpc.WHIPCreateRequest) (*r return nil, ErrParticipantNotFound } - if err := lp.HandleOffer(webrtc.SessionDescription{Type: webrtc.SDPTypeOffer, SDP: req.OfferSdp}, 0); err != nil { + if err := lp.HandleOffer(&livekit.SessionDescription{ + Type: webrtc.SDPTypeOffer.String(), + Sdp: req.OfferSdp, + Id: 0, + }); err != nil { lp.GetLogger().Errorw("whip service: could not handle offer", err) return nil, err }