Rpcs for ingress proxy WHIP (#3911)
See https://github.com/livekit/protocol/pull/1194
This commit is contained in:
+29
-14
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/atomic"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"golang.org/x/exp/maps"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/mediatransportutil/pkg/twcc"
|
||||
@@ -305,7 +306,7 @@ type ParticipantImpl struct {
|
||||
migrateState atomic.Value // types.MigrateState
|
||||
migratedTracksPublishedFuse core.Fuse
|
||||
|
||||
onClose func(types.LocalParticipant)
|
||||
onClose map[string]func(types.LocalParticipant)
|
||||
onClaimsChanged func(participant types.LocalParticipant)
|
||||
onICEConfigChanged func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)
|
||||
|
||||
@@ -359,6 +360,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
joiningMessageFirstSeqs: make(map[livekit.ParticipantID]uint32),
|
||||
joiningMessageLastWrittenSeqs: make(map[livekit.ParticipantID]uint32),
|
||||
},
|
||||
onClose: make(map[string]func(types.LocalParticipant)),
|
||||
}
|
||||
p.setupSignalling()
|
||||
|
||||
@@ -1048,14 +1050,18 @@ func (p *ParticipantImpl) getOnLeave() func(types.LocalParticipant, types.Partic
|
||||
return p.onLeave
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) OnClose(callback func(types.LocalParticipant)) {
|
||||
func (p *ParticipantImpl) AddOnClose(key string, callback func(types.LocalParticipant)) {
|
||||
if p.isClosed.Load() {
|
||||
go callback(p)
|
||||
return
|
||||
}
|
||||
|
||||
p.lock.Lock()
|
||||
p.onClose = callback
|
||||
if callback == nil {
|
||||
delete(p.onClose, key)
|
||||
} else {
|
||||
p.onClose[key] = callback
|
||||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
@@ -1505,10 +1511,10 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
|
||||
// ensure this is synchronized
|
||||
p.CloseSignalConnection(types.SignallingCloseReasonParticipantClose)
|
||||
p.lock.RLock()
|
||||
onClose := p.onClose
|
||||
onClose := maps.Values(p.onClose)
|
||||
p.lock.RUnlock()
|
||||
if onClose != nil {
|
||||
onClose(p)
|
||||
for _, cb := range onClose {
|
||||
cb(p)
|
||||
}
|
||||
|
||||
// Close peer connections without blocking participant Close. If peer connections are gathering candidates
|
||||
@@ -2851,9 +2857,14 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
|
||||
if len(req.SimulcastCodecs) == 0 {
|
||||
// clients not supporting simulcast codecs, synthesise a codec
|
||||
videoLayerMode := livekit.VideoLayer_MODE_UNUSED
|
||||
if p.params.ClientInfo.isOBS() {
|
||||
videoLayerMode = livekit.VideoLayer_ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR
|
||||
}
|
||||
ti.Codecs = append(ti.Codecs, &livekit.SimulcastCodecInfo{
|
||||
Cid: req.Cid,
|
||||
Layers: cloneLayers(req.Layers),
|
||||
Cid: req.Cid,
|
||||
Layers: cloneLayers(req.Layers),
|
||||
VideoLayerMode: videoLayerMode,
|
||||
})
|
||||
} else {
|
||||
seenCodecs := make(map[string]struct{})
|
||||
@@ -2888,7 +2899,11 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
if mime.IsMimeTypeStringSVC(mimeType) {
|
||||
videoLayerMode = livekit.VideoLayer_MULTIPLE_SPATIAL_LAYERS_PER_STREAM
|
||||
} else {
|
||||
videoLayerMode = livekit.VideoLayer_ONE_SPATIAL_LAYER_PER_STREAM
|
||||
if p.params.ClientInfo.isOBS() {
|
||||
videoLayerMode = livekit.VideoLayer_ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR
|
||||
} else {
|
||||
videoLayerMode = livekit.VideoLayer_ONE_SPATIAL_LAYER_PER_STREAM
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if req.Type == livekit.TrackType_AUDIO {
|
||||
@@ -3966,8 +3981,8 @@ func (p *ParticipantImpl) SupportsMoving() error {
|
||||
return ErrMoveOldClientVersion
|
||||
}
|
||||
|
||||
if kind := p.Kind(); kind == livekit.ParticipantInfo_EGRESS || kind == livekit.ParticipantInfo_AGENT {
|
||||
return fmt.Errorf("%s participants cannot be moved", kind.String())
|
||||
if kind := p.Kind(); kind == livekit.ParticipantInfo_EGRESS || kind == livekit.ParticipantInfo_AGENT || p.params.UseOneShotSignallingMode {
|
||||
return fmt.Errorf("%s participants cannot be moved, one-shot signaling mode: %t", kind.String(), p.params.UseOneShotSignallingMode)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -3977,10 +3992,10 @@ func (p *ParticipantImpl) MoveToRoom(params types.MoveToRoomParams) {
|
||||
// fire onClose callback for original room
|
||||
p.lock.Lock()
|
||||
onClose := p.onClose
|
||||
p.onClose = nil
|
||||
p.onClose = make(map[string]func(types.LocalParticipant))
|
||||
p.lock.Unlock()
|
||||
if onClose != nil {
|
||||
onClose(p)
|
||||
for _, cb := range onClose {
|
||||
cb(p)
|
||||
}
|
||||
|
||||
for _, track := range p.GetPublishedTracks() {
|
||||
|
||||
Reference in New Issue
Block a user