Index: content/browser/renderer_host/media/media_devices_manager.h |
diff --git a/content/browser/renderer_host/media/media_devices_manager.h b/content/browser/renderer_host/media/media_devices_manager.h |
index 9610acbbaa7f47a940a9ffb0f8167a236cb50ed5..63b0040959f7bedf4693ce79d0ac9a0cc76c3c7b 100644 |
--- a/content/browser/renderer_host/media/media_devices_manager.h |
+++ b/content/browser/renderer_host/media/media_devices_manager.h |
@@ -29,6 +29,18 @@ class VideoCaptureManager; |
using MediaDeviceEnumeration = |
std::array<MediaDeviceInfoArray, NUM_MEDIA_DEVICE_TYPES>; |
+// MediaDeviceChangeSubscriber is an interface to be implemented by classes |
+// that can register with MediaDevicesManager to get notifications about changes |
+// in the set of media devices. |
+class CONTENT_EXPORT MediaDeviceChangeSubscriber { |
+ public: |
+ // This function is invoked to notify about changes in the set of media |
+ // devices of type |type|. |device_infos| contains the updated list of |
+ // devices of type |type|. |
+ virtual void OnDevicesChanged(MediaDeviceType type, |
+ const MediaDeviceInfoArray& device_infos) = 0; |
+}; |
+ |
// MediaDevicesManager is responsible for doing media-device enumerations. |
// In addition it implements caching for enumeration results and device |
// monitoring in order to keep caches consistent. |
@@ -63,6 +75,22 @@ class CONTENT_EXPORT MediaDevicesManager |
void EnumerateDevices(const BoolDeviceTypes& requested_types, |
const EnumerationCallback& callback); |
+ // Subscribes |subscriber| to receive device-change notifications for devices |
+ // of type |type|. If |subscriber| is already subscribed, this function has |
+ // no side effects. MediaDevicesManager does not own |subscriber|. It is the |
+ // responsibility of the caller to ensure that all registered subscribers |
+ // remain valid while the they are subscribed. |
+ void SubscribeDeviceChangeNotifications( |
+ MediaDeviceType type, |
+ MediaDeviceChangeSubscriber* subscriber); |
+ |
+ // Unubscribes |subscriber| from device-change notifications for the devices |
+ // of type |type|. If |subscriber| is not subscribed, this function has no |
+ // side effects. |
+ void UnsubscribeDeviceChangeNotifications( |
+ MediaDeviceType type, |
+ MediaDeviceChangeSubscriber* subscriber); |
+ |
// Tries to start device monitoring. If successful, enables caching of |
// enumeration results for the device types supported by the monitor. |
void StartMonitoring(); |
@@ -145,6 +173,9 @@ class CONTENT_EXPORT MediaDevicesManager |
MediaDeviceEnumeration current_snapshot_; |
bool monitoring_started_; |
+ std::vector<MediaDeviceChangeSubscriber*> |
+ device_change_subscribers_[NUM_MEDIA_DEVICE_TYPES]; |
+ |
base::WeakPtrFactory<MediaDevicesManager> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(MediaDevicesManager); |