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

Side by Side Diff: content/browser/renderer_host/media/audio_stream_registry_impl.h

Issue 2578983003: Add AudioStreamRegistry. Move stream counting logic (Closed)
Patch Set: Thread checks. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_
7
8 #include <map>
9 #include <memory>
10 #include <set>
11
12 #include "base/atomic_ref_count.h"
13 #include "base/files/file_path.h"
14 #include "base/macros.h"
15 #include "base/threading/thread_checker.h"
16 #include "content/browser/renderer_host/media/audio_stream_registry.h"
17 #include "content/common/content_export.h"
18 #include "content/public/browser/browser_thread.h"
19
20 namespace content {
21
22 class CONTENT_EXPORT AudioStreamRegistryImpl : public AudioStreamRegistry {
23 public:
24 explicit AudioStreamRegistryImpl(int render_process_id);
25 ~AudioStreamRegistryImpl() override;
26
27 using UniquePtr =
28 std::unique_ptr<AudioStreamRegistryImpl, BrowserThread::DeleteOnIOThread>;
29
30 static UniquePtr Create(int render_process_id);
31
32 // Indicates whether there is an output stream currently playing.
33 // May be called from any thread.
34 bool HasActiveAudio();
35
36 #if BUILDFLAG(ENABLE_WEBRTC)
37 void EnableDebugRecording(const base::FilePath& base_file_path);
38 void DisableDebugRecording();
39 #endif // BUILDFLAG(ENABLE_WEBRTC)
40
41 // Streams must be removed before this object is destructed.
42 // void RegisterInputStream(Stream* stream) override;
o1ka 2017/01/10 11:47:40 Add TODOs instead of commented out methods? (here,
43 void RegisterOutputStream(Stream* stream) override;
44 // void DeregisterInputStream(Stream* stream) override;
45 void DeregisterOutputStream(Stream* stream) override;
46
47 void OutputStreamStateChanged(Stream* stream, bool playing) override;
48
49 // Resets the thread checker for AudioStreamsTracker. Needed when using
50 // real threads when testing.
51 static void DetachAudioStreamsTrackerFromThreadForTesting();
52
53 private:
54 using StreamSet = std::set<Stream*>;
55
56 size_t max_simultaneous_output_streams_ = 0;
57 const int render_process_id_;
58 base::AtomicRefCount num_playing_output_streams_ = 0;
59 // StreamSet input_streams_;
60 StreamSet output_streams_;
61
62 #if BUILDFLAG(ENABLE_WEBRTC)
63 // If debug recoding is active, this is the base file path used.
64 base::FilePath debug_recording_path_;
65 #endif // BUILDFLAG(ENABLE_WEBRTC)
66
67 #if DCHECK_IS_ON()
68 std::map<Stream*, bool> stream_currently_playing_;
o1ka 2017/01/10 11:47:40 How about to always have the current status (=map
69 #endif
70
71 DISALLOW_COPY_AND_ASSIGN(AudioStreamRegistryImpl);
72 };
73
74 } // namespace content
75
76 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_STREAM_REGISTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698