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

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_x11.cc

Issue 1910203002: Revert of Modify ScreenCaptureFrameQueue into a template (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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 14
15 #include <memory> 15 #include <memory>
16 #include <set> 16 #include <set>
17 17
18 #include <X11/extensions/Xdamage.h> 18 #include <X11/extensions/Xdamage.h>
19 #include <X11/extensions/Xfixes.h> 19 #include <X11/extensions/Xfixes.h>
20 #include <X11/Xlib.h> 20 #include <X11/Xlib.h>
21 #include <X11/Xutil.h> 21 #include <X11/Xutil.h>
22 22
23 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
24 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 24 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
25 #include "webrtc/modules/desktop_capture/desktop_frame.h" 25 #include "webrtc/modules/desktop_capture/desktop_frame.h"
26 #include "webrtc/modules/desktop_capture/differ.h" 26 #include "webrtc/modules/desktop_capture/differ.h"
27 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" 27 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
28 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" 28 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
29 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
30 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h" 29 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h"
31 #include "webrtc/system_wrappers/include/logging.h" 30 #include "webrtc/system_wrappers/include/logging.h"
32 #include "webrtc/system_wrappers/include/tick_util.h" 31 #include "webrtc/system_wrappers/include/tick_util.h"
33 32
34 namespace webrtc { 33 namespace webrtc {
35 namespace { 34 namespace {
36 35
37 // A class to perform video frame capturing for Linux. 36 // A class to perform video frame capturing for Linux.
38 class ScreenCapturerLinux : public ScreenCapturer, 37 class ScreenCapturerLinux : public ScreenCapturer,
39 public SharedXDisplay::XEventHandler { 38 public SharedXDisplay::XEventHandler {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 XserverRegion damage_region_; 99 XserverRegion damage_region_;
101 100
102 // Access to the X Server's pixel buffer. 101 // Access to the X Server's pixel buffer.
103 XServerPixelBuffer x_server_pixel_buffer_; 102 XServerPixelBuffer x_server_pixel_buffer_;
104 103
105 // A thread-safe list of invalid rectangles, and the size of the most 104 // A thread-safe list of invalid rectangles, and the size of the most
106 // recently captured screen. 105 // recently captured screen.
107 ScreenCapturerHelper helper_; 106 ScreenCapturerHelper helper_;
108 107
109 // Queue of the frames buffers. 108 // Queue of the frames buffers.
110 ScreenCaptureFrameQueue<SharedDesktopFrame> queue_; 109 ScreenCaptureFrameQueue queue_;
111 110
112 // 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
113 // current with the last buffer used. 112 // current with the last buffer used.
114 DesktopRegion last_invalid_region_; 113 DesktopRegion last_invalid_region_;
115 114
116 // |Differ| for use when polling for changes. 115 // |Differ| for use when polling for changes.
117 std::unique_ptr<Differ> differ_; 116 std::unique_ptr<Differ> differ_;
118 117
119 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux); 118 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux);
120 }; 119 };
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 RTC_DCHECK(!callback_); 230 RTC_DCHECK(!callback_);
232 RTC_DCHECK(callback); 231 RTC_DCHECK(callback);
233 232
234 callback_ = callback; 233 callback_ = callback;
235 } 234 }
236 235
237 void ScreenCapturerLinux::Capture(const DesktopRegion& region) { 236 void ScreenCapturerLinux::Capture(const DesktopRegion& region) {
238 TickTime capture_start_time = TickTime::Now(); 237 TickTime capture_start_time = TickTime::Now();
239 238
240 queue_.MoveToNextFrame(); 239 queue_.MoveToNextFrame();
241 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared());
242 240
243 // Process XEvents for XDamage and cursor shape tracking. 241 // Process XEvents for XDamage and cursor shape tracking.
244 options_.x_display()->ProcessPendingXEvents(); 242 options_.x_display()->ProcessPendingXEvents();
245 243
246 // ProcessPendingXEvents() may call ScreenConfigurationChanged() which 244 // ProcessPendingXEvents() may call ScreenConfigurationChanged() which
247 // reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still 245 // reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still
248 // in a good shape. 246 // in a good shape.
249 if (!x_server_pixel_buffer_.is_initialized()) { 247 if (!x_server_pixel_buffer_.is_initialized()) {
250 // We failed to initialize pixel buffer. 248 // We failed to initialize pixel buffer.
251 callback_->OnCaptureCompleted(NULL); 249 callback_->OnCaptureCompleted(NULL);
252 return; 250 return;
253 } 251 }
254 252
255 // 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.
256 // 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
257 // may still be reading from them. 255 // may still be reading from them.
258 if (!queue_.current_frame()) { 256 if (!queue_.current_frame()) {
259 std::unique_ptr<DesktopFrame> frame( 257 std::unique_ptr<DesktopFrame> frame(
260 new BasicDesktopFrame(x_server_pixel_buffer_.window_size())); 258 new BasicDesktopFrame(x_server_pixel_buffer_.window_size()));
261 queue_.ReplaceCurrentFrame(SharedDesktopFrame::Wrap(frame.release())); 259 queue_.ReplaceCurrentFrame(frame.release());
262 } 260 }
263 261
264 // Refresh the Differ helper used by CaptureFrame(), if needed. 262 // Refresh the Differ helper used by CaptureFrame(), if needed.
265 DesktopFrame* frame = queue_.current_frame(); 263 DesktopFrame* frame = queue_.current_frame();
266 if (!use_damage_ && ( 264 if (!use_damage_ && (
267 !differ_.get() || 265 !differ_.get() ||
268 (differ_->width() != frame->size().width()) || 266 (differ_->width() != frame->size().width()) ||
269 (differ_->height() != frame->size().height()) || 267 (differ_->height() != frame->size().height()) ||
270 (differ_->bytes_per_row() != frame->stride()))) { 268 (differ_->bytes_per_row() != frame->stride()))) {
271 differ_.reset(new Differ(frame->size().width(), frame->size().height(), 269 differ_.reset(new Differ(frame->size().width(), frame->size().height(),
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 if (!options.x_display()) 436 if (!options.x_display())
439 return NULL; 437 return NULL;
440 438
441 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); 439 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux());
442 if (!capturer->Init(options)) 440 if (!capturer->Init(options))
443 capturer.reset(); 441 capturer.reset();
444 return capturer.release(); 442 return capturer.release();
445 } 443 }
446 444
447 } // namespace webrtc 445 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/screen_capturer_mac.mm ('k') | webrtc/modules/desktop_capture/shared_desktop_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698