Index: content/browser/renderer_host/media/audio_stream_registry_impl.h |
diff --git a/content/browser/renderer_host/media/audio_stream_registry_impl.h b/content/browser/renderer_host/media/audio_stream_registry_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..12e8f2901136c87f1a49e121db417982f0e44d03 |
--- /dev/null |
+++ b/content/browser/renderer_host/media/audio_stream_registry_impl.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2016 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_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_ |
+#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_ |
+ |
+#include <map> |
+#include <memory> |
+#include <set> |
+ |
+#include "base/atomic_ref_count.h" |
+#include "base/files/file_path.h" |
+#include "base/macros.h" |
+#include "base/threading/thread_checker.h" |
+#include "content/browser/renderer_host/media/audio_stream_registry.h" |
+#include "content/common/content_export.h" |
+#include "content/public/browser/browser_thread.h" |
+ |
+namespace content { |
+ |
+class CONTENT_EXPORT AudioStreamRegistryImpl : public AudioStreamRegistry { |
+ public: |
+ explicit AudioStreamRegistryImpl(int render_process_id); |
+ ~AudioStreamRegistryImpl() override; |
+ |
+ using UniquePtr = |
+ std::unique_ptr<AudioStreamRegistryImpl, BrowserThread::DeleteOnIOThread>; |
+ |
+ static UniquePtr Create(int render_process_id); |
+ |
+ // Indicates whether there is an output stream currently playing. |
+ // May be called from any thread. |
+ bool HasActiveAudio(); |
+ |
+#if BUILDFLAG(ENABLE_WEBRTC) |
+ void EnableDebugRecording(const base::FilePath& base_file_path); |
+ void DisableDebugRecording(); |
+#endif // BUILDFLAG(ENABLE_WEBRTC) |
+ |
+ // Streams must be removed before this object is destructed. |
+ // void RegisterInputStream(Stream* stream) override; |
+ void RegisterOutputStream(Stream* stream) override; |
+ // void DeregisterInputStream(Stream* stream) override; |
+ void DeregisterOutputStream(Stream* stream) override; |
+ |
+ void OutputStreamStateChanged(Stream* stream, bool playing) override; |
+ |
+ // Resets the thread checker for AudioStreamsTracker. Needed when using |
+ // real threads when testing. |
+ static void DetachAudioStreamsTrackerFromThreadForTesting(); |
+ |
+ private: |
+ using StreamSet = std::set<Stream*>; |
+ |
+ size_t max_simultaneous_output_streams_ = 0; |
+ const int render_process_id_; |
+ base::AtomicRefCount num_playing_output_streams_ = 0; |
+ // StreamSet input_streams_; |
+ StreamSet output_streams_; |
+ |
+#if BUILDFLAG(ENABLE_WEBRTC) |
+ // If debug recoding is active, this is the base file path used. |
+ base::FilePath debug_recording_path_; |
+#endif // BUILDFLAG(ENABLE_WEBRTC) |
+ |
+#if DCHECK_IS_ON() |
+ std::map<Stream*, bool> stream_currently_playing_; |
+#endif |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioStreamRegistryImpl); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_ |