2009-03-24 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2009 02:14:09 +0000 (02:14 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2009 02:14:09 +0000 (02:14 +0000)
        Reviewed by Antti Koivisto.

        Fix for <rdar://problem/6719375> Deal with QTKit loadstate changes when playing streaming movies

        *  WebCore/html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::setNetworkState): Deal with media engine reviving after having
        network state of NETWORK_NO_SOURCE.

        *  WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivate::updateStates): Reset m_readyState at each state change since
        some types of movies currently cause QTKit's load state to bounce around. QTMovieLoadStatePlaythroughOK
        corresponds to HaveFutureData, not HaveEnoughData.

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

WebCore/ChangeLog
WebCore/html/HTMLMediaElement.cpp
WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

index bbebf71..8a63f90 100644 (file)
@@ -1,3 +1,18 @@
+2009-03-24  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Antti Koivisto.
+
+        Fix for <rdar://problem/6719375> Deal with QTKit loadstate changes when playing streaming movies
+
+        *  WebCore/html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::setNetworkState): Deal with media engine reviving after having
+        network state of NETWORK_NO_SOURCE.
+
+        *  WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivate::updateStates): Reset m_readyState at each state change since
+        some types of movies currently cause QTKit's load state to bounce around. QTMovieLoadStatePlaythroughOK
+        corresponds to HaveFutureData, not HaveEnoughData.
+
 2009-03-24  Adele Peterson  <adele@apple.com>
 
         Reviewed by Darin Adler.
index fd1751f..df0ed04 100644 (file)
@@ -593,13 +593,13 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
         scheduleProgressEvent(eventNames().suspendEvent);
     }
 
-    if (state == MediaPlayer::Loading && m_networkState < NETWORK_LOADING) {
+    if (state == MediaPlayer::Loading && (m_networkState < NETWORK_LOADING || m_networkState == NETWORK_NO_SOURCE)) {
         ASSERT(static_cast<ReadyState>(m_player->readyState()) < HAVE_ENOUGH_DATA);
         m_networkState = NETWORK_LOADING;
         startProgressEventTimer();
     }
 
-    if (state == MediaPlayer::Loaded && m_networkState < NETWORK_LOADED) {
+    if (state == MediaPlayer::Loaded && (m_networkState < NETWORK_LOADED || m_networkState == NETWORK_NO_SOURCE)) {
         m_networkState = NETWORK_LOADED;
         m_progressEventTimer.stop();
 
index d1d929f..74a9ff9 100644 (file)
@@ -635,7 +635,7 @@ void MediaPlayerPrivate::updateStates()
     MediaPlayer::ReadyState oldReadyState = m_readyState;
     
     long loadState = m_qtMovie ? [[m_qtMovie.get() attributeForKey:QTMovieLoadStateAttribute] longValue] : static_cast<long>(QTMovieLoadStateError);
-    
+
     if (loadState >= QTMovieLoadStateLoaded && m_readyState < MediaPlayer::HaveMetadata && !m_player->inMediaDocument()) {
         disableUnsupportedTracks();
         if (!m_enabledTrackCount)
@@ -647,15 +647,18 @@ void MediaPlayerPrivate::updateStates()
         m_networkState = MediaPlayer::Loaded;
         m_readyState = MediaPlayer::HaveEnoughData;
     } else if (loadState >= QTMovieLoadStatePlaythroughOK) {
-        m_readyState = MediaPlayer::HaveEnoughData;
+        m_readyState = MediaPlayer::HaveFutureData;
+        m_networkState = MediaPlayer::Loading;
     } else if (loadState >= QTMovieLoadStatePlayable) {
         // FIXME: This might not work correctly in streaming case, <rdar://problem/5693967>
         m_readyState = currentTime() < maxTimeLoaded() ? MediaPlayer::HaveFutureData : MediaPlayer::HaveCurrentData;
+        m_networkState = MediaPlayer::Loading;
     } else if (loadState >= QTMovieLoadStateLoaded) {
         m_readyState = MediaPlayer::HaveMetadata;
-    } else if (loadState > QTMovieLoadStateError) {
         m_networkState = MediaPlayer::Loading;
+    } else if (loadState > QTMovieLoadStateError) {
         m_readyState = MediaPlayer::HaveNothing;        
+        m_networkState = MediaPlayer::Loading;
     } else {
         float loaded = maxTimeLoaded();