Skip to content

Commit

Permalink
fix echo screenshare
Browse files Browse the repository at this point in the history
  • Loading branch information
SupertigerDev committed Oct 12, 2024
1 parent eb48750 commit e4ecaa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/common/Electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface WindowAPI {

setNotification(value: boolean): void;
getDesktopCaptureSources(): Promise<ElectronCaptureSource[]>;
setDesktopCaptureSourceId(sourceId: string): void;

getRunningPrograms(ignoredPrograms?: Program[]): Promise<Program[]>;
restartActivityStatus(listenToPrograms: Program[]): void;
Expand Down
29 changes: 5 additions & 24 deletions src/components/main-pane-header/ScreenShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,13 @@ export function ScreenShareModal(props: { close: () => void }) {

if (electronWindowAPI()?.isElectron) {
const sourceId = electronSourceIdRef();
if (!sourceId) return;
stream = await navigator.mediaDevices.getUserMedia({
audio: {
mandatory: {
chromeMediaSource: "desktop",
},
},
video: {
mandatory: {
chromeMediaSource: "desktop",
chromeMediaSourceId: sourceId,
maxFrameRate: constraints.video.frameRate,
minWidth: constraints.video.width,
maxWidth: constraints.video.width,
minHeight: constraints.video.height,
maxHeight: constraints.video.height,
},
},
});
await stream.getAudioTracks()[0].applyConstraints(constraints.audio);
} else {
stream = await navigator.mediaDevices
.getDisplayMedia(constraints)
.catch(() => {});
electronWindowAPI()?.setDesktopCaptureSourceId(sourceId);
}

stream = await navigator.mediaDevices
.getDisplayMedia(constraints)
.catch(() => {});

if (!stream) return;
voiceUsers.setVideoStream(stream);
props.close();
Expand Down

0 comments on commit e4ecaa4

Please sign in to comment.