@whereby.com/media 3.1.1 → 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 +31 -41
- package/dist/index.d.mts +31 -41
- package/dist/index.d.ts +31 -41
- package/dist/index.mjs +132 -202
- package/dist/legacy-esm.js +132 -202
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2231,10 +2231,6 @@ class Session {
|
|
|
2231
2231
|
});
|
|
2232
2232
|
this.wasEverConnected = false;
|
|
2233
2233
|
this.connectionStatus = null;
|
|
2234
|
-
this.stats = {
|
|
2235
|
-
totalSent: 0,
|
|
2236
|
-
totalRecv: 0,
|
|
2237
|
-
};
|
|
2238
2234
|
this.bandwidth = bandwidth || 0;
|
|
2239
2235
|
this.pending = [];
|
|
2240
2236
|
this.isOperationPending = false;
|
|
@@ -2244,7 +2240,6 @@ class Session {
|
|
|
2244
2240
|
this.afterConnected = new Promise((resolve) => {
|
|
2245
2241
|
this.registerConnected = resolve;
|
|
2246
2242
|
});
|
|
2247
|
-
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2248
2243
|
this._deprioritizeH264Encoding = deprioritizeH264Encoding;
|
|
2249
2244
|
this._incrementAnalyticMetric = incrementAnalyticMetric;
|
|
2250
2245
|
}
|
|
@@ -2397,12 +2392,6 @@ class Session {
|
|
|
2397
2392
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2398
2393
|
logger$7.info("replacetrack() [oldTrackId: %s, newTrackId: %s]", oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id, newTrack.id);
|
|
2399
2394
|
if (newTrack.readyState === "ended") {
|
|
2400
|
-
rtcStats.sendEvent("P2PReplaceTrackNewTrackEnded", {
|
|
2401
|
-
newTrackId: newTrack.id,
|
|
2402
|
-
newTrackKind: newTrack.kind,
|
|
2403
|
-
newTrackIsEffect: trackAnnotations(newTrack).isEffectTrack,
|
|
2404
|
-
});
|
|
2405
|
-
this._incrementAnalyticMetric("P2PReplaceTrackNewTrackEnded");
|
|
2406
2395
|
throw new Error(`refusing to replace track trackId: ${newTrack.id} kind: ${newTrack.kind} with readyState: ${newTrack.readyState}`);
|
|
2407
2396
|
}
|
|
2408
2397
|
const pc = this.pc;
|
|
@@ -2417,20 +2406,6 @@ class Session {
|
|
|
2417
2406
|
return (track === null || track === void 0 ? void 0 : track.kind) === newTrack.kind && !trackAnnotations(track).fromGetDisplayMedia;
|
|
2418
2407
|
});
|
|
2419
2408
|
if (sender) {
|
|
2420
|
-
this._incrementAnalyticMetric("P2PReplaceTrackOldTrackNotFound");
|
|
2421
|
-
const track = sender.track;
|
|
2422
|
-
rtcStats.sendEvent("P2PReplaceTrackOldTrackNotFound", {
|
|
2423
|
-
targetTrackId: track === null || track === void 0 ? void 0 : track.id,
|
|
2424
|
-
targetTrackKind: track === null || track === void 0 ? void 0 : track.kind,
|
|
2425
|
-
targetTrackIsEffect: track && trackAnnotations(track).isEffectTrack,
|
|
2426
|
-
targetTrackReadyState: track === null || track === void 0 ? void 0 : track.readyState,
|
|
2427
|
-
newTrackId: newTrack.id,
|
|
2428
|
-
newTrackKind: newTrack.kind,
|
|
2429
|
-
newTrackIsEffect: trackAnnotations(newTrack).isEffectTrack,
|
|
2430
|
-
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2431
|
-
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2432
|
-
oldTrackIsEffect: oldTrack && trackAnnotations(oldTrack).isEffectTrack,
|
|
2433
|
-
});
|
|
2434
2409
|
return yield sender.replaceTrack(newTrack);
|
|
2435
2410
|
}
|
|
2436
2411
|
let stream = this.streams.find((s) => s.getTracks().find((t) => t.id === newTrack.id));
|
|
@@ -2451,15 +2426,6 @@ class Session {
|
|
|
2451
2426
|
this._incrementAnalyticMetric("P2PReplaceTrackNoStream");
|
|
2452
2427
|
throw new Error("replaceTrack: No stream?");
|
|
2453
2428
|
}
|
|
2454
|
-
rtcStats.sendEvent("P2PReplaceTrackSourceKindNotFound", {
|
|
2455
|
-
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2456
|
-
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2457
|
-
oldTrackIsEffect: oldTrack && trackAnnotations(oldTrack).isEffectTrack,
|
|
2458
|
-
newTrackId: newTrack.id,
|
|
2459
|
-
newTrackKind: newTrack.kind,
|
|
2460
|
-
newTrackIsEffect: trackAnnotations(newTrack).isEffectTrack,
|
|
2461
|
-
});
|
|
2462
|
-
this._incrementAnalyticMetric("P2PReplaceTrackSourceKindNotFound");
|
|
2463
2429
|
pc.addTrack(newTrack, stream);
|
|
2464
2430
|
});
|
|
2465
2431
|
}
|
|
@@ -2562,12 +2528,6 @@ var rtcManagerEvents = {
|
|
|
2562
2528
|
DOMINANT_SPEAKER: "dominant_speaker",
|
|
2563
2529
|
};
|
|
2564
2530
|
|
|
2565
|
-
const CAMERA_STREAM_ID = "0";
|
|
2566
|
-
const STREAM_TYPES = {
|
|
2567
|
-
webcam: "webcam",
|
|
2568
|
-
screenshare: "screenshare",
|
|
2569
|
-
};
|
|
2570
|
-
|
|
2571
2531
|
var _a$2, _b$1;
|
|
2572
2532
|
const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
|
|
2573
2533
|
const logger$6 = new Logger();
|
|
@@ -2588,8 +2548,6 @@ class P2pRtcManager {
|
|
|
2588
2548
|
this._roomName = name;
|
|
2589
2549
|
this._roomSessionId = session && session.id;
|
|
2590
2550
|
this.peerConnections = {};
|
|
2591
|
-
this.localStreams = {};
|
|
2592
|
-
this.enabledLocalStreamIds = [];
|
|
2593
2551
|
this._screenshareVideoTrackIds = [];
|
|
2594
2552
|
this._socketListenerDeregisterFunctions = [];
|
|
2595
2553
|
this._localStreamDeregisterFunction = null;
|
|
@@ -2599,7 +2557,6 @@ class P2pRtcManager {
|
|
|
2599
2557
|
this._features = features || {};
|
|
2600
2558
|
this._isAudioOnlyMode = false;
|
|
2601
2559
|
this._closed = false;
|
|
2602
|
-
this.skipEmittingServerMessageCount = 0;
|
|
2603
2560
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
2604
2561
|
this._audioTrackOnEnded = () => {
|
|
2605
2562
|
rtcStats.sendEvent("audio_ended", { unloading: unloading$1 });
|
|
@@ -2634,13 +2591,8 @@ class P2pRtcManager {
|
|
|
2634
2591
|
numPcOnAnswerFailure: 0,
|
|
2635
2592
|
numPcOnOfferFailure: 0,
|
|
2636
2593
|
P2PChangeBandwidthEmptySDPType: 0,
|
|
2637
|
-
P2PSessionAlreadyCreated: 0,
|
|
2638
2594
|
P2PReplaceTrackNoStream: 0,
|
|
2639
|
-
P2PReplaceTrackNewTrackEnded: 0,
|
|
2640
2595
|
P2PReplaceTrackNewTrackNotInStream: 0,
|
|
2641
|
-
P2PReplaceTrackOldTrackNotFound: 0,
|
|
2642
|
-
P2PReplaceTrackWithoutPC: 0,
|
|
2643
|
-
P2PReplaceTrackSourceKindNotFound: 0,
|
|
2644
2596
|
P2POnTrackNoStream: 0,
|
|
2645
2597
|
P2PSetCodecPreferenceError: 0,
|
|
2646
2598
|
P2PCreateOfferNoSDP: 0,
|
|
@@ -2648,6 +2600,7 @@ class P2pRtcManager {
|
|
|
2648
2600
|
P2PMicNotWorking: 0,
|
|
2649
2601
|
P2PLocalNetworkFailed: 0,
|
|
2650
2602
|
P2PRelayedIceCandidate: 0,
|
|
2603
|
+
P2PStartScreenshareNoStream: 0,
|
|
2651
2604
|
};
|
|
2652
2605
|
}
|
|
2653
2606
|
numberOfPeerconnections() {
|
|
@@ -2656,50 +2609,59 @@ class P2pRtcManager {
|
|
|
2656
2609
|
isInitializedWith({ selfId, roomName, isSfu }) {
|
|
2657
2610
|
return this._selfId === selfId && this._roomName === roomName && !isSfu;
|
|
2658
2611
|
}
|
|
2659
|
-
|
|
2660
|
-
if (stream === this.
|
|
2612
|
+
addCameraStream(stream, { beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
2613
|
+
if (stream === this._localCameraStream) {
|
|
2661
2614
|
return;
|
|
2662
2615
|
}
|
|
2663
|
-
this.
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
if (audioTrack) {
|
|
2669
|
-
|
|
2670
|
-
this._monitorAudioTrack(audioTrack);
|
|
2671
|
-
}
|
|
2672
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
2673
|
-
if (beforeEffectTrack) {
|
|
2674
|
-
this._monitorAudioTrack(beforeEffectTrack);
|
|
2675
|
-
}
|
|
2616
|
+
this._localCameraStream = stream;
|
|
2617
|
+
this._addStreamToPeerConnections(stream);
|
|
2618
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
2619
|
+
const audioTrack = stream.getAudioTracks()[0];
|
|
2620
|
+
if (audioTrack) {
|
|
2621
|
+
if (!trackAnnotations(audioTrack).isEffectTrack) {
|
|
2622
|
+
this._monitorAudioTrack(audioTrack);
|
|
2676
2623
|
}
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
}
|
|
2681
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
2682
|
-
if (beforeEffectTrack) {
|
|
2683
|
-
this._monitorVideoTrack(beforeEffectTrack);
|
|
2684
|
-
}
|
|
2624
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
2625
|
+
if (beforeEffectTrack) {
|
|
2626
|
+
this._monitorAudioTrack(beforeEffectTrack);
|
|
2685
2627
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2628
|
+
}
|
|
2629
|
+
if (videoTrack) {
|
|
2630
|
+
if (!trackAnnotations(videoTrack).isEffectTrack) {
|
|
2631
|
+
this._monitorVideoTrack(videoTrack);
|
|
2689
2632
|
}
|
|
2690
|
-
const
|
|
2691
|
-
|
|
2692
|
-
this.
|
|
2693
|
-
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2633
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
2634
|
+
if (beforeEffectTrack) {
|
|
2635
|
+
this._monitorVideoTrack(beforeEffectTrack);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
this._enableStopResumeVideoForBrowserSDK(stream);
|
|
2639
|
+
}
|
|
2640
|
+
_enableStopResumeVideoForBrowserSDK(stream) {
|
|
2641
|
+
if (this._localStreamDeregisterFunction) {
|
|
2642
|
+
this._localStreamDeregisterFunction();
|
|
2643
|
+
this._localStreamDeregisterFunction = null;
|
|
2644
|
+
}
|
|
2645
|
+
const localStreamHandler = (e) => {
|
|
2646
|
+
const { enable, track } = e.detail;
|
|
2647
|
+
this._handleStopOrResumeVideo({ enable, track });
|
|
2648
|
+
};
|
|
2649
|
+
stream.addEventListener("stopresumevideo", localStreamHandler);
|
|
2650
|
+
this._localStreamDeregisterFunction = () => {
|
|
2651
|
+
stream.removeEventListener("stopresumevideo", localStreamHandler);
|
|
2652
|
+
};
|
|
2653
|
+
}
|
|
2654
|
+
addScreenshareStream(stream) {
|
|
2655
|
+
if (stream === this._localScreenshareStream) {
|
|
2698
2656
|
return;
|
|
2699
2657
|
}
|
|
2658
|
+
this._localScreenshareStream = stream;
|
|
2700
2659
|
this._screenshareVideoTrackIds.push(stream.getVideoTracks()[0].id);
|
|
2701
|
-
this.
|
|
2702
|
-
|
|
2660
|
+
this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
|
|
2661
|
+
streamId: stream.id,
|
|
2662
|
+
hasAudioTrack: !!stream.getAudioTracks().length,
|
|
2663
|
+
});
|
|
2664
|
+
this._addStreamToPeerConnections(stream);
|
|
2703
2665
|
}
|
|
2704
2666
|
replaceTrack(oldTrack, newTrack) {
|
|
2705
2667
|
if (newTrack.kind === "audio" && !trackAnnotations(newTrack).isEffectTrack) {
|
|
@@ -2853,11 +2815,12 @@ class P2pRtcManager {
|
|
|
2853
2815
|
});
|
|
2854
2816
|
}
|
|
2855
2817
|
setRemoteScreenshareVideoTrackIds(remoteScreenshareVideoTrackIds = []) {
|
|
2856
|
-
|
|
2857
|
-
this._screenshareVideoTrackIds = [
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2818
|
+
var _a, _b;
|
|
2819
|
+
this._screenshareVideoTrackIds = [...remoteScreenshareVideoTrackIds];
|
|
2820
|
+
const localScreenShareTrack = (_b = (_a = this._localScreenshareStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks()) === null || _b === void 0 ? void 0 : _b[0];
|
|
2821
|
+
if (localScreenShareTrack) {
|
|
2822
|
+
this._screenshareVideoTrackIds.push(localScreenShareTrack.id);
|
|
2823
|
+
}
|
|
2861
2824
|
}
|
|
2862
2825
|
setRoomSessionId(roomSessionId) {
|
|
2863
2826
|
this._roomSessionId = roomSessionId;
|
|
@@ -2903,7 +2866,6 @@ class P2pRtcManager {
|
|
|
2903
2866
|
}
|
|
2904
2867
|
if (this._features.awaitJoinRoomFinished && !this._serverSocket.joinRoomFinished) {
|
|
2905
2868
|
rtcStats.sendEvent("skip_emitting_server_message", { eventName });
|
|
2906
|
-
this.skipEmittingServerMessageCount++;
|
|
2907
2869
|
}
|
|
2908
2870
|
else {
|
|
2909
2871
|
this._serverSocket.emit(eventName, data);
|
|
@@ -2912,34 +2874,12 @@ class P2pRtcManager {
|
|
|
2912
2874
|
_emit(eventName, data) {
|
|
2913
2875
|
this._emitter.emit(eventName, data);
|
|
2914
2876
|
}
|
|
2915
|
-
_addEnabledLocalStreamId(streamId) {
|
|
2916
|
-
this.enabledLocalStreamIds.push(streamId);
|
|
2917
|
-
}
|
|
2918
|
-
_deleteEnabledLocalStreamId(streamId) {
|
|
2919
|
-
const index = this.enabledLocalStreamIds.indexOf(streamId);
|
|
2920
|
-
if (index !== -1) {
|
|
2921
|
-
this.enabledLocalStreamIds.splice(index, 1);
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
2877
|
_getSession(peerConnectionId) {
|
|
2925
2878
|
if (!(peerConnectionId in this.peerConnections)) {
|
|
2926
2879
|
return null;
|
|
2927
2880
|
}
|
|
2928
2881
|
return this.peerConnections[peerConnectionId];
|
|
2929
2882
|
}
|
|
2930
|
-
_getLocalCameraStream() {
|
|
2931
|
-
return this.localStreams[CAMERA_STREAM_ID];
|
|
2932
|
-
}
|
|
2933
|
-
_getNonLocalCameraStreamIds() {
|
|
2934
|
-
return Object.keys(this.localStreams).filter((streamId) => streamId !== CAMERA_STREAM_ID);
|
|
2935
|
-
}
|
|
2936
|
-
_isScreensharingLocally() {
|
|
2937
|
-
return this._getNonLocalCameraStreamIds().length > 0;
|
|
2938
|
-
}
|
|
2939
|
-
_getFirstLocalNonCameraStream() {
|
|
2940
|
-
const streamIds = this._getNonLocalCameraStreamIds();
|
|
2941
|
-
return streamIds.length === 0 ? null : this.localStreams[streamIds[0]];
|
|
2942
|
-
}
|
|
2943
2883
|
_createSession({ clientId, initialBandwidth, isOfferer, peerConnectionId }) {
|
|
2944
2884
|
if (!peerConnectionId) {
|
|
2945
2885
|
throw new Error("peerConnectionId is missing");
|
|
@@ -3072,29 +3012,34 @@ class P2pRtcManager {
|
|
|
3072
3012
|
break;
|
|
3073
3013
|
}
|
|
3074
3014
|
};
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
session.addStream(localCameraStream);
|
|
3015
|
+
if (this._localCameraStream) {
|
|
3016
|
+
session.addStream(this._localCameraStream);
|
|
3078
3017
|
}
|
|
3079
|
-
|
|
3080
|
-
if (id === CAMERA_STREAM_ID) {
|
|
3081
|
-
return;
|
|
3082
|
-
}
|
|
3083
|
-
const screenshareStream = this.localStreams[id];
|
|
3018
|
+
if (this._localScreenshareStream) {
|
|
3084
3019
|
if (isOfferer) {
|
|
3085
|
-
session.addStream(
|
|
3020
|
+
session.addStream(this._localScreenshareStream);
|
|
3086
3021
|
}
|
|
3087
3022
|
else {
|
|
3088
3023
|
session.afterConnected.then(() => {
|
|
3024
|
+
if (!this._localScreenshareStream)
|
|
3025
|
+
return;
|
|
3089
3026
|
this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
|
|
3090
3027
|
receiverId: session.clientId,
|
|
3091
|
-
streamId:
|
|
3092
|
-
hasAudioTrack: !!
|
|
3028
|
+
streamId: this._localScreenshareStream.id,
|
|
3029
|
+
hasAudioTrack: !!this._localScreenshareStream.getAudioTracks().length,
|
|
3030
|
+
});
|
|
3031
|
+
this._withForcedRenegotiation(session, () => {
|
|
3032
|
+
if (this._localScreenshareStream) {
|
|
3033
|
+
session.addStream(this._localScreenshareStream);
|
|
3034
|
+
}
|
|
3035
|
+
else {
|
|
3036
|
+
this.analytics.P2PStartScreenshareNoStream++;
|
|
3037
|
+
rtcStats.sendEvent("P2PStartScreenshareNoStream", {});
|
|
3038
|
+
}
|
|
3093
3039
|
});
|
|
3094
|
-
this._withForcedRenegotiation(session, () => session.addStream(screenshareStream));
|
|
3095
3040
|
});
|
|
3096
3041
|
}
|
|
3097
|
-
}
|
|
3042
|
+
}
|
|
3098
3043
|
return session;
|
|
3099
3044
|
}
|
|
3100
3045
|
_cleanup(peerConnectionId) {
|
|
@@ -3128,11 +3073,6 @@ class P2pRtcManager {
|
|
|
3128
3073
|
if (session.pc.connectionState === "closed")
|
|
3129
3074
|
return;
|
|
3130
3075
|
logger$6.info("Session doesn't have a connected PeerConnection, adding pending action!");
|
|
3131
|
-
this.analytics.P2PReplaceTrackWithoutPC++;
|
|
3132
|
-
rtcStats.sendEvent("P2PReplaceTrackWithoutPC", {
|
|
3133
|
-
connectionState: session.pc.connectionState,
|
|
3134
|
-
iceConnectionState: session.pc.iceConnectionState,
|
|
3135
|
-
});
|
|
3136
3076
|
const promise = new Promise((resolve, reject) => {
|
|
3137
3077
|
const action = () => __awaiter(this, void 0, void 0, function* () {
|
|
3138
3078
|
try {
|
|
@@ -3164,14 +3104,6 @@ class P2pRtcManager {
|
|
|
3164
3104
|
this._withForcedRenegotiation(session, () => session.removeTrack(track));
|
|
3165
3105
|
});
|
|
3166
3106
|
}
|
|
3167
|
-
_addLocalStream(streamId, stream) {
|
|
3168
|
-
this._addEnabledLocalStreamId(streamId);
|
|
3169
|
-
this.localStreams[streamId] = stream;
|
|
3170
|
-
}
|
|
3171
|
-
_removeLocalStream(streamId) {
|
|
3172
|
-
delete this.localStreams[streamId];
|
|
3173
|
-
this._deleteEnabledLocalStreamId(streamId);
|
|
3174
|
-
}
|
|
3175
3107
|
_updateAndScheduleMediaServersRefresh({ iceServers, turnServers, mediaserverConfigTtlSeconds, }) {
|
|
3176
3108
|
this._iceServers = iceServers;
|
|
3177
3109
|
this._turnServers = turnServers;
|
|
@@ -3381,6 +3313,7 @@ class P2pRtcManager {
|
|
|
3381
3313
|
return bandwidth;
|
|
3382
3314
|
}
|
|
3383
3315
|
_createP2pSession({ clientId, initialBandwidth, isOfferer = false, }) {
|
|
3316
|
+
var _a, _b;
|
|
3384
3317
|
const session = this._createSession({
|
|
3385
3318
|
peerConnectionId: clientId,
|
|
3386
3319
|
clientId,
|
|
@@ -3391,9 +3324,8 @@ class P2pRtcManager {
|
|
|
3391
3324
|
if (this._features.increaseIncomingMediaBufferOn) {
|
|
3392
3325
|
this._setJitterBufferTarget(pc);
|
|
3393
3326
|
}
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
pc.addTrack(this._stoppedVideoTrack, localCameraStream);
|
|
3327
|
+
if (((_b = (_a = this._localCameraStream) === null || _a === void 0 ? void 0 : _a.getVideoTracks()) === null || _b === void 0 ? void 0 : _b.length) && this._stoppedVideoTrack) {
|
|
3328
|
+
pc.addTrack(this._stoppedVideoTrack, this._localCameraStream);
|
|
3397
3329
|
}
|
|
3398
3330
|
pc.onicegatheringstatechange = (event) => {
|
|
3399
3331
|
const connection = event.target;
|
|
@@ -3603,19 +3535,10 @@ class P2pRtcManager {
|
|
|
3603
3535
|
}
|
|
3604
3536
|
}
|
|
3605
3537
|
}
|
|
3606
|
-
|
|
3607
|
-
this._emitServerEvent(PROTOCOL_REQUESTS.START_SCREENSHARE, {
|
|
3608
|
-
streamId,
|
|
3609
|
-
hasAudioTrack: !!stream.getAudioTracks().length,
|
|
3610
|
-
});
|
|
3611
|
-
this._wasScreenSharing = true;
|
|
3612
|
-
this._addStreamToPeerConnections(stream);
|
|
3613
|
-
}
|
|
3614
|
-
removeStream(streamId, stream, requestedByClientId) {
|
|
3615
|
-
this._removeLocalStream(streamId);
|
|
3538
|
+
removeScreenshareStream(stream, { requestedByClientId } = {}) {
|
|
3616
3539
|
this._removeStreamFromPeerConnections(stream);
|
|
3617
|
-
this.
|
|
3618
|
-
this.
|
|
3540
|
+
this._emitServerEvent(PROTOCOL_REQUESTS.STOP_SCREENSHARE, { streamId: stream.id, requestedByClientId });
|
|
3541
|
+
delete this._localScreenshareStream;
|
|
3619
3542
|
}
|
|
3620
3543
|
hasClient(clientId) {
|
|
3621
3544
|
return Object.keys(this.peerConnections).includes(clientId);
|
|
@@ -4447,6 +4370,12 @@ function createVegaConnectionManager(config) {
|
|
|
4447
4370
|
return { connect, updateHostList, networkIsUp, networkIsPossiblyDown };
|
|
4448
4371
|
}
|
|
4449
4372
|
|
|
4373
|
+
const CAMERA_STREAM_ID = "0";
|
|
4374
|
+
const STREAM_TYPES = {
|
|
4375
|
+
webcam: "webcam",
|
|
4376
|
+
screenshare: "screenshare",
|
|
4377
|
+
};
|
|
4378
|
+
|
|
4450
4379
|
var _a$1;
|
|
4451
4380
|
const adapter$1 = (_a$1 = adapterRaw.default) !== null && _a$1 !== void 0 ? _a$1 : adapterRaw;
|
|
4452
4381
|
const logger$2 = new Logger();
|
|
@@ -5390,7 +5319,7 @@ class VegaRtcManager {
|
|
|
5390
5319
|
(_a = this._vegaConnection) === null || _a === void 0 ? void 0 : _a.message("eventClaim", { eventClaim });
|
|
5391
5320
|
}
|
|
5392
5321
|
}
|
|
5393
|
-
replaceTrack(
|
|
5322
|
+
replaceTrack(_, track) {
|
|
5394
5323
|
if (track.kind === "audio") {
|
|
5395
5324
|
if (!trackAnnotations(track).isEffectTrack) {
|
|
5396
5325
|
this._monitorAudioTrack(track);
|
|
@@ -5406,8 +5335,8 @@ class VegaRtcManager {
|
|
|
5406
5335
|
this._replaceWebcamTrack();
|
|
5407
5336
|
}
|
|
5408
5337
|
}
|
|
5409
|
-
|
|
5410
|
-
logger$2.info("
|
|
5338
|
+
removeScreenshareStream(stream, { requestedByClientId } = { requestedByClientId: undefined }) {
|
|
5339
|
+
logger$2.info("removeScreenshareStream() [streamId:%s, requestedByClientId:%s]", stream.id, requestedByClientId);
|
|
5411
5340
|
this._emitToSignal(PROTOCOL_REQUESTS.STOP_SCREENSHARE, {
|
|
5412
5341
|
streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
|
|
5413
5342
|
requestedByClientId,
|
|
@@ -5424,57 +5353,58 @@ class VegaRtcManager {
|
|
|
5424
5353
|
(_b = (_a = this._micAnalyserDebugger) === null || _a === void 0 ? void 0 : _a.onScoreUpdated) === null || _b === void 0 ? void 0 : _b.call(_a, data);
|
|
5425
5354
|
this._sendMicScore(this._micPaused ? 0 : data.out);
|
|
5426
5355
|
}
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
this._monitorVideoTrack(videoTrack);
|
|
5437
|
-
}
|
|
5438
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
5439
|
-
if (beforeEffectTrack) {
|
|
5440
|
-
this._monitorVideoTrack(beforeEffectTrack);
|
|
5441
|
-
}
|
|
5356
|
+
addCameraStream(stream, { audioPaused, videoPaused, beforeEffectTracks = [] } = { beforeEffectTracks: [] }) {
|
|
5357
|
+
this._micPaused = audioPaused;
|
|
5358
|
+
this._webcamPaused = videoPaused;
|
|
5359
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
5360
|
+
const audioTrack = stream.getAudioTracks()[0];
|
|
5361
|
+
if (videoTrack) {
|
|
5362
|
+
this._sendWebcam(videoTrack);
|
|
5363
|
+
if (!trackAnnotations(videoTrack).isEffectTrack) {
|
|
5364
|
+
this._monitorVideoTrack(videoTrack);
|
|
5442
5365
|
}
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
this.
|
|
5446
|
-
if (!trackAnnotations(audioTrack).isEffectTrack) {
|
|
5447
|
-
this._monitorAudioTrack(audioTrack);
|
|
5448
|
-
}
|
|
5449
|
-
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
5450
|
-
if (beforeEffectTrack) {
|
|
5451
|
-
this._monitorAudioTrack(beforeEffectTrack);
|
|
5452
|
-
}
|
|
5366
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
|
|
5367
|
+
if (beforeEffectTrack) {
|
|
5368
|
+
this._monitorVideoTrack(beforeEffectTrack);
|
|
5453
5369
|
}
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5370
|
+
}
|
|
5371
|
+
if (audioTrack) {
|
|
5372
|
+
this._sendMic(audioTrack);
|
|
5373
|
+
this._syncMicAnalyser();
|
|
5374
|
+
if (!trackAnnotations(audioTrack).isEffectTrack) {
|
|
5375
|
+
this._monitorAudioTrack(audioTrack);
|
|
5376
|
+
}
|
|
5377
|
+
const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
|
|
5378
|
+
if (beforeEffectTrack) {
|
|
5379
|
+
this._monitorAudioTrack(beforeEffectTrack);
|
|
5457
5380
|
}
|
|
5458
|
-
const localStreamHandler = (e) => {
|
|
5459
|
-
const { enable, track } = e.detail;
|
|
5460
|
-
this._webcamPaused = !enable;
|
|
5461
|
-
this._pauseResumeWebcam();
|
|
5462
|
-
this._handleStopOrResumeVideo({ enable, track });
|
|
5463
|
-
};
|
|
5464
|
-
stream.addEventListener("stopresumevideo", localStreamHandler);
|
|
5465
|
-
this._localStreamDeregisterFunction = () => {
|
|
5466
|
-
stream.removeEventListener("stopresumevideo", localStreamHandler);
|
|
5467
|
-
};
|
|
5468
5381
|
}
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
this._sendScreenAudio(audioTrack);
|
|
5476
|
-
this._emitScreenshareStarted();
|
|
5382
|
+
this._enableStopResumeVideoForBrowserSDK(stream);
|
|
5383
|
+
}
|
|
5384
|
+
_enableStopResumeVideoForBrowserSDK(stream) {
|
|
5385
|
+
if (this._localStreamDeregisterFunction) {
|
|
5386
|
+
this._localStreamDeregisterFunction();
|
|
5387
|
+
this._localStreamDeregisterFunction = null;
|
|
5477
5388
|
}
|
|
5389
|
+
const localStreamHandler = (e) => {
|
|
5390
|
+
const { enable, track } = e.detail;
|
|
5391
|
+
this._webcamPaused = !enable;
|
|
5392
|
+
this._pauseResumeWebcam();
|
|
5393
|
+
this._handleStopOrResumeVideo({ enable, track });
|
|
5394
|
+
};
|
|
5395
|
+
stream.addEventListener("stopresumevideo", localStreamHandler);
|
|
5396
|
+
this._localStreamDeregisterFunction = () => {
|
|
5397
|
+
stream.removeEventListener("stopresumevideo", localStreamHandler);
|
|
5398
|
+
};
|
|
5399
|
+
}
|
|
5400
|
+
addScreenshareStream(stream) {
|
|
5401
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
5402
|
+
const audioTrack = stream.getAudioTracks()[0];
|
|
5403
|
+
if (videoTrack)
|
|
5404
|
+
this._sendScreenVideo(videoTrack);
|
|
5405
|
+
if (audioTrack)
|
|
5406
|
+
this._sendScreenAudio(audioTrack);
|
|
5407
|
+
this._emitScreenshareStarted();
|
|
5478
5408
|
}
|
|
5479
5409
|
_syncMicAnalyser() {
|
|
5480
5410
|
if (this._micTrack && this._colocation && !this._micAnalyser) {
|