[WebRTC] Prevent capturing at unconventional resolutions when using the SW encoder...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2017 15:29:14 +0000 (15:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2017 15:29:14 +0000 (15:29 +0000)
commit1b8032fe3f6ca4e9862c42b3ac52b38cc156f494
tree498a92e48b3ed2a63a930ff82282f798fb23aebc
parent750b6bd3127a5f94d6912d3519d0c2e7b15e9f04
[WebRTC] Prevent capturing at unconventional resolutions when using the SW encoder on Mac
https://bugs.webkit.org/show_bug.cgi?id=172602
<rdar://problem/32407693>

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-22
Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Adding a parameter to disable hardware encoder.

* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h:
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.mm:
(webrtc::H264VideoToolboxEncoder::CreateCompressionSession):

Source/WebCore:

Test: platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html

Add internal API to switch on/off hardware H264 encoder.
Add checks for standard size. If using a software encoder and frame size is not standard,
the session is destroyed and no frame is sent at all.

Added tests based on captureStream.
Fixed the case of capturing a canvas which size is changing.

* Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
(WebCore::CanvasCaptureMediaStreamTrack::Source::canvasResized):
* platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.h:
* platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.mm:
(WebCore::H264VideoToolboxEncoder::setHardwareEncoderForWebRTCAllowed):
(WebCore::H264VideoToolboxEncoder::hardwareEncoderForWebRTCAllowed):
(WebCore::isUsingSoftwareEncoder):
(WebCore::H264VideoToolboxEncoder::CreateCompressionSession):
(isStandardFrameSize): Added.
(isUsingSoftwareEncoder): Added.
* testing/Internals.cpp:
(WebCore::Internals::setH264HardwareEncoderAllowed):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* platform/mac-wk1/TestExpectations: Mark captureCanvas as flaky due to AVDCreateGPUAccelerator: Error loading GPU renderer" appearing on some bots.
* platform/mac/webrtc/captureCanvas-webrtc-software-encoder-expected.txt: Copied from LayoutTests/webrtc/captureCanvas-webrtc-expected.txt.
* platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html: Added.
* webrtc/captureCanvas-webrtc-expected.txt:
* webrtc/captureCanvas-webrtc.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218699 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html [new file with mode: 0644]
LayoutTests/webrtc/captureCanvas-webrtc-expected.txt
LayoutTests/webrtc/captureCanvas-webrtc.html
LayoutTests/webrtc/routines.js
LayoutTests/webrtc/video.html
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.mm
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
Source/WebCore/platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.h
Source/WebCore/platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.mm
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl