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

Unified Diff: media/audio/audio_debug_recording_manager.h

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/audio_debug_recording_manager.h
diff --git a/media/audio/audio_debug_recording_manager.h b/media/audio/audio_debug_recording_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..686fce7dc935af3400e82b9d0cb57e40801ed7f7
--- /dev/null
+++ b/media/audio/audio_debug_recording_manager.h
@@ -0,0 +1,85 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_
+#define MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_
+
+#include <map>
+#include <memory>
+
+#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "media/audio/audio_debug_recording_helper.h"
+#include "media/audio/audio_file_writer.h"
+#include "media/base/audio_parameters.h"
+
+namespace base {
+class FilePath;
+class SingleThreadTaskRunner;
+}
+
+namespace media {
+
+class AudioDebugRecordingHelper;
+
+// A manager for audio debug recording that handles registration of data
+// sources and hands them a recorder (AudioDebugRecordingHelper) to feed data
+// to, wrapped so that it unregisters automatically when deleted. When debug
+// recording is enabled, it is enabled on all recorders. It handles constructing
+// a file name for each recorder.
+class AudioDebugRecordingManager {
+ public:
+ explicit AudioDebugRecordingManager(
+ CreateAudioFileWriterCallback create_audio_file_writer_callback,
+ const std::string& file_name_extension,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ ~AudioDebugRecordingManager();
+
+ // Enables and disables debug recording.
+ void EnableDebugRecording(const base::FilePath& base_file_name);
+ void DisableDebugRecording();
+
+ // Registers a source and returns a wrapped recorder.
+ std::unique_ptr<AudioDebugRecorder> RegisterDebugRecordingSource(
+ const AudioParameters& params);
+
+ private:
+ // Map type from source id to recorder.
+ using DebugRecordingHelperMap = std::map<int, AudioDebugRecordingHelper*>;
+
+ // Unregisters a source.
+ void UnregisterDebugRecordingSource(int id);
+
+ // Returns |file_name| with |file_name_extension_| and |id| added to it as
+ // as extensions.
+ base::FilePath GetOutputDebugRecordingFileNameWithExtensions(
+ const base::FilePath& file_name,
+ int id);
+
+ // Recorders, one per source.
+ DebugRecordingHelperMap debug_recording_helpers_;
+
+ // Callback for creating AudioFileWriter objects.
+ const CreateAudioFileWriterCallback create_audio_file_writer_callback_;
+
+ // The base file name for debug recording files. If this is non-empty, debug
+ // recording is enabled.
+ base::FilePath debug_recording_base_file_name_;
+
+ // File name extension that will be added to the base file name.
+ const std::string file_name_extension_;
+
+ // The task runner this class lives on. Also handed to
+ // AudioDebugRecordingHelpers.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ base::ThreadChecker thread_checker_;
+ DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingManager);
+};
+
+} // namespace media
+
+#endif // MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698