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

Side by Side Diff: content/renderer/media/user_media_client_impl.cc

Issue 1966043006: Revert of MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 // 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/thread_task_runner_handle.h" 20 #include "base/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/media_stream.h" 22 #include "content/renderer/media/media_stream.h"
23 #include "content/renderer/media/media_stream_audio_source.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/webrtc_video_capturer_adapter.h" 29 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
30 #include "content/renderer/media/webrtc_audio_capturer.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"
32 #include "content/renderer/render_thread_impl.h" 33 #include "content/renderer/render_thread_impl.h"
33 #include "third_party/WebKit/public/platform/URLConversion.h" 34 #include "third_party/WebKit/public/platform/URLConversion.h"
34 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 35 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
35 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" 36 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
36 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 37 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
37 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h " 38 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h "
38 #include "third_party/WebKit/public/web/WebDocument.h" 39 #include "third_party/WebKit/public/web/WebDocument.h"
39 #include "third_party/WebKit/public/web/WebLocalFrame.h" 40 #include "third_party/WebKit/public/web/WebLocalFrame.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 << ", name = " << webkit_source->name().utf8(); 621 << ", name = " << webkit_source->name().utf8();
621 622
622 if (type == blink::WebMediaStreamSource::TypeVideo) { 623 if (type == blink::WebMediaStreamSource::TypeVideo) {
623 webkit_source->setExtraData( 624 webkit_source->setExtraData(
624 CreateVideoSource( 625 CreateVideoSource(
625 device, 626 device,
626 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, 627 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped,
627 weak_factory_.GetWeakPtr()))); 628 weak_factory_.GetWeakPtr())));
628 } else { 629 } else {
629 DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, type); 630 DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, type);
630 MediaStreamAudioSource* const audio_source = 631 MediaStreamAudioSource* audio_source(
631 CreateAudioSource(device, constraints); 632 new MediaStreamAudioSource(
632 audio_source->SetStopCallback( 633 RenderFrameObserver::routing_id(),
633 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, 634 device,
634 weak_factory_.GetWeakPtr())); 635 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped,
635 webkit_source->setExtraData(audio_source); // Takes ownership. 636 weak_factory_.GetWeakPtr()),
637 dependency_factory_));
638 webkit_source->setExtraData(audio_source);
636 } 639 }
637 local_sources_.push_back(*webkit_source); 640 local_sources_.push_back(*webkit_source);
638 } 641 }
639 642
640 MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource(
641 const StreamDeviceInfo& device,
642 const blink::WebMediaConstraints& constraints) {
643 // TODO(miu): In a soon-upcoming change, I'll be providing an alternative
644 // MediaStreamAudioSource that bypasses audio processing for the non-WebRTC
645 // use cases. http://crbug.com/577881
646 ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource(
647 RenderFrameObserver::routing_id(), device, dependency_factory_);
648 source->SetSourceConstraints(constraints);
649 return source;
650 }
651
652 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource( 643 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource(
653 const StreamDeviceInfo& device, 644 const StreamDeviceInfo& device,
654 const MediaStreamSource::SourceStoppedCallback& stop_callback) { 645 const MediaStreamSource::SourceStoppedCallback& stop_callback) {
655 content::MediaStreamVideoCapturerSource* ret = 646 content::MediaStreamVideoCapturerSource* ret =
656 new content::MediaStreamVideoCapturerSource(stop_callback, device); 647 new content::MediaStreamVideoCapturerSource(stop_callback, device);
657 return ret; 648 return ret;
658 } 649 }
659 650
660 void UserMediaClientImpl::CreateVideoTracks( 651 void UserMediaClientImpl::CreateVideoTracks(
661 const StreamDeviceInfoArray& devices, 652 const StreamDeviceInfoArray& devices,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 695 }
705 } 696 }
706 697
707 for (size_t i = 0; i < overridden_audio_array.size(); ++i) { 698 for (size_t i = 0; i < overridden_audio_array.size(); ++i) {
708 blink::WebMediaStreamSource webkit_source; 699 blink::WebMediaStreamSource webkit_source;
709 InitializeSourceObject(overridden_audio_array[i], 700 InitializeSourceObject(overridden_audio_array[i],
710 blink::WebMediaStreamSource::TypeAudio, 701 blink::WebMediaStreamSource::TypeAudio,
711 constraints, 702 constraints,
712 &webkit_source); 703 &webkit_source);
713 (*webkit_tracks)[i].initialize(webkit_source); 704 (*webkit_tracks)[i].initialize(webkit_source);
714 request->StartAudioTrack((*webkit_tracks)[i]); 705 request->StartAudioTrack((*webkit_tracks)[i], constraints);
715 } 706 }
716 } 707 }
717 708
718 void UserMediaClientImpl::OnCreateNativeTracksCompleted( 709 void UserMediaClientImpl::OnCreateNativeTracksCompleted(
719 UserMediaRequestInfo* request, 710 UserMediaRequestInfo* request,
720 MediaStreamRequestResult result, 711 MediaStreamRequestResult result,
721 const blink::WebString& result_name) { 712 const blink::WebString& result_name) {
722 DVLOG(1) << "UserMediaClientImpl::OnCreateNativeTracksComplete(" 713 DVLOG(1) << "UserMediaClientImpl::OnCreateNativeTracksComplete("
723 << "{request_id = " << request->request_id << "} " 714 << "{request_id = " << request->request_id << "} "
724 << "{result = " << result << "})"; 715 << "{result = " << result << "})";
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 request(request), 1076 request(request),
1086 request_result_(MEDIA_DEVICE_OK), 1077 request_result_(MEDIA_DEVICE_OK),
1087 request_result_name_("") { 1078 request_result_name_("") {
1088 } 1079 }
1089 1080
1090 UserMediaClientImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { 1081 UserMediaClientImpl::UserMediaRequestInfo::~UserMediaRequestInfo() {
1091 DVLOG(1) << "~UserMediaRequestInfo"; 1082 DVLOG(1) << "~UserMediaRequestInfo";
1092 } 1083 }
1093 1084
1094 void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack( 1085 void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack(
1095 const blink::WebMediaStreamTrack& track) { 1086 const blink::WebMediaStreamTrack& track,
1087 const blink::WebMediaConstraints& constraints) {
1096 DCHECK(track.source().getType() == blink::WebMediaStreamSource::TypeAudio); 1088 DCHECK(track.source().getType() == blink::WebMediaStreamSource::TypeAudio);
1097 MediaStreamAudioSource* native_source = 1089 MediaStreamAudioSource* native_source =
1098 MediaStreamAudioSource::From(track.source()); 1090 MediaStreamAudioSource::From(track.source());
1099 DCHECK(native_source); 1091 DCHECK(native_source);
1100 1092
1101 sources_.push_back(track.source()); 1093 sources_.push_back(track.source());
1102 sources_waiting_for_callback_.push_back(native_source); 1094 sources_waiting_for_callback_.push_back(native_source);
1103 if (native_source->ConnectToTrack(track)) 1095 native_source->AddTrack(
1104 OnTrackStarted(native_source, MEDIA_DEVICE_OK, ""); 1096 track, constraints, base::Bind(
1105 else 1097 &UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted,
1106 OnTrackStarted(native_source, MEDIA_DEVICE_TRACK_START_FAILURE, ""); 1098 AsWeakPtr()));
1107 } 1099 }
1108 1100
1109 blink::WebMediaStreamTrack 1101 blink::WebMediaStreamTrack
1110 UserMediaClientImpl::UserMediaRequestInfo::CreateAndStartVideoTrack( 1102 UserMediaClientImpl::UserMediaRequestInfo::CreateAndStartVideoTrack(
1111 const blink::WebMediaStreamSource& source, 1103 const blink::WebMediaStreamSource& source,
1112 const blink::WebMediaConstraints& constraints) { 1104 const blink::WebMediaConstraints& constraints) {
1113 DCHECK(source.getType() == blink::WebMediaStreamSource::TypeVideo); 1105 DCHECK(source.getType() == blink::WebMediaStreamSource::TypeVideo);
1114 MediaStreamVideoSource* native_source = 1106 MediaStreamVideoSource* native_source =
1115 MediaStreamVideoSource::GetVideoSource(source); 1107 MediaStreamVideoSource::GetVideoSource(source);
1116 DCHECK(native_source); 1108 DCHECK(native_source);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 return; 1170 return;
1179 } 1171 }
1180 } 1172 }
1181 } 1173 }
1182 1174
1183 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { 1175 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const {
1184 return !sources_waiting_for_callback_.empty(); 1176 return !sources_waiting_for_callback_.empty();
1185 } 1177 }
1186 1178
1187 } // namespace content 1179 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/user_media_client_impl.h ('k') | content/renderer/media/user_media_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698