WebRTC OfferToReceiveAudio error in Firefox

2019-01-08 01:59发布

I'm developing a simple example to test WebRTC, and I've found the following strange behaviour.

When using Chrome, the media constraints are specified as:

mediaConstraints = {'mandatory': {'OfferToReceiveAudio':true, 'OfferToReceiveVideo':true}};

which works fine.

However, when using Firefox (35.0.1 on the mac), according to the spec it should be:

mediaConstraints = {'offerToReceiveAudio':true,'offerToReceiveVideo':true};

But doesn't work (Ice failed!)

Using "OfferToReceiveAudio"

mediaConstraints = {'OfferToReceiveAudio':true,'offerToReceiveVideo':true};

works fine.

Is this documented behaviour?

2条回答
Ridiculous、
2楼-- · 2019-01-08 02:31

In the specs here:

https://developer.mozilla.org/en-US/docs/Web/Guide/API/WebRTC/WebRTC_basics

I see that the constraints should be in the following format:

var constraints = {
    mandatory: {
        OfferToReceiveAudio: true,
        OfferToReceiveVideo: true
    }
};

Chrome only supports that format.

you can refer to this discussion for same issue:

WebRTC - getting 'malformed constraints object' from Chrome but not Firefox

查看更多
虎瘦雄心在
3楼-- · 2019-01-08 02:44

The right format (by now) is:

offerOptions = {'offerToReceiveAudio':true,'offerToReceiveVideo':true};

as this is the new spec format and is supported by both Chrome and Firefox.

Take special care to note the lower-case 'o's, as this did change and threw more than a few people. Hopefully you got it working by now.

Also note that these are no longer "constraints", just "options". Simpler.

查看更多
登录 后发表回答