fix subscription update on codec change (#757)

This commit is contained in:
cnderrauber
2022-06-10 12:31:34 +08:00
committed by GitHub
parent b81694b664
commit 15da445fd7
3 changed files with 5 additions and 6 deletions
+2 -4
View File
@@ -224,9 +224,6 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr *
})
downTrack.OnMaxLayerChanged(func(dt *sfu.DownTrack, layer int32) {
if dt.Codec().MimeType == "" {
t.params.Logger.Errorw("codec mime type is empty", nil)
}
go t.notifySubscriberMaxQuality(subscriberID, dt.Codec(), QualityForSpatialLayer(layer))
})
@@ -438,10 +435,11 @@ func (t *MediaTrackSubscriptions) notifySubscriberMaxQuality(subscriberID liveki
} else {
maxQuality, ok := t.maxSubscriberQuality[subscriberID]
if ok {
if maxQuality.Quality == quality {
if maxQuality.Quality == quality && maxQuality.CodecMime == codec.MimeType {
t.maxQualityLock.Unlock()
return
}
maxQuality.CodecMime = codec.MimeType
maxQuality.Quality = quality
} else {
t.maxSubscriberQuality[subscriberID] = &types.SubscribedCodecQuality{
+1 -1
View File
@@ -209,7 +209,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
Config: params.Config,
CongestionControlConfig: params.CongestionControlConfig,
Telemetry: p.params.Telemetry,
EnabledCodecs: p.params.EnabledCodecs,
EnabledCodecs: enabledCodecs,
Logger: LoggerWithPCTarget(params.Logger, livekit.SignalTarget_SUBSCRIBER),
})
if err != nil {
+2 -1
View File
@@ -694,7 +694,8 @@ func (d *DownTrack) SetMaxSpatialLayer(spatialLayer int32) {
return
}
if d.onMaxLayerChanged != nil && d.kind == webrtc.RTPCodecTypeVideo && maxLayers.SpatialGreaterThanOrEqual(currentLayers) {
if d.onMaxLayerChanged != nil && d.kind == webrtc.RTPCodecTypeVideo &&
maxLayers.SpatialGreaterThanOrEqual(currentLayers) && d.bound.Load() {
//
// Notify when new max is
// 1. Equal to current -> already locked to the new max