Commit graph

511 commits

Author SHA1 Message Date
Jan Grulich
a18e38fed2 Video capture PipeWire: drop corrupted PipeWire buffers
Use SPA_CHUNK_FLAG_CORRUPTED and SPA_META_HEADER_FLAG_CORRUPTED flags to
determine corrupted buffers or corrupted buffer data. We used to only
rely on compositors setting chunk->size, but this doesn't make sense for
dmabufs where they have to make up arbitrary values. It also looks this
is not reliable and can cause glitches as we end up processing corrupted buffers.

(cherry picked from commit cfbd6b0884)

Bug: chromium:341928670
Change-Id: Ida0c6a5e7a37e19598c6d5884726200f81b94962
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/349881
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#42292}
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/351563
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/6478@{#1}
Cr-Branched-From: 16fb7903e546051483720548168cd40cded7a040-refs/heads/main@{#42290}
2024-05-23 21:01:17 +00:00
memetao
decc48fd97 Fix 'Screen flickering on ScreenCapturerWinDirectx'
Bug: webrtc:15718
Change-Id: I230a0a7d196a4a3aea3b3e47cdf4f47c437e7196
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330800
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Zijie He <zijiehe@chromium.org>
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#42177}
2024-04-25 21:18:27 +00:00
Evan Shrubsole
5bfcc873d9 Add event scope to all TRACE_EVENT_INSTANTs
These are required by the Perfetto API and the missing argument prevents
the use of Perfetto.

Bug: webrtc:15917
Change-Id: Ie40c0344dc9d8cd40f7c751b133d150b975a33c7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/347702
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/main@{#42147}
2024-04-23 09:56:33 +00:00
Caroline Liu
74e9c4302c [fuchsia] DesktopCapturer gets display info from
fuchsia.ui.display.singleton

We previously used fuchsia.ui.scenic.Scenic/GetDisplayInfo to get
fuchsia.ui.gfx.DisplayInfo. This has been migrated to
fuchsia.ui.display.singleton.Info/GetMetrics and
fuchsia.ui.display.singleton.Metrics.

Bug: fuchsia:64206
Test: applied changes manually to local chromium repo's third_party/webrtc directory and compiled
Change-Id: If3c7fbd641ebd3b3333e7e5f1126f8f3ae3b97e7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/322780
Commit-Queue: Caroline Liu <carolineliu@google.com>
Reviewed-by: Emircan Uysaler <emircan@google.com>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#42104}
2024-04-17 23:17:29 +00:00
henrika
71b9a581b4 WGC capturer now fails with error when source is closed
When refactoring the WGC capture path, the check of a closed source
had been placed at a level where the notification of a closed source
was left without being detected since the error message was never
provided to the main WgcCapturerWin::CaptureFrame() which sends the
error message up to the client.

This trivial change ensures that WgcCapturerWin::CaptureFrame() returns
with DesktopCapturer::Result::ERROR_PERMANENT as soon as
WgcCaptureSession::OnItemClosed() has been triggered and it will
ensure that the WGC capture session stops and that any attached
MediaStreamTrack will signal its onended event as expected.

Bug: chromium:330863510
Change-Id: I57e44df417c33efa0595fc277cac5429cf539b26
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/344420
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41963}
2024-03-25 18:37:13 +00:00
Jan Grulich
334e9133dc Video capture PipeWire: add support for DMABuf buffer type
Announce that we support SPA_DATA_DmaBuf and tell PipeWire not to map
memory for us so we can handle it ourself, similar like we do in case of
screen sharing. This fixes an issue when a camera is already in use by
gstreamer (pipewiresrc), where DMABufs are used, and we try to share
same camera and get no content, as PipeWire doesn't want to mmap DMABuf
memory for us and we get NULL data pointers.

Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1876895

Bug: webrtc:15654
Change-Id: I788d8d12b2fcd5588329d7265e45b479f74bb628
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/338921
Commit-Queue: Jan Grulich <grulja@gmail.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#41826}
2024-02-27 18:31:26 +00:00
Jan Grulich
058bfe3ae3 PipeWire capturer: set capturer as failed when session is closed
Marking capturer as failed will indicate consumers will not be getting
any new frames by sending back ERROR_PERMANENT and let them know that
screencast can be stopped from their side. This will make screencast to
stop when a window we share is closed or when screencast is closed from
system tray.

Bug: chromium:40276865
Change-Id: Ia2c13461bd3126cab9c4838b8aa6840578562e9e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339560
Commit-Queue: Jan Grulich <grulja@gmail.com>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#41817}
2024-02-27 07:41:41 +00:00
Sunggook Chue
62cbdcea05 Allow getDisplayMedia capture HDR monitor.
The code uses IDXGIOutput1::DuplicateOutput for screen capture and
it allows only DXGI_FORMAT_B8G8R8A8_UNORM texture format, which
works on most monitor cases except HDR monitor.

HDR mointor returns type of DXGI_FORMAT_R16G16B16A16_FLOAT.

These two types of DXGI_FORMAT_B8G8R8A8_UNORM and
DXGI_FORMAT_R16G16B16A16_FLOAT are all formats that DuplicateOutput
returns based on Windows OS team.

The fix is to add allowed format of DXGI_FORMAT_R16G16B16A16_FLOAT.

Manually repro the issue and validated the fix.

Bug: chromium:40787684
Change-Id: I0a7be38b14a06261d631d2db172f12725edbbf1f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339621
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#41749}
2024-02-15 23:15:31 +00:00
Johannes Kron
fb99c6ebb5 Disable the use of CGDisplayStreamCreate() for desktop capture on Sonoma
CGDisplayStreamCreate is an deprecated API. It was believed that the use
of it was disabled on Sonoma through the setting allow_iosurface = false
[1], which causes the thumbnails to be created by the API CGDisplayCreateImage.
This API is not marked as deprecated at the moment.

However, although the thumbnails are created through CGDisplayCreateImage,
CGDisplayStreamCreate() is still called and runs in the background.
This makes the capture chip appear.

No capture chip appears if this CL is landed and the ScreenCaptureKit
thumbnail capturer is enabled,
--enable-features="ScreenCaptureKitMac,ScreenCaptureKitStreamPickerSonoma,ThumbnailCapturerMac:capture_mode/sc_screenshot_manager"

[1] https://chromium-review.googlesource.com/c/chromium/src/+/4892397

Bug: chromium:1486851
Change-Id: I3422efffc57dcb3e8965f19a5eca7f2a95d62da1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334721
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41563}
2024-01-18 15:56:40 +00:00
Jeremy Leconte
634cb403e6 Revert "Fix 'Image will be cropped if WindowCapturerWinGdi used'"
This reverts commit 844225a76a.

Reason for revert: potential nullptr dereference

Original change's description:
> Fix 'Image will be cropped if WindowCapturerWinGdi used'
>
> Bug: webrtc:15719
> Change-Id: I7daf8ee5b90fbe9f1246f1d99211ffa0d8a19f73
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330780
> Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> Commit-Queue: Alexander Cooper <alcooper@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#41503}

Bug: webrtc:15719
Change-Id: Ib38e1345c4c590b6a71bbea476a9d780a2f5e800
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334200
Owners-Override: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Reviewed-by: Manashi Sarkar <manashi@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#41509}
2024-01-12 10:16:26 +00:00
memetao
844225a76a Fix 'Image will be cropped if WindowCapturerWinGdi used'
Bug: webrtc:15719
Change-Id: I7daf8ee5b90fbe9f1246f1d99211ffa0d8a19f73
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330780
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#41503}
2024-01-10 19:52:44 +00:00
henrika
4be5927dc7 Reduces rate at which TryGetNextFrame returns NULL for WGC
This CL is a follow-up of work done in
https://webrtc-review.googlesource.com/c/src/+/323882 where the goal
was to reduce the amount of FrameDropped error logs in
WebRTC.DesktopCapture.Win.WgcCaptureSessionGetFrameResult.

The previous work avoids FrameDropped logs for a minimized window
being captured with WGC but we still se a large amount of these error
(or rather warning) logs. See [1] which comes from Canary.

This CL does two different things to improve the situation:

1) It adds kFramePoolEmpty to the existing
GetFrameResult::kFrameDropped enum to point out that the warning
comes from the frame pool not being able to return a valid new frame.
It also makes it more clear that it does not cause an outer/final
error as WgcCapturerResult::kFrameDropped. We still keep the inner
GetFrameResult::kFrameDropped but it is only produced when the frame
pool returns NULL and our external queue is empty. Hence, a real
frame-drop error. Note that, it is still easy to provoke
kFramePoolEmpty simply by asking for a high resolution at a high rate.
The example in [2] comes from a 4K screen @30fps. Hence, we have not
fixed anything yet.

2) It also increases the size of the internal frame pool from 1 to 2.
This does lead to an almost zero rate of kFramePoolEmpt
warnings at the expense of a slightly reduced max capture rate. BUT,
with 1 as size, we can "see" a higher max capture rate but it is not
a true rate since it comes with a high rate of kFramePoolEmpty
errors. Hence, we "emulate" a high capture rate by simply feeding
copies of the last frame that we had stored in the external queue.
Using 2 leads to a more "true" rate of what we actually can capture
in terms of *new* frames and also a substantially lower rate of
kFramePoolEmpty.
In addition, with 1 as size, if we ask at a too high rate and provide
a copy of the last frame, our CPU adaptation will not reduce its rate
since we think that things are OK when it is actually not.

Also, the samples in [3] and [4] both use 2 as numberOfBuffers
as well.

Let me also mention that with this small change, I a have not been
able to provoke any kFramePoolEmpty error messages.

Finally, geDisplayMedia can be called called with constraints where
min and max framerate is defined. The mechanism which maintains the
min rate is implemented via the RequestRefreshFrame API and it can
be sent to the source (DesktopCaptureDevice) back to back with a
previous timer interrupt for a capture request. Without this change,
these RRFs were also a source of a large amount of
kFramePoolEmpty error logs. With 2 buffers instead; this is no
longer the case.

