-
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
Clarify meaning of PTZ constraints presence #256
Comments
For context, this came up in #246 (comment). |
However we define constraints and distance, the user agent can select any of the devices in finalSet. Given PTZ is different in nature compared to other cameras in terms of permission, we could try to mandate that, in case the query asks for PTZ, UA is expected to prefer selecting PTZ devices first in finalSet.
That is my preference obviously. I would tend to leave 'pan', 'tilt' and 'zoom' to applyConstraints solely.
I do not see how this will guarantee to get what we want.
Isn't it investing in a model we know is too complex? |
The fitness distance algorithm could be hotfixed so that the distance is positive infinity if a PTZ constraint is present but the camera does not support that PTZ capability. In that case navigator.mediaDevices.getUserMedia({video: {tilt: {}}}); would select a tilt capable camera or fail with OverconstrainedError, navigator.mediaDevices.getUserMedia({video: {deviceId: {exact: '20983-20o198-109283-098-09812'}, tilt: {}}}); would select the device 20983-20o198-109283-098-09812 if it is tilt capable camera or fail with OverconstrainedError overwise and navigator.mediaDevices.getUserMedia({video: {deviceId: {exact: '20983-20o198-109283-098-09812'}, advanced: [{tilt: {}}]}}); would always select the device 20983-20o198-109283-098-09812 (given that it is available). |
That is probably what we want to avoid. |
Not really. A web site should have an option to choose either way.
That could be achieved with hotfixed fitness distance by navigator.mediaDevices.getUserMedia({video: {advanced: [{tilt: {}}]}}); If there were no PTZ cameras, the advanced constraint |
I think option 3 will give us what we want naturally. Then
Then we wouldn't need any special rules, which I think is a win. 1) For those with a sharp eye: yes we forgot to define distance for boolean constraints in mediacapture main, because it hasn't come up before. E.g. you can't really pick mics based on the |
Thanks @jan-ivar for the suggestions. I am in favour of Option 3. IIUC for Option 1, there might be some confusion if Option 3 aligns the pan, tilt and zoom to work in the same way as the other properties regarding
We will experiment with the changes in Chrome's implementation and then send a PR for the spec changes. |
I raised a similar concern when the boolean override was proposed since pan: {} is not different from having the property unconstrained in terms of the SelectSettings algorithm. Option 3 is similar to the current spec, except that has more possibilities. I would interpret it as follows (unless some other explicit meaning is given):
Not sure if the extra complexity of allowing pan to be used this way or in the usual DoubleConstraint way is worth it over using a separate constraint for the PTZ capability. |
I find no support in the spec for that interpretation. The spec says: "A value of
I see no way in the current spec to require PTZ capability without setting a value, e.g. Option 3 would add that with e.g.
You're listing the natural outcomes of the existing constraints algorithm. I think the complexity is exactly the same as having a separate boolean constraint, except we avoid some nonsense combos: {video: {ptz: {exact: false}, pan: {min: 3600}}} {video: {ptz: false, pan: 3600}} |
The spec says: " An empty ConstrainDoubleRange value implies no constraints but only a permission and capability request."
See above.
IIRC, the result of a previous discussion was that the presence of the constraint (with any value, including empty/true) indicated the capability/permission request. As indicated above, the spec explicitly says: "An empty ConstrainDoubleRange value implies no constraints but only a permission and capability request."
Indeed.
Having to deal with the weird combos, is part of the extra complexity. Having to deal with a range that is the union of all floating point numbers, true and false, where true and false have specific meanings that are not translations to a floating-point range is probably going to be harder in terms of implementation than dealing with just the set of floating numbers or just {true,false}. |
Agreed, this seems a recipe for bad interop. Let's take { video : { pan : 10, width : 1920 } } as an example with a 720p PTZ camera and a 1080p non PTZ camera. We should drive the design with what the developer might want to express as part of the getUserMedia call and what the user might want to do in terms of selection. |
But that is just a note. If that meaning is to be retained, it should be spelled out in the main descriptions and not only in a note.
Like that text does not say anything about that in this case an empty ConstrainDouble implies required hardware support for the property also in the basic set unlike in the case of all non-PTZ properties. In addition, in Chrome,
Option 3 would allow a request to prefer a pan and tilt capable camera over a zoom-only capable camera using
or to require a pan and tilt capable camera over a zoom-only capable camera using
The former is apparently not possible at the moment and the latter can be achieved only using
although the idea behind the true semantics is to able to avoid guessed defaults like With a separate constraint for the PTZ capability the former would remain impossible and the latter would remain the same or become
With @youennf's suggestion to remove pan/til/zoom support from getUserMedia, also the latter would become impossible. |
Agree. Normative statements should never reside solely in notes. Notes clarify normative text or algorithms elsewhere, and should never directly contradict algorithms. Here I see spec support for the permission part only, not "capability request" which appears undefined.
Implementers come last in the priority of constituencies. I think we must prioritize preserving web compatible semantics for users (who come first).
This is a perfect example of why we defined the constraints algorithm in the first place. What matters is not that I can intuit every corner case, but that it works the same in all browsers. Predictability trumps usefulness at the edges. The only way to preserve web compatible semantics here is to strictly adhere to an algorithm. I think evidence of poor web compat points to browsers not following the algorithm. |
Just to show I'm not insensitive to the complexity burden on implementers, I've been trying to get rid of w3c/mediacapture-main#369 |
We are deviating somehow from the initial issue, but I cannot resist... some answers inline.
The constraints algorithm tried to support a very high level of expressiveness and implementations fail to deliver.
I partially agree. The only hypothetical benefit I can see would be if we would be able to get rid off of enumerating all microphones and cameras, which we are very far from being able to do. A tree-based approach for device selection seems more natural and would be much simpler.
The spec should first define a precise and unambiguous algorithm. This is not yet the case.
I support this. |
Then it should be moved to be normative. Without that note, pan:true being equivalent to pan: {} is totally worthless and has no meaning since {} otherwise means unconstrained, which is largely the same as not saying anything, which is what pan:false is supposed to mean. if true and false mean the same thing, then there is no point in having a boolean.
Yes, it does. At least, that's what it did the last time I reviewed the code.
That is correct. However, in the discussions I have seen (and in the Chromium implementation) pan/tilt/zoom has been treated as a single hardware capability. If that is not the case, then this should be clarified in the spec and, if possible in practice, also in the Chromium implementation.
There are no
That is an issue only if pan,tilt and zoom are independent hardware capabilities and you use a single constraint. If they are indeed separate, you need three separate boolean constraints. This is orthogonal to the permission (there are lots of other constraints for the regular camera permission, just like there can be three constraints for a single PTZ permission). |
@youennf The SelectSettings algorithm is precise if you follow it. I'm all for tightening the SHOULD to a MUST, if you think we gave user agents too much rope to not follow it. In any case, it would seem adhering to the algorithm is the answer to web compat, not the problem.
@guidou While implementations are free to make such assumptions, I see no need to cement them in the spec¹ or contort the API over them. It seems cleaner in the abstract for apps to ask for what they want based on their needs, and not make cross-feature assumptions.
@eehakkin I find the separate navigator.mediaDevices.getUserMedia({video: {pan: {exact: 0}, tilt: {exact: 0}}}); ...or if I don't want to set values (for the same impact on fitness distance): navigator.mediaDevices.getUserMedia({video: {pan: {exact: true}, tilt: {exact: true}}}); 1) We combine them only in the permissions-space, where I think it makes sense since the trio shares similar privacy concerns. |
I think it's part of the answer. Another problem is that for requests that are not very constrained (e.g., unconstrained or wide min/max ranges) and without ideal values, implementations are allowed to select any setting that satisfies the constraints. Since lots of different values are allowed, browsers break this tie using different criteria. This is not bad, since different browsers can have very good reasons to choose different defaults, but it leads to different results.
I agree. But I was referring more to the point that having a separate single boolean constraint (e.g., ptzAbility or similar) wouldn't allow zoom-only, or pan-only, or tilt-only selection, to which the reply is that there should be separate constraints for that, and that this is orthogonal to the permission.
Agree
Agree that the spec should say this. |
True and false do not mean the same thing. Both From the spec: Any algorithm which uses a MediaTrackConstraintSet object and its pan dictionary member which exists after a possible normalization MUST request permission to use a PermissionDescriptor with its name member set to camera and its panTiltZoom member set to true, and, optionally, consider its deviceId member set to any appropriate device’s deviceId.
Does it? Below you say that in the Chromium implementation pan/tilt/zoom has been treated as a single hardware capability so in essence Chrome request and a hardware support for some PTZ property (pan, tilt or zoom).
True.
At least there are cameras which are capable to zoom but not capable to pan or tilt so might be useful to treat them as separate capabilities.
In the first place, the purpose of the boolean is to allow to request PTZ permission without forcing any movement to a particular setting. Selection of a PTZ-capable camera is also very useful. I am just not sure if it makes sense to implement that in a way there only PTZ constraint precense in the basic set become required capability constraints while all other constraints in the basic without explicit 'exact', 'min' or 'max' are non-required constraints. |
I do not think the following step is precise enough: 'For every possible settings dictionary of copy compute its fitness distance'? In general, this algorithm assumes to compute an absolute minimum of a multivariable function. I agree it is good to define an algorithm to compute settings in an interoperable manner, but what is the motivation for such complexity? It seems we are trying to solve a problem that users do not care about. The counter proposal that I hope to present next week is to select devices based on priorities of constraints. For camera, I was thinking of something like PTZ > deviceId > groupId > facingMode > aspectRatio > width > height > frameRate. To un break the tie, use the order exposed by enumerateDevices so that default devices are first. |
This seems like a natural and good default behavior. I think we should enforce it.
I agree it is worth discussing whether ptz boolean values should be ideal only or can also be exact. |
Using known pan, tilt, and zoom values could help on systems where multiple PTZ camera devices are plugged and you want user to pick one rather than another one. |
@youennf I don't think I care about that, since what constraints bring of value to this spec is the established user semantics. I think trying to carve out exceptions to those semantics solely for ptz is what is sinking us, and why we're here opening issues. While I appreciate the value of reducing functionality for test coverage, I think the constraints ship has sailed. Especially since we're not talking about a new API here, but extensions to the existing Challenging the core tenets of the constraints algorithm at this late stage also seems out of scope for this issue, even this spec. If you will: it seems overkill to me is to reinvent constraints over this issue. If you'd still like to try, please open a separate issue, since I think we should be able to make progress here in parallel. |
Back to this issue, to restate the problem, I think this spec has... A legitimate need to extend the modelWhile all cameras have
The consensus among those not challenging the whole constraints algorithm appears to be option 3 in the OP. |
Stated as a bug: we need to fix the way this spec has already embraced the |
PTZ is an exception in itself, given it requires a distinct permission so a distinct user decision.
Let's check first whether the spec needs to use a |
@eehakkin @youennf Since I won't be able to make it to today's virtual interimg, I've added this slide to the deck if someone wants to present it if the discussion leads this way. |
Now that required image capture constraints are not allowed any more, I think that the original option 3 ( However, I still think that defining the effect of So, how about that we define a new typedef
|
For info, WEBRTC WG meeting at TPAC 2020 recording about this issue is available at https://youtu.be/zjZy8evtkkc?t=6271 |
This spec appears to assume any mention of
pan
,tilt
orzoom
will result in a PTZ device (& thus require ptz permission).But that's not how the constraints algorithm works. E.g.
...is equivalent to
...where
{}
has no impact on fitness distance, and may choose your 1080p camera over your low-res PTZ camera.This seems unexpected, because a constraint value (even
true
) would usually carry weight, except as defined here.You may also have granted the site more permission than necessary to access the device chosen.
What's the model?
A related question is whether regular non-ptz cameras satisfy the following constraints:
Is it yes, because non-ptz cameras point front and center without zoom or tilt?
Is it no, because non-ptz cameras shouldn't have read-only
pan
,tilt
orzoom
settings? The spec doesn't say.It appears we've overloaded the presence or absence of
pan
,tilt
orzoom
constraints with meaning.Options I see:
true
overload ofpan
,tilt
andzoom
constraints, and replace it with aptz
ConstrainBoolean.true
a first-class value ofpan
,tilt
andzoom
, and specify a newConstrainULongOrBoolean
.The text was updated successfully, but these errors were encountered: