Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 209223002: Add support for HTMLMediaElement::getStartDate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Place code behind a runtime flag and add LayoutTest. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 , m_asyncEventQueue(GenericEventQueue::create(this)) 244 , m_asyncEventQueue(GenericEventQueue::create(this))
245 , m_playbackRate(1.0f) 245 , m_playbackRate(1.0f)
246 , m_defaultPlaybackRate(1.0f) 246 , m_defaultPlaybackRate(1.0f)
247 , m_networkState(NETWORK_EMPTY) 247 , m_networkState(NETWORK_EMPTY)
248 , m_readyState(HAVE_NOTHING) 248 , m_readyState(HAVE_NOTHING)
249 , m_readyStateMaximum(HAVE_NOTHING) 249 , m_readyStateMaximum(HAVE_NOTHING)
250 , m_volume(1.0f) 250 , m_volume(1.0f)
251 , m_lastSeekTime(0) 251 , m_lastSeekTime(0)
252 , m_previousProgressTime(numeric_limits<double>::max()) 252 , m_previousProgressTime(numeric_limits<double>::max())
253 , m_duration(numeric_limits<double>::quiet_NaN()) 253 , m_duration(numeric_limits<double>::quiet_NaN())
254 , m_timelineOffset(numeric_limits<double>::quiet_NaN())
254 , m_lastTimeUpdateEventWallTime(0) 255 , m_lastTimeUpdateEventWallTime(0)
255 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max()) 256 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max())
256 , m_loadState(WaitingForSource) 257 , m_loadState(WaitingForSource)
257 , m_webLayer(0) 258 , m_webLayer(0)
258 , m_preload(MediaPlayer::Auto) 259 , m_preload(MediaPlayer::Auto)
259 , m_displayMode(Unknown) 260 , m_displayMode(Unknown)
260 , m_cachedTime(MediaPlayer::invalidTime()) 261 , m_cachedTime(MediaPlayer::invalidTime())
261 , m_cachedTimeWallClockUpdateTime(0) 262 , m_cachedTimeWallClockUpdateTime(0)
262 , m_minimumWallClockTimeToCacheMediaTime(0) 263 , m_minimumWallClockTimeToCacheMediaTime(0)
263 , m_fragmentStartTime(MediaPlayer::invalidTime()) 264 , m_fragmentStartTime(MediaPlayer::invalidTime())
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element. 670 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element.
670 // FIXME: Add support for firing this event. 671 // FIXME: Add support for firing this event.
671 672
672 // 4.8 - Set the initial playback position to 0. 673 // 4.8 - Set the initial playback position to 0.
673 // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call 674 // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call
674 // above. 675 // above.
675 refreshCachedTime(); 676 refreshCachedTime();
676 invalidateCachedTime(); 677 invalidateCachedTime();
677 678
678 // 4.9 - Set the timeline offset to Not-a-Number (NaN). 679 // 4.9 - Set the timeline offset to Not-a-Number (NaN).
680 m_timelineOffset = numeric_limits<double>::quiet_NaN();
681
679 // 4.10 - Update the duration attribute to Not-a-Number (NaN). 682 // 4.10 - Update the duration attribute to Not-a-Number (NaN).
680 683
681 684
682 updateMediaController(); 685 updateMediaController();
683 updateActiveTextTrackCues(0); 686 updateActiveTextTrackCues(0);
684 } 687 }
685 688
686 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute. 689 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat e attribute.
687 setPlaybackRate(defaultPlaybackRate()); 690 setPlaybackRate(defaultPlaybackRate());
688 691
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 finishSeek(); 1598 finishSeek();
1596 } else { 1599 } else {
1597 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { 1600 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) {
1598 // 4.8.10.8 1601 // 4.8.10.8
1599 scheduleTimeupdateEvent(false); 1602 scheduleTimeupdateEvent(false);
1600 scheduleEvent(EventTypeNames::waiting); 1603 scheduleEvent(EventTypeNames::waiting);
1601 } 1604 }
1602 } 1605 }
1603 1606
1604 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { 1607 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
1608 // This block corresponds to the "Once enough of the media data has been fetched to determine the duration of the media resource, its dimensions, and ot her metadata"
1609 // section of step 4 of the resource fetch algorithm.
1610
1611 // FIXME: This appears to correspond to step 10 in the algorithm. Invest igate moving this code to a position that matches the spec text.
1605 prepareMediaFragmentURI(); 1612 prepareMediaFragmentURI();
1613
1614 // 1. Establish the media timeline for the purposes of the current playb ack position, the earliest possible position, and the initial playback position, based on the media data.
1615 // 2. Update the timeline offset to the date and time that corresponds t o the zero time in the media timeline established in the previous step, if any. If no explicit time and date is given by the media resource, the timeline offset must be set to Not-a-Number (NaN).
philipj_slow 2014/05/06 11:13:52 Nit: this is a very long line. There isn't a lot o
1616 m_timelineOffset = webMediaPlayer()->timelineOffset();
1617
1618 // 3. Set the current playback position and the official playback positi on to the earliest possible position.
1619
1620 // 4. Update the duration attribute with the time of the last frame of t he resource, if known, on the media timeline established above. If it is not kno wn (e.g. a stream that is in principle infinite), update the duration attribute to the value positive Infinity.
1606 scheduleEvent(EventTypeNames::durationchange); 1621 scheduleEvent(EventTypeNames::durationchange);
1622
1623 // 5. For video elements, set the videoWidth and videoHeight attributes, and queue a task to fire a simple event named resize at the media element.
1607 if (isHTMLVideoElement(*this)) 1624 if (isHTMLVideoElement(*this))
1608 scheduleEvent(EventTypeNames::resize); 1625 scheduleEvent(EventTypeNames::resize);
1626
1627 // 6. Set the readyState attribute to HAVE_METADATA.
1628 // Note: A loadedmetadata DOM event will be fired as part of setting t he readyState attribute to a new value.
1609 scheduleEvent(EventTypeNames::loadedmetadata); 1629 scheduleEvent(EventTypeNames::loadedmetadata);
1630
1631 // Steps 7-12 appear to be handled elsewhere.
1632 // FIXME: Code should be refactored to make it easier to verify that the se steps are implemented according to spec.
1633
1610 if (hasMediaControls()) 1634 if (hasMediaControls())
1611 mediaControls()->reset(); 1635 mediaControls()->reset();
1612 if (renderer()) 1636 if (renderer())
1613 renderer()->updateFromElement(); 1637 renderer()->updateFromElement();
1614 } 1638 }
1615 1639
1616 bool shouldUpdateDisplayState = false; 1640 bool shouldUpdateDisplayState = false;
1617 1641
1618 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { 1642 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) {
1619 m_haveFiredLoadedData = true; 1643 m_haveFiredLoadedData = true;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 // implementation observing that the underlying engine has updated duration 1931 // implementation observing that the underlying engine has updated duration
1908 // and notifying the element to consult its MediaSource for current 1932 // and notifying the element to consult its MediaSource for current
1909 // duration. See http://crbug.com/266644 1933 // duration. See http://crbug.com/266644
1910 1934
1911 if (m_mediaSource) 1935 if (m_mediaSource)
1912 return m_mediaSource->duration(); 1936 return m_mediaSource->duration();
1913 1937
1914 return m_player->duration(); 1938 return m_player->duration();
1915 } 1939 }
1916 1940
1941 double HTMLMediaElement::getStartDate()
1942 {
1943 return m_timelineOffset;
philipj_slow 2014/05/15 11:38:00 My colleague has noticed that this value will be w
acolwell GONE FROM CHROMIUM 2014/05/15 13:01:22 It is already supposed to be in milliseconds since
philipj_slow 2014/05/15 13:28:29 Thanks!
1944 }
1945
1917 bool HTMLMediaElement::paused() const 1946 bool HTMLMediaElement::paused() const
1918 { 1947 {
1919 return m_paused; 1948 return m_paused;
1920 } 1949 }
1921 1950
1922 double HTMLMediaElement::defaultPlaybackRate() const 1951 double HTMLMediaElement::defaultPlaybackRate() const
1923 { 1952 {
1924 return m_defaultPlaybackRate; 1953 return m_defaultPlaybackRate;
1925 } 1954 }
1926 1955
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 3641
3613 void HTMLMediaElement::trace(Visitor* visitor) 3642 void HTMLMediaElement::trace(Visitor* visitor)
3614 { 3643 {
3615 visitor->trace(m_textTracks); 3644 visitor->trace(m_textTracks);
3616 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3645 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3617 Supplementable<HTMLMediaElement>::trace(visitor); 3646 Supplementable<HTMLMediaElement>::trace(visitor);
3618 HTMLElement::trace(visitor); 3647 HTMLElement::trace(visitor);
3619 } 3648 }
3620 3649
3621 } 3650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698