@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/index.cjs
CHANGED
|
@@ -1828,6 +1828,16 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
|
|
|
1828
1828
|
}
|
|
1829
1829
|
fromLocation(window && window.location);
|
|
1830
1830
|
|
|
1831
|
+
const _trackAnnotations = new WeakMap();
|
|
1832
|
+
function trackAnnotations(o) {
|
|
1833
|
+
let props = _trackAnnotations.get(o);
|
|
1834
|
+
if (!props) {
|
|
1835
|
+
props = {};
|
|
1836
|
+
_trackAnnotations.set(o, props);
|
|
1837
|
+
}
|
|
1838
|
+
return props;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1831
1841
|
const logger$9 = new Logger();
|
|
1832
1842
|
const debugLogger = {
|
|
1833
1843
|
print: (...args) => console.debug(args[0], ...args.slice(1)),
|
|
@@ -2167,7 +2177,7 @@ var _a$4;
|
|
|
2167
2177
|
const adapter$4 = (_a$4 = adapterRaw.default) !== null && _a$4 !== void 0 ? _a$4 : adapterRaw;
|
|
2168
2178
|
const logger$7 = new Logger();
|
|
2169
2179
|
class Session {
|
|
2170
|
-
constructor({ peerConnectionId, bandwidth, deprioritizeH264Encoding, incrementAnalyticMetric, }) {
|
|
2180
|
+
constructor({ peerConnectionId, clientId, bandwidth, peerConnectionConfig, deprioritizeH264Encoding, shouldAddLocalVideo, incrementAnalyticMetric, }) {
|
|
2171
2181
|
this.peerConnectionId = peerConnectionId;
|
|
2172
2182
|
this.relayCandidateSeen = false;
|
|
2173
2183
|
this.serverReflexiveCandidateSeen = false;
|
|
@@ -2176,7 +2186,24 @@ class Session {
|
|
|
2176
2186
|
this.ipv6HostCandidateTeredoSeen = false;
|
|
2177
2187
|
this.ipv6HostCandidate6to4Seen = false;
|
|
2178
2188
|
this.mdnsHostCandidateSeen = false;
|
|
2179
|
-
this.
|
|
2189
|
+
this.peerConnectionConfig = peerConnectionConfig;
|
|
2190
|
+
this.shouldAddLocalVideo = shouldAddLocalVideo;
|
|
2191
|
+
this.clientId = clientId;
|
|
2192
|
+
this.pc = new RTCPeerConnection(this.peerConnectionConfig);
|
|
2193
|
+
this.signalingState = this.pc.signalingState;
|
|
2194
|
+
this.pc.addEventListener("signalingstatechange", () => {
|
|
2195
|
+
if (this.signalingState === this.pc.signalingState) {
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
this.signalingState = this.pc.signalingState;
|
|
2199
|
+
if (this.pc.signalingState === "stable") {
|
|
2200
|
+
this.isOperationPending = false;
|
|
2201
|
+
const action = this.pending.shift();
|
|
2202
|
+
if (action) {
|
|
2203
|
+
action.apply();
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
});
|
|
2180
2207
|
this.wasEverConnected = false;
|
|
2181
2208
|
this.connectionStatus = null;
|
|
2182
2209
|
this.stats = {
|
|
@@ -2196,27 +2223,6 @@ class Session {
|
|
|
2196
2223
|
this._deprioritizeH264Encoding = deprioritizeH264Encoding;
|
|
2197
2224
|
this._incrementAnalyticMetric = incrementAnalyticMetric;
|
|
2198
2225
|
}
|
|
2199
|
-
setAndGetPeerConnection({ clientId, constraints, peerConnectionConfig, shouldAddLocalVideo, }) {
|
|
2200
|
-
this.peerConnectionConfig = peerConnectionConfig;
|
|
2201
|
-
this.shouldAddLocalVideo = shouldAddLocalVideo;
|
|
2202
|
-
this.clientId = clientId;
|
|
2203
|
-
this.pc = new RTCPeerConnection(peerConnectionConfig);
|
|
2204
|
-
this.signalingState = this.pc.signalingState;
|
|
2205
|
-
this.pc.addEventListener("signalingstatechange", () => {
|
|
2206
|
-
if (this.signalingState === this.pc.signalingState) {
|
|
2207
|
-
return;
|
|
2208
|
-
}
|
|
2209
|
-
this.signalingState = this.pc.signalingState;
|
|
2210
|
-
if (this.pc.signalingState === "stable") {
|
|
2211
|
-
this.isOperationPending = false;
|
|
2212
|
-
const action = this.pending.shift();
|
|
2213
|
-
if (action) {
|
|
2214
|
-
action.apply();
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
});
|
|
2218
|
-
return this.pc;
|
|
2219
|
-
}
|
|
2220
2226
|
addStream(stream) {
|
|
2221
2227
|
this.streamIds.push(stream.id);
|
|
2222
2228
|
this.streams.push(stream);
|
|
@@ -2229,6 +2235,7 @@ class Session {
|
|
|
2229
2235
|
});
|
|
2230
2236
|
}
|
|
2231
2237
|
else {
|
|
2238
|
+
rtcStats.sendEvent("P2PNoAddTrackSupport", {});
|
|
2232
2239
|
this.pc.addStream(stream);
|
|
2233
2240
|
}
|
|
2234
2241
|
}
|
|
@@ -2267,6 +2274,10 @@ class Session {
|
|
|
2267
2274
|
this.pc.removeStream(stream);
|
|
2268
2275
|
}
|
|
2269
2276
|
}
|
|
2277
|
+
else {
|
|
2278
|
+
rtcStats.sendEvent("P2PRemoveStreamNoPC", {});
|
|
2279
|
+
this._incrementAnalyticMetric("P2PRemoveStreamNoPC");
|
|
2280
|
+
}
|
|
2270
2281
|
}
|
|
2271
2282
|
_setRemoteDescription(desc) {
|
|
2272
2283
|
if (this._deprioritizeH264Encoding)
|
|
@@ -2351,102 +2362,109 @@ class Session {
|
|
|
2351
2362
|
return this.pc && this.pc.connectionState === "connected";
|
|
2352
2363
|
}
|
|
2353
2364
|
replaceTrack(oldTrack, newTrack) {
|
|
2354
|
-
var _a;
|
|
2355
|
-
|
|
2356
|
-
if (!
|
|
2357
|
-
rtcStats.sendEvent("
|
|
2365
|
+
var _a, _b, _c;
|
|
2366
|
+
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);
|
|
2367
|
+
if (!newTrack) {
|
|
2368
|
+
rtcStats.sendEvent("P2PReplaceTrackNoNewTrack", {
|
|
2358
2369
|
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2359
|
-
|
|
2370
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2371
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2360
2372
|
});
|
|
2361
|
-
this._incrementAnalyticMetric("
|
|
2373
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNoNewTrack");
|
|
2362
2374
|
return false;
|
|
2363
2375
|
}
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
return null;
|
|
2381
|
-
};
|
|
2382
|
-
const result = process();
|
|
2383
|
-
if (result) {
|
|
2384
|
-
return result;
|
|
2376
|
+
if (newTrack.readyState === "ended") {
|
|
2377
|
+
rtcStats.sendEvent("P2PReplaceTrackNewTrackEnded", {
|
|
2378
|
+
newTrackId: newTrack.id,
|
|
2379
|
+
newTrackKind: newTrack.kind,
|
|
2380
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2381
|
+
});
|
|
2382
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNewTrackEnded");
|
|
2383
|
+
return false;
|
|
2384
|
+
}
|
|
2385
|
+
const pc = this.pc;
|
|
2386
|
+
if ((_b = (_a = window.RTCRtpSender) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.replaceTrack) {
|
|
2387
|
+
if (oldTrack) {
|
|
2388
|
+
const sender = pc.getSenders().find((s) => { var _a; return ((_a = s.track) === null || _a === void 0 ? void 0 : _a.id) === oldTrack.id; });
|
|
2389
|
+
if (sender) {
|
|
2390
|
+
sender.replaceTrack(newTrack);
|
|
2391
|
+
return Promise.resolve(newTrack);
|
|
2385
2392
|
}
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
rtcStats.sendEvent("P2PReplaceTrackFailed", {
|
|
2406
|
-
newTrackId: newTrack === null || newTrack === void 0 ? void 0 : newTrack.id,
|
|
2407
|
-
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2408
|
-
oldTrackFallbackId: oldTrackFallback === null || oldTrackFallback === void 0 ? void 0 : oldTrackFallback.id,
|
|
2409
|
-
sendersCount: senders === null || senders === void 0 ? void 0 : senders.length,
|
|
2410
|
-
sendersAnalytics,
|
|
2411
|
-
});
|
|
2412
|
-
reject("No sender track to replace");
|
|
2413
|
-
}
|
|
2414
|
-
return;
|
|
2415
|
-
}
|
|
2416
|
-
clearInterval(timer);
|
|
2417
|
-
timer = null;
|
|
2418
|
-
const trackReplaced = yield trackReplacedPromise;
|
|
2419
|
-
resolve(trackReplaced);
|
|
2420
|
-
}), 1000);
|
|
2393
|
+
}
|
|
2394
|
+
const sender = pc.getSenders().find((s) => {
|
|
2395
|
+
const track = s.track;
|
|
2396
|
+
return (track === null || track === void 0 ? void 0 : track.kind) === newTrack.kind && !trackAnnotations(track).fromGetDisplayMedia;
|
|
2397
|
+
});
|
|
2398
|
+
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 === null || track === void 0 ? void 0 : track.effectTrack,
|
|
2405
|
+
targetTrackReadyState: track === null || track === void 0 ? void 0 : track.readyState,
|
|
2406
|
+
newTrackId: newTrack.id,
|
|
2407
|
+
newTrackKind: newTrack.kind,
|
|
2408
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
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 === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2421
2412
|
});
|
|
2413
|
+
sender.replaceTrack(newTrack);
|
|
2414
|
+
return Promise.resolve(newTrack);
|
|
2422
2415
|
}
|
|
2423
|
-
|
|
2416
|
+
let stream = this.streams.find((s) => s.getTracks().find((t) => t.id === newTrack.id));
|
|
2424
2417
|
if (!stream) {
|
|
2418
|
+
rtcStats.sendEvent("P2PReplaceTrackNewTrackNotInStream", {
|
|
2419
|
+
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2420
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2421
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2422
|
+
newTrackId: newTrack.id,
|
|
2423
|
+
newTrackKind: newTrack.kind,
|
|
2424
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2425
|
+
});
|
|
2426
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNewTrackNotInStream");
|
|
2427
|
+
}
|
|
2428
|
+
stream = this.streams[0];
|
|
2429
|
+
if (!stream) {
|
|
2430
|
+
rtcStats.sendEvent("P2PReplaceTrackNoStream", {});
|
|
2431
|
+
this._incrementAnalyticMetric("P2PReplaceTrackNoStream");
|
|
2425
2432
|
return Promise.reject(new Error("replaceTrack: No stream?"));
|
|
2426
2433
|
}
|
|
2434
|
+
rtcStats.sendEvent("P2PReplaceTrackSourceKindNotFound", {
|
|
2435
|
+
oldTrackId: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.id,
|
|
2436
|
+
oldTrackKind: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.kind,
|
|
2437
|
+
oldTrackIsEffect: oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.effectTrack,
|
|
2438
|
+
newTrackId: newTrack.id,
|
|
2439
|
+
newTrackKind: newTrack.kind,
|
|
2440
|
+
newTrackIsEffect: newTrack.effectTrack,
|
|
2441
|
+
});
|
|
2442
|
+
this._incrementAnalyticMetric("P2PReplaceTrackSourceKindNotFound");
|
|
2427
2443
|
return pc.addTrack(newTrack, stream);
|
|
2428
2444
|
}
|
|
2445
|
+
rtcStats.sendEvent("P2PNoReplaceTrackSupport", {});
|
|
2429
2446
|
if (!this.canModifyPeerConnection()) {
|
|
2430
2447
|
this.pending.push(() => {
|
|
2431
|
-
this.replaceTrack(
|
|
2448
|
+
this.replaceTrack(oldTrack, newTrack);
|
|
2432
2449
|
});
|
|
2433
2450
|
return;
|
|
2434
2451
|
}
|
|
2435
2452
|
this.isOperationPending = true;
|
|
2436
2453
|
const onn = pc.onnegotiationneeded;
|
|
2437
2454
|
pc.onnegotiationneeded = null;
|
|
2438
|
-
if (
|
|
2439
|
-
this.removeTrack(
|
|
2455
|
+
if (oldTrack) {
|
|
2456
|
+
this.removeTrack(oldTrack);
|
|
2440
2457
|
}
|
|
2441
2458
|
this.addTrack(newTrack);
|
|
2442
2459
|
setTimeout(() => {
|
|
2443
2460
|
pc.onnegotiationneeded = onn;
|
|
2444
2461
|
}, 0);
|
|
2445
|
-
if (pc.localDescription.type === "offer") {
|
|
2462
|
+
if (((_c = pc.localDescription) === null || _c === void 0 ? void 0 : _c.type) === "offer") {
|
|
2446
2463
|
return pc
|
|
2447
2464
|
.createOffer()
|
|
2448
2465
|
.then((offer) => {
|
|
2449
|
-
|
|
2466
|
+
var _a;
|
|
2467
|
+
offer.sdp = replaceSSRCs((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp, offer.sdp);
|
|
2450
2468
|
return pc.setLocalDescription(offer);
|
|
2451
2469
|
})
|
|
2452
2470
|
.then(() => {
|
|
@@ -2459,12 +2477,14 @@ class Session {
|
|
|
2459
2477
|
return pc.createAnswer();
|
|
2460
2478
|
})
|
|
2461
2479
|
.then((answer) => {
|
|
2462
|
-
|
|
2480
|
+
var _a;
|
|
2481
|
+
answer.sdp = replaceSSRCs((_a = pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp, answer.sdp);
|
|
2463
2482
|
return pc.setLocalDescription(answer);
|
|
2464
2483
|
});
|
|
2465
2484
|
}
|
|
2466
2485
|
}
|
|
2467
2486
|
changeBandwidth(bandwidth) {
|
|
2487
|
+
var _a;
|
|
2468
2488
|
if (bandwidth === this.bandwidth) {
|
|
2469
2489
|
return;
|
|
2470
2490
|
}
|
|
@@ -2473,22 +2493,24 @@ class Session {
|
|
|
2473
2493
|
return;
|
|
2474
2494
|
}
|
|
2475
2495
|
this.bandwidth = bandwidth;
|
|
2476
|
-
if (
|
|
2496
|
+
if (((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.type) === "") {
|
|
2497
|
+
this._incrementAnalyticMetric("P2PChangeBandwidthEmptySDPType");
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
if (!this.pc.localDescription) {
|
|
2477
2501
|
return;
|
|
2478
2502
|
}
|
|
2479
2503
|
setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
|
|
2480
2504
|
}
|
|
2481
2505
|
setAudioOnly(enable, excludedTrackIds = []) {
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
.filter((videoTransceiver) => {
|
|
2506
|
+
var _a;
|
|
2507
|
+
(_a = this.pc) === null || _a === void 0 ? void 0 : _a.getTransceivers().filter((videoTransceiver) => {
|
|
2485
2508
|
var _a, _b, _c, _d, _e, _f;
|
|
2486
2509
|
return (videoTransceiver === null || videoTransceiver === void 0 ? void 0 : videoTransceiver.direction) !== "recvonly" &&
|
|
2487
2510
|
((_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" &&
|
|
2488
2511
|
!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) &&
|
|
2489
2512
|
!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);
|
|
2490
|
-
})
|
|
2491
|
-
.forEach((videoTransceiver) => {
|
|
2513
|
+
}).forEach((videoTransceiver) => {
|
|
2492
2514
|
videoTransceiver.direction = enable ? "sendonly" : "sendrecv";
|
|
2493
2515
|
});
|
|
2494
2516
|
}
|
|
@@ -2664,9 +2686,7 @@ class P2pRtcManager {
|
|
|
2664
2686
|
turnServers: turnServers || [],
|
|
2665
2687
|
mediaserverConfigTtlSeconds,
|
|
2666
2688
|
});
|
|
2667
|
-
this.totalSessionsCreated = 0;
|
|
2668
2689
|
this.analytics = {
|
|
2669
|
-
P2PReplaceTrackNoPC: 0,
|
|
2670
2690
|
P2PNonErrorRejectionValueGUMError: 0,
|
|
2671
2691
|
numNewPc: 0,
|
|
2672
2692
|
numIceConnected: 0,
|
|
@@ -2682,6 +2702,19 @@ class P2pRtcManager {
|
|
|
2682
2702
|
numPcSldFailure: 0,
|
|
2683
2703
|
numPcOnAnswerFailure: 0,
|
|
2684
2704
|
numPcOnOfferFailure: 0,
|
|
2705
|
+
P2PChangeBandwidthEmptySDPType: 0,
|
|
2706
|
+
P2PNegotiationNeeded: 0,
|
|
2707
|
+
P2PSessionAlreadyCreated: 0,
|
|
2708
|
+
P2PReplaceTrackNoStream: 0,
|
|
2709
|
+
P2PReplaceTrackNoNewTrack: 0,
|
|
2710
|
+
P2PReplaceTrackNewTrackEnded: 0,
|
|
2711
|
+
P2PReplaceTrackNewTrackNotInStream: 0,
|
|
2712
|
+
P2PReplaceTrackOldTrackNotFound: 0,
|
|
2713
|
+
P2PReplaceTrackToPCsPendingActionsNull: 0,
|
|
2714
|
+
P2PReplaceTrackReturnedFalse: 0,
|
|
2715
|
+
P2PReplaceTrackWithoutPC: 0,
|
|
2716
|
+
P2PReplaceTrackSourceKindNotFound: 0,
|
|
2717
|
+
P2PRemoveStreamNoPC: 0,
|
|
2685
2718
|
};
|
|
2686
2719
|
}
|
|
2687
2720
|
numberOfPeerconnections() {
|
|
@@ -2801,7 +2834,7 @@ class P2pRtcManager {
|
|
|
2801
2834
|
logger$6.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
2802
2835
|
return;
|
|
2803
2836
|
}
|
|
2804
|
-
const offer = this._transformIncomingSdp(data.message
|
|
2837
|
+
const offer = this._transformIncomingSdp(data.message);
|
|
2805
2838
|
(_b = (_a = session
|
|
2806
2839
|
.handleOffer(offer)
|
|
2807
2840
|
.then((answer) => {
|
|
@@ -2820,7 +2853,7 @@ class P2pRtcManager {
|
|
|
2820
2853
|
logger$6.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
2821
2854
|
return;
|
|
2822
2855
|
}
|
|
2823
|
-
const answer = this._transformIncomingSdp(data.message
|
|
2856
|
+
const answer = this._transformIncomingSdp(data.message);
|
|
2824
2857
|
(_b = (_a = session.handleAnswer(answer)) === null || _a === void 0 ? void 0 : _a.catch) === null || _b === void 0 ? void 0 : _b.call(_a, (e) => {
|
|
2825
2858
|
logger$6.warn("Could not set remote description from remote answer: ", e);
|
|
2826
2859
|
this.analytics.numPcOnAnswerFailure++;
|
|
@@ -2959,7 +2992,7 @@ class P2pRtcManager {
|
|
|
2959
2992
|
}
|
|
2960
2993
|
return this.peerConnections[peerConnectionId];
|
|
2961
2994
|
}
|
|
2962
|
-
_getOrCreateSession(peerConnectionId, initialBandwidth) {
|
|
2995
|
+
_getOrCreateSession({ peerConnectionId, clientId, initialBandwidth, peerConnectionConfig, shouldAddLocalVideo, }) {
|
|
2963
2996
|
let session = this.peerConnections[peerConnectionId];
|
|
2964
2997
|
if (session === undefined) {
|
|
2965
2998
|
const deprioritizeH264Encoding = browserName$1 === "safari" &&
|
|
@@ -2968,11 +3001,20 @@ class P2pRtcManager {
|
|
|
2968
3001
|
this._features.deprioritizeH264OnSafari;
|
|
2969
3002
|
this.peerConnections[peerConnectionId] = session = new Session({
|
|
2970
3003
|
peerConnectionId,
|
|
3004
|
+
clientId,
|
|
3005
|
+
peerConnectionConfig,
|
|
2971
3006
|
bandwidth: initialBandwidth,
|
|
2972
3007
|
deprioritizeH264Encoding,
|
|
3008
|
+
shouldAddLocalVideo,
|
|
2973
3009
|
incrementAnalyticMetric: (metric) => this.analytics[metric]++,
|
|
2974
3010
|
});
|
|
2975
|
-
|
|
3011
|
+
}
|
|
3012
|
+
else {
|
|
3013
|
+
this.analytics.P2PSessionAlreadyCreated++;
|
|
3014
|
+
rtcStats.sendEvent("P2PSessionAlreadyCreated", {
|
|
3015
|
+
clientId,
|
|
3016
|
+
peerConnectionId,
|
|
3017
|
+
});
|
|
2976
3018
|
}
|
|
2977
3019
|
return session;
|
|
2978
3020
|
}
|
|
@@ -2989,7 +3031,7 @@ class P2pRtcManager {
|
|
|
2989
3031
|
const streamIds = this._getNonLocalCameraStreamIds();
|
|
2990
3032
|
return streamIds.length === 0 ? null : this.localStreams[streamIds[0]];
|
|
2991
3033
|
}
|
|
2992
|
-
_transformIncomingSdp(original
|
|
3034
|
+
_transformIncomingSdp(original) {
|
|
2993
3035
|
return { type: original.type, sdp: original.sdpU };
|
|
2994
3036
|
}
|
|
2995
3037
|
_transformOutgoingSdp(original) {
|
|
@@ -3002,34 +3044,33 @@ class P2pRtcManager {
|
|
|
3002
3044
|
if (!clientId) {
|
|
3003
3045
|
throw new Error("clientId is missing");
|
|
3004
3046
|
}
|
|
3005
|
-
const
|
|
3047
|
+
const peerConnectionConfig = {
|
|
3048
|
+
iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
|
|
3049
|
+
};
|
|
3006
3050
|
const constraints = { optional: [] };
|
|
3051
|
+
constraints.optional.push({ rtcStatsRoomSessionId: this._roomSessionId });
|
|
3052
|
+
constraints.optional.push({ rtcStatsClientId: this._selfId });
|
|
3053
|
+
constraints.optional.push({ rtcStatsPeerId: peerConnectionId });
|
|
3054
|
+
constraints.optional.push({ rtcStatsConferenceId: this._roomName });
|
|
3007
3055
|
if (browserName$1 === "chrome") {
|
|
3008
3056
|
constraints.optional.push({
|
|
3009
3057
|
googCpuOveruseDetection: true,
|
|
3010
3058
|
});
|
|
3059
|
+
peerConnectionConfig.sdpSemantics = "unified-plan";
|
|
3011
3060
|
}
|
|
3012
|
-
constraints.optional.push({ rtcStatsRoomSessionId: this._roomSessionId });
|
|
3013
|
-
constraints.optional.push({ rtcStatsClientId: this._selfId });
|
|
3014
|
-
constraints.optional.push({ rtcStatsPeerId: peerConnectionId });
|
|
3015
|
-
constraints.optional.push({ rtcStatsConferenceId: this._roomName });
|
|
3016
|
-
const peerConnectionConfig = {
|
|
3017
|
-
iceServers: this._features.turnServersOn ? this._turnServers : this._iceServers,
|
|
3018
|
-
};
|
|
3019
3061
|
peerConnectionConfig.iceServers = turnServerOverride(peerConnectionConfig.iceServers, this._features.turnServerOverrideHost);
|
|
3020
3062
|
external_stun_servers(peerConnectionConfig, this._features);
|
|
3021
3063
|
maybeTurnOnly(peerConnectionConfig, this._features);
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
constraints,
|
|
3064
|
+
const session = this._getOrCreateSession({
|
|
3065
|
+
peerConnectionId,
|
|
3066
|
+
clientId,
|
|
3067
|
+
initialBandwidth,
|
|
3027
3068
|
peerConnectionConfig,
|
|
3028
3069
|
shouldAddLocalVideo,
|
|
3029
|
-
clientId,
|
|
3030
3070
|
});
|
|
3031
3071
|
setTimeout(() => this._emit(rtcManagerEvents.NEW_PC), 0);
|
|
3032
3072
|
this.analytics.numNewPc++;
|
|
3073
|
+
const { pc } = session;
|
|
3033
3074
|
pc.ontrack = (event) => {
|
|
3034
3075
|
const stream = event.streams[0];
|
|
3035
3076
|
if (stream.id === "default" && stream.getAudioTracks().length === 0) {
|
|
@@ -3182,9 +3223,13 @@ class P2pRtcManager {
|
|
|
3182
3223
|
const promises = [];
|
|
3183
3224
|
this._forEachPeerConnection((session) => {
|
|
3184
3225
|
if (!session.hasConnectedPeerConnection()) {
|
|
3226
|
+
rtcStats.sendEvent("P2PReplaceTrackWithoutPC", {});
|
|
3227
|
+
this.analytics.P2PReplaceTrackWithoutPC++;
|
|
3185
3228
|
logger$6.info("Session doesn't have a connected PeerConnection, adding pending action!");
|
|
3186
3229
|
const pendingActions = this._pendingActionsForConnectedPeerConnections;
|
|
3187
3230
|
if (!pendingActions) {
|
|
3231
|
+
rtcStats.sendEvent("P2PReplaceTrackToPCsPendingActionsNull", {});
|
|
3232
|
+
this.analytics.P2PReplaceTrackToPCsPendingActionsNull++;
|
|
3188
3233
|
logger$6.warn(`No pending action is created to replace track, because the pending actions array is null`);
|
|
3189
3234
|
return;
|
|
3190
3235
|
}
|
|
@@ -3192,6 +3237,8 @@ class P2pRtcManager {
|
|
|
3192
3237
|
const action = () => {
|
|
3193
3238
|
const replacedTrackPromise = session.replaceTrack(oldTrack, newTrack);
|
|
3194
3239
|
if (!replacedTrackPromise) {
|
|
3240
|
+
rtcStats.sendEvent("P2PReplaceTrackReturnedFalse", {});
|
|
3241
|
+
this.analytics.P2PReplaceTrackReturnedFalse++;
|
|
3195
3242
|
logger$6.error("replaceTrack returned false!");
|
|
3196
3243
|
reject(`ReplaceTrack returned false`);
|
|
3197
3244
|
return;
|
|
@@ -3205,6 +3252,8 @@ class P2pRtcManager {
|
|
|
3205
3252
|
}
|
|
3206
3253
|
const replacedTrackResult = session.replaceTrack(oldTrack, newTrack);
|
|
3207
3254
|
if (!replacedTrackResult) {
|
|
3255
|
+
rtcStats.sendEvent("P2PReplaceTrackReturnedFalse", {});
|
|
3256
|
+
this.analytics.P2PReplaceTrackReturnedFalse++;
|
|
3208
3257
|
logger$6.error("replaceTrack returned false!");
|
|
3209
3258
|
return;
|
|
3210
3259
|
}
|
|
@@ -3388,7 +3437,7 @@ class P2pRtcManager {
|
|
|
3388
3437
|
}
|
|
3389
3438
|
_withForcedRenegotiation(session, action) {
|
|
3390
3439
|
const pc = session.pc;
|
|
3391
|
-
const originalOnnegotationneeded = pc.
|
|
3440
|
+
const originalOnnegotationneeded = pc.onnegotiationneeded;
|
|
3392
3441
|
pc.onnegotiationneeded = null;
|
|
3393
3442
|
action();
|
|
3394
3443
|
this._negotiatePeerConnection(session.clientId, session);
|
|
@@ -3453,7 +3502,7 @@ class P2pRtcManager {
|
|
|
3453
3502
|
if (!session.publicHostCandidateSeen &&
|
|
3454
3503
|
!session.relayCandidateSeen &&
|
|
3455
3504
|
!session.serverReflexiveCandidateSeen) {
|
|
3456
|
-
if (pc.iceConnectionState !== "connected"
|
|
3505
|
+
if (pc.iceConnectionState !== "connected" && pc.iceConnectionState !== "completed")
|
|
3457
3506
|
this.analytics.numIceNoPublicIpGatheredIn3sec++;
|
|
3458
3507
|
}
|
|
3459
3508
|
}, ICE_PUBLIC_IP_GATHERING_TIMEOUT);
|
|
@@ -3537,6 +3586,8 @@ class P2pRtcManager {
|
|
|
3537
3586
|
}
|
|
3538
3587
|
};
|
|
3539
3588
|
pc.onnegotiationneeded = () => {
|
|
3589
|
+
this.analytics.P2PNegotiationNeeded++;
|
|
3590
|
+
rtcStats.sendEvent("P2PNegotiationNeeded", {});
|
|
3540
3591
|
if (pc.iceConnectionState === "new" || !session.connectionStatus) {
|
|
3541
3592
|
return;
|
|
3542
3593
|
}
|
|
@@ -7036,8 +7087,12 @@ class BandwidthTester extends EventEmitter {
|
|
|
7036
7087
|
this._sendTransport.getStats(),
|
|
7037
7088
|
this._receiveTransport.getStats(),
|
|
7038
7089
|
]);
|
|
7039
|
-
|
|
7040
|
-
|
|
7090
|
+
let availableOutgoingBitrate = 5000000;
|
|
7091
|
+
try {
|
|
7092
|
+
availableOutgoingBitrate = (yield this._vegaConnection.request("getTransportStats")).recvStats[0]
|
|
7093
|
+
.availableOutgoingBitrate;
|
|
7094
|
+
}
|
|
7095
|
+
catch (_a) { }
|
|
7041
7096
|
let outboundPackets = 0;
|
|
7042
7097
|
let remotePacketsLost = 0;
|
|
7043
7098
|
localSendStats.forEach((localSendStat) => {
|
|
@@ -7427,6 +7482,9 @@ function getDisplayMedia(constraints = defaultDisplayMediaConstraints, contentHi
|
|
|
7427
7482
|
t.contentHint = contentHint;
|
|
7428
7483
|
}
|
|
7429
7484
|
});
|
|
7485
|
+
stream.getTracks().forEach((t) => {
|
|
7486
|
+
trackAnnotations(t).fromGetDisplayMedia = true;
|
|
7487
|
+
});
|
|
7430
7488
|
return stream;
|
|
7431
7489
|
});
|
|
7432
7490
|
}
|
|
@@ -7600,6 +7658,7 @@ exports.startPerformanceMonitor = startPerformanceMonitor;
|
|
|
7600
7658
|
exports.stopStreamTracks = stopStreamTracks;
|
|
7601
7659
|
exports.subscribeIssues = subscribeIssues;
|
|
7602
7660
|
exports.subscribeStats = subscribeStats;
|
|
7661
|
+
exports.trackAnnotations = trackAnnotations;
|
|
7603
7662
|
exports.turnServerOverride = turnServerOverride;
|
|
7604
7663
|
exports.variance = variance;
|
|
7605
7664
|
//# sourceMappingURL=index.cjs.map
|