@whereby.com/media 3.1.0 → 4.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 +132 -202
- package/dist/index.d.cts +32 -51
- package/dist/index.d.mts +32 -51
- package/dist/index.d.ts +32 -51
- package/dist/index.mjs +132 -202
- package/dist/legacy-esm.js +132 -202
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -2210,10 +2210,6 @@ class Session {
|
|
|
2210
2210
|
});
|
|
2211
2211
|
this.wasEverConnected = false;
|
|
2212
2212
|
this.connectionStatus = null;
|
|
2213
|
-
this.stats = {
|
|
2214
|
-
totalSent: 0,
|
|
2215
|
-
totalRecv: 0,
|
|
2216
|
-
};
|
|
2217
2213
|
this.bandwidth = bandwidth || 0;
|
|
2218
2214
|
this.pending = [];
|
|
2219
2215
|
this.isOperationPending = false;
|
|
@@ -2223,7 +2219,6 @@ class Session {
|
|
|
2223
2219
|
this.afterConnected = new Promise((resolve) => {
|
|
2224
2220
|
this.registerConnected = resolve;
|
|
2225
2221
|
});
|
|
2226
|
-
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2227
2222
|
this._deprioritizeH264Encoding = deprioritizeH264Encoding;
|
|
2228
2223
|
this._incrementAnalyticMetric = incrementAnalyticMetric;
|
|
2229
2224
|
}
|
|
@@ -2376,12 +2371,6 @@ class Session {
|
|
|
2376
2371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2377
2372
|
logger$7.info("replacetrack() [oldTrackId: %s, newTrackId: %s]", oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id, newTrack.id);
|
|
2378
2373
|
if (newTrack.readyState === "ended") {
|
|
2379
|
-
rtcStats.sendEvent("P2PReplaceTrackNewTrackEnded", {
|
|
2380
|
-
newTrackId: newTrack.id,
|
|
2381
|
-
newTrackKind: newTrack.kind,
|
|
2382
|
-
newTrackIsEffect: trackAnnotations(newTrack).isEffectTrack,
|
|
2383
|
-
});
|
|
2384
|
-
this._incrementAnalyticMetric("P2PReplaceTrackNewTrackEnded");
|
|
2385
2374
|
throw new Error(`refusing to replace track trackId: ${newTrack.id} kind: ${newTrack.kind} with readyState: ${newTrack.readyState}`);
|
|
2386
2375
|
}
|
|
2387
2376
|
const pc = this.pc;
|
|
@@ -2396,20 +2385,6 @@ class Session {
|
|
|
2396
2385
|
return (track === null || track === void 0 ? void 0 : track.kind) === newTrack.kind && !trackAnnotations(track).fromGetDisplayMedia;
|
|
2397
2386
|
});
|
|
2398
2387
|
if (sender) {
|
|
2399
|
-
this._incrementAnalyticMetric("P2PReplaceTrackOldTrackNotFound");
|
|
2400
|
-
const track = sender.track;
|
|
2401
|
-
rtcStats.sendEvent("P2PReplaceTrackOldTrackNotFound", {
|
|
2402
|
-
targetTrackId: track === null || track === void 0 ? void 0 : track.id,
|
|
2403
|
-
targetTrackKind: track === null || track === void 0 ? void 0 : track.kind,
|
|
2404
|
-
targetTrackIsEffect: track && trackAnnotations(track).isEffectTrack,
|
|
2405
|
-
targetTrackReadyState: track === null || track === void 0 ? void 0 : track.readyState,
|
|
2406
|
-
newTrackId: newTrack.id,
|
|
2407
|
-
newTrackKind: newTrack.kind,
|
|
2408
|
-
newTrackIsEffect: trackAnnotations(newTrack).isEffectTrack,
|
|
2409
|
-
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2410
|
-
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2411
|
-
oldTrackIsEffect: oldTrack && trackAnnotations(oldTrack).isEffectTrack,
|
|
2412
|
-
});
|
|
2413
2388
|
return yield sender.replaceTrack(newTrack);
|
|
2414
2389
|
}
|
|
2415
2390
|
let stream = this.streams.find((s) => s.getTracks().find((t) => t.id === newTrack.id));
|
|
@@ -2430,15 +2405,6 @@ class Session {
|
|
|
2430
2405
|
this._incrementAnalyticMetric("P2PReplaceTrackNoStream");
|
|
2431
2406
|
throw new Error("replaceTrack: No stream?");
|
|
2432
2407
|
}
|
|
2433
|
-
rtcStats.sendEvent("P2PReplaceTrackSourceKindNotFound", {
|
|
2434
|
-
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2435
|
-
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2436
|
-
oldTrackIsEffect: oldTrack && trackAnnotations(oldTrack).isEffectTrack,
|
|
2437
|
-
newTrackId: newTrack.id,
|
|
2438
|
-
newTrackKind: newTrack.kind,
|
|
2439
|
-
newTrackIsEffect: trackAnnotations(newTrack).isEffectTrack,
|
|
2440
|
-
});
|
|
2441
|
-
this._incrementAnalyticMetric("P2PReplaceTrackSourceKindNotFound");
|
|
2442
2408
|
pc.addTrack(newTrack, stream);
|
|
2443
2409
|
});
|
|
2444
2410
|
}
|
|
@@ -2541,12 +2507,6 @@ var rtcManagerEvents = {
|
|
|
2541
2507
|
DOMINANT_SPEAKER: "dominant_speaker",
|
|
2542
2508
|
};
|
|
2543
2509
|
|
|
2544
|
-
const CAMERA_STREAM_ID = "0";
|
|
2545
|
-
const STREAM_TYPES = {
|
|
2546
|
-
webcam: "webcam",
|
|
2547
|
-
screenshare: "screenshare",
|
|
2548
|
-
};
|
|
2549
|
-
|
|
2550
2510
|
var _a$2, _b$1;
|
|
2551
2511
|
const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
|
|
2552
2512
|
const logger$6 = new Logger();
|
|
@@ -2567,8 +2527,6 @@ class P2pRtcManager {
|
|
|
2567
2527
|
this._roomName = name;
|
|
2568
2528
|
this._roomSessionId = session && session.id;
|
|
2569
2529
|
this.peerConnections = {};
|
|
2570
|
-
this.localStreams = {};
|
|
2571
|
-
this.enabledLocalStreamIds = [];
|
|
2572
2530
|
this._screenshareVideoTrackIds = [];
|
|
2573
2531
|
this._socketListenerDeregisterFunctions = [];
|
|
2574
2532
|
this._localStreamDeregisterFunction = null;
|
|
@@ -2578,7 +2536,6 @@ class P2pRtcManager {
|
|
|
2578
2536
|
this._features = features || {};
|
|
2579
2537
|
this._isAudioOnlyMode = false;
|
|
2580
2538
|
this._closed = false;
|
|
2581
|
-
this.skipEmittingServerMessageCount = 0;
|
|
2582
2539
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2583
2540
|
this._audioTrackOnEnded = () => {
|
|
2584
2541
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2613,13 +2570,8 @@ class P2pRtcManager {
|
|
|
2613
2570
|
numPcOnAnswerFailure: 0,
|
|
2614
2571
|
numPcOnOfferFailure: 0,
|
|
2615
2572
|
P2PChangeBandwidthEmptySDPType: 0,
|
|
2616
|
-
P2PSessionAlreadyCreated: 0,
|
|
2617
2573
|
P2PReplaceTrackNoStream: 0,
|
|
2618
|
-
P2PReplaceTrackNewTrackEnded: 0,
|
|
2619
2574
|
P2PReplaceTrackNewTrackNotInStream: 0,
|
|
2620
|
-
P2PReplaceTrackOldTrackNotFound: 0,
|
|
2621
|
-
P2PReplaceTrackWithoutPC: 0,
|
|
2622
|
-
P2PReplaceTrackSourceKindNotFound: 0,
|
|
2623
2575
|
P2POnTrackNoStream: 0,
|
|
2624
2576
|
P2PSetCodecPreferenceError: 0,
|
|
2625
2577
|
P2PCreateOfferNoSDP: 0,
|
|
@@ -2627,6 +2579,7 @@ class P2pRtcManager {
|
|
|
2627
2579
|
P2PMicNotWorking: 0,
|
|
2628
2580
|
P2PLocalNetworkFailed: 0,
|
|
2629
2581
|
P2PRelayedIceCandidate: 0,
|
|
2582
|
+
P2PStartScreenshareNoStream: 0,
|
|
2630
2583
|
};
|
|
2631
2584
|
}
|
|
2632
2585
|
numberOfPeerconnections() {
|
|
@@ -2635,50 +2588,59 @@ class P2pRtcManager {
|
|
|
2635
2588
|
isInitializedWith({ selfId, roomName, isSfu }) {
|
|
2636
2589
|
return this._selfId === selfId && this._roomName === roomName && !isSfu;
|
|
2637
2590
|
}
|
|
2638
|
-
|
|
2639
|
-
if (stream === this.
|
|
2591
|
+
addCameraStream(stream, { beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
2592
|
+
if (stream === this._localCameraStream) {
|
|
2640
2593
|
return;
|
|
2641
2594
|
}
|
|
2642
|
-
this.
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
if (audioTrack) {
|
|
2648
|
-
|
|
2649
|
-
this._monitorAudioTrack(audioTrack);
|
|
2650
|
-
}
|
|
2651
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
2652
|
-
if (beforeEffectTrack) {
|
|
2653
|
-
this._monitorAudioTrack(beforeEffectTrack);
|
|
2654
|
-
}
|
|
2595
|
+
this._localCameraStream = stream;
|
|
2596
|
+
this._addStreamToPeerConnections(stream);
|
|
2597
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
2598
|
+
const audioTrack = stream.getAudioTracks()[0];
|
|
2599
|
+
if (audioTrack) {
|
|
2600
|
+
if (!trackAnnotations(audioTrack).isEffectTrack) {
|
|
2601
|
+
this._monitorAudioTrack(audioTrack);
|
|
2655
2602
|
}
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
}
|
|
2660
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
2661
|
-
if (beforeEffectTrack) {
|
|
2662
|
-
this._monitorVideoTrack(beforeEffectTrack);
|
|
2663
|
-
}
|
|
2603
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
2604
|
+
if (beforeEffectTrack) {
|
|
2605
|
+
this._monitorAudioTrack(beforeEffectTrack);
|
|
2664
2606
|
}
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2607
|
+
}
|
|
2608
|
+
if (videoTrack) {
|
|
2609
|
+
if (!trackAnnotations(videoTrack).isEffectTrack) {
|
|
2610
|
+
this._monitorVideoTrack(videoTrack);
|
|
2668
2611
|
}
|
|
2669
|
-
const
|
|
2670
|
-
|
|
2671
|
-
this.
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2612
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
2613
|
+
if (beforeEffectTrack) {
|
|
2614
|
+
this._monitorVideoTrack(beforeEffectTrack);
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
this._enableStopResumeVideoForBrowserSDK(stream);
|
|
2618
|
+
}
|
|
2619
|
+
_enableStopResumeVideoForBrowserSDK(stream) {
|
|
2620
|
+
if (this._localStreamDeregisterFunction) {
|
|
2621
|
+
this._localStreamDeregisterFunction();
|
|
2622
|
+
this._localStreamDeregisterFunction = null;
|
|
2623
|
+
}
|
|
2624
|
+
const localStreamHandler = (e) => {
|
|
2625
|
+
const { enable, track } = e.detail;
|
|
2626
|
+
this._handleStopOrResumeVideo({ enable, track });
|
|
2627
|
+
};
|
|
2628
|
+
stream.addEventListener("stopresumevideo", localStreamHandler);
|
|
2629
|
+
this._localStreamDeregisterFunction = () => {
|
|
2630
|
+
stream.removeEventListener("stopresumevideo", localStreamHandler);
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
addScreenshareStream(stream) {
|
|
2634
|
+
if (stream === this._localScreenshareStream) {
|
|
2677
2635
|
return;
|
|
2678
2636
|
}
|
|
2637
|
+
this._localScreenshareStream = stream;
|
|
2679
2638
|
this._screenshareVideoTrackIds.push(stream.getVideoTracks()[0].id);
|
|
2680
|
-
this.
|
|
2681
|
-
|
|
2639
|
+
this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
|
|
2640
|
+
streamId: stream.id,
|
|
2641
|
+
hasAudioTrack: !!stream.getAudioTracks().length,
|
|
2642
|
+
});
|
|
2643
|
+
this._addStreamToPeerConnections(stream);
|
|
2682
2644
|
}
|
|
2683
2645
|
replaceTrack(oldTrack, newTrack) {
|
|
2684
2646
|
if (newTrack.kind === "audio" && !trackAnnotations(newTrack).isEffectTrack) {
|
|
@@ -2832,11 +2794,12 @@ class P2pRtcManager {
|
|
|
2832
2794
|
});
|
|
2833
2795
|
}
|
|
2834
2796
|
setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds = []) {
|
|
2835
|
-
|
|
2836
|
-
this._screenshareVideoTrackIds = [
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2797
|
+
var _a, _b;
|
|
2798
|
+
this._screenshareVideoTrackIds = [...remoteScreenshareVideoTrackIds];
|
|
2799
|
+
const localScreenShareTrack = (_b = (_a = this._localScreenshareStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks()) === null || _b === void 0 ? void 0 : _b[0];
|
|
2800
|
+
if (localScreenShareTrack) {
|
|
2801
|
+
this._screenshareVideoTrackIds.push(localScreenShareTrack.id);
|
|
2802
|
+
}
|
|
2840
2803
|
}
|
|
2841
2804
|
setRoomSessionId(roomSessionId) {
|
|
2842
2805
|
this._roomSessionId = roomSessionId;
|
|
@@ -2882,7 +2845,6 @@ class P2pRtcManager {
|
|
|
2882
2845
|
}
|
|
2883
2846
|
if (this._features.awaitJoinRoomFinished && !this._serverSocket.joinRoomFinished) {
|
|
2884
2847
|
rtcStats.sendEvent("skip_emitting_server_message", { eventName });
|
|
2885
|
-
this.skipEmittingServerMessageCount++;
|
|
2886
2848
|
}
|
|
2887
2849
|
else {
|
|
2888
2850
|
this._serverSocket.emit(eventName, data);
|
|
@@ -2891,34 +2853,12 @@ class P2pRtcManager {
|
|
|
2891
2853
|
_emit(eventName, data) {
|
|
2892
2854
|
this._emitter.emit(eventName, data);
|
|
2893
2855
|
}
|
|
2894
|
-
_addEnabledLocalStreamId(streamId) {
|
|
2895
|
-
this.enabledLocalStreamIds.push(streamId);
|
|
2896
|
-
}
|
|
2897
|
-
_deleteEnabledLocalStreamId(streamId) {
|
|
2898
|
-
const index = this.enabledLocalStreamIds.indexOf(streamId);
|
|
2899
|
-
if (index !== -1) {
|
|
2900
|
-
this.enabledLocalStreamIds.splice(index, 1);
|
|
2901
|
-
}
|
|
2902
|
-
}
|
|
2903
2856
|
_getSession(peerConnectionId) {
|
|
2904
2857
|
if (!(peerConnectionId in this.peerConnections)) {
|
|
2905
2858
|
return null;
|
|
2906
2859
|
}
|
|
2907
2860
|
return this.peerConnections[peerConnectionId];
|
|
2908
2861
|
}
|
|
2909
|
-
_getLocalCameraStream() {
|
|
2910
|
-
return this.localStreams[CAMERA_STREAM_ID];
|
|
2911
|
-
}
|
|
2912
|
-
_getNonLocalCameraStreamIds() {
|
|
2913
|
-
return Object.keys(this.localStreams).filter((streamId) => streamId !== CAMERA_STREAM_ID);
|
|
2914
|
-
}
|
|
2915
|
-
_isScreensharingLocally() {
|
|
2916
|
-
return this._getNonLocalCameraStreamIds().length > 0;
|
|
2917
|
-
}
|
|
2918
|
-
_getFirstLocalNonCameraStream() {
|
|
2919
|
-
const streamIds = this._getNonLocalCameraStreamIds();
|
|
2920
|
-
return streamIds.length === 0 ? null : this.localStreams[streamIds[0]];
|
|
2921
|
-
}
|
|
2922
2862
|
_createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId }) {
|
|
2923
2863
|
if (!peerConnectionId) {
|
|
2924
2864
|
throw new Error("peerConnectionId is missing");
|
|
@@ -3051,29 +2991,34 @@ class P2pRtcManager {
|
|
|
3051
2991
|
break;
|
|
3052
2992
|
}
|
|
3053
2993
|
};
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
session.addStream(localCameraStream);
|
|
2994
|
+
if (this._localCameraStream) {
|
|
2995
|
+
session.addStream(this._localCameraStream);
|
|
3057
2996
|
}
|
|
3058
|
-
|
|
3059
|
-
if (id === CAMERA_STREAM_ID) {
|
|
3060
|
-
return;
|
|
3061
|
-
}
|
|
3062
|
-
const screenshareStream = this.localStreams[id];
|
|
2997
|
+
if (this._localScreenshareStream) {
|
|
3063
2998
|
if (isOfferer) {
|
|
3064
|
-
session.addStream(
|
|
2999
|
+
session.addStream(this._localScreenshareStream);
|
|
3065
3000
|
}
|
|
3066
3001
|
else {
|
|
3067
3002
|
session.afterConnected.then(() => {
|
|
3003
|
+
if (!this._localScreenshareStream)
|
|
3004
|
+
return;
|
|
3068
3005
|
this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
|
|
3069
3006
|
receiverId: session.clientId,
|
|
3070
|
-
streamId:
|
|
3071
|
-
hasAudioTrack: !!
|
|
3007
|
+
streamId: this._localScreenshareStream.id,
|
|
3008
|
+
hasAudioTrack: !!this._localScreenshareStream.getAudioTracks().length,
|
|
3009
|
+
});
|
|
3010
|
+
this._withForcedRenegotiation(session, () => {
|
|
3011
|
+
if (this._localScreenshareStream) {
|
|
3012
|
+
session.addStream(this._localScreenshareStream);
|
|
3013
|
+
}
|
|
3014
|
+
else {
|
|
3015
|
+
this.analytics.P2PStartScreenshareNoStream++;
|
|
3016
|
+
rtcStats.sendEvent("P2PStartScreenshareNoStream", {});
|
|
3017
|
+
}
|
|
3072
3018
|
});
|
|
3073
|
-
this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
|
|
3074
3019
|
});
|
|
3075
3020
|
}
|
|
3076
|
-
}
|
|
3021
|
+
}
|
|
3077
3022
|
return session;
|
|
3078
3023
|
}
|
|
3079
3024
|
_cleanup(peerConnectionId) {
|
|
@@ -3107,11 +3052,6 @@ class P2pRtcManager {
|
|
|
3107
3052
|
if (session.pc.connectionState === "closed")
|
|
3108
3053
|
return;
|
|
3109
3054
|
logger$6.info("Session doesn't have a connected PeerConnection, adding pending action!");
|
|
3110
|
-
this.analytics.P2PReplaceTrackWithoutPC++;
|
|
3111
|
-
rtcStats.sendEvent("P2PReplaceTrackWithoutPC", {
|
|
3112
|
-
connectionState: session.pc.connectionState,
|
|
3113
|
-
iceConnectionState: session.pc.iceConnectionState,
|
|
3114
|
-
});
|
|
3115
3055
|
const promise = new Promise((resolve, reject) => {
|
|
3116
3056
|
const action = () => __awaiter(this, void 0, void 0, function* () {
|
|
3117
3057
|
try {
|
|
@@ -3143,14 +3083,6 @@ class P2pRtcManager {
|
|
|
3143
3083
|
this._withForcedRenegotiation(session, () => session.removeTrack(track));
|
|
3144
3084
|
});
|
|
3145
3085
|
}
|
|
3146
|
-
_addLocalStream(streamId, stream) {
|
|
3147
|
-
this._addEnabledLocalStreamId(streamId);
|
|
3148
|
-
this.localStreams[streamId] = stream;
|
|
3149
|
-
}
|
|
3150
|
-
_removeLocalStream(streamId) {
|
|
3151
|
-
delete this.localStreams[streamId];
|
|
3152
|
-
this._deleteEnabledLocalStreamId(streamId);
|
|
3153
|
-
}
|
|
3154
3086
|
_updateAndScheduleMediaServersRefresh({ iceServers, turnServers, mediaserverConfigTtlSeconds, }) {
|
|
3155
3087
|
this._iceServers = iceServers;
|
|
3156
3088
|
this._turnServers = turnServers;
|
|
@@ -3360,6 +3292,7 @@ class P2pRtcManager {
|
|
|
3360
3292
|
return bandwidth;
|
|
3361
3293
|
}
|
|
3362
3294
|
_createP2pSession({ clientId, initialBandwidth, isOfferer = false, }) {
|
|
3295
|
+
var _a, _b;
|
|
3363
3296
|
const session = this._createSession({
|
|
3364
3297
|
peerConnectionId: clientId,
|
|
3365
3298
|
clientId,
|
|
@@ -3370,9 +3303,8 @@ class P2pRtcManager {
|
|
|
3370
3303
|
if (this._features.increaseIncomingMediaBufferOn) {
|
|
3371
3304
|
this._setJitterBufferTarget(pc);
|
|
3372
3305
|
}
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
pc.addTrack(this._stoppedVideoTrack, localCameraStream);
|
|
3306
|
+
if (((_b = (_a = this._localCameraStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks()) === null || _b === void 0 ? void 0 : _b.length) && this._stoppedVideoTrack) {
|
|
3307
|
+
pc.addTrack(this._stoppedVideoTrack, this._localCameraStream);
|
|
3376
3308
|
}
|
|
3377
3309
|
pc.onicegatheringstatechange = (event) => {
|
|
3378
3310
|
const connection = event.target;
|
|
@@ -3582,19 +3514,10 @@ class P2pRtcManager {
|
|
|
3582
3514
|
}
|
|
3583
3515
|
}
|
|
3584
3516
|
}
|
|
3585
|
-
|
|
3586
|
-
this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
|
|
3587
|
-
streamId,
|
|
3588
|
-
hasAudioTrack: !!stream.getAudioTracks().length,
|
|
3589
|
-
});
|
|
3590
|
-
this._wasScreenSharing = true;
|
|
3591
|
-
this._addStreamToPeerConnections(stream);
|
|
3592
|
-
}
|
|
3593
|
-
removeStream(streamId, stream, requestedByClientId) {
|
|
3594
|
-
this._removeLocalStream(streamId);
|
|
3517
|
+
removeScreenshareStream(stream, { requestedByClientId } = {}) {
|
|
3595
3518
|
this._removeStreamFromPeerConnections(stream);
|
|
3596
|
-
this.
|
|
3597
|
-
this.
|
|
3519
|
+
this._emitServerEvent(PROTOCOL_REQUESTS.STOP_SCREENSHARE, { streamId: stream.id, requestedByClientId });
|
|
3520
|
+
delete this._localScreenshareStream;
|
|
3598
3521
|
}
|
|
3599
3522
|
hasClient(clientId) {
|
|
3600
3523
|
return Object.keys(this.peerConnections).includes(clientId);
|
|
@@ -4426,6 +4349,12 @@ function createVegaConnectionManager(config) {
|
|
|
4426
4349
|
return { connect, updateHostList, networkIsUp, networkIsPossiblyDown };
|
|
4427
4350
|
}
|
|
4428
4351
|
|
|
4352
|
+
const CAMERA_STREAM_ID = "0";
|
|
4353
|
+
const STREAM_TYPES = {
|
|
4354
|
+
webcam: "webcam",
|
|
4355
|
+
screenshare: "screenshare",
|
|
4356
|
+
};
|
|
4357
|
+
|
|
4429
4358
|
var _a$1;
|
|
4430
4359
|
const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
|
|
4431
4360
|
const logger$2 = new Logger();
|
|
@@ -5369,7 +5298,7 @@ class VegaRtcManager {
|
|
|
5369
5298
|
(_a = this._vegaConnection) === null || _a === void 0 ? void 0 : _a.message("eventClaim", { eventClaim });
|
|
5370
5299
|
}
|
|
5371
5300
|
}
|
|
5372
|
-
replaceTrack(
|
|
5301
|
+
replaceTrack(_, track) {
|
|
5373
5302
|
if (track.kind === "audio") {
|
|
5374
5303
|
if (!trackAnnotations(track).isEffectTrack) {
|
|
5375
5304
|
this._monitorAudioTrack(track);
|
|
@@ -5385,8 +5314,8 @@ class VegaRtcManager {
|
|
|
5385
5314
|
this._replaceWebcamTrack();
|
|
5386
5315
|
}
|
|
5387
5316
|
}
|
|
5388
|
-
|
|
5389
|
-
logger$2.info("
|
|
5317
|
+
removeScreenshareStream(stream, { requestedByClientId } = { requestedByClientId: undefined }) {
|
|
5318
|
+
logger$2.info("removeScreenshareStream() [streamId:%s, requestedByClientId:%s]", stream.id, requestedByClientId);
|
|
5390
5319
|
this._emitToSignal(PROTOCOL_REQUESTS.STOP_SCREENSHARE, {
|
|
5391
5320
|
streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
|
|
5392
5321
|
requestedByClientId,
|
|
@@ -5403,57 +5332,58 @@ class VegaRtcManager {
|
|
|
5403
5332
|
(_b = (_a = this._micAnalyserDebugger) === null || _a === void 0 ? void 0 : _a.onScoreUpdated) === null || _b === void 0 ? void 0 : _b.call(_a, data);
|
|
5404
5333
|
this._sendMicScore(this._micPaused ? 0 : data.out);
|
|
5405
5334
|
}
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
this._monitorVideoTrack(videoTrack);
|
|
5416
|
-
}
|
|
5417
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
5418
|
-
if (beforeEffectTrack) {
|
|
5419
|
-
this._monitorVideoTrack(beforeEffectTrack);
|
|
5420
|
-
}
|
|
5335
|
+
addCameraStream(stream, { audioPaused, videoPaused, beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
5336
|
+
this._micPaused = audioPaused;
|
|
5337
|
+
this._webcamPaused = videoPaused;
|
|
5338
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
5339
|
+
const audioTrack = stream.getAudioTracks()[0];
|
|
5340
|
+
if (videoTrack) {
|
|
5341
|
+
this._sendWebcam(videoTrack);
|
|
5342
|
+
if (!trackAnnotations(videoTrack).isEffectTrack) {
|
|
5343
|
+
this._monitorVideoTrack(videoTrack);
|
|
5421
5344
|
}
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
this.
|
|
5425
|
-
if (!trackAnnotations(audioTrack).isEffectTrack) {
|
|
5426
|
-
this._monitorAudioTrack(audioTrack);
|
|
5427
|
-
}
|
|
5428
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
5429
|
-
if (beforeEffectTrack) {
|
|
5430
|
-
this._monitorAudioTrack(beforeEffectTrack);
|
|
5431
|
-
}
|
|
5345
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
5346
|
+
if (beforeEffectTrack) {
|
|
5347
|
+
this._monitorVideoTrack(beforeEffectTrack);
|
|
5432
5348
|
}
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5349
|
+
}
|
|
5350
|
+
if (audioTrack) {
|
|
5351
|
+
this._sendMic(audioTrack);
|
|
5352
|
+
this._syncMicAnalyser();
|
|
5353
|
+
if (!trackAnnotations(audioTrack).isEffectTrack) {
|
|
5354
|
+
this._monitorAudioTrack(audioTrack);
|
|
5355
|
+
}
|
|
5356
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
5357
|
+
if (beforeEffectTrack) {
|
|
5358
|
+
this._monitorAudioTrack(beforeEffectTrack);
|
|
5436
5359
|
}
|
|
5437
|
-
const localStreamHandler = (e) => {
|
|
5438
|
-
const { enable, track } = e.detail;
|
|
5439
|
-
this._webcamPaused = !enable;
|
|
5440
|
-
this._pauseResumeWebcam();
|
|
5441
|
-
this._handleStopOrResumeVideo({ enable, track });
|
|
5442
|
-
};
|
|
5443
|
-
stream.addEventListener("stopresumevideo", localStreamHandler);
|
|
5444
|
-
this._localStreamDeregisterFunction = () => {
|
|
5445
|
-
stream.removeEventListener("stopresumevideo", localStreamHandler);
|
|
5446
|
-
};
|
|
5447
5360
|
}
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
this._sendScreenAudio(audioTrack);
|
|
5455
|
-
this._emitScreenshareStarted();
|
|
5361
|
+
this._enableStopResumeVideoForBrowserSDK(stream);
|
|
5362
|
+
}
|
|
5363
|
+
_enableStopResumeVideoForBrowserSDK(stream) {
|
|
5364
|
+
if (this._localStreamDeregisterFunction) {
|
|
5365
|
+
this._localStreamDeregisterFunction();
|
|
5366
|
+
this._localStreamDeregisterFunction = null;
|
|
5456
5367
|
}
|
|
5368
|
+
const localStreamHandler = (e) => {
|
|
5369
|
+
const { enable, track } = e.detail;
|
|
5370
|
+
this._webcamPaused = !enable;
|
|
5371
|
+
this._pauseResumeWebcam();
|
|
5372
|
+
this._handleStopOrResumeVideo({ enable, track });
|
|
5373
|
+
};
|
|
5374
|
+
stream.addEventListener("stopresumevideo", localStreamHandler);
|
|
5375
|
+
this._localStreamDeregisterFunction = () => {
|
|
5376
|
+
stream.removeEventListener("stopresumevideo", localStreamHandler);
|
|
5377
|
+
};
|
|
5378
|
+
}
|
|
5379
|
+
addScreenshareStream(stream) {
|
|
5380
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
5381
|
+
const audioTrack = stream.getAudioTracks()[0];
|
|
5382
|
+
if (videoTrack)
|
|
5383
|
+
this._sendScreenVideo(videoTrack);
|
|
5384
|
+
if (audioTrack)
|
|
5385
|
+
this._sendScreenAudio(audioTrack);
|
|
5386
|
+
this._emitScreenshareStarted();
|
|
5457
5387
|
}
|
|
5458
5388
|
_syncMicAnalyser() {
|
|
5459
5389
|
if (this._micTrack && this._colocation && !this._micAnalyser) {
|