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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #include "wtf/MathExtras.h" | 74 #include "wtf/MathExtras.h" |
75 #include "wtf/NonCopyingSort.h" | 75 #include "wtf/NonCopyingSort.h" |
76 #include "wtf/Uint8Array.h" | 76 #include "wtf/Uint8Array.h" |
77 #include "wtf/text/CString.h" | 77 #include "wtf/text/CString.h" |
78 | 78 |
79 #if ENABLE(WEB_AUDIO) | 79 #if ENABLE(WEB_AUDIO) |
80 #include "platform/audio/AudioSourceProvider.h" | 80 #include "platform/audio/AudioSourceProvider.h" |
81 #include "platform/audio/AudioSourceProviderClient.h" | 81 #include "platform/audio/AudioSourceProviderClient.h" |
82 #endif | 82 #endif |
83 | 83 |
84 using namespace std; | |
85 using blink::WebInbandTextTrack; | 84 using blink::WebInbandTextTrack; |
86 using blink::WebMediaPlayer; | 85 using blink::WebMediaPlayer; |
87 using blink::WebMimeRegistry; | 86 using blink::WebMimeRegistry; |
88 | 87 |
89 namespace WebCore { | 88 namespace WebCore { |
90 | 89 |
91 #if !LOG_DISABLED | 90 #if !LOG_DISABLED |
92 static String urlForLoggingMedia(const KURL& url) | 91 static String urlForLoggingMedia(const KURL& url) |
93 { | 92 { |
94 static const unsigned maximumURLLengthForLogging = 128; | 93 static const unsigned maximumURLLengthForLogging = 128; |
(...skipping 18 matching lines...) Expand all Loading... |
113 #ifndef LOG_CACHED_TIME_WARNINGS | 112 #ifndef LOG_CACHED_TIME_WARNINGS |
114 // Default to not logging warnings about excessive drift in the cached media tim
e because it adds a | 113 // Default to not logging warnings about excessive drift in the cached media tim
e because it adds a |
115 // fair amount of overhead and logging. | 114 // fair amount of overhead and logging. |
116 #define LOG_CACHED_TIME_WARNINGS 0 | 115 #define LOG_CACHED_TIME_WARNINGS 0 |
117 #endif | 116 #endif |
118 | 117 |
119 // URL protocol used to signal that the media source API is being used. | 118 // URL protocol used to signal that the media source API is being used. |
120 static const char mediaSourceBlobProtocol[] = "blob"; | 119 static const char mediaSourceBlobProtocol[] = "blob"; |
121 | 120 |
122 using namespace HTMLNames; | 121 using namespace HTMLNames; |
123 using namespace std; | |
124 | 122 |
125 typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > WeakMediaEl
ementSet; | 123 typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > WeakMediaEl
ementSet; |
126 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WeakMediaElementSet>
DocumentElementSetMap; | 124 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WeakMediaElementSet>
DocumentElementSetMap; |
127 static DocumentElementSetMap& documentToElementSetMap() | 125 static DocumentElementSetMap& documentToElementSetMap() |
128 { | 126 { |
129 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DocumentElementSetMap>, map, (ado
ptPtrWillBeNoop(new DocumentElementSetMap()))); | 127 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DocumentElementSetMap>, map, (ado
ptPtrWillBeNoop(new DocumentElementSetMap()))); |
130 return *map; | 128 return *map; |
131 } | 129 } |
132 | 130 |
133 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen
t) | 131 static void addElementToDocumentMap(HTMLMediaElement* element, Document* documen
t) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) | 235 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) |
238 , m_playedTimeRanges() | 236 , m_playedTimeRanges() |
239 , m_asyncEventQueue(GenericEventQueue::create(this)) | 237 , m_asyncEventQueue(GenericEventQueue::create(this)) |
240 , m_playbackRate(1.0f) | 238 , m_playbackRate(1.0f) |
241 , m_defaultPlaybackRate(1.0f) | 239 , m_defaultPlaybackRate(1.0f) |
242 , m_networkState(NETWORK_EMPTY) | 240 , m_networkState(NETWORK_EMPTY) |
243 , m_readyState(HAVE_NOTHING) | 241 , m_readyState(HAVE_NOTHING) |
244 , m_readyStateMaximum(HAVE_NOTHING) | 242 , m_readyStateMaximum(HAVE_NOTHING) |
245 , m_volume(1.0f) | 243 , m_volume(1.0f) |
246 , m_lastSeekTime(0) | 244 , m_lastSeekTime(0) |
247 , m_previousProgressTime(numeric_limits<double>::max()) | 245 , m_previousProgressTime(std::numeric_limits<double>::max()) |
248 , m_duration(numeric_limits<double>::quiet_NaN()) | 246 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
249 , m_lastTimeUpdateEventWallTime(0) | 247 , m_lastTimeUpdateEventWallTime(0) |
250 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max()) | 248 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max()) |
251 , m_loadState(WaitingForSource) | 249 , m_loadState(WaitingForSource) |
252 , m_webLayer(0) | 250 , m_webLayer(0) |
253 , m_preload(MediaPlayer::Auto) | 251 , m_preload(MediaPlayer::Auto) |
254 , m_displayMode(Unknown) | 252 , m_displayMode(Unknown) |
255 , m_cachedTime(MediaPlayer::invalidTime()) | 253 , m_cachedTime(MediaPlayer::invalidTime()) |
256 , m_cachedTimeWallClockUpdateTime(0) | 254 , m_cachedTimeWallClockUpdateTime(0) |
257 , m_minimumWallClockTimeToCacheMediaTime(0) | 255 , m_minimumWallClockTimeToCacheMediaTime(0) |
258 , m_fragmentStartTime(MediaPlayer::invalidTime()) | 256 , m_fragmentStartTime(MediaPlayer::invalidTime()) |
259 , m_fragmentEndTime(MediaPlayer::invalidTime()) | 257 , m_fragmentEndTime(MediaPlayer::invalidTime()) |
260 , m_pendingActionFlags(0) | 258 , m_pendingActionFlags(0) |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 // 1 - Set the networkState to NETWORK_NO_SOURCE | 713 // 1 - Set the networkState to NETWORK_NO_SOURCE |
716 m_networkState = NETWORK_NO_SOURCE; | 714 m_networkState = NETWORK_NO_SOURCE; |
717 | 715 |
718 // 2 - Asynchronously await a stable state. | 716 // 2 - Asynchronously await a stable state. |
719 | 717 |
720 m_playedTimeRanges = TimeRanges::create(); | 718 m_playedTimeRanges = TimeRanges::create(); |
721 | 719 |
722 // FIXME: Investigate whether these can be moved into m_networkState != NETW
ORK_EMPTY block above | 720 // FIXME: Investigate whether these can be moved into m_networkState != NETW
ORK_EMPTY block above |
723 // so they are closer to the relevant spec steps. | 721 // so they are closer to the relevant spec steps. |
724 m_lastSeekTime = 0; | 722 m_lastSeekTime = 0; |
725 m_duration = numeric_limits<double>::quiet_NaN(); | 723 m_duration = std::numeric_limits<double>::quiet_NaN(); |
726 | 724 |
727 // The spec doesn't say to block the load event until we actually run the as
ynchronous section | 725 // The spec doesn't say to block the load event until we actually run the as
ynchronous section |
728 // algorithm, but do it now because we won't start that until after the time
r fires and the | 726 // algorithm, but do it now because we won't start that until after the time
r fires and the |
729 // event may have already fired by then. | 727 // event may have already fired by then. |
730 setShouldDelayLoadEvent(true); | 728 setShouldDelayLoadEvent(true); |
731 | 729 |
732 configureMediaControls(); | 730 configureMediaControls(); |
733 } | 731 } |
734 | 732 |
735 void HTMLMediaElement::loadInternal() | 733 void HTMLMediaElement::loadInternal() |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 // Otherwise, let missed cues be an empty list. | 1027 // Otherwise, let missed cues be an empty list. |
1030 if (lastTime >= 0 && m_lastSeekTime < movieTime) { | 1028 if (lastTime >= 0 && m_lastSeekTime < movieTime) { |
1031 CueList potentiallySkippedCues = | 1029 CueList potentiallySkippedCues = |
1032 m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))
; | 1030 m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))
; |
1033 | 1031 |
1034 for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) { | 1032 for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) { |
1035 double cueStartTime = potentiallySkippedCues[i].low(); | 1033 double cueStartTime = potentiallySkippedCues[i].low(); |
1036 double cueEndTime = potentiallySkippedCues[i].high(); | 1034 double cueEndTime = potentiallySkippedCues[i].high(); |
1037 | 1035 |
1038 // Consider cues that may have been missed since the last seek time. | 1036 // Consider cues that may have been missed since the last seek time. |
1039 if (cueStartTime > max(m_lastSeekTime, lastTime) && cueEndTime < mov
ieTime) | 1037 if (cueStartTime > std::max(m_lastSeekTime, lastTime) && cueEndTime
< movieTime) |
1040 missedCues.append(potentiallySkippedCues[i]); | 1038 missedCues.append(potentiallySkippedCues[i]); |
1041 } | 1039 } |
1042 } | 1040 } |
1043 | 1041 |
1044 m_lastTextTrackUpdateTime = movieTime; | 1042 m_lastTextTrackUpdateTime = movieTime; |
1045 | 1043 |
1046 // 5 - If the time was reached through the usual monotonic increase of the | 1044 // 5 - If the time was reached through the usual monotonic increase of the |
1047 // current playback position during normal playback, and if the user agent | 1045 // current playback position during normal playback, and if the user agent |
1048 // has not fired a timeupdate event at the element in the past 15 to 250ms | 1046 // has not fired a timeupdate event at the element in the past 15 to 250ms |
1049 // and is not still running event handlers for such an event, then the user | 1047 // and is not still running event handlers for such an event, then the user |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 textTrackRemoveCue(cues->item(i)->track(), cues->item(i)); | 1318 textTrackRemoveCue(cues->item(i)->track(), cues->item(i)); |
1321 } | 1319 } |
1322 | 1320 |
1323 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtrWillBeRawPtr<
TextTrackCue> cue) | 1321 void HTMLMediaElement::textTrackAddCue(TextTrack* track, PassRefPtrWillBeRawPtr<
TextTrackCue> cue) |
1324 { | 1322 { |
1325 if (track->mode() == TextTrack::disabledKeyword()) | 1323 if (track->mode() == TextTrack::disabledKeyword()) |
1326 return; | 1324 return; |
1327 | 1325 |
1328 // Negative duration cues need be treated in the interval tree as | 1326 // Negative duration cues need be treated in the interval tree as |
1329 // zero-length cues. | 1327 // zero-length cues. |
1330 double endTime = max(cue->startTime(), cue->endTime()); | 1328 double endTime = std::max(cue->startTime(), cue->endTime()); |
1331 | 1329 |
1332 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c
ue.get()); | 1330 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c
ue.get()); |
1333 if (!m_cueTree.contains(interval)) | 1331 if (!m_cueTree.contains(interval)) |
1334 m_cueTree.add(interval); | 1332 m_cueTree.add(interval); |
1335 updateActiveTextTrackCues(currentTime()); | 1333 updateActiveTextTrackCues(currentTime()); |
1336 } | 1334 } |
1337 | 1335 |
1338 void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtrWillBeRawPtr<Tex
tTrackCue> cue) | 1336 void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtrWillBeRawPtr<Tex
tTrackCue> cue) |
1339 { | 1337 { |
1340 // Negative duration cues need to be treated in the interval tree as | 1338 // Negative duration cues need to be treated in the interval tree as |
1341 // zero-length cues. | 1339 // zero-length cues. |
1342 double endTime = max(cue->startTime(), cue->endTime()); | 1340 double endTime = std::max(cue->startTime(), cue->endTime()); |
1343 | 1341 |
1344 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c
ue.get()); | 1342 CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, c
ue.get()); |
1345 m_cueTree.remove(interval); | 1343 m_cueTree.remove(interval); |
1346 | 1344 |
1347 // Since the cue will be removed from the media element and likely the | 1345 // Since the cue will be removed from the media element and likely the |
1348 // TextTrack might also be destructed, notifying the region of the cue | 1346 // TextTrack might also be destructed, notifying the region of the cue |
1349 // removal shouldn't be done. | 1347 // removal shouldn't be done. |
1350 cue->notifyRegionWhenRemovingDisplayTree(false); | 1348 cue->notifyRegionWhenRemovingDisplayTree(false); |
1351 | 1349 |
1352 size_t index = m_currentlyActiveCues.find(interval); | 1350 size_t index = m_currentlyActiveCues.find(interval); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 // it is running to complete. | 1772 // it is running to complete. |
1775 // Nothing specific to be done here. | 1773 // Nothing specific to be done here. |
1776 | 1774 |
1777 // 3 - Set the seeking IDL attribute to true. | 1775 // 3 - Set the seeking IDL attribute to true. |
1778 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1776 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1779 bool previousSeekStillPending = m_seeking; | 1777 bool previousSeekStillPending = m_seeking; |
1780 m_seeking = true; | 1778 m_seeking = true; |
1781 | 1779 |
1782 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 1780 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
1783 // of the media resource instead. | 1781 // of the media resource instead. |
1784 time = min(time, duration()); | 1782 time = std::min(time, duration()); |
1785 | 1783 |
1786 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1784 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1787 time = max(time, 0.0); | 1785 time = std::max(time, 0.0); |
1788 | 1786 |
1789 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1787 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1790 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1788 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1791 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1789 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1792 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1790 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1793 // fire a 'seeked' event. | 1791 // fire a 'seeked' event. |
1794 #if !LOG_DISABLED | 1792 #if !LOG_DISABLED |
1795 double mediaTime = m_player->mediaTimeForTimeValue(time); | 1793 double mediaTime = m_player->mediaTimeForTimeValue(time); |
1796 if (time != mediaTime) | 1794 if (time != mediaTime) |
1797 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i
s %f", time, mediaTime); | 1795 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i
s %f", time, mediaTime); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 if (m_mediaController) { | 1924 if (m_mediaController) { |
1927 exceptionState.throwDOMException(InvalidStateError, "The element is slav
ed to a MediaController."); | 1925 exceptionState.throwDOMException(InvalidStateError, "The element is slav
ed to a MediaController."); |
1928 return; | 1926 return; |
1929 } | 1927 } |
1930 seek(time, exceptionState); | 1928 seek(time, exceptionState); |
1931 } | 1929 } |
1932 | 1930 |
1933 double HTMLMediaElement::duration() const | 1931 double HTMLMediaElement::duration() const |
1934 { | 1932 { |
1935 if (!m_player || m_readyState < HAVE_METADATA) | 1933 if (!m_player || m_readyState < HAVE_METADATA) |
1936 return numeric_limits<double>::quiet_NaN(); | 1934 return std::numeric_limits<double>::quiet_NaN(); |
1937 | 1935 |
1938 // FIXME: Refactor so m_duration is kept current (in both MSE and | 1936 // FIXME: Refactor so m_duration is kept current (in both MSE and |
1939 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> | 1937 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> |
1940 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE | 1938 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE |
1941 // case because MediaSource and SourceBuffer do not notify the element | 1939 // case because MediaSource and SourceBuffer do not notify the element |
1942 // directly upon duration changes caused by endOfStream, remove, or append | 1940 // directly upon duration changes caused by endOfStream, remove, or append |
1943 // operations; rather the notification is triggered by the WebMediaPlayer | 1941 // operations; rather the notification is triggered by the WebMediaPlayer |
1944 // implementation observing that the underlying engine has updated duration | 1942 // implementation observing that the underlying engine has updated duration |
1945 // and notifying the element to consult its MediaSource for current | 1943 // and notifying the element to consult its MediaSource for current |
1946 // duration. See http://crbug.com/266644 | 1944 // duration. See http://crbug.com/266644 |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3655 visitor->trace(m_currentSourceNode); | 3653 visitor->trace(m_currentSourceNode); |
3656 visitor->trace(m_nextChildNodeToConsider); | 3654 visitor->trace(m_nextChildNodeToConsider); |
3657 visitor->trace(m_textTracks); | 3655 visitor->trace(m_textTracks); |
3658 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3656 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3659 visitor->trace(m_mediaController); | 3657 visitor->trace(m_mediaController); |
3660 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3658 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3661 HTMLElement::trace(visitor); | 3659 HTMLElement::trace(visitor); |
3662 } | 3660 } |
3663 | 3661 |
3664 } | 3662 } |
OLD | NEW |