@whereby.com/browser-sdk 2.0.0-alpha15 → 2.0.0-alpha17
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/lib.cjs +176 -147
- package/dist/lib.esm.js +176 -147
- package/dist/types.d.ts +26 -1
- package/dist/{v2-alpha15.js → v2-alpha17.js} +4 -4
- package/package.json +2 -2
package/dist/lib.esm.js
CHANGED
|
@@ -128,7 +128,7 @@ define("WherebyEmbed", {
|
|
|
128
128
|
if (roomUrl.searchParams.get("roomKey")) {
|
|
129
129
|
this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
|
|
130
130
|
}
|
|
131
|
-
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-
|
|
131
|
+
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha17", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
|
|
132
132
|
// add to URL if set in any way
|
|
133
133
|
(o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
|
|
134
134
|
if (!this.url.searchParams.has(k) && typeof v === "string") {
|
|
@@ -648,21 +648,21 @@ var rtcManagerEvents = {
|
|
|
648
648
|
DOMINANT_SPEAKER: "dominant_speaker",
|
|
649
649
|
};
|
|
650
650
|
|
|
651
|
-
const browserName$
|
|
651
|
+
const browserName$2 = adapter.browserDetails.browser;
|
|
652
652
|
const browserVersion$1 = adapter.browserDetails.version;
|
|
653
653
|
|
|
654
654
|
// SDP mangling for deprioritizing H264
|
|
655
655
|
function deprioritizeH264(sdp) {
|
|
656
656
|
return SDPUtils.splitSections(sdp)
|
|
657
|
-
.map(
|
|
657
|
+
.map(section => {
|
|
658
658
|
// only modify video sections
|
|
659
659
|
if (SDPUtils.getKind(section) !== "video") return section;
|
|
660
660
|
|
|
661
661
|
// list of payloadTypes used in this sdp/section
|
|
662
662
|
const h264payloadTypes = SDPUtils.matchPrefix(section, "a=rtpmap:")
|
|
663
|
-
.map(
|
|
664
|
-
.filter(
|
|
665
|
-
.map(
|
|
663
|
+
.map(line => SDPUtils.parseRtpMap(line))
|
|
664
|
+
.filter(codec => /h264/i.test(codec.name))
|
|
665
|
+
.map(codec => "" + codec.payloadType);
|
|
666
666
|
|
|
667
667
|
// return as is if no h264 found
|
|
668
668
|
if (!h264payloadTypes.length) return section;
|
|
@@ -672,7 +672,7 @@ function deprioritizeH264(sdp) {
|
|
|
672
672
|
const mlinePayloadsSection = /(\s\d+)+$/i.exec(mline)[0];
|
|
673
673
|
const mlinePayloadsNonH264 = mlinePayloadsSection
|
|
674
674
|
.split(" ")
|
|
675
|
-
.filter(
|
|
675
|
+
.filter(payloadType => payloadType && !h264payloadTypes.includes(payloadType));
|
|
676
676
|
const reorderedPayloads = [...mlinePayloadsNonH264, ...h264payloadTypes].join(" ");
|
|
677
677
|
const newmline = mline.replace(mlinePayloadsSection, " " + reorderedPayloads);
|
|
678
678
|
return section.replace(mline, newmline);
|
|
@@ -700,12 +700,12 @@ function replaceSSRCs(currentDescription, newDescription) {
|
|
|
700
700
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1478685
|
|
701
701
|
// filter out the mid rtp header extension
|
|
702
702
|
function filterMidExtension(sdp) {
|
|
703
|
-
if (browserName$
|
|
703
|
+
if (browserName$2 !== "safari" && (browserName$2 !== "firefox" || browserVersion$1 >= 63 || browserVersion$1 === 60)) {
|
|
704
704
|
return sdp;
|
|
705
705
|
}
|
|
706
706
|
return (
|
|
707
707
|
SDPUtils.splitLines(sdp.trim())
|
|
708
|
-
.filter(
|
|
708
|
+
.filter(line => {
|
|
709
709
|
if (!line.startsWith("a=extmap:")) {
|
|
710
710
|
return true;
|
|
711
711
|
}
|
|
@@ -721,21 +721,21 @@ function filterMidExtension(sdp) {
|
|
|
721
721
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1534673
|
|
722
722
|
// Filter out a:msid-semantic header
|
|
723
723
|
function filterMsidSemantic(sdp) {
|
|
724
|
-
if (browserName$
|
|
724
|
+
if (browserName$2 !== "firefox") {
|
|
725
725
|
return sdp;
|
|
726
726
|
}
|
|
727
727
|
return (
|
|
728
728
|
SDPUtils.splitLines(sdp.trim())
|
|
729
|
-
.map(
|
|
729
|
+
.map(line => (line.startsWith("a=msid-semantic:") ? "a=msid-semantic: WMS *" : line))
|
|
730
730
|
.join("\r\n") + "\r\n"
|
|
731
731
|
);
|
|
732
732
|
}
|
|
733
733
|
|
|
734
734
|
function isRelayed(pc) {
|
|
735
|
-
return pc.getStats(null).then(
|
|
735
|
+
return pc.getStats(null).then(result => {
|
|
736
736
|
let localCandidateType;
|
|
737
737
|
let remoteCandidateType;
|
|
738
|
-
result.forEach(
|
|
738
|
+
result.forEach(report => {
|
|
739
739
|
// Chrome 58+ / spec
|
|
740
740
|
if (report.type === "transport" && report.selectedCandidatePairId) {
|
|
741
741
|
const transport = result.get(report.selectedCandidatePairId);
|
|
@@ -765,7 +765,7 @@ const logger$4 = console;
|
|
|
765
765
|
|
|
766
766
|
// use https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-setparameters to change the video bandwidth.
|
|
767
767
|
function setVideoBandwidthUsingSetParameters(pc, bandwidth) {
|
|
768
|
-
const sender = pc.getSenders().find(
|
|
768
|
+
const sender = pc.getSenders().find(s => s.track && s.track.kind === "video");
|
|
769
769
|
if (!sender) {
|
|
770
770
|
return Promise.resolve();
|
|
771
771
|
}
|
|
@@ -786,7 +786,7 @@ function setVideoBandwidthUsingSetParameters(pc, bandwidth) {
|
|
|
786
786
|
parameters.encodings[0].maxBitrate = bandwidth * 1000; // convert to bps
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
-
return sender.setParameters(parameters).catch(
|
|
789
|
+
return sender.setParameters(parameters).catch(err => {
|
|
790
790
|
logger$4.error("setParameters err: ", err);
|
|
791
791
|
});
|
|
792
792
|
}
|
|
@@ -811,7 +811,7 @@ class Session {
|
|
|
811
811
|
this.streamIds = [];
|
|
812
812
|
this.streams = [];
|
|
813
813
|
this.earlyIceCandidates = [];
|
|
814
|
-
this.afterConnected = new Promise(
|
|
814
|
+
this.afterConnected = new Promise(resolve => {
|
|
815
815
|
this.registerConnected = resolve;
|
|
816
816
|
});
|
|
817
817
|
this.offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
|
|
@@ -848,10 +848,10 @@ class Session {
|
|
|
848
848
|
this.streamIds.push(stream.id);
|
|
849
849
|
this.streams.push(stream);
|
|
850
850
|
if (RTCPeerConnection.prototype.addTrack) {
|
|
851
|
-
stream.getAudioTracks().forEach(
|
|
851
|
+
stream.getAudioTracks().forEach(track => {
|
|
852
852
|
this.pc.addTrack(track, stream);
|
|
853
853
|
});
|
|
854
|
-
stream.getVideoTracks().forEach(
|
|
854
|
+
stream.getVideoTracks().forEach(track => {
|
|
855
855
|
this.pc.addTrack(track, stream);
|
|
856
856
|
});
|
|
857
857
|
} else {
|
|
@@ -871,7 +871,7 @@ class Session {
|
|
|
871
871
|
removeTrack(track) {
|
|
872
872
|
const stream = this.streams[0];
|
|
873
873
|
stream.removeTrack(track);
|
|
874
|
-
const sender = this.pc.getSenders().find(
|
|
874
|
+
const sender = this.pc.getSenders().find(sender => sender.track === track);
|
|
875
875
|
if (sender) {
|
|
876
876
|
this.pc.removeTrack(sender);
|
|
877
877
|
}
|
|
@@ -887,8 +887,8 @@ class Session {
|
|
|
887
887
|
|
|
888
888
|
if (this.pc) {
|
|
889
889
|
if (this.pc.removeTrack) {
|
|
890
|
-
stream.getTracks().forEach(
|
|
891
|
-
const sender = this.pc.getSenders().find(
|
|
890
|
+
stream.getTracks().forEach(track => {
|
|
891
|
+
const sender = this.pc.getSenders().find(sender => sender.track === track);
|
|
892
892
|
if (sender) {
|
|
893
893
|
this.pc.removeTrack(sender);
|
|
894
894
|
}
|
|
@@ -906,14 +906,14 @@ class Session {
|
|
|
906
906
|
// wrapper around SRD which stores a promise
|
|
907
907
|
this.srdComplete = this.pc.setRemoteDescription(desc);
|
|
908
908
|
return this.srdComplete.then(() => {
|
|
909
|
-
this.earlyIceCandidates.forEach(
|
|
909
|
+
this.earlyIceCandidates.forEach(candidate => this.pc.addIceCandidate(candidate));
|
|
910
910
|
this.earlyIceCandidates = [];
|
|
911
911
|
});
|
|
912
912
|
}
|
|
913
913
|
|
|
914
914
|
handleOffer(message) {
|
|
915
915
|
if (!this.canModifyPeerConnection()) {
|
|
916
|
-
return new Promise(
|
|
916
|
+
return new Promise(resolve => {
|
|
917
917
|
this.pending.push(() => this.handleOffer(message).then(resolve));
|
|
918
918
|
});
|
|
919
919
|
}
|
|
@@ -931,7 +931,7 @@ class Session {
|
|
|
931
931
|
.then(() => {
|
|
932
932
|
return this.pc.createAnswer();
|
|
933
933
|
})
|
|
934
|
-
.then(
|
|
934
|
+
.then(answer => {
|
|
935
935
|
answerToSignal = answer;
|
|
936
936
|
return this.pc.setLocalDescription(answer);
|
|
937
937
|
})
|
|
@@ -959,7 +959,7 @@ class Session {
|
|
|
959
959
|
() => {
|
|
960
960
|
return setVideoBandwidthUsingSetParameters(this.pc, this.bandwidth);
|
|
961
961
|
},
|
|
962
|
-
|
|
962
|
+
e => {
|
|
963
963
|
logger$3.warn("Could not set remote description from remote answer: ", e);
|
|
964
964
|
}
|
|
965
965
|
);
|
|
@@ -980,7 +980,7 @@ class Session {
|
|
|
980
980
|
// filter due to https://github.com/webrtcHacks/adapter/issues/863
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
|
-
this.pc.addIceCandidate(candidate).catch(
|
|
983
|
+
this.pc.addIceCandidate(candidate).catch(e => {
|
|
984
984
|
logger$3.warn("Failed to add ICE candidate ('%s'): %s", candidate ? candidate.candidate : null, e);
|
|
985
985
|
});
|
|
986
986
|
});
|
|
@@ -1018,11 +1018,11 @@ class Session {
|
|
|
1018
1018
|
if (!pc) return false;
|
|
1019
1019
|
const senders = pc.getSenders();
|
|
1020
1020
|
function dbg(msg) {
|
|
1021
|
-
const tr =
|
|
1021
|
+
const tr = t => t && `id:${t.id},kind:${t.kind},state:${t.readyState}`;
|
|
1022
1022
|
logger$3.warn(
|
|
1023
1023
|
`${msg}. newTrack:${tr(newTrack)}, oldTrack:${tr(oldTrack)}, sender tracks: ${JSON.stringify(
|
|
1024
|
-
senders.map(
|
|
1025
|
-
)}, sender first codecs: ${JSON.stringify(senders.map(
|
|
1024
|
+
senders.map(s => `s ${tr(s.track)}`)
|
|
1025
|
+
)}, sender first codecs: ${JSON.stringify(senders.map(s => (s.getParameters().codecs || [])[0]))}`
|
|
1026
1026
|
);
|
|
1027
1027
|
}
|
|
1028
1028
|
if (!senders.length) {
|
|
@@ -1030,7 +1030,7 @@ class Session {
|
|
|
1030
1030
|
}
|
|
1031
1031
|
// If we didn't specify oldTrack, replace with first of its kind
|
|
1032
1032
|
if (!oldTrack) {
|
|
1033
|
-
oldTrack = (senders.find(
|
|
1033
|
+
oldTrack = (senders.find(s => s.track && s.track.kind === newTrack.kind) || {}).track;
|
|
1034
1034
|
if (!oldTrack) {
|
|
1035
1035
|
// odin: Temporary debug data, remove if you see after 2020-12-01
|
|
1036
1036
|
dbg("No sender with same kind! Add new track then.");
|
|
@@ -1087,7 +1087,7 @@ class Session {
|
|
|
1087
1087
|
// we already know that the track has been added at least to the mediastream
|
|
1088
1088
|
return result;
|
|
1089
1089
|
}
|
|
1090
|
-
const stream = this.streams.find(
|
|
1090
|
+
const stream = this.streams.find(s => s.getTracks().find(t => t.id === newTrack.id)) || this.streams[0];
|
|
1091
1091
|
if (!stream) {
|
|
1092
1092
|
dbg("No stream?");
|
|
1093
1093
|
return Promise.reject(new Error("replaceTrack: No stream?"));
|
|
@@ -1116,7 +1116,7 @@ class Session {
|
|
|
1116
1116
|
if (pc.localDescription.type === "offer") {
|
|
1117
1117
|
return pc
|
|
1118
1118
|
.createOffer()
|
|
1119
|
-
.then(
|
|
1119
|
+
.then(offer => {
|
|
1120
1120
|
offer.sdp = replaceSSRCs(pc.localDescription.sdp, offer.sdp);
|
|
1121
1121
|
return pc.setLocalDescription(offer);
|
|
1122
1122
|
})
|
|
@@ -1128,7 +1128,7 @@ class Session {
|
|
|
1128
1128
|
.then(() => {
|
|
1129
1129
|
return pc.createAnswer();
|
|
1130
1130
|
})
|
|
1131
|
-
.then(
|
|
1131
|
+
.then(answer => {
|
|
1132
1132
|
answer.sdp = replaceSSRCs(pc.localDescription.sdp, answer.sdp);
|
|
1133
1133
|
return pc.setLocalDescription(answer);
|
|
1134
1134
|
});
|
|
@@ -1143,7 +1143,7 @@ class Session {
|
|
|
1143
1143
|
if (!this.pc.getStats) {
|
|
1144
1144
|
return;
|
|
1145
1145
|
}
|
|
1146
|
-
isRelayed(this.pc).then(
|
|
1146
|
+
isRelayed(this.pc).then(isRelayed => {
|
|
1147
1147
|
if (isRelayed && this.bandwidth === 0) {
|
|
1148
1148
|
this.changeBandwidth(this.maximumTurnBandwidth);
|
|
1149
1149
|
}
|
|
@@ -4239,7 +4239,7 @@ const CAMERA_STREAM_ID = "0";
|
|
|
4239
4239
|
|
|
4240
4240
|
const logger$2 = console;
|
|
4241
4241
|
|
|
4242
|
-
const browserName$
|
|
4242
|
+
const browserName$1 = adapter.browserDetails.browser;
|
|
4243
4243
|
const browserVersion = adapter.browserDetails.version;
|
|
4244
4244
|
|
|
4245
4245
|
class BaseRtcManager {
|
|
@@ -4279,7 +4279,7 @@ class BaseRtcManager {
|
|
|
4279
4279
|
}
|
|
4280
4280
|
|
|
4281
4281
|
numberOfRemotePeers() {
|
|
4282
|
-
return Object.values(this.peerConnections).filter(
|
|
4282
|
+
return Object.values(this.peerConnections).filter(session => session.clientId !== this._selfId).length;
|
|
4283
4283
|
}
|
|
4284
4284
|
|
|
4285
4285
|
_setConnectionStatus(session, newStatus, clientId) {
|
|
@@ -4353,7 +4353,7 @@ class BaseRtcManager {
|
|
|
4353
4353
|
// Some macs + ios devices have troubles using h264 encoder since safari 14
|
|
4354
4354
|
// this will make them encode VP8 instead if available
|
|
4355
4355
|
const deprioritizeH264Encoding =
|
|
4356
|
-
browserName$
|
|
4356
|
+
browserName$1 === "safari" && browserVersion >= 14 && this._features.deprioritizeH264OnSafari;
|
|
4357
4357
|
|
|
4358
4358
|
this.peerConnections[peerConnectionId] = session = new Session({
|
|
4359
4359
|
peerConnectionId,
|
|
@@ -4372,7 +4372,7 @@ class BaseRtcManager {
|
|
|
4372
4372
|
}
|
|
4373
4373
|
|
|
4374
4374
|
_getNonLocalCameraStreamIds() {
|
|
4375
|
-
return Object.keys(this.localStreams).filter(
|
|
4375
|
+
return Object.keys(this.localStreams).filter(streamId => streamId !== CAMERA_STREAM_ID);
|
|
4376
4376
|
}
|
|
4377
4377
|
|
|
4378
4378
|
_isScreensharingLocally() {
|
|
@@ -4401,7 +4401,7 @@ class BaseRtcManager {
|
|
|
4401
4401
|
}
|
|
4402
4402
|
const session = this._getOrCreateSession(peerConnectionId, initialBandwidth);
|
|
4403
4403
|
const constraints = { optional: [] };
|
|
4404
|
-
if (browserName$
|
|
4404
|
+
if (browserName$1 === "chrome") {
|
|
4405
4405
|
constraints.optional.push({
|
|
4406
4406
|
googCpuOveruseDetection: true,
|
|
4407
4407
|
});
|
|
@@ -4414,13 +4414,13 @@ class BaseRtcManager {
|
|
|
4414
4414
|
const host = this._features.turnServerOverrideHost;
|
|
4415
4415
|
const port = host.indexOf(":") > 0 ? "" : ":443";
|
|
4416
4416
|
const override = ":" + host + port;
|
|
4417
|
-
peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.map(
|
|
4417
|
+
peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.map(original => {
|
|
4418
4418
|
const entry = Object.assign({}, original);
|
|
4419
4419
|
if (entry.url) {
|
|
4420
4420
|
entry.url = entry.url.replace(/:[^?]*/, override);
|
|
4421
4421
|
}
|
|
4422
4422
|
if (entry.urls) {
|
|
4423
|
-
entry.urls = entry.urls.map(
|
|
4423
|
+
entry.urls = entry.urls.map(url => url.replace(/:[^?]*/, override));
|
|
4424
4424
|
}
|
|
4425
4425
|
return entry;
|
|
4426
4426
|
});
|
|
@@ -4434,12 +4434,12 @@ class BaseRtcManager {
|
|
|
4434
4434
|
}[this._features.useOnlyTURN];
|
|
4435
4435
|
if (filter) {
|
|
4436
4436
|
peerConnectionConfig.iceServers = peerConnectionConfig.iceServers.filter(
|
|
4437
|
-
|
|
4437
|
+
entry => entry.url && entry.url.match(filter)
|
|
4438
4438
|
);
|
|
4439
4439
|
}
|
|
4440
4440
|
}
|
|
4441
4441
|
|
|
4442
|
-
if (browserName$
|
|
4442
|
+
if (browserName$1 === "chrome") {
|
|
4443
4443
|
peerConnectionConfig.sdpSemantics = "unified-plan";
|
|
4444
4444
|
}
|
|
4445
4445
|
|
|
@@ -4450,7 +4450,7 @@ class BaseRtcManager {
|
|
|
4450
4450
|
clientId,
|
|
4451
4451
|
});
|
|
4452
4452
|
|
|
4453
|
-
pc.ontrack =
|
|
4453
|
+
pc.ontrack = event => {
|
|
4454
4454
|
const stream = event.streams[0];
|
|
4455
4455
|
if (stream.id === "default" && stream.getAudioTracks().length === 0) {
|
|
4456
4456
|
// due to our PlanB / UnifiedPlan conversion we can run into this:
|
|
@@ -4492,7 +4492,7 @@ class BaseRtcManager {
|
|
|
4492
4492
|
case "completed":
|
|
4493
4493
|
newStatus = TYPES.CONNECTION_SUCCESSFUL;
|
|
4494
4494
|
if (!session.wasEverConnected) {
|
|
4495
|
-
this._pendingActionsForConnectedPeerConnections.forEach(
|
|
4495
|
+
this._pendingActionsForConnectedPeerConnections.forEach(action => {
|
|
4496
4496
|
if (typeof action === "function") {
|
|
4497
4497
|
action();
|
|
4498
4498
|
}
|
|
@@ -4504,7 +4504,7 @@ class BaseRtcManager {
|
|
|
4504
4504
|
if (
|
|
4505
4505
|
!session.wasEverConnected &&
|
|
4506
4506
|
(pc.iceConnectionState.match(/connected|completed/) ||
|
|
4507
|
-
(browserName$
|
|
4507
|
+
(browserName$1 === "chrome" && pc.localDescription && pc.localDescription.type === "answer"))
|
|
4508
4508
|
) {
|
|
4509
4509
|
session.wasEverConnected = true;
|
|
4510
4510
|
if (this._features.bandwidth !== "false") {
|
|
@@ -4575,7 +4575,7 @@ class BaseRtcManager {
|
|
|
4575
4575
|
// Don't add existing screenshare-streams when using SFU as those will be
|
|
4576
4576
|
// added in a separate session/peerConnection
|
|
4577
4577
|
if (shouldAddLocalVideo) {
|
|
4578
|
-
Object.keys(this.localStreams).forEach(
|
|
4578
|
+
Object.keys(this.localStreams).forEach(id => {
|
|
4579
4579
|
if (id === CAMERA_STREAM_ID) {
|
|
4580
4580
|
return;
|
|
4581
4581
|
}
|
|
@@ -4612,27 +4612,27 @@ class BaseRtcManager {
|
|
|
4612
4612
|
}
|
|
4613
4613
|
|
|
4614
4614
|
_forEachPeerConnection(func) {
|
|
4615
|
-
Object.keys(this.peerConnections).forEach(
|
|
4615
|
+
Object.keys(this.peerConnections).forEach(peerConnectionId => {
|
|
4616
4616
|
const peerConnection = this.peerConnections[peerConnectionId];
|
|
4617
4617
|
func(peerConnection);
|
|
4618
4618
|
});
|
|
4619
4619
|
}
|
|
4620
4620
|
|
|
4621
4621
|
_addStreamToPeerConnections(stream) {
|
|
4622
|
-
this._forEachPeerConnection(
|
|
4622
|
+
this._forEachPeerConnection(session => {
|
|
4623
4623
|
this._withForcedRenegotiation(session, () => session.addStream(stream));
|
|
4624
4624
|
});
|
|
4625
4625
|
}
|
|
4626
4626
|
|
|
4627
4627
|
_addTrackToPeerConnections(track, stream) {
|
|
4628
|
-
this._forEachPeerConnection(
|
|
4628
|
+
this._forEachPeerConnection(session => {
|
|
4629
4629
|
this._withForcedRenegotiation(session, () => session.addTrack(track, stream));
|
|
4630
4630
|
});
|
|
4631
4631
|
}
|
|
4632
4632
|
|
|
4633
4633
|
_replaceTrackToPeerConnections(oldTrack, newTrack) {
|
|
4634
4634
|
const promises = [];
|
|
4635
|
-
this._forEachPeerConnection(
|
|
4635
|
+
this._forEachPeerConnection(session => {
|
|
4636
4636
|
if (!session.hasConnectedPeerConnection()) {
|
|
4637
4637
|
logger$2.log("Session doesn't have a connected PeerConnection, adding pending action!");
|
|
4638
4638
|
const pendingActions = this._pendingActionsForConnectedPeerConnections;
|
|
@@ -4650,7 +4650,7 @@ class BaseRtcManager {
|
|
|
4650
4650
|
reject(`ReplaceTrack returned false`);
|
|
4651
4651
|
return;
|
|
4652
4652
|
}
|
|
4653
|
-
replacedTrackPromise.then(
|
|
4653
|
+
replacedTrackPromise.then(track => resolve(track)).catch(error => reject(error));
|
|
4654
4654
|
};
|
|
4655
4655
|
pendingActions.push(action);
|
|
4656
4656
|
});
|
|
@@ -4668,13 +4668,13 @@ class BaseRtcManager {
|
|
|
4668
4668
|
}
|
|
4669
4669
|
|
|
4670
4670
|
_removeStreamFromPeerConnections(stream) {
|
|
4671
|
-
this._forEachPeerConnection(
|
|
4671
|
+
this._forEachPeerConnection(session => {
|
|
4672
4672
|
this._withForcedRenegotiation(session, () => session.removeStream(stream));
|
|
4673
4673
|
});
|
|
4674
4674
|
}
|
|
4675
4675
|
|
|
4676
4676
|
_removeTrackFromPeerConnections(track) {
|
|
4677
|
-
this._forEachPeerConnection(
|
|
4677
|
+
this._forEachPeerConnection(session => {
|
|
4678
4678
|
this._withForcedRenegotiation(session, () => session.removeTrack(track));
|
|
4679
4679
|
});
|
|
4680
4680
|
}
|
|
@@ -4727,11 +4727,11 @@ class BaseRtcManager {
|
|
|
4727
4727
|
}
|
|
4728
4728
|
|
|
4729
4729
|
disconnectAll() {
|
|
4730
|
-
Object.keys(this.peerConnections).forEach(
|
|
4730
|
+
Object.keys(this.peerConnections).forEach(peerConnectionId => {
|
|
4731
4731
|
this.disconnect(peerConnectionId);
|
|
4732
4732
|
});
|
|
4733
4733
|
this.peerConnections = {};
|
|
4734
|
-
this._socketListenerDeregisterFunctions.forEach(
|
|
4734
|
+
this._socketListenerDeregisterFunctions.forEach(func => {
|
|
4735
4735
|
func();
|
|
4736
4736
|
});
|
|
4737
4737
|
this._socketListenerDeregisterFunctions = [];
|
|
@@ -4748,7 +4748,7 @@ class BaseRtcManager {
|
|
|
4748
4748
|
* used in getUserMedia.
|
|
4749
4749
|
*/
|
|
4750
4750
|
fixChromeAudio(constraints) {
|
|
4751
|
-
if (browserName$
|
|
4751
|
+
if (browserName$1 !== "chrome") {
|
|
4752
4752
|
return;
|
|
4753
4753
|
}
|
|
4754
4754
|
const localStream = this._getLocalCameraStream();
|
|
@@ -4756,7 +4756,7 @@ class BaseRtcManager {
|
|
|
4756
4756
|
if (!audioTrack || audioTrack.readyState !== "ended") {
|
|
4757
4757
|
return;
|
|
4758
4758
|
}
|
|
4759
|
-
return navigator.mediaDevices.getUserMedia({ audio: constraints }).then(
|
|
4759
|
+
return navigator.mediaDevices.getUserMedia({ audio: constraints }).then(stream => {
|
|
4760
4760
|
const track = stream.getAudioTracks()[0];
|
|
4761
4761
|
track.enabled = audioTrack.enabled; // retain mute state and don't accidentally unmute.
|
|
4762
4762
|
localStream.removeTrack(audioTrack); // remove the old track.
|
|
@@ -4790,7 +4790,7 @@ class BaseRtcManager {
|
|
|
4790
4790
|
this._socketListenerDeregisterFunctions = [
|
|
4791
4791
|
() => this._clearMediaServersRefresh(),
|
|
4792
4792
|
|
|
4793
|
-
this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG,
|
|
4793
|
+
this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, data => {
|
|
4794
4794
|
if (data.error) {
|
|
4795
4795
|
logger$2.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
|
|
4796
4796
|
return;
|
|
@@ -4798,11 +4798,11 @@ class BaseRtcManager {
|
|
|
4798
4798
|
this._updateAndScheduleMediaServersRefresh(data);
|
|
4799
4799
|
}),
|
|
4800
4800
|
|
|
4801
|
-
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER,
|
|
4801
|
+
this._serverSocket.on(RELAY_MESSAGES.READY_TO_RECEIVE_OFFER, data => {
|
|
4802
4802
|
this._connect(data.clientId);
|
|
4803
4803
|
}),
|
|
4804
4804
|
|
|
4805
|
-
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE,
|
|
4805
|
+
this._serverSocket.on(RELAY_MESSAGES.ICE_CANDIDATE, data => {
|
|
4806
4806
|
const session = this._getSession(data.clientId);
|
|
4807
4807
|
if (!session) {
|
|
4808
4808
|
logger$2.warn("No RTCPeerConnection on ICE_CANDIDATE", data);
|
|
@@ -4811,7 +4811,7 @@ class BaseRtcManager {
|
|
|
4811
4811
|
session.addIceCandidate(data.message);
|
|
4812
4812
|
}),
|
|
4813
4813
|
|
|
4814
|
-
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES,
|
|
4814
|
+
this._serverSocket.on(RELAY_MESSAGES.ICE_END_OF_CANDIDATES, data => {
|
|
4815
4815
|
const session = this._getSession(data.clientId);
|
|
4816
4816
|
if (!session) {
|
|
4817
4817
|
logger$2.warn("No RTCPeerConnection on ICE_END_OF_CANDIDATES", data);
|
|
@@ -4821,14 +4821,14 @@ class BaseRtcManager {
|
|
|
4821
4821
|
}),
|
|
4822
4822
|
|
|
4823
4823
|
// when a new SDP offer is received from another client
|
|
4824
|
-
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER,
|
|
4824
|
+
this._serverSocket.on(RELAY_MESSAGES.SDP_OFFER, data => {
|
|
4825
4825
|
const session = this._getSession(data.clientId);
|
|
4826
4826
|
if (!session) {
|
|
4827
4827
|
logger$2.warn("No RTCPeerConnection on SDP_OFFER", data);
|
|
4828
4828
|
return;
|
|
4829
4829
|
}
|
|
4830
4830
|
const offer = this._transformIncomingSdp(data.message, session.pc);
|
|
4831
|
-
session.handleOffer(offer).then(
|
|
4831
|
+
session.handleOffer(offer).then(answer => {
|
|
4832
4832
|
this._emitServerEvent(RELAY_MESSAGES.SDP_ANSWER, {
|
|
4833
4833
|
receiverId: data.clientId,
|
|
4834
4834
|
message: this._transformOutgoingSdp(answer),
|
|
@@ -4837,7 +4837,7 @@ class BaseRtcManager {
|
|
|
4837
4837
|
}),
|
|
4838
4838
|
|
|
4839
4839
|
// when a new SDP answer is received from another client
|
|
4840
|
-
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER,
|
|
4840
|
+
this._serverSocket.on(RELAY_MESSAGES.SDP_ANSWER, data => {
|
|
4841
4841
|
const session = this._getSession(data.clientId);
|
|
4842
4842
|
if (!session) {
|
|
4843
4843
|
logger$2.warn("No RTCPeerConnection on SDP_ANSWER", data);
|
|
@@ -4855,7 +4855,7 @@ class BaseRtcManager {
|
|
|
4855
4855
|
}
|
|
4856
4856
|
|
|
4857
4857
|
const logger$1 = console;
|
|
4858
|
-
const browserName
|
|
4858
|
+
const browserName = adapter.browserDetails.browser;
|
|
4859
4859
|
class P2pRtcManager extends BaseRtcManager {
|
|
4860
4860
|
_connect(clientId) {
|
|
4861
4861
|
const shouldAddLocalVideo = true;
|
|
@@ -4907,7 +4907,7 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
4907
4907
|
session.isOperationPending = true;
|
|
4908
4908
|
|
|
4909
4909
|
pc.createOffer(constraints || this.offerOptions)
|
|
4910
|
-
.then(
|
|
4910
|
+
.then(offer => {
|
|
4911
4911
|
this._emitServerEvent(RELAY_MESSAGES.SDP_OFFER, {
|
|
4912
4912
|
receiverId: clientId,
|
|
4913
4913
|
message: this._transformOutgoingSdp(offer),
|
|
@@ -4916,17 +4916,17 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
4916
4916
|
// workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1394602
|
|
4917
4917
|
// make Chrome send media later when there are two (more more?) video tracks.
|
|
4918
4918
|
if (
|
|
4919
|
-
browserName
|
|
4920
|
-
pc.getSenders().filter(
|
|
4919
|
+
browserName === "chrome" &&
|
|
4920
|
+
pc.getSenders().filter(sender => sender.track && sender.track.kind === "video").length >= 2
|
|
4921
4921
|
) {
|
|
4922
4922
|
session.pendingOffer = offer;
|
|
4923
4923
|
return;
|
|
4924
4924
|
}
|
|
4925
|
-
pc.setLocalDescription(offer).catch(
|
|
4925
|
+
pc.setLocalDescription(offer).catch(e => {
|
|
4926
4926
|
logger$1.warn("RTCPeerConnection.setLocalDescription() failed with local offer", e);
|
|
4927
4927
|
});
|
|
4928
4928
|
})
|
|
4929
|
-
.catch(
|
|
4929
|
+
.catch(e => {
|
|
4930
4930
|
logger$1.warn("RTCPeerConnection.createOffer() failed to create local offer", e);
|
|
4931
4931
|
});
|
|
4932
4932
|
}
|
|
@@ -4976,7 +4976,7 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
4976
4976
|
return 0;
|
|
4977
4977
|
}
|
|
4978
4978
|
|
|
4979
|
-
this._forEachPeerConnection(
|
|
4979
|
+
this._forEachPeerConnection(session => {
|
|
4980
4980
|
session.changeBandwidth(bandwidth);
|
|
4981
4981
|
});
|
|
4982
4982
|
|
|
@@ -5007,7 +5007,7 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
5007
5007
|
pc.addTrack(this._stoppedVideoTrack, localCameraStream);
|
|
5008
5008
|
}
|
|
5009
5009
|
|
|
5010
|
-
pc.onicecandidate =
|
|
5010
|
+
pc.onicecandidate = event => {
|
|
5011
5011
|
if (event.candidate) {
|
|
5012
5012
|
session.relayCandidateSeen = session.relayCandidateSeen || event.candidate.type === "relay";
|
|
5013
5013
|
this._emitServerEvent(RELAY_MESSAGES.ICE_CANDIDATE, {
|
|
@@ -5064,7 +5064,7 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
5064
5064
|
const numPeers = this.numberOfPeerconnections();
|
|
5065
5065
|
if (numPeers === 0) {
|
|
5066
5066
|
setTimeout(() => {
|
|
5067
|
-
this.numberOfPeerconnections();
|
|
5067
|
+
//const numPeers = this.numberOfPeerconnections();
|
|
5068
5068
|
}, 60 * 1000);
|
|
5069
5069
|
}
|
|
5070
5070
|
}
|
|
@@ -5078,13 +5078,13 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
5078
5078
|
|
|
5079
5079
|
stopOrResumeVideo(localStream, enable) {
|
|
5080
5080
|
// actually turn off the camera. Chrome-only (Firefox has different plans)
|
|
5081
|
-
if (browserName
|
|
5081
|
+
if (browserName !== "chrome") {
|
|
5082
5082
|
return;
|
|
5083
5083
|
}
|
|
5084
5084
|
if (enable === false) {
|
|
5085
5085
|
// try to stop the local camera so the camera light goes off.
|
|
5086
5086
|
setTimeout(() => {
|
|
5087
|
-
localStream.getVideoTracks().forEach(
|
|
5087
|
+
localStream.getVideoTracks().forEach(track => {
|
|
5088
5088
|
if (track.enabled === false) {
|
|
5089
5089
|
track.stop();
|
|
5090
5090
|
localStream.removeTrack(track);
|
|
@@ -5123,7 +5123,7 @@ class P2pRtcManager extends BaseRtcManager {
|
|
|
5123
5123
|
// device has been plugged out or similar
|
|
5124
5124
|
return;
|
|
5125
5125
|
}
|
|
5126
|
-
navigator.mediaDevices.getUserMedia({ video: constraints }).then(
|
|
5126
|
+
navigator.mediaDevices.getUserMedia({ video: constraints }).then(stream => {
|
|
5127
5127
|
const track = stream.getVideoTracks()[0];
|
|
5128
5128
|
localStream.addTrack(track);
|
|
5129
5129
|
this._emit(EVENTS.LOCAL_STREAM_TRACK_ADDED, {
|
|
@@ -5309,7 +5309,7 @@ class VegaConnection extends EventEmitter {
|
|
|
5309
5309
|
this.socket.onerror = null;
|
|
5310
5310
|
this.socket = null;
|
|
5311
5311
|
|
|
5312
|
-
this.sents.forEach(
|
|
5312
|
+
this.sents.forEach(sent => sent.close());
|
|
5313
5313
|
|
|
5314
5314
|
this.emit("close");
|
|
5315
5315
|
}
|
|
@@ -5383,13 +5383,13 @@ class VegaConnection extends EventEmitter {
|
|
|
5383
5383
|
const sent = {
|
|
5384
5384
|
id: request.id,
|
|
5385
5385
|
method: request.method,
|
|
5386
|
-
resolve:
|
|
5386
|
+
resolve: data2 => {
|
|
5387
5387
|
if (!this.sents.delete(request.id)) return;
|
|
5388
5388
|
|
|
5389
5389
|
clearTimeout(sent.timer);
|
|
5390
5390
|
pResolve(data2);
|
|
5391
5391
|
},
|
|
5392
|
-
reject:
|
|
5392
|
+
reject: error => {
|
|
5393
5393
|
if (!this.sents.delete(request.id)) return;
|
|
5394
5394
|
|
|
5395
5395
|
clearTimeout(sent.timer);
|
|
@@ -5487,30 +5487,30 @@ const modifyMediaCapabilities = (routerRtpCapabilities, features) => {
|
|
|
5487
5487
|
|
|
5488
5488
|
if (vp9On) {
|
|
5489
5489
|
const { preferredPayloadType } = routerRtpCapabilities.codecs.find(
|
|
5490
|
-
|
|
5490
|
+
codec => codec.mimeType.toLowerCase() === "video/vp9"
|
|
5491
5491
|
);
|
|
5492
5492
|
|
|
5493
5493
|
const { preferredPayloadType: aptPreferredPayloadType } = routerRtpCapabilities.codecs.find(
|
|
5494
|
-
|
|
5494
|
+
codec => codec.mimeType.toLowerCase() === "video/rtx" && codec.parameters.apt === preferredPayloadType
|
|
5495
5495
|
);
|
|
5496
5496
|
|
|
5497
5497
|
routerRtpCapabilities.codecs = routerRtpCapabilities.codecs.filter(
|
|
5498
|
-
|
|
5498
|
+
codec =>
|
|
5499
5499
|
codec.kind === "audio" ||
|
|
5500
5500
|
codec.preferredPayloadType === preferredPayloadType ||
|
|
5501
5501
|
codec.preferredPayloadType === aptPreferredPayloadType
|
|
5502
5502
|
);
|
|
5503
5503
|
} else if (h264On) {
|
|
5504
5504
|
const { preferredPayloadType } = routerRtpCapabilities.codecs.find(
|
|
5505
|
-
|
|
5505
|
+
codec => codec.mimeType.toLowerCase() === "video/h264"
|
|
5506
5506
|
);
|
|
5507
5507
|
|
|
5508
5508
|
const { preferredPayloadType: aptPreferredPayloadType } = routerRtpCapabilities.codecs.find(
|
|
5509
|
-
|
|
5509
|
+
codec => codec.mimeType.toLowerCase() === "video/rtx" && codec.parameters.apt === preferredPayloadType
|
|
5510
5510
|
);
|
|
5511
5511
|
|
|
5512
5512
|
routerRtpCapabilities.codecs = routerRtpCapabilities.codecs.filter(
|
|
5513
|
-
|
|
5513
|
+
codec =>
|
|
5514
5514
|
codec.kind === "audio" ||
|
|
5515
5515
|
codec.preferredPayloadType === preferredPayloadType ||
|
|
5516
5516
|
codec.preferredPayloadType === aptPreferredPayloadType
|
|
@@ -5544,7 +5544,7 @@ const maybeTurnOnly = (transportConfig, features) => {
|
|
|
5544
5544
|
}[features.useOnlyTURN];
|
|
5545
5545
|
|
|
5546
5546
|
if (filter) {
|
|
5547
|
-
transportConfig.iceServers = transportConfig.iceServers.filter(
|
|
5547
|
+
transportConfig.iceServers = transportConfig.iceServers.filter(entry => entry.url && entry.url.match(filter));
|
|
5548
5548
|
}
|
|
5549
5549
|
};
|
|
5550
5550
|
|
|
@@ -5648,7 +5648,7 @@ class VegaRtcManager {
|
|
|
5648
5648
|
this._socketListenerDeregisterFunctions.push(
|
|
5649
5649
|
() => this._clearMediaServersRefresh(),
|
|
5650
5650
|
|
|
5651
|
-
this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG,
|
|
5651
|
+
this._serverSocket.on(PROTOCOL_RESPONSES.MEDIASERVER_CONFIG, data => {
|
|
5652
5652
|
if (data.error) {
|
|
5653
5653
|
logger.warn("FETCH_MEDIASERVER_CONFIG failed:", data.error);
|
|
5654
5654
|
return;
|
|
@@ -5685,7 +5685,7 @@ class VegaRtcManager {
|
|
|
5685
5685
|
this._vegaConnection = new VegaConnection(wsUrl, logger);
|
|
5686
5686
|
this._vegaConnection.on("open", () => this._join());
|
|
5687
5687
|
this._vegaConnection.on("close", () => this._onClose());
|
|
5688
|
-
this._vegaConnection.on("message",
|
|
5688
|
+
this._vegaConnection.on("message", message => this._onMessage(message));
|
|
5689
5689
|
}
|
|
5690
5690
|
|
|
5691
5691
|
_onClose() {
|
|
@@ -5766,7 +5766,7 @@ class VegaRtcManager {
|
|
|
5766
5766
|
maybeTurnOnly(transportOptions, this._features);
|
|
5767
5767
|
|
|
5768
5768
|
const transport = this._mediasoupDevice[creator](transportOptions);
|
|
5769
|
-
const onConnectionStateListener = async
|
|
5769
|
+
const onConnectionStateListener = async connectionState => {
|
|
5770
5770
|
logger.debug(`Transport ConnectionStateChanged ${connectionState}`);
|
|
5771
5771
|
if (connectionState !== "disconnected" && connectionState !== "failed") {
|
|
5772
5772
|
return;
|
|
@@ -5878,7 +5878,7 @@ class VegaRtcManager {
|
|
|
5878
5878
|
const error = await transport
|
|
5879
5879
|
.restartIce({ iceParameters })
|
|
5880
5880
|
.then(() => null)
|
|
5881
|
-
.catch(
|
|
5881
|
+
.catch(err => err);
|
|
5882
5882
|
|
|
5883
5883
|
if (error) {
|
|
5884
5884
|
logger.error(`_restartIce: ICE restart failed: ${error}`);
|
|
@@ -5889,7 +5889,7 @@ class VegaRtcManager {
|
|
|
5889
5889
|
break;
|
|
5890
5890
|
default:
|
|
5891
5891
|
// exponential backoff
|
|
5892
|
-
await new Promise(
|
|
5892
|
+
await new Promise(resolve => {
|
|
5893
5893
|
setTimeout(() => {
|
|
5894
5894
|
resolve();
|
|
5895
5895
|
}, Math.min(RESTARTICE_ERROR_RETRY_THRESHOLD_IN_MS * 2 ** retried, 60000));
|
|
@@ -5899,7 +5899,7 @@ class VegaRtcManager {
|
|
|
5899
5899
|
}
|
|
5900
5900
|
return;
|
|
5901
5901
|
}
|
|
5902
|
-
await new Promise(
|
|
5902
|
+
await new Promise(resolve => {
|
|
5903
5903
|
setTimeout(() => {
|
|
5904
5904
|
resolve();
|
|
5905
5905
|
}, 60000 * Math.min(8, retried + 1));
|
|
@@ -6473,54 +6473,6 @@ class VegaRtcManager {
|
|
|
6473
6473
|
this._webcamPaused = !enable;
|
|
6474
6474
|
|
|
6475
6475
|
this._pauseResumeWebcam();
|
|
6476
|
-
|
|
6477
|
-
if (browserName === "chrome") {
|
|
6478
|
-
// actually turn off the camera. Chrome-only (Firefox etc. has different plans)
|
|
6479
|
-
|
|
6480
|
-
if (!enable) {
|
|
6481
|
-
clearTimeout(this._stopCameraTimeout);
|
|
6482
|
-
|
|
6483
|
-
// try to stop the local camera so the camera light goes off.
|
|
6484
|
-
this._stopCameraTimeout = setTimeout(() => {
|
|
6485
|
-
localStream.getVideoTracks().forEach((track) => {
|
|
6486
|
-
if (track.enabled === false) {
|
|
6487
|
-
track.stop();
|
|
6488
|
-
localStream.removeTrack(track);
|
|
6489
|
-
|
|
6490
|
-
this._emitToPWA(EVENTS.LOCAL_STREAM_TRACK_REMOVED, {
|
|
6491
|
-
stream: localStream,
|
|
6492
|
-
track,
|
|
6493
|
-
});
|
|
6494
|
-
|
|
6495
|
-
if (
|
|
6496
|
-
this._webcamProducer &&
|
|
6497
|
-
!this._webcamProducer.closed &&
|
|
6498
|
-
this._webcamProducer.track === track
|
|
6499
|
-
) {
|
|
6500
|
-
this._stopProducer(this._webcamProducer);
|
|
6501
|
-
this._webcamProducer = null;
|
|
6502
|
-
this._webcamTrack = null;
|
|
6503
|
-
}
|
|
6504
|
-
}
|
|
6505
|
-
});
|
|
6506
|
-
}, 5000);
|
|
6507
|
-
} else if (localStream.getVideoTracks().length === 0) {
|
|
6508
|
-
// re-enable the stream
|
|
6509
|
-
const constraints = this._webrtcProvider.getMediaConstraints().video;
|
|
6510
|
-
navigator.mediaDevices.getUserMedia({ video: constraints }).then((stream) => {
|
|
6511
|
-
const track = stream.getVideoTracks()[0];
|
|
6512
|
-
localStream.addTrack(track);
|
|
6513
|
-
|
|
6514
|
-
this._emitToPWA(EVENTS.LOCAL_STREAM_TRACK_ADDED, {
|
|
6515
|
-
streamId: localStream.id,
|
|
6516
|
-
tracks: [track],
|
|
6517
|
-
screenShare: false,
|
|
6518
|
-
});
|
|
6519
|
-
|
|
6520
|
-
this._sendWebcam(track);
|
|
6521
|
-
});
|
|
6522
|
-
}
|
|
6523
|
-
}
|
|
6524
6476
|
}
|
|
6525
6477
|
|
|
6526
6478
|
supportsScreenShareAudio() {
|
|
@@ -6587,7 +6539,7 @@ class VegaRtcManager {
|
|
|
6587
6539
|
}
|
|
6588
6540
|
|
|
6589
6541
|
disconnectAll() {
|
|
6590
|
-
this._socketListenerDeregisterFunctions.forEach(
|
|
6542
|
+
this._socketListenerDeregisterFunctions.forEach(func => {
|
|
6591
6543
|
func();
|
|
6592
6544
|
});
|
|
6593
6545
|
|
|
@@ -6630,7 +6582,7 @@ class VegaRtcManager {
|
|
|
6630
6582
|
return;
|
|
6631
6583
|
}
|
|
6632
6584
|
})
|
|
6633
|
-
.catch(
|
|
6585
|
+
.catch(error => {
|
|
6634
6586
|
console.error('"message" failed [error:%o]', error);
|
|
6635
6587
|
});
|
|
6636
6588
|
}
|
|
@@ -6765,7 +6717,7 @@ class VegaRtcManager {
|
|
|
6765
6717
|
const toPauseConsumers = [];
|
|
6766
6718
|
const toResumeConsumers = [];
|
|
6767
6719
|
|
|
6768
|
-
this._consumers.forEach(
|
|
6720
|
+
this._consumers.forEach(consumer => {
|
|
6769
6721
|
if (consumer.appData.sourceClientId !== clientId) return;
|
|
6770
6722
|
|
|
6771
6723
|
const hasAccepted = consumer.appData.screenShare ? hasAcceptedScreenStream : hasAcceptedWebcamStream;
|
|
@@ -6803,6 +6755,7 @@ class VegaRtcManager {
|
|
|
6803
6755
|
clientId,
|
|
6804
6756
|
stream: webcamStream,
|
|
6805
6757
|
streamId: camStreamId,
|
|
6758
|
+
streamType: "webcam",
|
|
6806
6759
|
});
|
|
6807
6760
|
|
|
6808
6761
|
clientState.hasEmittedWebcamStream = true;
|
|
@@ -6814,6 +6767,7 @@ class VegaRtcManager {
|
|
|
6814
6767
|
clientId,
|
|
6815
6768
|
stream: screenStream,
|
|
6816
6769
|
streamId: screenShareStreamId,
|
|
6770
|
+
streamType: "screenshare",
|
|
6817
6771
|
});
|
|
6818
6772
|
|
|
6819
6773
|
clientState.hasEmittedScreenStream = true;
|
|
@@ -8316,6 +8270,15 @@ class RemoteParticipant extends RoomParticipant {
|
|
|
8316
8270
|
this.newJoiner = newJoiner;
|
|
8317
8271
|
this.streams = streams.map((streamId) => ({ id: streamId, state: newJoiner ? "new_accept" : "to_accept" }));
|
|
8318
8272
|
}
|
|
8273
|
+
addStream(streamId, state) {
|
|
8274
|
+
this.streams.push({ id: streamId, state });
|
|
8275
|
+
}
|
|
8276
|
+
removeStream(streamId) {
|
|
8277
|
+
const index = this.streams.findIndex((s) => s.id === streamId);
|
|
8278
|
+
if (index !== -1) {
|
|
8279
|
+
this.streams.splice(index, 1);
|
|
8280
|
+
}
|
|
8281
|
+
}
|
|
8319
8282
|
updateStreamState(streamId, state) {
|
|
8320
8283
|
const stream = this.streams.find((s) => s.id === streamId);
|
|
8321
8284
|
if (stream) {
|
|
@@ -8357,6 +8320,7 @@ class RoomConnection extends TypedEventTarget {
|
|
|
8357
8320
|
super();
|
|
8358
8321
|
this.localParticipant = null;
|
|
8359
8322
|
this.remoteParticipants = [];
|
|
8323
|
+
this.screenshares = [];
|
|
8360
8324
|
this._deviceCredentials = null;
|
|
8361
8325
|
this._ownsLocalMedia = false;
|
|
8362
8326
|
this.organizationId = "";
|
|
@@ -8418,6 +8382,8 @@ class RoomConnection extends TypedEventTarget {
|
|
|
8418
8382
|
this.signalSocket.on("room_joined", this._handleRoomJoined.bind(this));
|
|
8419
8383
|
this.signalSocket.on("room_knocked", this._handleRoomKnocked.bind(this));
|
|
8420
8384
|
this.signalSocket.on("cloud_recording_stopped", this._handleCloudRecordingStopped.bind(this));
|
|
8385
|
+
this.signalSocket.on("screenshare_started", this._handleScreenshareStarted.bind(this));
|
|
8386
|
+
this.signalSocket.on("screenshare_stopped", this._handleScreenshareStopped.bind(this));
|
|
8421
8387
|
this.signalSocket.on("streaming_stopped", this._handleStreamingStopped.bind(this));
|
|
8422
8388
|
this.signalSocket.on("disconnect", this._handleDisconnect.bind(this));
|
|
8423
8389
|
this.signalSocket.on("connect_error", this._handleDisconnect.bind(this));
|
|
@@ -8635,6 +8601,33 @@ class RoomConnection extends TypedEventTarget {
|
|
|
8635
8601
|
_handleStreamingStopped() {
|
|
8636
8602
|
this.dispatchEvent(new CustomEvent("streaming_stopped"));
|
|
8637
8603
|
}
|
|
8604
|
+
_handleScreenshareStarted(screenshare) {
|
|
8605
|
+
const { clientId: participantId, streamId: id, hasAudioTrack } = screenshare;
|
|
8606
|
+
const remoteParticipant = this.remoteParticipants.find((p) => p.id === participantId);
|
|
8607
|
+
if (!remoteParticipant) {
|
|
8608
|
+
this.logger.log("WARN: Could not find participant for screenshare");
|
|
8609
|
+
return;
|
|
8610
|
+
}
|
|
8611
|
+
const foundScreenshare = this.screenshares.find((s) => s.id === id);
|
|
8612
|
+
if (foundScreenshare) {
|
|
8613
|
+
this.logger.log("WARN: Screenshare already exists");
|
|
8614
|
+
return;
|
|
8615
|
+
}
|
|
8616
|
+
remoteParticipant.addStream(id, "to_accept");
|
|
8617
|
+
this._handleAcceptStreams([remoteParticipant]);
|
|
8618
|
+
this.screenshares = [...this.screenshares, { participantId, id, hasAudioTrack, stream: undefined }];
|
|
8619
|
+
}
|
|
8620
|
+
_handleScreenshareStopped(screenshare) {
|
|
8621
|
+
const { clientId: participantId, streamId: id } = screenshare;
|
|
8622
|
+
const remoteParticipant = this.remoteParticipants.find((p) => p.id === participantId);
|
|
8623
|
+
if (!remoteParticipant) {
|
|
8624
|
+
this.logger.log("WARN: Could not find participant for screenshare");
|
|
8625
|
+
return;
|
|
8626
|
+
}
|
|
8627
|
+
remoteParticipant.removeStream(id);
|
|
8628
|
+
this.screenshares = this.screenshares.filter((s) => !(s.participantId === participantId && s.id === id));
|
|
8629
|
+
this.dispatchEvent(new CustomEvent("screenshare_stopped", { detail: { participantId, id } }));
|
|
8630
|
+
}
|
|
8638
8631
|
_handleRtcEvent(eventName, data) {
|
|
8639
8632
|
if (eventName === "rtc_manager_created") {
|
|
8640
8633
|
return this._handleRtcManagerCreated(data);
|
|
@@ -8711,13 +8704,24 @@ class RoomConnection extends TypedEventTarget {
|
|
|
8711
8704
|
});
|
|
8712
8705
|
});
|
|
8713
8706
|
}
|
|
8714
|
-
_handleStreamAdded({ clientId, stream, streamId }) {
|
|
8707
|
+
_handleStreamAdded({ clientId, stream, streamId, streamType }) {
|
|
8715
8708
|
const remoteParticipant = this.remoteParticipants.find((p) => p.id === clientId);
|
|
8716
8709
|
if (!remoteParticipant) {
|
|
8717
8710
|
this.logger.log("WARN: Could not find participant for incoming stream");
|
|
8718
8711
|
return;
|
|
8719
8712
|
}
|
|
8720
|
-
|
|
8713
|
+
const remoteParticipantStream = remoteParticipant.streams.find((s) => s.id === streamId);
|
|
8714
|
+
if ((remoteParticipant.stream && remoteParticipant.stream.id === streamId) ||
|
|
8715
|
+
(!remoteParticipant.stream && streamType === "webcam") ||
|
|
8716
|
+
(!remoteParticipant.stream &&
|
|
8717
|
+
!streamType &&
|
|
8718
|
+
remoteParticipantStream &&
|
|
8719
|
+
remoteParticipant.streams.indexOf(remoteParticipantStream) < 1)) {
|
|
8720
|
+
this.dispatchEvent(new CustomEvent("participant_stream_added", { detail: { participantId: clientId, stream, streamId } }));
|
|
8721
|
+
return;
|
|
8722
|
+
}
|
|
8723
|
+
// screenshare
|
|
8724
|
+
this.dispatchEvent(new CustomEvent("screenshare_started", { detail: { participantId: clientId, stream, id: streamId } }));
|
|
8721
8725
|
}
|
|
8722
8726
|
_joinRoom() {
|
|
8723
8727
|
this.signalSocket.emit("join_room", {
|
|
@@ -8843,6 +8847,7 @@ const initialState = {
|
|
|
8843
8847
|
mostRecentChatMessage: null,
|
|
8844
8848
|
remoteParticipants: [],
|
|
8845
8849
|
roomConnectionStatus: "",
|
|
8850
|
+
screenshares: [],
|
|
8846
8851
|
streaming: {
|
|
8847
8852
|
status: "",
|
|
8848
8853
|
startedAt: null,
|
|
@@ -8861,6 +8866,13 @@ function updateParticipant(remoteParticipants, participantId, updates) {
|
|
|
8861
8866
|
...remoteParticipants.slice(index + 1),
|
|
8862
8867
|
];
|
|
8863
8868
|
}
|
|
8869
|
+
function addScreenshare(screenshares, screenshare) {
|
|
8870
|
+
const existingScreenshare = screenshares.find((ss) => ss.id === screenshare.id);
|
|
8871
|
+
if (existingScreenshare) {
|
|
8872
|
+
return screenshares;
|
|
8873
|
+
}
|
|
8874
|
+
return [...screenshares, screenshare];
|
|
8875
|
+
}
|
|
8864
8876
|
function reducer(state, action) {
|
|
8865
8877
|
switch (action.type) {
|
|
8866
8878
|
case "CHAT_MESSAGE":
|
|
@@ -8903,6 +8915,15 @@ function reducer(state, action) {
|
|
|
8903
8915
|
if (!state.localParticipant)
|
|
8904
8916
|
return state;
|
|
8905
8917
|
return Object.assign(Object.assign({}, state), { localParticipant: Object.assign(Object.assign({}, state.localParticipant), { displayName: action.payload.displayName }) });
|
|
8918
|
+
case "SCREENSHARE_STARTED":
|
|
8919
|
+
return Object.assign(Object.assign({}, state), { screenshares: addScreenshare(state.screenshares, {
|
|
8920
|
+
participantId: action.payload.participantId,
|
|
8921
|
+
id: action.payload.id,
|
|
8922
|
+
hasAudioTrack: action.payload.hasAudioTrack,
|
|
8923
|
+
stream: action.payload.stream,
|
|
8924
|
+
}) });
|
|
8925
|
+
case "SCREENSHARE_STOPPED":
|
|
8926
|
+
return Object.assign(Object.assign({}, state), { screenshares: state.screenshares.filter((ss) => ss.participantId !== action.payload.participantId || ss.id !== action.payload.id) });
|
|
8906
8927
|
case "STREAMING_STARTED":
|
|
8907
8928
|
return Object.assign(Object.assign({}, state), { streaming: {
|
|
8908
8929
|
status: action.payload.status,
|
|
@@ -8974,6 +8995,14 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
8974
8995
|
const { participantId, displayName } = e.detail;
|
|
8975
8996
|
dispatch({ type: "PARTICIPANT_METADATA_CHANGED", payload: { participantId, displayName } });
|
|
8976
8997
|
});
|
|
8998
|
+
roomConnection.addEventListener("screenshare_started", (e) => {
|
|
8999
|
+
const { participantId, id, hasAudioTrack, stream } = e.detail;
|
|
9000
|
+
dispatch({ type: "SCREENSHARE_STARTED", payload: { participantId, id, hasAudioTrack, stream } });
|
|
9001
|
+
});
|
|
9002
|
+
roomConnection.addEventListener("screenshare_stopped", (e) => {
|
|
9003
|
+
const { participantId, id } = e.detail;
|
|
9004
|
+
dispatch({ type: "SCREENSHARE_STOPPED", payload: { participantId, id } });
|
|
9005
|
+
});
|
|
8977
9006
|
roomConnection.addEventListener("streaming_started", (e) => {
|
|
8978
9007
|
const { status, startedAt } = e.detail;
|
|
8979
9008
|
dispatch({ type: "STREAMING_STARTED", payload: { status, startedAt } });
|
|
@@ -9027,6 +9056,6 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
9027
9056
|
};
|
|
9028
9057
|
}
|
|
9029
9058
|
|
|
9030
|
-
const sdkVersion = "2.0.0-
|
|
9059
|
+
const sdkVersion = "2.0.0-alpha17";
|
|
9031
9060
|
|
|
9032
9061
|
export { VideoView, sdkVersion, useLocalMedia, useRoomConnection };
|