Use libwebrtc ObjectiveC H264 encoder and decoder
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 01:18:31 +0000 (01:18 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 01:18:31 +0000 (01:18 +0000)
commit79f2a06ccb94ac94cc167d7e1598d7faa058c93d
tree754d5024123f2336a988c23aac516190fed296a7
parent23c5228f97ec49fe0e84271f71727ab1b1ebc365
Use libwebrtc ObjectiveC H264 encoder and decoder
https://bugs.webkit.org/show_bug.cgi?id=183912

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Add utilities inside libwebrtc to be used by WebKit:
- Create ObjectiveC encoder/decoder factories
- Notify of application status to invalidate encoders/decoders when in background
Implement RTCUIApplicationStatusObserver as a simple boolean that is set by WebCore.
This allows limiting the changes made to libwebrtc codec implementations.

Minor modifications done to libwebrtc to fix compilation.
Add Block_copy/Block_release to codec callbacks.

* Configurations/libwebrtc.iOS.exp:
* Configurations/libwebrtc.iOSsim.exp:
* Configurations/libwebrtc.mac.exp:
* Source/webrtc/sdk/WebKit/WebKitUtilities.h: Added.
* Source/webrtc/sdk/WebKit/WebKitUtilities.mm: Added.
(+[RTCUIApplicationStatusObserver sharedInstance]):
(+[RTCUIApplicationStatusObserver prepareForUse]):
(-[RTCUIApplicationStatusObserver setActive]):
(-[RTCUIApplicationStatusObserver setInactive]):
(-[RTCUIApplicationStatusObserver isApplicationActive]):
(webrtc::setApplicationStatus):
(webrtc::createVideoToolboxEncoderFactory):
(webrtc::createVideoToolboxDecoderFactory):
(webrtc::setH264HardwareEncoderAllowed):
(webrtc::isH264HardwareEncoderAllowed):
(webrtc::pixelBufferFromFrame):
* Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm:
(-[RTCCVPixelBuffer dealloc]):
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm:
(-[RTCVideoDecoderH264 dealloc]):
(-[RTCVideoDecoderH264 setCallback:]):
(-[RTCVideoDecoderH264 releaseDecoder]):
* Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm:
(-[RTCVideoEncoderH264 dealloc]):
(-[RTCVideoEncoderH264 setCallback:]):
(-[RTCVideoEncoderH264 releaseEncoder]):
(-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
* WebKit/0001-Adapting-libwebrtc-H264-codec.patch: Added.
* libwebrtc.xcodeproj/project.pbxproj:

Source/WebCore:

No observable change of behavior.
Made use of libwebrtc WebKit utilities.
Updated RealtimeINcomingVideoSourceCocoa as it now receives ObjcVideoFrame.

* Configurations/WebCore.xcconfig:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
(WebCore::LibWebRTCProviderCocoa::~LibWebRTCProviderCocoa):
(WebCore::LibWebRTCProviderCocoa::setH264HardwareEncoderAllowed):
(WebCore::LibWebRTCProviderCocoa::createDecoderFactory):
(WebCore::LibWebRTCProviderCocoa::createEncoderFactory):
(WebCore::LibWebRTCProviderCocoa::setActive):
* platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.h:
* platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm: Renamed from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp.
(WebCore::RealtimeIncomingVideoSourceCocoa::pixelBufferFromVideoFrame):
(WebCore::RealtimeIncomingVideoSourceCocoa::OnFrame):
* testing/Internals.cpp: Removed commented out include.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229876 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h [new file with mode: 0644]
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm [new file with mode: 0644]
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
Source/ThirdParty/libwebrtc/WebKit/0001-Adapting-libwebrtc-H264-codec.patch [new file with mode: 0644]
Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj
Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.h
Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm [moved from Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.cpp with 84% similarity]
Source/WebCore/testing/Internals.cpp