Chromium Code Reviews

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

Issue 183743021: Implement MediaCaptureDevices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
(Empty)
1 // Copyright (c) 2014 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_MEDIA_CAPTURE_DEVICES_H
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_CAPTURE_DEVICES_H
7
8 #include "base/memory/singleton.h"
9 #include "base/observer_list.h"
10 #include "content/public/browser/media_capture_devices.h"
11 #include "content/public/browser/media_observer.h"
12
13 namespace content {
14
15 class MediaCaptureDevicesImpl : public MediaCaptureDevices {
16 public:
17 static MediaCaptureDevicesImpl* GetInstance();
18
19 // Overriden from MediaCaptureDevices
20 virtual const MediaStreamDevices& GetAudioCaptureDevices() OVERRIDE;
21 virtual const MediaStreamDevices& GetVideoCaptureDevices() OVERRIDE;
22 virtual void AddObserver(Observer* observer) OVERRIDE;
23 virtual void RemoveObserver(Observer* observer) OVERRIDE;
24 // Only for testing
25 virtual void SetAudioCaptureDevices(
26 const MediaStreamDevices& devices) OVERRIDE;
27 virtual void SetVideoCaptureDevices(
28 const MediaStreamDevices& devices) OVERRIDE;
29 virtual void DisableDeviceEnumerationForTesting() OVERRIDE;
30
31 // Called by MediaStreamManager to notify the change of media capture
32 // devices, these 2 methods are called in IO thread.
33 void OnAudioCaptureDevicesChanged(const MediaStreamDevices& devices);
34 void OnVideoCaptureDevicesChanged(const MediaStreamDevices& devices);
35
36 private:
37 friend struct DefaultSingletonTraits<MediaCaptureDevicesImpl>;
38 MediaCaptureDevicesImpl();
39 virtual ~MediaCaptureDevicesImpl();
40
41 // Called by the MediaObserver() functions, executed on UI thread.
42 void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices);
43 void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices);
44
45 // Flag to indicate if device enumeration has been done/doing.
46 // Only accessed on UI thread.
47 bool devices_enumerated_;
48
49 // Flag used by unittests to disable device enumeration.
50 bool is_device_enumeration_disabled_;
51
52 // A list of cached audio capture devices.
53 MediaStreamDevices audio_devices_;
54
55 // A list of cached video capture devices.
56 MediaStreamDevices video_devices_;
57
58 // A list of observers for the device update notifications.
59 ObserverList<Observer> observers_;
60
61 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesImpl);
62 };
63
64 } // namespace content
65
66 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_CAPTURE_DEVICES_H
OLDNEW

Powered by Google App Engine