@whereby.com/media 2.6.8 → 2.6.10
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 +182 -123
- package/dist/index.d.cts +104 -89
- package/dist/index.d.mts +104 -89
- package/dist/index.d.ts +104 -89
- package/dist/index.mjs +182 -124
- package/dist/legacy-esm.js +182 -124
- package/package.json +1 -1
package/dist/legacy-esm.js
CHANGED
|
@@ -1807,6 +1807,16 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
|
|
|
1807
1807
|
}
|
|
1808
1808
|
fromLocation(window && window.location);
|
|
1809
1809
|
|
|
1810
|
+
const _trackAnnotations = new WeakMap();
|
|
1811
|
+
function trackAnnotations(o) {
|
|
1812
|
+
let props = _trackAnnotations.get(o);
|
|
1813
|
+
if (!props) {
|
|
1814
|
+
props = {};
|
|
1815
|
+
_trackAnnotations.set(o, props);
|
|
1816
|
+
}
|
|
1817
|
+
return props;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1810
1820
|
const logger$9 = new Logger();
|
|
1811
1821
|
const debugLogger = {
|
|
1812
1822
|
print: (...args) => console.debug(args[0], ...args.slice(1)),
|
|
@@ -2146,7 +2156,7 @@ var _a$4;
|
|
|
2146
2156
|
const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
|
|
2147
2157
|
const logger$7 = new Logger();
|
|
2148
2158
|
class Session {
|
|
2149
|
-
constructor({ peerConnectionId, bandwidth, deprioritizeH264Encoding, incrementAnalyticMetric, }) {
|
|
2159
|
+
constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }) {
|
|
2150
2160
|
this.peerConnectionId = peerConnectionId;
|
|
2151
2161
|
this.relayCandidateSeen = false;
|
|
2152
2162
|
this.serverReflexiveCandidateSeen = false;
|
|
@@ -2155,7 +2165,24 @@ class Session {
|
|
|
2155
2165
|
this.ipv6HostCandidateTeredoSeen = false;
|
|
2156
2166
|
this.ipv6HostCandidate6to4Seen = false;
|
|
2157
2167
|
this.mdnsHostCandidateSeen = false;
|
|
2158
|
-
this.
|
|
2168
|
+
this.peerConnectionConfig = peerConnectionConfig;
|
|
2169
|
+
this.shouldAddLocalVideo = shouldAddLocalVideo;
|
|
2170
|
+
this.clientId = clientId;
|
|
2171
|
+
this.pc = new RTCPeerConnection(this.peerConnectionConfig);
|
|
2172
|
+
this.signalingState = this.pc.signalingState;
|
|
2173
|
+
this.pc.addEventListener("signalingstatechange", () => {
|
|
2174
|
+
if (this.signalingState === this.pc.signalingState) {
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
this.signalingState = this.pc.signalingState;
|
|
2178
|
+
if (this.pc.signalingState === "stable") {
|
|
2179
|
+
this.isOperationPending = false;
|
|
2180
|
+
const action = this.pending.shift();
|
|
2181
|
+
if (action) {
|
|
2182
|
+
action.apply();
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
});
|
|
2159
2186
|
this.wasEverConnected = false;
|
|
2160
2187
|
this.connectionStatus = null;
|
|
2161
2188
|
this.stats = {
|
|
@@ -2175,27 +2202,6 @@ class Session {
|
|
|
2175
2202
|
this._deprioritizeH264Encoding = deprioritizeH264Encoding;
|
|
2176
2203
|
this._incrementAnalyticMetric = incrementAnalyticMetric;
|
|
2177
2204
|
}
|
|
2178
|
-
setAndGetPeerConnection({ clientId, constraints, peerConnectionConfig, shouldAddLocalVideo, }) {
|
|
2179
|
-
this.peerConnectionConfig = peerConnectionConfig;
|
|
2180
|
-
this.shouldAddLocalVideo = shouldAddLocalVideo;
|
|
2181
|
-
this.clientId = clientId;
|
|
2182
|
-
this.pc = new RTCPeerConnection(peerConnectionConfig);
|
|
2183
|
-
this.signalingState = this.pc.signalingState;
|
|
2184
|
-
this.pc.addEventListener("signalingstatechange", () => {
|
|
2185
|
-
if (this.signalingState === this.pc.signalingState) {
|
|
2186
|
-
return;
|
|
2187
|
-
}
|
|
2188
|
-
this.signalingState = this.pc.signalingState;
|
|
2189
|
-
if (this.pc.signalingState === "stable") {
|
|
2190
|
-
this.isOperationPending = false;
|
|
2191
|
-
const action = this.pending.shift();
|
|
2192
|
-
if (action) {
|
|
2193
|
-
action.apply();
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
});
|
|
2197
|
-
return this.pc;
|
|
2198
|
-
}
|
|
2199
2205
|
addStream(stream) {
|
|
2200
2206
|
this.streamIds.push(stream.id);
|
|
2201
2207
|
this.streams.push(stream);
|
|
@@ -2208,6 +2214,7 @@ class Session {
|
|
|
2208
2214
|
});
|
|
2209
2215
|
}
|
|
2210
2216
|
else {
|
|
2217
|
+
rtcStats.sendEvent("P2PNoAddTrackSupport", {});
|
|
2211
2218
|
this.pc.addStream(stream);
|
|
2212
2219
|
}
|
|
2213
2220
|
}
|
|
@@ -2246,6 +2253,10 @@ class Session {
|
|
|
2246
2253
|
this.pc.removeStream(stream);
|
|
2247
2254
|
}
|
|
2248
2255
|
}
|
|
2256
|
+
else {
|
|
2257
|
+
rtcStats.sendEvent("P2PRemoveStreamNoPC", {});
|
|
2258
|
+
this._incrementAnalyticMetric("P2PRemoveStreamNoPC");
|
|
2259
|
+
}
|
|
2249
2260
|
}
|
|
2250
2261
|
_setRemoteDescription(desc) {
|
|
2251
2262
|
if (this._deprioritizeH264Encoding)
|
|
@@ -2330,102 +2341,109 @@ class Session {
|
|
|
2330
2341
|
return this.pc && this.pc.connectionState === "connected";
|
|
2331
2342
|
}
|
|
2332
2343
|
replaceTrack(oldTrack, newTrack) {
|
|
2333
|
-
var _a;
|
|
2334
|
-
|
|
2335
|
-
if (!
|
|
2336
|
-
rtcStats.sendEvent("
|
|
2344
|
+
var _a, _b, _c;
|
|
2345
|
+
logger$7.info("replacetrack() [oldTrackId: %s, newTrackId: %s]", oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id, newTrack === null || newTrack === void 0 ? void 0 : newTrack.id);
|
|
2346
|
+
if (!newTrack) {
|
|
2347
|
+
rtcStats.sendEvent("P2PReplaceTrackNoNewTrack", {
|
|
2337
2348
|
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2338
|
-
|
|
2349
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2350
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2339
2351
|
});
|
|
2340
|
-
this._incrementAnalyticMetric("
|
|
2352
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNoNewTrack");
|
|
2341
2353
|
return false;
|
|
2342
2354
|
}
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
return null;
|
|
2360
|
-
};
|
|
2361
|
-
const result = process();
|
|
2362
|
-
if (result) {
|
|
2363
|
-
return result;
|
|
2355
|
+
if (newTrack.readyState === "ended") {
|
|
2356
|
+
rtcStats.sendEvent("P2PReplaceTrackNewTrackEnded", {
|
|
2357
|
+
newTrackId: newTrack.id,
|
|
2358
|
+
newTrackKind: newTrack.kind,
|
|
2359
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2360
|
+
});
|
|
2361
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNewTrackEnded");
|
|
2362
|
+
return false;
|
|
2363
|
+
}
|
|
2364
|
+
const pc = this.pc;
|
|
2365
|
+
if ((_b = (_a = window.RTCRtpSender) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.replaceTrack) {
|
|
2366
|
+
if (oldTrack) {
|
|
2367
|
+
const sender = pc.getSenders().find((s) => { var _a; return ((_a = s.track) === null || _a === void 0 ? void 0 : _a.id) === oldTrack.id; });
|
|
2368
|
+
if (sender) {
|
|
2369
|
+
sender.replaceTrack(newTrack);
|
|
2370
|
+
return Promise.resolve(newTrack);
|
|
2364
2371
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
rtcStats.sendEvent("P2PReplaceTrackFailed", {
|
|
2385
|
-
newTrackId: newTrack === null || newTrack === void 0 ? void 0 : newTrack.id,
|
|
2386
|
-
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2387
|
-
oldTrackFallbackId: oldTrackFallback === null || oldTrackFallback === void 0 ? void 0 : oldTrackFallback.id,
|
|
2388
|
-
sendersCount: senders === null || senders === void 0 ? void 0 : senders.length,
|
|
2389
|
-
sendersAnalytics,
|
|
2390
|
-
});
|
|
2391
|
-
reject("No sender track to replace");
|
|
2392
|
-
}
|
|
2393
|
-
return;
|
|
2394
|
-
}
|
|
2395
|
-
clearInterval(timer);
|
|
2396
|
-
timer = null;
|
|
2397
|
-
const trackReplaced = yield trackReplacedPromise;
|
|
2398
|
-
resolve(trackReplaced);
|
|
2399
|
-
}), 1000);
|
|
2372
|
+
}
|
|
2373
|
+
const sender = pc.getSenders().find((s) => {
|
|
2374
|
+
const track = s.track;
|
|
2375
|
+
return (track === null || track === void 0 ? void 0 : track.kind) === newTrack.kind && !trackAnnotations(track).fromGetDisplayMedia;
|
|
2376
|
+
});
|
|
2377
|
+
if (sender) {
|
|
2378
|
+
this._incrementAnalyticMetric("P2PReplaceTrackOldTrackNotFound");
|
|
2379
|
+
const track = sender.track;
|
|
2380
|
+
rtcStats.sendEvent("P2PReplaceTrackOldTrackNotFound", {
|
|
2381
|
+
targetTrackId: track === null || track === void 0 ? void 0 : track.id,
|
|
2382
|
+
targetTrackKind: track === null || track === void 0 ? void 0 : track.kind,
|
|
2383
|
+
targetTrackIsEffect: track === null || track === void 0 ? void 0 : track.effectTrack,
|
|
2384
|
+
targetTrackReadyState: track === null || track === void 0 ? void 0 : track.readyState,
|
|
2385
|
+
newTrackId: newTrack.id,
|
|
2386
|
+
newTrackKind: newTrack.kind,
|
|
2387
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2388
|
+
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2389
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2390
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2400
2391
|
});
|
|
2392
|
+
sender.replaceTrack(newTrack);
|
|
2393
|
+
return Promise.resolve(newTrack);
|
|
2401
2394
|
}
|
|
2402
|
-
|
|
2395
|
+
let stream = this.streams.find((s) => s.getTracks().find((t) => t.id === newTrack.id));
|
|
2403
2396
|
if (!stream) {
|
|
2397
|
+
rtcStats.sendEvent("P2PReplaceTrackNewTrackNotInStream", {
|
|
2398
|
+
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2399
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2400
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2401
|
+
newTrackId: newTrack.id,
|
|
2402
|
+
newTrackKind: newTrack.kind,
|
|
2403
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2404
|
+
});
|
|
2405
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNewTrackNotInStream");
|
|
2406
|
+
}
|
|
2407
|
+
stream = this.streams[0];
|
|
2408
|
+
if (!stream) {
|
|
2409
|
+
rtcStats.sendEvent("P2PReplaceTrackNoStream", {});
|
|
2410
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNoStream");
|
|
2404
2411
|
return Promise.reject(new Error("replaceTrack: No stream?"));
|
|
2405
2412
|
}
|
|
2413
|
+
rtcStats.sendEvent("P2PReplaceTrackSourceKindNotFound", {
|
|
2414
|
+
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2415
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2416
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2417
|
+
newTrackId: newTrack.id,
|
|
2418
|
+
newTrackKind: newTrack.kind,
|
|
2419
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2420
|
+
});
|
|
2421
|
+
this._incrementAnalyticMetric("P2PReplaceTrackSourceKindNotFound");
|
|
2406
2422
|
return pc.addTrack(newTrack, stream);
|
|
2407
2423
|
}
|
|
2424
|
+
rtcStats.sendEvent("P2PNoReplaceTrackSupport", {});
|
|
2408
2425
|
if (!this.canModifyPeerConnection()) {
|
|
2409
2426
|
this.pending.push(() => {
|
|
2410
|
-
this.replaceTrack(
|
|
2427
|
+
this.replaceTrack(oldTrack, newTrack);
|
|
2411
2428
|
});
|
|
2412
2429
|
return;
|
|
2413
2430
|
}
|
|
2414
2431
|
this.isOperationPending = true;
|
|
2415
2432
|
const onn = pc.onnegotiationneeded;
|
|
2416
2433
|
pc.onnegotiationneeded = null;
|
|
2417
|
-
if (
|
|
2418
|
-
this.removeTrack(
|
|
2434
|
+
if (oldTrack) {
|
|
2435
|
+
this.removeTrack(oldTrack);
|
|
2419
2436
|
}
|
|
2420
2437
|
this.addTrack(newTrack);
|
|
2421
2438
|
setTimeout(() => {
|
|
2422
2439
|
pc.onnegotiationneeded = onn;
|
|
2423
2440
|
}, 0);
|
|
2424
|
-
if (pc.localDescription.type === "offer") {
|
|
2441
|
+
if (((_c = pc.localDescription) === null || _c === void 0 ? void 0 : _c.type) === "offer") {
|
|
2425
2442
|
return pc
|
|
2426
2443
|
.createOffer()
|
|
2427
2444
|
.then((offer) => {
|
|
2428
|
-
|
|
2445
|
+
var _a;
|
|
2446
|
+
offer.sdp = replaceSSRCs((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp, offer.sdp);
|
|
2429
2447
|
return pc.setLocalDescription(offer);
|
|
2430
2448
|
})
|
|
2431
2449
|
.then(() => {
|
|
@@ -2438,12 +2456,14 @@ class Session {
|
|
|
2438
2456
|
return pc.createAnswer();
|
|
2439
2457
|
})
|
|
2440
2458
|
.then((answer) => {
|
|
2441
|
-
|
|
2459
|
+
var _a;
|
|
2460
|
+
answer.sdp = replaceSSRCs((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp, answer.sdp);
|
|
2442
2461
|
return pc.setLocalDescription(answer);
|
|
2443
2462
|
});
|
|
2444
2463
|
}
|
|
2445
2464
|
}
|
|
2446
2465
|
changeBandwidth(bandwidth) {
|
|
2466
|
+
var _a;
|
|
2447
2467
|
if (bandwidth === this.bandwidth) {
|
|
2448
2468
|
return;
|
|
2449
2469
|
}
|
|
@@ -2452,22 +2472,24 @@ class Session {
|
|
|
2452
2472
|
return;
|
|
2453
2473
|
}
|
|
2454
2474
|
this.bandwidth = bandwidth;
|
|
2455
|
-
if (
|
|
2475
|
+
if (((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "") {
|
|
2476
|
+
this._incrementAnalyticMetric("P2PChangeBandwidthEmptySDPType");
|
|
2477
|
+
return;
|
|
2478
|
+
}
|
|
2479
|
+
if (!this.pc.localDescription) {
|
|
2456
2480
|
return;
|
|
2457
2481
|
}
|
|
2458
2482
|
setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
|
|
2459
2483
|
}
|
|
2460
2484
|
setAudioOnly(enable, excludedTrackIds = []) {
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
.filter((videoTransceiver) => {
|
|
2485
|
+
var _a;
|
|
2486
|
+
(_a = this.pc) === null || _a === void 0 ? void 0 : _a.getTransceivers().filter((videoTransceiver) => {
|
|
2464
2487
|
var _a, _b, _c, _d, _e, _f;
|
|
2465
2488
|
return (videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.direction) !== "recvonly" &&
|
|
2466
2489
|
((_b = (_a = videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.receiver) === null || _a === void 0 ? void 0 : _a.track) === null || _b === void 0 ? void 0 : _b.kind) === "video" &&
|
|
2467
2490
|
!excludedTrackIds.includes((_d = (_c = videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.receiver) === null || _c === void 0 ? void 0 : _c.track) === null || _d === void 0 ? void 0 : _d.id) &&
|
|
2468
2491
|
!excludedTrackIds.includes((_f = (_e = videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.sender) === null || _e === void 0 ? void 0 : _e.track) === null || _f === void 0 ? void 0 : _f.id);
|
|
2469
|
-
})
|
|
2470
|
-
.forEach((videoTransceiver) => {
|
|
2492
|
+
}).forEach((videoTransceiver) => {
|
|
2471
2493
|
videoTransceiver.direction = enable ? "sendonly" : "sendrecv";
|
|
2472
2494
|
});
|
|
2473
2495
|
}
|
|
@@ -2643,9 +2665,7 @@ class P2pRtcManager {
|
|
|
2643
2665
|
turnServers: turnServers || [],
|
|
2644
2666
|
mediaserverConfigTtlSeconds,
|
|
2645
2667
|
});
|
|
2646
|
-
this.totalSessionsCreated = 0;
|
|
2647
2668
|
this.analytics = {
|
|
2648
|
-
P2PReplaceTrackNoPC: 0,
|
|
2649
2669
|
P2PNonErrorRejectionValueGUMError: 0,
|
|
2650
2670
|
numNewPc: 0,
|
|
2651
2671
|
numIceConnected: 0,
|
|
@@ -2661,6 +2681,19 @@ class P2pRtcManager {
|
|
|
2661
2681
|
numPcSldFailure: 0,
|
|
2662
2682
|
numPcOnAnswerFailure: 0,
|
|
2663
2683
|
numPcOnOfferFailure: 0,
|
|
2684
|
+
P2PChangeBandwidthEmptySDPType: 0,
|
|
2685
|
+
P2PNegotiationNeeded: 0,
|
|
2686
|
+
P2PSessionAlreadyCreated: 0,
|
|
2687
|
+
P2PReplaceTrackNoStream: 0,
|
|
2688
|
+
P2PReplaceTrackNoNewTrack: 0,
|
|
2689
|
+
P2PReplaceTrackNewTrackEnded: 0,
|
|
2690
|
+
P2PReplaceTrackNewTrackNotInStream: 0,
|
|
2691
|
+
P2PReplaceTrackOldTrackNotFound: 0,
|
|
2692
|
+
P2PReplaceTrackToPCsPendingActionsNull: 0,
|
|
2693
|
+
P2PReplaceTrackReturnedFalse: 0,
|
|
2694
|
+
P2PReplaceTrackWithoutPC: 0,
|
|
2695
|
+
P2PReplaceTrackSourceKindNotFound: 0,
|
|
2696
|
+
P2PRemoveStreamNoPC: 0,
|
|
2664
2697
|
};
|
|
2665
2698
|
}
|
|
2666
2699
|
numberOfPeerconnections() {
|
|
@@ -2780,7 +2813,7 @@ class P2pRtcManager {
|
|
|
2780
2813
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
2781
2814
|
return;
|
|
2782
2815
|
}
|
|
2783
|
-
const offer = this._transformIncomingSdp(data.message
|
|
2816
|
+
const offer = this._transformIncomingSdp(data.message);
|
|
2784
2817
|
(_b = (_a = session
|
|
2785
2818
|
.handleOffer(offer)
|
|
2786
2819
|
.then((answer) => {
|
|
@@ -2799,7 +2832,7 @@ class P2pRtcManager {
|
|
|
2799
2832
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
2800
2833
|
return;
|
|
2801
2834
|
}
|
|
2802
|
-
const answer = this._transformIncomingSdp(data.message
|
|
2835
|
+
const answer = this._transformIncomingSdp(data.message);
|
|
2803
2836
|
(_b = (_a = session.handleAnswer(answer)) === null || _a === void 0 ? void 0 : _a.catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2804
2837
|
logger$6.warn("Could not set remote description from remote answer: ", e);
|
|
2805
2838
|
this.analytics.numPcOnAnswerFailure++;
|
|
@@ -2938,7 +2971,7 @@ class P2pRtcManager {
|
|
|
2938
2971
|
}
|
|
2939
2972
|
return this.peerConnections[peerConnectionId];
|
|
2940
2973
|
}
|
|
2941
|
-
_getOrCreateSession(peerConnectionId, initialBandwidth) {
|
|
2974
|
+
_getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }) {
|
|
2942
2975
|
let session = this.peerConnections[peerConnectionId];
|
|
2943
2976
|
if (session === undefined) {
|
|
2944
2977
|
const deprioritizeH264Encoding = browserName$1 === "safari" &&
|
|
@@ -2947,11 +2980,20 @@ class P2pRtcManager {
|
|
|
2947
2980
|
this._features.deprioritizeH264OnSafari;
|
|
2948
2981
|
this.peerConnections[peerConnectionId] = session = new Session({
|
|
2949
2982
|
peerConnectionId,
|
|
2983
|
+
clientId,
|
|
2984
|
+
peerConnectionConfig,
|
|
2950
2985
|
bandwidth: initialBandwidth,
|
|
2951
2986
|
deprioritizeH264Encoding,
|
|
2987
|
+
shouldAddLocalVideo,
|
|
2952
2988
|
incrementAnalyticMetric: (metric) => this.analytics[metric]++,
|
|
2953
2989
|
});
|
|
2954
|
-
|
|
2990
|
+
}
|
|
2991
|
+
else {
|
|
2992
|
+
this.analytics.P2PSessionAlreadyCreated++;
|
|
2993
|
+
rtcStats.sendEvent("P2PSessionAlreadyCreated", {
|
|
2994
|
+
clientId,
|
|
2995
|
+
peerConnectionId,
|
|
2996
|
+
});
|
|
2955
2997
|
}
|
|
2956
2998
|
return session;
|
|
2957
2999
|
}
|
|
@@ -2968,7 +3010,7 @@ class P2pRtcManager {
|
|
|
2968
3010
|
const streamIds = this._getNonLocalCameraStreamIds();
|
|
2969
3011
|
return streamIds.length === 0 ? null : this.localStreams[streamIds[0]];
|
|
2970
3012
|
}
|
|
2971
|
-
_transformIncomingSdp(original
|
|
3013
|
+
_transformIncomingSdp(original) {
|
|
2972
3014
|
return { type: original.type, sdp: original.sdpU };
|
|
2973
3015
|
}
|
|
2974
3016
|
_transformOutgoingSdp(original) {
|
|
@@ -2981,34 +3023,33 @@ class P2pRtcManager {
|
|
|
2981
3023
|
if (!clientId) {
|
|
2982
3024
|
throw new Error("clientId is missing");
|
|
2983
3025
|
}
|
|
2984
|
-
const
|
|
3026
|
+
const peerConnectionConfig = {
|
|
3027
|
+
iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
|
|
3028
|
+
};
|
|
2985
3029
|
const constraints = { optional: [] };
|
|
3030
|
+
constraints.optional.push({ rtcStatsRoomSessionId: this._roomSessionId });
|
|
3031
|
+
constraints.optional.push({ rtcStatsClientId: this._selfId });
|
|
3032
|
+
constraints.optional.push({ rtcStatsPeerId: peerConnectionId });
|
|
3033
|
+
constraints.optional.push({ rtcStatsConferenceId: this._roomName });
|
|
2986
3034
|
if (browserName$1 === "chrome") {
|
|
2987
3035
|
constraints.optional.push({
|
|
2988
3036
|
googCpuOveruseDetection: true,
|
|
2989
3037
|
});
|
|
3038
|
+
peerConnectionConfig.sdpSemantics = "unified-plan";
|
|
2990
3039
|
}
|
|
2991
|
-
constraints.optional.push({ rtcStatsRoomSessionId: this._roomSessionId });
|
|
2992
|
-
constraints.optional.push({ rtcStatsClientId: this._selfId });
|
|
2993
|
-
constraints.optional.push({ rtcStatsPeerId: peerConnectionId });
|
|
2994
|
-
constraints.optional.push({ rtcStatsConferenceId: this._roomName });
|
|
2995
|
-
const peerConnectionConfig = {
|
|
2996
|
-
iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
|
|
2997
|
-
};
|
|
2998
3040
|
peerConnectionConfig.iceServers = turnServerOverride(peerConnectionConfig.iceServers, this._features.turnServerOverrideHost);
|
|
2999
3041
|
external_stun_servers(peerConnectionConfig, this._features);
|
|
3000
3042
|
maybeTurnOnly(peerConnectionConfig, this._features);
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
constraints,
|
|
3043
|
+
const session = this._getOrCreateSession({
|
|
3044
|
+
peerConnectionId,
|
|
3045
|
+
clientId,
|
|
3046
|
+
initialBandwidth,
|
|
3006
3047
|
peerConnectionConfig,
|
|
3007
3048
|
shouldAddLocalVideo,
|
|
3008
|
-
clientId,
|
|
3009
3049
|
});
|
|
3010
3050
|
setTimeout(() => this._emit(rtcManagerEvents.NEW_PC), 0);
|
|
3011
3051
|
this.analytics.numNewPc++;
|
|
3052
|
+
const { pc } = session;
|
|
3012
3053
|
pc.ontrack = (event) => {
|
|
3013
3054
|
const stream = event.streams[0];
|
|
3014
3055
|
if (stream.id === "default" && stream.getAudioTracks().length === 0) {
|
|
@@ -3161,9 +3202,13 @@ class P2pRtcManager {
|
|
|
3161
3202
|
const promises = [];
|
|
3162
3203
|
this._forEachPeerConnection((session) => {
|
|
3163
3204
|
if (!session.hasConnectedPeerConnection()) {
|
|
3205
|
+
rtcStats.sendEvent("P2PReplaceTrackWithoutPC", {});
|
|
3206
|
+
this.analytics.P2PReplaceTrackWithoutPC++;
|
|
3164
3207
|
logger$6.info("Session doesn't have a connected PeerConnection, adding pending action!");
|
|
3165
3208
|
const pendingActions = this._pendingActionsForConnectedPeerConnections;
|
|
3166
3209
|
if (!pendingActions) {
|
|
3210
|
+
rtcStats.sendEvent("P2PReplaceTrackToPCsPendingActionsNull", {});
|
|
3211
|
+
this.analytics.P2PReplaceTrackToPCsPendingActionsNull++;
|
|
3167
3212
|
logger$6.warn(`No pending action is created to replace track, because the pending actions array is null`);
|
|
3168
3213
|
return;
|
|
3169
3214
|
}
|
|
@@ -3171,6 +3216,8 @@ class P2pRtcManager {
|
|
|
3171
3216
|
const action = () => {
|
|
3172
3217
|
const replacedTrackPromise = session.replaceTrack(oldTrack, newTrack);
|
|
3173
3218
|
if (!replacedTrackPromise) {
|
|
3219
|
+
rtcStats.sendEvent("P2PReplaceTrackReturnedFalse", {});
|
|
3220
|
+
this.analytics.P2PReplaceTrackReturnedFalse++;
|
|
3174
3221
|
logger$6.error("replaceTrack returned false!");
|
|
3175
3222
|
reject(`ReplaceTrack returned false`);
|
|
3176
3223
|
return;
|
|
@@ -3184,6 +3231,8 @@ class P2pRtcManager {
|
|
|
3184
3231
|
}
|
|
3185
3232
|
const replacedTrackResult = session.replaceTrack(oldTrack, newTrack);
|
|
3186
3233
|
if (!replacedTrackResult) {
|
|
3234
|
+
rtcStats.sendEvent("P2PReplaceTrackReturnedFalse", {});
|
|
3235
|
+
this.analytics.P2PReplaceTrackReturnedFalse++;
|
|
3187
3236
|
logger$6.error("replaceTrack returned false!");
|
|
3188
3237
|
return;
|
|
3189
3238
|
}
|
|
@@ -3367,7 +3416,7 @@ class P2pRtcManager {
|
|
|
3367
3416
|
}
|
|
3368
3417
|
_withForcedRenegotiation(session, action) {
|
|
3369
3418
|
const pc = session.pc;
|
|
3370
|
-
const originalOnnegotationneeded = pc.
|
|
3419
|
+
const originalOnnegotationneeded = pc.onnegotiationneeded;
|
|
3371
3420
|
pc.onnegotiationneeded = null;
|
|
3372
3421
|
action();
|
|
3373
3422
|
this._negotiatePeerConnection(session.clientId, session);
|
|
@@ -3432,7 +3481,7 @@ class P2pRtcManager {
|
|
|
3432
3481
|
if (!session.publicHostCandidateSeen &&
|
|
3433
3482
|
!session.relayCandidateSeen &&
|
|
3434
3483
|
!session.serverReflexiveCandidateSeen) {
|
|
3435
|
-
if (pc.iceConnectionState !== "connected"
|
|
3484
|
+
if (pc.iceConnectionState !== "connected" && pc.iceConnectionState !== "completed")
|
|
3436
3485
|
this.analytics.numIceNoPublicIpGatheredIn3sec++;
|
|
3437
3486
|
}
|
|
3438
3487
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
@@ -3516,6 +3565,8 @@ class P2pRtcManager {
|
|
|
3516
3565
|
}
|
|
3517
3566
|
};
|
|
3518
3567
|
pc.onnegotiationneeded = () => {
|
|
3568
|
+
this.analytics.P2PNegotiationNeeded++;
|
|
3569
|
+
rtcStats.sendEvent("P2PNegotiationNeeded", {});
|
|
3519
3570
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3520
3571
|
return;
|
|
3521
3572
|
}
|
|
@@ -7015,8 +7066,12 @@ class BandwidthTester extends EventEmitter {
|
|
|
7015
7066
|
this._sendTransport.getStats(),
|
|
7016
7067
|
this._receiveTransport.getStats(),
|
|
7017
7068
|
]);
|
|
7018
|
-
|
|
7019
|
-
|
|
7069
|
+
let availableOutgoingBitrate = 5000000;
|
|
7070
|
+
try {
|
|
7071
|
+
availableOutgoingBitrate = (yield this._vegaConnection.request("getTransportStats")).recvStats[0]
|
|
7072
|
+
.availableOutgoingBitrate;
|
|
7073
|
+
}
|
|
7074
|
+
catch (_a) { }
|
|
7020
7075
|
let outboundPackets = 0;
|
|
7021
7076
|
let remotePacketsLost = 0;
|
|
7022
7077
|
localSendStats.forEach((localSendStat) => {
|
|
@@ -7406,6 +7461,9 @@ function getDisplayMedia(constraints = defaultDisplayMediaConstraints, contentHi
|
|
|
7406
7461
|
t.contentHint = contentHint;
|
|
7407
7462
|
}
|
|
7408
7463
|
});
|
|
7464
|
+
stream.getTracks().forEach((t) => {
|
|
7465
|
+
trackAnnotations(t).fromGetDisplayMedia = true;
|
|
7466
|
+
});
|
|
7409
7467
|
return stream;
|
|
7410
7468
|
});
|
|
7411
7469
|
}
|
|
@@ -7484,5 +7542,5 @@ var RtcEventNames;
|
|
|
7484
7542
|
RtcEventNames["stream_added"] = "stream_added";
|
|
7485
7543
|
})(RtcEventNames || (RtcEventNames = {}));
|
|
7486
7544
|
|
|
7487
|
-
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, issueDetectorOrMetricEnabled, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, turnServerOverride, variance };
|
|
7545
|
+
export { ADDITIONAL_SCREEN_SHARE_SETTINGS, AUDIO_SETTINGS, BandwidthTester, EVENTS, KNOCK_MESSAGES, KalmanFilter, Logger, MEDIA_JITTER_BUFFER_TARGET, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, RtcEventNames, RtcManagerDispatcher, RtcStream, SCREEN_SHARE_SETTINGS, SCREEN_SHARE_SIMULCAST_SETTINGS, STREAM_TYPES, ServerSocket, Session, SfuV2Parser, TYPES, VIDEO_SETTINGS_HD, VIDEO_SETTINGS_SD, VIDEO_SETTINGS_VP9, VIDEO_SETTINGS_VP9_LOW_BANDWIDTH, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, cleanSdp, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, external_stun_servers, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getMediasoupDeviceAsync, getNumFailedStatsReports, getNumFailedTrackSsrcLookups, getNumMissingTrackSsrcLookups, getPeerConnectionIndex, getStats, getStream, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, issueDetectorOrMetricEnabled, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, sortCodecs, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, trackAnnotations, turnServerOverride, variance };
|
|
7488
7546
|
//# sourceMappingURL=legacy-esm.js.map
|