subscriber control of tracks (unsubscribe/mute/quality), support simulcast (#23)
* subscription control & simulcast RTC APIs * don't remove tracks for simulcast
This commit is contained in:
@@ -89,6 +89,13 @@ func (t *DataTrack) OnClose(f func()) {
|
||||
}
|
||||
|
||||
func (t *DataTrack) AddSubscriber(participant types.Participant) error {
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
if t.subscribers[participant.ID()] != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
label := PackDataTrackLabel(t.participantId, t.ID(), t.dataChannel.Label())
|
||||
downChannel, err := participant.SubscriberPC().CreateDataChannel(label, t.dataChannelOptions())
|
||||
if err != nil {
|
||||
@@ -100,9 +107,7 @@ func (t *DataTrack) AddSubscriber(participant types.Participant) error {
|
||||
dataChannel: downChannel,
|
||||
}
|
||||
|
||||
t.lock.Lock()
|
||||
t.subscribers[participant.ID()] = sub
|
||||
t.lock.Unlock()
|
||||
|
||||
downChannel.OnClose(func() {
|
||||
t.RemoveSubscriber(sub.participantId)
|
||||
|
||||
@@ -117,9 +117,6 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
|
||||
|
||||
// don't subscribe to the same track multiple times
|
||||
if existingSt != nil {
|
||||
logger.Warnw("participant already subscribed to track",
|
||||
"sub", sub.Identity(),
|
||||
"track", t.ID())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+21
-6
@@ -265,6 +265,12 @@ func (p *ParticipantImpl) AddTrack(clientId, name string, trackType livekit.Trac
|
||||
})
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) GetPublishedTracks() []types.PublishedTrack {
|
||||
p.lock.RUnlock()
|
||||
defer p.lock.RUnlock()
|
||||
return funk.Values(p.publishedTracks).([]types.PublishedTrack)
|
||||
}
|
||||
|
||||
// handles a client answer response, with subscriber PC, server initiates the offer
|
||||
// and client answers
|
||||
func (p *ParticipantImpl) HandleAnswer(sdp webrtc.SessionDescription) error {
|
||||
@@ -455,6 +461,12 @@ func (p *ParticipantImpl) SubscriberPC() *webrtc.PeerConnection {
|
||||
return p.subscriber.pc
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) GetSubscribedTracks() []types.SubscribedTrack {
|
||||
p.lock.RLock()
|
||||
defer p.lock.RUnlock()
|
||||
return funk.Values(p.subscribedTracks).([]types.SubscribedTrack)
|
||||
}
|
||||
|
||||
// add a track to the participant's subscribed list
|
||||
func (p *ParticipantImpl) AddSubscribedTrack(pubId string, subTrack types.SubscribedTrack) {
|
||||
logger.Debugw("added subscribedTrack", "srcParticipant", pubId,
|
||||
@@ -561,9 +573,13 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
|
||||
|
||||
// when a new remoteTrack is created, creates a Track and adds it to room
|
||||
func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *webrtc.RTPReceiver) {
|
||||
logger.Debugw("mediaTrack added", "participant", p.Identity(), "remoteTrack", track.ID())
|
||||
logger.Debugw("mediaTrack added",
|
||||
"participant", p.Identity(),
|
||||
"remoteTrack", track.ID(),
|
||||
"rid", track.RID())
|
||||
|
||||
ti := p.popPendingTrack(track.ID(), ToProtoTrackKind(track.Kind()))
|
||||
// delete pending track if it's not simulcasting
|
||||
ti := p.getPendingTrack(track.ID(), ToProtoTrackKind(track.Kind()), track.RID() == "")
|
||||
if ti == nil {
|
||||
return
|
||||
}
|
||||
@@ -575,7 +591,6 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
var mt *MediaTrack
|
||||
var newTrack bool
|
||||
if trk, ok := ptrack.(*MediaTrack); ok {
|
||||
logger.Debugw("using existing mediatrack, simulcast", "rid", track.RID())
|
||||
mt = trk
|
||||
} else {
|
||||
mt = NewMediaTrack(ti.Sid, p.id, p.rtcpCh, track, p.receiverConfig, p.audioConfig)
|
||||
@@ -604,7 +619,7 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
|
||||
logger.Debugw("dataChannel added", "participant", p.Identity(), "label", dc.Label())
|
||||
|
||||
// data channels have numeric ids, so we use its label to identify
|
||||
ti := p.popPendingTrack(dc.Label(), livekit.TrackType_DATA)
|
||||
ti := p.getPendingTrack(dc.Label(), livekit.TrackType_DATA, true)
|
||||
if ti == nil {
|
||||
return
|
||||
}
|
||||
@@ -615,7 +630,7 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
|
||||
p.handleTrackPublished(dt)
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) popPendingTrack(clientId string, kind livekit.TrackType) *livekit.TrackInfo {
|
||||
func (p *ParticipantImpl) getPendingTrack(clientId string, kind livekit.TrackType, deleteAfter bool) *livekit.TrackInfo {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
ti := p.pendingTracks[clientId]
|
||||
@@ -635,7 +650,7 @@ func (p *ParticipantImpl) popPendingTrack(clientId string, kind livekit.TrackTyp
|
||||
// if still not found, we are done
|
||||
if ti == nil {
|
||||
logger.Errorw("track info not published prior to track", "clientId", clientId)
|
||||
} else {
|
||||
} else if deleteAfter {
|
||||
delete(p.pendingTracks, clientId)
|
||||
}
|
||||
return ti
|
||||
|
||||
@@ -215,6 +215,33 @@ func (r *Room) RemoveParticipant(identity string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Room) UpdateSubscriptions(participant types.Participant, subscription *livekit.UpdateSubscription) error {
|
||||
// find all matching tracks
|
||||
var tracks []types.PublishedTrack
|
||||
participants := r.GetParticipants()
|
||||
for _, p := range participants {
|
||||
for _, sid := range subscription.TrackSids {
|
||||
for _, track := range p.GetPublishedTracks() {
|
||||
if sid == track.ID() {
|
||||
tracks = append(tracks, track)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle subscription changes
|
||||
for _, track := range tracks {
|
||||
if subscription.Subscribe {
|
||||
if err := track.AddSubscriber(participant); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
track.RemoveSubscriber(participant.ID())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close the room if all participants had left, or it's still empty past timeout
|
||||
func (r *Room) CloseIfEmpty() {
|
||||
if r.isClosed.Get() {
|
||||
|
||||
@@ -2,8 +2,10 @@ package rtc
|
||||
|
||||
import (
|
||||
"github.com/pion/ion-sfu/pkg/sfu"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
"github.com/livekit/livekit-server/proto/livekit"
|
||||
)
|
||||
|
||||
type SubscribedTrack struct {
|
||||
@@ -18,6 +20,10 @@ func NewSubscribedTrack(dt *sfu.DownTrack) *SubscribedTrack {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *SubscribedTrack) ID() string {
|
||||
return t.dt.ID()
|
||||
}
|
||||
|
||||
func (t *SubscribedTrack) DownTrack() *sfu.DownTrack {
|
||||
return t.dt
|
||||
}
|
||||
@@ -38,6 +44,12 @@ func (t *SubscribedTrack) SetPublisherMuted(muted bool) {
|
||||
t.updateDownTrackMute()
|
||||
}
|
||||
|
||||
func (t *SubscribedTrack) SetVideoQuality(quality livekit.VideoQuality) {
|
||||
if t.dt.Kind() == webrtc.RTPCodecTypeVideo {
|
||||
t.dt.SwitchSpatialLayer(int64(quality), true)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *SubscribedTrack) updateDownTrackMute() {
|
||||
muted := t.subMuted.Get() || t.pubMuted.Get()
|
||||
t.dt.Mute(muted)
|
||||
|
||||
@@ -34,6 +34,8 @@ type Participant interface {
|
||||
SubscriberMediaEngine() *webrtc.MediaEngine
|
||||
|
||||
AddTrack(clientId, name string, trackType livekit.TrackType)
|
||||
GetPublishedTracks() []PublishedTrack
|
||||
GetSubscribedTracks() []SubscribedTrack
|
||||
HandleOffer(sdp webrtc.SessionDescription) (answer webrtc.SessionDescription, err error)
|
||||
HandleAnswer(sdp webrtc.SessionDescription) error
|
||||
AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) error
|
||||
@@ -82,9 +84,11 @@ type PublishedTrack interface {
|
||||
|
||||
//counterfeiter:generate . SubscribedTrack
|
||||
type SubscribedTrack interface {
|
||||
ID() string
|
||||
DownTrack() *sfu.DownTrack
|
||||
IsMuted() bool
|
||||
SetMuted(muted bool)
|
||||
SetVideoQuality(quality livekit.VideoQuality)
|
||||
SetPublisherMuted(muted bool)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,16 @@ type FakeParticipant struct {
|
||||
result1 uint8
|
||||
result2 bool
|
||||
}
|
||||
GetPublishedTracksStub func() []types.PublishedTrack
|
||||
getPublishedTracksMutex sync.RWMutex
|
||||
getPublishedTracksArgsForCall []struct {
|
||||
}
|
||||
getPublishedTracksReturns struct {
|
||||
result1 []types.PublishedTrack
|
||||
}
|
||||
getPublishedTracksReturnsOnCall map[int]struct {
|
||||
result1 []types.PublishedTrack
|
||||
}
|
||||
GetResponseSinkStub func() routing.MessageSink
|
||||
getResponseSinkMutex sync.RWMutex
|
||||
getResponseSinkArgsForCall []struct {
|
||||
@@ -80,6 +90,16 @@ type FakeParticipant struct {
|
||||
getResponseSinkReturnsOnCall map[int]struct {
|
||||
result1 routing.MessageSink
|
||||
}
|
||||
GetSubscribedTracksStub func() []types.SubscribedTrack
|
||||
getSubscribedTracksMutex sync.RWMutex
|
||||
getSubscribedTracksArgsForCall []struct {
|
||||
}
|
||||
getSubscribedTracksReturns struct {
|
||||
result1 []types.SubscribedTrack
|
||||
}
|
||||
getSubscribedTracksReturnsOnCall map[int]struct {
|
||||
result1 []types.SubscribedTrack
|
||||
}
|
||||
HandleAnswerStub func(webrtc.SessionDescription) error
|
||||
handleAnswerMutex sync.RWMutex
|
||||
handleAnswerArgsForCall []struct {
|
||||
@@ -578,6 +598,59 @@ func (fake *FakeParticipant) GetAudioLevelReturnsOnCall(i int, result1 uint8, re
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetPublishedTracks() []types.PublishedTrack {
|
||||
fake.getPublishedTracksMutex.Lock()
|
||||
ret, specificReturn := fake.getPublishedTracksReturnsOnCall[len(fake.getPublishedTracksArgsForCall)]
|
||||
fake.getPublishedTracksArgsForCall = append(fake.getPublishedTracksArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.GetPublishedTracksStub
|
||||
fakeReturns := fake.getPublishedTracksReturns
|
||||
fake.recordInvocation("GetPublishedTracks", []interface{}{})
|
||||
fake.getPublishedTracksMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetPublishedTracksCallCount() int {
|
||||
fake.getPublishedTracksMutex.RLock()
|
||||
defer fake.getPublishedTracksMutex.RUnlock()
|
||||
return len(fake.getPublishedTracksArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetPublishedTracksCalls(stub func() []types.PublishedTrack) {
|
||||
fake.getPublishedTracksMutex.Lock()
|
||||
defer fake.getPublishedTracksMutex.Unlock()
|
||||
fake.GetPublishedTracksStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetPublishedTracksReturns(result1 []types.PublishedTrack) {
|
||||
fake.getPublishedTracksMutex.Lock()
|
||||
defer fake.getPublishedTracksMutex.Unlock()
|
||||
fake.GetPublishedTracksStub = nil
|
||||
fake.getPublishedTracksReturns = struct {
|
||||
result1 []types.PublishedTrack
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetPublishedTracksReturnsOnCall(i int, result1 []types.PublishedTrack) {
|
||||
fake.getPublishedTracksMutex.Lock()
|
||||
defer fake.getPublishedTracksMutex.Unlock()
|
||||
fake.GetPublishedTracksStub = nil
|
||||
if fake.getPublishedTracksReturnsOnCall == nil {
|
||||
fake.getPublishedTracksReturnsOnCall = make(map[int]struct {
|
||||
result1 []types.PublishedTrack
|
||||
})
|
||||
}
|
||||
fake.getPublishedTracksReturnsOnCall[i] = struct {
|
||||
result1 []types.PublishedTrack
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetResponseSink() routing.MessageSink {
|
||||
fake.getResponseSinkMutex.Lock()
|
||||
ret, specificReturn := fake.getResponseSinkReturnsOnCall[len(fake.getResponseSinkArgsForCall)]
|
||||
@@ -631,6 +704,59 @@ func (fake *FakeParticipant) GetResponseSinkReturnsOnCall(i int, result1 routing
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetSubscribedTracks() []types.SubscribedTrack {
|
||||
fake.getSubscribedTracksMutex.Lock()
|
||||
ret, specificReturn := fake.getSubscribedTracksReturnsOnCall[len(fake.getSubscribedTracksArgsForCall)]
|
||||
fake.getSubscribedTracksArgsForCall = append(fake.getSubscribedTracksArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.GetSubscribedTracksStub
|
||||
fakeReturns := fake.getSubscribedTracksReturns
|
||||
fake.recordInvocation("GetSubscribedTracks", []interface{}{})
|
||||
fake.getSubscribedTracksMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetSubscribedTracksCallCount() int {
|
||||
fake.getSubscribedTracksMutex.RLock()
|
||||
defer fake.getSubscribedTracksMutex.RUnlock()
|
||||
return len(fake.getSubscribedTracksArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetSubscribedTracksCalls(stub func() []types.SubscribedTrack) {
|
||||
fake.getSubscribedTracksMutex.Lock()
|
||||
defer fake.getSubscribedTracksMutex.Unlock()
|
||||
fake.GetSubscribedTracksStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetSubscribedTracksReturns(result1 []types.SubscribedTrack) {
|
||||
fake.getSubscribedTracksMutex.Lock()
|
||||
defer fake.getSubscribedTracksMutex.Unlock()
|
||||
fake.GetSubscribedTracksStub = nil
|
||||
fake.getSubscribedTracksReturns = struct {
|
||||
result1 []types.SubscribedTrack
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) GetSubscribedTracksReturnsOnCall(i int, result1 []types.SubscribedTrack) {
|
||||
fake.getSubscribedTracksMutex.Lock()
|
||||
defer fake.getSubscribedTracksMutex.Unlock()
|
||||
fake.GetSubscribedTracksStub = nil
|
||||
if fake.getSubscribedTracksReturnsOnCall == nil {
|
||||
fake.getSubscribedTracksReturnsOnCall = make(map[int]struct {
|
||||
result1 []types.SubscribedTrack
|
||||
})
|
||||
}
|
||||
fake.getSubscribedTracksReturnsOnCall[i] = struct {
|
||||
result1 []types.SubscribedTrack
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) HandleAnswer(arg1 webrtc.SessionDescription) error {
|
||||
fake.handleAnswerMutex.Lock()
|
||||
ret, specificReturn := fake.handleAnswerReturnsOnCall[len(fake.handleAnswerArgsForCall)]
|
||||
@@ -1737,8 +1863,12 @@ func (fake *FakeParticipant) Invocations() map[string][][]interface{} {
|
||||
defer fake.closeMutex.RUnlock()
|
||||
fake.getAudioLevelMutex.RLock()
|
||||
defer fake.getAudioLevelMutex.RUnlock()
|
||||
fake.getPublishedTracksMutex.RLock()
|
||||
defer fake.getPublishedTracksMutex.RUnlock()
|
||||
fake.getResponseSinkMutex.RLock()
|
||||
defer fake.getResponseSinkMutex.RUnlock()
|
||||
fake.getSubscribedTracksMutex.RLock()
|
||||
defer fake.getSubscribedTracksMutex.RUnlock()
|
||||
fake.handleAnswerMutex.RLock()
|
||||
defer fake.handleAnswerMutex.RUnlock()
|
||||
fake.handleOfferMutex.RLock()
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/proto/livekit"
|
||||
"github.com/pion/ion-sfu/pkg/sfu"
|
||||
)
|
||||
|
||||
@@ -19,6 +20,16 @@ type FakeSubscribedTrack struct {
|
||||
downTrackReturnsOnCall map[int]struct {
|
||||
result1 *sfu.DownTrack
|
||||
}
|
||||
IDStub func() string
|
||||
iDMutex sync.RWMutex
|
||||
iDArgsForCall []struct {
|
||||
}
|
||||
iDReturns struct {
|
||||
result1 string
|
||||
}
|
||||
iDReturnsOnCall map[int]struct {
|
||||
result1 string
|
||||
}
|
||||
IsMutedStub func() bool
|
||||
isMutedMutex sync.RWMutex
|
||||
isMutedArgsForCall []struct {
|
||||
@@ -39,6 +50,11 @@ type FakeSubscribedTrack struct {
|
||||
setPublisherMutedArgsForCall []struct {
|
||||
arg1 bool
|
||||
}
|
||||
SetVideoQualityStub func(livekit.VideoQuality)
|
||||
setVideoQualityMutex sync.RWMutex
|
||||
setVideoQualityArgsForCall []struct {
|
||||
arg1 livekit.VideoQuality
|
||||
}
|
||||
invocations map[string][][]interface{}
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
@@ -96,6 +112,59 @@ func (fake *FakeSubscribedTrack) DownTrackReturnsOnCall(i int, result1 *sfu.Down
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) ID() string {
|
||||
fake.iDMutex.Lock()
|
||||
ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)]
|
||||
fake.iDArgsForCall = append(fake.iDArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.IDStub
|
||||
fakeReturns := fake.iDReturns
|
||||
fake.recordInvocation("ID", []interface{}{})
|
||||
fake.iDMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) IDCallCount() int {
|
||||
fake.iDMutex.RLock()
|
||||
defer fake.iDMutex.RUnlock()
|
||||
return len(fake.iDArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) IDCalls(stub func() string) {
|
||||
fake.iDMutex.Lock()
|
||||
defer fake.iDMutex.Unlock()
|
||||
fake.IDStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) IDReturns(result1 string) {
|
||||
fake.iDMutex.Lock()
|
||||
defer fake.iDMutex.Unlock()
|
||||
fake.IDStub = nil
|
||||
fake.iDReturns = struct {
|
||||
result1 string
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) IDReturnsOnCall(i int, result1 string) {
|
||||
fake.iDMutex.Lock()
|
||||
defer fake.iDMutex.Unlock()
|
||||
fake.IDStub = nil
|
||||
if fake.iDReturnsOnCall == nil {
|
||||
fake.iDReturnsOnCall = make(map[int]struct {
|
||||
result1 string
|
||||
})
|
||||
}
|
||||
fake.iDReturnsOnCall[i] = struct {
|
||||
result1 string
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) IsMuted() bool {
|
||||
fake.isMutedMutex.Lock()
|
||||
ret, specificReturn := fake.isMutedReturnsOnCall[len(fake.isMutedArgsForCall)]
|
||||
@@ -213,17 +282,53 @@ func (fake *FakeSubscribedTrack) SetPublisherMutedArgsForCall(i int) bool {
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) SetVideoQuality(arg1 livekit.VideoQuality) {
|
||||
fake.setVideoQualityMutex.Lock()
|
||||
fake.setVideoQualityArgsForCall = append(fake.setVideoQualityArgsForCall, struct {
|
||||
arg1 livekit.VideoQuality
|
||||
}{arg1})
|
||||
stub := fake.SetVideoQualityStub
|
||||
fake.recordInvocation("SetVideoQuality", []interface{}{arg1})
|
||||
fake.setVideoQualityMutex.Unlock()
|
||||
if stub != nil {
|
||||
fake.SetVideoQualityStub(arg1)
|
||||
}
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) SetVideoQualityCallCount() int {
|
||||
fake.setVideoQualityMutex.RLock()
|
||||
defer fake.setVideoQualityMutex.RUnlock()
|
||||
return len(fake.setVideoQualityArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) SetVideoQualityCalls(stub func(livekit.VideoQuality)) {
|
||||
fake.setVideoQualityMutex.Lock()
|
||||
defer fake.setVideoQualityMutex.Unlock()
|
||||
fake.SetVideoQualityStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) SetVideoQualityArgsForCall(i int) livekit.VideoQuality {
|
||||
fake.setVideoQualityMutex.RLock()
|
||||
defer fake.setVideoQualityMutex.RUnlock()
|
||||
argsForCall := fake.setVideoQualityArgsForCall[i]
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *FakeSubscribedTrack) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.downTrackMutex.RLock()
|
||||
defer fake.downTrackMutex.RUnlock()
|
||||
fake.iDMutex.RLock()
|
||||
defer fake.iDMutex.RUnlock()
|
||||
fake.isMutedMutex.RLock()
|
||||
defer fake.isMutedMutex.RUnlock()
|
||||
fake.setMutedMutex.RLock()
|
||||
defer fake.setMutedMutex.RUnlock()
|
||||
fake.setPublisherMutedMutex.RLock()
|
||||
defer fake.setPublisherMutedMutex.RUnlock()
|
||||
fake.setVideoQualityMutex.RLock()
|
||||
defer fake.setVideoQualityMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
for key, value := range fake.invocations {
|
||||
copiedInvocations[key] = value
|
||||
|
||||
@@ -302,6 +302,18 @@ func (r *RoomManager) rtcSessionWorker(room *rtc.Room, participant types.Partici
|
||||
}
|
||||
case *livekit.SignalRequest_Mute:
|
||||
participant.SetTrackMuted(msg.Mute.Sid, msg.Mute.Muted)
|
||||
case *livekit.SignalRequest_Subscription:
|
||||
room.UpdateSubscriptions(participant, msg.Subscription)
|
||||
case *livekit.SignalRequest_TrackSetting:
|
||||
for _, subTrack := range participant.GetSubscribedTracks() {
|
||||
for _, sid := range msg.TrackSetting.TrackSids {
|
||||
if subTrack.ID() != sid {
|
||||
continue
|
||||
}
|
||||
subTrack.SetMuted(msg.TrackSetting.Mute)
|
||||
subTrack.SetVideoQuality(msg.TrackSetting.Quality)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user