-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document OverConstrainedError for PTZ in explainer #229
Comments
I did not follow PTZ discussions, so I might lack some background here. In general, I think we want to move away from mandatory constraints. |
This issue is probably worth some 'privacy' label |
@youennf Do we have examples of constraints that are only treated as ideal? |
Adding the necessary hooks in media capture main is possible. |
At least ideal constraints for getUserMedia, applyConstraints might be another discussion |
Restricting pan, tilt, and zoom constraints in // [NEW] Does not fail with OverConstrainedError if no PTZ camera.
await navigator.mediaDevices.getUserMedia({ video: { pan: true } });
// [NEW] Both would be equivalent.
await navigator.mediaDevices.getUserMedia({ video: { pan: true } });
await navigator.mediaDevices.getUserMedia({ video: { advanced: [{ pan: true }] } }); It seems like a bigger change than PTZ according to w3c/mediacapture-main#697 |
For info, #231 documents the current OverConstrainedError in the PTZ explainer. |
@youennf What would be the next steps? |
It seems there is consensus to make the PTZ constraints be ideal only. We could add a step in getUserMedia algorithm that would further remove some required constraints, for instance any required constraint whose name is not in a well defined list. This list could of course be extended by specifications defining new constraints. PTZ constraints would not be in that list. |
Discussing at the webrtc editor meeting, we might need to further discuss this at next webrtc interim. |
Note the above would never fail with await navigator.mediaDevices.getUserMedia({video: {pan: {exact: 0}}}); The latter would indeed be bad for privacy if it didn't prompt first (which the spec currently says to do the way I read it.) But prompting users for permission only to fail afterwards seems like bad UX, so #246 seems like the right direction. |
Also, I am not sure it is a great idea to allow to set exact PTZ values as part of getUserMedia. All examples in the spec and explainer are getUserMedia with boolean as pan/tilt/zoom constraint values. Also, is there a case where we would want { pan: true, zoom: false }? |
(That's not a feature unique to But I see no reason to outlaw it either, since the following accomplishes the same: const [track] = (await navigator.mediaDevices.getUserMedia({video: {pan: true}})).getVideoTracks();
await track.applyConstraints({video: {pan: 100}}); In any case, the user was arguably warned when they allowed the site to "Use and move the camera". |
Supporting this pattern adds some complexity to the specification and to implementations. There is also the edge case of getUserMedia failing to applyConstraints while user granted device: the camera moved even though the web page never received a MediaStreamTrack. This seems slightly annoying. Also, the following example would most probably succeed, which somehow shows how strange this API is: const [track] = (await navigator.mediaDevices.getUserMedia({video: {tilt: true}})).getVideoTracks();
await track.applyConstraints({video: {pan: 100}}); |
On the contrary, I think special casing this is what would add complexity. Right now it's the same algorithm. Good or bad, I think it's important that behavior is predictable. I also don't think there's necessarily anything bad with setting pan, tilt and zoom immediately. That's an app choice, much like a car adjusting seat & steeringwheel when a driver gets in.
That would be an implemention bug I think, since applying constraints is step 6.6 in the |
Well, it is very predictable if the web page cannot express that behavior, except as part of applyConstraints :) Also, navigator.mediaDevices.getUserMedia({ video : { width : 481 } }) is still not very interoperable between browsers. Things are a bit simpler with applyConstraints since it starts with a device initial state that is exposed to the web page. step 6.6 is potentially calling the applyConstraints constraints twice for audio and video tracks, so "In a single operation" is not always guaranteed. step 6.6 is also handling the case of an error. If it is guaranteed to never happen, we should remove it from the spec. |
What would be unpredictable would be web devs needing to refer to a list over which constraints can be set from
Does it? Isn't that only if people make the effort to call await track.applyConstraints(buildMyConstraintsFromSettings(track.getSettings())); I don't think that's been common, until this spec at least where you're kinda forced to do that initially since the units of
It also says about these steps: "For each media type kind ... run the following sub steps, preferably at the same time" So it seems possible to implement this where all constraints failures from step 6.6. are dealt with before |
Unless there's a strong argument for using a brand new boolean member |
Some arguments have been described above, some more below. The current algorithm makes it so that getUserMedia({ pan : true } is different from getUserMedia({ pan : 1 }). PTZ constraints are currently numerical constraints. This entails selecting devices based on a distance. The current model is adding complexity to web browser implementations. |
This is not true ;) Note that this example though may be better with a device id. const videoStream = await navigator.mediaDevices.getUserMedia({
// Website asks to reset known camera pan.
video: { pan: 1, deviceId: { exact: "myCameraDeviceId" } }
}); However, as you said, this could be done with gUM and applyConstraints. |
As discussed at w3c/mediacapture-main#697, the resolution to the fingerprinting/capabilities query in
getUserMedia()
in general seems to be to keep things as they are. It means that pan/tilt/zoom properties will be three more properties among the many thatgetUserMedia()
already exposes.In other words,
getUserMedia()
will reject with anOverConstrainedError
if camera does not support PTZ and PTZ constraints are required without user prompt.I believe we should document this in the upcoming privacy section of the PTZ explainer.
@riju @reillyeon @eehakkin @andypaicu @guidou
The text was updated successfully, but these errors were encountered: