OLD | NEW |
---|---|
1 /** | 1 /** |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 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 /** | 7 /** |
8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more | 8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more |
9 * information on getUserMedia. | 9 * information on getUserMedia. |
10 */ | 10 */ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 * | 47 * |
48 * @param {!object} constraints Defines what to be requested, with mandatory | 48 * @param {!object} constraints Defines what to be requested, with mandatory |
49 * and optional constraints defined. The contents of this parameter depends | 49 * and optional constraints defined. The contents of this parameter depends |
50 * on the WebRTC version. | 50 * on the WebRTC version. |
51 */ | 51 */ |
52 function doGetUserMedia(constraints) { | 52 function doGetUserMedia(constraints) { |
53 if (!getUserMedia) { | 53 if (!getUserMedia) { |
54 returnToTest('Browser does not support WebRTC.'); | 54 returnToTest('Browser does not support WebRTC.'); |
55 return; | 55 return; |
56 } | 56 } |
57 debug('Requesting doGetUserMedia: constraints: ' + constraints); | 57 debug('Requesting doGetUserMedia: constraints: ' + |
58 JSON.stringify(constraints, null, 0).replace(/[\r\n]/g, '')); | |
58 getUserMedia(constraints, | 59 getUserMedia(constraints, |
59 function(stream) { | 60 function(stream) { |
60 ensureGotAllExpectedStreams_(stream, constraints); | 61 ensureGotAllExpectedStreams_(stream, constraints); |
61 getUserMediaOkCallback_(stream); | 62 getUserMediaOkCallback_(stream); |
62 }, | 63 }, |
63 getUserMediaFailedCallback_); | 64 getUserMediaFailedCallback_); |
64 returnToTest('ok-requested'); | 65 returnToTest('ok-requested'); |
65 } | 66 } |
66 | 67 |
67 /** | 68 /** |
68 * Must be called after calling doGetUserMedia. | 69 * Must be called after calling doGetUserMedia. |
69 * @return {string} Returns not-called-yet if we have not yet been called back | 70 * @return {string} Returns not-called-yet if we have not yet been called back |
70 * by WebRTC. Otherwise it returns either ok-got-stream or | 71 * by WebRTC. Otherwise it returns either ok-got-stream or |
71 * failed-with-error-x (where x is the error code from the error | 72 * failed-with-error-x (where x is the error code from the error |
72 * callback) depending on which callback got called by WebRTC. | 73 * callback) depending on which callback got called by WebRTC. |
73 */ | 74 */ |
74 function obtainGetUserMediaResult() { | 75 function obtainGetUserMediaResult() { |
75 returnToTest(gRequestWebcamAndMicrophoneResult); | 76 returnToTest(gRequestWebcamAndMicrophoneResult); |
76 return gRequestWebcamAndMicrophoneResult; | 77 var ret = gRequestWebcamAndMicrophoneResult; |
78 // Reset for the next call. | |
79 gRequestWebcamAndMicrophoneResult = 'not-called-yet'; | |
tommi (sloooow) - chröme
2015/04/26 10:55:02
The problem we were hitting here is that when doin
phoglund_chromium
2015/04/27 07:46:48
Good catch. It's possible the re-set should actual
| |
80 return ret; | |
77 } | 81 } |
78 | 82 |
79 /** | 83 /** |
80 * Stops all tracks of the last acquired local stream. | 84 * Stops all tracks of the last acquired local stream. |
81 */ | 85 */ |
82 function stopLocalStream() { | 86 function stopLocalStream() { |
83 if (gLocalStream == null) | 87 if (gLocalStream == null) |
84 throw failTest('Tried to stop local stream, ' + | 88 throw failTest('Tried to stop local stream, ' + |
85 'but media access is not granted.'); | 89 'but media access is not granted.'); |
86 | 90 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 * @param {NavigatorUserMediaError} error Error containing details. | 163 * @param {NavigatorUserMediaError} error Error containing details. |
160 */ | 164 */ |
161 function getUserMediaFailedCallback_(error) { | 165 function getUserMediaFailedCallback_(error) { |
162 // Translate from the old error to the new. Remove when rename fully deployed. | 166 // Translate from the old error to the new. Remove when rename fully deployed. |
163 var errorName = error.name; | 167 var errorName = error.name; |
164 | 168 |
165 debug('GetUserMedia FAILED: Maybe the camera is in use by another process?'); | 169 debug('GetUserMedia FAILED: Maybe the camera is in use by another process?'); |
166 gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + errorName; | 170 gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + errorName; |
167 debug(gRequestWebcamAndMicrophoneResult); | 171 debug(gRequestWebcamAndMicrophoneResult); |
168 } | 172 } |
OLD | NEW |