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

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

Issue 2703123002: Skips the first frame in DxgiDuplicatorController (Closed)
Patch Set: Resolve review comments Created 3 years, 10 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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // function copies the content to the rectangle of (offset.x(), offset.y()) to 65 // function copies the content to the rectangle of (offset.x(), offset.y()) to
66 // (offset.x() + desktop_rect_.width(), offset.y() + desktop_rect_.height()). 66 // (offset.x() + desktop_rect_.width(), offset.y() + desktop_rect_.height()).
67 // Returns false in case of a failure. 67 // Returns false in case of a failure.
68 bool Duplicate(Context* context, 68 bool Duplicate(Context* context,
69 DesktopVector offset, 69 DesktopVector offset,
70 SharedDesktopFrame* target); 70 SharedDesktopFrame* target);
71 71
72 // Returns the desktop rect covered by this DxgiOutputDuplicator. 72 // Returns the desktop rect covered by this DxgiOutputDuplicator.
73 DesktopRect desktop_rect() const { return desktop_rect_; } 73 DesktopRect desktop_rect() const { return desktop_rect_; }
74 74
75 void Setup(Context* context);
76
77 void Unregister(const Context* const context);
78
79 // How many frames have been captured by this DxigOutputDuplicator.
80 int64_t num_frames_captured() const;
81
75 private: 82 private:
76 friend class DxgiAdapterDuplicator;
77
78 // Detects updated region translated by offset from IDXGIOutput1. This 83 // Detects updated region translated by offset from IDXGIOutput1. This
79 // function will set the |updated_region| as entire DesktopRect starts from 84 // function will set the |updated_region| as entire DesktopRect starts from
80 // offset if it failed to execute Windows APIs. 85 // offset if it failed to execute Windows APIs.
81 void DetectUpdatedRegion(const DXGI_OUTDUPL_FRAME_INFO& frame_info, 86 void DetectUpdatedRegion(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
82 DesktopVector offset, 87 DesktopVector offset,
83 DesktopRegion* updated_region); 88 DesktopRegion* updated_region);
84 89
85 // Returns untranslated updated region, which are directly returned by Windows 90 // Returns untranslated updated region, which are directly returned by Windows
86 // APIs. Returns false in case of a failure. 91 // APIs. Returns false in case of a failure.
87 bool DoDetectUpdatedRegion(const DXGI_OUTDUPL_FRAME_INFO& frame_info, 92 bool DoDetectUpdatedRegion(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
88 DesktopRegion* updated_region); 93 DesktopRegion* updated_region);
89 94
90 bool ReleaseFrame(); 95 bool ReleaseFrame();
91 96
92 // Initializes duplication_ instance. Expects duplication_ is in empty status. 97 // Initializes duplication_ instance. Expects duplication_ is in empty status.
93 // Returns false if system does not support IDXGIOutputDuplication. 98 // Returns false if system does not support IDXGIOutputDuplication.
94 bool DuplicateOutput(); 99 bool DuplicateOutput();
95 100
96 // Returns a DesktopRect with the same size of desktop_size_, but translated 101 // Returns a DesktopRect with the same size of desktop_size_, but translated
97 // by offset. 102 // by offset.
98 DesktopRect TranslatedDesktopRect(DesktopVector offset); 103 DesktopRect TranslatedDesktopRect(DesktopVector offset);
99 104
100 void Setup(Context* context);
101
102 void Unregister(const Context* const context);
103
104 // Spreads changes from |context| to other registered Context(s) in 105 // Spreads changes from |context| to other registered Context(s) in
105 // contexts_. 106 // contexts_.
106 void SpreadContextChange(const Context* const context); 107 void SpreadContextChange(const Context* const context);
107 108
108 const D3dDevice device_; 109 const D3dDevice device_;
109 const Microsoft::WRL::ComPtr<IDXGIOutput1> output_; 110 const Microsoft::WRL::ComPtr<IDXGIOutput1> output_;
110 const DesktopRect desktop_rect_; 111 const DesktopRect desktop_rect_;
111 Microsoft::WRL::ComPtr<IDXGIOutputDuplication> duplication_; 112 Microsoft::WRL::ComPtr<IDXGIOutputDuplication> duplication_;
112 DXGI_OUTDUPL_DESC desc_; 113 DXGI_OUTDUPL_DESC desc_;
113 std::vector<uint8_t> metadata_; 114 std::vector<uint8_t> metadata_;
114 std::unique_ptr<DxgiTexture> texture_; 115 std::unique_ptr<DxgiTexture> texture_;
115 Rotation rotation_; 116 Rotation rotation_;
116 DesktopSize unrotated_size_; 117 DesktopSize unrotated_size_;
117 118
118 // After each AcquireNextFrame() function call, updated_region_(s) of all 119 // After each AcquireNextFrame() function call, updated_region_(s) of all
119 // active Context(s) need to be updated. Since they have missed the 120 // active Context(s) need to be updated. Since they have missed the
120 // change this time. And during next Duplicate() function call, their 121 // change this time. And during next Duplicate() function call, their
121 // updated_region_ will be merged and copied. 122 // updated_region_ will be merged and copied.
122 std::vector<Context*> contexts_; 123 std::vector<Context*> contexts_;
123 124
124 // The last full frame of this output and its offset. If on AcquireNextFrame() 125 // The last full frame of this output and its offset. If on AcquireNextFrame()
125 // failed because of timeout, i.e. no update, we can copy content from 126 // failed because of timeout, i.e. no update, we can copy content from
126 // |last_frame_|. 127 // |last_frame_|.
127 std::unique_ptr<SharedDesktopFrame> last_frame_; 128 std::unique_ptr<SharedDesktopFrame> last_frame_;
128 DesktopVector last_frame_offset_; 129 DesktopVector last_frame_offset_;
130
131 int64_t num_frames_captured_;
129 }; 132 };
130 133
131 } // namespace webrtc 134 } // namespace webrtc
132 135
133 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_ 136 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698