Diff
Modified: trunk/Source/WebCore/ChangeLog (148290 => 148291)
--- trunk/Source/WebCore/ChangeLog 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/ChangeLog 2013-04-12 18:39:37 UTC (rev 148291)
@@ -1,3 +1,42 @@
+2013-04-11 Jer Noble <jer.no...@apple.com>
+
+ Add support for MediaPlayer::minTimeSeekable()
+ https://bugs.webkit.org/show_bug.cgi?id=114484
+
+ Reviewed by Eric Carlson.
+
+ Plumb a new minTimeSeekable() method through MediaPlayer and
+ MediaPlayerPrivate and use this new method in the existing
+ HTMLMediaElement::minTimeSeekable() method.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::minTimeSeekable): Pass to MediaPlayer.
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::NullMediaPlayerPrivate::minTimeSeekable): Return 0.
+ (WebCore::MediaPlayer::minTimeSeekable): Pass to MediaPlayerPrivate.
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::seekable): Define in terms of
+ minTimeSeekable()
+ (WebCore::MediaPlayerPrivateInterface::minTimeSeekable): Default to 0.
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+ (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
+ Initialize new m_cachedMinTimeSeekable ivar.
+ (WebCore::MediaPlayerPrivateAVFoundation::maxTimeSeekableDouble):
+ Renamed from maxTimeSeekable().
+ (WebCore::MediaPlayerPrivateAVFoundation::minTimeSeekable): Added.
+ Cache value of platformMinTimeSeekable().
+ (WebCore::MediaPlayerPrivateAVFoundation::seekableTimeRangesChanged):
+ Reset m_cachedMinTimeSeekable.
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::seekToTime): float -> double.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::platformMinTimeSeekable):
+ Added. Retrieve the lowest value from -[m_playerItem seekableTimeRanges].
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable):
+ float -> double.
+
2013-04-12 Commit Queue <rn...@webkit.org>
Unreviewed, rolling out r147942, r148026, and r148092.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (148290 => 148291)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-04-12 18:39:37 UTC (rev 148291)
@@ -3778,7 +3778,7 @@
double HTMLMediaElement::minTimeSeekable() const
{
- return 0;
+ return m_player ? m_player->minTimeSeekable() : 0;
}
double HTMLMediaElement::maxTimeSeekable() const
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2013-04-12 18:39:37 UTC (rev 148291)
@@ -135,6 +135,7 @@
virtual MediaPlayer::ReadyState readyState() const { return MediaPlayer::HaveNothing; }
virtual double maxTimeSeekableDouble() const { return 0; }
+ virtual double minTimeSeekable() const { return 0; }
virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); }
virtual unsigned totalBytes() const { return 0; }
@@ -681,6 +682,11 @@
return m_private->maxTimeSeekableDouble();
}
+double MediaPlayer::minTimeSeekable()
+{
+ return m_private->minTimeSeekable();
+}
+
bool MediaPlayer::didLoadingProgress()
{
return m_private->didLoadingProgress();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2013-04-12 18:39:37 UTC (rev 148291)
@@ -315,6 +315,7 @@
PassRefPtr<TimeRanges> buffered();
PassRefPtr<TimeRanges> seekable();
+ double minTimeSeekable();
double maxTimeSeekable();
bool didLoadingProgress();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2013-04-12 18:39:37 UTC (rev 148291)
@@ -105,9 +105,10 @@
virtual MediaPlayer::NetworkState networkState() const = 0;
virtual MediaPlayer::ReadyState readyState() const = 0;
- virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekable() ? TimeRanges::create(0, maxTimeSeekable()) : TimeRanges::create(); }
+ virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekableDouble() ? TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble()) : TimeRanges::create(); }
virtual float maxTimeSeekable() const { return 0; }
virtual double maxTimeSeekableDouble() const { return maxTimeSeekable(); }
+ virtual double minTimeSeekable() const { return 0; }
virtual PassRefPtr<TimeRanges> buffered() const = 0;
virtual bool didLoadingProgress() const = 0;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp 2013-04-12 18:39:37 UTC (rev 148291)
@@ -57,6 +57,7 @@
, m_preload(MediaPlayer::Auto)
, m_cachedMaxTimeLoaded(0)
, m_cachedMaxTimeSeekable(0)
+ , m_cachedMinTimeSeekable(0)
, m_cachedDuration(MediaPlayer::invalidTime())
, m_reportedDuration(MediaPlayer::invalidTime())
, m_maxTimeLoadedAtLastDidLoadingProgress(MediaPlayer::invalidTime())
@@ -361,7 +362,7 @@
return m_cachedLoadedTimeRanges->copy();
}
-float MediaPlayerPrivateAVFoundation::maxTimeSeekable() const
+double MediaPlayerPrivateAVFoundation::maxTimeSeekableDouble() const
{
if (!metaDataAvailable())
return 0;
@@ -373,6 +374,18 @@
return m_cachedMaxTimeSeekable;
}
+double MediaPlayerPrivateAVFoundation::minTimeSeekable() const
+{
+ if (!metaDataAvailable())
+ return 0;
+
+ if (!m_cachedMinTimeSeekable)
+ m_cachedMinTimeSeekable = platformMinTimeSeekable();
+
+ LOG(Media, "MediaPlayerPrivateAVFoundation::minTimeSeekable(%p) - returning %f", this, m_cachedMinTimeSeekable);
+ return m_cachedMinTimeSeekable;
+}
+
float MediaPlayerPrivateAVFoundation::maxTimeLoaded() const
{
if (!metaDataAvailable())
@@ -570,6 +583,7 @@
void MediaPlayerPrivateAVFoundation::seekableTimeRangesChanged()
{
m_cachedMaxTimeSeekable = 0;
+ m_cachedMinTimeSeekable = 0;
}
void MediaPlayerPrivateAVFoundation::timeChanged(double time)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2013-04-12 18:39:37 UTC (rev 148291)
@@ -157,7 +157,8 @@
virtual void setClosedCaptionsVisible(bool) = 0;
virtual MediaPlayer::NetworkState networkState() const { return m_networkState; }
virtual MediaPlayer::ReadyState readyState() const { return m_readyState; }
- virtual float maxTimeSeekable() const;
+ virtual double maxTimeSeekableDouble() const;
+ virtual double minTimeSeekable() const;
virtual PassRefPtr<TimeRanges> buffered() const;
virtual bool didLoadingProgress() const;
virtual void setSize(const IntSize&);
@@ -209,10 +210,11 @@
virtual void checkPlayability() = 0;
virtual void updateRate() = 0;
virtual float rate() const = 0;
- virtual void seekToTime(float time) = 0;
+ virtual void seekToTime(double time) = 0;
virtual unsigned totalBytes() const = 0;
virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const = 0;
- virtual float platformMaxTimeSeekable() const = 0;
+ virtual double platformMaxTimeSeekable() const = 0;
+ virtual double platformMinTimeSeekable() const = 0;
virtual float platformMaxTimeLoaded() const = 0;
virtual float platformDuration() const = 0;
@@ -285,11 +287,12 @@
IntSize m_cachedNaturalSize;
mutable float m_cachedMaxTimeLoaded;
- mutable float m_cachedMaxTimeSeekable;
+ mutable double m_cachedMaxTimeSeekable;
+ mutable double m_cachedMinTimeSeekable;
mutable float m_cachedDuration;
float m_reportedDuration;
mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
- float m_seekTo;
+ double m_seekTo;
float m_requestedRate;
mutable int m_delayCallbacks;
bool m_mainThreadCallPending;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2013-04-12 18:39:37 UTC (rev 148291)
@@ -122,10 +122,11 @@
virtual void checkPlayability();
virtual void updateRate();
virtual float rate() const;
- virtual void seekToTime(float time);
+ virtual void seekToTime(double time);
virtual unsigned totalBytes() const;
virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;
- virtual float platformMaxTimeSeekable() const;
+ virtual double platformMinTimeSeekable() const;
+ virtual double platformMaxTimeSeekable() const;
virtual float platformDuration() const;
virtual float platformMaxTimeLoaded() const;
virtual void beginLoadingMetadata();
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (148290 => 148291)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2013-04-12 18:36:30 UTC (rev 148290)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2013-04-12 18:39:37 UTC (rev 148291)
@@ -601,7 +601,7 @@
return 0;
}
-void MediaPlayerPrivateAVFoundationObjC::seekToTime(float time)
+void MediaPlayerPrivateAVFoundationObjC::seekToTime(double time)
{
// setCurrentTime generates several event callbacks, update afterwards.
setDelayCallbacks(true);
@@ -669,23 +669,44 @@
return timeRanges.release();
}
-float MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable() const
+double MediaPlayerPrivateAVFoundationObjC::platformMinTimeSeekable() const
{
NSArray *seekableRanges = [m_avPlayerItem.get() seekableTimeRanges];
+ if (!seekableRanges || ![seekableRanges count])
+ return 0;
+
+ double minTimeSeekable = std::numeric_limits<double>::infinity();
+ bool hasValidRange = false;
+ for (NSValue *thisRangeValue in seekableRanges) {
+ CMTimeRange timeRange = [thisRangeValue CMTimeRangeValue];
+ if (!CMTIMERANGE_IS_VALID(timeRange) || CMTIMERANGE_IS_EMPTY(timeRange))
+ continue;
+
+ hasValidRange = true;
+ double startOfRange = CMTimeGetSeconds(timeRange.start);
+ if (minTimeSeekable > startOfRange)
+ minTimeSeekable = startOfRange;
+ }
+ return hasValidRange ? minTimeSeekable : 0;
+}
+
+double MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable() const
+{
+ NSArray *seekableRanges = [m_avPlayerItem.get() seekableTimeRanges];
if (!seekableRanges)
return 0;
- float maxTimeSeekable = 0;
+ double maxTimeSeekable = 0;
for (NSValue *thisRangeValue in seekableRanges) {
CMTimeRange timeRange = [thisRangeValue CMTimeRangeValue];
if (!CMTIMERANGE_IS_VALID(timeRange) || CMTIMERANGE_IS_EMPTY(timeRange))
continue;
- float endOfRange = narrowPrecisionToFloat(CMTimeGetSeconds(CMTimeRangeGetEnd(timeRange)));
+ double endOfRange = CMTimeGetSeconds(CMTimeRangeGetEnd(timeRange));
if (maxTimeSeekable < endOfRange)
maxTimeSeekable = endOfRange;
}
- return maxTimeSeekable;
+ return maxTimeSeekable;
}
float MediaPlayerPrivateAVFoundationObjC::platformMaxTimeLoaded() const
@@ -1430,7 +1451,7 @@
m_languageOfPrimaryAudioTrack = emptyString();
return m_languageOfPrimaryAudioTrack;
}
-
+
NSArray* assetMetadataKeyNames()
{
static NSArray* keys;