]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8204 #resolve [Add stereo audio support for opus on FireFox]
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 22 Sep 2015 20:10:29 +0000 (15:10 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 22 Sep 2015 20:10:42 +0000 (15:10 -0500)
html5/verto/js/src/jquery.FSRTC.js
html5/verto/video_demo/js/verto-min.js

index d1ea75ed9037e72e39a159a4b6a1ffeb2341b84d..282d6e2e33488bd2e5462ec26c0253b716ec2dfb 100644 (file)
         var sdpLines = sdp.split('\r\n');
 
         // Find opus payload.
-        var opusIndex = findLine(sdpLines, 'a=rtpmap', 'opus/48000'),
-        opusPayload;
-        if (opusIndex) {
+        var opusIndex = findLine(sdpLines, 'a=rtpmap', 'opus/48000'), opusPayload;
+
+        if (!opusIndex) {
+           return sdp;
+       } else {
             opusPayload = getCodecPayloadType(sdpLines[opusIndex]);
         }
 
         // Find the payload in fmtp line.
         var fmtpLineIndex = findLine(sdpLines, 'a=fmtp:' + opusPayload.toString());
-        if (fmtpLineIndex === null) return sdp;
 
-        // Append stereo=1 to fmtp line.
-        sdpLines[fmtpLineIndex] = sdpLines[fmtpLineIndex].concat('; stereo=1');
+        if (fmtpLineIndex === null) {
+           // create an fmtp line
+           sdpLines[opusIndex] = sdpLines[opusIndex] + '\r\na=fmtp:' + opusPayload.toString() + " stereo=1"
+       } else {
+            // Append stereo=1 to fmtp line.
+            sdpLines[fmtpLineIndex] = sdpLines[fmtpLineIndex].concat('; stereo=1');
+       }
 
         sdp = sdpLines.join('\r\n');
         return sdp;
index 758c3d6f9a06176cb8df02cc4abe7798a69db074..372e83341921002e95082e647dcc439a644166a4 100644 (file)
@@ -10,8 +10,9 @@ $.FSRTC=function(options){this.options=$.extend({useVideo:null,useStereo:false,u
 if(self.options.useVideo){self.options.useVideo.style.display='none';}
 setCompat();checkCompat();};$.FSRTC.validRes=[];$.FSRTC.prototype.useVideo=function(obj,local){var self=this;if(obj){self.options.useVideo=obj;self.options.localVideo=local;if(moz){self.constraints.offerToReceiveVideo=true;}else{self.constraints.mandatory.OfferToReceiveVideo=true;}}else{self.options.useVideo=null;self.options.localVideo=null;if(moz){self.constraints.offerToReceiveVideo=false;}else{self.constraints.mandatory.OfferToReceiveVideo=false;}}
 if(self.options.useVideo){self.options.useVideo.style.display='none';}};$.FSRTC.prototype.useStereo=function(on){var self=this;self.options.useStereo=on;};$.FSRTC.prototype.stereoHack=function(sdp){var self=this;if(!self.options.useStereo){return sdp;}
-var sdpLines=sdp.split('\r\n');var opusIndex=findLine(sdpLines,'a=rtpmap','opus/48000'),opusPayload;if(opusIndex){opusPayload=getCodecPayloadType(sdpLines[opusIndex]);}
-var fmtpLineIndex=findLine(sdpLines,'a=fmtp:'+opusPayload.toString());if(fmtpLineIndex===null)return sdp;sdpLines[fmtpLineIndex]=sdpLines[fmtpLineIndex].concat('; stereo=1');sdp=sdpLines.join('\r\n');return sdp;};function setCompat(){$.FSRTC.moz=!!navigator.mozGetUserMedia;if(!navigator.getUserMedia){navigator.getUserMedia=navigator.mozGetUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia;}}
+var sdpLines=sdp.split('\r\n');var opusIndex=findLine(sdpLines,'a=rtpmap','opus/48000'),opusPayload;if(!opusIndex){return sdp;}else{opusPayload=getCodecPayloadType(sdpLines[opusIndex]);}
+var fmtpLineIndex=findLine(sdpLines,'a=fmtp:'+opusPayload.toString());if(fmtpLineIndex===null){sdpLines[opusIndex]=sdpLines[opusIndex]+'\r\na=fmtp:'+opusPayload.toString()+" stereo=1"}else{sdpLines[fmtpLineIndex]=sdpLines[fmtpLineIndex].concat('; stereo=1');}
+sdp=sdpLines.join('\r\n');return sdp;};function setCompat(){$.FSRTC.moz=!!navigator.mozGetUserMedia;if(!navigator.getUserMedia){navigator.getUserMedia=navigator.mozGetUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia;}}
 function checkCompat(){if(!navigator.getUserMedia){alert('This application cannot function in this browser.');return false;}
 return true;}
 function onStreamError(self,e){console.log('There has been a problem retrieving the streams - did you allow access? Check Device Resolution',e);doCallback(self,"onError",e);}