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

Side by Side Diff: chrome/browser/media/audio_stream_indicator.h

Issue 14600025: Replace AudioSilenceDetector with an AudioPowerMonitor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use CancelableCallback instead of extra-task for close reply. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/time/time.cc ('k') | chrome/browser/media/audio_stream_indicator.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ 5 #ifndef CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_
6 #define CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ 6 #define CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 12
13 namespace content { 13 namespace content {
14 class WebContents; 14 class WebContents;
15 } 15 }
16 16
17 class AudioStreamIndicator 17 class AudioStreamIndicator
18 : public base::RefCountedThreadSafe<AudioStreamIndicator> { 18 : public base::RefCountedThreadSafe<AudioStreamIndicator> {
19 public: 19 public:
20 AudioStreamIndicator(); 20 AudioStreamIndicator();
21 21
22 // This method should be called on the IO thread. 22 // This method should be called on the IO thread.
23 void UpdateWebContentsStatus(int render_process_id, 23 void UpdateWebContentsStatus(int render_process_id,
24 int render_view_id, 24 int render_view_id,
25 int stream_id, 25 int stream_id,
26 bool is_playing_and_audible); 26 bool is_playing,
27 float power_dbfs,
28 bool clipped);
27 29
28 // This method should be called on the UI thread. 30 // This method should be called on the UI thread.
29 bool IsPlayingAudio(content::WebContents* contents); 31 bool IsPlayingAudio(const content::WebContents* contents);
32
33 // Returns the audible |level| in the range [0.0,1.0], where 0.0 means the
34 // audio signal is imperceivably silent and 1.0 means it is at maximum
35 // volume. |signal_has_clipped| is set to true if any part of the audio
36 // signal has clipped since the last call to this method.
37 //
38 // This method should be called on the UI thread.
39 void CurrentAudibleLevel(const content::WebContents* contents,
40 float* level, bool* signal_has_clipped);
30 41
31 private: 42 private:
32 struct RenderViewId { 43 // <render process ID, render view ID>
33 RenderViewId(int render_process_id, 44 // Note: Using std::pair<> to reduce binary-size bloat.
34 int render_view_id); 45 typedef std::pair<int, int> RenderViewId;
35 46 struct StreamPowerLevel {
36 // Required to use this struct in the std::multiset below. 47 int stream_id;
37 bool operator<(const RenderViewId& other) const; 48 float power_dbfs;
38 49 bool clipped;
39 int render_process_id;
40 int render_view_id;
41 }; 50 };
51 typedef std::vector<StreamPowerLevel> StreamPowerLevels;
52 // Container for the power levels of streams playing from each render view.
53 typedef std::map<RenderViewId, StreamPowerLevels> RenderViewStreamMap;
42 54
43 friend class base::RefCountedThreadSafe<AudioStreamIndicator>; 55 friend class base::RefCountedThreadSafe<AudioStreamIndicator>;
44 virtual ~AudioStreamIndicator(); 56 virtual ~AudioStreamIndicator();
45 57
46 void UpdateWebContentsStatusOnUIThread(int render_process_id, 58 void UpdateWebContentsStatusOnUIThread(int render_process_id,
47 int render_view_id, 59 int render_view_id,
48 int stream_id, 60 int stream_id,
49 bool playing); 61 bool is_playing,
62 float power_dbfs,
63 bool clipped);
50 64
51 // A map from RenderViews to sets of streams playing in them (each RenderView 65 RenderViewStreamMap audio_streams_;
52 // might have more than one stream).
53 std::map<RenderViewId, std::set<int> > audio_streams_;
54 }; 66 };
55 67
56 #endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ 68 #endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_
OLDNEW
« no previous file with comments | « base/time/time.cc ('k') | chrome/browser/media/audio_stream_indicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698