WebRTC video does not resume receiving when switching back to Safari 11 on iOS
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 23:23:27 +0000 (23:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 23:23:27 +0000 (23:23 +0000)
commitf9acbaeeea8a9d8c18e621521c5d358aea7c336a
tree803658f95c476c92250f7bd73edef94efa144ca3
parente18171012ad186e9ad48d75e9eec252d3b3dc9da
WebRTC video does not resume receiving when switching back to Safari 11 on iOS
https://bugs.webkit.org/show_bug.cgi?id=175472
<rdar://problem/33860863>

Patch by Youenn Fablet <youenn@apple.com> on 2017-09-25
Reviewed by Darin Adler.

Source/ThirdParty/libwebrtc:

Adding a method to disable any decoding/encoding task.
When reenabling the decoder, the decoder will request an I frame after failing the first initial decoding task.

* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h:
(webrtc::H264VideoToolboxDecoder::SetActive):
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:
(webrtc::H264VideoToolboxDecoder::Decode):
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.h:
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/encoder.mm:
(webrtc::H264VideoToolboxEncoder::Encode):

Source/WebCore:

Test: webrtc/video-interruption.html and manual testing.

Using new SetActive method from libwebrtc encoder/decoder to enable/disable them based on interuptions.
For that purpose, LibWebRTCProvider is now storing the peer connection factory and keeping track of the encoder/decoder factories.
LibWebRTCProvider is then notified by WebPage when backgrounded/foregrounded.

* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::staticFactoryAndThreads):
(WebCore::initializePeerConnectionFactoryAndThreads):
(WebCore::LibWebRTCProvider::factory):
(WebCore::LibWebRTCProvider::setPeerConnectionFactory):
(WebCore::LibWebRTCProvider::createPeerConnection):
(WebCore::LibWebRTCProvider::setActive):
(WebCore::LibWebRTCProvider::webRTCAvailable):
(WebCore::LibWebRTCProvider::mayResumePlayback): Deleted.
(WebCore::LibWebRTCProvider::suspendPlayback): Deleted.
* platform/mediastream/libwebrtc/LibWebRTCProvider.h:
* platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.cpp: Copied from Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp.
(WebCore::VideoToolboxVideoDecoderFactory::setActive):
(WebCore::VideoToolboxVideoDecoderFactory::CreateVideoDecoder):
(WebCore::VideoToolboxVideoDecoderFactory::DestroyVideoDecoder):
* platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.h: Copied from Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h.
* platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp:
(WebCore::VideoToolboxVideoEncoderFactory::setActive):
(WebCore::VideoToolboxVideoEncoderFactory::CreateSupportedVideoEncoder):
(WebCore::VideoToolboxVideoEncoderFactory::DestroyVideoEncoder):
* platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h:
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
* testing/MockLibWebRTCPeerConnection.cpp:
(WebCore::useRealRTCPeerConnectionFactory):
(WebCore::useMockRTCPeerConnectionFactory):
* testing/MockLibWebRTCPeerConnection.h:

Source/WebKit:

Notifying LibWebRTC of backgrounding/foregrouding.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::applicationDidEnterBackground):
(WebKit::WebPage::applicationWillEnterForeground):

LayoutTests:

* webrtc/video-interruption-expected.txt: Added.
* webrtc/video-interruption.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222478 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/video-interruption-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/video-interruption.html [new file with mode: 0644]
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.h
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm
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/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.cpp [new file with mode: 0644]
Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxDecoderFactory.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp
Source/WebCore/platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp
Source/WebCore/testing/MockLibWebRTCPeerConnection.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme