I have verified this change on my laptop, which cannot reproduce the issue anymore.
BUG=704205
Review-Url: https://codereview.webrtc.org/2781253002
Cr-Commit-Position: refs/heads/master@{#17494}
Once the first capture attempt failed, we should keep the
context->updated_region unchanged for next attempt. This change can (partially?)
fix issue 704205.
BUG=704205
Review-Url: https://codereview.webrtc.org/2780093002
Cr-Commit-Position: refs/heads/master@{#17456}
When screen/window capturers fail to use shared memory, they are
supposed to fall back to XGetImage(). It's slower, but should still
allow to capture desktop content. This wasn't implemented correclty in
XScreenPixelBuffer - it was failing completely when shmget() returns an
error.
BUG=705146
Review-Url: https://codereview.webrtc.org/2775793003
Cr-Commit-Position: refs/heads/master@{#17401}
constexpr function should be preferred than a macro. So this change replaces
FOURCC() macro with a constexpr uint32_t FourCC() function.
BUG=679523, 650926
Review-Url: https://codereview.webrtc.org/2771573002
Cr-Commit-Position: refs/heads/master@{#17351}
This change adds a DesktopCapturerId namespace, and attaches an int to each
DesktopFrame. ScreenCapturerWinGdi and ScreenCapturerWinDirectx now actively set
this field to differentiate themselves.
BUG=679523, 650926
Review-Url: https://codereview.webrtc.org/2759493002
Cr-Original-Commit-Position: refs/heads/master@{#17329}
Committed: 41e3d9ff3b
Review-Url: https://codereview.webrtc.org/2759493002
Cr-Commit-Position: refs/heads/master@{#17347}
Reason for revert:
I suspect that this CL breaks Chromium WebRTC FYI bots. (Thanks kjellander@ for spotting.) The added dep in BUILD.gn would be the problem.
Example:
https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.webrtc.fyi%2FLinux_Builder%2F15058%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout
FAILED: newlib_pnacl/obj/third_party/webrtc/api/libjingle_peerconnection_api/mediaconstraintsinterface.o
/b/c/goma_client/gomacc ../../native_client/toolchain/linux_x86/pnacl_newlib/bin/pnacl-clang++ -MMD -MF newlib_pnacl/obj/third_party/webrtc/api/libjingle_peerconnection_api/mediaconstraintsinterface.o.d -DNACL_TC_REV=5dfe030a71ca66e72c5719ef5034c2ed24706c43 -DV8_DEPRECATION_WARNINGS -DUSE_OPENSSL_CERTS=1 -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DENABLE_MEDIA_ROUTER=1 -DFIELDTRIAL_TESTING_ENABLED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DNDEBUG -DNVALGRIND -DWEBRTC_RESTRICT_LOGGING -DEXPAT_RELATIVE_PATH -DHAVE_SCTP -DENABLE_EXTERNAL_AUTH -DHAVE_WEBRTC_VIDEO -DHAVE_WEBRTC_VOICE -DLOGGING_INSIDE_WEBRTC -DUSE_WEBRTC_DEV_BRANCH -DFEATURE_ENABLE_VOICEMAIL -DEXPAT_RELATIVE_PATH -DGTEST_RELATIVE_PATH -DNO_MAIN_THREAD_WRAPPING -DNO_SOUND_SYSTEM -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -I../.. -Inewlib_pnacl/gen -I../../third_party/webrtc_overrides -I../../third_party -fno-strict-aliasing -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-deprecated-register -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -O2 -fno-ident -fdata-sections -ffunction-sections -g0 -fvisibility=hidden -fvisibility-inlines-hidden -std=gnu++11 -fno-rtti -fno-exceptions -c ../../third_party/webrtc/api/mediaconstraintsinterface.cc -o newlib_pnacl/obj/third_party/webrtc/api/libjingle_peerconnection_api/mediaconstraintsinterface.o
In file included from ../../third_party/webrtc/api/mediaconstraintsinterface.cc:11:
In file included from ../../third_party/webrtc/api/mediaconstraintsinterface.h:27:
In file included from ../../third_party/webrtc/api/peerconnectioninterface.h:77:
In file included from ../../third_party/webrtc/api/dtmfsenderinterface.h:16:
In file included from ../../third_party/webrtc/api/mediastreaminterface.h:33:
In file included from ../../third_party/webrtc/media/base/mediachannel.h:28:
../../third_party/webrtc/base/socket.h:18:10: fatal error: 'sys/socket.h' file not found
#include <sys/socket.h>
^
1 error generated.
Original issue's description:
> Add DesktopCapturerId and attach it to DesktopFrame
>
> This change adds a DesktopCapturerId namespace, and attaches an int to each
> DesktopFrame. ScreenCapturerWinGdi and ScreenCapturerWinDirectx now actively set
> this field to differentiate themselves.
>
> BUG=679523, 650926
>
> Review-Url: https://codereview.webrtc.org/2759493002
> Cr-Commit-Position: refs/heads/master@{#17329}
> Committed: 41e3d9ff3bTBR=sergeyu@chromium.org,zijiehe@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=679523, 650926
Review-Url: https://codereview.webrtc.org/2767003002
Cr-Commit-Position: refs/heads/master@{#17336}
This change adds a DesktopCapturerId namespace, and attaches an int to each
DesktopFrame. ScreenCapturerWinGdi and ScreenCapturerWinDirectx now actively set
this field to differentiate themselves.
BUG=679523, 650926
Review-Url: https://codereview.webrtc.org/2759493002
Cr-Commit-Position: refs/heads/master@{#17329}
CreateRawScreenCapturer() and CreateRawWindowCapturer() in
DesktopCapturer are allowed to return nullptr when capturer cannot be
initialized for some reason. CreateWindowCapturer() and
CreateScreenCapturer() in DesktopCapturer were not handling this case
correctly, which may lead to crash.
BUG=chromium:702745
Review-Url: https://codereview.webrtc.org/2754403002
Cr-Commit-Position: refs/heads/master@{#17298}
I cannot even imagine this change is useful. But it consistently reduces average
capture time by 0.375% (4.07 -> 4.055), and average encode time by 0.313%
(8.042 -> 8.016) without other impacts. Considering this is a one-line change,
it's worthy to be added.
BUG=679523
Review-Url: https://codereview.webrtc.org/2743233002
Cr-Commit-Position: refs/heads/master@{#17235}
Previously we grab a run loop source and add a source with mode
kCFRunLoopDefaultMode. With this mode, it won't callback when context menu popup
(which needs the NSEventTrackingRunLoopMode), then screen capture can't get
refreshed frame with context menu until the context menu is gone.
The fix is to use kCFRunLoopComonModes, which includes default,modal and event
tracking modes by default.
BUG=chromium:697780
Review-Url: https://codereview.webrtc.org/2732393003
Cr-Commit-Position: refs/heads/master@{#17171}
DisplayStream refresh rects are in display coordinates. When the whole screen is
being captured, the coordinates passed to the ScreenCapturerHelper need to be in
screen coordinates. This CL translates display coordinates to screen
coordinates for whole screen capture.
BUG=chromium:699672
Review-Url: https://codereview.webrtc.org/2740823002
Cr-Commit-Position: refs/heads/master@{#17153}
Previusly errors from XServerPixelBuffer::CaptureRect() were not always
handled, which results in a black frame returned from the capturer
instead of an error.
BUG=webrtc:7305
Review-Url: https://codereview.webrtc.org/2738513005
Cr-Commit-Position: refs/heads/master@{#17101}
DXGI capturer highly depends on video adapter and its driver, as well as Windows
itself. I recently found it cannot work on my virtualbox instance any more,
which indicates it may not work well on some specific systems. What worse is,
the APIs do not return a failure in such case.
So this change adds a BlankDetectorDesktopCapturerWrapper, which samples several
pixels in the frame returned by a DesktopCapturer implementation. If all the
pixels selected are blank, this wrapper returns a failure. A typical usage is to
combine BlankDetectorDesktopCapturerWrapper with FallbackDesktopCapturerWrapper,
and use GDI capturer in case of failure.
Usually less than 10000 pixels are checked, so the
BlankDetectorDesktopCapturerWrapper should not significant impact the capturer
performance.
This change is expected to resolve bug 682112 in another dimension.
BUG=682112
Review-Url: https://codereview.webrtc.org/2709523003
Cr-Original-Commit-Position: refs/heads/master@{#16984}
Committed: c4e9d210b3
Review-Url: https://codereview.webrtc.org/2709523003
Cr-Commit-Position: refs/heads/master@{#17024}
Reason for revert:
Misses deps for RTC_HISTOGRAM in Chrome.
email sent separately.
Also see https://codereview.chromium.org/2725143004/.
Original issue's description:
> BlankDetectorDesktopCapturerWrapper to detect a blank DesktopFrame
>
> DXGI capturer highly depends on video adapter and its driver, as well as Windows
> itself. I recently found it cannot work on my virtualbox instance any more,
> which indicates it may not work well on some specific systems. What worse is,
> the APIs do not return a failure in such case.
>
> So this change adds a BlankDetectorDesktopCapturerWrapper, which samples several
> pixels in the frame returned by a DesktopCapturer implementation. If all the
> pixels selected are blank, this wrapper returns a failure. A typical usage is to
> combine BlankDetectorDesktopCapturerWrapper with FallbackDesktopCapturerWrapper,
> and use GDI capturer in case of failure.
>
> Usually less than 500 pixels are checked, so the
> BlankDetectorDesktopCapturerWrapper should not impact the capturer performance.
>
> This change is expected to resolve bug 682112 in another dimension.
>
> BUG=682112
>
> Review-Url: https://codereview.webrtc.org/2709523003
> Cr-Commit-Position: refs/heads/master@{#16984}
> Committed: c4e9d210b3TBR=sergeyu@chromium.org,zijiehe@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=682112
Review-Url: https://codereview.webrtc.org/2726983005
Cr-Commit-Position: refs/heads/master@{#16993}
DXGI capturer highly depends on video adapter and its driver, as well as Windows
itself. I recently found it cannot work on my virtualbox instance any more,
which indicates it may not work well on some specific systems. What worse is,
the APIs do not return a failure in such case.
So this change adds a BlankDetectorDesktopCapturerWrapper, which samples several
pixels in the frame returned by a DesktopCapturer implementation. If all the
pixels selected are blank, this wrapper returns a failure. A typical usage is to
combine BlankDetectorDesktopCapturerWrapper with FallbackDesktopCapturerWrapper,
and use GDI capturer in case of failure.
Usually less than 500 pixels are checked, so the
BlankDetectorDesktopCapturerWrapper should not impact the capturer performance.
This change is expected to resolve bug 682112 in another dimension.
BUG=682112
Review-Url: https://codereview.webrtc.org/2709523003
Cr-Commit-Position: refs/heads/master@{#16984}
A bug has been reported to complaint the ScreenCapturerWinDirectx cannot capture
the first frame, which is used in "Report an issue" page.
A simple solution here is to skip the first frame.
This change also removes the friend relationship between
DxgiDuplicatorController / DxgiAdapterDuplicator / DxgiOutputDuplicator, which
is not really necessary.
BUG=682112
Review-Url: https://codereview.webrtc.org/2703123002
Cr-Commit-Position: refs/heads/master@{#16815}
This is a trivial change to remove duplicate logic, i.e. fallback capturer, from
ScreenCapturerWinMagnifier.
BUG=webrtc:7215
Review-Url: https://codereview.webrtc.org/2704943002
Cr-Commit-Position: refs/heads/master@{#16781}
Update the year in copyright headers from 2016 to 2017, and also rename a
variable in FallbackDesktopCapturerWrapperTest to follow coding style.
BUG=webrtc:7205
Review-Url: https://codereview.webrtc.org/2706193005
Cr-Commit-Position: refs/heads/master@{#16759}
FallbackDesktopCapturerWrapper is a DesktopCapturer implementation, which owns
two DesktopCapturer implementations. If the main DesktopCapturer fails, it uses
the secondary capturer. The logic is now used in ScreenCapturerWinMagnifier, and
it can also be shared in ScreenCapturerWinDirectx to fallback to Gdi capturer on
privilege prompt or login screen.
BUG=684937
Review-Url: https://codereview.webrtc.org/2697453002
Cr-Commit-Position: refs/heads/master@{#16677}
This change adds a ResolutionChangeDetector to help dxgi components, say
DxgiDuplicatorController and DxgiTexture to detect resolution changes.
BUG=684162
Review-Url: https://codereview.webrtc.org/2682913002
Cr-Commit-Position: refs/heads/master@{#16654}
The tests need "x11/shared_x_display.h" which is not included when use_x11 is false and we're on linux.
The problem is:
screen_capturer_integration_test.cc
- requires ->
screen_drawer.h
- requires ->
screen_drawer_linux.cc
- requires ->
x11/shared_x_display.h
which is not included when use_x11 is false.
BUG=None
NOTRY=True
Review-Url: https://codereview.webrtc.org/2684683003
Cr-Commit-Position: refs/heads/master@{#16529}
In order to implicit cast an lvalue to an rvalue when returning
from a function, the return type and type of variable in the return
statement previously had to be exactly the same. When this was not
the case, std::move was required. For instance, when returning a
std::unique_ptr<Derived> variable in a function with a
std::unique_ptr<Base> return type, std::move is required.
DR 1579 changed this, and allows for implicitly converting
to the return type, if the return type has a constructor(T&&), where
T is the type of the local variable being returned. DR 1579 was
implemented in GCC 5, but not in GCC 4.9 and below. By explicitly
qualifying the local variable with std::move, we allow for compiling
with GCC 4.9 and incur no performance penalty. The code is still
absolutely correct to the word of C++11.
BUG=chromium:682965
See also:
* https://bugs.gentoo.org/show_bug.cgi?id=600288
* https://stackoverflow.com/questions/22018115/converting-stdunique-ptrderived-to-stdunique-ptrbase#comment33375875_22018521
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3833.html#1579
Review-Url: https://codereview.webrtc.org/2642053003
Cr-Commit-Position: refs/heads/master@{#16175}
Bulk of changes done using
git grep -l 'RTC_DCHECK(false)' | \
xargs sed -i 's/RTC_DCHECK(false)/RTC_NOTREACHED()/'
peerconnection.cc also used RTC_DCHECK(false && "msg") in two places,
which were updated manually.
BUG=webrtc:6424
Review-Url: https://codereview.webrtc.org/2623313004
Cr-Commit-Position: refs/heads/master@{#16026}
Reason for revert:
Trying to reland this CL.
Original issue's description:
> Revert of Refactor webrtc/modules/desktop_capture for GN check (patchset #1 id:1 of https://codereview.webrtc.org/2593713002/ )
>
> Reason for revert:
> Apparently breaks Chromium compile for unknown reason:
> https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/12314
>
> Original issue's description:
> > Refactor webrtc/modules/desktop_capture for GN check
> >
> > This moves some GN check configurations out of .gn to individual
> > targets.
> >
> > The now checked target is:
> > "//webrtc/modules/desktop_capture/*"
> >
> > BUG=webrtc:6828
> > NOTRY=True
> >
> > Review-Url: https://codereview.webrtc.org/2593713002
> > Cr-Commit-Position: refs/heads/master@{#15725}
> > Committed: 70870b9211
>
> TBR=sergeyu@chromium.org,mbonadei@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6828
>
> Review-Url: https://codereview.webrtc.org/2597923002
> Cr-Commit-Position: refs/heads/master@{#15750}
> Committed: d943c48454TBR=sergeyu@chromium.org,kjellander@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:6828
Review-Url: https://codereview.webrtc.org/2609523002
Cr-Commit-Position: refs/heads/master@{#15832}
Reason for revert:
Apparently breaks Chromium compile for unknown reason:
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/12314
Original issue's description:
> Refactor webrtc/modules/desktop_capture for GN check
>
> This moves some GN check configurations out of .gn to individual
> targets.
>
> The now checked target is:
> "//webrtc/modules/desktop_capture/*"
>
> BUG=webrtc:6828
> NOTRY=True
>
> Review-Url: https://codereview.webrtc.org/2593713002
> Cr-Commit-Position: refs/heads/master@{#15725}
> Committed: 70870b9211TBR=sergeyu@chromium.org,mbonadei@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6828
Review-Url: https://codereview.webrtc.org/2597923002
Cr-Commit-Position: refs/heads/master@{#15750}
This moves some GN check configurations out of .gn to individual
targets.
The now checked target is:
"//webrtc/modules/desktop_capture/*"
BUG=webrtc:6828
NOTRY=True
Review-Url: https://codereview.webrtc.org/2593713002
Cr-Commit-Position: refs/heads/master@{#15725}
The CGDisplayStream API returns rects in physical pixel coordinates, not
Density-Independent Pixel coordinates. The code was incorrectly re-applying the
dip_to_pixel scaling.
BUG=chromium:675490
Review-Url: https://codereview.webrtc.org/2588973002
Cr-Commit-Position: refs/heads/master@{#15720}
ScreenCapturerWinGdi randomly returns black frames in test environment. The root
cause is still unknown, so change ScreenCapturerWinGdi tests into MANUAL mode to
execute in test environment, but unblock other developers. We can eventually get
a failure ratio and more samples for debugging.
BUG=webrtc:6666, webrtc:6843
Review-Url: https://codereview.webrtc.org/2564173002
Cr-Commit-Position: refs/heads/master@{#15518}
GDI capturer may randomly return a blank frame. So this change enables tests for
Linux / DirectX capturer / magnifier capturer.
BUG=webrtc:6666
Review-Url: https://codereview.webrtc.org/2559583002
Cr-Commit-Position: refs/heads/master@{#15489}
BitBlt returns a BOOL value, which should be taken care in ScreenCapturerWinGdi.
Meanwhile, this change also replaces assert() / abort() with RTC_DCHECK() /
RTC_CHECK() / RTC_NOTREACHED().
This change cannot fix the bug, the reason of the issue is still unknown, but it
is still the right thing to do.
In ScreenCapturerIntegrationTest, each frame will be captured at most 600 times.
Since the test case fails, which means the ScreenCapturerWinGdi consistently
returns a white frame for 600 times under a certain state. With this change,
instead of returning white frame, ScreenCapturerWinGdi will return a temporary
error. But I do not think a ScreenCapturerWinGdi can automatically recover by
retrying.
BUG=webrtc:6843
Review-Url: https://codereview.webrtc.org/2553353002
Cr-Commit-Position: refs/heads/master@{#15465}
A trivial change to remove a deprecated comment.
BUG=chromium:314516
Review-Url: https://codereview.webrtc.org/2553283002
Cr-Commit-Position: refs/heads/master@{#15454}
To support rotation in DirectX capturer, several other changes are also
required.
1. Removing AddRect in RotateDesktopFrame, this is a performance improvement.
DxgiOutputDuplicator creates a rotated DesktopRegion, which can be directly
add to updated_region.
2. DxgiOutputDuplicator::SourceRect() is not accurate, the rectangle in source
is controlled by |offset| or |rotation_| + |offset|, instead of desktop_rect().
3. The |region| in DxgiTexture::CopyFrom() is not accurate. It needs an
unrotated DesktopRegion which offsets by |offset| instead of desktop_rect(). To
avoid generating both rotated and unrotated updated_region, this parameter has
been removed. This impacts DxgiTextureStagning performance a little bit (1.5ms).
Refer to bug for details.
BUG=webrtc:6646
Review-Url: https://codereview.webrtc.org/2530303002
Cr-Commit-Position: refs/heads/master@{#15308}
This change adds RotateDesktopFrame(), RotateRect(), RotateSize(),
ReverseRotate() functions, so an implementation can use these free functions to
rotate and copy pixels from one DesktopFrame to another at the same time.
This is the first part of the change to support rotation in DirectX capturer. In
a coming change, these functions will be used in DxgiOutputDuplicator to do the
rotation and copying.
Background,
DirectX APIs always return unrotated data buffer, so we need to rotate it to
match the user-selected rotation. What worse is except for the data buffer,
other variables return by these APIs are all rotated, e.g. output size, monitor
position. So we will eventually not be able to capture the rotated monitors,
because we cannot set their position and size correctly. Though
DXGI_OUTDUPL_DESC provides a DXGI_MODE_ROTATION enumeration to indicate the
output rotation, it does not provide a simple way to rotate an IDXGIResource,
which is the only thing we can get from duplication APIs. A typical user case
here is to use a matrix to transform the IDXGIResource and render it to a
surface. But since we do not render the IDXGIResource at all, we need to
manually rotate it.
BUG=314516
Review-Url: https://codereview.webrtc.org/2500883004
Cr-Commit-Position: refs/heads/master@{#15205}
ScreenCapturerIntegrationTest is flaky on Windows systems due to some unknown
reason. But it's do easily impacted by the environment, so this change adds more
logging (entire screenshot) to help debugging.
Meanwhile, this change also includes a nice-to-have change in ScreenDrawerWin to
always bring the window to front in each WaitForPendingDraws() function call. I
cannot quite tell whether this change can help to resolve the issue, but it is
worth trying.
BUG=webrtc:6666
Review-Url: https://codereview.webrtc.org/2492723002
Cr-Commit-Position: refs/heads/master@{#15158}