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

Side by Side Diff: media/audio/audio_debug_recording_manager.h

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 10 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_
6 #define MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_
7
8 #include <map>
9 #include <memory>
10
11 #include "base/callback.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "media/audio/audio_debug_recording_helper.h"
16 #include "media/audio/audio_file_writer.h"
17 #include "media/base/audio_parameters.h"
18
19 namespace base {
20 class FilePath;
21 class SingleThreadTaskRunner;
22 }
23
24 namespace media {
25
26 class AudioDebugRecordingHelper;
27
28 // A manager for audio debug recording that handles registration of data
29 // sources and hands them a recorder (AudioDebugRecordingHelper) to feed data
30 // to, wrapped so that it unregisters automatically when deleted. When debug
31 // recording is enabled, it is enabled on all recorders. It handles constructing
32 // a file name for each recorder.
33 class AudioDebugRecordingManager {
34 public:
35 explicit AudioDebugRecordingManager(
36 CreateAudioFileWriterCallback create_audio_file_writer_callback,
37 const std::string& file_name_extension,
38 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
39 ~AudioDebugRecordingManager();
40
41 // Enables and disables debug recording.
42 void EnableDebugRecording(const base::FilePath& base_file_name);
43 void DisableDebugRecording();
44
45 // Registers a source and returns a wrapped recorder.
46 std::unique_ptr<AudioDebugRecorder> RegisterDebugRecordingSource(
47 const AudioParameters& params);
48
49 private:
50 // Map type from source id to recorder.
51 using DebugRecordingHelperMap = std::map<int, AudioDebugRecordingHelper*>;
52
53 // Unregisters a source.
54 void UnregisterDebugRecordingSource(int id);
55
56 // Returns |file_name| with |file_name_extension_| and |id| added to it as
57 // as extensions.
58 base::FilePath GetOutputDebugRecordingFileNameWithExtensions(
59 const base::FilePath& file_name,
60 int id);
61
62 // Recorders, one per source.
63 DebugRecordingHelperMap debug_recording_helpers_;
64
65 // Callback for creating AudioFileWriter objects.
66 const CreateAudioFileWriterCallback create_audio_file_writer_callback_;
67
68 // The base file name for debug recording files. If this is non-empty, debug
69 // recording is enabled.
70 base::FilePath debug_recording_base_file_name_;
71
72 // File name extension that will be added to the base file name.
73 const std::string file_name_extension_;
74
75 // The task runner this class lives on. Also handed to
76 // AudioDebugRecordingHelpers.
77 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
78
79 base::ThreadChecker thread_checker_;
80 DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingManager);
81 };
82
83 } // namespace media
84
85 #endif // MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698