| 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 class AudioBus; | 13 class AudioBus; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // This class is used by the WebRtcAudioCapturer to calculate the level of the | 18 // This class is used by the WebRtcAudioCapturer to calculate the level of the |
| 19 // audio signal. And the audio level will be eventually used by the volume | 19 // audio signal. And the audio level will be eventually used by the volume |
| 20 // animation UI. | 20 // animation UI. |
| 21 // | 21 // |
| 22 // The algorithm used by this class is the same as how it is done in | 22 // The algorithm used by this class is the same as how it is done in |
| 23 // third_party/webrtc/voice_engine/level_indicator.cc. | 23 // third_party/webrtc/voice_engine/level_indicator.cc. |
| 24 class CONTENT_EXPORT MediaStreamAudioLevelCalculator { | 24 class CONTENT_EXPORT MediaStreamAudioLevelCalculator { |
| 25 public: | 25 public: |
| 26 // Provides thread-safe access to the current signal level. This object is | 26 // Provides thread-safe access to the current signal level. This object is |
| 27 // intended to be passed to modules running on other threads that poll for the | 27 // intended to be passed to modules running on other threads that poll for the |
| 28 // current signal level. | 28 // current signal level. |
| 29 class Level : public base::RefCountedThreadSafe<Level> { | 29 class CONTENT_EXPORT Level : public base::RefCountedThreadSafe<Level> { |
| 30 public: | 30 public: |
| 31 float GetCurrent() const; | 31 float GetCurrent() const; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 friend class MediaStreamAudioLevelCalculator; | 34 friend class MediaStreamAudioLevelCalculator; |
| 35 friend class base::RefCountedThreadSafe<Level>; | 35 friend class base::RefCountedThreadSafe<Level>; |
| 36 | 36 |
| 37 Level(); | 37 Level(); |
| 38 ~Level(); | 38 ~Level(); |
| 39 | 39 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 int counter_; | 58 int counter_; |
| 59 float max_amplitude_; | 59 float max_amplitude_; |
| 60 const scoped_refptr<Level> level_; | 60 const scoped_refptr<Level> level_; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace content | 63 } // namespace content |
| 64 | 64 |
| 65 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ | 65 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ |
| OLD | NEW |