Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h

Issue 1845113002: DirectX based screen capturer logic (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove width change in Texture::Capture Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_
13
14 #include "webrtc/modules/desktop_capture/screen_capturer.h"
15
16 #include <windows.h>
17 #include <wrl/client.h>
18
19 #include <memory>
20 #include <vector>
21
22 #include <D3DCommon.h>
23 #include <D3D11.h>
24 #include <DXGI.h>
25 #include <DXGI1_2.h>
26
27 #include "webrtc/base/scoped_ptr.h"
28 #include "webrtc/base/thread_annotations.h"
29 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
30 #include "webrtc/modules/desktop_capture/desktop_geometry.h"
31 #include "webrtc/modules/desktop_capture/desktop_region.h"
32 #include "webrtc/modules/desktop_capture/screen_capture_content_queue.h"
33 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
34
35 namespace webrtc {
36
37 // ScreenCapturerWinDirectx captures 32bit RGBA using DirectX.
38 class ScreenCapturerWinDirectx : public ScreenCapturer {
39 public:
40 // Initializes DirectX related components. Returns false if any error
41 // happened, any instance of this class won't be able to work in such status.
42 // Thread safe, guarded by initialize_lock.
43 static bool Initialize();
44
45 explicit ScreenCapturerWinDirectx(const DesktopCaptureOptions& options);
46 virtual ~ScreenCapturerWinDirectx();
47
48 void Start(Callback* callback) override;
49 void SetSharedMemoryFactory(
50 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) override;
51 void Capture(const DesktopRegion& region) override;
52 bool GetScreenList(ScreenList* screens) override;
53 bool SelectScreen(ScreenId id) override;
54
55 private:
56 // In milliseconds, consistent with windows api.
57 static const uint32_t kAcquireTimeout = 10;
Sergey Ulanov 2016/04/14 23:10:43 These constants do not need to be class members. M
Hzj_jie 2016/04/15 19:42:18 Done.
58 // Wait time between two DuplicateOutput operations, DuplicateOutput may fail
59 // if display mode is changing.
60 static const uint32_t kDuplicateOutputWait = 50;
61 // How many times we attempt to DuplicateOutput before returning an error to
62 // upstream components.
63 static const int kDuplicateOutputAttempts = 10;
64
65 static bool DoInitialize();
66
67 // Initializes dxgi_output_duplication. Returns false if it fails to execute
68 // windows api.
69 static bool DuplicateOutput();
70
71 // Detect update regions in last frame, if anything wrong, returns false.
72 // ProcessFrame will insert a whole desktop size as updated region instead.
73 static bool DetectUpdatedRegion(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
74 DesktopFrame* frame);
75
76 // Process one frame received from AcquireNextFrame function, returns false if
77 // anything wrong, and Capture function will call
78 // callback_->OnCaptureCompleted(nullptr), otherwise
79 // callback_->OnCaptureCompleted(frame) will be called.
80 bool ProcessFrame(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
81 IDXGIResource* resource);
82
83 // A shortcut to execute callback with current frame in frames.
84 void EmitCurrentFrame();
85
86 // Texture is a pair of an ID3D11Texture2D and an IDXGISurface. Refer to its
87 // implementation in source code for details.
88 class Texture;
Sergey Ulanov 2016/04/14 23:10:43 Move this to the top of the private section. See h
Hzj_jie 2016/04/15 19:42:18 Done.
89
90 ScreenCaptureContentQueue<Texture> surfaces_;
91 ScreenCaptureFrameQueue frames_;
92 std::unique_ptr<SharedMemoryFactory> shared_memory_factory_;
93 Callback* callback_;
Sergey Ulanov 2016/04/14 23:10:43 = nullptr
Hzj_jie 2016/04/15 19:42:18 Done.
94
95 bool set_thread_execution_state_failed_;
Sergey Ulanov 2016/04/14 23:10:43 = false;
Hzj_jie 2016/04/15 19:42:18 Done.
96
97 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinDirectx);
98 };
99
100 } // namespace webrtc
101
102 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698