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

后端 未结 2 1766
栀梦
栀梦 2021-01-19 07:49

I wonder what I\'m doing wrong.

I\'m getting \'malformed constraints object\' errors from this:

pc.createAnswer( function (answer) {
  ...
}, fail, {         


        
2条回答
  •  离开以前
    2021-01-19 07:58

    According to the newest Webrtc spec the correct form of the constraint parameter should be:

    { offerToReceiveAudio: true, offerToReceiveVideo: true }
    

    Note the lowercase 'o's at the beginnings of offerToReceiveAudio and offerToReceiveVideo.

    This is currently supported only by FF 33 or newer.

    Chrome supports only the own way:

    { mandatory: { OfferToReceiveAudio: true, OfferToReceiveVideo: true } }
    

    Chrome will throw and error if you give it a constraint object that has a structure according to the new spec.

    The good news is that Firefox still accepts the old form. It just prints a warning message in that case. So, at least for now, use the old version.

提交回复
热议问题