Use backticks not vertical bars to denote variables in comments for /modules/desktop_capture
Bug: webrtc:12338
Change-Id: I300ba78fc4423db7030e555d7e51d2cb2246e9a4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227162
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34678}
diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h
index 46ba525..f5c2ce2 100644
--- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h
+++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h
@@ -31,8 +31,8 @@
public DesktopCapturer::Callback {
public:
// Creates BlankDetectorDesktopCapturerWrapper. BlankDesktopCapturerWrapper
- // takes ownership of |capturer|. The |blank_pixel| is the unmodified color
- // returned by the |capturer|.
+ // takes ownership of `capturer`. The `blank_pixel` is the unmodified color
+ // returned by the `capturer`.
BlankDetectorDesktopCapturerWrapper(std::unique_ptr<DesktopCapturer> capturer,
RgbaColor blank_pixel);
~BlankDetectorDesktopCapturerWrapper() override;
@@ -55,7 +55,7 @@
bool IsBlankFrame(const DesktopFrame& frame) const;
- // Detects whether pixel at (x, y) equals to |blank_pixel_|.
+ // Detects whether pixel at (x, y) equals to `blank_pixel_`.
bool IsBlankPixel(const DesktopFrame& frame, int x, int y) const;
const std::unique_ptr<DesktopCapturer> capturer_;
diff --git a/modules/desktop_capture/cropped_desktop_frame.h b/modules/desktop_capture/cropped_desktop_frame.h
index bbc3c86..5c672c7 100644
--- a/modules/desktop_capture/cropped_desktop_frame.h
+++ b/modules/desktop_capture/cropped_desktop_frame.h
@@ -19,11 +19,11 @@
namespace webrtc {
-// Creates a DesktopFrame to contain only the area of |rect| in the original
-// |frame|.
-// |frame| should not be nullptr. |rect| is in |frame| coordinate, i.e.
-// |frame|->top_left() does not impact the area of |rect|.
-// Returns nullptr frame if |rect| is not contained by the bounds of |frame|.
+// Creates a DesktopFrame to contain only the area of `rect` in the original
+// `frame`.
+// `frame` should not be nullptr. `rect` is in `frame` coordinate, i.e.
+// `frame`->top_left() does not impact the area of `rect`.
+// Returns nullptr frame if `rect` is not contained by the bounds of `frame`.
std::unique_ptr<DesktopFrame> RTC_EXPORT
CreateCroppedDesktopFrame(std::unique_ptr<DesktopFrame> frame,
const DesktopRect& rect);
diff --git a/modules/desktop_capture/cropped_desktop_frame_unittest.cc b/modules/desktop_capture/cropped_desktop_frame_unittest.cc
index c4ccb87..ff9b8ca 100644
--- a/modules/desktop_capture/cropped_desktop_frame_unittest.cc
+++ b/modules/desktop_capture/cropped_desktop_frame_unittest.cc
@@ -25,7 +25,7 @@
TEST(CroppedDesktopFrameTest, DoNotCreateWrapperIfSizeIsNotChanged) {
std::unique_ptr<DesktopFrame> original = CreateTestFrame();
- // owned by |original| and CroppedDesktopFrame.
+ // owned by `original` and CroppedDesktopFrame.
DesktopFrame* raw_original = original.get();
std::unique_ptr<DesktopFrame> cropped = CreateCroppedDesktopFrame(
std::move(original), DesktopRect::MakeWH(10, 20));
diff --git a/modules/desktop_capture/cropping_window_capturer.h b/modules/desktop_capture/cropping_window_capturer.h
index 272a196..5647803 100644
--- a/modules/desktop_capture/cropping_window_capturer.h
+++ b/modules/desktop_capture/cropping_window_capturer.h
@@ -45,7 +45,7 @@
bool FocusOnSelectedSource() override;
bool IsOccluded(const DesktopVector& pos) override;
- // DesktopCapturer::Callback implementation, passed to |screen_capturer_| to
+ // DesktopCapturer::Callback implementation, passed to `screen_capturer_` to
// intercept the capture result.
void OnCaptureResult(DesktopCapturer::Result result,
std::unique_ptr<DesktopFrame> frame) override;
diff --git a/modules/desktop_capture/cropping_window_capturer_win.cc b/modules/desktop_capture/cropping_window_capturer_win.cc
index 31ddbe1..a8eacde 100644
--- a/modules/desktop_capture/cropping_window_capturer_win.cc
+++ b/modules/desktop_capture/cropping_window_capturer_win.cc
@@ -247,7 +247,7 @@
}
if (region_type == SIMPLEREGION) {
- // The |region_rect| returned from GetRgnBox() is always in window
+ // The `region_rect` returned from GetRgnBox() is always in window
// coordinate.
region_rect.Translate(window_region_rect_.left(),
window_region_rect_.top());
@@ -255,10 +255,10 @@
// system permits drawing.
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd144950(v=vs.85).aspx.
//
- // |region_rect| should always be inside of |window_region_rect_|. So after
- // the intersection, |window_region_rect_| == |region_rect|. If so, what's
+ // `region_rect` should always be inside of `window_region_rect_`. So after
+ // the intersection, `window_region_rect_` == `region_rect`. If so, what's
// the point of the intersecting operations? Why cannot we directly retrieve
- // |window_region_rect_| from GetWindowRegionTypeWithBoundary() function?
+ // `window_region_rect_` from GetWindowRegionTypeWithBoundary() function?
// TODO(zijiehe): Figure out the purpose of these intersections.
window_region_rect_.IntersectWith(region_rect);
content_rect.IntersectWith(region_rect);
@@ -266,14 +266,14 @@
// Check if the client area is out of the screen area. When the window is
// maximized, only its client area is visible in the screen, the border will
- // be hidden. So we are using |content_rect| here.
+ // be hidden. So we are using `content_rect` here.
if (!GetFullscreenRect().ContainsRect(content_rect)) {
return false;
}
// Check if the window is occluded by any other window, excluding the child
- // windows, context menus, and |excluded_window_|.
- // |content_rect| is preferred, see the comments on
+ // windows, context menus, and `excluded_window_`.
+ // `content_rect` is preferred, see the comments on
// IsWindowIntersectWithSelectedWindow().
TopWindowVerifierContext context(selected,
reinterpret_cast<HWND>(excluded_window()),
@@ -293,7 +293,7 @@
}
window_rect.IntersectWith(window_region_rect_);
- // Convert |window_rect| to be relative to the top-left of the virtual screen.
+ // Convert `window_rect` to be relative to the top-left of the virtual screen.
DesktopRect screen_rect(GetFullscreenRect());
window_rect.IntersectWith(screen_rect);
window_rect.Translate(-screen_rect.left(), -screen_rect.top());
diff --git a/modules/desktop_capture/desktop_and_cursor_composer.cc b/modules/desktop_capture/desktop_and_cursor_composer.cc
index 69b8b40..7be8982 100644
--- a/modules/desktop_capture/desktop_and_cursor_composer.cc
+++ b/modules/desktop_capture/desktop_and_cursor_composer.cc
@@ -64,7 +64,7 @@
// content before releasing the underlying frame.
class DesktopFrameWithCursor : public DesktopFrame {
public:
- // Takes ownership of |frame|.
+ // Takes ownership of `frame`.
DesktopFrameWithCursor(std::unique_ptr<DesktopFrame> frame,
const MouseCursor& cursor,
const DesktopVector& position,
@@ -113,7 +113,7 @@
if (cursor_rect_.is_empty())
return;
- // Copy original screen content under cursor to |restore_frame_|.
+ // Copy original screen content under cursor to `restore_frame_`.
restore_position_ = cursor_rect_.top_left();
restore_frame_.reset(new BasicDesktopFrame(cursor_rect_.size()));
restore_frame_->CopyPixelsFrom(*this, cursor_rect_.top_left(),
@@ -218,7 +218,7 @@
// and location in logical(DIP) pixels on Retina monitor. This will cause
// problem when the desktop is mixed with Retina and non-Retina monitors.
// So we use DIP pixel for all location info and compensate with the scale
- // factor of current frame to the |relative_position|.
+ // factor of current frame to the `relative_position`.
const float scale = frame->scale_factor();
relative_position.set(relative_position.x() * scale,
relative_position.y() * scale);
diff --git a/modules/desktop_capture/desktop_and_cursor_composer.h b/modules/desktop_capture/desktop_and_cursor_composer.h
index 8f95721..a027058 100644
--- a/modules/desktop_capture/desktop_and_cursor_composer.h
+++ b/modules/desktop_capture/desktop_and_cursor_composer.h
@@ -35,7 +35,7 @@
public:
// Creates a new composer that captures mouse cursor using
// MouseCursorMonitor::Create(options) and renders it into the frames
- // generated by |desktop_capturer|.
+ // generated by `desktop_capturer`.
DesktopAndCursorComposer(std::unique_ptr<DesktopCapturer> desktop_capturer,
const DesktopCaptureOptions& options);
diff --git a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc
index 00253d3..5596576 100644
--- a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc
+++ b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc
@@ -201,7 +201,7 @@
}
protected:
- // Owned by |blender_|.
+ // Owned by `blender_`.
FakeScreenCapturer* fake_screen_;
FakeMouseMonitor* fake_cursor_;
@@ -280,7 +280,7 @@
fake_cursor_->SetState(MouseCursorMonitor::INSIDE, abs_pos);
blender_.CaptureFrame();
- // If the frame may already have contained the cursor, then |CaptureFrame()|
+ // If the frame may already have contained the cursor, then `CaptureFrame()`
// should not have modified it, so it should be the same as the control.
EXPECT_TRUE(frame_);
const DesktopVector rel_pos(abs_pos.subtract(control_frame->top_left()));
@@ -291,7 +291,7 @@
control_frame->GetFrameDataAtPos(rel_pos)));
} else {
- // |CaptureFrame()| should have modified the frame to have the cursor.
+ // `CaptureFrame()` should have modified the frame to have the cursor.
EXPECT_NE(
*reinterpret_cast<uint32_t*>(frame_->GetFrameDataAtPos(rel_pos)),
*reinterpret_cast<uint32_t*>(
diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h
index a693803..26eb0f5 100644
--- a/modules/desktop_capture/desktop_capture_options.h
+++ b/modules/desktop_capture/desktop_capture_options.h
@@ -100,13 +100,13 @@
#if defined(WEBRTC_WIN)
// Enumerating windows owned by the current process on Windows has some
// complications due to |GetWindowText*()| APIs potentially causing a
- // deadlock (see the comments in the |GetWindowListHandler()| function in
+ // deadlock (see the comments in the `GetWindowListHandler()` function in
// window_capture_utils.cc for more details on the deadlock).
// To avoid this issue, consumers can either ensure that the thread that runs
- // their message loop never waits on |GetSourceList()|, or they can set this
+ // their message loop never waits on `GetSourceList()`, or they can set this
// flag to false which will prevent windows running in the current process
// from being enumerated and included in the results. Consumers can still
- // provide the WindowId for their own windows to |SelectSource()| and capture
+ // provide the WindowId for their own windows to `SelectSource()` and capture
// them.
bool enumerate_current_process_windows() const {
return enumerate_current_process_windows_;
diff --git a/modules/desktop_capture/desktop_capture_types.h b/modules/desktop_capture/desktop_capture_types.h
index 5f9966b..4dcfc82 100644
--- a/modules/desktop_capture/desktop_capture_types.h
+++ b/modules/desktop_capture/desktop_capture_types.h
@@ -39,7 +39,7 @@
// Integers to attach to each DesktopFrame to differentiate the generator of
// the frame. The entries in this namespace should remain in sync with the
// SequentialDesktopCapturerId enum, which is logged via UMA.
-// |kScreenCapturerWinGdi| and |kScreenCapturerWinDirectx| values are preserved
+// `kScreenCapturerWinGdi` and `kScreenCapturerWinDirectx` values are preserved
// to maintain compatibility
namespace DesktopCapturerId {
constexpr uint32_t CreateFourCC(char a, char b, char c, char d) {
diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h
index 64339c0..8a65e57 100644
--- a/modules/desktop_capture/desktop_capturer.h
+++ b/modules/desktop_capture/desktop_capturer.h
@@ -50,8 +50,8 @@
// Interface that must be implemented by the DesktopCapturer consumers.
class Callback {
public:
- // Called after a frame has been captured. |frame| is not nullptr if and
- // only if |result| is SUCCESS.
+ // Called after a frame has been captured. `frame` is not nullptr if and
+ // only if `result` is SUCCESS.
virtual void OnCaptureResult(Result result,
std::unique_ptr<DesktopFrame> frame) = 0;
@@ -77,7 +77,7 @@
virtual ~DesktopCapturer();
- // Called at the beginning of a capturing session. |callback| must remain
+ // Called at the beginning of a capturing session. `callback` must remain
// valid until capturer is destroyed.
virtual void Start(Callback* callback) = 0;
@@ -120,11 +120,11 @@
// implementation does not support this functionality.
virtual bool FocusOnSelectedSource();
- // Returns true if the |pos| on the selected source is covered by other
+ // Returns true if the `pos` on the selected source is covered by other
// elements on the display, and is not visible to the users.
- // |pos| is in full desktop coordinates, i.e. the top-left monitor always
+ // `pos` is in full desktop coordinates, i.e. the top-left monitor always
// starts from (0, 0).
- // The return value if |pos| is out of the scope of the source is undefined.
+ // The return value if `pos` is out of the scope of the source is undefined.
virtual bool IsOccluded(const DesktopVector& pos);
// Creates a DesktopCapturer instance which targets to capture windows.
diff --git a/modules/desktop_capture/desktop_capturer_differ_wrapper.cc b/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
index 4e80f30..916d76f 100644
--- a/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
+++ b/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
@@ -25,8 +25,8 @@
namespace {
-// Returns true if (0, 0) - (|width|, |height|) vector in |old_buffer| and
-// |new_buffer| are equal. |width| should be less than 32
+// Returns true if (0, 0) - (`width`, `height`) vector in `old_buffer` and
+// `new_buffer` are equal. `width` should be less than 32
// (defined by kBlockSize), otherwise BlockDifference() should be used.
bool PartialBlockDifference(const uint8_t* old_buffer,
const uint8_t* new_buffer,
@@ -45,9 +45,9 @@
return false;
}
-// Compares columns in the range of [|left|, |right|), in a row in the
-// range of [|top|, |top| + |height|), starts from |old_buffer| and
-// |new_buffer|, and outputs updated regions into |output|. |stride| is the
+// Compares columns in the range of [`left`, `right`), in a row in the
+// range of [`top`, `top` + `height`), starts from `old_buffer` and
+// `new_buffer`, and outputs updated regions into `output`. `stride` is the
// DesktopFrame::stride().
void CompareRow(const uint8_t* old_buffer,
const uint8_t* new_buffer,
@@ -68,7 +68,7 @@
// The first block-column in a continuous dirty area in current block-row.
int first_dirty_x_block = -1;
- // We always need to add dirty area into |output| in the last block, so handle
+ // We always need to add dirty area into `output` in the last block, so handle
// it separatedly.
for (int x = 0; x < block_count; x++) {
if (BlockDifference(old_buffer, new_buffer, height, stride)) {
@@ -109,8 +109,8 @@
}
}
-// Compares |rect| area in |old_frame| and |new_frame|, and outputs dirty
-// regions into |output|.
+// Compares `rect` area in `old_frame` and `new_frame`, and outputs dirty
+// regions into `output`.
void CompareFrames(const DesktopFrame& old_frame,
const DesktopFrame& new_frame,
DesktopRect rect,
diff --git a/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc b/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
index d16390d..9ccef3c 100644
--- a/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
+++ b/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
@@ -29,9 +29,9 @@
namespace {
-// Compares and asserts |frame|.updated_region() equals to |rects|. This
-// function does not care about the order of the |rects| and it does not expect
-// DesktopRegion to return an exact area for each rectangle in |rects|.
+// Compares and asserts `frame`.updated_region() equals to `rects`. This
+// function does not care about the order of the `rects` and it does not expect
+// DesktopRegion to return an exact area for each rectangle in `rects`.
template <template <typename, typename...> class T = std::initializer_list,
typename... Rect>
void AssertUpdatedRegionIs(const DesktopFrame& frame,
@@ -43,10 +43,10 @@
ASSERT_TRUE(frame.updated_region().Equals(region));
}
-// Compares and asserts |frame|.updated_region() covers all rectangles in
-// |rects|, but does not cover areas other than a kBlockSize expansion. This
-// function does not care about the order of the |rects|, and it does not expect
-// DesktopRegion to return an exact area of each rectangle in |rects|.
+// Compares and asserts `frame`.updated_region() covers all rectangles in
+// `rects`, but does not cover areas other than a kBlockSize expansion. This
+// function does not care about the order of the `rects`, and it does not expect
+// DesktopRegion to return an exact area of each rectangle in `rects`.
template <template <typename, typename...> class T = std::initializer_list,
typename... Rect>
void AssertUpdatedRegionCovers(const DesktopFrame& frame,
@@ -56,13 +56,13 @@
region.AddRect(rect);
}
- // Intersect of |rects| and |frame|.updated_region() should be |rects|. i.e.
- // |frame|.updated_region() should be a superset of |rects|.
+ // Intersect of `rects` and `frame`.updated_region() should be `rects`. i.e.
+ // `frame`.updated_region() should be a superset of `rects`.
DesktopRegion intersect(region);
intersect.IntersectWith(frame.updated_region());
ASSERT_TRUE(region.Equals(intersect));
- // Difference between |rects| and |frame|.updated_region() should not cover
+ // Difference between `rects` and `frame`.updated_region() should not cover
// areas which have larger than twice of kBlockSize width and height.
//
// Explanation of the 'twice' of kBlockSize (indeed kBlockSize * 2 - 2) is
@@ -106,8 +106,8 @@
}
// Executes a DesktopCapturerDifferWrapper::Capture() and compares its output
-// DesktopFrame::updated_region() with |updated_region| if |check_result| is
-// true. If |exactly_match| is true, AssertUpdatedRegionIs() will be used,
+// DesktopFrame::updated_region() with `updated_region` if `check_result` is
+// true. If `exactly_match` is true, AssertUpdatedRegionIs() will be used,
// otherwise AssertUpdatedRegionCovers() will be used.
template <template <typename, typename...> class T = std::initializer_list,
typename... Rect>
diff --git a/modules/desktop_capture/desktop_frame.h b/modules/desktop_capture/desktop_frame.h
index bc47cc5..9c53b83 100644
--- a/modules/desktop_capture/desktop_frame.h
+++ b/modules/desktop_capture/desktop_frame.h
@@ -85,7 +85,7 @@
int64_t capture_time_ms() const { return capture_time_ms_; }
void set_capture_time_ms(int64_t time_ms) { capture_time_ms_ = time_ms; }
- // Copies pixels from a buffer or another frame. |dest_rect| rect must lay
+ // Copies pixels from a buffer or another frame. `dest_rect` rect must lay
// within bounds of this frame.
void CopyPixelsFrom(const uint8_t* src_buffer,
int src_stride,
@@ -113,21 +113,21 @@
uint32_t capturer_id() const { return capturer_id_; }
void set_capturer_id(uint32_t capturer_id) { capturer_id_ = capturer_id; }
- // Copies various information from |other|. Anything initialized in
+ // Copies various information from `other`. Anything initialized in
// constructor are not copied.
// This function is usually used when sharing a source DesktopFrame with
// several clients: the original DesktopFrame should be kept unchanged. For
// example, BasicDesktopFrame::CopyOf() and SharedDesktopFrame::Share().
void CopyFrameInfoFrom(const DesktopFrame& other);
- // Copies various information from |other|. Anything initialized in
+ // Copies various information from `other`. Anything initialized in
// constructor are not copied. Not like CopyFrameInfoFrom() function, this
// function uses swap or move constructor to avoid data copy. It won't break
- // the |other|, but some of its information may be missing after this
+ // the `other`, but some of its information may be missing after this
// operation. E.g. other->updated_region_;
// This function is usually used when wrapping a DesktopFrame: the wrapper
- // instance takes the ownership of |other|, so other components cannot access
- // |other| anymore. For example, CroppedDesktopFrame and
+ // instance takes the ownership of `other`, so other components cannot access
+ // `other` anymore. For example, CroppedDesktopFrame and
// DesktopFrameWithCursor.
void MoveFrameInfoFrom(DesktopFrame* other);
@@ -175,7 +175,7 @@
~BasicDesktopFrame() override;
- // Creates a BasicDesktopFrame that contains copy of |frame|.
+ // Creates a BasicDesktopFrame that contains copy of `frame`.
// TODO(zijiehe): Return std::unique_ptr<DesktopFrame>
static DesktopFrame* CopyOf(const DesktopFrame& frame);
@@ -186,14 +186,14 @@
// A DesktopFrame that stores data in shared memory.
class RTC_EXPORT SharedMemoryDesktopFrame : public DesktopFrame {
public:
- // May return nullptr if |shared_memory_factory| failed to create a
+ // May return nullptr if `shared_memory_factory` failed to create a
// SharedMemory instance.
- // |shared_memory_factory| should not be nullptr.
+ // `shared_memory_factory` should not be nullptr.
static std::unique_ptr<DesktopFrame> Create(
DesktopSize size,
SharedMemoryFactory* shared_memory_factory);
- // Takes ownership of |shared_memory|.
+ // Takes ownership of `shared_memory`.
// Deprecated, use the next constructor.
SharedMemoryDesktopFrame(DesktopSize size,
int stride,
diff --git a/modules/desktop_capture/desktop_frame_generator.cc b/modules/desktop_capture/desktop_frame_generator.cc
index 64ba86c..b5dfc28 100644
--- a/modules/desktop_capture/desktop_frame_generator.cc
+++ b/modules/desktop_capture/desktop_frame_generator.cc
@@ -24,11 +24,11 @@
namespace {
-// Sets |updated_region| to |frame|. If |enlarge_updated_region| is
+// Sets `updated_region` to `frame`. If `enlarge_updated_region` is
// true, this function will randomly enlarge each DesktopRect in
-// |updated_region|. But the enlarged DesktopRegion won't excceed the
-// frame->size(). If |add_random_updated_region| is true, several random
-// rectangles will also be included in |frame|.
+// `updated_region`. But the enlarged DesktopRegion won't excceed the
+// frame->size(). If `add_random_updated_region` is true, several random
+// rectangles will also be included in `frame`.
void SetUpdatedRegion(DesktopFrame* frame,
const DesktopRegion& updated_region,
bool enlarge_updated_region,
@@ -61,7 +61,7 @@
}
}
-// Paints pixels in |rect| of |frame| to |color|.
+// Paints pixels in `rect` of `frame` to `color`.
void PaintRect(DesktopFrame* frame, DesktopRect rect, RgbaColor rgba_color) {
static_assert(DesktopFrame::kBytesPerPixel == sizeof(uint32_t),
"kBytesPerPixel should be 4.");
@@ -78,7 +78,7 @@
}
}
-// Paints pixels in |region| of |frame| to |color|.
+// Paints pixels in `region` of `frame` to `color`.
void PaintRegion(DesktopFrame* frame,
DesktopRegion* region,
RgbaColor rgba_color) {
diff --git a/modules/desktop_capture/desktop_frame_generator.h b/modules/desktop_capture/desktop_frame_generator.h
index c8ac5a9..3dedee9 100644
--- a/modules/desktop_capture/desktop_frame_generator.h
+++ b/modules/desktop_capture/desktop_frame_generator.h
@@ -71,9 +71,9 @@
// regions' return from OS APIs.
void set_enlarge_updated_region(bool enlarge_updated_region);
- // The range to enlarge a updated region if |enlarge_updated_region_| is true.
+ // The range to enlarge a updated region if `enlarge_updated_region_` is true.
// If this field is less than zero, it will be treated as zero, and
- // |enlarge_updated_region_| will be ignored.
+ // `enlarge_updated_region_` will be ignored.
void set_enlarge_range(int enlarge_range);
// Decides whether BaseDesktopFrameGenerator randomly add some updated regions
@@ -81,10 +81,10 @@
// updated regions' return from OS APIs.
void set_add_random_updated_region(bool add_random_updated_region);
- // Sets the painter object to do the real painting work, if no |painter_| has
+ // Sets the painter object to do the real painting work, if no `painter_` has
// been set to this instance, the DesktopFrame returned by GetNextFrame()
// function will keep in an undefined but valid state.
- // PainterDesktopFrameGenerator does not take ownership of the |painter|.
+ // PainterDesktopFrameGenerator does not take ownership of the `painter`.
void set_desktop_frame_painter(DesktopFramePainter* painter);
private:
diff --git a/modules/desktop_capture/desktop_frame_rotation.cc b/modules/desktop_capture/desktop_frame_rotation.cc
index 5e9928d..daef385 100644
--- a/modules/desktop_capture/desktop_frame_rotation.cc
+++ b/modules/desktop_capture/desktop_frame_rotation.cc
@@ -97,7 +97,7 @@
DesktopFrame* target) {
RTC_DCHECK(target);
RTC_DCHECK(DesktopRect::MakeSize(source.size()).ContainsRect(source_rect));
- // The rectangle in |target|.
+ // The rectangle in `target`.
const DesktopRect target_rect =
RotateAndOffsetRect(source_rect, source.size(), rotation, target_offset);
RTC_DCHECK(DesktopRect::MakeSize(target->size()).ContainsRect(target_rect));
diff --git a/modules/desktop_capture/desktop_frame_rotation.h b/modules/desktop_capture/desktop_frame_rotation.h
index 72bb1a6..6b51b2f 100644
--- a/modules/desktop_capture/desktop_frame_rotation.h
+++ b/modules/desktop_capture/desktop_frame_rotation.h
@@ -24,27 +24,27 @@
CLOCK_WISE_270,
};
-// Rotates input DesktopFrame |source|, copies pixel in an unrotated rectangle
-// |source_rect| into the target rectangle of another DesktopFrame |target|.
-// Target rectangle here is the rotated |source_rect| plus |target_offset|.
-// |rotation| specifies |source| to |target| rotation. |source_rect| is in
-// |source| coordinate. |target_offset| is in |target| coordinate.
-// This function triggers check failure if |source| does not cover the
-// |source_rect|, or |target| does not cover the rotated |rect|.
+// Rotates input DesktopFrame `source`, copies pixel in an unrotated rectangle
+// `source_rect` into the target rectangle of another DesktopFrame `target`.
+// Target rectangle here is the rotated `source_rect` plus `target_offset`.
+// `rotation` specifies `source` to `target` rotation. `source_rect` is in
+// `source` coordinate. `target_offset` is in `target` coordinate.
+// This function triggers check failure if `source` does not cover the
+// `source_rect`, or `target` does not cover the rotated `rect`.
void RotateDesktopFrame(const DesktopFrame& source,
const DesktopRect& source_rect,
const Rotation& rotation,
const DesktopVector& target_offset,
DesktopFrame* target);
-// Returns a reverse rotation of |rotation|.
+// Returns a reverse rotation of `rotation`.
Rotation ReverseRotation(Rotation rotation);
-// Returns a rotated DesktopSize of |size|.
+// Returns a rotated DesktopSize of `size`.
DesktopSize RotateSize(DesktopSize size, Rotation rotation);
-// Returns a rotated DesktopRect of |rect|. The |size| represents the size of
-// the DesktopFrame which |rect| belongs in.
+// Returns a rotated DesktopRect of `rect`. The `size` represents the size of
+// the DesktopFrame which `rect` belongs in.
DesktopRect RotateRect(DesktopRect rect, DesktopSize size, Rotation rotation);
} // namespace webrtc
diff --git a/modules/desktop_capture/desktop_geometry.h b/modules/desktop_capture/desktop_geometry.h
index 09ebefd..691455d 100644
--- a/modules/desktop_capture/desktop_geometry.h
+++ b/modules/desktop_capture/desktop_geometry.h
@@ -123,35 +123,35 @@
right_ == other.right_ && bottom_ == other.bottom_;
}
- // Returns true if |point| lies within the rectangle boundaries.
+ // Returns true if `point` lies within the rectangle boundaries.
bool Contains(const DesktopVector& point) const;
- // Returns true if |rect| lies within the boundaries of this rectangle.
+ // Returns true if `rect` lies within the boundaries of this rectangle.
bool ContainsRect(const DesktopRect& rect) const;
- // Finds intersection with |rect|.
+ // Finds intersection with `rect`.
void IntersectWith(const DesktopRect& rect);
- // Extends the rectangle to cover |rect|. If |this| is empty, replaces |this|
- // with |rect|; if |rect| is empty, this function takes no effect.
+ // Extends the rectangle to cover `rect`. If `this` is empty, replaces `this`
+ // with `rect`; if `rect` is empty, this function takes no effect.
void UnionWith(const DesktopRect& rect);
// Adds (dx, dy) to the position of the rectangle.
void Translate(int32_t dx, int32_t dy);
void Translate(DesktopVector d) { Translate(d.x(), d.y()); }
- // Enlarges current DesktopRect by subtracting |left_offset| and |top_offset|
- // from |left_| and |top_|, and adding |right_offset| and |bottom_offset| to
- // |right_| and |bottom_|. This function does not normalize the result, so
- // |left_| and |top_| may be less than zero or larger than |right_| and
- // |bottom_|.
+ // Enlarges current DesktopRect by subtracting `left_offset` and `top_offset`
+ // from `left_` and `top_`, and adding `right_offset` and `bottom_offset` to
+ // `right_` and `bottom_`. This function does not normalize the result, so
+ // `left_` and `top_` may be less than zero or larger than `right_` and
+ // `bottom_`.
void Extend(int32_t left_offset,
int32_t top_offset,
int32_t right_offset,
int32_t bottom_offset);
- // Scales current DesktopRect. This function does not impact the |top_| and
- // |left_|.
+ // Scales current DesktopRect. This function does not impact the `top_` and
+ // `left_`.
void Scale(double horizontal, double vertical);
private:
diff --git a/modules/desktop_capture/desktop_region.cc b/modules/desktop_capture/desktop_region.cc
index 96f142d..d4e7179 100644
--- a/modules/desktop_capture/desktop_region.cc
+++ b/modules/desktop_capture/desktop_region.cc
@@ -90,24 +90,24 @@
if (rect.is_empty())
return;
- // Top of the part of the |rect| that hasn't been inserted yet. Increased as
+ // Top of the part of the `rect` that hasn't been inserted yet. Increased as
// we iterate over the rows until it reaches |rect.bottom()|.
int top = rect.top();
- // Iterate over all rows that may intersect with |rect| and add new rows when
+ // Iterate over all rows that may intersect with `rect` and add new rows when
// necessary.
Rows::iterator row = rows_.upper_bound(top);
while (top < rect.bottom()) {
if (row == rows_.end() || top < row->second->top) {
- // If |top| is above the top of the current |row| then add a new row above
+ // If `top` is above the top of the current `row` then add a new row above
// the current one.
int32_t bottom = rect.bottom();
if (row != rows_.end() && row->second->top < bottom)
bottom = row->second->top;
row = rows_.insert(row, Rows::value_type(bottom, new Row(top, bottom)));
} else if (top > row->second->top) {
- // If the |top| falls in the middle of the |row| then split |row| into
- // two, at |top|, and leave |row| referring to the lower of the two,
+ // If the `top` falls in the middle of the `row` then split `row` into
+ // two, at `top`, and leave `row` referring to the lower of the two,
// ready to insert a new span into.
RTC_DCHECK_LE(top, row->second->bottom);
Rows::iterator new_row = rows_.insert(
@@ -117,8 +117,8 @@
}
if (rect.bottom() < row->second->bottom) {
- // If the bottom of the |rect| falls in the middle of the |row| split
- // |row| into two, at |top|, and leave |row| referring to the upper of
+ // If the bottom of the `rect` falls in the middle of the `row` split
+ // `row` into two, at `top`, and leave `row` referring to the upper of
// the two, ready to insert a new span into.
Rows::iterator new_row = rows_.insert(
row, Rows::value_type(rect.bottom(), new Row(top, rect.bottom())));
@@ -154,7 +154,7 @@
Rows::iterator previous_row = row;
previous_row--;
- // If |row| and |previous_row| are next to each other and contain the same
+ // If `row` and `previous_row` are next to each other and contain the same
// set of spans then they can be merged.
if (previous_row->second->bottom == row->second->top &&
previous_row->second->spans == row->second->spans) {
@@ -185,20 +185,20 @@
return;
while (it1 != end1 && it2 != end2) {
- // Arrange for |it1| to always be the top-most of the rows.
+ // Arrange for `it1` to always be the top-most of the rows.
if (it2->second->top < it1->second->top) {
std::swap(it1, it2);
std::swap(end1, end2);
}
- // Skip |it1| if it doesn't intersect |it2| at all.
+ // Skip `it1` if it doesn't intersect `it2` at all.
if (it1->second->bottom <= it2->second->top) {
++it1;
continue;
}
- // Top of the |it1| row is above the top of |it2|, so top of the
- // intersection is always the top of |it2|.
+ // Top of the `it1` row is above the top of `it2`, so top of the
+ // intersection is always the top of `it2`.
int32_t top = it2->second->top;
int32_t bottom = std::min(it1->second->bottom, it2->second->bottom);
@@ -213,10 +213,10 @@
MergeWithPrecedingRow(new_row);
}
- // If |it1| was completely consumed, move to the next one.
+ // If `it1` was completely consumed, move to the next one.
if (it1->second->bottom == bottom)
++it1;
- // If |it2| was completely consumed, move to the next one.
+ // If `it2` was completely consumed, move to the next one.
if (it2->second->bottom == bottom)
++it2;
}
@@ -233,13 +233,13 @@
RTC_DCHECK(it1 != end1 && it2 != end2);
do {
- // Arrange for |it1| to always be the left-most of the spans.
+ // Arrange for `it1` to always be the left-most of the spans.
if (it2->left < it1->left) {
std::swap(it1, it2);
std::swap(end1, end2);
}
- // Skip |it1| if it doesn't intersect |it2| at all.
+ // Skip `it1` if it doesn't intersect `it2` at all.
if (it1->right <= it2->left) {
++it1;
continue;
@@ -251,10 +251,10 @@
output->push_back(RowSpan(left, right));
- // If |it1| was completely consumed, move to the next one.
+ // If `it1` was completely consumed, move to the next one.
if (it1->right == right)
++it1;
- // If |it2| was completely consumed, move to the next one.
+ // If `it2` was completely consumed, move to the next one.
if (it2->right == right)
++it2;
} while (it1 != end1 && it2 != end2);
@@ -276,20 +276,20 @@
if (region.rows_.empty())
return;
- // |row_b| refers to the current row being subtracted.
+ // `row_b` refers to the current row being subtracted.
Rows::const_iterator row_b = region.rows_.begin();
// Current vertical position at which subtraction is happening.
int top = row_b->second->top;
- // |row_a| refers to the current row we are subtracting from. Skip all rows
- // above |top|.
+ // `row_a` refers to the current row we are subtracting from. Skip all rows
+ // above `top`.
Rows::iterator row_a = rows_.upper_bound(top);
- // Step through rows of the both regions subtracting content of |row_b| from
- // |row_a|.
+ // Step through rows of the both regions subtracting content of `row_b` from
+ // `row_a`.
while (row_a != rows_.end() && row_b != region.rows_.end()) {
- // Skip |row_a| if it doesn't intersect with the |row_b|.
+ // Skip `row_a` if it doesn't intersect with the `row_b`.
if (row_a->second->bottom <= top) {
// Each output row is merged with previously-processed rows before further
// rows are processed.
@@ -299,8 +299,8 @@
}
if (top > row_a->second->top) {
- // If |top| falls in the middle of |row_a| then split |row_a| into two, at
- // |top|, and leave |row_a| referring to the lower of the two, ready to
+ // If `top` falls in the middle of `row_a` then split `row_a` into two, at
+ // `top`, and leave `row_a` referring to the lower of the two, ready to
// subtract spans from.
RTC_DCHECK_LE(top, row_a->second->bottom);
Rows::iterator new_row = rows_.insert(
@@ -308,8 +308,8 @@
row_a->second->top = top;
new_row->second->spans = row_a->second->spans;
} else if (top < row_a->second->top) {
- // If the |top| is above |row_a| then skip the range between |top| and
- // top of |row_a| because it's empty.
+ // If the `top` is above `row_a` then skip the range between `top` and
+ // top of `row_a` because it's empty.
top = row_a->second->top;
if (top >= row_b->second->bottom) {
++row_b;
@@ -320,8 +320,8 @@
}
if (row_b->second->bottom < row_a->second->bottom) {
- // If the bottom of |row_b| falls in the middle of the |row_a| split
- // |row_a| into two, at |top|, and leave |row_a| referring to the upper of
+ // If the bottom of `row_b` falls in the middle of the `row_a` split
+ // `row_a` into two, at `top`, and leave `row_a` referring to the upper of
// the two, ready to subtract spans from.
int bottom = row_b->second->bottom;
Rows::iterator new_row =
@@ -331,8 +331,8 @@
row_a = new_row;
}
- // At this point the vertical range covered by |row_a| lays within the
- // range covered by |row_b|. Subtract |row_b| spans from |row_a|.
+ // At this point the vertical range covered by `row_a` lays within the
+ // range covered by `row_b`. Subtract `row_b` spans from `row_a`.
RowSpanSet new_spans;
SubtractRows(row_a->second->spans, row_b->second->spans, &new_spans);
new_spans.swap(row_a->second->spans);
@@ -417,12 +417,12 @@
return;
}
- // Find the first span that ends at or after |left|.
+ // Find the first span that ends at or after `left`.
RowSpanSet::iterator start = std::lower_bound(
row->spans.begin(), row->spans.end(), left, CompareSpanRight);
RTC_DCHECK(start < row->spans.end());
- // Find the first span that starts after |right|.
+ // Find the first span that starts after `right`.
RowSpanSet::iterator end =
std::lower_bound(start, row->spans.end(), right + 1, CompareSpanLeft);
if (end == row->spans.begin()) {
@@ -432,7 +432,7 @@
}
// Move end to the left, so that it points the last span that ends at or
- // before |right|.
+ // before `right`.
end--;
// At this point [start, end] is the range of spans that intersect with the
@@ -471,8 +471,8 @@
RowSpanSet::const_iterator it_b = set_b.begin();
- // Iterate over all spans in |set_a| adding parts of it that do not intersect
- // with |set_b| to the |output|.
+ // Iterate over all spans in `set_a` adding parts of it that do not intersect
+ // with `set_b` to the `output`.
for (RowSpanSet::const_iterator it_a = set_a.begin(); it_a != set_a.end();
++it_a) {
// If there is no intersection then append the current span and continue.
@@ -481,7 +481,7 @@
continue;
}
- // Iterate over |set_b| spans that may intersect with |it_a|.
+ // Iterate over `set_b` spans that may intersect with `it_a`.
int pos = it_a->left;
while (it_b != set_b.end() && it_b->left < it_a->right) {
if (it_b->left > pos)
diff --git a/modules/desktop_capture/desktop_region.h b/modules/desktop_capture/desktop_region.h
index 1aa95d0..ae9d8a0 100644
--- a/modules/desktop_capture/desktop_region.h
+++ b/modules/desktop_capture/desktop_region.h
@@ -80,9 +80,9 @@
private:
const DesktopRegion& region_;
- // Updates |rect_| based on the current |row_| and |row_span_|. If
- // |row_span_| matches spans on consecutive rows then they are also merged
- // into |rect_|, to generate more efficient output.
+ // Updates `rect_` based on the current `row_` and `row_span_`. If
+ // `row_span_` matches spans on consecutive rows then they are also merged
+ // into `rect_`, to generate more efficient output.
void UpdateCurrentRect();
Rows::const_iterator row_;
@@ -106,7 +106,7 @@
// Reset the region to be empty.
void Clear();
- // Reset region to contain just |rect|.
+ // Reset region to contain just `rect`.
void SetRect(const DesktopRect& rect);
// Adds specified rect(s) or region to the region.
@@ -117,16 +117,16 @@
// Finds intersection of two regions and stores them in the current region.
void Intersect(const DesktopRegion& region1, const DesktopRegion& region2);
- // Same as above but intersects content of the current region with |region|.
+ // Same as above but intersects content of the current region with `region`.
void IntersectWith(const DesktopRegion& region);
- // Clips the region by the |rect|.
+ // Clips the region by the `rect`.
void IntersectWith(const DesktopRect& rect);
- // Subtracts |region| from the current content of the region.
+ // Subtracts `region` from the current content of the region.
void Subtract(const DesktopRegion& region);
- // Subtracts |rect| from the current content of the region.
+ // Subtracts `rect` from the current content of the region.
void Subtract(const DesktopRect& rect);
// Adds (dx, dy) to the position of the region.
@@ -136,14 +136,14 @@
private:
// Comparison functions used for std::lower_bound(). Compare left or right
- // edges withs a given |value|.
+ // edges withs a given `value`.
static bool CompareSpanLeft(const RowSpan& r, int32_t value);
static bool CompareSpanRight(const RowSpan& r, int32_t value);
// Adds a new span to the row, coalescing spans if necessary.
static void AddSpanToRow(Row* row, int32_t left, int32_t right);
- // Returns true if the |span| exists in the given |row|.
+ // Returns true if the `span` exists in the given `row`.
static bool IsSpanInRow(const Row& row, const RowSpan& rect);
// Calculates the intersection of two sets of spans.
@@ -155,9 +155,9 @@
const RowSpanSet& set_b,
RowSpanSet* output);
- // Merges |row| with the row above it if they contain the same spans. Doesn't
- // do anything if called with |row| set to rows_.begin() (i.e. first row of
- // the region). If the rows were merged |row| remains a valid iterator to the
+ // Merges `row` with the row above it if they contain the same spans. Doesn't
+ // do anything if called with `row` set to rows_.begin() (i.e. first row of
+ // the region). If the rows were merged `row` remains a valid iterator to the
// merged row.
void MergeWithPrecedingRow(Rows::iterator row);
diff --git a/modules/desktop_capture/differ_block.h b/modules/desktop_capture/differ_block.h
index 2019ae0..6c71e21 100644
--- a/modules/desktop_capture/differ_block.h
+++ b/modules/desktop_capture/differ_block.h
@@ -27,7 +27,7 @@
bool VectorDifference(const uint8_t* image1, const uint8_t* image2);
// Low level function to compare 2 blocks of pixels of size
-// (kBlockSize, |height|). Returns whether the blocks differ.
+// (kBlockSize, `height`). Returns whether the blocks differ.
bool BlockDifference(const uint8_t* image1,
const uint8_t* image2,
int height,
diff --git a/modules/desktop_capture/fake_desktop_capturer.cc b/modules/desktop_capture/fake_desktop_capturer.cc
index 83e360b..f9d9dbd 100644
--- a/modules/desktop_capture/fake_desktop_capturer.cc
+++ b/modules/desktop_capture/fake_desktop_capturer.cc
@@ -32,9 +32,9 @@
return num_capture_attempts_;
}
-// Uses the |generator| provided as DesktopFrameGenerator, FakeDesktopCapturer
+// Uses the `generator` provided as DesktopFrameGenerator, FakeDesktopCapturer
// does
-// not take the ownership of |generator|.
+// not take the ownership of `generator`.
void FakeDesktopCapturer::set_frame_generator(
DesktopFrameGenerator* generator) {
generator_ = generator;
diff --git a/modules/desktop_capture/fake_desktop_capturer.h b/modules/desktop_capture/fake_desktop_capturer.h
index 2aa000a..086e6df 100644
--- a/modules/desktop_capture/fake_desktop_capturer.h
+++ b/modules/desktop_capture/fake_desktop_capturer.h
@@ -39,8 +39,8 @@
// Decides the result which will be returned in next Capture() callback.
void set_result(DesktopCapturer::Result result);
- // Uses the |generator| provided as DesktopFrameGenerator, FakeDesktopCapturer
- // does not take the ownership of |generator|.
+ // Uses the `generator` provided as DesktopFrameGenerator, FakeDesktopCapturer
+ // does not take the ownership of `generator`.
void set_frame_generator(DesktopFrameGenerator* generator);
// Count of DesktopFrame(s) have been returned by this instance. This field
diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
index 0b1ab7e..61fdb41 100644
--- a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
@@ -27,13 +27,13 @@
// implementations only.
class SharedMemoryFactoryProxy : public SharedMemoryFactory {
public:
- // Users should maintain the lifetime of |factory| to ensure it overlives
+ // Users should maintain the lifetime of `factory` to ensure it overlives
// current instance.
static std::unique_ptr<SharedMemoryFactory> Create(
SharedMemoryFactory* factory);
~SharedMemoryFactoryProxy() override;
- // Forwards CreateSharedMemory() calls to |factory_|. Users should always call
+ // Forwards CreateSharedMemory() calls to `factory_`. Users should always call
// this function in one thread. Users should not call this function after the
// SharedMemoryFactory which current instance created from has been destroyed.
std::unique_ptr<SharedMemory> CreateSharedMemory(size_t size) override;
@@ -88,7 +88,7 @@
main_capturer_->Start(this);
// For the secondary capturer, we do not have a backup plan anymore, so
// FallbackDesktopCapturerWrapper won't check its return value any more. It
- // will directly return to the input |callback|.
+ // will directly return to the input `callback`.
secondary_capturer_->Start(callback);
}
diff --git a/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc b/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc
index e3668a5..761d428 100644
--- a/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc
+++ b/modules/desktop_capture/linux/mouse_cursor_monitor_x11.cc
@@ -36,7 +36,7 @@
// window managers may re-parent them to add decorations. However,
// XQueryPointer() expects to be passed children of the root. This function
// searches up the list of the windows to find the root child that corresponds
-// to |window|.
+// to `window`.
Window GetTopLevelWindow(Display* display, Window window) {
while (true) {
// If the window is in WithdrawnState then look at all of its children.
@@ -153,17 +153,17 @@
state = OUTSIDE;
} else {
// In screen mode (window_ == root_window) the mouse is always inside.
- // XQueryPointer() sets |child_window| to None if the cursor is outside
- // |window_|.
+ // XQueryPointer() sets `child_window` to None if the cursor is outside
+ // `window_`.
state =
(window_ == root_window || child_window != None) ? INSIDE : OUTSIDE;
}
// As the comments to GetTopLevelWindow() above indicate, in window capture,
- // the cursor position capture happens in |window_|, while the frame catpure
- // happens in |child_window|. These two windows are not alwyas same, as
- // window manager may add some decorations to the |window_|. So translate
- // the coordinate in |window_| to the coordinate space of |child_window|.
+ // the cursor position capture happens in `window_`, while the frame catpure
+ // happens in `child_window`. These two windows are not alwyas same, as
+ // window manager may add some decorations to the `window_`. So translate
+ // the coordinate in `window_` to the coordinate space of `child_window`.
if (window_ != root_window && state == INSIDE) {
int translated_x, translated_y;
Window unused;
diff --git a/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h b/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h
index 9603341..c34eaf4 100644
--- a/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h
+++ b/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h
@@ -48,7 +48,7 @@
Display* display() { return x_display_->display(); }
- // Captures current cursor shape and stores it in |cursor_shape_|.
+ // Captures current cursor shape and stores it in `cursor_shape_`.
void CaptureCursor();
rtc::scoped_refptr<SharedXDisplay> x_display_;
diff --git a/modules/desktop_capture/linux/screen_capturer_x11.cc b/modules/desktop_capture/linux/screen_capturer_x11.cc
index 1b17071..7cdbb2a 100644
--- a/modules/desktop_capture/linux/screen_capturer_x11.cc
+++ b/modules/desktop_capture/linux/screen_capturer_x11.cc
@@ -234,7 +234,7 @@
options_.x_display()->ProcessPendingXEvents();
// ProcessPendingXEvents() may call ScreenConfigurationChanged() which
- // reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still
+ // reinitializes `x_server_pixel_buffer_`. Check if the pixel buffer is still
// in a good shape.
if (!x_server_pixel_buffer_.is_initialized()) {
// We failed to initialize pixel buffer.
@@ -276,7 +276,7 @@
return true;
}
- // Ensure that |monitors_| is updated with changes that may have happened
+ // Ensure that `monitors_` is updated with changes that may have happened
// between calls to GetSourceList().
options_.x_display()->ProcessPendingXEvents();
@@ -350,7 +350,7 @@
// In the DAMAGE case, ensure the frame is up-to-date with the previous frame
// if any. If there isn't a previous frame, that means a screen-resolution
- // change occurred, and |invalid_rects| will be updated to include the whole
+ // change occurred, and `invalid_rects` will be updated to include the whole
// screen.
if (use_damage_ && queue_.previous_frame())
SynchronizeFrame();
@@ -419,7 +419,7 @@
// positives.
// TODO(hclam): We can reduce the amount of copying here by subtracting
- // |capturer_helper_|s region from |last_invalid_region_|.
+ // `capturer_helper_`s region from `last_invalid_region_`.
// http://crbug.com/92354
RTC_DCHECK(queue_.previous_frame());
diff --git a/modules/desktop_capture/linux/screen_capturer_x11.h b/modules/desktop_capture/linux/screen_capturer_x11.h
index b19e2e4..c98b9fb 100644
--- a/modules/desktop_capture/linux/screen_capturer_x11.h
+++ b/modules/desktop_capture/linux/screen_capturer_x11.h
@@ -78,10 +78,10 @@
// Called when the screen configuration is changed.
void ScreenConfigurationChanged();
- // Synchronize the current buffer with |last_buffer_|, by copying pixels from
- // the area of |last_invalid_rects|.
+ // Synchronize the current buffer with `last_buffer_`, by copying pixels from
+ // the area of `last_invalid_rects`.
// Note this only works on the assumption that kNumBuffers == 2, as
- // |last_invalid_rects| holds the differences from the previous buffer and
+ // `last_invalid_rects` holds the differences from the previous buffer and
// the one prior to that (which will then be the current buffer).
void SynchronizeFrame();
diff --git a/modules/desktop_capture/linux/shared_x_display.cc b/modules/desktop_capture/linux/shared_x_display.cc
index f0b35f6..3133134 100644
--- a/modules/desktop_capture/linux/shared_x_display.cc
+++ b/modules/desktop_capture/linux/shared_x_display.cc
@@ -65,7 +65,7 @@
}
void SharedXDisplay::ProcessPendingXEvents() {
- // Hold reference to |this| to prevent it from being destroyed while
+ // Hold reference to `this` to prevent it from being destroyed while
// processing events.
rtc::scoped_refptr<SharedXDisplay> self(this);
diff --git a/modules/desktop_capture/linux/shared_x_display.h b/modules/desktop_capture/linux/shared_x_display.h
index dd52e45..da130b0 100644
--- a/modules/desktop_capture/linux/shared_x_display.h
+++ b/modules/desktop_capture/linux/shared_x_display.h
@@ -39,8 +39,8 @@
virtual bool HandleXEvent(const XEvent& event) = 0;
};
- // Creates a new X11 Display for the |display_name|. NULL is returned if X11
- // connection failed. Equivalent to CreateDefault() when |display_name| is
+ // Creates a new X11 Display for the `display_name`. NULL is returned if X11
+ // connection failed. Equivalent to CreateDefault() when `display_name` is
// empty.
static rtc::scoped_refptr<SharedXDisplay> Create(
const std::string& display_name);
@@ -51,11 +51,11 @@
Display* display() { return display_; }
- // Adds a new event |handler| for XEvent's of |type|.
+ // Adds a new event `handler` for XEvent's of `type`.
void AddEventHandler(int type, XEventHandler* handler);
- // Removes event |handler| added using |AddEventHandler|. Doesn't do anything
- // if |handler| is not registered.
+ // Removes event `handler` added using `AddEventHandler`. Doesn't do anything
+ // if `handler` is not registered.
void RemoveEventHandler(int type, XEventHandler* handler);
// Processes pending XEvents, calling corresponding event handlers.
@@ -66,7 +66,7 @@
~SharedXDisplay();
protected:
- // Takes ownership of |display|.
+ // Takes ownership of `display`.
explicit SharedXDisplay(Display* display);
private:
diff --git a/modules/desktop_capture/linux/window_capturer_x11.h b/modules/desktop_capture/linux/window_capturer_x11.h
index f689dd6..d8a085f 100644
--- a/modules/desktop_capture/linux/window_capturer_x11.h
+++ b/modules/desktop_capture/linux/window_capturer_x11.h
@@ -52,7 +52,7 @@
private:
Display* display() { return x_display_->display(); }
- // Returns window title for the specified X |window|.
+ // Returns window title for the specified X `window`.
bool GetWindowTitle(::Window window, std::string* title);
Callback* callback_ = nullptr;
diff --git a/modules/desktop_capture/linux/window_list_utils.cc b/modules/desktop_capture/linux/window_list_utils.cc
index 06660dd..ade92d2 100644
--- a/modules/desktop_capture/linux/window_list_utils.cc
+++ b/modules/desktop_capture/linux/window_list_utils.cc
@@ -40,7 +40,7 @@
XFree(data_);
}
-// Iterates through |window| hierarchy to find first visible window, i.e. one
+// Iterates through `window` hierarchy to find first visible window, i.e. one
// that has WM_STATE property set to NormalState.
// See http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.3.1 .
::Window GetApplicationWindow(XAtomCache* cache, ::Window window) {
@@ -76,7 +76,7 @@
return app_window;
}
-// Returns true if the |window| is a desktop element.
+// Returns true if the `window` is a desktop element.
bool IsDesktopElement(XAtomCache* cache, ::Window window) {
RTC_DCHECK(cache);
if (window == 0)
diff --git a/modules/desktop_capture/linux/window_list_utils.h b/modules/desktop_capture/linux/window_list_utils.h
index 243680d..3ffd336 100644
--- a/modules/desktop_capture/linux/window_list_utils.h
+++ b/modules/desktop_capture/linux/window_list_utils.h
@@ -21,30 +21,30 @@
namespace webrtc {
-// Synchronously iterates all on-screen windows in |cache|.display() in
-// decreasing z-order and sends them one-by-one to |on_window| function before
-// GetWindowList() returns. If |on_window| returns false, this function ignores
+// Synchronously iterates all on-screen windows in `cache`.display() in
+// decreasing z-order and sends them one-by-one to `on_window` function before
+// GetWindowList() returns. If `on_window` returns false, this function ignores
// other windows and returns immediately. GetWindowList() returns false if
-// native APIs failed. If multiple screens are attached to the |display|, this
+// native APIs failed. If multiple screens are attached to the `display`, this
// function returns false only when native APIs failed on all screens. Menus,
// panels and minimized windows will be ignored.
bool GetWindowList(XAtomCache* cache,
rtc::FunctionView<bool(::Window)> on_window);
-// Returns WM_STATE property of the |window|. This function returns
-// WithdrawnState if the |window| is missing.
+// Returns WM_STATE property of the `window`. This function returns
+// WithdrawnState if the `window` is missing.
int32_t GetWindowState(XAtomCache* cache, ::Window window);
-// Returns the rectangle of the |window| in the coordinates of |display|. This
-// function returns false if native APIs failed. If |attributes| is provided, it
-// will be filled with the attributes of |window|. The |rect| is in system
+// Returns the rectangle of the `window` in the coordinates of `display`. This
+// function returns false if native APIs failed. If `attributes` is provided, it
+// will be filled with the attributes of `window`. The `rect` is in system
// coordinate, i.e. the primary monitor always starts from (0, 0).
bool GetWindowRect(::Display* display,
::Window window,
DesktopRect* rect,
XWindowAttributes* attributes = nullptr);
-// Creates a DesktopRect from |attributes|.
+// Creates a DesktopRect from `attributes`.
template <typename T>
DesktopRect DesktopRectFromXAttributes(const T& attributes) {
return DesktopRect::MakeXYWH(attributes.x, attributes.y, attributes.width,
diff --git a/modules/desktop_capture/linux/x_server_pixel_buffer.cc b/modules/desktop_capture/linux/x_server_pixel_buffer.cc
index d3b568d..84b57f1 100644
--- a/modules/desktop_capture/linux/x_server_pixel_buffer.cc
+++ b/modules/desktop_capture/linux/x_server_pixel_buffer.cc
@@ -27,9 +27,9 @@
namespace {
-// Returns the number of bits |mask| has to be shifted left so its last
+// Returns the number of bits `mask` has to be shifted left so its last
// (most-significant) bit set becomes the most-significant bit of the word.
-// When |mask| is 0 the function returns 31.
+// When `mask` is 0 the function returns 31.
uint32_t MaskToShift(uint32_t mask) {
int shift = 0;
if ((mask & 0xffff0000u) == 0) {
@@ -54,7 +54,7 @@
return shift;
}
-// Returns true if |image| is in RGB format.
+// Returns true if `image` is in RGB format.
bool IsXImageRGBFormat(XImage* image) {
return image->bits_per_pixel == 32 && image->red_mask == 0xff0000 &&
image->green_mask == 0xff00 && image->blue_mask == 0xff;
@@ -191,7 +191,7 @@
}
if (cache->IccProfile() != None) {
- // |window| is the root window when doing screen capture.
+ // `window` is the root window when doing screen capture.
XWindowProperty<uint8_t> icc_profile_property(cache->display(), window,
cache->IccProfile());
if (icc_profile_property.is_valid() && icc_profile_property.size() > 0) {
@@ -283,7 +283,7 @@
window_rect_.width(), window_rect_.height(), depth);
XSync(display_, False);
if (error_trap.GetLastErrorAndDisable() != 0) {
- // |shm_pixmap_| is not not valid because the request was not processed
+ // `shm_pixmap_` is not not valid because the request was not processed
// by the X Server, so zero it.
shm_pixmap_ = 0;
return false;
diff --git a/modules/desktop_capture/linux/x_server_pixel_buffer.h b/modules/desktop_capture/linux/x_server_pixel_buffer.h
index 06dd1a1..aa3f903 100644
--- a/modules/desktop_capture/linux/x_server_pixel_buffer.h
+++ b/modules/desktop_capture/linux/x_server_pixel_buffer.h
@@ -36,7 +36,7 @@
void Release();
- // Allocate (or reallocate) the pixel buffer for |window|. Returns false in
+ // Allocate (or reallocate) the pixel buffer for `window`. Returns false in
// case of an error (e.g. window doesn't exist).
bool Init(XAtomCache* cache, Window window);
@@ -58,10 +58,10 @@
// beginning.
void Synchronize();
- // Capture the specified rectangle and stores it in the |frame|. In the case
+ // Capture the specified rectangle and stores it in the `frame`. In the case
// where the full-screen data is captured by Synchronize(), this simply
// returns the pointer without doing any more work. The caller must ensure
- // that |rect| is not larger than window_size().
+ // that `rect` is not larger than window_size().
bool CaptureRect(const DesktopRect& rect, DesktopFrame* frame);
private:
diff --git a/modules/desktop_capture/mac/desktop_configuration.h b/modules/desktop_capture/mac/desktop_configuration.h
index d95957d..2ad5474 100644
--- a/modules/desktop_capture/mac/desktop_configuration.h
+++ b/modules/desktop_capture/mac/desktop_configuration.h
@@ -71,7 +71,7 @@
// Returns true if the given desktop configuration equals this one.
bool Equals(const MacDesktopConfiguration& other);
- // If |id| corresponds to the built-in display, return its configuration,
+ // If `id` corresponds to the built-in display, return its configuration,
// otherwise return the configuration for the display with the specified id,
// or nullptr if no such display exists.
const MacDisplayConfiguration* FindDisplayConfigurationById(
diff --git a/modules/desktop_capture/mac/desktop_configuration.mm b/modules/desktop_capture/mac/desktop_configuration.mm
index ef69b64..93fb3f6 100644
--- a/modules/desktop_capture/mac/desktop_configuration.mm
+++ b/modules/desktop_capture/mac/desktop_configuration.mm
@@ -38,8 +38,8 @@
static_cast<int>(ceil(ns_rect.origin.y + ns_rect.size.height)));
}
-// Inverts the position of |rect| from bottom-up coordinates to top-down,
-// relative to |bounds|.
+// Inverts the position of `rect` from bottom-up coordinates to top-down,
+// relative to `bounds`.
void InvertRectYOrigin(const DesktopRect& bounds,
DesktopRect* rect) {
RTC_DCHECK_EQ(bounds.top(), 0);
@@ -125,7 +125,7 @@
if (i > 0 && origin == TopLeftOrigin) {
InvertRectYOrigin(desktop_config.displays[0].bounds,
&display_config.bounds);
- // |display_bounds| is density dependent, so we need to convert the
+ // `display_bounds` is density dependent, so we need to convert the
// primay monitor's position into the secondary monitor's density context.
float scaling_factor = display_config.dip_to_pixel_scale /
desktop_config.displays[0].dip_to_pixel_scale;
diff --git a/modules/desktop_capture/mac/desktop_frame_cgimage.h b/modules/desktop_capture/mac/desktop_frame_cgimage.h
index 8e00666..8780438 100644
--- a/modules/desktop_capture/mac/desktop_frame_cgimage.h
+++ b/modules/desktop_capture/mac/desktop_frame_cgimage.h
@@ -39,7 +39,7 @@
static std::unique_ptr<DesktopFrameCGImage> CreateFromCGImage(
rtc::ScopedCFTypeRef<CGImageRef> cg_image);
- // This constructor expects |cg_image| to hold a non-null CGImageRef.
+ // This constructor expects `cg_image` to hold a non-null CGImageRef.
DesktopFrameCGImage(DesktopSize size,
int stride,
uint8_t* data,
diff --git a/modules/desktop_capture/mac/desktop_frame_iosurface.h b/modules/desktop_capture/mac/desktop_frame_iosurface.h
index be2fc4f..f79197a 100644
--- a/modules/desktop_capture/mac/desktop_frame_iosurface.h
+++ b/modules/desktop_capture/mac/desktop_frame_iosurface.h
@@ -31,7 +31,7 @@
~DesktopFrameIOSurface() override;
private:
- // This constructor expects |io_surface| to hold a non-null IOSurfaceRef.
+ // This constructor expects `io_surface` to hold a non-null IOSurfaceRef.
explicit DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
const rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
diff --git a/modules/desktop_capture/mac/desktop_frame_provider.h b/modules/desktop_capture/mac/desktop_frame_provider.h
index f71959b..bb45d1e 100644
--- a/modules/desktop_capture/mac/desktop_frame_provider.h
+++ b/modules/desktop_capture/mac/desktop_frame_provider.h
@@ -29,7 +29,7 @@
~DesktopFrameProvider();
// The caller takes ownership of the returned desktop frame. Otherwise
- // returns null if |display_id| is invalid or not ready. Note that this
+ // returns null if `display_id` is invalid or not ready. Note that this
// function does not remove the frame from the internal container. Caller
// has to call the Release function.
std::unique_ptr<DesktopFrame> TakeLatestFrameForDisplay(
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index a79384c..29d2017 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -33,8 +33,8 @@
static_cast<int>(ceil((rect.origin.y + rect.size.height) * scale)));
}
-// Copy pixels in the |rect| from |src_place| to |dest_plane|. |rect| should be
-// relative to the origin of |src_plane| and |dest_plane|.
+// Copy pixels in the `rect` from `src_place` to `dest_plane`. `rect` should be
+// relative to the origin of `src_plane` and `dest_plane`.
void CopyRect(const uint8_t* src_plane,
int src_plane_stride,
uint8_t* dest_plane,
@@ -59,7 +59,7 @@
}
// Returns an array of CGWindowID for all the on-screen windows except
-// |window_to_exclude|, or NULL if the window is not found or it fails. The
+// `window_to_exclude`, or NULL if the window is not found or it fails. The
// caller should release the returned CFArrayRef.
CFArrayRef CreateWindowListWithExclusion(CGWindowID window_to_exclude) {
if (!window_to_exclude) return nullptr;
@@ -92,7 +92,7 @@
return returned_array;
}
-// Returns the bounds of |window| in physical pixels, enlarged by a small amount
+// Returns the bounds of `window` in physical pixels, enlarged by a small amount
// on four edges to take account of the border/shadow effects.
DesktopRect GetExcludedWindowPixelBounds(CGWindowID window, float dip_to_pixel_scale) {
// The amount of pixels to add to the actual window bounds to take into
@@ -121,12 +121,12 @@
rect.origin.y -= kBorderEffectSize;
rect.size.width += kBorderEffectSize * 2;
rect.size.height += kBorderEffectSize * 2;
- // |rect| is in DIP, so convert to physical pixels.
+ // `rect` is in DIP, so convert to physical pixels.
return ScaleAndRoundCGRect(rect, dip_to_pixel_scale);
}
-// Create an image of the given region using the given |window_list|.
-// |pixel_bounds| should be in the primary display's coordinate in physical
+// Create an image of the given region using the given `window_list`.
+// `pixel_bounds` should be in the primary display's coordinate in physical
// pixels.
rtc::ScopedCFTypeRef<CGImageRef> CreateExcludedWindowRegionImage(const DesktopRect& pixel_bounds,
float dip_to_pixel_scale,
@@ -366,7 +366,7 @@
int src_bytes_per_row = frame_source->stride();
RTC_DCHECK(display_base_address);
- // |frame_source| size may be different from display_bounds in case the screen was
+ // `frame_source` size may be different from display_bounds in case the screen was
// resized recently.
copy_region.IntersectWith(frame_source->rect());
@@ -388,7 +388,7 @@
display_base_address = CFDataGetBytePtr(excluded_image_data.get());
src_bytes_per_row = CGImageGetBytesPerRow(excluded_image.get());
- // Translate the bounds relative to the desktop, because |frame| data
+ // Translate the bounds relative to the desktop, because `frame` data
// starts from the desktop top-left corner.
DesktopRect window_bounds_relative_to_desktop(excluded_window_bounds);
window_bounds_relative_to_desktop.Translate(-screen_pixel_bounds_.left(),
diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc
index 56d87ce..d2fb20e 100644
--- a/modules/desktop_capture/mac/window_list_utils.cc
+++ b/modules/desktop_capture/mac/window_list_utils.cc
@@ -44,15 +44,15 @@
return true;
}
-// Get CFDictionaryRef from |id| and call |on_window| against it. This function
-// returns false if native APIs fail, typically it indicates that the |id| does
-// not represent a window. |on_window| will not be called if false is returned
+// Get CFDictionaryRef from `id` and call `on_window` against it. This function
+// returns false if native APIs fail, typically it indicates that the `id` does
+// not represent a window. `on_window` will not be called if false is returned
// from this function.
bool GetWindowRef(CGWindowID id,
rtc::FunctionView<void(CFDictionaryRef)> on_window) {
RTC_DCHECK(on_window);
- // TODO(zijiehe): |id| is a 32-bit integer, casting it to an array seems not
+ // TODO(zijiehe): `id` is a 32-bit integer, casting it to an array seems not
// safe enough. Maybe we should create a new
// const void* arr[] = {
// reinterpret_cast<void*>(id) }
diff --git a/modules/desktop_capture/mac/window_list_utils.h b/modules/desktop_capture/mac/window_list_utils.h
index f1c0601..a9b1e70 100644
--- a/modules/desktop_capture/mac/window_list_utils.h
+++ b/modules/desktop_capture/mac/window_list_utils.h
@@ -23,10 +23,10 @@
namespace webrtc {
// Iterates all on-screen windows in decreasing z-order and sends them
-// one-by-one to |on_window| function. If |on_window| returns false, this
+// one-by-one to `on_window` function. If `on_window` returns false, this
// function returns immediately. GetWindowList() returns false if native APIs
-// failed. Menus, dock (if |only_zero_layer|), minimized windows (if
-// |ignore_minimized| is true) and any windows which do not have a valid window
+// failed. Menus, dock (if `only_zero_layer`), minimized windows (if
+// `ignore_minimized` is true) and any windows which do not have a valid window
// id or title will be ignored.
bool GetWindowList(rtc::FunctionView<bool(CFDictionaryRef)> on_window,
bool ignore_minimized,
@@ -45,59 +45,59 @@
bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config,
CGWindowID id);
-// Returns true if the |window| is on screen. This function returns false if
+// Returns true if the `window` is on screen. This function returns false if
// native APIs fail.
bool IsWindowOnScreen(CFDictionaryRef window);
// Returns true if the window is on screen. This function returns false if
-// native APIs fail or |id| cannot be found.
+// native APIs fail or `id` cannot be found.
bool IsWindowOnScreen(CGWindowID id);
-// Returns utf-8 encoded title of |window|. If |window| is not a window or no
+// Returns utf-8 encoded title of `window`. If `window` is not a window or no
// valid title can be retrieved, this function returns an empty string.
std::string GetWindowTitle(CFDictionaryRef window);
-// Returns utf-8 encoded title of window |id|. If |id| cannot be found or no
+// Returns utf-8 encoded title of window `id`. If `id` cannot be found or no
// valid title can be retrieved, this function returns an empty string.
std::string GetWindowTitle(CGWindowID id);
-// Returns utf-8 encoded owner name of |window|. If |window| is not a window or
+// Returns utf-8 encoded owner name of `window`. If `window` is not a window or
// if no valid owner name can be retrieved, returns an empty string.
std::string GetWindowOwnerName(CFDictionaryRef window);
-// Returns utf-8 encoded owner name of the given window |id|. If |id| cannot be
+// Returns utf-8 encoded owner name of the given window `id`. If `id` cannot be
// found or if no valid owner name can be retrieved, returns an empty string.
std::string GetWindowOwnerName(CGWindowID id);
-// Returns id of |window|. If |window| is not a window or the window id cannot
+// Returns id of `window`. If `window` is not a window or the window id cannot
// be retrieved, this function returns kNullWindowId.
WindowId GetWindowId(CFDictionaryRef window);
-// Returns the pid of the process owning |window|. Return 0 if |window| is not
+// Returns the pid of the process owning `window`. Return 0 if `window` is not
// a window or no valid owner can be retrieved.
int GetWindowOwnerPid(CFDictionaryRef window);
-// Returns the pid of the process owning the window |id|. Return 0 if |id|
+// Returns the pid of the process owning the window `id`. Return 0 if `id`
// cannot be found or no valid owner can be retrieved.
int GetWindowOwnerPid(CGWindowID id);
-// Returns the DIP to physical pixel scale at |position|. |position| is in
+// Returns the DIP to physical pixel scale at `position`. `position` is in
// *unscaled* system coordinate, i.e. it's device-independent and the primary
-// monitor starts from (0, 0). If |position| is out of the system display, this
+// monitor starts from (0, 0). If `position` is out of the system display, this
// function returns 1.
float GetScaleFactorAtPosition(const MacDesktopConfiguration& desktop_config,
DesktopVector position);
-// Returns the DIP to physical pixel scale factor of the window with |id|.
-// The bounds of the window with |id| is in DIP coordinates and |size| is the
-// CGImage size of the window with |id| in physical coordinates. Comparing them
+// Returns the DIP to physical pixel scale factor of the window with `id`.
+// The bounds of the window with `id` is in DIP coordinates and `size` is the
+// CGImage size of the window with `id` in physical coordinates. Comparing them
// can give the current scale factor.
// If the window overlaps multiple monitors, OS will decide on which monitor the
// window is displayed and use its scale factor to the window. So this method
// still works.
float GetWindowScaleFactor(CGWindowID id, DesktopSize size);
-// Returns the bounds of |window|. If |window| is not a window or the bounds
+// Returns the bounds of `window`. If `window` is not a window or the bounds
// cannot be retrieved, this function returns an empty DesktopRect. The returned
// DesktopRect is in system coordinate, i.e. the primary monitor always starts
// from (0, 0).
@@ -105,7 +105,7 @@
// MacDesktopConfiguration.
DesktopRect GetWindowBounds(CFDictionaryRef window);
-// Returns the bounds of window with |id|. If |id| does not represent a window
+// Returns the bounds of window with `id`. If `id` does not represent a window
// or the bounds cannot be retrieved, this function returns an empty
// DesktopRect. The returned DesktopRect is in system coordinates.
// Deprecated: This function should be avoided in favor of the overload with
diff --git a/modules/desktop_capture/mouse_cursor.h b/modules/desktop_capture/mouse_cursor.h
index 2263610..0a74140 100644
--- a/modules/desktop_capture/mouse_cursor.h
+++ b/modules/desktop_capture/mouse_cursor.h
@@ -24,7 +24,7 @@
public:
MouseCursor();
- // Takes ownership of |image|. |hotspot| must be within |image| boundaries.
+ // Takes ownership of `image`. `hotspot` must be within `image` boundaries.
MouseCursor(DesktopFrame* image, const DesktopVector& hotspot);
~MouseCursor();
diff --git a/modules/desktop_capture/mouse_cursor_monitor.h b/modules/desktop_capture/mouse_cursor_monitor.h
index 43b75b3..e88a5b7 100644
--- a/modules/desktop_capture/mouse_cursor_monitor.h
+++ b/modules/desktop_capture/mouse_cursor_monitor.h
@@ -47,16 +47,16 @@
class Callback {
public:
// Called in response to Capture() when the cursor shape has changed. Must
- // take ownership of |cursor|.
+ // take ownership of `cursor`.
virtual void OnMouseCursor(MouseCursor* cursor) = 0;
- // Called in response to Capture(). |position| indicates cursor position
- // relative to the |window| specified in the constructor.
+ // Called in response to Capture(). `position` indicates cursor position
+ // relative to the `window` specified in the constructor.
// Deprecated: use the following overload instead.
virtual void OnMouseCursorPosition(CursorState state,
const DesktopVector& position) {}
- // Called in response to Capture(). |position| indicates cursor absolute
+ // Called in response to Capture(). `position` indicates cursor absolute
// position on the system in fullscreen coordinate, i.e. the top-left
// monitor always starts from (0, 0).
// The coordinates of the position is controlled by OS, but it's always
@@ -94,11 +94,11 @@
static std::unique_ptr<MouseCursorMonitor> Create(
const DesktopCaptureOptions& options);
- // Initializes the monitor with the |callback|, which must remain valid until
+ // Initializes the monitor with the `callback`, which must remain valid until
// capturer is destroyed.
virtual void Init(Callback* callback, Mode mode) = 0;
- // Captures current cursor shape and position (depending on the |mode| passed
+ // Captures current cursor shape and position (depending on the `mode` passed
// to Init()). Calls Callback::OnMouseCursor() if cursor shape has
// changed since the last call (or when Capture() is called for the first
// time) and then Callback::OnMouseCursorPosition() if mode is set to
diff --git a/modules/desktop_capture/resolution_tracker.h b/modules/desktop_capture/resolution_tracker.h
index 55f25d1..8fe9d61 100644
--- a/modules/desktop_capture/resolution_tracker.h
+++ b/modules/desktop_capture/resolution_tracker.h
@@ -17,8 +17,8 @@
class ResolutionTracker final {
public:
- // Sets the resolution to |size|. Returns true if a previous size was recorded
- // and differs from |size|.
+ // Sets the resolution to `size`. Returns true if a previous size was recorded
+ // and differs from `size`.
bool SetResolution(DesktopSize size);
// Resets to the initial state.
diff --git a/modules/desktop_capture/rgba_color.h b/modules/desktop_capture/rgba_color.h
index c47c8bc..2b13430 100644
--- a/modules/desktop_capture/rgba_color.h
+++ b/modules/desktop_capture/rgba_color.h
@@ -37,10 +37,10 @@
// instance from the ToUInt32() result of another RgbaColor instance.
explicit RgbaColor(uint32_t bgra);
- // Returns true if |this| and |right| is the same color.
+ // Returns true if `this` and `right` is the same color.
bool operator==(const RgbaColor& right) const;
- // Returns true if |this| and |right| are different colors.
+ // Returns true if `this` and `right` are different colors.
bool operator!=(const RgbaColor& right) const;
uint32_t ToUInt32() const;
diff --git a/modules/desktop_capture/screen_capture_frame_queue.h b/modules/desktop_capture/screen_capture_frame_queue.h
index 40dc6da..a92bac6 100644
--- a/modules/desktop_capture/screen_capture_frame_queue.h
+++ b/modules/desktop_capture/screen_capture_frame_queue.h
@@ -45,7 +45,7 @@
void MoveToNextFrame() { current_ = (current_ + 1) % kQueueLength; }
// Replaces the current frame with a new one allocated by the caller. The
- // existing frame (if any) is destroyed. Takes ownership of |frame|.
+ // existing frame (if any) is destroyed. Takes ownership of `frame`.
void ReplaceCurrentFrame(std::unique_ptr<FrameType> frame) {
frames_[current_] = std::move(frame);
}
diff --git a/modules/desktop_capture/screen_capturer_helper.cc b/modules/desktop_capture/screen_capturer_helper.cc
index d55aea6..f8261a9 100644
--- a/modules/desktop_capture/screen_capturer_helper.cc
+++ b/modules/desktop_capture/screen_capturer_helper.cc
@@ -58,14 +58,14 @@
size_most_recent_ = size;
}
-// Returns the largest multiple of |n| that is <= |x|.
-// |n| must be a power of 2. |nMask| is ~(|n| - 1).
+// Returns the largest multiple of `n` that is <= `x`.
+// `n` must be a power of 2. `nMask` is ~(`n` - 1).
static int DownToMultiple(int x, int nMask) {
return (x & nMask);
}
-// Returns the smallest multiple of |n| that is >= |x|.
-// |n| must be a power of 2. |nMask| is ~(|n| - 1).
+// Returns the smallest multiple of `n` that is >= `x`.
+// `n` must be a power of 2. `nMask` is ~(`n` - 1).
static int UpToMultiple(int x, int n, int nMask) {
return ((x + n - 1) & nMask);
}
diff --git a/modules/desktop_capture/screen_capturer_helper.h b/modules/desktop_capture/screen_capturer_helper.h
index 3e65860..f7c447a 100644
--- a/modules/desktop_capture/screen_capturer_helper.h
+++ b/modules/desktop_capture/screen_capturer_helper.h
@@ -39,7 +39,7 @@
// Invalidate the entire screen, of a given size.
void InvalidateScreen(const DesktopSize& size);
- // Copies current invalid region to |invalid_region| clears invalid region
+ // Copies current invalid region to `invalid_region` clears invalid region
// storage for the next frame.
void TakeInvalidRegion(DesktopRegion* invalid_region);
@@ -52,16 +52,16 @@
// be changed in the compressed output. So we need to re-render an entire
// block whenever part of the block changes.
//
- // If |log_grid_size| is >= 1, then this function makes TakeInvalidRegion()
+ // If `log_grid_size` is >= 1, then this function makes TakeInvalidRegion()
// produce an invalid region expanded so that its vertices lie on a grid of
- // size 2 ^ |log_grid_size|. The expanded region is then clipped to the size
+ // size 2 ^ `log_grid_size`. The expanded region is then clipped to the size
// of the most recently captured screen, as previously set by
// set_size_most_recent().
- // If |log_grid_size| is <= 0, then the invalid region is not expanded.
+ // If `log_grid_size` is <= 0, then the invalid region is not expanded.
void SetLogGridSize(int log_grid_size);
// Expands a region so that its vertices all lie on a grid.
- // The grid size must be >= 2, so |log_grid_size| must be >= 1.
+ // The grid size must be >= 2, so `log_grid_size` must be >= 1.
static void ExpandToGrid(const DesktopRegion& region,
int log_grid_size,
DesktopRegion* result);
@@ -72,7 +72,7 @@
// capture.
DesktopRegion invalid_region_ RTC_GUARDED_BY(invalid_region_mutex_);
- // A lock protecting |invalid_region_| across threads.
+ // A lock protecting `invalid_region_` across threads.
Mutex invalid_region_mutex_;
// The size of the most recently captured screen.
diff --git a/modules/desktop_capture/screen_capturer_integration_test.cc b/modules/desktop_capture/screen_capturer_integration_test.cc
index f9745b9..4d3f83a 100644
--- a/modules/desktop_capture/screen_capturer_integration_test.cc
+++ b/modules/desktop_capture/screen_capturer_integration_test.cc
@@ -47,7 +47,7 @@
*dest = std::move(*arg1);
}
-// Returns true if color in |rect| of |frame| is |color|.
+// Returns true if color in `rect` of `frame` is `color`.
bool ArePixelsColoredBy(const DesktopFrame& frame,
DesktopRect rect,
RgbaColor color,
@@ -61,7 +61,7 @@
}
}
- // Color in the |rect| should be |color|.
+ // Color in the `rect` should be `color`.
uint8_t* row = frame.GetFrameDataAtPos(rect.top_left());
for (int i = 0; i < rect.height(); i++) {
uint8_t* column = row;
@@ -118,9 +118,9 @@
capturer->Start(&callback_);
}
- // Draw a set of |kRectSize| by |kRectSize| rectangles at (|i|, |i|), or
- // |i| by |i| rectangles at (|kRectSize|, |kRectSize|). One of (controlled
- // by |c|) its primary colors is |i|, and the other two are 0x7f. So we
+ // Draw a set of `kRectSize` by `kRectSize` rectangles at (`i`, `i`), or
+ // `i` by `i` rectangles at (`kRectSize`, `kRectSize`). One of (controlled
+ // by `c`) its primary colors is `i`, and the other two are 0x7f. So we
// won't draw a black or white rectangle.
for (int c = 0; c < 3; c++) {
// A fixed size rectangle.
@@ -184,9 +184,9 @@
MockDesktopCapturerCallback callback_;
private:
- // Repeats capturing the frame by using |capturers| one-by-one for 600 times,
- // typically 30 seconds, until they succeeded captured a |color| rectangle at
- // |rect|. This function uses |drawer|->WaitForPendingDraws() between two
+ // Repeats capturing the frame by using `capturers` one-by-one for 600 times,
+ // typically 30 seconds, until they succeeded captured a `color` rectangle at
+ // `rect`. This function uses `drawer`->WaitForPendingDraws() between two
// attempts to wait for the screen to update.
void TestCaptureOneFrame(std::vector<DesktopCapturer*> capturers,
ScreenDrawer* drawer,
@@ -262,7 +262,7 @@
ASSERT_EQ(succeeded_capturers, capturers.size());
}
- // Expects |capturer| to successfully capture a frame, and returns it.
+ // Expects `capturer` to successfully capture a frame, and returns it.
std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) {
for (int i = 0; i < 10; i++) {
std::unique_ptr<DesktopFrame> frame;
diff --git a/modules/desktop_capture/screen_capturer_win.cc b/modules/desktop_capture/screen_capturer_win.cc
index be6d8a5..b5935dc 100644
--- a/modules/desktop_capture/screen_capturer_win.cc
+++ b/modules/desktop_capture/screen_capturer_win.cc
@@ -38,7 +38,7 @@
const DesktopCaptureOptions& options) {
std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options));
if (options.allow_directx_capturer()) {
- // |dxgi_duplicator_controller| should be alive in this scope to ensure it
+ // `dxgi_duplicator_controller` should be alive in this scope to ensure it
// won't unload DxgiDuplicatorController.
auto dxgi_duplicator_controller = DxgiDuplicatorController::Instance();
if (ScreenCapturerWinDirectx::IsSupported()) {
diff --git a/modules/desktop_capture/screen_drawer.h b/modules/desktop_capture/screen_drawer.h
index 0619000..ad7c0ad 100644
--- a/modules/desktop_capture/screen_drawer.h
+++ b/modules/desktop_capture/screen_drawer.h
@@ -50,8 +50,8 @@
// system coordinate, i.e. the primary monitor always starts from (0, 0).
virtual DesktopRect DrawableRegion() = 0;
- // Draws a rectangle to cover |rect| with |color|. Note, rect.bottom() and
- // rect.right() two lines are not included. The part of |rect| which is out of
+ // Draws a rectangle to cover `rect` with `color`. Note, rect.bottom() and
+ // rect.right() two lines are not included. The part of `rect` which is out of
// DrawableRegion() will be ignored.
virtual void DrawRectangle(DesktopRect rect, RgbaColor color) = 0;
diff --git a/modules/desktop_capture/screen_drawer_unittest.cc b/modules/desktop_capture/screen_drawer_unittest.cc
index 2394260..584770d 100644
--- a/modules/desktop_capture/screen_drawer_unittest.cc
+++ b/modules/desktop_capture/screen_drawer_unittest.cc
@@ -64,7 +64,7 @@
// SleepMs() may return early. See
// https://cs.chromium.org/chromium/src/third_party/webrtc/system_wrappers/include/sleep.h?rcl=4a604c80cecce18aff6fc5e16296d04675312d83&l=20
// But we need to ensure at least 100 ms has been passed before unlocking
- // |lock|.
+ // `lock`.
while (rtc::TimeMillis() - current_ms < kLockDurationMs) {
SleepMs(kLockDurationMs - (rtc::TimeMillis() - current_ms));
}
diff --git a/modules/desktop_capture/screen_drawer_win.cc b/modules/desktop_capture/screen_drawer_win.cc
index cacb889..7cf634f 100644
--- a/modules/desktop_capture/screen_drawer_win.cc
+++ b/modules/desktop_capture/screen_drawer_win.cc
@@ -89,10 +89,10 @@
// windows or shadow effects.
void BringToFront();
- // Draw a line with |color|.
+ // Draw a line with `color`.
void DrawLine(DesktopVector start, DesktopVector end, RgbaColor color);
- // Draw a dot with |color|.
+ // Draw a dot with `color`.
void DrawDot(DesktopVector vect, RgbaColor color);
const DesktopRect rect_;
@@ -105,7 +105,7 @@
rect_(GetScreenRect()),
window_(CreateDrawerWindow(rect_)),
hdc_(GetWindowDC(window_)) {
- // We do not need to handle any messages for the |window_|, so disable Windows
+ // We do not need to handle any messages for the `window_`, so disable Windows
// from processing windows ghosting feature.
DisableProcessWindowsGhosting();
diff --git a/modules/desktop_capture/shared_desktop_frame.h b/modules/desktop_capture/shared_desktop_frame.h
index 1f451b6..29f9306 100644
--- a/modules/desktop_capture/shared_desktop_frame.h
+++ b/modules/desktop_capture/shared_desktop_frame.h
@@ -40,7 +40,7 @@
// Returns the underlying instance of DesktopFrame.
DesktopFrame* GetUnderlyingFrame();
- // Returns whether |this| and |other| share the underlying DesktopFrame.
+ // Returns whether `this` and `other` share the underlying DesktopFrame.
bool ShareFrameWith(const SharedDesktopFrame& other) const;
// Creates a clone of this object.
diff --git a/modules/desktop_capture/test_utils.h b/modules/desktop_capture/test_utils.h
index 1e8b5f9..8669fec 100644
--- a/modules/desktop_capture/test_utils.h
+++ b/modules/desktop_capture/test_utils.h
@@ -15,10 +15,10 @@
namespace webrtc {
-// Clears a DesktopFrame |frame| by setting its data() into 0.
+// Clears a DesktopFrame `frame` by setting its data() into 0.
void ClearDesktopFrame(DesktopFrame* frame);
-// Compares size() and data() of two DesktopFrames |left| and |right|.
+// Compares size() and data() of two DesktopFrames `left` and `right`.
bool DesktopFrameDataEquals(const DesktopFrame& left,
const DesktopFrame& right);
diff --git a/modules/desktop_capture/win/cursor.cc b/modules/desktop_capture/win/cursor.cc
index 5aba769..1d645098e 100644
--- a/modules/desktop_capture/win/cursor.cc
+++ b/modules/desktop_capture/win/cursor.cc
@@ -88,7 +88,7 @@
}
// Scans a 32bpp bitmap looking for any pixels with non-zero alpha component.
-// Returns true if non-zero alpha is found. |stride| is expressed in pixels.
+// Returns true if non-zero alpha is found. `stride` is expressed in pixels.
bool HasAlphaChannel(const uint32_t* data, int stride, int width, int height) {
const RGBQUAD* plane = reinterpret_cast<const RGBQUAD*>(data);
for (int y = 0; y < height; ++y) {
@@ -121,7 +121,7 @@
win::ScopedBitmap scoped_color(iinfo.hbmColor);
bool is_color = iinfo.hbmColor != NULL;
- // Get |scoped_mask| dimensions.
+ // Get `scoped_mask` dimensions.
BITMAP bitmap_info;
if (!GetObject(scoped_mask, sizeof(bitmap_info), &bitmap_info)) {
RTC_LOG_F(LS_ERROR) << "Unable to get bitmap info. Error = "
@@ -133,7 +133,7 @@
int height = bitmap_info.bmHeight;
std::unique_ptr<uint32_t[]> mask_data(new uint32_t[width * height]);
- // Get pixel data from |scoped_mask| converting it to 32bpp along the way.
+ // Get pixel data from `scoped_mask` converting it to 32bpp along the way.
// GetDIBits() sets the alpha component of every pixel to 0.
BITMAPV5HEADER bmi = {0};
bmi.bV5Size = sizeof(bmi);
diff --git a/modules/desktop_capture/win/cursor.h b/modules/desktop_capture/win/cursor.h
index e67c711..54d7816 100644
--- a/modules/desktop_capture/win/cursor.h
+++ b/modules/desktop_capture/win/cursor.h
@@ -17,7 +17,7 @@
class MouseCursor;
-// Converts an HCURSOR into a |MouseCursor| instance.
+// Converts an HCURSOR into a `MouseCursor` instance.
MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor);
} // namespace webrtc
diff --git a/modules/desktop_capture/win/cursor_unittest.cc b/modules/desktop_capture/win/cursor_unittest.cc
index a1ae6d8..23f5d89 100644
--- a/modules/desktop_capture/win/cursor_unittest.cc
+++ b/modules/desktop_capture/win/cursor_unittest.cc
@@ -23,18 +23,18 @@
namespace {
-// Loads |left| from resources, converts it to a |MouseCursor| instance and
-// compares pixels with |right|. Returns true of MouseCursor bits match |right|.
-// |right| must be a 32bpp cursor with alpha channel.
+// Loads `left` from resources, converts it to a `MouseCursor` instance and
+// compares pixels with `right`. Returns true of MouseCursor bits match `right`.
+// `right` must be a 32bpp cursor with alpha channel.
bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) {
HMODULE instance = GetModuleHandle(NULL);
- // Load |left| from the EXE module's resources.
+ // Load `left` from the EXE module's resources.
win::ScopedCursor cursor(reinterpret_cast<HCURSOR>(
LoadImage(instance, MAKEINTRESOURCE(left), IMAGE_CURSOR, 0, 0, 0)));
EXPECT_TRUE(cursor != NULL);
- // Convert |cursor| to |mouse_shape|.
+ // Convert `cursor` to `mouse_shape`.
HDC dc = GetDC(NULL);
std::unique_ptr<MouseCursor> mouse_shape(
CreateMouseCursorFromHCursor(dc, cursor));
@@ -42,7 +42,7 @@
EXPECT_TRUE(mouse_shape.get());
- // Load |right|.
+ // Load `right`.
cursor.Set(reinterpret_cast<HCURSOR>(
LoadImage(instance, MAKEINTRESOURCE(right), IMAGE_CURSOR, 0, 0, 0)));
@@ -54,7 +54,7 @@
win::ScopedBitmap scoped_mask(iinfo.hbmMask);
win::ScopedBitmap scoped_color(iinfo.hbmColor);
- // Get |scoped_color| dimensions.
+ // Get `scoped_color` dimensions.
BITMAP bitmap_info;
EXPECT_TRUE(GetObject(scoped_color, sizeof(bitmap_info), &bitmap_info));
@@ -62,12 +62,12 @@
int height = bitmap_info.bmHeight;
EXPECT_TRUE(DesktopSize(width, height).equals(mouse_shape->image()->size()));
- // Get the pixels from |scoped_color|.
+ // Get the pixels from `scoped_color`.
int size = width * height;
std::unique_ptr<uint32_t[]> data(new uint32_t[size]);
EXPECT_TRUE(GetBitmapBits(scoped_color, size * sizeof(uint32_t), data.get()));
- // Compare the 32bpp image in |mouse_shape| with the one loaded from |right|.
+ // Compare the 32bpp image in `mouse_shape` with the one loaded from `right`.
return memcmp(data.get(), mouse_shape->image()->data(),
size * sizeof(uint32_t)) == 0;
}
diff --git a/modules/desktop_capture/win/desktop.h b/modules/desktop_capture/win/desktop.h
index 4d75419..382df60 100644
--- a/modules/desktop_capture/win/desktop.h
+++ b/modules/desktop_capture/win/desktop.h
@@ -28,7 +28,7 @@
// quering the name failed for any reason.
bool GetName(std::wstring* desktop_name_out) const;
- // Returns true if |other| has the same name as this desktop. Returns false
+ // Returns true if `other` has the same name as this desktop. Returns false
// in any other case including failing Win32 APIs and uninitialized desktop
// handles.
bool IsSame(const Desktop& other) const;
@@ -54,7 +54,7 @@
// The desktop handle.
HDESK desktop_;
- // True if |desktop_| must be closed on teardown.
+ // True if `desktop_` must be closed on teardown.
bool own_;
RTC_DISALLOW_COPY_AND_ASSIGN(Desktop);
diff --git a/modules/desktop_capture/win/dxgi_adapter_duplicator.h b/modules/desktop_capture/win/dxgi_adapter_duplicator.h
index d70eb7c..5931b51 100644
--- a/modules/desktop_capture/win/dxgi_adapter_duplicator.h
+++ b/modules/desktop_capture/win/dxgi_adapter_duplicator.h
@@ -43,10 +43,10 @@
bool Initialize();
// Sequentially calls Duplicate function of all the DxgiOutputDuplicator
- // instances owned by this instance, and writes into |target|.
+ // instances owned by this instance, and writes into `target`.
bool Duplicate(Context* context, SharedDesktopFrame* target);
- // Captures one monitor and writes into |target|. |monitor_id| should be
+ // Captures one monitor and writes into `target`. `monitor_id` should be
// between [0, screen_count()).
bool DuplicateMonitor(Context* context,
int monitor_id,
@@ -55,12 +55,12 @@
// Returns desktop rect covered by this DxgiAdapterDuplicator.
DesktopRect desktop_rect() const { return desktop_rect_; }
- // Returns the size of one screen owned by this DxgiAdapterDuplicator. |id|
+ // Returns the size of one screen owned by this DxgiAdapterDuplicator. `id`
// should be between [0, screen_count()).
DesktopRect ScreenRect(int id) const;
// Returns the device name of one screen owned by this DxgiAdapterDuplicator
- // in utf8 encoding. |id| should be between [0, screen_count()).
+ // in utf8 encoding. `id` should be between [0, screen_count()).
const std::string& GetDeviceName(int id) const;
// Returns the count of screens owned by this DxgiAdapterDuplicator. These
@@ -72,10 +72,10 @@
void Unregister(const Context* const context);
- // The minimum num_frames_captured() returned by |duplicators_|.
+ // The minimum num_frames_captured() returned by `duplicators_`.
int64_t GetNumFramesCaptured() const;
- // Moves |desktop_rect_| and all underlying |duplicators_|. See
+ // Moves `desktop_rect_` and all underlying `duplicators_`. See
// DxgiDuplicatorController::TranslateRect().
void TranslateRect(const DesktopVector& position);
diff --git a/modules/desktop_capture/win/dxgi_context.h b/modules/desktop_capture/win/dxgi_context.h
index c96773b..59c2112 100644
--- a/modules/desktop_capture/win/dxgi_context.h
+++ b/modules/desktop_capture/win/dxgi_context.h
@@ -48,7 +48,7 @@
// Reset current Context, so it will be reinitialized next time.
void Reset();
- // A Context will have an exactly same |controller_id| as
+ // A Context will have an exactly same `controller_id` as
// DxgiDuplicatorController, to ensure it has been correctly setted up after
// each DxgiDuplicatorController::Initialize().
int controller_id = 0;
diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc
index 4460ad9..59ad4eb 100644
--- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc
+++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc
@@ -186,12 +186,12 @@
return Result::SUCCEEDED;
}
if (monitor_id >= ScreenCountUnlocked()) {
- // It's a user error to provide a |monitor_id| larger than screen count. We
+ // It's a user error to provide a `monitor_id` larger than screen count. We
// do not need to deinitialize.
return Result::INVALID_MONITOR_ID;
}
- // If the |monitor_id| is valid, but DoDuplicateUnlocked() failed, something
+ // If the `monitor_id` is valid, but DoDuplicateUnlocked() failed, something
// must be wrong from capturer APIs. We should Deinitialize().
Deinitialize();
return Result::DUPLICATION_FAILED;
@@ -440,8 +440,8 @@
SharedDesktopFrame* shared_frame = nullptr;
if (target->size().width() >= desktop_size().width() &&
target->size().height() >= desktop_size().height()) {
- // |target| is large enough to cover entire screen, we do not need to use
- // |fallback_frame|.
+ // `target` is large enough to cover entire screen, we do not need to use
+ // `fallback_frame`.
shared_frame = target;
} else {
fallback_frame = SharedDesktopFrame::Wrap(
@@ -453,7 +453,7 @@
int64_t last_frame_start_ms = 0;
while (GetNumFramesCaptured() < frames_to_skip) {
if (GetNumFramesCaptured() > 0) {
- // Sleep |ms_per_frame| before capturing next frame to ensure the screen
+ // Sleep `ms_per_frame` before capturing next frame to ensure the screen
// has been updated by the video adapter.
webrtc::SleepMs(ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms));
}
diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.h b/modules/desktop_capture/win/dxgi_duplicator_controller.h
index 5e714f3..38e8549 100644
--- a/modules/desktop_capture/win/dxgi_duplicator_controller.h
+++ b/modules/desktop_capture/win/dxgi_duplicator_controller.h
@@ -68,7 +68,7 @@
INVALID_MONITOR_ID,
};
- // Converts |result| into user-friendly string representation. The return
+ // Converts `result` into user-friendly string representation. The return
// value should not be used to identify error types.
static std::string ResultName(Result result);
@@ -84,19 +84,19 @@
bool IsSupported();
// Returns a copy of D3dInfo composed by last Initialize() function call. This
- // function always copies the latest information into |info|. But once the
- // function returns false, the information in |info| may not accurate.
+ // function always copies the latest information into `info`. But once the
+ // function returns false, the information in `info` may not accurate.
bool RetrieveD3dInfo(D3dInfo* info);
- // Captures current screen and writes into |frame|.
+ // Captures current screen and writes into `frame`.
// TODO(zijiehe): Windows cannot guarantee the frames returned by each
// IDXGIOutputDuplication are synchronized. But we are using a totally
// different threading model than the way Windows suggested, it's hard to
// synchronize them manually. We should find a way to do it.
Result Duplicate(DxgiFrame* frame);
- // Captures one monitor and writes into target. |monitor_id| should >= 0. If
- // |monitor_id| is greater than the total screen count of all the Duplicators,
+ // Captures one monitor and writes into target. `monitor_id` should >= 0. If
+ // `monitor_id` is greater than the total screen count of all the Duplicators,
// this function returns false.
Result DuplicateMonitor(DxgiFrame* frame, int monitor_id);
@@ -135,21 +135,21 @@
void AddRef();
void Release();
- // Does the real duplication work. Setting |monitor_id| < 0 to capture entire
+ // Does the real duplication work. Setting `monitor_id` < 0 to capture entire
// screen. This function calls Initialize(). And if the duplication failed,
// this function calls Deinitialize() to ensure the Dxgi components can be
// reinitialized next time.
Result DoDuplicate(DxgiFrame* frame, int monitor_id);
// Unload all the DXGI components and releases the resources. This function
- // wraps Deinitialize() with |mutex_|.
+ // wraps Deinitialize() with `mutex_`.
void Unload();
// Unregisters Context from this instance and all DxgiAdapterDuplicator(s)
// it owns.
void Unregister(const Context* const context);
- // All functions below should be called in |mutex_| locked scope and should be
+ // All functions below should be called in `mutex_` locked scope and should be
// after a successful Initialize().
// If current instance has not been initialized, executes DoInitialize()
@@ -187,14 +187,14 @@
SharedDesktopFrame* target)
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- // The minimum GetNumFramesCaptured() returned by |duplicators_|.
+ // The minimum GetNumFramesCaptured() returned by `duplicators_`.
int64_t GetNumFramesCaptured() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- // Returns a DesktopSize to cover entire |desktop_rect_|.
+ // Returns a DesktopSize to cover entire `desktop_rect_`.
DesktopSize desktop_size() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- // Returns the size of one screen. |id| should be >= 0. If system does not
- // support DXGI based capturer, or |id| is greater than the total screen count
+ // Returns the size of one screen. `id` should be >= 0. If system does not
+ // support DXGI based capturer, or `id` is greater than the total screen count
// of all the Duplicators, this function returns an empty DesktopRect.
DesktopRect ScreenRect(int id) const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
@@ -203,8 +203,8 @@
void GetDeviceNamesUnlocked(std::vector<std::string>* output) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- // Returns the desktop size of the selected screen |monitor_id|. Setting
- // |monitor_id| < 0 to return the entire screen size.
+ // Returns the desktop size of the selected screen `monitor_id`. Setting
+ // `monitor_id` < 0 to return the entire screen size.
DesktopSize SelectedDesktopSize(int monitor_id) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
@@ -216,7 +216,7 @@
bool EnsureFrameCaptured(Context* context, SharedDesktopFrame* target)
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- // Moves |desktop_rect_| and all underlying |duplicators_|, putting top left
+ // Moves `desktop_rect_` and all underlying `duplicators_`, putting top left
// corner of the desktop at (0, 0). This is necessary because DXGI_OUTPUT_DESC
// may return negative coordinates. Called from DoInitialize() after all
// DxgiAdapterDuplicator and DxgiOutputDuplicator instances are initialized.
diff --git a/modules/desktop_capture/win/dxgi_frame.h b/modules/desktop_capture/win/dxgi_frame.h
index c87f42e..6a9ce86 100644
--- a/modules/desktop_capture/win/dxgi_frame.h
+++ b/modules/desktop_capture/win/dxgi_frame.h
@@ -32,7 +32,7 @@
public:
using Context = DxgiFrameContext;
- // DxgiFrame does not take ownership of |factory|, consumers should ensure it
+ // DxgiFrame does not take ownership of `factory`, consumers should ensure it
// outlives this instance. nullptr is acceptable.
explicit DxgiFrame(SharedMemoryFactory* factory);
~DxgiFrame();
diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.cc b/modules/desktop_capture/win/dxgi_output_duplicator.cc
index 65a0d77..177e126 100644
--- a/modules/desktop_capture/win/dxgi_output_duplicator.cc
+++ b/modules/desktop_capture/win/dxgi_output_duplicator.cc
@@ -171,7 +171,7 @@
// We need to merge updated region with the one from context, but only spread
// updated region from current frame. So keeps a copy of updated region from
- // context here. The |updated_region| always starts from (0, 0).
+ // context here. The `updated_region` always starts from (0, 0).
DesktopRegion updated_region;
updated_region.Swap(&context->updated_region);
if (error.Error() == S_OK && frame_info.AccumulatedFrames > 0 && resource) {
@@ -188,7 +188,7 @@
if (rotation_ != Rotation::CLOCK_WISE_0) {
for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd();
it.Advance()) {
- // The |updated_region| returned by Windows is rotated, but the |source|
+ // The `updated_region` returned by Windows is rotated, but the `source`
// frame is not. So we need to rotate it reversely.
const DesktopRect source_rect =
RotateRect(it.rect(), desktop_size(), ReverseRotation(rotation_));
@@ -197,7 +197,7 @@
} else {
for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd();
it.Advance()) {
- // The DesktopRect in |target|, starts from offset.
+ // The DesktopRect in `target`, starts from offset.
DesktopRect dest_rect = it.rect();
dest_rect.Translate(offset);
target->CopyPixelsFrom(source, it.rect().top_left(), dest_rect);
@@ -216,9 +216,9 @@
// export last frame to the target.
for (DesktopRegion::Iterator it(updated_region); !it.IsAtEnd();
it.Advance()) {
- // The DesktopRect in |source|, starts from last_frame_offset_.
+ // The DesktopRect in `source`, starts from last_frame_offset_.
DesktopRect source_rect = it.rect();
- // The DesktopRect in |target|, starts from offset.
+ // The DesktopRect in `target`, starts from offset.
DesktopRect target_rect = source_rect;
source_rect.Translate(last_frame_offset_);
target_rect.Translate(offset);
diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.h b/modules/desktop_capture/win/dxgi_output_duplicator.h
index 3079d39..198b5a6 100644
--- a/modules/desktop_capture/win/dxgi_output_duplicator.h
+++ b/modules/desktop_capture/win/dxgi_output_duplicator.h
@@ -54,10 +54,10 @@
// Initializes duplication_ object.
bool Initialize();
- // Copies the content of current IDXGIOutput to the |target|. To improve the
+ // Copies the content of current IDXGIOutput to the `target`. To improve the
// performance, this function copies only regions merged from
- // |context|->updated_region and DetectUpdatedRegion(). The |offset| decides
- // the offset in the |target| where the content should be copied to. i.e. this
+ // `context`->updated_region and DetectUpdatedRegion(). The `offset` decides
+ // the offset in the `target` where the content should be copied to. i.e. this
// function copies the content to the rectangle of (offset.x(), offset.y()) to
// (offset.x() + desktop_rect_.width(), offset.y() + desktop_rect_.height()).
// Returns false in case of a failure.
@@ -78,12 +78,12 @@
// How many frames have been captured by this DxigOutputDuplicator.
int64_t num_frames_captured() const;
- // Moves |desktop_rect_|. See DxgiDuplicatorController::TranslateRect().
+ // Moves `desktop_rect_`. See DxgiDuplicatorController::TranslateRect().
void TranslateRect(const DesktopVector& position);
private:
// Calls DoDetectUpdatedRegion(). If it fails, this function sets the
- // |updated_region| as entire UntranslatedDesktopRect().
+ // `updated_region` as entire UntranslatedDesktopRect().
void DetectUpdatedRegion(const DXGI_OUTDUPL_FRAME_INFO& frame_info,
DesktopRegion* updated_region);
@@ -106,7 +106,7 @@
// (0, 0).
DesktopRect GetUntranslatedDesktopRect() const;
- // Spreads changes from |context| to other registered Context(s) in
+ // Spreads changes from `context` to other registered Context(s) in
// contexts_.
void SpreadContextChange(const Context* const context);
@@ -132,7 +132,7 @@
// The last full frame of this output and its offset. If on AcquireNextFrame()
// failed because of timeout, i.e. no update, we can copy content from
- // |last_frame_|.
+ // `last_frame_`.
std::unique_ptr<SharedDesktopFrame> last_frame_;
DesktopVector last_frame_offset_;
diff --git a/modules/desktop_capture/win/dxgi_texture.h b/modules/desktop_capture/win/dxgi_texture.h
index 208e6a9..a663b95 100644
--- a/modules/desktop_capture/win/dxgi_texture.h
+++ b/modules/desktop_capture/win/dxgi_texture.h
@@ -26,7 +26,7 @@
// A texture copied or mapped from a DXGI_OUTDUPL_FRAME_INFO and IDXGIResource.
class DxgiTexture {
public:
- // Creates a DxgiTexture instance, which represents the |desktop_size| area of
+ // Creates a DxgiTexture instance, which represents the `desktop_size` area of
// entire screen -- usually a monitor on the system.
DxgiTexture();
diff --git a/modules/desktop_capture/win/dxgi_texture_mapping.h b/modules/desktop_capture/win/dxgi_texture_mapping.h
index 043ce61..71f00b9 100644
--- a/modules/desktop_capture/win/dxgi_texture_mapping.h
+++ b/modules/desktop_capture/win/dxgi_texture_mapping.h
@@ -27,7 +27,7 @@
class DxgiTextureMapping : public DxgiTexture {
public:
// Creates a DxgiTextureMapping instance. Caller must maintain the lifetime
- // of input |duplication| to make sure it outlives this instance.
+ // of input `duplication` to make sure it outlives this instance.
explicit DxgiTextureMapping(IDXGIOutputDuplication* duplication);
~DxgiTextureMapping() override;
diff --git a/modules/desktop_capture/win/full_screen_win_application_handler.cc b/modules/desktop_capture/win/full_screen_win_application_handler.cc
index dd21410..ad45047 100644
--- a/modules/desktop_capture/win/full_screen_win_application_handler.cc
+++ b/modules/desktop_capture/win/full_screen_win_application_handler.cc
@@ -24,7 +24,7 @@
namespace webrtc {
namespace {
-// Utility function to verify that |window| has class name equal to |class_name|
+// Utility function to verify that `window` has class name equal to `class_name`
bool CheckWindowClassName(HWND window, const wchar_t* class_name) {
const size_t classNameLength = wcslen(class_name);
@@ -69,9 +69,9 @@
}
// Returns windows which belong to given process id
-// |sources| is a full list of available windows
-// |processId| is a process identifier (window owner)
-// |window_to_exclude| is a window to be exluded from result
+// `sources` is a full list of available windows
+// `processId` is a process identifier (window owner)
+// `window_to_exclude` is a window to be exluded from result
DesktopCapturer::SourceList GetProcessWindows(
const DesktopCapturer::SourceList& sources,
DWORD processId,
diff --git a/modules/desktop_capture/win/scoped_thread_desktop.h b/modules/desktop_capture/win/scoped_thread_desktop.h
index 2eee674..04abaaf 100644
--- a/modules/desktop_capture/win/scoped_thread_desktop.h
+++ b/modules/desktop_capture/win/scoped_thread_desktop.h
@@ -27,7 +27,7 @@
ScopedThreadDesktop();
~ScopedThreadDesktop();
- // Returns true if |desktop| has the same desktop name as the currently
+ // Returns true if `desktop` has the same desktop name as the currently
// assigned desktop (if assigned) or as the initial desktop (if not assigned).
// Returns false in any other case including failing Win32 APIs and
// uninitialized desktop handles.
@@ -36,8 +36,8 @@
// Reverts the calling thread to use the initial desktop.
void Revert();
- // Assigns |desktop| to be the calling thread. Returns true if the thread has
- // been switched to |desktop| successfully. Takes ownership of |desktop|.
+ // Assigns `desktop` to be the calling thread. Returns true if the thread has
+ // been switched to `desktop` successfully. Takes ownership of `desktop`.
bool SetThreadDesktop(Desktop* desktop);
private:
diff --git a/modules/desktop_capture/win/screen_capture_utils.cc b/modules/desktop_capture/win/screen_capture_utils.cc
index 53b6dd399..8411533 100644
--- a/modules/desktop_capture/win/screen_capture_utils.cc
+++ b/modules/desktop_capture/win/screen_capture_utils.cc
@@ -37,7 +37,7 @@
device.cb = sizeof(device);
enum_result = EnumDisplayDevicesW(NULL, device_index, &device, 0);
- // |enum_result| is 0 if we have enumerated all devices.
+ // `enum_result` is 0 if we have enumerated all devices.
if (!enum_result) {
break;
}
@@ -57,7 +57,7 @@
bool GetHmonitorFromDeviceIndex(const DesktopCapturer::SourceId device_index,
HMONITOR* hmonitor) {
- // A device index of |kFullDesktopScreenId| or -1 represents all screens, an
+ // A device index of `kFullDesktopScreenId` or -1 represents all screens, an
// HMONITOR of 0 indicates the same.
if (device_index == kFullDesktopScreenId) {
*hmonitor = 0;
diff --git a/modules/desktop_capture/win/screen_capture_utils.h b/modules/desktop_capture/win/screen_capture_utils.h
index dc993da..1e0541b 100644
--- a/modules/desktop_capture/win/screen_capture_utils.h
+++ b/modules/desktop_capture/win/screen_capture_utils.h
@@ -19,30 +19,30 @@
namespace webrtc {
-// Output the list of active screens into |screens|. Returns true if succeeded,
-// or false if it fails to enumerate the display devices. If the |device_names|
+// Output the list of active screens into `screens`. Returns true if succeeded,
+// or false if it fails to enumerate the display devices. If the `device_names`
// is provided, it will be filled with the DISPLAY_DEVICE.DeviceName in UTF-8
// encoding. If this function returns true, consumers can always assume that
-// |screens|[i] and |device_names|[i] indicate the same monitor on the system.
+// `screens`[i] and `device_names`[i] indicate the same monitor on the system.
bool GetScreenList(DesktopCapturer::SourceList* screens,
std::vector<std::string>* device_names = nullptr);
-// Converts a device index (which are returned by |GetScreenList|) into an
+// Converts a device index (which are returned by `GetScreenList`) into an
// HMONITOR.
bool GetHmonitorFromDeviceIndex(const DesktopCapturer::SourceId device_index,
HMONITOR* hmonitor);
-// Returns true if |monitor| represents a valid display
+// Returns true if `monitor` represents a valid display
// monitor. Consumers should recheck the validity of HMONITORs before use if a
// WM_DISPLAYCHANGE message has been received.
bool IsMonitorValid(const HMONITOR monitor);
-// Returns the rect of the monitor identified by |monitor|, relative to the
+// Returns the rect of the monitor identified by `monitor`, relative to the
// primary display's top-left. On failure, returns an empty rect.
DesktopRect GetMonitorRect(const HMONITOR monitor);
-// Returns true if |screen| is a valid screen. The screen device key is
-// returned through |device_key| if the screen is valid. The device key can be
+// Returns true if `screen` is a valid screen. The screen device key is
+// returned through `device_key` if the screen is valid. The device key can be
// used in GetScreenRect to verify the screen matches the previously obtained
// id.
bool IsScreenValid(const DesktopCapturer::SourceId screen,
@@ -52,8 +52,8 @@
// primary monitor always starts from (0, 0).
DesktopRect GetFullscreenRect();
-// Get the rect of the screen identified by |screen|, relative to the primary
-// display's top-left. If the screen device key does not match |device_key|, or
+// Get the rect of the screen identified by `screen`, relative to the primary
+// display's top-left. If the screen device key does not match `device_key`, or
// the screen does not exist, or any error happens, an empty rect is returned.
RTC_EXPORT DesktopRect GetScreenRect(const DesktopCapturer::SourceId screen,
const std::wstring& device_key);
diff --git a/modules/desktop_capture/win/screen_capturer_win_directx.h b/modules/desktop_capture/win/screen_capturer_win_directx.h
index feeddff..378f9a7 100644
--- a/modules/desktop_capture/win/screen_capturer_win_directx.h
+++ b/modules/desktop_capture/win/screen_capturer_win_directx.h
@@ -52,18 +52,18 @@
// always try IsSupported() function.
static bool IsCurrentSessionSupported();
- // Maps |device_names| with the result from GetScreenList() and creates a new
- // SourceList to include only the ones in |device_names|. If this function
- // returns true, consumers can always assume |device_names|.size() equals to
- // |screens|->size(), meanwhile |device_names|[i] and |screens|[i] indicate
+ // Maps `device_names` with the result from GetScreenList() and creates a new
+ // SourceList to include only the ones in `device_names`. If this function
+ // returns true, consumers can always assume `device_names`.size() equals to
+ // `screens`->size(), meanwhile `device_names`[i] and `screens`[i] indicate
// the same monitor on the system.
// Public for test only.
static bool GetScreenListFromDeviceNames(
const std::vector<std::string>& device_names,
DesktopCapturer::SourceList* screens);
- // Maps |id| with the result from GetScreenListFromDeviceNames() and returns
- // the index of the entity in |device_names|. This function returns -1 if |id|
+ // Maps `id` with the result from GetScreenListFromDeviceNames() and returns
+ // the index of the entity in `device_names`. This function returns -1 if `id`
// cannot be found.
// Public for test only.
static int GetIndexFromScreenId(ScreenId id,
diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.h b/modules/desktop_capture/win/screen_capturer_win_magnifier.h
index 19202a7..29966e9 100644
--- a/modules/desktop_capture/win/screen_capturer_win_magnifier.h
+++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.h
@@ -80,7 +80,7 @@
RECT clipped,
HRGN dirty);
- // Captures the screen within |rect| in the desktop coordinates. Returns true
+ // Captures the screen within `rect` in the desktop coordinates. Returns true
// if succeeded.
// It can only capture the primary screen for now. The magnification library
// crashes under some screen configurations (e.g. secondary screen on top of
@@ -95,7 +95,7 @@
// Called by OnMagImageScalingCallback to output captured data.
void OnCaptured(void* data, const MAGIMAGEHEADER& header);
- // Makes sure the current frame exists and matches |size|.
+ // Makes sure the current frame exists and matches `size`.
void CreateCurrentFrameIfNecessary(const DesktopSize& size);
Callback* callback_ = nullptr;
diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc
index 48c5686..5caaaea 100644
--- a/modules/desktop_capture/win/wgc_capture_session.cc
+++ b/modules/desktop_capture/win/wgc_capture_session.cc
@@ -1,372 +1,372 @@
-/*
- * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/desktop_capture/win/wgc_capture_session.h"
-
-#include <windows.graphics.capture.interop.h>
-#include <windows.graphics.directX.direct3d11.interop.h>
-#include <wrl.h>
-
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "modules/desktop_capture/win/wgc_desktop_frame.h"
-#include "rtc_base/checks.h"
-#include "rtc_base/logging.h"
-#include "rtc_base/time_utils.h"
-#include "rtc_base/win/create_direct3d_device.h"
-#include "rtc_base/win/get_activation_factory.h"
-#include "system_wrappers/include/metrics.h"
-
-using Microsoft::WRL::ComPtr;
-namespace WGC = ABI::Windows::Graphics::Capture;
-
-namespace webrtc {
-namespace {
-
-// We must use a BGRA pixel format that has 4 bytes per pixel, as required by
-// the DesktopFrame interface.
-const auto kPixelFormat = ABI::Windows::Graphics::DirectX::DirectXPixelFormat::
- DirectXPixelFormat_B8G8R8A8UIntNormalized;
-
-// We only want 1 buffer in our frame pool to reduce latency. If we had more,
-// they would sit in the pool for longer and be stale by the time we are asked
-// for a new frame.
-const int kNumBuffers = 1;
-
-// These values are persisted to logs. Entries should not be renumbered and
-// numeric values should never be reused.
-enum class StartCaptureResult {
- kSuccess = 0,
- kSourceClosed = 1,
- kAddClosedFailed = 2,
- kDxgiDeviceCastFailed = 3,
- kD3dDelayLoadFailed = 4,
- kD3dDeviceCreationFailed = 5,
- kFramePoolActivationFailed = 6,
- kFramePoolCastFailed = 7,
- kGetItemSizeFailed = 8,
- kCreateFreeThreadedFailed = 9,
- kCreateCaptureSessionFailed = 10,
- kStartCaptureFailed = 11,
- kMaxValue = kStartCaptureFailed
-};
-
-// These values are persisted to logs. Entries should not be renumbered and
-// numeric values should never be reused.
-enum class GetFrameResult {
- kSuccess = 0,
- kItemClosed = 1,
- kTryGetNextFrameFailed = 2,
- kFrameDropped = 3,
- kGetSurfaceFailed = 4,
- kDxgiInterfaceAccessFailed = 5,
- kTexture2dCastFailed = 6,
- kCreateMappedTextureFailed = 7,
- kMapFrameFailed = 8,
- kGetContentSizeFailed = 9,
- kResizeMappedTextureFailed = 10,
- kRecreateFramePoolFailed = 11,
- kMaxValue = kRecreateFramePoolFailed
-};
-
-void RecordStartCaptureResult(StartCaptureResult error) {
- RTC_HISTOGRAM_ENUMERATION(
- "WebRTC.DesktopCapture.Win.WgcCaptureSessionStartResult",
- static_cast<int>(error), static_cast<int>(StartCaptureResult::kMaxValue));
-}
-
-void RecordGetFrameResult(GetFrameResult error) {
- RTC_HISTOGRAM_ENUMERATION(
- "WebRTC.DesktopCapture.Win.WgcCaptureSessionGetFrameResult",
- static_cast<int>(error), static_cast<int>(GetFrameResult::kMaxValue));
-}
-
-} // namespace
-
-WgcCaptureSession::WgcCaptureSession(ComPtr<ID3D11Device> d3d11_device,
- ComPtr<WGC::IGraphicsCaptureItem> item)
- : d3d11_device_(std::move(d3d11_device)), item_(std::move(item)) {}
-WgcCaptureSession::~WgcCaptureSession() = default;
-
-HRESULT WgcCaptureSession::StartCapture() {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
- RTC_DCHECK(!is_capture_started_);
-
- if (item_closed_) {
- RTC_LOG(LS_ERROR) << "The target source has been closed.";
- RecordStartCaptureResult(StartCaptureResult::kSourceClosed);
- return E_ABORT;
- }
-
- RTC_DCHECK(d3d11_device_);
- RTC_DCHECK(item_);
-
- // Listen for the Closed event, to detect if the source we are capturing is
- // closed (e.g. application window is closed or monitor is disconnected). If
- // it is, we should abort the capture.
- auto closed_handler =
- Microsoft::WRL::Callback<ABI::Windows::Foundation::ITypedEventHandler<
- WGC::GraphicsCaptureItem*, IInspectable*>>(
- this, &WgcCaptureSession::OnItemClosed);
- EventRegistrationToken item_closed_token;
- HRESULT hr = item_->add_Closed(closed_handler.Get(), &item_closed_token);
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kAddClosedFailed);
- return hr;
- }
-
- ComPtr<IDXGIDevice> dxgi_device;
- hr = d3d11_device_->QueryInterface(IID_PPV_ARGS(&dxgi_device));
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kDxgiDeviceCastFailed);
- return hr;
- }
-
- if (!ResolveCoreWinRTDirect3DDelayload()) {
- RecordStartCaptureResult(StartCaptureResult::kD3dDelayLoadFailed);
- return E_FAIL;
- }
-
- hr = CreateDirect3DDeviceFromDXGIDevice(dxgi_device.Get(), &direct3d_device_);
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kD3dDeviceCreationFailed);
- return hr;
- }
-
- ComPtr<WGC::IDirect3D11CaptureFramePoolStatics> frame_pool_statics;
- hr = GetActivationFactory<
- ABI::Windows::Graphics::Capture::IDirect3D11CaptureFramePoolStatics,
- RuntimeClass_Windows_Graphics_Capture_Direct3D11CaptureFramePool>(
- &frame_pool_statics);
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kFramePoolActivationFailed);
- return hr;
- }
-
- // Cast to FramePoolStatics2 so we can use CreateFreeThreaded and avoid the
- // need to have a DispatcherQueue. We don't listen for the FrameArrived event,
- // so there's no difference.
- ComPtr<WGC::IDirect3D11CaptureFramePoolStatics2> frame_pool_statics2;
- hr = frame_pool_statics->QueryInterface(IID_PPV_ARGS(&frame_pool_statics2));
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kFramePoolCastFailed);
- return hr;
- }
-
- ABI::Windows::Graphics::SizeInt32 item_size;
- hr = item_.Get()->get_Size(&item_size);
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kGetItemSizeFailed);
- return hr;
- }
-
- previous_size_ = item_size;
-
- hr = frame_pool_statics2->CreateFreeThreaded(direct3d_device_.Get(),
- kPixelFormat, kNumBuffers,
- item_size, &frame_pool_);
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kCreateFreeThreadedFailed);
- return hr;
- }
-
- hr = frame_pool_->CreateCaptureSession(item_.Get(), &session_);
- if (FAILED(hr)) {
- RecordStartCaptureResult(StartCaptureResult::kCreateCaptureSessionFailed);
- return hr;
- }
-
- hr = session_->StartCapture();
- if (FAILED(hr)) {
- RTC_LOG(LS_ERROR) << "Failed to start CaptureSession: " << hr;
- RecordStartCaptureResult(StartCaptureResult::kStartCaptureFailed);
- return hr;
- }
-
- RecordStartCaptureResult(StartCaptureResult::kSuccess);
-
- is_capture_started_ = true;
- return hr;
-}
-
-HRESULT WgcCaptureSession::GetFrame(
- std::unique_ptr<DesktopFrame>* output_frame) {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
-
- if (item_closed_) {
- RTC_LOG(LS_ERROR) << "The target source has been closed.";
- RecordGetFrameResult(GetFrameResult::kItemClosed);
- return E_ABORT;
- }
-
- RTC_DCHECK(is_capture_started_);
-
- ComPtr<WGC::IDirect3D11CaptureFrame> capture_frame;
- HRESULT hr = frame_pool_->TryGetNextFrame(&capture_frame);
- if (FAILED(hr)) {
- RTC_LOG(LS_ERROR) << "TryGetNextFrame failed: " << hr;
- RecordGetFrameResult(GetFrameResult::kTryGetNextFrameFailed);
- return hr;
- }
-
- if (!capture_frame) {
- RecordGetFrameResult(GetFrameResult::kFrameDropped);
- return hr;
- }
-
- // We need to get this CaptureFrame as an ID3D11Texture2D so that we can get
- // the raw image data in the format required by the DesktopFrame interface.
- ComPtr<ABI::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface>
- d3d_surface;
- hr = capture_frame->get_Surface(&d3d_surface);
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kGetSurfaceFailed);
- return hr;
- }
-
- ComPtr<Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess>
- direct3DDxgiInterfaceAccess;
- hr = d3d_surface->QueryInterface(IID_PPV_ARGS(&direct3DDxgiInterfaceAccess));
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kDxgiInterfaceAccessFailed);
- return hr;
- }
-
- ComPtr<ID3D11Texture2D> texture_2D;
- hr = direct3DDxgiInterfaceAccess->GetInterface(IID_PPV_ARGS(&texture_2D));
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kTexture2dCastFailed);
- return hr;
- }
-
- if (!mapped_texture_) {
- hr = CreateMappedTexture(texture_2D);
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kCreateMappedTextureFailed);
- return hr;
- }
- }
-
- // We need to copy |texture_2D| into |mapped_texture_| as the latter has the
- // D3D11_CPU_ACCESS_READ flag set, which lets us access the image data.
- // Otherwise it would only be readable by the GPU.
- ComPtr<ID3D11DeviceContext> d3d_context;
- d3d11_device_->GetImmediateContext(&d3d_context);
- d3d_context->CopyResource(mapped_texture_.Get(), texture_2D.Get());
-
- D3D11_MAPPED_SUBRESOURCE map_info;
- hr = d3d_context->Map(mapped_texture_.Get(), /*subresource_index=*/0,
- D3D11_MAP_READ, /*D3D11_MAP_FLAG_DO_NOT_WAIT=*/0,
- &map_info);
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kMapFrameFailed);
- return hr;
- }
-
- ABI::Windows::Graphics::SizeInt32 new_size;
- hr = capture_frame->get_ContentSize(&new_size);
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kGetContentSizeFailed);
- return hr;
- }
-
- // If the size has changed since the last capture, we must be sure to use
- // the smaller dimensions. Otherwise we might overrun our buffer, or
- // read stale data from the last frame.
- int image_height = std::min(previous_size_.Height, new_size.Height);
- int image_width = std::min(previous_size_.Width, new_size.Width);
- int row_data_length = image_width * DesktopFrame::kBytesPerPixel;
-
- // Make a copy of the data pointed to by |map_info.pData| so we are free to
- // unmap our texture.
- uint8_t* src_data = static_cast<uint8_t*>(map_info.pData);
- std::vector<uint8_t> image_data;
- image_data.reserve(image_height * row_data_length);
- uint8_t* image_data_ptr = image_data.data();
- for (int i = 0; i < image_height; i++) {
- memcpy(image_data_ptr, src_data, row_data_length);
- image_data_ptr += row_data_length;
- src_data += map_info.RowPitch;
- }
-
- // Transfer ownership of |image_data| to the output_frame.
- DesktopSize size(image_width, image_height);
- *output_frame = std::make_unique<WgcDesktopFrame>(size, row_data_length,
- std::move(image_data));
-
- d3d_context->Unmap(mapped_texture_.Get(), 0);
-
- // If the size changed, we must resize the texture and frame pool to fit the
- // new size.
- if (previous_size_.Height != new_size.Height ||
- previous_size_.Width != new_size.Width) {
- hr = CreateMappedTexture(texture_2D, new_size.Width, new_size.Height);
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kResizeMappedTextureFailed);
- return hr;
- }
-
- hr = frame_pool_->Recreate(direct3d_device_.Get(), kPixelFormat,
- kNumBuffers, new_size);
- if (FAILED(hr)) {
- RecordGetFrameResult(GetFrameResult::kRecreateFramePoolFailed);
- return hr;
- }
- }
-
- RecordGetFrameResult(GetFrameResult::kSuccess);
-
- previous_size_ = new_size;
- return hr;
-}
-
-HRESULT WgcCaptureSession::CreateMappedTexture(
- ComPtr<ID3D11Texture2D> src_texture,
- UINT width,
- UINT height) {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
-
- D3D11_TEXTURE2D_DESC src_desc;
- src_texture->GetDesc(&src_desc);
- D3D11_TEXTURE2D_DESC map_desc;
- map_desc.Width = width == 0 ? src_desc.Width : width;
- map_desc.Height = height == 0 ? src_desc.Height : height;
- map_desc.MipLevels = src_desc.MipLevels;
- map_desc.ArraySize = src_desc.ArraySize;
- map_desc.Format = src_desc.Format;
- map_desc.SampleDesc = src_desc.SampleDesc;
- map_desc.Usage = D3D11_USAGE_STAGING;
- map_desc.BindFlags = 0;
- map_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
- map_desc.MiscFlags = 0;
- return d3d11_device_->CreateTexture2D(&map_desc, nullptr, &mapped_texture_);
-}
-
-HRESULT WgcCaptureSession::OnItemClosed(WGC::IGraphicsCaptureItem* sender,
- IInspectable* event_args) {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
-
- RTC_LOG(LS_INFO) << "Capture target has been closed.";
- item_closed_ = true;
- is_capture_started_ = false;
-
- mapped_texture_ = nullptr;
- session_ = nullptr;
- frame_pool_ = nullptr;
- direct3d_device_ = nullptr;
- item_ = nullptr;
- d3d11_device_ = nullptr;
-
- return S_OK;
-}
-
-} // namespace webrtc
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "modules/desktop_capture/win/wgc_capture_session.h"
+
+#include <windows.graphics.capture.interop.h>
+#include <windows.graphics.directX.direct3d11.interop.h>
+#include <wrl.h>
+
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "modules/desktop_capture/win/wgc_desktop_frame.h"
+#include "rtc_base/checks.h"
+#include "rtc_base/logging.h"
+#include "rtc_base/time_utils.h"
+#include "rtc_base/win/create_direct3d_device.h"
+#include "rtc_base/win/get_activation_factory.h"
+#include "system_wrappers/include/metrics.h"
+
+using Microsoft::WRL::ComPtr;
+namespace WGC = ABI::Windows::Graphics::Capture;
+
+namespace webrtc {
+namespace {
+
+// We must use a BGRA pixel format that has 4 bytes per pixel, as required by
+// the DesktopFrame interface.
+const auto kPixelFormat = ABI::Windows::Graphics::DirectX::DirectXPixelFormat::
+ DirectXPixelFormat_B8G8R8A8UIntNormalized;
+
+// We only want 1 buffer in our frame pool to reduce latency. If we had more,
+// they would sit in the pool for longer and be stale by the time we are asked
+// for a new frame.
+const int kNumBuffers = 1;
+
+// These values are persisted to logs. Entries should not be renumbered and
+// numeric values should never be reused.
+enum class StartCaptureResult {
+ kSuccess = 0,
+ kSourceClosed = 1,
+ kAddClosedFailed = 2,
+ kDxgiDeviceCastFailed = 3,
+ kD3dDelayLoadFailed = 4,
+ kD3dDeviceCreationFailed = 5,
+ kFramePoolActivationFailed = 6,
+ kFramePoolCastFailed = 7,
+ kGetItemSizeFailed = 8,
+ kCreateFreeThreadedFailed = 9,
+ kCreateCaptureSessionFailed = 10,
+ kStartCaptureFailed = 11,
+ kMaxValue = kStartCaptureFailed
+};
+
+// These values are persisted to logs. Entries should not be renumbered and
+// numeric values should never be reused.
+enum class GetFrameResult {
+ kSuccess = 0,
+ kItemClosed = 1,
+ kTryGetNextFrameFailed = 2,
+ kFrameDropped = 3,
+ kGetSurfaceFailed = 4,
+ kDxgiInterfaceAccessFailed = 5,
+ kTexture2dCastFailed = 6,
+ kCreateMappedTextureFailed = 7,
+ kMapFrameFailed = 8,
+ kGetContentSizeFailed = 9,
+ kResizeMappedTextureFailed = 10,
+ kRecreateFramePoolFailed = 11,
+ kMaxValue = kRecreateFramePoolFailed
+};
+
+void RecordStartCaptureResult(StartCaptureResult error) {
+ RTC_HISTOGRAM_ENUMERATION(
+ "WebRTC.DesktopCapture.Win.WgcCaptureSessionStartResult",
+ static_cast<int>(error), static_cast<int>(StartCaptureResult::kMaxValue));
+}
+
+void RecordGetFrameResult(GetFrameResult error) {
+ RTC_HISTOGRAM_ENUMERATION(
+ "WebRTC.DesktopCapture.Win.WgcCaptureSessionGetFrameResult",
+ static_cast<int>(error), static_cast<int>(GetFrameResult::kMaxValue));
+}
+
+} // namespace
+
+WgcCaptureSession::WgcCaptureSession(ComPtr<ID3D11Device> d3d11_device,
+ ComPtr<WGC::IGraphicsCaptureItem> item)
+ : d3d11_device_(std::move(d3d11_device)), item_(std::move(item)) {}
+WgcCaptureSession::~WgcCaptureSession() = default;
+
+HRESULT WgcCaptureSession::StartCapture() {
+ RTC_DCHECK_RUN_ON(&sequence_checker_);
+ RTC_DCHECK(!is_capture_started_);
+
+ if (item_closed_) {
+ RTC_LOG(LS_ERROR) << "The target source has been closed.";
+ RecordStartCaptureResult(StartCaptureResult::kSourceClosed);
+ return E_ABORT;
+ }
+
+ RTC_DCHECK(d3d11_device_);
+ RTC_DCHECK(item_);
+
+ // Listen for the Closed event, to detect if the source we are capturing is
+ // closed (e.g. application window is closed or monitor is disconnected). If
+ // it is, we should abort the capture.
+ auto closed_handler =
+ Microsoft::WRL::Callback<ABI::Windows::Foundation::ITypedEventHandler<
+ WGC::GraphicsCaptureItem*, IInspectable*>>(
+ this, &WgcCaptureSession::OnItemClosed);
+ EventRegistrationToken item_closed_token;
+ HRESULT hr = item_->add_Closed(closed_handler.Get(), &item_closed_token);
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kAddClosedFailed);
+ return hr;
+ }
+
+ ComPtr<IDXGIDevice> dxgi_device;
+ hr = d3d11_device_->QueryInterface(IID_PPV_ARGS(&dxgi_device));
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kDxgiDeviceCastFailed);
+ return hr;
+ }
+
+ if (!ResolveCoreWinRTDirect3DDelayload()) {
+ RecordStartCaptureResult(StartCaptureResult::kD3dDelayLoadFailed);
+ return E_FAIL;
+ }
+
+ hr = CreateDirect3DDeviceFromDXGIDevice(dxgi_device.Get(), &direct3d_device_);
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kD3dDeviceCreationFailed);
+ return hr;
+ }
+
+ ComPtr<WGC::IDirect3D11CaptureFramePoolStatics> frame_pool_statics;
+ hr = GetActivationFactory<
+ ABI::Windows::Graphics::Capture::IDirect3D11CaptureFramePoolStatics,
+ RuntimeClass_Windows_Graphics_Capture_Direct3D11CaptureFramePool>(
+ &frame_pool_statics);
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kFramePoolActivationFailed);
+ return hr;
+ }
+
+ // Cast to FramePoolStatics2 so we can use CreateFreeThreaded and avoid the
+ // need to have a DispatcherQueue. We don't listen for the FrameArrived event,
+ // so there's no difference.
+ ComPtr<WGC::IDirect3D11CaptureFramePoolStatics2> frame_pool_statics2;
+ hr = frame_pool_statics->QueryInterface(IID_PPV_ARGS(&frame_pool_statics2));
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kFramePoolCastFailed);
+ return hr;
+ }
+
+ ABI::Windows::Graphics::SizeInt32 item_size;
+ hr = item_.Get()->get_Size(&item_size);
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kGetItemSizeFailed);
+ return hr;
+ }
+
+ previous_size_ = item_size;
+
+ hr = frame_pool_statics2->CreateFreeThreaded(direct3d_device_.Get(),
+ kPixelFormat, kNumBuffers,
+ item_size, &frame_pool_);
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kCreateFreeThreadedFailed);
+ return hr;
+ }
+
+ hr = frame_pool_->CreateCaptureSession(item_.Get(), &session_);
+ if (FAILED(hr)) {
+ RecordStartCaptureResult(StartCaptureResult::kCreateCaptureSessionFailed);
+ return hr;
+ }
+
+ hr = session_->StartCapture();
+ if (FAILED(hr)) {
+ RTC_LOG(LS_ERROR) << "Failed to start CaptureSession: " << hr;
+ RecordStartCaptureResult(StartCaptureResult::kStartCaptureFailed);
+ return hr;
+ }
+
+ RecordStartCaptureResult(StartCaptureResult::kSuccess);
+
+ is_capture_started_ = true;
+ return hr;
+}
+
+HRESULT WgcCaptureSession::GetFrame(
+ std::unique_ptr<DesktopFrame>* output_frame) {
+ RTC_DCHECK_RUN_ON(&sequence_checker_);
+
+ if (item_closed_) {
+ RTC_LOG(LS_ERROR) << "The target source has been closed.";
+ RecordGetFrameResult(GetFrameResult::kItemClosed);
+ return E_ABORT;
+ }
+
+ RTC_DCHECK(is_capture_started_);
+
+ ComPtr<WGC::IDirect3D11CaptureFrame> capture_frame;
+ HRESULT hr = frame_pool_->TryGetNextFrame(&capture_frame);
+ if (FAILED(hr)) {
+ RTC_LOG(LS_ERROR) << "TryGetNextFrame failed: " << hr;
+ RecordGetFrameResult(GetFrameResult::kTryGetNextFrameFailed);
+ return hr;
+ }
+
+ if (!capture_frame) {
+ RecordGetFrameResult(GetFrameResult::kFrameDropped);
+ return hr;
+ }
+
+ // We need to get this CaptureFrame as an ID3D11Texture2D so that we can get
+ // the raw image data in the format required by the DesktopFrame interface.
+ ComPtr<ABI::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface>
+ d3d_surface;
+ hr = capture_frame->get_Surface(&d3d_surface);
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kGetSurfaceFailed);
+ return hr;
+ }
+
+ ComPtr<Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess>
+ direct3DDxgiInterfaceAccess;
+ hr = d3d_surface->QueryInterface(IID_PPV_ARGS(&direct3DDxgiInterfaceAccess));
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kDxgiInterfaceAccessFailed);
+ return hr;
+ }
+
+ ComPtr<ID3D11Texture2D> texture_2D;
+ hr = direct3DDxgiInterfaceAccess->GetInterface(IID_PPV_ARGS(&texture_2D));
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kTexture2dCastFailed);
+ return hr;
+ }
+
+ if (!mapped_texture_) {
+ hr = CreateMappedTexture(texture_2D);
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kCreateMappedTextureFailed);
+ return hr;
+ }
+ }
+
+ // We need to copy `texture_2D` into `mapped_texture_` as the latter has the
+ // D3D11_CPU_ACCESS_READ flag set, which lets us access the image data.
+ // Otherwise it would only be readable by the GPU.
+ ComPtr<ID3D11DeviceContext> d3d_context;
+ d3d11_device_->GetImmediateContext(&d3d_context);
+ d3d_context->CopyResource(mapped_texture_.Get(), texture_2D.Get());
+
+ D3D11_MAPPED_SUBRESOURCE map_info;
+ hr = d3d_context->Map(mapped_texture_.Get(), /*subresource_index=*/0,
+ D3D11_MAP_READ, /*D3D11_MAP_FLAG_DO_NOT_WAIT=*/0,
+ &map_info);
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kMapFrameFailed);
+ return hr;
+ }
+
+ ABI::Windows::Graphics::SizeInt32 new_size;
+ hr = capture_frame->get_ContentSize(&new_size);
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kGetContentSizeFailed);
+ return hr;
+ }
+
+ // If the size has changed since the last capture, we must be sure to use
+ // the smaller dimensions. Otherwise we might overrun our buffer, or
+ // read stale data from the last frame.
+ int image_height = std::min(previous_size_.Height, new_size.Height);
+ int image_width = std::min(previous_size_.Width, new_size.Width);
+ int row_data_length = image_width * DesktopFrame::kBytesPerPixel;
+
+ // Make a copy of the data pointed to by |map_info.pData| so we are free to
+ // unmap our texture.
+ uint8_t* src_data = static_cast<uint8_t*>(map_info.pData);
+ std::vector<uint8_t> image_data;
+ image_data.reserve(image_height * row_data_length);
+ uint8_t* image_data_ptr = image_data.data();
+ for (int i = 0; i < image_height; i++) {
+ memcpy(image_data_ptr, src_data, row_data_length);
+ image_data_ptr += row_data_length;
+ src_data += map_info.RowPitch;
+ }
+
+ // Transfer ownership of `image_data` to the output_frame.
+ DesktopSize size(image_width, image_height);
+ *output_frame = std::make_unique<WgcDesktopFrame>(size, row_data_length,
+ std::move(image_data));
+
+ d3d_context->Unmap(mapped_texture_.Get(), 0);
+
+ // If the size changed, we must resize the texture and frame pool to fit the
+ // new size.
+ if (previous_size_.Height != new_size.Height ||
+ previous_size_.Width != new_size.Width) {
+ hr = CreateMappedTexture(texture_2D, new_size.Width, new_size.Height);
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kResizeMappedTextureFailed);
+ return hr;
+ }
+
+ hr = frame_pool_->Recreate(direct3d_device_.Get(), kPixelFormat,
+ kNumBuffers, new_size);
+ if (FAILED(hr)) {
+ RecordGetFrameResult(GetFrameResult::kRecreateFramePoolFailed);
+ return hr;
+ }
+ }
+
+ RecordGetFrameResult(GetFrameResult::kSuccess);
+
+ previous_size_ = new_size;
+ return hr;
+}
+
+HRESULT WgcCaptureSession::CreateMappedTexture(
+ ComPtr<ID3D11Texture2D> src_texture,
+ UINT width,
+ UINT height) {
+ RTC_DCHECK_RUN_ON(&sequence_checker_);
+
+ D3D11_TEXTURE2D_DESC src_desc;
+ src_texture->GetDesc(&src_desc);
+ D3D11_TEXTURE2D_DESC map_desc;
+ map_desc.Width = width == 0 ? src_desc.Width : width;
+ map_desc.Height = height == 0 ? src_desc.Height : height;
+ map_desc.MipLevels = src_desc.MipLevels;
+ map_desc.ArraySize = src_desc.ArraySize;
+ map_desc.Format = src_desc.Format;
+ map_desc.SampleDesc = src_desc.SampleDesc;
+ map_desc.Usage = D3D11_USAGE_STAGING;
+ map_desc.BindFlags = 0;
+ map_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
+ map_desc.MiscFlags = 0;
+ return d3d11_device_->CreateTexture2D(&map_desc, nullptr, &mapped_texture_);
+}
+
+HRESULT WgcCaptureSession::OnItemClosed(WGC::IGraphicsCaptureItem* sender,
+ IInspectable* event_args) {
+ RTC_DCHECK_RUN_ON(&sequence_checker_);
+
+ RTC_LOG(LS_INFO) << "Capture target has been closed.";
+ item_closed_ = true;
+ is_capture_started_ = false;
+
+ mapped_texture_ = nullptr;
+ session_ = nullptr;
+ frame_pool_ = nullptr;
+ direct3d_device_ = nullptr;
+ item_ = nullptr;
+ d3d11_device_ = nullptr;
+
+ return S_OK;
+}
+
+} // namespace webrtc
diff --git a/modules/desktop_capture/win/wgc_capture_session.h b/modules/desktop_capture/win/wgc_capture_session.h
index 9f08b7c..e1456b2 100644
--- a/modules/desktop_capture/win/wgc_capture_session.h
+++ b/modules/desktop_capture/win/wgc_capture_session.h
@@ -1,110 +1,110 @@
-/*
- * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURE_SESSION_H_
-#define MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURE_SESSION_H_
-
-#include <d3d11.h>
-#include <windows.graphics.capture.h>
-#include <wrl/client.h>
-
-#include <memory>
-
-#include "api/sequence_checker.h"
-#include "modules/desktop_capture/desktop_capture_options.h"
-#include "modules/desktop_capture/win/wgc_capture_source.h"
-
-namespace webrtc {
-
-class WgcCaptureSession final {
- public:
- WgcCaptureSession(
- Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
- Microsoft::WRL::ComPtr<
- ABI::Windows::Graphics::Capture::IGraphicsCaptureItem> item);
-
- // Disallow copy and assign.
- WgcCaptureSession(const WgcCaptureSession&) = delete;
- WgcCaptureSession& operator=(const WgcCaptureSession&) = delete;
-
- ~WgcCaptureSession();
-
- HRESULT StartCapture();
-
- // Returns a frame from the frame pool, if any are present.
- HRESULT GetFrame(std::unique_ptr<DesktopFrame>* output_frame);
-
- bool IsCaptureStarted() const {
- RTC_DCHECK_RUN_ON(&sequence_checker_);
- return is_capture_started_;
- }
-
- private:
- // Initializes |mapped_texture_| with the properties of the |src_texture|,
- // overrides the values of some necessary properties like the
- // D3D11_CPU_ACCESS_READ flag. Also has optional parameters for what size
- // |mapped_texture_| should be, if they aren't provided we will use the size
- // of |src_texture|.
- HRESULT CreateMappedTexture(
- Microsoft::WRL::ComPtr<ID3D11Texture2D> src_texture,
- UINT width = 0,
- UINT height = 0);
-
- // Event handler for |item_|'s Closed event.
- HRESULT OnItemClosed(
- ABI::Windows::Graphics::Capture::IGraphicsCaptureItem* sender,
- IInspectable* event_args);
-
- // A Direct3D11 Device provided by the caller. We use this to create an
- // IDirect3DDevice, and also to create textures that will hold the image data.
- Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
-
- // This item represents what we are capturing, we use it to create the
- // capture session, and also to listen for the Closed event.
- Microsoft::WRL::ComPtr<ABI::Windows::Graphics::Capture::IGraphicsCaptureItem>
- item_;
-
- // The IDirect3DDevice is necessary to instantiate the frame pool.
- Microsoft::WRL::ComPtr<
- ABI::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice>
- direct3d_device_;
-
- // The frame pool is where frames are deposited during capture, we retrieve
- // them from here with TryGetNextFrame().
- Microsoft::WRL::ComPtr<
- ABI::Windows::Graphics::Capture::IDirect3D11CaptureFramePool>
- frame_pool_;
-
- // This texture holds the final image data. We made it a member so we can
- // reuse it, instead of having to create a new texture every time we grab a
- // frame.
- Microsoft::WRL::ComPtr<ID3D11Texture2D> mapped_texture_;
-
- // This lets us know when the source has been resized, which is important
- // because we must resize the framepool and our texture to be able to hold
- // enough data for the frame.
- ABI::Windows::Graphics::SizeInt32 previous_size_;
-
- // The capture session lets us set properties about the capture before it
- // starts such as whether to capture the mouse cursor, and it lets us tell WGC
- // to start capturing frames.
- Microsoft::WRL::ComPtr<
- ABI::Windows::Graphics::Capture::IGraphicsCaptureSession>
- session_;
-
- bool item_closed_ = false;
- bool is_capture_started_ = false;
-
- SequenceChecker sequence_checker_;
-};
-
-} // namespace webrtc
-
-#endif // MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURE_SESSION_H_
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURE_SESSION_H_
+#define MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURE_SESSION_H_
+
+#include <d3d11.h>
+#include <windows.graphics.capture.h>
+#include <wrl/client.h>
+
+#include <memory>
+
+#include "api/sequence_checker.h"
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/win/wgc_capture_source.h"
+
+namespace webrtc {
+
+class WgcCaptureSession final {
+ public:
+ WgcCaptureSession(
+ Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
+ Microsoft::WRL::ComPtr<
+ ABI::Windows::Graphics::Capture::IGraphicsCaptureItem> item);
+
+ // Disallow copy and assign.
+ WgcCaptureSession(const WgcCaptureSession&) = delete;
+ WgcCaptureSession& operator=(const WgcCaptureSession&) = delete;
+
+ ~WgcCaptureSession();
+
+ HRESULT StartCapture();
+
+ // Returns a frame from the frame pool, if any are present.
+ HRESULT GetFrame(std::unique_ptr<DesktopFrame>* output_frame);
+
+ bool IsCaptureStarted() const {
+ RTC_DCHECK_RUN_ON(&sequence_checker_);
+ return is_capture_started_;
+ }
+
+ private:
+ // Initializes `mapped_texture_` with the properties of the `src_texture`,
+ // overrides the values of some necessary properties like the
+ // D3D11_CPU_ACCESS_READ flag. Also has optional parameters for what size
+ // `mapped_texture_` should be, if they aren't provided we will use the size
+ // of `src_texture`.
+ HRESULT CreateMappedTexture(
+ Microsoft::WRL::ComPtr<ID3D11Texture2D> src_texture,
+ UINT width = 0,
+ UINT height = 0);
+
+ // Event handler for `item_`'s Closed event.
+ HRESULT OnItemClosed(
+ ABI::Windows::Graphics::Capture::IGraphicsCaptureItem* sender,
+ IInspectable* event_args);
+
+ // A Direct3D11 Device provided by the caller. We use this to create an
+ // IDirect3DDevice, and also to create textures that will hold the image data.
+ Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
+
+ // This item represents what we are capturing, we use it to create the
+ // capture session, and also to listen for the Closed event.
+ Microsoft::WRL::ComPtr<ABI::Windows::Graphics::Capture::IGraphicsCaptureItem>
+ item_;
+
+ // The IDirect3DDevice is necessary to instantiate the frame pool.
+ Microsoft::WRL::ComPtr<
+ ABI::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice>
+ direct3d_device_;
+
+ // The frame pool is where frames are deposited during capture, we retrieve
+ // them from here with TryGetNextFrame().
+ Microsoft::WRL::ComPtr<
+ ABI::Windows::Graphics::Capture::IDirect3D11CaptureFramePool>
+ frame_pool_;
+
+ // This texture holds the final image data. We made it a member so we can
+ // reuse it, instead of having to create a new texture every time we grab a
+ // frame.
+ Microsoft::WRL::ComPtr<ID3D11Texture2D> mapped_texture_;
+
+ // This lets us know when the source has been resized, which is important
+ // because we must resize the framepool and our texture to be able to hold
+ // enough data for the frame.
+ ABI::Windows::Graphics::SizeInt32 previous_size_;
+
+ // The capture session lets us set properties about the capture before it
+ // starts such as whether to capture the mouse cursor, and it lets us tell WGC
+ // to start capturing frames.
+ Microsoft::WRL::ComPtr<
+ ABI::Windows::Graphics::Capture::IGraphicsCaptureSession>
+ session_;
+
+ bool item_closed_ = false;
+ bool is_capture_started_ = false;
+
+ SequenceChecker sequence_checker_;
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURE_SESSION_H_
diff --git a/modules/desktop_capture/win/wgc_capture_source.cc b/modules/desktop_capture/win/wgc_capture_source.cc
index 9786ca6..c81cfcb 100644
--- a/modules/desktop_capture/win/wgc_capture_source.cc
+++ b/modules/desktop_capture/win/wgc_capture_source.cc
@@ -123,7 +123,7 @@
WgcScreenSource::WgcScreenSource(DesktopCapturer::SourceId source_id)
: WgcCaptureSource(source_id) {
// Getting the HMONITOR could fail if the source_id is invalid. In that case,
- // we leave hmonitor_ uninitialized and |IsCapturable()| will fail.
+ // we leave hmonitor_ uninitialized and `IsCapturable()` will fail.
HMONITOR hmon;
if (GetHmonitorFromDeviceIndex(GetSourceId(), &hmon))
hmonitor_ = hmon;
diff --git a/modules/desktop_capture/win/wgc_capture_source.h b/modules/desktop_capture/win/wgc_capture_source.h
index 135f92b..44090ec 100644
--- a/modules/desktop_capture/win/wgc_capture_source.h
+++ b/modules/desktop_capture/win/wgc_capture_source.h
@@ -128,7 +128,7 @@
// To maintain compatibility with other capturers, this class accepts a
// device index as it's SourceId. However, WGC requires we use an HMONITOR to
// describe which screen to capture. So, we internally convert the supplied
- // device index into an HMONITOR when |IsCapturable()| is called.
+ // device index into an HMONITOR when `IsCapturable()` is called.
absl::optional<HMONITOR> hmonitor_;
};
diff --git a/modules/desktop_capture/win/wgc_capturer_win.cc b/modules/desktop_capture/win/wgc_capturer_win.cc
index 442c827a..9b2cce4 100644
--- a/modules/desktop_capture/win/wgc_capturer_win.cc
+++ b/modules/desktop_capture/win/wgc_capturer_win.cc
@@ -1,218 +1,218 @@
-/*
- * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/desktop_capture/win/wgc_capturer_win.h"
-
-#include <utility>
-
-#include "modules/desktop_capture/desktop_capture_metrics_helper.h"
-#include "modules/desktop_capture/desktop_capture_types.h"
-#include "modules/desktop_capture/win/wgc_desktop_frame.h"
-#include "rtc_base/logging.h"
-#include "rtc_base/time_utils.h"
-#include "system_wrappers/include/metrics.h"
-
-namespace WGC = ABI::Windows::Graphics::Capture;
-using Microsoft::WRL::ComPtr;
-
-namespace webrtc {
-
-namespace {
-
-enum class WgcCapturerResult {
- kSuccess = 0,
- kNoDirect3dDevice = 1,
- kNoSourceSelected = 2,
- kItemCreationFailure = 3,
- kSessionStartFailure = 4,
- kGetFrameFailure = 5,
- kFrameDropped = 6,
- kMaxValue = kFrameDropped
-};
-
-void RecordWgcCapturerResult(WgcCapturerResult error) {
- RTC_HISTOGRAM_ENUMERATION("WebRTC.DesktopCapture.Win.WgcCapturerResult",
- static_cast<int>(error),
- static_cast<int>(WgcCapturerResult::kMaxValue));
-}
-
-} // namespace
-
-WgcCapturerWin::WgcCapturerWin(
- std::unique_ptr<WgcCaptureSourceFactory> source_factory,
- std::unique_ptr<SourceEnumerator> source_enumerator)
- : source_factory_(std::move(source_factory)),
- source_enumerator_(std::move(source_enumerator)) {}
-WgcCapturerWin::~WgcCapturerWin() = default;
-
-// static
-std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawWindowCapturer(
- const DesktopCaptureOptions& options) {
- return std::make_unique<WgcCapturerWin>(
- std::make_unique<WgcWindowSourceFactory>(),
- std::make_unique<WindowEnumerator>(
- options.enumerate_current_process_windows()));
-}
-
-// static
-std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawScreenCapturer(
- const DesktopCaptureOptions& options) {
- return std::make_unique<WgcCapturerWin>(
- std::make_unique<WgcScreenSourceFactory>(),
- std::make_unique<ScreenEnumerator>());
-}
-
-bool WgcCapturerWin::GetSourceList(SourceList* sources) {
- return source_enumerator_->FindAllSources(sources);
-}
-
-bool WgcCapturerWin::SelectSource(DesktopCapturer::SourceId id) {
- capture_source_ = source_factory_->CreateCaptureSource(id);
- return capture_source_->IsCapturable();
-}
-
-bool WgcCapturerWin::FocusOnSelectedSource() {
- if (!capture_source_)
- return false;
-
- return capture_source_->FocusOnSource();
-}
-
-void WgcCapturerWin::Start(Callback* callback) {
- RTC_DCHECK(!callback_);
- RTC_DCHECK(callback);
- RecordCapturerImpl(DesktopCapturerId::kWgcCapturerWin);
-
- callback_ = callback;
-
- // Create a Direct3D11 device to share amongst the WgcCaptureSessions. Many
- // parameters are nullptr as the implemention uses defaults that work well for
- // us.
- HRESULT hr = D3D11CreateDevice(
- /*adapter=*/nullptr, D3D_DRIVER_TYPE_HARDWARE,
- /*software_rasterizer=*/nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT,
- /*feature_levels=*/nullptr, /*feature_levels_size=*/0, D3D11_SDK_VERSION,
- &d3d11_device_, /*feature_level=*/nullptr, /*device_context=*/nullptr);
- if (hr == DXGI_ERROR_UNSUPPORTED) {
- // If a hardware device could not be created, use WARP which is a high speed
- // software device.
- hr = D3D11CreateDevice(
- /*adapter=*/nullptr, D3D_DRIVER_TYPE_WARP,
- /*software_rasterizer=*/nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT,
- /*feature_levels=*/nullptr, /*feature_levels_size=*/0,
- D3D11_SDK_VERSION, &d3d11_device_, /*feature_level=*/nullptr,
- /*device_context=*/nullptr);
- }
-
- if (FAILED(hr)) {
- RTC_LOG(LS_ERROR) << "Failed to create D3D11Device: " << hr;
- }
-}
-
-void WgcCapturerWin::CaptureFrame() {
- RTC_DCHECK(callback_);
-
- if (!capture_source_) {
- RTC_LOG(LS_ERROR) << "Source hasn't been selected";
- callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
- /*frame=*/nullptr);
- RecordWgcCapturerResult(WgcCapturerResult::kNoSourceSelected);
- return;
- }
-
- if (!d3d11_device_) {
- RTC_LOG(LS_ERROR) << "No D3D11D3evice, cannot capture.";
- callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
- /*frame=*/nullptr);
- RecordWgcCapturerResult(WgcCapturerResult::kNoDirect3dDevice);
- return;
- }
-
- int64_t capture_start_time_nanos = rtc::TimeNanos();
-
- HRESULT hr;
- WgcCaptureSession* capture_session = nullptr;
- std::map<SourceId, WgcCaptureSession>::iterator session_iter =
- ongoing_captures_.find(capture_source_->GetSourceId());
- if (session_iter == ongoing_captures_.end()) {
- ComPtr<WGC::IGraphicsCaptureItem> item;
- hr = capture_source_->GetCaptureItem(&item);
- if (FAILED(hr)) {
- RTC_LOG(LS_ERROR) << "Failed to create a GraphicsCaptureItem: " << hr;
- callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
- /*frame=*/nullptr);
- RecordWgcCapturerResult(WgcCapturerResult::kItemCreationFailure);
- return;
- }
-
- std::pair<std::map<SourceId, WgcCaptureSession>::iterator, bool>
- iter_success_pair = ongoing_captures_.emplace(
- std::piecewise_construct,
- std::forward_as_tuple(capture_source_->GetSourceId()),
- std::forward_as_tuple(d3d11_device_, item));
- RTC_DCHECK(iter_success_pair.second);
- capture_session = &iter_success_pair.first->second;
- } else {
- capture_session = &session_iter->second;
- }
-
- if (!capture_session->IsCaptureStarted()) {
- hr = capture_session->StartCapture();
- if (FAILED(hr)) {
- RTC_LOG(LS_ERROR) << "Failed to start capture: " << hr;
- ongoing_captures_.erase(capture_source_->GetSourceId());
- callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
- /*frame=*/nullptr);
- RecordWgcCapturerResult(WgcCapturerResult::kSessionStartFailure);
- return;
- }
- }
-
- std::unique_ptr<DesktopFrame> frame;
- hr = capture_session->GetFrame(&frame);
- if (FAILED(hr)) {
- RTC_LOG(LS_ERROR) << "GetFrame failed: " << hr;
- ongoing_captures_.erase(capture_source_->GetSourceId());
- callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
- /*frame=*/nullptr);
- RecordWgcCapturerResult(WgcCapturerResult::kGetFrameFailure);
- return;
- }
-
- if (!frame) {
- callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_TEMPORARY,
- /*frame=*/nullptr);
- RecordWgcCapturerResult(WgcCapturerResult::kFrameDropped);
- return;
- }
-
- int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) /
- rtc::kNumNanosecsPerMillisec;
- RTC_HISTOGRAM_COUNTS_1000("WebRTC.DesktopCapture.Win.WgcCapturerFrameTime",
- capture_time_ms);
- frame->set_capture_time_ms(capture_time_ms);
- frame->set_capturer_id(DesktopCapturerId::kWgcCapturerWin);
- frame->set_may_contain_cursor(true);
- frame->set_top_left(capture_source_->GetTopLeft());
- RecordWgcCapturerResult(WgcCapturerResult::kSuccess);
- callback_->OnCaptureResult(DesktopCapturer::Result::SUCCESS,
- std::move(frame));
-}
-
-bool WgcCapturerWin::IsSourceBeingCaptured(DesktopCapturer::SourceId id) {
- std::map<DesktopCapturer::SourceId, WgcCaptureSession>::iterator
- session_iter = ongoing_captures_.find(id);
- if (session_iter == ongoing_captures_.end())
- return false;
-
- return session_iter->second.IsCaptureStarted();
-}
-
-} // namespace webrtc
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "modules/desktop_capture/win/wgc_capturer_win.h"
+
+#include <utility>
+
+#include "modules/desktop_capture/desktop_capture_metrics_helper.h"
+#include "modules/desktop_capture/desktop_capture_types.h"
+#include "modules/desktop_capture/win/wgc_desktop_frame.h"
+#include "rtc_base/logging.h"
+#include "rtc_base/time_utils.h"
+#include "system_wrappers/include/metrics.h"
+
+namespace WGC = ABI::Windows::Graphics::Capture;
+using Microsoft::WRL::ComPtr;
+
+namespace webrtc {
+
+namespace {
+
+enum class WgcCapturerResult {
+ kSuccess = 0,
+ kNoDirect3dDevice = 1,
+ kNoSourceSelected = 2,
+ kItemCreationFailure = 3,
+ kSessionStartFailure = 4,
+ kGetFrameFailure = 5,
+ kFrameDropped = 6,
+ kMaxValue = kFrameDropped
+};
+
+void RecordWgcCapturerResult(WgcCapturerResult error) {
+ RTC_HISTOGRAM_ENUMERATION("WebRTC.DesktopCapture.Win.WgcCapturerResult",
+ static_cast<int>(error),
+ static_cast<int>(WgcCapturerResult::kMaxValue));
+}
+
+} // namespace
+
+WgcCapturerWin::WgcCapturerWin(
+ std::unique_ptr<WgcCaptureSourceFactory> source_factory,
+ std::unique_ptr<SourceEnumerator> source_enumerator)
+ : source_factory_(std::move(source_factory)),
+ source_enumerator_(std::move(source_enumerator)) {}
+WgcCapturerWin::~WgcCapturerWin() = default;
+
+// static
+std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options) {
+ return std::make_unique<WgcCapturerWin>(
+ std::make_unique<WgcWindowSourceFactory>(),
+ std::make_unique<WindowEnumerator>(
+ options.enumerate_current_process_windows()));
+}
+
+// static
+std::unique_ptr<DesktopCapturer> WgcCapturerWin::CreateRawScreenCapturer(
+ const DesktopCaptureOptions& options) {
+ return std::make_unique<WgcCapturerWin>(
+ std::make_unique<WgcScreenSourceFactory>(),
+ std::make_unique<ScreenEnumerator>());
+}
+
+bool WgcCapturerWin::GetSourceList(SourceList* sources) {
+ return source_enumerator_->FindAllSources(sources);
+}
+
+bool WgcCapturerWin::SelectSource(DesktopCapturer::SourceId id) {
+ capture_source_ = source_factory_->CreateCaptureSource(id);
+ return capture_source_->IsCapturable();
+}
+
+bool WgcCapturerWin::FocusOnSelectedSource() {
+ if (!capture_source_)
+ return false;
+
+ return capture_source_->FocusOnSource();
+}
+
+void WgcCapturerWin::Start(Callback* callback) {
+ RTC_DCHECK(!callback_);
+ RTC_DCHECK(callback);
+ RecordCapturerImpl(DesktopCapturerId::kWgcCapturerWin);
+
+ callback_ = callback;
+
+ // Create a Direct3D11 device to share amongst the WgcCaptureSessions. Many
+ // parameters are nullptr as the implemention uses defaults that work well for
+ // us.
+ HRESULT hr = D3D11CreateDevice(
+ /*adapter=*/nullptr, D3D_DRIVER_TYPE_HARDWARE,
+ /*software_rasterizer=*/nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT,
+ /*feature_levels=*/nullptr, /*feature_levels_size=*/0, D3D11_SDK_VERSION,
+ &d3d11_device_, /*feature_level=*/nullptr, /*device_context=*/nullptr);
+ if (hr == DXGI_ERROR_UNSUPPORTED) {
+ // If a hardware device could not be created, use WARP which is a high speed
+ // software device.
+ hr = D3D11CreateDevice(
+ /*adapter=*/nullptr, D3D_DRIVER_TYPE_WARP,
+ /*software_rasterizer=*/nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT,
+ /*feature_levels=*/nullptr, /*feature_levels_size=*/0,
+ D3D11_SDK_VERSION, &d3d11_device_, /*feature_level=*/nullptr,
+ /*device_context=*/nullptr);
+ }
+
+ if (FAILED(hr)) {
+ RTC_LOG(LS_ERROR) << "Failed to create D3D11Device: " << hr;
+ }
+}
+
+void WgcCapturerWin::CaptureFrame() {
+ RTC_DCHECK(callback_);
+
+ if (!capture_source_) {
+ RTC_LOG(LS_ERROR) << "Source hasn't been selected";
+ callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
+ /*frame=*/nullptr);
+ RecordWgcCapturerResult(WgcCapturerResult::kNoSourceSelected);
+ return;
+ }
+
+ if (!d3d11_device_) {
+ RTC_LOG(LS_ERROR) << "No D3D11D3evice, cannot capture.";
+ callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
+ /*frame=*/nullptr);
+ RecordWgcCapturerResult(WgcCapturerResult::kNoDirect3dDevice);
+ return;
+ }
+
+ int64_t capture_start_time_nanos = rtc::TimeNanos();
+
+ HRESULT hr;
+ WgcCaptureSession* capture_session = nullptr;
+ std::map<SourceId, WgcCaptureSession>::iterator session_iter =
+ ongoing_captures_.find(capture_source_->GetSourceId());
+ if (session_iter == ongoing_captures_.end()) {
+ ComPtr<WGC::IGraphicsCaptureItem> item;
+ hr = capture_source_->GetCaptureItem(&item);
+ if (FAILED(hr)) {
+ RTC_LOG(LS_ERROR) << "Failed to create a GraphicsCaptureItem: " << hr;
+ callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
+ /*frame=*/nullptr);
+ RecordWgcCapturerResult(WgcCapturerResult::kItemCreationFailure);
+ return;
+ }
+
+ std::pair<std::map<SourceId, WgcCaptureSession>::iterator, bool>
+ iter_success_pair = ongoing_captures_.emplace(
+ std::piecewise_construct,
+ std::forward_as_tuple(capture_source_->GetSourceId()),
+ std::forward_as_tuple(d3d11_device_, item));
+ RTC_DCHECK(iter_success_pair.second);
+ capture_session = &iter_success_pair.first->second;
+ } else {
+ capture_session = &session_iter->second;
+ }
+
+ if (!capture_session->IsCaptureStarted()) {
+ hr = capture_session->StartCapture();
+ if (FAILED(hr)) {
+ RTC_LOG(LS_ERROR) << "Failed to start capture: " << hr;
+ ongoing_captures_.erase(capture_source_->GetSourceId());
+ callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
+ /*frame=*/nullptr);
+ RecordWgcCapturerResult(WgcCapturerResult::kSessionStartFailure);
+ return;
+ }
+ }
+
+ std::unique_ptr<DesktopFrame> frame;
+ hr = capture_session->GetFrame(&frame);
+ if (FAILED(hr)) {
+ RTC_LOG(LS_ERROR) << "GetFrame failed: " << hr;
+ ongoing_captures_.erase(capture_source_->GetSourceId());
+ callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
+ /*frame=*/nullptr);
+ RecordWgcCapturerResult(WgcCapturerResult::kGetFrameFailure);
+ return;
+ }
+
+ if (!frame) {
+ callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_TEMPORARY,
+ /*frame=*/nullptr);
+ RecordWgcCapturerResult(WgcCapturerResult::kFrameDropped);
+ return;
+ }
+
+ int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) /
+ rtc::kNumNanosecsPerMillisec;
+ RTC_HISTOGRAM_COUNTS_1000("WebRTC.DesktopCapture.Win.WgcCapturerFrameTime",
+ capture_time_ms);
+ frame->set_capture_time_ms(capture_time_ms);
+ frame->set_capturer_id(DesktopCapturerId::kWgcCapturerWin);
+ frame->set_may_contain_cursor(true);
+ frame->set_top_left(capture_source_->GetTopLeft());
+ RecordWgcCapturerResult(WgcCapturerResult::kSuccess);
+ callback_->OnCaptureResult(DesktopCapturer::Result::SUCCESS,
+ std::move(frame));
+}
+
+bool WgcCapturerWin::IsSourceBeingCaptured(DesktopCapturer::SourceId id) {
+ std::map<DesktopCapturer::SourceId, WgcCaptureSession>::iterator
+ session_iter = ongoing_captures_.find(id);
+ if (session_iter == ongoing_captures_.end())
+ return false;
+
+ return session_iter->second.IsCaptureStarted();
+}
+
+} // namespace webrtc
diff --git a/modules/desktop_capture/win/wgc_capturer_win.h b/modules/desktop_capture/win/wgc_capturer_win.h
index 58f3fc3..34e6874 100644
--- a/modules/desktop_capture/win/wgc_capturer_win.h
+++ b/modules/desktop_capture/win/wgc_capturer_win.h
@@ -1,138 +1,138 @@
-/*
- * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_
-#define MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_
-
-#include <d3d11.h>
-#include <wrl/client.h>
-
-#include <map>
-#include <memory>
-
-#include "modules/desktop_capture/desktop_capture_options.h"
-#include "modules/desktop_capture/desktop_capturer.h"
-#include "modules/desktop_capture/win/screen_capture_utils.h"
-#include "modules/desktop_capture/win/wgc_capture_session.h"
-#include "modules/desktop_capture/win/wgc_capture_source.h"
-#include "modules/desktop_capture/win/window_capture_utils.h"
-
-namespace webrtc {
-
-// WgcCapturerWin is initialized with an implementation of this base class,
-// which it uses to find capturable sources of a particular type. This way,
-// WgcCapturerWin can remain source-agnostic.
-class SourceEnumerator {
- public:
- virtual ~SourceEnumerator() = default;
-
- virtual bool FindAllSources(DesktopCapturer::SourceList* sources) = 0;
-};
-
-class WindowEnumerator final : public SourceEnumerator {
- public:
- explicit WindowEnumerator(bool enumerate_current_process_windows)
- : enumerate_current_process_windows_(enumerate_current_process_windows) {}
-
- WindowEnumerator(const WindowEnumerator&) = delete;
- WindowEnumerator& operator=(const WindowEnumerator&) = delete;
-
- ~WindowEnumerator() override = default;
-
- bool FindAllSources(DesktopCapturer::SourceList* sources) override {
- // WGC fails to capture windows with the WS_EX_TOOLWINDOW style, so we
- // provide it as a filter to ensure windows with the style are not returned.
- return window_capture_helper_.EnumerateCapturableWindows(
- sources, enumerate_current_process_windows_, WS_EX_TOOLWINDOW);
- }
-
- private:
- WindowCaptureHelperWin window_capture_helper_;
- bool enumerate_current_process_windows_;
-};
-
-class ScreenEnumerator final : public SourceEnumerator {
- public:
- ScreenEnumerator() = default;
-
- ScreenEnumerator(const ScreenEnumerator&) = delete;
- ScreenEnumerator& operator=(const ScreenEnumerator&) = delete;
-
- ~ScreenEnumerator() override = default;
-
- bool FindAllSources(DesktopCapturer::SourceList* sources) override {
- return webrtc::GetScreenList(sources);
- }
-};
-
-// A capturer that uses the Window.Graphics.Capture APIs. It is suitable for
-// both window and screen capture (but only one type per instance). Consumers
-// should not instantiate this class directly, instead they should use
-// |CreateRawWindowCapturer()| or |CreateRawScreenCapturer()| to receive a
-// capturer appropriate for the type of source they want to capture.
-class WgcCapturerWin : public DesktopCapturer {
- public:
- WgcCapturerWin(std::unique_ptr<WgcCaptureSourceFactory> source_factory,
- std::unique_ptr<SourceEnumerator> source_enumerator);
-
- WgcCapturerWin(const WgcCapturerWin&) = delete;
- WgcCapturerWin& operator=(const WgcCapturerWin&) = delete;
-
- ~WgcCapturerWin() override;
-
- static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
- const DesktopCaptureOptions& options);
-
- static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
- const DesktopCaptureOptions& options);
-
- // DesktopCapturer interface.
- bool GetSourceList(SourceList* sources) override;
- bool SelectSource(SourceId id) override;
- bool FocusOnSelectedSource() override;
- void Start(Callback* callback) override;
- void CaptureFrame() override;
-
- // Used in WgcCapturerTests.
- bool IsSourceBeingCaptured(SourceId id);
-
- private:
- // Factory to create a WgcCaptureSource for us whenever SelectSource is
- // called. Initialized at construction with a source-specific implementation.
- std::unique_ptr<WgcCaptureSourceFactory> source_factory_;
-
- // The source enumerator helps us find capturable sources of the appropriate
- // type. Initialized at construction with a source-specific implementation.
- std::unique_ptr<SourceEnumerator> source_enumerator_;
-
- // The WgcCaptureSource represents the source we are capturing. It tells us
- // if the source is capturable and it creates the GraphicsCaptureItem for us.
- std::unique_ptr<WgcCaptureSource> capture_source_;
-
- // A map of all the sources we are capturing and the associated
- // WgcCaptureSession. Frames for the current source (indicated via
- // SelectSource) will be retrieved from the appropriate session when
- // requested via CaptureFrame.
- // This helps us efficiently capture multiple sources (e.g. when consumers
- // are trying to display a list of available capture targets with thumbnails).
- std::map<SourceId, WgcCaptureSession> ongoing_captures_;
-
- // The callback that we deliver frames to, synchronously, before CaptureFrame
- // returns.
- Callback* callback_ = nullptr;
-
- // A Direct3D11 device that is shared amongst the WgcCaptureSessions, who
- // require one to perform the capture.
- Microsoft::WRL::ComPtr<::ID3D11Device> d3d11_device_;
-};
-
-} // namespace webrtc
-
-#endif // MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_
+#define MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_
+
+#include <d3d11.h>
+#include <wrl/client.h>
+
+#include <map>
+#include <memory>
+
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+#include "modules/desktop_capture/win/screen_capture_utils.h"
+#include "modules/desktop_capture/win/wgc_capture_session.h"
+#include "modules/desktop_capture/win/wgc_capture_source.h"
+#include "modules/desktop_capture/win/window_capture_utils.h"
+
+namespace webrtc {
+
+// WgcCapturerWin is initialized with an implementation of this base class,
+// which it uses to find capturable sources of a particular type. This way,
+// WgcCapturerWin can remain source-agnostic.
+class SourceEnumerator {
+ public:
+ virtual ~SourceEnumerator() = default;
+
+ virtual bool FindAllSources(DesktopCapturer::SourceList* sources) = 0;
+};
+
+class WindowEnumerator final : public SourceEnumerator {
+ public:
+ explicit WindowEnumerator(bool enumerate_current_process_windows)
+ : enumerate_current_process_windows_(enumerate_current_process_windows) {}
+
+ WindowEnumerator(const WindowEnumerator&) = delete;
+ WindowEnumerator& operator=(const WindowEnumerator&) = delete;
+
+ ~WindowEnumerator() override = default;
+
+ bool FindAllSources(DesktopCapturer::SourceList* sources) override {
+ // WGC fails to capture windows with the WS_EX_TOOLWINDOW style, so we
+ // provide it as a filter to ensure windows with the style are not returned.
+ return window_capture_helper_.EnumerateCapturableWindows(
+ sources, enumerate_current_process_windows_, WS_EX_TOOLWINDOW);
+ }
+
+ private:
+ WindowCaptureHelperWin window_capture_helper_;
+ bool enumerate_current_process_windows_;
+};
+
+class ScreenEnumerator final : public SourceEnumerator {
+ public:
+ ScreenEnumerator() = default;
+
+ ScreenEnumerator(const ScreenEnumerator&) = delete;
+ ScreenEnumerator& operator=(const ScreenEnumerator&) = delete;
+
+ ~ScreenEnumerator() override = default;
+
+ bool FindAllSources(DesktopCapturer::SourceList* sources) override {
+ return webrtc::GetScreenList(sources);
+ }
+};
+
+// A capturer that uses the Window.Graphics.Capture APIs. It is suitable for
+// both window and screen capture (but only one type per instance). Consumers
+// should not instantiate this class directly, instead they should use
+// `CreateRawWindowCapturer()` or `CreateRawScreenCapturer()` to receive a
+// capturer appropriate for the type of source they want to capture.
+class WgcCapturerWin : public DesktopCapturer {
+ public:
+ WgcCapturerWin(std::unique_ptr<WgcCaptureSourceFactory> source_factory,
+ std::unique_ptr<SourceEnumerator> source_enumerator);
+
+ WgcCapturerWin(const WgcCapturerWin&) = delete;
+ WgcCapturerWin& operator=(const WgcCapturerWin&) = delete;
+
+ ~WgcCapturerWin() override;
+
+ static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options);
+
+ static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
+ const DesktopCaptureOptions& options);
+
+ // DesktopCapturer interface.
+ bool GetSourceList(SourceList* sources) override;
+ bool SelectSource(SourceId id) override;
+ bool FocusOnSelectedSource() override;
+ void Start(Callback* callback) override;
+ void CaptureFrame() override;
+
+ // Used in WgcCapturerTests.
+ bool IsSourceBeingCaptured(SourceId id);
+
+ private:
+ // Factory to create a WgcCaptureSource for us whenever SelectSource is
+ // called. Initialized at construction with a source-specific implementation.
+ std::unique_ptr<WgcCaptureSourceFactory> source_factory_;
+
+ // The source enumerator helps us find capturable sources of the appropriate
+ // type. Initialized at construction with a source-specific implementation.
+ std::unique_ptr<SourceEnumerator> source_enumerator_;
+
+ // The WgcCaptureSource represents the source we are capturing. It tells us
+ // if the source is capturable and it creates the GraphicsCaptureItem for us.
+ std::unique_ptr<WgcCaptureSource> capture_source_;
+
+ // A map of all the sources we are capturing and the associated
+ // WgcCaptureSession. Frames for the current source (indicated via
+ // SelectSource) will be retrieved from the appropriate session when
+ // requested via CaptureFrame.
+ // This helps us efficiently capture multiple sources (e.g. when consumers
+ // are trying to display a list of available capture targets with thumbnails).
+ std::map<SourceId, WgcCaptureSession> ongoing_captures_;
+
+ // The callback that we deliver frames to, synchronously, before CaptureFrame
+ // returns.
+ Callback* callback_ = nullptr;
+
+ // A Direct3D11 device that is shared amongst the WgcCaptureSessions, who
+ // require one to perform the capture.
+ Microsoft::WRL::ComPtr<::ID3D11Device> d3d11_device_;
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_WIN_WGC_CAPTURER_WIN_H_
diff --git a/modules/desktop_capture/win/wgc_capturer_win_unittest.cc b/modules/desktop_capture/win/wgc_capturer_win_unittest.cc
index ebfb576..441ff3b 100644
--- a/modules/desktop_capture/win/wgc_capturer_win_unittest.cc
+++ b/modules/desktop_capture/win/wgc_capturer_win_unittest.cc
@@ -238,7 +238,7 @@
}
// DesktopCapturer::Callback interface
- // The capturer synchronously invokes this method before |CaptureFrame()|
+ // The capturer synchronously invokes this method before `CaptureFrame()`
// returns.
void OnCaptureResult(DesktopCapturer::Result result,
std::unique_ptr<DesktopFrame> frame) override {
diff --git a/modules/desktop_capture/win/wgc_desktop_frame.h b/modules/desktop_capture/win/wgc_desktop_frame.h
index 0eca763..0a671cf 100644
--- a/modules/desktop_capture/win/wgc_desktop_frame.h
+++ b/modules/desktop_capture/win/wgc_desktop_frame.h
@@ -26,7 +26,7 @@
// Windows.Graphics.Capture API.
class WgcDesktopFrame final : public DesktopFrame {
public:
- // WgcDesktopFrame receives an rvalue reference to the |image_data| vector
+ // WgcDesktopFrame receives an rvalue reference to the `image_data` vector
// so that it can take ownership of it (and avoid a copy).
WgcDesktopFrame(DesktopSize size,
int stride,
diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc
index aaaef0a..032465f 100644
--- a/modules/desktop_capture/win/window_capture_utils.cc
+++ b/modules/desktop_capture/win/window_capture_utils.cc
@@ -79,7 +79,7 @@
DesktopCapturer::Source window;
window.id = reinterpret_cast<WindowId>(hwnd);
- // GetWindowText* are potentially blocking operations if |hwnd| is
+ // GetWindowText* are potentially blocking operations if `hwnd` is
// owned by the current process. The APIs will send messages to the window's
// message loop, and if the message loop is waiting on this operation we will
// enter a deadlock.
@@ -228,7 +228,7 @@
// - We assume a window has same border width in each side.
// So we shrink half of the width difference from all four sides.
const int shrink = ((width - result->width()) / 2);
- // When |shrink| is negative, DesktopRect::Extend() shrinks itself.
+ // When `shrink` is negative, DesktopRect::Extend() shrinks itself.
result->Extend(shrink, 0, shrink, 0);
// Usually this should not happen, just in case we have received a strange
// window, which has only left and right borders.
@@ -364,7 +364,7 @@
return false;
}
-// |content_rect| is preferred because,
+// `content_rect` is preferred because,
// 1. WindowCapturerWinGdi is using GDI capturer, which cannot capture DX
// output.
// So ScreenCapturer should be used as much as possible to avoid
diff --git a/modules/desktop_capture/win/window_capture_utils.h b/modules/desktop_capture/win/window_capture_utils.h
index a6a295d..335d8737 100644
--- a/modules/desktop_capture/win/window_capture_utils.h
+++ b/modules/desktop_capture/win/window_capture_utils.h
@@ -28,13 +28,13 @@
// Outputs the window rect, with the left/right/bottom frame border cropped if
// the window is maximized or has a transparent resize border.
-// |avoid_cropping_border| may be set to true to avoid cropping the visible
+// `avoid_cropping_border` may be set to true to avoid cropping the visible
// border when cropping any resize border.
-// |cropped_rect| is the cropped rect relative to the
-// desktop. |original_rect| is the original rect returned from GetWindowRect.
+// `cropped_rect` is the cropped rect relative to the
+// desktop. `original_rect` is the original rect returned from GetWindowRect.
// Returns true if all API calls succeeded. The returned DesktopRect is in
// system coordinates, i.e. the primary monitor on the system always starts from
-// (0, 0). |original_rect| can be nullptr.
+// (0, 0). `original_rect` can be nullptr.
//
// TODO(zijiehe): Move this function to CroppingWindowCapturerWin after it has
// been removed from MouseCursorMonitorWin.
@@ -48,22 +48,22 @@
DesktopRect* cropped_rect,
DesktopRect* original_rect);
-// Retrieves the rectangle of the content area of |window|. Usually it contains
+// Retrieves the rectangle of the content area of `window`. Usually it contains
// title bar and window client area, but borders or shadow are excluded. The
// returned DesktopRect is in system coordinates, i.e. the primary monitor on
// the system always starts from (0, 0). This function returns false if native
// APIs fail.
bool GetWindowContentRect(HWND window, DesktopRect* result);
-// Returns the region type of the |window| and fill |rect| with the region of
-// |window| if region type is SIMPLEREGION.
+// Returns the region type of the `window` and fill `rect` with the region of
+// `window` if region type is SIMPLEREGION.
int GetWindowRegionTypeWithBoundary(HWND window, DesktopRect* result);
-// Retrieves the size of the |hdc|. This function returns false if native APIs
+// Retrieves the size of the `hdc`. This function returns false if native APIs
// fail.
bool GetDcSize(HDC hdc, DesktopSize* size);
-// Retrieves whether the |window| is maximized and stores in |result|. This
+// Retrieves whether the `window` is maximized and stores in `result`. This
// function returns false if native APIs fail.
bool IsWindowMaximized(HWND window, bool* result);
@@ -88,7 +88,7 @@
// - [with kIgnoreUntitled] windows with no title.
// - [with kIgnoreUnresponsive] windows that are unresponsive.
// - [with kIgnoreCurrentProcessWindows] windows owned by the current process.
-// - Any windows with extended styles that match |ex_style_filters|.
+// - Any windows with extended styles that match `ex_style_filters`.
// Returns false if native APIs failed.
bool GetWindowList(int flags,
DesktopCapturer::SourceList* windows,
@@ -113,9 +113,9 @@
bool IsWindowVisibleOnCurrentDesktop(HWND hwnd);
bool IsWindowCloaked(HWND hwnd);
- // The optional |ex_style_filters| parameter allows callers to provide
+ // The optional `ex_style_filters` parameter allows callers to provide
// extended window styles (e.g. WS_EX_TOOLWINDOW) and prevent windows that
- // match from being included in |results|.
+ // match from being included in `results`.
bool EnumerateCapturableWindows(DesktopCapturer::SourceList* results,
bool enumerate_current_process_windows,
LONG ex_style_filters = 0);
diff --git a/modules/desktop_capture/win/window_capture_utils_unittest.cc b/modules/desktop_capture/win/window_capture_utils_unittest.cc
index 4b426fc..f3da4b5 100644
--- a/modules/desktop_capture/win/window_capture_utils_unittest.cc
+++ b/modules/desktop_capture/win/window_capture_utils_unittest.cc
@@ -1,154 +1,155 @@
-/*
- * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/desktop_capture/win/window_capture_utils.h"
-
-#include <winuser.h>
-#include <algorithm>
-#include <memory>
-#include <mutex>
-
-#include "modules/desktop_capture/desktop_capturer.h"
-#include "modules/desktop_capture/win/test_support/test_window.h"
-#include "rtc_base/thread.h"
-#include "test/gtest.h"
-
-namespace webrtc {
-namespace {
-
-const char kWindowThreadName[] = "window_capture_utils_test_thread";
-const WCHAR kWindowTitle[] = L"Window Capture Utils Test";
-
-std::unique_ptr<rtc::Thread> SetUpUnresponsiveWindow(std::mutex& mtx,
- WindowInfo& info) {
- std::unique_ptr<rtc::Thread> window_thread;
- window_thread = rtc::Thread::Create();
- window_thread->SetName(kWindowThreadName, nullptr);
- window_thread->Start();
-
- window_thread->Invoke<void>(
- RTC_FROM_HERE, [&info]() { info = CreateTestWindow(kWindowTitle); });
-
- // Intentionally create a deadlock to cause the window to become unresponsive.
- mtx.lock();
- window_thread->PostTask(RTC_FROM_HERE, [&mtx]() {
- mtx.lock();
- mtx.unlock();
- });
-
- return window_thread;
-}
-
-} // namespace
-
-TEST(WindowCaptureUtilsTest, GetWindowList) {
- WindowInfo info = CreateTestWindow(kWindowTitle);
- DesktopCapturer::SourceList window_list;
- ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list));
- EXPECT_GT(window_list.size(), 0ULL);
- EXPECT_NE(std::find_if(window_list.begin(), window_list.end(),
- [&info](DesktopCapturer::Source window) {
- return reinterpret_cast<HWND>(window.id) ==
- info.hwnd;
- }),
- window_list.end());
- DestroyTestWindow(info);
-}
-
-TEST(WindowCaptureUtilsTest, IncludeUnresponsiveWindows) {
- std::mutex mtx;
- WindowInfo info;
- std::unique_ptr<rtc::Thread> window_thread =
- SetUpUnresponsiveWindow(mtx, info);
-
- EXPECT_FALSE(IsWindowResponding(info.hwnd));
-
- DesktopCapturer::SourceList window_list;
- ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list));
- EXPECT_GT(window_list.size(), 0ULL);
- EXPECT_NE(std::find_if(window_list.begin(), window_list.end(),
- [&info](DesktopCapturer::Source window) {
- return reinterpret_cast<HWND>(window.id) ==
- info.hwnd;
- }),
- window_list.end());
-
- mtx.unlock();
- window_thread->Invoke<void>(RTC_FROM_HERE,
- [&info]() { DestroyTestWindow(info); });
- window_thread->Stop();
-}
-
-TEST(WindowCaptureUtilsTest, IgnoreUnresponsiveWindows) {
- std::mutex mtx;
- WindowInfo info;
- std::unique_ptr<rtc::Thread> window_thread =
- SetUpUnresponsiveWindow(mtx, info);
-
- EXPECT_FALSE(IsWindowResponding(info.hwnd));
-
- DesktopCapturer::SourceList window_list;
- ASSERT_TRUE(
- GetWindowList(GetWindowListFlags::kIgnoreUnresponsive, &window_list));
- EXPECT_EQ(std::find_if(window_list.begin(), window_list.end(),
- [&info](DesktopCapturer::Source window) {
- return reinterpret_cast<HWND>(window.id) ==
- info.hwnd;
- }),
- window_list.end());
-
- mtx.unlock();
- window_thread->Invoke<void>(RTC_FROM_HERE,
- [&info]() { DestroyTestWindow(info); });
- window_thread->Stop();
-}
-
-TEST(WindowCaptureUtilsTest, IncludeUntitledWindows) {
- WindowInfo info = CreateTestWindow(L"");
- DesktopCapturer::SourceList window_list;
- ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list));
- EXPECT_GT(window_list.size(), 0ULL);
- EXPECT_NE(std::find_if(window_list.begin(), window_list.end(),
- [&info](DesktopCapturer::Source window) {
- return reinterpret_cast<HWND>(window.id) ==
- info.hwnd;
- }),
- window_list.end());
- DestroyTestWindow(info);
-}
-
-TEST(WindowCaptureUtilsTest, IgnoreUntitledWindows) {
- WindowInfo info = CreateTestWindow(L"");
- DesktopCapturer::SourceList window_list;
- ASSERT_TRUE(GetWindowList(GetWindowListFlags::kIgnoreUntitled, &window_list));
- EXPECT_EQ(std::find_if(window_list.begin(), window_list.end(),
- [&info](DesktopCapturer::Source window) {
- return reinterpret_cast<HWND>(window.id) ==
- info.hwnd;
- }),
- window_list.end());
- DestroyTestWindow(info);
-}
-
-TEST(WindowCaptureUtilsTest, IgnoreCurrentProcessWindows) {
- WindowInfo info = CreateTestWindow(kWindowTitle);
- DesktopCapturer::SourceList window_list;
- ASSERT_TRUE(GetWindowList(GetWindowListFlags::kIgnoreCurrentProcessWindows,
- &window_list));
- EXPECT_EQ(std::find_if(window_list.begin(), window_list.end(),
- [&info](DesktopCapturer::Source window) {
- return reinterpret_cast<HWND>(window.id) ==
- info.hwnd;
- }),
- window_list.end());
- DestroyTestWindow(info);
-}
-
-} // namespace webrtc
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "modules/desktop_capture/win/window_capture_utils.h"
+
+#include <winuser.h>
+
+#include <algorithm>
+#include <memory>
+#include <mutex>
+
+#include "modules/desktop_capture/desktop_capturer.h"
+#include "modules/desktop_capture/win/test_support/test_window.h"
+#include "rtc_base/thread.h"
+#include "test/gtest.h"
+
+namespace webrtc {
+namespace {
+
+const char kWindowThreadName[] = "window_capture_utils_test_thread";
+const WCHAR kWindowTitle[] = L"Window Capture Utils Test";
+
+std::unique_ptr<rtc::Thread> SetUpUnresponsiveWindow(std::mutex& mtx,
+ WindowInfo& info) {
+ std::unique_ptr<rtc::Thread> window_thread;
+ window_thread = rtc::Thread::Create();
+ window_thread->SetName(kWindowThreadName, nullptr);
+ window_thread->Start();
+
+ window_thread->Invoke<void>(
+ RTC_FROM_HERE, [&info]() { info = CreateTestWindow(kWindowTitle); });
+
+ // Intentionally create a deadlock to cause the window to become unresponsive.
+ mtx.lock();
+ window_thread->PostTask(RTC_FROM_HERE, [&mtx]() {
+ mtx.lock();
+ mtx.unlock();
+ });
+
+ return window_thread;
+}
+
+} // namespace
+
+TEST(WindowCaptureUtilsTest, GetWindowList) {
+ WindowInfo info = CreateTestWindow(kWindowTitle);
+ DesktopCapturer::SourceList window_list;
+ ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list));
+ EXPECT_GT(window_list.size(), 0ULL);
+ EXPECT_NE(std::find_if(window_list.begin(), window_list.end(),
+ [&info](DesktopCapturer::Source window) {
+ return reinterpret_cast<HWND>(window.id) ==
+ info.hwnd;
+ }),
+ window_list.end());
+ DestroyTestWindow(info);
+}
+
+TEST(WindowCaptureUtilsTest, IncludeUnresponsiveWindows) {
+ std::mutex mtx;
+ WindowInfo info;
+ std::unique_ptr<rtc::Thread> window_thread =
+ SetUpUnresponsiveWindow(mtx, info);
+
+ EXPECT_FALSE(IsWindowResponding(info.hwnd));
+
+ DesktopCapturer::SourceList window_list;
+ ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list));
+ EXPECT_GT(window_list.size(), 0ULL);
+ EXPECT_NE(std::find_if(window_list.begin(), window_list.end(),
+ [&info](DesktopCapturer::Source window) {
+ return reinterpret_cast<HWND>(window.id) ==
+ info.hwnd;
+ }),
+ window_list.end());
+
+ mtx.unlock();
+ window_thread->Invoke<void>(RTC_FROM_HERE,
+ [&info]() { DestroyTestWindow(info); });
+ window_thread->Stop();
+}
+
+TEST(WindowCaptureUtilsTest, IgnoreUnresponsiveWindows) {
+ std::mutex mtx;
+ WindowInfo info;
+ std::unique_ptr<rtc::Thread> window_thread =
+ SetUpUnresponsiveWindow(mtx, info);
+
+ EXPECT_FALSE(IsWindowResponding(info.hwnd));
+
+ DesktopCapturer::SourceList window_list;
+ ASSERT_TRUE(
+ GetWindowList(GetWindowListFlags::kIgnoreUnresponsive, &window_list));
+ EXPECT_EQ(std::find_if(window_list.begin(), window_list.end(),
+ [&info](DesktopCapturer::Source window) {
+ return reinterpret_cast<HWND>(window.id) ==
+ info.hwnd;
+ }),
+ window_list.end());
+
+ mtx.unlock();
+ window_thread->Invoke<void>(RTC_FROM_HERE,
+ [&info]() { DestroyTestWindow(info); });
+ window_thread->Stop();
+}
+
+TEST(WindowCaptureUtilsTest, IncludeUntitledWindows) {
+ WindowInfo info = CreateTestWindow(L"");
+ DesktopCapturer::SourceList window_list;
+ ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list));
+ EXPECT_GT(window_list.size(), 0ULL);
+ EXPECT_NE(std::find_if(window_list.begin(), window_list.end(),
+ [&info](DesktopCapturer::Source window) {
+ return reinterpret_cast<HWND>(window.id) ==
+ info.hwnd;
+ }),
+ window_list.end());
+ DestroyTestWindow(info);
+}
+
+TEST(WindowCaptureUtilsTest, IgnoreUntitledWindows) {
+ WindowInfo info = CreateTestWindow(L"");
+ DesktopCapturer::SourceList window_list;
+ ASSERT_TRUE(GetWindowList(GetWindowListFlags::kIgnoreUntitled, &window_list));
+ EXPECT_EQ(std::find_if(window_list.begin(), window_list.end(),
+ [&info](DesktopCapturer::Source window) {
+ return reinterpret_cast<HWND>(window.id) ==
+ info.hwnd;
+ }),
+ window_list.end());
+ DestroyTestWindow(info);
+}
+
+TEST(WindowCaptureUtilsTest, IgnoreCurrentProcessWindows) {
+ WindowInfo info = CreateTestWindow(kWindowTitle);
+ DesktopCapturer::SourceList window_list;
+ ASSERT_TRUE(GetWindowList(GetWindowListFlags::kIgnoreCurrentProcessWindows,
+ &window_list));
+ EXPECT_EQ(std::find_if(window_list.begin(), window_list.end(),
+ [&info](DesktopCapturer::Source window) {
+ return reinterpret_cast<HWND>(window.id) ==
+ info.hwnd;
+ }),
+ window_list.end());
+ DestroyTestWindow(info);
+}
+
+} // namespace webrtc
diff --git a/modules/desktop_capture/win/window_capturer_win_gdi.cc b/modules/desktop_capture/win/window_capturer_win_gdi.cc
index 25677e9..4a73a9a 100644
--- a/modules/desktop_capture/win/window_capturer_win_gdi.cc
+++ b/modules/desktop_capture/win/window_capturer_win_gdi.cc
@@ -230,19 +230,19 @@
DesktopSize window_dc_size;
if (GetDcSize(window_dc, &window_dc_size)) {
- // The |window_dc_size| is used to detect the scaling of the original
+ // The `window_dc_size` is used to detect the scaling of the original
// window. If the application does not support high-DPI settings, it will
// be scaled by Windows according to the scaling setting.
// https://www.google.com/search?q=windows+scaling+settings&ie=UTF-8
- // So the size of the |window_dc|, i.e. the bitmap we can retrieve from
+ // So the size of the `window_dc`, i.e. the bitmap we can retrieve from
// PrintWindow() or BitBlt() function, will be smaller than
- // |original_rect| and |cropped_rect|. Part of the captured desktop frame
+ // `original_rect` and `cropped_rect`. Part of the captured desktop frame
// will be black. See
// bug https://bugs.chromium.org/p/webrtc/issues/detail?id=8112 for
// details.
- // If |window_dc_size| is smaller than |window_rect|, let's resize both
- // |original_rect| and |cropped_rect| according to the scaling factor.
+ // If `window_dc_size` is smaller than `window_rect`, let's resize both
+ // `original_rect` and `cropped_rect` according to the scaling factor.
// This will adjust the width and height of the two rects.
horizontal_scale =
static_cast<double>(window_dc_size.width()) / original_rect.width();
@@ -251,8 +251,8 @@
original_rect.Scale(horizontal_scale, vertical_scale);
cropped_rect.Scale(horizontal_scale, vertical_scale);
- // Translate |cropped_rect| to the left so that its position within
- // |original_rect| remains accurate after scaling.
+ // Translate `cropped_rect` to the left so that its position within
+ // `original_rect` remains accurate after scaling.
// See crbug.com/1083527 for more info.
int translate_left = static_cast<int>(std::round(
(cropped_rect.left() - original_rect.left()) * (horizontal_scale - 1)));
diff --git a/modules/desktop_capture/win/window_capturer_win_gdi.h b/modules/desktop_capture/win/window_capturer_win_gdi.h
index 5091458..bf94dfe 100644
--- a/modules/desktop_capture/win/window_capturer_win_gdi.h
+++ b/modules/desktop_capture/win/window_capturer_win_gdi.h
@@ -1,78 +1,78 @@
-/*
- * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
-#define MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "modules/desktop_capture/desktop_capture_options.h"
-#include "modules/desktop_capture/desktop_capturer.h"
-#include "modules/desktop_capture/win/window_capture_utils.h"
-#include "modules/desktop_capture/window_finder_win.h"
-
-namespace webrtc {
-
-class WindowCapturerWinGdi : public DesktopCapturer {
- public:
- explicit WindowCapturerWinGdi(bool enumerate_current_process_windows);
-
- // Disallow copy and assign
- WindowCapturerWinGdi(const WindowCapturerWinGdi&) = delete;
- WindowCapturerWinGdi& operator=(const WindowCapturerWinGdi&) = delete;
-
- ~WindowCapturerWinGdi() override;
-
- static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
- const DesktopCaptureOptions& options);
-
- // DesktopCapturer interface.
- void Start(Callback* callback) override;
- void CaptureFrame() override;
- bool GetSourceList(SourceList* sources) override;
- bool SelectSource(SourceId id) override;
- bool FocusOnSelectedSource() override;
- bool IsOccluded(const DesktopVector& pos) override;
-
- private:
- struct CaptureResults {
- Result result;
- std::unique_ptr<DesktopFrame> frame;
- };
-
- CaptureResults CaptureFrame(bool capture_owned_windows);
-
- Callback* callback_ = nullptr;
-
- // HWND and HDC for the currently selected window or nullptr if window is not
- // selected.
- HWND window_ = nullptr;
-
- DesktopSize previous_size_;
-
- WindowCaptureHelperWin window_capture_helper_;
-
- bool enumerate_current_process_windows_;
-
- // This map is used to avoid flickering for the case when SelectWindow() calls
- // are interleaved with Capture() calls.
- std::map<HWND, DesktopSize> window_size_map_;
-
- WindowFinderWin window_finder_;
-
- std::vector<HWND> owned_windows_;
- std::unique_ptr<WindowCapturerWinGdi> owned_window_capturer_;
-};
-
-} // namespace webrtc
-
-#endif // MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
+#define MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+#include "modules/desktop_capture/win/window_capture_utils.h"
+#include "modules/desktop_capture/window_finder_win.h"
+
+namespace webrtc {
+
+class WindowCapturerWinGdi : public DesktopCapturer {
+ public:
+ explicit WindowCapturerWinGdi(bool enumerate_current_process_windows);
+
+ // Disallow copy and assign
+ WindowCapturerWinGdi(const WindowCapturerWinGdi&) = delete;
+ WindowCapturerWinGdi& operator=(const WindowCapturerWinGdi&) = delete;
+
+ ~WindowCapturerWinGdi() override;
+
+ static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options);
+
+ // DesktopCapturer interface.
+ void Start(Callback* callback) override;
+ void CaptureFrame() override;
+ bool GetSourceList(SourceList* sources) override;
+ bool SelectSource(SourceId id) override;
+ bool FocusOnSelectedSource() override;
+ bool IsOccluded(const DesktopVector& pos) override;
+
+ private:
+ struct CaptureResults {
+ Result result;
+ std::unique_ptr<DesktopFrame> frame;
+ };
+
+ CaptureResults CaptureFrame(bool capture_owned_windows);
+
+ Callback* callback_ = nullptr;
+
+ // HWND and HDC for the currently selected window or nullptr if window is not
+ // selected.
+ HWND window_ = nullptr;
+
+ DesktopSize previous_size_;
+
+ WindowCaptureHelperWin window_capture_helper_;
+
+ bool enumerate_current_process_windows_;
+
+ // This map is used to avoid flickering for the case when SelectWindow() calls
+ // are interleaved with Capture() calls.
+ std::map<HWND, DesktopSize> window_size_map_;
+
+ WindowFinderWin window_finder_;
+
+ std::vector<HWND> owned_windows_;
+ std::unique_ptr<WindowCapturerWinGdi> owned_window_capturer_;
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
diff --git a/modules/desktop_capture/window_finder.h b/modules/desktop_capture/window_finder.h
index 0d34664..99e3cce 100644
--- a/modules/desktop_capture/window_finder.h
+++ b/modules/desktop_capture/window_finder.h
@@ -33,10 +33,10 @@
WindowFinder() = default;
virtual ~WindowFinder() = default;
- // Returns the id of the visible window under |point|. This function returns
- // kNullWindowId if no window is under |point| and the platform does not have
- // "root window" concept, i.e. the visible area under |point| is the desktop.
- // |point| is always in system coordinate, i.e. the primary monitor always
+ // Returns the id of the visible window under `point`. This function returns
+ // kNullWindowId if no window is under `point` and the platform does not have
+ // "root window" concept, i.e. the visible area under `point` is the desktop.
+ // `point` is always in system coordinate, i.e. the primary monitor always
// starts from (0, 0).
virtual WindowId GetWindowUnderPoint(DesktopVector point) = 0;
@@ -55,7 +55,7 @@
};
// Creates a platform-independent WindowFinder implementation. This function
- // returns nullptr if |options| does not contain enough information or
+ // returns nullptr if `options` does not contain enough information or
// WindowFinder does not support current platform.
static std::unique_ptr<WindowFinder> Create(const Options& options);
};