| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 contentMIMEType == "application/octet-stream" || | 255 contentMIMEType == "application/octet-stream" || |
| 256 contentMIMEType == "text/plain") { | 256 contentMIMEType == "text/plain") { |
| 257 if (url.protocolIsData()) | 257 if (url.protocolIsData()) |
| 258 contentMIMEType = mimeTypeFromDataURL(url.getString()); | 258 contentMIMEType = mimeTypeFromDataURL(url.getString()); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // If no MIME type is specified, always attempt to load. | 261 // If no MIME type is specified, always attempt to load. |
| 262 if (contentMIMEType.isEmpty()) | 262 if (contentMIMEType.isEmpty()) |
| 263 return true; | 263 return true; |
| 264 | 264 |
| 265 // 4.8.10.3 MIME types - In the absence of a specification to the contrary, | 265 // 4.8.12.3 MIME types - In the absence of a specification to the contrary, |
| 266 // the MIME type "application/octet-stream" when used with parameters, e.g. | 266 // the MIME type "application/octet-stream" when used with parameters, e.g. |
| 267 // "application/octet-stream;codecs=theora", is a type that the user agent | 267 // "application/octet-stream;codecs=theora", is a type that the user agent |
| 268 // knows it cannot render. | 268 // knows it cannot render. |
| 269 if (contentMIMEType != "application/octet-stream" || | 269 if (contentMIMEType != "application/octet-stream" || |
| 270 contentTypeCodecs.isEmpty()) { | 270 contentTypeCodecs.isEmpty()) { |
| 271 return MIMETypeRegistry::supportsMediaMIMEType(contentMIMEType, | 271 return MIMETypeRegistry::supportsMediaMIMEType(contentMIMEType, |
| 272 contentTypeCodecs); | 272 contentTypeCodecs); |
| 273 } | 273 } |
| 274 | 274 |
| 275 return false; | 275 return false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 330 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
| 331 | 331 |
| 332 String type = contentType.type().lower(); | 332 String type = contentType.type().lower(); |
| 333 // The codecs string is not lower-cased because MP4 values are case sensitive | 333 // The codecs string is not lower-cased because MP4 values are case sensitive |
| 334 // per http://tools.ietf.org/html/rfc4281#page-7. | 334 // per http://tools.ietf.org/html/rfc4281#page-7. |
| 335 String typeCodecs = contentType.parameter(codecs); | 335 String typeCodecs = contentType.parameter(codecs); |
| 336 | 336 |
| 337 if (type.isEmpty()) | 337 if (type.isEmpty()) |
| 338 return MIMETypeRegistry::IsNotSupported; | 338 return MIMETypeRegistry::IsNotSupported; |
| 339 | 339 |
| 340 // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty | 340 // 4.8.12.3 MIME types - The canPlayType(type) method must return the empty |
| 341 // string if type is a type that the user agent knows it cannot render or is | 341 // string if type is a type that the user agent knows it cannot render or is |
| 342 // the type "application/octet-stream" | 342 // the type "application/octet-stream" |
| 343 if (type == "application/octet-stream") | 343 if (type == "application/octet-stream") |
| 344 return MIMETypeRegistry::IsNotSupported; | 344 return MIMETypeRegistry::IsNotSupported; |
| 345 | 345 |
| 346 return MIMETypeRegistry::supportsMediaMIMEType(type, typeCodecs); | 346 return MIMETypeRegistry::supportsMediaMIMEType(type, typeCodecs); |
| 347 } | 347 } |
| 348 | 348 |
| 349 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; | 349 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; |
| 350 | 350 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 732 } |
| 733 | 733 |
| 734 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const { | 734 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const { |
| 735 return m_networkState; | 735 return m_networkState; |
| 736 } | 736 } |
| 737 | 737 |
| 738 String HTMLMediaElement::canPlayType(const String& mimeType) const { | 738 String HTMLMediaElement::canPlayType(const String& mimeType) const { |
| 739 MIMETypeRegistry::SupportsType support = supportsType(ContentType(mimeType)); | 739 MIMETypeRegistry::SupportsType support = supportsType(ContentType(mimeType)); |
| 740 String canPlay; | 740 String canPlay; |
| 741 | 741 |
| 742 // 4.8.10.3 | 742 // 4.8.12.3 |
| 743 switch (support) { | 743 switch (support) { |
| 744 case MIMETypeRegistry::IsNotSupported: | 744 case MIMETypeRegistry::IsNotSupported: |
| 745 canPlay = emptyString; | 745 canPlay = emptyString; |
| 746 break; | 746 break; |
| 747 case MIMETypeRegistry::MayBeSupported: | 747 case MIMETypeRegistry::MayBeSupported: |
| 748 canPlay = "maybe"; | 748 canPlay = "maybe"; |
| 749 break; | 749 break; |
| 750 case MIMETypeRegistry::IsSupported: | 750 case MIMETypeRegistry::IsSupported: |
| 751 canPlay = "probably"; | 751 canPlay = "probably"; |
| 752 break; | 752 break; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 | 1220 |
| 1221 if (loadIsDeferred() && effectivePreloadType() != WebMediaPlayer::PreloadNone) | 1221 if (loadIsDeferred() && effectivePreloadType() != WebMediaPlayer::PreloadNone) |
| 1222 startDeferredLoad(); | 1222 startDeferredLoad(); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 bool HTMLMediaElement::loadIsDeferred() const { | 1225 bool HTMLMediaElement::loadIsDeferred() const { |
| 1226 return m_deferredLoadState != NotDeferred; | 1226 return m_deferredLoadState != NotDeferred; |
| 1227 } | 1227 } |
| 1228 | 1228 |
| 1229 void HTMLMediaElement::deferLoad() { | 1229 void HTMLMediaElement::deferLoad() { |
| 1230 // This implements the "optional" step 3 from the resource fetch algorithm. | 1230 // This implements the "optional" step 4 from the resource fetch algorithm |
| 1231 // "If mode is remote". |
| 1231 DCHECK(!m_deferredLoadTimer.isActive()); | 1232 DCHECK(!m_deferredLoadTimer.isActive()); |
| 1232 DCHECK_EQ(m_deferredLoadState, NotDeferred); | 1233 DCHECK_EQ(m_deferredLoadState, NotDeferred); |
| 1233 // 1. Set the networkState to NETWORK_IDLE. | 1234 // 1. Set the networkState to NETWORK_IDLE. |
| 1234 // 2. Queue a task to fire a simple event named suspend at the element. | 1235 // 2. Queue a task to fire a simple event named suspend at the element. |
| 1235 changeNetworkStateFromLoadingToIdle(); | 1236 changeNetworkStateFromLoadingToIdle(); |
| 1236 // 3. Queue a task to set the element's delaying-the-load-event | 1237 // 3. Queue a task to set the element's delaying-the-load-event |
| 1237 // flag to false. This stops delaying the load event. | 1238 // flag to false. This stops delaying the load event. |
| 1238 m_deferredLoadTimer.startOneShot(0, BLINK_FROM_HERE); | 1239 m_deferredLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1239 // 4. Wait for the task to be run. | 1240 // 4. Wait for the task to be run. |
| 1240 m_deferredLoadState = WaitingForStopDelayingLoadEventTask; | 1241 m_deferredLoadState = WaitingForStopDelayingLoadEventTask; |
| 1241 // Continued in executeDeferredLoad(). | 1242 // Continued in executeDeferredLoad(). |
| 1242 } | 1243 } |
| 1243 | 1244 |
| 1244 void HTMLMediaElement::cancelDeferredLoad() { | 1245 void HTMLMediaElement::cancelDeferredLoad() { |
| 1245 m_deferredLoadTimer.stop(); | 1246 m_deferredLoadTimer.stop(); |
| 1246 m_deferredLoadState = NotDeferred; | 1247 m_deferredLoadState = NotDeferred; |
| 1247 } | 1248 } |
| 1248 | 1249 |
| 1249 void HTMLMediaElement::executeDeferredLoad() { | 1250 void HTMLMediaElement::executeDeferredLoad() { |
| 1250 DCHECK_GE(m_deferredLoadState, WaitingForTrigger); | 1251 DCHECK_GE(m_deferredLoadState, WaitingForTrigger); |
| 1251 | 1252 |
| 1252 // resource fetch algorithm step 3 - continued from deferLoad(). | 1253 // resource fetch algorithm step 4 - continued from deferLoad(). |
| 1253 | 1254 |
| 1254 // 5. Wait for an implementation-defined event (e.g. the user requesting that | 1255 // 5. Wait for an implementation-defined event (e.g. the user requesting that |
| 1255 // the media element begin playback). This is assumed to be whatever 'event' | 1256 // the media element begin playback). This is assumed to be whatever 'event' |
| 1256 // ended up calling this method. | 1257 // ended up calling this method. |
| 1257 cancelDeferredLoad(); | 1258 cancelDeferredLoad(); |
| 1258 // 6. Set the element's delaying-the-load-event flag back to true (this | 1259 // 6. Set the element's delaying-the-load-event flag back to true (this |
| 1259 // delays the load event again, in case it hasn't been fired yet). | 1260 // delays the load event again, in case it hasn't been fired yet). |
| 1260 setShouldDelayLoadEvent(true); | 1261 setShouldDelayLoadEvent(true); |
| 1261 // 7. Set the networkState to NETWORK_LOADING. | 1262 // 7. Set the networkState to NETWORK_LOADING. |
| 1262 setNetworkState(kNetworkLoading); | 1263 setNetworkState(kNetworkLoading); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1293 return WebMediaPlayer::LoadTypeMediaSource; | 1294 return WebMediaPlayer::LoadTypeMediaSource; |
| 1294 | 1295 |
| 1295 if (m_srcObject || | 1296 if (m_srcObject || |
| 1296 (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc.getString()))) | 1297 (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc.getString()))) |
| 1297 return WebMediaPlayer::LoadTypeMediaStream; | 1298 return WebMediaPlayer::LoadTypeMediaStream; |
| 1298 | 1299 |
| 1299 return WebMediaPlayer::LoadTypeURL; | 1300 return WebMediaPlayer::LoadTypeURL; |
| 1300 } | 1301 } |
| 1301 | 1302 |
| 1302 bool HTMLMediaElement::textTracksAreReady() const { | 1303 bool HTMLMediaElement::textTracksAreReady() const { |
| 1303 // 4.8.10.12.1 Text track model | 1304 // 4.8.12.11.1 Text track model |
| 1304 // ... | 1305 // ... |
| 1305 // The text tracks of a media element are ready if all the text tracks whose | 1306 // The text tracks of a media element are ready if all the text tracks whose |
| 1306 // mode was not in the disabled state when the element's resource selection | 1307 // mode was not in the disabled state when the element's resource selection |
| 1307 // algorithm last started now have a text track readiness state of loaded or | 1308 // algorithm last started now have a text track readiness state of loaded or |
| 1308 // failed to load. | 1309 // failed to load. |
| 1309 for (const auto& textTrack : m_textTracksWhenResourceSelectionBegan) { | 1310 for (const auto& textTrack : m_textTracksWhenResourceSelectionBegan) { |
| 1310 if (textTrack->getReadinessState() == TextTrack::Loading || | 1311 if (textTrack->getReadinessState() == TextTrack::Loading || |
| 1311 textTrack->getReadinessState() == TextTrack::NotLoaded) | 1312 textTrack->getReadinessState() == TextTrack::NotLoaded) |
| 1312 return false; | 1313 return false; |
| 1313 } | 1314 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 layoutObject()->updateFromElement(); | 1428 layoutObject()->updateFromElement(); |
| 1428 } | 1429 } |
| 1429 | 1430 |
| 1430 void HTMLMediaElement::noneSupported() { | 1431 void HTMLMediaElement::noneSupported() { |
| 1431 BLINK_MEDIA_LOG << "noneSupported(" << (void*)this << ")"; | 1432 BLINK_MEDIA_LOG << "noneSupported(" << (void*)this << ")"; |
| 1432 | 1433 |
| 1433 stopPeriodicTimers(); | 1434 stopPeriodicTimers(); |
| 1434 m_loadState = WaitingForSource; | 1435 m_loadState = WaitingForSource; |
| 1435 m_currentSourceNode = nullptr; | 1436 m_currentSourceNode = nullptr; |
| 1436 | 1437 |
| 1437 // 4.8.13.5 | 1438 // 4.8.12.5 |
| 1438 // The dedicated media source failure steps are the following steps: | 1439 // The dedicated media source failure steps are the following steps: |
| 1439 | 1440 |
| 1440 // 1 - Set the error attribute to a new MediaError object whose code attribute | 1441 // 1 - Set the error attribute to a new MediaError object whose code attribute |
| 1441 // is set to MEDIA_ERR_SRC_NOT_SUPPORTED. | 1442 // is set to MEDIA_ERR_SRC_NOT_SUPPORTED. |
| 1442 m_error = MediaError::create(MediaError::kMediaErrSrcNotSupported); | 1443 m_error = MediaError::create(MediaError::kMediaErrSrcNotSupported); |
| 1443 | 1444 |
| 1444 // 2 - Forget the media element's media-resource-specific text tracks. | 1445 // 2 - Forget the media element's media-resource-specific text tracks. |
| 1445 forgetResourceSpecificTracks(); | 1446 forgetResourceSpecificTracks(); |
| 1446 | 1447 |
| 1447 // 3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE | 1448 // 3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 m_readyState = kHaveCurrentData; | 1645 m_readyState = kHaveCurrentData; |
| 1645 } | 1646 } |
| 1646 | 1647 |
| 1647 if (oldState > m_readyStateMaximum) | 1648 if (oldState > m_readyStateMaximum) |
| 1648 m_readyStateMaximum = oldState; | 1649 m_readyStateMaximum = oldState; |
| 1649 | 1650 |
| 1650 if (m_networkState == kNetworkEmpty) | 1651 if (m_networkState == kNetworkEmpty) |
| 1651 return; | 1652 return; |
| 1652 | 1653 |
| 1653 if (m_seeking) { | 1654 if (m_seeking) { |
| 1654 // 4.8.10.9, step 9 note: If the media element was potentially playing | 1655 // 4.8.12.9, step 9 note: If the media element was potentially playing |
| 1655 // immediately before it started seeking, but seeking caused its readyState | 1656 // immediately before it started seeking, but seeking caused its readyState |
| 1656 // attribute to change to a value lower than kHaveFutureData, then a waiting | 1657 // attribute to change to a value lower than kHaveFutureData, then a waiting |
| 1657 // will be fired at the element. | 1658 // will be fired at the element. |
| 1658 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) | 1659 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) |
| 1659 scheduleEvent(EventTypeNames::waiting); | 1660 scheduleEvent(EventTypeNames::waiting); |
| 1660 | 1661 |
| 1661 // 4.8.10.9 steps 12-14 | 1662 // 4.8.12.9 steps 12-14 |
| 1662 if (m_readyState >= kHaveCurrentData) | 1663 if (m_readyState >= kHaveCurrentData) |
| 1663 finishSeek(); | 1664 finishSeek(); |
| 1664 } else { | 1665 } else { |
| 1665 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) { | 1666 if (wasPotentiallyPlaying && m_readyState < kHaveFutureData) { |
| 1666 // Force an update to official playback position. Automatic updates from | 1667 // Force an update to official playback position. Automatic updates from |
| 1667 // currentPlaybackPosition() will be blocked while m_readyState remains | 1668 // currentPlaybackPosition() will be blocked while m_readyState remains |
| 1668 // < kHaveFutureData. This blocking is desired after 'waiting' has been | 1669 // < kHaveFutureData. This blocking is desired after 'waiting' has been |
| 1669 // fired, but its good to update it one final time to accurately reflect | 1670 // fired, but its good to update it one final time to accurately reflect |
| 1670 // media time at the moment we ran out of data to play. | 1671 // media time at the moment we ran out of data to play. |
| 1671 setOfficialPlaybackPosition(currentPlaybackPosition()); | 1672 setOfficialPlaybackPosition(currentPlaybackPosition()); |
| 1672 | 1673 |
| 1673 // 4.8.10.8 | 1674 // 4.8.12.8 |
| 1674 scheduleTimeupdateEvent(false); | 1675 scheduleTimeupdateEvent(false); |
| 1675 scheduleEvent(EventTypeNames::waiting); | 1676 scheduleEvent(EventTypeNames::waiting); |
| 1676 } | 1677 } |
| 1677 } | 1678 } |
| 1678 | 1679 |
| 1679 // Once enough of the media data has been fetched to determine the duration of | 1680 // Once enough of the media data has been fetched to determine the duration of |
| 1680 // the media resource, its dimensions, and other metadata... | 1681 // the media resource, its dimensions, and other metadata... |
| 1681 if (m_readyState >= kHaveMetadata && oldState < kHaveMetadata) { | 1682 if (m_readyState >= kHaveMetadata && oldState < kHaveMetadata) { |
| 1682 createPlaceholderTracksIfNecessary(); | 1683 createPlaceholderTracksIfNecessary(); |
| 1683 | 1684 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 | 2107 |
| 2107 void HTMLMediaElement::updatePlaybackRate() { | 2108 void HTMLMediaElement::updatePlaybackRate() { |
| 2108 // FIXME: remove m_webMediaPlayer check once we figure out how | 2109 // FIXME: remove m_webMediaPlayer check once we figure out how |
| 2109 // m_webMediaPlayer is going out of sync with readystate. | 2110 // m_webMediaPlayer is going out of sync with readystate. |
| 2110 // m_webMediaPlayer is cleared but readystate is not set to kHaveNothing. | 2111 // m_webMediaPlayer is cleared but readystate is not set to kHaveNothing. |
| 2111 if (m_webMediaPlayer && potentiallyPlaying()) | 2112 if (m_webMediaPlayer && potentiallyPlaying()) |
| 2112 webMediaPlayer()->setRate(playbackRate()); | 2113 webMediaPlayer()->setRate(playbackRate()); |
| 2113 } | 2114 } |
| 2114 | 2115 |
| 2115 bool HTMLMediaElement::ended() const { | 2116 bool HTMLMediaElement::ended() const { |
| 2116 // 4.8.10.8 Playing the media resource | 2117 // 4.8.12.8 Playing the media resource |
| 2117 // The ended attribute must return true if the media element has ended | 2118 // The ended attribute must return true if the media element has ended |
| 2118 // playback and the direction of playback is forwards, and false otherwise. | 2119 // playback and the direction of playback is forwards, and false otherwise. |
| 2119 return endedPlayback() && getDirectionOfPlayback() == Forward; | 2120 return endedPlayback() && getDirectionOfPlayback() == Forward; |
| 2120 } | 2121 } |
| 2121 | 2122 |
| 2122 bool HTMLMediaElement::autoplay() const { | 2123 bool HTMLMediaElement::autoplay() const { |
| 2123 return fastHasAttribute(autoplayAttr); | 2124 return fastHasAttribute(autoplayAttr); |
| 2124 } | 2125 } |
| 2125 | 2126 |
| 2126 bool HTMLMediaElement::shouldAutoplay() { | 2127 bool HTMLMediaElement::shouldAutoplay() { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 void HTMLMediaElement::playInternal() { | 2289 void HTMLMediaElement::playInternal() { |
| 2289 BLINK_MEDIA_LOG << "playInternal(" << (void*)this << ")"; | 2290 BLINK_MEDIA_LOG << "playInternal(" << (void*)this << ")"; |
| 2290 | 2291 |
| 2291 // Always return the buffering strategy to normal when not paused, | 2292 // Always return the buffering strategy to normal when not paused, |
| 2292 // regardless of the cause. (In contrast with aggressive buffering which is | 2293 // regardless of the cause. (In contrast with aggressive buffering which is |
| 2293 // only enabled by pause(), not pauseInternal().) | 2294 // only enabled by pause(), not pauseInternal().) |
| 2294 if (webMediaPlayer()) | 2295 if (webMediaPlayer()) |
| 2295 webMediaPlayer()->setBufferingStrategy( | 2296 webMediaPlayer()->setBufferingStrategy( |
| 2296 WebMediaPlayer::BufferingStrategy::Normal); | 2297 WebMediaPlayer::BufferingStrategy::Normal); |
| 2297 | 2298 |
| 2298 // 4.8.10.9. Playing the media resource | 2299 // 4.8.12.8. Playing the media resource |
| 2299 if (m_networkState == kNetworkEmpty) | 2300 if (m_networkState == kNetworkEmpty) |
| 2300 invokeResourceSelectionAlgorithm(); | 2301 invokeResourceSelectionAlgorithm(); |
| 2301 | 2302 |
| 2302 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 2303 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| 2303 // is ignored to seek back to start in case loop was set after playback | 2304 // is ignored to seek back to start in case loop was set after playback |
| 2304 // ended. See http://crbug.com/364442 | 2305 // ended. See http://crbug.com/364442 |
| 2305 if (endedPlayback(LoopCondition::Ignored)) | 2306 if (endedPlayback(LoopCondition::Ignored)) |
| 2306 seek(0); | 2307 seek(0); |
| 2307 | 2308 |
| 2308 if (m_paused) { | 2309 if (m_paused) { |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2674 return videoTrack->id(); | 2675 return videoTrack->id(); |
| 2675 } | 2676 } |
| 2676 | 2677 |
| 2677 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { | 2678 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) { |
| 2678 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; | 2679 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; |
| 2679 | 2680 |
| 2680 videoTracks().remove(trackId); | 2681 videoTracks().remove(trackId); |
| 2681 } | 2682 } |
| 2682 | 2683 |
| 2683 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { | 2684 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) { |
| 2684 // 4.8.10.12.2 Sourcing in-band text tracks | 2685 // 4.8.12.11.2 Sourcing in-band text tracks |
| 2685 // 1. Associate the relevant data with a new text track and its corresponding | 2686 // 1. Associate the relevant data with a new text track and its corresponding |
| 2686 // new TextTrack object. | 2687 // new TextTrack object. |
| 2687 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); | 2688 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); |
| 2688 | 2689 |
| 2689 // 2. Set the new text track's kind, label, and language based on the | 2690 // 2. Set the new text track's kind, label, and language based on the |
| 2690 // semantics of the relevant data, as defined by the relevant specification. | 2691 // semantics of the relevant data, as defined by the relevant specification. |
| 2691 // If there is no label in that data, then the label must be set to the empty | 2692 // If there is no label in that data, then the label must be set to the empty |
| 2692 // string. | 2693 // string. |
| 2693 // 3. Associate the text track list of cues with the rules for updating the | 2694 // 3. Associate the text track list of cues with the rules for updating the |
| 2694 // text track rendering appropriate for the format in question. | 2695 // text track rendering appropriate for the format in question. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2785 } | 2786 } |
| 2786 | 2787 |
| 2787 TextTrackList* HTMLMediaElement::textTracks() { | 2788 TextTrackList* HTMLMediaElement::textTracks() { |
| 2788 if (!m_textTracks) | 2789 if (!m_textTracks) |
| 2789 m_textTracks = TextTrackList::create(this); | 2790 m_textTracks = TextTrackList::create(this); |
| 2790 | 2791 |
| 2791 return m_textTracks.get(); | 2792 return m_textTracks.get(); |
| 2792 } | 2793 } |
| 2793 | 2794 |
| 2794 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) { | 2795 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) { |
| 2795 // 4.8.10.12.3 Sourcing out-of-band text tracks | 2796 // 4.8.12.11.3 Sourcing out-of-band text tracks |
| 2796 // When a track element's parent element changes and the new parent is a media | 2797 // When a track element's parent element changes and the new parent is a media |
| 2797 // element, then the user agent must add the track element's corresponding | 2798 // element, then the user agent must add the track element's corresponding |
| 2798 // text track to the media element's list of text tracks ... [continues in | 2799 // text track to the media element's list of text tracks ... [continues in |
| 2799 // TextTrackList::append] | 2800 // TextTrackList::append] |
| 2800 TextTrack* textTrack = trackElement->track(); | 2801 TextTrack* textTrack = trackElement->track(); |
| 2801 if (!textTrack) | 2802 if (!textTrack) |
| 2802 return; | 2803 return; |
| 2803 | 2804 |
| 2804 textTracks()->append(textTrack); | 2805 textTracks()->append(textTrack); |
| 2805 | 2806 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2816 | 2817 |
| 2817 TextTrack* textTrack = trackElement->track(); | 2818 TextTrack* textTrack = trackElement->track(); |
| 2818 if (!textTrack) | 2819 if (!textTrack) |
| 2819 return; | 2820 return; |
| 2820 | 2821 |
| 2821 textTrack->setHasBeenConfigured(false); | 2822 textTrack->setHasBeenConfigured(false); |
| 2822 | 2823 |
| 2823 if (!m_textTracks) | 2824 if (!m_textTracks) |
| 2824 return; | 2825 return; |
| 2825 | 2826 |
| 2826 // 4.8.10.12.3 Sourcing out-of-band text tracks | 2827 // 4.8.12.11.3 Sourcing out-of-band text tracks |
| 2827 // When a track element's parent element changes and the old parent was a | 2828 // When a track element's parent element changes and the old parent was a |
| 2828 // media element, then the user agent must remove the track element's | 2829 // media element, then the user agent must remove the track element's |
| 2829 // corresponding text track from the media element's list of text tracks. | 2830 // corresponding text track from the media element's list of text tracks. |
| 2830 m_textTracks->remove(textTrack); | 2831 m_textTracks->remove(textTrack); |
| 2831 | 2832 |
| 2832 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); | 2833 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack); |
| 2833 if (index != kNotFound) | 2834 if (index != kNotFound) |
| 2834 m_textTracksWhenResourceSelectionBegan.remove(index); | 2835 m_textTracksWhenResourceSelectionBegan.remove(index); |
| 2835 } | 2836 } |
| 2836 | 2837 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this | 3054 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this |
| 3054 << ") - m_currentSourceNode set to 0"; | 3055 << ") - m_currentSourceNode set to 0"; |
| 3055 } | 3056 } |
| 3056 } | 3057 } |
| 3057 | 3058 |
| 3058 void HTMLMediaElement::timeChanged() { | 3059 void HTMLMediaElement::timeChanged() { |
| 3059 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")"; | 3060 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")"; |
| 3060 | 3061 |
| 3061 cueTimeline().updateActiveCues(currentTime()); | 3062 cueTimeline().updateActiveCues(currentTime()); |
| 3062 | 3063 |
| 3063 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with the | 3064 // 4.8.12.9 steps 12-14. Needed if no ReadyState change is associated with the |
| 3064 // seek. | 3065 // seek. |
| 3065 if (m_seeking && m_readyState >= kHaveCurrentData && | 3066 if (m_seeking && m_readyState >= kHaveCurrentData && |
| 3066 !webMediaPlayer()->seeking()) | 3067 !webMediaPlayer()->seeking()) |
| 3067 finishSeek(); | 3068 finishSeek(); |
| 3068 | 3069 |
| 3069 // Always call scheduleTimeupdateEvent when the media engine reports a time | 3070 // Always call scheduleTimeupdateEvent when the media engine reports a time |
| 3070 // discontinuity, it will only queue a 'timeupdate' event if we haven't | 3071 // discontinuity, it will only queue a 'timeupdate' event if we haven't |
| 3071 // already posted one at the current movie time. | 3072 // already posted one at the current movie time. |
| 3072 scheduleTimeupdateEvent(false); | 3073 scheduleTimeupdateEvent(false); |
| 3073 | 3074 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3304 | 3305 |
| 3305 bool HTMLMediaElement::couldPlayIfEnoughData() const { | 3306 bool HTMLMediaElement::couldPlayIfEnoughData() const { |
| 3306 return !paused() && !endedPlayback() && !stoppedDueToErrors(); | 3307 return !paused() && !endedPlayback() && !stoppedDueToErrors(); |
| 3307 } | 3308 } |
| 3308 | 3309 |
| 3309 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const { | 3310 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const { |
| 3310 double dur = duration(); | 3311 double dur = duration(); |
| 3311 if (std::isnan(dur)) | 3312 if (std::isnan(dur)) |
| 3312 return false; | 3313 return false; |
| 3313 | 3314 |
| 3314 // 4.8.10.8 Playing the media resource | 3315 // 4.8.12.8 Playing the media resource |
| 3315 | 3316 |
| 3316 // A media element is said to have ended playback when the element's | 3317 // A media element is said to have ended playback when the element's |
| 3317 // readyState attribute is HAVE_METADATA or greater, | 3318 // readyState attribute is HAVE_METADATA or greater, |
| 3318 if (m_readyState < kHaveMetadata) | 3319 if (m_readyState < kHaveMetadata) |
| 3319 return false; | 3320 return false; |
| 3320 | 3321 |
| 3321 // and the current playback position is the end of the media resource and the | 3322 // and the current playback position is the end of the media resource and the |
| 3322 // direction of playback is forwards, Either the media element does not have a | 3323 // direction of playback is forwards, Either the media element does not have a |
| 3323 // loop attribute specified, | 3324 // loop attribute specified, |
| 3324 double now = currentPlaybackPosition(); | 3325 double now = currentPlaybackPosition(); |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4168 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4169 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4169 } | 4170 } |
| 4170 | 4171 |
| 4171 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4172 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4172 m_mostlyFillingViewport = true; | 4173 m_mostlyFillingViewport = true; |
| 4173 if (m_webMediaPlayer) | 4174 if (m_webMediaPlayer) |
| 4174 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4175 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4175 } | 4176 } |
| 4176 | 4177 |
| 4177 } // namespace blink | 4178 } // namespace blink |
| OLD | NEW |