[1] https://screenshot.googleplex.com/7sfv6HdGXLwyxdj
[2] https://paste.googleplex.com/4795680001359872
[3] https://github.com/robmikh/Win32CaptureSample/blob/master/Win32CaptureSample/SimpleCapture.cpp
[4] https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/screen-capture#add-the-screen-capture-capability

Bug: chromium:1314868
Change-Id: I73b823b31a993fd2cd6e007b212826dfe1a80012
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325521
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#41079}
2023-11-03 18:05:17 +00:00
Harald Alvestrand
23cecc1d43 Move scoped_refptr from rtc:: to webrtc::
leaving a compatible alias.

Bug: webrtc:15622
Change-Id: Ie25d87fa372cc71eaf52882454f4dd24c7c33789
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325462
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41072}
2023-11-03 07:36:07 +00:00
henrika
992d708e8e Improves comments for ShouldBeCapturable
Bug: webrtc:1314868
Change-Id: Ia743d17d61d7d8ffc44030b5691efef1c7ed7991
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/324305
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40994}
2023-10-23 17:07:49 +00:00
henrika
2bf3620e13 Avoids spamming WebRTC.DesktopCapture.Win.WgcCaptureSessionGetFrameResult with FrameDropped
Without this change a FrameDropped sample will be added to
WebRTC.DesktopCapture.Win.WgcCaptureSessionGetFrameResult at the
current capture rate as long as a captured window is minimized.

Bug: webrtc:1314868
Change-Id: I9b68675486642e7ca25674df689c207ac94a206e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323882
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40969}
2023-10-18 17:29:04 +00:00
henrika
5f78ed6eaf Minor change in comment for use of an IGraphicsCaptureSession3 API
Makes it more clear that a certain API is only supported in Windows 11.

Bug: webrtc:15451
Change-Id: Ic3abfb2cbf0e30f9cb722ac843876f41279bf200
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323161
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40931}
2023-10-14 15:20:11 +00:00
Jan Grulich
01932ebaec PipeWire capturer: make restore tokens re-usable more than one time
Do not automatically remove all tokens once we attempt to use them. This
mitigates an issue with Google Meet where an additional instance of a
DesktopCapturer is created and destroyed right away, taking away the
token we would use otherwise. Also save the token under same SourceId
once we get a new (but could be same) token from the restored session.

Bug: webrtc:15544
Change-Id: I565b22f5bf6a4d8a3b7d6d757f9c1046c7a0557d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/322621
Commit-Queue: Jan Grulich <grulja@gmail.com>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40892}
2023-10-09 19:08:41 +00:00
Johannes Kron
bbf27e0081 Remove NSApplicationActivateIgnoringOtherApps
NSApplicationActivateIgnoringOtherApps is about to be deprecated.
The default behavior is good enough.

Tested on Chrome using https://wicg.github.io/conditional-focus/demo/

Bug: webrtc:15511
Change-Id: I1f59aea3d4e7c4942d17ee5c4f1b6c2d398016ee
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/321080
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Auto-Submit: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40795}
2023-09-24 13:55:12 +00:00
Avi Drissman
46da472f82 Revert "mac: Work around an inccorect availability annotation in the 13.3 SDK"
This reverts commit 0f87b38535.

