@jellyfish-dev/react-client-sdk
Version:
React client library for Jellyfish.
48 lines (47 loc) • 1.38 kB
JavaScript
export const AUDIO_TRACK_CONSTRAINTS = {
advanced: [{ autoGainControl: true }, { noiseSuppression: true }, { echoCancellation: true }],
};
export const VIDEO_TRACK_CONSTRAINTS = {
width: {
max: 1280,
ideal: 1280,
min: 640,
},
height: {
max: 720,
ideal: 720,
min: 320,
},
frameRate: {
max: 30,
ideal: 24,
},
};
export const SCREEN_SHARING_MEDIA_CONSTRAINTS = {
video: {
frameRate: { ideal: 20, max: 25 },
width: { max: 1920, ideal: 1920 },
height: { max: 1080, ideal: 1080 },
},
};
export const toMediaTrackConstraints = (constraint) => {
if (typeof constraint === "boolean") {
return constraint ? {} : undefined;
}
return constraint;
};
export const prepareMediaTrackConstraints = (deviceId, constraints) => {
if (!deviceId)
return false;
if (deviceId === true)
return { ...constraints };
const exactId = deviceId ? { deviceId: { exact: deviceId } } : {};
return { ...constraints, ...exactId };
};
export const getExactDeviceConstraint = (constraints, deviceId) => ({
...constraints,
deviceId: { exact: deviceId },
});
export const prepareConstraints = (deviceIdToStart, constraints) => {
return deviceIdToStart ? getExactDeviceConstraint(constraints, deviceIdToStart) : constraints;
};