Interface updates (#194)
* update interfaces, a bit of cleaning * regenerate * return interface for RoomService * export packetBufferSize * update router interface * move participant key into router * change locks back * read only room store * fix server rm locks * update SendJoinResponse * clean up imports * update room messaging * regenerate
This commit is contained in:
+3
-3
@@ -4,12 +4,12 @@ import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
serverlogger "github.com/livekit/livekit-server/pkg/logger"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -28,7 +28,7 @@ type WebRTCConfig struct {
|
||||
}
|
||||
|
||||
type ReceiverConfig struct {
|
||||
packetBufferSize int
|
||||
PacketBufferSize int
|
||||
maxBitrate uint64
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
||||
Configuration: c,
|
||||
SettingEngine: s,
|
||||
Receiver: ReceiverConfig{
|
||||
packetBufferSize: rtcConf.PacketBufferSize,
|
||||
PacketBufferSize: rtcConf.PacketBufferSize,
|
||||
maxBitrate: rtcConf.MaxBitrate,
|
||||
},
|
||||
UDPMux: udpMux,
|
||||
|
||||
@@ -187,7 +187,7 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
|
||||
Channels: codec.Channels,
|
||||
SDPFmtpLine: codec.SDPFmtpLine,
|
||||
RTCPFeedback: feedbackTypes,
|
||||
}, receiver, t.params.BufferFactory, sub.ID(), t.params.ReceiverConfig.packetBufferSize)
|
||||
}, receiver, t.params.BufferFactory, sub.ID(), t.params.ReceiverConfig.PacketBufferSize)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -504,14 +504,14 @@ func (p *ParticipantImpl) RemoveSubscriber(participantId string) {
|
||||
|
||||
// signal connection methods
|
||||
|
||||
func (p *ParticipantImpl) SendJoinResponse(roomInfo *livekit.Room, otherParticipants []types.Participant, iceServers []*livekit.ICEServer) error {
|
||||
func (p *ParticipantImpl) SendJoinResponse(roomInfo *livekit.Room, otherParticipants []*livekit.ParticipantInfo, iceServers []*livekit.ICEServer) error {
|
||||
// send Join response
|
||||
return p.writeMessage(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_Join{
|
||||
Join: &livekit.JoinResponse{
|
||||
Room: roomInfo,
|
||||
Participant: p.ToProto(),
|
||||
OtherParticipants: ToProtoParticipants(otherParticipants),
|
||||
OtherParticipants: otherParticipants,
|
||||
ServerVersion: version.Version,
|
||||
IceServers: iceServers,
|
||||
// indicates both server and client support subscriber as primary
|
||||
|
||||
+11
-11
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/protocol/logger"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -16,6 +15,7 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
)
|
||||
@@ -27,10 +27,15 @@ const (
|
||||
)
|
||||
|
||||
type Room struct {
|
||||
lock sync.RWMutex
|
||||
|
||||
Room *livekit.Room
|
||||
Logger logger.Logger
|
||||
config WebRTCConfig
|
||||
lock sync.RWMutex
|
||||
|
||||
config WebRTCConfig
|
||||
audioConfig *config.AudioConfig
|
||||
telemetry *telemetry.TelemetryService
|
||||
|
||||
// map of identity -> Participant
|
||||
participants map[string]types.Participant
|
||||
participantOpts map[string]*ParticipantOptions
|
||||
@@ -43,11 +48,6 @@ type Room struct {
|
||||
closed chan struct{}
|
||||
closeOnce sync.Once
|
||||
|
||||
// for active speaker updates
|
||||
audioConfig *config.AudioConfig
|
||||
|
||||
telemetry *telemetry.TelemetryService
|
||||
|
||||
onParticipantChanged func(p types.Participant)
|
||||
onMetadataUpdate func(metadata string)
|
||||
onClose func()
|
||||
@@ -66,7 +66,7 @@ func NewRoom(room *livekit.Room, config WebRTCConfig, audioConfig *config.AudioC
|
||||
telemetry: telemetry,
|
||||
participants: make(map[string]types.Participant),
|
||||
participantOpts: make(map[string]*ParticipantOptions),
|
||||
bufferFactory: buffer.NewBufferFactory(config.Receiver.packetBufferSize, logr.Logger{}),
|
||||
bufferFactory: buffer.NewBufferFactory(config.Receiver.PacketBufferSize, logr.Logger{}),
|
||||
closed: make(chan struct{}),
|
||||
}
|
||||
if r.Room.EmptyTimeout == 0 {
|
||||
@@ -199,10 +199,10 @@ func (r *Room) Join(participant types.Participant, opts *ParticipantOptions, ice
|
||||
r.participantOpts[participant.Identity()] = opts
|
||||
|
||||
// gather other participants and send join response
|
||||
otherParticipants := make([]types.Participant, 0, len(r.participants))
|
||||
otherParticipants := make([]*livekit.ParticipantInfo, 0, len(r.participants))
|
||||
for _, p := range r.participants {
|
||||
if p.ID() != participant.ID() && !p.Hidden() {
|
||||
otherParticipants = append(otherParticipants, p)
|
||||
otherParticipants = append(otherParticipants, p.ToProto())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package types
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
livekit "github.com/livekit/protocol/proto"
|
||||
"github.com/livekit/livekit-server/pkg/sfu"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
|
||||
@@ -48,7 +48,7 @@ type Participant interface {
|
||||
AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) error
|
||||
AddSubscriber(op Participant) (int, error)
|
||||
RemoveSubscriber(peerId string)
|
||||
SendJoinResponse(info *livekit.Room, otherParticipants []Participant, iceServers []*livekit.ICEServer) error
|
||||
SendJoinResponse(info *livekit.Room, otherParticipants []*livekit.ParticipantInfo, iceServers []*livekit.ICEServer) error
|
||||
SendParticipantUpdate(participants []*livekit.ParticipantInfo, updatedAt time.Time) error
|
||||
SendSpeakerUpdate(speakers []*livekit.SpeakerInfo) error
|
||||
SendDataPacket(packet *livekit.DataPacket) error
|
||||
|
||||
@@ -363,11 +363,11 @@ type FakeParticipant struct {
|
||||
sendDataPacketReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
SendJoinResponseStub func(*livekit.Room, []types.Participant, []*livekit.ICEServer) error
|
||||
SendJoinResponseStub func(*livekit.Room, []*livekit.ParticipantInfo, []*livekit.ICEServer) error
|
||||
sendJoinResponseMutex sync.RWMutex
|
||||
sendJoinResponseArgsForCall []struct {
|
||||
arg1 *livekit.Room
|
||||
arg2 []types.Participant
|
||||
arg2 []*livekit.ParticipantInfo
|
||||
arg3 []*livekit.ICEServer
|
||||
}
|
||||
sendJoinResponseReturns struct {
|
||||
@@ -2390,10 +2390,10 @@ func (fake *FakeParticipant) SendDataPacketReturnsOnCall(i int, result1 error) {
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SendJoinResponse(arg1 *livekit.Room, arg2 []types.Participant, arg3 []*livekit.ICEServer) error {
|
||||
var arg2Copy []types.Participant
|
||||
func (fake *FakeParticipant) SendJoinResponse(arg1 *livekit.Room, arg2 []*livekit.ParticipantInfo, arg3 []*livekit.ICEServer) error {
|
||||
var arg2Copy []*livekit.ParticipantInfo
|
||||
if arg2 != nil {
|
||||
arg2Copy = make([]types.Participant, len(arg2))
|
||||
arg2Copy = make([]*livekit.ParticipantInfo, len(arg2))
|
||||
copy(arg2Copy, arg2)
|
||||
}
|
||||
var arg3Copy []*livekit.ICEServer
|
||||
@@ -2405,7 +2405,7 @@ func (fake *FakeParticipant) SendJoinResponse(arg1 *livekit.Room, arg2 []types.P
|
||||
ret, specificReturn := fake.sendJoinResponseReturnsOnCall[len(fake.sendJoinResponseArgsForCall)]
|
||||
fake.sendJoinResponseArgsForCall = append(fake.sendJoinResponseArgsForCall, struct {
|
||||
arg1 *livekit.Room
|
||||
arg2 []types.Participant
|
||||
arg2 []*livekit.ParticipantInfo
|
||||
arg3 []*livekit.ICEServer
|
||||
}{arg1, arg2Copy, arg3Copy})
|
||||
stub := fake.SendJoinResponseStub
|
||||
@@ -2427,13 +2427,13 @@ func (fake *FakeParticipant) SendJoinResponseCallCount() int {
|
||||
return len(fake.sendJoinResponseArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SendJoinResponseCalls(stub func(*livekit.Room, []types.Participant, []*livekit.ICEServer) error) {
|
||||
func (fake *FakeParticipant) SendJoinResponseCalls(stub func(*livekit.Room, []*livekit.ParticipantInfo, []*livekit.ICEServer) error) {
|
||||
fake.sendJoinResponseMutex.Lock()
|
||||
defer fake.sendJoinResponseMutex.Unlock()
|
||||
fake.SendJoinResponseStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeParticipant) SendJoinResponseArgsForCall(i int) (*livekit.Room, []types.Participant, []*livekit.ICEServer) {
|
||||
func (fake *FakeParticipant) SendJoinResponseArgsForCall(i int) (*livekit.Room, []*livekit.ParticipantInfo, []*livekit.ICEServer) {
|
||||
fake.sendJoinResponseMutex.RLock()
|
||||
defer fake.sendJoinResponseMutex.RUnlock()
|
||||
argsForCall := fake.sendJoinResponseArgsForCall[i]
|
||||
|
||||
Reference in New Issue
Block a user