Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

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

Issue 10912004: Begin adding support for tab mirroring via the MediaStream audio/video capturing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed MEDIA_USER_*_CAPTURE to MEDIA_*_DEVICE_CAPTURE, as suggested by wjia@. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // VideoCaptureManager is used to open/close, start/stop, enumerate available 5 // VideoCaptureManager is used to open/close, start/stop, enumerate available
6 // video capture devices, and manage VideoCaptureController's. 6 // video capture devices, and manage VideoCaptureController's.
7 // All functions are expected to be called from Browser::IO thread. 7 // All functions are expected to be called from Browser::IO thread.
8 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. 8 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice.
9 // A device can only be opened once. 9 // A device can only be opened once.
10 10
(...skipping 11 matching lines...) Expand all
22 #include "media/video/capture/video_capture_device.h" 22 #include "media/video/capture/video_capture_device.h"
23 #include "media/video/capture/video_capture_types.h" 23 #include "media/video/capture/video_capture_types.h"
24 24
25 class MockVideoCaptureManager; 25 class MockVideoCaptureManager;
26 class VideoCaptureController; 26 class VideoCaptureController;
27 class VideoCaptureControllerEventHandler; 27 class VideoCaptureControllerEventHandler;
28 28
29 namespace media_stream { 29 namespace media_stream {
30 30
31 // VideoCaptureManager opens/closes and start/stops video capture devices. 31 // VideoCaptureManager opens/closes and start/stops video capture devices.
32 class CONTENT_EXPORT VideoCaptureManager 32 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
33 : public base::RefCountedThreadSafe<VideoCaptureManager>,
34 public MediaStreamProvider {
35 public: 33 public:
36 // Calling |Start| of this id will open the first device, even though open has 34 // Calling |Start| of this id will open the first device, even though open has
37 // not been called. This is used to be able to use video capture devices 35 // not been called. This is used to be able to use video capture devices
38 // before MediaStream is implemented in Chrome and WebKit. 36 // before MediaStream is implemented in Chrome and WebKit.
39 enum { kStartOpenSessionId = 1 }; 37 enum { kStartOpenSessionId = 1 };
40 38
41 VideoCaptureManager(); 39 explicit VideoCaptureManager(media_stream::MediaStreamType device_type);
42 40
43 // Implements MediaStreamProvider. 41 // Implements MediaStreamProvider.
44 virtual void Register(MediaStreamProviderListener* listener, 42 virtual void Register(MediaStreamProviderListener* listener,
45 base::MessageLoopProxy* device_thread_loop) OVERRIDE; 43 base::MessageLoopProxy* device_thread_loop) OVERRIDE;
46 44
47 virtual void Unregister() OVERRIDE; 45 virtual void Unregister() OVERRIDE;
48 46
49 virtual void EnumerateDevices() OVERRIDE; 47 virtual void EnumerateDevices() OVERRIDE;
50 48
51 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; 49 virtual int Open(const StreamDeviceInfo& device) OVERRIDE;
(...skipping 28 matching lines...) Expand all
80 const media::VideoCaptureParams& capture_params, 78 const media::VideoCaptureParams& capture_params,
81 VideoCaptureControllerEventHandler* handler, 79 VideoCaptureControllerEventHandler* handler,
82 base::Callback<void(VideoCaptureController*)> added_cb); 80 base::Callback<void(VideoCaptureController*)> added_cb);
83 // Called by VideoCaptureHost to remove the |controller|. 81 // Called by VideoCaptureHost to remove the |controller|.
84 void RemoveController( 82 void RemoveController(
85 VideoCaptureController* controller, 83 VideoCaptureController* controller,
86 VideoCaptureControllerEventHandler* handler); 84 VideoCaptureControllerEventHandler* handler);
87 85
88 private: 86 private:
89 friend class ::MockVideoCaptureManager; 87 friend class ::MockVideoCaptureManager;
90 friend class base::RefCountedThreadSafe<VideoCaptureManager>;
91 88
92 virtual ~VideoCaptureManager(); 89 virtual ~VideoCaptureManager();
93 90
94 typedef std::list<VideoCaptureControllerEventHandler*> Handlers; 91 typedef std::list<VideoCaptureControllerEventHandler*> Handlers;
95 struct Controller; 92 struct Controller;
96 93
97 // Called by the public functions, executed on device thread. 94 // Called by the public functions, executed on device thread.
98 void OnEnumerateDevices(); 95 void OnEnumerateDevices();
99 void OnOpen(int capture_session_id, const StreamDeviceInfo& device); 96 void OnOpen(int capture_session_id, const StreamDeviceInfo& device);
100 void OnClose(int capture_session_id); 97 void OnClose(int capture_session_id);
(...skipping 24 matching lines...) Expand all
125 122
126 // Helpers 123 // Helpers
127 void GetAvailableDevices(media::VideoCaptureDevice::Names* device_names); 124 void GetAvailableDevices(media::VideoCaptureDevice::Names* device_names);
128 bool DeviceOpened(const media::VideoCaptureDevice::Name& device_name); 125 bool DeviceOpened(const media::VideoCaptureDevice::Name& device_name);
129 bool DeviceInUse(const media::VideoCaptureDevice* video_capture_device); 126 bool DeviceInUse(const media::VideoCaptureDevice* video_capture_device);
130 media::VideoCaptureDevice* GetOpenedDevice( 127 media::VideoCaptureDevice* GetOpenedDevice(
131 const StreamDeviceInfo& device_info); 128 const StreamDeviceInfo& device_info);
132 bool IsOnDeviceThread() const; 129 bool IsOnDeviceThread() const;
133 media::VideoCaptureDevice* GetDeviceInternal(int capture_session_id); 130 media::VideoCaptureDevice* GetDeviceInternal(int capture_session_id);
134 131
132 // The type of video capture devices managed by this instance (e.g., physical
133 // device video capture, tab mirroring).
134 const media_stream::MediaStreamType device_type_;
135
135 // The message loop of media stream device thread that this object runs on. 136 // The message loop of media stream device thread that this object runs on.
136 scoped_refptr<base::MessageLoopProxy> device_loop_; 137 scoped_refptr<base::MessageLoopProxy> device_loop_;
137 138
138 // Only accessed on Browser::IO thread. 139 // Only accessed on Browser::IO thread.
139 MediaStreamProviderListener* listener_; 140 MediaStreamProviderListener* listener_;
140 int new_capture_session_id_; 141 int new_capture_session_id_;
141 142
142 // Only accessed from device thread. 143 // Only accessed from device thread.
143 // VideoCaptureManager owns all VideoCaptureDevices and is responsible for 144 // VideoCaptureManager owns all VideoCaptureDevices and is responsible for
144 // deleting the instances when they are not used any longer. 145 // deleting the instances when they are not used any longer.
145 typedef std::map<int, media::VideoCaptureDevice*> VideoCaptureDevices; 146 typedef std::map<int, media::VideoCaptureDevice*> VideoCaptureDevices;
146 VideoCaptureDevices devices_; 147 VideoCaptureDevices devices_;
147 148
148 // Set to true if using fake devices for testing, false by default. 149 // Set to true if using fake devices for testing, false by default.
149 bool use_fake_device_; 150 bool use_fake_device_;
150 151
151 // Only accessed from device thread. 152 // Only accessed from device thread.
152 // VideoCaptureManager owns all VideoCaptureController's and is responsible 153 // VideoCaptureManager owns all VideoCaptureController's and is responsible
153 // for deleting the instances when they are not used any longer. 154 // for deleting the instances when they are not used any longer.
154 // VideoCaptureDevice is one-to-one mapped to VideoCaptureController. 155 // VideoCaptureDevice is one-to-one mapped to VideoCaptureController.
155 typedef std::map<media::VideoCaptureDevice*, Controller*> Controllers; 156 typedef std::map<media::VideoCaptureDevice*, Controller*> Controllers;
156 Controllers controllers_; 157 Controllers controllers_;
157 158
158 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); 159 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager);
159 }; 160 };
160 161
161 } // namespace media_stream 162 } // namespace media_stream
162 163
163 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 164 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698