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

Side by Side Diff: content/renderer/media/media_stream_audio_level_calculator.h

Issue 669393002: Merge 661693003 to M39: Avoid reporting 0 as input level when AudioProcessing zero out the audio da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2171
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/media_stream_audio_level_calculator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // |force_report_nonzero_energy| is a flag forcing the calculator to
25 // report nonzero energy even if the energy of the processed audio is zero.
26 // Since |audio_data| is post processed data, and the audio processing might
27 // zero all the audio data, when the caller detects the pre processed data
28 // contain energy, it could pass |force_report_nonzero_energy| as true to
29 // force calculator to report 1 as energy when |audio_data| is all zero.
24 int Calculate(const int16* audio_data, int number_of_channels, 30 int Calculate(const int16* audio_data, int number_of_channels,
25 int number_of_frames); 31 int number_of_frames, bool force_report_nonzero_energy);
26 32
27 private: 33 private:
28 // Used to DCHECK that the constructor and Calculate() are always called on 34 // 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 35 // 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 36 // different thread, which can be either the main render thread or a new
31 // audio thread where WebRtcLocalAudioTrack::OnSetFormat() is called. 37 // audio thread where WebRtcLocalAudioTrack::OnSetFormat() is called.
32 base::ThreadChecker thread_checker_; 38 base::ThreadChecker thread_checker_;
33 39
34 int counter_; 40 int counter_;
35 int max_amplitude_; 41 int max_amplitude_;
36 int level_; 42 int level_;
37 }; 43 };
38 44
39 } // namespace content 45 } // namespace content
40 46
41 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_ 47 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_LEVEL_CALCULATOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/media_stream_audio_level_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698