| 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 |
| 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_ |
| 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_ |
| 13 | 13 |
| 14 #include <D3DCommon.h> | 14 #include <D3DCommon.h> |
| 15 | 15 |
| 16 #include <memory> | 16 #include <memory> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/base/scoped_ref_ptr.h" |
| 19 #include "webrtc/modules/desktop_capture/desktop_capturer.h" | 20 #include "webrtc/modules/desktop_capture/desktop_capturer.h" |
| 20 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 21 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 21 #include "webrtc/modules/desktop_capture/desktop_region.h" | 22 #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 22 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" | 23 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" |
| 23 #include "webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h" | 24 #include "webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h" |
| 24 #include "webrtc/modules/desktop_capture/win/dxgi_frame.h" | 25 #include "webrtc/modules/desktop_capture/win/dxgi_frame.h" |
| 25 | 26 |
| 26 namespace webrtc { | 27 namespace webrtc { |
| 27 | 28 |
| 28 // ScreenCapturerWinDirectx captures 32bit RGBA using DirectX. | 29 // ScreenCapturerWinDirectx captures 32bit RGBA using DirectX. |
| 29 class ScreenCapturerWinDirectx : public DesktopCapturer { | 30 class ScreenCapturerWinDirectx : public DesktopCapturer { |
| 30 public: | 31 public: |
| 31 using D3dInfo = DxgiDuplicatorController::D3dInfo; | 32 using D3dInfo = DxgiDuplicatorController::D3dInfo; |
| 32 | 33 |
| 33 // Whether the system supports DirectX based capturing. | 34 // Whether the system supports DirectX based capturing. |
| 34 static bool IsSupported(); | 35 static bool IsSupported(); |
| 35 | 36 |
| 36 // Returns a most recent D3dInfo composed by | 37 // Returns a most recent D3dInfo composed by |
| 37 // DxgiDuplicatorController::Initialize() function. This function implicitly | 38 // DxgiDuplicatorController::Initialize() function. This function implicitly |
| 38 // calls DxgiDuplicatorController::Initialize() if it has not been | 39 // calls DxgiDuplicatorController::Initialize() if it has not been |
| 39 // initialized. This function returns false and output parameter is kept | 40 // initialized. This function returns false and output parameter is kept |
| 40 // unchanged if DxgiDuplicatorController::Initialize() failed. | 41 // unchanged if DxgiDuplicatorController::Initialize() failed. |
| 41 // The D3dInfo may change based on hardware configuration even without | 42 // The D3dInfo may change based on hardware configuration even without |
| 42 // restarting the hardware and software. Refer to https://goo.gl/OOCppq. So | 43 // restarting the hardware and software. Refer to https://goo.gl/OOCppq. So |
| 43 // consumers should not cache the result returned by this function. | 44 // consumers should not cache the result returned by this function. |
| 44 static bool RetrieveD3dInfo(D3dInfo* info); | 45 static bool RetrieveD3dInfo(D3dInfo* info); |
| 45 | 46 |
| 46 explicit ScreenCapturerWinDirectx(const DesktopCaptureOptions& options); | 47 explicit ScreenCapturerWinDirectx(); |
| 47 | 48 |
| 48 ~ScreenCapturerWinDirectx() override; | 49 ~ScreenCapturerWinDirectx() override; |
| 49 | 50 |
| 51 // DesktopCapturer implementation. |
| 50 void Start(Callback* callback) override; | 52 void Start(Callback* callback) override; |
| 51 void SetSharedMemoryFactory( | 53 void SetSharedMemoryFactory( |
| 52 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override; | 54 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override; |
| 53 void CaptureFrame() override; | 55 void CaptureFrame() override; |
| 54 bool GetSourceList(SourceList* sources) override; | 56 bool GetSourceList(SourceList* sources) override; |
| 55 bool SelectSource(SourceId id) override; | 57 bool SelectSource(SourceId id) override; |
| 56 | 58 |
| 57 private: | 59 private: |
| 60 const rtc::scoped_refptr<DxgiDuplicatorController> controller_; |
| 58 ScreenCaptureFrameQueue<DxgiFrame> frames_; | 61 ScreenCaptureFrameQueue<DxgiFrame> frames_; |
| 59 std::unique_ptr<SharedMemoryFactory> shared_memory_factory_; | 62 std::unique_ptr<SharedMemoryFactory> shared_memory_factory_; |
| 60 Callback* callback_ = nullptr; | 63 Callback* callback_ = nullptr; |
| 61 SourceId current_screen_id_ = kFullDesktopScreenId; | 64 SourceId current_screen_id_ = kFullDesktopScreenId; |
| 62 | 65 |
| 63 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinDirectx); | 66 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinDirectx); |
| 64 }; | 67 }; |
| 65 | 68 |
| 66 } // namespace webrtc | 69 } // namespace webrtc |
| 67 | 70 |
| 68 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_ | 71 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_ |
| OLD | NEW |