This is not needed with the macOS 14 SDK, which has the fix, and which
was landed in https://crrev.com/c/4875713.

Bug: chromium:1484363, chromium:1431897
Change-Id: I1e019ce71b90333d5d1333a3cf8bb510a3dbd212
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/320820
Reviewed-by: Tomas Gunnarsson <tommi@google.com>
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40777}
2023-09-20 12:50:43 +00:00
henrika
66b7275561 Disables yellow frame of captured object for WGC.
Only has an effect on Windows versions higher than 2104 (10.0.20348.0).

Bug: webrtc:15451
Change-Id: I3ca48c88a6c2b9b87d43805fcb2ade444cd90480
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318060
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40721}
2023-09-08 10:07:18 +00:00
Johannes Kron
0e4a9bcd6d Export GetWindowList(...)
These two functions contain complicated logic that will be used as
a fallback in Chromium if the new macOS picker code does not work
as intended.

Bug: chromium:1478172
Change-Id: I5f2878c5a8da38d59aa42ec1358398e3c921b65c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/319260
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40711}
2023-09-06 21:31:45 +00:00
Johannes Kron
d23d450a50 Make DesktopFrame::CreateFromCGImage() accessible for external targets
The build target that CreateFromCGImage() belongs to, desktop_capture_obj
is not visible externally. A utility header is created to make it accessible.

Bug: chromium:1471931
Change-Id: Ie40f39114d277dc4b62fe2ce95a6b0c7b61a3943
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318123
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Johannes Kron <kron@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40659}
2023-08-30 08:09:46 +00:00
Johannes Kron
e5af52e1f2 Make DesktopFrameCGImage::CreateFromCGImage() public
CreateFromCGImage() is needed to be called directly when we move away
from using the deprecated API that is used in CreateForWindow().

Bug: chromium:1471931
Change-Id: I28a2972a2a995103829fd9aff4bc1137a8b424b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/315324
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40563}
2023-08-18 01:12:17 +00:00
Caroline Liu
0689cfc6ce Reland "[fuchsia] remove Scenic/UseFlatland dependency in DesktopCapturer"
This reverts commit 726992d7a4.

Reason for revert: Relanding with original errors fixed (tested by building the patch locally against Chromium)

This change no longer attempts to migrate the display size protocol from fuchsia.ui.scenic.Scenic/GetDisplayInfo to fuchsia.ui.display.singleton.Info/GetMetrics because the latter API was introduced in Fuchsia API 12, which is not yet supported in Chrome (hence some of the build errors causing the revert).

Original change's description:
> Revert "[fuchsia] remove Scenic and GFX  dependencies in DesktopCapturer"
>
> This reverts commit fe5be2eb4f.
>
> Reason for revert: This breaks the WebRTC roll into Chromium:
>
> - https://chromium-review.googlesource.com/c/chromium/src/+/4688561
> - https://ci.chromium.org/ui/p/chromium/builders/try/fuchsia-binary-size/399140/overview
>
> Error:
>
> [4273/4389] CXX obj/third_party/webrtc/modules/desktop_capture/desktop_capture/screen_capturer_fuchsia.o
> FAILED: obj/third_party/webrtc/modules/desktop_capture/desktop_capture/screen_capturer_fuchsia.o
> ../../buildtools/reclient/rewrapper -cfg=../../buildtools/reclient_cfgs/chromium-browser-clang/rewra...(too long)
> ../../third_party/webrtc/modules/desktop_capture/screen_capturer_fuchsia.cc:59:10: error: use of undeclared identifier 'capturer'
> 59 |   return capturer(new ScreenCapturerFuchsia());
> |          ^
> ../../third_party/webrtc/modules/desktop_capture/screen_capturer_fuchsia.cc:199:36: error: no type named 'InfoSyncPtr' in namespace 'fuchsia::ui::display::singleton'
>
> Original change's description:
> > [fuchsia] remove Scenic and GFX  dependencies in DesktopCapturer
> >
> > We previously used:
> > - fuchsia.ui.scenic.Scenic/UsesFlatland to determine whether to use
> >   Flatland; from now on it should always be the case, so this check is
> >   no longer necessary.
> > - fuchsia.ui.scenic.Scenic/GetDisplayInfo to get
> >   fuchsia.ui.gfx.DisplayInfo. This has been migrated to
> >   fuchsia.ui.display.singleton.Info/GetMetrics and
> >   fuchsia.ui.display.singleton.Metrics.
> >
> > Bug: fuchsia:100303
> > Change-Id: I147da9ffdf0ca49e1c5bde5d188e434fc660becc
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311860
> > Reviewed-by: Emircan Uysaler <emircan@google.com>
> > Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> > Commit-Queue: Caroline Liu <carolineliu@google.com>
> > Cr-Commit-Position: refs/heads/main@{#40432}
>
> Bug: fuchsia:100303, b/291393959
> Change-Id: Iae70e568a8c9819e40e48069af8cea0d4ef2b6c5
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311801
> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#40436}

Bug: fuchsia:100303, b/291393959
Change-Id: Icb7074ac86c1804ab2bdf809ea1496539ee2bf80
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/312000
Commit-Queue: Caroline Liu <carolineliu@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40452}
2023-07-21 16:47:17 +00:00
Mirko Bonadei
726992d7a4 Revert "[fuchsia] remove Scenic and GFX dependencies in DesktopCapturer"
This reverts commit fe5be2eb4f.

Reason for revert: This breaks the WebRTC roll into Chromium:

- https://chromium-review.googlesource.com/c/chromium/src/+/4688561
- https://ci.chromium.org/ui/p/chromium/builders/try/fuchsia-binary-size/399140/overview

Error:

[4273/4389] CXX obj/third_party/webrtc/modules/desktop_capture/desktop_capture/screen_capturer_fuchsia.o
FAILED: obj/third_party/webrtc/modules/desktop_capture/desktop_capture/screen_capturer_fuchsia.o
../../buildtools/reclient/rewrapper -cfg=../../buildtools/reclient_cfgs/chromium-browser-clang/rewra...(too long)
../../third_party/webrtc/modules/desktop_capture/screen_capturer_fuchsia.cc:59:10: error: use of undeclared identifier 'capturer'
59 |   return capturer(new ScreenCapturerFuchsia());
|          ^
../../third_party/webrtc/modules/desktop_capture/screen_capturer_fuchsia.cc:199:36: error: no type named 'InfoSyncPtr' in namespace 'fuchsia::ui::display::singleton'

Original change's description:
> [fuchsia] remove Scenic and GFX  dependencies in DesktopCapturer
>
> We previously used:
> - fuchsia.ui.scenic.Scenic/UsesFlatland to determine whether to use
>   Flatland; from now on it should always be the case, so this check is
>   no longer necessary.
> - fuchsia.ui.scenic.Scenic/GetDisplayInfo to get
>   fuchsia.ui.gfx.DisplayInfo. This has been migrated to
>   fuchsia.ui.display.singleton.Info/GetMetrics and
>   fuchsia.ui.display.singleton.Metrics.
>
> Bug: fuchsia:100303
> Change-Id: I147da9ffdf0ca49e1c5bde5d188e434fc660becc
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311860
> Reviewed-by: Emircan Uysaler <emircan@google.com>
> Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> Commit-Queue: Caroline Liu <carolineliu@google.com>
> Cr-Commit-Position: refs/heads/main@{#40432}

Bug: fuchsia:100303, b/291393959
Change-Id: Iae70e568a8c9819e40e48069af8cea0d4ef2b6c5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311801
Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40436}
2023-07-17 08:12:48 +00:00
Caroline Liu
fe5be2eb4f [fuchsia] remove Scenic and GFX dependencies in DesktopCapturer
We previously used:
- fuchsia.ui.scenic.Scenic/UsesFlatland to determine whether to use
  Flatland; from now on it should always be the case, so this check is
  no longer necessary.
- fuchsia.ui.scenic.Scenic/GetDisplayInfo to get
  fuchsia.ui.gfx.DisplayInfo. This has been migrated to
  fuchsia.ui.display.singleton.Info/GetMetrics and
  fuchsia.ui.display.singleton.Metrics.

Bug: fuchsia:100303
Change-Id: I147da9ffdf0ca49e1c5bde5d188e434fc660becc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311860
Reviewed-by: Emircan Uysaler <emircan@google.com>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Caroline Liu <carolineliu@google.com>
Cr-Commit-Position: refs/heads/main@{#40432}
2023-07-14 21:05:29 +00:00
Jan Grulich
0e9556a90c Desktop capture: introduce capturer requesting both screen and windows
When PipeWire and xdg-desktop-portals are used, we can actually combine
both source types into one request. Make this part of the API for those
who want to use it this way, e.g. Firefox or Electron, otherwise they
will end up making two simultaneous requests, resulting into two dialogs
at the same time asking, while they can be combined into just one.

Bug: webrtc:15363
Change-Id: Ib6e1e47f66cb01d5c65096aec378b44c3af5f387
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311549
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#40425}
2023-07-12 18:59:24 +00:00
Jan Grulich
8fcc6df79d PipeWire capturer: increase buffer size to avoid buffer overflow
Recently added framerate option can cause a buffer overflow and make
PipeWire to fail on negotiation, which effectively makes screen sharing
not to work.

Bug: webrtc:15346
Change-Id: I4a68e26c8f85ca287b06a25da500b6a7009e075f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311541
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#40413}
2023-07-10 17:32:30 +00:00
henrika
58e97b8600 Removes AllowWgcDesktopCapturer feature flag
This flag is no longer used in Chrome and can now be removed.

Bug: chromium:1314868
Change-Id: Id91b3352dc7ec0543d54894cc206a6e0c7667e9e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309960
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40337}
2023-06-22 16:07:51 +00:00
henrika
c3a74024bf Splits AllowWgcDesktopCapturer into AllowWgc[Window/Screen]Capturer flags
This CL allows the users to now enable/disable WGC capturing support
for Window and Screen sharing independently.

Bug: chromium:1314868
Change-Id: Ieeb15539434dac2caf29c515aa7c5dbb7abcc5df
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309560
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40330}
2023-06-21 19:25:23 +00:00
henrika
bb917acb10 Fixes crash in WgcCaptureSession::ProcessFrame
This change fixes a minor issue where we previosuly assumed that the
following was true:

RTC_DCHECK_EQ(map_info.RowPitch, current_frame->stride())

It turns out that this is not always the case when sharing a window
where the stride can sometimes be a few bytes smaller than the
rowpitch.

The code is behind a command-line flag and no tests are affected.
Given limited review resources I therefore plan to bypass the CQ.
I know that it is not recommended but the change has been tested
locally on two different Windows platforms and it does avoid an
existing crash.

Code-Review: alcooper@chromium.org
No-Try: true
Bug: chromium:1421242
Change-Id: I01e7105a6f9fca7ce1349a57635dd373c28d160b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309342
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40308}
2023-06-19 14:39:39 +00:00
henrika
6c453b7d59 Light-weight detection of static content when using WGC
This CL adds a light-weight detection of "frame content has changed
since last frame" to an existing pass where bytes are copied from a
texture to a DesktopFrame. The resulting boolean can then later be
used to bypass a full detection of if the content is static or not.
As a result, we only check for static content for a small fraction of
all captured WGC frames and this reduces the total load when 0Hz
is enabled for WGC.

Both WGC and 0Hz support for WGC is still behind a flag.

Bug: chromium:1421242
Change-Id: If9e3721c60a244a3919758fe861d56d4b54cb039
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/308821
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40299}
2023-06-16 11:00:34 +00:00
Jan Grulich
9caef2a8b8 Use a constant for invalid PipeWire file descriptor
We use value -1 on over all the places through our code so it might be
better to define a constant and use it instead to make the code more
understandable on first look.

Bug: webrtc:15203
Change-Id: I4fc3e561bc7a7778c43ec6cfde7acebef2af79e8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/306620
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40156}
2023-05-26 11:38:49 +00:00
henrika
2264e7aacc Fixes distortion in WGC screen capture path
This is a partial revert of the previously landed CL in
https://webrtc-review.googlesource.com/c/src/+/301200.

I noticed when I used `getDisplayMedia` on my private Windows laptop
in combination with WGC that the captured screen was distorted and
did only contain tilted (~35 degrees) lines in all sorts of colors.

The issue only happened for one particular screen resolution
3000 x 2000 and 200% scale. Changing to 100% scale instead resolved
the issue.

I tried many other resolutions but could only trigger for the one
above with 200% scaling.

Next, I bisected and found [1] which led to [2] which contains my own
change in https://webrtc-review.googlesource.com/c/src/+/301200.

The only part that could affect the video frame was the part which
did `CopyPixelsFrom` so I reverted that part and it solved the issue
on my private Windows laptop.

I did not dig deeper into why this particular resolution triggered
the distortion but deiced to revert to avoid more reports.

[1] b4c2a7fcf5..ff848b7a43

[2] a9a2957dbc

Bug: chromium:1428592
Change-Id: I328e77840cd3ca6871254cdf06500bdc616b0c36
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/306600
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40147}
2023-05-25 16:46:47 +00:00
Alexander Cooper
a7d10811cd Revert "pipewire capturer: Reduce the amount of copying"
This reverts commit 8856410b6d.

Reason for revert: chromium:1447540

Original change's description:
> pipewire capturer: Reduce the amount of copying
>
> Improves the capture latency by reducing the amount of
> copying needed from the frame. We keep track of the
> damaged region of previous frame and union it with
> the damaged region of this frame and only copy this
> union of the frame over. X11 capturer already has
> such synchronization in place.
>
> The change is beneficial especially when there are
> small changes on the screen (e.g. clock ticking).
> For a 4k screen with 128 cores, I observed the
> capture latencies drop from 5 - 8 ms to 0 ms when the
> system is left idle. This is in line with the X11
> capturer.
>
> Bug: chromium:1291247
> Change-Id: Iffb441f9e1902d2658031f5f35b5372ee8e94073
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299720
> Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> Commit-Queue: Salman Malik <salmanmalik@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#39968}

Bug: chromium:1291247
Change-Id: Id1bfd3fc39fea2bb1f232cad5218f90e144920e7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/306263
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#40123}
2023-05-23 17:58:08 +00:00
Jan Grulich
7b0d7f48fb PipeWire capturer: fix fcntl call when duplicating a file descriptor
The fcntl() call has variable arguments, therefore we need to pass 0 to
specify there are no other arguments for this call, otherwise we might
end up with an argument that is random garbage.

Bug: webrtc:15174
Change-Id: I34f16a942d80913b667d8ade7eed557b0233be01
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305120
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#40060}
2023-05-12 20:39:07 +00:00
henrika
2d7424305d Adds debug logs which warns about cursor flickering
Main issue is https://chromium-review.googlesource.com/c/chromium/src/+/4507078

Bug: chromium:1421656
Change-Id: I61c6df59176e10bc29356ea924a4e483270db75f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304284
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40038}
2023-05-10 09:06:19 +00:00
Salman Malik
8856410b6d pipewire capturer: Reduce the amount of copying
Improves the capture latency by reducing the amount of
copying needed from the frame. We keep track of the
damaged region of previous frame and union it with
the damaged region of this frame and only copy this
union of the frame over. X11 capturer already has
such synchronization in place.

The change is beneficial especially when there are
small changes on the screen (e.g. clock ticking).
For a 4k screen with 128 cores, I observed the
capture latencies drop from 5 - 8 ms to 0 ms when the
system is left idle. This is in line with the X11
capturer.

Bug: chromium:1291247
Change-Id: Iffb441f9e1902d2658031f5f35b5372ee8e94073
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299720
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Salman Malik <salmanmalik@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39968}
2023-04-28 16:07:00 +00:00
Jared Siskin
c018bae807 Format /modules
git ls-files | grep -e  "\(\.h\|\.cc\)$" | grep -e  "^modules/" | xargs clang-format -i ; git cl format
after landing: add to .git-blame-ignore-revs

Bug: webrtc:15082
Change-Id: I2c3cd28740062794f8c10e39d8406aadb9e9a35a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301620
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Jared Siskin <jtsiskin@meta.com>
Cr-Commit-Position: refs/heads/main@{#39901}
2023-04-20 02:02:45 +00:00
henrika
56e830819f Removes usage of FrameArrived event for WGC - part 2
Minor changes adding a final touch to
https://webrtc-review.googlesource.com/c/src/+/301200

Bug: chromium:1428592
Change-Id: I6271b01f2c63645db080897f19fbdb343ae499b8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301520
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39882}
2023-04-18 08:05:42 +00:00
henrika
58e8cb0553 Removes usage of FrameArrived event for WGC
* Removes a ~60Hz thread-wakeup signal caused by the FrameArrived event
* Initial power measurements shows a reduced power consumption
* No increase in time to first captured packet found

Bug: chromium:1428592
Change-Id: Ia23b5db0c87e70e5b0d6919394494a24d8944493
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301200
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39861}
2023-04-14 11:44:12 +00:00
henrika
b9313b9584 Removes usage of the Magnifier API on Windows
This CL removes the usage of the Magnifier screen capture API on
Windows. The idea is to remove the actual source in a second step
once this change lands.

