OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 // VideoCaptureImplManager manages video capture devices in renderer process. | |
6 // The video capture clients use AddDevice() to get a pointer to | |
7 // video capture device. VideoCaputreImplManager supports multiple clients | |
8 // accessing same device. | |
9 | |
10 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | |
11 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | |
12 | |
13 #include <list> | |
14 #include <map> | |
15 | |
16 #include "base/message_loop_proxy.h" | |
17 #include "base/synchronization/lock.h" | |
18 #include "content/renderer/media/video_capture_impl.h" | |
19 #include "content/renderer/video_capture_message_filter.h" | |
20 #include "media/base/callback.h" | |
21 #include "media/base/message_loop_factory.h" | |
22 #include "media/video/capture/video_capture.h" | |
23 | |
24 class VideoCaptureImplManager { | |
25 public: | |
26 VideoCaptureImplManager(); | |
27 ~VideoCaptureImplManager(); | |
28 | |
29 // Called by video capture client |handler| to add device referenced | |
30 // by |id| to VideoCaptureImplManager's list of opened device list. | |
31 // A pointer to VideoCapture is returned to client so that client can | |
32 // operate on that pointer, such as StartCaptrue, StopCapture. | |
33 static media::VideoCapture* AddDevice( | |
34 media::VideoCaptureSessionId id, | |
35 media::VideoCapture::EventHandler* handler); | |
36 | |
37 // Called by video capture client |handler| to remove device referenced | |
38 // by |id| from VideoCaptureImplManager's list of opened device list. | |
39 static void RemoveDevice(media::VideoCaptureSessionId id, | |
40 media::VideoCapture::EventHandler* handler); | |
41 | |
42 static VideoCaptureImplManager* GetInstance(); | |
43 | |
44 private: | |
45 struct Device { | |
46 Device(); | |
47 Device(VideoCaptureImpl* device, | |
48 media::VideoCapture::EventHandler* handler); | |
49 ~Device(); | |
50 | |
51 VideoCaptureImpl* vc; | |
52 std::list<media::VideoCapture::EventHandler*> clients; | |
53 }; | |
54 | |
55 void FreeDevice(VideoCaptureImpl* vc); | |
56 | |
57 typedef std::map<media::VideoCaptureSessionId, Device> Devices; | |
58 Devices devices_; | |
59 base::Lock lock_; | |
60 scoped_refptr<base::MessageLoopProxy> ml_proxy_; | |
61 scoped_ptr<media::MessageLoopFactory> ml_factory_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplManager); | |
64 }; | |
65 | |
66 DISABLE_RUNNABLE_METHOD_REFCOUNT(VideoCaptureImplManager); | |
67 | |
68 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | |
OLD | NEW |