OLD | NEW |
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 RenderProcessHostImpl, and instantiated on UI | 8 // This class is owned by RenderProcessHostImpl, 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 29 matching lines...) Expand all Loading... |
40 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 40 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
41 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 41 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
42 | 42 |
43 #include <map> | 43 #include <map> |
44 #include <memory> | 44 #include <memory> |
45 #include <string> | 45 #include <string> |
46 #include <utility> | 46 #include <utility> |
47 #include <vector> | 47 #include <vector> |
48 | 48 |
49 #include "content/browser/renderer_host/media/audio_output_authorization_handler
.h" | 49 #include "content/browser/renderer_host/media/audio_output_authorization_handler
.h" |
50 #include "content/browser/renderer_host/media/audio_output_delegate.h" | |
51 #include "content/common/content_export.h" | 50 #include "content/common/content_export.h" |
52 #include "content/public/browser/browser_message_filter.h" | 51 #include "content/public/browser/browser_message_filter.h" |
53 #include "content/public/browser/render_process_host.h" | 52 #include "content/public/browser/render_process_host.h" |
| 53 #include "media/audio/audio_output_delegate.h" |
54 | 54 |
55 namespace base { | 55 namespace base { |
56 class SharedMemory; | 56 class SharedMemory; |
57 class CancelableSyncSocket; | 57 class CancelableSyncSocket; |
58 } | 58 } |
59 | 59 |
60 namespace media { | 60 namespace media { |
61 class AudioManager; | 61 class AudioManager; |
62 class AudioParameters; | 62 class AudioParameters; |
63 } | 63 } |
64 | 64 |
65 namespace content { | 65 namespace content { |
66 | 66 |
67 class AudioMirroringManager; | 67 class AudioMirroringManager; |
68 class MediaStreamManager; | 68 class MediaStreamManager; |
69 | 69 |
70 class CONTENT_EXPORT AudioRendererHost | 70 class CONTENT_EXPORT AudioRendererHost |
71 : public BrowserMessageFilter, | 71 : public BrowserMessageFilter, |
72 public AudioOutputDelegate::EventHandler { | 72 public media::AudioOutputDelegate::EventHandler { |
73 public: | 73 public: |
74 // Called from UI thread from the owner of this object. | 74 // Called from UI thread from the owner of this object. |
75 AudioRendererHost(int render_process_id, | 75 AudioRendererHost(int render_process_id, |
76 media::AudioManager* audio_manager, | 76 media::AudioManager* audio_manager, |
77 AudioMirroringManager* mirroring_manager, | 77 AudioMirroringManager* mirroring_manager, |
78 MediaStreamManager* media_stream_manager, | 78 MediaStreamManager* media_stream_manager, |
79 const std::string& salt); | 79 const std::string& salt); |
80 | 80 |
81 // Calls |callback| with the list of AudioOutputControllers for this object. | 81 // Calls |callback| with the list of AudioOutputControllers for this object. |
82 void GetOutputControllers( | 82 void GetOutputControllers( |
(...skipping 20 matching lines...) Expand all Loading... |
103 friend class MockAudioRendererHost; | 103 friend class MockAudioRendererHost; |
104 friend class TestAudioRendererHost; | 104 friend class TestAudioRendererHost; |
105 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); | 105 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); |
106 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); | 106 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); |
107 | 107 |
108 // Internal callback type for access requests to output devices. | 108 // Internal callback type for access requests to output devices. |
109 // |have_access| is true only if there is permission to access the device. | 109 // |have_access| is true only if there is permission to access the device. |
110 typedef base::Callback<void(bool have_access)> OutputDeviceAccessCB; | 110 typedef base::Callback<void(bool have_access)> OutputDeviceAccessCB; |
111 | 111 |
112 using AudioOutputDelegateVector = | 112 using AudioOutputDelegateVector = |
113 std::vector<std::unique_ptr<AudioOutputDelegate>>; | 113 std::vector<std::unique_ptr<media::AudioOutputDelegate>>; |
114 | 114 |
115 // The type of a function that is run on the UI thread to check whether the | 115 // The type of a function that is run on the UI thread to check whether the |
116 // routing IDs reference a valid RenderFrameHost. The function then runs | 116 // routing IDs reference a valid RenderFrameHost. The function then runs |
117 // |callback| on the IO thread with true/false if valid/invalid. | 117 // |callback| on the IO thread with true/false if valid/invalid. |
118 using ValidateRenderFrameIdFunction = | 118 using ValidateRenderFrameIdFunction = |
119 void (*)(int render_process_id, | 119 void (*)(int render_process_id, |
120 int render_frame_id, | 120 int render_frame_id, |
121 const base::Callback<void(bool)>& callback); | 121 const base::Callback<void(bool)>& callback); |
122 | 122 |
123 ~AudioRendererHost() override; | 123 ~AudioRendererHost() override; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 RenderProcessHost::AudioOutputControllerList DoGetOutputControllers() const; | 180 RenderProcessHost::AudioOutputControllerList DoGetOutputControllers() const; |
181 | 181 |
182 // Send an error message to the renderer. | 182 // Send an error message to the renderer. |
183 void SendErrorMessage(int stream_id); | 183 void SendErrorMessage(int stream_id); |
184 | 184 |
185 // Helper methods to look up a AudioOutputDelegate identified by |stream_id|. | 185 // Helper methods to look up a AudioOutputDelegate identified by |stream_id|. |
186 // Returns delegates_.end() if not found. | 186 // Returns delegates_.end() if not found. |
187 AudioOutputDelegateVector::iterator LookupIteratorById(int stream_id); | 187 AudioOutputDelegateVector::iterator LookupIteratorById(int stream_id); |
188 // Returns nullptr if not found. | 188 // Returns nullptr if not found. |
189 AudioOutputDelegate* LookupById(int stream_id); | 189 media::AudioOutputDelegate* LookupById(int stream_id); |
190 | 190 |
191 // Helper method to check if the authorization procedure for stream | 191 // Helper method to check if the authorization procedure for stream |
192 // |stream_id| has started. | 192 // |stream_id| has started. |
193 bool IsAuthorizationStarted(int stream_id); | 193 bool IsAuthorizationStarted(int stream_id); |
194 | 194 |
195 // Called from AudioRendererHostTest to override the function that checks for | 195 // Called from AudioRendererHostTest to override the function that checks for |
196 // the existence of the RenderFrameHost at stream creation time. | 196 // the existence of the RenderFrameHost at stream creation time. |
197 void set_render_frame_id_validate_function_for_testing( | 197 void set_render_frame_id_validate_function_for_testing( |
198 ValidateRenderFrameIdFunction function) { | 198 ValidateRenderFrameIdFunction function) { |
199 validate_render_frame_id_function_ = function; | 199 validate_render_frame_id_function_ = function; |
(...skipping 26 matching lines...) Expand all Loading... |
226 ValidateRenderFrameIdFunction validate_render_frame_id_function_; | 226 ValidateRenderFrameIdFunction validate_render_frame_id_function_; |
227 | 227 |
228 AudioOutputAuthorizationHandler authorization_handler_; | 228 AudioOutputAuthorizationHandler authorization_handler_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 230 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace content | 233 } // namespace content |
234 | 234 |
235 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 235 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |