AdapterJS
AdapterJS copied to clipboard
Add method createOfferOptions
It would be great to add a new polyfill to handle differences in createOffer options dict. Firefox already supports (from version 33-34) a new syntax http://www.w3.org/TR/webrtc/#idl-def-RTCOfferOptions (and throws deprecation warning when using "mandatory: {}"). Googgle Chrome still doesn't accept new syntax, I did not yet check the plugin. To fix this I use this helper function. I think it's place is in AdapterJS library :)
/**
* Create options dict for RTCPeerConnection.createOffer()
* @see http://www.w3.org/TR/webrtc/#idl-def-RTCOfferOptions for param description
*
* @param recieveAudio
* @param recieveVideo
* @param iceRestart
* @param voiceDetection
*
* @returns {Object}
*/
function createOfferOptions(recieveAudio, recieveVideo, iceRestart, voiceDetection) {
var options;
iceRestart = iceRestart || false;
voiceDetection = voiceDetection === false ? false : true;
// current spec: http://www.w3.org/TR/webrtc/#idl-def-RTCOfferOptions
if (webrtcDetectedBrowser === 'firefox' && webrtcDetectedVersion >= 36) {
options = {
offerToReceiveAudio: recieveAudio,
offerToReceiveVideo: recieveVideo,
iceRestart: iceRestart,
voiceActivityDetection: voiceDetection
};
}
// old spec: http://www.w3.org/TR/2013/WD-webrtc-20130910/#constraints
else {
options = {mandatory: {
OfferToReceiveAudio: (recieveAudio ? true : false),
OfferToReceiveVideo: (recieveVideo ? true : false),
IceRestart: iceRestart,
VoiceActivityDetection: voiceDetection
}};
}
return options;
}
Cool. Gonna review and evaluate!