Fixed setting stream settings while changing window

This commit is contained in:
Oleh Polisan 2024-04-11 01:12:31 +03:00
parent 83d4164eac
commit 006f4e96de

View file

@ -89,10 +89,12 @@ addPatch({
bitrateTarget: 600000 bitrateTarget: 600000
}); });
console.log("opts: ", opts); console.log("opts: ", opts);
// Object.assign(opts.encode, { if(opts?.encode) {
// framerate, Object.assign(opts.encode, {
// pixelCount: height * width framerate,
// }); pixelCount: height * width
});
}
Object.assign(opts.capture, { Object.assign(opts.capture, {
framerate, framerate,
width, width,
@ -449,12 +451,14 @@ function ModalComponent({
console.log("No current stream."); console.log("No current stream.");
} }
try { try {
if(!conn) {
submit({ submit({
id: selected!, id: selected!,
...settings ...settings
}); });
} else {
//reapply contraints after some time to let discord resubmit stream
//i believe there MUST be way to do it cleaner..
setTimeout(() => {
console.log(conn); console.log(conn);
const track = conn.input.stream.getVideoTracks()[0]; const track = conn.input.stream.getVideoTracks()[0];
console.log(track); console.log(track);
@ -472,7 +476,8 @@ function ModalComponent({
console.log("Applied constraints from ScreenSharePicker successfully."); console.log("Applied constraints from ScreenSharePicker successfully.");
console.log("New constraints:", track.getConstraints()); console.log("New constraints:", track.getConstraints());
}); });
} }, 100);
} catch { } catch {
console.log("Unable to start stream."); console.log("Unable to start stream.");
} }