| 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 // AudioInputRendererHost serves audio related requests from audio capturer | 5 // AudioInputRendererHost serves audio related requests from audio capturer |
| 6 // which lives inside the render process and provide access to audio hardware. | 6 // which lives inside the render process and provide access to audio hardware. |
| 7 // | 7 // |
| 8 // Create stream sequence (AudioInputController = AIC): | 8 // Create stream sequence (AudioInputController = AIC): |
| 9 // | 9 // |
| 10 // AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency -> | 10 // AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency -> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 25 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
| 26 | 26 |
| 27 #include <map> | 27 #include <map> |
| 28 #include <string> | 28 #include <string> |
| 29 | 29 |
| 30 #include "base/compiler_specific.h" | 30 #include "base/compiler_specific.h" |
| 31 #include "base/gtest_prod_util.h" | 31 #include "base/gtest_prod_util.h" |
| 32 #include "base/memory/ref_counted.h" | 32 #include "base/memory/ref_counted.h" |
| 33 #include "base/memory/scoped_ptr.h" | 33 #include "base/memory/scoped_ptr.h" |
| 34 #include "base/memory/shared_memory.h" | 34 #include "base/memory/shared_memory.h" |
| 35 #include "base/memory/weak_ptr.h" |
| 35 #include "base/process/process.h" | 36 #include "base/process/process.h" |
| 36 #include "base/sequenced_task_runner_helpers.h" | 37 #include "base/sequenced_task_runner_helpers.h" |
| 37 #include "content/common/media/audio_messages.h" | 38 #include "content/common/media/audio_messages.h" |
| 38 #include "content/public/browser/browser_message_filter.h" | 39 #include "content/public/browser/browser_message_filter.h" |
| 39 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 40 #include "media/audio/audio_input_controller.h" | 41 #include "media/audio/audio_input_controller.h" |
| 41 #include "media/audio/audio_io.h" | 42 #include "media/audio/audio_io.h" |
| 42 #include "media/audio/audio_logging.h" | 43 #include "media/audio/audio_logging.h" |
| 43 #include "media/audio/simple_sources.h" | 44 #include "media/audio/simple_sources.h" |
| 44 | 45 |
| 45 namespace media { | 46 namespace media { |
| 46 class AudioManager; | 47 class AudioManager; |
| 47 class AudioParameters; | 48 class AudioParameters; |
| 48 class UserInputMonitor; | 49 class UserInputMonitor; |
| 49 } | 50 } |
| 50 | 51 |
| 51 namespace content { | 52 namespace content { |
| 52 class AudioMirroringManager; | 53 class AudioMirroringManager; |
| 53 class MediaStreamManager; | 54 class MediaStreamManager; |
| 55 class RenderProcessHost; |
| 54 | 56 |
| 55 class CONTENT_EXPORT AudioInputRendererHost | 57 class CONTENT_EXPORT AudioInputRendererHost |
| 56 : public BrowserMessageFilter, | 58 : public BrowserMessageFilter, |
| 57 public media::AudioInputController::EventHandler { | 59 public media::AudioInputController::EventHandler { |
| 58 public: | 60 public: |
| 59 | 61 |
| 60 // Error codes to make native loggin more clear. These error codes are added | 62 // Error codes to make native loggin more clear. These error codes are added |
| 61 // to generic error strings to provide a higher degree of details. | 63 // to generic error strings to provide a higher degree of details. |
| 62 // Changing these values can lead to problems when matching native debug | 64 // Changing these values can lead to problems when matching native debug |
| 63 // logs with the actual cause of error. | 65 // logs with the actual cause of error. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Unable to prepare the foreign socket handle. | 97 // Unable to prepare the foreign socket handle. |
| 96 SYNC_SOCKET_ERROR, // = 10 | 98 SYNC_SOCKET_ERROR, // = 10 |
| 97 | 99 |
| 98 // This error message comes from the AudioInputController instance. | 100 // This error message comes from the AudioInputController instance. |
| 99 AUDIO_INPUT_CONTROLLER_ERROR, // = 11 | 101 AUDIO_INPUT_CONTROLLER_ERROR, // = 11 |
| 100 }; | 102 }; |
| 101 | 103 |
| 102 // Called from UI thread from the owner of this object. | 104 // Called from UI thread from the owner of this object. |
| 103 // |user_input_monitor| is used for typing detection and can be NULL. | 105 // |user_input_monitor| is used for typing detection and can be NULL. |
| 104 AudioInputRendererHost(int render_process_id, | 106 AudioInputRendererHost(int render_process_id, |
| 107 RenderProcessHost* render_process_host, |
| 105 media::AudioManager* audio_manager, | 108 media::AudioManager* audio_manager, |
| 106 MediaStreamManager* media_stream_manager, | 109 MediaStreamManager* media_stream_manager, |
| 107 AudioMirroringManager* audio_mirroring_manager, | 110 AudioMirroringManager* audio_mirroring_manager, |
| 108 media::UserInputMonitor* user_input_monitor); | 111 media::UserInputMonitor* user_input_monitor); |
| 109 | 112 |
| 113 // Enable and disable debug recording of input on all audio entries. |
| 114 void EnableDebugRecording(const base::FilePath& file); |
| 115 void DisableDebugRecording(); |
| 116 |
| 110 // BrowserMessageFilter implementation. | 117 // BrowserMessageFilter implementation. |
| 111 void OnChannelClosing() override; | 118 void OnChannelClosing() override; |
| 112 void OnDestruct() const override; | 119 void OnDestruct() const override; |
| 113 bool OnMessageReceived(const IPC::Message& message) override; | 120 bool OnMessageReceived(const IPC::Message& message) override; |
| 114 | 121 |
| 115 // AudioInputController::EventHandler implementation. | 122 // AudioInputController::EventHandler implementation. |
| 116 void OnCreated(media::AudioInputController* controller) override; | 123 void OnCreated(media::AudioInputController* controller) override; |
| 117 void OnRecording(media::AudioInputController* controller) override; | 124 void OnRecording(media::AudioInputController* controller) override; |
| 118 void OnError(media::AudioInputController* controller, | 125 void OnError(media::AudioInputController* controller, |
| 119 media::AudioInputController::ErrorCode error_code) override; | 126 media::AudioInputController::ErrorCode error_code) override; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Search for a AudioEntry having the reference to |controller|. | 210 // Search for a AudioEntry having the reference to |controller|. |
| 204 // This method is used to look up an AudioEntry after a controller | 211 // This method is used to look up an AudioEntry after a controller |
| 205 // event is received. | 212 // event is received. |
| 206 AudioEntry* LookupByController(media::AudioInputController* controller); | 213 AudioEntry* LookupByController(media::AudioInputController* controller); |
| 207 | 214 |
| 208 // If ChromeOS and |config|'s layout has keyboard mic, unregister in | 215 // If ChromeOS and |config|'s layout has keyboard mic, unregister in |
| 209 // AudioInputDeviceManager. | 216 // AudioInputDeviceManager. |
| 210 void MaybeUnregisterKeyboardMicStream( | 217 void MaybeUnregisterKeyboardMicStream( |
| 211 const AudioInputHostMsg_CreateStream_Config& config); | 218 const AudioInputHostMsg_CreateStream_Config& config); |
| 212 | 219 |
| 220 void MaybeEnableDebugRecordingForId(int stream_id); |
| 221 |
| 222 base::FilePath GetDebugRecordingFilePathWithExtensions( |
| 223 const base::FilePath& file); |
| 224 |
| 225 void EnabledDebugRecordingForId(const base::FilePath& file, int stream_id); |
| 226 |
| 227 void DoEnableDebugRecording(int stream_id, base::File file); |
| 228 void DoDisableDebugRecording(int stream_id); |
| 229 |
| 230 // Delete the debug writer used for debug recordings for |stream_id|. |
| 231 void DeleteDebugWriter(int stream_id); |
| 232 |
| 213 // ID of the RenderProcessHost that owns this instance. | 233 // ID of the RenderProcessHost that owns this instance. |
| 214 const int render_process_id_; | 234 const int render_process_id_; |
| 215 | 235 |
| 236 RenderProcessHost* render_process_host_; |
| 237 |
| 216 // Used to create an AudioInputController. | 238 // Used to create an AudioInputController. |
| 217 media::AudioManager* audio_manager_; | 239 media::AudioManager* audio_manager_; |
| 218 | 240 |
| 219 // Used to access to AudioInputDeviceManager. | 241 // Used to access to AudioInputDeviceManager. |
| 220 MediaStreamManager* media_stream_manager_; | 242 MediaStreamManager* media_stream_manager_; |
| 221 | 243 |
| 222 AudioMirroringManager* audio_mirroring_manager_; | 244 AudioMirroringManager* audio_mirroring_manager_; |
| 223 | 245 |
| 224 // A map of stream IDs to audio sources. | 246 // A map of stream IDs to audio sources. |
| 225 AudioEntryMap audio_entries_; | 247 AudioEntryMap audio_entries_; |
| 226 | 248 |
| 227 // Raw pointer of the UserInputMonitor. | 249 // Raw pointer of the UserInputMonitor. |
| 228 media::UserInputMonitor* user_input_monitor_; | 250 media::UserInputMonitor* user_input_monitor_; |
| 229 | 251 |
| 230 scoped_ptr<media::AudioLog> audio_log_; | 252 scoped_ptr<media::AudioLog> audio_log_; |
| 231 | 253 |
| 254 base::WeakPtrFactory<AudioInputRendererHost> weak_factory_; |
| 255 |
| 232 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 256 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
| 233 }; | 257 }; |
| 234 | 258 |
| 235 } // namespace content | 259 } // namespace content |
| 236 | 260 |
| 237 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 261 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
| OLD | NEW |