OLD | NEW |
---|---|
1 /** | 1 /** |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 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. See | 9 * information on getUserMedia. See |
10 * http://dev.w3.org/2011/webrtc/editor/webrtc.html for more information on | 10 * http://dev.w3.org/2011/webrtc/editor/webrtc.html for more information on |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 * capturing. | 202 * capturing. |
203 */ | 203 */ |
204 function updateGetUserMediaConstraints() { | 204 function updateGetUserMediaConstraints() { |
205 var audioSelected = $('audiosrc'); | 205 var audioSelected = $('audiosrc'); |
206 var videoSelected = $('videosrc'); | 206 var videoSelected = $('videosrc'); |
207 var constraints = { | 207 var constraints = { |
208 audio: $('audio').checked, | 208 audio: $('audio').checked, |
209 video: $('video').checked | 209 video: $('video').checked |
210 }; | 210 }; |
211 | 211 |
212 if ($('video').checked == true) { | |
phoglund_chromium
2014/06/19 10:06:59
Drop the == true (apply throughout)
jansson
2014/06/19 11:45:49
Done.
| |
213 // Default optional constraints placed here. | |
214 constraints.video = {optional: [{minWidth: $('video-width').value}, | |
215 {minHeight: $('video-height').value}, | |
216 {googLeakyBucket: true}]}; | |
217 } | |
218 | |
212 if (audioSelected.disabled == false && videoSelected.disabled == false) { | 219 if (audioSelected.disabled == false && videoSelected.disabled == false) { |
phoglund_chromium
2014/06/19 10:06:59
if (!audioSelected.disabled && !videoSelected) {
jansson
2014/06/19 11:45:49
Done.
| |
213 var devices = getSourcesFromField_(audioSelected, videoSelected); | 220 var devices = getSourcesFromField_(audioSelected, videoSelected); |
221 | |
214 if ($('audio').checked == true) { | 222 if ($('audio').checked == true) { |
phoglund_chromium
2014/06/19 10:06:59
Umm, what is audioSelected and videoSelected anywa
jansson
2014/06/19 11:45:49
Yes you are correct, Fixed it for both getDevices(
| |
215 if (devices.audioId != null) { | 223 if (devices.audioId != null) |
216 constraints.audio = {optional: [{sourceId: devices.audioId}]}; | 224 constraints.audio = {optional: [{sourceId: devices.audioId}]}; |
217 } else { | |
218 constraints.audio = true; | |
219 } | |
220 } | 225 } |
226 | |
221 if ($('video').checked == true) { | 227 if ($('video').checked == true) { |
222 // Default optional constraints placed here. | 228 if (devices.videoId != null) |
223 constraints.video = {optional: [{minWidth: $('video-width').value}, | |
224 {minHeight: $('video-height').value}, | |
225 {googLeakyBucket: true}] | |
226 }; | |
227 if (devices.videoId != null) { | |
228 constraints.video.optional.push({sourceId: devices.videoId}); | 229 constraints.video.optional.push({sourceId: devices.videoId}); |
229 } | |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 if ($('screencapture').checked) { | 233 if ($('screencapture').checked) { |
234 var constraints = { | 234 var constraints = { |
235 audio: $('audio').checked, | 235 audio: $('audio').checked, |
236 video: {mandatory: {chromeMediaSource: 'screen', | 236 video: {mandatory: {chromeMediaSource: 'screen', |
237 maxWidth: screen.width, | 237 maxWidth: screen.width, |
238 maxHeight: screen.height}} | 238 maxHeight: screen.height}} |
239 }; | 239 }; |
240 if ($('audio').checked == true) | 240 if ($('audio').checked == true) |
241 print_('Audio for screencapture is not implemented yet, please ' + | 241 print_('Audio for screencapture is not implemented yet, please ' + |
242 'try to set audio = false prior requesting screencapture'); | 242 'try to set audio = false prior requesting screencapture'); |
243 } | 243 } |
244 | |
244 $('getusermedia-constraints').value = JSON.stringify(constraints, null, ' '); | 245 $('getusermedia-constraints').value = JSON.stringify(constraints, null, ' '); |
245 } | 246 } |
246 | 247 |
247 function showServerHelp() { | 248 function showServerHelp() { |
248 alert('You need to build and run a peerconnection_server on some ' + | 249 alert('You need to build and run a peerconnection_server on some ' + |
249 'suitable machine. To build it in chrome, just run make/ninja ' + | 250 'suitable machine. To build it in chrome, just run make/ninja ' + |
250 'peerconnection_server. Otherwise, read in https://code.google' + | 251 'peerconnection_server. Otherwise, read in https://code.google' + |
251 '.com/searchframe#xSWYf0NTG_Q/trunk/peerconnection/README&q=REA' + | 252 '.com/searchframe#xSWYf0NTG_Q/trunk/peerconnection/README&q=REA' + |
252 'DME%20package:webrtc%5C.googlecode%5C.com.'); | 253 'DME%20package:webrtc%5C.googlecode%5C.com.'); |
253 } | 254 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 var audio_select = $('audiosrc'); | 315 var audio_select = $('audiosrc'); |
315 var video_select = $('videosrc'); | 316 var video_select = $('videosrc'); |
316 var get_devices = $('get-devices'); | 317 var get_devices = $('get-devices'); |
317 audio_select.innerHTML = ''; | 318 audio_select.innerHTML = ''; |
318 video_select.innerHTML = ''; | 319 video_select.innerHTML = ''; |
319 try { | 320 try { |
320 eval(MediaStreamTrack.getSources(function() {})); | 321 eval(MediaStreamTrack.getSources(function() {})); |
321 } catch (exception) { | 322 } catch (exception) { |
322 audio_select.disabled = true; | 323 audio_select.disabled = true; |
323 video_select.disabled = true; | 324 video_select.disabled = true; |
324 refresh_devices.disabled = true; | 325 get_devices.disabled = true; |
325 updateGetUserMediaConstraints(); | 326 updateGetUserMediaConstraints(); |
326 error_('Device enumeration not supported. ' + exception); | 327 error_('Device enumeration not supported. ' + exception); |
327 } | 328 } |
328 MediaStreamTrack.getSources(function(devices) { | 329 MediaStreamTrack.getSources(function(devices) { |
329 for (var i = 0; i < devices.length; i++) { | 330 for (var i = 0; i < devices.length; i++) { |
330 var option = document.createElement('option'); | 331 var option = document.createElement('option'); |
331 option.value = devices[i].id; | 332 option.value = devices[i].id; |
332 option.text = devices[i].label; | 333 option.text = devices[i].label; |
333 if (devices[i].kind == 'audio') { | 334 if (devices[i].kind == 'audio') { |
334 if (option.text == '') { | 335 if (option.text == '') { |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1379 | 1380 |
1380 /** @private */ | 1381 /** @private */ |
1381 function readResponseHeader_(request, key) { | 1382 function readResponseHeader_(request, key) { |
1382 var value = request.getResponseHeader(key); | 1383 var value = request.getResponseHeader(key); |
1383 if (value == null || value.length == 0) { | 1384 if (value == null || value.length == 0) { |
1384 error_('Received empty value ' + value + | 1385 error_('Received empty value ' + value + |
1385 ' for response header key ' + key + '.'); | 1386 ' for response header key ' + key + '.'); |
1386 } | 1387 } |
1387 return parseInt(value); | 1388 return parseInt(value); |
1388 } | 1389 } |
OLD | NEW |