| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/hash.h" | 12 #include "base/hash.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "content/public/renderer/render_frame.h" | 21 #include "content/public/renderer/render_frame.h" |
| 22 #include "content/renderer/media/local_media_stream_audio_source.h" |
| 22 #include "content/renderer/media/media_stream.h" | 23 #include "content/renderer/media/media_stream.h" |
| 23 #include "content/renderer/media/media_stream_constraints_util.h" | 24 #include "content/renderer/media/media_stream_constraints_util.h" |
| 24 #include "content/renderer/media/media_stream_dispatcher.h" | 25 #include "content/renderer/media/media_stream_dispatcher.h" |
| 25 #include "content/renderer/media/media_stream_video_capturer_source.h" | 26 #include "content/renderer/media/media_stream_video_capturer_source.h" |
| 26 #include "content/renderer/media/media_stream_video_track.h" | 27 #include "content/renderer/media/media_stream_video_track.h" |
| 27 #include "content/renderer/media/peer_connection_tracker.h" | 28 #include "content/renderer/media/peer_connection_tracker.h" |
| 28 #include "content/renderer/media/webrtc/processed_local_audio_source.h" | 29 #include "content/renderer/media/webrtc/processed_local_audio_source.h" |
| 29 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 30 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
| 30 #include "content/renderer/media/webrtc_logging.h" | 31 #include "content/renderer/media/webrtc_logging.h" |
| 31 #include "content/renderer/media/webrtc_uma_histograms.h" | 32 #include "content/renderer/media/webrtc_uma_histograms.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, | 634 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, |
| 634 weak_factory_.GetWeakPtr())); | 635 weak_factory_.GetWeakPtr())); |
| 635 webkit_source->setExtraData(audio_source); // Takes ownership. | 636 webkit_source->setExtraData(audio_source); // Takes ownership. |
| 636 } | 637 } |
| 637 local_sources_.push_back(*webkit_source); | 638 local_sources_.push_back(*webkit_source); |
| 638 } | 639 } |
| 639 | 640 |
| 640 MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource( | 641 MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource( |
| 641 const StreamDeviceInfo& device, | 642 const StreamDeviceInfo& device, |
| 642 const blink::WebMediaConstraints& constraints) { | 643 const blink::WebMediaConstraints& constraints) { |
| 643 // TODO(miu): In a soon-upcoming change, I'll be providing an alternative | 644 // If the audio device is a loopback device (for screen capture), or if the |
| 644 // MediaStreamAudioSource that bypasses audio processing for the non-WebRTC | 645 // constraints/effects parameters indicate no audio processing is needed, |
| 645 // use cases. http://crbug.com/577881 | 646 // create an efficient, direct-path MediaStreamAudioSource instance. |
| 647 if (IsScreenCaptureMediaType(device.device.type) || |
| 648 !MediaStreamAudioProcessor::WouldModifyAudio( |
| 649 constraints, device.device.input.effects)) { |
| 650 return new LocalMediaStreamAudioSource(RenderFrameObserver::routing_id(), |
| 651 device); |
| 652 } |
| 653 |
| 654 // The audio device is not associated with screen capture and also requires |
| 655 // processing. |
| 646 ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource( | 656 ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource( |
| 647 RenderFrameObserver::routing_id(), device, dependency_factory_); | 657 RenderFrameObserver::routing_id(), device, dependency_factory_); |
| 648 source->SetSourceConstraints(constraints); | 658 source->SetSourceConstraints(constraints); |
| 649 return source; | 659 return source; |
| 650 } | 660 } |
| 651 | 661 |
| 652 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource( | 662 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource( |
| 653 const StreamDeviceInfo& device, | 663 const StreamDeviceInfo& device, |
| 654 const MediaStreamSource::SourceStoppedCallback& stop_callback) { | 664 const MediaStreamSource::SourceStoppedCallback& stop_callback) { |
| 655 content::MediaStreamVideoCapturerSource* ret = | 665 content::MediaStreamVideoCapturerSource* ret = |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 | 1194 |
| 1185 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { | 1195 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { |
| 1186 return !sources_waiting_for_callback_.empty(); | 1196 return !sources_waiting_for_callback_.empty(); |
| 1187 } | 1197 } |
| 1188 | 1198 |
| 1189 void UserMediaClientImpl::OnDestruct() { | 1199 void UserMediaClientImpl::OnDestruct() { |
| 1190 delete this; | 1200 delete this; |
| 1191 } | 1201 } |
| 1192 | 1202 |
| 1193 } // namespace content | 1203 } // namespace content |
| OLD | NEW |