Support updating local track features when pending. (#2863)
This commit is contained in:
@@ -2652,3 +2652,64 @@ func (p *ParticipantImpl) setupEnabledCodecs(publishEnabledCodecs []*livekit.Cod
|
|||||||
}
|
}
|
||||||
p.enabledSubscribeCodecs = subscribeCodecs
|
p.enabledSubscribeCodecs = subscribeCodecs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ParticipantImpl) UpdateAudioTrack(update *livekit.UpdateLocalAudioTrack) error {
|
||||||
|
if track := p.UpTrackManager.UpdatePublishedAudioTrack(update); track != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
isPending := false
|
||||||
|
p.pendingTracksLock.RLock()
|
||||||
|
for _, pti := range p.pendingTracks {
|
||||||
|
for _, ti := range pti.trackInfos {
|
||||||
|
if ti.Sid == update.TrackSid {
|
||||||
|
isPending = true
|
||||||
|
|
||||||
|
ti.AudioFeatures = update.Features
|
||||||
|
ti.Stereo = false
|
||||||
|
ti.DisableDtx = false
|
||||||
|
for _, feature := range update.Features {
|
||||||
|
switch feature {
|
||||||
|
case livekit.AudioTrackFeature_TF_STEREO:
|
||||||
|
ti.Stereo = true
|
||||||
|
case livekit.AudioTrackFeature_TF_NO_DTX:
|
||||||
|
ti.DisableDtx = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.pendingTracksLock.RUnlock()
|
||||||
|
if isPending {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
p.pubLogger.Debugw("could not locate track", "trackID", update.TrackSid)
|
||||||
|
return errors.New("could not find track")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ParticipantImpl) UpdateVideoTrack(update *livekit.UpdateLocalVideoTrack) error {
|
||||||
|
if track := p.UpTrackManager.UpdatePublishedVideoTrack(update); track != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
isPending := false
|
||||||
|
p.pendingTracksLock.RLock()
|
||||||
|
for _, pti := range p.pendingTracks {
|
||||||
|
for _, ti := range pti.trackInfos {
|
||||||
|
if ti.Sid == update.TrackSid {
|
||||||
|
isPending = true
|
||||||
|
|
||||||
|
ti.Width = update.Width
|
||||||
|
ti.Height = update.Height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.pendingTracksLock.RUnlock()
|
||||||
|
if isPending {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
p.pubLogger.Debugw("could not locate track", "trackID", update.TrackSid)
|
||||||
|
return errors.New("could not find track")
|
||||||
|
}
|
||||||
|
|||||||
+15
-24
@@ -118,10 +118,7 @@ func (u *UpTrackManager) OnPublishedTrackUpdated(f func(track types.MediaTrack))
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpTrackManager) SetPublishedTrackMuted(trackID livekit.TrackID, muted bool) types.MediaTrack {
|
func (u *UpTrackManager) SetPublishedTrackMuted(trackID livekit.TrackID, muted bool) types.MediaTrack {
|
||||||
u.lock.RLock()
|
track := u.GetPublishedTrack(trackID)
|
||||||
track := u.publishedTracks[trackID]
|
|
||||||
u.lock.RUnlock()
|
|
||||||
|
|
||||||
if track != nil {
|
if track != nil {
|
||||||
currentMuted := track.IsMuted()
|
currentMuted := track.IsMuted()
|
||||||
track.SetMuted(muted)
|
track.SetMuted(muted)
|
||||||
@@ -236,34 +233,28 @@ func (u *UpTrackManager) HasPermission(trackID livekit.TrackID, subIdentity live
|
|||||||
return u.hasPermissionLocked(trackID, subIdentity)
|
return u.hasPermissionLocked(trackID, subIdentity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpTrackManager) UpdateAudioTrack(update *livekit.UpdateLocalAudioTrack) error {
|
func (u *UpTrackManager) UpdatePublishedAudioTrack(update *livekit.UpdateLocalAudioTrack) types.MediaTrack {
|
||||||
track := u.GetPublishedTrack(livekit.TrackID(update.TrackSid))
|
track := u.GetPublishedTrack(livekit.TrackID(update.TrackSid))
|
||||||
if track == nil {
|
if track != nil {
|
||||||
u.params.Logger.Warnw("could not find track", nil, "trackID", livekit.TrackID(update.TrackSid))
|
track.UpdateAudioTrack(update)
|
||||||
return errors.New("could not find published track")
|
if u.onTrackUpdated != nil {
|
||||||
|
u.onTrackUpdated(track)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
track.UpdateAudioTrack(update)
|
return track
|
||||||
if u.onTrackUpdated != nil {
|
|
||||||
u.onTrackUpdated(track)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpTrackManager) UpdateVideoTrack(update *livekit.UpdateLocalVideoTrack) error {
|
func (u *UpTrackManager) UpdatePublishedVideoTrack(update *livekit.UpdateLocalVideoTrack) types.MediaTrack {
|
||||||
track := u.GetPublishedTrack(livekit.TrackID(update.TrackSid))
|
track := u.GetPublishedTrack(livekit.TrackID(update.TrackSid))
|
||||||
if track == nil {
|
if track != nil {
|
||||||
u.params.Logger.Warnw("could not find track", nil, "trackID", livekit.TrackID(update.TrackSid))
|
track.UpdateVideoTrack(update)
|
||||||
return errors.New("could not find published track")
|
if u.onTrackUpdated != nil {
|
||||||
|
u.onTrackUpdated(track)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
track.UpdateVideoTrack(update)
|
return track
|
||||||
if u.onTrackUpdated != nil {
|
|
||||||
u.onTrackUpdated(track)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpTrackManager) AddPublishedTrack(track types.MediaTrack) {
|
func (u *UpTrackManager) AddPublishedTrack(track types.MediaTrack) {
|
||||||
|
|||||||
Reference in New Issue
Block a user