orgasm.dev

Camera and microphone

Ask for the camera and microphone after explaining why, from a click, with every refusal named along with what to do about it.

A browser asks once for the camera and microphone, in a prompt it words itself, and remembers a no. The device SDK's capture module asks well: from a click, with the constraints the analysis needs, and when the answer is no, it says why and what to do in that browser. <orgasm-capture-primer> explains before the prompt appears.

Explain first

<orgasm-capture-primer developer="Lumen Games" retention-days="7" privacy-url="https://lumen.example/privacy"></orgasm-capture-primer>

Before the browser asks anything, the primer tells the person, in plain words:

  • what is measured: how close they are to orgasm, and when one begins, peaks and ends;
  • why the camera: their face shows how close they are;
  • why the microphone: breath and voice mark when an orgasm begins, peaks and ends, and without it those moments aren't called;
  • that only numbers leave their device: video and sound go to an enclave their device checks first, are analysed there and never stored, and nobody can watch them, you included;
  • who receives the readings and for how long: your name (developer) and your retention-days, or 0 for not kept;
  • that they are in control: a light shows whenever analysis is on, and they can stop it at any time.
Attribute
developerYour product's name, as the person knows it
purposeA sentence on what your product does with the readings
retention-daysHow long you keep them; without it, the primer points to your privacy policy
privacy-urlYour privacy policy
audiofalse to ask for the camera alone

primer.strings rewords any of it, for another language or your product's voice; keep what each line says.

device.js
import { verifyEnclave } from '@orgasm-dev/device';
import '@orgasm-dev/device/hud';

const primer = document.querySelector('orgasm-capture-primer');
primer.verify = () => verifyEnclave({ origin: new URL(session.ingest.attestationUrl).origin, policyUrl: 'https://orgasm.dev/v1/attestation-policy' });
primer.addEventListener('orgasm-capture', (event) => publish(event.detail.capture.stream));
primer.addEventListener('orgasm-capture-refused', (event) => track('camera_refused', event.detail.reason));
primer.addEventListener('orgasm-capture-declined', () => showLater());

With verify set, the primer checks the enclave on the person's device before it asks, and says that it did, with the release it found. If the check fails it asks for nothing and fires orgasm-capture-failed. A sandbox session has no enclave to check, so leave verify unset with a test key.

Ask from a click

Without the primer, call requestCapture from a click: browsers show their prompt only in answer to one.

device.ts
import { CaptureRefused, requestCapture } from '@orgasm-dev/device/capture';

button.addEventListener('click', async () => {
  try {
    const capture = await requestCapture();
    // capture.stream for publishLiveSession; capture.audio is false when only the camera started
  } catch (error) {
    if (error instanceof CaptureRefused) message.textContent = error.recovery;
    else throw error;
  }
});

It asks for the front camera at a long edge of 1280 pixels and 30 frames a second, the inputs the analysis reads, and for the microphone. A missing or busy microphone doesn't stop it: the camera starts alone and capture.audio says so, because imminence and edges need only the face. requestCapture({ audio: false }) asks for the camera alone.

When the answer is no

CaptureRefused names the refusal in reason, and recovery is a sentence to show the person, written for their browser:

reasonWhat happened
deniedThe person, the browser or the system said no. recovery says where this browser's camera permission is, and the system's setting behind it.
no_cameraThere is no camera, or not the one asked for
in_useAnother app holds the camera; recovery mentions OBS's Virtual Camera
insecureThe page isn't https (or localhost)
unsupportedThis browser can't share a camera with a page
abortedThe camera didn't start, for no reason the browser gave

Before asking anything

captureSupport() says whether this browser can run a live session at all, before any prompt: { ok, missing }, where missing lists secure_page, camera_access, webrtc, streams or ed25519 (the enclave's signatures). Show a browser that can't run one what to use instead, rather than a prompt that fails.

listCaptureDevices() lists the cameras and microphones, with names once the person has granted access. Pass one as videoDeviceId to requestCapture, or as the primer's captureOptions, to use a camera other than the front one, such as OBS's Virtual Camera.

The primer explains; it doesn't ask for consent and doesn't record it. Your product still asks the person, explicitly, before the session starts, keeps a record, and attests both in consent when it creates the session (Acceptable use). Show the primer after that consent, as the step that turns the camera on.

On this page