From c49dc0333ee0cf742dfad1c4aa802fcb7f2e1157 Mon Sep 17 00:00:00 2001 From: kaitlynkittyy Date: Wed, 10 Apr 2024 15:17:43 -0400 Subject: [PATCH] yeah --- src/renderer/components/ScreenSharePicker.tsx | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index a8e93f7..69eb86a 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -415,10 +415,19 @@ function ModalComponent({ currentSettings = settings; // If there are 2 connections, the second one is the existing stream. // In that case, we patch its quality - const conn = [...MediaEngineStore.getMediaEngine().connections][1]; + try { + var conn = [...MediaEngineStore.getMediaEngine().connections].find( + connection => connection.streamUserId === UserStore.getCurrentUser().id + ); + } catch { + console.log("No current stream."); + } + console.log([...MediaEngineStore.getMediaEngine().connections]); try { if (conn.streamUserId === UserStore.getCurrentUser().id) { + console.log(conn); const track = conn.input.stream.getVideoTracks()[0]; + console.log(track); const frameRate = Number(settings.fps); const height = Number(settings.resolution); const width = Math.round(height * (16 / 9)); @@ -437,12 +446,32 @@ function ModalComponent({ } catch { console.log("No current stream."); } - - if (!conn) { + try { submit({ id: selected!, ...settings }); + if (conn.streamUserId === UserStore.getCurrentUser().id) { + console.log(conn); + const track = conn.input.stream.getVideoTracks()[0]; + console.log(track); + const frameRate = Number(settings.fps); + const height = Number(settings.resolution); + const width = Math.round(height * (16 / 9)); + var constraints = track.getConstraints(); + const newConstraints = { + ...constraints, + frameRate, + advanced: [{ width: width, height: height }], + resizeMode: "none" + }; + track.applyConstraints(newConstraints).then(() => { + console.log("Applied constraints from ScreenSharePicker successfully."); + console.log("New constraints:", track.getConstraints()); + }); + } + } catch { + console.log("Unable to start stream."); } close();