Delete v2 signalling (#3835)
* Delete v2 signalling * deps * mage generate * deelte unused file
This commit is contained in:
+34
-70
@@ -54,7 +54,6 @@ import (
|
||||
"github.com/livekit/livekit-server/pkg/sfu"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/connectionquality"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/datachannel"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/mime"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/pacer"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/streamallocator"
|
||||
@@ -201,7 +200,6 @@ type ParticipantParams struct {
|
||||
DisableSenderReportPassThrough bool
|
||||
MetricConfig metric.MetricConfig
|
||||
UseOneShotSignallingMode bool
|
||||
SynchronousLocalCandidatesMode bool
|
||||
EnableMetrics bool
|
||||
DataChannelMaxBufferedAmount uint64
|
||||
DatachannelSlowThreshold int
|
||||
@@ -1781,23 +1779,6 @@ func (h PublisherTransportHandler) OnDataMessageUnlabeled(data []byte) {
|
||||
h.p.onReceivedDataMessageUnlabeled(data)
|
||||
}
|
||||
|
||||
func (h PublisherTransportHandler) OnDataChannelOpenSignalling(dc *datachannel.DataChannelWriter[*webrtc.DataChannel]) {
|
||||
sink := signalling.NewDataChannelMessageSink(signalling.DataChannelMessageSinkParams{
|
||||
Logger: h.p.params.Logger,
|
||||
DataChannel: dc,
|
||||
})
|
||||
h.p.signaller.SetResponseSink(sink)
|
||||
}
|
||||
|
||||
func (h PublisherTransportHandler) OnDataChannelCloseSignalling(dc *datachannel.DataChannelWriter[*webrtc.DataChannel]) {
|
||||
// SIGNALLING-V2-TODO: check that the closed data channel is actually the same as response sink
|
||||
h.p.signaller.SetResponseSink(nil)
|
||||
}
|
||||
|
||||
func (h PublisherTransportHandler) OnDataMessageSignalling(data []byte) {
|
||||
h.p.signalHandler.HandleEncodedMessage(data)
|
||||
}
|
||||
|
||||
func (h PublisherTransportHandler) OnDataSendError(err error) {
|
||||
h.p.onDataSendError(err)
|
||||
}
|
||||
@@ -1841,33 +1822,17 @@ func (h PrimaryTransportHandler) OnFullyEstablished() {
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) setupSignalling() {
|
||||
// SIGNALLING-V2-TODO: do proper types to decide which signalling components to instantiate
|
||||
if !p.params.SynchronousLocalCandidatesMode {
|
||||
p.signalling = signalling.NewSignalling(signalling.SignallingParams{
|
||||
Logger: p.params.Logger,
|
||||
})
|
||||
p.signalHandler = signalling.NewSignalHandler(signalling.SignalHandlerParams{
|
||||
Logger: p.params.Logger,
|
||||
Participant: p,
|
||||
})
|
||||
p.signaller = signalling.NewSignallerAsync(signalling.SignallerAsyncParams{
|
||||
Logger: p.params.Logger,
|
||||
Participant: p,
|
||||
})
|
||||
} else {
|
||||
p.signalling = signalling.NewSignallingv2(signalling.Signallingv2Params{
|
||||
Logger: p.params.Logger,
|
||||
})
|
||||
p.signalHandler = signalling.NewSignalHandlerv2(signalling.SignalHandlerv2Params{
|
||||
Logger: p.params.Logger,
|
||||
Participant: p,
|
||||
Signalling: p.signalling,
|
||||
})
|
||||
p.signaller = signalling.NewSignallerv2Async(signalling.Signallerv2AsyncParams{
|
||||
Logger: p.params.Logger,
|
||||
Participant: p,
|
||||
})
|
||||
}
|
||||
p.signalling = signalling.NewSignalling(signalling.SignallingParams{
|
||||
Logger: p.params.Logger,
|
||||
})
|
||||
p.signalHandler = signalling.NewSignalHandler(signalling.SignalHandlerParams{
|
||||
Logger: p.params.Logger,
|
||||
Participant: p,
|
||||
})
|
||||
p.signaller = signalling.NewSignallerAsync(signalling.SignallerAsyncParams{
|
||||
Logger: p.params.Logger,
|
||||
Participant: p,
|
||||
})
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) setupTransportManager() error {
|
||||
@@ -1889,30 +1854,29 @@ func (p *ParticipantImpl) setupTransportManager() error {
|
||||
params := TransportManagerParams{
|
||||
// primary connection does not change, canSubscribe can change if permission was updated
|
||||
// after the participant has joined
|
||||
SubscriberAsPrimary: subscriberAsPrimary,
|
||||
Config: p.params.Config,
|
||||
Twcc: p.twcc,
|
||||
ProtocolVersion: p.params.ProtocolVersion,
|
||||
CongestionControlConfig: p.params.CongestionControlConfig,
|
||||
EnabledPublishCodecs: p.enabledPublishCodecs,
|
||||
EnabledSubscribeCodecs: p.enabledSubscribeCodecs,
|
||||
SimTracks: p.params.SimTracks,
|
||||
ClientInfo: p.params.ClientInfo,
|
||||
Migration: p.params.Migration,
|
||||
AllowTCPFallback: p.params.AllowTCPFallback,
|
||||
TCPFallbackRTTThreshold: p.params.TCPFallbackRTTThreshold,
|
||||
AllowUDPUnstableFallback: p.params.AllowUDPUnstableFallback,
|
||||
TURNSEnabled: p.params.TURNSEnabled,
|
||||
AllowPlayoutDelay: p.params.PlayoutDelay.GetEnabled(),
|
||||
DataChannelMaxBufferedAmount: p.params.DataChannelMaxBufferedAmount,
|
||||
DatachannelSlowThreshold: p.params.DatachannelSlowThreshold,
|
||||
Logger: p.params.Logger.WithComponent(sutils.ComponentTransport),
|
||||
PublisherHandler: pth,
|
||||
SubscriberHandler: sth,
|
||||
DataChannelStats: p.dataChannelStats,
|
||||
UseOneShotSignallingMode: p.params.UseOneShotSignallingMode,
|
||||
SynchronousLocalCandidatesMode: p.params.SynchronousLocalCandidatesMode,
|
||||
FireOnTrackBySdp: p.params.FireOnTrackBySdp,
|
||||
SubscriberAsPrimary: subscriberAsPrimary,
|
||||
Config: p.params.Config,
|
||||
Twcc: p.twcc,
|
||||
ProtocolVersion: p.params.ProtocolVersion,
|
||||
CongestionControlConfig: p.params.CongestionControlConfig,
|
||||
EnabledPublishCodecs: p.enabledPublishCodecs,
|
||||
EnabledSubscribeCodecs: p.enabledSubscribeCodecs,
|
||||
SimTracks: p.params.SimTracks,
|
||||
ClientInfo: p.params.ClientInfo,
|
||||
Migration: p.params.Migration,
|
||||
AllowTCPFallback: p.params.AllowTCPFallback,
|
||||
TCPFallbackRTTThreshold: p.params.TCPFallbackRTTThreshold,
|
||||
AllowUDPUnstableFallback: p.params.AllowUDPUnstableFallback,
|
||||
TURNSEnabled: p.params.TURNSEnabled,
|
||||
AllowPlayoutDelay: p.params.PlayoutDelay.GetEnabled(),
|
||||
DataChannelMaxBufferedAmount: p.params.DataChannelMaxBufferedAmount,
|
||||
DatachannelSlowThreshold: p.params.DatachannelSlowThreshold,
|
||||
Logger: p.params.Logger.WithComponent(sutils.ComponentTransport),
|
||||
PublisherHandler: pth,
|
||||
SubscriberHandler: sth,
|
||||
DataChannelStats: p.dataChannelStats,
|
||||
UseOneShotSignallingMode: p.params.UseOneShotSignallingMode,
|
||||
FireOnTrackBySdp: p.params.FireOnTrackBySdp,
|
||||
}
|
||||
if p.params.SyncStreams && p.params.PlayoutDelay.GetEnabled() && p.params.ClientInfo.isFirefox() {
|
||||
// we will disable playout delay for Firefox if the user is expecting
|
||||
|
||||
@@ -25,8 +25,6 @@ import (
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (p *ParticipantImpl) SetResponseSink(sink routing.MessageSink) {
|
||||
@@ -332,37 +330,3 @@ func (p *ParticipantImpl) SendSubscriptionPermissionUpdate(publisherID livekit.P
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) SendConnectResponse(connectResponse *livekit.ConnectResponse) error {
|
||||
// keep track of participant updates and versions
|
||||
p.updateLock.Lock()
|
||||
for _, op := range connectResponse.OtherParticipants {
|
||||
p.updateCache.Add(livekit.ParticipantID(op.Sid), participantUpdateInfo{
|
||||
identity: livekit.ParticipantIdentity(op.Identity),
|
||||
version: op.Version,
|
||||
state: op.State,
|
||||
updatedAt: time.Now(),
|
||||
})
|
||||
}
|
||||
p.updateLock.Unlock()
|
||||
|
||||
err := p.signaller.WriteMessage(p.signalling.SignalConnectResponse(connectResponse))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update state after sending message, so that no participant updates could slip through before JoinResponse is sent
|
||||
p.updateLock.Lock()
|
||||
if p.State() == livekit.ParticipantInfo_JOINING {
|
||||
p.updateState(livekit.ParticipantInfo_JOINED)
|
||||
}
|
||||
queuedUpdates := p.queuedUpdates
|
||||
p.queuedUpdates = nil
|
||||
p.updateLock.Unlock()
|
||||
|
||||
return p.SendParticipantUpdate(queuedUpdates)
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) SignalPendingMessages() proto.Message {
|
||||
return p.signalling.PendingMessages()
|
||||
}
|
||||
|
||||
-218
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/livekit/protocol/observability/roomobs"
|
||||
"github.com/livekit/protocol/rpc"
|
||||
protosignalling "github.com/livekit/protocol/signalling"
|
||||
"github.com/livekit/protocol/utils"
|
||||
"github.com/livekit/protocol/utils/guid"
|
||||
"github.com/livekit/psrpc"
|
||||
@@ -616,199 +615,6 @@ func (r *Room) Join(
|
||||
return nil
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: consolidate common parts between this function and Join()
|
||||
func (r *Room) Joinv2(
|
||||
participant types.LocalParticipant,
|
||||
opts *ParticipantOptions,
|
||||
iceServers []*livekit.ICEServer,
|
||||
) error {
|
||||
connectResponse, err := func() (*livekit.ConnectResponse, error) {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
|
||||
if r.IsClosed() {
|
||||
return nil, ErrRoomClosed
|
||||
}
|
||||
|
||||
if r.participants[participant.Identity()] != nil {
|
||||
return nil, ErrAlreadyJoined
|
||||
}
|
||||
if r.protoRoom.MaxParticipants > 0 && !participant.IsDependent() {
|
||||
numParticipants := uint32(0)
|
||||
for _, p := range r.participants {
|
||||
if !p.IsDependent() {
|
||||
numParticipants++
|
||||
}
|
||||
}
|
||||
if numParticipants >= r.protoRoom.MaxParticipants {
|
||||
return nil, ErrMaxParticipantsExceeded
|
||||
}
|
||||
}
|
||||
|
||||
if r.FirstJoinedAt() == 0 && !participant.IsDependent() {
|
||||
r.joinedAt.Store(time.Now().Unix())
|
||||
}
|
||||
|
||||
var onStateChangeMu sync.Mutex
|
||||
participant.OnStateChange(func(p types.LocalParticipant) {
|
||||
if r.onParticipantChanged != nil {
|
||||
r.onParticipantChanged(p)
|
||||
}
|
||||
r.broadcastParticipantState(p, broadcastOptions{skipSource: true})
|
||||
|
||||
onStateChangeMu.Lock()
|
||||
defer onStateChangeMu.Unlock()
|
||||
if state := p.State(); state == livekit.ParticipantInfo_ACTIVE {
|
||||
// subscribe participant to existing published tracks
|
||||
r.subscribeToExistingTracks(p, false)
|
||||
|
||||
connectTime := time.Since(p.ConnectedAt())
|
||||
meta := &livekit.AnalyticsClientMeta{
|
||||
ClientConnectTime: uint32(connectTime.Milliseconds()),
|
||||
}
|
||||
infos := p.GetICEConnectionInfo()
|
||||
var connectionType roomobs.ConnectionType
|
||||
for _, info := range infos {
|
||||
if info.Type != types.ICEConnectionTypeUnknown {
|
||||
meta.ConnectionType = info.Type.String()
|
||||
connectionType = info.Type.ReporterType()
|
||||
break
|
||||
}
|
||||
}
|
||||
r.telemetry.ParticipantActive(context.Background(),
|
||||
r.ToProto(),
|
||||
p.ToProto(),
|
||||
meta,
|
||||
false,
|
||||
)
|
||||
|
||||
participant.GetReporter().Tx(func(tx roomobs.ParticipantSessionTx) {
|
||||
tx.ReportClientConnectTime(uint16(connectTime.Milliseconds()))
|
||||
tx.ReportConnectResult(roomobs.ConnectionResultSuccess)
|
||||
tx.ReportConnectionType(connectionType)
|
||||
})
|
||||
|
||||
fields := append(
|
||||
connectionDetailsFields(infos),
|
||||
"clientInfo", logger.Proto(sutils.ClientInfoWithoutAddress(p.GetClientInfo())),
|
||||
)
|
||||
p.GetLogger().Infow("participant active", fields...)
|
||||
} else if state == livekit.ParticipantInfo_DISCONNECTED {
|
||||
// remove participant from room
|
||||
go r.RemoveParticipant(p.Identity(), p.ID(), p.CloseReason())
|
||||
}
|
||||
})
|
||||
participant.OnSubscriberReady(func(p types.LocalParticipant) {
|
||||
r.subscribeToExistingTracks(p, false)
|
||||
})
|
||||
// it's important to set this before connection, we don't want to miss out on any published tracks
|
||||
participant.OnTrackPublished(r.onTrackPublished)
|
||||
participant.OnTrackUpdated(r.onTrackUpdated)
|
||||
participant.OnTrackUnpublished(r.onTrackUnpublished)
|
||||
participant.OnParticipantUpdate(r.onParticipantUpdate)
|
||||
participant.OnDataPacket(r.onDataPacket)
|
||||
participant.OnDataMessage(r.onDataMessage)
|
||||
participant.OnMetrics(r.onMetrics)
|
||||
participant.OnSubscribeStatusChanged(func(publisherID livekit.ParticipantID, subscribed bool) {
|
||||
if subscribed {
|
||||
pub := r.GetParticipantByID(publisherID)
|
||||
if pub != nil && pub.State() == livekit.ParticipantInfo_ACTIVE {
|
||||
// when a participant subscribes to another participant,
|
||||
// send speaker update if the subscribed to participant is active.
|
||||
level, active := pub.GetAudioLevel()
|
||||
if active {
|
||||
_ = participant.SendSpeakerUpdate([]*livekit.SpeakerInfo{
|
||||
{
|
||||
Sid: string(pub.ID()),
|
||||
Level: float32(level),
|
||||
Active: active,
|
||||
},
|
||||
}, false)
|
||||
}
|
||||
|
||||
if cq := pub.GetConnectionQuality(); cq != nil {
|
||||
update := &livekit.ConnectionQualityUpdate{}
|
||||
update.Updates = append(update.Updates, cq)
|
||||
_ = participant.SendConnectionQualityUpdate(update)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no longer subscribed to the publisher, clear speaker status
|
||||
_ = participant.SendSpeakerUpdate([]*livekit.SpeakerInfo{
|
||||
{
|
||||
Sid: string(publisherID),
|
||||
Level: 0,
|
||||
Active: false,
|
||||
},
|
||||
}, true)
|
||||
}
|
||||
})
|
||||
|
||||
r.launchTargetAgents(maps.Values(r.agentDispatches), participant, livekit.JobType_JT_PARTICIPANT)
|
||||
|
||||
r.logger.Debugw(
|
||||
"new participant joined",
|
||||
"pID", participant.ID(),
|
||||
"participant", participant.Identity(),
|
||||
"clientInfo", logger.Proto(participant.GetClientInfo()),
|
||||
"options", opts,
|
||||
"numParticipants", len(r.participants),
|
||||
)
|
||||
|
||||
if participant.IsRecorder() && !r.protoRoom.ActiveRecording {
|
||||
r.protoRoom.ActiveRecording = true
|
||||
r.protoProxy.MarkDirty(true)
|
||||
} else {
|
||||
r.protoProxy.MarkDirty(false)
|
||||
}
|
||||
|
||||
r.participants[participant.Identity()] = participant
|
||||
r.participantOpts[participant.Identity()] = opts
|
||||
|
||||
if r.onParticipantChanged != nil {
|
||||
r.onParticipantChanged(participant)
|
||||
}
|
||||
|
||||
time.AfterFunc(time.Minute, func() {
|
||||
if !participant.Verify() {
|
||||
r.RemoveParticipant(participant.Identity(), participant.ID(), types.ParticipantCloseReasonJoinTimeout)
|
||||
}
|
||||
})
|
||||
|
||||
connectResponse := r.createConnectResponseLocked(participant, iceServers)
|
||||
|
||||
participant.SetMigrateState(types.MigrateStateComplete)
|
||||
|
||||
return connectResponse, nil
|
||||
}()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO
|
||||
// 1. process published audio_tracks
|
||||
// 2. process published video_tracks
|
||||
// 3. HandleOffer and get answer (publisher)
|
||||
|
||||
r.subscribeToExistingTracks(participant, true)
|
||||
offer, offerId, err := participant.GetOffer()
|
||||
if err != nil {
|
||||
participant.GetLogger().Warnw("could not get offer", err)
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("participant_join", "error", "get_subscriber_offer").Add(1)
|
||||
return err
|
||||
}
|
||||
// SIGNALLING-V2-TODO: when moving to envelope response, do SendSdpOffer after sending connect response
|
||||
connectResponse.SubscriberSdp = protosignalling.ToProtoSessionDescription(offer, offerId)
|
||||
// for sync response, this does not actually send, only generates messageId and caches the message
|
||||
if err := participant.SendConnectResponse(connectResponse); err != nil {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("participant_join", "error", "send_response").Add(1)
|
||||
return err
|
||||
}
|
||||
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("participant_join", "success", "").Add(1)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Room) ReplaceParticipantRequestSource(identity livekit.ParticipantIdentity, reqSource routing.MessageSource) {
|
||||
r.lock.Lock()
|
||||
if rs, ok := r.participantRequestSources[identity]; ok {
|
||||
@@ -1275,30 +1081,6 @@ func (r *Room) createJoinResponseLocked(participant types.LocalParticipant, iceS
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Room) createConnectResponseLocked(
|
||||
participant types.LocalParticipant,
|
||||
iceServers []*livekit.ICEServer,
|
||||
) *livekit.ConnectResponse {
|
||||
iceConfig := participant.GetICEConfig()
|
||||
hasICEFallback := iceConfig.GetPreferencePublisher() != livekit.ICECandidateType_ICT_NONE || iceConfig.GetPreferenceSubscriber() != livekit.ICECandidateType_ICT_NONE
|
||||
return &livekit.ConnectResponse{
|
||||
Room: r.ToProto(),
|
||||
Participant: participant.ToProto(),
|
||||
OtherParticipants: GetOtherParticipantInfo(
|
||||
participant,
|
||||
false, // isMigratingIn
|
||||
toParticipants(maps.Values(r.participants)),
|
||||
false, // skipSubscriberBroadcast
|
||||
),
|
||||
IceServers: iceServers,
|
||||
ClientConfiguration: participant.GetClientConfiguration(),
|
||||
ServerInfo: r.serverInfo,
|
||||
SifTrailer: r.trailer,
|
||||
EnabledPublishCodecs: participant.GetEnabledPublishCodecs(),
|
||||
FastPublish: participant.CanPublish() && !hasICEFallback,
|
||||
}
|
||||
}
|
||||
|
||||
// a ParticipantImpl in the room added a new track, subscribe other participants to it
|
||||
func (r *Room) onTrackPublished(participant types.LocalParticipant, track types.MediaTrack) {
|
||||
// publish participant update, since track state is changed
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
// Copyright 2023 LiveKit, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package signalling
|
||||
|
||||
import (
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/webrtc/v4"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/datachannel"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var _ routing.MessageSink = (*dataChannelMessageSink)(nil)
|
||||
|
||||
type DataChannelMessageSinkParams struct {
|
||||
Logger logger.Logger
|
||||
DataChannel *datachannel.DataChannelWriter[*webrtc.DataChannel]
|
||||
}
|
||||
|
||||
type dataChannelMessageSink struct {
|
||||
params DataChannelMessageSinkParams
|
||||
}
|
||||
|
||||
func NewDataChannelMessageSink(params DataChannelMessageSinkParams) routing.MessageSink {
|
||||
return &dataChannelMessageSink{
|
||||
params: params,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *dataChannelMessageSink) WriteMessage(msg proto.Message) error {
|
||||
if msg == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
protoMsg, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
d.params.Logger.Errorw("could not marshal message", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := d.params.DataChannel.Write(protoMsg); err != nil {
|
||||
// SIGNALLING-V2-TODO: filter out logging expected errors
|
||||
d.params.Logger.Errorw("could not send message", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *dataChannelMessageSink) IsClosed() bool {
|
||||
// SIGNALLING-V2-TODO
|
||||
return false
|
||||
}
|
||||
|
||||
func (d *dataChannelMessageSink) Close() {
|
||||
// SIGNALLING-V2-TODO
|
||||
}
|
||||
|
||||
func (d *dataChannelMessageSink) ConnectionID() livekit.ConnectionID {
|
||||
// SIGNALLING-V2-TODO
|
||||
return ""
|
||||
}
|
||||
@@ -25,8 +25,6 @@ import (
|
||||
|
||||
type ParticipantSignalHandler interface {
|
||||
HandleMessage(msg proto.Message) error
|
||||
HandleEncodedMessage(data []byte) error
|
||||
PruneStaleReassemblies()
|
||||
}
|
||||
|
||||
type ParticipantSignaller interface {
|
||||
@@ -59,11 +57,4 @@ type ParticipantSignalling interface {
|
||||
SignalSubscribedQualityUpdate(subscribedQualityUpdate *livekit.SubscribedQualityUpdate) proto.Message
|
||||
SignalSubscriptionResponse(subscriptionResponse *livekit.SubscriptionResponse) proto.Message
|
||||
SignalSubscriptionPermissionUpdate(subscriptionPermissionUpdate *livekit.SubscriptionPermissionUpdate) proto.Message
|
||||
|
||||
AckMessageId(ackMessageId uint32)
|
||||
SetLastProcessedRemoteMessageId(lastProcessedRemoteMessageId uint32)
|
||||
|
||||
PendingMessages() proto.Message
|
||||
|
||||
SignalConnectResponse(connectResponse *livekit.ConnectResponse) proto.Message
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ func NewSignalHandler(params SignalHandlerParams) ParticipantSignalHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: consolidate base message handling for messages common to different signalling versions
|
||||
func (s *signalhandler) HandleMessage(msg proto.Message) error {
|
||||
req, ok := msg.(*livekit.SignalRequest)
|
||||
if !ok {
|
||||
@@ -194,12 +193,3 @@ func (s *signalhandler) HandleMessage(msg proto.Message) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *signalhandler) HandleEncodedMessage(data []byte) error {
|
||||
signalRequest := &livekit.SignalRequest{}
|
||||
if err := proto.Unmarshal(data, signalRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.HandleMessage(signalRequest)
|
||||
}
|
||||
|
||||
@@ -25,9 +25,3 @@ type signalhandlerUnimplemented struct{}
|
||||
func (u *signalhandlerUnimplemented) HandleMessage(msg proto.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *signalhandlerUnimplemented) HandleEncodedMessage(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *signalhandlerUnimplemented) PruneStaleReassemblies() {}
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
// Copyright 2023 LiveKit, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package signalling
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
protosignalling "github.com/livekit/protocol/signalling"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
||||
var _ ParticipantSignalHandler = (*signalhandlerv2)(nil)
|
||||
|
||||
type SignalHandlerv2Params struct {
|
||||
Logger logger.Logger
|
||||
Participant types.LocalParticipant
|
||||
Signalling ParticipantSignalling
|
||||
}
|
||||
|
||||
type signalhandlerv2 struct {
|
||||
signalhandlerUnimplemented
|
||||
|
||||
params SignalHandlerv2Params
|
||||
|
||||
// SIGNALLING-V2-TODO: have to set this properly for `ConnectRequest` coming via sync HTTP path
|
||||
lastProcessedRemoteMessageId atomic.Uint32
|
||||
signalReassembler *protosignalling.SignalReassembler
|
||||
}
|
||||
|
||||
func NewSignalHandlerv2(params SignalHandlerv2Params) ParticipantSignalHandler {
|
||||
return &signalhandlerv2{
|
||||
params: params,
|
||||
signalReassembler: protosignalling.NewSignalReassembler(protosignalling.SignalReassemblerParams{
|
||||
Logger: params.Logger,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *signalhandlerv2) HandleMessage(msg proto.Message) error {
|
||||
req, ok := msg.(*livekit.Signalv2WireMessage)
|
||||
if !ok {
|
||||
s.params.Logger.Warnw(
|
||||
"unknown message type", nil,
|
||||
"messageType", fmt.Sprintf("%T", msg),
|
||||
)
|
||||
return ErrInvalidMessageType
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: check if this makes sense for data channel based signalling
|
||||
s.params.Participant.UpdateLastSeenSignal()
|
||||
|
||||
switch msg := req.GetMessage().(type) {
|
||||
case *livekit.Signalv2WireMessage_Envelope:
|
||||
for _, clientMessage := range msg.Envelope.ClientMessages {
|
||||
sequencer := clientMessage.GetSequencer()
|
||||
if sequencer == nil || sequencer.MessageId == 0 {
|
||||
s.params.Logger.Warnw(
|
||||
"skipping message without sequencer", nil,
|
||||
"messageType", fmt.Sprintf("%T", clientMessage),
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
lprmi := s.lastProcessedRemoteMessageId.Load()
|
||||
if sequencer.MessageId <= lprmi {
|
||||
s.params.Logger.Infow(
|
||||
"duplicate in message stream",
|
||||
"last", lprmi,
|
||||
"current", clientMessage.Sequencer.MessageId,
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: ask for replay if there are gaps
|
||||
if lprmi != 0 && sequencer.MessageId != lprmi+1 {
|
||||
s.params.Logger.Infow(
|
||||
"gap in message stream",
|
||||
"last", lprmi,
|
||||
"current", clientMessage.Sequencer.MessageId,
|
||||
)
|
||||
}
|
||||
|
||||
switch payload := clientMessage.GetMessage().(type) {
|
||||
case *livekit.Signalv2ClientMessage_PublisherSdp:
|
||||
s.params.Participant.HandleOffer(protosignalling.FromProtoSessionDescription(payload.PublisherSdp))
|
||||
|
||||
case *livekit.Signalv2ClientMessage_SubscriberSdp:
|
||||
s.params.Participant.HandleAnswer(protosignalling.FromProtoSessionDescription(payload.SubscriberSdp))
|
||||
|
||||
case *livekit.Signalv2ClientMessage_Trickle:
|
||||
candidateInit, err := protosignalling.FromProtoTrickle(payload.Trickle)
|
||||
if err != nil {
|
||||
s.params.Logger.Warnw("could not decode trickle", err)
|
||||
return err
|
||||
}
|
||||
s.params.Participant.AddICECandidate(candidateInit, payload.Trickle.Target)
|
||||
}
|
||||
|
||||
s.lastProcessedRemoteMessageId.Store(sequencer.MessageId)
|
||||
s.params.Signalling.AckMessageId(sequencer.LastProcessedRemoteMessageId)
|
||||
s.params.Signalling.SetLastProcessedRemoteMessageId(sequencer.MessageId)
|
||||
}
|
||||
|
||||
case *livekit.Signalv2WireMessage_Fragment:
|
||||
bytes := s.signalReassembler.Reassemble(msg.Fragment)
|
||||
if len(bytes) != 0 {
|
||||
wireMessage := &livekit.Signalv2WireMessage{}
|
||||
err := proto.Unmarshal(bytes, wireMessage)
|
||||
if err != nil {
|
||||
s.params.Logger.Warnw("could not unmarshal re-assembled packet", err)
|
||||
return err
|
||||
}
|
||||
|
||||
s.HandleMessage(wireMessage)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *signalhandlerv2) HandleEncodedMessage(data []byte) error {
|
||||
wireMessage := &livekit.Signalv2WireMessage{}
|
||||
if err := proto.Unmarshal(data, wireMessage); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.HandleMessage(wireMessage)
|
||||
}
|
||||
|
||||
func (s *signalhandlerv2) PruneStaleReassemblies() {
|
||||
s.signalReassembler.Prune()
|
||||
}
|
||||
@@ -83,7 +83,6 @@ func (s *signallerAsync) WriteMessage(msg proto.Message) error {
|
||||
|
||||
err := sink.WriteMessage(msg)
|
||||
if err != nil {
|
||||
// SIGNALLING-V2-TODO: check for data channel errors to treat as non-error
|
||||
if utils.ErrorIsOneOf(err, psrpc.Canceled, routing.ErrChannelClosed) {
|
||||
if typed, ok := msg.(*livekit.SignalResponse); ok {
|
||||
s.params.Logger.Debugw(
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
// Copyright 2023 LiveKit, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package signalling
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
protosignalling "github.com/livekit/protocol/signalling"
|
||||
"github.com/livekit/protocol/utils"
|
||||
"github.com/livekit/psrpc"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var _ ParticipantSignaller = (*signallerv2Async)(nil)
|
||||
|
||||
type Signallerv2AsyncParams struct {
|
||||
Logger logger.Logger
|
||||
Participant types.LocalParticipant
|
||||
}
|
||||
|
||||
type signallerv2Async struct {
|
||||
params Signallerv2AsyncParams
|
||||
|
||||
*signallerAsyncBase
|
||||
|
||||
signalSegmenter *protosignalling.SignalSegmenter
|
||||
}
|
||||
|
||||
func NewSignallerv2Async(params Signallerv2AsyncParams) ParticipantSignaller {
|
||||
return &signallerv2Async{
|
||||
params: params,
|
||||
signallerAsyncBase: newSignallerAsyncBase(signallerAsyncBaseParams{Logger: params.Logger}),
|
||||
signalSegmenter: protosignalling.NewSignalSegmenter(protosignalling.SignalSegmenterParams{
|
||||
Logger: params.Logger,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: need to lock write so that fragments do not get interrupted
|
||||
func (s *signallerv2Async) WriteMessage(msg proto.Message) error {
|
||||
if msg == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if s.params.Participant.IsDisconnected() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !s.params.Participant.IsReady() {
|
||||
if typed, ok := msg.(*livekit.Signalv2WireMessage); !ok {
|
||||
s.params.Logger.Warnw(
|
||||
"unknown message type", nil,
|
||||
"messageType", fmt.Sprintf("%T", msg),
|
||||
)
|
||||
} else {
|
||||
if !hasConnectResponse(typed) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sink := s.GetResponseSink()
|
||||
if sink == nil {
|
||||
if typed, ok := msg.(*livekit.Signalv2WireMessage); ok {
|
||||
s.params.Logger.Debugw(
|
||||
"could not send message to participant",
|
||||
"messageType", fmt.Sprintf("%T", typed.Message),
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: avoid double marshalling,
|
||||
// have to marshal once to get size of serialised packet and decide if it needs fragmentation,
|
||||
// should used the marshaled bytes if fragmentation is not needed
|
||||
var fragments []*livekit.Fragment
|
||||
marshaled, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
if typed, ok := msg.(*livekit.Signalv2WireMessage); ok {
|
||||
s.params.Logger.Warnw(
|
||||
"could not send message to participant", err,
|
||||
"messageType", fmt.Sprintf("%T", typed.Message),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
fragments = s.signalSegmenter.Segment(marshaled)
|
||||
}
|
||||
|
||||
sendMsg := func(m proto.Message) error {
|
||||
if err := sink.WriteMessage(m); err != nil {
|
||||
// SIGNALLING-V2-TODO: check for data channel errors to treat as debug too
|
||||
if utils.ErrorIsOneOf(err, psrpc.Canceled, routing.ErrChannelClosed) {
|
||||
if typed, ok := m.(*livekit.Signalv2WireMessage); ok {
|
||||
s.params.Logger.Debugw(
|
||||
"could not send message to participant",
|
||||
"error", err,
|
||||
"messageType", fmt.Sprintf("%T", typed.Message),
|
||||
)
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
if typed, ok := m.(*livekit.Signalv2WireMessage); ok {
|
||||
s.params.Logger.Warnw(
|
||||
"could not send message to participant", err,
|
||||
"messageType", fmt.Sprintf("%T", typed.Message),
|
||||
)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(fragments) != 0 {
|
||||
for _, fragment := range fragments {
|
||||
wireMessage := &livekit.Signalv2WireMessage{
|
||||
Message: &livekit.Signalv2WireMessage_Fragment{
|
||||
Fragment: fragment,
|
||||
},
|
||||
}
|
||||
if err := sendMsg(wireMessage); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := sendMsg(msg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
|
||||
func hasConnectResponse(wireMessage *livekit.Signalv2WireMessage) bool {
|
||||
switch msg := wireMessage.GetMessage().(type) {
|
||||
case *livekit.Signalv2WireMessage_Envelope:
|
||||
for _, innerMsg := range msg.Envelope.GetServerMessages() {
|
||||
switch innerMsg.GetMessage().(type) {
|
||||
case *livekit.Signalv2ServerMessage_ConnectResponse:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false // first message should be `ConnectResponse`
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
// SIGNALLING-V2-TODO: handle ConnectResponse getting fragmented.
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Copyright 2023 LiveKit, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package signalling
|
||||
|
||||
import (
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
var _ ParticipantSignaller = (*signallerv2Hybrid)(nil)
|
||||
|
||||
type Signallerv2HybridParams struct {
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
type signallerv2Hybrid struct {
|
||||
params Signallerv2HybridParams
|
||||
|
||||
*signallerv2Async
|
||||
}
|
||||
|
||||
func NewSignallerv2Hybrid(params Signallerv2HybridParams) ParticipantSignaller {
|
||||
return &signallerv2Hybrid{
|
||||
params: params,
|
||||
signallerv2Async: NewSignallerv2Async(Signallerv2AsyncParams{Logger: params.Logger}).(*signallerv2Async),
|
||||
}
|
||||
}
|
||||
@@ -107,16 +107,3 @@ func (u *signallingUnimplemented) SignalSubscriptionResponse(subscriptionRespons
|
||||
func (u *signallingUnimplemented) SignalSubscriptionPermissionUpdate(subscriptionPermissionUpdate *livekit.SubscriptionPermissionUpdate) proto.Message {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *signallingUnimplemented) AckMessageId(ackMessageId uint32) {}
|
||||
|
||||
func (u *signallingUnimplemented) SetLastProcessedRemoteMessageId(lastProcessedRemoteMessageId uint32) {
|
||||
}
|
||||
|
||||
func (u *signallingUnimplemented) PendingMessages() proto.Message {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *signallingUnimplemented) SignalConnectResponse(connectResponse *livekit.ConnectResponse) proto.Message {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
// Copyright 2023 LiveKit, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package signalling
|
||||
|
||||
import (
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
protosignalling "github.com/livekit/protocol/signalling"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var _ ParticipantSignalling = (*signallingv2)(nil)
|
||||
|
||||
type Signallingv2Params struct {
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
type signallingv2 struct {
|
||||
signallingUnimplemented
|
||||
|
||||
params Signallingv2Params
|
||||
|
||||
signalCache *protosignalling.Signalv2ServerMessageCache
|
||||
}
|
||||
|
||||
func NewSignallingv2(params Signallingv2Params) ParticipantSignalling {
|
||||
return &signallingv2{
|
||||
params: params,
|
||||
signalCache: protosignalling.NewSignalv2ServerMessageCache(protosignalling.SignalCacheParams{
|
||||
Logger: params.Logger,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *signallingv2) AckMessageId(ackMessageId uint32) {
|
||||
s.signalCache.Clear(ackMessageId)
|
||||
}
|
||||
|
||||
func (s *signallingv2) SetLastProcessedRemoteMessageId(lastProcessedRemoteMessageId uint32) {
|
||||
s.signalCache.SetLastProcessedRemoteMessageId(lastProcessedRemoteMessageId)
|
||||
}
|
||||
|
||||
func (s *signallingv2) PendingMessages() proto.Message {
|
||||
serverMessages := s.signalCache.GetFromFront()
|
||||
if len(serverMessages) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &livekit.Signalv2WireMessage{
|
||||
Message: &livekit.Signalv2WireMessage_Envelope{
|
||||
Envelope: &livekit.Envelope{
|
||||
ServerMessages: serverMessages,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *signallingv2) SignalConnectResponse(connectResponse *livekit.ConnectResponse) proto.Message {
|
||||
serverMessage := &livekit.Signalv2ServerMessage{
|
||||
Message: &livekit.Signalv2ServerMessage_ConnectResponse{
|
||||
ConnectResponse: connectResponse,
|
||||
},
|
||||
}
|
||||
return s.cacheAndReturnEnvelope(serverMessage)
|
||||
}
|
||||
|
||||
func (s *signallingv2) SignalSdpOffer(offer *livekit.SessionDescription) proto.Message {
|
||||
serverMessage := &livekit.Signalv2ServerMessage{
|
||||
Message: &livekit.Signalv2ServerMessage_SubscriberSdp{
|
||||
SubscriberSdp: offer,
|
||||
},
|
||||
}
|
||||
return s.cacheAndReturnEnvelope(serverMessage)
|
||||
}
|
||||
|
||||
func (s *signallingv2) SignalSdpAnswer(answer *livekit.SessionDescription) proto.Message {
|
||||
serverMessage := &livekit.Signalv2ServerMessage{
|
||||
Message: &livekit.Signalv2ServerMessage_PublisherSdp{
|
||||
PublisherSdp: answer,
|
||||
},
|
||||
}
|
||||
return s.cacheAndReturnEnvelope(serverMessage)
|
||||
}
|
||||
|
||||
func (s *signallingv2) SignalRoomUpdate(room *livekit.Room) proto.Message {
|
||||
serverMessage := &livekit.Signalv2ServerMessage{
|
||||
Message: &livekit.Signalv2ServerMessage_RoomUpdate{
|
||||
RoomUpdate: &livekit.RoomUpdate{
|
||||
Room: room,
|
||||
},
|
||||
},
|
||||
}
|
||||
return s.cacheAndReturnEnvelope(serverMessage)
|
||||
}
|
||||
|
||||
func (s *signallingv2) SignalParticipantUpdate(participants []*livekit.ParticipantInfo) proto.Message {
|
||||
if len(participants) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
serverMessage := &livekit.Signalv2ServerMessage{
|
||||
Message: &livekit.Signalv2ServerMessage_ParticipantUpdate{
|
||||
ParticipantUpdate: &livekit.ParticipantUpdate{
|
||||
Participants: participants,
|
||||
},
|
||||
},
|
||||
}
|
||||
return s.cacheAndReturnEnvelope(serverMessage)
|
||||
}
|
||||
|
||||
func (s *signallingv2) cacheAndReturnEnvelope(sm *livekit.Signalv2ServerMessage) proto.Message {
|
||||
sm = s.signalCache.Add(sm)
|
||||
if sm == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &livekit.Signalv2WireMessage{
|
||||
Message: &livekit.Signalv2WireMessage_Envelope{
|
||||
Envelope: &livekit.Envelope{
|
||||
ServerMessages: []*livekit.Signalv2ServerMessage{sm},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
+21
-73
@@ -266,25 +266,24 @@ type PCTransport struct {
|
||||
}
|
||||
|
||||
type TransportParams struct {
|
||||
Handler transport.Handler
|
||||
ProtocolVersion types.ProtocolVersion
|
||||
Config *WebRTCConfig
|
||||
Twcc *lktwcc.Responder
|
||||
DirectionConfig DirectionConfig
|
||||
CongestionControlConfig config.CongestionControlConfig
|
||||
EnabledCodecs []*livekit.Codec
|
||||
Logger logger.Logger
|
||||
Transport livekit.SignalTarget
|
||||
SimTracks map[uint32]SimulcastTrackInfo
|
||||
ClientInfo ClientInfo
|
||||
IsOfferer bool
|
||||
IsSendSide bool
|
||||
AllowPlayoutDelay bool
|
||||
UseOneShotSignallingMode bool
|
||||
SynchronousLocalCandidatesMode bool
|
||||
FireOnTrackBySdp bool
|
||||
DataChannelMaxBufferedAmount uint64
|
||||
DatachannelSlowThreshold int
|
||||
Handler transport.Handler
|
||||
ProtocolVersion types.ProtocolVersion
|
||||
Config *WebRTCConfig
|
||||
Twcc *lktwcc.Responder
|
||||
DirectionConfig DirectionConfig
|
||||
CongestionControlConfig config.CongestionControlConfig
|
||||
EnabledCodecs []*livekit.Codec
|
||||
Logger logger.Logger
|
||||
Transport livekit.SignalTarget
|
||||
SimTracks map[uint32]SimulcastTrackInfo
|
||||
ClientInfo ClientInfo
|
||||
IsOfferer bool
|
||||
IsSendSide bool
|
||||
AllowPlayoutDelay bool
|
||||
UseOneShotSignallingMode bool
|
||||
FireOnTrackBySdp bool
|
||||
DataChannelMaxBufferedAmount uint64
|
||||
DatachannelSlowThreshold int
|
||||
|
||||
// for development test
|
||||
DatachannelMaxReceiverBufferSize int
|
||||
@@ -555,8 +554,7 @@ func (t *PCTransport) createPeerConnection() (cc.BandwidthEstimator, error) {
|
||||
}
|
||||
|
||||
t.pc = pc
|
||||
// SIGNALLING-V2-TODO: have to support both sync and async candidates, so has to be a check at function level
|
||||
if !t.params.UseOneShotSignallingMode /* SIGNALLING-V2-TODO && !t.params.SynchronousLocalCandidatesMode */ {
|
||||
if !t.params.UseOneShotSignallingMode {
|
||||
// one shot signalling mode gathers all candidates and sends in answer
|
||||
t.pc.OnICEGatheringStateChange(t.onICEGatheringStateChange)
|
||||
t.pc.OnICECandidate(t.onICECandidateTrickle)
|
||||
@@ -1330,10 +1328,8 @@ func (t *PCTransport) clearConnTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: this needs both sync and async support when not in one shot mode,
|
||||
// cannot use the state `SynchronousLocalCandidatesMode`, needs a flag at function level
|
||||
func (t *PCTransport) HandleRemoteDescription(sd webrtc.SessionDescription, remoteId uint32) error {
|
||||
if t.params.UseOneShotSignallingMode /* SIGNALLING-V2-TODO || t.params.SynchronousLocalCandidatesMode */ {
|
||||
if t.params.UseOneShotSignallingMode {
|
||||
if sd.Type == webrtc.SDPTypeOffer {
|
||||
remoteOfferId := t.remoteOfferId.Load()
|
||||
if remoteOfferId != 0 && remoteOfferId != t.localAnswerId.Load() {
|
||||
@@ -1352,7 +1348,6 @@ func (t *PCTransport) HandleRemoteDescription(sd webrtc.SessionDescription, remo
|
||||
t.remoteAnswerId.Store(remoteId)
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: need to support filtering candidates for transport fallback
|
||||
// add remote candidates to ICE connection details
|
||||
parsed, err := sd.Unmarshal()
|
||||
if err == nil {
|
||||
@@ -1400,10 +1395,8 @@ func (t *PCTransport) HandleRemoteDescription(sd webrtc.SessionDescription, remo
|
||||
return nil
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: use a flag at function level for sync vs async rather
|
||||
// then state `SynchronousLocalCandidatesMode`
|
||||
func (t *PCTransport) GetAnswer() (webrtc.SessionDescription, uint32, error) {
|
||||
if !t.params.UseOneShotSignallingMode && !t.params.SynchronousLocalCandidatesMode {
|
||||
if !t.params.UseOneShotSignallingMode {
|
||||
return webrtc.SessionDescription{}, 0, ErrNotSynchronousLocalCandidatesMode
|
||||
}
|
||||
|
||||
@@ -1453,51 +1446,6 @@ func (t *PCTransport) GetAnswer() (webrtc.SessionDescription, uint32, error) {
|
||||
return *cld, answerId, nil
|
||||
}
|
||||
|
||||
// SIGNALLING-V2-TODO: use a flag at function level for sync vs async rather
|
||||
// then state `SynchronousLocalCandidatesMode`
|
||||
func (t *PCTransport) GetOffer() (webrtc.SessionDescription, uint32, error) {
|
||||
if !t.params.SynchronousLocalCandidatesMode {
|
||||
return webrtc.SessionDescription{}, 0, ErrNotSynchronousLocalCandidatesMode
|
||||
}
|
||||
|
||||
offer, err := t.pc.CreateOffer(nil)
|
||||
if err != nil {
|
||||
return webrtc.SessionDescription{}, 0, err
|
||||
}
|
||||
|
||||
if err = t.pc.SetLocalDescription(offer); err != nil {
|
||||
return webrtc.SessionDescription{}, 0, err
|
||||
}
|
||||
|
||||
// wait for gathering to complete to include all candidates in the answer
|
||||
<-webrtc.GatheringCompletePromise(t.pc)
|
||||
|
||||
pld := t.pc.PendingLocalDescription()
|
||||
|
||||
// add local candidates to ICE connection details
|
||||
parsed, err := pld.Unmarshal()
|
||||
if err == nil {
|
||||
addLocalICECandidates := func(attrs []sdp.Attribute) {
|
||||
for _, a := range attrs {
|
||||
if a.IsICECandidate() {
|
||||
c, err := ice.UnmarshalCandidate(a.Value)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
t.connectionDetails.AddLocalICECandidate(c, false, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addLocalICECandidates(parsed.Attributes)
|
||||
for _, m := range parsed.MediaDescriptions {
|
||||
addLocalICECandidates(m.Attributes)
|
||||
}
|
||||
}
|
||||
|
||||
return *pld, t.localOfferId.Inc(), nil
|
||||
}
|
||||
|
||||
func (t *PCTransport) GetICESessionUfrag() (string, error) {
|
||||
cld := t.pc.CurrentLocalDescription()
|
||||
if cld == nil {
|
||||
|
||||
+51
-58
@@ -83,30 +83,29 @@ func (h TransportManagerPublisherTransportHandler) OnAnswer(sd webrtc.SessionDes
|
||||
// -------------------------------
|
||||
|
||||
type TransportManagerParams struct {
|
||||
SubscriberAsPrimary bool
|
||||
Config *WebRTCConfig
|
||||
Twcc *twcc.Responder
|
||||
ProtocolVersion types.ProtocolVersion
|
||||
CongestionControlConfig config.CongestionControlConfig
|
||||
EnabledSubscribeCodecs []*livekit.Codec
|
||||
EnabledPublishCodecs []*livekit.Codec
|
||||
SimTracks map[uint32]SimulcastTrackInfo
|
||||
ClientInfo ClientInfo
|
||||
Migration bool
|
||||
AllowTCPFallback bool
|
||||
TCPFallbackRTTThreshold int
|
||||
AllowUDPUnstableFallback bool
|
||||
TURNSEnabled bool
|
||||
AllowPlayoutDelay bool
|
||||
DataChannelMaxBufferedAmount uint64
|
||||
DatachannelSlowThreshold int
|
||||
Logger logger.Logger
|
||||
PublisherHandler transport.Handler
|
||||
SubscriberHandler transport.Handler
|
||||
DataChannelStats *telemetry.BytesTrackStats
|
||||
UseOneShotSignallingMode bool
|
||||
SynchronousLocalCandidatesMode bool
|
||||
FireOnTrackBySdp bool
|
||||
SubscriberAsPrimary bool
|
||||
Config *WebRTCConfig
|
||||
Twcc *twcc.Responder
|
||||
ProtocolVersion types.ProtocolVersion
|
||||
CongestionControlConfig config.CongestionControlConfig
|
||||
EnabledSubscribeCodecs []*livekit.Codec
|
||||
EnabledPublishCodecs []*livekit.Codec
|
||||
SimTracks map[uint32]SimulcastTrackInfo
|
||||
ClientInfo ClientInfo
|
||||
Migration bool
|
||||
AllowTCPFallback bool
|
||||
TCPFallbackRTTThreshold int
|
||||
AllowUDPUnstableFallback bool
|
||||
TURNSEnabled bool
|
||||
AllowPlayoutDelay bool
|
||||
DataChannelMaxBufferedAmount uint64
|
||||
DatachannelSlowThreshold int
|
||||
Logger logger.Logger
|
||||
PublisherHandler transport.Handler
|
||||
SubscriberHandler transport.Handler
|
||||
DataChannelStats *telemetry.BytesTrackStats
|
||||
UseOneShotSignallingMode bool
|
||||
FireOnTrackBySdp bool
|
||||
}
|
||||
|
||||
type TransportManager struct {
|
||||
@@ -151,22 +150,21 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
|
||||
|
||||
lgr := LoggerWithPCTarget(params.Logger, livekit.SignalTarget_PUBLISHER)
|
||||
publisher, err := NewPCTransport(TransportParams{
|
||||
ProtocolVersion: params.ProtocolVersion,
|
||||
Config: params.Config,
|
||||
Twcc: params.Twcc,
|
||||
DirectionConfig: params.Config.Publisher,
|
||||
CongestionControlConfig: params.CongestionControlConfig,
|
||||
EnabledCodecs: params.EnabledPublishCodecs,
|
||||
Logger: lgr,
|
||||
SimTracks: params.SimTracks,
|
||||
ClientInfo: params.ClientInfo,
|
||||
Transport: livekit.SignalTarget_PUBLISHER,
|
||||
Handler: TransportManagerPublisherTransportHandler{TransportManagerTransportHandler{params.PublisherHandler, t, lgr}},
|
||||
UseOneShotSignallingMode: params.UseOneShotSignallingMode,
|
||||
SynchronousLocalCandidatesMode: params.SynchronousLocalCandidatesMode,
|
||||
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
|
||||
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
||||
FireOnTrackBySdp: params.FireOnTrackBySdp,
|
||||
ProtocolVersion: params.ProtocolVersion,
|
||||
Config: params.Config,
|
||||
Twcc: params.Twcc,
|
||||
DirectionConfig: params.Config.Publisher,
|
||||
CongestionControlConfig: params.CongestionControlConfig,
|
||||
EnabledCodecs: params.EnabledPublishCodecs,
|
||||
Logger: lgr,
|
||||
SimTracks: params.SimTracks,
|
||||
ClientInfo: params.ClientInfo,
|
||||
Transport: livekit.SignalTarget_PUBLISHER,
|
||||
Handler: TransportManagerPublisherTransportHandler{TransportManagerTransportHandler{params.PublisherHandler, t, lgr}},
|
||||
UseOneShotSignallingMode: params.UseOneShotSignallingMode,
|
||||
DataChannelMaxBufferedAmount: params.DataChannelMaxBufferedAmount,
|
||||
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
||||
FireOnTrackBySdp: params.FireOnTrackBySdp,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -175,20 +173,19 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
|
||||
|
||||
lgr = LoggerWithPCTarget(params.Logger, livekit.SignalTarget_SUBSCRIBER)
|
||||
subscriber, err := NewPCTransport(TransportParams{
|
||||
ProtocolVersion: params.ProtocolVersion,
|
||||
Config: params.Config,
|
||||
DirectionConfig: params.Config.Subscriber,
|
||||
CongestionControlConfig: params.CongestionControlConfig,
|
||||
EnabledCodecs: params.EnabledSubscribeCodecs,
|
||||
Logger: lgr,
|
||||
ClientInfo: params.ClientInfo,
|
||||
IsOfferer: true,
|
||||
IsSendSide: true,
|
||||
AllowPlayoutDelay: params.AllowPlayoutDelay,
|
||||
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
||||
Transport: livekit.SignalTarget_SUBSCRIBER,
|
||||
Handler: TransportManagerTransportHandler{params.SubscriberHandler, t, lgr},
|
||||
SynchronousLocalCandidatesMode: params.SynchronousLocalCandidatesMode,
|
||||
ProtocolVersion: params.ProtocolVersion,
|
||||
Config: params.Config,
|
||||
DirectionConfig: params.Config.Subscriber,
|
||||
CongestionControlConfig: params.CongestionControlConfig,
|
||||
EnabledCodecs: params.EnabledSubscribeCodecs,
|
||||
Logger: lgr,
|
||||
ClientInfo: params.ClientInfo,
|
||||
IsOfferer: true,
|
||||
IsSendSide: true,
|
||||
AllowPlayoutDelay: params.AllowPlayoutDelay,
|
||||
DatachannelSlowThreshold: params.DatachannelSlowThreshold,
|
||||
Transport: livekit.SignalTarget_SUBSCRIBER,
|
||||
Handler: TransportManagerTransportHandler{params.SubscriberHandler, t, lgr},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -496,10 +493,6 @@ func (t *TransportManager) HandleAnswer(answer webrtc.SessionDescription, answer
|
||||
t.subscriber.HandleRemoteDescription(answer, answerId)
|
||||
}
|
||||
|
||||
func (t *TransportManager) GetOffer() (webrtc.SessionDescription, uint32, error) {
|
||||
return t.subscriber.GetOffer()
|
||||
}
|
||||
|
||||
// AddICECandidate adds candidates for remote peer
|
||||
func (t *TransportManager) AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) {
|
||||
switch target {
|
||||
|
||||
@@ -411,7 +411,6 @@ type LocalParticipant interface {
|
||||
SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool) *livekit.TrackInfo
|
||||
|
||||
HandleAnswer(sdp webrtc.SessionDescription, answerId uint32)
|
||||
GetOffer() (webrtc.SessionDescription, uint32, error)
|
||||
Negotiate(force bool)
|
||||
ICERestart(iceConfig *livekit.ICEConfig)
|
||||
AddTrackLocal(trackLocal webrtc.TrackLocal, params AddTrackParams) (*webrtc.RTPSender, *webrtc.RTPTransceiver, error)
|
||||
@@ -454,8 +453,6 @@ type LocalParticipant interface {
|
||||
HandleReconnectAndSendResponse(reconnectReason livekit.ReconnectReason, reconnectResponse *livekit.ReconnectResponse) error
|
||||
IssueFullReconnect(reason ParticipantCloseReason)
|
||||
SendRoomMovedResponse(moved *livekit.RoomMovedResponse) error
|
||||
SendConnectResponse(connectResponse *livekit.ConnectResponse) error
|
||||
SignalPendingMessages() proto.Message
|
||||
|
||||
// callbacks
|
||||
OnStateChange(func(p LocalParticipant))
|
||||
|
||||
@@ -373,20 +373,6 @@ type FakeLocalParticipant struct {
|
||||
getLoggerResolverReturnsOnCall map[int]struct {
|
||||
result1 logger.DeferredFieldResolver
|
||||
}
|
||||
GetOfferStub func() (webrtc.SessionDescription, uint32, error)
|
||||
getOfferMutex sync.RWMutex
|
||||
getOfferArgsForCall []struct {
|
||||
}
|
||||
getOfferReturns struct {
|
||||
result1 webrtc.SessionDescription
|
||||
result2 uint32
|
||||
result3 error
|
||||
}
|
||||
getOfferReturnsOnCall map[int]struct {
|
||||
result1 webrtc.SessionDescription
|
||||
result2 uint32
|
||||
result3 error
|
||||
}
|
||||
GetPacerStub func() pacer.Pacer
|
||||
getPacerMutex sync.RWMutex
|
||||
getPacerArgsForCall []struct {
|
||||
@@ -986,17 +972,6 @@ type FakeLocalParticipant struct {
|
||||
removeTrackLocalReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
SendConnectResponseStub func(*livekit.ConnectResponse) error
|
||||
sendConnectResponseMutex sync.RWMutex
|
||||
sendConnectResponseArgsForCall []struct {
|
||||
arg1 *livekit.ConnectResponse
|
||||
}
|
||||
sendConnectResponseReturns struct {
|
||||
result1 error
|
||||
}
|
||||
sendConnectResponseReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
SendConnectionQualityUpdateStub func(*livekit.ConnectionQualityUpdate) error
|
||||
sendConnectionQualityUpdateMutex sync.RWMutex
|
||||
sendConnectionQualityUpdateArgsForCall []struct {
|
||||
@@ -1204,16 +1179,6 @@ type FakeLocalParticipant struct {
|
||||
setTrackMutedReturnsOnCall map[int]struct {
|
||||
result1 *livekit.TrackInfo
|
||||
}
|
||||
SignalPendingMessagesStub func() proto.Message
|
||||
signalPendingMessagesMutex sync.RWMutex
|
||||
signalPendingMessagesArgsForCall []struct {
|
||||
}
|
||||
signalPendingMessagesReturns struct {
|
||||
result1 proto.Message
|
||||
}
|
||||
signalPendingMessagesReturnsOnCall map[int]struct {
|
||||
result1 proto.Message
|
||||
}
|
||||
StateStub func() livekit.ParticipantInfo_State
|
||||
stateMutex sync.RWMutex
|
||||
stateArgsForCall []struct {
|
||||
@@ -3274,65 +3239,6 @@ func (fake *FakeLocalParticipant) GetLoggerResolverReturnsOnCall(i int, result1
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) GetOffer() (webrtc.SessionDescription, uint32, error) {
|
||||
fake.getOfferMutex.Lock()
|
||||
ret, specificReturn := fake.getOfferReturnsOnCall[len(fake.getOfferArgsForCall)]
|
||||
fake.getOfferArgsForCall = append(fake.getOfferArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.GetOfferStub
|
||||
fakeReturns := fake.getOfferReturns
|
||||
fake.recordInvocation("GetOffer", []interface{}{})
|
||||
fake.getOfferMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2, ret.result3
|
||||
}
|
||||
return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) GetOfferCallCount() int {
|
||||
fake.getOfferMutex.RLock()
|
||||
defer fake.getOfferMutex.RUnlock()
|
||||
return len(fake.getOfferArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) GetOfferCalls(stub func() (webrtc.SessionDescription, uint32, error)) {
|
||||
fake.getOfferMutex.Lock()
|
||||
defer fake.getOfferMutex.Unlock()
|
||||
fake.GetOfferStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) GetOfferReturns(result1 webrtc.SessionDescription, result2 uint32, result3 error) {
|
||||
fake.getOfferMutex.Lock()
|
||||
defer fake.getOfferMutex.Unlock()
|
||||
fake.GetOfferStub = nil
|
||||
fake.getOfferReturns = struct {
|
||||
result1 webrtc.SessionDescription
|
||||
result2 uint32
|
||||
result3 error
|
||||
}{result1, result2, result3}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) GetOfferReturnsOnCall(i int, result1 webrtc.SessionDescription, result2 uint32, result3 error) {
|
||||
fake.getOfferMutex.Lock()
|
||||
defer fake.getOfferMutex.Unlock()
|
||||
fake.GetOfferStub = nil
|
||||
if fake.getOfferReturnsOnCall == nil {
|
||||
fake.getOfferReturnsOnCall = make(map[int]struct {
|
||||
result1 webrtc.SessionDescription
|
||||
result2 uint32
|
||||
result3 error
|
||||
})
|
||||
}
|
||||
fake.getOfferReturnsOnCall[i] = struct {
|
||||
result1 webrtc.SessionDescription
|
||||
result2 uint32
|
||||
result3 error
|
||||
}{result1, result2, result3}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) GetPacer() pacer.Pacer {
|
||||
fake.getPacerMutex.Lock()
|
||||
ret, specificReturn := fake.getPacerReturnsOnCall[len(fake.getPacerArgsForCall)]
|
||||
@@ -6658,67 +6564,6 @@ func (fake *FakeLocalParticipant) RemoveTrackLocalReturnsOnCall(i int, result1 e
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectResponse(arg1 *livekit.ConnectResponse) error {
|
||||
fake.sendConnectResponseMutex.Lock()
|
||||
ret, specificReturn := fake.sendConnectResponseReturnsOnCall[len(fake.sendConnectResponseArgsForCall)]
|
||||
fake.sendConnectResponseArgsForCall = append(fake.sendConnectResponseArgsForCall, struct {
|
||||
arg1 *livekit.ConnectResponse
|
||||
}{arg1})
|
||||
stub := fake.SendConnectResponseStub
|
||||
fakeReturns := fake.sendConnectResponseReturns
|
||||
fake.recordInvocation("SendConnectResponse", []interface{}{arg1})
|
||||
fake.sendConnectResponseMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectResponseCallCount() int {
|
||||
fake.sendConnectResponseMutex.RLock()
|
||||
defer fake.sendConnectResponseMutex.RUnlock()
|
||||
return len(fake.sendConnectResponseArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectResponseCalls(stub func(*livekit.ConnectResponse) error) {
|
||||
fake.sendConnectResponseMutex.Lock()
|
||||
defer fake.sendConnectResponseMutex.Unlock()
|
||||
fake.SendConnectResponseStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectResponseArgsForCall(i int) *livekit.ConnectResponse {
|
||||
fake.sendConnectResponseMutex.RLock()
|
||||
defer fake.sendConnectResponseMutex.RUnlock()
|
||||
argsForCall := fake.sendConnectResponseArgsForCall[i]
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectResponseReturns(result1 error) {
|
||||
fake.sendConnectResponseMutex.Lock()
|
||||
defer fake.sendConnectResponseMutex.Unlock()
|
||||
fake.SendConnectResponseStub = nil
|
||||
fake.sendConnectResponseReturns = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectResponseReturnsOnCall(i int, result1 error) {
|
||||
fake.sendConnectResponseMutex.Lock()
|
||||
defer fake.sendConnectResponseMutex.Unlock()
|
||||
fake.SendConnectResponseStub = nil
|
||||
if fake.sendConnectResponseReturnsOnCall == nil {
|
||||
fake.sendConnectResponseReturnsOnCall = make(map[int]struct {
|
||||
result1 error
|
||||
})
|
||||
}
|
||||
fake.sendConnectResponseReturnsOnCall[i] = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SendConnectionQualityUpdate(arg1 *livekit.ConnectionQualityUpdate) error {
|
||||
fake.sendConnectionQualityUpdateMutex.Lock()
|
||||
ret, specificReturn := fake.sendConnectionQualityUpdateReturnsOnCall[len(fake.sendConnectionQualityUpdateArgsForCall)]
|
||||
@@ -7881,59 +7726,6 @@ func (fake *FakeLocalParticipant) SetTrackMutedReturnsOnCall(i int, result1 *liv
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SignalPendingMessages() proto.Message {
|
||||
fake.signalPendingMessagesMutex.Lock()
|
||||
ret, specificReturn := fake.signalPendingMessagesReturnsOnCall[len(fake.signalPendingMessagesArgsForCall)]
|
||||
fake.signalPendingMessagesArgsForCall = append(fake.signalPendingMessagesArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.SignalPendingMessagesStub
|
||||
fakeReturns := fake.signalPendingMessagesReturns
|
||||
fake.recordInvocation("SignalPendingMessages", []interface{}{})
|
||||
fake.signalPendingMessagesMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SignalPendingMessagesCallCount() int {
|
||||
fake.signalPendingMessagesMutex.RLock()
|
||||
defer fake.signalPendingMessagesMutex.RUnlock()
|
||||
return len(fake.signalPendingMessagesArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SignalPendingMessagesCalls(stub func() proto.Message) {
|
||||
fake.signalPendingMessagesMutex.Lock()
|
||||
defer fake.signalPendingMessagesMutex.Unlock()
|
||||
fake.SignalPendingMessagesStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SignalPendingMessagesReturns(result1 proto.Message) {
|
||||
fake.signalPendingMessagesMutex.Lock()
|
||||
defer fake.signalPendingMessagesMutex.Unlock()
|
||||
fake.SignalPendingMessagesStub = nil
|
||||
fake.signalPendingMessagesReturns = struct {
|
||||
result1 proto.Message
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) SignalPendingMessagesReturnsOnCall(i int, result1 proto.Message) {
|
||||
fake.signalPendingMessagesMutex.Lock()
|
||||
defer fake.signalPendingMessagesMutex.Unlock()
|
||||
fake.SignalPendingMessagesStub = nil
|
||||
if fake.signalPendingMessagesReturnsOnCall == nil {
|
||||
fake.signalPendingMessagesReturnsOnCall = make(map[int]struct {
|
||||
result1 proto.Message
|
||||
})
|
||||
}
|
||||
fake.signalPendingMessagesReturnsOnCall[i] = struct {
|
||||
result1 proto.Message
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeLocalParticipant) State() livekit.ParticipantInfo_State {
|
||||
fake.stateMutex.Lock()
|
||||
ret, specificReturn := fake.stateReturnsOnCall[len(fake.stateArgsForCall)]
|
||||
@@ -9341,8 +9133,6 @@ func (fake *FakeLocalParticipant) Invocations() map[string][][]interface{} {
|
||||
defer fake.getLoggerMutex.RUnlock()
|
||||
fake.getLoggerResolverMutex.RLock()
|
||||
defer fake.getLoggerResolverMutex.RUnlock()
|
||||
fake.getOfferMutex.RLock()
|
||||
defer fake.getOfferMutex.RUnlock()
|
||||
fake.getPacerMutex.RLock()
|
||||
defer fake.getPacerMutex.RUnlock()
|
||||
fake.getPendingTrackMutex.RLock()
|
||||
@@ -9487,8 +9277,6 @@ func (fake *FakeLocalParticipant) Invocations() map[string][][]interface{} {
|
||||
defer fake.removePublishedTrackMutex.RUnlock()
|
||||
fake.removeTrackLocalMutex.RLock()
|
||||
defer fake.removeTrackLocalMutex.RUnlock()
|
||||
fake.sendConnectResponseMutex.RLock()
|
||||
defer fake.sendConnectResponseMutex.RUnlock()
|
||||
fake.sendConnectionQualityUpdateMutex.RLock()
|
||||
defer fake.sendConnectionQualityUpdateMutex.RUnlock()
|
||||
fake.sendDataMessageMutex.RLock()
|
||||
@@ -9535,8 +9323,6 @@ func (fake *FakeLocalParticipant) Invocations() map[string][][]interface{} {
|
||||
defer fake.setSubscriberChannelCapacityMutex.RUnlock()
|
||||
fake.setTrackMutedMutex.RLock()
|
||||
defer fake.setTrackMutedMutex.RUnlock()
|
||||
fake.signalPendingMessagesMutex.RLock()
|
||||
defer fake.signalPendingMessagesMutex.RUnlock()
|
||||
fake.stateMutex.RLock()
|
||||
defer fake.stateMutex.RUnlock()
|
||||
fake.stopAndGetSubscribedTracksForwarderStateMutex.RLock()
|
||||
|
||||
@@ -171,25 +171,3 @@ func MaybeTruncateIP(addr string) string {
|
||||
|
||||
return addr[:len(addr)-3] + "..."
|
||||
}
|
||||
|
||||
func Signalv2FragmentsAsSignalv2WireMessages(fragments []*livekit.Fragment) []*livekit.Signalv2WireMessage {
|
||||
msgs := make([]*livekit.Signalv2WireMessage, len(fragments))
|
||||
for idx, fragment := range fragments {
|
||||
msgs[idx] = &livekit.Signalv2WireMessage{
|
||||
Message: &livekit.Signalv2WireMessage_Fragment{
|
||||
Fragment: fragment,
|
||||
},
|
||||
}
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
|
||||
func EnvelopeSignalv2ServerMessages(msgs []*livekit.Signalv2ServerMessage) *livekit.Signalv2WireMessage {
|
||||
return &livekit.Signalv2WireMessage{
|
||||
Message: &livekit.Signalv2WireMessage_Envelope{
|
||||
Envelope: &livekit.Envelope{
|
||||
ServerMessages: msgs,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user