@webex/web-client-media-engine 2.0.3 → 2.0.5
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 +91 -94
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +91 -94
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -5130,41 +5130,6 @@ class PeerConnection extends EventEmitter$2 {
|
|
|
5130
5130
|
}
|
|
5131
5131
|
PeerConnection.Events = PeerConnectionEvents;
|
|
5132
5132
|
|
|
5133
|
-
/**
|
|
5134
|
-
* Wait until the given peer connection has finished gathering ICE candidates and, when it has,
|
|
5135
|
-
* return the local description with the candidates.
|
|
5136
|
-
*
|
|
5137
|
-
* @param peerConnection - The PeerConnection to use.
|
|
5138
|
-
* @returns A Promise that resolves with the local description with the ICE candidates in it.
|
|
5139
|
-
*/
|
|
5140
|
-
function getLocalDescriptionWithIceCandidates(peerConnection) {
|
|
5141
|
-
return new Promise((resolve, reject) => {
|
|
5142
|
-
/**
|
|
5143
|
-
* A helper method to retrieve the local description and resolve, if one is found, or reject
|
|
5144
|
-
* with an error if it's not.
|
|
5145
|
-
*/
|
|
5146
|
-
const getLocalDescAndResolve = () => {
|
|
5147
|
-
const localDesc = peerConnection.getLocalDescription();
|
|
5148
|
-
if (localDesc) {
|
|
5149
|
-
resolve(localDesc);
|
|
5150
|
-
}
|
|
5151
|
-
else {
|
|
5152
|
-
reject(new Error('Local description was null'));
|
|
5153
|
-
}
|
|
5154
|
-
};
|
|
5155
|
-
peerConnection.on(PeerConnection.Events.IceGatheringStateChange, (e) => {
|
|
5156
|
-
if (e.target.iceGatheringState === 'complete') {
|
|
5157
|
-
getLocalDescAndResolve();
|
|
5158
|
-
}
|
|
5159
|
-
// TODO(brian): throw an error if we see an error iceGatheringState
|
|
5160
|
-
});
|
|
5161
|
-
// It's possible ICE gathering is already done
|
|
5162
|
-
if (peerConnection.iceGatheringState === 'complete') {
|
|
5163
|
-
getLocalDescAndResolve();
|
|
5164
|
-
}
|
|
5165
|
-
});
|
|
5166
|
-
}
|
|
5167
|
-
|
|
5168
5133
|
var MediaCodecMimeType;
|
|
5169
5134
|
(function (MediaCodecMimeType) {
|
|
5170
5135
|
MediaCodecMimeType["H264"] = "video/H264";
|
|
@@ -9003,6 +8968,59 @@ class ReceiveOnlyTransceiver extends Transceiver {
|
|
|
9003
8968
|
}
|
|
9004
8969
|
ReceiveOnlyTransceiver.rid = '1';
|
|
9005
8970
|
|
|
8971
|
+
function deepCopy(source) {
|
|
8972
|
+
return Array.isArray(source)
|
|
8973
|
+
? source.map((item) => deepCopy(item))
|
|
8974
|
+
: source instanceof Map
|
|
8975
|
+
? new Map(source)
|
|
8976
|
+
: source instanceof Date
|
|
8977
|
+
? new Date(source.getTime())
|
|
8978
|
+
: source && typeof source === 'object'
|
|
8979
|
+
? Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
8980
|
+
Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop));
|
|
8981
|
+
o[prop] = deepCopy(source[prop]);
|
|
8982
|
+
return o;
|
|
8983
|
+
}, Object.create(Object.getPrototypeOf(source)))
|
|
8984
|
+
: source;
|
|
8985
|
+
}
|
|
8986
|
+
|
|
8987
|
+
function matchMlinesInAnswer(parsedOffer, parsedAnswer, streamSignalerManager) {
|
|
8988
|
+
parsedAnswer.session.groups = parsedOffer.session.groups;
|
|
8989
|
+
parsedAnswer.media = parsedOffer.media.map((offerMline) => {
|
|
8990
|
+
if (!offerMline.mid) {
|
|
8991
|
+
throw new Error(`Offer mline is missing MID`);
|
|
8992
|
+
}
|
|
8993
|
+
const answerMline = parsedAnswer.media.find((m) => m.mid === offerMline.mid);
|
|
8994
|
+
if (answerMline) {
|
|
8995
|
+
if (answerMline instanceof AvMediaDescription) {
|
|
8996
|
+
[...answerMline.codecs.values()].forEach((ci) => {
|
|
8997
|
+
ci.fmtParams.set('x-google-start-bitrate', '60000');
|
|
8998
|
+
});
|
|
8999
|
+
}
|
|
9000
|
+
return answerMline;
|
|
9001
|
+
}
|
|
9002
|
+
if (!(offerMline instanceof AvMediaDescription)) {
|
|
9003
|
+
throw new Error(`Answer is missing a non-media mline: ${offerMline.mid}`);
|
|
9004
|
+
}
|
|
9005
|
+
const startingMline = parsedAnswer.avMedia.find((m) => m.type === offerMline.type);
|
|
9006
|
+
if (!startingMline) {
|
|
9007
|
+
throw new Error(`Answer has no mline of type ${offerMline.type}, can't generate synthetic answer mline for mid ${offerMline.mid}`);
|
|
9008
|
+
}
|
|
9009
|
+
const fakeCorrespondingMline = deepCopy(startingMline);
|
|
9010
|
+
fakeCorrespondingMline.mid = offerMline.mid;
|
|
9011
|
+
fakeCorrespondingMline.simulcast = undefined;
|
|
9012
|
+
if (offerMline.direction === 'sendrecv' || offerMline.direction === 'sendonly') {
|
|
9013
|
+
fakeCorrespondingMline.direction = 'recvonly';
|
|
9014
|
+
}
|
|
9015
|
+
if (offerMline.direction === 'recvonly') {
|
|
9016
|
+
fakeCorrespondingMline.direction = 'sendonly';
|
|
9017
|
+
const ingressSignaler = streamSignalerManager.getIngressStreamSignalerOrThrow(offerMline.mid);
|
|
9018
|
+
ingressSignaler.signalRemoteStreams(fakeCorrespondingMline);
|
|
9019
|
+
}
|
|
9020
|
+
return fakeCorrespondingMline;
|
|
9021
|
+
});
|
|
9022
|
+
}
|
|
9023
|
+
|
|
9006
9024
|
class JmpLine extends Line {
|
|
9007
9025
|
constructor(versions) {
|
|
9008
9026
|
super();
|
|
@@ -9067,22 +9085,6 @@ DefaultSdpGrammar.addParser('a', JmpLine.fromSdpLine);
|
|
|
9067
9085
|
DefaultSdpGrammar.addParser('a', JmpSourceLine.fromSdpLine);
|
|
9068
9086
|
DefaultSdpGrammar.addParser('a', JmpStreamIdModeLine.fromSdpLine);
|
|
9069
9087
|
|
|
9070
|
-
function deepCopy(source) {
|
|
9071
|
-
return Array.isArray(source)
|
|
9072
|
-
? source.map((item) => deepCopy(item))
|
|
9073
|
-
: source instanceof Map
|
|
9074
|
-
? new Map(source)
|
|
9075
|
-
: source instanceof Date
|
|
9076
|
-
? new Date(source.getTime())
|
|
9077
|
-
: source && typeof source === 'object'
|
|
9078
|
-
? Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
9079
|
-
Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop));
|
|
9080
|
-
o[prop] = deepCopy(source[prop]);
|
|
9081
|
-
return o;
|
|
9082
|
-
}, Object.create(Object.getPrototypeOf(source)))
|
|
9083
|
-
: source;
|
|
9084
|
-
}
|
|
9085
|
-
|
|
9086
9088
|
function getMediaTypeForMline(mLine) {
|
|
9087
9089
|
var _a, _b;
|
|
9088
9090
|
let mediaFamily;
|
|
@@ -9152,42 +9154,6 @@ function filterRecvOnlyMlines(parsedSdp) {
|
|
|
9152
9154
|
g.mids = g.mids.filter((m) => filteredMids.includes(m));
|
|
9153
9155
|
});
|
|
9154
9156
|
}
|
|
9155
|
-
function matchMlinesInAnswer(parsedOffer, parsedAnswer, streamSignalerManager) {
|
|
9156
|
-
parsedAnswer.session.groups = parsedOffer.session.groups;
|
|
9157
|
-
parsedAnswer.media = parsedOffer.media.map((offerMline) => {
|
|
9158
|
-
if (!offerMline.mid) {
|
|
9159
|
-
throw new Error(`Offer mline is missing MID`);
|
|
9160
|
-
}
|
|
9161
|
-
const answerMline = parsedAnswer.media.find((m) => m.mid === offerMline.mid);
|
|
9162
|
-
if (answerMline) {
|
|
9163
|
-
if (answerMline instanceof AvMediaDescription) {
|
|
9164
|
-
[...answerMline.codecs.values()].forEach((ci) => {
|
|
9165
|
-
ci.fmtParams.set('x-google-start-bitrate', '60000');
|
|
9166
|
-
});
|
|
9167
|
-
}
|
|
9168
|
-
return answerMline;
|
|
9169
|
-
}
|
|
9170
|
-
if (!(offerMline instanceof AvMediaDescription)) {
|
|
9171
|
-
throw new Error(`Answer is missing a non-media mline: ${offerMline.mid}`);
|
|
9172
|
-
}
|
|
9173
|
-
const startingMline = parsedAnswer.avMedia.find((m) => m.type === offerMline.type);
|
|
9174
|
-
if (!startingMline) {
|
|
9175
|
-
throw new Error(`Answer has no mline of type ${offerMline.type}, can't generate synthetic answer mline for mid ${offerMline.mid}`);
|
|
9176
|
-
}
|
|
9177
|
-
const fakeCorrespondingMline = deepCopy(startingMline);
|
|
9178
|
-
fakeCorrespondingMline.mid = offerMline.mid;
|
|
9179
|
-
fakeCorrespondingMline.simulcast = undefined;
|
|
9180
|
-
if (offerMline.direction === 'sendrecv' || offerMline.direction === 'sendonly') {
|
|
9181
|
-
fakeCorrespondingMline.direction = 'recvonly';
|
|
9182
|
-
}
|
|
9183
|
-
if (offerMline.direction === 'recvonly') {
|
|
9184
|
-
fakeCorrespondingMline.direction = 'sendonly';
|
|
9185
|
-
const ingressSignaler = streamSignalerManager.getIngressStreamSignalerOrThrow(offerMline.mid);
|
|
9186
|
-
ingressSignaler.signalRemoteStreams(fakeCorrespondingMline);
|
|
9187
|
-
}
|
|
9188
|
-
return fakeCorrespondingMline;
|
|
9189
|
-
});
|
|
9190
|
-
}
|
|
9191
9157
|
function injectContentTypes(sdp, contentTypeMap) {
|
|
9192
9158
|
contentTypeMap.forEach((mediaContent, mid) => {
|
|
9193
9159
|
const mline = sdp.media.find((m) => m.mid === mid);
|
|
@@ -9219,8 +9185,23 @@ function injectJmpAttributes(parsedSdp, csiMap, streamSignalingMode) {
|
|
|
9219
9185
|
}
|
|
9220
9186
|
});
|
|
9221
9187
|
}
|
|
9188
|
+
function injectDummyCandidates(parsedSdp) {
|
|
9189
|
+
parsedSdp.media.forEach((mLine) => {
|
|
9190
|
+
if (mLine.iceInfo.candidates.length === 0) {
|
|
9191
|
+
mLine.addLine(new CandidateLine('dummy', 1, 'udp', 1, '0.0.0.0', 1, 'host'));
|
|
9192
|
+
}
|
|
9193
|
+
});
|
|
9194
|
+
}
|
|
9222
9195
|
function hasSimulcast(av) {
|
|
9223
9196
|
return !!av.simulcast || av.ssrcGroups.map((sg) => sg.semantics).some((sem) => sem === 'SIM');
|
|
9197
|
+
}
|
|
9198
|
+
function addVlaExtension(mLine) {
|
|
9199
|
+
const vlaUri = 'http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00';
|
|
9200
|
+
if (mLine.extMaps.findIndex((extMapLine) => extMapLine.uri === vlaUri) === -1) {
|
|
9201
|
+
const maxIdValue = Math.max(...mLine.extMaps.map((extMapLine) => extMapLine.id), 0);
|
|
9202
|
+
const videoLayersAllocationLine = new ExtMapLine(maxIdValue + 1, vlaUri, undefined);
|
|
9203
|
+
mLine.extMaps.push(videoLayersAllocationLine);
|
|
9204
|
+
}
|
|
9224
9205
|
}
|
|
9225
9206
|
|
|
9226
9207
|
class SendOnlyTransceiver extends Transceiver {
|
|
@@ -9382,6 +9363,7 @@ class RidEgressStreamSignaler {
|
|
|
9382
9363
|
if (simulcastEnabled) {
|
|
9383
9364
|
mLine.rids = this.streamIds.map((streamId, index) => new RidLine(streamId.rid, 'send', `max-fs=${simulcastMaxFrameSizes[index]}`));
|
|
9384
9365
|
mLine.simulcast = new SimulcastLine(SimulcastLayerList.fromString('low;medium;high'), new SimulcastLayerList());
|
|
9366
|
+
addVlaExtension(mLine);
|
|
9385
9367
|
}
|
|
9386
9368
|
}
|
|
9387
9369
|
getSenderIds() {
|
|
@@ -9488,6 +9470,7 @@ class SsrcEgressStreamSignaler {
|
|
|
9488
9470
|
});
|
|
9489
9471
|
if (simulcastEnabled) {
|
|
9490
9472
|
mLine.addLine(new SsrcGroupLine('SIM', this.streamIds.map((streamId) => streamId.ssrc)));
|
|
9473
|
+
addVlaExtension(mLine);
|
|
9491
9474
|
}
|
|
9492
9475
|
}
|
|
9493
9476
|
getSenderIds() {
|
|
@@ -13229,7 +13212,7 @@ class MultistreamConnection extends EventEmitter {
|
|
|
13229
13212
|
(_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
|
|
13230
13213
|
this.pc = new PeerConnection({
|
|
13231
13214
|
iceServers: this.options.iceServers,
|
|
13232
|
-
bundlePolicy:
|
|
13215
|
+
bundlePolicy: this.options.bundlePolicy,
|
|
13233
13216
|
});
|
|
13234
13217
|
this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
|
|
13235
13218
|
this.attachMetricsObserver();
|
|
@@ -13613,6 +13596,7 @@ class MultistreamConnection extends EventEmitter {
|
|
|
13613
13596
|
}
|
|
13614
13597
|
return new Promise((createOfferResolve) => {
|
|
13615
13598
|
this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
13599
|
+
var _a;
|
|
13616
13600
|
if (this.setAnswerResolve !== undefined) {
|
|
13617
13601
|
throw new Error(`Tried to start a new createOffer flow before the old one had finished`);
|
|
13618
13602
|
}
|
|
@@ -13625,12 +13609,8 @@ class MultistreamConnection extends EventEmitter {
|
|
|
13625
13609
|
}
|
|
13626
13610
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
13627
13611
|
yield this.pc.setLocalDescription(offer);
|
|
13628
|
-
const
|
|
13629
|
-
|
|
13630
|
-
createOfferResolve({
|
|
13631
|
-
sdp: sdpToSend,
|
|
13632
|
-
type: offerWithCandidates.type,
|
|
13633
|
-
});
|
|
13612
|
+
const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
13613
|
+
createOfferResolve({ type: 'offer', sdp: sdpToSend });
|
|
13634
13614
|
yield setAnswerPromise;
|
|
13635
13615
|
}));
|
|
13636
13616
|
});
|
|
@@ -13739,6 +13719,7 @@ class MultistreamConnection extends EventEmitter {
|
|
|
13739
13719
|
});
|
|
13740
13720
|
injectJmpAttributes(parsed, csiMap, this.options.streamSignalingMode);
|
|
13741
13721
|
filterRecvOnlyMlines(parsed);
|
|
13722
|
+
injectDummyCandidates(parsed);
|
|
13742
13723
|
parsed.avMedia
|
|
13743
13724
|
.filter((av) => av.direction === 'sendrecv' && av.type === 'video')
|
|
13744
13725
|
.forEach((av) => {
|
|
@@ -13751,6 +13732,13 @@ class MultistreamConnection extends EventEmitter {
|
|
|
13751
13732
|
});
|
|
13752
13733
|
if (getBrowserDetails().name === 'Firefox') {
|
|
13753
13734
|
setupBundle(parsed, this.options.bundlePolicy, this.midMap);
|
|
13735
|
+
if (this.options.bundlePolicy === 'max-bundle') {
|
|
13736
|
+
parsed.media.forEach((mline, index) => {
|
|
13737
|
+
if (index > 0) {
|
|
13738
|
+
mline.port = parsed.media[0].port;
|
|
13739
|
+
}
|
|
13740
|
+
});
|
|
13741
|
+
}
|
|
13754
13742
|
}
|
|
13755
13743
|
return parsed.toString();
|
|
13756
13744
|
}
|
|
@@ -13761,6 +13749,15 @@ class MultistreamConnection extends EventEmitter {
|
|
|
13761
13749
|
matchMlinesInAnswer(parsedOffer, parsedAnswer, this.streamSignalerManager);
|
|
13762
13750
|
if (getBrowserDetails().name === 'Firefox') {
|
|
13763
13751
|
setupBundle(parsedAnswer, this.options.bundlePolicy, this.midMap);
|
|
13752
|
+
if (this.options.bundlePolicy === 'max-bundle') {
|
|
13753
|
+
const { ufrag, pwd } = parsedAnswer.media[0].iceInfo;
|
|
13754
|
+
parsedAnswer.media.forEach((mline, index) => {
|
|
13755
|
+
if (index > 0) {
|
|
13756
|
+
mline.iceInfo.ufrag = ufrag;
|
|
13757
|
+
mline.iceInfo.pwd = pwd;
|
|
13758
|
+
}
|
|
13759
|
+
});
|
|
13760
|
+
}
|
|
13764
13761
|
}
|
|
13765
13762
|
return parsedAnswer.toString();
|
|
13766
13763
|
}
|