Merge pull request #645 from vector-im/SimonBrandner/feat/screenshare-ec

This commit is contained in:
Šimon Brandner 2022-10-20 19:11:47 +02:00 committed by GitHub
commit 3ef84c069c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View file

@ -30,6 +30,7 @@ import { useTranslation } from "react-i18next";
import { usePageUnload } from "./usePageUnload";
import { TranslatedError, translatedError } from "../TranslatedError";
import { ElementWidgetActions, widget } from "../widget";
export interface UseGroupCallReturnType {
state: GroupCallState;
@ -304,11 +305,31 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
const toggleScreensharing = useCallback(() => {
updateState({ requestingScreenshare: true });
groupCall
.setScreensharingEnabled(!groupCall.isScreensharing(), { audio: true })
.then(() => {
if (groupCall.isScreensharing()) {
groupCall.setScreensharingEnabled(false).then(() => {
updateState({ requestingScreenshare: false });
});
} else {
widget.api.transport
.send(ElementWidgetActions.Screenshare, {})
.then(
(reply: { desktopCapturerSourceId: string; failed?: boolean }) => {
if (reply.failed) {
updateState({ requestingScreenshare: false });
return;
}
groupCall
.setScreensharingEnabled(true, {
audio: !reply.desktopCapturerSourceId,
desktopCapturerSourceId: reply.desktopCapturerSourceId,
})
.then(() => {
updateState({ requestingScreenshare: false });
});
}
);
}
}, [groupCall]);
const { t } = useTranslation();

View file

@ -30,6 +30,7 @@ export enum ElementWidgetActions {
HangupCall = "im.vector.hangup",
TileLayout = "io.element.tile_layout",
SpotlightLayout = "io.element.spotlight_layout",
Screenshare = "io.element.screenshare",
}
export interface JoinCallData {