@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/cjs/index.js
CHANGED
|
@@ -5712,6 +5712,10 @@ var PeerConnectionEvents;
|
|
|
5712
5712
|
(function (PeerConnectionEvents) {
|
|
5713
5713
|
PeerConnectionEvents["IceGatheringStateChange"] = "icegatheringstatechange";
|
|
5714
5714
|
PeerConnectionEvents["ConnectionStateChange"] = "connectionstatechange";
|
|
5715
|
+
PeerConnectionEvents["CreateOfferOnSuccess"] = "createofferonsuccess";
|
|
5716
|
+
PeerConnectionEvents["CreateAnswerOnSuccess"] = "createansweronsuccess";
|
|
5717
|
+
PeerConnectionEvents["SetLocalDescriptionOnSuccess"] = "setlocaldescriptiononsuccess";
|
|
5718
|
+
PeerConnectionEvents["SetRemoteDescriptionOnSuccess"] = "setremotedescriptiononsuccess";
|
|
5715
5719
|
})(PeerConnectionEvents || (PeerConnectionEvents = {}));
|
|
5716
5720
|
/**
|
|
5717
5721
|
* Manages a single RTCPeerConnection with the server.
|
|
@@ -5825,7 +5829,10 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5825
5829
|
*/
|
|
5826
5830
|
createAnswer(options) {
|
|
5827
5831
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5828
|
-
return this.pc.createAnswer(options)
|
|
5832
|
+
return this.pc.createAnswer(options).then((answer) => {
|
|
5833
|
+
this.emit(PeerConnection.Events.CreateAnswerOnSuccess, answer);
|
|
5834
|
+
return answer;
|
|
5835
|
+
});
|
|
5829
5836
|
});
|
|
5830
5837
|
}
|
|
5831
5838
|
/**
|
|
@@ -5840,7 +5847,10 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5840
5847
|
*/
|
|
5841
5848
|
createOffer(options) {
|
|
5842
5849
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5843
|
-
return this.pc.createOffer(options)
|
|
5850
|
+
return this.pc.createOffer(options).then((offer) => {
|
|
5851
|
+
this.emit(PeerConnection.Events.CreateOfferOnSuccess, offer);
|
|
5852
|
+
return offer;
|
|
5853
|
+
});
|
|
5844
5854
|
});
|
|
5845
5855
|
}
|
|
5846
5856
|
/**
|
|
@@ -5865,7 +5875,11 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5865
5875
|
}
|
|
5866
5876
|
});
|
|
5867
5877
|
}
|
|
5868
|
-
return this.pc.setLocalDescription(description)
|
|
5878
|
+
return this.pc.setLocalDescription(description).then(() => {
|
|
5879
|
+
if (description) {
|
|
5880
|
+
this.emit(PeerConnection.Events.SetLocalDescriptionOnSuccess, description);
|
|
5881
|
+
}
|
|
5882
|
+
});
|
|
5869
5883
|
});
|
|
5870
5884
|
}
|
|
5871
5885
|
/**
|
|
@@ -5879,7 +5893,9 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5879
5893
|
*/
|
|
5880
5894
|
setRemoteDescription(description) {
|
|
5881
5895
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5882
|
-
return this.pc.setRemoteDescription(description)
|
|
5896
|
+
return this.pc.setRemoteDescription(description).then(() => {
|
|
5897
|
+
this.emit(PeerConnection.Events.SetRemoteDescriptionOnSuccess, description);
|
|
5898
|
+
});
|
|
5883
5899
|
});
|
|
5884
5900
|
}
|
|
5885
5901
|
/**
|
|
@@ -9406,6 +9422,8 @@ function deepCopy(source) {
|
|
|
9406
9422
|
: source;
|
|
9407
9423
|
}
|
|
9408
9424
|
|
|
9425
|
+
const ipv4Regex = /(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3}\b)/g;
|
|
9426
|
+
const ipv6Regex = /(\b[\da-fA-F]{1,4}(:[\da-fA-F]{1,4}){7}\b)/g;
|
|
9409
9427
|
function matchMediaDescriptionsInAnswer(parsedOffer, parsedAnswer) {
|
|
9410
9428
|
parsedAnswer.session.groups = parsedOffer.session.groups;
|
|
9411
9429
|
parsedAnswer.media = parsedOffer.media.map((offerMediaDescription) => {
|
|
@@ -9493,6 +9511,15 @@ function injectDummyCandidates(mediaDescription) {
|
|
|
9493
9511
|
mediaDescription.addLine(new CandidateLine('dummy2', 1, 'tcp', 2, '0.0.0.0', 9, 'host'));
|
|
9494
9512
|
mediaDescription.addLine(new CandidateLine('dummy3', 1, 'udp', 1, '0.0.0.0', 9, 'relay'));
|
|
9495
9513
|
}
|
|
9514
|
+
function maskIp(sdp) {
|
|
9515
|
+
let maskedSdp = sdp.replace(ipv4Regex, (match, firstOctets) => {
|
|
9516
|
+
return `${firstOctets}0`;
|
|
9517
|
+
});
|
|
9518
|
+
maskedSdp = maskedSdp.replace(ipv6Regex, (match) => {
|
|
9519
|
+
return match.replace(/:[\da-fA-F]{1,4}$/, ':0');
|
|
9520
|
+
});
|
|
9521
|
+
return maskedSdp;
|
|
9522
|
+
}
|
|
9496
9523
|
function removeMidRidExtensions(mediaDescription) {
|
|
9497
9524
|
mediaDescription.extMaps.forEach((extMapLine, extId, extMap) => {
|
|
9498
9525
|
if (/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri)) {
|
|
@@ -14393,6 +14420,10 @@ exports.MultistreamConnectionEventNames = void 0;
|
|
|
14393
14420
|
MultistreamConnectionEventNames["ActiveSpeakerNotification"] = "active-speaker-notification";
|
|
14394
14421
|
MultistreamConnectionEventNames["ConnectionStateUpdate"] = "connection-state-update";
|
|
14395
14422
|
MultistreamConnectionEventNames["NegotiationNeeded"] = "negotiation-needed";
|
|
14423
|
+
MultistreamConnectionEventNames["CreateOfferOnSuccess"] = "createofferonsuccess";
|
|
14424
|
+
MultistreamConnectionEventNames["CreateAnswerOnSuccess"] = "createansweronsuccess";
|
|
14425
|
+
MultistreamConnectionEventNames["SetLocalDescriptionOnSuccess"] = "setlocaldescriptiononsuccess";
|
|
14426
|
+
MultistreamConnectionEventNames["SetRemoteDescriptionOnSuccess"] = "setremotedescriptiononsuccess";
|
|
14396
14427
|
})(exports.MultistreamConnectionEventNames || (exports.MultistreamConnectionEventNames = {}));
|
|
14397
14428
|
const defaultMultistreamConnectionOptions = {
|
|
14398
14429
|
disableSimulcast: BrowserInfo.isFirefox(),
|
|
@@ -14435,10 +14466,27 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14435
14466
|
iceServers: this.options.iceServers,
|
|
14436
14467
|
bundlePolicy: this.options.bundlePolicy,
|
|
14437
14468
|
});
|
|
14438
|
-
this.
|
|
14469
|
+
this.propagatePeerConnectionEvents();
|
|
14439
14470
|
this.attachMetricsObserver();
|
|
14440
14471
|
this.createDataChannel();
|
|
14441
14472
|
}
|
|
14473
|
+
propagatePeerConnectionEvents() {
|
|
14474
|
+
this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => {
|
|
14475
|
+
this.emit(exports.MultistreamConnectionEventNames.ConnectionStateUpdate, state);
|
|
14476
|
+
});
|
|
14477
|
+
this.pc.on(PeerConnection.Events.CreateOfferOnSuccess, (description) => {
|
|
14478
|
+
this.emit(exports.MultistreamConnectionEventNames.CreateOfferOnSuccess, description);
|
|
14479
|
+
});
|
|
14480
|
+
this.pc.on(PeerConnection.Events.CreateAnswerOnSuccess, (description) => {
|
|
14481
|
+
this.emit(exports.MultistreamConnectionEventNames.CreateAnswerOnSuccess, description);
|
|
14482
|
+
});
|
|
14483
|
+
this.pc.on(PeerConnection.Events.SetLocalDescriptionOnSuccess, (description) => {
|
|
14484
|
+
this.emit(exports.MultistreamConnectionEventNames.SetLocalDescriptionOnSuccess, description);
|
|
14485
|
+
});
|
|
14486
|
+
this.pc.on(PeerConnection.Events.SetRemoteDescriptionOnSuccess, (description) => {
|
|
14487
|
+
this.emit(exports.MultistreamConnectionEventNames.SetRemoteDescriptionOnSuccess, description);
|
|
14488
|
+
});
|
|
14489
|
+
}
|
|
14442
14490
|
getConnectionState() {
|
|
14443
14491
|
return this.pc.getConnectionState();
|
|
14444
14492
|
}
|
|
@@ -14809,7 +14857,15 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14809
14857
|
logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
|
|
14810
14858
|
}
|
|
14811
14859
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
14812
|
-
yield this.pc
|
|
14860
|
+
yield this.pc
|
|
14861
|
+
.setLocalDescription(offer)
|
|
14862
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14863
|
+
logger.info('this.pc.setLocalDescription() resolved');
|
|
14864
|
+
}))
|
|
14865
|
+
.catch((error) => {
|
|
14866
|
+
var _a;
|
|
14867
|
+
logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
|
|
14868
|
+
});
|
|
14813
14869
|
const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
14814
14870
|
createOfferResolve({ type: 'offer', sdp: sdpToSend });
|
|
14815
14871
|
if (this.currentCreateOfferId > createOfferId) {
|
|
@@ -14835,7 +14891,9 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14835
14891
|
logErrorAndThrow(exports.WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
|
|
14836
14892
|
}
|
|
14837
14893
|
logger.info('calling this.pc.setRemoteDescription()');
|
|
14838
|
-
return this.pc
|
|
14894
|
+
return this.pc
|
|
14895
|
+
.setRemoteDescription({ type: 'answer', sdp })
|
|
14896
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14839
14897
|
logger.info('this.pc.setRemoteDescription() resolved');
|
|
14840
14898
|
if (this.setAnswerResolve) {
|
|
14841
14899
|
this.setAnswerResolve();
|
|
@@ -14844,7 +14902,10 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14844
14902
|
else {
|
|
14845
14903
|
logger.debug(`setAnswerResolve function was cleared between setAnswer and result of setRemoteDescription`);
|
|
14846
14904
|
}
|
|
14847
|
-
}))
|
|
14905
|
+
}))
|
|
14906
|
+
.catch((error) => {
|
|
14907
|
+
logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp(answer)}`);
|
|
14908
|
+
});
|
|
14848
14909
|
});
|
|
14849
14910
|
}
|
|
14850
14911
|
doLocalOfferAnswer() {
|
|
@@ -14855,9 +14916,24 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14855
14916
|
logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
|
|
14856
14917
|
}
|
|
14857
14918
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
14858
|
-
yield this.pc
|
|
14919
|
+
yield this.pc
|
|
14920
|
+
.setLocalDescription(offer)
|
|
14921
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14922
|
+
logger.info('this.pc.setLocalDescription() resolved');
|
|
14923
|
+
}))
|
|
14924
|
+
.catch((error) => {
|
|
14925
|
+
var _a;
|
|
14926
|
+
logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error: ${error}. SDP: ${maskIp((_a = offer.sdp) !== null && _a !== void 0 ? _a : '')}`);
|
|
14927
|
+
});
|
|
14859
14928
|
const answer = this.preProcessRemoteAnswer((_a = this.pc.getRemoteDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
14860
|
-
return this.pc
|
|
14929
|
+
return this.pc
|
|
14930
|
+
.setRemoteDescription({ type: 'answer', sdp: answer })
|
|
14931
|
+
.then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14932
|
+
logger.info('this.pc.setRemoteDescription() resolved');
|
|
14933
|
+
}))
|
|
14934
|
+
.catch((error) => {
|
|
14935
|
+
logErrorAndThrow(exports.WcmeErrorType.CREATE_OFFER_FAILED, `Error ${error}. SDP: ${maskIp(answer)}`);
|
|
14936
|
+
});
|
|
14861
14937
|
});
|
|
14862
14938
|
}
|
|
14863
14939
|
queueLocalOfferAnswer() {
|