| 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 int32 renderer_pid, |
| 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 #if defined(ENABLE_WEBRTC) |
| 114 // Enable and disable debug recording of input on all audio entries. |
| 115 void EnableDebugRecording(const base::FilePath& file); |
| 116 void DisableDebugRecording(); |
| 117 #endif |
| 118 |
| 110 // BrowserMessageFilter implementation. | 119 // BrowserMessageFilter implementation. |
| 111 void OnChannelClosing() override; | 120 void OnChannelClosing() override; |
| 112 void OnDestruct() const override; | 121 void OnDestruct() const override; |
| 113 bool OnMessageReceived(const IPC::Message& message) override; | 122 bool OnMessageReceived(const IPC::Message& message) override; |
| 114 | 123 |
| 115 // AudioInputController::EventHandler implementation. | 124 // AudioInputController::EventHandler implementation. |
| 116 void OnCreated(media::AudioInputController* controller) override; | 125 void OnCreated(media::AudioInputController* controller) override; |
| 117 void OnRecording(media::AudioInputController* controller) override; | 126 void OnRecording(media::AudioInputController* controller) override; |
| 118 void OnError(media::AudioInputController* controller, | 127 void OnError(media::AudioInputController* controller, |
| 119 media::AudioInputController::ErrorCode error_code) override; | 128 media::AudioInputController::ErrorCode error_code) override; |
| 120 void OnData(media::AudioInputController* controller, | 129 void OnData(media::AudioInputController* controller, |
| 121 const media::AudioBus* data) override; | 130 const media::AudioBus* data) override; |
| 122 void OnLog(media::AudioInputController* controller, | 131 void OnLog(media::AudioInputController* controller, |
| 123 const std::string& message) override; | 132 const std::string& message) override; |
| 124 | 133 |
| 134 // Sets the PID renderer. This is used for constructing the debug recording |
| 135 // filename. |
| 136 void set_renderer_pid(int32 renderer_pid); |
| 137 |
| 125 private: | 138 private: |
| 126 // TODO(henrika): extend test suite (compare AudioRenderHost) | 139 // TODO(henrika): extend test suite (compare AudioRenderHost) |
| 127 friend class BrowserThread; | 140 friend class BrowserThread; |
| 128 friend class TestAudioInputRendererHost; | 141 friend class TestAudioInputRendererHost; |
| 129 friend class base::DeleteHelper<AudioInputRendererHost>; | 142 friend class base::DeleteHelper<AudioInputRendererHost>; |
| 130 | 143 |
| 131 struct AudioEntry; | 144 struct AudioEntry; |
| 132 typedef std::map<int, AudioEntry*> AudioEntryMap; | 145 typedef std::map<int, AudioEntry*> AudioEntryMap; |
| 133 | 146 |
| 134 ~AudioInputRendererHost() override; | 147 ~AudioInputRendererHost() override; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Search for a AudioEntry having the reference to |controller|. | 216 // Search for a AudioEntry having the reference to |controller|. |
| 204 // This method is used to look up an AudioEntry after a controller | 217 // This method is used to look up an AudioEntry after a controller |
| 205 // event is received. | 218 // event is received. |
| 206 AudioEntry* LookupByController(media::AudioInputController* controller); | 219 AudioEntry* LookupByController(media::AudioInputController* controller); |
| 207 | 220 |
| 208 // If ChromeOS and |config|'s layout has keyboard mic, unregister in | 221 // If ChromeOS and |config|'s layout has keyboard mic, unregister in |
| 209 // AudioInputDeviceManager. | 222 // AudioInputDeviceManager. |
| 210 void MaybeUnregisterKeyboardMicStream( | 223 void MaybeUnregisterKeyboardMicStream( |
| 211 const AudioInputHostMsg_CreateStream_Config& config); | 224 const AudioInputHostMsg_CreateStream_Config& config); |
| 212 | 225 |
| 226 #if defined(ENABLE_WEBRTC) |
| 227 void MaybeEnableDebugRecordingForId(int stream_id); |
| 228 |
| 229 base::FilePath GetDebugRecordingFilePathWithExtensions( |
| 230 const base::FilePath& file); |
| 231 |
| 232 void EnableDebugRecordingForId(const base::FilePath& file, int stream_id); |
| 233 |
| 234 void DoEnableDebugRecording(int stream_id, base::File file); |
| 235 void DoDisableDebugRecording(int stream_id); |
| 236 |
| 237 // Delete the debug writer used for debug recordings for |stream_id|. |
| 238 void DeleteDebugWriter(int stream_id); |
| 239 #endif |
| 240 |
| 213 // ID of the RenderProcessHost that owns this instance. | 241 // ID of the RenderProcessHost that owns this instance. |
| 214 const int render_process_id_; | 242 const int render_process_id_; |
| 215 | 243 |
| 244 // PID of the render process connected to the RenderProcessHost that owns this |
| 245 // instance. |
| 246 int32 renderer_pid_; |
| 247 |
| 216 // Used to create an AudioInputController. | 248 // Used to create an AudioInputController. |
| 217 media::AudioManager* audio_manager_; | 249 media::AudioManager* audio_manager_; |
| 218 | 250 |
| 219 // Used to access to AudioInputDeviceManager. | 251 // Used to access to AudioInputDeviceManager. |
| 220 MediaStreamManager* media_stream_manager_; | 252 MediaStreamManager* media_stream_manager_; |
| 221 | 253 |
| 222 AudioMirroringManager* audio_mirroring_manager_; | 254 AudioMirroringManager* audio_mirroring_manager_; |
| 223 | 255 |
| 224 // A map of stream IDs to audio sources. | 256 // A map of stream IDs to audio sources. |
| 225 AudioEntryMap audio_entries_; | 257 AudioEntryMap audio_entries_; |
| 226 | 258 |
| 227 // Raw pointer of the UserInputMonitor. | 259 // Raw pointer of the UserInputMonitor. |
| 228 media::UserInputMonitor* user_input_monitor_; | 260 media::UserInputMonitor* user_input_monitor_; |
| 229 | 261 |
| 230 scoped_ptr<media::AudioLog> audio_log_; | 262 scoped_ptr<media::AudioLog> audio_log_; |
| 231 | 263 |
| 264 base::WeakPtrFactory<AudioInputRendererHost> weak_factory_; |
| 265 |
| 232 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 266 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
| 233 }; | 267 }; |
| 234 | 268 |
| 235 } // namespace content | 269 } // namespace content |
| 236 | 270 |
| 237 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 271 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
| OLD | NEW |