问题描述
我正在开发一个简单的示例来测试 WebRTC,我发现了以下奇怪的行为.
I'm developing a simple example to test WebRTC, and I've found the following strange behaviour.
使用 Chrome 时,媒体约束指定为:
When using Chrome, the media constraints are specified as:
mediaConstraints = {'mandatory': {'OfferToReceiveAudio':true, 'OfferToReceiveVideo':true}};
效果很好.
但是,当使用 Firefox(mac 上为 35.0.1)时,根据规范应该是:
However, when using Firefox (35.0.1 on the mac), according to the spec it should be:
mediaConstraints = {'offerToReceiveAudio':true,'offerToReceiveVideo':true};
但是不起作用(Ice 失败了!)
But doesn't work (Ice failed!)
使用OfferToReceiveAudio"
Using "OfferToReceiveAudio"
mediaConstraints = {'OfferToReceiveAudio':true,'offerToReceiveVideo':true};
工作正常.
这是记录在案的行为吗?
Is this documented behaviour?
推荐答案
正确的格式(现在)是:
The right format (by now) is:
offerOptions = {'offerToReceiveAudio':true,'offerToReceiveVideo':true};
因为这是新的规范格式并且受支持通过 Chrome 和 火狐.
as this is the new spec format and is supported by both Chrome and Firefox.
请特别注意小写的 'o',因为这确实发生了变化,并且会引起不少人的注意.希望你现在已经可以使用了.
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.
这篇关于Firefox 中的 WebRTC OfferToReceiveAudio 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!