2009-03-03 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2009 00:44:46 +0000 (00:44 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2009 00:44:46 +0000 (00:44 +0000)
        Reviewed by Simon Fraser.

        Fix for <rdar://problem/6641045>
        Don't call QTKit to get movie properties until movie metadata has been loaded.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
        (WebCore::MediaPlayerPrivate::metaDataAvailable): defined
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivate::createQTTime): return default if !metaDataAvailable.
        (WebCore::MediaPlayerPrivate::play): Ditto.
        (WebCore::MediaPlayerPrivate::pause): Ditto.
        (WebCore::MediaPlayerPrivate::duration): Ditto.
        (WebCore::MediaPlayerPrivate::currentTime): Ditto.
        (WebCore::MediaPlayerPrivate::seek): Ditto.
        (WebCore::MediaPlayerPrivate::seekTimerFired): Ditto.
        (WebCore::MediaPlayerPrivate::paused): Ditto.
        (WebCore::MediaPlayerPrivate::seeking): Ditto.
        (WebCore::MediaPlayerPrivate::naturalSize): Ditto.
        (WebCore::MediaPlayerPrivate::hasVideo): Ditto.
        (WebCore::MediaPlayerPrivate::setVolume): Ditto.
        (WebCore::MediaPlayerPrivate::setRate): Ditto.
        (WebCore::MediaPlayerPrivate::dataRate): Ditto.
        (WebCore::MediaPlayerPrivate::maxTimeLoaded): Ditto.
        (WebCore::MediaPlayerPrivate::totalBytes): Ditto.

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

WebCore/ChangeLog
WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

index f216b436a742e4ad01c534694cd9bd1baca416f5..ec3fe4667025bf74ecf5b1db92ffccfe5bf6d6be 100644 (file)
@@ -1,3 +1,30 @@
+2009-03-03  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Fix for <rdar://problem/6641045>
+        Don't call QTKit to get movie properties until movie metadata has been loaded.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        (WebCore::MediaPlayerPrivate::metaDataAvailable): defined
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivate::createQTTime): return default if !metaDataAvailable.
+        (WebCore::MediaPlayerPrivate::play): Ditto.
+        (WebCore::MediaPlayerPrivate::pause): Ditto.
+        (WebCore::MediaPlayerPrivate::duration): Ditto.
+        (WebCore::MediaPlayerPrivate::currentTime): Ditto.
+        (WebCore::MediaPlayerPrivate::seek): Ditto.
+        (WebCore::MediaPlayerPrivate::seekTimerFired): Ditto.
+        (WebCore::MediaPlayerPrivate::paused): Ditto.
+        (WebCore::MediaPlayerPrivate::seeking): Ditto.
+        (WebCore::MediaPlayerPrivate::naturalSize): Ditto.
+        (WebCore::MediaPlayerPrivate::hasVideo): Ditto.
+        (WebCore::MediaPlayerPrivate::setVolume): Ditto.
+        (WebCore::MediaPlayerPrivate::setRate): Ditto.
+        (WebCore::MediaPlayerPrivate::dataRate): Ditto.
+        (WebCore::MediaPlayerPrivate::maxTimeLoaded): Ditto.
+        (WebCore::MediaPlayerPrivate::totalBytes): Ditto.
+
 2009-03-03  Kevin McCullough  <kmccullough@apple.com>
 
         - Spelling fix.
index 1a2793f038103b6c8ccfe68b60fa51c5c7081ff7..804637f67cf67b042b95ecc95ad3ce6ec7096bcf 100644 (file)
@@ -127,6 +127,8 @@ private:
     float maxTimeLoaded() const;
     void startEndPointTimerIfNeeded();
     void disableUnsupportedTracks(unsigned& enabledTrackCount);
+    
+    bool metaDataAvailable() const { return m_qtMovie && m_networkState >= MediaPlayer::LoadedMetaData; }
 
     MediaPlayer* m_player;
     RetainPtr<QTMovie> m_qtMovie;
