| 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_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ | 6 #define CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // usually called whenever the tab data model is refreshed; but there are | 47 // usually called whenever the tab data model is refreshed; but there are |
| 48 // other use cases as well (e.g., the OOM killer uses this to de-prioritize | 48 // other use cases as well (e.g., the OOM killer uses this to de-prioritize |
| 49 // the killing of tabs making sounds). | 49 // the killing of tabs making sounds). |
| 50 bool WasRecentlyAudible() const; | 50 bool WasRecentlyAudible() const; |
| 51 | 51 |
| 52 // Returns true if the audio is currently audible from the given WebContents. | 52 // Returns true if the audio is currently audible from the given WebContents. |
| 53 // The difference from WasRecentlyAudible() is that this method will return | 53 // The difference from WasRecentlyAudible() is that this method will return |
| 54 // false as soon as the WebContents stop producing sound. | 54 // false as soon as the WebContents stop producing sound. |
| 55 bool IsCurrentlyAudible() const; | 55 bool IsCurrentlyAudible() const; |
| 56 | 56 |
| 57 // Called by the WebContentsImpl if |render_process_id| dies; used to clear |
| 58 // any outstanding poll callbacks. |
| 59 void RenderProcessGone(int render_process_id); |
| 60 |
| 57 // Starts or stops audio level monitoring respectively for the stream owned by | 61 // Starts or stops audio level monitoring respectively for the stream owned by |
| 58 // the specified renderer. Safe to call from any thread. | 62 // the specified renderer. Safe to call from any thread. |
| 59 // | 63 // |
| 60 // The callback returns the current power level (in dBFS units) and the clip | 64 // The callback returns the current power level (in dBFS units) and the clip |
| 61 // status (true if any part of the audio signal has clipped since the last | 65 // status (true if any part of the audio signal has clipped since the last |
| 62 // callback run). |stream_id| must be unique within a |render_process_id|. | 66 // callback run). |stream_id| must be unique within a |render_process_id|. |
| 63 typedef base::Callback<std::pair<float, bool>()> ReadPowerAndClipCallback; | 67 typedef base::Callback<std::pair<float, bool>()> ReadPowerAndClipCallback; |
| 64 static void StartMonitoringStream( | 68 static void StartMonitoringStream( |
| 65 int render_process_id, | 69 int render_process_id, |
| 66 int render_frame_id, | 70 int render_frame_id, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // Number of active streams to be used as a proxy for audibility when power | 170 // Number of active streams to be used as a proxy for audibility when power |
| 167 // level monitoring is not available. | 171 // level monitoring is not available. |
| 168 size_t active_streams_; | 172 size_t active_streams_; |
| 169 | 173 |
| 170 DISALLOW_COPY_AND_ASSIGN(AudioStreamMonitor); | 174 DISALLOW_COPY_AND_ASSIGN(AudioStreamMonitor); |
| 171 }; | 175 }; |
| 172 | 176 |
| 173 } // namespace content | 177 } // namespace content |
| 174 | 178 |
| 175 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ | 179 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ |
| OLD | NEW |