Add success/error callback to set sdp calls.

Add a workaround for crbug/322756 to append a line break to the end of sdp if needed.

R=juberti@webrtc.org, vikasmarwaha@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/4299004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5167 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org 2013-11-23 00:37:50 +00:00
parent 5272eb8d83
commit aa74b5d690

View File

@ -197,16 +197,38 @@ function createPC() {
trace("Adding Local Stream to peer connection");
}
function onSetSessionDescriptionSuccess() {
trace('Set session description success.');
}
function onSetSessionDescriptionError(error) {
trace('Failed to set session description: ' + error.toString());
}
// Workaround for crbug/322756.
function maybeAddLineBreakToEnd(sdp) {
var endWithLineBreak = new RegExp(/\n$/);
if (!endWithLineBreak.test(sdp)) {
return sdp + '\n';
}
return sdp;
}
function createOffer(){
pc1.createOffer(gotDescription1,null,null);
}
function setOffer(){
var sdp = document.getElementById("offerSdp").value;
sdp = maybeAddLineBreakToEnd(sdp);
var offer = new RTCSessionDescription({type:'offer',sdp:sdp});
pc1.setLocalDescription(offer);
pc1.setLocalDescription(offer,
onSetSessionDescriptionSuccess,
onSetSessionDescriptionError);
trace("Modified Offer from pc1 \n" + sdp);
pc2.setRemoteDescription(offer);
pc2.setRemoteDescription(offer,
onSetSessionDescriptionSuccess,
onSetSessionDescriptionError);
}
function gotDescription1(desc) {
@ -223,10 +245,15 @@ function createAnswer(){
function setAnswer(){
var sdp = document.getElementById("answerSdp").value;
sdp = maybeAddLineBreakToEnd(sdp);
var answer = new RTCSessionDescription({type:'answer',sdp:sdp});
pc2.setLocalDescription(answer);
pc2.setLocalDescription(answer,
onSetSessionDescriptionSuccess,
onSetSessionDescriptionError);
trace("Modified Answer from pc2 \n" + sdp);
pc1.setRemoteDescription(answer);
pc1.setRemoteDescription(answer,
onSetSessionDescriptionSuccess,
onSetSessionDescriptionError);
}
function gotDescription2(desc) {