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 { usePageUnload } from "./usePageUnload";
 | 
				
			||||||
import { TranslatedError, translatedError } from "../TranslatedError";
 | 
					import { TranslatedError, translatedError } from "../TranslatedError";
 | 
				
			||||||
 | 
					import { ElementWidgetActions, widget } from "../widget";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface UseGroupCallReturnType {
 | 
					export interface UseGroupCallReturnType {
 | 
				
			||||||
  state: GroupCallState;
 | 
					  state: GroupCallState;
 | 
				
			||||||
| 
						 | 
					@ -304,11 +305,31 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
 | 
				
			||||||
  const toggleScreensharing = useCallback(() => {
 | 
					  const toggleScreensharing = useCallback(() => {
 | 
				
			||||||
    updateState({ requestingScreenshare: true });
 | 
					    updateState({ requestingScreenshare: true });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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
 | 
					            groupCall
 | 
				
			||||||
      .setScreensharingEnabled(!groupCall.isScreensharing(), { audio: true })
 | 
					              .setScreensharingEnabled(true, {
 | 
				
			||||||
 | 
					                audio: !reply.desktopCapturerSourceId,
 | 
				
			||||||
 | 
					                desktopCapturerSourceId: reply.desktopCapturerSourceId,
 | 
				
			||||||
 | 
					              })
 | 
				
			||||||
              .then(() => {
 | 
					              .then(() => {
 | 
				
			||||||
                updateState({ requestingScreenshare: false });
 | 
					                updateState({ requestingScreenshare: false });
 | 
				
			||||||
              });
 | 
					              });
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }, [groupCall]);
 | 
					  }, [groupCall]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const { t } = useTranslation();
 | 
					  const { t } = useTranslation();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,7 @@ export enum ElementWidgetActions {
 | 
				
			||||||
  HangupCall = "im.vector.hangup",
 | 
					  HangupCall = "im.vector.hangup",
 | 
				
			||||||
  TileLayout = "io.element.tile_layout",
 | 
					  TileLayout = "io.element.tile_layout",
 | 
				
			||||||
  SpotlightLayout = "io.element.spotlight_layout",
 | 
					  SpotlightLayout = "io.element.spotlight_layout",
 | 
				
			||||||
 | 
					  Screenshare = "io.element.screenshare",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface JoinCallData {
 | 
					export interface JoinCallData {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue