You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
42
src/@types/global.d.ts
vendored
42
src/@types/global.d.ts
vendored
@@ -26,10 +26,50 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Window {
|
||||||
|
desktopCapturer?: {
|
||||||
|
getSources(options: GetSourcesOptions): Promise<Array<DesktopCapturerSource>>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface MediaDevices {
|
interface MediaDevices {
|
||||||
// This is experimental and types don't know about it yet
|
// This is experimental and types don't know about it yet
|
||||||
// https://github.com/microsoft/TypeScript/issues/33232
|
// 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 {
|
interface HTMLAudioElement {
|
||||||
|
|||||||
@@ -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 {
|
interface CallOpts {
|
||||||
roomId?: string,
|
roomId?: string,
|
||||||
client?: any, // Fix when client is TSified
|
client?: any, // Fix when client is TSified
|
||||||
@@ -361,8 +336,8 @@ export class MatrixCall extends EventEmitter {
|
|||||||
remoteVideoElement: HTMLVideoElement,
|
remoteVideoElement: HTMLVideoElement,
|
||||||
localVideoElement: HTMLVideoElement,
|
localVideoElement: HTMLVideoElement,
|
||||||
selectDesktopCapturerSource: (
|
selectDesktopCapturerSource: (
|
||||||
sources: Array<ElectronDesktopCapturerSource>,
|
sources: Array<DesktopCapturerSource>,
|
||||||
) => Promise<ElectronDesktopCapturerSource>,
|
) => Promise<DesktopCapturerSource>,
|
||||||
) {
|
) {
|
||||||
logger.debug("placeScreenSharingCall");
|
logger.debug("placeScreenSharingCall");
|
||||||
this.checkForErrorListener();
|
this.checkForErrorListener();
|
||||||
@@ -373,7 +348,7 @@ export class MatrixCall extends EventEmitter {
|
|||||||
// We have access to the Electron desktop capturer
|
// We have access to the Electron desktop capturer
|
||||||
logger.debug("Electron desktopCapturer is available...");
|
logger.debug("Electron desktopCapturer is available...");
|
||||||
try {
|
try {
|
||||||
const options: ElectronGetSourcesOptions = {
|
const getSourcesOptions: GetSourcesOptions = {
|
||||||
thumbnailSize: {
|
thumbnailSize: {
|
||||||
height: 176,
|
height: 176,
|
||||||
width: 312,
|
width: 312,
|
||||||
@@ -383,10 +358,9 @@ export class MatrixCall extends EventEmitter {
|
|||||||
"window",
|
"window",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
const sources = await window.desktopCapturer.getSources(getSourcesOptions);
|
||||||
const sources = await window.desktopCapturer.getSources(options);
|
|
||||||
const selectedSource = await selectDesktopCapturerSource(sources);
|
const selectedSource = await selectDesktopCapturerSource(sources);
|
||||||
this.screenSharingStream = await window.navigator.mediaDevices.getUserMedia({
|
const getUserMediaOptions: MediaStreamConstraints | DesktopCapturerConstraints = {
|
||||||
audio: false,
|
audio: false,
|
||||||
video: {
|
video: {
|
||||||
mandatory: {
|
mandatory: {
|
||||||
@@ -394,7 +368,9 @@ export class MatrixCall extends EventEmitter {
|
|||||||
chromeMediaSourceId: selectedSource.id,
|
chromeMediaSourceId: selectedSource.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
}
|
||||||
|
this.screenSharingStream = await window.navigator.mediaDevices.getUserMedia(getUserMediaOptions);
|
||||||
|
|
||||||
logger.debug("Got screen stream, requesting audio stream...");
|
logger.debug("Got screen stream, requesting audio stream...");
|
||||||
const audioConstraints = getUserMediaVideoContraints(CallType.Voice);
|
const audioConstraints = getUserMediaVideoContraints(CallType.Voice);
|
||||||
this.placeCallWithConstraints(audioConstraints);
|
this.placeCallWithConstraints(audioConstraints);
|
||||||
|
|||||||
Reference in New Issue
Block a user