Chromium Code Reviews| Index: content/renderer/media/user_media_client_impl.cc |
| diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc |
| index 96ebd7bdfa3e904ab5ee720b51fc1a33f03277a6..4ba10f4c03ca964c72959dd2cb2a1c192329b539 100644 |
| --- a/content/renderer/media/user_media_client_impl.cc |
| +++ b/content/renderer/media/user_media_client_impl.cc |
| @@ -232,6 +232,15 @@ bool IsValidVideoContentSource(const std::string& source) { |
| source == kMediaStreamSourceScreen; |
| } |
| +void SetHardwareEchoCancellationSetting(blink::WebMediaStreamSource* source) { |
|
hbos_chromium
2017/07/04 15:26:49
Should this be generalized and/or renamed, e.g. Su
Guido Urdaneta
2017/07/05 09:23:36
This would probably be the place for future settin
|
| + MediaStreamAudioSource* source_impl = |
| + static_cast<MediaStreamAudioSource*>(source->GetExtraData()); |
| + media::AudioParameters params = source_impl->GetAudioParameters(); |
| + if (params.IsValid() && |
| + (params.effects() & media::AudioParameters::ECHO_CANCELLER)) |
| + source->SetEchoCancellation(true); |
| +} |
| + |
| static int g_next_request_id = 0; |
| } // namespace |
| @@ -968,18 +977,23 @@ blink::WebMediaStreamSource UserMediaClientImpl::InitializeAudioSourceObject( |
| &UserMediaClientImpl::OnAudioSourceStartedOnAudioThread, |
| base::ThreadTaskRunnerHandle::Get(), weak_factory_.GetWeakPtr()); |
| - MediaStreamAudioSource* const audio_source = |
| - CreateAudioSource(device, constraints, source_ready); |
| + bool has_sw_echo_cancellation = false; |
| + MediaStreamAudioSource* const audio_source = CreateAudioSource( |
| + device, constraints, source_ready, &has_sw_echo_cancellation); |
| audio_source->SetStopCallback(base::Bind( |
| &UserMediaClientImpl::OnLocalSourceStopped, weak_factory_.GetWeakPtr())); |
| source.SetExtraData(audio_source); // Takes ownership. |
| + // If the hardware has echo cancellation, the value is updated in |
| + // CreateAudioTracks(), after the track has started. |
|
hbos_chromium
2017/07/04 15:26:48
Could you clarify that the reason we don't set it
Guido Urdaneta
2017/07/05 09:23:37
Done.
|
| + source.SetEchoCancellation(has_sw_echo_cancellation); |
| return source; |
| } |
| MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource( |
| const StreamDeviceInfo& device, |
| const blink::WebMediaConstraints& constraints, |
| - const MediaStreamSource::ConstraintsCallback& source_ready) { |
| + const MediaStreamSource::ConstraintsCallback& source_ready, |
| + bool* has_sw_echo_cancellation) { |
| DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| DCHECK(current_request_info_); |
| // If the audio device is a loopback device (for screen capture), or if the |
| @@ -993,6 +1007,7 @@ MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource( |
| if (IsScreenCaptureMediaType(device.device.type) || |
| !MediaStreamAudioProcessor::WouldModifyAudio( |
| audio_processing_properties)) { |
| + *has_sw_echo_cancellation = false; |
| return new LocalMediaStreamAudioSource(RenderFrameObserver::routing_id(), |
| device, source_ready); |
| } |
| @@ -1002,6 +1017,8 @@ MediaStreamAudioSource* UserMediaClientImpl::CreateAudioSource( |
| ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource( |
| RenderFrameObserver::routing_id(), device, audio_processing_properties, |
| source_ready, dependency_factory_); |
| + *has_sw_echo_cancellation = |
| + audio_processing_properties.enable_sw_echo_cancellation; |
| return source; |
| } |
| @@ -1070,6 +1087,7 @@ void UserMediaClientImpl::CreateAudioTracks( |
| overridden_audio_array[i], constraints, &is_pending); |
| (*webkit_tracks)[i].Initialize(source); |
| current_request_info_->StartAudioTrack((*webkit_tracks)[i], is_pending); |
| + SetHardwareEchoCancellationSetting(&source); |
|
hbos_chromium
2017/07/04 15:26:48
Add a comment saying the source's current value re
Guido Urdaneta
2017/07/05 09:23:36
Done.
|
| } |
| } |