| 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/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "content/public/browser/media_observer.h" | 12 #include "content/public/browser/media_observer.h" |
| 13 #include "content/public/common/media_stream_request.h" | 13 #include "content/public/common/media_stream_request.h" |
| 14 | 14 |
| 15 class AudioStreamIndicator; |
| 15 class MediaStreamCaptureIndicator; | 16 class MediaStreamCaptureIndicator; |
| 16 class PrefServiceSyncable; | 17 class PrefServiceSyncable; |
| 17 class Profile; | 18 class Profile; |
| 18 | 19 |
| 19 // This singleton is used to receive updates about media events from the content | 20 // This singleton is used to receive updates about media events from the content |
| 20 // layer. | 21 // layer. |
| 21 class MediaCaptureDevicesDispatcher : public content::MediaObserver { | 22 class MediaCaptureDevicesDispatcher : public content::MediaObserver { |
| 22 public: | 23 public: |
| 23 class Observer { | 24 class Observer { |
| 24 public: | 25 public: |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const content::MediaStreamDevices& devices) OVERRIDE; | 85 const content::MediaStreamDevices& devices) OVERRIDE; |
| 85 virtual void OnAudioCaptureDevicesChanged( | 86 virtual void OnAudioCaptureDevicesChanged( |
| 86 const content::MediaStreamDevices& devices) OVERRIDE; | 87 const content::MediaStreamDevices& devices) OVERRIDE; |
| 87 virtual void OnVideoCaptureDevicesChanged( | 88 virtual void OnVideoCaptureDevicesChanged( |
| 88 const content::MediaStreamDevices& devices) OVERRIDE; | 89 const content::MediaStreamDevices& devices) OVERRIDE; |
| 89 virtual void OnMediaRequestStateChanged( | 90 virtual void OnMediaRequestStateChanged( |
| 90 int render_process_id, | 91 int render_process_id, |
| 91 int render_view_id, | 92 int render_view_id, |
| 92 const content::MediaStreamDevice& device, | 93 const content::MediaStreamDevice& device, |
| 93 content::MediaRequestState state) OVERRIDE; | 94 content::MediaRequestState state) OVERRIDE; |
| 95 virtual void OnAudioStreamPlayingChanged( |
| 96 int render_process_id, |
| 97 int render_view_id, |
| 98 bool playing) OVERRIDE; |
| 94 | 99 |
| 95 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator(); | 100 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator(); |
| 96 | 101 |
| 102 scoped_refptr<AudioStreamIndicator> GetAudioStreamIndicator(); |
| 103 |
| 97 private: | 104 private: |
| 98 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; | 105 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; |
| 99 | 106 |
| 100 MediaCaptureDevicesDispatcher(); | 107 MediaCaptureDevicesDispatcher(); |
| 101 virtual ~MediaCaptureDevicesDispatcher(); | 108 virtual ~MediaCaptureDevicesDispatcher(); |
| 102 | 109 |
| 103 // Called by the MediaObserver() functions, executed on UI thread. | 110 // Called by the MediaObserver() functions, executed on UI thread. |
| 104 void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); | 111 void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); |
| 105 void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices); | 112 void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices); |
| 106 void UpdateMediaRequestStateOnUIThread( | 113 void UpdateMediaRequestStateOnUIThread( |
| 107 int render_process_id, | 114 int render_process_id, |
| 108 int render_view_id, | 115 int render_view_id, |
| 109 const content::MediaStreamDevice& device, | 116 const content::MediaStreamDevice& device, |
| 110 content::MediaRequestState state); | 117 content::MediaRequestState state); |
| 111 | 118 |
| 112 // A list of cached audio capture devices. | 119 // A list of cached audio capture devices. |
| 113 content::MediaStreamDevices audio_devices_; | 120 content::MediaStreamDevices audio_devices_; |
| 114 | 121 |
| 115 // A list of cached video capture devices. | 122 // A list of cached video capture devices. |
| 116 content::MediaStreamDevices video_devices_; | 123 content::MediaStreamDevices video_devices_; |
| 117 | 124 |
| 118 // A list of observers for the device update notifications. | 125 // A list of observers for the device update notifications. |
| 119 ObserverList<Observer> observers_; | 126 ObserverList<Observer> observers_; |
| 120 | 127 |
| 121 // Flag to indicate if device enumeration has been done/doing. | 128 // Flag to indicate if device enumeration has been done/doing. |
| 122 // Only accessed on UI thread. | 129 // Only accessed on UI thread. |
| 123 bool devices_enumerated_; | 130 bool devices_enumerated_; |
| 124 | 131 |
| 125 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; | 132 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_; |
| 133 |
| 134 scoped_refptr<AudioStreamIndicator> audio_stream_indicator_; |
| 126 }; | 135 }; |
| 127 | 136 |
| 128 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ | 137 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ |
| OLD | NEW |