Changeset 202857 in webkit
- Timestamp:
- Jul 6, 2016 6:27:40 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r202856 r202857 1 2016-07-06 Philippe Normand <pnormand@igalia.com> 2 3 [GStreamer] duration query improvements 4 https://bugs.webkit.org/show_bug.cgi?id=159458 5 6 Reviewed by Carlos Garcia Campos. 7 8 Currently the player caches the result of the duration query but 9 this is overkill because it's cached by playbin already. The only 10 time where the player needs to cache the duration is when EOS was 11 reached because in that situation the query would fail. 12 13 No new tests, existing media tests cover this patch. 14 15 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 16 (WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer): Member variables update. 17 (WebCore::MediaPlayerPrivateGStreamer::load): Stop the fill timer 18 before loading a new URL, the same player can be used for 19 different assets. 20 (WebCore::MediaPlayerPrivateGStreamer::playbackPosition): Perform 21 a duration query, the duration value is no longer locally cached. 22 (WebCore::MediaPlayerPrivateGStreamer::duration): Return cached value only after EOS was reached. 23 (WebCore::MediaPlayerPrivateGStreamer::fillTimerFired): Perform 24 a duration query, the duration value is no longer locally cached. 25 (WebCore::MediaPlayerPrivateGStreamer::maxTimeSeekable): Ditto. 26 (WebCore::MediaPlayerPrivateGStreamer::maxTimeLoaded): Ditto. 27 (WebCore::MediaPlayerPrivateGStreamer::didLoadingProgress): Ditto. 28 (WebCore::MediaPlayerPrivateGStreamer::updateStates): Remove duration caching support. 29 (WebCore::MediaPlayerPrivateGStreamer::didEnd): Ditto. 30 (WebCore::MediaPlayerPrivateGStreamer::durationChanged): Ditto. 31 (WebCore::MediaPlayerPrivateGStreamer::cacheDuration): Deleted. 32 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 33 1 34 2016-07-06 Manuel Rego Casasnovas <rego@igalia.com> 2 35 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r202611 r202857 152 152 , m_lastPlaybackRate(1) 153 153 , m_errorOccured(false) 154 , m_mediaDuration(0)155 154 , m_downloadFinished(false) 155 , m_durationAtEOS(0) 156 156 , m_fillTimer(*this, &MediaPlayerPrivateGStreamer::fillTimerFired) 157 157 , m_maxTimeLoaded(0) … … 159 159 , m_preload(player->preload()) 160 160 , m_delayingLoad(false) 161 , m_mediaDurationKnown(true)162 161 , m_maxTimeLoadedAtLastDidLoadingProgress(0) 163 162 , m_volumeAndMuteInitialized(false) … … 238 237 createGSTPlayBin(); 239 238 239 if (m_fillTimer.isActive()) 240 m_fillTimer.stop(); 241 240 242 ASSERT(m_pipeline); 241 243 … … 257 259 m_player->readyStateChanged(); 258 260 m_volumeAndMuteInitialized = false; 261 m_durationAtEOS = 0; 259 262 260 263 if (!m_delayingLoad) … … 300 303 if (m_seeking) 301 304 return m_seekTime; 302 if (m_mediaDuration) 303 return m_mediaDuration; 305 306 float mediaDuration = duration(); 307 if (mediaDuration) 308 return mediaDuration; 304 309 return 0; 305 310 } … … 417 422 return 0.0f; 418 423 419 // Media duration query failed already, don't attempt new useless queries.420 if (!m_mediaDurationKnown)421 return numeric_limits<float>::infinity(); 422 423 if ( m_mediaDuration)424 return m_mediaDuration;424 if (m_durationAtEOS) 425 return m_durationAtEOS; 426 427 // The duration query would fail on a not-prerolled pipeline. 428 if (GST_STATE(m_pipeline.get()) < GST_STATE_PAUSED) 429 return 0.0f; 425 430 426 431 GstFormat timeFormat = GST_FORMAT_TIME; … … 435 440 LOG_MEDIA_MESSAGE("Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength)); 436 441 437 m_mediaDuration = static_cast<double>(timeLength) / GST_SECOND; 438 return m_mediaDuration; 442 return static_cast<double>(timeLength) / GST_SECOND; 439 443 // FIXME: handle 3.14.9.5 properly 440 444 } … … 1178 1182 LOG_MEDIA_MESSAGE("[Buffering] Download buffer filled up to %f%%", fillStatus); 1179 1183 1180 if (!m_mediaDuration) 1181 durationChanged(); 1184 float mediaDuration = duration(); 1182 1185 1183 1186 // Update maxTimeLoaded only if the media duration is 1184 1187 // available. Otherwise we can't compute it. 1185 if (m _mediaDuration) {1188 if (mediaDuration) { 1186 1189 if (fillStatus == 100.0) 1187 m_maxTimeLoaded = m _mediaDuration;1190 m_maxTimeLoaded = mediaDuration; 1188 1191 else 1189 m_maxTimeLoaded = static_cast<float>((fillStatus * m _mediaDuration) / 100.0);1192 m_maxTimeLoaded = static_cast<float>((fillStatus * mediaDuration) / 100.0); 1190 1193 LOG_MEDIA_MESSAGE("[Buffering] Updated maxTimeLoaded: %f", m_maxTimeLoaded); 1191 1194 } … … 1209 1212 return 0.0f; 1210 1213 1211 LOG_MEDIA_MESSAGE("maxTimeSeekable"); 1214 float mediaDuration = duration(); 1215 LOG_MEDIA_MESSAGE("maxTimeSeekable, duration: %f", mediaDuration); 1212 1216 // infinite duration means live stream 1213 if (std::isinf( duration()))1217 if (std::isinf(mediaDuration)) 1214 1218 return 0.0f; 1215 1219 1216 return duration();1220 return mediaDuration; 1217 1221 } 1218 1222 … … 1223 1227 1224 1228 float loaded = m_maxTimeLoaded; 1225 if (m_isEndReached && m_mediaDuration)1226 loaded = m_mediaDuration;1229 if (m_isEndReached) 1230 loaded = duration(); 1227 1231 LOG_MEDIA_MESSAGE("maxTimeLoaded: %f", loaded); 1228 1232 return loaded; … … 1231 1235 bool MediaPlayerPrivateGStreamer::didLoadingProgress() const 1232 1236 { 1233 if (!m_pipeline || ! m_mediaDuration|| (!isMediaSource() && !totalBytes()))1237 if (!m_pipeline || !duration() || (!isMediaSource() && !totalBytes())) 1234 1238 return false; 1235 1239 float currentMaxTimeLoaded = maxTimeLoaded(); … … 1375 1379 break; 1376 1380 1377 if (state <= GST_STATE_READY) { 1378 m_resetPipeline = true; 1379 m_mediaDuration = 0; 1380 } else { 1381 m_resetPipeline = false; 1382 cacheDuration(); 1383 } 1381 m_resetPipeline = state <= GST_STATE_READY; 1384 1382 1385 1383 bool didBuffering = m_buffering; … … 1616 1614 // position is not always reported as 0 for instance. 1617 1615 float now = currentTime(); 1618 if (now > 0 && now <= duration() && m_mediaDuration != now) { 1619 m_mediaDurationKnown = true; 1620 m_mediaDuration = now; 1616 if (now > 0 && now <= duration()) 1621 1617 m_player->durationChanged(); 1622 }1623 1618 1624 1619 m_isEndReached = true; … … 1627 1622 if (!m_player->client().mediaPlayerIsLooping()) { 1628 1623 m_paused = true; 1624 m_durationAtEOS = duration(); 1629 1625 changePipelineState(GST_STATE_READY); 1630 1626 m_downloadFinished = false; … … 1632 1628 } 1633 1629 1634 void MediaPlayerPrivateGStreamer::cacheDuration()1635 {1636 if (m_mediaDuration || !m_mediaDurationKnown)1637 return;1638 1639 float newDuration = duration();1640 if (std::isinf(newDuration)) {1641 // Only pretend that duration is not available if the the query failed in a stable pipeline state.1642 GstState state;1643 if (gst_element_get_state(m_pipeline.get(), &state, nullptr, 0) == GST_STATE_CHANGE_SUCCESS && state > GST_STATE_READY)1644 m_mediaDurationKnown = false;1645 return;1646 }1647 1648 m_mediaDuration = newDuration;1649 }1650 1651 1630 void MediaPlayerPrivateGStreamer::durationChanged() 1652 1631 { 1653 float previousDuration = m_mediaDuration; 1654 1655 cacheDuration(); 1632 float previousDuration = duration(); 1633 1656 1634 // Avoid emiting durationchanged in the case where the previous 1657 1635 // duration was 0 because that case is already handled by the 1658 1636 // HTMLMediaElement. 1659 if (previousDuration && m_mediaDuration!= previousDuration)1637 if (previousDuration && duration() != previousDuration) 1660 1638 m_player->durationChanged(); 1661 1639 } -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
r202611 r202857 138 138 float playbackPosition() const; 139 139 140 void cacheDuration();141 140 void updateStates(); 142 141 void asyncStateChangeDone(); … … 220 219 float m_lastPlaybackRate; 221 220 bool m_errorOccured; 222 mutable gfloat m_mediaDuration;223 221 bool m_downloadFinished; 222 float m_durationAtEOS; 224 223 Timer m_fillTimer; 225 224 float m_maxTimeLoaded; … … 227 226 MediaPlayer::Preload m_preload; 228 227 bool m_delayingLoad; 229 bool m_mediaDurationKnown;230 228 mutable float m_maxTimeLoadedAtLastDidLoadingProgress; 231 229 bool m_volumeAndMuteInitialized;
Note: See TracChangeset
for help on using the changeset viewer.