mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
expose mediaDevices and webRTC from platform
This commit is contained in:
parent
6daae797e5
commit
e482e3aeef
@ -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 New Issue
Block a user