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

Side by Side Diff: content/browser/media/media_internals.h

Issue 616833004: chrome://media-internals: update MediaInternals when devices capabilities are enumerated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FakeVCDFactory needs to specify capture API for Win. Linux/CrOs MediaInternalsVideoCaptureDeviceTes… Created 6 years, 2 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
« no previous file with comments | « no previous file | content/browser/media/media_internals.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_
6 #define CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_ 6 #define CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "media/audio/audio_logging.h" 18 #include "media/audio/audio_logging.h"
19 #include "media/video/capture/video_capture_device_info.h"
19 20
20 namespace media { 21 namespace media {
21 class AudioParameters; 22 class AudioParameters;
22 struct MediaLogEvent; 23 struct MediaLogEvent;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 // This class stores information about currently active media. 28 // This class stores information about currently active media.
28 class CONTENT_EXPORT MediaInternals 29 class CONTENT_EXPORT MediaInternals
29 : NON_EXPORTED_BASE(public media::AudioLogFactory) { 30 : NON_EXPORTED_BASE(public media::AudioLogFactory) {
30 public: 31 public:
32 // Called with the update string.
33 typedef base::Callback<void(const base::string16&)> UpdateCallback;
34
31 static MediaInternals* GetInstance(); 35 static MediaInternals* GetInstance();
32 36
33 virtual ~MediaInternals(); 37 virtual ~MediaInternals();
34 38
35 // Called when a MediaEvent occurs. 39 // Called when a MediaEvent occurs.
36 void OnMediaEvents(int render_process_id, 40 void OnMediaEvents(int render_process_id,
37 const std::vector<media::MediaLogEvent>& events); 41 const std::vector<media::MediaLogEvent>& events);
38 42
39 // Called with the update string.
40 typedef base::Callback<void(const base::string16&)> UpdateCallback;
41
42 // Add/remove update callbacks (see above). Must be called on the IO thread. 43 // Add/remove update callbacks (see above). Must be called on the IO thread.
43 void AddUpdateCallback(const UpdateCallback& callback); 44 void AddUpdateCallback(const UpdateCallback& callback);
44 void RemoveUpdateCallback(const UpdateCallback& callback); 45 void RemoveUpdateCallback(const UpdateCallback& callback);
45 46
46 // Sends all cached data to each registered UpdateCallback. 47 // Sends all audio cached data to each registered UpdateCallback.
47 void SendEverything(); 48 void SendAudioStreamData();
49
50 // Called to inform of the capabilities enumerated for video devices.
51 void UpdateVideoCaptureDeviceCapabilities(
52 const media::VideoCaptureDeviceInfos& video_capture_device_infos);
48 53
49 // AudioLogFactory implementation. Safe to call from any thread. 54 // AudioLogFactory implementation. Safe to call from any thread.
50 virtual scoped_ptr<media::AudioLog> CreateAudioLog( 55 virtual scoped_ptr<media::AudioLog> CreateAudioLog(
51 AudioComponent component) override; 56 AudioComponent component) override;
52 57
53 private: 58 private:
54 friend class AudioLogImpl; 59 friend class AudioLogImpl;
55 friend class MediaInternalsTest; 60 friend class MediaInternalsTest;
56 friend struct base::DefaultLazyInstanceTraits<MediaInternals>; 61 friend struct base::DefaultLazyInstanceTraits<MediaInternals>;
57 62
58 MediaInternals(); 63 MediaInternals();
59 64
60 // Sends |update| to each registered UpdateCallback. Safe to call from any 65 // Sends |update| to each registered UpdateCallback. Safe to call from any
61 // thread, but will forward to the IO thread. 66 // thread, but will forward to the IO thread.
62 void SendUpdate(const base::string16& update); 67 void SendUpdate(const base::string16& update);
63 68
64 // Caches |value| under |cache_key| so that future SendEverything() calls will 69 // Caches |value| under |cache_key| so that future SendAudioStreamData() calls
65 // include the current data. Calls JavaScript |function|(|value|) for each 70 // will include the current data. Calls JavaScript |function|(|value|) for
66 // registered UpdateCallback. SendUpdateAndPurgeCache() is similar but purges 71 // each registered UpdateCallback. SendUpdateAndPurgeCache() is similar but
67 // the cache entry after completion instead. 72 // purges the cache entry after completion instead.
68 void SendUpdateAndCache(const std::string& cache_key, 73 void SendUpdateAndCacheAudioStreamKey(const std::string& cache_key,
69 const std::string& function, 74 const std::string& function,
70 const base::DictionaryValue* value); 75 const base::DictionaryValue* value);
71 void SendUpdateAndPurgeCache(const std::string& cache_key, 76 void SendUpdateAndPurgeAudioStreamCache(const std::string& cache_key,
72 const std::string& function, 77 const std::string& function,
73 const base::DictionaryValue* value); 78 const base::DictionaryValue* value);
79
74 // Must only be accessed on the IO thread. 80 // Must only be accessed on the IO thread.
75 std::vector<UpdateCallback> update_callbacks_; 81 std::vector<UpdateCallback> update_callbacks_;
76 82
77 // All variables below must be accessed under |lock_|. 83 // All variables below must be accessed under |lock_|.
78 base::Lock lock_; 84 base::Lock lock_;
79 base::DictionaryValue cached_data_; 85 base::DictionaryValue audio_streams_cached_data_;
80 int owner_ids_[AUDIO_COMPONENT_MAX]; 86 int owner_ids_[AUDIO_COMPONENT_MAX];
81 87
82 DISALLOW_COPY_AND_ASSIGN(MediaInternals); 88 DISALLOW_COPY_AND_ASSIGN(MediaInternals);
83 }; 89 };
84 90
85 } // namespace content 91 } // namespace content
86 92
87 #endif // CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_ 93 #endif // CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/media_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698