| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright 2017 The Chromium Authors. All rights reserved. | 2 * Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** |
| 8 * ... |
| 9 * @private |
| 10 */ |
| 11 var gOnTrackEvents = []; |
| 12 |
| 7 // Public interface to tests. These are expected to be called with | 13 // Public interface to tests. These are expected to be called with |
| 8 // ExecuteJavascript invocations from the browser tests and will return answers | 14 // ExecuteJavascript invocations from the browser tests and will return answers |
| 9 // through the DOM automation controller. | 15 // through the DOM automation controller. |
| 10 | 16 |
| 11 /** | 17 /** |
| 12 * Adds |count| streams to the peer connection, with one audio and one video | 18 * Adds |count| streams to the peer connection, with one audio and one video |
| 13 * track per stream. | 19 * track per stream. |
| 14 * | 20 * |
| 15 * Returns "ok-streams-created-and-added" on success. | 21 * Returns "ok-streams-created-and-added" on success. |
| 16 */ | 22 */ |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 let videoStreamId = videoStream ? videoStream.id : 'null'; | 154 let videoStreamId = videoStream ? videoStream.id : 'null'; |
| 149 returnToTest('ok-' + audioStreamId + ' ' + audioTrack.id | 155 returnToTest('ok-' + audioStreamId + ' ' + audioTrack.id |
| 150 + ' ' + videoStreamId + ' ' + videoTrack.id); | 156 + ' ' + videoStreamId + ' ' + videoTrack.id); |
| 151 }, | 157 }, |
| 152 function(error) { | 158 function(error) { |
| 153 throw failTest('getUserMedia failed: ' + error); | 159 throw failTest('getUserMedia failed: ' + error); |
| 154 }); | 160 }); |
| 155 } | 161 } |
| 156 | 162 |
| 157 /** | 163 /** |
| 164 * ... |
| 165 */ |
| 166 function setupOnTrackListener() { |
| 167 peerConnection_().ontrack = function(event) { |
| 168 console.log('HBOS ontrack: ' + event); |
| 169 console.log('HBOS event.receiver: ' + event.receiver); |
| 170 console.log('HBOS event.receiver.track: ' + event.receiver.track); |
| 171 console.log('HBOS event.receiver.track.id: ' + event.receiver.track.id); |
| 172 console.log('HBOS event.track: ' + event.track); |
| 173 console.log('HBOS event.track.id: ' + event.track.id); |
| 174 console.log('HBOS event.streams: ' + event.streams); |
| 175 for (let i = 0; i < event.streams.length; ++i) { |
| 176 console.log('HBOS event.streams[i]: ' + event.streams[i]); |
| 177 console.log('HBOS event.streams[i].id: ' + event.streams[i].id); |
| 178 } |
| 179 gOnTrackEvents.push(event); |
| 180 } |
| 181 returnToTest('ok-ontrack-wired'); |
| 182 } |
| 183 |
| 184 /** |
| 185 * ... |
| 186 */ |
| 187 function getOnTrackEvents() { |
| 188 let result = ''; |
| 189 gOnTrackEvents.forEach(function(event) { |
| 190 if (event.receiver.track != event.track) |
| 191 throw failTest('RTCTrackEvent\'s track does not match its receiver\'s.'); |
| 192 let eventString = 'RTCTrackEvent ' + event.track.id; |
| 193 event.streams.forEach(function(stream) { |
| 194 eventString += ' ' + stream.id; |
| 195 }); |
| 196 if (result.length) |
| 197 result += ' '; |
| 198 result += eventString; |
| 199 }); |
| 200 returnToTest('ok-' + result); |
| 201 } |
| 202 |
| 203 /** |
| 158 * Calls |removeTrack| with the first sender that has the track with |trackId| | 204 * Calls |removeTrack| with the first sender that has the track with |trackId| |
| 159 * and verifies the SDP is updated accordingly. | 205 * and verifies the SDP is updated accordingly. |
| 160 * | 206 * |
| 161 * Returns "ok-sender-removed" on success. | 207 * Returns "ok-sender-removed" on success. |
| 162 */ | 208 */ |
| 163 function removeTrack(trackId) { | 209 function removeTrack(trackId) { |
| 164 let sender = null; | 210 let sender = null; |
| 165 let otherSenderHasTrack = false; | 211 let otherSenderHasTrack = false; |
| 166 peerConnection_().getSenders().forEach(function(s) { | 212 peerConnection_().getSenders().forEach(function(s) { |
| 167 if (s.track && s.track.id == trackId) { | 213 if (s.track && s.track.id == trackId) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (a == null) | 321 if (a == null) |
| 276 return b == null; | 322 return b == null; |
| 277 if (a.size != b.size) | 323 if (a.size != b.size) |
| 278 return false; | 324 return false; |
| 279 a.forEach(function(value) { | 325 a.forEach(function(value) { |
| 280 if (!b.has(value)) | 326 if (!b.has(value)) |
| 281 return false; | 327 return false; |
| 282 }); | 328 }); |
| 283 return true; | 329 return true; |
| 284 } | 330 } |
| OLD | NEW |