1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

allow setting the output device for webrtc calls

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2018-05-26 16:44:27 +01:00
parent 4153845346
commit 4b203b6b63
2 changed files with 20 additions and 1 deletions

View File

@@ -81,6 +81,13 @@ module.exports.IndexedDBCryptoStore =
module.exports.createNewMatrixCall = require("./webrtc/call").createNewMatrixCall; module.exports.createNewMatrixCall = require("./webrtc/call").createNewMatrixCall;
/**
* Set an audio output device to use for MatrixCalls
* @function
* @param {string=} deviceId the identifier for the device
* undefined treated as unset
*/
module.exports.setMatrixCallAudioOutput = require('./webrtc/call').setAudioOutput;
/** /**
* Set an audio input device to use for MatrixCalls * Set an audio input device to use for MatrixCalls
* @function * @function

View File

@@ -1121,9 +1121,13 @@ const _tryPlayRemoteStream = function(self) {
} }
}; };
const _tryPlayRemoteAudioStream = function(self) { const _tryPlayRemoteAudioStream = async function(self) {
if (self.getRemoteAudioElement() && self.remoteAStream) { if (self.getRemoteAudioElement() && self.remoteAStream) {
const player = self.getRemoteAudioElement(); const player = self.getRemoteAudioElement();
// if audioOutput is non-default:
if (audioOutput) await player.setSinkId(audioOutput);
player.autoplay = true; player.autoplay = true;
self.assignElement(player, self.remoteAStream, "remoteAudio"); self.assignElement(player, self.remoteAStream, "remoteAudio");
setTimeout(function() { setTimeout(function() {
@@ -1317,8 +1321,16 @@ const forAllTracksOnStream = function(s, f) {
/** The MatrixCall class. */ /** The MatrixCall class. */
module.exports.MatrixCall = MatrixCall; module.exports.MatrixCall = MatrixCall;
let audioOutput;
let audioInput; let audioInput;
let videoInput; let videoInput;
/**
* Set an audio output device to use for MatrixCalls
* @function
* @param {string=} deviceId the identifier for the device
* undefined treated as unset
*/
module.exports.setAudioOutput = function(deviceId) { audioOutput = deviceId; };
/** /**
* Set an audio input device to use for MatrixCalls * Set an audio input device to use for MatrixCalls
* @function * @function