mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 17:45:40 +00:00
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
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -118,10 +118,7 @@ func (u *UpTrackManager) OnPublishedTrackUpdated(f func(track types.MediaTrack))
|
||||
}
|
||||
|
||||
func (u *UpTrackManager) SetPublishedTrackMuted(trackID livekit.TrackID, muted bool) types.MediaTrack {
|
||||
u.lock.RLock()
|
||||
track := u.publishedTracks[trackID]
|
||||
u.lock.RUnlock()
|
||||
|
||||
track := u.GetPublishedTrack(trackID)
|
||||
if track != nil {
|
||||
currentMuted := track.IsMuted()
|
||||
track.SetMuted(muted)
|
||||
@@ -236,34 +233,28 @@ func (u *UpTrackManager) HasPermission(trackID livekit.TrackID, subIdentity live
|
||||
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))
|
||||
if track == nil {
|
||||
u.params.Logger.Warnw("could not find track", nil, "trackID", livekit.TrackID(update.TrackSid))
|
||||
return errors.New("could not find published track")
|
||||
if track != nil {
|
||||
track.UpdateAudioTrack(update)
|
||||
if u.onTrackUpdated != nil {
|
||||
u.onTrackUpdated(track)
|
||||
}
|
||||
}
|
||||
|
||||
track.UpdateAudioTrack(update)
|
||||
if u.onTrackUpdated != nil {
|
||||
u.onTrackUpdated(track)
|
||||
}
|
||||
|
||||
return nil
|
||||
return track
|
||||
}
|
||||
|
||||
func (u *UpTrackManager) UpdateVideoTrack(update *livekit.UpdateLocalVideoTrack) error {
|
||||
func (u *UpTrackManager) UpdatePublishedVideoTrack(update *livekit.UpdateLocalVideoTrack) types.MediaTrack {
|
||||
track := u.GetPublishedTrack(livekit.TrackID(update.TrackSid))
|
||||
if track == nil {
|
||||
u.params.Logger.Warnw("could not find track", nil, "trackID", livekit.TrackID(update.TrackSid))
|
||||
return errors.New("could not find published track")
|
||||
if track != nil {
|
||||
track.UpdateVideoTrack(update)
|
||||
if u.onTrackUpdated != nil {
|
||||
u.onTrackUpdated(track)
|
||||
}
|
||||
}
|
||||
|
||||
track.UpdateVideoTrack(update)
|
||||
if u.onTrackUpdated != nil {
|
||||
u.onTrackUpdated(track)
|
||||
}
|
||||
|
||||
return nil
|
||||
return track
|
||||
}
|
||||
|
||||
func (u *UpTrackManager) AddPublishedTrack(track types.MediaTrack) {
|
||||
|
||||
Reference in New Issue
Block a user