Title: [217906] trunk/Source/WebCore
Revision
217906
Author
[email protected]
Date
2017-06-07 15:18:56 -0700 (Wed, 07 Jun 2017)

Log Message

Exempt exclusively wall-powered devices from hardware codec requirement
https://bugs.webkit.org/show_bug.cgi?id=173009

Reviewed by Eric Carlson.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm:
(WebCore::systemHasBattery):
(WebCore::assetTrackMeetsHardwareDecodeRequirements):
* platform/spi/cocoa/IOPSLibSPI.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (217905 => 217906)


--- trunk/Source/WebCore/ChangeLog	2017-06-07 22:15:50 UTC (rev 217905)
+++ trunk/Source/WebCore/ChangeLog	2017-06-07 22:18:56 UTC (rev 217906)
@@ -1,5 +1,18 @@
 2017-06-07  Jer Noble  <[email protected]>
 
+        Exempt exclusively wall-powered devices from hardware codec requirement
+        https://bugs.webkit.org/show_bug.cgi?id=173009
+
+        Reviewed by Eric Carlson.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm:
+        (WebCore::systemHasBattery):
+        (WebCore::assetTrackMeetsHardwareDecodeRequirements):
+        * platform/spi/cocoa/IOPSLibSPI.h: Added.
+
+2017-06-07  Jer Noble  <[email protected]>
+
         Refactoring: MediaEngineSupportParameters should take a ContentType rather than separate type & codecs strings
         https://bugs.webkit.org/show_bug.cgi?id=173038
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (217905 => 217906)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-07 22:15:50 UTC (rev 217905)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-07 22:18:56 UTC (rev 217906)
@@ -14840,6 +14840,7 @@
 		CDCD41E51C3DDB0900965D99 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; };
 		CDCD41E61C3DDB0900965D99 /* ParsedContentRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParsedContentRange.h; sourceTree = "<group>"; };
 		CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventTargetFactory.in; sourceTree = "<group>"; };
+		CDCEA92A1EE76D9800E7552B /* IOPSLibSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOPSLibSPI.h; sourceTree = "<group>"; };
 		CDCFABBB18C0AE31006F8450 /* SelectionSubtreeRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionSubtreeRoot.h; sourceTree = "<group>"; };
 		CDCFABBC18C0AF19006F8450 /* SelectionSubtreeRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionSubtreeRoot.cpp; sourceTree = "<group>"; };
 		CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentation.h; sourceTree = "<group>"; };
@@ -18828,6 +18829,7 @@
 				1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */,
 				935E2B4D1AFF06CA00976F9F /* DataDetectorsCoreSPI.h */,
 				CE12524C1A1A77DE00864480 /* IOPMLibSPI.h */,
+				CDCEA92A1EE76D9800E7552B /* IOPSLibSPI.h */,
 				44DEF6421A6FF92700D45EEC /* IOReturnSPI.h */,
 				44DFF6421A6FF92700D45EEC /* IOSurfaceSPI.h */,
 				44EFF6421A6FF92700D45EEC /* IOTypesSPI.h */,

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm (217905 => 217906)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm	2017-06-07 22:15:50 UTC (rev 217905)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm	2017-06-07 22:18:56 UTC (rev 217906)
@@ -29,6 +29,7 @@
 #if ENABLE(VIDEO) && USE(AVFOUNDATION)
 
 #import "FourCC.h"
+#import "IOPSLibSPI.h"
 #import <AVFoundation/AVAssetTrack.h>
 
 #import "CoreMediaSoftLink.h"
@@ -36,8 +37,31 @@
 
 namespace WebCore {
 
+static bool systemHasBattery()
+{
+    RetainPtr<CFTypeRef> powerSourcesInfo = adoptCF(IOPSCopyPowerSourcesInfo());
+    if (!powerSourcesInfo)
+        return false;
+    RetainPtr<CFArrayRef> powerSourcesList = adoptCF(IOPSCopyPowerSourcesList(powerSourcesInfo.get()));
+    if (!powerSourcesList)
+        return false;
+    for (CFIndex i = 0, count = CFArrayGetCount(powerSourcesList.get()); i < count; ++i) {
+        CFDictionaryRef description = IOPSGetPowerSourceDescription(powerSourcesInfo.get(), CFArrayGetValueAtIndex(powerSourcesList.get(), i));
+        CFTypeRef value = CFDictionaryGetValue(description, CFSTR(kIOPSTypeKey));
+        if (!value || CFEqual(value, CFSTR(kIOPSInternalBatteryType)))
+            return true;
+    }
+    return false;
+}
+
 bool assetTrackMeetsHardwareDecodeRequirements(AVAssetTrack *track, const Vector<ContentType>& contentTypesRequiringHardwareDecode)
 {
+    static bool hasBattery = systemHasBattery();
+
+    // If the system is exclusively wall-powered, do not require hardware support.
+    if (!hasBattery)
+        return true;
+
     // If we can't determine whether a codec has hardware support or not, default to true.
     if (!canLoad_VideoToolbox_VTIsHardwareDecodeSupported())
         return true;

Added: trunk/Source/WebCore/platform/spi/cocoa/IOPSLibSPI.h (0 => 217906)


--- trunk/Source/WebCore/platform/spi/cocoa/IOPSLibSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/spi/cocoa/IOPSLibSPI.h	2017-06-07 22:18:56 UTC (rev 217906)
@@ -0,0 +1,48 @@
+/*
+ * 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 <CoreFoundation/CoreFoundation.h>
+
+#if PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK)
+
+#include <IOKit/ps/IOPSKeys.h>
+#include <IOKit/ps/IOPowerSources.h>
+
+#else
+
+#define kIOPSTypeKey "Type"
+#define kIOPSInternalBatteryType "InternalBattery"
+
+#endif
+
+WTF_EXTERN_C_BEGIN
+
+CFTypeRef IOPSCopyPowerSourcesInfo(void);
+CFArrayRef IOPSCopyPowerSourcesList(CFTypeRef blob);
+CFDictionaryRef IOPSGetPowerSourceDescription(CFTypeRef blob, CFTypeRef ps);
+
+WTF_EXTERN_C_END
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to