Skip to content

Commit 81737da

Browse files
authored
Fix client not setting msid for camera video tracks (#518)
## Description Root cause: createSimulcastTransceiverConfig in transceivers.ts was missing the streams field in its return object. Audio and non-simulcast video both had it, but simulcast video did not so the browser sent the simulcast track with no stream ID in the SDP (a=msid:- ...), causing the server to see streams: [] for the video track while audio got the correct stream ID. ## Motivation and Context Why is this change required? What problem does it solve? If it fixes an open issue, please link to the issue here. ## Documentation impact - [ ] Documentation update required - [ ] Documentation updated [in another PR](_) - [x] No documentation update required ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
1 parent b68ff22 commit 81737da

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

packages/webrtc-client/src/tracks/transceivers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const createSimulcastTransceiverConfig = (
9999
// in other case lower resolution encoding can get
100100
// higher max_bitrate
101101
sendEncodings: calculateSimulcastEncodings(encodings, maxBandwidth),
102+
streams: trackContext.stream ? [trackContext.stream] : [],
102103
};
103104
};
104105

packages/webrtc-client/tests/methods/addTrackMethod.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { FakeMediaStreamTrack } from 'fake-mediastreamtrack';
12
import { expect, it } from 'vitest';
23

3-
import { WebRTCEndpoint } from '../../src';
4+
import { Variant, WebRTCEndpoint } from '../../src';
5+
import { TrackContextImpl } from '../../src/internal';
46
import { deserializePeerMediaEvent, serializeServerMediaEvent } from '../../src/mediaEvent';
7+
import { createTransceiverConfig } from '../../src/tracks/transceivers';
58
import { createConnectedEventWithOneEndpoint, mockTrack } from '../fixtures';
69
import { mockMediaStream, mockRTCPeerConnection } from '../mocks';
710

@@ -51,6 +54,29 @@ it('Adding track updates internal state', () => {
5154
expect(localEndpoint.tracks.size).toBe(1);
5255
});
5356

57+
it('Simulcast transceiver config includes the stream', () => {
58+
const stream = { id: 'test-stream-id' } as MediaStream;
59+
const videoTrack = new FakeMediaStreamTrack({ kind: 'video' });
60+
61+
const trackContext = new TrackContextImpl(
62+
{ id: 'endpoint-1', type: 'webrtc', metadata: undefined, tracks: new Map() },
63+
'track-1',
64+
undefined,
65+
{
66+
enabled: true,
67+
enabledVariants: [Variant.VARIANT_LOW, Variant.VARIANT_MEDIUM, Variant.VARIANT_HIGH],
68+
disabledVariants: [],
69+
},
70+
);
71+
trackContext.track = videoTrack;
72+
trackContext.stream = stream;
73+
trackContext.maxBandwidth = 0;
74+
75+
const config = createTransceiverConfig(trackContext);
76+
77+
expect(config.streams).toEqual([stream]);
78+
});
79+
5480
it('Adding track before being accepted by the server throws error', async () => {
5581
// Given
5682
mockRTCPeerConnection();

0 commit comments

Comments
 (0)