Commit c6e0536b authored by Oskar Sundbom's avatar Oskar Sundbom Committed by Commit Bot

Disable Mac ambient noise reduction for origin trial

The setting does not seem to be documented, but was easily found by
tracking property changes to a device and playing around in settings.

This implementation keeps a suppression count and re-enables ambient
noise reduction, if it was initially enabled, once all streams
requesting this behavior have stopped.

Bug: chromium:789152
Change-Id: I1672a44bf185beedef2caaff8f66f5c50a9aad95
Reviewed-on: https://chromium-review.googlesource.com/737873
Commit-Queue: Oskar Sundbom <ossu@chromium.org>
Reviewed-by: default avatarJason Chase <chasej@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520679}
parent 4b201b8f
......@@ -47,6 +47,7 @@ struct CONTENT_EXPORT AudioProcessingProperties {
bool enable_sw_echo_cancellation = true;
bool disable_hw_echo_cancellation = false;
bool disable_hw_noise_suppression = false;
bool goog_audio_mirroring = false;
bool goog_auto_gain_control = true;
bool goog_experimental_echo_cancellation =
......
......@@ -458,7 +458,8 @@ AudioProcessingProperties SelectAudioProcessingProperties(
const AudioCaptureCandidates& candidates,
const blink::WebMediaTrackConstraintSet& basic_constraint_set,
const media::AudioParameters& audio_parameters,
bool is_device_capture) {
bool is_device_capture,
bool should_disable_hardware_noise_suppression) {
DCHECK(!candidates.IsEmpty());
base::Optional<bool> echo_cancellation =
SelectOptionalBool(candidates.echo_cancellation_set(),
......@@ -480,6 +481,9 @@ AudioProcessingProperties SelectAudioProcessingProperties(
properties.disable_hw_echo_cancellation =
(echo_cancellation && !*echo_cancellation) ||
(goog_echo_cancellation && !*goog_echo_cancellation);
properties.disable_hw_noise_suppression =
should_disable_hardware_noise_suppression &&
!properties.disable_hw_echo_cancellation;
properties.goog_audio_mirroring =
SelectBool(candidates.goog_audio_mirroring_set(),
......@@ -512,7 +516,8 @@ AudioCaptureSettings SelectResult(
const AudioCaptureCandidates& candidates,
const blink::WebMediaTrackConstraintSet& basic_constraint_set,
const std::string& default_device_id,
const std::string& media_stream_source) {
const std::string& media_stream_source,
bool should_disable_hardware_noise_suppression) {
bool is_device_capture = media_stream_source.empty();
AudioDeviceInfo device_info =
SelectDevice(candidates.audio_device_set(), basic_constraint_set,
......@@ -530,9 +535,9 @@ AudioCaptureSettings SelectResult(
basic_constraint_set.render_to_associated_sink, false);
AudioProcessingProperties audio_processing_properties =
SelectAudioProcessingProperties(candidates, basic_constraint_set,
device_info.parameters(),
is_device_capture);
SelectAudioProcessingProperties(
candidates, basic_constraint_set, device_info.parameters(),
is_device_capture, should_disable_hardware_noise_suppression);
return AudioCaptureSettings(device_info.device_id(), device_info.parameters(),
hotword_enabled, disable_local_echo,
......@@ -544,7 +549,8 @@ AudioCaptureSettings SelectResult(
AudioCaptureSettings SelectSettingsAudioCapture(
const AudioDeviceCaptureCapabilities& capabilities,
const blink::WebMediaConstraints& constraints) {
const blink::WebMediaConstraints& constraints,
bool should_disable_hardware_noise_suppression) {
std::string media_stream_source = GetMediaStreamSource(constraints);
bool is_device_capture = media_stream_source.empty();
if (is_device_capture && capabilities.empty())
......@@ -571,7 +577,8 @@ AudioCaptureSettings SelectSettingsAudioCapture(
default_device_id = (*capabilities.begin())->device_id;
return SelectResult(candidates, constraints.Basic(), default_device_id,
media_stream_source);
media_stream_source,
should_disable_hardware_noise_suppression);
}
} // namespace content
......@@ -91,7 +91,8 @@ using AudioDeviceCaptureCapabilities =
// channelCount and groupId. http://crbug.com/731170
AudioCaptureSettings CONTENT_EXPORT
SelectSettingsAudioCapture(const AudioDeviceCaptureCapabilities& capabilities,
const blink::WebMediaConstraints& constraints);
const blink::WebMediaConstraints& constraints,
bool should_disable_hardware_noise_suppression);
} // namespace content
......
......@@ -106,7 +106,7 @@ class MediaStreamConstraintsUtilAudioTest
AudioCaptureSettings SelectSettings() {
blink::WebMediaConstraints constraints =
constraint_factory_.CreateWebMediaConstraints();
return SelectSettingsAudioCapture(capabilities_, constraints);
return SelectSettingsAudioCapture(capabilities_, constraints, false);
}
// When googExperimentalEchoCancellation is not explicitly set, its default
......@@ -958,7 +958,7 @@ TEST_P(MediaStreamConstraintsUtilAudioTest, NoDevicesNoConstraints) {
AudioDeviceCaptureCapabilities capabilities;
auto result = SelectSettingsAudioCapture(
capabilities, constraint_factory_.CreateWebMediaConstraints());
capabilities, constraint_factory_.CreateWebMediaConstraints(), false);
EXPECT_FALSE(result.HasValue());
EXPECT_TRUE(std::string(result.failed_constraint_name()).empty());
}
......@@ -971,7 +971,7 @@ TEST_P(MediaStreamConstraintsUtilAudioTest, NoDevicesWithConstraints) {
AudioDeviceCaptureCapabilities capabilities;
constraint_factory_.basic().sample_size.SetExact(16);
auto result = SelectSettingsAudioCapture(
capabilities, constraint_factory_.CreateWebMediaConstraints());
capabilities, constraint_factory_.CreateWebMediaConstraints(), false);
EXPECT_FALSE(result.HasValue());
EXPECT_TRUE(std::string(result.failed_constraint_name()).empty());
}
......
......@@ -405,7 +405,8 @@ void UserMediaProcessor::SelectAudioSettings(
DCHECK(current_request_info_->stream_controls()->audio.requested);
auto settings = SelectSettingsAudioCapture(
std::move(audio_input_capabilities), web_request.AudioConstraints());
std::move(audio_input_capabilities), web_request.AudioConstraints(),
web_request.ShouldDisableHardwareNoiseSuppression());
if (!settings.HasValue()) {
blink::WebString failed_constraint_name =
blink::WebString::FromASCII(settings.failed_constraint_name());
......
......@@ -92,16 +92,31 @@ bool ProcessedLocalAudioSource::EnsureSourceIsStarted() {
device().session_id, device().matched_output.sample_rate(),
device().matched_output.frames_per_buffer(), device().input.effects()));
MediaStreamDevice modified_device(device());
bool device_is_modified = false;
// Disable HW echo cancellation if constraints explicitly specified no
// echo cancellation.
if (audio_processing_properties_.disable_hw_echo_cancellation &&
(device().input.effects() & media::AudioParameters::ECHO_CANCELLER)) {
MediaStreamDevice modified_device(device());
modified_device.input.set_effects(modified_device.input.effects() &
~media::AudioParameters::ECHO_CANCELLER);
SetDevice(modified_device);
device_is_modified = true;
}
// Disable noise suppression on the device if the properties explicitly
// specify to do so.
if (audio_processing_properties_.disable_hw_noise_suppression &&
(device().input.effects() & media::AudioParameters::NOISE_SUPPRESSION)) {
modified_device.input.set_effects(
modified_device.input.effects() &
~media::AudioParameters::NOISE_SUPPRESSION);
device_is_modified = true;
}
if (device_is_modified)
SetDevice(modified_device);
// Create the MediaStreamAudioProcessor, bound to the WebRTC audio device
// module.
WebRtcAudioDeviceImpl* const rtc_audio_device =
......
......@@ -224,7 +224,7 @@ AUAudioInputStream::AUAudioInputStream(
AudioDeviceID audio_device_id,
const AudioManager::LogCallback& log_callback)
: manager_(manager),
number_of_frames_(input_params.frames_per_buffer()),
input_params_(input_params),
number_of_frames_provided_(0),
io_buffer_frame_size_(0),
sink_(nullptr),
......@@ -232,7 +232,7 @@ AUAudioInputStream::AUAudioInputStream(
input_device_id_(audio_device_id),
number_of_channels_in_frame_(0),
fifo_(input_params.channels(),
number_of_frames_,
input_params.frames_per_buffer(),
kNumberOfBlocksBufferInFifo),
got_input_callback_(false),
input_callback_is_active_(false),
......@@ -240,6 +240,7 @@ AUAudioInputStream::AUAudioInputStream(
buffer_size_was_changed_(false),
audio_unit_render_has_worked_(false),
device_listener_is_active_(false),
noise_reduction_suppressed_(false),
last_sample_time_(0.0),
last_number_of_frames_(0),
total_lost_frames_(0),
......@@ -266,12 +267,13 @@ AUAudioInputStream::AUAudioInputStream(
DVLOG(1) << "ctor";
DVLOG(1) << "device ID: 0x" << std::hex << audio_device_id;
DVLOG(1) << "buffer size : " << number_of_frames_;
DVLOG(1) << "buffer size : " << input_params.frames_per_buffer();
DVLOG(1) << "channels : " << input_params.channels();
DVLOG(1) << "desired output format: " << format_;
// Derive size (in bytes) of the buffers that we will render to.
UInt32 data_byte_size = number_of_frames_ * format_.mBytesPerFrame;
UInt32 data_byte_size =
input_params.frames_per_buffer() * format_.mBytesPerFrame;
DVLOG(1) << "size of data buffer in bytes : " << data_byte_size;
// Allocate AudioBuffers to be used as storage for the received audio.
......@@ -434,7 +436,7 @@ bool AUAudioInputStream::Open() {
// the UMA stats tied to the Media.Audio.InputStartupSuccessMac record.
size_t io_buffer_frame_size = 0;
if (!manager_->MaybeChangeBufferSize(
input_device_id_, audio_unit_, 1, number_of_frames_,
input_device_id_, audio_unit_, 1, input_params_.frames_per_buffer(),
&buffer_size_was_changed_, &io_buffer_frame_size)) {
result = kAudioUnitErr_FormatNotSupported;
HandleError(result);
......@@ -446,16 +448,17 @@ bool AUAudioInputStream::Open() {
DCHECK(!io_buffer_frame_size_);
io_buffer_frame_size_ = io_buffer_frame_size;
// If |number_of_frames_| is out of range, the closest valid buffer size will
// be set instead. Check the current setting and log a warning for a non
// perfect match. Any such mismatch will be compensated for in
// If the requested number of frames is out of range, the closest valid buffer
// size will be set instead. Check the current setting and log a warning for a
// non perfect match. Any such mismatch will be compensated for in
// OnDataIsAvailable().
UInt32 buffer_frame_size = 0;
UInt32 property_size = sizeof(buffer_frame_size);
result = AudioUnitGetProperty(
audio_unit_, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global,
0, &buffer_frame_size, &property_size);
LOG_IF(WARNING, buffer_frame_size != number_of_frames_)
LOG_IF(WARNING, buffer_frame_size !=
static_cast<UInt32>(input_params_.frames_per_buffer()))
<< "AUHAL is using best match of IO buffer size: " << buffer_frame_size;
// Channel mapping should be supported but add a warning just in case.
......@@ -523,6 +526,11 @@ void AUAudioInputStream::Start(AudioInputCallback* callback) {
sink_ = callback;
last_success_time_ = base::TimeTicks::Now();
audio_unit_render_has_worked_ = false;
if (!(input_params_.effects() & AudioParameters::NOISE_SUPPRESSION) &&
manager_->DeviceSupportsAmbientNoiseReduction(input_device_id_)) {
noise_reduction_suppressed_ =
manager_->SuppressNoiseReduction(input_device_id_);
}
StartAgc();
OSStatus result = AudioOutputUnitStart(audio_unit_);
OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
......@@ -550,6 +558,10 @@ void AUAudioInputStream::Stop() {
deferred_start_cb_.Cancel();
DVLOG(1) << "Stop";
StopAgc();
if (noise_reduction_suppressed_) {
manager_->UnsuppressNoiseReduction(input_device_id_);
noise_reduction_suppressed_ = false;
}
if (input_callback_timer_ != nullptr) {
input_callback_timer_->Stop();
input_callback_timer_.reset();
......@@ -586,7 +598,9 @@ void AUAudioInputStream::Close() {
// It is valid to call Close() before calling open or Start().
// It is also valid to call Close() after Start() has been called.
Stop();
if (IsRunning()) {
Stop();
}
// Uninitialize and dispose the audio unit.
CloseAudioUnit();
......@@ -900,7 +914,9 @@ OSStatus AUAudioInputStream::Provide(UInt32 number_of_frames,
// TODO(grunell): We'll only care about the first buffer size change, any
// further changes will be ignored. This is in line with output side stats.
// It would be nice to have all changes reflected in UMA stats.
if (number_of_frames != number_of_frames_ && number_of_frames_provided_ == 0)
if (number_of_frames !=
static_cast<UInt32>(input_params_.frames_per_buffer()) &&
number_of_frames_provided_ == 0)
number_of_frames_provided_ = number_of_frames;
base::TimeTicks capture_time = GetCaptureTime(time_stamp);
......@@ -927,7 +943,7 @@ OSStatus AUAudioInputStream::Provide(UInt32 number_of_frames,
// typically one block.
const int blocks =
static_cast<int>((number_of_frames - fifo_.GetUnfilledFrames()) /
number_of_frames_) +
input_params_.frames_per_buffer()) +
1;
DLOG(WARNING) << "Increasing FIFO capacity by " << blocks << " blocks";
TRACE_EVENT_INSTANT1("audio", "Increasing FIFO capacity",
......@@ -945,7 +961,8 @@ OSStatus AUAudioInputStream::Provide(UInt32 number_of_frames,
// Consume and deliver the data when the FIFO has a block of available data.
while (fifo_.available_blocks()) {
const AudioBus* audio_bus = fifo_.Consume();
DCHECK_EQ(audio_bus->frames(), static_cast<int>(number_of_frames_));
DCHECK_EQ(audio_bus->frames(),
static_cast<int>(input_params_.frames_per_buffer()));
sink_->OnData(audio_bus, capture_time, normalized_volume);
......@@ -1182,18 +1199,19 @@ void AUAudioInputStream::AddHistogramsForFailedStartup() {
manager_->low_latency_input_streams());
UMA_HISTOGRAM_COUNTS_1000("Media.Audio.NumberOfBasicInputStreamsMac",
manager_->basic_input_streams());
// |number_of_frames_| is set at construction and corresponds to the
// requested (by the client) number of audio frames per I/O buffer connected
// to the selected input device. Ideally, this size will be the same as the
// native I/O buffer size given by |io_buffer_frame_size_|.
// |input_params_.frames_per_buffer()| is set at construction and corresponds
// to the requested (by the client) number of audio frames per I/O buffer
// connected to the selected input device. Ideally, this size will be the same
// as the native I/O buffer size given by |io_buffer_frame_size_|.
UMA_HISTOGRAM_SPARSE_SLOWLY("Media.Audio.RequestedInputBufferFrameSizeMac",
number_of_frames_);
DVLOG(1) << "number_of_frames_: " << number_of_frames_;
// This value indicates the number of frames in the IO buffers connected
// to the selected input device. It has been set by the audio manger in
// Open() and can be the same as |number_of_frames_|, which is the desired
// buffer size. These two values might differ if other streams are using the
// same device and any of these streams have asked for a smaller buffer size.
input_params_.frames_per_buffer());
DVLOG(1) << "number_of_frames_: " << input_params_.frames_per_buffer();
// This value indicates the number of frames in the IO buffers connected to
// the selected input device. It has been set by the audio manger in Open()
// and can be the same as |input_params_.frames_per_buffer()|, which is the
// desired buffer size. These two values might differ if other streams are
// using the same device and any of these streams have asked for a smaller
// buffer size.
UMA_HISTOGRAM_SPARSE_SLOWLY("Media.Audio.ActualInputBufferFrameSizeMac",
io_buffer_frame_size_);
DVLOG(1) << "io_buffer_frame_size_: " << io_buffer_frame_size_;
......
......@@ -92,7 +92,9 @@ class MEDIA_EXPORT AUAudioInputStream
bool IsRunning();
AudioDeviceID device_id() const { return input_device_id_; }
size_t requested_buffer_size() const { return number_of_frames_; }
size_t requested_buffer_size() const {
return input_params_.frames_per_buffer();
}
private:
static const AudioObjectPropertyAddress kDeviceChangePropertyAddress;
......@@ -182,8 +184,8 @@ class MEDIA_EXPORT AUAudioInputStream
// Our creator, the audio manager needs to be notified when we close.
AudioManagerMac* const manager_;
// Contains the desired number of audio frames in each callback.
const size_t number_of_frames_;
// The audio parameters requested when creating the stream.
const AudioParameters input_params_;
// Stores the number of frames that we actually get callbacks for.
// This may be different from what we ask for, so we use this for stats in
......@@ -276,6 +278,10 @@ class MEDIA_EXPORT AUAudioInputStream
// Only touched on the creating thread.
bool device_listener_is_active_;
// Set to true when we've successfully called SuppressNoiseReduction to
// disable ambient noise reduction.
bool noise_reduction_suppressed_;
// Stores the timestamp of the previous audio buffer provided by the OS.
// We use this in combination with |last_number_of_frames_| to detect when
// the OS has decided to skip providing frames (i.e. a glitch).
......
......@@ -53,6 +53,9 @@ static AudioObjectPropertyAddress GetAudioObjectPropertyAddress(
return property_address;
}
static const AudioObjectPropertyAddress kNoiseReductionPropertyAddress = {
'nzca', kAudioDevicePropertyScopeInput, kAudioObjectPropertyElementMaster};
// Get IO buffer size range from HAL given device id and scope.
static OSStatus GetIOBufferFrameSizeRange(AudioDeviceID device_id,
bool is_input,
......@@ -640,10 +643,15 @@ AudioParameters AudioManagerMac::GetInputStreamParameters(
// http://crbug.com/154352.
const int buffer_size = ChooseBufferSize(true, sample_rate);
// TODO(xians): query the native channel layout for the specific device.
return AudioParameters(
AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
sample_rate, 16, buffer_size);
// TODO(grunell): query the native channel layout for the specific device.
AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
sample_rate, 16, buffer_size);
if (DeviceSupportsAmbientNoiseReduction(device)) {
params.set_effects(AudioParameters::NOISE_SUPPRESSION);
}
return params;
}
std::string AudioManagerMac::GetAssociatedOutputDeviceID(
......@@ -1113,6 +1121,65 @@ base::TimeDelta AudioManagerMac::GetHardwareLatency(
device_latency_frames + stream_latency_frames, sample_rate);
}
bool AudioManagerMac::DeviceSupportsAmbientNoiseReduction(
AudioDeviceID device_id) {
return AudioObjectHasProperty(device_id, &kNoiseReductionPropertyAddress);
}
bool AudioManagerMac::SuppressNoiseReduction(AudioDeviceID device_id) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
DCHECK(DeviceSupportsAmbientNoiseReduction(device_id));
NoiseReductionState& state = device_noise_reduction_states_[device_id];
if (state.suppression_count == 0) {
UInt32 initially_enabled = 0;
UInt32 size = sizeof(initially_enabled);
OSStatus result =
AudioObjectGetPropertyData(device_id, &kNoiseReductionPropertyAddress,
0, nullptr, &size, &initially_enabled);
if (result != noErr)
return false;
if (initially_enabled) {
const UInt32 disable = 0;
OSStatus result =
AudioObjectSetPropertyData(device_id, &kNoiseReductionPropertyAddress,
0, nullptr, sizeof(disable), &disable);
if (result != noErr) {
OSSTATUS_DLOG(WARNING, result)
<< "Failed to disable ambient noise reduction for device: "
<< std::hex << device_id;
}
state.initial_state = NoiseReductionState::ENABLED;
} else {
state.initial_state = NoiseReductionState::DISABLED;
}
}
// Only increase the counter if suppression succeeded or is already active.
++state.suppression_count;
return true;
}
void AudioManagerMac::UnsuppressNoiseReduction(AudioDeviceID device_id) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
NoiseReductionState& state = device_noise_reduction_states_[device_id];
DCHECK_NE(state.suppression_count, 0);
--state.suppression_count;
if (state.suppression_count == 0) {
if (state.initial_state == NoiseReductionState::ENABLED) {
const UInt32 enable = 1;
OSStatus result =
AudioObjectSetPropertyData(device_id, &kNoiseReductionPropertyAddress,
0, nullptr, sizeof(enable), &enable);
if (result != noErr) {
OSSTATUS_DLOG(WARNING, result)
<< "Failed to re-enable ambient noise reduction for device: "
<< std::hex << device_id;
}
}
}
}
bool AudioManagerMac::IncreaseIOBufferSizeIfPossible(AudioDeviceID device_id) {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
DVLOG(1) << "IncreaseIOBufferSizeIfPossible(id=0x" << std::hex << device_id
......
......@@ -127,6 +127,24 @@ class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase {
}
size_t basic_input_streams() const { return basic_input_streams_.size(); }
bool DeviceSupportsAmbientNoiseReduction(AudioDeviceID device_id);
bool SuppressNoiseReduction(AudioDeviceID device_id);
void UnsuppressNoiseReduction(AudioDeviceID device_id);
// The state of a single device for which we've tried to disable Ambient Noise
// Reduction. If the device initially has ANR enabled, it will be turned off
// as the suppression count goes from 0 to 1 and turned on again as the count
// returns to 0.
struct NoiseReductionState {
enum State { DISABLED, ENABLED };
State initial_state = DISABLED;
int suppression_count = 0;
};
// Keep track of the devices that we've changed the Ambient Noise Reduction
// setting on.
std::map<AudioDeviceID, NoiseReductionState> device_noise_reduction_states_;
protected:
AudioParameters GetPreferredOutputStreamParameters(
const std::string& output_device_id,
......
......@@ -135,6 +135,7 @@ class MEDIA_SHMEM_EXPORT AudioParameters {
DUCKING = 0x2, // Enables ducking if the OS supports it.
KEYBOARD_MIC = 0x4,
HOTWORD = 0x8,
NOISE_SUPPRESSION = 0x10
};
AudioParameters();
......
......@@ -77,6 +77,11 @@ WebMediaConstraints WebUserMediaRequest::VideoConstraints() const {
return private_->VideoConstraints();
}
bool WebUserMediaRequest::ShouldDisableHardwareNoiseSuppression() const {
DCHECK(!IsNull());
return private_->ShouldDisableHardwareNoiseSuppression();
}
WebSecurityOrigin WebUserMediaRequest::GetSecurityOrigin() const {
DCHECK(!IsNull());
if (!private_->GetExecutionContext())
......
......@@ -42,6 +42,7 @@
#include "core/dom/SpaceSplitString.h"
#include "core/frame/Deprecation.h"
#include "core/frame/HostsUsingFeatures.h"
#include "core/origin_trials/origin_trials.h"
#include "modules/mediastream/MediaConstraintsImpl.h"
#include "modules/mediastream/MediaStream.h"
#include "modules/mediastream/MediaStreamConstraints.h"
......@@ -374,9 +375,16 @@ UserMediaRequest::UserMediaRequest(
: ContextLifecycleObserver(context),
audio_(audio),
video_(video),
should_disable_hardware_noise_suppression_(
OriginTrials::disableHardwareNoiseSuppressionEnabled(context)),
controller_(controller),
success_callback_(success_callback),
error_callback_(error_callback) {}
error_callback_(error_callback) {
if (should_disable_hardware_noise_suppression_) {
UseCounter::Count(context,
WebFeature::kUserMediaDisableHardwareNoiseSuppression);
}
}
UserMediaRequest::~UserMediaRequest() {}
......@@ -396,6 +404,10 @@ WebMediaConstraints UserMediaRequest::VideoConstraints() const {
return video_;
}
bool UserMediaRequest::ShouldDisableHardwareNoiseSuppression() const {
return should_disable_hardware_noise_suppression_;
}
bool UserMediaRequest::IsSecureContextUse(String& error_message) {
Document* document = OwnerDocument();
......
......@@ -83,6 +83,10 @@ class MODULES_EXPORT UserMediaRequest final
WebMediaConstraints AudioConstraints() const;
WebMediaConstraints VideoConstraints() const;
// Flag tied to whether or not the similarly named Origin Trial is
// enabled. Will be removed at end of trial. See: http://crbug.com/789152.
bool ShouldDisableHardwareNoiseSuppression() const;
// errorMessage is only set if requestIsPrivilegedContext() returns |false|.
// Caller is responsible for properly setting errors and canceling request.
bool IsSecureContextUse(String& error_message);
......@@ -102,6 +106,7 @@ class MODULES_EXPORT UserMediaRequest final
WebMediaConstraints audio_;
WebMediaConstraints video_;
bool should_disable_hardware_noise_suppression_;
Member<UserMediaController> controller_;
......
......@@ -331,6 +331,11 @@
name: "DeviceMemoryHeader",
status: "stable",
},
{
name: "DisableHardwareNoiseSuppression",
origin_trial_feature_name: "DisableHardwareNoiseSuppression",
status: "experimental",
},
{
name: "DisplayList2dCanvas",
status: "stable",
......
......@@ -1776,6 +1776,7 @@ enum WebFeature {
kV8RTCPeerConnection_RemoveTrack_Method = 2255,
kLocalCSSFile = 2256,
kLocalCSSFileExtensionRejected = 2257,
kUserMediaDisableHardwareNoiseSuppression = 2258,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -79,6 +79,10 @@ class BLINK_EXPORT WebUserMediaRequest {
WebMediaConstraints AudioConstraints() const;
WebMediaConstraints VideoConstraints() const;
// Flag tied to whether or not the similarly named Origin Trial is
// enabled. Will be removed at end of trial. See: http://crbug.com/789152.
bool ShouldDisableHardwareNoiseSuppression() const;
WebSecurityOrigin GetSecurityOrigin() const;
WebDocument OwnerDocument() const;
......
......@@ -17108,6 +17108,7 @@ Called by update_net_error_codes.py.-->
<int value="2255" label="V8RTCPeerConnection_RemoveTrack_Method"/>
<int value="2256" label="LocalCSSFile"/>
<int value="2257" label="LocalCSSFileExtensionRejected"/>
<int value="2258" label="UserMediaDisableHardwareNoiseSuppression"/>
</enum>
<enum name="FeedbackSource">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment