You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-12 08:42:46 +03:00
allow setting iceTransportPolicy to relay through forceTURN option
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -71,6 +71,7 @@ const DEBUG = true; // set true to enable console logging.
|
|||||||
* @param {Object} opts Config options.
|
* @param {Object} opts Config options.
|
||||||
* @param {string} opts.roomId The room ID for this call.
|
* @param {string} opts.roomId The room ID for this call.
|
||||||
* @param {Object} opts.webRtc The WebRTC globals from the browser.
|
* @param {Object} opts.webRtc The WebRTC globals from the browser.
|
||||||
|
* @param {boolean} opts.forceTURN whether relay through TURN should be forced.
|
||||||
* @param {Object} opts.URL The URL global.
|
* @param {Object} opts.URL The URL global.
|
||||||
* @param {Array<Object>} opts.turnServers Optional. A list of TURN servers.
|
* @param {Array<Object>} opts.turnServers Optional. A list of TURN servers.
|
||||||
* @param {MatrixClient} opts.client The Matrix Client instance to send events to.
|
* @param {MatrixClient} opts.client The Matrix Client instance to send events to.
|
||||||
@@ -79,6 +80,7 @@ function MatrixCall(opts) {
|
|||||||
this.roomId = opts.roomId;
|
this.roomId = opts.roomId;
|
||||||
this.client = opts.client;
|
this.client = opts.client;
|
||||||
this.webRtc = opts.webRtc;
|
this.webRtc = opts.webRtc;
|
||||||
|
this.forceTURN = opts.forceTURN;
|
||||||
this.URL = opts.URL;
|
this.URL = opts.URL;
|
||||||
// Array of Objects with urls, username, credential keys
|
// Array of Objects with urls, username, credential keys
|
||||||
this.turnServers = opts.turnServers || [];
|
this.turnServers = opts.turnServers || [];
|
||||||
@@ -1184,6 +1186,7 @@ const _createPeerConnection = function(self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pc = new self.webRtc.RtcPeerConnection({
|
const pc = new self.webRtc.RtcPeerConnection({
|
||||||
|
iceTransportPolicy: self.forceTURN ? 'relay' : undefined,
|
||||||
iceServers: servers,
|
iceServers: servers,
|
||||||
});
|
});
|
||||||
pc.oniceconnectionstatechange = hookCallback(self, self._onIceConnectionStateChanged);
|
pc.oniceconnectionstatechange = hookCallback(self, self._onIceConnectionStateChanged);
|
||||||
@@ -1293,9 +1296,11 @@ module.exports.setVideoInput = function(deviceId) { videoInput = deviceId; };
|
|||||||
* Create a new Matrix call for the browser.
|
* Create a new Matrix call for the browser.
|
||||||
* @param {MatrixClient} client The client instance to use.
|
* @param {MatrixClient} client The client instance to use.
|
||||||
* @param {string} roomId The room the call is in.
|
* @param {string} roomId The room the call is in.
|
||||||
|
* @param {Object?} options optional options map.
|
||||||
|
* @param {boolean} options.forceTURN whether relay through TURN should be forced.
|
||||||
* @return {MatrixCall} the call or null if the browser doesn't support calling.
|
* @return {MatrixCall} the call or null if the browser doesn't support calling.
|
||||||
*/
|
*/
|
||||||
module.exports.createNewMatrixCall = function(client, roomId) {
|
module.exports.createNewMatrixCall = function(client, roomId, options) {
|
||||||
const w = global.window;
|
const w = global.window;
|
||||||
const doc = global.document;
|
const doc = global.document;
|
||||||
if (!w || !doc) {
|
if (!w || !doc) {
|
||||||
@@ -1351,6 +1356,8 @@ module.exports.createNewMatrixCall = function(client, roomId) {
|
|||||||
URL: w.URL,
|
URL: w.URL,
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
turnServers: client.getTurnServers(),
|
turnServers: client.getTurnServers(),
|
||||||
|
// call level options
|
||||||
|
forceTURN: options ? options.forceTURN : false,
|
||||||
};
|
};
|
||||||
return new MatrixCall(opts);
|
return new MatrixCall(opts);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user