Title: [164660] trunk/Source/WebCore
Revision
164660
Author
[email protected]
Date
2014-02-25 11:47:37 -0800 (Tue, 25 Feb 2014)

Log Message

[Win] Gracefully recover from missing 'naturalSize' parameter for media
https://bugs.webkit.org/show_bug.cgi?id=129278

Reviewed by Eric Carlson.

* platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h: Add declaration for
missing function call.
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::assetStatus): Don't treat missing 'naturalSize'
as a fatal error.
(WebCore::MediaPlayerPrivateAVFoundationCF::tracksChanged): Handle case of asset track
not being available yet. 
(WebCore::MediaPlayerPrivateAVFoundationCF::sizeChanged): If the 'naturalSize' is empty,
use the Player Item's 'presentationSize' instead.
(WebCore::AVFWrapper::processNotification): Add missing handler for duration changed.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164659 => 164660)


--- trunk/Source/WebCore/ChangeLog	2014-02-25 19:10:26 UTC (rev 164659)
+++ trunk/Source/WebCore/ChangeLog	2014-02-25 19:47:37 UTC (rev 164660)
@@ -1,3 +1,21 @@
+2014-02-24  Brent Fulgham  <[email protected]>
+
+        [Win] Gracefully recover from missing 'naturalSize' parameter for media
+        https://bugs.webkit.org/show_bug.cgi?id=129278
+
+        Reviewed by Eric Carlson.
+
+        * platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h: Add declaration for
+        missing function call.
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundationCF::assetStatus): Don't treat missing 'naturalSize'
+        as a fatal error.
+        (WebCore::MediaPlayerPrivateAVFoundationCF::tracksChanged): Handle case of asset track
+        not being available yet. 
+        (WebCore::MediaPlayerPrivateAVFoundationCF::sizeChanged): If the 'naturalSize' is empty,
+        use the Player Item's 'presentationSize' instead.
+        (WebCore::AVFWrapper::processNotification): Add missing handler for duration changed.
+
 2014-02-25  Sergio Villar Senin  <[email protected]>
 
         [CSS Grid Layout] Add ENABLE flag

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h (164659 => 164660)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h	2014-02-25 19:10:26 UTC (rev 164659)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h	2014-02-25 19:47:37 UTC (rev 164660)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -149,6 +149,9 @@
 SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetDuration, CMTime, __cdecl, (AVCFPlayerItemRef playerItem), (playerItem))
 #define AVCFPlayerItemGetDuration softLink_AVCFPlayerItemGetDuration
 
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetPresentationSize, CGSize, __cdecl, (AVCFPlayerItemRef playerItem), (playerItem))
+#define AVCFPlayerItemGetPresentationSize softLink_AVCFPlayerItemGetPresentationSize
+
 SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetStatus, AVCFPlayerItemStatus, __cdecl, (AVCFPlayerItemRef playerItem, CFErrorRef *errorOut), (playerItem, errorOut))
 #define AVCFPlayerItemGetStatus softLink_AVCFPlayerItemGetStatus
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (164659 => 164660)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-02-25 19:10:26 UTC (rev 164659)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-02-25 19:47:37 UTC (rev 164660)
@@ -751,8 +751,21 @@
 
         if (keyStatus < AVCFPropertyValueStatusLoaded)
             return MediaPlayerAVAssetStatusLoading;
-        if (keyStatus == AVCFPropertyValueStatusFailed)
+        if (keyStatus == AVCFPropertyValueStatusFailed) {
+            if (CFStringCompare(keyName, AVCFAssetPropertyNaturalSize, 0) == kCFCompareEqualTo) {
+                // Don't treat a failure to retrieve @"naturalSize" as fatal. We will use @"presentationSize" instead.
+                // <rdar://problem/15966685>
+                continue;
+            }
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+            if (CFStringCompare(keyName, AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions, 0) == kCFCompareEqualTo) {
+                // On Windows, the media selection options are not available when initially interacting with a streaming source.
+                // <rdar://problem/16160699>
+                continue;
+            }
+#endif
             return MediaPlayerAVAssetStatusFailed;
+        }
         if (keyStatus == AVCFPropertyValueStatusCancelled)
             return MediaPlayerAVAssetStatusCancelled;
     }
@@ -893,6 +906,11 @@
             
             if (AVCFPlayerItemTrackIsEnabled(track)) {
                 RetainPtr<AVCFAssetTrackRef> assetTrack = adoptCF(AVCFPlayerItemTrackCopyAssetTrack(track));
+                if (!assetTrack) {
+                    // Asset tracks may not be available yet when streaming. <rdar://problem/16160699>
+                    LOG(Media, "MediaPlayerPrivateAVFoundationCF:tracksChanged(%p) - track = %d is enabled, but has no asset track.", this, track);
+                    continue;
+                }
                 CFStringRef mediaType = AVCFAssetTrackGetMediaType(assetTrack.get());
                 if (!mediaType)
                     continue;
@@ -963,6 +981,9 @@
     trackRectUnion = CGRectOffset(trackRectUnion, trackRectUnion.origin.x, trackRectUnion.origin.y);
     CGSize naturalSize = trackRectUnion.size;
 
+    if (!naturalSize.height && !naturalSize.width && avPlayerItem(m_avfWrapper))
+        naturalSize = AVCFPlayerItemGetPresentationSize(avPlayerItem(m_avfWrapper));
+
     // Also look at the asset's preferred transform so we account for a movie matrix.
     CGSize movieSize = CGSizeApplyAffineTransform(AVCFAssetGetNaturalSize(avAsset(m_avfWrapper)), AVCFAssetGetPreferredTransform(avAsset(m_avfWrapper)));
     if (movieSize.width > naturalSize.width)
@@ -997,6 +1018,11 @@
         AVCFPlayerItemTrackRef playerItemTrack = (AVCFPlayerItemTrackRef)(CFArrayGetValueAtIndex(tracks.get(), i));
 
         RetainPtr<AVCFAssetTrackRef> assetTrack = adoptCF(AVCFPlayerItemTrackCopyAssetTrack(playerItemTrack));
+        if (!assetTrack) {
+            // Asset tracks may not be available yet when streaming. <rdar://problem/16160699>
+            LOG(Media, "MediaPlayerPrivateAVFoundationCF:tracksChanged(%p) - track = %d is enabled, but has no asset track.", this, track);
+            continue;
+        }
         CFStringRef mediaType = AVCFAssetTrackGetMediaType(assetTrack.get());
         if (!mediaType)
             continue;
@@ -1470,6 +1496,8 @@
         self->m_owner->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::PlayerRateChanged);
     else if (CFEqual(propertyName, CACFContextNeedsFlushNotification()))
         self->m_owner->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::ContentsNeedsDisplay);
+    else if (CFEqual(propertyName, AVCFPlayerItemDurationChangedNotification))
+        self->m_owner->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::DurationChanged);
     else
         ASSERT_NOT_REACHED();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to