OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_ |
6 #define CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class RenderProcessHost; | 20 class RenderProcessHost; |
21 } // namespace content | 21 } |
| 22 |
| 23 namespace media { |
| 24 class AudioManager; |
| 25 } |
22 | 26 |
23 class Profile; | 27 class Profile; |
24 | 28 |
25 // AudioDebugRecordingsHandler provides an interface to start and stop | 29 // AudioDebugRecordingsHandler provides an interface to start and stop |
26 // AudioDebugRecordings, including WebRTC AEC dumps. | 30 // AudioDebugRecordings, including WebRTC AEC dumps. Lives on the UI thread. |
27 class AudioDebugRecordingsHandler | 31 class AudioDebugRecordingsHandler |
28 : public base::RefCountedThreadSafe<AudioDebugRecordingsHandler> { | 32 : public base::RefCountedThreadSafe<AudioDebugRecordingsHandler> { |
29 public: | 33 public: |
30 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; | 34 typedef base::Callback<void(bool, const std::string&)> GenericDoneCallback; |
31 typedef base::Callback<void(const std::string&)> RecordingErrorCallback; | 35 typedef base::Callback<void(const std::string&)> RecordingErrorCallback; |
32 typedef base::Callback<void(const std::string&, bool, bool)> | 36 typedef base::Callback<void(const std::string&, bool, bool)> |
33 RecordingDoneCallback; | 37 RecordingDoneCallback; |
34 | 38 |
35 // Key used to attach the handler to the RenderProcessHost | 39 // Key used to attach the handler to the RenderProcessHost |
36 static const char kAudioDebugRecordingsHandlerKey[]; | 40 static const char kAudioDebugRecordingsHandlerKey[]; |
37 | 41 |
38 explicit AudioDebugRecordingsHandler(Profile* profile); | 42 AudioDebugRecordingsHandler(Profile* profile, |
| 43 media::AudioManager* audio_manager); |
39 | 44 |
40 // Starts an audio debug recording. The recording lasts the given |delay|, | 45 // Starts an audio debug recording. The recording lasts the given |delay|, |
41 // unless |delay| is zero, in which case recording will continue until | 46 // unless |delay| is zero, in which case recording will continue until |
42 // StopAudioDebugRecordings() is explicitly invoked. | 47 // StopAudioDebugRecordings() is explicitly invoked. |
43 // |callback| is invoked once recording stops. If |delay| is zero | 48 // |callback| is invoked once recording stops. If |delay| is zero |
44 // |callback| is invoked once recording starts. | 49 // |callback| is invoked once recording starts. |
45 // If a recording was already in progress, |error_callback| is invoked instead | 50 // If a recording was already in progress, |error_callback| is invoked instead |
46 // of |callback|. | 51 // of |callback|. |
47 void StartAudioDebugRecordings(content::RenderProcessHost* host, | 52 void StartAudioDebugRecordings(content::RenderProcessHost* host, |
48 base::TimeDelta delay, | 53 base::TimeDelta delay, |
(...skipping 25 matching lines...) Expand all Loading... |
74 void DoStopAudioDebugRecordings(content::RenderProcessHost* host, | 79 void DoStopAudioDebugRecordings(content::RenderProcessHost* host, |
75 bool is_manual_stop, | 80 bool is_manual_stop, |
76 uint64_t audio_debug_recordings_id, | 81 uint64_t audio_debug_recordings_id, |
77 const RecordingDoneCallback& callback, | 82 const RecordingDoneCallback& callback, |
78 const RecordingErrorCallback& error_callback, | 83 const RecordingErrorCallback& error_callback, |
79 const base::FilePath& log_directory); | 84 const base::FilePath& log_directory); |
80 | 85 |
81 // The profile associated with our renderer process. | 86 // The profile associated with our renderer process. |
82 Profile* const profile_; | 87 Profile* const profile_; |
83 | 88 |
84 // Must be accessed on the UI thread. | 89 // Set if recordings are in progress. |
85 bool is_audio_debug_recordings_in_progress_; | 90 bool is_audio_debug_recordings_in_progress_; |
86 | 91 |
87 // This counter allows saving each debug recording in separate files. | 92 // This counter allows saving each debug recording in separate files. |
88 uint64_t current_audio_debug_recordings_id_; | 93 uint64_t current_audio_debug_recordings_id_; |
89 | 94 |
90 base::ThreadChecker thread_checker_; | 95 // Audio manager, used for enabling output recordings. |
| 96 media::AudioManager* const audio_manager_; |
| 97 |
91 DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingsHandler); | 98 DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingsHandler); |
92 }; | 99 }; |
93 | 100 |
94 #endif // CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_ | 101 #endif // CHROME_BROWSER_MEDIA_AUDIO_DEBUG_RECORDINGS_HANDLER_H_ |
OLD | NEW |