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