From 1666419beaf08cafefdc34cced417cb0ba120b2e Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 21 Oct 2022 21:08:00 +0100 Subject: [PATCH 1/2] Add throwOnFail to groupCall.setScreensharingEnabled For https://github.com/vector-im/element-call/pull/652 --- src/webrtc/groupCall.ts | 1 + src/webrtc/mediaHandler.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/webrtc/groupCall.ts b/src/webrtc/groupCall.ts index c20592f52f9..eb122a395ce 100644 --- a/src/webrtc/groupCall.ts +++ b/src/webrtc/groupCall.ts @@ -600,6 +600,7 @@ export class GroupCall extends TypedEventEmitter< return true; } catch (error) { + if (opts.throwOnFail) throw error; logger.error("Enabling screensharing error", error); this.emit(GroupCallEvent.Error, new GroupCallError(GroupCallErrorCode.NoUserMedia, "Failed to get screen-sharing stream: ", error), diff --git a/src/webrtc/mediaHandler.ts b/src/webrtc/mediaHandler.ts index 2eba5f2f534..79f5c12d91d 100644 --- a/src/webrtc/mediaHandler.ts +++ b/src/webrtc/mediaHandler.ts @@ -33,6 +33,11 @@ export type MediaHandlerEventHandlerMap = { export interface IScreensharingOpts { desktopCapturerSourceId?: string; audio?: boolean; + // For electron screen capture, there are very few options for detecting electron + // apart from inspecting the user agent or just trying getDisplayMedia() and + // catching the failure, so we do the latter - this flag tells the function to just + // throw an error so we can catch it in this case, rather than logging an emitting. + throwOnFail?: boolean; } export class MediaHandler extends TypedEventEmitter< From 62f0f41be82ec6830171157e077dfb0dda34e928 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 24 Oct 2022 10:11:52 +0100 Subject: [PATCH 2/2] Update mediaHandler.ts --- src/webrtc/mediaHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webrtc/mediaHandler.ts b/src/webrtc/mediaHandler.ts index 79f5c12d91d..718adfd4f60 100644 --- a/src/webrtc/mediaHandler.ts +++ b/src/webrtc/mediaHandler.ts @@ -36,7 +36,7 @@ export interface IScreensharingOpts { // For electron screen capture, there are very few options for detecting electron // apart from inspecting the user agent or just trying getDisplayMedia() and // catching the failure, so we do the latter - this flag tells the function to just - // throw an error so we can catch it in this case, rather than logging an emitting. + // throw an error so we can catch it in this case, rather than logging and emitting. throwOnFail?: boolean; }