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,25 +459,32 @@ 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..
setTimeout(() => { if (conn) {
console.log(conn); setTimeout(() => {
const track = conn.input.stream.getVideoTracks()[0]; console.log(conn);
console.log(track); const track = conn.input.stream.getVideoTracks()[0];
const frameRate = Number(settings.fps); console.log(track);
const height = Number(settings.resolution); const frameRate = Number(settings.fps);
const width = Math.round(height * (16 / 9)); const height = Number(settings.resolution);
var constraints = track.getConstraints(); const width = Math.round(height * (16 / 9));
const newConstraints = { var constraints = track.getConstraints();
...constraints, const newConstraints = {
frameRate, ...constraints,
advanced: [{ width: width, height: height }], frameRate,
resizeMode: "none" advanced: [{ width: width, height: height }],
}; resizeMode: "none"
track.applyConstraints(newConstraints).then(() => { };
console.log("Applied constraints from ScreenSharePicker successfully."); track.applyConstraints(newConstraints).then(() => {
console.log("New constraints:", track.getConstraints()); console.log("Applied constraints from ScreenSharePicker successfully.");
}); console.log("New constraints:", track.getConstraints());
}, 100); });
// 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);
}
} catch { } catch {
console.log("Unable to start stream."); console.log("Unable to start stream.");
} }