| 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 27 matching lines...) Expand all Loading... |
| 38 * @param requestVideo, requestAudio: whether to request video/audio. | 38 * @param requestVideo, requestAudio: whether to request video/audio. |
| 39 * @param mediaHints The media hints to use when we add streams to a peer | 39 * @param mediaHints The media hints to use when we add streams to a peer |
| 40 * connection later. The contents of this parameter depends on the WebRTC | 40 * connection later. The contents of this parameter depends on the WebRTC |
| 41 * version. This should be javascript code that we eval(). | 41 * version. This should be javascript code that we eval(). |
| 42 */ | 42 */ |
| 43 function getUserMedia(requestVideo, requestAudio, mediaHints) { | 43 function getUserMedia(requestVideo, requestAudio, mediaHints) { |
| 44 if (!navigator.webkitGetUserMedia) { | 44 if (!navigator.webkitGetUserMedia) { |
| 45 returnToTest('Browser does not support WebRTC.'); | 45 returnToTest('Browser does not support WebRTC.'); |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 eval('gMediaHints = ' + mediaHints); | 48 try { |
| 49 eval('gMediaHints = ' + mediaHints); |
| 50 } catch (exception) { |
| 51 failTest('Not valid javascript expression: ' + mediaHints); |
| 52 } |
| 49 | 53 |
| 50 debug('Requesting: video ' + requestVideo + ', audio ' + requestAudio); | 54 debug('Requesting: video ' + requestVideo + ', audio ' + requestAudio); |
| 51 navigator.webkitGetUserMedia({video: requestVideo, audio: requestAudio}, | 55 navigator.webkitGetUserMedia({video: requestVideo, audio: requestAudio}, |
| 52 getUserMediaOkCallback_, | 56 getUserMediaOkCallback_, |
| 53 getUserMediaFailedCallback_); | 57 getUserMediaFailedCallback_); |
| 54 returnToTest('ok-requested'); | 58 returnToTest('ok-requested'); |
| 55 } | 59 } |
| 56 | 60 |
| 57 /** | 61 /** |
| 58 * Must be called after calling getUserMedia. Returns not-called-yet if we have | 62 * Must be called after calling getUserMedia. Returns not-called-yet if we have |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 var streamUrl = webkitURL.createObjectURL(stream); | 129 var streamUrl = webkitURL.createObjectURL(stream); |
| 126 document.getElementById('local-view').src = streamUrl; | 130 document.getElementById('local-view').src = streamUrl; |
| 127 | 131 |
| 128 gRequestWebcamAndMicrophoneResult = 'ok-got-stream'; | 132 gRequestWebcamAndMicrophoneResult = 'ok-got-stream'; |
| 129 } | 133 } |
| 130 | 134 |
| 131 /** @private */ | 135 /** @private */ |
| 132 function getUserMediaFailedCallback_(error) { | 136 function getUserMediaFailedCallback_(error) { |
| 133 gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + error.code; | 137 gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + error.code; |
| 134 } | 138 } |
| OLD | NEW |