Title: [94302] trunk/Source/WebCore
Revision
94302
Author
[email protected]
Date
2011-09-01 10:15:46 -0700 (Thu, 01 Sep 2011)

Log Message

Defer creating AVPlayer and AVPlayerItem in MediaPlayerPrivateAVFoundation::setPreload()
https://bugs.webkit.org/show_bug.cgi?id=66253

Reviewed by Jon Honeycutt.

No new tests, should be covered by existing media tests.

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::setPreload): Use the same code on Mac and Windows to only create the AVPlayer and AVPlayerItem when needed.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Assign any existing AVPlayerItem to the new AVPlayer.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Allow creation of the AVPlayerItem before the AVPlayer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (94301 => 94302)


--- trunk/Source/WebCore/ChangeLog	2011-09-01 16:10:46 UTC (rev 94301)
+++ trunk/Source/WebCore/ChangeLog	2011-09-01 17:15:46 UTC (rev 94302)
@@ -1,3 +1,19 @@
+2011-08-31  Jeff Miller  <[email protected]>
+
+        Defer creating AVPlayer and AVPlayerItem in MediaPlayerPrivateAVFoundation::setPreload()
+        https://bugs.webkit.org/show_bug.cgi?id=66253
+
+        Reviewed by Jon Honeycutt.
+
+        No new tests, should be covered by existing media tests.
+
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::setPreload): Use the same code on Mac and Windows to only create the AVPlayer and AVPlayerItem when needed.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Assign any existing AVPlayerItem to the new AVPlayer.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Allow creation of the AVPlayerItem before the AVPlayer.
+
 2011-08-31  David Hyatt  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=67321

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (94301 => 94302)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2011-09-01 16:10:46 UTC (rev 94301)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2011-09-01 17:15:46 UTC (rev 94302)
@@ -617,23 +617,15 @@
 
     if (m_preload >= MediaPlayer::MetaData && assetStatus() == MediaPlayerAVAssetStatusDoesNotExist) {
         createAVAssetForURL(m_assetURL);
-        // FIXME: Remove this Windows-specific code when <rdar://problem/9877730> is fixed, until then
-        // we can't create an AVPlayer without an AVPlayerItem on Windows, so we always have to create
-        // the item first.
-#if PLATFORM(WIN)
-        createAVPlayerItem();
-#endif
-        createAVPlayer();
         checkPlayability();
     }
 
-    // FIXME: Enable this code on Windows when <rdar://problem/9877730> is fixed.
-#if PLATFORM(MAC)
-    // Don't force creation of the player item unless we already know that the asset is playable. If we aren't
-    // there yet, or if we already know it is not playable, creating it now won't help.
-    if (m_preload == MediaPlayer::Auto && m_assetIsPlayable)
+    // Don't force creation of the player and player item unless we already know that the asset is playable. If we aren't
+    // there yet, or if we already know it is not playable, creating them now won't help.
+    if (m_preload == MediaPlayer::Auto && m_assetIsPlayable) {
         createAVPlayerItem();
-#endif
+        createAVPlayer();
+    }
 
     setDelayCallbacks(false);
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (94301 => 94302)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2011-09-01 16:10:46 UTC (rev 94301)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2011-09-01 17:15:46 UTC (rev 94302)
@@ -287,6 +287,9 @@
     m_timeObserver = [m_avPlayer.get() addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(veryLongInterval, 10) queue:nil usingBlock:^(CMTime time){
         [observer timeChanged:CMTimeGetSeconds(time)];
     }];
+    
+    if (m_avPlayerItem)
+        [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
 
     setDelayCallbacks(false);
 }
@@ -298,8 +301,6 @@
 
     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem(%p)", this);
 
-    ASSERT(m_avPlayer);
-
     setDelayCallbacks(true);
 
     // Create the player item so we can load media data. 
@@ -310,7 +311,8 @@
     for (NSString *keyName in itemKVOProperties())
         [m_avPlayerItem.get() addObserver:m_objcObserver.get() forKeyPath:keyName options:nil context:(void *)MediaPlayerAVFoundationObservationContextPlayerItem];
 
-    [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
+    if (m_avPlayer)
+        [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
 
     setDelayCallbacks(false);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to