add psrpc room service (#2171)

* add psrpc room service

* update deps

* disable by default

* feedback

* config

* test
This commit is contained in:
Paul Wells
2023-10-22 22:49:38 -07:00
committed by GitHub
parent 08997c96b0
commit 325e5ca753
17 changed files with 401 additions and 143 deletions
+1
View File
@@ -27,6 +27,7 @@ var (
ErrEmptyIdentity = errors.New("participant identity cannot be empty")
ErrEmptyParticipantID = errors.New("participant ID cannot be empty")
ErrMissingGrants = errors.New("VideoGrant is missing")
ErrInternalError = errors.New("internal error")
// Track subscription related
ErrNoTrackPermission = errors.New("participant is not allowed to subscribe to this track")
+2 -1
View File
@@ -64,8 +64,9 @@ func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro
}
}
p.SetTrackMutedCalls(func(sid livekit.TrackID, muted bool, fromServer bool) {
p.SetTrackMutedCalls(func(sid livekit.TrackID, muted bool, fromServer bool) *livekit.TrackInfo {
updateTrack()
return nil
})
p.AddTrackCalls(func(req *livekit.AddTrackRequest) {
updateTrack()
+5 -3
View File
@@ -1670,16 +1670,16 @@ func (p *ParticipantImpl) sendTrackPublished(cid string, ti *livekit.TrackInfo)
})
}
func (p *ParticipantImpl) SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool) {
func (p *ParticipantImpl) SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool) *livekit.TrackInfo {
// when request is coming from admin, send message to current participant
if fromAdmin {
p.sendTrackMuted(trackID, muted)
}
p.setTrackMuted(trackID, muted)
return p.setTrackMuted(trackID, muted)
}
func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) {
func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) *livekit.TrackInfo {
p.dirty.Store(true)
p.supervisor.SetPublicationMute(trackID, muted)
@@ -1713,6 +1713,8 @@ func (p *ParticipantImpl) setTrackMuted(trackID livekit.TrackID, muted bool) {
if !isPending && track == nil {
p.pubLogger.Warnw("could not locate track", nil, "trackID", trackID)
}
return trackInfo
}
func (p *ParticipantImpl) mediaTrackReceived(track *webrtc.TrackRemote, rtpReceiver *webrtc.RTPReceiver) (*MediaTrack, bool) {
+5 -2
View File
@@ -87,6 +87,7 @@ const (
ParticipantCloseReasonVerifyFailed
ParticipantCloseReasonJoinFailed
ParticipantCloseReasonJoinTimeout
ParticipantCloseReasonMessageBusFailed
ParticipantCloseReasonStateDisconnected
ParticipantCloseReasonPeerConnectionDisconnected
ParticipantCloseReasonDuplicateIdentity
@@ -119,6 +120,8 @@ func (p ParticipantCloseReason) String() string {
return "JOIN_FAILED"
case ParticipantCloseReasonJoinTimeout:
return "JOIN_TIMEOUT"
case ParticipantCloseReasonMessageBusFailed:
return "MESSAGE_BUS_FAILED"
case ParticipantCloseReasonStateDisconnected:
return "STATE_DISCONNECTED"
case ParticipantCloseReasonPeerConnectionDisconnected:
@@ -162,7 +165,7 @@ func (p ParticipantCloseReason) ToDisconnectReason() livekit.DisconnectReason {
return livekit.DisconnectReason_CLIENT_INITIATED
case ParticipantCloseReasonRoomManagerStop:
return livekit.DisconnectReason_SERVER_SHUTDOWN
case ParticipantCloseReasonVerifyFailed, ParticipantCloseReasonJoinFailed, ParticipantCloseReasonJoinTimeout:
case ParticipantCloseReasonVerifyFailed, ParticipantCloseReasonJoinFailed, ParticipantCloseReasonJoinTimeout, ParticipantCloseReasonMessageBusFailed:
// expected to be connected but is not
return livekit.DisconnectReason_JOIN_FAILURE
case ParticipantCloseReasonPeerConnectionDisconnected:
@@ -335,7 +338,7 @@ type LocalParticipant interface {
AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget)
HandleOffer(sdp webrtc.SessionDescription)
AddTrack(req *livekit.AddTrackRequest)
SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool)
SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool) *livekit.TrackInfo
HandleAnswer(sdp webrtc.SessionDescription)
Negotiate(force bool)
@@ -738,13 +738,19 @@ type FakeLocalParticipant struct {
setSubscriberChannelCapacityArgsForCall []struct {
arg1 int64
}
SetTrackMutedStub func(livekit.TrackID, bool, bool)
SetTrackMutedStub func(livekit.TrackID, bool, bool) *livekit.TrackInfo
setTrackMutedMutex sync.RWMutex
setTrackMutedArgsForCall []struct {
arg1 livekit.TrackID
arg2 bool
arg3 bool
}
setTrackMutedReturns struct {
result1 *livekit.TrackInfo
}
setTrackMutedReturnsOnCall map[int]struct {
result1 *livekit.TrackInfo
}
StartStub func()
startMutex sync.RWMutex
startArgsForCall []struct {
@@ -4877,19 +4883,25 @@ func (fake *FakeLocalParticipant) SetSubscriberChannelCapacityArgsForCall(i int)
return argsForCall.arg1
}
func (fake *FakeLocalParticipant) SetTrackMuted(arg1 livekit.TrackID, arg2 bool, arg3 bool) {
func (fake *FakeLocalParticipant) SetTrackMuted(arg1 livekit.TrackID, arg2 bool, arg3 bool) *livekit.TrackInfo {
fake.setTrackMutedMutex.Lock()
ret, specificReturn := fake.setTrackMutedReturnsOnCall[len(fake.setTrackMutedArgsForCall)]
fake.setTrackMutedArgsForCall = append(fake.setTrackMutedArgsForCall, struct {
arg1 livekit.TrackID
arg2 bool
arg3 bool
}{arg1, arg2, arg3})
stub := fake.SetTrackMutedStub
fakeReturns := fake.setTrackMutedReturns
fake.recordInvocation("SetTrackMuted", []interface{}{arg1, arg2, arg3})
fake.setTrackMutedMutex.Unlock()
if stub != nil {
fake.SetTrackMutedStub(arg1, arg2, arg3)
return stub(arg1, arg2, arg3)
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *FakeLocalParticipant) SetTrackMutedCallCount() int {
@@ -4898,7 +4910,7 @@ func (fake *FakeLocalParticipant) SetTrackMutedCallCount() int {
return len(fake.setTrackMutedArgsForCall)
}
func (fake *FakeLocalParticipant) SetTrackMutedCalls(stub func(livekit.TrackID, bool, bool)) {
func (fake *FakeLocalParticipant) SetTrackMutedCalls(stub func(livekit.TrackID, bool, bool) *livekit.TrackInfo) {
fake.setTrackMutedMutex.Lock()
defer fake.setTrackMutedMutex.Unlock()
fake.SetTrackMutedStub = stub
@@ -4911,6 +4923,29 @@ func (fake *FakeLocalParticipant) SetTrackMutedArgsForCall(i int) (livekit.Track
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
}
func (fake *FakeLocalParticipant) SetTrackMutedReturns(result1 *livekit.TrackInfo) {
fake.setTrackMutedMutex.Lock()
defer fake.setTrackMutedMutex.Unlock()
fake.SetTrackMutedStub = nil
fake.setTrackMutedReturns = struct {
result1 *livekit.TrackInfo
}{result1}
}
func (fake *FakeLocalParticipant) SetTrackMutedReturnsOnCall(i int, result1 *livekit.TrackInfo) {
fake.setTrackMutedMutex.Lock()
defer fake.setTrackMutedMutex.Unlock()
fake.SetTrackMutedStub = nil
if fake.setTrackMutedReturnsOnCall == nil {
fake.setTrackMutedReturnsOnCall = make(map[int]struct {
result1 *livekit.TrackInfo
})
}
fake.setTrackMutedReturnsOnCall[i] = struct {
result1 *livekit.TrackInfo
}{result1}
}
func (fake *FakeLocalParticipant) Start() {
fake.startMutex.Lock()
fake.startArgsForCall = append(fake.startArgsForCall, struct {