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