Fixed changing stream quality description

This commit is contained in:
Oleh Polisan 2024-04-11 15:44:39 +03:00
parent b9b336126a
commit c34533295c

View file

@ -442,6 +442,11 @@ 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());
}); });
// changing stream quality description
conn.videoStreamParameters[0].maxFrameRate = Number(settings.fps);
conn.videoStreamParameters[0].maxResolution.height = Number(settings.resolution);
conn.videoStreamParameters[0].maxResolution.width = Math.round(height * (16 / 9));
} }
} catch { } catch {
console.log("No current stream."); console.log("No current stream.");
@ -454,6 +459,7 @@ function ModalComponent({
// reapply contraints after some time to let discord resubmit stream // reapply contraints after some time to let discord resubmit stream
// i believe there MUST be way to do it cleaner.. // i believe there MUST be way to do it cleaner..
if (conn) {
setTimeout(() => { setTimeout(() => {
console.log(conn); console.log(conn);
const track = conn.input.stream.getVideoTracks()[0]; const track = conn.input.stream.getVideoTracks()[0];
@ -472,7 +478,13 @@ 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());
}); });
// changing stream quality description
conn.videoStreamParameters[0].maxFrameRate = Number(settings.fps);
conn.videoStreamParameters[0].maxResolution.height = Number(settings.resolution);
conn.videoStreamParameters[0].maxResolution.width = Math.round(height * (16 / 9));
}, 100); }, 100);
}
} catch { } catch {
console.log("Unable to start stream."); console.log("Unable to start stream.");
} }