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

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

Issue 1888593004: Delete all use of tick_util.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 7 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/base/constructormagic.h" 24 #include "webrtc/base/constructormagic.h"
25 #include "webrtc/base/timeutils.h"
25 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 26 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
26 #include "webrtc/modules/desktop_capture/desktop_frame.h" 27 #include "webrtc/modules/desktop_capture/desktop_frame.h"
27 #include "webrtc/modules/desktop_capture/differ.h" 28 #include "webrtc/modules/desktop_capture/differ.h"
28 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" 29 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
29 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" 30 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
30 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" 31 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
31 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h" 32 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h"
32 #include "webrtc/system_wrappers/include/logging.h" 33 #include "webrtc/system_wrappers/include/logging.h"
33 #include "webrtc/system_wrappers/include/tick_util.h"
34 34
35 namespace webrtc { 35 namespace webrtc {
36 namespace { 36 namespace {
37 37
38 // A class to perform video frame capturing for Linux. 38 // A class to perform video frame capturing for Linux.
39 class ScreenCapturerLinux : public ScreenCapturer, 39 class ScreenCapturerLinux : public ScreenCapturer,
40 public SharedXDisplay::XEventHandler { 40 public SharedXDisplay::XEventHandler {
41 public: 41 public:
42 ScreenCapturerLinux(); 42 ScreenCapturerLinux();
43 virtual ~ScreenCapturerLinux(); 43 virtual ~ScreenCapturerLinux();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 230
231 void ScreenCapturerLinux::Start(Callback* callback) { 231 void ScreenCapturerLinux::Start(Callback* callback) {
232 RTC_DCHECK(!callback_); 232 RTC_DCHECK(!callback_);
233 RTC_DCHECK(callback); 233 RTC_DCHECK(callback);
234 234
235 callback_ = callback; 235 callback_ = callback;
236 } 236 }
237 237
238 void ScreenCapturerLinux::Capture(const DesktopRegion& region) { 238 void ScreenCapturerLinux::Capture(const DesktopRegion& region) {
239 TickTime capture_start_time = TickTime::Now(); 239 int64_t capture_start_time_nanos = rtc::TimeNanos();
240 240
241 queue_.MoveToNextFrame(); 241 queue_.MoveToNextFrame();
242 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared()); 242 RTC_DCHECK(!queue_.current_frame() || !queue_.current_frame()->IsShared());
243 243
244 // Process XEvents for XDamage and cursor shape tracking. 244 // Process XEvents for XDamage and cursor shape tracking.
245 options_.x_display()->ProcessPendingXEvents(); 245 options_.x_display()->ProcessPendingXEvents();
246 246
247 // ProcessPendingXEvents() may call ScreenConfigurationChanged() which 247 // ProcessPendingXEvents() may call ScreenConfigurationChanged() which
248 // reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still 248 // reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still
249 // in a good shape. 249 // in a good shape.
(...skipping 20 matching lines...) Expand all
270 (differ_->height() != frame->size().height()) || 270 (differ_->height() != frame->size().height()) ||
271 (differ_->bytes_per_row() != frame->stride()))) { 271 (differ_->bytes_per_row() != frame->stride()))) {
272 differ_.reset(new Differ(frame->size().width(), frame->size().height(), 272 differ_.reset(new Differ(frame->size().width(), frame->size().height(),
273 DesktopFrame::kBytesPerPixel, 273 DesktopFrame::kBytesPerPixel,
274 frame->stride())); 274 frame->stride()));
275 } 275 }
276 276
277 DesktopFrame* result = CaptureScreen(); 277 DesktopFrame* result = CaptureScreen();
278 last_invalid_region_ = result->updated_region(); 278 last_invalid_region_ = result->updated_region();
279 result->set_capture_time_ms( 279 result->set_capture_time_ms(
280 (TickTime::Now() - capture_start_time).Milliseconds()); 280 (rtc::TimeNanos() - capture_start_time_nanos) /
281 rtc::kNumNanosecsPerMillisec);
281 callback_->OnCaptureCompleted(result); 282 callback_->OnCaptureCompleted(result);
282 } 283 }
283 284
284 bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) { 285 bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) {
285 RTC_DCHECK(screens->size() == 0); 286 RTC_DCHECK(screens->size() == 0);
286 // TODO(jiayl): implement screen enumeration. 287 // TODO(jiayl): implement screen enumeration.
287 Screen default_screen; 288 Screen default_screen;
288 default_screen.id = 0; 289 default_screen.id = 0;
289 screens->push_back(default_screen); 290 screens->push_back(default_screen);
290 return true; 291 return true;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (!options.x_display()) 440 if (!options.x_display())
440 return NULL; 441 return NULL;
441 442
442 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); 443 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux());
443 if (!capturer->Init(options)) 444 if (!capturer->Init(options))
444 capturer.reset(); 445 capturer.reset();
445 return capturer.release(); 446 return capturer.release();
446 } 447 }
447 448
448 } // namespace webrtc 449 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/screen_capturer_mac.mm ('k') | webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698