[Mac][MSE] setCurrentTime() goes down fastSeek path in MediaPlayerPrivateMediaSourceA...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 May 2014 05:41:47 +0000 (05:41 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 May 2014 05:41:47 +0000 (05:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133023

Reviewed by Eric Carlson.

When seeking a MSE video, do not go down the fastSeekForMediaTime() path if the
seek resulted from a setCurrentTime() call. The logic can lead to attempted seeks
before buffered ranges.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::seekToTime):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168991 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm

index a275dcb..5fae1ce 100644 (file)
@@ -1,3 +1,20 @@
+2014-05-16  Jer Noble  <jer.noble@apple.com>
+
+        [Mac][MSE] setCurrentTime() goes down fastSeek path in MediaPlayerPrivateMediaSourceAVFObjC.
+        https://bugs.webkit.org/show_bug.cgi?id=133023
+
+        Reviewed by Eric Carlson.
+
+        When seeking a MSE video, do not go down the fastSeekForMediaTime() path if the
+        seek resulted from a setCurrentTime() call. The logic can lead to attempted seeks
+        before buffered ranges.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+        (WebCore::MediaSourcePrivateAVFObjC::seekToTime):
+
 2014-05-16  Benjamin Poulain  <bpoulain@apple.com>
 
         [iOS] ScrollView::visibleContentRectInternal is bypassing the iOS code for unobscuredContentRect
index f7a21bd..5865676 100644 (file)
@@ -417,7 +417,14 @@ void MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance(double time, double
 
 void MediaPlayerPrivateMediaSourceAVFObjC::seekInternal(double time, double negativeThreshold, double positiveThreshold)
 {
-    MediaTime seekTime = m_mediaSourcePrivate ? m_mediaSourcePrivate->seekToTime(MediaTime::createWithDouble(time), MediaTime::createWithDouble(positiveThreshold), MediaTime::createWithDouble(negativeThreshold)) : MediaTime::zeroTime();
+    if (!m_mediaSourcePrivate)
+        return;
+
+    MediaTime seekTime = MediaTime::createWithDouble(time);
+    if (!negativeThreshold && !positiveThreshold)
+        m_mediaSourcePrivate->seekToTime(seekTime);
+    else
+        seekTime = m_mediaSourcePrivate->seekToTime(seekTime, MediaTime::createWithDouble(positiveThreshold), MediaTime::createWithDouble(negativeThreshold));
 
     [m_synchronizer setRate:(m_playing ? m_rate : 0) time:toCMTime(seekTime)];
 }
index 3d1ba1f..d69ad8d 100644 (file)
@@ -67,6 +67,7 @@ public:
     bool hasAudio() const;
     bool hasVideo() const;
 
+    void seekToTime(MediaTime);
     MediaTime seekToTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
     IntSize naturalSize() const;
 
index c0bda0d..7e6fcb3 100644 (file)
@@ -178,17 +178,23 @@ bool MediaSourcePrivateAVFObjC::hasVideo() const
     return std::any_of(m_activeSourceBuffers.begin(), m_activeSourceBuffers.end(), MediaSourcePrivateAVFObjCHasVideo);
 }
 
+void MediaSourcePrivateAVFObjC::seekToTime(MediaTime time)
+{
+    for (auto& buffer : m_activeSourceBuffers)
+        buffer->seekToTime(time);
+}
+
 MediaTime MediaSourcePrivateAVFObjC::seekToTime(MediaTime targetTime, MediaTime negativeThreshold, MediaTime positiveThreshold)
 {
     MediaTime seekTime = targetTime;
+
     for (auto it = m_activeSourceBuffers.begin(), end = m_activeSourceBuffers.end(); it != end; ++it) {
         MediaTime sourceSeekTime = (*it)->fastSeekTimeForMediaTime(targetTime, negativeThreshold, positiveThreshold);
         if (abs(targetTime - sourceSeekTime) > abs(targetTime - seekTime))
             seekTime = sourceSeekTime;
     }
 
-    for (auto it = m_activeSourceBuffers.begin(), end = m_activeSourceBuffers.end(); it != end; ++it)
-        (*it)->seekToTime(seekTime);
+    seekToTime(seekTime);
 
     return seekTime;
 }