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

Side by Side 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: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 // AudioRendererHost serves audio related requests from AudioRenderer which 5 // AudioRendererHost serves audio related requests from AudioRenderer which
6 // lives inside the render process and provide access to audio hardware. 6 // lives inside the render process and provide access to audio hardware.
7 // 7 //
8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI
9 // thread, but all other operations and method calls happen on IO thread, so we 9 // thread, but all other operations and method calls happen on IO thread, so we
10 // need to be extra careful about the lifetime of this object. AudioManager is a 10 // need to be extra careful about the lifetime of this object. AudioManager is a
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 namespace media { 55 namespace media {
56 class AudioManager; 56 class AudioManager;
57 class AudioParameters; 57 class AudioParameters;
58 } 58 }
59 59
60 namespace content { 60 namespace content {
61 61
62 class MediaObserver; 62 class MediaObserver;
63 class ResourceContext; 63 class ResourceContext;
64 class WebContentsAudioInputStream;
64 65
65 class CONTENT_EXPORT AudioRendererHost 66 class CONTENT_EXPORT AudioRendererHost
66 : public BrowserMessageFilter, 67 : public BrowserMessageFilter,
67 public media::AudioOutputController::EventHandler { 68 public media::AudioOutputController::EventHandler {
68 public: 69 public:
69 // Called from UI thread from the owner of this object. 70 // Called from UI thread from the owner of this object.
70 AudioRendererHost(media::AudioManager* audio_manager, 71 AudioRendererHost(int render_process_id,
72 media::AudioManager* audio_manager,
71 MediaObserver* media_observer); 73 MediaObserver* media_observer);
72 74
73 // BrowserMessageFilter implementation. 75 // BrowserMessageFilter implementation.
74 virtual void OnChannelClosing() OVERRIDE; 76 virtual void OnChannelClosing() OVERRIDE;
75 virtual void OnDestruct() const OVERRIDE; 77 virtual void OnDestruct() const OVERRIDE;
76 virtual bool OnMessageReceived(const IPC::Message& message, 78 virtual bool OnMessageReceived(const IPC::Message& message,
77 bool* message_was_ok) OVERRIDE; 79 bool* message_was_ok) OVERRIDE;
78 80
79 // AudioOutputController::EventHandler implementations. 81 // AudioOutputController::EventHandler implementations.
80 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE; 82 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE;
81 virtual void OnPlaying(media::AudioOutputController* controller) OVERRIDE; 83 virtual void OnPlaying(media::AudioOutputController* controller) OVERRIDE;
82 virtual void OnPaused(media::AudioOutputController* controller) OVERRIDE; 84 virtual void OnPaused(media::AudioOutputController* controller) OVERRIDE;
83 virtual void OnError(media::AudioOutputController* controller, 85 virtual void OnError(media::AudioOutputController* controller,
84 int error_code) OVERRIDE; 86 int error_code) OVERRIDE;
85 87
88 // Start/stop mirroring all audio output streams associated with
89 // |render_view_id| to |destination|.
90 void StartMirroring(int render_view_id,
91 WebContentsAudioInputStream* destination);
92 void StopMirroring(int render_view_id,
Alpha Left Google 2012/11/20 21:49:43 Does a destination associate with multiple render
miu 2012/11/21 08:27:48 I thought about this, and I don't think I needed t
93 WebContentsAudioInputStream* destination);
94
95 // Return the AudioRendererHost instance for a render process.
96 static scoped_refptr<AudioRendererHost> FromRenderProcessID(
97 int render_process_id);
98
86 private: 99 private:
87 friend class AudioRendererHostTest; 100 friend class AudioRendererHostTest;
88 friend class BrowserThread; 101 friend class BrowserThread;
89 friend class base::DeleteHelper<AudioRendererHost>; 102 friend class base::DeleteHelper<AudioRendererHost>;
90 friend class MockAudioRendererHost; 103 friend class MockAudioRendererHost;
91 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); 104 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream);
92 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); 105 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation);
93 106
94 struct AudioEntry; 107 struct AudioEntry;
95 typedef std::map<int, AudioEntry*> AudioEntryMap; 108 typedef std::map<int, AudioEntry*> AudioEntryMap;
96 109
110 typedef std::map<int, WebContentsAudioInputStream*> MirrorSessionMap;
111
97 virtual ~AudioRendererHost(); 112 virtual ~AudioRendererHost();
98 113
99 // Methods called on IO thread ---------------------------------------------- 114 // Methods called on IO thread ----------------------------------------------
100 115
101 // Audio related IPC message handlers. 116 // Audio related IPC message handlers.
102 // Creates an audio output stream with the specified format. If this call is 117 // Creates an audio output stream with the specified format. If this call is
103 // successful this object would keep an internal entry of the stream for the 118 // successful this object would keep an internal entry of the stream for the
104 // required properties. 119 // required properties.
105 void OnCreateStream(int stream_id, 120 void OnCreateStream(int stream_id,
106 const media::AudioParameters& params, 121 const media::AudioParameters& params,
107 int input_channels); 122 int input_channels);
108 123
124 // Associate |render_view_id| as the producer of audio for the stream
125 // referenced by |stream_id|.
126 void OnAssociateStreamWithProducer(int stream_id, int render_view_id);
127
109 // Play the audio stream referenced by |stream_id|. 128 // Play the audio stream referenced by |stream_id|.
110 void OnPlayStream(int stream_id); 129 void OnPlayStream(int stream_id);
111 130
112 // Pause the audio stream referenced by |stream_id|. 131 // Pause the audio stream referenced by |stream_id|.
113 void OnPauseStream(int stream_id); 132 void OnPauseStream(int stream_id);
114 133
115 // Discard all audio data in stream referenced by |stream_id|. 134 // Discard all audio data in stream referenced by |stream_id|.
116 void OnFlushStream(int stream_id); 135 void OnFlushStream(int stream_id);
117 136
118 // Close the audio stream referenced by |stream_id|. 137 // Close the audio stream referenced by |stream_id|.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Returns NULL if not found. 172 // Returns NULL if not found.
154 AudioEntry* LookupById(int stream_id); 173 AudioEntry* LookupById(int stream_id);
155 174
156 // Search for a AudioEntry having the reference to |controller|. 175 // Search for a AudioEntry having the reference to |controller|.
157 // This method is used to look up an AudioEntry after a controller 176 // This method is used to look up an AudioEntry after a controller
158 // event is received. 177 // event is received.
159 AudioEntry* LookupByController(media::AudioOutputController* controller); 178 AudioEntry* LookupByController(media::AudioOutputController* controller);
160 179
161 media::AudioOutputController* LookupControllerByIdForTesting(int stream_id); 180 media::AudioOutputController* LookupControllerByIdForTesting(int stream_id);
162 181
182 // ID of the RenderProcessImpl that owns this instance.
183 const int render_process_id_;
184
163 // A map of stream IDs to audio sources. 185 // A map of stream IDs to audio sources.
164 AudioEntryMap audio_entries_; 186 AudioEntryMap audio_entries_;
165 187
188 // A map of render view IDs to the destination for active mirroring sessions.
189 MirrorSessionMap mirror_sessions_;
190
166 media::AudioManager* audio_manager_; 191 media::AudioManager* audio_manager_;
167 MediaObserver* media_observer_; 192 MediaObserver* media_observer_;
168 193
169 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); 194 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
170 }; 195 };
171 196
172 } // namespace content 197 } // namespace content
173 198
174 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ 199 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698