expose mediaDevices and webRTC from platform

This commit is contained in:
Bruno Windels 2022-03-17 11:31:36 +01:00
parent 6daae797e5
commit e482e3aeef
3 changed files with 11 additions and 1 deletions

View file

@ -38,6 +38,8 @@ import {downloadInIframe} from "./dom/download.js";
import {Disposables} from "../../utils/Disposables";
import {parseHTML} from "./parsehtml.js";
import {handleAvatarError} from "./ui/avatar";
import {MediaDevicesWrapper} from "./dom/MediaDevices";
import {DOMWebRTC} from "./dom/WebRTC";
function addScript(src) {
return new Promise(function (resolve, reject) {
@ -163,6 +165,8 @@ export class Platform {
this._disposables = new Disposables();
this._olmPromise = undefined;
this._workerPromise = undefined;
this.mediaDevices = new MediaDevicesWrapper(navigator.mediaDevices);
this.webRTC = new DOMWebRTC();
}
_createLogger(isDevelopment) {

View file

@ -21,7 +21,7 @@ const POLLING_INTERVAL = 200; // ms
export const SPEAKING_THRESHOLD = -60; // dB
const SPEAKING_SAMPLE_COUNT = 8; // samples
class MediaDevicesWrapper implements IMediaDevices {
export class MediaDevicesWrapper implements IMediaDevices {
constructor(private readonly mediaDevices: MediaDevices) {}
enumerate(): Promise<MediaDeviceInfo[]> {

View file

@ -23,6 +23,12 @@ const POLLING_INTERVAL = 200; // ms
export const SPEAKING_THRESHOLD = -60; // dB
const SPEAKING_SAMPLE_COUNT = 8; // samples
export class DOMWebRTC implements WebRTC {
createPeerConnection(handler: PeerConnectionHandler): PeerConnection {
return new DOMPeerConnection(handler, false, []);
}
}
class DOMPeerConnection implements PeerConnection {
private readonly peerConnection: RTCPeerConnection;
private readonly handler: PeerConnectionHandler;