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..718adfd4f60 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 and emitting. + throwOnFail?: boolean; } export class MediaHandler extends TypedEventEmitter<