Skip to content

Commit 2a0dc39

Browse files
dbkrrobertlong
authored andcommitted
Fix bug with ine-way audio after a transfer (#2193)
Seems chrome at least will give you a disabled audio track if you already had another user media audio track and disabled it, so make sure our tracks are enabled when we add them. We already did this on one code path but it didn't get moved over when a new code path was added. On the plus side, we now know the reason for the ancient code that had the comment asking what it was for, so update that.
1 parent 6e25b13 commit 2a0dc39

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/webrtc/call.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -603,9 +603,11 @@ export class MatrixCall extends EventEmitter {
603603
private pushNewLocalFeed(stream: MediaStream, purpose: SDPStreamMetadataPurpose, addToPeerConnection = true): void {
604604
const userId = this.client.getUserId();
605605

606-
// TODO: Find out what is going on here
607-
// why do we enable audio (and only audio) tracks here? -- matthew
606+
// Tracks don't always start off enabled, eg. chrome will give a disabled
607+
// audio track if you ask for user media audio and already had one that
608+
// you'd set to disabled (presumably because it clones them internally).
608609
setTracksEnabled(stream.getAudioTracks(), true);
610+
setTracksEnabled(stream.getVideoTracks(), true);
609611

610612
// We try to replace an existing feed if there already is one with the same purpose
611613
const existingFeed = this.getLocalFeeds().find((feed) => feed.purpose === purpose);
@@ -654,7 +656,8 @@ export class MatrixCall extends EventEmitter {
654656
`id="${track.id}", ` +
655657
`kind="${track.kind}", ` +
656658
`streamId="${callFeed.stream.id}", ` +
657-
`streamPurpose="${callFeed.purpose}"` +
659+
`streamPurpose="${callFeed.purpose}", ` +
660+
`enabled=${track.enabled}` +
658661
`) to peer connection`,
659662
);
660663
senderArray.push(this.peerConn.addTrack(track, callFeed.stream));
@@ -2298,6 +2301,12 @@ export class MatrixCall extends EventEmitter {
22982301

22992302
try {
23002303
const stream = await this.client.getMediaHandler().getUserMediaStream(audio, video);
2304+
2305+
// make sure all the tracks are enabled (same as pushNewLocalFeed -
2306+
// we probably ought to just have one code path for adding streams)
2307+
setTracksEnabled(stream.getAudioTracks(), true);
2308+
setTracksEnabled(stream.getVideoTracks(), true);
2309+
23012310
const callFeed = new CallFeed({
23022311
client: this.client,
23032312
roomId: this.roomId,

0 commit comments

Comments
 (0)