ActiveRecording (#234)
* ActiveRecording * regenerate * update to 0.10.3 * 1.17
This commit is contained in:
@@ -9,8 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/livekit/livekit-server/pkg/sfu"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/twcc"
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"github.com/livekit/protocol/utils"
|
||||
@@ -19,6 +17,9 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/twcc"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
@@ -43,6 +44,7 @@ type ParticipantParams struct {
|
||||
ThrottleConfig config.PLIThrottleConfig
|
||||
EnabledCodecs []*livekit.Codec
|
||||
Hidden bool
|
||||
Recorder bool
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
@@ -235,6 +237,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
|
||||
State: p.State(),
|
||||
JoinedAt: p.ConnectedAt().Unix(),
|
||||
Hidden: p.Hidden(),
|
||||
Recorder: p.IsRecorder(),
|
||||
}
|
||||
|
||||
p.lock.RLock()
|
||||
@@ -758,6 +761,10 @@ func (p *ParticipantImpl) Hidden() bool {
|
||||
return p.params.Hidden
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) IsRecorder() bool {
|
||||
return p.params.Recorder
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) SubscriberAsPrimary() bool {
|
||||
return p.ProtocolVersion().SubscriberAsPrimary() && p.CanSubscribe()
|
||||
}
|
||||
|
||||
+31
-5
@@ -198,6 +198,11 @@ func (r *Room) Join(participant types.Participant, opts *ParticipantOptions, ice
|
||||
"room", r.Room.Name,
|
||||
"roomID", r.Room.Sid)
|
||||
|
||||
if participant.IsRecorder() && !r.Room.ActiveRecording {
|
||||
r.Room.ActiveRecording = true
|
||||
r.sendRoomUpdateLocked()
|
||||
}
|
||||
|
||||
r.participants[participant.Identity()] = participant
|
||||
r.participantOpts[participant.Identity()] = opts
|
||||
|
||||
@@ -264,7 +269,22 @@ func (r *Room) RemoveParticipant(identity string) {
|
||||
}
|
||||
}
|
||||
|
||||
activeRecording := false
|
||||
if (p != nil && p.IsRecorder()) || p == nil && r.Room.ActiveRecording {
|
||||
for _, op := range r.participants {
|
||||
if op.IsRecorder() {
|
||||
activeRecording = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if r.Room.ActiveRecording != activeRecording {
|
||||
r.Room.ActiveRecording = activeRecording
|
||||
r.sendRoomUpdateLocked()
|
||||
}
|
||||
r.lock.Unlock()
|
||||
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
@@ -402,8 +422,18 @@ func (r *Room) SendDataPacket(up *livekit.UserPacket, kind livekit.DataPacket_Ki
|
||||
func (r *Room) SetMetadata(metadata string) {
|
||||
r.Room.Metadata = metadata
|
||||
|
||||
r.lock.RLock()
|
||||
r.sendRoomUpdateLocked()
|
||||
r.lock.RUnlock()
|
||||
|
||||
if r.onMetadataUpdate != nil {
|
||||
r.onMetadataUpdate(metadata)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Room) sendRoomUpdateLocked() {
|
||||
// Send update to participants
|
||||
for _, p := range r.GetParticipants() {
|
||||
for _, p := range r.participants {
|
||||
if !p.IsReady() {
|
||||
continue
|
||||
}
|
||||
@@ -413,10 +443,6 @@ func (r *Room) SetMetadata(metadata string) {
|
||||
r.Logger.Warnw("failed to send room update", err, "room", r.Room.Name, "participant", p.Identity())
|
||||
}
|
||||
}
|
||||
|
||||
if r.onMetadataUpdate != nil {
|
||||
r.onMetadataUpdate(metadata)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Room) OnMetadataUpdate(f func(metadata string)) {
|
||||
|
||||
@@ -67,6 +67,7 @@ type Participant interface {
|
||||
CanSubscribe() bool
|
||||
CanPublishData() bool
|
||||
Hidden() bool
|
||||
IsRecorder() bool
|
||||
SubscriberAsPrimary() bool
|
||||
|
||||
Start()
|
||||
|
||||
@@ -266,6 +266,16 @@ type FakeParticipant struct {
|
||||
isReadyReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
}
|
||||
IsRecorderStub func() bool
|
||||
isRecorderMutex sync.RWMutex
|
||||
isRecorderArgsForCall []struct {
|
||||
}
|
||||
isRecorderReturns struct {
|
||||
result1 bool
|
||||
}
|
||||
isRecorderReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
}
|
||||
IsSubscribedToStub func(string) bool
|
||||
isSubscribedToMutex sync.RWMutex
|
||||
isSubscribedToArgsForCall []struct {
|
||||
@@ -1831,6 +1841,59 @@ func (fake *FakeParticipant) IsReadyReturnsOnCall(i int, result1 bool) {
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) IsRecorder() bool {
|
||||
fake.isRecorderMutex.Lock()
|
||||
ret, specificReturn := fake.isRecorderReturnsOnCall[len(fake.isRecorderArgsForCall)]
|
||||
fake.isRecorderArgsForCall = append(fake.isRecorderArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.IsRecorderStub
|
||||
fakeReturns := fake.isRecorderReturns
|
||||
fake.recordInvocation("IsRecorder", []interface{}{})
|
||||
fake.isRecorderMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) IsRecorderCallCount() int {
|
||||
fake.isRecorderMutex.RLock()
|
||||
defer fake.isRecorderMutex.RUnlock()
|
||||
return len(fake.isRecorderArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) IsRecorderCalls(stub func() bool) {
|
||||
fake.isRecorderMutex.Lock()
|
||||
defer fake.isRecorderMutex.Unlock()
|
||||
fake.IsRecorderStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) IsRecorderReturns(result1 bool) {
|
||||
fake.isRecorderMutex.Lock()
|
||||
defer fake.isRecorderMutex.Unlock()
|
||||
fake.IsRecorderStub = nil
|
||||
fake.isRecorderReturns = struct {
|
||||
result1 bool
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) IsRecorderReturnsOnCall(i int, result1 bool) {
|
||||
fake.isRecorderMutex.Lock()
|
||||
defer fake.isRecorderMutex.Unlock()
|
||||
fake.IsRecorderStub = nil
|
||||
if fake.isRecorderReturnsOnCall == nil {
|
||||
fake.isRecorderReturnsOnCall = make(map[int]struct {
|
||||
result1 bool
|
||||
})
|
||||
}
|
||||
fake.isRecorderReturnsOnCall[i] = struct {
|
||||
result1 bool
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) IsSubscribedTo(arg1 string) bool {
|
||||
fake.isSubscribedToMutex.Lock()
|
||||
ret, specificReturn := fake.isSubscribedToReturnsOnCall[len(fake.isSubscribedToArgsForCall)]
|
||||
@@ -3139,6 +3202,8 @@ func (fake *FakeParticipant) Invocations() map[string][][]interface{} {
|
||||
defer fake.identityMutex.RUnlock()
|
||||
fake.isReadyMutex.RLock()
|
||||
defer fake.isReadyMutex.RUnlock()
|
||||
fake.isRecorderMutex.RLock()
|
||||
defer fake.isRecorderMutex.RUnlock()
|
||||
fake.isSubscribedToMutex.RLock()
|
||||
defer fake.isSubscribedToMutex.RUnlock()
|
||||
fake.negotiateMutex.RLock()
|
||||
|
||||
Reference in New Issue
Block a user