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 #include "content/renderer/media/user_media_client_impl.h" | 5 #include "content/renderer/media/user_media_client_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/renderer/media/media_stream_constraints_util_video_content.h" | 24 #include "content/renderer/media/media_stream_constraints_util_video_content.h" |
25 #include "content/renderer/media/media_stream_constraints_util_video_device.h" | 25 #include "content/renderer/media/media_stream_constraints_util_video_device.h" |
26 #include "content/renderer/media/media_stream_dispatcher.h" | 26 #include "content/renderer/media/media_stream_dispatcher.h" |
27 #include "content/renderer/media/media_stream_video_capturer_source.h" | 27 #include "content/renderer/media/media_stream_video_capturer_source.h" |
28 #include "content/renderer/media/media_stream_video_track.h" | 28 #include "content/renderer/media/media_stream_video_track.h" |
29 #include "content/renderer/media/peer_connection_tracker.h" | 29 #include "content/renderer/media/peer_connection_tracker.h" |
30 #include "content/renderer/media/webrtc/processed_local_audio_source.h" | 30 #include "content/renderer/media/webrtc/processed_local_audio_source.h" |
31 #include "content/renderer/media/webrtc_logging.h" | 31 #include "content/renderer/media/webrtc_logging.h" |
32 #include "content/renderer/media/webrtc_uma_histograms.h" | 32 #include "content/renderer/media/webrtc_uma_histograms.h" |
33 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
| 34 #include "media/audio/audio_device_description.h" |
34 #include "media/capture/video_capture_types.h" | 35 #include "media/capture/video_capture_types.h" |
35 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 36 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
36 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" | 37 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" |
37 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 38 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
38 #include "third_party/WebKit/public/platform/WebString.h" | 39 #include "third_party/WebKit/public/platform/WebString.h" |
39 #include "third_party/WebKit/public/web/WebDocument.h" | 40 #include "third_party/WebKit/public/web/WebDocument.h" |
40 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 41 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
41 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 42 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
42 | 43 |
43 namespace content { | 44 namespace content { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // advanced constraint in |constraints| is found in |device_infos|, the first | 79 // advanced constraint in |constraints| is found in |device_infos|, the first |
79 // such device ID is copied to |*device_id| and the function returns true. | 80 // such device ID is copied to |*device_id| and the function returns true. |
80 // If no such device ID is found, |*device_id| is left unmodified and the | 81 // If no such device ID is found, |*device_id| is left unmodified and the |
81 // function returns true. | 82 // function returns true. |
82 // TODO(guidou): Replace with a spec-compliant selection algorithm. See | 83 // TODO(guidou): Replace with a spec-compliant selection algorithm. See |
83 // http://crbug.com/657733. | 84 // http://crbug.com/657733. |
84 bool PickDeviceId(const blink::WebMediaConstraints& constraints, | 85 bool PickDeviceId(const blink::WebMediaConstraints& constraints, |
85 const MediaDeviceInfoArray& device_infos, | 86 const MediaDeviceInfoArray& device_infos, |
86 std::string* device_id) { | 87 std::string* device_id) { |
87 DCHECK(!constraints.IsNull()); | 88 DCHECK(!constraints.IsNull()); |
88 DCHECK(device_id->empty()); | 89 DCHECK(media::AudioDeviceDescription::IsDefaultDevice(*device_id)); |
89 | 90 |
90 if (constraints.Basic().device_id.Exact().size() > 1) { | 91 if (constraints.Basic().device_id.Exact().size() > 1) { |
91 LOG(ERROR) << "Only one required device ID is supported"; | 92 LOG(ERROR) << "Only one required device ID is supported"; |
92 return false; | 93 return false; |
93 } | 94 } |
94 | 95 |
95 if (constraints.Basic().device_id.Exact().size() == 1 && | 96 if (constraints.Basic().device_id.Exact().size() == 1 && |
96 !FindDeviceId(constraints.Basic().device_id.Exact(), device_infos, | 97 !FindDeviceId(constraints.Basic().device_id.Exact(), device_infos, |
97 device_id)) { | 98 device_id)) { |
98 LOG(ERROR) << "Invalid mandatory device ID = " | 99 LOG(ERROR) << "Invalid mandatory device ID = " |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 392 |
392 // TODO(guidou): Request audio and video capabilities in parallel. | 393 // TODO(guidou): Request audio and video capabilities in parallel. |
393 if (current_request_info_->request().Audio()) { | 394 if (current_request_info_->request().Audio()) { |
394 bool request_audio_input_devices = false; | 395 bool request_audio_input_devices = false; |
395 // TODO(guidou): Implement spec-compliant device selection for audio. See | 396 // TODO(guidou): Implement spec-compliant device selection for audio. See |
396 // http://crbug.com/623104. | 397 // http://crbug.com/623104. |
397 CopyConstraintsToTrackControls( | 398 CopyConstraintsToTrackControls( |
398 current_request_info_->request().AudioConstraints(), | 399 current_request_info_->request().AudioConstraints(), |
399 ¤t_request_info_->stream_controls()->audio, | 400 ¤t_request_info_->stream_controls()->audio, |
400 &request_audio_input_devices); | 401 &request_audio_input_devices); |
| 402 // Explicitly initialize the requested device ID to the default. |
| 403 if (IsDeviceSource( |
| 404 current_request_info_->stream_controls()->audio.stream_source)) { |
| 405 current_request_info_->stream_controls()->audio.device_id = |
| 406 std::string(media::AudioDeviceDescription::kDefaultDeviceId); |
| 407 } |
401 CopyHotwordAndLocalEchoToStreamControls( | 408 CopyHotwordAndLocalEchoToStreamControls( |
402 current_request_info_->request().AudioConstraints(), | 409 current_request_info_->request().AudioConstraints(), |
403 current_request_info_->stream_controls()); | 410 current_request_info_->stream_controls()); |
404 // Check if this input device should be used to select a matching output | 411 // Check if this input device should be used to select a matching output |
405 // device for audio rendering. | 412 // device for audio rendering. |
406 bool enable_automatic_output_device_selection = false; | 413 bool enable_automatic_output_device_selection = false; |
407 GetConstraintValueAsBoolean( | 414 GetConstraintValueAsBoolean( |
408 current_request_info_->request().AudioConstraints(), | 415 current_request_info_->request().AudioConstraints(), |
409 &blink::WebMediaTrackConstraintSet::render_to_associated_sink, | 416 &blink::WebMediaTrackConstraintSet::render_to_associated_sink, |
410 &enable_automatic_output_device_selection); | 417 &enable_automatic_output_device_selection); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 const blink::WebString& result_name) { | 1397 const blink::WebString& result_name) { |
1391 // Check if we're waiting to be notified of this source. If not, then we'll | 1398 // Check if we're waiting to be notified of this source. If not, then we'll |
1392 // ignore the notification. | 1399 // ignore the notification. |
1393 auto found = std::find(sources_waiting_for_callback_.begin(), | 1400 auto found = std::find(sources_waiting_for_callback_.begin(), |
1394 sources_waiting_for_callback_.end(), source); | 1401 sources_waiting_for_callback_.end(), source); |
1395 if (found != sources_waiting_for_callback_.end()) | 1402 if (found != sources_waiting_for_callback_.end()) |
1396 OnTrackStarted(source, result, result_name); | 1403 OnTrackStarted(source, result, result_name); |
1397 } | 1404 } |
1398 | 1405 |
1399 } // namespace content | 1406 } // namespace content |
OLD | NEW |