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

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

Issue 1272223003: Implement writing mic audio input data to file for debugging purposes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 5 years, 4 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 // 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
105 media::AudioManager* audio_manager, 107 media::AudioManager* audio_manager,
106 MediaStreamManager* media_stream_manager, 108 MediaStreamManager* media_stream_manager,
107 AudioMirroringManager* audio_mirroring_manager, 109 AudioMirroringManager* audio_mirroring_manager,
108 media::UserInputMonitor* user_input_monitor); 110 media::UserInputMonitor* user_input_monitor);
109 111
112 // Enable and disable debug recording of input on all audio entries.
113 void EnableDebugRecording(const base::FilePath& file);
114 void DisableDebugRecording();
115
110 // BrowserMessageFilter implementation. 116 // BrowserMessageFilter implementation.
111 void OnChannelClosing() override; 117 void OnChannelClosing() override;
112 void OnDestruct() const override; 118 void OnDestruct() const override;
113 bool OnMessageReceived(const IPC::Message& message) override; 119 bool OnMessageReceived(const IPC::Message& message) override;
114 120
115 // AudioInputController::EventHandler implementation. 121 // AudioInputController::EventHandler implementation.
116 void OnCreated(media::AudioInputController* controller) override; 122 void OnCreated(media::AudioInputController* controller) override;
117 void OnRecording(media::AudioInputController* controller) override; 123 void OnRecording(media::AudioInputController* controller) override;
118 void OnError(media::AudioInputController* controller, 124 void OnError(media::AudioInputController* controller,
119 media::AudioInputController::ErrorCode error_code) override; 125 media::AudioInputController::ErrorCode error_code) override;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Search for a AudioEntry having the reference to |controller|. 209 // Search for a AudioEntry having the reference to |controller|.
204 // This method is used to look up an AudioEntry after a controller 210 // This method is used to look up an AudioEntry after a controller
205 // event is received. 211 // event is received.
206 AudioEntry* LookupByController(media::AudioInputController* controller); 212 AudioEntry* LookupByController(media::AudioInputController* controller);
207 213
208 // If ChromeOS and |config|'s layout has keyboard mic, unregister in 214 // If ChromeOS and |config|'s layout has keyboard mic, unregister in
209 // AudioInputDeviceManager. 215 // AudioInputDeviceManager.
210 void MaybeUnregisterKeyboardMicStream( 216 void MaybeUnregisterKeyboardMicStream(
211 const AudioInputHostMsg_CreateStream_Config& config); 217 const AudioInputHostMsg_CreateStream_Config& config);
212 218
219 void MaybeEnableDebugRecordingForId(int stream_id);
220
221 base::FilePath GetDebugRecordingFilePathWithExtensions(
222 const base::FilePath& file);
223
224 void EnabledDebugRecordingForId(const base::FilePath& file, int stream_id);
225
226 void DoEnableDebugRecording(int stream_id, base::File file);
227 void DoDisableDebugRecording(int stream_id);
228
229 // Delete the debug writer used for debug recordings for |stream_id|.
230 void DeleteDebugWriter(int stream_id);
231
213 // ID of the RenderProcessHost that owns this instance. 232 // ID of the RenderProcessHost that owns this instance.
214 const int render_process_id_; 233 const int render_process_id_;
215 234
216 // Used to create an AudioInputController. 235 // Used to create an AudioInputController.
217 media::AudioManager* audio_manager_; 236 media::AudioManager* audio_manager_;
218 237
219 // Used to access to AudioInputDeviceManager. 238 // Used to access to AudioInputDeviceManager.
220 MediaStreamManager* media_stream_manager_; 239 MediaStreamManager* media_stream_manager_;
221 240
222 AudioMirroringManager* audio_mirroring_manager_; 241 AudioMirroringManager* audio_mirroring_manager_;
223 242
224 // A map of stream IDs to audio sources. 243 // A map of stream IDs to audio sources.
225 AudioEntryMap audio_entries_; 244 AudioEntryMap audio_entries_;
226 245
227 // Raw pointer of the UserInputMonitor. 246 // Raw pointer of the UserInputMonitor.
228 media::UserInputMonitor* user_input_monitor_; 247 media::UserInputMonitor* user_input_monitor_;
229 248
230 scoped_ptr<media::AudioLog> audio_log_; 249 scoped_ptr<media::AudioLog> audio_log_;
231 250
251 base::WeakPtrFactory<AudioInputRendererHost> weak_factory_;
252
232 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); 253 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost);
233 }; 254 };
234 255
235 } // namespace content 256 } // namespace content
236 257
237 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ 258 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698