livekit-client 2.18.6 → 2.18.8
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/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +2 -2
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +399 -259
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/logger.d.ts +11 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +13 -3
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/PCTransportManager.d.ts +3 -1
- package/dist/src/room/PCTransportManager.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/data-track/LocalDataTrack.d.ts +31 -0
- package/dist/src/room/data-track/LocalDataTrack.d.ts.map +1 -1
- package/dist/src/room/data-track/RemoteDataTrack.d.ts.map +1 -1
- package/dist/src/room/data-track/handle.d.ts +1 -0
- package/dist/src/room/data-track/handle.d.ts.map +1 -1
- package/dist/src/room/data-track/incoming/IncomingDataTrackManager.d.ts +4 -3
- package/dist/src/room/data-track/incoming/IncomingDataTrackManager.d.ts.map +1 -1
- package/dist/src/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +18 -3
- package/dist/src/room/data-track/outgoing/OutgoingDataTrackManager.d.ts.map +1 -1
- package/dist/src/room/data-track/outgoing/types.d.ts +6 -0
- package/dist/src/room/data-track/outgoing/types.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/processor/types.d.ts +2 -0
- package/dist/src/room/track/processor/types.d.ts.map +1 -1
- package/dist/src/utils/subscribeToEvents.d.ts.map +1 -1
- package/dist/ts4.2/logger.d.ts +11 -1
- package/dist/ts4.2/room/PCTransport.d.ts +13 -3
- package/dist/ts4.2/room/PCTransportManager.d.ts +3 -1
- package/dist/ts4.2/room/data-track/LocalDataTrack.d.ts +31 -0
- package/dist/ts4.2/room/data-track/handle.d.ts +1 -0
- package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +4 -3
- package/dist/ts4.2/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +18 -3
- package/dist/ts4.2/room/data-track/outgoing/types.d.ts +6 -0
- package/dist/ts4.2/room/track/processor/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/api/SignalClient.ts +19 -31
- package/src/logger.test.ts +61 -0
- package/src/logger.ts +38 -4
- package/src/room/PCTransport.ts +26 -3
- package/src/room/PCTransportManager.test.ts +281 -0
- package/src/room/PCTransportManager.ts +45 -31
- package/src/room/RTCEngine.ts +34 -52
- package/src/room/Room.ts +37 -59
- package/src/room/data-track/LocalDataTrack.ts +51 -0
- package/src/room/data-track/RemoteDataTrack.ts +4 -1
- package/src/room/data-track/handle.ts +4 -0
- package/src/room/data-track/incoming/IncomingDataTrackManager.test.ts +72 -2
- package/src/room/data-track/incoming/IncomingDataTrackManager.ts +5 -3
- package/src/room/data-track/outgoing/OutgoingDataTrackManager.test.ts +235 -1
- package/src/room/data-track/outgoing/OutgoingDataTrackManager.ts +45 -3
- package/src/room/data-track/outgoing/types.ts +5 -0
- package/src/room/participant/LocalParticipant.ts +59 -144
- package/src/room/participant/Participant.ts +4 -1
- package/src/room/participant/publishUtils.ts +2 -2
- package/src/room/track/LocalAudioTrack.ts +1 -0
- package/src/room/track/LocalTrack.ts +2 -0
- package/src/room/track/processor/types.ts +2 -0
- package/src/utils/subscribeToEvents.ts +11 -8
|
@@ -8152,16 +8152,45 @@ var LoggerNames;
|
|
|
8152
8152
|
LoggerNames["E2EE"] = "lk-e2ee";
|
|
8153
8153
|
LoggerNames["DataTracks"] = "livekit-data-tracks";
|
|
8154
8154
|
})(LoggerNames || (LoggerNames = {}));
|
|
8155
|
-
let livekitLogger = loglevelExports.getLogger(
|
|
8155
|
+
let livekitLogger = loglevelExports.getLogger(LoggerNames.Default);
|
|
8156
8156
|
const livekitLoggers = Object.values(LoggerNames).map(name => loglevelExports.getLogger(name));
|
|
8157
8157
|
livekitLogger.setDefaultLevel(LogLevel.info);
|
|
8158
8158
|
/**
|
|
8159
8159
|
* @internal
|
|
8160
|
+
*
|
|
8161
|
+
* Get a named logger. When `ctxFn` is supplied, every log call
|
|
8162
|
+
* automatically:
|
|
8163
|
+
* 1. prepends a `[key=value ...]` prefix derived from `ctxFn()` to the
|
|
8164
|
+
* message string, so identifiers are visible in browser devtools
|
|
8165
|
+
* without expanding the structured context object, and
|
|
8166
|
+
* 2. merges `ctxFn()` into the structured context passed to any
|
|
8167
|
+
* `setLogExtension` consumer, so ingestion pipelines continue to
|
|
8168
|
+
* receive the full metadata unchanged.
|
|
8160
8169
|
*/
|
|
8161
|
-
function getLogger(name) {
|
|
8170
|
+
function getLogger(name, ctxFn) {
|
|
8162
8171
|
const logger = loglevelExports.getLogger(name);
|
|
8163
8172
|
logger.setDefaultLevel(livekitLogger.getLevel());
|
|
8164
|
-
|
|
8173
|
+
if (!ctxFn) {
|
|
8174
|
+
return logger;
|
|
8175
|
+
}
|
|
8176
|
+
return wrapWithContext(logger, ctxFn);
|
|
8177
|
+
}
|
|
8178
|
+
function wrapWithContext(base, ctxFn) {
|
|
8179
|
+
// Resolve the underlying method on every call so that later
|
|
8180
|
+
// setLogExtension installations (which replace the base logger's
|
|
8181
|
+
// methods via loglevel's methodFactory) are picked up.
|
|
8182
|
+
const wrap = method => (msg, extra) => {
|
|
8183
|
+
const ctx = ctxFn();
|
|
8184
|
+
const merged = ctx || extra ? Object.assign(Object.assign({}, ctx), extra) : undefined;
|
|
8185
|
+
base[method](msg, merged);
|
|
8186
|
+
};
|
|
8187
|
+
const proxy = Object.create(base);
|
|
8188
|
+
proxy.trace = wrap('trace');
|
|
8189
|
+
proxy.debug = wrap('debug');
|
|
8190
|
+
proxy.info = wrap('info');
|
|
8191
|
+
proxy.warn = wrap('warn');
|
|
8192
|
+
proxy.error = wrap('error');
|
|
8193
|
+
return proxy;
|
|
8165
8194
|
}
|
|
8166
8195
|
function setLogLevel(level, loggerName) {
|
|
8167
8196
|
if (loggerName) {
|
|
@@ -8194,7 +8223,7 @@ function setLogExtension(extension, logger) {
|
|
|
8194
8223
|
logR.setLevel(logR.getLevel());
|
|
8195
8224
|
});
|
|
8196
8225
|
}
|
|
8197
|
-
const workerLogger = loglevelExports.getLogger(
|
|
8226
|
+
const workerLogger = loglevelExports.getLogger(LoggerNames.E2EE);const maxRetryDelay = 7000;
|
|
8198
8227
|
const DEFAULT_RETRY_DELAYS_IN_MS = [0, 300, 2 * 2 * 300, 3 * 3 * 300, 4 * 4 * 300, maxRetryDelay, maxRetryDelay, maxRetryDelay, maxRetryDelay, maxRetryDelay];
|
|
8199
8228
|
class DefaultReconnectPolicy {
|
|
8200
8229
|
constructor(retryDelays) {
|
|
@@ -11744,7 +11773,7 @@ function getMatch(exp, ua) {
|
|
|
11744
11773
|
}
|
|
11745
11774
|
function getOSVersion(ua) {
|
|
11746
11775
|
return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
|
|
11747
|
-
}var version$1 = "2.18.
|
|
11776
|
+
}var version$1 = "2.18.8";const version = version$1;
|
|
11748
11777
|
const protocolVersion = 16;/** Base error that all LiveKit specific custom errors inherit from. */
|
|
11749
11778
|
class LivekitError extends Error {
|
|
11750
11779
|
constructor(code, message, options) {
|
|
@@ -15115,6 +15144,9 @@ class DataTrackHandleAllocator {
|
|
|
15115
15144
|
}
|
|
15116
15145
|
return this.value;
|
|
15117
15146
|
}
|
|
15147
|
+
reset() {
|
|
15148
|
+
this.value = 0;
|
|
15149
|
+
}
|
|
15118
15150
|
}const DataTrackInfo = {
|
|
15119
15151
|
from(protocolInfo) {
|
|
15120
15152
|
return {
|
|
@@ -15328,8 +15360,8 @@ class SignalClient {
|
|
|
15328
15360
|
this.onClose = undefined;
|
|
15329
15361
|
this.onMediaSectionsRequirement = undefined;
|
|
15330
15362
|
};
|
|
15331
|
-
this.log = getLogger((_a = loggerOptions.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Signal);
|
|
15332
15363
|
this.loggerContextCb = loggerOptions.loggerContextCb;
|
|
15364
|
+
this.log = getLogger((_a = loggerOptions.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Signal, () => this.logContext);
|
|
15333
15365
|
this.useJSON = useJSON;
|
|
15334
15366
|
this.requestQueue = new AsyncQueue();
|
|
15335
15367
|
this.queuedRequests = [];
|
|
@@ -15359,7 +15391,7 @@ class SignalClient {
|
|
|
15359
15391
|
reconnect(url, token, sid, reason) {
|
|
15360
15392
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15361
15393
|
if (!this.options) {
|
|
15362
|
-
this.log.warn('attempted to reconnect without signal options being set, ignoring'
|
|
15394
|
+
this.log.warn('attempted to reconnect without signal options being set, ignoring');
|
|
15363
15395
|
return;
|
|
15364
15396
|
}
|
|
15365
15397
|
this.state = SignalConnectionState.RECONNECTING;
|
|
@@ -15424,10 +15456,10 @@ class SignalClient {
|
|
|
15424
15456
|
if (redactedUrl.searchParams.has('access_token')) {
|
|
15425
15457
|
redactedUrl.searchParams.set('access_token', '<redacted>');
|
|
15426
15458
|
}
|
|
15427
|
-
this.log.
|
|
15459
|
+
this.log.info("signal connecting to ".concat(redactedUrl), {
|
|
15428
15460
|
reconnect: opts.reconnect,
|
|
15429
15461
|
reconnectReason: opts.reconnectReason
|
|
15430
|
-
}
|
|
15462
|
+
});
|
|
15431
15463
|
if (this.ws) {
|
|
15432
15464
|
yield this.close(false);
|
|
15433
15465
|
}
|
|
@@ -15439,12 +15471,12 @@ class SignalClient {
|
|
|
15439
15471
|
reject(ConnectionError.internal("Websocket got closed during a (re)connection attempt: ".concat(closeInfo.reason)));
|
|
15440
15472
|
}
|
|
15441
15473
|
if (closeInfo.closeCode !== 1000) {
|
|
15442
|
-
this.log.warn("websocket closed",
|
|
15474
|
+
this.log.warn("websocket closed", {
|
|
15443
15475
|
reason: closeInfo.reason,
|
|
15444
15476
|
code: closeInfo.closeCode,
|
|
15445
15477
|
wasClean: closeInfo.closeCode === 1000,
|
|
15446
15478
|
state: this.state
|
|
15447
|
-
})
|
|
15479
|
+
});
|
|
15448
15480
|
if (this.state === SignalConnectionState.CONNECTED) {
|
|
15449
15481
|
this.handleOnClose((_a = closeInfo.reason) !== null && _a !== void 0 ? _a : 'Unexpected WS error');
|
|
15450
15482
|
}
|
|
@@ -15492,10 +15524,10 @@ class SignalClient {
|
|
|
15492
15524
|
this.pingTimeoutDuration = firstSignalResponse.message.value.pingTimeout;
|
|
15493
15525
|
this.pingIntervalDuration = firstSignalResponse.message.value.pingInterval;
|
|
15494
15526
|
if (this.pingTimeoutDuration && this.pingTimeoutDuration > 0) {
|
|
15495
|
-
this.log.debug('ping config',
|
|
15527
|
+
this.log.debug('ping config', {
|
|
15496
15528
|
timeout: this.pingTimeoutDuration,
|
|
15497
15529
|
interval: this.pingIntervalDuration
|
|
15498
|
-
})
|
|
15530
|
+
});
|
|
15499
15531
|
}
|
|
15500
15532
|
if (this.onJoined) {
|
|
15501
15533
|
this.onJoined(firstSignalResponse.message.value);
|
|
@@ -15566,9 +15598,9 @@ class SignalClient {
|
|
|
15566
15598
|
yield Promise.race([closePromise, sleep(MAX_WS_CLOSE_TIME)]);
|
|
15567
15599
|
}
|
|
15568
15600
|
} catch (e) {
|
|
15569
|
-
_this3.log.debug('websocket error while closing',
|
|
15601
|
+
_this3.log.debug('websocket error while closing', {
|
|
15570
15602
|
error: e
|
|
15571
|
-
})
|
|
15603
|
+
});
|
|
15572
15604
|
} finally {
|
|
15573
15605
|
if (updateState) {
|
|
15574
15606
|
_this3.state = SignalConnectionState.DISCONNECTED;
|
|
@@ -15580,9 +15612,9 @@ class SignalClient {
|
|
|
15580
15612
|
}
|
|
15581
15613
|
// initial offer after joining
|
|
15582
15614
|
sendOffer(offer, offerId) {
|
|
15583
|
-
this.log.debug('sending offer',
|
|
15615
|
+
this.log.debug('sending offer', {
|
|
15584
15616
|
offerSdp: offer.sdp
|
|
15585
|
-
})
|
|
15617
|
+
});
|
|
15586
15618
|
this.sendRequest({
|
|
15587
15619
|
case: 'offer',
|
|
15588
15620
|
value: toProtoSessionDescription(offer, offerId)
|
|
@@ -15590,18 +15622,18 @@ class SignalClient {
|
|
|
15590
15622
|
}
|
|
15591
15623
|
// answer a server-initiated offer
|
|
15592
15624
|
sendAnswer(answer, offerId) {
|
|
15593
|
-
this.log.debug('sending answer',
|
|
15625
|
+
this.log.debug('sending answer', {
|
|
15594
15626
|
answerSdp: answer.sdp
|
|
15595
|
-
})
|
|
15627
|
+
});
|
|
15596
15628
|
return this.sendRequest({
|
|
15597
15629
|
case: 'answer',
|
|
15598
15630
|
value: toProtoSessionDescription(answer, offerId)
|
|
15599
15631
|
});
|
|
15600
15632
|
}
|
|
15601
15633
|
sendIceCandidate(candidate, target) {
|
|
15602
|
-
this.log.debug('sending ice candidate',
|
|
15634
|
+
this.log.debug('sending ice candidate', {
|
|
15603
15635
|
candidate
|
|
15604
|
-
})
|
|
15636
|
+
});
|
|
15605
15637
|
return this.sendRequest({
|
|
15606
15638
|
case: 'trickle',
|
|
15607
15639
|
value: new TrickleRequest({
|
|
@@ -15776,7 +15808,7 @@ class SignalClient {
|
|
|
15776
15808
|
return;
|
|
15777
15809
|
}
|
|
15778
15810
|
if (!_this5.streamWriter) {
|
|
15779
|
-
_this5.log.error("cannot send signal request before connected, type: ".concat(message === null || message === void 0 ? void 0 : message.case)
|
|
15811
|
+
_this5.log.error("cannot send signal request before connected, type: ".concat(message === null || message === void 0 ? void 0 : message.case));
|
|
15780
15812
|
return;
|
|
15781
15813
|
}
|
|
15782
15814
|
const req = new SignalRequest({
|
|
@@ -15789,9 +15821,9 @@ class SignalClient {
|
|
|
15789
15821
|
yield _this5.streamWriter.write(req.toBinary());
|
|
15790
15822
|
}
|
|
15791
15823
|
} catch (e) {
|
|
15792
|
-
_this5.log.error('error sending signal message',
|
|
15824
|
+
_this5.log.error('error sending signal message', {
|
|
15793
15825
|
error: e
|
|
15794
|
-
})
|
|
15826
|
+
});
|
|
15795
15827
|
}
|
|
15796
15828
|
}();
|
|
15797
15829
|
});
|
|
@@ -15800,7 +15832,7 @@ class SignalClient {
|
|
|
15800
15832
|
var _a, _b;
|
|
15801
15833
|
const msg = res.message;
|
|
15802
15834
|
if (msg == undefined) {
|
|
15803
|
-
this.log.debug('received unsupported message'
|
|
15835
|
+
this.log.debug('received unsupported message');
|
|
15804
15836
|
return;
|
|
15805
15837
|
}
|
|
15806
15838
|
let pingHandled = false;
|
|
@@ -15907,9 +15939,9 @@ class SignalClient {
|
|
|
15907
15939
|
this.onDataTrackSubscriberHandles(msg.value);
|
|
15908
15940
|
}
|
|
15909
15941
|
} else {
|
|
15910
|
-
this.log.debug('unsupported message',
|
|
15942
|
+
this.log.debug('unsupported message', {
|
|
15911
15943
|
msgCase: msg.case
|
|
15912
|
-
})
|
|
15944
|
+
});
|
|
15913
15945
|
}
|
|
15914
15946
|
if (!pingHandled) {
|
|
15915
15947
|
this.resetPingTimeout();
|
|
@@ -15928,18 +15960,18 @@ class SignalClient {
|
|
|
15928
15960
|
if (this.state === SignalConnectionState.DISCONNECTED) return;
|
|
15929
15961
|
const onCloseCallback = this.onClose;
|
|
15930
15962
|
yield this.close(undefined, reason);
|
|
15931
|
-
this.log.
|
|
15963
|
+
this.log.info("websocket connection closed: ".concat(reason), {
|
|
15932
15964
|
reason
|
|
15933
|
-
})
|
|
15965
|
+
});
|
|
15934
15966
|
if (onCloseCallback) {
|
|
15935
15967
|
onCloseCallback(reason);
|
|
15936
15968
|
}
|
|
15937
15969
|
});
|
|
15938
15970
|
}
|
|
15939
15971
|
handleWSError(error) {
|
|
15940
|
-
this.log.error('websocket error',
|
|
15972
|
+
this.log.error('websocket error', {
|
|
15941
15973
|
error
|
|
15942
|
-
})
|
|
15974
|
+
});
|
|
15943
15975
|
}
|
|
15944
15976
|
/**
|
|
15945
15977
|
* Resets the ping timeout and starts a new timeout.
|
|
@@ -15948,11 +15980,11 @@ class SignalClient {
|
|
|
15948
15980
|
resetPingTimeout() {
|
|
15949
15981
|
this.clearPingTimeout();
|
|
15950
15982
|
if (!this.pingTimeoutDuration) {
|
|
15951
|
-
this.log.warn('ping timeout duration not set'
|
|
15983
|
+
this.log.warn('ping timeout duration not set');
|
|
15952
15984
|
return;
|
|
15953
15985
|
}
|
|
15954
15986
|
this.pingTimeout = CriticalTimers.setTimeout(() => {
|
|
15955
|
-
this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now() - this.pingTimeoutDuration * 1000).toUTCString())
|
|
15987
|
+
this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now() - this.pingTimeoutDuration * 1000).toUTCString()));
|
|
15956
15988
|
this.handleOnClose('ping timeout');
|
|
15957
15989
|
}, this.pingTimeoutDuration * 1000);
|
|
15958
15990
|
}
|
|
@@ -15968,16 +16000,16 @@ class SignalClient {
|
|
|
15968
16000
|
this.clearPingInterval();
|
|
15969
16001
|
this.resetPingTimeout();
|
|
15970
16002
|
if (!this.pingIntervalDuration) {
|
|
15971
|
-
this.log.warn('ping interval duration not set'
|
|
16003
|
+
this.log.warn('ping interval duration not set');
|
|
15972
16004
|
return;
|
|
15973
16005
|
}
|
|
15974
|
-
this.log.debug('start ping interval'
|
|
16006
|
+
this.log.debug('start ping interval');
|
|
15975
16007
|
this.pingInterval = CriticalTimers.setInterval(() => {
|
|
15976
16008
|
this.sendPing();
|
|
15977
16009
|
}, this.pingIntervalDuration * 1000);
|
|
15978
16010
|
}
|
|
15979
16011
|
clearPingInterval() {
|
|
15980
|
-
this.log.debug('clearing ping interval'
|
|
16012
|
+
this.log.debug('clearing ping interval');
|
|
15981
16013
|
this.clearPingTimeout();
|
|
15982
16014
|
if (this.pingInterval) {
|
|
15983
16015
|
CriticalTimers.clearInterval(this.pingInterval);
|
|
@@ -15992,6 +16024,7 @@ class SignalClient {
|
|
|
15992
16024
|
*/
|
|
15993
16025
|
handleSignalConnected(connection, timeoutHandle, firstMessage) {
|
|
15994
16026
|
this.state = SignalConnectionState.CONNECTED;
|
|
16027
|
+
this.log.info('signal connected');
|
|
15995
16028
|
clearTimeout(timeoutHandle);
|
|
15996
16029
|
this.startPingInterval();
|
|
15997
16030
|
this.startReadingLoop(connection.readable.getReader(), firstMessage);
|
|
@@ -16018,7 +16051,7 @@ class SignalClient {
|
|
|
16018
16051
|
};
|
|
16019
16052
|
} else {
|
|
16020
16053
|
// in reconnecting, any message received means signal reconnected and we still need to process it
|
|
16021
|
-
this.log.debug('declaring signal reconnected without reconnect response received'
|
|
16054
|
+
this.log.debug('declaring signal reconnected without reconnect response received');
|
|
16022
16055
|
return {
|
|
16023
16056
|
isValid: true,
|
|
16024
16057
|
response: undefined,
|
|
@@ -17124,6 +17157,11 @@ const debounceInterval = 20;
|
|
|
17124
17157
|
const PCEvents = {
|
|
17125
17158
|
NegotiationStarted: 'negotiationStarted',
|
|
17126
17159
|
NegotiationComplete: 'negotiationComplete',
|
|
17160
|
+
// Fired with the offerId for every successful publisher answer application,
|
|
17161
|
+
// including answers that immediately recurse into another offer via
|
|
17162
|
+
// `renegotiate`. Use this rather than NegotiationComplete to know that a
|
|
17163
|
+
// specific offer has been negotiated end-to-end.
|
|
17164
|
+
OfferAnswered: 'offerAnswered',
|
|
17127
17165
|
RTPVideoPayloadTypes: 'rtpVideoPayloadTypes'
|
|
17128
17166
|
};
|
|
17129
17167
|
/** @internal */
|
|
@@ -17141,6 +17179,7 @@ class PCTransport extends eventsExports.EventEmitter {
|
|
|
17141
17179
|
this.log = livekitLogger;
|
|
17142
17180
|
this.ddExtID = 0;
|
|
17143
17181
|
this.latestOfferId = 0;
|
|
17182
|
+
this.latestAcknowledgedOfferId = 0;
|
|
17144
17183
|
this.pendingCandidates = [];
|
|
17145
17184
|
this.restartingIce = false;
|
|
17146
17185
|
this.renegotiate = false;
|
|
@@ -17313,6 +17352,13 @@ class PCTransport extends eventsExports.EventEmitter {
|
|
|
17313
17352
|
});
|
|
17314
17353
|
this.pendingCandidates = [];
|
|
17315
17354
|
this.restartingIce = false;
|
|
17355
|
+
// Fire OfferAnswered for every successfully applied answer, including the
|
|
17356
|
+
// ones that recurse into another offer via `renegotiate`. Callers waiting
|
|
17357
|
+
// on a specific offerId can resolve as soon as their offer's answer is in.
|
|
17358
|
+
if (sd.type === 'answer') {
|
|
17359
|
+
this.latestAcknowledgedOfferId = offerId;
|
|
17360
|
+
this.emit(PCEvents.OfferAnswered, offerId);
|
|
17361
|
+
}
|
|
17316
17362
|
if (this.renegotiate) {
|
|
17317
17363
|
this.renegotiate = false;
|
|
17318
17364
|
yield this.createAndSendOffer();
|
|
@@ -17984,41 +18030,47 @@ class PCTransportManager {
|
|
|
17984
18030
|
}
|
|
17985
18031
|
negotiate(abortController) {
|
|
17986
18032
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17987
|
-
return new TypedPromise((resolve, reject) =>
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
18033
|
+
return new TypedPromise((resolve, reject) => {
|
|
18034
|
+
// Capture the publisher's latest offer id at request time. We are done
|
|
18035
|
+
// when an offer with a higher id has had its answer successfully
|
|
18036
|
+
// applied — that offer is the one that includes any transceiver/SDP
|
|
18037
|
+
// changes that motivated this negotiate call. Concurrent callers each
|
|
18038
|
+
// get their own checkpoint and resolve independently.
|
|
18039
|
+
const checkpoint = this.publisher.latestOfferId;
|
|
18040
|
+
// Race: an answer past our checkpoint already arrived before we had a
|
|
18041
|
+
// chance to subscribe.
|
|
18042
|
+
if (this.publisher.latestAcknowledgedOfferId > checkpoint) {
|
|
18043
|
+
this.log.debug("negotiation already handled in more recent acknowledged offer", this.logContext);
|
|
18044
|
+
resolve();
|
|
18045
|
+
return;
|
|
18046
|
+
}
|
|
18047
|
+
let cleanedUp = false;
|
|
17991
18048
|
const cleanup = () => {
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
18049
|
+
if (cleanedUp) return;
|
|
18050
|
+
cleanedUp = true;
|
|
18051
|
+
clearTimeout(deadlineTimer);
|
|
18052
|
+
this.publisher.off(PCEvents.OfferAnswered, onAnswered);
|
|
18053
|
+
abortController.signal.removeEventListener('abort', onAbort);
|
|
18054
|
+
};
|
|
18055
|
+
const onAnswered = offerId => {
|
|
18056
|
+
if (offerId > checkpoint) {
|
|
18057
|
+
cleanup();
|
|
18058
|
+
resolve();
|
|
18059
|
+
}
|
|
17995
18060
|
};
|
|
17996
|
-
const
|
|
18061
|
+
const onAbort = () => {
|
|
17997
18062
|
cleanup();
|
|
17998
18063
|
reject(new NegotiationError('negotiation aborted'));
|
|
17999
18064
|
};
|
|
18000
|
-
//
|
|
18001
|
-
//
|
|
18002
|
-
|
|
18003
|
-
// NegotiationComplete hasn't fired yet because new requirements keep
|
|
18004
|
-
// arriving between offer/answer round-trips.
|
|
18005
|
-
const onNegotiationStarted = () => {
|
|
18006
|
-
if (abortController.signal.aborted) {
|
|
18007
|
-
return;
|
|
18008
|
-
}
|
|
18009
|
-
clearTimeout(negotiationTimeout);
|
|
18010
|
-
negotiationTimeout = setTimeout(() => {
|
|
18011
|
-
cleanup();
|
|
18012
|
-
reject(new NegotiationError('negotiation timed out'));
|
|
18013
|
-
}, this.peerConnectionTimeout);
|
|
18014
|
-
};
|
|
18015
|
-
abortController.signal.addEventListener('abort', abortHandler);
|
|
18016
|
-
this.publisher.on(PCEvents.NegotiationStarted, onNegotiationStarted);
|
|
18017
|
-
this.publisher.once(PCEvents.NegotiationComplete, () => {
|
|
18065
|
+
// Single hard deadline as a backstop. Not reset on cycle progress —
|
|
18066
|
+
// progress is tracked via OfferAnswered, not NegotiationStarted.
|
|
18067
|
+
const deadlineTimer = setTimeout(() => {
|
|
18018
18068
|
cleanup();
|
|
18019
|
-
|
|
18020
|
-
});
|
|
18021
|
-
|
|
18069
|
+
reject(new NegotiationError('negotiation timed out'));
|
|
18070
|
+
}, this.peerConnectionTimeout);
|
|
18071
|
+
abortController.signal.addEventListener('abort', onAbort);
|
|
18072
|
+
this.publisher.on(PCEvents.OfferAnswered, onAnswered);
|
|
18073
|
+
this.publisher.negotiate(e => {
|
|
18022
18074
|
cleanup();
|
|
18023
18075
|
if (e instanceof Error) {
|
|
18024
18076
|
reject(e);
|
|
@@ -18026,7 +18078,7 @@ class PCTransportManager {
|
|
|
18026
18078
|
reject(new Error(String(e)));
|
|
18027
18079
|
}
|
|
18028
18080
|
});
|
|
18029
|
-
})
|
|
18081
|
+
});
|
|
18030
18082
|
});
|
|
18031
18083
|
}
|
|
18032
18084
|
addPublisherTransceiver(track, transceiverInit) {
|
|
@@ -18446,7 +18498,8 @@ class LocalTrack extends Track {
|
|
|
18446
18498
|
yield this.processor.restart({
|
|
18447
18499
|
track: newTrack,
|
|
18448
18500
|
kind: this.kind,
|
|
18449
|
-
element: this.processorElement
|
|
18501
|
+
element: this.processorElement,
|
|
18502
|
+
localTrack: this
|
|
18450
18503
|
});
|
|
18451
18504
|
processedTrack = this.processor.processedTrack;
|
|
18452
18505
|
}
|
|
@@ -18784,7 +18837,8 @@ class LocalTrack extends Track {
|
|
|
18784
18837
|
kind: _this3.kind,
|
|
18785
18838
|
track: _this3._mediaStreamTrack,
|
|
18786
18839
|
element: processorElement,
|
|
18787
|
-
audioContext: _this3.audioContext
|
|
18840
|
+
audioContext: _this3.audioContext,
|
|
18841
|
+
localTrack: _this3
|
|
18788
18842
|
};
|
|
18789
18843
|
yield processor.init(processorOptions);
|
|
18790
18844
|
_this3.log.debug('processor initialized', _this3.logContext);
|
|
@@ -19084,7 +19138,8 @@ class LocalTrack extends Track {
|
|
|
19084
19138
|
kind: this.kind,
|
|
19085
19139
|
track: this._mediaStreamTrack,
|
|
19086
19140
|
// RN won't have or use AudioContext
|
|
19087
|
-
audioContext: this.audioContext
|
|
19141
|
+
audioContext: this.audioContext,
|
|
19142
|
+
localTrack: this
|
|
19088
19143
|
};
|
|
19089
19144
|
this.log.debug("setting up audio processor ".concat(processor.name), this.logContext);
|
|
19090
19145
|
yield processor.init(processorOptions);
|
|
@@ -19407,7 +19462,8 @@ function encodingsFromPresets(width, height, presets, sourceFramerate) {
|
|
|
19407
19462
|
if (maxFramerate) {
|
|
19408
19463
|
encoding.maxFramerate = maxFramerate;
|
|
19409
19464
|
}
|
|
19410
|
-
const
|
|
19465
|
+
const browser = getBrowser();
|
|
19466
|
+
const canSetPriority = (browser === null || browser === void 0 ? void 0 : browser.name) === 'Firefox' && browser.os !== 'iOS' || idx === 0;
|
|
19411
19467
|
if (preset.encoding.priority && canSetPriority) {
|
|
19412
19468
|
encoding.priority = preset.encoding.priority;
|
|
19413
19469
|
encoding.networkPriority = preset.encoding.priority;
|
|
@@ -20343,7 +20399,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20343
20399
|
} else {
|
|
20344
20400
|
return;
|
|
20345
20401
|
}
|
|
20346
|
-
_this.log.debug("on data channel ".concat(channel.id, ", ").concat(channel.label)
|
|
20402
|
+
_this.log.debug("on data channel ".concat(channel.id, ", ").concat(channel.label));
|
|
20347
20403
|
channel.onmessage = handler;
|
|
20348
20404
|
}();
|
|
20349
20405
|
});
|
|
@@ -20359,9 +20415,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20359
20415
|
} else if (message.data instanceof Blob) {
|
|
20360
20416
|
buffer = yield message.data.arrayBuffer();
|
|
20361
20417
|
} else {
|
|
20362
|
-
this.log.error('unsupported data type',
|
|
20418
|
+
this.log.error('unsupported data type', {
|
|
20363
20419
|
data: message.data
|
|
20364
|
-
})
|
|
20420
|
+
});
|
|
20365
20421
|
return;
|
|
20366
20422
|
}
|
|
20367
20423
|
const dp = DataPacket.fromBinary(new Uint8Array(buffer));
|
|
@@ -20378,7 +20434,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20378
20434
|
this.emit(EngineEvent.ActiveSpeakersUpdate, dp.value.value.speakers);
|
|
20379
20435
|
} else if (((_b = dp.value) === null || _b === void 0 ? void 0 : _b.case) === 'encryptedPacket') {
|
|
20380
20436
|
if (!this.e2eeManager) {
|
|
20381
|
-
this.log.error('Received encrypted packet but E2EE not set up'
|
|
20437
|
+
this.log.error('Received encrypted packet but E2EE not set up');
|
|
20382
20438
|
return;
|
|
20383
20439
|
}
|
|
20384
20440
|
const decryptedData = yield (_c = this.e2eeManager) === null || _c === void 0 ? void 0 : _c.handleEncryptedData(dp.value.value.encryptedValue, dp.value.value.iv, dp.participantIdentity, dp.value.value.keyIndex);
|
|
@@ -20412,9 +20468,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20412
20468
|
} else if (message.data instanceof Blob) {
|
|
20413
20469
|
buffer = yield message.data.arrayBuffer();
|
|
20414
20470
|
} else {
|
|
20415
|
-
this.log.error('unsupported data type',
|
|
20471
|
+
this.log.error('unsupported data type', {
|
|
20416
20472
|
data: message.data
|
|
20417
|
-
})
|
|
20473
|
+
});
|
|
20418
20474
|
return;
|
|
20419
20475
|
}
|
|
20420
20476
|
this.emit('dataTrackPacketReceived', new Uint8Array(buffer));
|
|
@@ -20426,13 +20482,13 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20426
20482
|
const {
|
|
20427
20483
|
error
|
|
20428
20484
|
} = event.error;
|
|
20429
|
-
this.log.error("DataChannel error on ".concat(channelKind, ": ").concat(event.message),
|
|
20485
|
+
this.log.error("DataChannel error on ".concat(channelKind, ": ").concat(event.message), {
|
|
20430
20486
|
error
|
|
20431
|
-
})
|
|
20487
|
+
});
|
|
20432
20488
|
} else {
|
|
20433
|
-
this.log.error("Unknown DataChannel error on ".concat(channelKind),
|
|
20489
|
+
this.log.error("Unknown DataChannel error on ".concat(channelKind), {
|
|
20434
20490
|
event
|
|
20435
|
-
})
|
|
20491
|
+
});
|
|
20436
20492
|
}
|
|
20437
20493
|
};
|
|
20438
20494
|
this.handleBufferedAmountLow = channelKind => {
|
|
@@ -20445,13 +20501,13 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20445
20501
|
if (this._isClosed) {
|
|
20446
20502
|
return;
|
|
20447
20503
|
}
|
|
20448
|
-
this.log.warn("".concat(connection, " disconnected")
|
|
20504
|
+
this.log.warn("".concat(connection, " disconnected"));
|
|
20449
20505
|
if (this.reconnectAttempts === 0) {
|
|
20450
20506
|
// only reset start time on the first try
|
|
20451
20507
|
this.reconnectStart = Date.now();
|
|
20452
20508
|
}
|
|
20453
20509
|
const disconnect = duration => {
|
|
20454
|
-
this.log.warn("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(duration, "ms. giving up")
|
|
20510
|
+
this.log.warn("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(duration, "ms. giving up"));
|
|
20455
20511
|
this.emit(EngineEvent.Disconnected);
|
|
20456
20512
|
this.close();
|
|
20457
20513
|
};
|
|
@@ -20467,7 +20523,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20467
20523
|
if (connection === leaveReconnect) {
|
|
20468
20524
|
delay = 0;
|
|
20469
20525
|
}
|
|
20470
|
-
this.log.debug("reconnecting in ".concat(delay, "ms")
|
|
20526
|
+
this.log.debug("reconnecting in ".concat(delay, "ms"));
|
|
20471
20527
|
this.clearReconnectTimeout();
|
|
20472
20528
|
if (this.token) {
|
|
20473
20529
|
// token may have been refreshed, we do not want to recreate the regionUrlProvider
|
|
@@ -20551,7 +20607,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20551
20607
|
}
|
|
20552
20608
|
}
|
|
20553
20609
|
});
|
|
20554
|
-
this.log = getLogger((_a = options.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Engine);
|
|
20610
|
+
this.log = getLogger((_a = options.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Engine, () => this.logContext);
|
|
20555
20611
|
this.loggerOptions = {
|
|
20556
20612
|
loggerName: options.loggerName,
|
|
20557
20613
|
loggerContextCb: () => this.logContext
|
|
@@ -20595,7 +20651,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20595
20651
|
var _this2 = this;
|
|
20596
20652
|
let useV0Path = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
20597
20653
|
return function* () {
|
|
20598
|
-
var _a, _b, _c
|
|
20654
|
+
var _a, _b, _c;
|
|
20599
20655
|
_this2._isNewlyCreated = false;
|
|
20600
20656
|
_this2.url = url;
|
|
20601
20657
|
_this2.token = token;
|
|
@@ -20637,7 +20693,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20637
20693
|
// create offer
|
|
20638
20694
|
if (!_this2.subscriberPrimary || joinResponse.fastPublish) {
|
|
20639
20695
|
_this2.negotiate().catch(err => {
|
|
20640
|
-
|
|
20696
|
+
_this2.log.error(err);
|
|
20641
20697
|
});
|
|
20642
20698
|
}
|
|
20643
20699
|
}
|
|
@@ -20651,14 +20707,10 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20651
20707
|
region: joinResponse.serverRegion
|
|
20652
20708
|
};
|
|
20653
20709
|
}
|
|
20654
|
-
_this2.log.
|
|
20710
|
+
_this2.log.info("connected to Livekit Server ".concat(Object.entries(serverInfo).map(_ref2 => {
|
|
20655
20711
|
let [key, value] = _ref2;
|
|
20656
20712
|
return "".concat(key, ": ").concat(value);
|
|
20657
|
-
}).join(', '))
|
|
20658
|
-
room: (_d = joinResponse.room) === null || _d === void 0 ? void 0 : _d.name,
|
|
20659
|
-
roomSid: (_e = joinResponse.room) === null || _e === void 0 ? void 0 : _e.sid,
|
|
20660
|
-
identity: (_f = joinResponse.participant) === null || _f === void 0 ? void 0 : _f.identity
|
|
20661
|
-
});
|
|
20713
|
+
}).join(', ')));
|
|
20662
20714
|
return {
|
|
20663
20715
|
joinResponse,
|
|
20664
20716
|
serverInfo
|
|
@@ -20666,7 +20718,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20666
20718
|
} catch (e) {
|
|
20667
20719
|
if (e instanceof ConnectionError) {
|
|
20668
20720
|
if (e.reason === ConnectionErrorReason.ServerUnreachable) {
|
|
20669
|
-
_this2.log.warn("Couldn't connect to server, attempt ".concat(_this2.joinAttempts, " of ").concat(_this2.maxJoinAttempts)
|
|
20721
|
+
_this2.log.warn("Couldn't connect to server, attempt ".concat(_this2.joinAttempts, " of ").concat(_this2.maxJoinAttempts));
|
|
20670
20722
|
if (_this2.joinAttempts < _this2.maxJoinAttempts) {
|
|
20671
20723
|
return _this2.join(url, token, opts, abortSignal, useV0Path);
|
|
20672
20724
|
}
|
|
@@ -20803,9 +20855,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20803
20855
|
this.pcManager.removeTrack(sender);
|
|
20804
20856
|
return true;
|
|
20805
20857
|
} catch (e) {
|
|
20806
|
-
this.log.warn('failed to remove track',
|
|
20858
|
+
this.log.warn('failed to remove track', {
|
|
20807
20859
|
error: e
|
|
20808
|
-
})
|
|
20860
|
+
});
|
|
20809
20861
|
}
|
|
20810
20862
|
return false;
|
|
20811
20863
|
}
|
|
@@ -20850,7 +20902,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20850
20902
|
};
|
|
20851
20903
|
this.pcManager.onDataChannel = this.handleDataChannel;
|
|
20852
20904
|
this.pcManager.onStateChange = (connectionState, publisherState, subscriberState) => __awaiter(this, void 0, void 0, function* () {
|
|
20853
|
-
this.log.debug("primary PC state changed ".concat(connectionState)
|
|
20905
|
+
this.log.debug("primary PC state changed ".concat(connectionState));
|
|
20854
20906
|
if (['closed', 'disconnected', 'failed'].includes(publisherState)) {
|
|
20855
20907
|
// reset publisher connection promise
|
|
20856
20908
|
this.publisherConnectionPromise = undefined;
|
|
@@ -20889,11 +20941,11 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20889
20941
|
if (!this.pcManager) {
|
|
20890
20942
|
return;
|
|
20891
20943
|
}
|
|
20892
|
-
this.log.debug('received server answer',
|
|
20944
|
+
this.log.debug('received server answer', {
|
|
20893
20945
|
RTCSdpType: sd.type,
|
|
20894
20946
|
sdp: sd.sdp,
|
|
20895
20947
|
midToTrackId
|
|
20896
|
-
})
|
|
20948
|
+
});
|
|
20897
20949
|
this.midToTrackId = midToTrackId;
|
|
20898
20950
|
yield this.pcManager.setPublisherAnswer(sd, offerId);
|
|
20899
20951
|
});
|
|
@@ -20902,10 +20954,10 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20902
20954
|
if (!this.pcManager) {
|
|
20903
20955
|
return;
|
|
20904
20956
|
}
|
|
20905
|
-
this.log.debug('got ICE candidate from peer',
|
|
20957
|
+
this.log.debug('got ICE candidate from peer', {
|
|
20906
20958
|
candidate,
|
|
20907
20959
|
target
|
|
20908
|
-
})
|
|
20960
|
+
});
|
|
20909
20961
|
this.pcManager.addIceCandidate(candidate, target);
|
|
20910
20962
|
};
|
|
20911
20963
|
// when server creates an offer for the client
|
|
@@ -20922,14 +20974,14 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20922
20974
|
});
|
|
20923
20975
|
this.client.onLocalTrackPublished = res => {
|
|
20924
20976
|
var _a;
|
|
20925
|
-
this.log.debug('received trackPublishedResponse',
|
|
20977
|
+
this.log.debug('received trackPublishedResponse', {
|
|
20926
20978
|
cid: res.cid,
|
|
20927
20979
|
track: (_a = res.track) === null || _a === void 0 ? void 0 : _a.sid
|
|
20928
|
-
})
|
|
20980
|
+
});
|
|
20929
20981
|
if (!this.pendingTrackResolvers[res.cid]) {
|
|
20930
|
-
this.log.error("missing track resolver for ".concat(res.cid),
|
|
20982
|
+
this.log.error("missing track resolver for ".concat(res.cid), {
|
|
20931
20983
|
cid: res.cid
|
|
20932
|
-
})
|
|
20984
|
+
});
|
|
20933
20985
|
return;
|
|
20934
20986
|
}
|
|
20935
20987
|
const {
|
|
@@ -20979,11 +21031,11 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
20979
21031
|
this.handleDisconnect('signal', ReconnectReason.RR_SIGNAL_DISCONNECTED);
|
|
20980
21032
|
};
|
|
20981
21033
|
this.client.onLeave = leave => {
|
|
20982
|
-
this.log.
|
|
21034
|
+
this.log.info("client leave request received (action=".concat(leave === null || leave === void 0 ? void 0 : leave.action, ")"), {
|
|
20983
21035
|
reason: leave === null || leave === void 0 ? void 0 : leave.reason
|
|
20984
|
-
})
|
|
21036
|
+
});
|
|
20985
21037
|
if (leave.regions) {
|
|
20986
|
-
this.log.debug('updating regions'
|
|
21038
|
+
this.log.debug('updating regions');
|
|
20987
21039
|
this.emit(EngineEvent.ServerRegionsReported, leave.regions);
|
|
20988
21040
|
}
|
|
20989
21041
|
switch (leave.action) {
|
|
@@ -21006,7 +21058,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21006
21058
|
var _a;
|
|
21007
21059
|
const rtcConfig = Object.assign({}, this.rtcConfig);
|
|
21008
21060
|
if ((_a = this.signalOpts) === null || _a === void 0 ? void 0 : _a.e2eeEnabled) {
|
|
21009
|
-
this.log.debug('E2EE - setting up transports with insertable streams'
|
|
21061
|
+
this.log.debug('E2EE - setting up transports with insertable streams');
|
|
21010
21062
|
// this makes sure that no data is sent before the transforms are ready
|
|
21011
21063
|
// @ts-ignore
|
|
21012
21064
|
rtcConfig.encodedInsertableStreams = true;
|
|
@@ -21114,7 +21166,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21114
21166
|
return sender;
|
|
21115
21167
|
}
|
|
21116
21168
|
if (supportsAddTrack()) {
|
|
21117
|
-
this.log.warn('using add-track fallback'
|
|
21169
|
+
this.log.warn('using add-track fallback');
|
|
21118
21170
|
const sender = yield this.createRTCRtpSender(track.mediaStreamTrack);
|
|
21119
21171
|
return sender;
|
|
21120
21172
|
}
|
|
@@ -21128,7 +21180,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21128
21180
|
return this.createSimulcastTransceiverSender(track, simulcastTrack, opts, encodings);
|
|
21129
21181
|
}
|
|
21130
21182
|
if (supportsAddTrack()) {
|
|
21131
|
-
this.log.debug('using add-track fallback'
|
|
21183
|
+
this.log.debug('using add-track fallback');
|
|
21132
21184
|
return this.createRTCRtpSender(track.mediaStreamTrack);
|
|
21133
21185
|
}
|
|
21134
21186
|
throw new UnexpectedConnectionState('Cannot stream on this device');
|
|
@@ -21194,7 +21246,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21194
21246
|
}
|
|
21195
21247
|
// guard for attempting reconnection multiple times while one attempt is still not finished
|
|
21196
21248
|
if (this.attemptingReconnect) {
|
|
21197
|
-
|
|
21249
|
+
this.log.warn('already attempting reconnect, returning early');
|
|
21198
21250
|
return;
|
|
21199
21251
|
}
|
|
21200
21252
|
if (((_a = this.clientConfiguration) === null || _a === void 0 ? void 0 : _a.resumeConnection) === ClientConfigSetting.DISABLED ||
|
|
@@ -21216,9 +21268,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21216
21268
|
this.reconnectAttempts += 1;
|
|
21217
21269
|
let recoverable = true;
|
|
21218
21270
|
if (e instanceof UnexpectedConnectionState) {
|
|
21219
|
-
this.log.debug('received unrecoverable error',
|
|
21271
|
+
this.log.debug('received unrecoverable error', {
|
|
21220
21272
|
error: e
|
|
21221
|
-
})
|
|
21273
|
+
});
|
|
21222
21274
|
// unrecoverable
|
|
21223
21275
|
recoverable = false;
|
|
21224
21276
|
} else if (!(e instanceof SignalReconnectError)) {
|
|
@@ -21228,7 +21280,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21228
21280
|
if (recoverable) {
|
|
21229
21281
|
this.handleDisconnect('reconnect', ReconnectReason.RR_UNKNOWN);
|
|
21230
21282
|
} else {
|
|
21231
|
-
this.log.info("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(Date.now() - this.reconnectStart, "ms. giving up")
|
|
21283
|
+
this.log.info("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(Date.now() - this.reconnectStart, "ms. giving up"));
|
|
21232
21284
|
this.emit(EngineEvent.Disconnected);
|
|
21233
21285
|
yield this.close();
|
|
21234
21286
|
}
|
|
@@ -21241,9 +21293,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21241
21293
|
try {
|
|
21242
21294
|
return this.reconnectPolicy.nextRetryDelayInMs(context);
|
|
21243
21295
|
} catch (e) {
|
|
21244
|
-
this.log.warn('encountered error in reconnect policy',
|
|
21296
|
+
this.log.warn('encountered error in reconnect policy', {
|
|
21245
21297
|
error: e
|
|
21246
|
-
})
|
|
21298
|
+
});
|
|
21247
21299
|
}
|
|
21248
21300
|
// error in user code with provided reconnect policy, stop reconnecting
|
|
21249
21301
|
return null;
|
|
@@ -21256,7 +21308,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21256
21308
|
// permanent failure, don't attempt reconnection
|
|
21257
21309
|
throw new UnexpectedConnectionState('could not reconnect, url or token not saved');
|
|
21258
21310
|
}
|
|
21259
|
-
this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts)
|
|
21311
|
+
this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts));
|
|
21260
21312
|
this.emit(EngineEvent.Restarting);
|
|
21261
21313
|
if (!this.client.isDisconnected) {
|
|
21262
21314
|
yield this.client.sendLeave();
|
|
@@ -21266,7 +21318,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21266
21318
|
let joinResponse;
|
|
21267
21319
|
try {
|
|
21268
21320
|
if (!this.signalOpts) {
|
|
21269
|
-
this.log.warn('attempted connection restart, without signal options present'
|
|
21321
|
+
this.log.warn('attempted connection restart, without signal options present');
|
|
21270
21322
|
throw new SignalReconnectError();
|
|
21271
21323
|
}
|
|
21272
21324
|
// in case a regionUrl is passed, the region URL takes precedence
|
|
@@ -21315,7 +21367,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21315
21367
|
if (!this.pcManager) {
|
|
21316
21368
|
throw new UnexpectedConnectionState('publisher and subscriber connections unset');
|
|
21317
21369
|
}
|
|
21318
|
-
this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts)
|
|
21370
|
+
this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts));
|
|
21319
21371
|
this.emit(EngineEvent.Resuming);
|
|
21320
21372
|
let res;
|
|
21321
21373
|
try {
|
|
@@ -21325,9 +21377,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21325
21377
|
let message = '';
|
|
21326
21378
|
if (error instanceof Error) {
|
|
21327
21379
|
message = error.message;
|
|
21328
|
-
this.log.error(error.message,
|
|
21380
|
+
this.log.error(error.message, {
|
|
21329
21381
|
error
|
|
21330
|
-
})
|
|
21382
|
+
});
|
|
21331
21383
|
}
|
|
21332
21384
|
if (error instanceof ConnectionError && error.reason === ConnectionErrorReason.NotAllowed) {
|
|
21333
21385
|
throw new UnexpectedConnectionState('could not reconnect, token might be expired');
|
|
@@ -21345,7 +21397,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21345
21397
|
this.latestJoinResponse.serverInfo = res.serverInfo;
|
|
21346
21398
|
}
|
|
21347
21399
|
} else {
|
|
21348
|
-
this.log.warn('Did not receive reconnect response'
|
|
21400
|
+
this.log.warn('Did not receive reconnect response');
|
|
21349
21401
|
}
|
|
21350
21402
|
if (this.shouldFailNext) {
|
|
21351
21403
|
this.shouldFailNext = false;
|
|
@@ -21381,7 +21433,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21381
21433
|
waitForPCReconnected() {
|
|
21382
21434
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21383
21435
|
this.pcState = PCState.Reconnecting;
|
|
21384
|
-
this.log.debug('waiting for peer connection to reconnect'
|
|
21436
|
+
this.log.debug('waiting for peer connection to reconnect');
|
|
21385
21437
|
try {
|
|
21386
21438
|
yield sleep(minReconnectWait); // FIXME setTimeout again not ideal for a connection critical path
|
|
21387
21439
|
if (!this.pcManager) {
|
|
@@ -21503,7 +21555,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21503
21555
|
// Drop messages to reduce latency
|
|
21504
21556
|
_this3.lossyDataDropCount += 1;
|
|
21505
21557
|
if (_this3.lossyDataDropCount % 100 === 0) {
|
|
21506
|
-
_this3.log.warn("dropping lossy data channel messages, total dropped: ".concat(_this3.lossyDataDropCount)
|
|
21558
|
+
_this3.log.warn("dropping lossy data channel messages, total dropped: ".concat(_this3.lossyDataDropCount));
|
|
21507
21559
|
}
|
|
21508
21560
|
return;
|
|
21509
21561
|
}
|
|
@@ -21581,7 +21633,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21581
21633
|
if (needNegotiation) {
|
|
21582
21634
|
// start negotiation
|
|
21583
21635
|
_this4.negotiate().catch(err => {
|
|
21584
|
-
|
|
21636
|
+
_this4.log.error(err);
|
|
21585
21637
|
});
|
|
21586
21638
|
}
|
|
21587
21639
|
const targetChannel = _this4.dataChannelForKind(kind, subscriber);
|
|
@@ -21640,7 +21692,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21640
21692
|
const abortController = new AbortController();
|
|
21641
21693
|
const handleClosed = () => {
|
|
21642
21694
|
abortController.abort();
|
|
21643
|
-
this.log.debug('engine disconnected while negotiation was ongoing'
|
|
21695
|
+
this.log.debug('engine disconnected while negotiation was ongoing');
|
|
21644
21696
|
resolve();
|
|
21645
21697
|
return;
|
|
21646
21698
|
};
|
|
@@ -21711,7 +21763,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21711
21763
|
sendSyncState(remoteTracks, localTracks, localDataTrackInfos) {
|
|
21712
21764
|
var _a, _b, _c, _d;
|
|
21713
21765
|
if (!this.pcManager) {
|
|
21714
|
-
this.log.warn('sync state cannot be sent without peer connection setup'
|
|
21766
|
+
this.log.warn('sync state cannot be sent without peer connection setup');
|
|
21715
21767
|
return;
|
|
21716
21768
|
}
|
|
21717
21769
|
const previousPublisherOffer = this.pcManager.publisher.getLocalDescription();
|
|
@@ -23159,7 +23211,10 @@ const DataTrackSymbol = Symbol.for('lk.data-track');class RemoteDataTrack {
|
|
|
23159
23211
|
*/
|
|
23160
23212
|
subscribe(options) {
|
|
23161
23213
|
try {
|
|
23162
|
-
const [stream] = this.manager.openSubscriptionStream(this.info.sid, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.bufferSize);
|
|
23214
|
+
const [stream, sfuSubscriptionComplete] = this.manager.openSubscriptionStream(this.info.sid, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.bufferSize);
|
|
23215
|
+
// Prevent uncaught promise rejections from bubbling up if rejections occur after the
|
|
23216
|
+
// readable stream is discarded.
|
|
23217
|
+
sfuSubscriptionComplete.catch(() => {});
|
|
23163
23218
|
return stream;
|
|
23164
23219
|
} catch (err) {
|
|
23165
23220
|
// NOTE: Rethrow errors to break Throws<...> type boundary
|
|
@@ -23700,7 +23755,7 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
23700
23755
|
*
|
|
23701
23756
|
* This is an index that allows track descriptors to be looked up
|
|
23702
23757
|
* by subscriber handle in O(1) time, to make routing incoming packets
|
|
23703
|
-
* a
|
|
23758
|
+
* (a hot code path) faster.
|
|
23704
23759
|
*/
|
|
23705
23760
|
this.subscriptionHandles = new Map();
|
|
23706
23761
|
this.e2eeManager = (_a = options === null || options === void 0 ? void 0 : options.e2eeManager) !== null && _a !== void 0 ? _a : null;
|
|
@@ -24184,8 +24239,9 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24184
24239
|
}
|
|
24185
24240
|
}
|
|
24186
24241
|
}
|
|
24187
|
-
/**
|
|
24188
|
-
|
|
24242
|
+
/** Resets the manager, ending any subscriptions, and getting it ready for the next room
|
|
24243
|
+
* connection. */
|
|
24244
|
+
reset() {
|
|
24189
24245
|
var _a, _b;
|
|
24190
24246
|
for (const descriptor of this.descriptors.values()) {
|
|
24191
24247
|
this.emit('trackUnpublished', {
|
|
@@ -24200,6 +24256,7 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24200
24256
|
}
|
|
24201
24257
|
}
|
|
24202
24258
|
this.descriptors.clear();
|
|
24259
|
+
this.subscriptionHandles.clear();
|
|
24203
24260
|
}
|
|
24204
24261
|
}class DataTrackPacketizerError extends LivekitReasonedError {
|
|
24205
24262
|
constructor(message, reason, options) {
|
|
@@ -24398,9 +24455,26 @@ class DataTrackOutgoingPipelineError extends LivekitReasonedError {
|
|
|
24398
24455
|
/** Represents the currently active {@link DataTrackHandle} for the publication. */
|
|
24399
24456
|
this.handle = null;
|
|
24400
24457
|
this.log = livekitLogger;
|
|
24458
|
+
/** Resolves once the data track has sent all pending packets the rtc data channel buffer. */
|
|
24459
|
+
this.flushedFuture = new Future();
|
|
24460
|
+
this.handleManagerReset = () => {
|
|
24461
|
+
// When the associated manager resets, mark any in flight flushes as complete
|
|
24462
|
+
// There's nothing actionable a user can do to get these to complete so no
|
|
24463
|
+
// error is being thrown.
|
|
24464
|
+
this.handleManagerPacketsFlushed();
|
|
24465
|
+
this.manager.off('packetsFlushed', this.handleManagerReset);
|
|
24466
|
+
this.manager.off('reset', this.handleManagerReset);
|
|
24467
|
+
};
|
|
24468
|
+
this.handleManagerPacketsFlushed = () => {
|
|
24469
|
+
var _a, _b;
|
|
24470
|
+
(_b = (_a = this.flushedFuture).resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
24471
|
+
this.flushedFuture = new Future();
|
|
24472
|
+
};
|
|
24401
24473
|
this.options = options;
|
|
24402
24474
|
this.manager = manager;
|
|
24403
24475
|
this.log = getLogger(LoggerNames.DataTracks);
|
|
24476
|
+
this.manager.on('packetsFlushed', this.handleManagerPacketsFlushed);
|
|
24477
|
+
this.manager.on('reset', this.handleManagerReset);
|
|
24404
24478
|
}
|
|
24405
24479
|
/** @internal */
|
|
24406
24480
|
static withExplicitHandle(options, manager, handle) {
|
|
@@ -24461,6 +24535,36 @@ class DataTrackOutgoingPipelineError extends LivekitReasonedError {
|
|
|
24461
24535
|
throw err;
|
|
24462
24536
|
}
|
|
24463
24537
|
}
|
|
24538
|
+
/**
|
|
24539
|
+
* When called, waits for all in flight packets to be sent before resolving.
|
|
24540
|
+
*
|
|
24541
|
+
* Use this to:
|
|
24542
|
+
*
|
|
24543
|
+
* 1. Send frames exactly in order:
|
|
24544
|
+
* ```ts
|
|
24545
|
+
* await track.tryPush(/* ... *\/);
|
|
24546
|
+
* await track.flush();
|
|
24547
|
+
* await track.tryPush(/* ... *\/);
|
|
24548
|
+
* await track.flush();
|
|
24549
|
+
* // ... etc ...
|
|
24550
|
+
* ```
|
|
24551
|
+
*
|
|
24552
|
+
* 2. Wait for frames to all be delivered before unpublishing a local data track:
|
|
24553
|
+
*
|
|
24554
|
+
* ```ts
|
|
24555
|
+
* await track.tryPush(/* ... *\/);
|
|
24556
|
+
* await track.tryPush(/* ... *\/);
|
|
24557
|
+
* await track.tryPush(/* ... *\/);
|
|
24558
|
+
* // ... etc ...
|
|
24559
|
+
* await track.flush();
|
|
24560
|
+
* await track.unpublish();
|
|
24561
|
+
* ```
|
|
24562
|
+
**/
|
|
24563
|
+
flush() {
|
|
24564
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24565
|
+
return this.flushedFuture.promise;
|
|
24566
|
+
});
|
|
24567
|
+
}
|
|
24464
24568
|
/**
|
|
24465
24569
|
* Unpublish the track from the SFU. Once this is called, any further calls to {@link tryPush}
|
|
24466
24570
|
* will fail.
|
|
@@ -24548,6 +24652,10 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24548
24652
|
super();
|
|
24549
24653
|
this.handleAllocator = new DataTrackHandleAllocator();
|
|
24550
24654
|
this.descriptors = new Map();
|
|
24655
|
+
/** Number of packets for each data track which have been emitted via the `packetAvailable` event
|
|
24656
|
+
* and which have not yet been sent via the rtc data channel yet. Once this goes to 0, then
|
|
24657
|
+
* all in flight packets have been delivered, and the data tracks is "flushed". */
|
|
24658
|
+
this.inFlightPacketCounter = new Map();
|
|
24551
24659
|
this.e2eeManager = (_a = options === null || options === void 0 ? void 0 : options.e2eeManager) !== null && _a !== void 0 ? _a : null;
|
|
24552
24660
|
}
|
|
24553
24661
|
static withDescriptors(descriptors) {
|
|
@@ -24580,6 +24688,7 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24580
24688
|
tryProcessAndSend(handle, frame) {
|
|
24581
24689
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24582
24690
|
var _a, e_1, _b, _c;
|
|
24691
|
+
var _d;
|
|
24583
24692
|
const descriptor = this.getDescriptor(handle);
|
|
24584
24693
|
if ((descriptor === null || descriptor === void 0 ? void 0 : descriptor.type) !== 'active') {
|
|
24585
24694
|
throw DataTrackPushFrameError.trackUnpublished();
|
|
@@ -24592,11 +24701,14 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24592
24701
|
}
|
|
24593
24702
|
try {
|
|
24594
24703
|
try {
|
|
24595
|
-
for (var
|
|
24596
|
-
_c =
|
|
24597
|
-
|
|
24704
|
+
for (var _e = true, _f = __asyncValues(descriptor.pipeline.processFrame(frame)), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
|
|
24705
|
+
_c = _g.value;
|
|
24706
|
+
_e = false;
|
|
24598
24707
|
const packet = _c;
|
|
24708
|
+
const prev = (_d = this.inFlightPacketCounter.get(handle)) !== null && _d !== void 0 ? _d : 0;
|
|
24709
|
+
this.inFlightPacketCounter.set(handle, prev + 1);
|
|
24599
24710
|
this.emit('packetAvailable', {
|
|
24711
|
+
handle,
|
|
24600
24712
|
bytes: packet.toBinary()
|
|
24601
24713
|
});
|
|
24602
24714
|
}
|
|
@@ -24606,7 +24718,7 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24606
24718
|
};
|
|
24607
24719
|
} finally {
|
|
24608
24720
|
try {
|
|
24609
|
-
if (!
|
|
24721
|
+
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
|
|
24610
24722
|
} finally {
|
|
24611
24723
|
if (e_1) throw e_1.error;
|
|
24612
24724
|
}
|
|
@@ -24618,6 +24730,25 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24618
24730
|
}
|
|
24619
24731
|
});
|
|
24620
24732
|
}
|
|
24733
|
+
/** The client has sent a packet over the rtc data channel. This signal is used for determining
|
|
24734
|
+
* once all packets are sent and a data track has been "flushed".
|
|
24735
|
+
*
|
|
24736
|
+
* @internal */
|
|
24737
|
+
handlePacketSendComplete(handle) {
|
|
24738
|
+
var _a;
|
|
24739
|
+
const prev = (_a = this.inFlightPacketCounter.get(handle)) !== null && _a !== void 0 ? _a : 0;
|
|
24740
|
+
let counter = prev - 1;
|
|
24741
|
+
if (counter < 0) {
|
|
24742
|
+
log.warn("OutgoingDataTrackManager.handlePacketSendComplete: inFlightPacketCounter was decremented below 0 (got ".concat(this.inFlightPacketCounter, " - resetting to 0. Were more packets send than were emitted?"));
|
|
24743
|
+
counter = 0;
|
|
24744
|
+
}
|
|
24745
|
+
this.inFlightPacketCounter.set(handle, counter);
|
|
24746
|
+
if (counter === 0) {
|
|
24747
|
+
this.emit('packetsFlushed', {
|
|
24748
|
+
handle
|
|
24749
|
+
});
|
|
24750
|
+
}
|
|
24751
|
+
}
|
|
24621
24752
|
/**
|
|
24622
24753
|
* Client requested to publish a track.
|
|
24623
24754
|
*
|
|
@@ -24703,6 +24834,7 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24703
24834
|
handle
|
|
24704
24835
|
});
|
|
24705
24836
|
yield descriptor.unpublishingFuture.promise;
|
|
24837
|
+
this.inFlightPacketCounter.delete(handle);
|
|
24706
24838
|
this.emit('trackUnpublished', {
|
|
24707
24839
|
sid: descriptor.info.sid
|
|
24708
24840
|
});
|
|
@@ -24795,12 +24927,14 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24795
24927
|
}
|
|
24796
24928
|
}
|
|
24797
24929
|
/**
|
|
24798
|
-
*
|
|
24930
|
+
* Reset's the state of the manager and all associated tracks. Run on room disconnect to get
|
|
24931
|
+
* the manager ready for the next room connection.
|
|
24799
24932
|
* @internal
|
|
24800
24933
|
**/
|
|
24801
|
-
|
|
24934
|
+
reset() {
|
|
24802
24935
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24803
24936
|
var _a, _b, _c, _d;
|
|
24937
|
+
this.handleAllocator.reset();
|
|
24804
24938
|
for (const descriptor of this.descriptors.values()) {
|
|
24805
24939
|
switch (descriptor.type) {
|
|
24806
24940
|
case 'pending':
|
|
@@ -24815,6 +24949,8 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
|
|
|
24815
24949
|
}
|
|
24816
24950
|
}
|
|
24817
24951
|
this.descriptors.clear();
|
|
24952
|
+
this.inFlightPacketCounter.clear();
|
|
24953
|
+
this.emit('reset');
|
|
24818
24954
|
});
|
|
24819
24955
|
}
|
|
24820
24956
|
}class RemoteTrack extends Track {
|
|
@@ -25929,8 +26065,8 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
25929
26065
|
this.isSpeaking = false;
|
|
25930
26066
|
this._connectionQuality = ConnectionQuality.Unknown;
|
|
25931
26067
|
this.log = livekitLogger;
|
|
25932
|
-
this.log = getLogger((_a = loggerOptions === null || loggerOptions === void 0 ? void 0 : loggerOptions.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Participant);
|
|
25933
26068
|
this.loggerOptions = loggerOptions;
|
|
26069
|
+
this.log = getLogger((_a = loggerOptions === null || loggerOptions === void 0 ? void 0 : loggerOptions.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Participant, () => this.logContext);
|
|
25934
26070
|
this.setMaxListeners(100);
|
|
25935
26071
|
this.sid = sid;
|
|
25936
26072
|
this.identity = identity;
|
|
@@ -26182,7 +26318,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26182
26318
|
if (this.reconnectFuture) {
|
|
26183
26319
|
// @throws-transformer ignore - introduced due to adding Throws into Future, investigate this
|
|
26184
26320
|
// further
|
|
26185
|
-
this.reconnectFuture.promise.catch(e => this.log.warn(e.message
|
|
26321
|
+
this.reconnectFuture.promise.catch(e => this.log.warn(e.message));
|
|
26186
26322
|
(_b = (_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.reject) === null || _b === void 0 ? void 0 : _b.call(_a, new Error('Got disconnected during reconnection attempt'));
|
|
26187
26323
|
this.reconnectFuture = undefined;
|
|
26188
26324
|
}
|
|
@@ -26266,10 +26402,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26266
26402
|
}
|
|
26267
26403
|
};
|
|
26268
26404
|
this.updateTrackSubscriptionPermissions = () => {
|
|
26269
|
-
this.log.debug('updating track subscription permissions',
|
|
26405
|
+
this.log.debug('updating track subscription permissions', {
|
|
26270
26406
|
allParticipantsAllowed: this.allParticipantsAllowedToSubscribe,
|
|
26271
26407
|
participantTrackPermissions: this.participantTrackPermissions
|
|
26272
|
-
})
|
|
26408
|
+
});
|
|
26273
26409
|
this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe, this.participantTrackPermissions.map(p => trackPermissionToProto(p)));
|
|
26274
26410
|
};
|
|
26275
26411
|
/** @internal */
|
|
@@ -26283,29 +26419,29 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26283
26419
|
muted = true;
|
|
26284
26420
|
}
|
|
26285
26421
|
if (!track.sid) {
|
|
26286
|
-
this.log.error('could not update mute status for unpublished track',
|
|
26422
|
+
this.log.error('could not update mute status for unpublished track', getLogContextFromTrack(track));
|
|
26287
26423
|
return;
|
|
26288
26424
|
}
|
|
26289
26425
|
this.engine.updateMuteStatus(track.sid, muted);
|
|
26290
26426
|
};
|
|
26291
26427
|
this.onTrackUpstreamPaused = track => {
|
|
26292
|
-
this.log.debug('upstream paused',
|
|
26428
|
+
this.log.debug('upstream paused', getLogContextFromTrack(track));
|
|
26293
26429
|
this.onTrackMuted(track, true);
|
|
26294
26430
|
};
|
|
26295
26431
|
this.onTrackUpstreamResumed = track => {
|
|
26296
|
-
this.log.debug('upstream resumed',
|
|
26432
|
+
this.log.debug('upstream resumed', getLogContextFromTrack(track));
|
|
26297
26433
|
this.onTrackMuted(track, track.isMuted);
|
|
26298
26434
|
};
|
|
26299
26435
|
this.onTrackFeatureUpdate = track => {
|
|
26300
26436
|
const pub = this.audioTrackPublications.get(track.sid);
|
|
26301
26437
|
if (!pub) {
|
|
26302
|
-
this.log.warn("Could not update local audio track settings, missing publication for track ".concat(track.sid)
|
|
26438
|
+
this.log.warn("Could not update local audio track settings, missing publication for track ".concat(track.sid));
|
|
26303
26439
|
return;
|
|
26304
26440
|
}
|
|
26305
26441
|
this.engine.client.sendUpdateLocalAudioTrack(pub.trackSid, pub.getTrackFeatures());
|
|
26306
26442
|
};
|
|
26307
26443
|
this.onTrackCpuConstrained = (track, publication) => {
|
|
26308
|
-
this.log.debug('track cpu constrained',
|
|
26444
|
+
this.log.debug('track cpu constrained', getLogContextFromTrack(publication));
|
|
26309
26445
|
this.emit(ParticipantEvent.LocalTrackCpuConstrained, track, publication);
|
|
26310
26446
|
};
|
|
26311
26447
|
this.handleSubscribedQualityUpdate = update => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -26316,9 +26452,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26316
26452
|
}
|
|
26317
26453
|
const pub = this.videoTrackPublications.get(update.trackSid);
|
|
26318
26454
|
if (!pub) {
|
|
26319
|
-
this.log.warn('received subscribed quality update for unknown track',
|
|
26455
|
+
this.log.warn('received subscribed quality update for unknown track', {
|
|
26320
26456
|
trackSid: update.trackSid
|
|
26321
|
-
})
|
|
26457
|
+
});
|
|
26322
26458
|
return;
|
|
26323
26459
|
}
|
|
26324
26460
|
if (!pub.videoTrack) {
|
|
@@ -26331,7 +26467,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26331
26467
|
_e = false;
|
|
26332
26468
|
const codec = _c;
|
|
26333
26469
|
if (isBackupCodec(codec)) {
|
|
26334
|
-
this.log.debug("publish ".concat(codec, " for ").concat(pub.videoTrack.sid),
|
|
26470
|
+
this.log.debug("publish ".concat(codec, " for ").concat(pub.videoTrack.sid), getLogContextFromTrack(pub));
|
|
26335
26471
|
yield this.publishAdditionalCodecForTrack(pub.videoTrack, codec, pub.options);
|
|
26336
26472
|
}
|
|
26337
26473
|
}
|
|
@@ -26350,16 +26486,16 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26350
26486
|
this.handleLocalTrackUnpublished = unpublished => {
|
|
26351
26487
|
const track = this.trackPublications.get(unpublished.trackSid);
|
|
26352
26488
|
if (!track) {
|
|
26353
|
-
this.log.warn('received unpublished event for unknown track',
|
|
26489
|
+
this.log.warn('received unpublished event for unknown track', {
|
|
26354
26490
|
trackSid: unpublished.trackSid
|
|
26355
|
-
})
|
|
26491
|
+
});
|
|
26356
26492
|
return;
|
|
26357
26493
|
}
|
|
26358
26494
|
this.unpublishTrack(track.track);
|
|
26359
26495
|
};
|
|
26360
26496
|
this.handleTrackEnded = track => __awaiter(this, void 0, void 0, function* () {
|
|
26361
26497
|
if (track.source === Track.Source.ScreenShare || track.source === Track.Source.ScreenShareAudio) {
|
|
26362
|
-
this.log.debug('unpublishing local track due to TrackEnded',
|
|
26498
|
+
this.log.debug('unpublishing local track due to TrackEnded', getLogContextFromTrack(track));
|
|
26363
26499
|
this.unpublishTrack(track);
|
|
26364
26500
|
} else if (track.isUserProvided) {
|
|
26365
26501
|
yield track.mute();
|
|
@@ -26373,7 +26509,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26373
26509
|
name: track.source === Track.Source.Camera ? 'camera' : 'microphone'
|
|
26374
26510
|
});
|
|
26375
26511
|
if (currentPermissions && currentPermissions.state === 'denied') {
|
|
26376
|
-
this.log.warn("user has revoked access to ".concat(track.source),
|
|
26512
|
+
this.log.warn("user has revoked access to ".concat(track.source), getLogContextFromTrack(track));
|
|
26377
26513
|
// detect granted change after permissions were denied to try and resume then
|
|
26378
26514
|
currentPermissions.onchange = () => {
|
|
26379
26515
|
if (currentPermissions.state !== 'denied') {
|
|
@@ -26390,7 +26526,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26390
26526
|
}
|
|
26391
26527
|
}
|
|
26392
26528
|
if (!track.isMuted) {
|
|
26393
|
-
this.log.debug('track ended, attempting to use a different device',
|
|
26529
|
+
this.log.debug('track ended, attempting to use a different device', getLogContextFromTrack(track));
|
|
26394
26530
|
if (isLocalAudioTrack(track)) {
|
|
26395
26531
|
// fall back to default device if available
|
|
26396
26532
|
yield track.restartTrack({
|
|
@@ -26401,7 +26537,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26401
26537
|
}
|
|
26402
26538
|
}
|
|
26403
26539
|
} catch (e) {
|
|
26404
|
-
this.log.warn("could not restart track, muting instead",
|
|
26540
|
+
this.log.warn("could not restart track, muting instead", getLogContextFromTrack(track));
|
|
26405
26541
|
yield track.mute();
|
|
26406
26542
|
}
|
|
26407
26543
|
}
|
|
@@ -26594,10 +26730,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26594
26730
|
setTrackEnabled(source, enabled, options, publishOptions) {
|
|
26595
26731
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26596
26732
|
var _a, _b;
|
|
26597
|
-
this.log.debug('setTrackEnabled',
|
|
26733
|
+
this.log.debug('setTrackEnabled', {
|
|
26598
26734
|
source,
|
|
26599
26735
|
enabled
|
|
26600
|
-
})
|
|
26736
|
+
});
|
|
26601
26737
|
if (this.republishPromise) {
|
|
26602
26738
|
yield this.republishPromise;
|
|
26603
26739
|
}
|
|
@@ -26610,9 +26746,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26610
26746
|
if (this.pendingPublishing.has(source)) {
|
|
26611
26747
|
const pendingTrack = yield this.waitForPendingPublicationOfSource(source);
|
|
26612
26748
|
if (!pendingTrack) {
|
|
26613
|
-
this.log.info('waiting for pending publication promise timed out',
|
|
26749
|
+
this.log.info('waiting for pending publication promise timed out', {
|
|
26614
26750
|
source
|
|
26615
|
-
})
|
|
26751
|
+
});
|
|
26616
26752
|
}
|
|
26617
26753
|
yield pendingTrack === null || pendingTrack === void 0 ? void 0 : pendingTrack.unmute();
|
|
26618
26754
|
return pendingTrack;
|
|
@@ -26649,14 +26785,14 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26649
26785
|
for (const localTrack of localTracks) {
|
|
26650
26786
|
const opts = Object.assign(Object.assign({}, this.roomOptions.publishDefaults), options);
|
|
26651
26787
|
if (source === Track.Source.Microphone && isAudioTrack(localTrack) && opts.preConnectBuffer) {
|
|
26652
|
-
this.log.info('starting preconnect buffer for microphone'
|
|
26788
|
+
this.log.info('starting preconnect buffer for microphone');
|
|
26653
26789
|
localTrack.startPreConnectBuffer();
|
|
26654
26790
|
}
|
|
26655
26791
|
}
|
|
26656
26792
|
try {
|
|
26657
26793
|
const publishPromises = [];
|
|
26658
26794
|
for (const localTrack of localTracks) {
|
|
26659
|
-
this.log.info('publishing track',
|
|
26795
|
+
this.log.info('publishing track', getLogContextFromTrack(localTrack));
|
|
26660
26796
|
publishPromises.push(this.publishTrack(localTrack, publishOptions));
|
|
26661
26797
|
}
|
|
26662
26798
|
const publishedTracks = yield Promise.all(publishPromises);
|
|
@@ -26677,9 +26813,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26677
26813
|
// if there's no track available yet first wait for pending publishing promises of that source to see if it becomes available
|
|
26678
26814
|
track = yield this.waitForPendingPublicationOfSource(source);
|
|
26679
26815
|
if (!track) {
|
|
26680
|
-
this.log.info('waiting for pending publication promise timed out',
|
|
26816
|
+
this.log.info('waiting for pending publication promise timed out', {
|
|
26681
26817
|
source
|
|
26682
|
-
})
|
|
26818
|
+
});
|
|
26683
26819
|
}
|
|
26684
26820
|
}
|
|
26685
26821
|
if (track && track.track) {
|
|
@@ -26925,7 +27061,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26925
27061
|
}
|
|
26926
27062
|
});
|
|
26927
27063
|
if (existingPublication) {
|
|
26928
|
-
_this2.log.warn('track has already been published, skipping',
|
|
27064
|
+
_this2.log.warn('track has already been published, skipping', getLogContextFromTrack(existingPublication));
|
|
26929
27065
|
return existingPublication;
|
|
26930
27066
|
}
|
|
26931
27067
|
const opts = Object.assign(Object.assign({}, _this2.roomOptions.publishDefaults), options);
|
|
@@ -26936,16 +27072,16 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26936
27072
|
// disable dtx for stereo track if not enabled explicitly
|
|
26937
27073
|
if (isStereo) {
|
|
26938
27074
|
if (opts.dtx === undefined) {
|
|
26939
|
-
_this2.log.
|
|
27075
|
+
_this2.log.debug("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.", getLogContextFromTrack(track));
|
|
26940
27076
|
}
|
|
26941
27077
|
if (opts.red === undefined) {
|
|
26942
|
-
_this2.log.
|
|
27078
|
+
_this2.log.debug("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work.");
|
|
26943
27079
|
}
|
|
26944
27080
|
(_c = opts.dtx) !== null && _c !== void 0 ? _c : opts.dtx = false;
|
|
26945
27081
|
(_d = opts.red) !== null && _d !== void 0 ? _d : opts.red = false;
|
|
26946
27082
|
}
|
|
26947
27083
|
if (!isE2EESimulcastSupported() && _this2.roomOptions.e2ee) {
|
|
26948
|
-
_this2.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2"
|
|
27084
|
+
_this2.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2");
|
|
26949
27085
|
opts.simulcast = false;
|
|
26950
27086
|
}
|
|
26951
27087
|
if (opts.source) {
|
|
@@ -26954,9 +27090,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26954
27090
|
const publishPromise = new Promise((resolve, reject) => __awaiter(_this2, void 0, void 0, function* () {
|
|
26955
27091
|
try {
|
|
26956
27092
|
if (this.engine.client.currentState !== SignalConnectionState.CONNECTED) {
|
|
26957
|
-
this.log.debug('deferring track publication until signal is connected',
|
|
27093
|
+
this.log.debug('deferring track publication until signal is connected', {
|
|
26958
27094
|
track: getLogContextFromTrack(track)
|
|
26959
|
-
})
|
|
27095
|
+
});
|
|
26960
27096
|
let publicationTimedOut = false;
|
|
26961
27097
|
const timeout = setTimeout(() => {
|
|
26962
27098
|
publicationTimedOut = true;
|
|
@@ -26988,9 +27124,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
26988
27124
|
return publication;
|
|
26989
27125
|
} catch (e) {
|
|
26990
27126
|
if (!hasRetriedAfterNegotiationError && e instanceof NegotiationError) {
|
|
26991
|
-
_this2.log.warn('negotiation due to track publish failed, retrying after reconnect',
|
|
27127
|
+
_this2.log.warn('negotiation due to track publish failed, retrying after reconnect', {
|
|
26992
27128
|
error: e
|
|
26993
|
-
})
|
|
27129
|
+
});
|
|
26994
27130
|
_this2.pendingPublishPromises.delete(track);
|
|
26995
27131
|
yield _this2.waitForNextEngineRestart();
|
|
26996
27132
|
return yield _this2.publishOrRepublishTrack(track, options, isRepublish, true);
|
|
@@ -27010,7 +27146,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27010
27146
|
}
|
|
27011
27147
|
hasPermissionsToPublish(track) {
|
|
27012
27148
|
if (!this.permissions) {
|
|
27013
|
-
this.log.warn('no permissions present for publishing track',
|
|
27149
|
+
this.log.warn('no permissions present for publishing track', getLogContextFromTrack(track));
|
|
27014
27150
|
return false;
|
|
27015
27151
|
}
|
|
27016
27152
|
const {
|
|
@@ -27020,7 +27156,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27020
27156
|
if (canPublish && (canPublishSources.length === 0 || canPublishSources.map(source => getTrackSourceFromProto(source)).includes(track.source))) {
|
|
27021
27157
|
return true;
|
|
27022
27158
|
}
|
|
27023
|
-
this.log.warn('insufficient permissions to publish',
|
|
27159
|
+
this.log.warn('insufficient permissions to publish', getLogContextFromTrack(track));
|
|
27024
27160
|
return false;
|
|
27025
27161
|
}
|
|
27026
27162
|
publish(track, opts, isStereo) {
|
|
@@ -27031,7 +27167,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27031
27167
|
}
|
|
27032
27168
|
const existingTrackOfSource = Array.from(this.trackPublications.values()).find(publishedTrack => isLocalTrack(track) && publishedTrack.source === track.source);
|
|
27033
27169
|
if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
|
|
27034
|
-
this.log.info("publishing a second track with the same source: ".concat(track.source),
|
|
27170
|
+
this.log.info("publishing a second track with the same source: ".concat(track.source), getLogContextFromTrack(track));
|
|
27035
27171
|
}
|
|
27036
27172
|
if (opts.stopMicTrackOnMute && isAudioTrack(track)) {
|
|
27037
27173
|
track.stopOnMute = true;
|
|
@@ -27120,7 +27256,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27120
27256
|
height: defaultRes.height
|
|
27121
27257
|
};
|
|
27122
27258
|
// log failure
|
|
27123
|
-
this.log.error('could not determine track dimensions, using defaults', Object.assign(Object.assign(
|
|
27259
|
+
this.log.error('could not determine track dimensions, using defaults', Object.assign(Object.assign({}, getLogContextFromTrack(track)), {
|
|
27124
27260
|
dims
|
|
27125
27261
|
}));
|
|
27126
27262
|
}
|
|
@@ -27141,7 +27277,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27141
27277
|
// that we need
|
|
27142
27278
|
if ('contentHint' in track.mediaStreamTrack) {
|
|
27143
27279
|
track.mediaStreamTrack.contentHint = 'motion';
|
|
27144
|
-
this.log.
|
|
27280
|
+
this.log.debug('forcing contentHint to motion for screenshare with SVC codecs', getLogContextFromTrack(track));
|
|
27145
27281
|
}
|
|
27146
27282
|
}
|
|
27147
27283
|
// set scalabilityMode to 'L3T3_KEY' by default
|
|
@@ -27237,10 +27373,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27237
27373
|
try {
|
|
27238
27374
|
this.engine.pcManager.publisher.removeTrack(track.sender);
|
|
27239
27375
|
} catch (e) {
|
|
27240
|
-
this.log.error(e
|
|
27376
|
+
this.log.error(e);
|
|
27241
27377
|
}
|
|
27242
27378
|
yield this.engine.negotiate().catch(negotiateErr => {
|
|
27243
|
-
this.log.error('failed to negotiate after removing track due to failed add track request', Object.assign(Object.assign(
|
|
27379
|
+
this.log.error('failed to negotiate after removing track due to failed add track request', Object.assign(Object.assign({}, getLogContextFromTrack(track)), {
|
|
27244
27380
|
error: negotiateErr
|
|
27245
27381
|
}));
|
|
27246
27382
|
});
|
|
@@ -27264,7 +27400,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27264
27400
|
if (primaryCodecMime && track.kind === Track.Kind.Video) {
|
|
27265
27401
|
const updatedCodec = mimeTypeToVideoCodecString(primaryCodecMime);
|
|
27266
27402
|
if (updatedCodec !== videoCodec) {
|
|
27267
|
-
this.log.debug('falling back to server selected codec', Object.assign(Object.assign(
|
|
27403
|
+
this.log.debug('falling back to server selected codec', Object.assign(Object.assign({}, getLogContextFromTrack(track)), {
|
|
27268
27404
|
codec: updatedCodec
|
|
27269
27405
|
}));
|
|
27270
27406
|
opts.videoCodec = updatedCodec;
|
|
@@ -27295,10 +27431,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27295
27431
|
};
|
|
27296
27432
|
}
|
|
27297
27433
|
}
|
|
27298
|
-
this.log.debug("publishing ".concat(track.kind, " with encodings"),
|
|
27434
|
+
this.log.debug("publishing ".concat(track.kind, " with encodings"), {
|
|
27299
27435
|
encodings,
|
|
27300
27436
|
trackInfo: ti
|
|
27301
|
-
})
|
|
27437
|
+
});
|
|
27302
27438
|
if (isLocalVideoTrack(track)) {
|
|
27303
27439
|
track.startMonitor(this.engine.client);
|
|
27304
27440
|
} else if (isLocalAudioTrack(track)) {
|
|
@@ -27314,10 +27450,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27314
27450
|
this.on(ParticipantEvent.LocalTrackSubscribed, pub => {
|
|
27315
27451
|
if (pub.trackSid === ti.sid) {
|
|
27316
27452
|
if (!track.hasPreConnectBuffer) {
|
|
27317
|
-
this.log.warn('subscribe event came to late, buffer already closed'
|
|
27453
|
+
this.log.warn('subscribe event came to late, buffer already closed');
|
|
27318
27454
|
return;
|
|
27319
27455
|
}
|
|
27320
|
-
this.log.debug('finished recording preconnect buffer',
|
|
27456
|
+
this.log.debug('finished recording preconnect buffer', getLogContextFromTrack(track));
|
|
27321
27457
|
track.stopPreConnectBuffer();
|
|
27322
27458
|
}
|
|
27323
27459
|
});
|
|
@@ -27326,13 +27462,13 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27326
27462
|
var _a, e_2, _b, _c;
|
|
27327
27463
|
var _d, _e;
|
|
27328
27464
|
try {
|
|
27329
|
-
this.log.debug('waiting for agent',
|
|
27465
|
+
this.log.debug('waiting for agent', getLogContextFromTrack(track));
|
|
27330
27466
|
const agentActiveTimeout = setTimeout(() => {
|
|
27331
27467
|
reject(new Error('agent not active within 10 seconds'));
|
|
27332
27468
|
}, 10000);
|
|
27333
27469
|
const agent = yield this.waitUntilActiveAgentPresent();
|
|
27334
27470
|
clearTimeout(agentActiveTimeout);
|
|
27335
|
-
this.log.debug('sending preconnect buffer',
|
|
27471
|
+
this.log.debug('sending preconnect buffer', getLogContextFromTrack(track));
|
|
27336
27472
|
const writer = yield this.streamBytes({
|
|
27337
27473
|
name: 'preconnect-buffer',
|
|
27338
27474
|
mimeType,
|
|
@@ -27369,9 +27505,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27369
27505
|
}
|
|
27370
27506
|
}));
|
|
27371
27507
|
bufferStreamPromise.then(() => {
|
|
27372
|
-
this.log.debug('preconnect buffer sent successfully',
|
|
27508
|
+
this.log.debug('preconnect buffer sent successfully', getLogContextFromTrack(track));
|
|
27373
27509
|
}).catch(e => {
|
|
27374
|
-
this.log.error('error sending preconnect buffer', Object.assign(Object.assign(
|
|
27510
|
+
this.log.error('error sending preconnect buffer', Object.assign(Object.assign({}, getLogContextFromTrack(track)), {
|
|
27375
27511
|
error: e
|
|
27376
27512
|
}));
|
|
27377
27513
|
});
|
|
@@ -27412,7 +27548,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27412
27548
|
const opts = Object.assign(Object.assign({}, (_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.publishDefaults), options);
|
|
27413
27549
|
const encodings = computeTrackBackupEncodings(track, videoCodec, opts);
|
|
27414
27550
|
if (!encodings) {
|
|
27415
|
-
this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",
|
|
27551
|
+
this.log.info("backup codec has been disabled, ignoring request to add additional codec for track", getLogContextFromTrack(track));
|
|
27416
27552
|
return;
|
|
27417
27553
|
}
|
|
27418
27554
|
const simulcastTrack = track.addSimulcastTrack(videoCodec, encodings);
|
|
@@ -27440,10 +27576,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27440
27576
|
});
|
|
27441
27577
|
const rets = yield Promise.all([this.engine.addTrack(req), negotiate()]);
|
|
27442
27578
|
const ti = rets[0];
|
|
27443
|
-
this.log.debug("published ".concat(videoCodec, " for track ").concat(track.sid),
|
|
27579
|
+
this.log.debug("published ".concat(videoCodec, " for track ").concat(track.sid), {
|
|
27444
27580
|
encodings,
|
|
27445
27581
|
trackInfo: ti
|
|
27446
|
-
})
|
|
27582
|
+
});
|
|
27447
27583
|
});
|
|
27448
27584
|
}
|
|
27449
27585
|
unpublishTrack(track, stopOnUnpublish) {
|
|
@@ -27452,16 +27588,16 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27452
27588
|
if (isLocalTrack(track)) {
|
|
27453
27589
|
const publishPromise = this.pendingPublishPromises.get(track);
|
|
27454
27590
|
if (publishPromise) {
|
|
27455
|
-
this.log.
|
|
27591
|
+
this.log.debug('awaiting publish promise before attempting to unpublish', getLogContextFromTrack(track));
|
|
27456
27592
|
yield publishPromise;
|
|
27457
27593
|
}
|
|
27458
27594
|
}
|
|
27459
27595
|
// look through all published tracks to find the right ones
|
|
27460
27596
|
const publication = this.getPublicationForTrack(track);
|
|
27461
27597
|
const pubLogContext = publication ? getLogContextFromTrack(publication) : undefined;
|
|
27462
|
-
this.log.
|
|
27598
|
+
this.log.info('unpublishing track', pubLogContext);
|
|
27463
27599
|
if (!publication || !publication.track) {
|
|
27464
|
-
this.log.warn('track was not unpublished because no publication was found',
|
|
27600
|
+
this.log.warn('track was not unpublished because no publication was found', pubLogContext);
|
|
27465
27601
|
return undefined;
|
|
27466
27602
|
}
|
|
27467
27603
|
track = publication.track;
|
|
@@ -27497,7 +27633,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27497
27633
|
try {
|
|
27498
27634
|
negotiationNeeded = this.engine.removeTrack(trackSender);
|
|
27499
27635
|
} catch (e) {
|
|
27500
|
-
this.log.warn(e
|
|
27636
|
+
this.log.warn(e);
|
|
27501
27637
|
negotiationNeeded = true;
|
|
27502
27638
|
}
|
|
27503
27639
|
if (isLocalVideoTrack(track)) {
|
|
@@ -27506,7 +27642,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27506
27642
|
try {
|
|
27507
27643
|
negotiationNeeded = this.engine.removeTrack(trackInfo.sender);
|
|
27508
27644
|
} catch (e) {
|
|
27509
|
-
this.log.warn(e
|
|
27645
|
+
this.log.warn(e);
|
|
27510
27646
|
negotiationNeeded = true;
|
|
27511
27647
|
}
|
|
27512
27648
|
trackInfo.sender = undefined;
|
|
@@ -27515,7 +27651,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27515
27651
|
track.simulcastCodecs.clear();
|
|
27516
27652
|
}
|
|
27517
27653
|
} catch (e) {
|
|
27518
|
-
this.log.warn('failed to unpublish track', Object.assign(Object.assign(
|
|
27654
|
+
this.log.warn('failed to unpublish track', Object.assign(Object.assign({}, pubLogContext), {
|
|
27519
27655
|
error: e
|
|
27520
27656
|
}));
|
|
27521
27657
|
}
|
|
@@ -27569,9 +27705,9 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27569
27705
|
if (restartTracks && !track.isMuted && track.source !== Track.Source.ScreenShare && track.source !== Track.Source.ScreenShareAudio && (isLocalAudioTrack(track) || isLocalVideoTrack(track)) && !track.isUserProvided) {
|
|
27570
27706
|
// generally we need to restart the track before publishing, often a full reconnect
|
|
27571
27707
|
// is necessary because computer had gone to sleep.
|
|
27572
|
-
this.log.debug('restarting existing track',
|
|
27708
|
+
this.log.debug('restarting existing track', {
|
|
27573
27709
|
track: pub.trackSid
|
|
27574
|
-
})
|
|
27710
|
+
});
|
|
27575
27711
|
yield track.restartTrack();
|
|
27576
27712
|
}
|
|
27577
27713
|
yield this.publishOrRepublishTrack(track, pub.options, true);
|
|
@@ -27912,7 +28048,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
|
27912
28048
|
if (pub) {
|
|
27913
28049
|
const mutedOnServer = pub.isMuted || ((_b = (_a = pub.track) === null || _a === void 0 ? void 0 : _a.isUpstreamPaused) !== null && _b !== void 0 ? _b : false);
|
|
27914
28050
|
if (mutedOnServer !== ti.muted) {
|
|
27915
|
-
this.log.debug('updating server mute state after reconcile', Object.assign(Object.assign(
|
|
28051
|
+
this.log.debug('updating server mute state after reconcile', Object.assign(Object.assign({}, getLogContextFromTrack(pub)), {
|
|
27916
28052
|
mutedOnServer
|
|
27917
28053
|
}));
|
|
27918
28054
|
this.engine.client.sendMuteTrack(ti.sid, mutedOnServer);
|
|
@@ -28696,7 +28832,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28696
28832
|
const unlockDisconnect = yield this.disconnectLock.lock();
|
|
28697
28833
|
if (this.state === ConnectionState.Connected) {
|
|
28698
28834
|
// when the state is reconnecting or connected, this function returns immediately
|
|
28699
|
-
this.log.info("already connected to room ".concat(this.name)
|
|
28835
|
+
this.log.info("already connected to room ".concat(this.name));
|
|
28700
28836
|
unlockDisconnect();
|
|
28701
28837
|
return Promise.resolve();
|
|
28702
28838
|
}
|
|
@@ -28722,9 +28858,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28722
28858
|
var _a;
|
|
28723
28859
|
(_a = this.regionUrlProvider) === null || _a === void 0 ? void 0 : _a.setServerReportedRegions(settings);
|
|
28724
28860
|
}).catch(e => {
|
|
28725
|
-
this.log.warn('could not fetch region settings',
|
|
28861
|
+
this.log.warn('could not fetch region settings', {
|
|
28726
28862
|
error: e
|
|
28727
|
-
})
|
|
28863
|
+
});
|
|
28728
28864
|
});
|
|
28729
28865
|
}
|
|
28730
28866
|
const connectFn = (resolve, reject, regionUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -28765,7 +28901,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28765
28901
|
BackOffStrategy.getInstance().addFailedConnectionAttempt(url);
|
|
28766
28902
|
}
|
|
28767
28903
|
if (nextUrl && !((_b = this.abortController) === null || _b === void 0 ? void 0 : _b.signal.aborted)) {
|
|
28768
|
-
this.log.info("Initial connection failed with ConnectionError: ".concat(error.message, ". Retrying with another region: ").concat(nextUrl)
|
|
28904
|
+
this.log.info("Initial connection failed with ConnectionError: ".concat(error.message, ". Retrying with another region: ").concat(nextUrl));
|
|
28769
28905
|
this.recreateEngine(true);
|
|
28770
28906
|
yield connectFn(resolve, reject, nextUrl);
|
|
28771
28907
|
} else {
|
|
@@ -28807,7 +28943,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28807
28943
|
throw new UnsupportedServer('unknown server version');
|
|
28808
28944
|
}
|
|
28809
28945
|
if (serverInfo.version === '0.15.1' && this.options.dynacast) {
|
|
28810
|
-
this.log.debug('disabling dynacast due to server version'
|
|
28946
|
+
this.log.debug('disabling dynacast due to server version');
|
|
28811
28947
|
// dynacast has a bug in 0.15.1, so we cannot use it then
|
|
28812
28948
|
roomOptions.dynacast = false;
|
|
28813
28949
|
}
|
|
@@ -28822,9 +28958,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28822
28958
|
try {
|
|
28823
28959
|
this.e2eeManager.setSifTrailer(joinResponse.sifTrailer);
|
|
28824
28960
|
} catch (e) {
|
|
28825
|
-
this.log.error(e instanceof Error ? e.message : 'Could not set SifTrailer',
|
|
28961
|
+
this.log.error(e instanceof Error ? e.message : 'Could not set SifTrailer', {
|
|
28826
28962
|
error: e
|
|
28827
|
-
})
|
|
28963
|
+
});
|
|
28828
28964
|
}
|
|
28829
28965
|
}
|
|
28830
28966
|
// populate remote participants, these should not trigger new events
|
|
@@ -28836,7 +28972,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28836
28972
|
this.attemptConnection = (url, token, opts, abortController) => __awaiter(this, void 0, void 0, function* () {
|
|
28837
28973
|
var _a, _b;
|
|
28838
28974
|
if (this.state === ConnectionState.Reconnecting || this.isResuming || ((_a = this.engine) === null || _a === void 0 ? void 0 : _a.pendingReconnect)) {
|
|
28839
|
-
this.log.info('Reconnection attempt replaced by new connection attempt'
|
|
28975
|
+
this.log.info('Reconnection attempt replaced by new connection attempt');
|
|
28840
28976
|
// make sure we close and recreate the existing engine in order to get rid of any potentially ongoing reconnection attempts
|
|
28841
28977
|
this.recreateEngine(true);
|
|
28842
28978
|
} else {
|
|
@@ -28871,9 +29007,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28871
29007
|
resultingError.reason = err.reason;
|
|
28872
29008
|
resultingError.status = err.status;
|
|
28873
29009
|
}
|
|
28874
|
-
this.log.debug("error trying to establish signal connection",
|
|
29010
|
+
this.log.debug("error trying to establish signal connection", {
|
|
28875
29011
|
error: err
|
|
28876
|
-
})
|
|
29012
|
+
});
|
|
28877
29013
|
throw resultingError;
|
|
28878
29014
|
}
|
|
28879
29015
|
if (abortController.signal.aborted) {
|
|
@@ -28921,14 +29057,14 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28921
29057
|
const unlock = yield _this2.disconnectLock.lock();
|
|
28922
29058
|
try {
|
|
28923
29059
|
if (_this2.state === ConnectionState.Disconnected) {
|
|
28924
|
-
_this2.log.debug('already disconnected'
|
|
29060
|
+
_this2.log.debug('already disconnected');
|
|
28925
29061
|
return;
|
|
28926
29062
|
}
|
|
28927
|
-
_this2.log.info('disconnect from room'
|
|
29063
|
+
_this2.log.info('disconnect from room');
|
|
28928
29064
|
if (_this2.state === ConnectionState.Connecting || _this2.state === ConnectionState.Reconnecting || _this2.isResuming) {
|
|
28929
29065
|
// try aborting pending connection attempt
|
|
28930
29066
|
const msg = 'Abort connection attempt due to user initiated disconnect';
|
|
28931
|
-
_this2.log.warn(msg
|
|
29067
|
+
_this2.log.warn(msg);
|
|
28932
29068
|
(_a = _this2.abortController) === null || _a === void 0 ? void 0 : _a.abort(msg);
|
|
28933
29069
|
// in case the abort controller didn't manage to cancel the connection attempt, reject the connect promise explicitly
|
|
28934
29070
|
(_c = (_b = _this2.connectFuture) === null || _b === void 0 ? void 0 : _b.reject) === null || _c === void 0 ? void 0 : _c.call(_b, ConnectionError.cancelled('Client initiated disconnect'));
|
|
@@ -28952,7 +29088,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28952
29088
|
});
|
|
28953
29089
|
};
|
|
28954
29090
|
this.onPageLeave = () => __awaiter(this, void 0, void 0, function* () {
|
|
28955
|
-
this.log.info('Page leave detected, disconnecting'
|
|
29091
|
+
this.log.info('Page leave detected, disconnecting');
|
|
28956
29092
|
yield this.disconnect();
|
|
28957
29093
|
});
|
|
28958
29094
|
/**
|
|
@@ -28992,7 +29128,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
28992
29128
|
// set the srcObject to null on page hide in order to prevent lock screen controls to show up for it
|
|
28993
29129
|
dummyAudioEl.srcObject = document.hidden ? null : stream;
|
|
28994
29130
|
if (!document.hidden) {
|
|
28995
|
-
this.log.debug('page visible again, triggering startAudio to resume playback and update playback status'
|
|
29131
|
+
this.log.debug('page visible again, triggering startAudio to resume playback and update playback status');
|
|
28996
29132
|
this.startAudio();
|
|
28997
29133
|
}
|
|
28998
29134
|
});
|
|
@@ -29042,7 +29178,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29042
29178
|
if (e.name === 'NotAllowedError') {
|
|
29043
29179
|
this.handleVideoPlaybackFailed();
|
|
29044
29180
|
} else {
|
|
29045
|
-
this.log.warn('Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler'
|
|
29181
|
+
this.log.warn('Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler');
|
|
29046
29182
|
}
|
|
29047
29183
|
});
|
|
29048
29184
|
});
|
|
@@ -29063,24 +29199,24 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29063
29199
|
this.incomingDataTrackManager.resendSubscriptionUpdates();
|
|
29064
29200
|
};
|
|
29065
29201
|
this.handleSignalRestarted = joinResponse => __awaiter(this, void 0, void 0, function* () {
|
|
29066
|
-
this.log.debug("signal reconnected to server, region ".concat(joinResponse.serverRegion),
|
|
29202
|
+
this.log.debug("signal reconnected to server, region ".concat(joinResponse.serverRegion), {
|
|
29067
29203
|
region: joinResponse.serverRegion
|
|
29068
|
-
})
|
|
29204
|
+
});
|
|
29069
29205
|
this.bufferedEvents = [];
|
|
29070
29206
|
this.applyJoinResponse(joinResponse);
|
|
29071
29207
|
try {
|
|
29072
29208
|
// unpublish & republish tracks
|
|
29073
29209
|
yield this.localParticipant.republishAllTracks(undefined, true);
|
|
29074
29210
|
} catch (error) {
|
|
29075
|
-
this.log.error('error trying to re-publish tracks after reconnection',
|
|
29211
|
+
this.log.error('error trying to re-publish tracks after reconnection', {
|
|
29076
29212
|
error
|
|
29077
|
-
})
|
|
29213
|
+
});
|
|
29078
29214
|
}
|
|
29079
29215
|
try {
|
|
29080
29216
|
yield this.engine.waitForRestarted();
|
|
29081
|
-
this.log.debug("fully reconnected to server",
|
|
29217
|
+
this.log.debug("fully reconnected to server", {
|
|
29082
29218
|
region: joinResponse.serverRegion
|
|
29083
|
-
})
|
|
29219
|
+
});
|
|
29084
29220
|
} catch (_a) {
|
|
29085
29221
|
// reconnection failed, handleDisconnect is being invoked already, just return here
|
|
29086
29222
|
return;
|
|
@@ -29279,9 +29415,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29279
29415
|
this.emit(RoomEvent.AudioPlaybackStatusChanged, true);
|
|
29280
29416
|
};
|
|
29281
29417
|
this.handleAudioPlaybackFailed = e => {
|
|
29282
|
-
this.log.warn('could not playback audio',
|
|
29418
|
+
this.log.warn('could not playback audio', {
|
|
29283
29419
|
error: e
|
|
29284
|
-
})
|
|
29420
|
+
});
|
|
29285
29421
|
if (!this.canPlaybackAudio) {
|
|
29286
29422
|
return;
|
|
29287
29423
|
}
|
|
@@ -29378,7 +29514,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29378
29514
|
const deviceId = yield track.getDeviceId(false);
|
|
29379
29515
|
const deviceKind = sourceToKind(track.source);
|
|
29380
29516
|
if (deviceKind && deviceId && deviceId !== this.localParticipant.activeDeviceMap.get(deviceKind)) {
|
|
29381
|
-
this.log.debug("local track restarted, setting ".concat(deviceKind, " ").concat(deviceId, " active")
|
|
29517
|
+
this.log.debug("local track restarted, setting ".concat(deviceKind, " ").concat(deviceId, " active"));
|
|
29382
29518
|
this.localParticipant.activeDeviceMap.set(deviceKind, deviceId);
|
|
29383
29519
|
this.emit(RoomEvent.ActiveDeviceChanged, deviceKind, deviceId);
|
|
29384
29520
|
}
|
|
@@ -29399,7 +29535,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29399
29535
|
this.remoteParticipants = new Map();
|
|
29400
29536
|
this.sidToIdentity = new Map();
|
|
29401
29537
|
this.options = Object.assign(Object.assign({}, roomOptionDefaults), options);
|
|
29402
|
-
this.log = getLogger((_a = this.options.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Room);
|
|
29538
|
+
this.log = getLogger((_a = this.options.loggerName) !== null && _a !== void 0 ? _a : LoggerNames.Room, () => this.logContext);
|
|
29403
29539
|
this.transcriptionReceivedTimes = new Map();
|
|
29404
29540
|
this.options.audioCaptureDefaults = Object.assign(Object.assign({}, audioDefaults), options === null || options === void 0 ? void 0 : options.audioCaptureDefaults);
|
|
29405
29541
|
this.options.videoCaptureDefaults = Object.assign(Object.assign({}, videoDefaults), options === null || options === void 0 ? void 0 : options.videoCaptureDefaults);
|
|
@@ -29442,9 +29578,10 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29442
29578
|
this.emit(RoomEvent.LocalDataTrackUnpublished, event.sid);
|
|
29443
29579
|
}).on('packetAvailable', _ref => {
|
|
29444
29580
|
let {
|
|
29581
|
+
handle,
|
|
29445
29582
|
bytes
|
|
29446
29583
|
} = _ref;
|
|
29447
|
-
this.engine.sendLossyBytes(bytes, DataChannelKind.DATA_TRACK_LOSSY, 'wait');
|
|
29584
|
+
this.engine.sendLossyBytes(bytes, DataChannelKind.DATA_TRACK_LOSSY, 'wait').finally(() => this.outgoingDataTrackManager.handlePacketSendComplete(handle));
|
|
29448
29585
|
});
|
|
29449
29586
|
this.disconnectLock = new _();
|
|
29450
29587
|
this.localParticipant = new LocalParticipant('', '', this.engine, this.options, this.rpcHandlers, this.outgoingDataStreamManager, this.outgoingDataTrackManager);
|
|
@@ -29461,7 +29598,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29461
29598
|
this.localParticipant.activeDeviceMap.set('audioinput', unwrapConstraint(this.options.audioCaptureDefaults.deviceId));
|
|
29462
29599
|
}
|
|
29463
29600
|
if ((_d = this.options.audioOutput) === null || _d === void 0 ? void 0 : _d.deviceId) {
|
|
29464
|
-
this.switchActiveDevice('audiooutput', unwrapConstraint(this.options.audioOutput.deviceId)).catch(e => this.log.warn("Could not set audio output: ".concat(e.message)
|
|
29601
|
+
this.switchActiveDevice('audiooutput', unwrapConstraint(this.options.audioOutput.deviceId)).catch(e => this.log.warn("Could not set audio output: ".concat(e.message)));
|
|
29465
29602
|
}
|
|
29466
29603
|
if (isWeb()) {
|
|
29467
29604
|
const abortController = new AbortController();
|
|
@@ -29577,12 +29714,12 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29577
29714
|
}
|
|
29578
29715
|
}
|
|
29579
29716
|
get logContext() {
|
|
29580
|
-
var _a;
|
|
29717
|
+
var _a, _b, _c;
|
|
29581
29718
|
return {
|
|
29582
29719
|
room: this.name,
|
|
29583
29720
|
roomID: (_a = this.roomInfo) === null || _a === void 0 ? void 0 : _a.sid,
|
|
29584
|
-
participant: this.localParticipant.identity,
|
|
29585
|
-
participantID: this.localParticipant.sid
|
|
29721
|
+
participant: (_b = this.localParticipant) === null || _b === void 0 ? void 0 : _b.identity,
|
|
29722
|
+
participantID: (_c = this.localParticipant) === null || _c === void 0 ? void 0 : _c.sid
|
|
29586
29723
|
};
|
|
29587
29724
|
}
|
|
29588
29725
|
/**
|
|
@@ -29648,14 +29785,14 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29648
29785
|
}).on(EngineEvent.ActiveSpeakersUpdate, this.handleActiveSpeakersUpdate).on(EngineEvent.DataPacketReceived, this.handleDataPacket).on(EngineEvent.Resuming, () => {
|
|
29649
29786
|
this.clearConnectionReconcile();
|
|
29650
29787
|
this.isResuming = true;
|
|
29651
|
-
this.log.
|
|
29788
|
+
this.log.debug('Resuming signal connection');
|
|
29652
29789
|
if (this.setAndEmitConnectionState(ConnectionState.SignalReconnecting)) {
|
|
29653
29790
|
this.emit(RoomEvent.SignalReconnecting);
|
|
29654
29791
|
}
|
|
29655
29792
|
}).on(EngineEvent.Resumed, () => {
|
|
29656
29793
|
this.registerConnectionReconcile();
|
|
29657
29794
|
this.isResuming = false;
|
|
29658
|
-
this.log.
|
|
29795
|
+
this.log.debug('Resumed signal connection');
|
|
29659
29796
|
this.updateSubscriptions();
|
|
29660
29797
|
this.emitBufferedEvents();
|
|
29661
29798
|
if (this.setAndEmitConnectionState(ConnectionState.Connected)) {
|
|
@@ -29690,7 +29827,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29690
29827
|
}
|
|
29691
29828
|
}).on(EngineEvent.PublishDataTrackResponse, event => {
|
|
29692
29829
|
if (!event.info) {
|
|
29693
|
-
this.log.warn("received PublishDataTrackResponse, but event.info was ".concat(event.info, ", so skipping.")
|
|
29830
|
+
this.log.warn("received PublishDataTrackResponse, but event.info was ".concat(event.info, ", so skipping."));
|
|
29694
29831
|
return;
|
|
29695
29832
|
}
|
|
29696
29833
|
this.outgoingDataTrackManager.receivedSfuPublishResponse(event.info.pubHandle, {
|
|
@@ -29704,7 +29841,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29704
29841
|
});
|
|
29705
29842
|
}).on(EngineEvent.UnPublishDataTrackResponse, event => {
|
|
29706
29843
|
if (!event.info) {
|
|
29707
|
-
this.log.warn("received UnPublishDataTrackResponse, but event.info was ".concat(event.info, ", so skipping.")
|
|
29844
|
+
this.log.warn("received UnPublishDataTrackResponse, but event.info was ".concat(event.info, ", so skipping."));
|
|
29708
29845
|
return;
|
|
29709
29846
|
}
|
|
29710
29847
|
this.outgoingDataTrackManager.receivedSfuUnpublishResponse(event.info.pubHandle);
|
|
@@ -29785,7 +29922,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29785
29922
|
if (this.state !== ConnectionState.Disconnected) {
|
|
29786
29923
|
return;
|
|
29787
29924
|
}
|
|
29788
|
-
this.log.debug("prepareConnection to ".concat(url)
|
|
29925
|
+
this.log.debug("prepareConnection to ".concat(url));
|
|
29789
29926
|
try {
|
|
29790
29927
|
if (isCloud(new URL(url)) && token) {
|
|
29791
29928
|
this.regionUrlProvider = new RegionUrlProvider(url, token);
|
|
@@ -29797,7 +29934,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29797
29934
|
yield fetch(toHttpUrl(regionUrl), {
|
|
29798
29935
|
method: 'HEAD'
|
|
29799
29936
|
});
|
|
29800
|
-
this.log.debug("prepared connection to ".concat(regionUrl)
|
|
29937
|
+
this.log.debug("prepared connection to ".concat(regionUrl));
|
|
29801
29938
|
}
|
|
29802
29939
|
} else {
|
|
29803
29940
|
yield fetch(toHttpUrl(url), {
|
|
@@ -29805,9 +29942,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
29805
29942
|
});
|
|
29806
29943
|
}
|
|
29807
29944
|
} catch (e) {
|
|
29808
|
-
this.log.warn('could not prepare connection',
|
|
29945
|
+
this.log.warn('could not prepare connection', {
|
|
29809
29946
|
error: e
|
|
29810
|
-
})
|
|
29947
|
+
});
|
|
29811
29948
|
}
|
|
29812
29949
|
});
|
|
29813
29950
|
}
|
|
@@ -30106,11 +30243,11 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30106
30243
|
return;
|
|
30107
30244
|
}
|
|
30108
30245
|
if (this.state === ConnectionState.Disconnected) {
|
|
30109
|
-
this.log.warn('skipping incoming track after Room disconnected'
|
|
30246
|
+
this.log.warn('skipping incoming track after Room disconnected');
|
|
30110
30247
|
return;
|
|
30111
30248
|
}
|
|
30112
30249
|
if (mediaTrack.readyState === 'ended') {
|
|
30113
|
-
this.log.
|
|
30250
|
+
this.log.debug('skipping incoming track as it already ended');
|
|
30114
30251
|
return;
|
|
30115
30252
|
}
|
|
30116
30253
|
const parts = unpackStreamId(stream.id);
|
|
@@ -30121,14 +30258,14 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30121
30258
|
// and generates its own track id instead of infer from sdp track id.
|
|
30122
30259
|
if (streamId && streamId.startsWith('TR')) trackId = streamId;
|
|
30123
30260
|
if (participantSid === this.localParticipant.sid) {
|
|
30124
|
-
this.log.warn('tried to create RemoteParticipant for local participant'
|
|
30261
|
+
this.log.warn('tried to create RemoteParticipant for local participant');
|
|
30125
30262
|
return;
|
|
30126
30263
|
}
|
|
30127
30264
|
const participant = Array.from(this.remoteParticipants.values()).find(p => p.sid === participantSid);
|
|
30128
30265
|
if (!participant) {
|
|
30129
30266
|
// server could require extra media sections to accelerate subscription.
|
|
30130
30267
|
if (participantSid.startsWith('PA')) {
|
|
30131
|
-
this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(participantSid)
|
|
30268
|
+
this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(participantSid));
|
|
30132
30269
|
}
|
|
30133
30270
|
return;
|
|
30134
30271
|
}
|
|
@@ -30138,17 +30275,17 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30138
30275
|
if (!trackId.startsWith('TR')) {
|
|
30139
30276
|
const id = this.engine.getTrackIdForReceiver(receiver);
|
|
30140
30277
|
if (!id) {
|
|
30141
|
-
this.log.error("Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ".concat(participantSid)
|
|
30278
|
+
this.log.error("Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ".concat(participantSid));
|
|
30142
30279
|
return;
|
|
30143
30280
|
}
|
|
30144
30281
|
trackId = id;
|
|
30145
30282
|
}
|
|
30146
30283
|
if (!trackId.startsWith('TR')) {
|
|
30147
|
-
this.log.warn("Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ".concat(participantSid, ", streamId: ").concat(streamId, ", trackId: ").concat(trackId),
|
|
30284
|
+
this.log.warn("Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ".concat(participantSid, ", streamId: ").concat(streamId, ", trackId: ").concat(trackId), {
|
|
30148
30285
|
remoteParticipantID: participantSid,
|
|
30149
30286
|
streamId,
|
|
30150
30287
|
trackId
|
|
30151
|
-
})
|
|
30288
|
+
});
|
|
30152
30289
|
}
|
|
30153
30290
|
let adaptiveStreamSettings;
|
|
30154
30291
|
if (this.options.adaptiveStream) {
|
|
@@ -30178,9 +30315,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30178
30315
|
// the track publication may not be registered yet if the server signals
|
|
30179
30316
|
// the subscription before publishTrack has finished adding the publication.
|
|
30180
30317
|
// defer with a timeout until LocalTrackPublished fires for the matching trackSid
|
|
30181
|
-
this.log.debug('deferring LocalTrackSubscribed, publication not yet available',
|
|
30318
|
+
this.log.debug('deferring LocalTrackSubscribed, publication not yet available', {
|
|
30182
30319
|
subscribedSid
|
|
30183
|
-
})
|
|
30320
|
+
});
|
|
30184
30321
|
const TIMEOUT_MS = 10000;
|
|
30185
30322
|
let timer;
|
|
30186
30323
|
const onPublished = pub => {
|
|
@@ -30203,9 +30340,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30203
30340
|
if (pub) {
|
|
30204
30341
|
this.emitLocalTrackSubscribed(pub);
|
|
30205
30342
|
} else {
|
|
30206
|
-
this.log.warn('could not find local track publication for LocalTrackSubscribed event after timeout',
|
|
30343
|
+
this.log.warn('could not find local track publication for LocalTrackSubscribed event after timeout', {
|
|
30207
30344
|
subscribedSid
|
|
30208
|
-
})
|
|
30345
|
+
});
|
|
30209
30346
|
}
|
|
30210
30347
|
}, TIMEOUT_MS);
|
|
30211
30348
|
}
|
|
@@ -30222,6 +30359,8 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30222
30359
|
this.bufferedEvents = [];
|
|
30223
30360
|
this.transcriptionReceivedTimes.clear();
|
|
30224
30361
|
this.incomingDataStreamManager.clearControllers();
|
|
30362
|
+
this.incomingDataTrackManager.reset();
|
|
30363
|
+
this.outgoingDataTrackManager.reset();
|
|
30225
30364
|
if (this.state === ConnectionState.Disconnected) {
|
|
30226
30365
|
return;
|
|
30227
30366
|
}
|
|
@@ -30398,9 +30537,9 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30398
30537
|
try {
|
|
30399
30538
|
yield Promise.race([this.audioContext.resume(), sleep(200)]);
|
|
30400
30539
|
} catch (e) {
|
|
30401
|
-
this.log.warn('Could not resume audio context',
|
|
30540
|
+
this.log.warn('Could not resume audio context', {
|
|
30402
30541
|
error: e
|
|
30403
|
-
})
|
|
30542
|
+
});
|
|
30404
30543
|
}
|
|
30405
30544
|
}
|
|
30406
30545
|
const newContextIsRunning = ((_b = this.audioContext) === null || _b === void 0 ? void 0 : _b.state) === 'running';
|
|
@@ -30428,7 +30567,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30428
30567
|
participant.setAudioContext(this.audioContext);
|
|
30429
30568
|
}
|
|
30430
30569
|
if ((_a = this.options.audioOutput) === null || _a === void 0 ? void 0 : _a.deviceId) {
|
|
30431
|
-
participant.setAudioOutput(this.options.audioOutput).catch(e => this.log.warn("Could not set audio output: ".concat(e.message)
|
|
30570
|
+
participant.setAudioOutput(this.options.audioOutput).catch(e => this.log.warn("Could not set audio output: ".concat(e.message)));
|
|
30432
30571
|
}
|
|
30433
30572
|
return participant;
|
|
30434
30573
|
}
|
|
@@ -30540,13 +30679,13 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30540
30679
|
// transports failed without notifying engine
|
|
30541
30680
|
!this.engine.verifyTransport()) {
|
|
30542
30681
|
consecutiveFailures++;
|
|
30543
|
-
this.log.warn('detected connection state mismatch',
|
|
30682
|
+
this.log.warn('detected connection state mismatch', {
|
|
30544
30683
|
numFailures: consecutiveFailures,
|
|
30545
30684
|
engine: this.engine ? {
|
|
30546
30685
|
closed: this.engine.isClosed,
|
|
30547
30686
|
transportsConnectedOrConnecting: this.engine.verifyTransport()
|
|
30548
30687
|
} : undefined
|
|
30549
|
-
})
|
|
30688
|
+
});
|
|
30550
30689
|
if (consecutiveFailures >= 3) {
|
|
30551
30690
|
this.recreateEngine();
|
|
30552
30691
|
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish, DisconnectReason.STATE_MISMATCH);
|
|
@@ -30566,6 +30705,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30566
30705
|
// unchanged
|
|
30567
30706
|
return false;
|
|
30568
30707
|
}
|
|
30708
|
+
this.log.info("connection state changed: ".concat(this.state, " -> ").concat(state));
|
|
30569
30709
|
this.state = state;
|
|
30570
30710
|
this.incomingDataStreamManager.setConnected(state === ConnectionState.Connected);
|
|
30571
30711
|
this.emit(RoomEvent.ConnectionStateChanged, this.state);
|
|
@@ -30711,15 +30851,15 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30711
30851
|
// only extract logContext from arguments in order to avoid logging the whole object tree
|
|
30712
30852
|
const minimizedArgs = mapArgs(args).filter(arg => arg !== undefined);
|
|
30713
30853
|
if (event === RoomEvent.TrackSubscribed || event === RoomEvent.TrackUnsubscribed) {
|
|
30714
|
-
this.log.trace("subscribe trace: ".concat(event),
|
|
30854
|
+
this.log.trace("subscribe trace: ".concat(event), {
|
|
30715
30855
|
event,
|
|
30716
30856
|
args: minimizedArgs
|
|
30717
|
-
})
|
|
30857
|
+
});
|
|
30718
30858
|
}
|
|
30719
|
-
this.log.debug("room event ".concat(event),
|
|
30859
|
+
this.log.debug("room event ".concat(event), {
|
|
30720
30860
|
event,
|
|
30721
30861
|
args: minimizedArgs
|
|
30722
|
-
})
|
|
30862
|
+
});
|
|
30723
30863
|
}
|
|
30724
30864
|
return super.emit(event, ...args);
|
|
30725
30865
|
}
|