Summary
For <usermedia> implementations a concise, attribute-based syntax might be better suited for some use cases. The goal is to better surface user intent at the HTML layer, while preserving the existing script-based constraints as an escape hatch.
Motivation
PEPC optimizes for clear, declarative user intent. Requiring embedded JSON scripts for camera/microphone controls:
- Obscures intent in otherwise semantic HTML
- Reduces readability and diffability
- Adds CSP and tooling friction
Most real-world use cases only need coarse, predictable constraints that map to attributes.
Also, the following may not be the most readable semantics.
<usermedia>
<script type="permissionconstraints">
{
"video": {
"width": { "min": 640, "ideal": 1920, "max": 1920 },
"height": { "min": 400, "ideal": 1080 },
"aspectRatio": 1.777777778,
"frameRate": { "max": 30 }
}
}
</script>
</usermedia>
Proposed syntax
Minimal usage
<usermedia audio></usermedia>
<usermedia video></usermedia>
<usermedia audio video></usermedia>
Equivalent to:
{ audio: true }
{ video: true }
{ audio: true, video: true }
Constraint refinement via prefixed attributes
<usermedia
video
video-width="1920"
video-height="1080"
video-framerate-max="30">
</usermedia>
Maps to:
{
video: {
width: { ideal: 1920 },
height: { ideal: 1080 },
frameRate: { max: 30 }
}
}
<usermedia
audio
audio-channel-count="2"
audio-sample-size="16">
</usermedia>
Rules:
audio / video attributes express requested capabilities
audio-* and video-* attributes refine constraints
- Prefixed attributes without the base capability are invalid
Autostart (unchanged)
<usermedia audio video autostart></usermedia>
Escape hatch for advanced constraints
For less common or advanced cases, allow a single JSON attribute:
<usermedia constraints='{ "video": { "aspectRatio": 1.777 } }'></usermedia>
If present, constraints overrides all derived attributes.
Parsing model (high level)
-
If constraints attribute is present, parse and use it
-
Otherwise:
- Initialize
audio and/or video based on presence of attributes
-
Apply audio-* and video-* refinements
-
If neither audio nor video is present, the element is invalid
Why this fits PEPC
- Attributes express intent, scripts express behavior
- HTML-first, declarative, and inspectable
- Better tooling, accessibility, and CSP characteristics
This is a layering improvement, not a replacement.
Summary
For
<usermedia>implementations a concise, attribute-based syntax might be better suited for some use cases. The goal is to better surface user intent at the HTML layer, while preserving the existing script-based constraints as an escape hatch.Motivation
PEPC optimizes for clear, declarative user intent. Requiring embedded JSON scripts for camera/microphone controls:
Most real-world use cases only need coarse, predictable constraints that map to attributes.
Also, the following may not be the most readable semantics.
Proposed syntax
Minimal usage
Equivalent to:
Constraint refinement via prefixed attributes
Maps to:
Rules:
audio/videoattributes express requested capabilitiesaudio-*andvideo-*attributes refine constraintsAutostart (unchanged)
Escape hatch for advanced constraints
For less common or advanced cases, allow a single JSON attribute:
If present,
constraintsoverrides all derived attributes.Parsing model (high level)
If
constraintsattribute is present, parse and use itOtherwise:
audioand/orvideobased on presence of attributesApply
audio-*andvideo-*refinementsIf neither
audionorvideois present, the element is invalidWhy this fits PEPC
This is a layering improvement, not a replacement.