| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 if (g_container->duplication) { | 445 if (g_container->duplication) { |
| 446 g_container->duplication->ReleaseFrame(); | 446 g_container->duplication->ReleaseFrame(); |
| 447 g_container->duplication.Reset(); | 447 g_container->duplication.Reset(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 return DuplicateOutput(); | 450 return DuplicateOutput(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 ScreenCapturerWinDirectx::ScreenCapturerWinDirectx( | 453 ScreenCapturerWinDirectx::ScreenCapturerWinDirectx( |
| 454 const DesktopCaptureOptions& options) | 454 const DesktopCaptureOptions& options) |
| 455 : callback_(nullptr), set_thread_execution_state_failed_(false) { | 455 : callback_(nullptr) { |
| 456 RTC_DCHECK(g_container && g_container->initialize_result); | 456 RTC_DCHECK(g_container && g_container->initialize_result); |
| 457 | 457 |
| 458 // Texture instance won't change forever. | 458 // Texture instance won't change forever. |
| 459 while (!surfaces_.current_frame()) { | 459 while (!surfaces_.current_frame()) { |
| 460 surfaces_.ReplaceCurrentFrame(std::unique_ptr<rtc::scoped_refptr<Texture>>( | 460 surfaces_.ReplaceCurrentFrame(std::unique_ptr<rtc::scoped_refptr<Texture>>( |
| 461 new rtc::scoped_refptr<Texture>(new Texture()))); | 461 new rtc::scoped_refptr<Texture>(new Texture()))); |
| 462 surfaces_.MoveToNextFrame(); | 462 surfaces_.MoveToNextFrame(); |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 | 465 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 // Failed to initialize desktop duplication. This usually happens when | 622 // Failed to initialize desktop duplication. This usually happens when |
| 623 // Windows is switching display mode. Retrying later usually resolves the | 623 // Windows is switching display mode. Retrying later usually resolves the |
| 624 // issue. | 624 // issue. |
| 625 callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); | 625 callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); |
| 626 return; | 626 return; |
| 627 } | 627 } |
| 628 | 628 |
| 629 RTC_DCHECK(g_container->duplication); | 629 RTC_DCHECK(g_container->duplication); |
| 630 int64_t capture_start_time_nanos = rtc::TimeNanos(); | 630 int64_t capture_start_time_nanos = rtc::TimeNanos(); |
| 631 | 631 |
| 632 if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) { | |
| 633 if (!set_thread_execution_state_failed_) { | |
| 634 set_thread_execution_state_failed_ = true; | |
| 635 LOG(LS_WARNING) << "Failed to make system & display power assertion: " | |
| 636 << GetLastError(); | |
| 637 } | |
| 638 } | |
| 639 | |
| 640 DXGI_OUTDUPL_FRAME_INFO frame_info; | 632 DXGI_OUTDUPL_FRAME_INFO frame_info; |
| 641 memset(&frame_info, 0, sizeof(DXGI_OUTDUPL_FRAME_INFO)); | 633 memset(&frame_info, 0, sizeof(DXGI_OUTDUPL_FRAME_INFO)); |
| 642 ComPtr<IDXGIResource> resource; | 634 ComPtr<IDXGIResource> resource; |
| 643 rtc::CritScope lock(&g_container->acquire_lock); | 635 rtc::CritScope lock(&g_container->acquire_lock); |
| 644 _com_error error = g_container->duplication->AcquireNextFrame( | 636 _com_error error = g_container->duplication->AcquireNextFrame( |
| 645 kAcquireTimeoutMs, &frame_info, resource.GetAddressOf()); | 637 kAcquireTimeoutMs, &frame_info, resource.GetAddressOf()); |
| 646 | 638 |
| 647 if (error.Error() == DXGI_ERROR_WAIT_TIMEOUT) { | 639 if (error.Error() == DXGI_ERROR_WAIT_TIMEOUT) { |
| 648 // Nothing changed. | 640 // Nothing changed. |
| 649 EmitCurrentFrame(); | 641 EmitCurrentFrame(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 } | 711 } |
| 720 | 712 |
| 721 // If there is no shared_memory_factory_, last frame is stored in surfaces_ | 713 // If there is no shared_memory_factory_, last frame is stored in surfaces_ |
| 722 // queue. | 714 // queue. |
| 723 std::unique_ptr<DesktopFrame> frame( | 715 std::unique_ptr<DesktopFrame> frame( |
| 724 new DxgiDesktopFrame(*surfaces_.current_frame())); | 716 new DxgiDesktopFrame(*surfaces_.current_frame())); |
| 725 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); | 717 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); |
| 726 } | 718 } |
| 727 | 719 |
| 728 } // namespace webrtc | 720 } // namespace webrtc |
| OLD | NEW |