Skip to content

Commit

Permalink
fix: don't send none layer request for degradation (#3285)
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Sep 23, 2024
1 parent 8ef183a commit 53b7370
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/hms-video-store/src/media/tracks/HMSRemoteVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ export class HMSRemoteVideoTrack extends HMSVideoTrack {
* @returns {boolean} isDegraded - returns true if degraded
* */
setLayerFromServer(layerUpdate: VideoTrackLayerUpdate) {
this._degraded =
this.enabled &&
(layerUpdate.publisher_degraded || layerUpdate.subscriber_degraded) &&
layerUpdate.current_layer === HMSSimulcastLayer.NONE;
this._degraded = this.getDegradationValue(layerUpdate);
this._degradedAt = this._degraded ? new Date() : this._degradedAt;
const currentLayer = layerUpdate.current_layer;
HMSLogger.d(
Expand All @@ -171,11 +168,22 @@ export class HMSRemoteVideoTrack extends HMSVideoTrack {
return this._degraded;
}

private getDegradationValue(layerUpdate: VideoTrackLayerUpdate) {
return (
this.enabled &&
(layerUpdate.publisher_degraded || layerUpdate.subscriber_degraded) &&
layerUpdate.current_layer === HMSSimulcastLayer.NONE
);
}

private async updateLayer(source: string) {
const newLayer =
(this.degraded || !this.enabled || !this.hasSinks()) && !this.disableNoneLayerRequest
? HMSSimulcastLayer.NONE
: this.preferredLayer;
let newLayer: HMSSimulcastLayer = this.preferredLayer;
if (this.enabled && this.hasSinks()) {
newLayer = this.preferredLayer;
// send none only when the flag is not set
} else if (!this.disableNoneLayerRequest) {
newLayer = HMSSimulcastLayer.NONE;
}
if (!this.shouldSendVideoLayer(newLayer, source)) {
return;
}
Expand Down

0 comments on commit 53b7370

Please sign in to comment.