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 | 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/timeutils.h" | |
24 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 25 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
25 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 26 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
26 #include "webrtc/modules/desktop_capture/differ.h" | 27 #include "webrtc/modules/desktop_capture/differ.h" |
27 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" | 28 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" |
28 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" | 29 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" |
29 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h" | 30 #include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h" |
30 #include "webrtc/system_wrappers/include/logging.h" | 31 #include "webrtc/system_wrappers/include/logging.h" |
31 #include "webrtc/system_wrappers/include/tick_util.h" | |
32 | 32 |
33 namespace webrtc { | 33 namespace webrtc { |
34 namespace { | 34 namespace { |
35 | 35 |
36 // A class to perform video frame capturing for Linux. | 36 // A class to perform video frame capturing for Linux. |
37 class ScreenCapturerLinux : public ScreenCapturer, | 37 class ScreenCapturerLinux : public ScreenCapturer, |
38 public SharedXDisplay::XEventHandler { | 38 public SharedXDisplay::XEventHandler { |
39 public: | 39 public: |
40 ScreenCapturerLinux(); | 40 ScreenCapturerLinux(); |
41 virtual ~ScreenCapturerLinux(); | 41 virtual ~ScreenCapturerLinux(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 } | 227 } |
228 | 228 |
229 void ScreenCapturerLinux::Start(Callback* callback) { | 229 void ScreenCapturerLinux::Start(Callback* callback) { |
230 RTC_DCHECK(!callback_); | 230 RTC_DCHECK(!callback_); |
231 RTC_DCHECK(callback); | 231 RTC_DCHECK(callback); |
232 | 232 |
233 callback_ = callback; | 233 callback_ = callback; |
234 } | 234 } |
235 | 235 |
236 void ScreenCapturerLinux::Capture(const DesktopRegion& region) { | 236 void ScreenCapturerLinux::Capture(const DesktopRegion& region) { |
237 TickTime capture_start_time = TickTime::Now(); | 237 int64_t capture_start_time = rtc::TimeNanos(); |
stefan-webrtc
2016/04/19 09:19:12
_nanos
nisse-webrtc
2016/04/19 12:19:25
Done.
| |
238 | 238 |
239 queue_.MoveToNextFrame(); | 239 queue_.MoveToNextFrame(); |
240 | 240 |
241 // Process XEvents for XDamage and cursor shape tracking. | 241 // Process XEvents for XDamage and cursor shape tracking. |
242 options_.x_display()->ProcessPendingXEvents(); | 242 options_.x_display()->ProcessPendingXEvents(); |
243 | 243 |
244 // ProcessPendingXEvents() may call ScreenConfigurationChanged() which | 244 // ProcessPendingXEvents() may call ScreenConfigurationChanged() which |
245 // 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 |
246 // in a good shape. | 246 // in a good shape. |
247 if (!x_server_pixel_buffer_.is_initialized()) { | 247 if (!x_server_pixel_buffer_.is_initialized()) { |
(...skipping 19 matching lines...) Expand all Loading... | |
267 (differ_->height() != frame->size().height()) || | 267 (differ_->height() != frame->size().height()) || |
268 (differ_->bytes_per_row() != frame->stride()))) { | 268 (differ_->bytes_per_row() != frame->stride()))) { |
269 differ_.reset(new Differ(frame->size().width(), frame->size().height(), | 269 differ_.reset(new Differ(frame->size().width(), frame->size().height(), |
270 DesktopFrame::kBytesPerPixel, | 270 DesktopFrame::kBytesPerPixel, |
271 frame->stride())); | 271 frame->stride())); |
272 } | 272 } |
273 | 273 |
274 DesktopFrame* result = CaptureScreen(); | 274 DesktopFrame* result = CaptureScreen(); |
275 last_invalid_region_ = result->updated_region(); | 275 last_invalid_region_ = result->updated_region(); |
276 result->set_capture_time_ms( | 276 result->set_capture_time_ms( |
277 (TickTime::Now() - capture_start_time).Milliseconds()); | 277 (rtc::TimeNanos() - capture_start_time) / rtc::kNumNanosecsPerMillisec); |
278 callback_->OnCaptureCompleted(result); | 278 callback_->OnCaptureCompleted(result); |
279 } | 279 } |
280 | 280 |
281 bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) { | 281 bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) { |
282 RTC_DCHECK(screens->size() == 0); | 282 RTC_DCHECK(screens->size() == 0); |
283 // TODO(jiayl): implement screen enumeration. | 283 // TODO(jiayl): implement screen enumeration. |
284 Screen default_screen; | 284 Screen default_screen; |
285 default_screen.id = 0; | 285 default_screen.id = 0; |
286 screens->push_back(default_screen); | 286 screens->push_back(default_screen); |
287 return true; | 287 return true; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 if (!options.x_display()) | 436 if (!options.x_display()) |
437 return NULL; | 437 return NULL; |
438 | 438 |
439 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); | 439 std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); |
440 if (!capturer->Init(options)) | 440 if (!capturer->Init(options)) |
441 capturer.reset(); | 441 capturer.reset(); |
442 return capturer.release(); | 442 return capturer.release(); |
443 } | 443 } |
444 | 444 |
445 } // namespace webrtc | 445 } // namespace webrtc |
OLD | NEW |