@whereby.com/media 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +28 -27
- package/dist/index.mjs +28 -27
- package/dist/legacy-esm.js +28 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2246,18 +2246,12 @@ class Session {
|
|
|
2246
2246
|
addStream(stream) {
|
|
2247
2247
|
this.streamIds.push(stream.id);
|
|
2248
2248
|
this.streams.push(stream);
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
});
|
|
2256
|
-
}
|
|
2257
|
-
else {
|
|
2258
|
-
rtcStats.sendEvent("P2PNoAddTrackSupport", {});
|
|
2259
|
-
this.pc.addStream(stream);
|
|
2260
|
-
}
|
|
2249
|
+
stream.getAudioTracks().forEach((track) => {
|
|
2250
|
+
this.pc.addTrack(track, stream);
|
|
2251
|
+
});
|
|
2252
|
+
stream.getVideoTracks().forEach((track) => {
|
|
2253
|
+
this.pc.addTrack(track, stream);
|
|
2254
|
+
});
|
|
2261
2255
|
}
|
|
2262
2256
|
addTrack(track, stream) {
|
|
2263
2257
|
if (!stream) {
|
|
@@ -2283,17 +2277,12 @@ class Session {
|
|
|
2283
2277
|
if (streamIndex !== -1) {
|
|
2284
2278
|
this.streams.splice(streamIndex, 1);
|
|
2285
2279
|
}
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
});
|
|
2293
|
-
}
|
|
2294
|
-
else if (this.pc.removeStream) {
|
|
2295
|
-
this.pc.removeStream(stream);
|
|
2296
|
-
}
|
|
2280
|
+
stream.getTracks().forEach((track) => {
|
|
2281
|
+
const sender = this.pc.getSenders().find((sender) => sender.track === track);
|
|
2282
|
+
if (sender) {
|
|
2283
|
+
this.pc.removeTrack(sender);
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2297
2286
|
}
|
|
2298
2287
|
_setRemoteDescription(desc) {
|
|
2299
2288
|
if (this._deprioritizeH264Encoding)
|
|
@@ -2610,6 +2599,7 @@ class P2pRtcManager {
|
|
|
2610
2599
|
return this._selfId === selfId && this._roomName === roomName && !isSfu;
|
|
2611
2600
|
}
|
|
2612
2601
|
addCameraStream(stream, { beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
2602
|
+
logger$6.info("addCameraStream: [stream.id: %s]", stream.id);
|
|
2613
2603
|
if (stream === this._localCameraStream) {
|
|
2614
2604
|
return;
|
|
2615
2605
|
}
|
|
@@ -2652,6 +2642,7 @@ class P2pRtcManager {
|
|
|
2652
2642
|
};
|
|
2653
2643
|
}
|
|
2654
2644
|
addScreenshareStream(stream) {
|
|
2645
|
+
logger$6.info("addScreenshareStream() [stream.id: %s]", stream.id);
|
|
2655
2646
|
if (stream === this._localScreenshareStream) {
|
|
2656
2647
|
return;
|
|
2657
2648
|
}
|
|
@@ -2664,6 +2655,7 @@ class P2pRtcManager {
|
|
|
2664
2655
|
this._addStreamToPeerConnections(stream);
|
|
2665
2656
|
}
|
|
2666
2657
|
replaceTrack(oldTrack, newTrack) {
|
|
2658
|
+
logger$6.info("replaceTrack() [kind: %s, oldTrackId: %s, newTrackId: %s]", newTrack.kind, oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id, newTrack.id);
|
|
2667
2659
|
if (newTrack.kind === "audio" && !trackAnnotations(newTrack).isEffectTrack) {
|
|
2668
2660
|
this._monitorAudioTrack(newTrack);
|
|
2669
2661
|
}
|
|
@@ -2677,6 +2669,7 @@ class P2pRtcManager {
|
|
|
2677
2669
|
this.disconnectAll();
|
|
2678
2670
|
}
|
|
2679
2671
|
disconnectAll() {
|
|
2672
|
+
logger$6.info("disconnectAll()");
|
|
2680
2673
|
Object.keys(this.peerConnections).forEach((peerConnectionId) => {
|
|
2681
2674
|
this.disconnect(peerConnectionId);
|
|
2682
2675
|
});
|
|
@@ -2702,10 +2695,11 @@ class P2pRtcManager {
|
|
|
2702
2695
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
2703
2696
|
}),
|
|
2704
2697
|
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
|
|
2705
|
-
logger$6.info(`
|
|
2698
|
+
logger$6.info(`Got ready_to_receive_offer from client ${data.clientId}`);
|
|
2706
2699
|
this._connect(data.clientId);
|
|
2707
2700
|
}),
|
|
2708
2701
|
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
|
|
2702
|
+
logger$6.info(`Got ice_candidate from client ${data.clientId}`);
|
|
2709
2703
|
const session = this._getSession(data.clientId);
|
|
2710
2704
|
if (!session) {
|
|
2711
2705
|
logger$6.warn("No RTCPeerConnection on ICE_CANDIDATE", data);
|
|
@@ -2714,7 +2708,7 @@ class P2pRtcManager {
|
|
|
2714
2708
|
session.addIceCandidate(data.message);
|
|
2715
2709
|
}),
|
|
2716
2710
|
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
|
|
2717
|
-
logger$6.info(`
|
|
2711
|
+
logger$6.info(`Got end_of_ice_candidates from client ${data.clientId}`);
|
|
2718
2712
|
const session = this._getSession(data.clientId);
|
|
2719
2713
|
if (!session) {
|
|
2720
2714
|
logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -2724,7 +2718,7 @@ class P2pRtcManager {
|
|
|
2724
2718
|
}),
|
|
2725
2719
|
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
|
|
2726
2720
|
var _a, _b;
|
|
2727
|
-
logger$6.info(`
|
|
2721
|
+
logger$6.info(`Got offer from client ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
|
|
2728
2722
|
const session = this._getSession(data.clientId);
|
|
2729
2723
|
if (!session) {
|
|
2730
2724
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
@@ -2747,6 +2741,7 @@ class P2pRtcManager {
|
|
|
2747
2741
|
(_b = (_a = session
|
|
2748
2742
|
.handleOffer(sdp)
|
|
2749
2743
|
.then((answer) => {
|
|
2744
|
+
logger$6.info(`Sending answer to client ${data.clientId}`);
|
|
2750
2745
|
this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
|
|
2751
2746
|
receiverId: data.clientId,
|
|
2752
2747
|
message: answer,
|
|
@@ -2757,7 +2752,7 @@ class P2pRtcManager {
|
|
|
2757
2752
|
}),
|
|
2758
2753
|
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
|
|
2759
2754
|
var _a, _b;
|
|
2760
|
-
logger$6.info(`
|
|
2755
|
+
logger$6.info(`Got answer from client ${data.clientId}`);
|
|
2761
2756
|
const session = this._getSession(data.clientId);
|
|
2762
2757
|
if (!session) {
|
|
2763
2758
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -3264,6 +3259,7 @@ class P2pRtcManager {
|
|
|
3264
3259
|
type: offer.type,
|
|
3265
3260
|
isInitialOffer,
|
|
3266
3261
|
};
|
|
3262
|
+
logger$6.info(`sending offer to client ${clientId}`);
|
|
3267
3263
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
3268
3264
|
receiverId: clientId,
|
|
3269
3265
|
message,
|
|
@@ -3429,11 +3425,13 @@ class P2pRtcManager {
|
|
|
3429
3425
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3430
3426
|
return;
|
|
3431
3427
|
}
|
|
3428
|
+
logger$6.info(`onnegotiationneeded client ${clientId}`);
|
|
3432
3429
|
this._negotiatePeerConnection({ clientId, session });
|
|
3433
3430
|
};
|
|
3434
3431
|
return session;
|
|
3435
3432
|
}
|
|
3436
3433
|
acceptNewStream({ streamId, clientId }) {
|
|
3434
|
+
logger$6.info("acceptNewStream() [streamId: %s}, clientId: %s]", streamId, clientId);
|
|
3437
3435
|
let session = this._getSession(clientId);
|
|
3438
3436
|
if (session && streamId !== clientId) {
|
|
3439
3437
|
return session;
|
|
@@ -3456,6 +3454,7 @@ class P2pRtcManager {
|
|
|
3456
3454
|
return session;
|
|
3457
3455
|
}
|
|
3458
3456
|
disconnect(clientId) {
|
|
3457
|
+
logger$6.info("disconnect() [clientId: %s]", clientId);
|
|
3459
3458
|
this._cleanup(clientId);
|
|
3460
3459
|
this._changeBandwidthForAllClients(false);
|
|
3461
3460
|
const numPeers = this.numberOfPeerconnections();
|
|
@@ -3487,6 +3486,7 @@ class P2pRtcManager {
|
|
|
3487
3486
|
}
|
|
3488
3487
|
stopOrResumeVideo(localStream, enable) {
|
|
3489
3488
|
var _a;
|
|
3489
|
+
logger$6.info("stopOrResumeVideo() [enable: %s]", enable);
|
|
3490
3490
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3491
3491
|
return;
|
|
3492
3492
|
}
|
|
@@ -3536,6 +3536,7 @@ class P2pRtcManager {
|
|
|
3536
3536
|
}
|
|
3537
3537
|
}
|
|
3538
3538
|
removeScreenshareStream(stream, { requestedByClientId } = {}) {
|
|
3539
|
+
logger$6.info("removeScreenshareStream() [stream.id: %s, requestedByClientId: %s]", stream.id, requestedByClientId);
|
|
3539
3540
|
this._removeStreamFromPeerConnections(stream);
|
|
3540
3541
|
this._emitServerEvent(PROTOCOL_REQUESTS.STOP_SCREENSHARE, { streamId: stream.id, requestedByClientId });
|
|
3541
3542
|
delete this._localScreenshareStream;
|
package/dist/index.mjs
CHANGED
|
@@ -2225,18 +2225,12 @@ class Session {
|
|
|
2225
2225
|
addStream(stream) {
|
|
2226
2226
|
this.streamIds.push(stream.id);
|
|
2227
2227
|
this.streams.push(stream);
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
else {
|
|
2237
|
-
rtcStats.sendEvent("P2PNoAddTrackSupport", {});
|
|
2238
|
-
this.pc.addStream(stream);
|
|
2239
|
-
}
|
|
2228
|
+
stream.getAudioTracks().forEach((track) => {
|
|
2229
|
+
this.pc.addTrack(track, stream);
|
|
2230
|
+
});
|
|
2231
|
+
stream.getVideoTracks().forEach((track) => {
|
|
2232
|
+
this.pc.addTrack(track, stream);
|
|
2233
|
+
});
|
|
2240
2234
|
}
|
|
2241
2235
|
addTrack(track, stream) {
|
|
2242
2236
|
if (!stream) {
|
|
@@ -2262,17 +2256,12 @@ class Session {
|
|
|
2262
2256
|
if (streamIndex !== -1) {
|
|
2263
2257
|
this.streams.splice(streamIndex, 1);
|
|
2264
2258
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
else if (this.pc.removeStream) {
|
|
2274
|
-
this.pc.removeStream(stream);
|
|
2275
|
-
}
|
|
2259
|
+
stream.getTracks().forEach((track) => {
|
|
2260
|
+
const sender = this.pc.getSenders().find((sender) => sender.track === track);
|
|
2261
|
+
if (sender) {
|
|
2262
|
+
this.pc.removeTrack(sender);
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2276
2265
|
}
|
|
2277
2266
|
_setRemoteDescription(desc) {
|
|
2278
2267
|
if (this._deprioritizeH264Encoding)
|
|
@@ -2589,6 +2578,7 @@ class P2pRtcManager {
|
|
|
2589
2578
|
return this._selfId === selfId && this._roomName === roomName && !isSfu;
|
|
2590
2579
|
}
|
|
2591
2580
|
addCameraStream(stream, { beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
2581
|
+
logger$6.info("addCameraStream: [stream.id: %s]", stream.id);
|
|
2592
2582
|
if (stream === this._localCameraStream) {
|
|
2593
2583
|
return;
|
|
2594
2584
|
}
|
|
@@ -2631,6 +2621,7 @@ class P2pRtcManager {
|
|
|
2631
2621
|
};
|
|
2632
2622
|
}
|
|
2633
2623
|
addScreenshareStream(stream) {
|
|
2624
|
+
logger$6.info("addScreenshareStream() [stream.id: %s]", stream.id);
|
|
2634
2625
|
if (stream === this._localScreenshareStream) {
|
|
2635
2626
|
return;
|
|
2636
2627
|
}
|
|
@@ -2643,6 +2634,7 @@ class P2pRtcManager {
|
|
|
2643
2634
|
this._addStreamToPeerConnections(stream);
|
|
2644
2635
|
}
|
|
2645
2636
|
replaceTrack(oldTrack, newTrack) {
|
|
2637
|
+
logger$6.info("replaceTrack() [kind: %s, oldTrackId: %s, newTrackId: %s]", newTrack.kind, oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id, newTrack.id);
|
|
2646
2638
|
if (newTrack.kind === "audio" && !trackAnnotations(newTrack).isEffectTrack) {
|
|
2647
2639
|
this._monitorAudioTrack(newTrack);
|
|
2648
2640
|
}
|
|
@@ -2656,6 +2648,7 @@ class P2pRtcManager {
|
|
|
2656
2648
|
this.disconnectAll();
|
|
2657
2649
|
}
|
|
2658
2650
|
disconnectAll() {
|
|
2651
|
+
logger$6.info("disconnectAll()");
|
|
2659
2652
|
Object.keys(this.peerConnections).forEach((peerConnectionId) => {
|
|
2660
2653
|
this.disconnect(peerConnectionId);
|
|
2661
2654
|
});
|
|
@@ -2681,10 +2674,11 @@ class P2pRtcManager {
|
|
|
2681
2674
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
2682
2675
|
}),
|
|
2683
2676
|
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
|
|
2684
|
-
logger$6.info(`
|
|
2677
|
+
logger$6.info(`Got ready_to_receive_offer from client ${data.clientId}`);
|
|
2685
2678
|
this._connect(data.clientId);
|
|
2686
2679
|
}),
|
|
2687
2680
|
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
|
|
2681
|
+
logger$6.info(`Got ice_candidate from client ${data.clientId}`);
|
|
2688
2682
|
const session = this._getSession(data.clientId);
|
|
2689
2683
|
if (!session) {
|
|
2690
2684
|
logger$6.warn("No RTCPeerConnection on ICE_CANDIDATE", data);
|
|
@@ -2693,7 +2687,7 @@ class P2pRtcManager {
|
|
|
2693
2687
|
session.addIceCandidate(data.message);
|
|
2694
2688
|
}),
|
|
2695
2689
|
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
|
|
2696
|
-
logger$6.info(`
|
|
2690
|
+
logger$6.info(`Got end_of_ice_candidates from client ${data.clientId}`);
|
|
2697
2691
|
const session = this._getSession(data.clientId);
|
|
2698
2692
|
if (!session) {
|
|
2699
2693
|
logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -2703,7 +2697,7 @@ class P2pRtcManager {
|
|
|
2703
2697
|
}),
|
|
2704
2698
|
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
|
|
2705
2699
|
var _a, _b;
|
|
2706
|
-
logger$6.info(`
|
|
2700
|
+
logger$6.info(`Got offer from client ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
|
|
2707
2701
|
const session = this._getSession(data.clientId);
|
|
2708
2702
|
if (!session) {
|
|
2709
2703
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
@@ -2726,6 +2720,7 @@ class P2pRtcManager {
|
|
|
2726
2720
|
(_b = (_a = session
|
|
2727
2721
|
.handleOffer(sdp)
|
|
2728
2722
|
.then((answer) => {
|
|
2723
|
+
logger$6.info(`Sending answer to client ${data.clientId}`);
|
|
2729
2724
|
this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
|
|
2730
2725
|
receiverId: data.clientId,
|
|
2731
2726
|
message: answer,
|
|
@@ -2736,7 +2731,7 @@ class P2pRtcManager {
|
|
|
2736
2731
|
}),
|
|
2737
2732
|
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
|
|
2738
2733
|
var _a, _b;
|
|
2739
|
-
logger$6.info(`
|
|
2734
|
+
logger$6.info(`Got answer from client ${data.clientId}`);
|
|
2740
2735
|
const session = this._getSession(data.clientId);
|
|
2741
2736
|
if (!session) {
|
|
2742
2737
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -3243,6 +3238,7 @@ class P2pRtcManager {
|
|
|
3243
3238
|
type: offer.type,
|
|
3244
3239
|
isInitialOffer,
|
|
3245
3240
|
};
|
|
3241
|
+
logger$6.info(`sending offer to client ${clientId}`);
|
|
3246
3242
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
3247
3243
|
receiverId: clientId,
|
|
3248
3244
|
message,
|
|
@@ -3408,11 +3404,13 @@ class P2pRtcManager {
|
|
|
3408
3404
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3409
3405
|
return;
|
|
3410
3406
|
}
|
|
3407
|
+
logger$6.info(`onnegotiationneeded client ${clientId}`);
|
|
3411
3408
|
this._negotiatePeerConnection({ clientId, session });
|
|
3412
3409
|
};
|
|
3413
3410
|
return session;
|
|
3414
3411
|
}
|
|
3415
3412
|
acceptNewStream({ streamId, clientId }) {
|
|
3413
|
+
logger$6.info("acceptNewStream() [streamId: %s}, clientId: %s]", streamId, clientId);
|
|
3416
3414
|
let session = this._getSession(clientId);
|
|
3417
3415
|
if (session && streamId !== clientId) {
|
|
3418
3416
|
return session;
|
|
@@ -3435,6 +3433,7 @@ class P2pRtcManager {
|
|
|
3435
3433
|
return session;
|
|
3436
3434
|
}
|
|
3437
3435
|
disconnect(clientId) {
|
|
3436
|
+
logger$6.info("disconnect() [clientId: %s]", clientId);
|
|
3438
3437
|
this._cleanup(clientId);
|
|
3439
3438
|
this._changeBandwidthForAllClients(false);
|
|
3440
3439
|
const numPeers = this.numberOfPeerconnections();
|
|
@@ -3466,6 +3465,7 @@ class P2pRtcManager {
|
|
|
3466
3465
|
}
|
|
3467
3466
|
stopOrResumeVideo(localStream, enable) {
|
|
3468
3467
|
var _a;
|
|
3468
|
+
logger$6.info("stopOrResumeVideo() [enable: %s]", enable);
|
|
3469
3469
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3470
3470
|
return;
|
|
3471
3471
|
}
|
|
@@ -3515,6 +3515,7 @@ class P2pRtcManager {
|
|
|
3515
3515
|
}
|
|
3516
3516
|
}
|
|
3517
3517
|
removeScreenshareStream(stream, { requestedByClientId } = {}) {
|
|
3518
|
+
logger$6.info("removeScreenshareStream() [stream.id: %s, requestedByClientId: %s]", stream.id, requestedByClientId);
|
|
3518
3519
|
this._removeStreamFromPeerConnections(stream);
|
|
3519
3520
|
this._emitServerEvent(PROTOCOL_REQUESTS.STOP_SCREENSHARE, { streamId: stream.id, requestedByClientId });
|
|
3520
3521
|
delete this._localScreenshareStream;
|
package/dist/legacy-esm.js
CHANGED
|
@@ -2225,18 +2225,12 @@ class Session {
|
|
|
2225
2225
|
addStream(stream) {
|
|
2226
2226
|
this.streamIds.push(stream.id);
|
|
2227
2227
|
this.streams.push(stream);
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
else {
|
|
2237
|
-
rtcStats.sendEvent("P2PNoAddTrackSupport", {});
|
|
2238
|
-
this.pc.addStream(stream);
|
|
2239
|
-
}
|
|
2228
|
+
stream.getAudioTracks().forEach((track) => {
|
|
2229
|
+
this.pc.addTrack(track, stream);
|
|
2230
|
+
});
|
|
2231
|
+
stream.getVideoTracks().forEach((track) => {
|
|
2232
|
+
this.pc.addTrack(track, stream);
|
|
2233
|
+
});
|
|
2240
2234
|
}
|
|
2241
2235
|
addTrack(track, stream) {
|
|
2242
2236
|
if (!stream) {
|
|
@@ -2262,17 +2256,12 @@ class Session {
|
|
|
2262
2256
|
if (streamIndex !== -1) {
|
|
2263
2257
|
this.streams.splice(streamIndex, 1);
|
|
2264
2258
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
else if (this.pc.removeStream) {
|
|
2274
|
-
this.pc.removeStream(stream);
|
|
2275
|
-
}
|
|
2259
|
+
stream.getTracks().forEach((track) => {
|
|
2260
|
+
const sender = this.pc.getSenders().find((sender) => sender.track === track);
|
|
2261
|
+
if (sender) {
|
|
2262
|
+
this.pc.removeTrack(sender);
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2276
2265
|
}
|
|
2277
2266
|
_setRemoteDescription(desc) {
|
|
2278
2267
|
if (this._deprioritizeH264Encoding)
|
|
@@ -2589,6 +2578,7 @@ class P2pRtcManager {
|
|
|
2589
2578
|
return this._selfId === selfId && this._roomName === roomName && !isSfu;
|
|
2590
2579
|
}
|
|
2591
2580
|
addCameraStream(stream, { beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
2581
|
+
logger$6.info("addCameraStream: [stream.id: %s]", stream.id);
|
|
2592
2582
|
if (stream === this._localCameraStream) {
|
|
2593
2583
|
return;
|
|
2594
2584
|
}
|
|
@@ -2631,6 +2621,7 @@ class P2pRtcManager {
|
|
|
2631
2621
|
};
|
|
2632
2622
|
}
|
|
2633
2623
|
addScreenshareStream(stream) {
|
|
2624
|
+
logger$6.info("addScreenshareStream() [stream.id: %s]", stream.id);
|
|
2634
2625
|
if (stream === this._localScreenshareStream) {
|
|
2635
2626
|
return;
|
|
2636
2627
|
}
|
|
@@ -2643,6 +2634,7 @@ class P2pRtcManager {
|
|
|
2643
2634
|
this._addStreamToPeerConnections(stream);
|
|
2644
2635
|
}
|
|
2645
2636
|
replaceTrack(oldTrack, newTrack) {
|
|
2637
|
+
logger$6.info("replaceTrack() [kind: %s, oldTrackId: %s, newTrackId: %s]", newTrack.kind, oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id, newTrack.id);
|
|
2646
2638
|
if (newTrack.kind === "audio" && !trackAnnotations(newTrack).isEffectTrack) {
|
|
2647
2639
|
this._monitorAudioTrack(newTrack);
|
|
2648
2640
|
}
|
|
@@ -2656,6 +2648,7 @@ class P2pRtcManager {
|
|
|
2656
2648
|
this.disconnectAll();
|
|
2657
2649
|
}
|
|
2658
2650
|
disconnectAll() {
|
|
2651
|
+
logger$6.info("disconnectAll()");
|
|
2659
2652
|
Object.keys(this.peerConnections).forEach((peerConnectionId) => {
|
|
2660
2653
|
this.disconnect(peerConnectionId);
|
|
2661
2654
|
});
|
|
@@ -2681,10 +2674,11 @@ class P2pRtcManager {
|
|
|
2681
2674
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
2682
2675
|
}),
|
|
2683
2676
|
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, (data) => {
|
|
2684
|
-
logger$6.info(`
|
|
2677
|
+
logger$6.info(`Got ready_to_receive_offer from client ${data.clientId}`);
|
|
2685
2678
|
this._connect(data.clientId);
|
|
2686
2679
|
}),
|
|
2687
2680
|
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, (data) => {
|
|
2681
|
+
logger$6.info(`Got ice_candidate from client ${data.clientId}`);
|
|
2688
2682
|
const session = this._getSession(data.clientId);
|
|
2689
2683
|
if (!session) {
|
|
2690
2684
|
logger$6.warn("No RTCPeerConnection on ICE_CANDIDATE", data);
|
|
@@ -2693,7 +2687,7 @@ class P2pRtcManager {
|
|
|
2693
2687
|
session.addIceCandidate(data.message);
|
|
2694
2688
|
}),
|
|
2695
2689
|
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, (data) => {
|
|
2696
|
-
logger$6.info(`
|
|
2690
|
+
logger$6.info(`Got end_of_ice_candidates from client ${data.clientId}`);
|
|
2697
2691
|
const session = this._getSession(data.clientId);
|
|
2698
2692
|
if (!session) {
|
|
2699
2693
|
logger$6.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -2703,7 +2697,7 @@ class P2pRtcManager {
|
|
|
2703
2697
|
}),
|
|
2704
2698
|
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, (data) => {
|
|
2705
2699
|
var _a, _b;
|
|
2706
|
-
logger$6.info(`
|
|
2700
|
+
logger$6.info(`Got offer from client ${data.clientId}, isInitialOffer: ${Boolean(data.message.isInitialOffer)}`);
|
|
2707
2701
|
const session = this._getSession(data.clientId);
|
|
2708
2702
|
if (!session) {
|
|
2709
2703
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
@@ -2726,6 +2720,7 @@ class P2pRtcManager {
|
|
|
2726
2720
|
(_b = (_a = session
|
|
2727
2721
|
.handleOffer(sdp)
|
|
2728
2722
|
.then((answer) => {
|
|
2723
|
+
logger$6.info(`Sending answer to client ${data.clientId}`);
|
|
2729
2724
|
this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
|
|
2730
2725
|
receiverId: data.clientId,
|
|
2731
2726
|
message: answer,
|
|
@@ -2736,7 +2731,7 @@ class P2pRtcManager {
|
|
|
2736
2731
|
}),
|
|
2737
2732
|
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, (data) => {
|
|
2738
2733
|
var _a, _b;
|
|
2739
|
-
logger$6.info(`
|
|
2734
|
+
logger$6.info(`Got answer from client ${data.clientId}`);
|
|
2740
2735
|
const session = this._getSession(data.clientId);
|
|
2741
2736
|
if (!session) {
|
|
2742
2737
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -3243,6 +3238,7 @@ class P2pRtcManager {
|
|
|
3243
3238
|
type: offer.type,
|
|
3244
3239
|
isInitialOffer,
|
|
3245
3240
|
};
|
|
3241
|
+
logger$6.info(`sending offer to client ${clientId}`);
|
|
3246
3242
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
3247
3243
|
receiverId: clientId,
|
|
3248
3244
|
message,
|
|
@@ -3408,11 +3404,13 @@ class P2pRtcManager {
|
|
|
3408
3404
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3409
3405
|
return;
|
|
3410
3406
|
}
|
|
3407
|
+
logger$6.info(`onnegotiationneeded client ${clientId}`);
|
|
3411
3408
|
this._negotiatePeerConnection({ clientId, session });
|
|
3412
3409
|
};
|
|
3413
3410
|
return session;
|
|
3414
3411
|
}
|
|
3415
3412
|
acceptNewStream({ streamId, clientId }) {
|
|
3413
|
+
logger$6.info("acceptNewStream() [streamId: %s}, clientId: %s]", streamId, clientId);
|
|
3416
3414
|
let session = this._getSession(clientId);
|
|
3417
3415
|
if (session && streamId !== clientId) {
|
|
3418
3416
|
return session;
|
|
@@ -3435,6 +3433,7 @@ class P2pRtcManager {
|
|
|
3435
3433
|
return session;
|
|
3436
3434
|
}
|
|
3437
3435
|
disconnect(clientId) {
|
|
3436
|
+
logger$6.info("disconnect() [clientId: %s]", clientId);
|
|
3438
3437
|
this._cleanup(clientId);
|
|
3439
3438
|
this._changeBandwidthForAllClients(false);
|
|
3440
3439
|
const numPeers = this.numberOfPeerconnections();
|
|
@@ -3466,6 +3465,7 @@ class P2pRtcManager {
|
|
|
3466
3465
|
}
|
|
3467
3466
|
stopOrResumeVideo(localStream, enable) {
|
|
3468
3467
|
var _a;
|
|
3468
|
+
logger$6.info("stopOrResumeVideo() [enable: %s]", enable);
|
|
3469
3469
|
if (!["chrome", "safari"].includes(browserName$1)) {
|
|
3470
3470
|
return;
|
|
3471
3471
|
}
|
|
@@ -3515,6 +3515,7 @@ class P2pRtcManager {
|
|
|
3515
3515
|
}
|
|
3516
3516
|
}
|
|
3517
3517
|
removeScreenshareStream(stream, { requestedByClientId } = {}) {
|
|
3518
|
+
logger$6.info("removeScreenshareStream() [stream.id: %s, requestedByClientId: %s]", stream.id, requestedByClientId);
|
|
3518
3519
|
this._removeStreamFromPeerConnections(stream);
|
|
3519
3520
|
this._emitServerEvent(PROTOCOL_REQUESTS.STOP_SCREENSHARE, { streamId: stream.id, requestedByClientId });
|
|
3520
3521
|
delete this._localScreenshareStream;
|