From be588f9a58c9ebcaf88066ffe4bfe811327a6715 Mon Sep 17 00:00:00 2001 From: "braveyao@webrtc.org" Date: Thu, 5 Sep 2013 16:44:55 +0000 Subject: [PATCH] Apprtc Demo: calling createOffer/Answer without failureCallback is deprecated in FF BUG=2313 Test=Manual test R=dutton@google.com, juberti@google.com, vikasmarwaha@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2175004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4683 4adac7df-926f-26a2-2b94-8c16560cd09d --- samples/js/apprtc/js/main.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/samples/js/apprtc/js/main.js b/samples/js/apprtc/js/main.js index 538db7c825..bd05fd3ae0 100644 --- a/samples/js/apprtc/js/main.js +++ b/samples/js/apprtc/js/main.js @@ -170,7 +170,8 @@ function doCall() { var constraints = mergeConstraints(offerConstraints, sdpConstraints); console.log('Sending offer to peer, with constraints: \n' + ' \'' + JSON.stringify(constraints) + '\'.') - pc.createOffer(setLocalAndSendMessage, null, constraints); + pc.createOffer(setLocalAndSendMessage, + onCreateSessionDescriptionError, constraints); } function calleeStart() { @@ -182,7 +183,8 @@ function calleeStart() { function doAnswer() { console.log('Sending answer to peer.'); - pc.createAnswer(setLocalAndSendMessage, null, sdpConstraints); + pc.createAnswer(setLocalAndSendMessage, + onCreateSessionDescriptionError, sdpConstraints); } function mergeConstraints(cons1, cons2) { @@ -197,7 +199,8 @@ function mergeConstraints(cons1, cons2) { function setLocalAndSendMessage(sessionDescription) { // Set Opus as the preferred codec in SDP if Opus is present. sessionDescription.sdp = preferOpus(sessionDescription.sdp); - pc.setLocalDescription(sessionDescription); + pc.setLocalDescription(sessionDescription, + onSetSessionDescriptionSuccess, onSetSessionDescriptionError); sendMessage(sessionDescription); } @@ -222,13 +225,15 @@ function processSignalingMessage(message) { // Set Opus in Stereo, if stereo enabled. if (stereo) message.sdp = addStereo(message.sdp); - pc.setRemoteDescription(new RTCSessionDescription(message)); + pc.setRemoteDescription(new RTCSessionDescription(message), + onSetSessionDescriptionSuccess, onSetSessionDescriptionError); doAnswer(); } else if (message.type === 'answer') { // Set Opus in Stereo, if stereo enabled. if (stereo) message.sdp = addStereo(message.sdp); - pc.setRemoteDescription(new RTCSessionDescription(message)); + pc.setRemoteDescription(new RTCSessionDescription(message), + onSetSessionDescriptionSuccess, onSetSessionDescriptionError); } else if (message.type === 'candidate') { var candidate = new RTCIceCandidate({sdpMLineIndex: message.label, candidate: message.candidate}); @@ -289,6 +294,18 @@ function onUserMediaError(error) { error.code + '.'); } +function onCreateSessionDescriptionError(error) { + console.log('Failed to create session description: ' + error.name); +} + +function onSetSessionDescriptionSuccess() { + console.log('Set session description success.'); +} + +function onSetSessionDescriptionError(error) { + console.log('Failed to set session description: ' + error.name); +} + function iceCandidateType(candidateSDP) { if (candidateSDP.indexOf("typ relay ") >= 0) return "TURN";