Skip to content
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

MediaStreamTrack.applyConstraints() should resolve the Promise with the applied constraints #462

Closed
yellowdoge opened this issue May 30, 2017 · 12 comments
Assignees

Comments

@yellowdoge
Copy link
Member

At https://w3c.github.io/mediacapture-main/#dom-constrainablepattern-applyconstraints(), instead of resolving with void, it'd be better to resolve with the applied constraints.

@yellowdoge
Copy link
Member Author

yellowdoge commented May 30, 2017

@burnburn
Copy link
Contributor

burnburn commented Aug 3, 2017

@jan-ivar can you think of any reason why we couldn't do this?

@jan-ivar
Copy link
Member

jan-ivar commented Aug 3, 2017

@yellowdoge What's the utility? You already have them, and they're synchronously available:

await track.applyConstraints(constraints);
console.log(constraints == track.getConstraints()); // true

@yellowdoge
Copy link
Member Author

@beaufortfrancois what was the rationale...?

@beaufortfrancois
Copy link
Contributor

I'd like to know which constraints have been applied after each call as they might not be the ones currently set.

track.applyConstraints(someConstraints).then(appliedConstraints => {
  console.log(appliedConstraints + ' may be different from ' + track.getConstraints());
)};
track.applyConstraints(otherConstraints).then(appliedConstraints => {
  console.log(appliedConstraints + ' may be different from ' + track.getConstraints());
)};

@jan-ivar
Copy link
Member

jan-ivar commented Sep 5, 2017

they might not be the ones currently set.

@beaufortfrancois That cannot happen.

@beaufortfrancois
Copy link
Contributor

beaufortfrancois commented Sep 6, 2017

Chrome's implementation actually makes this happen. Go to https://beaufortfrancois.github.io/sandbox/image-capture/playground.html and execute JS code below in your console (webcam is expected):

imageCapture.track.applyConstraints({advanced: [{brightness: 100}]}).then(_ => {
  var appliedBrightness = imageCapture.track.getConstraints().advanced[0].brightness;
  console.assert(appliedBrightness == 100, 'applied brightness should be 100');
});
imageCapture.track.applyConstraints({advanced: [{brightness: 200}]}).then(_ => {
  var appliedBrightness = imageCapture.track.getConstraints().advanced[0].brightness;
  console.assert(appliedBrightness == 200, 'applied brightness should be 200');
});
>>> Assertion failed: applied brightness should be 100

@guidou
Copy link
Contributor

guidou commented Sep 7, 2017

@beaufortfrancois : Chrome's implementation is not spec compliant and only works in a limited way for image capture. If applyConstraints is successful, getConstraints() should be the same (or equivalent) to the constraints that were requested.

@jan-ivar
Copy link
Member

jan-ivar commented Sep 7, 2017

Isn't it also behind a flag still?

@beaufortfrancois
Copy link
Contributor

It is not behind a flag after Chrome 59.

@guidou
Copy link
Contributor

guidou commented Oct 25, 2017

We should close this.
I'm preparing a change in Chromium to make applyConstraints resolve promises with void for image capture, since the applied constraints and current settings can always be obtained using getConstraints() and getSettings(), respectively.

@alvestrand
Copy link
Contributor

Closing. You can get the most recently applied constraints by getConstraints(), and the settings that resulted by getSettings() (and they don't mean the same thing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants