Title: [208202] branches/safari-602-branch/Source/WebCore

Diff

Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-11-01 00:42:23 UTC (rev 208202)
@@ -1,5 +1,41 @@
 2016-10-31  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r208151. rdar://problem/29032335
+
+    2016-10-31  Jer Noble  <jer.no...@apple.com>
+
+            Opt-out of AVPlayer automatic sleep disabling
+            https://bugs.webkit.org/show_bug.cgi?id=163983
+
+            Reviewed by Eric Carlson.
+
+            In addition to the DisplaySleepDisabler, notify the MediaPlayerPrivateAVFoundationObjC object whether
+            it should disable display sleep.  Provide all the necessary boilerplate to allow the media player private
+            to query the HTMLMediaPlayer so that the correct value can be set on AVPlayer upon creation.
+
+            * html/HTMLMediaElement.cpp:
+            (WebCore::HTMLMediaElement::updateSleepDisabling):
+            * html/HTMLMediaElement.h:
+            * platform/graphics/MediaPlayer.cpp:
+            (WebCore::MediaPlayer::setShouldDisableSleep):
+            (WebCore::MediaPlayer::shouldDisableSleep):
+            * platform/graphics/MediaPlayer.h:
+            (WebCore::MediaPlayerClient::mediaPlayerShouldDisableSleep):
+            * platform/graphics/MediaPlayerPrivate.h:
+            (WebCore::MediaPlayerPrivateInterface::setShouldDisableSleep):
+            * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+            * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer):
+            (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep):
+
+            Drive-by fix: Re-organize the contents of AVFoundationSPI.h so that there's a single top-level
+            #if USE(APPLE_INTERNAL_SDK) statement, rather than that conditional being sprinkled about the
+            file.
+
+            * platform/spi/mac/AVFoundationSPI.h:
+
+2016-10-31  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r208168. rdar://problem/28962886
 
     2016-10-28  Brent Fulgham  <bfulg...@apple.com>

Modified: branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.cpp	2016-11-01 00:42:23 UTC (rev 208202)
@@ -6327,10 +6327,14 @@
 
 void HTMLMediaElement::updateSleepDisabling()
 {
-    if (!shouldDisableSleep() && m_sleepDisabler)
+    bool shouldDisableSleep = this->shouldDisableSleep();
+    if (!shouldDisableSleep && m_sleepDisabler)
         m_sleepDisabler = nullptr;
-    else if (shouldDisableSleep() && !m_sleepDisabler)
+    else if (shouldDisableSleep && !m_sleepDisabler)
         m_sleepDisabler = DisplaySleepDisabler::create("com.apple.WebCore: HTMLMediaElement playback");
+
+    if (m_player)
+        m_player->setShouldDisableSleep(shouldDisableSleep);
 }
 
 bool HTMLMediaElement::shouldDisableSleep() const

Modified: branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLMediaElement.h	2016-11-01 00:42:23 UTC (rev 208202)
@@ -644,6 +644,7 @@
 
     double mediaPlayerRequestedPlaybackRate() const final;
     VideoFullscreenMode mediaPlayerFullscreenMode() const final { return fullscreenMode(); }
+    bool mediaPlayerShouldDisableSleep() const final { return shouldDisableSleep(); }
 
 #if USE(GSTREAMER)
     void requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback&) final;

Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp	2016-11-01 00:42:23 UTC (rev 208202)
@@ -1464,6 +1464,17 @@
 }
 #endif
 
+void MediaPlayer::setShouldDisableSleep(bool flag)
+{
+    if (m_private)
+        m_private->setShouldDisableSleep(flag);
 }
 
+bool MediaPlayer::shouldDisableSleep() const
+{
+    return m_client.mediaPlayerShouldDisableSleep();
+}
+
+}
+
 #endif

Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayer.h (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayer.h	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayer.h	2016-11-01 00:42:23 UTC (rev 208202)
@@ -275,6 +275,8 @@
 #if USE(GSTREAMER)
     virtual void requestInstallMissingPlugins(const String&, const String&, MediaPlayerRequestInstallMissingPluginsCallback&) { };
 #endif
+
+    virtual bool mediaPlayerShouldDisableSleep() const { return false; }
 };
 
 class MediaPlayerSupportsTypeClient {
@@ -597,6 +599,9 @@
 
     bool ended() const;
 
+    void setShouldDisableSleep(bool);
+    bool shouldDisableSleep() const;
+
 private:
     const MediaPlayerFactory* nextBestMediaEngine(const MediaPlayerFactory*) const;
     void loadWithNextMediaEngine(const MediaPlayerFactory*);

Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2016-11-01 00:42:23 UTC (rev 208202)
@@ -277,6 +277,8 @@
 #endif
 
     virtual void notifyActiveSourceBuffersChanged() { }
+
+    virtual void setShouldDisableSleep(bool) { }
 };
 
 }

Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2016-11-01 00:42:23 UTC (rev 208202)
@@ -336,6 +336,8 @@
 
     Vector<String> preferredAudioCharacteristics() const;
 
+    void setShouldDisableSleep(bool) override;
+
     WeakPtrFactory<MediaPlayerPrivateAVFoundationObjC> m_weakPtrFactory;
 
     RetainPtr<AVURLAsset> m_avAsset;

Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2016-11-01 00:42:23 UTC (rev 208202)
@@ -1050,6 +1050,10 @@
     }
 #endif
 
+#if PLATFORM(IOS)
+    setShouldDisableSleep(player()->shouldDisableSleep());
+#endif
+
     if (m_muted) {
         // Clear m_muted so setMuted doesn't return without doing anything.
         m_muted = false;
@@ -3262,6 +3266,16 @@
     return URL([m_avAsset resolvedURL]);
 }
 
+void MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep(bool flag)
+{
+#if PLATFORM(IOS)
+    if (m_avPlayer && [m_avPlayer respondsToSelector:@selector(_setPreventsSleepDuringVideoPlayback:)])
+        [m_avPlayer _setPreventsSleepDuringVideoPlayback:flag];
+#else
+    UNUSED_PARAM(flag);
+#endif
+}
+
 NSArray* assetMetadataKeyNames()
 {
     static NSArray* keys;

Modified: branches/safari-602-branch/Source/WebCore/platform/spi/mac/AVFoundationSPI.h (208201 => 208202)


--- branches/safari-602-branch/Source/WebCore/platform/spi/mac/AVFoundationSPI.h	2016-11-01 00:32:08 UTC (rev 208201)
+++ branches/safari-602-branch/Source/WebCore/platform/spi/mac/AVFoundationSPI.h	2016-11-01 00:42:23 UTC (rev 208202)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,17 +28,27 @@
 #import "SoftLinking.h"
 #import <objc/runtime.h>
 
-#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
-
 #if USE(APPLE_INTERNAL_SDK)
 
+#import <AVFoundation/AVAssetCache_Private.h>
 #import <AVFoundation/AVOutputContext.h>
+#import <AVFoundation/AVPlayerLayer_Private.h>
 #import <AVFoundation/AVPlayer_Private.h>
 
+#if PLATFORM(IOS) && HAVE(AVKIT)
+#import <AVKit/AVPlayerViewController_WebKitOnly.h>
+#endif
+
+#if !PLATFORM(IOS)
+#import <AVFoundation/AVStreamDataParser.h>
+#endif
+
 #else
 
 #import <AVFoundation/AVPlayer.h>
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
+
 NS_ASSUME_NONNULL_BEGIN
 
 @class AVOutputContext;
@@ -53,13 +63,8 @@
 
 NS_ASSUME_NONNULL_END
 
-#endif
-
 #endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <AVFoundation/AVAssetCache_Private.h>
-#else
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)
 #import <AVFoundation/AVAssetCache.h>
 #else
@@ -76,37 +81,18 @@
 @property (nonatomic, readonly, copy) NSURL *URL;
 @end
 NS_ASSUME_NONNULL_END
-#endif
 
 #if PLATFORM(IOS)
-
-#if HAVE(AVKIT) && USE(APPLE_INTERNAL_SDK)
-
-#import <AVFoundation/AVPlayerLayer_Private.h>
-#import <AVKit/AVPlayerViewController_WebKitOnly.h>
-
-#else
-
-#import <AVFoundation/AVPlayerLayer.h>
-
-#endif
-
-#if !HAVE(AVKIT) || !USE(APPLE_INTERNAL_SDK)
-
-@interface AVPlayerLayer (AVPlayerLayerPictureInPictureModeSupportPrivate)
-- (void)setPIPModeEnabled:(BOOL)flag;
+@interface AVPlayer (AVPlayerVideoSleepPrevention)
+@property (nonatomic, getter=_preventsSleepDuringVideoPlayback, setter=_setPreventsSleepDuringVideoPlayback:) BOOL preventsSleepDuringVideoPlayback;
 @end
 
-#endif
-
 #endif // PLATFORM(IOS)
 
+#if !PLATFORM(IOS)
+
 #pragma mark -
 #pragma mark AVStreamDataParser
-#if !PLATFORM(IOS)
-#if USE(APPLE_INTERNAL_SDK)
-#import <AVFoundation/AVStreamDataParser.h>
-#else
 
 @protocol AVStreamDataParserOutputHandling <NSObject>
 @end
@@ -134,10 +120,7 @@
 - (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
 - (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
 @end
-NS_ASSUME_NONNULL_END
-#endif // USE(APPLE_INTERNAL_SDK)
 
-NS_ASSUME_NONNULL_BEGIN
 @interface AVStreamDataParser (AVStreamDataParserPrivate)
 + (NSString *)outputMIMECodecParameterForInputMIMECodecParameter:(NSString *)inputMIMECodecParameter;
 @end
@@ -144,7 +127,16 @@
 NS_ASSUME_NONNULL_END
 
 #endif // !PLATFORM(IOS)
+#endif // USE(APPLE_INTERNAL_SDK)
 
+#if PLATFORM(IOS) && (!HAVE(AVKIT) || !USE(APPLE_INTERNAL_SDK))
+#import <AVFoundation/AVPlayerLayer.h>
+@interface AVPlayerLayer (AVPlayerLayerPictureInPictureModeSupportPrivate)
+- (void)setPIPModeEnabled:(BOOL)flag;
+@end
+#endif // !HAVE(AVKIT)
+
+
 // FIXME: Wrap in a #if USE(APPLE_INTERNAL_SDK) once these SPI land
 #import <AVFoundation/AVAsset.h>
 #import <AVFoundation/AVAssetResourceLoader.h>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to