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
Simplifie placeScreenSharingCall()
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@@ -380,33 +380,21 @@ export class MatrixCall extends EventEmitter {
|
||||
this.localVideoElement = localVideoElement;
|
||||
this.remoteVideoElement = remoteVideoElement;
|
||||
|
||||
if (window.electron?.getDesktopCapturerSources) {
|
||||
// We have access to getDesktopCapturerSources()
|
||||
logger.debug("Electron getDesktopCapturerSources() is available...");
|
||||
try {
|
||||
const screenshareConstraints = await getUserMediaContraints(
|
||||
ConstraintsType.Screenshare,
|
||||
selectDesktopCapturerSource,
|
||||
);
|
||||
this.screenSharingStream = await window.navigator.mediaDevices.getUserMedia(screenshareConstraints);
|
||||
|
||||
logger.debug("Got screen stream, requesting audio stream...");
|
||||
const audioConstraints = await getUserMediaContraints(ConstraintsType.Audio);
|
||||
this.placeCallWithConstraints(audioConstraints);
|
||||
} catch (err) {
|
||||
this.emit(CallEvent.Error,
|
||||
new CallError(
|
||||
CallErrorCode.NoUserMedia,
|
||||
"Failed to get screen-sharing stream: ", err,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (window.electron?.getDesktopCapturerSources) {
|
||||
// We are using Electron
|
||||
logger.debug("Getting screen stream using getUserMedia()...");
|
||||
this.screenSharingStream = await navigator.mediaDevices.getUserMedia(screenshareConstraints);
|
||||
} else {
|
||||
/* We do not have access to the Electron desktop capturer,
|
||||
* therefore we can assume we are on the web */
|
||||
logger.debug("Electron desktopCapturer is not available...");
|
||||
try {
|
||||
this.screenSharingStream = await navigator.mediaDevices.getDisplayMedia({'audio': false});
|
||||
// We are not using Electron
|
||||
logger.debug("Getting screen stream using getDisplayMedia()...");
|
||||
this.screenSharingStream = await navigator.mediaDevices.getDisplayMedia(screenshareConstraints);
|
||||
}
|
||||
|
||||
logger.debug("Got screen stream, requesting audio stream...");
|
||||
const audioConstraints = await getUserMediaContraints(ConstraintsType.Audio);
|
||||
this.placeCallWithConstraints(audioConstraints);
|
||||
@@ -418,8 +406,6 @@ export class MatrixCall extends EventEmitter {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.type = CallType.Video;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user