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

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

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT FOR REVIEW -- This will be broken-up across multiple CLs. Created 4 years, 10 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_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
« no previous file with comments | « content/renderer/media/media_recorder_handler.cc ('k') | content/renderer/media/media_stream_audio_level_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698