Handle UpdateLocalAudioTrack and UpdateLocalVideoTrack. (#2684)

* Handle UpdateLocalAudioTrack and UpdateLocalVideoTrack.

- Update the TrackInfo
- NOTE: populating Stereo and DisableDtx fields although there are
  features now.
- The audio features in UpdateLocalAudioTrack is applied as is,
  i. e. the update has the latest set of features.
- Emits a track update which will broadcast a participant update.

TODO:
-----
- Telemetry event with track update?

* update deps
This commit is contained in:
Raja Subramanian
2024-04-26 12:06:35 +05:30
committed by GitHub
parent b55038af03
commit 90b47424b5
11 changed files with 588 additions and 42 deletions
+30
View File
@@ -254,6 +254,36 @@ func (u *UpTrackManager) UpdateVideoLayers(updateVideoLayers *livekit.UpdateVide
return nil
}
func (u *UpTrackManager) UpdateAudioTrack(update *livekit.UpdateLocalAudioTrack) error {
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")
}
track.UpdateAudioTrack(update)
if u.onTrackUpdated != nil {
u.onTrackUpdated(track)
}
return nil
}
func (u *UpTrackManager) UpdateVideoTrack(update *livekit.UpdateLocalVideoTrack) error {
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")
}
track.UpdateVideoTrack(update)
if u.onTrackUpdated != nil {
u.onTrackUpdated(track)
}
return nil
}
func (u *UpTrackManager) AddPublishedTrack(track types.MediaTrack) {
u.lock.Lock()
if _, ok := u.publishedTracks[track.ID()]; !ok {