@webex/web-client-media-engine 3.11.9 → 3.12.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/cjs/index.js +86 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +86 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +10 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -5708,6 +5708,10 @@ var PeerConnectionEvents;
|
|
|
5708
5708
|
(function (PeerConnectionEvents) {
|
|
5709
5709
|
PeerConnectionEvents["IceGatheringStateChange"] = "icegatheringstatechange";
|
|
5710
5710
|
PeerConnectionEvents["ConnectionStateChange"] = "connectionstatechange";
|
|
5711
|
+
PeerConnectionEvents["CreateOfferOnSuccess"] = "createofferonsuccess";
|
|
5712
|
+
PeerConnectionEvents["CreateAnswerOnSuccess"] = "createansweronsuccess";
|
|
5713
|
+
PeerConnectionEvents["SetLocalDescriptionOnSuccess"] = "setlocaldescriptiononsuccess";
|
|
5714
|
+
PeerConnectionEvents["SetRemoteDescriptionOnSuccess"] = "setremotedescriptiononsuccess";
|
|
5711
5715
|
})(PeerConnectionEvents || (PeerConnectionEvents = {}));
|
|
5712
5716
|
/**
|
|
5713
5717
|
* Manages a single RTCPeerConnection with the server.
|
|
@@ -5821,7 +5825,10 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5821
5825
|
*/
|
|
5822
5826
|
createAnswer(options) {
|
|
5823
5827
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5824
|
-
return this.pc.createAnswer(options)
|
|
5828
|
+
return this.pc.createAnswer(options).then((answer) => {
|
|
5829
|
+
this.emit(PeerConnection.Events.CreateAnswerOnSuccess, answer);
|
|
5830
|
+
return answer;
|
|
5831
|
+
});
|
|
5825
5832
|
});
|
|
5826
5833
|
}
|
|
5827
5834
|
/**
|
|
@@ -5836,7 +5843,10 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5836
5843
|
*/
|
|
5837
5844
|
createOffer(options) {
|
|
5838
5845
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5839
|
-
return this.pc.createOffer(options)
|
|
5846
|
+
return this.pc.createOffer(options).then((offer) => {
|
|
5847
|
+
this.emit(PeerConnection.Events.CreateOfferOnSuccess, offer);
|
|
5848
|
+
return offer;
|
|
5849
|
+
});
|
|
5840
5850
|
});
|
|
5841
5851
|
}
|
|
5842
5852
|
/**
|
|
@@ -5861,7 +5871,11 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5861
5871
|
}
|
|
5862
5872
|
});
|
|
5863
5873
|
}
|
|
5864
|
-
return this.pc.setLocalDescription(description)
|
|
5874
|
+
return this.pc.setLocalDescription(description).then(() => {
|
|
5875
|
+
if (description) {
|
|
5876
|
+
this.emit(PeerConnection.Events.SetLocalDescriptionOnSuccess, description);
|
|
5877
|
+
}
|
|
5878
|
+
});
|
|
5865
5879
|
});
|
|
5866
5880
|
}
|
|
5867
5881
|
/**
|
|
@@ -5875,7 +5889,9 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5875
5889
|
*/
|
|
5876
5890
|
setRemoteDescription(description) {
|
|
5877
5891
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5878
|
-
return this.pc.setRemoteDescription(description)
|
|
5892
|
+
return this.pc.setRemoteDescription(description).then(() => {
|
|
5893
|
+
this.emit(PeerConnection.Events.SetRemoteDescriptionOnSuccess, description);
|
|
5894
|
+
});
|
|
5879
5895
|
});
|
|
5880
5896
|
}
|
|
5881
5897
|
/**
|
|
@@ -9402,6 +9418,8 @@ function deepCopy(source) {
|
|
|
9402
9418
|
: source;
|
|
9403
9419
|
}
|
|
9404
9420
|
|
|
9421
|
+
const ipv4Regex = /(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3}\b)/g;
|
|
9422
|
+
const ipv6Regex = /(\b[\da-fA-F]{1,4}(:[\da-fA-F]{1,4}){7}\b)/g;
|
|
9405
9423
|
function matchMediaDescriptionsInAnswer(parsedOffer, parsedAnswer) {
|
|
9406
9424
|
parsedAnswer.session.groups = parsedOffer.session.groups;
|
|
9407
9425
|
parsedAnswer.media = parsedOffer.media.map((offerMediaDescription) => {
|
|
@@ -9489,6 +9507,15 @@ function injectDummyCandidates(mediaDescription) {
|
|
|
9489
9507
|
mediaDescription.addLine(new CandidateLine('dummy2', 1, 'tcp', 2, '0.0.0.0', 9, 'host'));
|
|
9490
9508
|
mediaDescription.addLine(new CandidateLine('dummy3', 1, 'udp', 1, '0.0.0.0', 9, 'relay'));
|
|
9491
9509
|
}
|
|
9510
|
+
function maskIp(sdp) {
|
|
9511
|
+
let maskedSdp = sdp.replace(ipv4Regex, (match, firstOctets) => {
|
|
9512
|
+
return `${firstOctets}0`;
|
|
9513
|
+
});
|
|
9514
|
+
maskedSdp = maskedSdp.replace(ipv6Regex, (match) => {
|
|
9515
|
+
return match.replace(/:[\da-fA-F]{1,4}$/, ':0');
|
|
9516
|
+
});
|
|
9517
|
+
return maskedSdp;
|
|
9518
|
+
}
|
|
9492
9519
|
function removeMidRidExtensions(mediaDescription) {
|
|
9493
9520
|
mediaDescription.extMaps.forEach((extMapLine, extId, extMap) => {
|
|
9494
9521
|
if (/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri)) {
|
|
@@ -14389,6 +14416,10 @@ var MultistreamConnectionEventNames;
|
|
|
14389
14416
|
MultistreamConnectionEventNames["ActiveSpeakerNotification"] = "active-speaker-notification";
|
|
14390
14417
|
MultistreamConnectionEventNames["ConnectionStateUpdate"] = "connection-state-update";
|
|
14391
14418
|
MultistreamConnectionEventNames["NegotiationNeeded"] = "negotiation-needed";
|
|
14419
|
+
MultistreamConnectionEventNames["CreateOfferOnSuccess"] = "createofferonsuccess";
|
|
14420
|
+
MultistreamConnectionEventNames["CreateAnswerOnSuccess"] = "createansweronsuccess";
|
|
14421
|
+
MultistreamConnectionEventNames["SetLocalDescriptionOnSuccess"] = "setlocaldescriptiononsuccess";
|
|
14422
|
+
MultistreamConnectionEventNames["SetRemoteDescriptionOnSuccess"] = "setremotedescriptiononsuccess";
|
|
14392
14423
|
})(MultistreamConnectionEventNames || (MultistreamConnectionEventNames = {}));
|
|
14393
14424
|
const defaultMultistreamConnectionOptions = {
|
|
14394
14425
|
disableSimulcast: BrowserInfo.isFirefox(),
|
|
@@ -14431,10 +14462,27 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14431
14462
|
iceServers: this.options.iceServers,
|
|
14432
14463
|
bundlePolicy: this.options.bundlePolicy,
|
|
14433
14464
|
});
|
|
14434
|
-
this.
|
|
14465
|
+
this.propagatePeerConnectionEvents();
|
|
14435
14466
|
this.attachMetricsObserver();
|
|
14436
14467
|
this.createDataChannel();
|
|
14437
14468
|
}
|
|
14469
|
+
propagatePeerConnectionEvents() {
|
|
14470
|
+
this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => {
|
|
14471
|
+
this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state);
|
|
14472
|
+
});
|
|
14473
|
+
this.pc.on(PeerConnection.Events.CreateOfferOnSuccess, (description) => {
|
|
14474
|
+
this.emit(MultistreamConnectionEventNames.CreateOfferOnSuccess, description);
|
|
14475
|
+
});
|
|
14476
|
+
this.pc.on(PeerConnection.Events.CreateAnswerOnSuccess, (description) => {
|
|
14477
|
+
this.emit(MultistreamConnectionEventNames.CreateAnswerOnSuccess, description);
|
|
14478
|
+
});
|
|
14479
|
+
this.pc.on(PeerConnection.Events.SetLocalDescriptionOnSuccess, (description) => {
|
|
14480
|
+
this.emit(MultistreamConnectionEventNames.SetLocalDescriptionOnSuccess, description);
|
|
14481
|
+
});
|
|
14482
|
+
this.pc.on(PeerConnection.Events.SetRemoteDescriptionOnSuccess, (description) => {
|
|
14483
|
+
this.emit(MultistreamConnectionEventNames.SetRemoteDescriptionOnSuccess, description);
|
|
14484
|
+
});
|
|
14485
|
+
}
|
|
14438
14486
|
getConnectionState() {
|
|
14439
14487
|
return this.pc.getConnectionState();
|
|
14440
14488
|
}
|
|
@@ -14805,7 +14853,15 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14805
14853
|
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
|
|
14806
14854
|
}
|
|
14807
14855
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
14808
|
-
yield this.pc
|
|
14856
|
+
yield this.pc
|
|
14857
|
+
.setLocalDescription(offer)
|
|
14858
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14859
|
+
logger.info('this.pc.setLocalDescription() resolved');
|
|
14860
|
+
}))
|
|
14861
|
+
.catch((error) => {
|
|
14862
|
+
var _a;
|
|
14863
|
+
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
|
|
14864
|
+
});
|
|
14809
14865
|
const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
14810
14866
|
createOfferResolve({ type: 'offer', sdp: sdpToSend });
|
|
14811
14867
|
if (this.currentCreateOfferId > createOfferId) {
|
|
@@ -14831,7 +14887,9 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14831
14887
|
logErrorAndThrow(WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
|
|
14832
14888
|
}
|
|
14833
14889
|
logger.info('calling this.pc.setRemoteDescription()');
|
|
14834
|
-
return this.pc
|
|
14890
|
+
return this.pc
|
|
14891
|
+
.setRemoteDescription({ type: 'answer', sdp })
|
|
14892
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14835
14893
|
logger.info('this.pc.setRemoteDescription() resolved');
|
|
14836
14894
|
if (this.setAnswerResolve) {
|
|
14837
14895
|
this.setAnswerResolve();
|
|
@@ -14840,7 +14898,10 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14840
14898
|
else {
|
|
14841
14899
|
logger.debug(`setAnswerResolve function was cleared between setAnswer and result of setRemoteDescription`);
|
|
14842
14900
|
}
|
|
14843
|
-
}))
|
|
14901
|
+
}))
|
|
14902
|
+
.catch((error) => {
|
|
14903
|
+
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp(answer)}`);
|
|
14904
|
+
});
|
|
14844
14905
|
});
|
|
14845
14906
|
}
|
|
14846
14907
|
doLocalOfferAnswer() {
|
|
@@ -14851,9 +14912,24 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14851
14912
|
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
|
|
14852
14913
|
}
|
|
14853
14914
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
14854
|
-
yield this.pc
|
|
14915
|
+
yield this.pc
|
|
14916
|
+
.setLocalDescription(offer)
|
|
14917
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14918
|
+
logger.info('this.pc.setLocalDescription() resolved');
|
|
14919
|
+
}))
|
|
14920
|
+
.catch((error) => {
|
|
14921
|
+
var _a;
|
|
14922
|
+
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
|
|
14923
|
+
});
|
|
14855
14924
|
const answer = this.preProcessRemoteAnswer((_a = this.pc.getRemoteDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
14856
|
-
return this.pc
|
|
14925
|
+
return this.pc
|
|
14926
|
+
.setRemoteDescription({ type: 'answer', sdp: answer })
|
|
14927
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14928
|
+
logger.info('this.pc.setRemoteDescription() resolved');
|
|
14929
|
+
}))
|
|
14930
|
+
.catch((error) => {
|
|
14931
|
+
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, `Error ${error}. SDP: ${maskIp(answer)}`);
|
|
14932
|
+
});
|
|
14857
14933
|
});
|
|
14858
14934
|
}
|
|
14859
14935
|
queueLocalOfferAnswer() {
|