Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.h

Issue 11413078: Tab Audio Capture: Browser-side connect/disconnect functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove WCAudioInputStream changes (split into another change). Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2c82939fc142500e91e0310f8fe9ea503ca5cb6b 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"
@@ -66,11 +67,34 @@ 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> {
DaleCurtis 2012/12/05 23:35:14 Do we really need this to be ref counted?
miu 2012/12/11 02:30:45 Yes. AudioRendererHost operates mainly on the IO
+ 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|. After this method returns, the caller
+ // can safely destroy the callback.
+ virtual void RemoveInput(
+ media::AudioOutputStream::AudioSourceCallback* callback) = 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;
DaleCurtis 2012/12/05 23:35:14 What is a peer_id?
miu 2012/12/11 02:30:45 The process ID (operating system PID?) of the proc
tommi (sloooow) - chröme 2012/12/18 13:41:25 is int32 needed or is int enough?
miu 2012/12/19 00:22:57 The method signature should probably match what's
virtual void OnChannelClosing() OVERRIDE;
virtual void OnDestruct() const OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message,
@@ -83,6 +107,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 +129,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;
tommi (sloooow) - chröme 2012/12/18 13:41:25 can you add a note about AudioRendererHost ownersh
miu 2012/12/19 00:22:57 Done. (in audio_mirroring_manager.h)
virtual ~AudioRendererHost();
@@ -164,12 +202,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);
};

Powered by Google App Engine
This is Rietveld 408576698