@whereby.com/media 1.24.0 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +53 -24
- package/dist/index.d.cts +18 -4
- package/dist/index.d.mts +18 -4
- package/dist/index.d.ts +18 -4
- package/dist/index.mjs +53 -24
- package/dist/legacy-esm.js +53 -24
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2578,15 +2578,30 @@ const SCREEN_SHARE_SIMULCAST_SETTINGS = {
|
|
|
2578
2578
|
{ scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
|
|
2579
2579
|
],
|
|
2580
2580
|
};
|
|
2581
|
+
const ADDITIONAL_SCREEN_SHARE_SETTINGS = {
|
|
2582
|
+
encodings: [
|
|
2583
|
+
{ scaleResolutionDownBy: 4, dtx: true, maxBitrate: 150000 },
|
|
2584
|
+
{ scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
|
|
2585
|
+
{ scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
|
|
2586
|
+
],
|
|
2587
|
+
};
|
|
2588
|
+
const ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9 = {
|
|
2589
|
+
encodings: [{ scalabilityMode: "L2T2_KEY", dtx: true, maxBitrate: 1500000 }],
|
|
2590
|
+
};
|
|
2581
2591
|
const SCREEN_SHARE_SETTINGS_VP9 = {
|
|
2582
2592
|
encodings: [{ dtx: true }],
|
|
2583
2593
|
};
|
|
2584
|
-
const getMediaSettings = (kind, isScreenShare, features) => {
|
|
2594
|
+
const getMediaSettings = (kind, isScreenShare, features, isSomeoneAlreadyPresenting = false) => {
|
|
2585
2595
|
const { lowDataModeEnabled, simulcastScreenshareOn, lowBandwidth, vp9On } = features;
|
|
2586
2596
|
if (kind === "audio") {
|
|
2587
2597
|
return AUDIO_SETTINGS;
|
|
2588
2598
|
}
|
|
2589
2599
|
if (isScreenShare) {
|
|
2600
|
+
if (isSomeoneAlreadyPresenting) {
|
|
2601
|
+
if (vp9On)
|
|
2602
|
+
return ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9;
|
|
2603
|
+
return ADDITIONAL_SCREEN_SHARE_SETTINGS;
|
|
2604
|
+
}
|
|
2590
2605
|
if (lowBandwidth && !vp9On)
|
|
2591
2606
|
return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
|
|
2592
2607
|
if (vp9On)
|
|
@@ -4882,6 +4897,21 @@ function createVegaConnectionManager(config) {
|
|
|
4882
4897
|
let connectionsToResolve = targetHostList.length;
|
|
4883
4898
|
let hasNotifiedDisconnect = false;
|
|
4884
4899
|
let wasConnected = false;
|
|
4900
|
+
const beforeNetworkPossiblyDownTime = lastNetworkPossiblyDownTime;
|
|
4901
|
+
const handleFailedOrAbortedConnection = () => {
|
|
4902
|
+
var _a;
|
|
4903
|
+
connectionsToResolve--;
|
|
4904
|
+
if (connectionsToResolve === 0 && !hasNotifiedDisconnect) {
|
|
4905
|
+
connectionAttemptInProgress = false;
|
|
4906
|
+
if (hasPendingConnectionAttempt) {
|
|
4907
|
+
setTimeout(connect, 0);
|
|
4908
|
+
}
|
|
4909
|
+
else {
|
|
4910
|
+
(_a = config.onFailed) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
};
|
|
4914
|
+
const timers = [];
|
|
4885
4915
|
targetHostList.forEach(({ host, dc }, index) => {
|
|
4886
4916
|
if (index > 0) {
|
|
4887
4917
|
timeBeforeConnect += timeNextServer;
|
|
@@ -4889,10 +4919,19 @@ function createVegaConnectionManager(config) {
|
|
|
4889
4919
|
timeBeforeConnect = Math.max(timeBeforeConnect, minTimeBeforeConnect);
|
|
4890
4920
|
}
|
|
4891
4921
|
prevTimeBeforeConnectByDC[dc] = timeBeforeConnect;
|
|
4892
|
-
setTimeout(() => {
|
|
4922
|
+
timers.push(setTimeout(() => {
|
|
4893
4923
|
var _a;
|
|
4924
|
+
timers.shift();
|
|
4894
4925
|
if (wasConnected)
|
|
4895
4926
|
return;
|
|
4927
|
+
if (beforeNetworkPossiblyDownTime !== lastNetworkPossiblyDownTime) {
|
|
4928
|
+
handleFailedOrAbortedConnection();
|
|
4929
|
+
timers.forEach((timeoutId) => {
|
|
4930
|
+
clearTimeout(timeoutId);
|
|
4931
|
+
handleFailedOrAbortedConnection();
|
|
4932
|
+
});
|
|
4933
|
+
return;
|
|
4934
|
+
}
|
|
4896
4935
|
const vegaConnection = new VegaConnection(((_a = config.getUrlForHost) === null || _a === void 0 ? void 0 : _a.call(config, host)) || host);
|
|
4897
4936
|
let wasClosed = false;
|
|
4898
4937
|
vegaConnection.on("open", () => {
|
|
@@ -4956,7 +4995,7 @@ function createVegaConnectionManager(config) {
|
|
|
4956
4995
|
}, timeToWaitForEarlyServerClose);
|
|
4957
4996
|
});
|
|
4958
4997
|
vegaConnection.on("close", () => {
|
|
4959
|
-
var _a
|
|
4998
|
+
var _a;
|
|
4960
4999
|
wasClosed = true;
|
|
4961
5000
|
if (vegaConnection === nominatedConnection) {
|
|
4962
5001
|
nominatedConnection = undefined;
|
|
@@ -4964,18 +5003,9 @@ function createVegaConnectionManager(config) {
|
|
|
4964
5003
|
hasNotifiedDisconnect = true;
|
|
4965
5004
|
(_a = config.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
4966
5005
|
}
|
|
4967
|
-
|
|
4968
|
-
if (connectionsToResolve === 0 && !hasNotifiedDisconnect) {
|
|
4969
|
-
connectionAttemptInProgress = false;
|
|
4970
|
-
if (hasPendingConnectionAttempt) {
|
|
4971
|
-
setTimeout(connect, 0);
|
|
4972
|
-
}
|
|
4973
|
-
else {
|
|
4974
|
-
(_b = config.onFailed) === null || _b === void 0 ? void 0 : _b.call(config);
|
|
4975
|
-
}
|
|
4976
|
-
}
|
|
5006
|
+
handleFailedOrAbortedConnection();
|
|
4977
5007
|
});
|
|
4978
|
-
}, timeBeforeConnect);
|
|
5008
|
+
}, timeBeforeConnect));
|
|
4979
5009
|
});
|
|
4980
5010
|
};
|
|
4981
5011
|
updateHostList(config.initialHostList);
|
|
@@ -5706,7 +5736,7 @@ class VegaRtcManager {
|
|
|
5706
5736
|
this._screenVideoProducerPromise = null;
|
|
5707
5737
|
return;
|
|
5708
5738
|
}
|
|
5709
|
-
const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }))), { appData: {
|
|
5739
|
+
const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }), this._getIsSomeoneAlreadyPresenting())), { appData: {
|
|
5710
5740
|
streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
|
|
5711
5741
|
sourceClientId: this._selfId,
|
|
5712
5742
|
screenShare: true,
|
|
@@ -5846,6 +5876,9 @@ class VegaRtcManager {
|
|
|
5846
5876
|
producer.appData.localClosed = true;
|
|
5847
5877
|
producer.close();
|
|
5848
5878
|
}
|
|
5879
|
+
_getIsSomeoneAlreadyPresenting() {
|
|
5880
|
+
return !![...this._clientStates.values()].find((state) => state.hasAcceptedScreenStream && state.screenStream);
|
|
5881
|
+
}
|
|
5849
5882
|
isInitializedWith({ selfId, roomName, isSfu }) {
|
|
5850
5883
|
return this._selfId === selfId && this._room.name === roomName && Boolean(isSfu);
|
|
5851
5884
|
}
|
|
@@ -5875,8 +5908,8 @@ class VegaRtcManager {
|
|
|
5875
5908
|
disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
|
|
5876
5909
|
var _a;
|
|
5877
5910
|
logger$3.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
|
|
5878
|
-
|
|
5879
|
-
|
|
5911
|
+
const clientState = this._clientStates.get(clientIdOrStreamId);
|
|
5912
|
+
if (clientState) {
|
|
5880
5913
|
clientState.hasAcceptedWebcamStream = false;
|
|
5881
5914
|
clientState.hasAcceptedScreenStream = false;
|
|
5882
5915
|
this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
|
|
@@ -6324,13 +6357,13 @@ class VegaRtcManager {
|
|
|
6324
6357
|
this._streamIdToVideoConsumerId.delete(stream.id);
|
|
6325
6358
|
this._streamIdToVideoResolution.delete(stream.id);
|
|
6326
6359
|
if (screenShare) {
|
|
6327
|
-
clientState.screenStream =
|
|
6360
|
+
clientState.screenStream = undefined;
|
|
6328
6361
|
clientState.hasEmittedScreenStream = false;
|
|
6329
|
-
clientState.screenShareStreamId =
|
|
6362
|
+
clientState.screenShareStreamId = undefined;
|
|
6330
6363
|
}
|
|
6331
6364
|
else {
|
|
6332
6365
|
clientState.hasEmittedWebcamStream = false;
|
|
6333
|
-
clientState.camStreamId =
|
|
6366
|
+
clientState.camStreamId = undefined;
|
|
6334
6367
|
}
|
|
6335
6368
|
}
|
|
6336
6369
|
}
|
|
@@ -6396,10 +6429,6 @@ class VegaRtcManager {
|
|
|
6396
6429
|
hasAcceptedScreenStream: false,
|
|
6397
6430
|
hasEmittedWebcamStream: false,
|
|
6398
6431
|
hasEmittedScreenStream: false,
|
|
6399
|
-
webcamStream: null,
|
|
6400
|
-
screenStream: null,
|
|
6401
|
-
screenShareStreamId: null,
|
|
6402
|
-
camStreamId: null,
|
|
6403
6432
|
};
|
|
6404
6433
|
this._clientStates.set(clientId, clientState);
|
|
6405
6434
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -601,7 +601,7 @@ declare const getMediaSettings: (kind: string, isScreenShare: boolean, features:
|
|
|
601
601
|
simulcastScreenshareOn?: boolean;
|
|
602
602
|
lowBandwidth?: boolean;
|
|
603
603
|
vp9On?: boolean;
|
|
604
|
-
}) => {
|
|
604
|
+
}, isSomeoneAlreadyPresenting?: boolean) => {
|
|
605
605
|
encodings: {}[];
|
|
606
606
|
};
|
|
607
607
|
declare const modifyMediaCapabilities: (routerRtpCapabilities: any, features: {
|
|
@@ -1355,6 +1355,19 @@ declare function createVegaConnectionManager(config: {
|
|
|
1355
1355
|
networkIsPossiblyDown: () => void;
|
|
1356
1356
|
};
|
|
1357
1357
|
|
|
1358
|
+
type MediaSteamWhichMayHaveInboundId = MediaStream & {
|
|
1359
|
+
inboundId?: string;
|
|
1360
|
+
};
|
|
1361
|
+
type ClientState = {
|
|
1362
|
+
hasAcceptedWebcamStream: Boolean;
|
|
1363
|
+
hasAcceptedScreenStream: Boolean;
|
|
1364
|
+
hasEmittedWebcamStream: Boolean;
|
|
1365
|
+
hasEmittedScreenStream: Boolean;
|
|
1366
|
+
webcamStream?: MediaSteamWhichMayHaveInboundId;
|
|
1367
|
+
screenStream?: MediaSteamWhichMayHaveInboundId;
|
|
1368
|
+
screenShareStreamId?: string;
|
|
1369
|
+
camStreamId?: string;
|
|
1370
|
+
};
|
|
1358
1371
|
declare class VegaRtcManager implements RtcManager {
|
|
1359
1372
|
_selfId: any;
|
|
1360
1373
|
_room: any;
|
|
@@ -1371,7 +1384,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1371
1384
|
_routerRtpCapabilities: any;
|
|
1372
1385
|
_sendTransport: any;
|
|
1373
1386
|
_receiveTransport: any;
|
|
1374
|
-
_clientStates:
|
|
1387
|
+
_clientStates: Map<string, ClientState>;
|
|
1375
1388
|
_streamIdToVideoConsumerId: any;
|
|
1376
1389
|
_streamIdToVideoResolution: Map<string, {
|
|
1377
1390
|
width: number;
|
|
@@ -1463,6 +1476,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1463
1476
|
_replaceScreenAudioTrack(): Promise<void>;
|
|
1464
1477
|
_sendScreenAudio(track: MediaStreamTrack): Promise<void>;
|
|
1465
1478
|
_stopProducer(producer: any): void;
|
|
1479
|
+
_getIsSomeoneAlreadyPresenting(): boolean;
|
|
1466
1480
|
isInitializedWith({ selfId, roomName, isSfu }: {
|
|
1467
1481
|
selfId: string;
|
|
1468
1482
|
roomName: string;
|
|
@@ -1534,13 +1548,13 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1534
1548
|
}): void;
|
|
1535
1549
|
_consumerClosedCleanup(consumer: any): void;
|
|
1536
1550
|
_syncIncomingStreamsWithPWA(clientId: string): void;
|
|
1537
|
-
_getOrCreateClientState(clientId: string):
|
|
1551
|
+
_getOrCreateClientState(clientId: string): ClientState;
|
|
1538
1552
|
_emitToPWA(eventName: string, data?: any): void;
|
|
1539
1553
|
_emitToSignal(eventName: string, data?: any, callback?: any): void;
|
|
1540
1554
|
shouldAcceptStreamsFromBothSides(): boolean;
|
|
1541
1555
|
setMicAnalyserDebugger(analyserDebugger: any): void;
|
|
1542
1556
|
setMicAnalyserParams(params: any): void;
|
|
1543
|
-
hasClient(clientId: string):
|
|
1557
|
+
hasClient(clientId: string): boolean;
|
|
1544
1558
|
}
|
|
1545
1559
|
|
|
1546
1560
|
declare const EVENTS: Record<string, keyof RtcEvents>;
|
package/dist/index.d.mts
CHANGED
|
@@ -601,7 +601,7 @@ declare const getMediaSettings: (kind: string, isScreenShare: boolean, features:
|
|
|
601
601
|
simulcastScreenshareOn?: boolean;
|
|
602
602
|
lowBandwidth?: boolean;
|
|
603
603
|
vp9On?: boolean;
|
|
604
|
-
}) => {
|
|
604
|
+
}, isSomeoneAlreadyPresenting?: boolean) => {
|
|
605
605
|
encodings: {}[];
|
|
606
606
|
};
|
|
607
607
|
declare const modifyMediaCapabilities: (routerRtpCapabilities: any, features: {
|
|
@@ -1355,6 +1355,19 @@ declare function createVegaConnectionManager(config: {
|
|
|
1355
1355
|
networkIsPossiblyDown: () => void;
|
|
1356
1356
|
};
|
|
1357
1357
|
|
|
1358
|
+
type MediaSteamWhichMayHaveInboundId = MediaStream & {
|
|
1359
|
+
inboundId?: string;
|
|
1360
|
+
};
|
|
1361
|
+
type ClientState = {
|
|
1362
|
+
hasAcceptedWebcamStream: Boolean;
|
|
1363
|
+
hasAcceptedScreenStream: Boolean;
|
|
1364
|
+
hasEmittedWebcamStream: Boolean;
|
|
1365
|
+
hasEmittedScreenStream: Boolean;
|
|
1366
|
+
webcamStream?: MediaSteamWhichMayHaveInboundId;
|
|
1367
|
+
screenStream?: MediaSteamWhichMayHaveInboundId;
|
|
1368
|
+
screenShareStreamId?: string;
|
|
1369
|
+
camStreamId?: string;
|
|
1370
|
+
};
|
|
1358
1371
|
declare class VegaRtcManager implements RtcManager {
|
|
1359
1372
|
_selfId: any;
|
|
1360
1373
|
_room: any;
|
|
@@ -1371,7 +1384,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1371
1384
|
_routerRtpCapabilities: any;
|
|
1372
1385
|
_sendTransport: any;
|
|
1373
1386
|
_receiveTransport: any;
|
|
1374
|
-
_clientStates:
|
|
1387
|
+
_clientStates: Map<string, ClientState>;
|
|
1375
1388
|
_streamIdToVideoConsumerId: any;
|
|
1376
1389
|
_streamIdToVideoResolution: Map<string, {
|
|
1377
1390
|
width: number;
|
|
@@ -1463,6 +1476,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1463
1476
|
_replaceScreenAudioTrack(): Promise<void>;
|
|
1464
1477
|
_sendScreenAudio(track: MediaStreamTrack): Promise<void>;
|
|
1465
1478
|
_stopProducer(producer: any): void;
|
|
1479
|
+
_getIsSomeoneAlreadyPresenting(): boolean;
|
|
1466
1480
|
isInitializedWith({ selfId, roomName, isSfu }: {
|
|
1467
1481
|
selfId: string;
|
|
1468
1482
|
roomName: string;
|
|
@@ -1534,13 +1548,13 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1534
1548
|
}): void;
|
|
1535
1549
|
_consumerClosedCleanup(consumer: any): void;
|
|
1536
1550
|
_syncIncomingStreamsWithPWA(clientId: string): void;
|
|
1537
|
-
_getOrCreateClientState(clientId: string):
|
|
1551
|
+
_getOrCreateClientState(clientId: string): ClientState;
|
|
1538
1552
|
_emitToPWA(eventName: string, data?: any): void;
|
|
1539
1553
|
_emitToSignal(eventName: string, data?: any, callback?: any): void;
|
|
1540
1554
|
shouldAcceptStreamsFromBothSides(): boolean;
|
|
1541
1555
|
setMicAnalyserDebugger(analyserDebugger: any): void;
|
|
1542
1556
|
setMicAnalyserParams(params: any): void;
|
|
1543
|
-
hasClient(clientId: string):
|
|
1557
|
+
hasClient(clientId: string): boolean;
|
|
1544
1558
|
}
|
|
1545
1559
|
|
|
1546
1560
|
declare const EVENTS: Record<string, keyof RtcEvents>;
|
package/dist/index.d.ts
CHANGED
|
@@ -601,7 +601,7 @@ declare const getMediaSettings: (kind: string, isScreenShare: boolean, features:
|
|
|
601
601
|
simulcastScreenshareOn?: boolean;
|
|
602
602
|
lowBandwidth?: boolean;
|
|
603
603
|
vp9On?: boolean;
|
|
604
|
-
}) => {
|
|
604
|
+
}, isSomeoneAlreadyPresenting?: boolean) => {
|
|
605
605
|
encodings: {}[];
|
|
606
606
|
};
|
|
607
607
|
declare const modifyMediaCapabilities: (routerRtpCapabilities: any, features: {
|
|
@@ -1355,6 +1355,19 @@ declare function createVegaConnectionManager(config: {
|
|
|
1355
1355
|
networkIsPossiblyDown: () => void;
|
|
1356
1356
|
};
|
|
1357
1357
|
|
|
1358
|
+
type MediaSteamWhichMayHaveInboundId = MediaStream & {
|
|
1359
|
+
inboundId?: string;
|
|
1360
|
+
};
|
|
1361
|
+
type ClientState = {
|
|
1362
|
+
hasAcceptedWebcamStream: Boolean;
|
|
1363
|
+
hasAcceptedScreenStream: Boolean;
|
|
1364
|
+
hasEmittedWebcamStream: Boolean;
|
|
1365
|
+
hasEmittedScreenStream: Boolean;
|
|
1366
|
+
webcamStream?: MediaSteamWhichMayHaveInboundId;
|
|
1367
|
+
screenStream?: MediaSteamWhichMayHaveInboundId;
|
|
1368
|
+
screenShareStreamId?: string;
|
|
1369
|
+
camStreamId?: string;
|
|
1370
|
+
};
|
|
1358
1371
|
declare class VegaRtcManager implements RtcManager {
|
|
1359
1372
|
_selfId: any;
|
|
1360
1373
|
_room: any;
|
|
@@ -1371,7 +1384,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1371
1384
|
_routerRtpCapabilities: any;
|
|
1372
1385
|
_sendTransport: any;
|
|
1373
1386
|
_receiveTransport: any;
|
|
1374
|
-
_clientStates:
|
|
1387
|
+
_clientStates: Map<string, ClientState>;
|
|
1375
1388
|
_streamIdToVideoConsumerId: any;
|
|
1376
1389
|
_streamIdToVideoResolution: Map<string, {
|
|
1377
1390
|
width: number;
|
|
@@ -1463,6 +1476,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1463
1476
|
_replaceScreenAudioTrack(): Promise<void>;
|
|
1464
1477
|
_sendScreenAudio(track: MediaStreamTrack): Promise<void>;
|
|
1465
1478
|
_stopProducer(producer: any): void;
|
|
1479
|
+
_getIsSomeoneAlreadyPresenting(): boolean;
|
|
1466
1480
|
isInitializedWith({ selfId, roomName, isSfu }: {
|
|
1467
1481
|
selfId: string;
|
|
1468
1482
|
roomName: string;
|
|
@@ -1534,13 +1548,13 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1534
1548
|
}): void;
|
|
1535
1549
|
_consumerClosedCleanup(consumer: any): void;
|
|
1536
1550
|
_syncIncomingStreamsWithPWA(clientId: string): void;
|
|
1537
|
-
_getOrCreateClientState(clientId: string):
|
|
1551
|
+
_getOrCreateClientState(clientId: string): ClientState;
|
|
1538
1552
|
_emitToPWA(eventName: string, data?: any): void;
|
|
1539
1553
|
_emitToSignal(eventName: string, data?: any, callback?: any): void;
|
|
1540
1554
|
shouldAcceptStreamsFromBothSides(): boolean;
|
|
1541
1555
|
setMicAnalyserDebugger(analyserDebugger: any): void;
|
|
1542
1556
|
setMicAnalyserParams(params: any): void;
|
|
1543
|
-
hasClient(clientId: string):
|
|
1557
|
+
hasClient(clientId: string): boolean;
|
|
1544
1558
|
}
|
|
1545
1559
|
|
|
1546
1560
|
declare const EVENTS: Record<string, keyof RtcEvents>;
|
package/dist/index.mjs
CHANGED
|
@@ -2553,15 +2553,30 @@ const SCREEN_SHARE_SIMULCAST_SETTINGS = {
|
|
|
2553
2553
|
{ scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
|
|
2554
2554
|
],
|
|
2555
2555
|
};
|
|
2556
|
+
const ADDITIONAL_SCREEN_SHARE_SETTINGS = {
|
|
2557
|
+
encodings: [
|
|
2558
|
+
{ scaleResolutionDownBy: 4, dtx: true, maxBitrate: 150000 },
|
|
2559
|
+
{ scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
|
|
2560
|
+
{ scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
|
|
2561
|
+
],
|
|
2562
|
+
};
|
|
2563
|
+
const ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9 = {
|
|
2564
|
+
encodings: [{ scalabilityMode: "L2T2_KEY", dtx: true, maxBitrate: 1500000 }],
|
|
2565
|
+
};
|
|
2556
2566
|
const SCREEN_SHARE_SETTINGS_VP9 = {
|
|
2557
2567
|
encodings: [{ dtx: true }],
|
|
2558
2568
|
};
|
|
2559
|
-
const getMediaSettings = (kind, isScreenShare, features) => {
|
|
2569
|
+
const getMediaSettings = (kind, isScreenShare, features, isSomeoneAlreadyPresenting = false) => {
|
|
2560
2570
|
const { lowDataModeEnabled, simulcastScreenshareOn, lowBandwidth, vp9On } = features;
|
|
2561
2571
|
if (kind === "audio") {
|
|
2562
2572
|
return AUDIO_SETTINGS;
|
|
2563
2573
|
}
|
|
2564
2574
|
if (isScreenShare) {
|
|
2575
|
+
if (isSomeoneAlreadyPresenting) {
|
|
2576
|
+
if (vp9On)
|
|
2577
|
+
return ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9;
|
|
2578
|
+
return ADDITIONAL_SCREEN_SHARE_SETTINGS;
|
|
2579
|
+
}
|
|
2565
2580
|
if (lowBandwidth && !vp9On)
|
|
2566
2581
|
return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
|
|
2567
2582
|
if (vp9On)
|
|
@@ -4857,6 +4872,21 @@ function createVegaConnectionManager(config) {
|
|
|
4857
4872
|
let connectionsToResolve = targetHostList.length;
|
|
4858
4873
|
let hasNotifiedDisconnect = false;
|
|
4859
4874
|
let wasConnected = false;
|
|
4875
|
+
const beforeNetworkPossiblyDownTime = lastNetworkPossiblyDownTime;
|
|
4876
|
+
const handleFailedOrAbortedConnection = () => {
|
|
4877
|
+
var _a;
|
|
4878
|
+
connectionsToResolve--;
|
|
4879
|
+
if (connectionsToResolve === 0 && !hasNotifiedDisconnect) {
|
|
4880
|
+
connectionAttemptInProgress = false;
|
|
4881
|
+
if (hasPendingConnectionAttempt) {
|
|
4882
|
+
setTimeout(connect, 0);
|
|
4883
|
+
}
|
|
4884
|
+
else {
|
|
4885
|
+
(_a = config.onFailed) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
};
|
|
4889
|
+
const timers = [];
|
|
4860
4890
|
targetHostList.forEach(({ host, dc }, index) => {
|
|
4861
4891
|
if (index > 0) {
|
|
4862
4892
|
timeBeforeConnect += timeNextServer;
|
|
@@ -4864,10 +4894,19 @@ function createVegaConnectionManager(config) {
|
|
|
4864
4894
|
timeBeforeConnect = Math.max(timeBeforeConnect, minTimeBeforeConnect);
|
|
4865
4895
|
}
|
|
4866
4896
|
prevTimeBeforeConnectByDC[dc] = timeBeforeConnect;
|
|
4867
|
-
setTimeout(() => {
|
|
4897
|
+
timers.push(setTimeout(() => {
|
|
4868
4898
|
var _a;
|
|
4899
|
+
timers.shift();
|
|
4869
4900
|
if (wasConnected)
|
|
4870
4901
|
return;
|
|
4902
|
+
if (beforeNetworkPossiblyDownTime !== lastNetworkPossiblyDownTime) {
|
|
4903
|
+
handleFailedOrAbortedConnection();
|
|
4904
|
+
timers.forEach((timeoutId) => {
|
|
4905
|
+
clearTimeout(timeoutId);
|
|
4906
|
+
handleFailedOrAbortedConnection();
|
|
4907
|
+
});
|
|
4908
|
+
return;
|
|
4909
|
+
}
|
|
4871
4910
|
const vegaConnection = new VegaConnection(((_a = config.getUrlForHost) === null || _a === void 0 ? void 0 : _a.call(config, host)) || host);
|
|
4872
4911
|
let wasClosed = false;
|
|
4873
4912
|
vegaConnection.on("open", () => {
|
|
@@ -4931,7 +4970,7 @@ function createVegaConnectionManager(config) {
|
|
|
4931
4970
|
}, timeToWaitForEarlyServerClose);
|
|
4932
4971
|
});
|
|
4933
4972
|
vegaConnection.on("close", () => {
|
|
4934
|
-
var _a
|
|
4973
|
+
var _a;
|
|
4935
4974
|
wasClosed = true;
|
|
4936
4975
|
if (vegaConnection === nominatedConnection) {
|
|
4937
4976
|
nominatedConnection = undefined;
|
|
@@ -4939,18 +4978,9 @@ function createVegaConnectionManager(config) {
|
|
|
4939
4978
|
hasNotifiedDisconnect = true;
|
|
4940
4979
|
(_a = config.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
4941
4980
|
}
|
|
4942
|
-
|
|
4943
|
-
if (connectionsToResolve === 0 && !hasNotifiedDisconnect) {
|
|
4944
|
-
connectionAttemptInProgress = false;
|
|
4945
|
-
if (hasPendingConnectionAttempt) {
|
|
4946
|
-
setTimeout(connect, 0);
|
|
4947
|
-
}
|
|
4948
|
-
else {
|
|
4949
|
-
(_b = config.onFailed) === null || _b === void 0 ? void 0 : _b.call(config);
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4981
|
+
handleFailedOrAbortedConnection();
|
|
4952
4982
|
});
|
|
4953
|
-
}, timeBeforeConnect);
|
|
4983
|
+
}, timeBeforeConnect));
|
|
4954
4984
|
});
|
|
4955
4985
|
};
|
|
4956
4986
|
updateHostList(config.initialHostList);
|
|
@@ -5681,7 +5711,7 @@ class VegaRtcManager {
|
|
|
5681
5711
|
this._screenVideoProducerPromise = null;
|
|
5682
5712
|
return;
|
|
5683
5713
|
}
|
|
5684
|
-
const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }))), { appData: {
|
|
5714
|
+
const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }), this._getIsSomeoneAlreadyPresenting())), { appData: {
|
|
5685
5715
|
streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
|
|
5686
5716
|
sourceClientId: this._selfId,
|
|
5687
5717
|
screenShare: true,
|
|
@@ -5821,6 +5851,9 @@ class VegaRtcManager {
|
|
|
5821
5851
|
producer.appData.localClosed = true;
|
|
5822
5852
|
producer.close();
|
|
5823
5853
|
}
|
|
5854
|
+
_getIsSomeoneAlreadyPresenting() {
|
|
5855
|
+
return !![...this._clientStates.values()].find((state) => state.hasAcceptedScreenStream && state.screenStream);
|
|
5856
|
+
}
|
|
5824
5857
|
isInitializedWith({ selfId, roomName, isSfu }) {
|
|
5825
5858
|
return this._selfId === selfId && this._room.name === roomName && Boolean(isSfu);
|
|
5826
5859
|
}
|
|
@@ -5850,8 +5883,8 @@ class VegaRtcManager {
|
|
|
5850
5883
|
disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
|
|
5851
5884
|
var _a;
|
|
5852
5885
|
logger$3.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
|
|
5853
|
-
|
|
5854
|
-
|
|
5886
|
+
const clientState = this._clientStates.get(clientIdOrStreamId);
|
|
5887
|
+
if (clientState) {
|
|
5855
5888
|
clientState.hasAcceptedWebcamStream = false;
|
|
5856
5889
|
clientState.hasAcceptedScreenStream = false;
|
|
5857
5890
|
this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
|
|
@@ -6299,13 +6332,13 @@ class VegaRtcManager {
|
|
|
6299
6332
|
this._streamIdToVideoConsumerId.delete(stream.id);
|
|
6300
6333
|
this._streamIdToVideoResolution.delete(stream.id);
|
|
6301
6334
|
if (screenShare) {
|
|
6302
|
-
clientState.screenStream =
|
|
6335
|
+
clientState.screenStream = undefined;
|
|
6303
6336
|
clientState.hasEmittedScreenStream = false;
|
|
6304
|
-
clientState.screenShareStreamId =
|
|
6337
|
+
clientState.screenShareStreamId = undefined;
|
|
6305
6338
|
}
|
|
6306
6339
|
else {
|
|
6307
6340
|
clientState.hasEmittedWebcamStream = false;
|
|
6308
|
-
clientState.camStreamId =
|
|
6341
|
+
clientState.camStreamId = undefined;
|
|
6309
6342
|
}
|
|
6310
6343
|
}
|
|
6311
6344
|
}
|
|
@@ -6371,10 +6404,6 @@ class VegaRtcManager {
|
|
|
6371
6404
|
hasAcceptedScreenStream: false,
|
|
6372
6405
|
hasEmittedWebcamStream: false,
|
|
6373
6406
|
hasEmittedScreenStream: false,
|
|
6374
|
-
webcamStream: null,
|
|
6375
|
-
screenStream: null,
|
|
6376
|
-
screenShareStreamId: null,
|
|
6377
|
-
camStreamId: null,
|
|
6378
6407
|
};
|
|
6379
6408
|
this._clientStates.set(clientId, clientState);
|
|
6380
6409
|
}
|
package/dist/legacy-esm.js
CHANGED
|
@@ -2553,15 +2553,30 @@ const SCREEN_SHARE_SIMULCAST_SETTINGS = {
|
|
|
2553
2553
|
{ scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
|
|
2554
2554
|
],
|
|
2555
2555
|
};
|
|
2556
|
+
const ADDITIONAL_SCREEN_SHARE_SETTINGS = {
|
|
2557
|
+
encodings: [
|
|
2558
|
+
{ scaleResolutionDownBy: 4, dtx: true, maxBitrate: 150000 },
|
|
2559
|
+
{ scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
|
|
2560
|
+
{ scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
|
|
2561
|
+
],
|
|
2562
|
+
};
|
|
2563
|
+
const ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9 = {
|
|
2564
|
+
encodings: [{ scalabilityMode: "L2T2_KEY", dtx: true, maxBitrate: 1500000 }],
|
|
2565
|
+
};
|
|
2556
2566
|
const SCREEN_SHARE_SETTINGS_VP9 = {
|
|
2557
2567
|
encodings: [{ dtx: true }],
|
|
2558
2568
|
};
|
|
2559
|
-
const getMediaSettings = (kind, isScreenShare, features) => {
|
|
2569
|
+
const getMediaSettings = (kind, isScreenShare, features, isSomeoneAlreadyPresenting = false) => {
|
|
2560
2570
|
const { lowDataModeEnabled, simulcastScreenshareOn, lowBandwidth, vp9On } = features;
|
|
2561
2571
|
if (kind === "audio") {
|
|
2562
2572
|
return AUDIO_SETTINGS;
|
|
2563
2573
|
}
|
|
2564
2574
|
if (isScreenShare) {
|
|
2575
|
+
if (isSomeoneAlreadyPresenting) {
|
|
2576
|
+
if (vp9On)
|
|
2577
|
+
return ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9;
|
|
2578
|
+
return ADDITIONAL_SCREEN_SHARE_SETTINGS;
|
|
2579
|
+
}
|
|
2565
2580
|
if (lowBandwidth && !vp9On)
|
|
2566
2581
|
return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
|
|
2567
2582
|
if (vp9On)
|
|
@@ -4857,6 +4872,21 @@ function createVegaConnectionManager(config) {
|
|
|
4857
4872
|
let connectionsToResolve = targetHostList.length;
|
|
4858
4873
|
let hasNotifiedDisconnect = false;
|
|
4859
4874
|
let wasConnected = false;
|
|
4875
|
+
const beforeNetworkPossiblyDownTime = lastNetworkPossiblyDownTime;
|
|
4876
|
+
const handleFailedOrAbortedConnection = () => {
|
|
4877
|
+
var _a;
|
|
4878
|
+
connectionsToResolve--;
|
|
4879
|
+
if (connectionsToResolve === 0 && !hasNotifiedDisconnect) {
|
|
4880
|
+
connectionAttemptInProgress = false;
|
|
4881
|
+
if (hasPendingConnectionAttempt) {
|
|
4882
|
+
setTimeout(connect, 0);
|
|
4883
|
+
}
|
|
4884
|
+
else {
|
|
4885
|
+
(_a = config.onFailed) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
};
|
|
4889
|
+
const timers = [];
|
|
4860
4890
|
targetHostList.forEach(({ host, dc }, index) => {
|
|
4861
4891
|
if (index > 0) {
|
|
4862
4892
|
timeBeforeConnect += timeNextServer;
|
|
@@ -4864,10 +4894,19 @@ function createVegaConnectionManager(config) {
|
|
|
4864
4894
|
timeBeforeConnect = Math.max(timeBeforeConnect, minTimeBeforeConnect);
|
|
4865
4895
|
}
|
|
4866
4896
|
prevTimeBeforeConnectByDC[dc] = timeBeforeConnect;
|
|
4867
|
-
setTimeout(() => {
|
|
4897
|
+
timers.push(setTimeout(() => {
|
|
4868
4898
|
var _a;
|
|
4899
|
+
timers.shift();
|
|
4869
4900
|
if (wasConnected)
|
|
4870
4901
|
return;
|
|
4902
|
+
if (beforeNetworkPossiblyDownTime !== lastNetworkPossiblyDownTime) {
|
|
4903
|
+
handleFailedOrAbortedConnection();
|
|
4904
|
+
timers.forEach((timeoutId) => {
|
|
4905
|
+
clearTimeout(timeoutId);
|
|
4906
|
+
handleFailedOrAbortedConnection();
|
|
4907
|
+
});
|
|
4908
|
+
return;
|
|
4909
|
+
}
|
|
4871
4910
|
const vegaConnection = new VegaConnection(((_a = config.getUrlForHost) === null || _a === void 0 ? void 0 : _a.call(config, host)) || host);
|
|
4872
4911
|
let wasClosed = false;
|
|
4873
4912
|
vegaConnection.on("open", () => {
|
|
@@ -4931,7 +4970,7 @@ function createVegaConnectionManager(config) {
|
|
|
4931
4970
|
}, timeToWaitForEarlyServerClose);
|
|
4932
4971
|
});
|
|
4933
4972
|
vegaConnection.on("close", () => {
|
|
4934
|
-
var _a
|
|
4973
|
+
var _a;
|
|
4935
4974
|
wasClosed = true;
|
|
4936
4975
|
if (vegaConnection === nominatedConnection) {
|
|
4937
4976
|
nominatedConnection = undefined;
|
|
@@ -4939,18 +4978,9 @@ function createVegaConnectionManager(config) {
|
|
|
4939
4978
|
hasNotifiedDisconnect = true;
|
|
4940
4979
|
(_a = config.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(config);
|
|
4941
4980
|
}
|
|
4942
|
-
|
|
4943
|
-
if (connectionsToResolve === 0 && !hasNotifiedDisconnect) {
|
|
4944
|
-
connectionAttemptInProgress = false;
|
|
4945
|
-
if (hasPendingConnectionAttempt) {
|
|
4946
|
-
setTimeout(connect, 0);
|
|
4947
|
-
}
|
|
4948
|
-
else {
|
|
4949
|
-
(_b = config.onFailed) === null || _b === void 0 ? void 0 : _b.call(config);
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4981
|
+
handleFailedOrAbortedConnection();
|
|
4952
4982
|
});
|
|
4953
|
-
}, timeBeforeConnect);
|
|
4983
|
+
}, timeBeforeConnect));
|
|
4954
4984
|
});
|
|
4955
4985
|
};
|
|
4956
4986
|
updateHostList(config.initialHostList);
|
|
@@ -5681,7 +5711,7 @@ class VegaRtcManager {
|
|
|
5681
5711
|
this._screenVideoProducerPromise = null;
|
|
5682
5712
|
return;
|
|
5683
5713
|
}
|
|
5684
|
-
const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }))), { appData: {
|
|
5714
|
+
const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }), this._getIsSomeoneAlreadyPresenting())), { appData: {
|
|
5685
5715
|
streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
|
|
5686
5716
|
sourceClientId: this._selfId,
|
|
5687
5717
|
screenShare: true,
|
|
@@ -5821,6 +5851,9 @@ class VegaRtcManager {
|
|
|
5821
5851
|
producer.appData.localClosed = true;
|
|
5822
5852
|
producer.close();
|
|
5823
5853
|
}
|
|
5854
|
+
_getIsSomeoneAlreadyPresenting() {
|
|
5855
|
+
return !![...this._clientStates.values()].find((state) => state.hasAcceptedScreenStream && state.screenStream);
|
|
5856
|
+
}
|
|
5824
5857
|
isInitializedWith({ selfId, roomName, isSfu }) {
|
|
5825
5858
|
return this._selfId === selfId && this._room.name === roomName && Boolean(isSfu);
|
|
5826
5859
|
}
|
|
@@ -5850,8 +5883,8 @@ class VegaRtcManager {
|
|
|
5850
5883
|
disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
|
|
5851
5884
|
var _a;
|
|
5852
5885
|
logger$3.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
|
|
5853
|
-
|
|
5854
|
-
|
|
5886
|
+
const clientState = this._clientStates.get(clientIdOrStreamId);
|
|
5887
|
+
if (clientState) {
|
|
5855
5888
|
clientState.hasAcceptedWebcamStream = false;
|
|
5856
5889
|
clientState.hasAcceptedScreenStream = false;
|
|
5857
5890
|
this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
|
|
@@ -6299,13 +6332,13 @@ class VegaRtcManager {
|
|
|
6299
6332
|
this._streamIdToVideoConsumerId.delete(stream.id);
|
|
6300
6333
|
this._streamIdToVideoResolution.delete(stream.id);
|
|
6301
6334
|
if (screenShare) {
|
|
6302
|
-
clientState.screenStream =
|
|
6335
|
+
clientState.screenStream = undefined;
|
|
6303
6336
|
clientState.hasEmittedScreenStream = false;
|
|
6304
|
-
clientState.screenShareStreamId =
|
|
6337
|
+
clientState.screenShareStreamId = undefined;
|
|
6305
6338
|
}
|
|
6306
6339
|
else {
|
|
6307
6340
|
clientState.hasEmittedWebcamStream = false;
|
|
6308
|
-
clientState.camStreamId =
|
|
6341
|
+
clientState.camStreamId = undefined;
|
|
6309
6342
|
}
|
|
6310
6343
|
}
|
|
6311
6344
|
}
|
|
@@ -6371,10 +6404,6 @@ class VegaRtcManager {
|
|
|
6371
6404
|
hasAcceptedScreenStream: false,
|
|
6372
6405
|
hasEmittedWebcamStream: false,
|
|
6373
6406
|
hasEmittedScreenStream: false,
|
|
6374
|
-
webcamStream: null,
|
|
6375
|
-
screenStream: null,
|
|
6376
|
-
screenShareStreamId: null,
|
|
6377
|
-
camStreamId: null,
|
|
6378
6407
|
};
|
|
6379
6408
|
this._clientStates.set(clientId, clientState);
|
|
6380
6409
|
}
|