PSA: Changes in constraint behavior

368 views
Skip to first unread message

Harald Alvestrand

unread,
Jan 22, 2016, 9:11:58 AM1/22/16
to WebRTC-discuss

Heads-up:

In our WebRTC media stream track support, we are in the process of adding support for standards compliant constraints.

In the long run, it will make constraints simpler to use; instead of


getUserMedia({video: {mandatory: { ‘maxWidth’: ‘640’ }, optional: [ {‘maxFrameRate’: ‘31’, ‘minFrameRate’: ‘29}]}})


(this expresses a requirement for video no wider than 640, and a wish for a framerate of 30)

you will be able to write


getUserMedia({video: { ‘frameRate’: 30, width: { ‘max’: 640 }})


We’re adding this while keeping backwards compatibility as far as possible, but there will be a few changes that are visible to the user.


  • If you look at “constraint errors” that include a constraint name, the constraint name may change. Even if you specify “maxWidth” in the old syntax, the constraint name will be “width”.

  • Some error codes may change. Particularly, we’re going to introduce some more checking on legal values - so that if you have been specifying “True” instead of “true”, you’ll get a TypeError. (Previously, depending on the particular constraint, it would be interpreted as false or give an error.)


You will be able to use old and new constraints for a while, but you can’t mix them; for example, this will give an error message:


getUserMedia({video: { mandatory: { ‘maxWidth’: ‘640’ }, ‘height’: {‘max’: 480}})


Not all features of the syntax will be supported at first. We’ll expect to keep the feature behind an experimental flag while we add the features; we hope to have the first experimental support out soon.


Harald, for the WebRTC Blink team

Harald Alvestrand

unread,
Jan 28, 2016, 1:56:02 PM1/28/16
to WebRTC-discuss
As part of this change, we're checking the names of constraints that are passed as mandatory in the old style.
If you specify constraints that don't exist as mandatory, you will get an error.

The name of the unknown constraint will be logged to the developer console.
We have room to skip the check for previously used names - please report these as you see them!

Gábor Tóth

unread,
Dec 14, 2017, 3:33:00 AM12/14/17
to discuss-webrtc
I've runned into a problem about supporting newer version of chromes and olders.  Could you please tell me from which version of chrome accepts constraints as in the specs? i feel this should be shimmed in webrtc-adapter


pc.createAnswer({offerToReceiveAudio: true, offerToReceiveVideo: true})

versus:

pc.createAnswer({mandatory: {offerToReceiveAudio: true, offerToReceiveVideo: true}})


Cheers
Gábor

Philipp Hancke

unread,
Dec 14, 2017, 3:36:40 AM12/14/17
to WebRTC-discuss
answer constraints have been non-spec for quite a while. The switch from mandatory: {Offer*} to {offer*} in createOffer happened years ago, I think support for Offer* was removed in Chrome 39 if I recall correctly.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/1011101e-19a5-49bb-a28d-e1c7fda8d458%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gábor Tóth

unread,
Dec 14, 2017, 3:42:26 AM12/14/17
to discuss...@googlegroups.com
i mean the mandatory part.  We've got a few errors of older chromes that say: Failed to execute 'createAnswer' on 'RTCPeerConnection': Malformed constraints object

What is the best practice today?

--

---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/ZRQiSy6z_Dg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/CADxkKiKmf4aMOZOhO%2BXx3MKYcq4gsj6SFvUWiK%3DtJga7XWNDfg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Üdvözlettel:
    Tóth Gábor

Harald Alvestrand

unread,
Dec 14, 2017, 4:45:49 AM12/14/17
to WebRTC-discuss
The standard-compliant offerToReceive* was added here:


That submission was done in March 2016. I'm not sure which version went out after that.

I'd suggest that if you're running Chrome that is > 1.5 years old, you may want to consider what security fixes you've missed out on. Non-support for createOffer({offerToReceive}) may be the least of your problems.



On Thu, Dec 14, 2017 at 9:42 AM, Gábor Tóth <tgab...@gmail.com> wrote:
i mean the mandatory part.  We've got a few errors of older chromes that say: Failed to execute 'createAnswer' on 'RTCPeerConnection': Malformed constraints object

What is the best practice today?
Reply all
Reply to author
Forward
0 new messages