| Index: content/renderer/media/media_stream_audio_level_calculator.h
|
| diff --git a/content/renderer/media/media_stream_audio_level_calculator.h b/content/renderer/media/media_stream_audio_level_calculator.h
|
| index e7d25cc5d548add19f02afa9b35796f20e0ca7ca..ae5991c3c95925cb999c7eae973f5af2a950798d 100644
|
| --- a/content/renderer/media/media_stream_audio_level_calculator.h
|
| +++ b/content/renderer/media/media_stream_audio_level_calculator.h
|
| @@ -5,6 +5,8 @@
|
| #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_
|
| #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_
|
|
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/synchronization/lock.h"
|
| #include "base/threading/thread_checker.h"
|
|
|
| namespace media {
|
| @@ -20,12 +22,35 @@ namespace content {
|
| // third_party/webrtc/voice_engine/level_indicator.cc.
|
| class MediaStreamAudioLevelCalculator {
|
| public:
|
| + // Provides thread-safe access to the current signal level.
|
| + class ReportedLevel : public base::RefCountedThreadSafe<ReportedLevel> {
|
| + public:
|
| + ReportedLevel();
|
| +
|
| + float Get() const;
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<ReportedLevel>;
|
| + friend class MediaStreamAudioLevelCalculator;
|
| +
|
| + ~ReportedLevel();
|
| +
|
| + mutable base::Lock lock_;
|
| + float level_;
|
| + };
|
| +
|
| MediaStreamAudioLevelCalculator();
|
| ~MediaStreamAudioLevelCalculator();
|
|
|
| - // Calculates the signal level of the audio data, returning the absolute value
|
| - // of the amplitude of the signal.
|
| - float Calculate(const media::AudioBus& audio_bus);
|
| + // Calculates the signal level of the audio data.
|
| + void Calculate(const media::AudioBus& audio_bus,
|
| + bool assume_nonzero_energy);
|
| +
|
| + // Returns a thread-safe accessor to the current absolute value of the
|
| + // amplitude of the signal.
|
| + scoped_refptr<ReportedLevel> reported_level() const {
|
| + return reported_level_;
|
| + }
|
|
|
| private:
|
| // Used to DCHECK that the constructor and Calculate() are always called on
|
| @@ -36,7 +61,7 @@ class MediaStreamAudioLevelCalculator {
|
|
|
| int counter_;
|
| float max_amplitude_;
|
| - float level_;
|
| + const scoped_refptr<ReportedLevel> reported_level_;
|
| };
|
|
|
| } // namespace content
|
|
|