Index: content/test/data/media/peerconnection-call.html |
diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html |
index 39b01b5a5f0a926c0e4d9e58fdd904bdb98cd6c2..bf348708f6176f555b5f594547ae9bdfac487673 100644 |
--- a/content/test/data/media/peerconnection-call.html |
+++ b/content/test/data/media/peerconnection-call.html |
@@ -13,8 +13,8 @@ |
var gLocalStream = null; |
var gSentTones = ''; |
- setAllEventsOccuredHandler(function() { |
- document.title = 'OK'; |
+ setAllEventsOccuredHandler(function() { |
+ document.title = 'OK'; |
}); |
// Test that we can setup call with an audio and video track. |
@@ -43,7 +43,7 @@ |
createConnections(null); |
gTestWithoutMsidAndBundle = true; |
navigator.webkitGetUserMedia({audio:true, video:true}, |
- addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
+ addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
waitForVideo('remote-view-1'); |
waitForVideo('remote-view-2'); |
} |
@@ -103,8 +103,8 @@ |
// Do the DTMF test after we have received video. |
detectVideoIn('remote-view-2', onCallEstablished); |
} |
- |
- // Test call with a new Video MediaStream that has been created based on a |
+ |
+ // Test call with a new Video MediaStream that has been created based on a |
// stream generated by getUserMedia. |
function callWithNewVideoMediaStream() { |
createConnections(null); |
@@ -114,6 +114,69 @@ |
waitForVideo('remote-view-2'); |
} |
+ // Test call with a new Video MediaStream that has been created based on a |
+ // stream generated by getUserMedia. When Video is flowing, an audio track |
+ // is added to the sent stream and the video track is removed. This |
+ // is to test that adding and removing of remote tracks on an existing |
+ // mediastream works. |
+ function callWithNewVideoMediaStreamLaterSwitchToAudio() { |
+ createConnections(null); |
+ navigator.webkitGetUserMedia({audio:true, video:true}, |
+ createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); |
+ |
+ waitForVideo('remote-view-1'); |
+ waitForVideo('remote-view-2'); |
+ |
+ // Set an event handler for when video is playing. |
+ setAllEventsOccuredHandler(function() { |
+ // Add an audio track to the local stream and remove the video track and |
+ // then renegotiate. But first - setup the expectations. |
+ local_stream = gFirstConnection.getLocalStreams()[0]; |
+ |
+ remote_stream_1 = gFirstConnection.getRemoteStreams()[0]; |
+ // Add an expected event that onaddtrack will be called on the remote |
+ // mediastream received on gFirstConnection when the audio track is |
+ // received. |
+ addExpectedEvent(); |
+ remote_stream_1.onaddtrack = function(){ |
+ expectEquals(remote_stream_1.getAudioTracks()[0].id, |
+ local_stream.getAudioTracks()[0].id); |
+ eventOccured(); |
+ } |
+ |
+ // Add an expectation that the received video track is removed from |
+ // gFirstConnection. |
+ addExpectedEvent(); |
+ remote_stream_1.onremovetrack = function() { |
+ eventOccured(); |
+ } |
+ |
+ // Add an expected event that onaddtrack will be called on the remote |
+ // mediastream received on gSecondConnection when the audio track is |
+ // received. |
+ remote_stream_2 = gSecondConnection.getRemoteStreams()[0]; |
+ addExpectedEvent(); |
+ remote_stream_2.onaddtrack = function() { |
+ expectEquals(remote_stream_2.getAudioTracks()[0].id, |
+ local_stream.getAudioTracks()[0].id); |
+ eventOccured(); |
+ } |
+ |
+ // Add an expectation that the received video track is removed from |
+ // gSecondConnection. |
+ addExpectedEvent(); |
+ remote_stream_2.onremovetrack = function() { |
+ eventOccured(); |
+ } |
+ // When all the above events have occurred- the test pass. |
+ setAllEventsOccuredHandler(function() { document.title = 'OK'; }); |
+ |
+ local_stream.addTrack(gLocalStream.getAudioTracks()[0]); |
+ local_stream.removeTrack(local_stream.getVideoTracks()[0]); |
+ negotiate(); |
+ }); // End of setAllEventsOccuredHandler. |
+ } |
+ |
// This function is used for setting up a test that: |
// 1. Creates a data channel on |gFirstConnection| and sends data to |
// |gSecondConnection|. |
@@ -159,7 +222,7 @@ |
secondDataChannel.send(sendDataString); |
} |
} |
- } |
+ } |
function onToneChange(tone) { |
gSentTones += tone.tone; |
@@ -207,14 +270,17 @@ |
gFirstConnection.addStream(localStream); |
negotiate(); |
} |
- |
+ |
// Called if getUserMedia succeeds when we want to send a modified |
- // MediaStream. A new MediaStream is created and the video track from |
+ // MediaStream. A new MediaStream is created and the video track from |
// |localStream| is added. |
function createNewVideoStreamAndAddToBothConnections(localStream) { |
+ displayAndRemember(localStream); |
var new_stream = new webkitMediaStream(); |
- new_stream.addTrack(localStream.getVideoTracks()[0]); |
- addStreamToBothConnectionsAndNegotiate(new_stream); |
+ new_stream.addTrack(localStream.getVideoTracks()[0]); |
+ gFirstConnection.addStream(new_stream); |
+ gSecondConnection.addStream(new_stream); |
+ negotiate(); |
} |
function negotiate() { |
@@ -288,7 +354,7 @@ |
var remoteVideo = $(target); |
remoteVideo.src = remoteStreamUrl; |
} |
- |
+ |
</script> |
</head> |
<body> |