Chromium Code Reviews| 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..ab5a5da39238073d0915f3e6d2a7c59d983387c4 |
| --- /dev/null |
| +++ b/content/renderer/media/media_stream_audio_level_calculator.h |
| @@ -0,0 +1,42 @@ |
| +// 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/thread_checker.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: |
| + 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: |
| + // Used to DCHECK that the constructor and Calculate() are always called on |
| + // the same audio thread. Note that the destructor can be called on a new |
| + // audio thread, this is because the WebRtcAudioCapturer will creates a new |
|
tommi (sloooow) - chröme
2014/03/02 10:19:53
s/creates/create
no longer working on chromium
2014/03/03 13:07:13
The comment has been modified.
|
| + // source with a new audio thread when the format of audio changes. |
|
tommi (sloooow) - chröme
2014/03/02 10:19:53
I think this comment assumes that the reader knows
no longer working on chromium
2014/03/03 13:07:13
No, either the main render thread or the new audio
|
| + base::ThreadChecker thread_checker_; |
| + |
| + int counter_; |
| + int max_amplitude_; |
| + int level_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ |