Skip to content

Commit

Permalink
Merge branch 'lukas/leave-reason' of github.com:livekit/client-sdk-js…
Browse files Browse the repository at this point in the history
… into lukas/leave-reason
  • Loading branch information
lukasIO committed Jul 2, 2022
2 parents 02953f2 + 6382b29 commit f3ae020
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-forks-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Do not stop tracks that are userProvided during mute
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setLogLevel, setLogExtension, LogLevel } from './logger';
import { LogLevel, setLogExtension, setLogLevel } from './logger';
import { DataPacket_Kind, VideoQuality, DisconnectReason } from './proto/livekit_models';
import LocalParticipant from './room/participant/LocalParticipant';
import Participant, { ConnectionQuality } from './room/participant/Participant';
Expand All @@ -14,6 +14,7 @@ import RemoteTrack from './room/track/RemoteTrack';
import RemoteTrackPublication from './room/track/RemoteTrackPublication';
import RemoteVideoTrack, { ElementInfo } from './room/track/RemoteVideoTrack';
import { TrackPublication } from './room/track/TrackPublication';
import { getEmptyAudioStreamTrack, getEmptyVideoStreamTrack } from './room/utils';

export * from './options';
export * from './room/errors';
Expand All @@ -26,6 +27,8 @@ export * from './version';
export {
setLogLevel,
setLogExtension,
getEmptyAudioStreamTrack,
getEmptyVideoStreamTrack,
LogLevel,
Room,
ConnectionState,
Expand Down
2 changes: 1 addition & 1 deletion src/room/track/LocalAudioTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class LocalAudioTrack extends LocalTrack {
async mute(): Promise<LocalAudioTrack> {
await this.muteQueue.run(async () => {
// disabled special handling as it will cause BT headsets to switch communication modes
if (this.source === Track.Source.Microphone && this.stopOnMute) {
if (this.source === Track.Source.Microphone && this.stopOnMute && !this.isUserProvided) {
log.debug('stopping mic track');
// also stop the track, so that microphone indicator is turned off
this._mediaStreamTrack.stop();
Expand Down
6 changes: 4 additions & 2 deletions src/room/track/LocalTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import log from '../../logger';
import DeviceManager from '../DeviceManager';
import { TrackInvalidError } from '../errors';
import { TrackEvent } from '../events';
import { VideoCodec } from './options';
import { getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, isMobile } from '../utils';
import { VideoCodec } from './options';
import { attachToElement, detachTrack, Track } from './Track';

export default class LocalTrack extends Track {
Expand Down Expand Up @@ -105,7 +105,9 @@ export default class LocalTrack extends Track {
// on Safari, the old audio track must be stopped before attempting to acquire
// the new track, otherwise the new track will stop with
// 'A MediaStreamTrack ended due to a capture failure`
this._mediaStreamTrack.stop();
if (!this.providedByUser) {
this._mediaStreamTrack.stop();
}

track.addEventListener('ended', this.handleEnded);
log.debug('replace MediaStreamTrack');
Expand Down
2 changes: 1 addition & 1 deletion src/room/track/LocalVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class LocalVideoTrack extends LocalTrack {

async mute(): Promise<LocalVideoTrack> {
await this.muteQueue.run(async () => {
if (this.source === Track.Source.Camera) {
if (this.source === Track.Source.Camera && !this.isUserProvided) {
log.debug('stopping camera track');
// also stop the track, so that camera indicator is turned off
this._mediaStreamTrack.stop();
Expand Down

0 comments on commit f3ae020

Please sign in to comment.