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 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // If the current frame is from an older generation then allocate a new one. | 249 // If the current frame is from an older generation then allocate a new one. |
250 // Note that we can't reallocate other buffers at this point, since the caller | 250 // Note that we can't reallocate other buffers at this point, since the caller |
251 // may still be reading from them. | 251 // may still be reading from them. |
252 if (!queue_.current_frame()) { | 252 if (!queue_.current_frame()) { |
253 queue_.ReplaceCurrentFrame( | 253 queue_.ReplaceCurrentFrame( |
254 SharedDesktopFrame::Wrap(std::unique_ptr<DesktopFrame>( | 254 SharedDesktopFrame::Wrap(std::unique_ptr<DesktopFrame>( |
255 new BasicDesktopFrame(x_server_pixel_buffer_.window_size())))); | 255 new BasicDesktopFrame(x_server_pixel_buffer_.window_size())))); |
256 } | 256 } |
257 | 257 |
258 std::unique_ptr<DesktopFrame> result = CaptureScreen(); | 258 std::unique_ptr<DesktopFrame> result = CaptureScreen(); |
| 259 if (!result) { |
| 260 callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); |
| 261 return; |
| 262 } |
| 263 |
259 last_invalid_region_ = result->updated_region(); | 264 last_invalid_region_ = result->updated_region(); |
260 result->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / | 265 result->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / |
261 rtc::kNumNanosecsPerMillisec); | 266 rtc::kNumNanosecsPerMillisec); |
262 callback_->OnCaptureResult(Result::SUCCESS, std::move(result)); | 267 callback_->OnCaptureResult(Result::SUCCESS, std::move(result)); |
263 } | 268 } |
264 | 269 |
265 bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) { | 270 bool ScreenCapturerLinux::GetScreenList(ScreenList* screens) { |
266 RTC_DCHECK(screens->size() == 0); | 271 RTC_DCHECK(screens->size() == 0); |
267 // TODO(jiayl): implement screen enumeration. | 272 // TODO(jiayl): implement screen enumeration. |
268 Screen default_screen; | 273 Screen default_screen; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 helper_.TakeInvalidRegion(updated_region); | 332 helper_.TakeInvalidRegion(updated_region); |
328 | 333 |
329 // Clip the damaged portions to the current screen size, just in case some | 334 // Clip the damaged portions to the current screen size, just in case some |
330 // spurious XDamage notifications were received for a previous (larger) | 335 // spurious XDamage notifications were received for a previous (larger) |
331 // screen size. | 336 // screen size. |
332 updated_region->IntersectWith( | 337 updated_region->IntersectWith( |
333 DesktopRect::MakeSize(x_server_pixel_buffer_.window_size())); | 338 DesktopRect::MakeSize(x_server_pixel_buffer_.window_size())); |
334 | 339 |
335 for (DesktopRegion::Iterator it(*updated_region); | 340 for (DesktopRegion::Iterator it(*updated_region); |
336 !it.IsAtEnd(); it.Advance()) { | 341 !it.IsAtEnd(); it.Advance()) { |
337 x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get()); | 342 if (!x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get())) |
| 343 return nullptr; |
338 } | 344 } |
339 } else { | 345 } else { |
340 // Doing full-screen polling, or this is the first capture after a | 346 // Doing full-screen polling, or this is the first capture after a |
341 // screen-resolution change. In either case, need a full-screen capture. | 347 // screen-resolution change. In either case, need a full-screen capture. |
342 DesktopRect screen_rect = DesktopRect::MakeSize(frame->size()); | 348 DesktopRect screen_rect = DesktopRect::MakeSize(frame->size()); |
343 x_server_pixel_buffer_.CaptureRect(screen_rect, frame.get()); | 349 x_server_pixel_buffer_.CaptureRect(screen_rect, frame.get()); |
344 updated_region->SetRect(screen_rect); | 350 updated_region->SetRect(screen_rect); |
345 } | 351 } |
346 | 352 |
347 return std::move(frame); | 353 return std::move(frame); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 418 } |
413 | 419 |
414 if (options.detect_updated_region()) { | 420 if (options.detect_updated_region()) { |
415 capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer))); | 421 capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer))); |
416 } | 422 } |
417 | 423 |
418 return capturer.release(); | 424 return capturer.release(); |
419 } | 425 } |
420 | 426 |
421 } // namespace webrtc | 427 } // namespace webrtc |
OLD | NEW |