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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Rebase. 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 #include <string>
11 #include <utility>
12
13 #include "base/callback.h"
14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/threading/thread_checker.h"
18 #include "media/audio/audio_debug_recording_helper.h"
19 #include "media/audio/audio_file_writer.h"
20 #include "media/base/audio_parameters.h"
21 #include "media/base/media_export.h"
22
23 namespace base {
24 class FilePath;
25 class SingleThreadTaskRunner;
26 }
27
28 namespace media {
29
30 class AudioDebugRecordingHelper;
31
32 // A manager for audio debug recording that handles registration of data
33 // sources and hands them a recorder (AudioDebugRecordingHelper) to feed data
34 // to. The recorder will unregister with the manager automatically when deleted.
35 // When debug recording is enabled, it is enabled on all recorders and
36 // constructs a unique file name for each recorder by using a running ID.
37 class MEDIA_EXPORT AudioDebugRecordingManager {
o1ka 2017/02/09 13:04:03 Can we have a description or pseudo-graphic of the
Henrik Grunell 2017/02/10 09:00:56 That's a good idea. I created a diagram doc to ass
38 public:
39 AudioDebugRecordingManager(
40 CreateAudioFileWriterCallback create_audio_file_writer_callback,
41 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
42 virtual ~AudioDebugRecordingManager();
43
44 // Enables and disables debug recording.
45 void EnableDebugRecording(const base::FilePath& base_file_name);
46 void DisableDebugRecording();
47
48 // Registers a source and returns a wrapped recorder. |file_name_extension| is
49 // added to the base filename, along with a unique running ID.
50 std::unique_ptr<AudioDebugRecorder> RegisterDebugRecordingSource(
51 const std::string& file_name_extension,
52 const AudioParameters& params);
53
54 protected:
55 // Creates a AudioDebugRecordingHelper. Overridden by test.
56 virtual std::unique_ptr<AudioDebugRecordingHelper>
57 CreateAudioDebugRecordingHelper(
58 const AudioParameters& params,
59 const CreateAudioFileWriterCallback& create_audio_file_writer_callback,
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
61 base::OnceClosure on_destruction_closure);
62
63 // Callback for creating AudioFileWriter objects.
64 const CreateAudioFileWriterCallback create_audio_file_writer_callback_;
65
66 // The task runner this class lives on. Also handed to
67 // AudioDebugRecordingHelpers.
68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
69
70 private:
71 FRIEND_TEST_ALL_PREFIXES(AudioDebugRecordingManagerTest,
72 RegisterAutomaticUnregisterAtDelete);
73 FRIEND_TEST_ALL_PREFIXES(AudioDebugRecordingManagerTest,
74 RegisterEnableDisable);
75 FRIEND_TEST_ALL_PREFIXES(AudioDebugRecordingManagerTest,
76 EnableRegisterDisable);
77
78 // Map type from source id to recorder and its filename extension.
79 using DebugRecordingHelperMap =
80 std::map<int, std::pair<AudioDebugRecordingHelper*, std::string>>;
81
82 // Unregisters a source.
83 void UnregisterDebugRecordingSource(int id);
84
85 // Recorders, one per source.
86 DebugRecordingHelperMap debug_recording_helpers_;
87
88 // The base file name for debug recording files. If this is non-empty, debug
89 // recording is enabled.
90 base::FilePath debug_recording_base_file_name_;
91
92 base::WeakPtrFactory<AudioDebugRecordingManager> weak_factory_;
93 DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingManager);
94 };
95
96 } // namespace media
97
98 #endif // MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698