index 320f56d6587bddc61e68644ccc1ea7cb97cb0939..91e91b64b89ec42e1fa96b2fd8c40963f123d1f5 100644 (file)
@@ -389,7 +389,7 @@ void MediaPlayerPrivate::tearDownVideoRendering()
 
 QTTime MediaPlayerPrivate::createQTTime(float time) const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return QTMakeTime(0, 600);
     long timeScale = [[m_qtMovie.get() attributeForKey:QTMovieTimeScaleAttribute] longValue];
     return QTMakeTime(time * timeScale, timeScale);
@@ -418,7 +418,7 @@ void MediaPlayerPrivate::load(const String& url)
 
 void MediaPlayerPrivate::play()
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return;
     m_startedPlaying = true;
 #if DRAW_FRAME_RATE
@@ -432,7 +432,7 @@ void MediaPlayerPrivate::play()
 
 void MediaPlayerPrivate::pause()
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return;
     m_startedPlaying = false;
 #if DRAW_FRAME_RATE
@@ -446,7 +446,7 @@ void MediaPlayerPrivate::pause()
 
 float MediaPlayerPrivate::duration() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return 0;
     QTTime time = [m_qtMovie.get() duration];
     if (time.flags == kQTTimeIsIndefinite)
@@ -456,7 +456,7 @@ float MediaPlayerPrivate::duration() const
 
 float MediaPlayerPrivate::currentTime() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return 0;
     QTTime time = [m_qtMovie.get() currentTime];
     return min(static_cast<float>(time.timeValue) / time.timeScale, m_endTime);
@@ -466,7 +466,7 @@ void MediaPlayerPrivate::seek(float time)
 {
     cancelSeek();
     
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return;
     
     if (time > duration())
@@ -503,7 +503,7 @@ void MediaPlayerPrivate::cancelSeek()
 
 void MediaPlayerPrivate::seekTimerFired(Timer<MediaPlayerPrivate>*)
 {        
-    if (!m_qtMovie || !seeking() || currentTime() == m_seekTo) {
+    if (!metaDataAvailable()|| !seeking() || currentTime() == m_seekTo) {
         cancelSeek();
         updateStates();
         m_player->timeChanged(); 
@@ -547,42 +547,42 @@ void MediaPlayerPrivate::endPointTimerFired(Timer<MediaPlayerPrivate>*)
 
 bool MediaPlayerPrivate::paused() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return true;
     return [m_qtMovie.get() rate] == 0;
 }
 
 bool MediaPlayerPrivate::seeking() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return false;
     return m_seekTo >= 0;
 }
 
 IntSize MediaPlayerPrivate::naturalSize() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return IntSize();
     return IntSize([[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue]);
 }
 
 bool MediaPlayerPrivate::hasVideo() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return false;
     return [[m_qtMovie.get() attributeForKey:QTMovieHasVideoAttribute] boolValue];
 }
 
 void MediaPlayerPrivate::setVolume(float volume)
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return;
     [m_qtMovie.get() setVolume:volume];  
 }
 
 void MediaPlayerPrivate::setRate(float rate)
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return;
     if (!paused())
         [m_qtMovie.get() setRate:rate];
@@ -590,7 +590,7 @@ void MediaPlayerPrivate::setRate(float rate)
 
 int MediaPlayerPrivate::dataRate() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return 0;
     return wkQTMovieDataRate(m_qtMovie.get()); 
 }
@@ -610,7 +610,7 @@ float MediaPlayerPrivate::maxTimeSeekable() const
 
 float MediaPlayerPrivate::maxTimeLoaded() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return 0;
     return wkQTMovieMaxTimeLoaded(m_qtMovie.get()); 
 }
@@ -630,7 +630,7 @@ bool MediaPlayerPrivate::totalBytesKnown() const
 
 unsigned MediaPlayerPrivate::totalBytes() const
 {
-    if (!m_qtMovie)
+    if (!metaDataAvailable())
         return 0;
     return [[m_qtMovie.get() attributeForKey:QTMovieDataSizeAttribute] intValue];
 }