| 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 44daef21f836cf0ee8da944de1d83fab60b04799..a7d3802f02353d5d18585f2d2ca46c54fe5d40da 100644
|
| --- a/content/browser/renderer_host/media/audio_renderer_host.h
|
| +++ b/content/browser/renderer_host/media/audio_renderer_host.h
|
| @@ -39,7 +39,9 @@
|
|
|
| #include <map>
|
|
|
| +#include "base/callback_forward.h"
|
| #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"
|
| @@ -66,11 +68,35 @@ class CONTENT_EXPORT AudioRendererHost
|
| : public BrowserMessageFilter,
|
| public media::AudioOutputController::EventHandler {
|
| public:
|
| + // Interface to be implemented by audio mirroring destinations. See
|
| + // comments for StartMirroring() and StopMirroring() below.
|
| + class MirroringDestination
|
| + : public base::RefCountedThreadSafe<MirroringDestination> {
|
| + public:
|
| + // Begin pulling data from |callback|, which is providing data in the format
|
| + // specified by |params|.
|
| + virtual void AddInput(
|
| + media::AudioOutputStream::AudioSourceCallback* callback,
|
| + const media::AudioParameters& params) = 0;
|
| +
|
| + // Stop pulling data from |callback|. |done| is run once the caller can
|
| + // safely destroy the callback.
|
| + virtual void RemoveInput(
|
| + media::AudioOutputStream::AudioSourceCallback* callback,
|
| + const base::Closure& done) = 0;
|
| +
|
| + protected:
|
| + friend class base::RefCountedThreadSafe<MirroringDestination>;
|
| + virtual ~MirroringDestination();
|
| + };
|
| +
|
| // 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 +109,18 @@ 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
|
| + // a reference is held on the MirroringDestination while the mirroring session
|
| + // is active.
|
| + static void StartMirroring(
|
| + int render_process_id, int render_view_id,
|
| + const scoped_refptr<MirroringDestination>& destination);
|
| + static void StopMirroring(
|
| + int render_process_id, int render_view_id,
|
| + const scoped_refptr<MirroringDestination>& destination);
|
| +
|
| private:
|
| friend class AudioRendererHostTest;
|
| friend class BrowserThread;
|
| @@ -93,6 +131,8 @@ class CONTENT_EXPORT AudioRendererHost
|
|
|
| struct AudioEntry;
|
| typedef std::map<int, AudioEntry*> AudioEntryMap;
|
| + typedef std::map<int, scoped_refptr<MirroringDestination> > MirrorSessionMap;
|
| + typedef std::map<int, AudioRendererHost*> ActiveHostMap;
|
|
|
| virtual ~AudioRendererHost();
|
|
|
| @@ -164,12 +204,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<MirroringDestination>& destination);
|
| + static void DoStopMirroring(
|
| + int render_process_id, int render_view_id,
|
| + const scoped_refptr<MirroringDestination>& 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);
|
| };
|
|
|
|
|