Skip to content

Commit

Permalink
tests for changePublishQuality
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlaz committed Oct 10, 2024
1 parent ce5ffaa commit da0e4fb
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions packages/client/src/rtc/__tests__/Publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ vi.mock('../../StreamSfuClient', () => {
};
});

vi.mock('../codecs', () => {
vi.mock('../codecs', async () => {
const codecs = await vi.importActual('../codecs');
return {
getPreferredCodecs: vi.fn((): RTCRtpCodecCapability[] => [
{
Expand All @@ -27,7 +28,7 @@ vi.mock('../codecs', () => {
sdpFmtpLine: 'profile-level-id=42e01f',
},
]),
isSvcCodec: vi.fn(() => false),
isSvcCodec: codecs.isSvcCodec,
};
});

Expand Down Expand Up @@ -418,5 +419,54 @@ describe('Publisher', () => {
},
]);
});

it('supports empty rid in SVC', async () => {
const transceiver = new RTCRtpTransceiver();
const setParametersSpy = vi
.spyOn(transceiver.sender, 'setParameters')
.mockResolvedValue();
const getParametersSpy = vi
.spyOn(transceiver.sender, 'getParameters')
.mockReturnValue({
codecs: [
// @ts-expect-error incomplete data
{ mimeType: 'video/VP9' },
],
encodings: [
{
rid: undefined, // empty rid
active: true,
// @ts-expect-error not in the standard lib yet
scalabilityMode: 'L3T3_KEY',
},
],
});

// inject the transceiver
publisher['transceiverRegistry'][TrackType.VIDEO] = transceiver;

await publisher['changePublishQuality']([
{
name: 'q',
active: true,
maxBitrate: 50,
scaleResolutionDownBy: 1,
maxFramerate: 30,
scalabilityMode: 'L1T3',
},
]);

expect(getParametersSpy).toHaveBeenCalled();
expect(setParametersSpy).toHaveBeenCalled();
expect(setParametersSpy.mock.calls[0][0].encodings).toEqual([
{
active: true,
maxBitrate: 50,
scaleResolutionDownBy: 1,
maxFramerate: 30,
scalabilityMode: 'L1T3',
},
]);
});
});
});

0 comments on commit da0e4fb

Please sign in to comment.