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

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: 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 base::FilePath GetDebugRecordingFilePathWithExtensions(
221 const base::FilePath& file);
222
223 void EnabledDebugRecordingForId(const base::FilePath& file, int stream_id);
224
225 void DoEnableDebugRecording(int stream_id, base::File file);
226 void DoDisableDebugRecording(int stream_id);
227
228 // Delete the debug writer used for debug recordings for |stream_id|.
229 void DeleteDebugWriter(int stream_id);
230
213 // ID of the RenderProcessHost that owns this instance. 231 // ID of the RenderProcessHost that owns this instance.
214 const int render_process_id_; 232 const int render_process_id_;
215 233
234 RenderProcessHost* render_process_host_;
235
216 // Used to create an AudioInputController. 236 // Used to create an AudioInputController.
217 media::AudioManager* audio_manager_; 237 media::AudioManager* audio_manager_;
218 238
219 // Used to access to AudioInputDeviceManager. 239 // Used to access to AudioInputDeviceManager.
220 MediaStreamManager* media_stream_manager_; 240 MediaStreamManager* media_stream_manager_;
221 241
222 AudioMirroringManager* audio_mirroring_manager_; 242 AudioMirroringManager* audio_mirroring_manager_;
223 243
224 // A map of stream IDs to audio sources. 244 // A map of stream IDs to audio sources.
225 AudioEntryMap audio_entries_; 245 AudioEntryMap audio_entries_;
226 246
227 // Raw pointer of the UserInputMonitor. 247 // Raw pointer of the UserInputMonitor.
228 media::UserInputMonitor* user_input_monitor_; 248 media::UserInputMonitor* user_input_monitor_;
229 249
230 scoped_ptr<media::AudioLog> audio_log_; 250 scoped_ptr<media::AudioLog> audio_log_;
231 251
252 base::WeakPtrFactory<AudioInputRendererHost> weak_factory_;
253
232 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); 254 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost);
233 }; 255 };
234 256
235 } // namespace content 257 } // namespace content
236 258
237 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ 259 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698