[WebRTC] Prevent capturing at unconventional resolutions when using the SW encoder...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 20:42:04 +0000 (20:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 20:42:04 +0000 (20:42 +0000)
commitbb66b99ed2c71e07afe8c8d44e7264c3f38a4b21
tree2253b721ff26043d634b86b6393963dff937da0c
parente94aa54945b35798f675f8154a5073b3ce12c0f9
[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-19
Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Adding a parameter to disable hardware encoder.

* Source/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h:
* Source/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_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@218505 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/h264_video_toolbox_encoder.h
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_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