@webex/web-client-media-engine 1.40.7 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +65 -58
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +65 -58
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function _mergeNamespaces(n, m) {
|
|
|
15
15
|
return Object.freeze(n);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/******************************************************************************
|
|
19
19
|
Copyright (c) Microsoft Corporation.
|
|
20
20
|
|
|
21
21
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -328,8 +328,13 @@ var Logger$2 = logger$1$1.exports;
|
|
|
328
328
|
|
|
329
329
|
const DEFAULT_LOGGER_NAME$1 = 'webrtc-core';
|
|
330
330
|
const logger$3 = Logger$2.get(DEFAULT_LOGGER_NAME$1);
|
|
331
|
-
|
|
332
|
-
|
|
331
|
+
Logger$2.useDefaults({
|
|
332
|
+
defaultLevel: Logger$2.DEBUG,
|
|
333
|
+
/* eslint-disable-next-line jsdoc/require-jsdoc */
|
|
334
|
+
formatter: (messages, context) => {
|
|
335
|
+
messages.unshift(`[${context.name}]`);
|
|
336
|
+
},
|
|
337
|
+
});
|
|
333
338
|
|
|
334
339
|
var DeviceKind;
|
|
335
340
|
(function (DeviceKind) {
|
|
@@ -1278,16 +1283,26 @@ class LocalTrack extends EventEmitter$2 {
|
|
|
1278
1283
|
}
|
|
1279
1284
|
return effect;
|
|
1280
1285
|
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Get a copy of the effects Map.
|
|
1288
|
+
*
|
|
1289
|
+
* @returns A copy of the effects map.
|
|
1290
|
+
*/
|
|
1291
|
+
getEffects() {
|
|
1292
|
+
return new Map(this.effects);
|
|
1293
|
+
}
|
|
1281
1294
|
/**
|
|
1282
1295
|
* Cleanup the local microphone track.
|
|
1283
1296
|
*/
|
|
1284
1297
|
disposeEffects() {
|
|
1285
|
-
|
|
1286
|
-
this.effects.
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1298
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
1299
|
+
if (this.effects.size > 0) {
|
|
1300
|
+
yield Promise.all(Array.from(this.effects.values(), (effect) => effect.dispose()));
|
|
1301
|
+
this.effects.clear();
|
|
1302
|
+
this.underlyingStream = this.originalStream;
|
|
1303
|
+
this.emit(LocalTrackEvents.UnderlyingTrackChange);
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1291
1306
|
}
|
|
1292
1307
|
/**
|
|
1293
1308
|
* Apply constraints to the track.
|
|
@@ -5231,8 +5246,15 @@ function getFrameHeightByMaxFs(sourceAspectRatio, requestedMaxFs) {
|
|
|
5231
5246
|
const minNumberRatiosForHeight = sourceAspectRatio[1] / _gcd;
|
|
5232
5247
|
return (Math.floor(Math.sqrt((requestedMaxFs * 16 * 16) / (minNumberRatiosForWidth * minNumberRatiosForHeight))) * minNumberRatiosForHeight);
|
|
5233
5248
|
}
|
|
5234
|
-
function getScaleDownRatio(
|
|
5235
|
-
|
|
5249
|
+
function getScaleDownRatio(sourceWidth, sourceHeight, maxFs, maxWidth, maxHeight) {
|
|
5250
|
+
if (!sourceWidth || !sourceHeight || !maxFs) {
|
|
5251
|
+
return undefined;
|
|
5252
|
+
}
|
|
5253
|
+
let scaleDownRatio = Math.max(sourceHeight / getFrameHeightByMaxFs([sourceWidth, sourceHeight], maxFs), 1.0);
|
|
5254
|
+
if (maxWidth && maxHeight) {
|
|
5255
|
+
scaleDownRatio = Math.max(sourceWidth / maxWidth, sourceHeight / maxHeight, scaleDownRatio);
|
|
5256
|
+
}
|
|
5257
|
+
return scaleDownRatio;
|
|
5236
5258
|
}
|
|
5237
5259
|
function getRecommendedMaxBitrateForFrameSize(requestedMaxFs) {
|
|
5238
5260
|
if (requestedMaxFs < 60) {
|
|
@@ -9056,45 +9078,6 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
9056
9078
|
}
|
|
9057
9079
|
});
|
|
9058
9080
|
}
|
|
9059
|
-
updateSimulcastStreamStates(requestedIdEncodingParamsMap) {
|
|
9060
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9061
|
-
const sendParameters = this.sender.getParameters();
|
|
9062
|
-
sendParameters.encodings.forEach((encoding, index) => {
|
|
9063
|
-
const encodingParams = requestedIdEncodingParamsMap.get(index);
|
|
9064
|
-
encoding.active = Boolean(encodingParams);
|
|
9065
|
-
if (encodingParams) {
|
|
9066
|
-
if (encodingParams.scaleDownRatio >= 1 &&
|
|
9067
|
-
encoding.scaleResolutionDownBy !== encodingParams.scaleDownRatio) {
|
|
9068
|
-
encoding.scaleResolutionDownBy = encodingParams.scaleDownRatio;
|
|
9069
|
-
}
|
|
9070
|
-
if (encodingParams.maxPayloadBitsPerSecond) {
|
|
9071
|
-
encoding.maxBitrate = encodingParams.maxPayloadBitsPerSecond;
|
|
9072
|
-
}
|
|
9073
|
-
}
|
|
9074
|
-
});
|
|
9075
|
-
yield this.sender.setParameters(sendParameters);
|
|
9076
|
-
});
|
|
9077
|
-
}
|
|
9078
|
-
getScaleDownRatio(maxFs, maxWidth, maxHeight) {
|
|
9079
|
-
var _a;
|
|
9080
|
-
if (!maxFs) {
|
|
9081
|
-
return -1;
|
|
9082
|
-
}
|
|
9083
|
-
if (!this.publishedTrack) {
|
|
9084
|
-
return -1;
|
|
9085
|
-
}
|
|
9086
|
-
const setting = (_a = this.publishedTrack) === null || _a === void 0 ? void 0 : _a.underlyingTrack.getSettings();
|
|
9087
|
-
const sourceHeight = setting === null || setting === void 0 ? void 0 : setting.height;
|
|
9088
|
-
const sourceWidth = setting === null || setting === void 0 ? void 0 : setting.width;
|
|
9089
|
-
if (!sourceWidth || !sourceHeight) {
|
|
9090
|
-
return -1;
|
|
9091
|
-
}
|
|
9092
|
-
let scaleDownRatio = getScaleDownRatio([sourceWidth, sourceHeight], sourceHeight, maxFs);
|
|
9093
|
-
if (maxWidth && maxHeight) {
|
|
9094
|
-
scaleDownRatio = Math.max(sourceWidth / maxWidth, sourceHeight / maxHeight, scaleDownRatio);
|
|
9095
|
-
}
|
|
9096
|
-
return scaleDownRatio;
|
|
9097
|
-
}
|
|
9098
9081
|
publishTrack(track) {
|
|
9099
9082
|
return this.replacePublishedTrack(track);
|
|
9100
9083
|
}
|
|
@@ -9109,6 +9092,25 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
9109
9092
|
getStats() {
|
|
9110
9093
|
return this.sender.getStats();
|
|
9111
9094
|
}
|
|
9095
|
+
updateSendParameters(requestedIdEncodingParamsMap) {
|
|
9096
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9097
|
+
const sendParameters = this.sender.getParameters();
|
|
9098
|
+
sendParameters.encodings.forEach((encoding, index) => {
|
|
9099
|
+
const encodingParams = requestedIdEncodingParamsMap.get(index);
|
|
9100
|
+
encoding.active = !!encodingParams;
|
|
9101
|
+
if (encodingParams) {
|
|
9102
|
+
const { maxPayloadBitsPerSecond, scaleDownRatio } = encodingParams;
|
|
9103
|
+
if (maxPayloadBitsPerSecond !== undefined && maxPayloadBitsPerSecond >= 0) {
|
|
9104
|
+
encoding.maxBitrate = maxPayloadBitsPerSecond;
|
|
9105
|
+
}
|
|
9106
|
+
if (scaleDownRatio !== undefined && scaleDownRatio >= 1.0) {
|
|
9107
|
+
encoding.scaleResolutionDownBy = scaleDownRatio;
|
|
9108
|
+
}
|
|
9109
|
+
}
|
|
9110
|
+
});
|
|
9111
|
+
yield this.sender.setParameters(sendParameters);
|
|
9112
|
+
});
|
|
9113
|
+
}
|
|
9112
9114
|
}
|
|
9113
9115
|
|
|
9114
9116
|
class StatsManager {
|
|
@@ -9729,6 +9731,7 @@ logger.setLevel(Logger.DEBUG);
|
|
|
9729
9731
|
function setLogLevel(level) {
|
|
9730
9732
|
logger.setLevel(level);
|
|
9731
9733
|
Logger$1.setLevel(level);
|
|
9734
|
+
Logger$2.setLevel(level);
|
|
9732
9735
|
}
|
|
9733
9736
|
function getLogLevel() {
|
|
9734
9737
|
return logger.getLevel();
|
|
@@ -9736,6 +9739,7 @@ function getLogLevel() {
|
|
|
9736
9739
|
function setLogHandler(logHandler) {
|
|
9737
9740
|
Logger.setHandler(logHandler);
|
|
9738
9741
|
Logger$1.setHandler(logHandler);
|
|
9742
|
+
Logger$2.setHandler(logHandler);
|
|
9739
9743
|
}
|
|
9740
9744
|
|
|
9741
9745
|
function toMediaStreamTrackKind(mediaType) {
|
|
@@ -9953,13 +9957,14 @@ class MultistreamConnection extends EventEmitter {
|
|
|
9953
9957
|
updateRequestedStreams(mediaType, requests) {
|
|
9954
9958
|
const sendTransceiver = this.getSendTransceiverOrThrow(mediaType);
|
|
9955
9959
|
const signaler = this.streamSignalerManager.getEgressStreamSignalerOrThrow(sendTransceiver.mid);
|
|
9960
|
+
const mediaFamily = getMediaFamily(mediaType);
|
|
9956
9961
|
const requestedIdEncodingParamsMap = new Map();
|
|
9957
9962
|
const rsRequests = requests.filter((r) => isValidReceiverSelectedInfo(r.policySpecificInfo));
|
|
9958
9963
|
if (rsRequests.length !== requests.length) {
|
|
9959
9964
|
logger.warn('Ignoring non-receiver-selected requests');
|
|
9960
9965
|
}
|
|
9961
9966
|
rsRequests.forEach(({ ids, policySpecificInfo, codecInfos, maxPayloadBitsPerSecond }) => {
|
|
9962
|
-
var _a, _b, _c;
|
|
9967
|
+
var _a, _b, _c, _d;
|
|
9963
9968
|
if (ids.length > 1) {
|
|
9964
9969
|
throw new Error(`More than a single ID being unexpected/invalid ${ids}`);
|
|
9965
9970
|
}
|
|
@@ -9978,10 +9983,14 @@ class MultistreamConnection extends EventEmitter {
|
|
|
9978
9983
|
if (streamIdsMatched) {
|
|
9979
9984
|
const encodingIndex = signaler.getEncodingIndexForStreamId(id);
|
|
9980
9985
|
if (encodingIndex !== -1) {
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9986
|
+
const encodingParams = { maxPayloadBitsPerSecond };
|
|
9987
|
+
if (mediaFamily === MediaFamily.Video) {
|
|
9988
|
+
const trackSettings = (_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.getSettings();
|
|
9989
|
+
if (trackSettings) {
|
|
9990
|
+
encodingParams.scaleDownRatio = getScaleDownRatio(trackSettings.width, trackSettings.height, (_b = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _b === void 0 ? void 0 : _b.maxFs, (_c = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _c === void 0 ? void 0 : _c.maxWidth, (_d = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _d === void 0 ? void 0 : _d.maxHeight);
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
requestedIdEncodingParamsMap.set(encodingIndex, encodingParams);
|
|
9985
9994
|
}
|
|
9986
9995
|
else {
|
|
9987
9996
|
logger.warn(`${mediaType}: Unable to get encoding index for stream ID: ${JSON.stringify(id)}`);
|
|
@@ -9992,9 +10001,7 @@ class MultistreamConnection extends EventEmitter {
|
|
|
9992
10001
|
}
|
|
9993
10002
|
});
|
|
9994
10003
|
sendTransceiver.setTrackRequested(requestedIdEncodingParamsMap.size > 0);
|
|
9995
|
-
|
|
9996
|
-
sendTransceiver.updateSimulcastStreamStates(requestedIdEncodingParamsMap);
|
|
9997
|
-
}
|
|
10004
|
+
sendTransceiver.updateSendParameters(requestedIdEncodingParamsMap);
|
|
9998
10005
|
}
|
|
9999
10006
|
createDataChannel() {
|
|
10000
10007
|
const dataChannel = this.pc.createDataChannel('datachannel', {});
|