Updated demos to use the sucess and failure callback in addIceCandidate api.

R=dutton@google.com

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5497 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
vikasmarwaha@webrtc.org
2014-02-06 22:38:37 +00:00
parent 60de116687
commit b307e86076
12 changed files with 141 additions and 23 deletions

View File

@@ -275,12 +275,21 @@ function processSignalingMessage(message) {
var candidate = new RTCIceCandidate({sdpMLineIndex: message.label, var candidate = new RTCIceCandidate({sdpMLineIndex: message.label,
candidate: message.candidate}); candidate: message.candidate});
noteIceCandidate("Remote", iceCandidateType(message.candidate)); noteIceCandidate("Remote", iceCandidateType(message.candidate));
pc.addIceCandidate(candidate); pc.addIceCandidate(candidate,
onAddIceCandidateSuccess, onAddIceCandidateError);
} else if (message.type === 'bye') { } else if (message.type === 'bye') {
onRemoteHangup(); onRemoteHangup();
} }
} }
function onAddIceCandidateSuccess() {
console.log('AddIceCandidate success.');
}
function onAddIceCandidateError(error) {
messageError('Failed to add Ice Candidate: ' + error.toString());
}
function onChannelOpened() { function onChannelOpened() {
console.log('Channel opened.'); console.log('Channel opened.');
channelReady = true; channelReady = true;

View File

@@ -86,13 +86,15 @@ function connect() {
pc1.onicecandidate = function(e) { pc1.onicecandidate = function(e) {
log('Candidate PC1'); log('Candidate PC1');
if (e.candidate) { if (e.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(e.candidate)); pc2.addIceCandidate(new RTCIceCandidate(e.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
} }
} }
pc2.onicecandidate = function(e) { pc2.onicecandidate = function(e) {
log('Candidate PC2'); log('Candidate PC2');
if (e.candidate) { if (e.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(e.candidate)); pc1.addIceCandidate(new RTCIceCandidate(e.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
} }
} }
pc2.onaddstream = function(e) { pc2.onaddstream = function(e) {
@@ -112,6 +114,14 @@ function connect() {
}); });
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
// Augumentation of stats entries with utility functions. // Augumentation of stats entries with utility functions.
// The augumented entry does what the stats entry does, but adds // The augumented entry does what the stats entry does, but adds
// utility functions. // utility functions.

View File

@@ -175,7 +175,8 @@ function gotDescription2(desc) {
function iceCallback1(event) { function iceCallback1(event) {
trace('local ice callback'); trace('local ice callback');
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(event.candidate); pc2.addIceCandidate(event.candidate,
onAddIceCandidateSuccess, onAddIceCandidateError);
trace('Local ICE candidate: \n' + event.candidate.candidate); trace('Local ICE candidate: \n' + event.candidate.candidate);
} }
} }
@@ -183,11 +184,20 @@ function iceCallback1(event) {
function iceCallback2(event) { function iceCallback2(event) {
trace('remote ice callback'); trace('remote ice callback');
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(event.candidate); pc1.addIceCandidate(event.candidate,
onAddIceCandidateSuccess, onAddIceCandidateError);
trace('Remote ICE candidate: \n ' + event.candidate.candidate); trace('Remote ICE candidate: \n ' + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace('AddIceCandidate success.');
}
function onAddIceCandidateError(error) {
trace('Failed to add Ice Candidate: ' + error.toString());
}
function receiveChannelCallback(event) { function receiveChannelCallback(event) {
trace('Receive Channel Callback'); trace('Receive Channel Callback');
receiveChannel = event.channel; receiveChannel = event.channel;

View File

@@ -185,17 +185,27 @@ function gotRemoteStream(e) {
function iceCallback1(event) { function iceCallback1(event) {
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} }
} }
function iceCallback2(event) { function iceCallback2(event) {
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -130,18 +130,28 @@ function gotRemoteStream(e){
function iceCallback1(event){ function iceCallback1(event){
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} }
} }
function iceCallback2(event){ function iceCallback2(event){
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
function enableDtmfSender(){ function enableDtmfSender(){
document.getElementById("dtmfTonesSent").value = "Dtmf activated\n"; document.getElementById("dtmfTonesSent").value = "Dtmf activated\n";
if (localstream != null) { if (localstream != null) {

View File

@@ -170,10 +170,19 @@ function iceCallback2Remote(event) {
function handleCandidate(candidate, dest, prefix, type) { function handleCandidate(candidate, dest, prefix, type) {
if (candidate) { if (candidate) {
dest.addIceCandidate(new RTCIceCandidate(candidate)); dest.addIceCandidate(new RTCIceCandidate(candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace(prefix + "New " + type + " ICE candidate: " + candidate.candidate); trace(prefix + "New " + type + " ICE candidate: " + candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -95,17 +95,27 @@ function gotRemoteStream(e){
function iceCallback1(event){ function iceCallback1(event){
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} }
} }
function iceCallback2(event){ function iceCallback2(event){
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -119,17 +119,27 @@ function gotRemoteStream(e){
function iceCallback1(event){ function iceCallback1(event){
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} }
} }
function iceCallback2(event){ function iceCallback2(event){
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -289,17 +289,27 @@ function gotRemoteStream(e) {
function iceCallback1(event) { function iceCallback1(event) {
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} }
} }
function iceCallback2(event) { function iceCallback2(event) {
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -122,17 +122,27 @@ function gotRemoteStream(e) {
function iceCallback1(event) { function iceCallback1(event) {
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} }
} }
function iceCallback2(event) { function iceCallback2(event) {
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -210,7 +210,8 @@ function iceStateCallback2() {
function iceCallback1(event){ function iceCallback1(event){
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Local ICE candidate: \n" + event.candidate.candidate); trace("Local ICE candidate: \n" + event.candidate.candidate);
} else { } else {
trace("end of candidates1"); trace("end of candidates1");
@@ -219,12 +220,21 @@ function iceCallback1(event){
function iceCallback2(event){ function iceCallback2(event){
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
trace("Remote ICE candidate: \n " + event.candidate.candidate); trace("Remote ICE candidate: \n " + event.candidate.candidate);
} else { } else {
trace("end of candidates2"); trace("end of candidates2");
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -174,18 +174,28 @@
function iceCallback1(event){ function iceCallback1(event){
if (event.candidate) { if (event.candidate) {
pc2.addIceCandidate(new RTCIceCandidate(event.candidate)); pc2.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
console.log('Local ICE candidate: \n' + event.candidate.candidate); console.log('Local ICE candidate: \n' + event.candidate.candidate);
} }
} }
function iceCallback2(event){ function iceCallback2(event){
if (event.candidate) { if (event.candidate) {
pc1.addIceCandidate(new RTCIceCandidate(event.candidate)); pc1.addIceCandidate(new RTCIceCandidate(event.candidate),
onAddIceCandidateSuccess, onAddIceCandidateError);
console.log('Remote ICE candidate: \n ' + event.candidate.candidate); console.log('Remote ICE candidate: \n ' + event.candidate.candidate);
} }
} }
function onAddIceCandidateSuccess() {
trace("AddIceCandidate success.");
}
function onAddIceCandidateError(error) {
trace("Failed to add Ice Candidate: " + error.toString());
}
function handleKeyDown(event) { function handleKeyDown(event) {
var keyCode = event.keyCode; var keyCode = event.keyCode;
webAudio.addEffect(); webAudio.addEffect();