OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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/cropping_window_capturer.h" | 11 #include "webrtc/modules/desktop_capture/cropping_window_capturer.h" |
12 | 12 |
13 #include "webrtc/modules/desktop_capture/cropped_desktop_frame.h" | 13 #include "webrtc/modules/desktop_capture/cropped_desktop_frame.h" |
14 #include "webrtc/system_wrappers/include/logging.h" | |
15 | 14 |
16 namespace webrtc { | 15 namespace webrtc { |
17 | 16 |
18 CroppingWindowCapturer::CroppingWindowCapturer( | 17 CroppingWindowCapturer::CroppingWindowCapturer( |
19 const DesktopCaptureOptions& options) | 18 const DesktopCaptureOptions& options) |
20 : options_(options), | 19 : options_(options), |
21 callback_(NULL), | 20 callback_(NULL), |
22 window_capturer_(DesktopCapturer::CreateRawWindowCapturer(options)), | 21 window_capturer_(DesktopCapturer::CreateRawWindowCapturer(options)), |
23 selected_window_(kNullWindowId), | 22 selected_window_(kNullWindowId), |
24 excluded_window_(kNullWindowId) {} | 23 excluded_window_(kNullWindowId) {} |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 69 } |
71 | 70 |
72 bool CroppingWindowCapturer::FocusOnSelectedSource() { | 71 bool CroppingWindowCapturer::FocusOnSelectedSource() { |
73 return window_capturer_->FocusOnSelectedSource(); | 72 return window_capturer_->FocusOnSelectedSource(); |
74 } | 73 } |
75 | 74 |
76 void CroppingWindowCapturer::OnCaptureResult( | 75 void CroppingWindowCapturer::OnCaptureResult( |
77 DesktopCapturer::Result result, | 76 DesktopCapturer::Result result, |
78 std::unique_ptr<DesktopFrame> screen_frame) { | 77 std::unique_ptr<DesktopFrame> screen_frame) { |
79 if (!ShouldUseScreenCapturer()) { | 78 if (!ShouldUseScreenCapturer()) { |
80 LOG(LS_INFO) << "Window no longer on top when ScreenCapturer finishes"; | |
81 window_capturer_->CaptureFrame(); | 79 window_capturer_->CaptureFrame(); |
82 return; | 80 return; |
83 } | 81 } |
84 | 82 |
85 if (result != Result::SUCCESS) { | 83 if (result != Result::SUCCESS) { |
86 LOG(LS_WARNING) << "ScreenCapturer failed to capture a frame"; | |
87 callback_->OnCaptureResult(result, nullptr); | 84 callback_->OnCaptureResult(result, nullptr); |
88 return; | 85 return; |
89 } | 86 } |
90 | 87 |
91 DesktopRect window_rect = GetWindowRectInVirtualScreen(); | 88 DesktopRect window_rect = GetWindowRectInVirtualScreen(); |
92 if (window_rect.is_empty()) { | 89 if (window_rect.is_empty()) { |
93 LOG(LS_WARNING) << "Window rect is empty"; | |
94 callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); | 90 callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); |
95 return; | 91 return; |
96 } | 92 } |
97 | 93 |
98 callback_->OnCaptureResult( | 94 callback_->OnCaptureResult( |
99 Result::SUCCESS, | 95 Result::SUCCESS, |
100 CreateCroppedDesktopFrame(std::move(screen_frame), window_rect)); | 96 CreateCroppedDesktopFrame(std::move(screen_frame), window_rect)); |
101 } | 97 } |
102 | 98 |
103 #if !defined(WEBRTC_WIN) | 99 #if !defined(WEBRTC_WIN) |
104 // CroppingWindowCapturer is implemented only for windows. On other platforms | 100 // CroppingWindowCapturer is implemented only for windows. On other platforms |
105 // the regular window capturer is used. | 101 // the regular window capturer is used. |
106 // static | 102 // static |
107 std::unique_ptr<DesktopCapturer> CroppingWindowCapturer::CreateCapturer( | 103 std::unique_ptr<DesktopCapturer> CroppingWindowCapturer::CreateCapturer( |
108 const DesktopCaptureOptions& options) { | 104 const DesktopCaptureOptions& options) { |
109 return DesktopCapturer::CreateWindowCapturer(options); | 105 return DesktopCapturer::CreateWindowCapturer(options); |
110 } | 106 } |
111 #endif | 107 #endif |
112 | 108 |
113 } // namespace webrtc | 109 } // namespace webrtc |
OLD | NEW |