Title: [168214] trunk/Source/WebCore
Revision
168214
Author
jer.no...@apple.com
Date
2014-05-02 18:09:49 -0700 (Fri, 02 May 2014)

Log Message

[MSE][Mac] AVAssetTrack returns incorrect track size
https://bugs.webkit.org/show_bug.cgi?id=132469

Reviewed by Brent Fulgham.

* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):  Remove the sizeChanged() notification.
(WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): Cache the last parsed video frame size.
(WebCore::SourceBufferPrivateAVFObjC::naturalSize): Return the cached value.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (168213 => 168214)


--- trunk/Source/WebCore/ChangeLog	2014-05-03 00:19:20 UTC (rev 168213)
+++ trunk/Source/WebCore/ChangeLog	2014-05-03 01:09:49 UTC (rev 168214)
@@ -1,3 +1,16 @@
+2014-05-02  Jer Noble  <jer.no...@apple.com>
+
+        [MSE][Mac] AVAssetTrack returns incorrect track size
+        https://bugs.webkit.org/show_bug.cgi?id=132469
+
+        Reviewed by Brent Fulgham.
+
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):  Remove the sizeChanged() notification.
+        (WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): Cache the last parsed video frame size.
+        (WebCore::SourceBufferPrivateAVFObjC::naturalSize): Return the cached value.
+
 2014-05-02  Zalan Bujtas  <za...@apple.com>
 
         Subpixel rendering[iOS]: Use pixelSnappedRoundedRectForPainting() to clip text area rect.

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (168213 => 168214)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2014-05-03 00:19:20 UTC (rev 168213)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2014-05-03 01:09:49 UTC (rev 168214)
@@ -122,6 +122,7 @@
     MediaSourcePrivateAVFObjC* m_mediaSource;
     SourceBufferPrivateClient* m_client;
 
+    FloatSize m_cachedSize;
     bool m_parsingSucceeded;
     int m_enabledVideoTrackID;
     int m_protectedTrackID;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (168213 => 168214)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2014-05-03 00:19:20 UTC (rev 168213)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2014-05-03 01:09:49 UTC (rev 168214)
@@ -86,10 +86,12 @@
 SOFT_LINK(CoreMedia, CMSampleBufferCallForEachSample, OSStatus, (CMSampleBufferRef sbuf, OSStatus (*callback)( CMSampleBufferRef sampleBuffer, CMItemCount index, void *refcon), void *refcon), (sbuf, callback, refcon))
 SOFT_LINK(CoreMedia, CMSampleBufferGetDecodeTimeStamp, CMTime, (CMSampleBufferRef sbuf), (sbuf))
 SOFT_LINK(CoreMedia, CMSampleBufferGetDuration, CMTime, (CMSampleBufferRef sbuf), (sbuf))
+SOFT_LINK(CoreMedia, CMSampleBufferGetFormatDescription, CMFormatDescriptionRef, (CMSampleBufferRef sbuf), (sbuf))
 SOFT_LINK(CoreMedia, CMSampleBufferGetPresentationTimeStamp, CMTime, (CMSampleBufferRef sbuf), (sbuf))
 SOFT_LINK(CoreMedia, CMSampleBufferGetSampleAttachmentsArray, CFArrayRef, (CMSampleBufferRef sbuf, Boolean createIfNecessary), (sbuf, createIfNecessary))
 SOFT_LINK(CoreMedia, CMFormatDescriptionGetMediaSubType, FourCharCode, (CMFormatDescriptionRef desc), (desc))
 SOFT_LINK(CoreMedia, CMSetAttachment, void, (CMAttachmentBearerRef target, CFStringRef key, CFTypeRef value, CMAttachmentMode attachmentMode), (target, key, value, attachmentMode))
+SOFT_LINK(CoreMedia, CMVideoFormatDescriptionGetPresentationDimensions, CGSize, (CMVideoFormatDescriptionRef videoDesc, Boolean usePixelAspectRatio, Boolean useCleanAperture), (videoDesc, usePixelAspectRatio, useCleanAperture))
 
 #define AVMediaTypeVideo getAVMediaTypeVideo()
 #define AVMediaTypeAudio getAVMediaTypeAudio()
@@ -381,9 +383,6 @@
         // FIXME(125161): Add TextTrack support
     }
 
-    if (!m_videoTracks.isEmpty())
-        m_mediaSource->player()->sizeChanged();
-
     if (m_client)
         m_client->sourceBufferPrivateDidReceiveInitializationSegment(this, segment);
 }
@@ -413,6 +412,15 @@
 
 bool SourceBufferPrivateAVFObjC::processCodedFrame(int trackID, CMSampleBufferRef sampleBuffer, const String&)
 {
+    if (trackID == m_enabledVideoTrackID) {
+        CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
+        FloatSize formatSize = FloatSize(CMVideoFormatDescriptionGetPresentationDimensions(formatDescription, true, true));
+        if (formatSize != m_cachedSize) {
+            LOG(Media, "SourceBufferPrivateAVFObjC::processCodedFrame(%p) - size change detected: {width=%lf, height=%lf", formatSize.width(), formatSize.height());
+            m_cachedSize = formatSize;
+            m_mediaSource->player()->sizeChanged();
+        }
+    }
     if (m_client)
         m_client->sourceBufferPrivateDidReceiveSample(this, MediaSampleAVFObjC::create(sampleBuffer, trackID));
 
@@ -695,12 +703,7 @@
 
 IntSize SourceBufferPrivateAVFObjC::naturalSize()
 {
-    for (auto& videoTrack : m_videoTracks) {
-        if (videoTrack->selected())
-            return videoTrack->naturalSize();
-    }
-
-    return IntSize();
+    return roundedIntSize(m_cachedSize);
 }
 
 void SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples(int trackID)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to