Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1682 WTF_LOG(Media, "HTMLMediaElement::setIgnorePreloadNone(%p)", this); | 1682 WTF_LOG(Media, "HTMLMediaElement::setIgnorePreloadNone(%p)", this); |
| 1683 m_ignorePreloadNone = true; | 1683 m_ignorePreloadNone = true; |
| 1684 setPlayerPreload(); | 1684 setPlayerPreload(); |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 void HTMLMediaElement::seek(double time) | 1687 void HTMLMediaElement::seek(double time) |
| 1688 { | 1688 { |
| 1689 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); | 1689 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); |
| 1690 | 1690 |
| 1691 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. | 1691 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
| 1692 if (m_readyState == HAVE_NOTHING) | 1692 if (m_readyState == HAVE_NOTHING) |
|
liberato (no reviews please)
2016/04/06 14:58:05
would it be better to early out here on !webMediaP
philipj_slow
2016/04/06 15:08:01
I think so, yes. Also duplicate the FIXME from HTM
| |
| 1693 return; | 1693 return; |
| 1694 | 1694 |
| 1695 // Ignore preload none and start load if necessary. | 1695 // Ignore preload none and start load if necessary. |
| 1696 setIgnorePreloadNone(); | 1696 setIgnorePreloadNone(); |
| 1697 | 1697 |
| 1698 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. | 1698 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. |
| 1699 refreshCachedTime(); | 1699 refreshCachedTime(); |
| 1700 // This is needed to avoid getting default playback start position from curr entTime(). | 1700 // This is needed to avoid getting default playback start position from curr entTime(). |
| 1701 double now = m_cachedTime; | 1701 double now = m_cachedTime; |
| 1702 | 1702 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1714 time = std::min(time, duration()); | 1714 time = std::min(time, duration()); |
| 1715 | 1715 |
| 1716 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. | 1716 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. |
| 1717 time = std::max(time, 0.0); | 1717 time = std::max(time, 0.0); |
| 1718 | 1718 |
| 1719 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This | 1719 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This |
| 1720 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's | 1720 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's |
| 1721 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and | 1721 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and |
| 1722 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never | 1722 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never |
| 1723 // fire a 'seeked' event. | 1723 // fire a 'seeked' event. |
| 1724 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | 1724 double mediaTime = webMediaPlayer() ? webMediaPlayer()->mediaTimeForTimeValu e(time) : 0.0; |
| 1725 if (time != mediaTime) { | 1725 if (time != mediaTime) { |
| 1726 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale nt is %f", this, time, mediaTime); | 1726 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale nt is %f", this, time, mediaTime); |
| 1727 time = mediaTime; | 1727 time = mediaTime; |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the | 1730 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the |
| 1731 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute | 1731 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute |
| 1732 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable | 1732 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable |
| 1733 // attribute then set the seeking IDL attribute to false and abort these ste ps. | 1733 // attribute then set the seeking IDL attribute to false and abort these ste ps. |
| 1734 TimeRanges* seekableRanges = seekable(); | 1734 TimeRanges* seekableRanges = seekable(); |
| 1735 | 1735 |
| 1736 if (!seekableRanges->length()) { | 1736 if (!webMediaPlayer() || !seekableRanges->length()) { |
| 1737 m_seeking = false; | 1737 m_seeking = false; |
| 1738 return; | 1738 return; |
| 1739 } | 1739 } |
| 1740 time = seekableRanges->nearest(time, now); | 1740 time = seekableRanges->nearest(time, now); |
| 1741 | 1741 |
| 1742 if (m_playing && m_lastSeekTime < now) | 1742 if (m_playing && m_lastSeekTime < now) |
| 1743 addPlayedRange(m_lastSeekTime, now); | 1743 addPlayedRange(m_lastSeekTime, now); |
| 1744 | 1744 |
| 1745 m_lastSeekTime = time; | 1745 m_lastSeekTime = time; |
| 1746 m_sentEndEvent = false; | 1746 m_sentEndEvent = false; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2130 scheduleEvent(EventTypeNames::pause); | 2130 scheduleEvent(EventTypeNames::pause); |
| 2131 scheduleRejectPlayPromises(AbortError); | 2131 scheduleRejectPlayPromises(AbortError); |
| 2132 } | 2132 } |
| 2133 | 2133 |
| 2134 updatePlayState(); | 2134 updatePlayState(); |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 void HTMLMediaElement::requestRemotePlayback() | 2137 void HTMLMediaElement::requestRemotePlayback() |
| 2138 { | 2138 { |
| 2139 ASSERT(m_remoteRoutesAvailable); | 2139 ASSERT(m_remoteRoutesAvailable); |
| 2140 webMediaPlayer()->requestRemotePlayback(); | 2140 if (webMediaPlayer()) |
|
philipj_slow
2016/04/06 15:08:01
Have you seen a crash here? I'd like to avoid spre
pavor
2016/05/12 12:03:36
I have only seen a crash inside seek. Because I ha
liberato (no reviews please)
2016/05/18 17:27:54
do you see these crashes only on android? can you
| |
| 2141 webMediaPlayer()->requestRemotePlayback(); | |
| 2141 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay back")); | 2142 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay back")); |
| 2142 } | 2143 } |
| 2143 | 2144 |
| 2144 void HTMLMediaElement::requestRemotePlaybackControl() | 2145 void HTMLMediaElement::requestRemotePlaybackControl() |
| 2145 { | 2146 { |
| 2146 ASSERT(m_remoteRoutesAvailable); | 2147 ASSERT(m_remoteRoutesAvailable); |
| 2147 webMediaPlayer()->requestRemotePlaybackControl(); | 2148 if (webMediaPlayer()) |
| 2149 webMediaPlayer()->requestRemotePlaybackControl(); | |
| 2148 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay back_Control")); | 2150 Platform::current()->recordAction(UserMetricsAction("Media_RequestRemotePlay back_Control")); |
| 2149 } | 2151 } |
| 2150 | 2152 |
| 2151 void HTMLMediaElement::closeMediaSource() | 2153 void HTMLMediaElement::closeMediaSource() |
| 2152 { | 2154 { |
| 2153 if (!m_mediaSource) | 2155 if (!m_mediaSource) |
| 2154 return; | 2156 return; |
| 2155 | 2157 |
| 2156 m_mediaSource->close(); | 2158 m_mediaSource->close(); |
| 2157 m_mediaSource = nullptr; | 2159 m_mediaSource = nullptr; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2346 | 2348 |
| 2347 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) | 2349 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) |
| 2348 { | 2350 { |
| 2349 Vector<WebMediaPlayer::TrackId> enabledTrackIds; | 2351 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
| 2350 for (unsigned i = 0; i < audioTracks().length(); ++i) { | 2352 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
| 2351 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); | 2353 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
| 2352 if (track->enabled()) | 2354 if (track->enabled()) |
| 2353 enabledTrackIds.append(track->trackId()); | 2355 enabledTrackIds.append(track->trackId()); |
| 2354 } | 2356 } |
| 2355 | 2357 |
| 2356 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | 2358 if (webMediaPlayer()) |
| 2359 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | |
| 2357 } | 2360 } |
| 2358 | 2361 |
| 2359 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled) | 2362 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled) |
| 2360 { | 2363 { |
| 2361 AtomicString kindString = AudioKindToString(kind); | 2364 AtomicString kindString = AudioKindToString(kind); |
| 2362 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", | 2365 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", |
| 2363 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), enabled); | 2366 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), enabled); |
| 2364 | 2367 |
| 2365 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2368 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2366 return 0; | 2369 return 0; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2390 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId) | 2393 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select edTrackId) |
| 2391 { | 2394 { |
| 2392 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged(%p)", this); | 2395 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged(%p)", this); |
| 2393 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2396 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2394 | 2397 |
| 2395 if (selectedTrackId) | 2398 if (selectedTrackId) |
| 2396 videoTracks().trackSelected(*selectedTrackId); | 2399 videoTracks().trackSelected(*selectedTrackId); |
| 2397 | 2400 |
| 2398 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | 2401 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. |
| 2399 | 2402 |
| 2400 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2403 if (webMediaPlayer()) |
| 2404 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | |
| 2401 } | 2405 } |
| 2402 | 2406 |
| 2403 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected) | 2407 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString& language, bool selected) |
| 2404 { | 2408 { |
| 2405 AtomicString kindString = VideoKindToString(kind); | 2409 AtomicString kindString = VideoKindToString(kind); |
| 2406 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", | 2410 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", |
| 2407 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), selected); | 2411 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), selected); |
| 2408 | 2412 |
| 2409 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2413 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2410 return 0; | 2414 return 0; |
| (...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3882 } | 3886 } |
| 3883 | 3887 |
| 3884 #if !ENABLE(OILPAN) | 3888 #if !ENABLE(OILPAN) |
| 3885 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() | 3889 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() |
| 3886 { | 3890 { |
| 3887 return m_weakPtrFactory.createWeakPtr(); | 3891 return m_weakPtrFactory.createWeakPtr(); |
| 3888 } | 3892 } |
| 3889 #endif | 3893 #endif |
| 3890 | 3894 |
| 3891 } // namespace blink | 3895 } // namespace blink |
| OLD | NEW |