You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Pass through eslint --fix
This commit is contained in:
@@ -18,9 +18,9 @@ limitations under the License.
|
||||
* This is an internal module. See {@link createNewMatrixCall} for the public API.
|
||||
* @module webrtc/call
|
||||
*/
|
||||
var utils = require("../utils");
|
||||
var EventEmitter = require("events").EventEmitter;
|
||||
var DEBUG = true; // set true to enable console logging.
|
||||
let utils = require("../utils");
|
||||
let EventEmitter = require("events").EventEmitter;
|
||||
let DEBUG = true; // set true to enable console logging.
|
||||
|
||||
// events: hangup, error(err), replaced(call), state(state, oldState)
|
||||
|
||||
@@ -43,7 +43,7 @@ function MatrixCall(opts) {
|
||||
this.turnServers = opts.turnServers || [];
|
||||
if (this.turnServers.length === 0) {
|
||||
this.turnServers.push({
|
||||
urls: [MatrixCall.FALLBACK_STUN_SERVER]
|
||||
urls: [MatrixCall.FALLBACK_STUN_SERVER],
|
||||
});
|
||||
}
|
||||
utils.forEach(this.turnServers, function(server) {
|
||||
@@ -122,21 +122,20 @@ MatrixCall.prototype.placeVideoCall = function(remoteVideoElement, localVideoEle
|
||||
* @throws If you have not specified a listener for 'error' events.
|
||||
*/
|
||||
MatrixCall.prototype.placeScreenSharingCall =
|
||||
function(remoteVideoElement, localVideoElement)
|
||||
{
|
||||
function(remoteVideoElement, localVideoElement) {
|
||||
debuglog("placeScreenSharingCall");
|
||||
checkForErrorListener(this);
|
||||
var screenConstraints = _getChromeScreenSharingConstraints(this);
|
||||
let screenConstraints = _getChromeScreenSharingConstraints(this);
|
||||
if (!screenConstraints) {
|
||||
return;
|
||||
}
|
||||
this.localVideoElement = localVideoElement;
|
||||
this.remoteVideoElement = remoteVideoElement;
|
||||
var self = this;
|
||||
let self = this;
|
||||
this.webRtc.getUserMedia(screenConstraints, function(stream) {
|
||||
self.screenSharingStream = stream;
|
||||
debuglog("Got screen stream, requesting audio stream...");
|
||||
var audioConstraints = _getUserMediaVideoContraints('voice');
|
||||
let audioConstraints = _getUserMediaVideoContraints('voice');
|
||||
_placeCallWithConstraints(self, audioConstraints);
|
||||
}, function(err) {
|
||||
self.emit("error",
|
||||
@@ -174,8 +173,7 @@ MatrixCall.prototype.playElement = function(element, queueId) {
|
||||
console.log("previous promise failed for " + queueId);
|
||||
return element.play();
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.mediaPromises[queueId] = element.play();
|
||||
}
|
||||
};
|
||||
@@ -197,8 +195,7 @@ MatrixCall.prototype.pauseElement = function(element, queueId) {
|
||||
console.log("previous promise failed for " + queueId);
|
||||
return element.pause();
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// pause doesn't actually return a promise, but do this for symmetry
|
||||
// and just in case it does in future.
|
||||
this.mediaPromises[queueId] = element.pause();
|
||||
@@ -224,8 +221,7 @@ MatrixCall.prototype.assignElement = function(element, src, queueId) {
|
||||
console.log("previous promise failed for " + queueId);
|
||||
element.src = src;
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
element.src = src;
|
||||
}
|
||||
};
|
||||
@@ -270,9 +266,9 @@ MatrixCall.prototype.setLocalVideoElement = function(element) {
|
||||
this.URL.createObjectURL(this.localAVStream),
|
||||
"localVideo");
|
||||
element.muted = true;
|
||||
var self = this;
|
||||
let self = this;
|
||||
setTimeout(function() {
|
||||
var vel = self.getLocalVideoElement();
|
||||
let vel = self.getLocalVideoElement();
|
||||
if (vel.play) {
|
||||
self.playElement(vel, "localVideo");
|
||||
}
|
||||
@@ -310,7 +306,7 @@ MatrixCall.prototype.setRemoteAudioElement = function(element) {
|
||||
MatrixCall.prototype._initWithInvite = function(event) {
|
||||
this.msg = event.getContent();
|
||||
this.peerConn = _createPeerConnection(this);
|
||||
var self = this;
|
||||
let self = this;
|
||||
if (this.peerConn) {
|
||||
this.peerConn.setRemoteDescription(
|
||||
new this.webRtc.RtcSessionDescription(this.msg.offer),
|
||||
@@ -330,8 +326,7 @@ MatrixCall.prototype._initWithInvite = function(event) {
|
||||
this.msg.offer.sdp.indexOf('m=video') > -1
|
||||
) {
|
||||
this.type = 'video';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.type = 'voice';
|
||||
}
|
||||
|
||||
@@ -369,7 +364,7 @@ MatrixCall.prototype._initWithHangup = function(event) {
|
||||
*/
|
||||
MatrixCall.prototype.answer = function() {
|
||||
debuglog("Answering call %s of type %s", this.callId, this.type);
|
||||
var self = this;
|
||||
let self = this;
|
||||
|
||||
if (!this.localAVStream && !this.waitForLocalAVStream) {
|
||||
this.webRtc.getUserMedia(
|
||||
@@ -421,10 +416,10 @@ MatrixCall.prototype._replacedBy = function(newCall) {
|
||||
MatrixCall.prototype.hangup = function(reason, suppressEvent) {
|
||||
debuglog("Ending call " + this.callId);
|
||||
terminate(this, "local", reason, !suppressEvent);
|
||||
var content = {
|
||||
let content = {
|
||||
version: 0,
|
||||
call_id: this.callId,
|
||||
reason: reason
|
||||
reason: reason,
|
||||
};
|
||||
sendEvent(this, 'm.call.hangup', content);
|
||||
};
|
||||
@@ -497,8 +492,8 @@ MatrixCall.prototype._gotUserMediaForInvite = function(stream) {
|
||||
return;
|
||||
}
|
||||
debuglog("_gotUserMediaForInvite -> " + this.type);
|
||||
var self = this;
|
||||
var videoEl = this.getLocalVideoElement();
|
||||
let self = this;
|
||||
let videoEl = this.getLocalVideoElement();
|
||||
|
||||
if (videoEl && this.type == 'video') {
|
||||
videoEl.autoplay = true;
|
||||
@@ -507,15 +502,14 @@ MatrixCall.prototype._gotUserMediaForInvite = function(stream) {
|
||||
this.assignElement(videoEl,
|
||||
this.URL.createObjectURL(this.screenSharingStream),
|
||||
"localVideo");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.assignElement(videoEl,
|
||||
this.URL.createObjectURL(stream),
|
||||
"localVideo");
|
||||
}
|
||||
videoEl.muted = true;
|
||||
setTimeout(function() {
|
||||
var vel = self.getLocalVideoElement();
|
||||
let vel = self.getLocalVideoElement();
|
||||
if (vel.play) {
|
||||
self.playElement(vel, "localVideo");
|
||||
}
|
||||
@@ -543,11 +537,11 @@ MatrixCall.prototype._gotUserMediaForInvite = function(stream) {
|
||||
* @param {Object} stream
|
||||
*/
|
||||
MatrixCall.prototype._gotUserMediaForAnswer = function(stream) {
|
||||
var self = this;
|
||||
let self = this;
|
||||
if (self.state == 'ended') {
|
||||
return;
|
||||
}
|
||||
var localVidEl = self.getLocalVideoElement();
|
||||
let localVidEl = self.getLocalVideoElement();
|
||||
|
||||
if (localVidEl && self.type == 'video') {
|
||||
localVidEl.autoplay = true;
|
||||
@@ -556,7 +550,7 @@ MatrixCall.prototype._gotUserMediaForAnswer = function(stream) {
|
||||
"localVideo");
|
||||
localVidEl.muted = true;
|
||||
setTimeout(function() {
|
||||
var vel = self.getLocalVideoElement();
|
||||
let vel = self.getLocalVideoElement();
|
||||
if (vel.play) {
|
||||
self.playElement(vel, "localVideo");
|
||||
}
|
||||
@@ -567,22 +561,22 @@ MatrixCall.prototype._gotUserMediaForAnswer = function(stream) {
|
||||
setTracksEnabled(stream.getAudioTracks(), true);
|
||||
self.peerConn.addStream(stream);
|
||||
|
||||
var constraints = {
|
||||
let constraints = {
|
||||
'mandatory': {
|
||||
'OfferToReceiveAudio': true,
|
||||
'OfferToReceiveVideo': self.type == 'video'
|
||||
}
|
||||
'OfferToReceiveVideo': self.type == 'video',
|
||||
},
|
||||
};
|
||||
self.peerConn.createAnswer(function(description) {
|
||||
debuglog("Created answer: " + description);
|
||||
self.peerConn.setLocalDescription(description, function() {
|
||||
var content = {
|
||||
let content = {
|
||||
version: 0,
|
||||
call_id: self.callId,
|
||||
answer: {
|
||||
sdp: self.peerConn.localDescription.sdp,
|
||||
type: self.peerConn.localDescription.type
|
||||
}
|
||||
type: self.peerConn.localDescription.type,
|
||||
},
|
||||
};
|
||||
sendEvent(self, 'm.call.answer', content);
|
||||
setState(self, 'connecting');
|
||||
@@ -608,10 +602,10 @@ MatrixCall.prototype._gotLocalIceCandidate = function(event) {
|
||||
);
|
||||
// As with the offer, note we need to make a copy of this object, not
|
||||
// pass the original: that broke in Chrome ~m43.
|
||||
var c = {
|
||||
let c = {
|
||||
candidate: event.candidate.candidate,
|
||||
sdpMid: event.candidate.sdpMid,
|
||||
sdpMLineIndex: event.candidate.sdpMLineIndex
|
||||
sdpMLineIndex: event.candidate.sdpMLineIndex,
|
||||
};
|
||||
sendCandidate(this, c);
|
||||
}
|
||||
@@ -645,7 +639,7 @@ MatrixCall.prototype._receivedAnswer = function(msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
let self = this;
|
||||
this.peerConn.setRemoteDescription(
|
||||
new this.webRtc.RtcSessionDescription(msg.answer),
|
||||
hookCallback(self, self._onSetRemoteDescriptionSuccess),
|
||||
@@ -660,7 +654,7 @@ MatrixCall.prototype._receivedAnswer = function(msg) {
|
||||
* @param {Object} description
|
||||
*/
|
||||
MatrixCall.prototype._gotLocalOffer = function(description) {
|
||||
var self = this;
|
||||
let self = this;
|
||||
debuglog("Created offer: " + description);
|
||||
|
||||
if (self.state == 'ended') {
|
||||
@@ -670,7 +664,7 @@ MatrixCall.prototype._gotLocalOffer = function(description) {
|
||||
}
|
||||
|
||||
self.peerConn.setLocalDescription(description, function() {
|
||||
var content = {
|
||||
let content = {
|
||||
version: 0,
|
||||
call_id: self.callId,
|
||||
// OpenWebRTC appears to add extra stuff (like the DTLS fingerprint)
|
||||
@@ -684,9 +678,9 @@ MatrixCall.prototype._gotLocalOffer = function(description) {
|
||||
// Chrome (as of about m43).
|
||||
offer: {
|
||||
sdp: self.peerConn.localDescription.sdp,
|
||||
type: self.peerConn.localDescription.type
|
||||
type: self.peerConn.localDescription.type,
|
||||
},
|
||||
lifetime: MatrixCall.CALL_TIMEOUT_MS
|
||||
lifetime: MatrixCall.CALL_TIMEOUT_MS,
|
||||
};
|
||||
sendEvent(self, 'm.call.invite', content);
|
||||
|
||||
@@ -788,7 +782,7 @@ MatrixCall.prototype._onSetRemoteDescriptionError = function(e) {
|
||||
MatrixCall.prototype._onAddStream = function(event) {
|
||||
debuglog("Stream id " + event.stream.id + " added");
|
||||
|
||||
var s = event.stream;
|
||||
let s = event.stream;
|
||||
|
||||
if (s.getVideoTracks().length > 0) {
|
||||
this.type = 'video';
|
||||
@@ -799,7 +793,7 @@ MatrixCall.prototype._onAddStream = function(event) {
|
||||
this.remoteAStream = s;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
let self = this;
|
||||
forAllTracksOnStream(s, function(t) {
|
||||
debuglog("Track id " + t.id + " added");
|
||||
// not currently implemented in chrome
|
||||
@@ -808,8 +802,7 @@ MatrixCall.prototype._onAddStream = function(event) {
|
||||
|
||||
if (event.stream.oninactive !== undefined) {
|
||||
event.stream.oninactive = hookCallback(self, self._onRemoteStreamEnded);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// onended is deprecated from Chrome 54
|
||||
event.stream.onended = hookCallback(self, self._onRemoteStreamEnded);
|
||||
}
|
||||
@@ -820,8 +813,7 @@ MatrixCall.prototype._onAddStream = function(event) {
|
||||
if (this.type === 'video') {
|
||||
_tryPlayRemoteStream(this);
|
||||
_tryPlayRemoteAudioStream(this);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_tryPlayRemoteAudioStream(this);
|
||||
}
|
||||
};
|
||||
@@ -880,14 +872,14 @@ MatrixCall.prototype._onAnsweredElsewhere = function(msg) {
|
||||
terminate(this, "remote", "answered_elsewhere", true);
|
||||
};
|
||||
|
||||
var setTracksEnabled = function(tracks, enabled) {
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
let setTracksEnabled = function(tracks, enabled) {
|
||||
for (let i = 0; i < tracks.length; i++) {
|
||||
tracks[i].enabled = enabled;
|
||||
}
|
||||
};
|
||||
|
||||
var isTracksEnabled = function(tracks) {
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
let isTracksEnabled = function(tracks) {
|
||||
for (let i = 0; i < tracks.length; i++) {
|
||||
if (tracks[i].enabled) {
|
||||
return true; // at least one track is enabled
|
||||
}
|
||||
@@ -895,8 +887,8 @@ var isTracksEnabled = function(tracks) {
|
||||
return false;
|
||||
};
|
||||
|
||||
var setState = function(self, state) {
|
||||
var oldState = self.state;
|
||||
let setState = function(self, state) {
|
||||
let oldState = self.state;
|
||||
self.state = state;
|
||||
self.emit("state", state, oldState);
|
||||
};
|
||||
@@ -908,11 +900,11 @@ var setState = function(self, state) {
|
||||
* @param {Object} content
|
||||
* @return {Promise}
|
||||
*/
|
||||
var sendEvent = function(self, eventType, content) {
|
||||
let sendEvent = function(self, eventType, content) {
|
||||
return self.client.sendEvent(self.roomId, eventType, content);
|
||||
};
|
||||
|
||||
var sendCandidate = function(self, content) {
|
||||
let sendCandidate = function(self, content) {
|
||||
// Sends candidates with are sent in a special way because we try to amalgamate
|
||||
// them into one message
|
||||
self.candidateSendQueue.push(content);
|
||||
@@ -923,7 +915,7 @@ var sendCandidate = function(self, content) {
|
||||
}
|
||||
};
|
||||
|
||||
var terminate = function(self, hangupParty, hangupReason, shouldEmit) {
|
||||
let terminate = function(self, hangupParty, hangupReason, shouldEmit) {
|
||||
if (self.getRemoteVideoElement()) {
|
||||
if (self.getRemoteVideoElement().pause) {
|
||||
self.pauseElement(self.getRemoteVideoElement(), "remoteVideo");
|
||||
@@ -954,7 +946,7 @@ var terminate = function(self, hangupParty, hangupReason, shouldEmit) {
|
||||
}
|
||||
};
|
||||
|
||||
var stopAllMedia = function(self) {
|
||||
let stopAllMedia = function(self) {
|
||||
debuglog("stopAllMedia (stream=%s)", self.localAVStream);
|
||||
if (self.localAVStream) {
|
||||
forAllTracksOnStream(self.localAVStream, function(t) {
|
||||
@@ -994,15 +986,15 @@ var stopAllMedia = function(self) {
|
||||
}
|
||||
};
|
||||
|
||||
var _tryPlayRemoteStream = function(self) {
|
||||
let _tryPlayRemoteStream = function(self) {
|
||||
if (self.getRemoteVideoElement() && self.remoteAVStream) {
|
||||
var player = self.getRemoteVideoElement();
|
||||
let player = self.getRemoteVideoElement();
|
||||
player.autoplay = true;
|
||||
self.assignElement(player,
|
||||
self.URL.createObjectURL(self.remoteAVStream),
|
||||
"remoteVideo");
|
||||
setTimeout(function() {
|
||||
var vel = self.getRemoteVideoElement();
|
||||
let vel = self.getRemoteVideoElement();
|
||||
if (vel.play) {
|
||||
self.playElement(vel, "remoteVideo");
|
||||
}
|
||||
@@ -1014,15 +1006,15 @@ var _tryPlayRemoteStream = function(self) {
|
||||
}
|
||||
};
|
||||
|
||||
var _tryPlayRemoteAudioStream = function(self) {
|
||||
let _tryPlayRemoteAudioStream = function(self) {
|
||||
if (self.getRemoteAudioElement() && self.remoteAStream) {
|
||||
var player = self.getRemoteAudioElement();
|
||||
let player = self.getRemoteAudioElement();
|
||||
player.autoplay = true;
|
||||
self.assignElement(player,
|
||||
self.URL.createObjectURL(self.remoteAStream),
|
||||
"remoteAudio");
|
||||
setTimeout(function() {
|
||||
var ael = self.getRemoteAudioElement();
|
||||
let ael = self.getRemoteAudioElement();
|
||||
if (ael.play) {
|
||||
self.playElement(ael, "remoteAudio");
|
||||
}
|
||||
@@ -1034,7 +1026,7 @@ var _tryPlayRemoteAudioStream = function(self) {
|
||||
}
|
||||
};
|
||||
|
||||
var checkForErrorListener = function(self) {
|
||||
let checkForErrorListener = function(self) {
|
||||
if (self.listeners("error").length === 0) {
|
||||
throw new Error(
|
||||
"You MUST attach an error listener using call.on('error', function() {})"
|
||||
@@ -1042,37 +1034,37 @@ var checkForErrorListener = function(self) {
|
||||
}
|
||||
};
|
||||
|
||||
var callError = function(code, msg) {
|
||||
var e = new Error(msg);
|
||||
let callError = function(code, msg) {
|
||||
let e = new Error(msg);
|
||||
e.code = code;
|
||||
return e;
|
||||
};
|
||||
|
||||
var debuglog = function() {
|
||||
let debuglog = function() {
|
||||
if (DEBUG) {
|
||||
console.log.apply(console, arguments);
|
||||
console.log(...arguments);
|
||||
}
|
||||
};
|
||||
|
||||
var _sendCandidateQueue = function(self) {
|
||||
let _sendCandidateQueue = function(self) {
|
||||
if (self.candidateSendQueue.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cands = self.candidateSendQueue;
|
||||
let cands = self.candidateSendQueue;
|
||||
self.candidateSendQueue = [];
|
||||
++self.candidateSendTries;
|
||||
var content = {
|
||||
let content = {
|
||||
version: 0,
|
||||
call_id: self.callId,
|
||||
candidates: cands
|
||||
candidates: cands,
|
||||
};
|
||||
debuglog("Attempting to send " + cands.length + " candidates");
|
||||
sendEvent(self, 'm.call.candidates', content).then(function() {
|
||||
self.candidateSendTries = 0;
|
||||
_sendCandidateQueue(self);
|
||||
}, function(error) {
|
||||
for (var i = 0; i < cands.length; i++) {
|
||||
for (let i = 0; i < cands.length; i++) {
|
||||
self.candidateSendQueue.push(cands[i]);
|
||||
}
|
||||
|
||||
@@ -1085,7 +1077,7 @@ var _sendCandidateQueue = function(self) {
|
||||
return;
|
||||
}
|
||||
|
||||
var delayMs = 500 * Math.pow(2, self.candidateSendTries);
|
||||
let delayMs = 500 * Math.pow(2, self.candidateSendTries);
|
||||
++self.candidateSendTries;
|
||||
debuglog("Failed to send candidates. Retrying in " + delayMs + "ms");
|
||||
setTimeout(function() {
|
||||
@@ -1094,7 +1086,7 @@ var _sendCandidateQueue = function(self) {
|
||||
});
|
||||
};
|
||||
|
||||
var _placeCallWithConstraints = function(self, constraints) {
|
||||
let _placeCallWithConstraints = function(self, constraints) {
|
||||
self.client.callList[self.callId] = self;
|
||||
self.webRtc.getUserMedia(
|
||||
constraints,
|
||||
@@ -1106,24 +1098,24 @@ var _placeCallWithConstraints = function(self, constraints) {
|
||||
self.config = constraints;
|
||||
};
|
||||
|
||||
var _createPeerConnection = function(self) {
|
||||
var servers = self.turnServers;
|
||||
let _createPeerConnection = function(self) {
|
||||
let servers = self.turnServers;
|
||||
if (self.webRtc.vendor === "mozilla") {
|
||||
// modify turnServers struct to match what mozilla expects.
|
||||
servers = [];
|
||||
for (var i = 0; i < self.turnServers.length; i++) {
|
||||
for (var j = 0; j < self.turnServers[i].urls.length; j++) {
|
||||
for (let i = 0; i < self.turnServers.length; i++) {
|
||||
for (let j = 0; j < self.turnServers[i].urls.length; j++) {
|
||||
servers.push({
|
||||
url: self.turnServers[i].urls[j],
|
||||
username: self.turnServers[i].username,
|
||||
credential: self.turnServers[i].credential
|
||||
credential: self.turnServers[i].credential,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pc = new self.webRtc.RtcPeerConnection({
|
||||
iceServers: servers
|
||||
let pc = new self.webRtc.RtcPeerConnection({
|
||||
iceServers: servers,
|
||||
});
|
||||
pc.oniceconnectionstatechange = hookCallback(self, self._onIceConnectionStateChanged);
|
||||
pc.onsignalingstatechange = hookCallback(self, self._onSignallingStateChanged);
|
||||
@@ -1132,8 +1124,8 @@ var _createPeerConnection = function(self) {
|
||||
return pc;
|
||||
};
|
||||
|
||||
var _getChromeScreenSharingConstraints = function(call) {
|
||||
var screen = global.screen;
|
||||
let _getChromeScreenSharingConstraints = function(call) {
|
||||
let screen = global.screen;
|
||||
if (!screen) {
|
||||
call.emit("error", callError(
|
||||
MatrixCall.ERR_NO_USER_MEDIA,
|
||||
@@ -1150,13 +1142,13 @@ var _getChromeScreenSharingConstraints = function(call) {
|
||||
maxWidth: screen.width,
|
||||
maxHeight: screen.height,
|
||||
minFrameRate: 1,
|
||||
maxFrameRate: 10
|
||||
}
|
||||
}
|
||||
maxFrameRate: 10,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
var _getUserMediaVideoContraints = function(callType) {
|
||||
let _getUserMediaVideoContraints = function(callType) {
|
||||
switch (callType) {
|
||||
case 'voice':
|
||||
return ({audio: true, video: false});
|
||||
@@ -1166,33 +1158,33 @@ var _getUserMediaVideoContraints = function(callType) {
|
||||
minWidth: 640,
|
||||
maxWidth: 640,
|
||||
minHeight: 360,
|
||||
maxHeight: 360
|
||||
}
|
||||
maxHeight: 360,
|
||||
},
|
||||
}});
|
||||
}
|
||||
};
|
||||
|
||||
var hookCallback = function(call, fn) {
|
||||
let hookCallback = function(call, fn) {
|
||||
return function() {
|
||||
return fn.apply(call, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
var forAllVideoTracksOnStream = function(s, f) {
|
||||
var tracks = s.getVideoTracks();
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
let forAllVideoTracksOnStream = function(s, f) {
|
||||
let tracks = s.getVideoTracks();
|
||||
for (let i = 0; i < tracks.length; i++) {
|
||||
f(tracks[i]);
|
||||
}
|
||||
};
|
||||
|
||||
var forAllAudioTracksOnStream = function(s, f) {
|
||||
var tracks = s.getAudioTracks();
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
let forAllAudioTracksOnStream = function(s, f) {
|
||||
let tracks = s.getAudioTracks();
|
||||
for (let i = 0; i < tracks.length; i++) {
|
||||
f(tracks[i]);
|
||||
}
|
||||
};
|
||||
|
||||
var forAllTracksOnStream = function(s, f) {
|
||||
let forAllTracksOnStream = function(s, f) {
|
||||
forAllVideoTracksOnStream(s, f);
|
||||
forAllAudioTracksOnStream(s, f);
|
||||
};
|
||||
@@ -1208,25 +1200,25 @@ module.exports.MatrixCall = MatrixCall;
|
||||
* @return {MatrixCall} the call or null if the browser doesn't support calling.
|
||||
*/
|
||||
module.exports.createNewMatrixCall = function(client, roomId) {
|
||||
var w = global.window;
|
||||
var doc = global.document;
|
||||
let w = global.window;
|
||||
let doc = global.document;
|
||||
if (!w || !doc) {
|
||||
return null;
|
||||
}
|
||||
var webRtc = {};
|
||||
let webRtc = {};
|
||||
webRtc.isOpenWebRTC = function() {
|
||||
var scripts = doc.getElementById("script");
|
||||
let scripts = doc.getElementById("script");
|
||||
if (!scripts || !scripts.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
for (let i = 0; i < scripts.length; i++) {
|
||||
if (scripts[i].src.indexOf("owr.js") > -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
var getUserMedia = (
|
||||
let getUserMedia = (
|
||||
w.navigator.getUserMedia || w.navigator.webkitGetUserMedia ||
|
||||
w.navigator.mozGetUserMedia
|
||||
);
|
||||
@@ -1248,23 +1240,21 @@ module.exports.createNewMatrixCall = function(client, roomId) {
|
||||
webRtc.vendor = null;
|
||||
if (w.mozRTCPeerConnection) {
|
||||
webRtc.vendor = "mozilla";
|
||||
}
|
||||
else if (w.webkitRTCPeerConnection) {
|
||||
} else if (w.webkitRTCPeerConnection) {
|
||||
webRtc.vendor = "webkit";
|
||||
}
|
||||
else if (w.RTCPeerConnection) {
|
||||
} else if (w.RTCPeerConnection) {
|
||||
webRtc.vendor = "generic";
|
||||
}
|
||||
if (!webRtc.RtcIceCandidate || !webRtc.RtcSessionDescription ||
|
||||
!webRtc.RtcPeerConnection || !webRtc.getUserMedia) {
|
||||
return null; // WebRTC is not supported.
|
||||
}
|
||||
var opts = {
|
||||
let opts = {
|
||||
webRtc: webRtc,
|
||||
client: client,
|
||||
URL: w.URL,
|
||||
roomId: roomId,
|
||||
turnServers: client.getTurnServers()
|
||||
turnServers: client.getTurnServers(),
|
||||
};
|
||||
return new MatrixCall(opts);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user