| Index: content/renderer/media/audio_debug_recorder.h
|
| diff --git a/content/renderer/media/audio_debug_recorder.h b/content/renderer/media/audio_debug_recorder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5d5b83f67145801ae3f84ad4eaff327cdaf2170f
|
| --- /dev/null
|
| +++ b/content/renderer/media/audio_debug_recorder.h
|
| @@ -0,0 +1,86 @@
|
| +// Copyright 2015 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 CONTENT_RENDERER_MEDIA_AUDIO_DEBUG_RECORDER_H_
|
| +#define CONTENT_RENDERER_MEDIA_AUDIO_DEBUG_RECORDER_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "base/files/file.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/common/media/audio_debug_recording.mojom.h"
|
| +
|
| +namespace content {
|
| +
|
| +class ServiceRegistry;
|
| +
|
| +// AudioDebugRecorder handles waiting for notifications from the browser
|
| +// process to enable/disable audio debug recordings.
|
| +// All functions must only be accessed from the creation thread.
|
| +class CONTENT_EXPORT AudioDebugRecorder
|
| + : public base::RefCountedThreadSafe<AudioDebugRecorder> {
|
| + public:
|
| + class AecDumpDelegate {
|
| + public:
|
| + virtual void OnAecDumpFile(base::PlatformFile file_handle) = 0;
|
| + virtual void OnDisableAecDump() = 0;
|
| + virtual void OnIpcClosing() = 0;
|
| + };
|
| +
|
| + explicit AudioDebugRecorder(ServiceRegistry* service_registry);
|
| +
|
| + // Getter for the one AudioDebugRecorder object.
|
| + static scoped_refptr<AudioDebugRecorder> Get();
|
| +
|
| + // Adds a delegate that receives the enable and disable notifications.
|
| + void AddDelegate(AudioDebugRecorder::AecDumpDelegate* delegate);
|
| +
|
| + // Removes a delegate.
|
| + void RemoveDelegate(AudioDebugRecorder::AecDumpDelegate* delegate);
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<AudioDebugRecorder>;
|
| + ~AudioDebugRecorder();
|
| +
|
| + // Observers are used to listen for audio recording enable/disable events from
|
| + // the browser.
|
| + class Observer;
|
| +
|
| + // Mojo connection error handler.
|
| + void OnConnectionError();
|
| +
|
| + void DoEnableAecDump(int id, base::PlatformFile file_handle);
|
| + void DoDisableAecDump(int id);
|
| + int GetIdForDelegate(AudioDebugRecorder::AecDumpDelegate* delegate);
|
| +
|
| + // The Mojo service for registering observers to listen for enable/disable
|
| + // events.
|
| + AudioDebugRecordingPtr service_;
|
| +
|
| + // The delegates that are waiting for notifications.
|
| + typedef std::map<int, AudioDebugRecorder::AecDumpDelegate*> DelegateMap;
|
| + DelegateMap delegates_;
|
| +
|
| + // Map from delegate IDs to observers.
|
| + using ObserverMap = std::map<int, scoped_ptr<Observer>>;
|
| + ObserverMap observers_;
|
| +
|
| + // Counter for generating unique IDs to delegates.
|
| + int delegate_id_counter_;
|
| +
|
| + // The singleton instance for this.
|
| + static AudioDebugRecorder* g_filter;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AudioDebugRecorder);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_MEDIA_AUDIO_DEBUG_RECORDER_H_
|
|
|