OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ |
7 | 7 |
8 #include "base/threading/thread_checker.h" | 8 #include "base/threading/thread_checker.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 // This class is used by the WebRtcLocalAudioTrack to calculate the level of | 12 // This class is used by the WebRtcLocalAudioTrack to calculate the level of |
13 // the audio signal. And the audio level will be eventually used by the volume | 13 // the audio signal. And the audio level will be eventually used by the volume |
14 // animation UI. | 14 // animation UI. |
15 // The algorithm used by this class is the same as how it is done in | 15 // The algorithm used by this class is the same as how it is done in |
16 // third_party/webrtc/voice_engine/level_indicator.cc. | 16 // third_party/webrtc/voice_engine/level_indicator.cc. |
17 class MediaStreamAudioLevelCalculator { | 17 class MediaStreamAudioLevelCalculator { |
18 public: | 18 public: |
19 MediaStreamAudioLevelCalculator(); | 19 MediaStreamAudioLevelCalculator(); |
20 ~MediaStreamAudioLevelCalculator(); | 20 ~MediaStreamAudioLevelCalculator(); |
21 | 21 |
22 // Calculates the signal level of the audio data. | 22 // Calculates the signal level of the audio data. |
23 // Returns the absolute value of the amplitude of the signal. | 23 // Returns the absolute value of the amplitude of the signal. |
24 int Calculate(const int16* audio_data, int number_of_channels, | 24 int Calculate(const int16* audio_data, int number_of_channels, |
25 int number_of_frames); | 25 int number_of_frames, bool has_energy); |
tommi (sloooow) - chröme
2014/10/17 11:59:08
can you add documentation for the new parameter?
no longer working on chromium
2014/10/20 08:08:42
All done, please take a look.
Thanks.
| |
26 | 26 |
27 private: | 27 private: |
28 // Used to DCHECK that the constructor and Calculate() are always called on | 28 // Used to DCHECK that the constructor and Calculate() are always called on |
29 // the same audio thread. Note that the destructor will be called on a | 29 // the same audio thread. Note that the destructor will be called on a |
30 // different thread, which can be either the main render thread or a new | 30 // different thread, which can be either the main render thread or a new |
31 // audio thread where WebRtcLocalAudioTrack::OnSetFormat() is called. | 31 // audio thread where WebRtcLocalAudioTrack::OnSetFormat() is called. |
32 base::ThreadChecker thread_checker_; | 32 base::ThreadChecker thread_checker_; |
33 | 33 |
34 int counter_; | 34 int counter_; |
35 int max_amplitude_; | 35 int max_amplitude_; |
36 int level_; | 36 int level_; |
37 }; | 37 }; |
38 | 38 |
39 } // namespace content | 39 } // namespace content |
40 | 40 |
41 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | 41 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ |
OLD | NEW |