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

Unified Diff: content/renderer/media/media_stream_audio_processor_options.h

Issue 227743004: Added a kEchoCancellation constraint to turn off the audio processing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added a GetEchoCancellationProperty method. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_audio_processor_options.h
diff --git a/content/renderer/media/media_stream_audio_processor_options.h b/content/renderer/media/media_stream_audio_processor_options.h
index 3ad41100b4c78f1157519b2598df4435fd692f1b..cec6c64c45e3cef01c727e174db96eda28420250 100644
--- a/content/renderer/media/media_stream_audio_processor_options.h
+++ b/content/renderer/media/media_stream_audio_processor_options.h
@@ -8,12 +8,9 @@
#include <string>
#include "base/platform_file.h"
+#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
-namespace blink {
-class WebMediaConstraints;
-}
-
namespace webrtc {
class AudioFrame;
@@ -30,26 +27,60 @@ class RTCMediaConstraints;
using webrtc::AudioProcessing;
using webrtc::MediaConstraintsInterface;
-// Merge |constraints| with |kDefaultAudioConstraints|. For any key which exists
-// in both, the value from |constraints| is maintained, including its
-// mandatory/optional status. New values from |kDefaultAudioConstraints| will
-// be added with mandatory status.
-void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints);
-
-// Checks if any audio constraints are set that requires audio processing to
-// be applied. |effects| is the bitmasks telling whether certain platform
-// hardware audio effects are enabled, like hardware echo cancellation. If some
-// hardware effect is enabled, the corresponding software audio processing will
-// be disabled.
-bool NeedsAudioProcessing(const blink::WebMediaConstraints& constraints,
- int effects);
-
-// Gets the property named by |key| from the |constraints|.
-// Returns true if the key is found and has a valid boolean value; Otherwise
-// false.
-bool GetPropertyFromConstraints(
- const MediaConstraintsInterface* constraints,
- const std::string& key);
+// A helper class to parse audio constraints from a blink::WebMediaConstraints
+// object.
+class MediaAudioConstraints {
+ public:
+ // Constraint keys used by audio processing.
+ static const char kEchoCancellation[];
+ static const char kGoogEchoCancellation[];
+ static const char kGoogExperimentalEchoCancellation[];
+ static const char kGoogAutoGainControl[];
+ static const char kGoogExperimentalAutoGainControl[];
+ static const char kGoogNoiseSuppression[];
+ static const char kGoogExperimentalNoiseSuppression[];
+ static const char kGoogHighpassFilter[];
+ static const char kGoogTypingNoiseDetection[];
+ static const char kGoogAudioMirroring[];
+
+ // Merge |constraints| with |kDefaultAudioConstraints|. For any key which
+ // exists in both, the value from |constraints| is maintained, including its
+ // mandatory/optional status. New values from |kDefaultAudioConstraints| will
+ // be added with optional status.
+ static void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints);
+
+ // |effects| is the bitmasks telling whether certain platform
+ // hardware audio effects are enabled, like hardware echo cancellation. If
+ // some hardware effect is enabled, the corresponding software audio
+ // processing will be disabled.
+ MediaAudioConstraints(const blink::WebMediaConstraints& constraints,
+ int effects);
+ virtual ~MediaAudioConstraints();
+
+ // Checks if any audio constraints are set that requires audio processing to
+ // be applied.
+ bool NeedsAudioProcessing();
+
+ // Gets the property of the constraint named by |key| in |constraints_|.
+ // Returns the constraint's value if the key is found; Otherwise returns the
+ // default value of the constraint.
+ // Note, for constraint of |kGoogEchoCancellation|, clients should use
+ // GetEchoCancellationProperty().
+ bool GetProperty(const std::string& key);
+
+ // Gets the property of |kGoogEchoCancellation| in |constraints_|.
+ // The returned value will be depending on a combination of |effects_|,
+ // |kEchoCancellation| and |kGoogEchoCancellation| in |constraints_|.
+ bool GetEchoCancellationProperty();
+
+ // Returns true if all the mandatory constraints in |constraints_| are valid;
+ // Otherwise return false.
+ bool IsValid();
+
+ private:
+ const blink::WebMediaConstraints constraints_;
+ const int effects_;
+};
// Enables the echo cancellation in |audio_processing|.
void EnableEchoCancellation(AudioProcessing* audio_processing);
@@ -72,7 +103,7 @@ void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing);
// Starts the echo cancellation dump in |audio_processing|.
void StartEchoCancellationDump(AudioProcessing* audio_processing,
- const base::PlatformFile& aec_dump_file);
+ const base::PlatformFile& aec_dump_file);
// Stops the echo cancellation dump in |audio_processing|.
// This method has no impact if echo cancellation dump has not been started on

Powered by Google App Engine
This is Rietveld 408576698