Skip to content

Commit

Permalink
Update uplink policy at codec degradation triggered by encoding healt…
Browse files Browse the repository at this point in the history
…h monitor (#2942)


---------

Co-authored-by: Shi Su <shisuss@amazon.com>
  • Loading branch information
shi-su and Shi Su authored Aug 29, 2024
1 parent 5987ecd commit 2687f23
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Update uplink policy at codec degradation triggered by encoding health monitor.

## [3.23.0] - 2024-05-14

### Added
Expand Down
8 changes: 8 additions & 0 deletions src/task/MonitorTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@ export default class MonitorTask
this.context.meetingSupportedVideoSendCodecPreferences[0]
);
this.context.meetingSupportedVideoSendCodecPreferences = newMeetingSupportedVideoSendCodecPreferences;

if (this.context.videoUplinkBandwidthPolicy.setMeetingSupportedVideoSendCodecs) {
this.context.videoUplinkBandwidthPolicy.setMeetingSupportedVideoSendCodecs(
this.context.meetingSupportedVideoSendCodecPreferences,
this.context.videoSendCodecPreferences
);
}

this.context.audioVideoController.update({ needsRenegotiation: true });
} else {
this.context.logger.warn(
Expand Down
25 changes: 24 additions & 1 deletion test/task/MonitorTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import DefaultVideoTileController from '../../src/videotilecontroller/DefaultVid
import DefaultVideoTileFactory from '../../src/videotilefactory/DefaultVideoTileFactory';
import DefaultSimulcastUplinkPolicy from '../../src/videouplinkbandwidthpolicy/DefaultSimulcastUplinkPolicy';
import NoVideoUplinkBandwidthPolicy from '../../src/videouplinkbandwidthpolicy/NoVideoUplinkBandwidthPolicy';
import NScaleVideoUplinkBandwidthPolicy from '../../src/videouplinkbandwidthpolicy/NScaleVideoUplinkBandwidthPolicy';
import DefaultWebSocketAdapter from '../../src/websocketadapter/DefaultWebSocketAdapter';
import DOMMockBehavior from '../dommock/DOMMockBehavior';
import DOMMockBuilder from '../dommock/DOMMockBuilder';
Expand Down Expand Up @@ -1460,7 +1461,7 @@ describe('MonitorTask', () => {
).to.be.true;
});

it('should degrade when there is more than one codec preferences', async () => {
it('should degrade when there is more than one codec preferences with NScaleVideoUplinkBandwidthPolicy', async () => {
context.meetingSupportedVideoSendCodecPreferences = [
VideoCodecCapability.vp9Profile0(),
VideoCodecCapability.vp8(),
Expand All @@ -1469,6 +1470,28 @@ describe('MonitorTask', () => {
VideoCodecCapability.vp9Profile0(),
VideoCodecCapability.vp8(),
];
context.videoUplinkBandwidthPolicy = new NScaleVideoUplinkBandwidthPolicy(
'self',
true,
logger
);
// @ts-ignore
task.degradeVideoCodec();
expect(
context.meetingSupportedVideoSendCodecPreferences[0].equals(VideoCodecCapability.vp8())
).to.be.true;
});

it('should degrade when there is more than one codec preferences with DefaultSimulcastUplinkPolicy', async () => {
context.meetingSupportedVideoSendCodecPreferences = [
VideoCodecCapability.vp9Profile0(),
VideoCodecCapability.vp8(),
];
context.videoSendCodecPreferences = [
VideoCodecCapability.vp9Profile0(),
VideoCodecCapability.vp8(),
];
context.videoUplinkBandwidthPolicy = new DefaultSimulcastUplinkPolicy('self', logger);
// @ts-ignore
task.degradeVideoCodec();
expect(
Expand Down

0 comments on commit 2687f23

Please sign in to comment.