Title: [172425] trunk
Revision
172425
Author
[email protected]
Date
2014-08-11 18:12:08 -0700 (Mon, 11 Aug 2014)

Log Message

[Mac, iOS] Some media content never reaches full 'loaded' state
https://bugs.webkit.org/show_bug.cgi?id=135814
<rdar://problem/17476923>

Reviewed by Jer Noble.

Source/WebCore:

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::duration): Change to a wrapper that just calls
the durationDouble method and narrows to a float.
(WebCore::MediaPlayerPrivateAVFoundation::durationDouble): Revised version of duration
that works with doubles.
(WebCore::MediaPlayerPrivateAVFoundation::currentTime): Wrapper that calls the
currentTimeDouble method and narrows to a float.
(WebCore::MediaPlayerPrivateAVFoundation::seekWithTolerance): Use durationDouble for
comparison with passed 'time' argument (which is a double).
(WebCore::MediaPlayerPrivateAVFoundation::didEnd): Use 'currentTimeDouble' so we can
cache the double precision version of this value.
(WebCore::MediaPlayerPrivateAVFoundation::extraMemoryCost): Use 'durationDouble' since
the rest of the calculation is in terms of doubles.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::platformDuration): Convert to 'double'. All
uses of this method are internal to the MediaPlayerPrivateAVFoundation* files.
(WebCore::MediaPlayerPrivateAVFoundationCF::currentTimeDouble): Switch from float implementation.
(WebCore::MediaPlayerPrivateAVFoundationCF::currentTime): Deleted. (Moved to parent class)
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::platformDuration): Convert to 'double'. All
uses of this method are internal to the MediaPlayerPrivateAVFoundation* files.
(WebCore::MediaPlayerPrivateAVFoundationObjC::currentTimeDouble): Switch from floating implementation.
(WebCore::MediaPlayerPrivateAVFoundationObjC::currentTime): Deleted. (Moved to parent class)

LayoutTests:

* platform/mac/media/video-seek-past-end-paused-expected.txt: Rebaseline
result for new rounding behavior.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (172424 => 172425)


--- trunk/LayoutTests/ChangeLog	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/LayoutTests/ChangeLog	2014-08-12 01:12:08 UTC (rev 172425)
@@ -1,3 +1,14 @@
+2014-08-11  Brent Fulgham  <[email protected]>
+
+        [Mac, iOS] Some media content never reaches full 'loaded' state
+        https://bugs.webkit.org/show_bug.cgi?id=135814
+        <rdar://problem/17476923>
+
+        Reviewed by Jer Noble.
+
+        * platform/mac/media/video-seek-past-end-paused-expected.txt: Rebaseline
+        result for new rounding behavior.
+
 2014-08-11  Beth Dakin  <[email protected]>
 
         Fixed backgrounds don't paint in blurred inset areas

Modified: trunk/LayoutTests/platform/mac/media/video-seek-past-end-paused-expected.txt (172424 => 172425)


--- trunk/LayoutTests/platform/mac/media/video-seek-past-end-paused-expected.txt	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/LayoutTests/platform/mac/media/video-seek-past-end-paused-expected.txt	2014-08-12 01:12:08 UTC (rev 172425)
@@ -12,7 +12,7 @@
 EXPECTED (video.paused == 'true') OK
 
 EXPECTED (video.paused == 'true') OK
-EXPECTED (mediaElement.currentTime == 'mediaElement.duration'), OBSERVED '6.026666641235352' FAIL
+EXPECTED (mediaElement.currentTime == 'mediaElement.duration'), OBSERVED '6.026666666666666' FAIL
 EXPECTED (video.ended == 'true'), OBSERVED 'false' FAIL
 
 END OF TEST

Modified: trunk/Source/WebCore/ChangeLog (172424 => 172425)


--- trunk/Source/WebCore/ChangeLog	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/ChangeLog	2014-08-12 01:12:08 UTC (rev 172425)
@@ -1,3 +1,38 @@
+2014-08-11  Brent Fulgham  <[email protected]>
+
+        [Mac, iOS] Some media content never reaches full 'loaded' state
+        https://bugs.webkit.org/show_bug.cgi?id=135814
+        <rdar://problem/17476923>
+
+        Reviewed by Jer Noble.
+
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::duration): Change to a wrapper that just calls
+        the durationDouble method and narrows to a float.
+        (WebCore::MediaPlayerPrivateAVFoundation::durationDouble): Revised version of duration
+        that works with doubles.
+        (WebCore::MediaPlayerPrivateAVFoundation::currentTime): Wrapper that calls the
+        currentTimeDouble method and narrows to a float.
+        (WebCore::MediaPlayerPrivateAVFoundation::seekWithTolerance): Use durationDouble for
+        comparison with passed 'time' argument (which is a double).
+        (WebCore::MediaPlayerPrivateAVFoundation::didEnd): Use 'currentTimeDouble' so we can
+        cache the double precision version of this value.
+        (WebCore::MediaPlayerPrivateAVFoundation::extraMemoryCost): Use 'durationDouble' since
+        the rest of the calculation is in terms of doubles.
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundationCF::platformDuration): Convert to 'double'. All
+        uses of this method are internal to the MediaPlayerPrivateAVFoundation* files.
+        (WebCore::MediaPlayerPrivateAVFoundationCF::currentTimeDouble): Switch from float implementation.
+        (WebCore::MediaPlayerPrivateAVFoundationCF::currentTime): Deleted. (Moved to parent class)
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::platformDuration): Convert to 'double'. All
+        uses of this method are internal to the MediaPlayerPrivateAVFoundation* files.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::currentTimeDouble): Switch from floating implementation.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::currentTime): Deleted. (Moved to parent class)
+
 2014-08-11  Enrica Casucci  <[email protected]>
 
         Improve look and feel of combined service menu..

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2014-08-12 01:12:08 UTC (rev 172425)
@@ -30,6 +30,7 @@
 #include "MediaPlayerPrivateAVFoundation.h"
 
 #include "DocumentLoader.h"
