| Index: content/renderer/media/media_stream_dependency_factory.cc
|
| diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc
|
| index 6172e06a8e31da352c32b056fc1cf6585ef2dcc6..231eafe635e107e8a713a90cbb446d01f5446255 100644
|
| --- a/content/renderer/media/media_stream_dependency_factory.cc
|
| +++ b/content/renderer/media/media_stream_dependency_factory.cc
|
| @@ -96,6 +96,40 @@ void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) {
|
| }
|
| }
|
|
|
| +void TransferConstraintToPlatformEffect(RTCMediaConstraints* constraints,
|
| + const char* key,
|
| + bool* platform_effect) {
|
| + bool value;
|
| + if (!webrtc::FindConstraint(constraints, key, &value, NULL) ||
|
| + value == false) {
|
| + // If the constraint does not exist, or is set to false, disable the
|
| + // corresponding platform effect.
|
| + *platform_effect = false;
|
| + DVLOG(1) << "Disabling platform effect: " << key;
|
| + } else {
|
| + if (*platform_effect) {
|
| + // If the constraint is set to true, and the corresponding platform effect
|
| + // is available, disable the constraint.
|
| + constraints->AddMandatory(key,
|
| + webrtc::MediaConstraintsInterface::kValueFalse, true);
|
| + DVLOG(1) << "Disabling constraint: " << key;
|
| + }
|
| + }
|
| +}
|
| +
|
| +// Any true constraint with an available corresponding platform effect will be
|
| +// set to false. Any false constraint will cause the corresponding platform
|
| +// effect to be disabled.
|
| +//
|
| +// This currently only deals with AEC, but is prepared for expansion to other
|
| +// platform effects.
|
| +void TransferConstraintsToPlatformEffects(RTCMediaConstraints* constraints,
|
| + MediaStreamDevice::AudioDeviceParameters* params) {
|
| + TransferConstraintToPlatformEffect(constraints,
|
| + webrtc::MediaConstraintsInterface::kEchoCancellation,
|
| + ¶ms->use_platform_aec);
|
| +}
|
| +
|
| class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface {
|
| public:
|
| P2PPortAllocatorFactory(
|
| @@ -323,7 +357,17 @@ void MediaStreamDependencyFactory::CreateNativeMediaSources(
|
|
|
| // TODO(xians): Create a new capturer for difference microphones when we
|
| // support multiple microphones. See issue crbug/262117 .
|
| - const StreamDeviceInfo device_info = source_data->device_info();
|
| + StreamDeviceInfo device_info = source_data->device_info();
|
| +
|
| + RTCMediaConstraints platform_constraints = native_audio_constraints;
|
| + // This causes constraint settings to be transferred to their corresponding
|
| + // platform effects. For example, if a platform AEC is available, and the
|
| + // AEC constraint is set to true, we should leave the platform AEC
|
| + // enabled, and disable the software AEC by setting the constraint to false.
|
| + // Contrariwise, if the AEC constraint is set to false, we should disable
|
| + // the platform AEC even if available.
|
| + TransferConstraintsToPlatformEffects(&platform_constraints,
|
| + &device_info.device.input);
|
| scoped_refptr<WebRtcAudioCapturer> capturer(
|
| MaybeCreateAudioCapturer(render_view_id, device_info));
|
| if (!capturer.get()) {
|
| @@ -341,7 +385,7 @@ void MediaStreamDependencyFactory::CreateNativeMediaSources(
|
| // Creates a LocalAudioSource object which holds audio options.
|
| // TODO(xians): The option should apply to the track instead of the source.
|
| source_data->SetLocalAudioSource(
|
| - CreateLocalAudioSource(&native_audio_constraints).get());
|
| + CreateLocalAudioSource(&platform_constraints).get());
|
| source_observer->AddSource(source_data->local_audio_source());
|
| }
|
|
|
| @@ -910,7 +954,8 @@ MediaStreamDependencyFactory::MaybeCreateAudioCapturer(
|
| device_info.session_id,
|
| device_info.device.id,
|
| device_info.device.matched_output.sample_rate,
|
| - device_info.device.matched_output.frames_per_buffer)) {
|
| + device_info.device.matched_output.frames_per_buffer,
|
| + device_info.device.input.use_platform_aec)) {
|
| return NULL;
|
| }
|
|
|
|
|