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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host.h

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 6 months 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
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 20 matching lines...) Expand all
31 // | ... | 31 // | ... |
32 // | CloseStream > | 32 // | CloseStream > |
33 // v v 33 // v v
34 34
35 // A SyncSocket pair is used to signal buffer readiness between processes. 35 // A SyncSocket pair is used to signal buffer readiness between processes.
36 36
37 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ 37 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_
38 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ 38 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_
39 39
40 #include <map> 40 #include <map>
41 #include <string>
41 42
42 #include "base/atomic_ref_count.h" 43 #include "base/atomic_ref_count.h"
43 #include "base/gtest_prod_util.h" 44 #include "base/gtest_prod_util.h"
44 #include "base/memory/ref_counted.h" 45 #include "base/memory/ref_counted.h"
45 #include "base/memory/scoped_ptr.h" 46 #include "base/memory/scoped_ptr.h"
46 #include "base/process/process.h" 47 #include "base/process/process.h"
47 #include "base/sequenced_task_runner_helpers.h" 48 #include "base/sequenced_task_runner_helpers.h"
48 #include "content/common/content_export.h" 49 #include "content/common/content_export.h"
49 #include "content/public/browser/browser_message_filter.h" 50 #include "content/public/browser/browser_message_filter.h"
50 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/render_process_host.h" 52 #include "content/public/browser/render_process_host.h"
53 #include "content/public/browser/resource_context.h"
52 #include "media/audio/audio_io.h" 54 #include "media/audio/audio_io.h"
53 #include "media/audio/audio_logging.h" 55 #include "media/audio/audio_logging.h"
54 #include "media/audio/audio_output_controller.h" 56 #include "media/audio/audio_output_controller.h"
55 #include "media/audio/simple_sources.h" 57 #include "media/audio/simple_sources.h"
56 58
57 namespace media { 59 namespace media {
58 class AudioManager; 60 class AudioManager;
59 class AudioParameters; 61 class AudioParameters;
60 } 62 }
61 63
62 namespace content { 64 namespace content {
63 65
64 class AudioMirroringManager; 66 class AudioMirroringManager;
65 class MediaInternals; 67 class MediaInternals;
66 class MediaStreamManager; 68 class MediaStreamManager;
69 class MediaStreamUIProxy;
67 class ResourceContext; 70 class ResourceContext;
68 71
69 class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { 72 class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
70 public: 73 public:
71 // Called from UI thread from the owner of this object. 74 // Called from UI thread from the owner of this object.
72 AudioRendererHost(int render_process_id, 75 AudioRendererHost(int render_process_id,
73 media::AudioManager* audio_manager, 76 media::AudioManager* audio_manager,
74 AudioMirroringManager* mirroring_manager, 77 AudioMirroringManager* mirroring_manager,
75 MediaInternals* media_internals, 78 MediaInternals* media_internals,
76 MediaStreamManager* media_stream_manager); 79 MediaStreamManager* media_stream_manager,
80 const ResourceContext::SaltCallback& salt_callback);
77 81
78 // Calls |callback| with the list of AudioOutputControllers for this object. 82 // Calls |callback| with the list of AudioOutputControllers for this object.
79 void GetOutputControllers( 83 void GetOutputControllers(
80 const RenderProcessHost::GetAudioOutputControllersCallback& 84 const RenderProcessHost::GetAudioOutputControllersCallback&
81 callback) const; 85 callback) const;
82 86
83 // BrowserMessageFilter implementation. 87 // BrowserMessageFilter implementation.
84 void OnChannelClosing() override; 88 void OnChannelClosing() override;
85 void OnDestruct() const override; 89 void OnDestruct() const override;
86 bool OnMessageReceived(const IPC::Message& message) override; 90 bool OnMessageReceived(const IPC::Message& message) override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 132
129 // Pause the audio stream referenced by |stream_id|. 133 // Pause the audio stream referenced by |stream_id|.
130 void OnPauseStream(int stream_id); 134 void OnPauseStream(int stream_id);
131 135
132 // Close the audio stream referenced by |stream_id|. 136 // Close the audio stream referenced by |stream_id|.
133 void OnCloseStream(int stream_id); 137 void OnCloseStream(int stream_id);
134 138
135 // Set the volume of the audio stream referenced by |stream_id|. 139 // Set the volume of the audio stream referenced by |stream_id|.
136 void OnSetVolume(int stream_id, double volume); 140 void OnSetVolume(int stream_id, double volume);
137 141
142 // Set the output device of the audio stream referenced by |stream_id|.
143 void OnSwitchOutputDevice(int stream_id,
144 const std::string& device_id,
145 const GURL& security_origin,
146 int render_frame_id,
147 int request_id);
148
149 void OutputDeviceAccessChecked(scoped_ptr<MediaStreamUIProxy> ui_proxy,
150 int stream_id,
151 const std::string& device_id,
152 const GURL& security_origin,
153 int render_frame_id,
154 int request_id,
155 bool have_access);
156
157 void StartTranslateOutputDeviceName(int stream_id,
158 const std::string& device_id,
159 const GURL& security_origin,
160 int request_id);
161
162 void FinishTranslateOutputDeviceName(int stream_id,
163 const std::string& device_id,
164 const GURL& security_origin,
165 int request_id,
166 media::AudioDeviceNames*);
167
168 void DoSwitchOutputDevice(int stream_id,
169 const std::string& raw_device_id,
170 int request_id);
171
172 void DoOutputDeviceSwitched(int stream_id, int request_id);
173
138 // Complete the process of creating an audio stream. This will set up the 174 // Complete the process of creating an audio stream. This will set up the
139 // shared memory or shared socket in low latency mode and send the 175 // shared memory or shared socket in low latency mode and send the
140 // NotifyStreamCreated message to the peer. 176 // NotifyStreamCreated message to the peer.
141 void DoCompleteCreation(int stream_id); 177 void DoCompleteCreation(int stream_id);
142 178
143 // Send playing/paused status to the renderer. 179 // Send playing/paused status to the renderer.
144 void DoNotifyStreamStateChanged(int stream_id, bool is_playing); 180 void DoNotifyStreamStateChanged(int stream_id, bool is_playing);
145 181
146 RenderProcessHost::AudioOutputControllerList DoGetOutputControllers() const; 182 RenderProcessHost::AudioOutputControllerList DoGetOutputControllers() const;
147 183
(...skipping 24 matching lines...) Expand all
172 208
173 // Used to access to AudioInputDeviceManager. 209 // Used to access to AudioInputDeviceManager.
174 MediaStreamManager* media_stream_manager_; 210 MediaStreamManager* media_stream_manager_;
175 211
176 // A map of stream IDs to audio sources. 212 // A map of stream IDs to audio sources.
177 AudioEntryMap audio_entries_; 213 AudioEntryMap audio_entries_;
178 214
179 // The number of streams in the playing state. 215 // The number of streams in the playing state.
180 base::AtomicRefCount num_playing_streams_; 216 base::AtomicRefCount num_playing_streams_;
181 217
218 // Salt required to translate renderer device IDs to raw device IDs
219 ResourceContext::SaltCallback salt_callback_;
220
182 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); 221 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
183 }; 222 };
184 223
185 } // namespace content 224 } // namespace content
186 225
187 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ 226 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698