Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: content/test/data/media/peerconnection-call.html

Issue 14200016: Added implementation of RemoteMediaStreams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script>
4 <script type="text/javascript"> 4 <script type="text/javascript">
5 $ = function(id) { 5 $ = function(id) {
6 return document.getElementById(id); 6 return document.getElementById(id);
7 }; 7 };
8 8
9 var gFirstConnection = null; 9 var gFirstConnection = null;
10 var gSecondConnection = null; 10 var gSecondConnection = null;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Test call with a new Video MediaStream that has been created based on a 107 // Test call with a new Video MediaStream that has been created based on a
108 // stream generated by getUserMedia. 108 // stream generated by getUserMedia.
109 function callWithNewVideoMediaStream() { 109 function callWithNewVideoMediaStream() {
110 createConnections(null); 110 createConnections(null);
111 navigator.webkitGetUserMedia({audio:true, video:true}, 111 navigator.webkitGetUserMedia({audio:true, video:true},
112 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); 112 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError);
113 waitForVideo('remote-view-1'); 113 waitForVideo('remote-view-1');
114 waitForVideo('remote-view-2'); 114 waitForVideo('remote-view-2');
115 } 115 }
116
117 // Test call with a new Video MediaStream that has been created based on a
118 // stream generated by getUserMedia. When Video is flowing, an audio track
119 // is added to the sent stream and the video track is removed. This
120 // is to test that adding and removing of remote tracks on an existing
121 // mediastream works.
122 function callWithNewVideoMediaStreamLaterSwitchToAudio() {
123 createConnections(null);
124 navigator.webkitGetUserMedia({audio:true, video:true},
phoglund_chromium 2013/04/16 14:44:58 Nit: line length
perkj_chrome 2013/04/18 14:46:58 Done.
125 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError);
126
127 waitForVideo('remote-view-1');
128 waitForVideo('remote-view-2');
129
130 // Set an event handler for when video is playing.
phoglund_chromium 2013/04/16 14:44:58 Side note: We should consider if we make this eve
perkj_chrome 2013/04/18 14:46:58 I was considering that. But one feature I like wit
131 setAllEventsOccuredHandler(function() {
132 // Add an audio track to the local stream and remove the video track.
133 local_stream = gFirstConnection.getLocalStreams()[0];
134 local_stream.addTrack(gLocalStream.getAudioTracks()[0]);
135 local_stream.removeTrack(local_stream.getVideoTracks()[0]);
136
137 remote_stream_1 = gFirstConnection.getRemoteStreams()[0];
138 // Add an expected event that onaddtrack will be called on the remote
phoglund_chromium 2013/04/16 14:44:58 So you call addTrack and removeTrack and _later_ s
perkj_chrome 2013/04/18 14:46:58 Nothing happens until you do the renegotiation. Th
139 // mediastream received on gFirstConnection when the audio track is
140 // received.
141 addExpectedEvent();
142 remote_stream_1.onaddtrack = function() {
143 expectEquals(remote_stream_1.getAudioTracks()[0].id,
144 local_stream.getAudioTracks()[0].id);
145 eventOccured();
146 }
147
148 // Add an expectation that the received video track is removed from
149 // gFirstConnection.
150 addExpectedEvent();
151 remote_stream_1.onremovetrack = function() {
152 eventOccured();
153 }
154
155 // Add an expected event that onaddtrack will be called on the remote
156 // mediastream received on gSecondConnection when the audio track is
157 // received.
158 remote_stream_2 = gSecondConnection.getRemoteStreams()[0];
159 addExpectedEvent();
160 remote_stream_2.onaddtrack = function() {
161 expectEquals(remote_stream_2.getAudioTracks()[0].id,
162 local_stream.getAudioTracks()[0].id);
163 eventOccured();
164 }
165
166 // Add an expectation that the received video track is removed from
167 // gSecondConnection.
168 addExpectedEvent();
169 remote_stream_2.onremovetrack = function() {
170 eventOccured();
171 }
172
173 // When all the above events have occurred- the test pass.
174 setAllEventsOccuredHandler(function() { document.title = 'OK'; });
175 negotiate();
176 });
177 }
116 178
117 // This function is used for setting up a test that: 179 // This function is used for setting up a test that:
118 // 1. Creates a data channel on |gFirstConnection| and sends data to 180 // 1. Creates a data channel on |gFirstConnection| and sends data to
119 // |gSecondConnection|. 181 // |gSecondConnection|.
120 // 2. When data is received on |gSecondConnection| a message 182 // 2. When data is received on |gSecondConnection| a message
121 // is sent to |gFirstConnection|. 183 // is sent to |gFirstConnection|.
122 // 3. When data is received on |gFirstConnection|, the data 184 // 3. When data is received on |gFirstConnection|, the data
123 // channel is closed. The test passes when the state transition completes. 185 // channel is closed. The test passes when the state transition completes.
124 function setupDataChannel() { 186 function setupDataChannel() {
125 var sendDataString = "send some text on a data channel." 187 var sendDataString = "send some text on a data channel."
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 function addStreamToTheFirstConnectionAndNegotiate(localStream) { 267 function addStreamToTheFirstConnectionAndNegotiate(localStream) {
206 displayAndRemember(localStream); 268 displayAndRemember(localStream);
207 gFirstConnection.addStream(localStream); 269 gFirstConnection.addStream(localStream);
208 negotiate(); 270 negotiate();
209 } 271 }
210 272
211 // Called if getUserMedia succeeds when we want to send a modified 273 // Called if getUserMedia succeeds when we want to send a modified
212 // MediaStream. A new MediaStream is created and the video track from 274 // MediaStream. A new MediaStream is created and the video track from
213 // |localStream| is added. 275 // |localStream| is added.
214 function createNewVideoStreamAndAddToBothConnections(localStream) { 276 function createNewVideoStreamAndAddToBothConnections(localStream) {
215 var new_stream = new webkitMediaStream(); 277 displayAndRemember(localStream);
phoglund_chromium 2013/04/16 14:44:58 This change doesn't make sense, accidental?
perkj_chrome 2013/04/18 14:46:58 Nope- I want to reuse createNewVideoStreamAndAddTo
278 var new_stream = new webkitMediaStream();
216 new_stream.addTrack(localStream.getVideoTracks()[0]); 279 new_stream.addTrack(localStream.getVideoTracks()[0]);
217 addStreamToBothConnectionsAndNegotiate(new_stream); 280 gFirstConnection.addStream(new_stream);
281 gSecondConnection.addStream(new_stream);
282 negotiate();
218 } 283 }
219 284
220 function negotiate() { 285 function negotiate() {
221 gFirstConnection.createOffer(onOfferCreated); 286 gFirstConnection.createOffer(onOfferCreated);
222 } 287 }
223 288
224 function onOfferCreated(offer) { 289 function onOfferCreated(offer) {
225 gFirstConnection.setLocalDescription(offer); 290 gFirstConnection.setLocalDescription(offer);
226 expectEquals('have-local-offer', gFirstConnection.signalingState); 291 expectEquals('have-local-offer', gFirstConnection.signalingState);
227 receiveOffer(offer.sdp); 292 receiveOffer(offer.sdp);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 autoplay="autoplay"></video></td> 372 autoplay="autoplay"></video></td>
308 <!-- Canvases are named after their corresponding video elements. --> 373 <!-- Canvases are named after their corresponding video elements. -->
309 <td><canvas width="320" height="240" id="remote-view-1-canvas" 374 <td><canvas width="320" height="240" id="remote-view-1-canvas"
310 style="display:none"></canvas></td> 375 style="display:none"></canvas></td>
311 <td><canvas width="320" height="240" id="remote-view-2-canvas"> 376 <td><canvas width="320" height="240" id="remote-view-2-canvas">
312 style="display:none"></canvas></td> 377 style="display:none"></canvas></td>
313 </tr> 378 </tr>
314 </table> 379 </table>
315 </body> 380 </body>
316 </html> 381 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698