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

Type cleanup

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2020-12-26 18:09:38 +01:00
parent f91edfabbb
commit c4e7c149a4
2 changed files with 49 additions and 33 deletions

View File

@@ -26,10 +26,50 @@ declare global {
}
}
interface Window {
desktopCapturer?: {
getSources(options: GetSourcesOptions): Promise<Array<DesktopCapturerSource>>;
};
}
interface MediaDevices {
// This is experimental and types don't know about it yet
// https://github.com/microsoft/TypeScript/issues/33232
getDisplayMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
getDisplayMedia(constraints: MediaStreamConstraints | DesktopCapturerConstraints): Promise<MediaStream>;
getUserMedia(constraints: MediaStreamConstraints | DesktopCapturerConstraints): Promise<MediaStream>;
}
export interface DesktopCapturerConstraints {
audio: boolean | {
mandatory: {
chromeMediaSource: string;
chromeMediaSourceId: string;
};
};
video: boolean | {
mandatory: {
chromeMediaSource: string;
chromeMediaSourceId: string;
};
};
}
export interface DesktopCapturerSource {
id: string;
name: string;
thumbnail;
// This property is not camelcase and isn't used, therefore it is commented
//display_id: string;
appIcon;
}
interface GetSourcesOptions {
types: Array<string>;
thumbnailSize?: {
height: number;
width: number;
};
fetchWindowIcons?: boolean;
}
interface HTMLAudioElement {

View File

@@ -46,31 +46,6 @@ import { RoomMember } from '../models/room-member';
* });
*/
export interface ElectronDesktopCapturerSource {
display_id: string;
id: string;
name: string;
}
interface ElectronGetSourcesOptions {
fetchWindowIcons?: boolean;
thumbnailSize?: {
height: number;
width: number;
};
types: string[];
}
declare global {
interface Window {
desktopCapturer?: {
getSources(options: ElectronGetSourcesOptions): Promise<Array<ElectronDesktopCapturerSource>>;
};
}
}
interface CallOpts {
roomId?: string,
client?: any, // Fix when client is TSified
@@ -361,8 +336,8 @@ export class MatrixCall extends EventEmitter {
remoteVideoElement: HTMLVideoElement,
localVideoElement: HTMLVideoElement,
selectDesktopCapturerSource: (
sources: Array<ElectronDesktopCapturerSource>,
) => Promise<ElectronDesktopCapturerSource>,
sources: Array<DesktopCapturerSource>,
) => Promise<DesktopCapturerSource>,
) {
logger.debug("placeScreenSharingCall");
this.checkForErrorListener();
@@ -373,7 +348,7 @@ export class MatrixCall extends EventEmitter {
// We have access to the Electron desktop capturer
logger.debug("Electron desktopCapturer is available...");
try {
const options: ElectronGetSourcesOptions = {
const getSourcesOptions: GetSourcesOptions = {
thumbnailSize: {
height: 176,
width: 312,
@@ -383,10 +358,9 @@ export class MatrixCall extends EventEmitter {
"window",
],
};
const sources = await window.desktopCapturer.getSources(options);
const sources = await window.desktopCapturer.getSources(getSourcesOptions);
const selectedSource = await selectDesktopCapturerSource(sources);
this.screenSharingStream = await window.navigator.mediaDevices.getUserMedia({
const getUserMediaOptions: MediaStreamConstraints | DesktopCapturerConstraints = {
audio: false,
video: {
mandatory: {
@@ -394,7 +368,9 @@ export class MatrixCall extends EventEmitter {
chromeMediaSourceId: selectedSource.id,
},
},
});
}
this.screenSharingStream = await window.navigator.mediaDevices.getUserMedia(getUserMediaOptions);
logger.debug("Got screen stream, requesting audio stream...");
const audioConstraints = getUserMediaVideoContraints(CallType.Voice);
this.placeCallWithConstraints(audioConstraints);