mirror of
https://github.com/livekit/livekit.git
synced 2026-04-30 03:45:52 +00:00
Allow subscription requests made from server APIs (#249)
This commit is contained in:
@@ -160,10 +160,6 @@ func (t *MediaTrack) PublishLossPercentage() uint32 {
|
||||
|
||||
// AddSubscriber subscribes sub to current mediaTrack
|
||||
func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
|
||||
if !sub.CanSubscribe() {
|
||||
return ErrPermissionDenied
|
||||
}
|
||||
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
|
||||
+1
-5
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/livekit"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
@@ -316,10 +316,6 @@ func (r *Room) RemoveParticipant(identity string) {
|
||||
}
|
||||
|
||||
func (r *Room) UpdateSubscriptions(participant types.Participant, trackIds []string, subscribe bool) error {
|
||||
if !participant.CanSubscribe() {
|
||||
return ErrCannotSubscribe
|
||||
}
|
||||
|
||||
// find all matching tracks
|
||||
var tracks []types.PublishedTrack
|
||||
participants := r.GetParticipants()
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/livekit"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
@@ -421,7 +421,16 @@ func (r *RoomManager) handleSignalRequest(room *rtc.Room, participant types.Part
|
||||
case *livekit.SignalRequest_Mute:
|
||||
participant.SetTrackMuted(msg.Mute.Sid, msg.Mute.Muted, false)
|
||||
case *livekit.SignalRequest_Subscription:
|
||||
if err := room.UpdateSubscriptions(participant, msg.Subscription.TrackSids, msg.Subscription.Subscribe); err != nil {
|
||||
var err error
|
||||
if participant.CanSubscribe() {
|
||||
updateErr := room.UpdateSubscriptions(participant, msg.Subscription.TrackSids, msg.Subscription.Subscribe)
|
||||
if updateErr != nil {
|
||||
err = updateErr
|
||||
}
|
||||
} else {
|
||||
err = rtc.ErrCannotSubscribe
|
||||
}
|
||||
if err != nil {
|
||||
logger.Warnw("could not update subscription", err,
|
||||
"room", room.Room.Name,
|
||||
"participant", participant.Identity(),
|
||||
|
||||
Reference in New Issue
Block a user