Allow subscription requests made from server APIs (#249)

This commit is contained in:
David Zhao
2021-12-10 11:51:03 -08:00
committed by GitHub
parent e7b50a79fe
commit 882f3bdde5
3 changed files with 12 additions and 11 deletions
-4
View File
@@ -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
View File
@@ -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()
+11 -2
View File
@@ -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(),