livekit-client 1.6.6 → 1.6.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.esm.mjs +96 -84
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +10 -3
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/Track.d.ts +2 -1
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +2 -2
- package/dist/ts4.2/src/room/RTCEngine.d.ts +10 -3
- package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
- package/dist/ts4.2/src/room/track/Track.d.ts +2 -1
- package/dist/ts4.2/src/room/track/options.d.ts +2 -2
- package/package.json +13 -13
- package/src/room/PCTransport.ts +2 -0
- package/src/room/RTCEngine.ts +46 -51
- package/src/room/Room.ts +13 -3
- package/src/room/participant/LocalParticipant.ts +19 -7
- package/src/room/participant/RemoteParticipant.ts +2 -3
- package/src/room/track/RemoteTrackPublication.ts +3 -2
- package/src/room/track/RemoteVideoTrack.ts +0 -3
- package/src/room/track/Track.ts +2 -1
- package/src/room/track/options.ts +2 -2
package/src/room/Room.ts
CHANGED
@@ -56,8 +56,8 @@ import type { AdaptiveStreamSettings } from './track/types';
|
|
56
56
|
import { getNewAudioContext } from './track/utils';
|
57
57
|
import type { SimulationOptions } from './types';
|
58
58
|
import {
|
59
|
-
Future,
|
60
59
|
createDummyVideoStreamTrack,
|
60
|
+
Future,
|
61
61
|
getEmptyAudioStreamTrack,
|
62
62
|
isWeb,
|
63
63
|
Mutex,
|
@@ -516,6 +516,13 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
516
516
|
},
|
517
517
|
});
|
518
518
|
break;
|
519
|
+
case 'resume-reconnect':
|
520
|
+
this.engine.failNext();
|
521
|
+
await this.engine.client.close();
|
522
|
+
if (this.engine.client.onClose) {
|
523
|
+
this.engine.client.onClose('simulate resume-reconnect');
|
524
|
+
}
|
525
|
+
break;
|
519
526
|
case 'force-tcp':
|
520
527
|
case 'force-tls':
|
521
528
|
req = SimulateScenario.fromPartial({
|
@@ -786,6 +793,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
786
793
|
});
|
787
794
|
await track.restartTrack();
|
788
795
|
}
|
796
|
+
log.debug('publishing new track', {
|
797
|
+
track: pub.trackSid,
|
798
|
+
});
|
789
799
|
await this.localParticipant.publishTrack(track, pub.options);
|
790
800
|
}
|
791
801
|
}),
|
@@ -886,7 +896,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
886
896
|
participant.tracks.forEach((publication) => {
|
887
897
|
participant.unpublishTrack(publication.trackSid, true);
|
888
898
|
});
|
889
|
-
this.
|
899
|
+
this.emit(RoomEvent.ParticipantDisconnected, participant);
|
890
900
|
}
|
891
901
|
|
892
902
|
// updates are sent only when there's a change to speaker ordering
|
@@ -1114,7 +1124,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
1114
1124
|
},
|
1115
1125
|
)
|
1116
1126
|
.on(ParticipantEvent.TrackUnpublished, (publication: RemoteTrackPublication) => {
|
1117
|
-
this.
|
1127
|
+
this.emit(RoomEvent.TrackUnpublished, publication, participant);
|
1118
1128
|
})
|
1119
1129
|
.on(
|
1120
1130
|
ParticipantEvent.TrackUnsubscribed,
|
@@ -439,7 +439,13 @@ export default class LocalParticipant extends Participant {
|
|
439
439
|
`Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.`,
|
440
440
|
);
|
441
441
|
}
|
442
|
+
if (options.red === undefined) {
|
443
|
+
log.info(
|
444
|
+
`Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work.`,
|
445
|
+
);
|
446
|
+
}
|
442
447
|
options.dtx ??= false;
|
448
|
+
options.red ??= false;
|
443
449
|
}
|
444
450
|
const opts: TrackPublishOptions = {
|
445
451
|
...this.roomOptions.publishDefaults,
|
@@ -721,17 +727,24 @@ export default class LocalParticipant extends Participant {
|
|
721
727
|
track.stop();
|
722
728
|
}
|
723
729
|
|
730
|
+
let negotiationNeeded = false;
|
731
|
+
const trackSender = track.sender;
|
732
|
+
track.sender = undefined;
|
724
733
|
if (
|
725
734
|
this.engine.publisher &&
|
726
735
|
this.engine.publisher.pc.connectionState !== 'closed' &&
|
727
|
-
|
736
|
+
trackSender
|
728
737
|
) {
|
729
738
|
try {
|
730
|
-
this.engine.removeTrack(
|
739
|
+
if (this.engine.removeTrack(trackSender)) {
|
740
|
+
negotiationNeeded = true;
|
741
|
+
}
|
731
742
|
if (track instanceof LocalVideoTrack) {
|
732
743
|
for (const [, trackInfo] of track.simulcastCodecs) {
|
733
744
|
if (trackInfo.sender) {
|
734
|
-
this.engine.removeTrack(trackInfo.sender)
|
745
|
+
if (this.engine.removeTrack(trackInfo.sender)) {
|
746
|
+
negotiationNeeded = true;
|
747
|
+
}
|
735
748
|
trackInfo.sender = undefined;
|
736
749
|
}
|
737
750
|
}
|
@@ -739,13 +752,9 @@ export default class LocalParticipant extends Participant {
|
|
739
752
|
}
|
740
753
|
} catch (e) {
|
741
754
|
log.warn('failed to unpublish track', { error: e, method: 'unpublishTrack' });
|
742
|
-
} finally {
|
743
|
-
await this.engine.negotiate();
|
744
755
|
}
|
745
756
|
}
|
746
757
|
|
747
|
-
track.sender = undefined;
|
748
|
-
|
749
758
|
// remove from our maps
|
750
759
|
this.tracks.delete(publication.trackSid);
|
751
760
|
switch (publication.kind) {
|
@@ -762,6 +771,9 @@ export default class LocalParticipant extends Participant {
|
|
762
771
|
this.emit(ParticipantEvent.LocalTrackUnpublished, publication);
|
763
772
|
publication.setTrack(undefined);
|
764
773
|
|
774
|
+
if (negotiationNeeded) {
|
775
|
+
await this.engine.negotiate();
|
776
|
+
}
|
765
777
|
return publication;
|
766
778
|
}
|
767
779
|
|
@@ -236,8 +236,7 @@ export default class RemoteParticipant extends Participant {
|
|
236
236
|
}
|
237
237
|
publication = new RemoteTrackPublication(
|
238
238
|
kind,
|
239
|
-
ti
|
240
|
-
ti.name,
|
239
|
+
ti,
|
241
240
|
this.signalClient.connectOptions?.autoSubscribe,
|
242
241
|
);
|
243
242
|
publication.updateInfo(ti);
|
@@ -246,7 +245,7 @@ export default class RemoteParticipant extends Participant {
|
|
246
245
|
(publishedTrack) => publishedTrack.source === publication?.source,
|
247
246
|
);
|
248
247
|
if (existingTrackOfSource && publication.source !== Track.Source.Unknown) {
|
249
|
-
log.
|
248
|
+
log.debug(
|
250
249
|
`received a second track publication for ${this.identity} with the same source: ${publication.source}`,
|
251
250
|
{
|
252
251
|
oldTrack: existingTrackOfSource,
|
@@ -24,9 +24,10 @@ export default class RemoteTrackPublication extends TrackPublication {
|
|
24
24
|
|
25
25
|
protected fps?: number;
|
26
26
|
|
27
|
-
constructor(kind: Track.Kind,
|
28
|
-
super(kind,
|
27
|
+
constructor(kind: Track.Kind, ti: TrackInfo, autoSubscribe: boolean | undefined) {
|
28
|
+
super(kind, ti.sid, ti.name);
|
29
29
|
this.subscribed = autoSubscribe;
|
30
|
+
this.updateInfo(ti);
|
30
31
|
}
|
31
32
|
|
32
33
|
/**
|
@@ -31,9 +31,6 @@ export default class RemoteVideoTrack extends RemoteTrack {
|
|
31
31
|
) {
|
32
32
|
super(mediaTrack, sid, Track.Kind.Video, receiver);
|
33
33
|
this.adaptiveStreamSettings = adaptiveStreamSettings;
|
34
|
-
if (this.isAdaptiveStream) {
|
35
|
-
this.streamState = Track.StreamState.Paused;
|
36
|
-
}
|
37
34
|
}
|
38
35
|
|
39
36
|
get isAdaptiveStream(): boolean {
|
package/src/room/track/Track.ts
CHANGED
@@ -32,7 +32,8 @@ export abstract class Track extends (EventEmitter as new () => TypedEventEmitter
|
|
32
32
|
mediaStream?: MediaStream;
|
33
33
|
|
34
34
|
/**
|
35
|
-
* indicates current state of stream
|
35
|
+
* indicates current state of stream, it'll indicate `paused` if the track
|
36
|
+
* has been paused by congestion controller
|
36
37
|
*/
|
37
38
|
streamState: Track.StreamState = Track.StreamState.Active;
|
38
39
|
|
@@ -28,12 +28,12 @@ export interface TrackPublishDefaults {
|
|
28
28
|
audioBitrate?: number;
|
29
29
|
|
30
30
|
/**
|
31
|
-
* dtx (Discontinuous Transmission of audio),
|
31
|
+
* dtx (Discontinuous Transmission of audio), enabled by default for mono tracks.
|
32
32
|
*/
|
33
33
|
dtx?: boolean;
|
34
34
|
|
35
35
|
/**
|
36
|
-
* red (Redundant Audio Data),
|
36
|
+
* red (Redundant Audio Data), enabled by default for mono tracks.
|
37
37
|
*/
|
38
38
|
red?: boolean;
|
39
39
|
|