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

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

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt Created 4 years, 11 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>
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 << ", name = " << webkit_source->name().utf8(); 591 << ", name = " << webkit_source->name().utf8();
592 592
593 if (type == blink::WebMediaStreamSource::TypeVideo) { 593 if (type == blink::WebMediaStreamSource::TypeVideo) {
594 webkit_source->setExtraData( 594 webkit_source->setExtraData(
595 CreateVideoSource( 595 CreateVideoSource(
596 device, 596 device,
597 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, 597 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped,
598 weak_factory_.GetWeakPtr()))); 598 weak_factory_.GetWeakPtr())));
599 } else { 599 } else {
600 DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, type); 600 DCHECK_EQ(blink::WebMediaStreamSource::TypeAudio, type);
601 MediaStreamAudioSource* audio_source( 601 MediaStreamAudioSource* audio_source;
602 new MediaStreamAudioSource( 602 // When no RenderFrame was provided, create a "null"
603 RenderFrameObserver::routing_id(), 603 // MediaStreamAudioSource. This should only happen for non-browser unit
604 device, 604 // tests (e.g., user_media_client_impl_unittest.cc).
605 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, 605 if (RenderFrameObserver::render_frame()) {
606 weak_factory_.GetWeakPtr()), 606 audio_source =
607 dependency_factory_)); 607 new MediaStreamAudioSource(RenderFrameObserver::routing_id(), device);
608 webkit_source->setExtraData(audio_source); 608 } else {
609 audio_source = new MediaStreamAudioSource();
610 audio_source->SetDeviceInfo(device);
611 }
612 audio_source->SetStopCallback(
613 base::Bind(&UserMediaClientImpl::OnLocalSourceStopped,
614 weak_factory_.GetWeakPtr()));
615 audio_source->set_dependency_factory(dependency_factory_);
616 webkit_source->setExtraData(audio_source); // Takes ownership.
609 } 617 }
610 local_sources_.push_back(*webkit_source); 618 local_sources_.push_back(*webkit_source);
611 } 619 }
612 620
613 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource( 621 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource(
614 const StreamDeviceInfo& device, 622 const StreamDeviceInfo& device,
615 const MediaStreamSource::SourceStoppedCallback& stop_callback) { 623 const MediaStreamSource::SourceStoppedCallback& stop_callback) {
616 content::MediaStreamVideoCapturerSource* ret = 624 content::MediaStreamVideoCapturerSource* ret =
617 new content::MediaStreamVideoCapturerSource(stop_callback, device); 625 new content::MediaStreamVideoCapturerSource(stop_callback, device);
618 return ret; 626 return ret;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack( 1056 void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack(
1049 const blink::WebMediaStreamTrack& track, 1057 const blink::WebMediaStreamTrack& track,
1050 const blink::WebMediaConstraints& constraints) { 1058 const blink::WebMediaConstraints& constraints) {
1051 DCHECK(track.source().type() == blink::WebMediaStreamSource::TypeAudio); 1059 DCHECK(track.source().type() == blink::WebMediaStreamSource::TypeAudio);
1052 MediaStreamAudioSource* native_source = 1060 MediaStreamAudioSource* native_source =
1053 static_cast <MediaStreamAudioSource*>(track.source().extraData()); 1061 static_cast <MediaStreamAudioSource*>(track.source().extraData());
1054 DCHECK(native_source); 1062 DCHECK(native_source);
1055 1063
1056 sources_.push_back(track.source()); 1064 sources_.push_back(track.source());
1057 sources_waiting_for_callback_.push_back(native_source); 1065 sources_waiting_for_callback_.push_back(native_source);
1058 native_source->AddTrack( 1066 if (native_source->ConnectToTrack(track, constraints))
1059 track, constraints, base::Bind( 1067 OnTrackStarted(native_source, MEDIA_DEVICE_OK, "");
1060 &UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted, 1068 else
1061 AsWeakPtr())); 1069 OnTrackStarted(native_source, MEDIA_DEVICE_TRACK_START_FAILURE, "");
1062 } 1070 }
1063 1071
1064 blink::WebMediaStreamTrack 1072 blink::WebMediaStreamTrack
1065 UserMediaClientImpl::UserMediaRequestInfo::CreateAndStartVideoTrack( 1073 UserMediaClientImpl::UserMediaRequestInfo::CreateAndStartVideoTrack(
1066 const blink::WebMediaStreamSource& source, 1074 const blink::WebMediaStreamSource& source,
1067 const blink::WebMediaConstraints& constraints) { 1075 const blink::WebMediaConstraints& constraints) {
1068 DCHECK(source.type() == blink::WebMediaStreamSource::TypeVideo); 1076 DCHECK(source.type() == blink::WebMediaStreamSource::TypeVideo);
1069 MediaStreamVideoSource* native_source = 1077 MediaStreamVideoSource* native_source =
1070 MediaStreamVideoSource::GetVideoSource(source); 1078 MediaStreamVideoSource::GetVideoSource(source);
1071 DCHECK(native_source); 1079 DCHECK(native_source);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 return; 1141 return;
1134 } 1142 }
1135 } 1143 }
1136 } 1144 }
1137 1145
1138 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { 1146 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const {
1139 return !sources_waiting_for_callback_.empty(); 1147 return !sources_waiting_for_callback_.empty();
1140 } 1148 }
1141 1149
1142 } // namespace content 1150 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698