OLD | NEW |
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 CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "content/public/common/media_stream_request.h" | 11 #include "content/public/common/media_stream_request.h" |
12 | 12 |
13 class PrefService; | 13 class PrefServiceSyncable; |
14 | 14 |
15 // This observer is owned by MediaInternals and deleted when MediaInternals | 15 // This observer is owned by MediaInternals and deleted when MediaInternals |
16 // is deleted. | 16 // is deleted. |
17 class MediaCaptureDevicesDispatcher | 17 class MediaCaptureDevicesDispatcher |
18 : public base::RefCountedThreadSafe<MediaCaptureDevicesDispatcher> { | 18 : public base::RefCountedThreadSafe<MediaCaptureDevicesDispatcher> { |
19 public: | 19 public: |
20 class Observer { | 20 class Observer { |
21 public: | 21 public: |
22 // Handle an information update consisting of a up-to-date audio capture | 22 // Handle an information update consisting of a up-to-date audio capture |
23 // device lists. This happens when a microphone is plugged in or unplugged. | 23 // device lists. This happens when a microphone is plugged in or unplugged. |
24 virtual void OnUpdateAudioDevices( | 24 virtual void OnUpdateAudioDevices( |
25 const content::MediaStreamDevices& devices) {} | 25 const content::MediaStreamDevices& devices) {} |
26 | 26 |
27 // Handle an information update consisting of a up-to-date video capture | 27 // Handle an information update consisting of a up-to-date video capture |
28 // device lists. This happens when a camera is plugged in or unplugged. | 28 // device lists. This happens when a camera is plugged in or unplugged. |
29 virtual void OnUpdateVideoDevices( | 29 virtual void OnUpdateVideoDevices( |
30 const content::MediaStreamDevices& devices) {} | 30 const content::MediaStreamDevices& devices) {} |
31 | 31 |
32 virtual ~Observer() {} | 32 virtual ~Observer() {} |
33 }; | 33 }; |
34 | 34 |
35 MediaCaptureDevicesDispatcher(); | 35 MediaCaptureDevicesDispatcher(); |
36 | 36 |
37 // Registers the preferences related to Media Stream default devices. | 37 // Registers the preferences related to Media Stream default devices. |
38 static void RegisterUserPrefs(PrefService* user_prefs); | 38 static void RegisterUserPrefs(PrefServiceSyncable* user_prefs); |
39 | 39 |
40 // Called on IO thread when one audio device is plugged in or unplugged. | 40 // Called on IO thread when one audio device is plugged in or unplugged. |
41 void AudioCaptureDevicesChanged(const content::MediaStreamDevices& devices); | 41 void AudioCaptureDevicesChanged(const content::MediaStreamDevices& devices); |
42 | 42 |
43 // Called on IO thread when one video device is plugged in or unplugged. | 43 // Called on IO thread when one video device is plugged in or unplugged. |
44 void VideoCaptureDevicesChanged(const content::MediaStreamDevices& devices); | 44 void VideoCaptureDevicesChanged(const content::MediaStreamDevices& devices); |
45 | 45 |
46 // Methods for observers. Called on UI thread. | 46 // Methods for observers. Called on UI thread. |
47 // Observers should add themselves on construction and remove themselves | 47 // Observers should add themselves on construction and remove themselves |
48 // on destruction. | 48 // on destruction. |
(...skipping 19 matching lines...) Expand all Loading... |
68 | 68 |
69 // A list of observers for the device update notifications. | 69 // A list of observers for the device update notifications. |
70 ObserverList<Observer> observers_; | 70 ObserverList<Observer> observers_; |
71 | 71 |
72 // Flag to indicate if device enumeration has been done/doing. | 72 // Flag to indicate if device enumeration has been done/doing. |
73 // Only accessed on UI thread. | 73 // Only accessed on UI thread. |
74 bool devices_enumerated_; | 74 bool devices_enumerated_; |
75 }; | 75 }; |
76 | 76 |
77 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 77 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
OLD | NEW |