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

Side by Side Diff: manual/constraints.js

Issue 12824011: Updated Chrome Test pages (Closed) Base URL: https://src.chromium.org/svn/trunk/src/chrome/test/data/webrtc/
Patch Set: Created 7 years, 9 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
OLDNEW
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 */
11 11
12 /** 12 /**
13 * Asks permission to use the webcam and mic from the browser. 13 * Asks permission to use the webcam and mic from the browser.
14 */ 14 */
15 function getUserMedia() { 15 function doGetUserMedia() {
16 // Call into getUserMedia via the polyfill (adapter.js).
16 var constraints = getConstraints_(); 17 var constraints = getConstraints_();
17 var constraintsString = JSON.stringify(constraints, null, ' '); 18 var constraintsString = JSON.stringify(constraints, null, ' ');
18 $('getusermedia-constraints').innerHTML = constraintsString; 19 $('getusermedia-constraints').innerHTML = constraintsString;
19 if (!navigator.webkitGetUserMedia) { 20 if (!getUserMedia) {
20 log_('Browser does not support WebRTC.'); 21 log_('Browser does not support WebRTC.');
21 return; 22 return;
22 } 23 }
23 log_('Requesting getUserMedia with constraints: ' + constraintsString); 24 log_('Requesting getUserMedia with constraints: ' + constraintsString);
24 navigator.webkitGetUserMedia(constraints, 25 getUserMedia(constraints,
25 getUserMediaOkCallback_, 26 getUserMediaOkCallback_,
kjellander_chromium 2013/03/15 09:14:06 Fix indentation.
26 getUserMediaFailedCallback_); 27 getUserMediaFailedCallback_);
27 } 28 }
28 29
29 // Internals 30 // Internals
30 31
31 /** 32 /**
32 * Builds a Javascript constraints dictionary out of the selected options in the 33 * Builds a Javascript constraints dictionary out of the selected options in the
33 * HTML controls on the page. 34 * HTML controls on the page.
34 * @private 35 * @private
35 * @return {Object} A dictionary of constraints. 36 * @return {Object} A dictionary of constraints.
36 */ 37 */
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return c; 98 return c;
98 } 99 }
99 100
100 /** 101 /**
101 * @private 102 * @private
102 * @param {MediaStream} stream Media stream. 103 * @param {MediaStream} stream Media stream.
103 */ 104 */
104 function getUserMediaOkCallback_(stream) { 105 function getUserMediaOkCallback_(stream) {
105 gLocalStream = stream; 106 gLocalStream = stream;
106 var videoTag = $('local-view'); 107 var videoTag = $('local-view');
107 videoTag.src = webkitURL.createObjectURL(stream); 108 attachMediaStream(videoTag, stream);
108
109 // Due to crbug.com/110938 the size is 0 when onloadedmetadata fires. 109 // Due to crbug.com/110938 the size is 0 when onloadedmetadata fires.
110 // videoTag.onloadedmetadata = updateVideoTagSize_(videoTag); 110 // videoTag.onloadedmetadata = updateVideoTagSize_(videoTag);
111 // Use setTimeout as a workaround for now. 111 // Use setTimeout as a workaround for now.
112 setTimeout(function() {updateVideoTagSize_(videoTag)}, 500); 112 setTimeout(function() {updateVideoTagSize_(videoTag)}, 500);
113 gRequestWebcamAndMicrophoneResult = 'ok-got-stream'; 113 gRequestWebcamAndMicrophoneResult = 'ok-got-stream';
114 } 114 }
115 115
116 /** 116 /**
117 * @private 117 * @private
118 * @param {Object} videoTag The video tag to update. 118 * @param {Object} videoTag The video tag to update.
(...skipping 22 matching lines...) Expand all
141 141
142 /** 142 /**
143 * Simple logging function. 143 * Simple logging function.
144 * @private 144 * @private
145 * @param {string} message Message to print. 145 * @param {string} message Message to print.
146 */ 146 */
147 function log_(message) { 147 function log_(message) {
148 console.log(message); 148 console.log(message);
149 $('messages').innerHTML += message + '<br>'; 149 $('messages').innerHTML += message + '<br>';
150 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698