Merge pull request #645 from vector-im/SimonBrandner/feat/screenshare-ec
This commit is contained in:
commit
3ef84c069c
2 changed files with 25 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue