| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/desktop_capture/screen_capturer.h" | 11 #include "webrtc/modules/desktop_capture/screen_capturer.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 |
| 15 #include <memory> |
| 14 #include <set> | 16 #include <set> |
| 15 | 17 |
| 16 #include <X11/extensions/Xdamage.h> | 18 #include <X11/extensions/Xdamage.h> |
| 17 #include <X11/extensions/Xfixes.h> | 19 #include <X11/extensions/Xfixes.h> |
| 18 #include <X11/Xlib.h> | 20 #include <X11/Xlib.h> |
| 19 #include <X11/Xutil.h> | 21 #include <X11/Xutil.h> |
| 20 | 22 |
| 21 #include "webrtc/base/checks.h" | 23 #include "webrtc/base/checks.h" |
| 22 #include "webrtc/base/scoped_ptr.h" | |
| 23 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 24 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 24 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 25 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 25 #include "webrtc/modules/desktop_capture/differ.h" | 26 #include "webrtc/modules/desktop_capture/differ.h" |
| 26 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" | 27 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" |
| 27 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" | 28 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" |
| 28 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h" | 29 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h" |
| 29 #include "webrtc/system_wrappers/include/logging.h" | 30 #include "webrtc/system_wrappers/include/logging.h" |
| 30 #include "webrtc/system_wrappers/include/tick_util.h" | 31 #include "webrtc/system_wrappers/include/tick_util.h" |
| 31 | 32 |
| 32 namespace webrtc { | 33 namespace webrtc { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 ScreenCapturerHelper helper_; | 106 ScreenCapturerHelper helper_; |
| 106 | 107 |
| 107 // Queue of the frames buffers. | 108 // Queue of the frames buffers. |
| 108 ScreenCaptureFrameQueue queue_; | 109 ScreenCaptureFrameQueue queue_; |
| 109 | 110 |
| 110 // Invalid region from the previous capture. This is used to synchronize the | 111 // Invalid region from the previous capture. This is used to synchronize the |
| 111 // current with the last buffer used. | 112 // current with the last buffer used. |
| 112 DesktopRegion last_invalid_region_; | 113 DesktopRegion last_invalid_region_; |
| 113 | 114 |
| 114 // |Differ| for use when polling for changes. | 115 // |Differ| for use when polling for changes. |
| 115 rtc::scoped_ptr<Differ> differ_; | 116 std::unique_ptr<Differ> differ_; |
| 116 | 117 |
| 117 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux); | 118 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux); |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 ScreenCapturerLinux::ScreenCapturerLinux() | 121 ScreenCapturerLinux::ScreenCapturerLinux() |
| 121 : callback_(NULL), | 122 : callback_(NULL), |
| 122 gc_(NULL), | 123 gc_(NULL), |
| 123 root_window_(BadValue), | 124 root_window_(BadValue), |
| 124 has_xfixes_(false), | 125 has_xfixes_(false), |
| 125 xfixes_event_base_(-1), | 126 xfixes_event_base_(-1), |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 if (!x_server_pixel_buffer_.is_initialized()) { | 247 if (!x_server_pixel_buffer_.is_initialized()) { |
| 247 // We failed to initialize pixel buffer. | 248 // We failed to initialize pixel buffer. |
| 248 callback_->OnCaptureCompleted(NULL); | 249 callback_->OnCaptureCompleted(NULL); |
| 249 return; | 250 return; |
| 250 } | 251 } |
| 251 | 252 |
| 252 // If the current frame is from an older generation then allocate a new one. | 253 // If the current frame is from an older generation then allocate a new one. |
| 253 // Note that we can't reallocate other buffers at this point, since the caller | 254 // Note that we can't reallocate other buffers at this point, since the caller |
| 254 // may still be reading from them. | 255 // may still be reading from them. |
| 255 if (!queue_.current_frame()) { | 256 if (!queue_.current_frame()) { |
| 256 rtc::scoped_ptr<DesktopFrame> frame( | 257 std::unique_ptr<DesktopFrame> frame( |
| 257 new BasicDesktopFrame(x_server_pixel_buffer_.window_size())); | 258 new BasicDesktopFrame(x_server_pixel_buffer_.window_size())); |
| 258 queue_.ReplaceCurrentFrame(frame.release()); | 259 queue_.ReplaceCurrentFrame(frame.release()); |
| 259 } | 260 } |
| 260 | 261 |
| 261 // Refresh the Differ helper used by CaptureFrame(), if needed. | 262 // Refresh the Differ helper used by CaptureFrame(), if needed. |
| 262 DesktopFrame* frame = queue_.current_frame(); | 263 DesktopFrame* frame = queue_.current_frame(); |
| 263 if (!use_damage_ && ( | 264 if (!use_damage_ && ( |
| 264 !differ_.get() || | 265 !differ_.get() || |
| 265 (differ_->width() != frame->size().width()) || | 266 (differ_->width() != frame->size().width()) || |
| 266 (differ_->height() != frame->size().height()) || | 267 (differ_->height() != frame->size().height()) || |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 } | 429 } |
| 429 } | 430 } |
| 430 | 431 |
| 431 } // namespace | 432 } // namespace |
| 432 | 433 |
| 433 // static | 434 // static |
| 434 ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) { | 435 ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) { |
| 435 if (!options.x_display()) | 436 if (!options.x_display()) |
| 436 return NULL; | 437 return NULL; |
| 437 | 438 |
| 438 rtc::scoped_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); | 439 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); |
| 439 if (!capturer->Init(options)) | 440 if (!capturer->Init(options)) |
| 440 capturer.reset(); | 441 capturer.reset(); |
| 441 return capturer.release(); | 442 return capturer.release(); |
| 442 } | 443 } |
| 443 | 444 |
| 444 } // namespace webrtc | 445 } // namespace webrtc |
| OLD | NEW |