OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / media / media-constraints.js

47 lines · javascript ref:
const e = { autoGainControl: !1, echoCancellation: !0, noiseSuppression: !0 }
export const VIDEO_QUALITY_LOW = 0
export const VIDEO_QUALITY_STANDARD = 1
export const VIDEO_QUALITY_HIGH = 2
const t = {
  [VIDEO_QUALITY_LOW]: {
    width: { ideal: 256 },
    height: { ideal: 144 },
    advanced: [{ aspectRatio: 1.33 }],
  },
  [VIDEO_QUALITY_STANDARD]: {
    width: { ideal: 426 },
    height: { ideal: 240 },
    advanced: [{ aspectRatio: 1.33 }],
  },
  [VIDEO_QUALITY_HIGH]: {
    width: { ideal: 1e6 },
    height: { ideal: 1e6 },
    advanced: [{ aspectRatio: 1.33 }],
  },
}
export const PERMISSIONS = {
  DENIED: "denied",
  GRANTED: "granted",
  NOT_DETERMINED: "not-determined",
  RESTRICTED: "restricted",
  UNKNOWN: "unknown",
  UNSUPPORTED: "unsupported",
}
const d = (e) => t[e] || t[1]
export const getCameraAudioConstraints = ({ audioDevice: t, audioMuted: d }) =>
  !(d || !t?.deviceId) && { ...e, deviceId: { exact: t.deviceId } }
export const getCameraVideoConstraints = ({ videoDevice: e, videoMuted: t, videoQuality: i }) =>
  !(t || !e?.deviceId) && { ...d(i), deviceId: { exact: e.deviceId } }
export const getScreenConstraints = ({ sourceId: e }) => ({
  audio: !1,
  video: {
    mandatory: {
      chromeMediaSource: "desktop",
      chromeMediaSourceId: e,
      minWidth: 1280,
      minHeight: 720,
    },
  },
})
export const getFaceCamDeviceStaticId = (e) => (e ? "Front Camera|videoinput|1" : "1|videoinput|1")