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

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

Issue 178223013: Calculate the signal level on the media stream local audio track (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/media_stream_audio_level_calculator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..dbd1fc8fd5d1c5b72c26389e55a2c74487106ca0
--- /dev/null
+++ b/content/renderer/media/media_stream_audio_level_calculator.h
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_
+#define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_
+
+#include "base/threading/non_thread_safe.h"
+
+namespace content {
+
+// This class is used by the WebRtcLocalAudioTrack to calculate the level of
+// the audio signal. And the audio level will be eventually used by the volume
+// animation UI.
+// The algorithm used by this class is the same as how it is done in
+// third_party/webrtc/voice_engine/level_indicator.cc.
+class MediaStreamAudioLevelCalculator : public base::NonThreadSafe {
no longer working on chromium 2014/03/01 11:34:28 I can't use the NonThreadSafe here since the objec
tommi (sloooow) - chröme 2014/03/01 11:49:33 Can you document that then instead?
no longer working on chromium 2014/03/01 12:37:00 Done with adding comment above the thread_check_ m
+ public:
+ MediaStreamAudioLevelCalculator();
+ ~MediaStreamAudioLevelCalculator();
+
+ // Calculates the signal level of the audio data.
+ // Returns the level of bars that the volume animation UI uses for
+ // presenting the energy level of the audio data.
+ int Calculate(const int16* audio_data, int number_of_channels,
+ int number_of_frames);
+
+ private:
+ int counter_;
+ int max_amplitude_;
+ int level_;
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_
« no previous file with comments | « content/content_renderer.gypi ('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