OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | |
7 | |
8 #include "base/threading/thread_checker.h" | |
9 | |
10 namespace content { | |
11 | |
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 | |
14 // animation UI. | |
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. | |
17 class MediaStreamAudioLevelCalculator { | |
18 public: | |
19 MediaStreamAudioLevelCalculator(); | |
20 ~MediaStreamAudioLevelCalculator(); | |
21 | |
22 // Calculates the signal level of the audio data. | |
23 // Returns the level of bars that the volume animation UI uses for | |
24 // presenting the energy level of the audio data. | |
25 int Calculate(const int16* audio_data, int number_of_channels, | |
26 int number_of_frames); | |
27 | |
28 private: | |
29 // Used to DCHECK that the constructor and Calculate() are always called on | |
30 // the same audio thread. Note that the destructor can be called on a new | |
31 // 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.
| |
32 // 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
| |
33 base::ThreadChecker thread_checker_; | |
34 | |
35 int counter_; | |
36 int max_amplitude_; | |
37 int level_; | |
38 }; | |
39 | |
40 } // namespace content | |
41 | |
42 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | |
OLD | NEW |