- From: Jan-Ivar Bruaroey <jib@mozilla.com>
- Date: Thu, 20 Feb 2014 16:13:21 -0500
- To: "public-media-capture@w3.org" <public-media-capture@w3.org>
(Hopefully fixes messed-up indentation) Constraints went general at every turn. What if we went the other way? Roc's MediaRecorder proposal http://lists.w3.org/Archives/Public/public-media-capture/2014Feb/0001.html was dismissed for not being compatible with constraints in gUM, so it seems there's no way around addressing gUM. Here's how to solve gUM with dictionaries, while keeping functional parity. The goal is to learn from constraints yet rid the spec of them entirely, as nothing less will simplify. dictionary UserMediaSettings { boolean video; boolean audio; DOMString peerIdentity; long width; long height; double aspectRatio; double frameRate; VideoFacingModeEnum facingMode; double volume; unsigned long sampleRate; unsigned long sampleSize; boolean echoCancelation; // Dictionary may be extended through gUM-specific IANA registry. }; dictionary Request { { DOMString require; // explained below DOMString prefer; // explained below }; dictionary UserMediaSettingsRequest : Request { { boolean video; boolean audio; DOMString peerIdentity; (unsigned long or UnsignedLongRequest) width; (unsigned long or UnsignedLongRequest) height; (double or DoubleRequest) aspectRatio; (double or DoubleRequest) frameRate; (VideoFacingModeEnum or sequence<VideoFacingModeEnum>) facingMode; (double or DoubleRequest) volume; (unsigned long or UnsignedLongRequest) sampleRate; (unsigned long or UnsignedLongRequest) sampleSize; boolean echoCancelation; // Dictionary may be extended through gUM-specific IANA registry. }; dictionary UnsignedLongRequest { unsigned long min; unsigned long max; unsigned long ideal; }; Clients may list the names of keys they require. Example: var request = { require: "width, height", width: { min: 640, ideal: 1280 }, height: { min: 480, ideal: 768 }, aspectRatio: 16/9, frameRate: 60, facingMode: "user", }; navigator.getUserMedia(request, success, failure); If they do, getUserMedia will fail if required keys are either missing, unknown or unsatisfied. There is no order by default, instead sources are ranked by how many settings they satisfy, with the UA breaking a tie for the default choice (which end-users may ultimately override). Clients who prefer an order may do this: var request = { require: "width, height", prefer: "aspectRatio", width: { min: 640, ideal: 1280 }, height: { min: 480, ideal: 768 }, aspectRatio: 16/9, frameRate: 60, facingMode: "user", }; navigator.getUserMedia(request, success, failure); which will pick a 16:9 environment-facing 75Hz camera over a user-facing 60hz 4:3 camera, without requiring 16:9. getUserMedia will not fail if preferred keys are missing, unknown or unsatisfied. MediaStreamTrack re-absorbs the affected functionality: interface MediaStreamTrack : EventTarget { UserMediaSettingsRequest getInherentCapabilities (); UserMediaSettings snapshotCurrentSettings (); void applySettings (UserMediaSettingsRequest settings, VoidFunction successCallback, ConstraintErrorCallback errorCallback); attribute EventHandler onconflict; readonly attribute DOMString kind; readonly attribute DOMString id; readonly attribute DOMString label; attribute boolean enabled; readonly attribute boolean muted; attribute EventHandler onmute; attribute EventHandler onunmute; readonly attribute boolean _readonly; readonly attribute boolean remote; readonly attribute MediaStreamTrackState readyState; attribute EventHandler onstarted; attribute EventHandler onended; MediaStreamTrack clone (); void stop (); }; More than just renaming, there is no universal constraint concept, no Constrainable interface, no object-based constraint object, and no co-mingled domain-spanning data definitions outside of WebIDL. Things are well defined in context using standard WebIDL. MediaRecorder may borrow what little it needs or invent its own API. .: Jan-Ivar :.
Received on Thursday, 20 February 2014 21:13:47 UTC