Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / media / audio_stream_indicator.h
blob613dc3c5741bdac4bd0dd5c3e31164a4c1f02dcd
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_
6 #define CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_
8 #include <map>
9 #include <vector>
11 #include "base/memory/ref_counted.h"
13 namespace content {
14 class WebContents;
17 class AudioStreamIndicator
18 : public base::RefCountedThreadSafe<AudioStreamIndicator> {
19 public:
20 AudioStreamIndicator();
22 // This method should be called on the IO thread.
23 void UpdateWebContentsStatus(int render_process_id,
24 int render_view_id,
25 int stream_id,
26 bool is_playing,
27 float power_dbfs,
28 bool clipped);
30 // This method should be called on the UI thread.
31 bool IsPlayingAudio(const content::WebContents* contents);
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.
38 // This method should be called on the UI thread.
39 void CurrentAudibleLevel(const content::WebContents* contents,
40 float* level, bool* signal_has_clipped);
42 private:
43 // <render process ID, render view ID>
44 // Note: Using std::pair<> to reduce binary-size bloat.
45 typedef std::pair<int, int> RenderViewId;
46 struct StreamPowerLevel {
47 int stream_id;
48 float power_dbfs;
49 bool clipped;
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;
55 friend class base::RefCountedThreadSafe<AudioStreamIndicator>;
56 virtual ~AudioStreamIndicator();
58 void UpdateWebContentsStatusOnUIThread(int render_process_id,
59 int render_view_id,
60 int stream_id,
61 bool is_playing,
62 float power_dbfs,
63 bool clipped);
65 RenderViewStreamMap audio_streams_;
68 #endif // CHROME_BROWSER_MEDIA_AUDIO_STREAM_INDICATOR_H_