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 #include "remoting/capturer/video_frame_capturer.h" | 5 #include "media/video/capture/screen/screen_capturer.h" |
6 | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 #include <Cocoa/Cocoa.h> | 8 #include <Cocoa/Cocoa.h> |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <IOKit/pwr_mgt/IOPMLib.h> | 10 #include <IOKit/pwr_mgt/IOPMLib.h> |
11 #include <OpenGL/CGLMacro.h> | 11 #include <OpenGL/CGLMacro.h> |
12 #include <OpenGL/OpenGL.h> | 12 #include <OpenGL/OpenGL.h> |
13 #include <set> | 13 #include <set> |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 | 15 |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/file_path.h" | 17 #include "base/file_path.h" |
18 #include "base/mac/mac_util.h" | 18 #include "base/mac/mac_util.h" |
19 #include "base/mac/scoped_cftyperef.h" | 19 #include "base/mac/scoped_cftyperef.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/scoped_native_library.h" | 21 #include "base/scoped_native_library.h" |
22 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
23 #include "base/time.h" | 23 #include "base/time.h" |
24 #include "remoting/capturer/capture_data.h" | 24 #include "media/video/capture/screen/mac/desktop_configuration.h" |
25 #include "remoting/capturer/mac/desktop_configuration.h" | 25 #include "media/video/capture/screen/mac/scoped_pixel_buffer_object.h" |
26 #include "remoting/capturer/mac/scoped_pixel_buffer_object.h" | 26 #include "media/video/capture/screen/mouse_cursor_shape.h" |
27 #include "remoting/capturer/mouse_cursor_shape.h" | 27 #include "media/video/capture/screen/screen_capture_data.h" |
28 #include "remoting/capturer/video_frame.h" | 28 #include "media/video/capture/screen/screen_capture_frame.h" |
29 #include "remoting/capturer/video_frame_capturer_helper.h" | 29 #include "media/video/capture/screen/screen_capture_frame_queue.h" |
30 #include "remoting/capturer/video_frame_queue.h" | 30 #include "media/video/capture/screen/screen_capturer_helper.h" |
31 #include "skia/ext/skia_utils_mac.h" | 31 #include "skia/ext/skia_utils_mac.h" |
32 | 32 |
33 namespace remoting { | 33 namespace media { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Definitions used to dynamic-link to deprecated OS 10.6 functions. | 37 // Definitions used to dynamic-link to deprecated OS 10.6 functions. |
38 const char* kApplicationServicesLibraryName = | 38 const char* kApplicationServicesLibraryName = |
39 "/System/Library/Frameworks/ApplicationServices.framework/" | 39 "/System/Library/Frameworks/ApplicationServices.framework/" |
40 "ApplicationServices"; | 40 "ApplicationServices"; |
41 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID); | 41 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID); |
42 typedef size_t (*CGDisplayBytesPerRowFunc)(CGDirectDisplayID); | 42 typedef size_t (*CGDisplayBytesPerRowFunc)(CGDirectDisplayID); |
43 typedef size_t (*CGDisplayBitsPerPixelFunc)(CGDirectDisplayID); | 43 typedef size_t (*CGDisplayBitsPerPixelFunc)(CGDirectDisplayID); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 memcpy(dest_plane, src_plane, bytes_per_line); | 85 memcpy(dest_plane, src_plane, bytes_per_line); |
86 src_plane += src_plane_stride; | 86 src_plane += src_plane_stride; |
87 dest_plane += dest_plane_stride; | 87 dest_plane += dest_plane_stride; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 // The amount of time allowed for displays to reconfigure. | 91 // The amount of time allowed for displays to reconfigure. |
92 const int64 kDisplayConfigurationEventTimeoutInSeconds = 10; | 92 const int64 kDisplayConfigurationEventTimeoutInSeconds = 10; |
93 | 93 |
94 // A class representing a full-frame pixel buffer. | 94 // A class representing a full-frame pixel buffer. |
95 class VideoFrameMac : public VideoFrame { | 95 class ScreenCaptureFrameMac : public ScreenCaptureFrame { |
96 public: | 96 public: |
97 explicit VideoFrameMac(const MacDesktopConfiguration& desktop_config); | 97 explicit ScreenCaptureFrameMac(const MacDesktopConfiguration& desktop_config); |
98 virtual ~VideoFrameMac(); | 98 virtual ~ScreenCaptureFrameMac(); |
99 | 99 |
100 const SkIPoint& dpi() const { return dpi_; } | 100 const SkIPoint& dpi() const { return dpi_; } |
101 | 101 |
102 private: | 102 private: |
103 // Allocated pixel buffer. | 103 // Allocated pixel buffer. |
104 scoped_array<uint8> data_; | 104 scoped_array<uint8> data_; |
105 | 105 |
106 // DPI settings for this buffer. | 106 // DPI settings for this buffer. |
107 SkIPoint dpi_; | 107 SkIPoint dpi_; |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(VideoFrameMac); | 109 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameMac); |
110 }; | 110 }; |
111 | 111 |
112 // A class to perform video frame capturing for mac. | 112 // A class to perform video frame capturing for mac. |
113 class VideoFrameCapturerMac : public VideoFrameCapturer { | 113 class ScreenCapturerMac : public ScreenCapturer { |
114 public: | 114 public: |
115 VideoFrameCapturerMac(); | 115 ScreenCapturerMac(); |
116 virtual ~VideoFrameCapturerMac(); | 116 virtual ~ScreenCapturerMac(); |
117 | 117 |
118 bool Init(); | 118 bool Init(); |
119 | 119 |
120 // Overridden from VideoFrameCapturer: | 120 // Overridden from ScreenCapturer: |
121 virtual void Start(Delegate* delegate) OVERRIDE; | 121 virtual void Start(Delegate* delegate) OVERRIDE; |
122 virtual void Stop() OVERRIDE; | 122 virtual void Stop() OVERRIDE; |
123 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; | 123 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; |
124 virtual void CaptureFrame() OVERRIDE; | 124 virtual void CaptureFrame() OVERRIDE; |
125 | 125 |
126 private: | 126 private: |
127 void CaptureCursor(); | 127 void CaptureCursor(); |
128 | 128 |
129 void GlBlitFast(const VideoFrame& buffer, const SkRegion& region); | 129 void GlBlitFast(const ScreenCaptureFrame& buffer, const SkRegion& region); |
130 void GlBlitSlow(const VideoFrame& buffer); | 130 void GlBlitSlow(const ScreenCaptureFrame& buffer); |
131 void CgBlitPreLion(const VideoFrame& buffer, const SkRegion& region); | 131 void CgBlitPreLion(const ScreenCaptureFrame& buffer, const SkRegion& region); |
132 void CgBlitPostLion(const VideoFrame& buffer, const SkRegion& region); | 132 void CgBlitPostLion(const ScreenCaptureFrame& buffer, const SkRegion& region); |
133 | 133 |
134 // Called when the screen configuration is changed. | 134 // Called when the screen configuration is changed. |
135 void ScreenConfigurationChanged(); | 135 void ScreenConfigurationChanged(); |
136 | 136 |
137 void ScreenRefresh(CGRectCount count, const CGRect *rect_array); | 137 void ScreenRefresh(CGRectCount count, const CGRect *rect_array); |
138 void ScreenUpdateMove(CGScreenUpdateMoveDelta delta, | 138 void ScreenUpdateMove(CGScreenUpdateMoveDelta delta, |
139 size_t count, | 139 size_t count, |
140 const CGRect *rect_array); | 140 const CGRect *rect_array); |
141 void DisplaysReconfigured(CGDirectDisplayID display, | 141 void DisplaysReconfigured(CGDirectDisplayID display, |
142 CGDisplayChangeSummaryFlags flags); | 142 CGDisplayChangeSummaryFlags flags); |
143 static void ScreenRefreshCallback(CGRectCount count, | 143 static void ScreenRefreshCallback(CGRectCount count, |
144 const CGRect *rect_array, | 144 const CGRect *rect_array, |
145 void *user_parameter); | 145 void *user_parameter); |
146 static void ScreenUpdateMoveCallback(CGScreenUpdateMoveDelta delta, | 146 static void ScreenUpdateMoveCallback(CGScreenUpdateMoveDelta delta, |
147 size_t count, | 147 size_t count, |
148 const CGRect *rect_array, | 148 const CGRect *rect_array, |
149 void *user_parameter); | 149 void *user_parameter); |
150 static void DisplaysReconfiguredCallback(CGDirectDisplayID display, | 150 static void DisplaysReconfiguredCallback(CGDirectDisplayID display, |
151 CGDisplayChangeSummaryFlags flags, | 151 CGDisplayChangeSummaryFlags flags, |
152 void *user_parameter); | 152 void *user_parameter); |
153 | 153 |
154 void ReleaseBuffers(); | 154 void ReleaseBuffers(); |
155 | 155 |
156 Delegate* delegate_; | 156 Delegate* delegate_; |
157 | 157 |
158 CGLContextObj cgl_context_; | 158 CGLContextObj cgl_context_; |
159 ScopedPixelBufferObject pixel_buffer_object_; | 159 ScopedPixelBufferObject pixel_buffer_object_; |
160 | 160 |
161 // Queue of the frames buffers. | 161 // Queue of the frames buffers. |
162 VideoFrameQueue queue_; | 162 ScreenCaptureFrameQueue queue_; |
163 | 163 |
164 // Current display configuration. | 164 // Current display configuration. |
165 MacDesktopConfiguration desktop_config_; | 165 MacDesktopConfiguration desktop_config_; |
166 | 166 |
167 // A thread-safe list of invalid rectangles, and the size of the most | 167 // A thread-safe list of invalid rectangles, and the size of the most |
168 // recently captured screen. | 168 // recently captured screen. |
169 VideoFrameCapturerHelper helper_; | 169 ScreenCapturerHelper helper_; |
170 | 170 |
171 // Image of the last cursor that we sent to the client. | 171 // Image of the last cursor that we sent to the client. |
172 base::mac::ScopedCFTypeRef<CGImageRef> current_cursor_; | 172 base::mac::ScopedCFTypeRef<CGImageRef> current_cursor_; |
173 | 173 |
174 // Contains an invalid region from the previous capture. | 174 // Contains an invalid region from the previous capture. |
175 SkRegion last_invalid_region_; | 175 SkRegion last_invalid_region_; |
176 | 176 |
177 // Used to ensure that frame captures do not take place while displays | 177 // Used to ensure that frame captures do not take place while displays |
178 // are being reconfigured. | 178 // are being reconfigured. |
179 base::WaitableEvent display_configuration_capture_event_; | 179 base::WaitableEvent display_configuration_capture_event_; |
180 | 180 |
181 // Records the Ids of attached displays which are being reconfigured. | 181 // Records the Ids of attached displays which are being reconfigured. |
182 // Accessed on the thread on which we are notified of display events. | 182 // Accessed on the thread on which we are notified of display events. |
183 std::set<CGDirectDisplayID> reconfiguring_displays_; | 183 std::set<CGDirectDisplayID> reconfiguring_displays_; |
184 | 184 |
185 // Power management assertion to prevent the screen from sleeping. | 185 // Power management assertion to prevent the screen from sleeping. |
186 IOPMAssertionID power_assertion_id_display_; | 186 IOPMAssertionID power_assertion_id_display_; |
187 | 187 |
188 // Power management assertion to indicate that the user is active. | 188 // Power management assertion to indicate that the user is active. |
189 IOPMAssertionID power_assertion_id_user_; | 189 IOPMAssertionID power_assertion_id_user_; |
190 | 190 |
191 // Dynamically link to deprecated APIs for Mac OS X 10.6 support. | 191 // Dynamically link to deprecated APIs for Mac OS X 10.6 support. |
192 base::ScopedNativeLibrary app_services_library_; | 192 base::ScopedNativeLibrary app_services_library_; |
193 CGDisplayBaseAddressFunc cg_display_base_address_; | 193 CGDisplayBaseAddressFunc cg_display_base_address_; |
194 CGDisplayBytesPerRowFunc cg_display_bytes_per_row_; | 194 CGDisplayBytesPerRowFunc cg_display_bytes_per_row_; |
195 CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_; | 195 CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_; |
196 base::ScopedNativeLibrary opengl_library_; | 196 base::ScopedNativeLibrary opengl_library_; |
197 CGLSetFullScreenFunc cgl_set_full_screen_; | 197 CGLSetFullScreenFunc cgl_set_full_screen_; |
198 | 198 |
199 DISALLOW_COPY_AND_ASSIGN(VideoFrameCapturerMac); | 199 DISALLOW_COPY_AND_ASSIGN(ScreenCapturerMac); |
200 }; | 200 }; |
201 | 201 |
202 VideoFrameMac::VideoFrameMac(const MacDesktopConfiguration& desktop_config) { | 202 ScreenCaptureFrameMac::ScreenCaptureFrameMac( |
| 203 const MacDesktopConfiguration& desktop_config) { |
203 SkISize size = SkISize::Make(desktop_config.pixel_bounds.width(), | 204 SkISize size = SkISize::Make(desktop_config.pixel_bounds.width(), |
204 desktop_config.pixel_bounds.height()); | 205 desktop_config.pixel_bounds.height()); |
205 set_bytes_per_row(size.width() * sizeof(uint32_t)); | 206 set_bytes_per_row(size.width() * sizeof(uint32_t)); |
206 set_dimensions(size); | 207 set_dimensions(size); |
207 | 208 |
208 size_t buffer_size = size.width() * size.height() * sizeof(uint32_t); | 209 size_t buffer_size = size.width() * size.height() * sizeof(uint32_t); |
209 data_.reset(new uint8[buffer_size]); | 210 data_.reset(new uint8[buffer_size]); |
210 set_pixels(data_.get()); | 211 set_pixels(data_.get()); |
211 | 212 |
212 dpi_ = SkIPoint::Make(kStandardDPI * desktop_config.dip_to_pixel_scale, | 213 dpi_ = SkIPoint::Make(kStandardDPI * desktop_config.dip_to_pixel_scale, |
213 kStandardDPI * desktop_config.dip_to_pixel_scale); | 214 kStandardDPI * desktop_config.dip_to_pixel_scale); |
214 } | 215 } |
215 | 216 |
216 VideoFrameMac::~VideoFrameMac() { | 217 ScreenCaptureFrameMac::~ScreenCaptureFrameMac() { |
217 } | 218 } |
218 | 219 |
219 VideoFrameCapturerMac::VideoFrameCapturerMac() | 220 ScreenCapturerMac::ScreenCapturerMac() |
220 : delegate_(NULL), | 221 : delegate_(NULL), |
221 cgl_context_(NULL), | 222 cgl_context_(NULL), |
222 display_configuration_capture_event_(false, true), | 223 display_configuration_capture_event_(false, true), |
223 power_assertion_id_display_(kIOPMNullAssertionID), | 224 power_assertion_id_display_(kIOPMNullAssertionID), |
224 power_assertion_id_user_(kIOPMNullAssertionID), | 225 power_assertion_id_user_(kIOPMNullAssertionID), |
225 cg_display_base_address_(NULL), | 226 cg_display_base_address_(NULL), |
226 cg_display_bytes_per_row_(NULL), | 227 cg_display_bytes_per_row_(NULL), |
227 cg_display_bits_per_pixel_(NULL), | 228 cg_display_bits_per_pixel_(NULL), |
228 cgl_set_full_screen_(NULL) | 229 cgl_set_full_screen_(NULL) |
229 { | 230 { |
230 } | 231 } |
231 | 232 |
232 VideoFrameCapturerMac::~VideoFrameCapturerMac() { | 233 ScreenCapturerMac::~ScreenCapturerMac() { |
233 ReleaseBuffers(); | 234 ReleaseBuffers(); |
234 CGUnregisterScreenRefreshCallback( | 235 CGUnregisterScreenRefreshCallback( |
235 VideoFrameCapturerMac::ScreenRefreshCallback, this); | 236 ScreenCapturerMac::ScreenRefreshCallback, this); |
236 CGScreenUnregisterMoveCallback( | 237 CGScreenUnregisterMoveCallback( |
237 VideoFrameCapturerMac::ScreenUpdateMoveCallback, this); | 238 ScreenCapturerMac::ScreenUpdateMoveCallback, this); |
238 CGError err = CGDisplayRemoveReconfigurationCallback( | 239 CGError err = CGDisplayRemoveReconfigurationCallback( |
239 VideoFrameCapturerMac::DisplaysReconfiguredCallback, this); | 240 ScreenCapturerMac::DisplaysReconfiguredCallback, this); |
240 if (err != kCGErrorSuccess) { | 241 if (err != kCGErrorSuccess) { |
241 LOG(ERROR) << "CGDisplayRemoveReconfigurationCallback " << err; | 242 LOG(ERROR) << "CGDisplayRemoveReconfigurationCallback " << err; |
242 } | 243 } |
243 } | 244 } |
244 | 245 |
245 bool VideoFrameCapturerMac::Init() { | 246 bool ScreenCapturerMac::Init() { |
246 CGError err = CGRegisterScreenRefreshCallback( | 247 CGError err = CGRegisterScreenRefreshCallback( |
247 VideoFrameCapturerMac::ScreenRefreshCallback, this); | 248 ScreenCapturerMac::ScreenRefreshCallback, this); |
248 if (err != kCGErrorSuccess) { | 249 if (err != kCGErrorSuccess) { |
249 LOG(ERROR) << "CGRegisterScreenRefreshCallback " << err; | 250 LOG(ERROR) << "CGRegisterScreenRefreshCallback " << err; |
250 return false; | 251 return false; |
251 } | 252 } |
252 | 253 |
253 err = CGScreenRegisterMoveCallback( | 254 err = CGScreenRegisterMoveCallback( |
254 VideoFrameCapturerMac::ScreenUpdateMoveCallback, this); | 255 ScreenCapturerMac::ScreenUpdateMoveCallback, this); |
255 if (err != kCGErrorSuccess) { | 256 if (err != kCGErrorSuccess) { |
256 LOG(ERROR) << "CGScreenRegisterMoveCallback " << err; | 257 LOG(ERROR) << "CGScreenRegisterMoveCallback " << err; |
257 return false; | 258 return false; |
258 } | 259 } |
259 err = CGDisplayRegisterReconfigurationCallback( | 260 err = CGDisplayRegisterReconfigurationCallback( |
260 VideoFrameCapturerMac::DisplaysReconfiguredCallback, this); | 261 ScreenCapturerMac::DisplaysReconfiguredCallback, this); |
261 if (err != kCGErrorSuccess) { | 262 if (err != kCGErrorSuccess) { |
262 LOG(ERROR) << "CGDisplayRegisterReconfigurationCallback " << err; | 263 LOG(ERROR) << "CGDisplayRegisterReconfigurationCallback " << err; |
263 return false; | 264 return false; |
264 } | 265 } |
265 | 266 |
266 ScreenConfigurationChanged(); | 267 ScreenConfigurationChanged(); |
267 return true; | 268 return true; |
268 } | 269 } |
269 | 270 |
270 void VideoFrameCapturerMac::ReleaseBuffers() { | 271 void ScreenCapturerMac::ReleaseBuffers() { |
271 if (cgl_context_) { | 272 if (cgl_context_) { |
272 pixel_buffer_object_.Release(); | 273 pixel_buffer_object_.Release(); |
273 CGLDestroyContext(cgl_context_); | 274 CGLDestroyContext(cgl_context_); |
274 cgl_context_ = NULL; | 275 cgl_context_ = NULL; |
275 } | 276 } |
276 // The buffers might be in use by the encoder, so don't delete them here. | 277 // The buffers might be in use by the encoder, so don't delete them here. |
277 // Instead, mark them as "needs update"; next time the buffers are used by | 278 // Instead, mark them as "needs update"; next time the buffers are used by |
278 // the capturer, they will be recreated if necessary. | 279 // the capturer, they will be recreated if necessary. |
279 queue_.SetAllFramesNeedUpdate(); | 280 queue_.SetAllFramesNeedUpdate(); |
280 } | 281 } |
281 | 282 |
282 void VideoFrameCapturerMac::Start(Delegate* delegate) { | 283 void ScreenCapturerMac::Start(Delegate* delegate) { |
283 DCHECK(delegate_ == NULL); | 284 DCHECK(delegate_ == NULL); |
284 | 285 |
285 delegate_ = delegate; | 286 delegate_ = delegate; |
286 | 287 |
287 // Create power management assertions to wake the display and prevent it from | 288 // Create power management assertions to wake the display and prevent it from |
288 // going to sleep on user idle. | 289 // going to sleep on user idle. |
289 // TODO(jamiewalch): Use IOPMAssertionDeclareUserActivity on 10.7.3 and above | 290 // TODO(jamiewalch): Use IOPMAssertionDeclareUserActivity on 10.7.3 and above |
290 // instead of the following two assertions. | 291 // instead of the following two assertions. |
291 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, | 292 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, |
292 kIOPMAssertionLevelOn, | 293 kIOPMAssertionLevelOn, |
293 CFSTR("Chrome Remote Desktop connection active"), | 294 CFSTR("Chrome Remote Desktop connection active"), |
294 &power_assertion_id_display_); | 295 &power_assertion_id_display_); |
295 // This assertion ensures that the display is woken up if it already asleep | 296 // This assertion ensures that the display is woken up if it already asleep |
296 // (as used by Apple Remote Desktop). | 297 // (as used by Apple Remote Desktop). |
297 IOPMAssertionCreateWithName(CFSTR("UserIsActive"), | 298 IOPMAssertionCreateWithName(CFSTR("UserIsActive"), |
298 kIOPMAssertionLevelOn, | 299 kIOPMAssertionLevelOn, |
299 CFSTR("Chrome Remote Desktop connection active"), | 300 CFSTR("Chrome Remote Desktop connection active"), |
300 &power_assertion_id_user_); | 301 &power_assertion_id_user_); |
301 } | 302 } |
302 | 303 |
303 void VideoFrameCapturerMac::Stop() { | 304 void ScreenCapturerMac::Stop() { |
304 if (power_assertion_id_display_ != kIOPMNullAssertionID) { | 305 if (power_assertion_id_display_ != kIOPMNullAssertionID) { |
305 IOPMAssertionRelease(power_assertion_id_display_); | 306 IOPMAssertionRelease(power_assertion_id_display_); |
306 power_assertion_id_display_ = kIOPMNullAssertionID; | 307 power_assertion_id_display_ = kIOPMNullAssertionID; |
307 } | 308 } |
308 if (power_assertion_id_user_ != kIOPMNullAssertionID) { | 309 if (power_assertion_id_user_ != kIOPMNullAssertionID) { |
309 IOPMAssertionRelease(power_assertion_id_user_); | 310 IOPMAssertionRelease(power_assertion_id_user_); |
310 power_assertion_id_user_ = kIOPMNullAssertionID; | 311 power_assertion_id_user_ = kIOPMNullAssertionID; |
311 } | 312 } |
312 } | 313 } |
313 | 314 |
314 void VideoFrameCapturerMac::InvalidateRegion(const SkRegion& invalid_region) { | 315 void ScreenCapturerMac::InvalidateRegion(const SkRegion& invalid_region) { |
315 helper_.InvalidateRegion(invalid_region); | 316 helper_.InvalidateRegion(invalid_region); |
316 } | 317 } |
317 | 318 |
318 void VideoFrameCapturerMac::CaptureFrame() { | 319 void ScreenCapturerMac::CaptureFrame() { |
319 // Only allow captures when the display configuration is not occurring. | 320 // Only allow captures when the display configuration is not occurring. |
320 scoped_refptr<CaptureData> data; | 321 scoped_refptr<ScreenCaptureData> data; |
321 | 322 |
322 base::Time capture_start_time = base::Time::Now(); | 323 base::Time capture_start_time = base::Time::Now(); |
323 | 324 |
324 // Wait until the display configuration is stable. If one or more displays | 325 // Wait until the display configuration is stable. If one or more displays |
325 // are reconfiguring then |display_configuration_capture_event_| will not be | 326 // are reconfiguring then |display_configuration_capture_event_| will not be |
326 // set until the reconfiguration completes. | 327 // set until the reconfiguration completes. |
327 // TODO(wez): Replace this with an early-exit (See crbug.com/104542). | 328 // TODO(wez): Replace this with an early-exit (See crbug.com/104542). |
328 CHECK(display_configuration_capture_event_.TimedWait( | 329 CHECK(display_configuration_capture_event_.TimedWait( |
329 base::TimeDelta::FromSeconds( | 330 base::TimeDelta::FromSeconds( |
330 kDisplayConfigurationEventTimeoutInSeconds))); | 331 kDisplayConfigurationEventTimeoutInSeconds))); |
331 | 332 |
332 SkRegion region; | 333 SkRegion region; |
333 helper_.SwapInvalidRegion(®ion); | 334 helper_.SwapInvalidRegion(®ion); |
334 | 335 |
335 // If the current buffer is from an older generation then allocate a new one. | 336 // If the current buffer is from an older generation then allocate a new one. |
336 // Note that we can't reallocate other buffers at this point, since the caller | 337 // Note that we can't reallocate other buffers at this point, since the caller |
337 // may still be reading from them. | 338 // may still be reading from them. |
338 if (queue_.current_frame_needs_update()) { | 339 if (queue_.current_frame_needs_update()) { |
339 scoped_ptr<VideoFrameMac> buffer(new VideoFrameMac(desktop_config_)); | 340 scoped_ptr<ScreenCaptureFrameMac> buffer( |
340 queue_.ReplaceCurrentFrame(buffer.PassAs<VideoFrame>()); | 341 new ScreenCaptureFrameMac(desktop_config_)); |
| 342 queue_.ReplaceCurrentFrame(buffer.PassAs<ScreenCaptureFrame>()); |
341 } | 343 } |
342 | 344 |
343 VideoFrame* current_buffer = queue_.current_frame(); | 345 ScreenCaptureFrame* current_buffer = queue_.current_frame(); |
344 | 346 |
345 bool flip = false; // GL capturers need flipping. | 347 bool flip = false; // GL capturers need flipping. |
346 if (base::mac::IsOSLionOrLater()) { | 348 if (base::mac::IsOSLionOrLater()) { |
347 // Lion requires us to use their new APIs for doing screen capture. These | 349 // Lion requires us to use their new APIs for doing screen capture. These |
348 // APIS currently crash on 10.6.8 if there is no monitor attached. | 350 // APIS currently crash on 10.6.8 if there is no monitor attached. |
349 CgBlitPostLion(*current_buffer, region); | 351 CgBlitPostLion(*current_buffer, region); |
350 } else if (cgl_context_) { | 352 } else if (cgl_context_) { |
351 flip = true; | 353 flip = true; |
352 if (pixel_buffer_object_.get() != 0) { | 354 if (pixel_buffer_object_.get() != 0) { |
353 GlBlitFast(*current_buffer, region); | 355 GlBlitFast(*current_buffer, region); |
354 } else { | 356 } else { |
355 // See comment in ScopedPixelBufferObject::Init about why the slow | 357 // See comment in ScopedPixelBufferObject::Init about why the slow |
356 // path is always used on 10.5. | 358 // path is always used on 10.5. |
357 GlBlitSlow(*current_buffer); | 359 GlBlitSlow(*current_buffer); |
358 } | 360 } |
359 } else { | 361 } else { |
360 CgBlitPreLion(*current_buffer, region); | 362 CgBlitPreLion(*current_buffer, region); |
361 } | 363 } |
362 | 364 |
363 uint8* buffer = current_buffer->pixels(); | 365 uint8* buffer = current_buffer->pixels(); |
364 int stride = current_buffer->bytes_per_row(); | 366 int stride = current_buffer->bytes_per_row(); |
365 if (flip) { | 367 if (flip) { |
366 stride = -stride; | 368 stride = -stride; |
367 buffer += (current_buffer->dimensions().height() - 1) * | 369 buffer += (current_buffer->dimensions().height() - 1) * |
368 current_buffer->bytes_per_row(); | 370 current_buffer->bytes_per_row(); |
369 } | 371 } |
370 | 372 |
371 data = new CaptureData(buffer, stride, current_buffer->dimensions()); | 373 data = new ScreenCaptureData(buffer, stride, current_buffer->dimensions()); |
372 data->set_dpi(static_cast<VideoFrameMac*>(current_buffer)->dpi()); | 374 data->set_dpi(static_cast<ScreenCaptureFrameMac*>(current_buffer)->dpi()); |
373 data->mutable_dirty_region() = region; | 375 data->mutable_dirty_region() = region; |
374 | 376 |
375 helper_.set_size_most_recent(data->size()); | 377 helper_.set_size_most_recent(data->size()); |
376 | 378 |
377 // Signal that we are done capturing data from the display framebuffer, | 379 // Signal that we are done capturing data from the display framebuffer, |
378 // and accessing display structures. | 380 // and accessing display structures. |
379 display_configuration_capture_event_.Signal(); | 381 display_configuration_capture_event_.Signal(); |
380 | 382 |
381 // Capture the current cursor shape and notify |delegate_| if it has changed. | 383 // Capture the current cursor shape and notify |delegate_| if it has changed. |
382 CaptureCursor(); | 384 CaptureCursor(); |
383 | 385 |
384 // Move the capture frame buffer queue on to the next buffer. | 386 // Move the capture frame buffer queue on to the next buffer. |
385 queue_.DoneWithCurrentFrame(); | 387 queue_.DoneWithCurrentFrame(); |
386 | 388 |
387 data->set_capture_time_ms( | 389 data->set_capture_time_ms( |
388 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); | 390 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); |
389 delegate_->OnCaptureCompleted(data); | 391 delegate_->OnCaptureCompleted(data); |
390 } | 392 } |
391 | 393 |
392 void VideoFrameCapturerMac::CaptureCursor() { | 394 void ScreenCapturerMac::CaptureCursor() { |
393 NSCursor* cursor = [NSCursor currentSystemCursor]; | 395 NSCursor* cursor = [NSCursor currentSystemCursor]; |
394 if (cursor == nil) { | 396 if (cursor == nil) { |
395 return; | 397 return; |
396 } | 398 } |
397 | 399 |
398 NSImage* nsimage = [cursor image]; | 400 NSImage* nsimage = [cursor image]; |
399 NSPoint hotspot = [cursor hotSpot]; | 401 NSPoint hotspot = [cursor hotSpot]; |
400 NSSize size = [nsimage size]; | 402 NSSize size = [nsimage size]; |
401 CGImageRef image = [nsimage CGImageForProposedRect:NULL | 403 CGImageRef image = [nsimage CGImageForProposedRect:NULL |
402 context:nil | 404 context:nil |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // Create a MouseCursorShape that describes the cursor and pass it to | 460 // Create a MouseCursorShape that describes the cursor and pass it to |
459 // the client. | 461 // the client. |
460 scoped_ptr<MouseCursorShape> cursor_shape(new MouseCursorShape()); | 462 scoped_ptr<MouseCursorShape> cursor_shape(new MouseCursorShape()); |
461 cursor_shape->size.set(size.width, size.height); | 463 cursor_shape->size.set(size.width, size.height); |
462 cursor_shape->hotspot.set(hotspot.x, hotspot.y); | 464 cursor_shape->hotspot.set(hotspot.x, hotspot.y); |
463 cursor_shape->data.assign(cursor_src_data, cursor_src_data + data_size); | 465 cursor_shape->data.assign(cursor_src_data, cursor_src_data + data_size); |
464 | 466 |
465 delegate_->OnCursorShapeChanged(cursor_shape.Pass()); | 467 delegate_->OnCursorShapeChanged(cursor_shape.Pass()); |
466 } | 468 } |
467 | 469 |
468 void VideoFrameCapturerMac::GlBlitFast(const VideoFrame& buffer, | 470 void ScreenCapturerMac::GlBlitFast(const ScreenCaptureFrame& buffer, |
469 const SkRegion& region) { | 471 const SkRegion& region) { |
470 const int buffer_height = buffer.dimensions().height(); | 472 const int buffer_height = buffer.dimensions().height(); |
471 const int buffer_width = buffer.dimensions().width(); | 473 const int buffer_width = buffer.dimensions().width(); |
472 | 474 |
473 // Clip to the size of our current screen. | 475 // Clip to the size of our current screen. |
474 SkIRect clip_rect = SkIRect::MakeWH(buffer_width, buffer_height); | 476 SkIRect clip_rect = SkIRect::MakeWH(buffer_width, buffer_height); |
475 if (queue_.previous_frame()) { | 477 if (queue_.previous_frame()) { |
476 // We are doing double buffer for the capture data so we just need to copy | 478 // We are doing double buffer for the capture data so we just need to copy |
477 // the invalid region from the previous capture in the current buffer. | 479 // the invalid region from the previous capture in the current buffer. |
478 // TODO(hclam): We can reduce the amount of copying here by subtracting | 480 // TODO(hclam): We can reduce the amount of copying here by subtracting |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // If glUnmapBuffer returns false, then the contents of the data store are | 527 // If glUnmapBuffer returns false, then the contents of the data store are |
526 // undefined. This might be because the screen mode has changed, in which | 528 // undefined. This might be because the screen mode has changed, in which |
527 // case it will be recreated in ScreenConfigurationChanged, but releasing | 529 // case it will be recreated in ScreenConfigurationChanged, but releasing |
528 // the object here is the best option. Capturing will fall back on | 530 // the object here is the best option. Capturing will fall back on |
529 // GlBlitSlow until such time as the pixel buffer object is recreated. | 531 // GlBlitSlow until such time as the pixel buffer object is recreated. |
530 pixel_buffer_object_.Release(); | 532 pixel_buffer_object_.Release(); |
531 } | 533 } |
532 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); | 534 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); |
533 } | 535 } |
534 | 536 |
535 void VideoFrameCapturerMac::GlBlitSlow(const VideoFrame& buffer) { | 537 void ScreenCapturerMac::GlBlitSlow(const ScreenCaptureFrame& buffer) { |
536 CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; | 538 CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; |
537 glReadBuffer(GL_FRONT); | 539 glReadBuffer(GL_FRONT); |
538 glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); | 540 glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); |
539 glPixelStorei(GL_PACK_ALIGNMENT, 4); // Force 4-byte alignment. | 541 glPixelStorei(GL_PACK_ALIGNMENT, 4); // Force 4-byte alignment. |
540 glPixelStorei(GL_PACK_ROW_LENGTH, 0); | 542 glPixelStorei(GL_PACK_ROW_LENGTH, 0); |
541 glPixelStorei(GL_PACK_SKIP_ROWS, 0); | 543 glPixelStorei(GL_PACK_SKIP_ROWS, 0); |
542 glPixelStorei(GL_PACK_SKIP_PIXELS, 0); | 544 glPixelStorei(GL_PACK_SKIP_PIXELS, 0); |
543 // Read a block of pixels from the frame buffer. | 545 // Read a block of pixels from the frame buffer. |
544 glReadPixels(0, 0, buffer.dimensions().width(), buffer.dimensions().height(), | 546 glReadPixels(0, 0, buffer.dimensions().width(), buffer.dimensions().height(), |
545 GL_BGRA, GL_UNSIGNED_BYTE, buffer.pixels()); | 547 GL_BGRA, GL_UNSIGNED_BYTE, buffer.pixels()); |
546 glPopClientAttrib(); | 548 glPopClientAttrib(); |
547 } | 549 } |
548 | 550 |
549 void VideoFrameCapturerMac::CgBlitPreLion(const VideoFrame& buffer, | 551 void ScreenCapturerMac::CgBlitPreLion(const ScreenCaptureFrame& buffer, |
550 const SkRegion& region) { | 552 const SkRegion& region) { |
551 const int buffer_height = buffer.dimensions().height(); | 553 const int buffer_height = buffer.dimensions().height(); |
552 | 554 |
553 // Copy the entire contents of the previous capture buffer, to capture over. | 555 // Copy the entire contents of the previous capture buffer, to capture over. |
554 // TODO(wez): Get rid of this as per crbug.com/145064, or implement | 556 // TODO(wez): Get rid of this as per crbug.com/145064, or implement |
555 // crbug.com/92354. | 557 // crbug.com/92354. |
556 if (queue_.previous_frame()) { | 558 if (queue_.previous_frame()) { |
557 memcpy(buffer.pixels(), | 559 memcpy(buffer.pixels(), |
558 queue_.previous_frame()->pixels(), | 560 queue_.previous_frame()->pixels(), |
559 buffer.bytes_per_row() * buffer_height); | 561 buffer.bytes_per_row() * buffer_height); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 CopyRect(display_base_address, | 598 CopyRect(display_base_address, |
597 src_bytes_per_row, | 599 src_bytes_per_row, |
598 out_ptr, | 600 out_ptr, |
599 buffer.bytes_per_row(), | 601 buffer.bytes_per_row(), |
600 src_bytes_per_pixel, | 602 src_bytes_per_pixel, |
601 i.rect()); | 603 i.rect()); |
602 } | 604 } |
603 } | 605 } |
604 } | 606 } |
605 | 607 |
606 void VideoFrameCapturerMac::CgBlitPostLion(const VideoFrame& buffer, | 608 void ScreenCapturerMac::CgBlitPostLion(const ScreenCaptureFrame& buffer, |
607 const SkRegion& region) { | 609 const SkRegion& region) { |
608 const int buffer_height = buffer.dimensions().height(); | 610 const int buffer_height = buffer.dimensions().height(); |
609 | 611 |
610 // Copy the entire contents of the previous capture buffer, to capture over. | 612 // Copy the entire contents of the previous capture buffer, to capture over. |
611 // TODO(wez): Get rid of this as per crbug.com/145064, or implement | 613 // TODO(wez): Get rid of this as per crbug.com/145064, or implement |
612 // crbug.com/92354. | 614 // crbug.com/92354. |
613 if (queue_.previous_frame()) { | 615 if (queue_.previous_frame()) { |
614 memcpy(buffer.pixels(), | 616 memcpy(buffer.pixels(), |
615 queue_.previous_frame()->pixels(), | 617 queue_.previous_frame()->pixels(), |
616 buffer.bytes_per_row() * buffer_height); | 618 buffer.bytes_per_row() * buffer_height); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 CopyRect(display_base_address, | 662 CopyRect(display_base_address, |
661 src_bytes_per_row, | 663 src_bytes_per_row, |
662 out_ptr, | 664 out_ptr, |
663 buffer.bytes_per_row(), | 665 buffer.bytes_per_row(), |
664 src_bytes_per_pixel, | 666 src_bytes_per_pixel, |
665 i.rect()); | 667 i.rect()); |
666 } | 668 } |
667 } | 669 } |
668 } | 670 } |
669 | 671 |
670 void VideoFrameCapturerMac::ScreenConfigurationChanged() { | 672 void ScreenCapturerMac::ScreenConfigurationChanged() { |
671 // Release existing buffers, which will be of the wrong size. | 673 // Release existing buffers, which will be of the wrong size. |
672 ReleaseBuffers(); | 674 ReleaseBuffers(); |
673 | 675 |
674 // Clear the dirty region, in case the display is down-sizing. | 676 // Clear the dirty region, in case the display is down-sizing. |
675 helper_.ClearInvalidRegion(); | 677 helper_.ClearInvalidRegion(); |
676 | 678 |
677 // Refresh the cached desktop configuration. | 679 // Refresh the cached desktop configuration. |
678 desktop_config_ = MacDesktopConfiguration::GetCurrent(); | 680 desktop_config_ = MacDesktopConfiguration::GetCurrent(); |
679 | 681 |
680 // Re-mark the entire desktop as dirty. | 682 // Re-mark the entire desktop as dirty. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 CGLDestroyPixelFormat(pixel_format); | 751 CGLDestroyPixelFormat(pixel_format); |
750 (*cgl_set_full_screen_)(cgl_context_); | 752 (*cgl_set_full_screen_)(cgl_context_); |
751 CGLSetCurrentContext(cgl_context_); | 753 CGLSetCurrentContext(cgl_context_); |
752 | 754 |
753 size_t buffer_size = desktop_config_.pixel_bounds.width() * | 755 size_t buffer_size = desktop_config_.pixel_bounds.width() * |
754 desktop_config_.pixel_bounds.height() * | 756 desktop_config_.pixel_bounds.height() * |
755 sizeof(uint32_t); | 757 sizeof(uint32_t); |
756 pixel_buffer_object_.Init(cgl_context_, buffer_size); | 758 pixel_buffer_object_.Init(cgl_context_, buffer_size); |
757 } | 759 } |
758 | 760 |
759 void VideoFrameCapturerMac::ScreenRefresh(CGRectCount count, | 761 void ScreenCapturerMac::ScreenRefresh(CGRectCount count, |
760 const CGRect* rect_array) { | 762 const CGRect* rect_array) { |
761 if (desktop_config_.pixel_bounds.isEmpty()) { | 763 if (desktop_config_.pixel_bounds.isEmpty()) { |
762 return; | 764 return; |
763 } | 765 } |
764 SkIRect skirect_array[count]; | 766 SkIRect skirect_array[count]; |
765 | 767 |
766 for (CGRectCount i = 0; i < count; ++i) { | 768 for (CGRectCount i = 0; i < count; ++i) { |
767 SkRect sk_rect = gfx::CGRectToSkRect(rect_array[i]); | 769 SkRect sk_rect = gfx::CGRectToSkRect(rect_array[i]); |
768 | 770 |
769 // Convert from Density-Independent Pixel to physical pixel coordinates. | 771 // Convert from Density-Independent Pixel to physical pixel coordinates. |
770 sk_rect = ScaleSkRect(sk_rect, desktop_config_.dip_to_pixel_scale); | 772 sk_rect = ScaleSkRect(sk_rect, desktop_config_.dip_to_pixel_scale); |
771 sk_rect.round(&skirect_array[i]); | 773 sk_rect.round(&skirect_array[i]); |
772 | 774 |
773 // Translate from local desktop to capturer framebuffer coordinates. | 775 // Translate from local desktop to capturer framebuffer coordinates. |
774 skirect_array[i].offset(-desktop_config_.pixel_bounds.left(), | 776 skirect_array[i].offset(-desktop_config_.pixel_bounds.left(), |
775 -desktop_config_.pixel_bounds.top()); | 777 -desktop_config_.pixel_bounds.top()); |
776 } | 778 } |
777 | 779 |
778 SkRegion region; | 780 SkRegion region; |
779 region.setRects(skirect_array, count); | 781 region.setRects(skirect_array, count); |
780 InvalidateRegion(region); | 782 InvalidateRegion(region); |
781 } | 783 } |
782 | 784 |
783 void VideoFrameCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta, | 785 void ScreenCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta, |
784 size_t count, | 786 size_t count, |
785 const CGRect* rect_array) { | 787 const CGRect* rect_array) { |
786 // Translate |rect_array| to identify the move's destination. | 788 // Translate |rect_array| to identify the move's destination. |
787 CGRect refresh_rects[count]; | 789 CGRect refresh_rects[count]; |
788 for (CGRectCount i = 0; i < count; ++i) { | 790 for (CGRectCount i = 0; i < count; ++i) { |
789 refresh_rects[i] = CGRectOffset(rect_array[i], delta.dX, delta.dY); | 791 refresh_rects[i] = CGRectOffset(rect_array[i], delta.dX, delta.dY); |
790 } | 792 } |
791 | 793 |
792 // Currently we just treat move events the same as refreshes. | 794 // Currently we just treat move events the same as refreshes. |
793 ScreenRefresh(count, refresh_rects); | 795 ScreenRefresh(count, refresh_rects); |
794 } | 796 } |
795 | 797 |
796 void VideoFrameCapturerMac::DisplaysReconfigured( | 798 void ScreenCapturerMac::DisplaysReconfigured( |
797 CGDirectDisplayID display, | 799 CGDirectDisplayID display, |
798 CGDisplayChangeSummaryFlags flags) { | 800 CGDisplayChangeSummaryFlags flags) { |
799 if (flags & kCGDisplayBeginConfigurationFlag) { | 801 if (flags & kCGDisplayBeginConfigurationFlag) { |
800 if (reconfiguring_displays_.empty()) { | 802 if (reconfiguring_displays_.empty()) { |
801 // If this is the first display to start reconfiguring then wait on | 803 // If this is the first display to start reconfiguring then wait on |
802 // |display_configuration_capture_event_| to block the capture thread | 804 // |display_configuration_capture_event_| to block the capture thread |
803 // from accessing display memory until the reconfiguration completes. | 805 // from accessing display memory until the reconfiguration completes. |
804 CHECK(display_configuration_capture_event_.TimedWait( | 806 CHECK(display_configuration_capture_event_.TimedWait( |
805 base::TimeDelta::FromSeconds( | 807 base::TimeDelta::FromSeconds( |
806 kDisplayConfigurationEventTimeoutInSeconds))); | 808 kDisplayConfigurationEventTimeoutInSeconds))); |
807 } | 809 } |
808 | 810 |
809 reconfiguring_displays_.insert(display); | 811 reconfiguring_displays_.insert(display); |
810 } else { | 812 } else { |
811 reconfiguring_displays_.erase(display); | 813 reconfiguring_displays_.erase(display); |
812 | 814 |
813 if (reconfiguring_displays_.empty()) { | 815 if (reconfiguring_displays_.empty()) { |
814 // If no other displays are reconfiguring then refresh capturer data | 816 // If no other displays are reconfiguring then refresh capturer data |
815 // structures and un-block the capturer thread. | 817 // structures and un-block the capturer thread. |
816 ScreenConfigurationChanged(); | 818 ScreenConfigurationChanged(); |
817 display_configuration_capture_event_.Signal(); | 819 display_configuration_capture_event_.Signal(); |
818 } | 820 } |
819 } | 821 } |
820 } | 822 } |
821 | 823 |
822 void VideoFrameCapturerMac::ScreenRefreshCallback(CGRectCount count, | 824 void ScreenCapturerMac::ScreenRefreshCallback(CGRectCount count, |
823 const CGRect* rect_array, | 825 const CGRect* rect_array, |
824 void* user_parameter) { | 826 void* user_parameter) { |
825 VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>( | 827 ScreenCapturerMac* capturer = reinterpret_cast<ScreenCapturerMac*>( |
826 user_parameter); | 828 user_parameter); |
827 if (capturer->desktop_config_.pixel_bounds.isEmpty()) { | 829 if (capturer->desktop_config_.pixel_bounds.isEmpty()) { |
828 capturer->ScreenConfigurationChanged(); | 830 capturer->ScreenConfigurationChanged(); |
829 } | 831 } |
830 capturer->ScreenRefresh(count, rect_array); | 832 capturer->ScreenRefresh(count, rect_array); |
831 } | 833 } |
832 | 834 |
833 void VideoFrameCapturerMac::ScreenUpdateMoveCallback( | 835 void ScreenCapturerMac::ScreenUpdateMoveCallback( |
834 CGScreenUpdateMoveDelta delta, | 836 CGScreenUpdateMoveDelta delta, |
835 size_t count, | 837 size_t count, |
836 const CGRect* rect_array, | 838 const CGRect* rect_array, |
837 void* user_parameter) { | 839 void* user_parameter) { |
838 VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>( | 840 ScreenCapturerMac* capturer = reinterpret_cast<ScreenCapturerMac*>( |
839 user_parameter); | 841 user_parameter); |
840 capturer->ScreenUpdateMove(delta, count, rect_array); | 842 capturer->ScreenUpdateMove(delta, count, rect_array); |
841 } | 843 } |
842 | 844 |
843 void VideoFrameCapturerMac::DisplaysReconfiguredCallback( | 845 void ScreenCapturerMac::DisplaysReconfiguredCallback( |
844 CGDirectDisplayID display, | 846 CGDirectDisplayID display, |
845 CGDisplayChangeSummaryFlags flags, | 847 CGDisplayChangeSummaryFlags flags, |
846 void* user_parameter) { | 848 void* user_parameter) { |
847 VideoFrameCapturerMac* capturer = reinterpret_cast<VideoFrameCapturerMac*>( | 849 ScreenCapturerMac* capturer = reinterpret_cast<ScreenCapturerMac*>( |
848 user_parameter); | 850 user_parameter); |
849 capturer->DisplaysReconfigured(display, flags); | 851 capturer->DisplaysReconfigured(display, flags); |
850 } | 852 } |
851 | 853 |
852 } // namespace | 854 } // namespace |
853 | 855 |
854 // static | 856 // static |
855 scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::Create() { | 857 scoped_ptr<ScreenCapturer> ScreenCapturer::Create() { |
856 scoped_ptr<VideoFrameCapturerMac> capturer(new VideoFrameCapturerMac()); | 858 scoped_ptr<ScreenCapturerMac> capturer(new ScreenCapturerMac()); |
857 if (!capturer->Init()) | 859 if (!capturer->Init()) |
858 capturer.reset(); | 860 capturer.reset(); |
859 return capturer.PassAs<VideoFrameCapturer>(); | 861 return capturer.PassAs<ScreenCapturer>(); |
860 } | 862 } |
861 | 863 |
862 // static | 864 // static |
863 scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::CreateWithFactory( | 865 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithFactory( |
864 SharedBufferFactory* shared_buffer_factory) { | 866 SharedBufferFactory* shared_buffer_factory) { |
865 NOTIMPLEMENTED(); | 867 NOTIMPLEMENTED(); |
866 return scoped_ptr<VideoFrameCapturer>(); | 868 return scoped_ptr<ScreenCapturer>(); |
867 } | 869 } |
868 | 870 |
869 } // namespace remoting | 871 } // namespace media |
OLD | NEW |