Index: chrome/browser/media/audio_stream_indicator.h |
diff --git a/chrome/browser/media/audio_stream_indicator.h b/chrome/browser/media/audio_stream_indicator.h |
index 2ce504e4cf67942859f1a1b6e08f7604a2516c6a..7e1abd2a1f6a94ca4599d98f6031b426ed250cfc 100644 |
--- a/chrome/browser/media/audio_stream_indicator.h |
+++ b/chrome/browser/media/audio_stream_indicator.h |
@@ -6,7 +6,6 @@ |
#define CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |
#include <map> |
-#include <set> |
#include "base/memory/ref_counted.h" |
@@ -23,34 +22,58 @@ class AudioStreamIndicator |
void UpdateWebContentsStatus(int render_process_id, |
int render_view_id, |
int stream_id, |
- bool is_playing_and_audible); |
+ bool is_playing, |
+ float power_dBFS, |
DaleCurtis
2013/07/02 22:26:34
Style should be all lowercase I think.
miu
2013/07/09 00:59:56
Done.
|
+ bool clipped); |
// This method should be called on the UI thread. |
- bool IsPlayingAudio(content::WebContents* contents); |
+ bool IsPlayingAudio(const content::WebContents* contents); |
+ |
+ // Returns the audible |level| in the range [0.0,1.0], where 0.0 means the |
+ // audio signal is imperceivably silent and 1.0 means it is at maximum |
+ // volume. |signal_has_clipped| is set to true if any part of the audio |
+ // signal has clipped since the last call to this method. |
+ // |
+ // This method should be called on the UI thread. |
+ // |
+ // TODO(miu): Consider replacing this "pull" API with an event-driven "push" |
+ // API. |
+ void CurrentAudibleLevel(const content::WebContents* contents, |
+ float* level, bool* signal_has_clipped); |
private: |
struct RenderViewId { |
DaleCurtis
2013/07/02 22:26:34
If you just use std::pair<int, int> you can avoid
miu
2013/07/09 00:59:56
Done.
I absolutely agree. There was a past discu
|
RenderViewId(int render_process_id, |
int render_view_id); |
- // Required to use this struct in the std::multiset below. |
+ // Required to use this struct in the std::map below. |
bool operator<(const RenderViewId& other) const; |
int render_process_id; |
int render_view_id; |
}; |
+ struct SignalPower { |
+ float power_dBFS; |
+ bool clipped; |
+ }; |
+ |
friend class base::RefCountedThreadSafe<AudioStreamIndicator>; |
virtual ~AudioStreamIndicator(); |
void UpdateWebContentsStatusOnUIThread(int render_process_id, |
int render_view_id, |
int stream_id, |
- bool playing); |
+ bool is_playing, |
+ float power_dBFS, |
+ bool clipped); |
- // A map from RenderViews to sets of streams playing in them (each RenderView |
- // might have more than one stream). |
- std::map<RenderViewId, std::set<int> > audio_streams_; |
+ // A map from RenderViews to the streams playing in them (each RenderView |
+ // might have more than one stream). An inner map associates each stream with |
+ // its last-known power level. |
+ typedef std::map<int, SignalPower> StreamPowerLevelMap; |
DaleCurtis
2013/07/02 22:26:34
About how many streams/renderview are we expecting
miu
2013/07/09 00:59:56
Took your advice on eliminating the nested map sin
|
+ typedef std::map<RenderViewId, StreamPowerLevelMap> RenderViewStreamMap; |
+ RenderViewStreamMap audio_streams_; |
}; |
#endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_ |