Chromium Code Reviews| Index: content/browser/renderer_host/media/audio_renderer_host.h |
| diff --git a/content/browser/renderer_host/media/audio_renderer_host.h b/content/browser/renderer_host/media/audio_renderer_host.h |
| index 43e9395ac50ff90293b55f24cda1c8a1e59c78cf..5853f9d2457474554af9ea2d0b6f316f9edd4922 100644 |
| --- a/content/browser/renderer_host/media/audio_renderer_host.h |
| +++ b/content/browser/renderer_host/media/audio_renderer_host.h |
| @@ -40,6 +40,7 @@ |
| #include <map> |
| #include "base/gtest_prod_util.h" |
| +#include "base/lazy_instance.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/process.h" |
| @@ -61,16 +62,19 @@ namespace content { |
| class MediaObserver; |
| class ResourceContext; |
| +class WebContentsAudioInputStream; |
| class CONTENT_EXPORT AudioRendererHost |
| : public BrowserMessageFilter, |
| public media::AudioOutputController::EventHandler { |
| public: |
| // Called from UI thread from the owner of this object. |
| - AudioRendererHost(media::AudioManager* audio_manager, |
| + AudioRendererHost(int render_process_id, |
| + media::AudioManager* audio_manager, |
| MediaObserver* media_observer); |
| // BrowserMessageFilter implementation. |
| + virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| virtual void OnChannelClosing() OVERRIDE; |
| virtual void OnDestruct() const OVERRIDE; |
| virtual bool OnMessageReceived(const IPC::Message& message, |
| @@ -83,6 +87,19 @@ class CONTENT_EXPORT AudioRendererHost |
| virtual void OnError(media::AudioOutputController* controller, |
| int error_code) OVERRIDE; |
| + // Start/stop mirroring all audio output streams associated with |
| + // |render_process_id| + |render_view_id| to |destination|. Any call to |
| + // StartMirroring() must be paired with a later call to StopMirroring() since |
| + // references are held to both the AudioRendererHost and |
|
Alpha Left Google
2012/11/28 20:02:25
Can we not hold reference to AudioRendererHost?
miu
2012/11/28 22:05:50
Done.
|
| + // WebContentsAudioInputStream instances while the mirroring session is |
| + // active. |
| + static void StartMirroring( |
|
Alpha Left Google
2012/11/28 20:02:25
It seems to me these two methods are called on the
|
| + int render_process_id, int render_view_id, |
| + const scoped_refptr<WebContentsAudioInputStream>& destination); |
| + static void StopMirroring( |
| + int render_process_id, int render_view_id, |
| + const scoped_refptr<WebContentsAudioInputStream>& destination); |
| + |
| private: |
| friend class AudioRendererHostTest; |
| friend class BrowserThread; |
| @@ -93,6 +110,9 @@ class CONTENT_EXPORT AudioRendererHost |
| struct AudioEntry; |
| typedef std::map<int, AudioEntry*> AudioEntryMap; |
| + typedef std::map<int, scoped_refptr<WebContentsAudioInputStream> > |
| + MirrorSessionMap; |
| + typedef std::map<int, scoped_refptr<AudioRendererHost> > ActiveHostMap; |
|
Alpha Left Google
2012/11/28 20:02:25
Don't use scoped_refptr, just a * is enough. I sug
miu
2012/11/28 22:05:50
Done.
Not sure what you meant about the asserts.
|
| virtual ~AudioRendererHost(); |
| @@ -106,6 +126,10 @@ class CONTENT_EXPORT AudioRendererHost |
| const media::AudioParameters& params, |
| int input_channels); |
| + // Associate |render_view_id| as the producer of audio for the stream |
| + // referenced by |stream_id|. |
| + void OnAssociateStreamWithProducer(int stream_id, int render_view_id); |
| + |
| // Play the audio stream referenced by |stream_id|. |
| void OnPlayStream(int stream_id); |
| @@ -160,12 +184,35 @@ class CONTENT_EXPORT AudioRendererHost |
| media::AudioOutputController* LookupControllerByIdForTesting(int stream_id); |
| + // Global look-up for the AudioRendererHost instance owned by the |
| + // RenderProcessHost specified by |render_process_id|. |
| + static AudioRendererHost* FromRenderProcessID(int render_process_id); |
| + |
| + // Implementations for StartMirroring() and StopMirroring() that are run on |
| + // the IO BrowserThread. |
| + static void DoStartMirroring( |
| + int render_process_id, int render_view_id, |
| + const scoped_refptr<WebContentsAudioInputStream>& destination); |
| + static void DoStopMirroring( |
| + int render_process_id, int render_view_id, |
| + const scoped_refptr<WebContentsAudioInputStream>& destination); |
| + |
| + // ID of the RenderProcessHost that owns this instance. |
| + const int render_process_id_; |
| + |
| // A map of stream IDs to audio sources. |
| AudioEntryMap audio_entries_; |
| + // A map of render view IDs to the destination for active mirroring sessions. |
| + MirrorSessionMap mirror_sessions_; |
| + |
| media::AudioManager* audio_manager_; |
| MediaObserver* media_observer_; |
| + // Global look-up map for currently-active (i.e., IPC channel is open) |
| + // AudioRendererHosts. |
| + static base::LazyInstance<ActiveHostMap>::Leaky g_host_map_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
| }; |