Bug: chromium:1428341
Change-Id: Id2cb25632c7edbea2cf527959b14b27ee00b0e56
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301164
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39856}
2023-04-13 20:27:24 +00:00
henrika
e02d50931b Adds temporary verbose logging to track cursor flickering (WebRTC)
The idea is to land this in Canary and ask for feedback from users
who can reproduce the issue, solve the issue and then revert this CL.

Example: https://paste.googleplex.com/6080504230051840

Bug: chromium:1421656
Change-Id: Ic214dc341a322470970abeca1794493f45b93843
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301080
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39834}
2023-04-12 22:47:33 +00:00
Nico Weber
0f87b38535 mac: Work around an inccorect availability annotation in the 13.3 SDK
Bug: chromium:1431897
Change-Id: Ib871dc22d2cf93180d7aa05016e34ffec944d73e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301040
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39830}
2023-04-12 16:56:22 +00:00
henrika
d549e4b6ce DXGI now consumes may_contain_cursor
Before:

No attempt was made to figure out of the cursor was embedded into the
captured video frame when using DXGI on Windows as screen capturer.
Instead the cursor is superimposed on the frame by an external mouse
and cursor composer.

After:

We now check if the display adapter supports embedding the mouse
cursor and if so use it as is and thereby avoid adding it independently.

Bug: chromium:1421656
Change-Id: Ie07fe13e1c8f9583769961328bb41fbc689cd8e0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299241
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39742}
2023-04-03 08:30:59 +00:00
henrika
9204210718 Clarifies selection of screen capture API on Windows
This change makes it more clear that there are three different
capture API combinations for screen sharing on Windows.

No option => GDI without fallback.

DirectX option => DirectX with GDI as fallback

Magnifier option => Magnifier API with GDI as fallback

Previously, if both DirectX and Magnifier were enabled, the end
result was Magnifier for unknown reasons.

With this change in place, we can remove usage of the Magnifier API
in Chrome and switch  between DirectX and GDI simply by allowing
DirectX or not.

Bug: None
Change-Id: Ice915d6721fa84a25d275f22246df73fc61f64b5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299061
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39692}
2023-03-27 20:22:33 +00:00
Jan Grulich
4bfc4ac4b0 PipeWire capturer: drop old DmaBuf support
Drop support for old compositors that don't use DmaBufs the way they are
supposed to be used now. There is now a whole negotiation process that
includes DmaBuf modifiers and there is also support for renegotiation in
case we fail to import DmaBufs with certain modifier. This is something
that didn't exist before and in such case, failing to import DmaBufs we
would just end up with broken screen sharing. For that reason it would
be better to use MemFD instead to make sure old compositors will work
just fine

Bug: webrtc:15029
Change-Id: Icc303504e510adc829c12feff7178ae01578a6da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/298700
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#39649}
2023-03-23 07:01:20 +00:00
henrika
6bdb285e21 Adds WebRTC.DesktopCapture.Win.DirectXCursorEmbedded UMA
Logs if the mouse cursor has moved and if so if it is embedded in the
captured DXGI frame or not.

Bug: chromium:1421656
Change-Id: Ic8fa8a5a3c020ec28b04064c765b1c204accec1c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/298564
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39644}
2023-03-22 17:19:06 +00:00
Jan Grulich
d9faa73cbb PipeWire capturer: import DMABufs directly into desktop frame
Originally DMABufs were imported into a temporary buffer followed by a
copy operation into the desktop frame itself. This is not needed as we
can import them directly into desktop frames and avoid this overhead.

Also drop support for MemPtr buffers as both Mutter and KWin don't seem
to support them and they are going to be too slow anyway.

Testing with latest Chromium, I could see two processes with usage around 20% and 40% without this change going down to 10% and 20% with
this change applied.

Bug: webrtc:13429
Bug: chrome:1378258
Change-Id: Ice3292528ff56300931c8638f8e03d4883d5e331
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/297501
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#39594}
2023-03-17 17:31:55 +00:00
Salman Malik
db9be7f194 x_server_pixel_buffer: Use CopyPixelsFrom instead of memcpy
`CopyPixelsFrom` uses libyuv underneath and has handrolled
implementation for copying with AVX.

Bug: chromium:1424776
Change-Id: I4fafeba97fcc1d2200a10070837672175a1dfc50
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/297800
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Auto-Submit: Salman Malik <salmanmalik@chromium.org>
Cr-Commit-Position: refs/heads/main@{#39567}
2023-03-15 17:15:54 +00:00