Title: [164688] branches/safari-537.60-branch/Source/WebCore
Revision
164688
Author
[email protected]
Date
2014-02-25 18:28:52 -0800 (Tue, 25 Feb 2014)

Log Message

Merge r164660

    2014-02-25  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::createMetadataKeyNames):
    (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: branches/safari-537.60-branch/Source/WebCore/ChangeLog (164687 => 164688)


--- branches/safari-537.60-branch/Source/WebCore/ChangeLog	2014-02-26 02:12:57 UTC (rev 164687)
+++ branches/safari-537.60-branch/Source/WebCore/ChangeLog	2014-02-26 02:28:52 UTC (rev 164688)
@@ -1,3 +1,26 @@
+2014-02-25  Brent Fulgham  <[email protected]>
+
+        Merge r164660
+
+    2014-02-25  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::createMetadataKeyNames):
+            (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-01-14  Brent Fulgham  <[email protected]>
 
         Merge r154470

Modified: branches/safari-537.60-branch/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h (164687 => 164688)


--- branches/safari-537.60-branch/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h	2014-02-26 02:12:57 UTC (rev 164687)
+++ branches/safari-537.60-branch/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h	2014-02-26 02:28:52 UTC (rev 164688)
@@ -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: branches/safari-537.60-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (164687 => 164688)


--- branches/safari-537.60-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-02-26 02:12:57 UTC (rev 164687)
+++ branches/safari-537.60-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-02-26 02:28:52 UTC (rev 164688)
@@ -209,7 +209,9 @@
         AVCFAssetPropertyPreferredRate,
         AVCFAssetPropertyPlayable,
         AVCFAssetPropertyTracks,
-        AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+        AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions,
+#endif
     };
     
     return CFArrayCreate(0, (const void**)keyNames, sizeof(keyNames) / sizeof(keyNames[0]), &kCFTypeArrayCallBacks);
@@ -736,8 +738,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;
     }
@@ -878,6 +893,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;
@@ -948,6 +968,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)
@@ -971,7 +994,9 @@
 #if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
 void MediaPlayerPrivateAVFoundationCF::processLegacyClosedCaptionsTracks()
 {
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
     AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup(avPlayerItem(m_avfWrapper), 0, safeMediaSelectionGroupForLegibleMedia(m_avfWrapper));
+#endif
 
     Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
     RetainPtr<CFArrayRef> tracks = adoptCF(AVCFPlayerItemCopyTracks(avPlayerItem(m_avfWrapper)));
@@ -980,6 +1005,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;
@@ -1295,8 +1325,11 @@
 {
     ASSERT(isMainThread());
     ASSERT(dispatch_get_main_queue() == dispatch_get_current_queue());
-    ASSERT(!avPlayer() && avPlayerItem());
+    ASSERT(avPlayerItem());
 
+    if (avPlayer())
+        return;
+
     RetainPtr<CFMutableDictionaryRef> optionsRef = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
 
     if (d3dDevice) {
@@ -1338,8 +1371,11 @@
 {
     ASSERT(isMainThread());
     ASSERT(dispatch_get_main_queue() == dispatch_get_current_queue());
-    ASSERT(!avPlayerItem() && avAsset());
+    ASSERT(avAsset());
 
+    if (avPlayerItem())
+        return;
+
     // Create the player item so we begin loading media data.
     AVCFPlayerItemRef itemRef = AVCFPlayerItemCreateWithAsset(kCFAllocatorDefault, avAsset(), m_notificationQueue);
     m_avPlayerItem = adoptCF(itemRef);
@@ -1447,6 +1483,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();
 }
@@ -1532,6 +1570,7 @@
         kCMTimeZero, kCMTimeZero, &seekCompletedCallback, callbackContext());
 }
 
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
 struct LegibleOutputData {
     RetainPtr<CFArrayRef> m_attributedStrings;
     double m_time;
@@ -1584,6 +1623,7 @@
 
     dispatch_async_f(dispatch_get_main_queue(), legibleOutputData.leakPtr(), processCue);
 }
+#endif
 
 void AVFWrapper::setAsset(AVCFURLAssetRef asset)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to