Skip to content
Permalink
Browse files

Enhance RTCPeerconnection SDP error handling. Thanks @ibc for reporting.

  • Loading branch information
jmillan committed Dec 28, 2012
1 parent d4e079b commit a8a7627ea1a9a48f2751cc3105bdd4269690acab
Showing with 26 additions and 24 deletions.
  1. +20 −18 src/MediaSession.js
  2. +6 −6 src/Session.js
@@ -49,8 +49,8 @@ JsSIP.MediaSession.prototype = {
}

/** @private */
function onGetUserMediaFailure() {
onFailure();
function onGetUserMediaFailure(e) {
onFailure(e);
}

this.getUserMedia(mediaType, onGetUserMediaSuccess, onGetUserMediaFailure);
@@ -82,16 +82,22 @@ JsSIP.MediaSession.prototype = {
// add stream to peerConnection
self.peerConnection.addStream(stream);

self.peerConnection.setRemoteDescription(new window.RTCSessionDescription({type:'offer', sdp:sdp}));

// Set local description and start Ice.
self.peerConnection.createAnswer(function(sessionDescription){
self.peerConnection.setLocalDescription(sessionDescription);
});
self.peerConnection.setRemoteDescription(
new window.RTCSessionDescription({type:'offer', sdp:sdp}),
function() {
self.peerConnection.createAnswer(
function(sessionDescription){
self.peerConnection.setLocalDescription(sessionDescription);
},
onSdpFailure
);
},
onSdpFailure
);
}

function onGetUserMediaFailure() {
onMediaFailure();
function onGetUserMediaFailure(e) {
onMediaFailure(e);
}

self.getUserMedia({'audio':true, 'video':true}, onGetUserMediaSuccess, onGetUserMediaFailure);
@@ -185,8 +191,8 @@ JsSIP.MediaSession.prototype = {
onSuccess(stream);
}

function getFailure() {
onFailure();
function getFailure(e) {
onFailure(e);
}

// Get User Media
@@ -206,12 +212,8 @@ JsSIP.MediaSession.prototype = {
if (type === 'offer') {
console.log(JsSIP.c.LOG_MEDIA_SESSION +'re-Invite received');
} else if (type === 'answer') {
try {
this.peerConnection.setRemoteDescription(new window.RTCSessionDescription({type:'answer', sdp:sdp}));
onSuccess();
} catch (e) {
onFailure(e);
}
this.peerConnection.setRemoteDescription(
new window.RTCSessionDescription({type:'answer', sdp:sdp}), onSuccess, onFailure);
}
}
};
@@ -373,7 +373,7 @@ JsSIP.Session.prototype.receiveInitialRequest = function(ua, request) {
* @param {HTMLVideoElement} remoteView
*/
this.answer = function(selfView, remoteView) {
var offer, onMediaSuccess, onMediaFailure, onSdpFailure;
var offer, onSuccess, onMediaFailure, onSdpFailure;

// Check UA Status
JsSIP.utils.checkUAStatus(this.ua);
@@ -385,7 +385,7 @@ JsSIP.Session.prototype.receiveInitialRequest = function(ua, request) {

offer = request.body;

onMediaSuccess = function() {
onSuccess = function() {
var sdp = session.mediaSession.peerConnection.localDescription.sdp;

if(!session.createConfirmedDialog(request, 'UAS')) {
@@ -435,7 +435,7 @@ JsSIP.Session.prototype.receiveInitialRequest = function(ua, request) {

//Initialize Media Session
session.mediaSession = new JsSIP.MediaSession(session, selfView, remoteView);
session.mediaSession.startCallee(onMediaSuccess, onMediaFailure, onSdpFailure, offer);
session.mediaSession.startCallee(onSuccess, onMediaFailure, onSdpFailure, offer);
};

// Fire 'call' event callback
@@ -526,7 +526,7 @@ JsSIP.Session.prototype.receiveResponse = function(response) {
return;
}

this.acceptAndTerminate(response,'SIP ;cause= 400 ;text= "Missing session description"');
this.acceptAndTerminate(response,'SIP ;cause=400 ;text= "Missing session description"');
this.failed('remote', response, JsSIP.c.causes.BAD_MEDIA_DESCRIPTION);

break;
@@ -561,7 +561,7 @@ JsSIP.Session.prototype.receiveResponse = function(response) {
*/
function(e) {
console.warn(e);
session.acceptAndTerminate(response, 'SIP ;cause= 488 ;text= "Not Acceptable Here"');
session.acceptAndTerminate(response, 'SIP ;cause=488 ;text="Not Acceptable Here"');
session.failed('remote', response, JsSIP.c.causes.BAD_MEDIA_DESCRIPTION);
}
);
@@ -947,7 +947,7 @@ JsSIP.Session.prototype.sendInitialRequest = function(mediaType) {
request_sender.send();
}

function onMediaFailure(fail,e) {
function onMediaFailure(e) {
if (self.status !== JsSIP.c.SESSION_TERMINATED) {
console.log(JsSIP.c.LOG_CLIENT_INVITE_SESSION +'Media Access denied');
self.failed('local', null, JsSIP.c.causes.USER_DENIED_MEDIA_ACCESS);

0 comments on commit a8a7627

Please sign in to comment.
You can’t perform that action at this time.