| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // These must match with how the video and canvas tags are declared in html. | 5 // These must match with how the video and canvas tags are declared in html. |
| 6 const VIDEO_TAG_WIDTH = 320; | 6 const VIDEO_TAG_WIDTH = 320; |
| 7 const VIDEO_TAG_HEIGHT = 240; | 7 const VIDEO_TAG_HEIGHT = 240; |
| 8 | 8 |
| 9 // Fake video capture background green is of value 135. | 9 // Fake video capture background green is of value 135. |
| 10 const COLOR_BACKGROUND_GREEN = 135; | 10 const COLOR_BACKGROUND_GREEN = 135; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 addExpectedEvent(); | 63 addExpectedEvent(); |
| 64 detectVideoPlaying(videoElement, function () { eventOccured(); }); | 64 detectVideoPlaying(videoElement, function () { eventOccured(); }); |
| 65 } | 65 } |
| 66 | 66 |
| 67 function waitForVideoToStop(videoElement) { | 67 function waitForVideoToStop(videoElement) { |
| 68 document.title = 'Waiting for video to stop...'; | 68 document.title = 'Waiting for video to stop...'; |
| 69 addExpectedEvent(); | 69 addExpectedEvent(); |
| 70 detectVideoStopped(videoElement, function () { eventOccured(); }); | 70 detectVideoStopped(videoElement, function () { eventOccured(); }); |
| 71 } | 71 } |
| 72 | 72 |
| 73 function waitForConnectionToStabilize(peerConnection) { | 73 function waitForConnectionToStabilize(peerConnection, callback) { |
| 74 addExpectedEvent(); | |
| 75 var waitForStabilization = setInterval(function() { | 74 var waitForStabilization = setInterval(function() { |
| 76 if (peerConnection.signalingState == 'stable') { | 75 if (peerConnection.signalingState == 'stable') { |
| 77 clearInterval(waitForStabilization); | 76 clearInterval(waitForStabilization); |
| 78 eventOccured(); | 77 callback(); |
| 79 } | 78 } |
| 80 }, 100); | 79 }, 100); |
| 81 } | 80 } |
| 82 | 81 |
| 83 function addExpectedEvent() { | 82 function addExpectedEvent() { |
| 84 ++gNumberOfExpectedEvents; | 83 ++gNumberOfExpectedEvents; |
| 85 } | 84 } |
| 86 | 85 |
| 87 function eventOccured() { | 86 function eventOccured() { |
| 88 ++gNumberOfEvents; | 87 ++gNumberOfEvents; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 detectedAspectRatioString += " cropped"; | 190 detectedAspectRatioString += " cropped"; |
| 192 } else | 191 } else |
| 193 detectedAspectRatioString += " letterbox"; | 192 detectedAspectRatioString += " letterbox"; |
| 194 | 193 |
| 195 console.log("Original image is: " + detectedAspectRatioString); | 194 console.log("Original image is: " + detectedAspectRatioString); |
| 196 callback(detectedAspectRatioString); | 195 callback(detectedAspectRatioString); |
| 197 } | 196 } |
| 198 }, | 197 }, |
| 199 50); | 198 50); |
| 200 } | 199 } |
| OLD | NEW |