From e482e3aeef0af29171418592b30d0b2df2150b40 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Thu, 17 Mar 2022 11:31:36 +0100 Subject: [PATCH] expose mediaDevices and webRTC from platform --- src/platform/web/Platform.js | 4 ++++ src/platform/web/dom/MediaDevices.ts | 2 +- src/platform/web/dom/WebRTC.ts | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/platform/web/Platform.js b/src/platform/web/Platform.js index 984bc45c..7426b138 100644 --- a/src/platform/web/Platform.js +++ b/src/platform/web/Platform.js @@ -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) { diff --git a/src/platform/web/dom/MediaDevices.ts b/src/platform/web/dom/MediaDevices.ts index 445ff22d..22f3d634 100644 --- a/src/platform/web/dom/MediaDevices.ts +++ b/src/platform/web/dom/MediaDevices.ts @@ -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 { diff --git a/src/platform/web/dom/WebRTC.ts b/src/platform/web/dom/WebRTC.ts index 0025dfec..39a6f9d2 100644 --- a/src/platform/web/dom/WebRTC.ts +++ b/src/platform/web/dom/WebRTC.ts @@ -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;