+#include "FloatConversion.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsContext.h"
@@ -246,18 +247,28 @@
 
 float MediaPlayerPrivateAVFoundation::duration() const
 {
+    return narrowPrecisionToFloat(durationDouble());
+}
+
+double MediaPlayerPrivateAVFoundation::durationDouble() const
+{
     if (m_cachedDuration != MediaPlayer::invalidTime())
         return m_cachedDuration;
 
-    float duration = platformDuration();
+    double duration = platformDuration();
     if (!duration || duration == MediaPlayer::invalidTime())
         return 0;
 
     m_cachedDuration = duration;
-    LOG(Media, "MediaPlayerPrivateAVFoundation::duration(%p) - caching %f", this, m_cachedDuration);
+    LOG(Media, "MediaPlayerPrivateAVFoundation::duration(%p) - caching %g", this, m_cachedDuration);
     return m_cachedDuration;
 }
 
+float MediaPlayerPrivateAVFoundation::currentTime() const
+{
+    return narrowPrecisionToFloat(currentTimeDouble());
+}
+
 void MediaPlayerPrivateAVFoundation::seek(float time)
 {
     seekWithTolerance(time, 0, 0);
@@ -277,10 +288,10 @@
     if (!metaDataAvailable())
         return;
 
-    if (time > duration())
-        time = duration();
+    if (time > durationDouble())
+        time = durationDouble();
 
-    if (currentTime() == time)
+    if (currentTimeDouble() == time)
         return;
 
     if (currentTextTrack())
@@ -672,7 +683,7 @@
 {
     // Hang onto the current time and use it as duration from now on since we are definitely at
     // the end of the movie. Do this because the initial duration is sometimes an estimate.
-    float now = currentTime();
+    double now = currentTimeDouble();
     if (now > 0)
         m_cachedDuration = now;
 
@@ -948,7 +959,7 @@
 
 size_t MediaPlayerPrivateAVFoundation::extraMemoryCost() const
 {
-    double duration = this->duration();
+    double duration = durationDouble();
     if (!duration)
         return 0;
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (172424 => 172425)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2014-08-12 01:12:08 UTC (rev 172425)
@@ -170,7 +170,9 @@
     virtual bool hasAudio() const override { return m_cachedHasAudio; }
     virtual void setVisible(bool) override;
     virtual float duration() const override;
-    virtual float currentTime() const = 0;
+    virtual double durationDouble() const override;
+    virtual float currentTime() const override;
+    virtual double currentTimeDouble() const = 0;
     virtual void seek(float) override;
     virtual void seekWithTolerance(double, double, double) override;
     virtual bool seeking() const override;
@@ -242,7 +244,7 @@
     virtual double platformMaxTimeSeekable() const = 0;
     virtual double platformMinTimeSeekable() const = 0;
     virtual float platformMaxTimeLoaded() const = 0;
-    virtual float platformDuration() const = 0;
+    virtual double platformDuration() const = 0;
 
     virtual void beginLoadingMetadata() = 0;
     virtual void tracksChanged() = 0;
@@ -329,7 +331,7 @@
     mutable float m_cachedMaxTimeLoaded;
     mutable double m_cachedMaxTimeSeekable;
     mutable double m_cachedMinTimeSeekable;
-    mutable float m_cachedDuration;
+    mutable double m_cachedDuration;
     float m_reportedDuration;
     mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
     float m_requestedRate;

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-08-12 01:12:08 UTC (rev 172425)
@@ -569,7 +569,7 @@
     setDelayCallbacks(false);
 }
 
-float MediaPlayerPrivateAVFoundationCF::platformDuration() const
+double MediaPlayerPrivateAVFoundationCF::platformDuration() const
 {
     if (!metaDataAvailable() || !avAsset(m_avfWrapper))
         return 0;
@@ -583,23 +583,23 @@
         cmDuration = AVCFAssetGetDuration(avAsset(m_avfWrapper));
 
     if (CMTIME_IS_NUMERIC(cmDuration))
-        return narrowPrecisionToFloat(CMTimeGetSeconds(cmDuration));
+        return CMTimeGetSeconds(cmDuration);
 
     if (CMTIME_IS_INDEFINITE(cmDuration))
-        return numeric_limits<float>::infinity();
+        return numeric_limits<double>::infinity();
 
     LOG(Media, "MediaPlayerPrivateAVFoundationCF::platformDuration(%p) - invalid duration, returning %.0f", this, static_cast<float>(MediaPlayer::invalidTime()));
     return static_cast<float>(MediaPlayer::invalidTime());
 }
 
-float MediaPlayerPrivateAVFoundationCF::currentTime() const
+double MediaPlayerPrivateAVFoundationCF::currentTimeDouble() const
 {
     if (!metaDataAvailable() || !avPlayerItem(m_avfWrapper))
         return 0;
 
     CMTime itemTime = AVCFPlayerItemGetCurrentTime(avPlayerItem(m_avfWrapper));
     if (CMTIME_IS_NUMERIC(itemTime))
-        return max(narrowPrecisionToFloat(CMTimeGetSeconds(itemTime)), 0.0f);
+        return std::max(CMTimeGetSeconds(itemTime), 0.0);
 
     return 0;
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h (172424 => 172425)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h	2014-08-12 01:12:08 UTC (rev 172425)
@@ -73,7 +73,8 @@
     virtual void platformSetVisible(bool);
     virtual void platformPlay();
     virtual void platformPause();
-    virtual float currentTime() const;
+    virtual float currentTime() const override;
+    virtual double currentTimeDouble() const override;
     virtual void setVolume(float);
     virtual void setClosedCaptionsVisible(bool);
     virtual void paint(GraphicsContext*, const IntRect&);
@@ -96,7 +97,7 @@
     virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const;
     virtual double platformMinTimeSeekable() const;
     virtual double platformMaxTimeSeekable() const;
-    virtual float platformDuration() const;
+    virtual double platformDuration() const;
     virtual float platformMaxTimeLoaded() const;
     virtual void beginLoadingMetadata();
     virtual void sizeChanged();

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (172424 => 172425)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2014-08-12 01:12:08 UTC (rev 172425)
@@ -146,7 +146,7 @@
     virtual void platformSetVisible(bool);
     virtual void platformPlay();
     virtual void platformPause();
-    virtual float currentTime() const;
+    virtual double currentTimeDouble() const override;
     virtual void setVolume(float);
     virtual void setClosedCaptionsVisible(bool);
     virtual void paint(GraphicsContext*, const IntRect&);
@@ -181,7 +181,7 @@
     virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const;
     virtual double platformMinTimeSeekable() const;
     virtual double platformMaxTimeSeekable() const;
-    virtual float platformDuration() const;
+    virtual double platformDuration() const;
     virtual float platformMaxTimeLoaded() const;
     virtual void beginLoadingMetadata();
     virtual void sizeChanged();

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2014-08-12 01:04:07 UTC (rev 172424)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2014-08-12 01:12:08 UTC (rev 172425)
@@ -1128,12 +1128,12 @@
     setDelayCallbacks(false);
 }
 
-float MediaPlayerPrivateAVFoundationObjC::platformDuration() const
+double MediaPlayerPrivateAVFoundationObjC::platformDuration() const
 {
     // Do not ask the asset for duration before it has been loaded or it will fetch the
     // answer synchronously.
     if (!m_avAsset || assetStatus() < MediaPlayerAVAssetStatusLoaded)
-         return MediaPlayer::invalidTime();
+        return MediaPlayer::invalidTime();
     
     CMTime cmDuration;
     
@@ -1144,24 +1144,24 @@
         cmDuration= [m_avAsset.get() duration];
 
     if (CMTIME_IS_NUMERIC(cmDuration))
-        return narrowPrecisionToFloat(CMTimeGetSeconds(cmDuration));
+        return CMTimeGetSeconds(cmDuration);
 
     if (CMTIME_IS_INDEFINITE(cmDuration)) {
-        return std::numeric_limits<float>::infinity();
+        return std::numeric_limits<double>::infinity();
     }
 
     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::platformDuration(%p) - invalid duration, returning %.0f", this, MediaPlayer::invalidTime());
     return MediaPlayer::invalidTime();
 }
 
-float MediaPlayerPrivateAVFoundationObjC::currentTime() const
+double MediaPlayerPrivateAVFoundationObjC::currentTimeDouble() const
 {
     if (!metaDataAvailable() || !m_avPlayerItem)
         return 0;
 
     CMTime itemTime = [m_avPlayerItem.get() currentTime];
     if (CMTIME_IS_NUMERIC(itemTime))
-        return std::max(narrowPrecisionToFloat(CMTimeGetSeconds(itemTime)), 0.0f);
+        return std::max(CMTimeGetSeconds(itemTime), 0.0);
 
     return 0;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to