Chromium Code Reviews| 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 // 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; |
| 120 void OnData(media::AudioInputController* controller, | 127 void OnData(media::AudioInputController* controller, |
| 121 const media::AudioBus* data) override; | 128 const media::AudioBus* data) override; |
| 122 void OnLog(media::AudioInputController* controller, | 129 void OnLog(media::AudioInputController* controller, |
| 123 const std::string& message) override; | 130 const std::string& message) override; |
| 124 | 131 |
| 132 // Sets the PID renderer. This is used for constructing the debug recording | |
| 133 // filename. | |
| 134 void set_renderer_pid(int32 renderer_pid); | |
| 135 | |
| 125 private: | 136 private: |
| 126 // TODO(henrika): extend test suite (compare AudioRenderHost) | 137 // TODO(henrika): extend test suite (compare AudioRenderHost) |
| 127 friend class BrowserThread; | 138 friend class BrowserThread; |
| 128 friend class TestAudioInputRendererHost; | 139 friend class TestAudioInputRendererHost; |
| 129 friend class base::DeleteHelper<AudioInputRendererHost>; | 140 friend class base::DeleteHelper<AudioInputRendererHost>; |
| 130 | 141 |
| 131 struct AudioEntry; | 142 struct AudioEntry; |
| 132 typedef std::map<int, AudioEntry*> AudioEntryMap; | 143 typedef std::map<int, AudioEntry*> AudioEntryMap; |
| 133 | 144 |
| 134 ~AudioInputRendererHost() override; | 145 ~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|. | 214 // Search for a AudioEntry having the reference to |controller|. |
| 204 // This method is used to look up an AudioEntry after a controller | 215 // This method is used to look up an AudioEntry after a controller |
| 205 // event is received. | 216 // event is received. |
| 206 AudioEntry* LookupByController(media::AudioInputController* controller); | 217 AudioEntry* LookupByController(media::AudioInputController* controller); |
| 207 | 218 |
| 208 // If ChromeOS and |config|'s layout has keyboard mic, unregister in | 219 // If ChromeOS and |config|'s layout has keyboard mic, unregister in |
| 209 // AudioInputDeviceManager. | 220 // AudioInputDeviceManager. |
| 210 void MaybeUnregisterKeyboardMicStream( | 221 void MaybeUnregisterKeyboardMicStream( |
| 211 const AudioInputHostMsg_CreateStream_Config& config); | 222 const AudioInputHostMsg_CreateStream_Config& config); |
| 212 | 223 |
| 224 void MaybeEnableDebugRecordingForId(int stream_id); | |
| 225 | |
| 226 base::FilePath GetDebugRecordingFilePathWithExtensions( | |
| 227 const base::FilePath& file); | |
| 228 | |
| 229 void EnabledDebugRecordingForId(const base::FilePath& file, int stream_id); | |
| 230 | |
| 231 void DoEnableDebugRecording(int stream_id, base::File file); | |
| 232 void DoDisableDebugRecording(int stream_id); | |
| 233 | |
| 234 // Delete the debug writer used for debug recordings for |stream_id|. | |
| 235 void DeleteDebugWriter(int stream_id); | |
| 236 | |
| 213 // ID of the RenderProcessHost that owns this instance. | 237 // ID of the RenderProcessHost that owns this instance. |
| 214 const int render_process_id_; | 238 const int render_process_id_; |
| 215 | 239 |
| 240 // PID of the render process connected to the RenderProcessHost that owns this | |
| 241 // instabce. | |
|
tommi (sloooow) - chröme
2015/08/31 17:19:07
instance
Henrik Grunell
2015/09/04 12:37:37
Done.
| |
| 242 int32 renderer_pid_; | |
|
tommi (sloooow) - chröme
2015/08/31 17:19:07
can this be const?
Henrik Grunell
2015/09/04 12:37:37
No, see
void set_renderer_pid(int32 renderer_pid);
| |
| 243 | |
| 216 // Used to create an AudioInputController. | 244 // Used to create an AudioInputController. |
| 217 media::AudioManager* audio_manager_; | 245 media::AudioManager* audio_manager_; |
| 218 | 246 |
| 219 // Used to access to AudioInputDeviceManager. | 247 // Used to access to AudioInputDeviceManager. |
| 220 MediaStreamManager* media_stream_manager_; | 248 MediaStreamManager* media_stream_manager_; |
| 221 | 249 |
| 222 AudioMirroringManager* audio_mirroring_manager_; | 250 AudioMirroringManager* audio_mirroring_manager_; |
| 223 | 251 |
| 224 // A map of stream IDs to audio sources. | 252 // A map of stream IDs to audio sources. |
| 225 AudioEntryMap audio_entries_; | 253 AudioEntryMap audio_entries_; |
| 226 | 254 |
| 227 // Raw pointer of the UserInputMonitor. | 255 // Raw pointer of the UserInputMonitor. |
| 228 media::UserInputMonitor* user_input_monitor_; | 256 media::UserInputMonitor* user_input_monitor_; |
| 229 | 257 |
| 230 scoped_ptr<media::AudioLog> audio_log_; | 258 scoped_ptr<media::AudioLog> audio_log_; |
| 231 | 259 |
| 260 base::WeakPtrFactory<AudioInputRendererHost> weak_factory_; | |
| 261 | |
| 232 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 262 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
| 233 }; | 263 }; |
| 234 | 264 |
| 235 } // namespace content | 265 } // namespace content |
| 236 | 266 |
| 237 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 267 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
| OLD | NEW |