forked from mystiq/hydrogen-web
expose mediaDevices and webRTC from platform
This commit is contained in:
parent
6daae797e5
commit
e482e3aeef
3 changed files with 11 additions and 1 deletions
|
@ -38,6 +38,8 @@ import {downloadInIframe} from "./dom/download.js";
|
||||||
import {Disposables} from "../../utils/Disposables";
|
import {Disposables} from "../../utils/Disposables";
|
||||||
import {parseHTML} from "./parsehtml.js";
|
import {parseHTML} from "./parsehtml.js";
|
||||||
import {handleAvatarError} from "./ui/avatar";
|
import {handleAvatarError} from "./ui/avatar";
|
||||||
|
import {MediaDevicesWrapper} from "./dom/MediaDevices";
|
||||||
|
import {DOMWebRTC} from "./dom/WebRTC";
|
||||||
|
|
||||||
function addScript(src) {
|
function addScript(src) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
@ -163,6 +165,8 @@ export class Platform {
|
||||||
this._disposables = new Disposables();
|
this._disposables = new Disposables();
|
||||||
this._olmPromise = undefined;
|
this._olmPromise = undefined;
|
||||||
this._workerPromise = undefined;
|
this._workerPromise = undefined;
|
||||||
|
this.mediaDevices = new MediaDevicesWrapper(navigator.mediaDevices);
|
||||||
|
this.webRTC = new DOMWebRTC();
|
||||||
}
|
}
|
||||||
|
|
||||||
_createLogger(isDevelopment) {
|
_createLogger(isDevelopment) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const POLLING_INTERVAL = 200; // ms
|
||||||
export const SPEAKING_THRESHOLD = -60; // dB
|
export const SPEAKING_THRESHOLD = -60; // dB
|
||||||
const SPEAKING_SAMPLE_COUNT = 8; // samples
|
const SPEAKING_SAMPLE_COUNT = 8; // samples
|
||||||
|
|
||||||
class MediaDevicesWrapper implements IMediaDevices {
|
export class MediaDevicesWrapper implements IMediaDevices {
|
||||||
constructor(private readonly mediaDevices: MediaDevices) {}
|
constructor(private readonly mediaDevices: MediaDevices) {}
|
||||||
|
|
||||||
enumerate(): Promise<MediaDeviceInfo[]> {
|
enumerate(): Promise<MediaDeviceInfo[]> {
|
||||||
|
|
|
@ -23,6 +23,12 @@ const POLLING_INTERVAL = 200; // ms
|
||||||
export const SPEAKING_THRESHOLD = -60; // dB
|
export const SPEAKING_THRESHOLD = -60; // dB
|
||||||
const SPEAKING_SAMPLE_COUNT = 8; // samples
|
const SPEAKING_SAMPLE_COUNT = 8; // samples
|
||||||
|
|
||||||
|
export class DOMWebRTC implements WebRTC {
|
||||||
|
createPeerConnection(handler: PeerConnectionHandler): PeerConnection {
|
||||||
|
return new DOMPeerConnection(handler, false, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DOMPeerConnection implements PeerConnection {
|
class DOMPeerConnection implements PeerConnection {
|
||||||
private readonly peerConnection: RTCPeerConnection;
|
private readonly peerConnection: RTCPeerConnection;
|
||||||
private readonly handler: PeerConnectionHandler;
|
private readonly handler: PeerConnectionHandler;
|
||||||
|
|
Loading…
Reference in a new issue