Diff
Modified: trunk/Source/WTF/ChangeLog (217798 => 217799)
--- trunk/Source/WTF/ChangeLog 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WTF/ChangeLog 2017-06-05 22:40:30 UTC (rev 217799)
@@ -1,3 +1,19 @@
+2017-06-05 Jer Noble <[email protected]>
+
+ Allow clients to specify a list of codecs which should require hardware decode support.
+ https://bugs.webkit.org/show_bug.cgi?id=172787
+
+ Reviewed by Alex Christensen.
+
+ Add a couple of convenience methods:
+ - a String::split() that returns a vector (rather than taking an out-reference to a vector).
+ - A Vector::map() template which takes a Callable and returns a Vector of a different type.
+
+ * wtf/Vector.h:
+ (WTF::Vector::map):
+ * wtf/text/WTFString.h:
+ (WTF::String::split):
+
2017-06-04 Konstantin Tokarev <[email protected]>
Fix build of Windows-specific code with ICU 59.1
Modified: trunk/Source/WTF/wtf/Vector.h (217798 => 217799)
--- trunk/Source/WTF/wtf/Vector.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WTF/wtf/Vector.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -780,6 +780,8 @@
void checkConsistency();
+ template<typename MapFunction, typename R = typename std::result_of<MapFunction(const T&)>::type> Vector<R> map(MapFunction) const;
+
private:
void expandCapacity(size_t newMinCapacity);
T* expandCapacity(size_t newMinCapacity, T*);
@@ -1457,6 +1459,16 @@
std::swap(at(i), at(m_size - 1 - i));
}
+template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity> template<typename MapFunction, typename R>
+inline Vector<R> Vector<T, inlineCapacity, OverflowHandler, minCapacity>::map(MapFunction mapFunction) const
+{
+ Vector<R> result;
+ result.reserveInitialCapacity(size());
+ for (size_t i = 0; i < size(); ++i)
+ result.uncheckedAppend(mapFunction(at(i)));
+ return result;
+}
+
template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
inline MallocPtr<T> Vector<T, inlineCapacity, OverflowHandler, minCapacity>::releaseBuffer()
{
Modified: trunk/Source/WTF/wtf/text/WTFString.h (217798 => 217799)
--- trunk/Source/WTF/wtf/text/WTFString.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -370,6 +370,13 @@
split(separator, false, result);
}
+ Vector<String> split(const String& separator) const
+ {
+ Vector<String> result;
+ split(separator, false, result);
+ return result;
+ }
+
WTF_EXPORT_STRING_API int toIntStrict(bool* ok = nullptr, int base = 10) const;
WTF_EXPORT_STRING_API unsigned toUIntStrict(bool* ok = nullptr, int base = 10) const;
WTF_EXPORT_STRING_API int64_t toInt64Strict(bool* ok = nullptr, int base = 10) const;
Modified: trunk/Source/WebCore/ChangeLog (217798 => 217799)
--- trunk/Source/WebCore/ChangeLog 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/ChangeLog 2017-06-05 22:40:30 UTC (rev 217799)
@@ -1,3 +1,36 @@
+2017-06-05 Jer Noble <[email protected]>
+
+ Allow clients to specify a list of codecs which should require hardware decode support.
+ https://bugs.webkit.org/show_bug.cgi?id=172787
+
+ Reviewed by Alex Christensen.
+
+ Add a new setting, checked by HTMLMediaElement, which allows MediaPlayerPrivate implementation
+ to require that the specified codecs have hardware support. This requirement will be supported
+ in the normal media loading path and the MSE path on Cocoa ports.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaCodecsRequiringHardwareSupport):
+ * html/HTMLMediaElement.h:
+ * page/Settings.cpp:
+ (WebCore::Settings::setMediaCodecsRequiringHardwareSupport):
+ * page/Settings.h:
+ (WebCore::Settings::mediaCodecsRequiringHardwareSupport):
+ * platform/cocoa/VideoToolboxSoftLink.cpp:
+ * platform/cocoa/VideoToolboxSoftLink.h:
+ * platform/graphics/MediaPlayer.h:
+ (WebCore::MediaPlayerClient::mediaCodecsRequiringHardwareSupport):
+ * platform/graphics/avfoundation/objc/AVAssetTrackUtilities.h: Added.
+ * platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm: Added.
+ (WebCore::assetTrackMeetsHardwareDecodeRequirements):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::checkPlayability):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::assetStatus):
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+ (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
+
2017-06-05 Dan Bernstein <[email protected]>
Tried to fix the build when targrting macOS 10.12 using the macOS 10.13 developer beta SDK.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (217798 => 217799)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-06-05 22:40:30 UTC (rev 217799)
@@ -1780,7 +1780,7 @@
41C760B10EDE03D300C1655F /* ScriptState.h in Headers */ = {isa = PBXBuildFile; fileRef = 41C760B00EDE03D300C1655F /* ScriptState.h */; settings = {ATTRIBUTES = (Private, ); }; };
41CAD71E1EA090A100178164 /* VideoToolBoxEncoderFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41CAD71C1EA0905700178164 /* VideoToolBoxEncoderFactory.cpp */; };
41CF8BE71D46226700707DC9 /* FetchBodyConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41CF8BE41D46222000707DC9 /* FetchBodyConsumer.cpp */; };
- 41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; };
+ 41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
41DEFCB51E56C1BD000D9E5F /* JSDOMMapLike.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */; };
41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */; };
@@ -6155,6 +6155,8 @@
CD5209E61B0BD9E10077184E /* HTMLMediaElementEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5209E51B0BD9E10077184E /* HTMLMediaElementEnums.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD52481A18E200ED0008A07D /* SleepDisabler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD52481818E200ED0008A07D /* SleepDisabler.cpp */; };
CD52481B18E200ED0008A07D /* SleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = CD52481918E200ED0008A07D /* SleepDisabler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ CD525BA31EE0B10700788DF5 /* FourCC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD525BA11EE0B10700788DF5 /* FourCC.cpp */; };
+ CD525BA41EE0B10700788DF5 /* FourCC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD525BA21EE0B10700788DF5 /* FourCC.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */; };
CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5393D2175E018600C07123 /* JSMemoryInfo.h */; };
CD54A762180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */; };
@@ -6303,6 +6305,8 @@
CDEA76351460B71A008B31F1 /* Clock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEA76331460B462008B31F1 /* Clock.cpp */; };
CDEA7C841276230400B846DD /* RenderFullScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEA7C821276230400B846DD /* RenderFullScreen.h */; };
CDEA7C851276230400B846DD /* RenderFullScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEA7C831276230400B846DD /* RenderFullScreen.cpp */; };
+ CDECA89A1EDF447D00DCB08B /* AVAssetTrackUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDECA8981EDF447D00DCB08B /* AVAssetTrackUtilities.mm */; };
+ CDECA89B1EDF447D00DCB08B /* AVAssetTrackUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CDECA8991EDF447D00DCB08B /* AVAssetTrackUtilities.h */; };
CDEE393717974259001D7580 /* PublicURLManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEE393617974259001D7580 /* PublicURLManager.cpp */; };
CDEF4FD717E85C8F00AEE24B /* GridLength.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEF4FD617E85C8F00AEE24B /* GridLength.h */; settings = {ATTRIBUTES = (Private, ); }; };
CDEFA2281E7669E8000AE99C /* PlatformAudioData.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE667A11E4BBA4D00E8154A /* PlatformAudioData.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -14696,6 +14700,8 @@
CD5209E51B0BD9E10077184E /* HTMLMediaElementEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLMediaElementEnums.h; sourceTree = "<group>"; };
CD52481818E200ED0008A07D /* SleepDisabler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SleepDisabler.cpp; sourceTree = "<group>"; };
CD52481918E200ED0008A07D /* SleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SleepDisabler.h; sourceTree = "<group>"; };
+ CD525BA11EE0B10700788DF5 /* FourCC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FourCC.cpp; sourceTree = "<group>"; };
+ CD525BA21EE0B10700788DF5 /* FourCC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FourCC.h; sourceTree = "<group>"; };
CD5393CB175DCCE600C07123 /* MemoryInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInfo.h; sourceTree = "<group>"; };
CD5393CC175DCCE600C07123 /* MemoryInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MemoryInfo.idl; sourceTree = "<group>"; };
CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMemoryInfo.cpp; sourceTree = "<group>"; };
@@ -14879,6 +14885,8 @@
CDEA76331460B462008B31F1 /* Clock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Clock.cpp; sourceTree = "<group>"; };
CDEA7C821276230400B846DD /* RenderFullScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFullScreen.h; sourceTree = "<group>"; };
CDEA7C831276230400B846DD /* RenderFullScreen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFullScreen.cpp; sourceTree = "<group>"; };
+ CDECA8981EDF447D00DCB08B /* AVAssetTrackUtilities.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AVAssetTrackUtilities.mm; sourceTree = "<group>"; };
+ CDECA8991EDF447D00DCB08B /* AVAssetTrackUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AVAssetTrackUtilities.h; sourceTree = "<group>"; };
CDEE393617974259001D7580 /* PublicURLManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PublicURLManager.cpp; sourceTree = "<group>"; };
CDEE393817974274001D7580 /* URLRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = URLRegistry.h; sourceTree = "<group>"; };
CDEF4FD617E85C8F00AEE24B /* GridLength.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GridLength.h; sourceTree = "<group>"; };
@@ -23321,6 +23329,8 @@
501BAAA813950E2C00F7ACEB /* WindRule.h */,
379919941200DDF400EA041C /* WOFFFileFormat.cpp */,
379919951200DDF400EA041C /* WOFFFileFormat.h */,
+ CD525BA11EE0B10700788DF5 /* FourCC.cpp */,
+ CD525BA21EE0B10700788DF5 /* FourCC.h */,
);
path = graphics;
sourceTree = "<group>";
@@ -24514,6 +24524,8 @@
CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm */,
CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */,
CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */,
+ CDECA8981EDF447D00DCB08B /* AVAssetTrackUtilities.mm */,
+ CDECA8991EDF447D00DCB08B /* AVAssetTrackUtilities.h */,
);
path = objc;
sourceTree = "<group>";
@@ -28257,6 +28269,7 @@
AA7FEEA716A4E6F3004C0C33 /* JSSpeechSynthesisUtterance.h in Headers */,
AA7FEEA916A4E6F3004C0C33 /* JSSpeechSynthesisVoice.h in Headers */,
BC8243290D0CE8A200460C8F /* JSSQLError.h in Headers */,
+ CDECA89B1EDF447D00DCB08B /* AVAssetTrackUtilities.h in Headers */,
B525A96511CA2340003A23A8 /* JSSQLException.h in Headers */,
1AE82FED0CAB07EE002237AE /* JSSQLResultSet.h in Headers */,
1AFE119A0CBFFCC4003017FA /* JSSQLResultSetRowList.h in Headers */,
@@ -29391,6 +29404,7 @@
0FB8890A167D2FA10010CDA5 /* ScrollingTreeStickyNode.h in Headers */,
7AAFE8D019CB8672000F56D8 /* ScrollLatchingState.h in Headers */,
F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */,
+ CD525BA41EE0B10700788DF5 /* FourCC.h in Headers */,
F46729281E0DE68500ACC3D8 /* ScrollSnapOffsetsInfo.h in Headers */,
83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */,
93C09C860B0657AA005ABD4D /* ScrollTypes.h in Headers */,
@@ -31237,6 +31251,7 @@
A8C4A80809D563270003AC8D /* Element.cpp in Sources */,
B5B7A17017C10AA800E4AA0A /* ElementData.cpp in Sources */,
4FFC022D1643B726004E1638 /* ElementRareData.cpp in Sources */,
+ CD525BA31EE0B10700788DF5 /* FourCC.cpp in Sources */,
FBDB619B16D6032A00BB3394 /* ElementRuleCollector.cpp in Sources */,
A8CFF6CB0A1561CD000A4234 /* EllipsisBox.cpp in Sources */,
F55B3DBB1251F12D003EF269 /* EmailInputType.cpp in Sources */,
@@ -33230,6 +33245,7 @@
931CBD0C161A44E900E4C874 /* ScrollingStateNode.cpp in Sources */,
93EF7D551954F13900DFB71D /* ScrollingStateNode.mm in Sources */,
0FEA3E83191B31BF000F1B55 /* ScrollingStateOverflowScrollingNode.cpp in Sources */,
+ CDECA89A1EDF447D00DCB08B /* AVAssetTrackUtilities.mm in Sources */,
931CBD0E161A44E900E4C874 /* ScrollingStateScrollingNode.cpp in Sources */,
0FB8890E167D30160010CDA5 /* ScrollingStateStickyNode.cpp in Sources */,
931CBD10161A44E900E4C874 /* ScrollingStateTree.cpp in Sources */,
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (217798 => 217799)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-06-05 22:40:30 UTC (rev 217799)
@@ -4291,6 +4291,8 @@
#if ENABLE(MEDIA_STREAM)
parameters.isMediaStream = mediaURL.protocolIs(mediaStreamBlobProtocol);
#endif
+ parameters.contentTypesRequiringHardwareSupport = mediaContentTypesRequiringHardwareSupport();
+
if (!MediaPlayer::supportsType(parameters, this))
goto CheckAgain;
}
@@ -6628,6 +6630,11 @@
return potentiallyPlaying() ? requestedPlaybackRate() : 0;
}
+const Vector<ContentType>& HTMLMediaElement::mediaContentTypesRequiringHardwareSupport() const
+{
+ return document().settings().mediaContentTypesRequiringHardwareSupport();
+}
+
#if USE(GSTREAMER)
void HTMLMediaElement::requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback& callback)
{
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (217798 => 217799)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -679,6 +679,7 @@
double mediaPlayerRequestedPlaybackRate() const final;
VideoFullscreenMode mediaPlayerFullscreenMode() const final { return fullscreenMode(); }
bool mediaPlayerShouldDisableSleep() const final { return shouldDisableSleep() == SleepType::Display; }
+ const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const final;
#if USE(GSTREAMER)
void requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback&) final;
Modified: trunk/Source/WebCore/page/Settings.cpp (217798 => 217799)
--- trunk/Source/WebCore/page/Settings.cpp 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/page/Settings.cpp 2017-06-05 22:40:30 UTC (rev 217799)
@@ -789,4 +789,15 @@
return gAllowsAnySSLCertificate;
}
+void Settings::setMediaContentTypesRequiringHardwareSupport(const String& contentTypes)
+{
+ m_mediaContentTypesRequiringHardwareSupport = contentTypes.split(":").map(ContentType::create);
+}
+
+void Settings::setMediaContentTypesRequiringHardwareSupport(const Vector<ContentType>& contentTypes)
+{
+ m_mediaContentTypesRequiringHardwareSupport = contentTypes;
+}
+
+
} // namespace WebCore
Modified: trunk/Source/WebCore/page/Settings.h (217798 => 217799)
--- trunk/Source/WebCore/page/Settings.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/page/Settings.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -27,6 +27,7 @@
#pragma once
#include "ClipboardAccessPolicy.h"
+#include "ContentType.h"
#include "EditingBehaviorTypes.h"
#include "IntSize.h"
#include "SecurityOrigin.h"
@@ -325,6 +326,10 @@
WEBCORE_EXPORT static void setAllowsAnySSLCertificate(bool);
static bool allowsAnySSLCertificate();
+ WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const Vector<ContentType>&);
+ WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const String&);
+ const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const { return m_mediaContentTypesRequiringHardwareSupport; }
+
private:
explicit Settings(Page*);
@@ -424,6 +429,8 @@
static bool gLowPowerVideoAudioBufferSizeEnabled;
static bool gResourceLoadStatisticsEnabledEnabled;
static bool gAllowsAnySSLCertificate;
+
+ Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport;
};
inline bool Settings::isPostLoadCPUUsageMeasurementEnabled()
Modified: trunk/Source/WebCore/platform/ContentType.h (217798 => 217799)
--- trunk/Source/WebCore/platform/ContentType.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/ContentType.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -31,18 +31,20 @@
namespace WebCore {
- class ContentType {
- public:
- explicit ContentType(const String& type);
- ContentType() = default;
+class ContentType {
+public:
+ static ContentType create(const String& type) { return ContentType(type); }
+ explicit ContentType(const String& type);
+ ContentType() = default;
- String parameter(const String& parameterName) const;
- String type() const;
- Vector<String> codecs() const;
- const String& raw() const { return m_type; }
- private:
- String m_type;
- };
+ String parameter(const String& parameterName) const;
+ String type() const;
+ Vector<String> codecs() const;
+ const String& raw() const { return m_type; }
+ bool isEmpty() const { return m_type.isEmpty(); }
+private:
+ String m_type;
+};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp (217798 => 217799)
--- trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp 2017-06-05 22:40:30 UTC (rev 217799)
@@ -38,5 +38,6 @@
#define VTDecompressionSessionWaitForAsynchronousFrames softLink_VideoToolbox_VTDecompressionSessionWaitForAsynchronousFrames
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, VideoToolbox, VTDecompressionSessionDecodeFrame, OSStatus, (VTDecompressionSessionRef session, CMSampleBufferRef sampleBuffer, VTDecodeFrameFlags decodeFlags, void* sourceFrameRefCon, VTDecodeInfoFlags* infoFlagsOut), (session, sampleBuffer, decodeFlags, sourceFrameRefCon, infoFlagsOut))
#define VTDecompressionSessionDecodeFrame softLink_VideoToolbox_VTDecompressionSessionDecodeFrame
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTIsHardwareDecodeSupported, Boolean, (CMVideoCodecType codecType), (codecType))
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, CFStringRef)
#define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder get_VideoToolbox_kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder()
Modified: trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h (217798 => 217799)
--- trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -38,5 +38,7 @@
#define VTDecompressionSessionWaitForAsynchronousFrames softLink_VideoToolbox_VTDecompressionSessionWaitForAsynchronousFrames
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, VideoToolbox, VTDecompressionSessionDecodeFrame, OSStatus, (VTDecompressionSessionRef session, CMSampleBufferRef sampleBuffer, VTDecodeFrameFlags decodeFlags, void* sourceFrameRefCon, VTDecodeInfoFlags* infoFlagsOut), (session, sampleBuffer, decodeFlags, sourceFrameRefCon, infoFlagsOut))
#define VTDecompressionSessionDecodeFrame softLink_VideoToolbox_VTDecompressionSessionDecodeFrame
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTIsHardwareDecodeSupported, Boolean, (CMVideoCodecType codecType), (codecType))
+#define VTIsHardwareDecodeSupported softLink_VideoToolbox_VTIsHardwareDecodeSupported
SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, CFStringRef)
#define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder get_VideoToolbox_kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder()
Added: trunk/Source/WebCore/platform/graphics/FourCC.cpp (0 => 217799)
--- trunk/Source/WebCore/platform/graphics/FourCC.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FourCC.cpp 2017-06-05 22:40:30 UTC (rev 217799)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FourCC.h"
+
+namespace WebCore {
+
+std::optional<FourCC> FourCC::fromString(const String& stringValue)
+{
+ auto asciiValue = stringValue.ascii();
+ if (asciiValue.length() != 4)
+ return std::nullopt;
+
+ const char* data = ""
+ ASSERT(asciiValue.data());
+ uint32_t value = data[3] << 24 | data[2] << 16 | data[1] << 8 | data[0];
+ return FourCC(value);
+}
+
+String FourCC::toString() const
+{
+ Vector<LChar, 4> data = {
+ LChar(value >> 24),
+ LChar((value >> 16) & 0xFF),
+ LChar((value >> 8) & 0xFF),
+ LChar(value & 0xFF),
+ };
+
+ return String::adopt(WTFMove(data));
+}
+
+}
Added: trunk/Source/WebCore/platform/graphics/FourCC.h (0 => 217799)
--- trunk/Source/WebCore/platform/graphics/FourCC.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FourCC.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct FourCC {
+ WEBCORE_EXPORT FourCC(uint32_t value) : value(value) { }
+
+ String toString() const;
+ WEBCORE_EXPORT static std::optional<FourCC> fromString(const String&);
+
+ bool operator==(const FourCC& other) const { return value == other.value; }
+
+ uint32_t value;
+};
+
+}
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2017-06-05 22:40:30 UTC (rev 217799)
@@ -161,6 +161,12 @@
bool hasSingleSecurityOrigin() const override { return true; }
};
+const Vector<ContentType>& MediaPlayerClient::mediaContentTypesRequiringHardwareSupport() const
+{
+ static NeverDestroyed<Vector<ContentType>> contentTypes;
+ return contentTypes;
+}
+
static MediaPlayerClient& nullMediaPlayerClient()
{
static NeverDestroyed<MediaPlayerClient> client;
@@ -1464,6 +1470,11 @@
return client().mediaPlayerShouldDisableSleep();
}
+const Vector<ContentType>& MediaPlayer::mediaContentTypesRequiringHardwareSupport() const
+{
+ return client().mediaContentTypesRequiringHardwareSupport();
}
+}
+
#endif
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -30,6 +30,7 @@
#include "GraphicsTypes3D.h"
#include "AudioTrackPrivate.h"
+#include "ContentType.h"
#include "LegacyCDMSession.h"
#include "InbandTextTrackPrivate.h"
#include "IntRect.h"
@@ -114,6 +115,7 @@
URL url;
bool isMediaSource { false };
bool isMediaStream { false };
+ Vector<ContentType> contentTypesRequiringHardwareSupport;
};
extern const PlatformMedia NoPlatformMedia;
@@ -273,6 +275,7 @@
#endif
virtual bool mediaPlayerShouldDisableSleep() const { return false; }
+ virtual const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
};
class MediaPlayerSupportsTypeClient {
@@ -587,6 +590,8 @@
const String& contentTypeCodecs() const { return m_contentTypeCodecs; }
bool contentMIMETypeWasInferredFromExtension() const { return m_contentMIMETypeWasInferredFromExtension; }
+ const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
+
private:
MediaPlayer(MediaPlayerClient&);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -296,6 +296,7 @@
const String& assetURL() const { return m_assetURL; }
MediaPlayer* player() { return m_player; }
+ const MediaPlayer* player() const { return m_player; }
String engineDescription() const override { return "AVFoundation"; }
long platformErrorCode() const override { return assetErrorCode(); }
Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.h (0 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION)
+
+#include "ContentType.h"
+#include <wtf/Vector.h>
+
+OBJC_CLASS AVAssetTrack;
+
+namespace WebCore {
+
+bool assetTrackMeetsHardwareDecodeRequirements(AVAssetTrack *, const Vector<ContentType>& contentTypesRequiringHardwareDecode);
+
+}
+
+#endif
Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm (0 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm 2017-06-05 22:40:30 UTC (rev 217799)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "AVAssetTrackUtilities.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION)
+
+#import "FourCC.h"
+#import <AVFoundation/AVAssetTrack.h>
+
+#import "CoreMediaSoftLink.h"
+#import "VideoToolboxSoftLink.h"
+
+namespace WebCore {
+
+bool assetTrackMeetsHardwareDecodeRequirements(AVAssetTrack *track, const Vector<ContentType>& contentTypesRequiringHardwareDecode)
+{
+ // If we can't determine whether a codec has hardware support or not, default to true.
+ if (!canLoad_VideoToolbox_VTIsHardwareDecodeSupported())
+ return true;
+
+ if (contentTypesRequiringHardwareDecode.isEmpty())
+ return true;
+
+ Vector<FourCC> hardwareCodecs;
+ for (auto& contentType : contentTypesRequiringHardwareDecode) {
+ auto codecStrings = contentType.codecs();
+ for (auto& codecString : codecStrings) {
+ auto codecIdentifier = FourCC::fromString(codecString);
+ if (codecIdentifier)
+ hardwareCodecs.append(codecIdentifier.value());
+ }
+ }
+
+ for (NSUInteger i = 0, count = track.formatDescriptions.count; i < count; ++i) {
+ CMFormatDescriptionRef description = (CMFormatDescriptionRef)track.formatDescriptions[i];
+ if (CMFormatDescriptionGetMediaType(description) != kCMMediaType_Video)
+ continue;
+
+ CMVideoCodecType codec = CMFormatDescriptionGetMediaSubType(description);
+ if (!hardwareCodecs.contains(FourCC(codec)))
+ continue;
+
+ if (!VTIsHardwareDecodeSupported(codec))
+ return false;
+ }
+ return true;
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -424,6 +424,7 @@
bool m_cachedCanPlayFastForward;
bool m_cachedCanPlayFastReverse;
bool m_muted { false };
+ mutable std::optional<bool> m_tracksArePlayable;
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
mutable bool m_allowsWirelessVideoPlayback;
bool m_shouldPlayToPlaybackTarget { false };
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2017-06-05 22:40:30 UTC (rev 217799)
@@ -28,6 +28,7 @@
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
+#import "AVAssetTrackUtilities.h"
#import "AVFoundationMIMETypeCache.h"
#import "AVFoundationSPI.h"
#import "AVTrackPrivateAVFObjCImpl.h"
@@ -1146,7 +1147,7 @@
LOG(Media, "MediaPlayerPrivateAVFoundationObjC::checkPlayability(%p)", this);
auto weakThis = createWeakPtr();
- [m_avAsset.get() loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:@"playable"] completionHandler:^{
+ [m_avAsset.get() loadValuesAsynchronouslyForKeys:[NSArray arrayWithObjects:@"playable", @"tracks", nil] completionHandler:^{
callOnMainThread([weakThis] {
if (weakThis)
weakThis->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::AssetPlayabilityKnown);
@@ -1589,7 +1590,17 @@
return MediaPlayerAVAssetStatusCancelled; // Loading of at least one key was cancelled.
}
- if ([[m_avAsset.get() valueForKey:@"playable"] boolValue])
+ if (!m_tracksArePlayable) {
+ m_tracksArePlayable = true;
+ for (AVAssetTrack *track in [m_avAsset tracks]) {
+ if (!assetTrackMeetsHardwareDecodeRequirements(track, player()->mediaContentTypesRequiringHardwareSupport())) {
+ m_tracksArePlayable = false;
+ break;
+ }
+ }
+ }
+
+ if ([[m_avAsset.get() valueForKey:@"playable"] boolValue] && m_tracksArePlayable.value())
return MediaPlayerAVAssetStatusPlayable;
return MediaPlayerAVAssetStatusLoaded;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -117,6 +117,8 @@
void keyNeeded(Uint8Array*);
#endif
+ const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
+
WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
private:
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2017-06-05 22:40:30 UTC (rev 217799)
@@ -948,6 +948,11 @@
}
#endif
+const Vector<ContentType>& MediaPlayerPrivateMediaSourceAVFObjC::mediaContentTypesRequiringHardwareSupport() const
+{
+ return m_player->mediaContentTypesRequiringHardwareSupport();
+}
+
void MediaPlayerPrivateMediaSourceAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
{
if (m_readyState == readyState)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (217798 => 217799)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2017-06-05 22:40:30 UTC (rev 217799)
@@ -28,6 +28,7 @@
#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+#import "AVAssetTrackUtilities.h"
#import "AVFoundationSPI.h"
#import "AudioTrackPrivateMediaSourceAVFObjC.h"
#import "CDMSessionAVContentKeySession.h"
@@ -431,6 +432,16 @@
{
LOG(MediaSource, "SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(%p)", this);
+ if (!m_mediaSource)
+ return;
+
+ for (AVAssetTrack *track in [asset tracks]) {
+ if (!assetTrackMeetsHardwareDecodeRequirements(track, m_mediaSource->player()->mediaContentTypesRequiringHardwareSupport())) {
+ m_parsingSucceeded = false;
+ return;
+ }
+ }
+
m_asset = asset;
m_videoTracks.clear();
Modified: trunk/Source/WebKit2/ChangeLog (217798 => 217799)
--- trunk/Source/WebKit2/ChangeLog 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-05 22:40:30 UTC (rev 217799)
@@ -1,3 +1,28 @@
+2017-06-05 Jer Noble <[email protected]>
+
+ Allow clients to specify a list of codecs which should require hardware decode support.
+ https://bugs.webkit.org/show_bug.cgi?id=172787
+
+ Reviewed by Alex Christensen.
+
+ Add a WKWebPageConfiguration (and associated WebPreferences and WKPreferencesRef) properties
+ allowing clients to require specified codecs have hardware decode support. Also open up the
+ sandbox on Cocoa ports to services required to check for hardware decode availability.
+
+ * Shared/WebPreferencesDefinitions.h:
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesSetMediaCodecsRequiringHardwareSupport):
+ (WKPreferencesCopyMediaCodecsRequiringHardwareSupport):
+ * UIProcess/API/C/WKPreferencesRefPrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]):
+ * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+ (-[WKWebViewConfiguration copyWithZone:]):
+ (-[WKWebViewConfiguration _mediaCodecsRequiringHardwareSupport]):
+ (-[WKWebViewConfiguration _setMediaCodecsRequiringHardwareSupport:]):
+ * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+ * WebProcess/com.apple.WebProcess.sb.in:
+
2017-06-05 Beth Dakin <[email protected]>
Modify Netflix controlsManager quirk to prevent only scrubbing
Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (217798 => 217799)
--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -401,6 +401,7 @@
FOR_EACH_WEBKIT_FONT_FAMILY_PREFERENCE(macro) \
macro(DefaultTextEncodingName, defaultTextEncodingName, String, String, defaultTextEncodingNameForSystemLanguage(), "", "") \
macro(FTPDirectoryTemplatePath, ftpDirectoryTemplatePath, String, String, "", "", "") \
+ macro(MediaContentTypesRequiringHardwareSupport, mediaContentTypesRequiringHardwareSupport, String, String, "", "", "") \
\
#define FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(macro) \
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (217798 => 217799)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp 2017-06-05 22:40:30 UTC (rev 217799)
@@ -1770,3 +1770,14 @@
{
return toImpl(preferencesRef)->mediaUserGestureInheritsFromDocument();
}
+
+void WKPreferencesSetMediaContentTypesRequiringHardwareSupport(WKPreferencesRef preferencesRef, WKStringRef codecs)
+{
+ toImpl(preferencesRef)->setMediaContentTypesRequiringHardwareSupport(toWTFString(codecs));
+}
+
+WKStringRef WKPreferencesCopyMediaContentTypesRequiringHardwareSupport(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->mediaContentTypesRequiringHardwareSupport());
+}
+
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h (217798 => 217799)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -497,6 +497,10 @@
WK_EXPORT void WKPreferencesSetMediaUserGestureInheritsFromDocument(WKPreferencesRef, bool flag);
WK_EXPORT bool WKPreferencesGetMediaUserGestureInheritsFromDocument(WKPreferencesRef);
+// Defaults to an empty string
+WK_EXPORT void WKPreferencesSetMediaContentTypesRequiringHardwareSupport(WKPreferencesRef, WKStringRef);
+WK_EXPORT WKStringRef WKPreferencesCopyMediaContentTypesRequiringHardwareSupport(WKPreferencesRef);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (217798 => 217799)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-06-05 22:40:30 UTC (rev 217799)
@@ -504,6 +504,8 @@
pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::needsStorageAccessFromFileURLsQuirkKey(), WebKit::WebPreferencesStore::Value(!![_configuration _needsStorageAccessFromFileURLsQuirk]));
+ pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::mediaContentTypesRequiringHardwareSupportKey(), WebKit::WebPreferencesStore::Value([_configuration _mediaContentTypesRequiringHardwareSupport]));
+
#if PLATFORM(IOS)
CGRect bounds = self.bounds;
_scrollView = adoptNS([[WKScrollView alloc] initWithFrame:bounds]);
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (217798 => 217799)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2017-06-05 22:40:30 UTC (rev 217799)
@@ -137,6 +137,7 @@
BOOL _needsStorageAccessFromFileURLsQuirk;
NSString *_overrideContentSecurityPolicy;
+ NSString *_mediaContentTypesRequiringHardwareSupport;
}
- (instancetype)init
@@ -330,6 +331,7 @@
configuration->_overrideContentSecurityPolicy = self->_overrideContentSecurityPolicy;
configuration->_urlSchemeHandlers.set(adoptNS([self._urlSchemeHandlers mutableCopyWithZone:zone]));
+ configuration->_mediaContentTypesRequiringHardwareSupport = self._mediaContentTypesRequiringHardwareSupport;
return configuration;
}
@@ -816,6 +818,16 @@
_overrideContentSecurityPolicy = overrideContentSecurityPolicy;
}
+- (NSString *)_mediaContentTypesRequiringHardwareSupport
+{
+ return _mediaContentTypesRequiringHardwareSupport;
+}
+
+- (void)_setMediaContentTypesRequiringHardwareSupport:(NSString *)mediaContentTypesRequiringHardwareSupport
+{
+ _mediaContentTypesRequiringHardwareSupport = mediaContentTypesRequiringHardwareSupport;
+}
+
@end
@implementation WKWebViewConfiguration (WKDeprecated)
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (217798 => 217799)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h 2017-06-05 22:40:30 UTC (rev 217799)
@@ -76,6 +76,7 @@
@property (nonatomic, setter=_setRequiresUserActionForVideoPlayback:) BOOL _requiresUserActionForVideoPlayback WK_API_DEPRECATED_WITH_REPLACEMENT("mediaTypesRequiringUserActionForPlayback", macosx(10.12, 10.12), ios(10.0, 10.0));
@property (nonatomic, setter=_setOverrideContentSecurityPolicy:) NSString *_overrideContentSecurityPolicy WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setMediaContentTypesRequiringHardwareSupport:) NSString *_mediaContentTypesRequiringHardwareSupport WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@end
Modified: trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in (217798 => 217799)
--- trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in 2017-06-05 22:28:03 UTC (rev 217798)
+++ trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in 2017-06-05 22:40:30 UTC (rev 217799)
@@ -89,7 +89,9 @@
(iokit-property "IOGeneralInterest")
(iokit-property "IOGLBundleName")
(iokit-property "IOI2CTransactionTypes")
+ (iokit-property "IOGVAVTCapabilities")
(iokit-property-regex #"^IOGVA(Codec|EncoderRestricted)")
+ (iokit-property-regex #"^IOGVA(.*)Decode$")
(iokit-property "IOMatchCategory")
(iokit-property-regex #"^IONameMatch(|ed)")
(iokit-property "IOPMStrictTreeOrder")