Changeset 148291 in webkit


Ignore:
Timestamp:
Apr 12, 2013 11:39:37 AM (11 years ago)
Author:
jer.noble@apple.com
Message:

Add support for MediaPlayer::minTimeSeekable()
https://bugs.webkit.org/show_bug.cgi?id=114484

Reviewed by Eric Carlson.

Plumb a new minTimeSeekable() method through MediaPlayer and
MediaPlayerPrivate and use this new method in the existing
HTMLMediaElement::minTimeSeekable() method.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::minTimeSeekable): Pass to MediaPlayer.

  • platform/graphics/MediaPlayer.cpp:

(WebCore::NullMediaPlayerPrivate::minTimeSeekable): Return 0.
(WebCore::MediaPlayer::minTimeSeekable): Pass to MediaPlayerPrivate.

  • platform/graphics/MediaPlayer.h:
  • platform/graphics/MediaPlayerPrivate.h:

(WebCore::MediaPlayerPrivateInterface::seekable): Define in terms of

minTimeSeekable()

(WebCore::MediaPlayerPrivateInterface::minTimeSeekable): Default to 0.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):

Initialize new m_cachedMinTimeSeekable ivar.

(WebCore::MediaPlayerPrivateAVFoundation::maxTimeSeekableDouble):

Renamed from maxTimeSeekable().

(WebCore::MediaPlayerPrivateAVFoundation::minTimeSeekable): Added.

Cache value of platformMinTimeSeekable().

(WebCore::MediaPlayerPrivateAVFoundation::seekableTimeRangesChanged):

Reset m_cachedMinTimeSeekable.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::seekToTime): float -> double.
(WebCore::MediaPlayerPrivateAVFoundationObjC::platformMinTimeSeekable):

Added. Retrieve the lowest value from -[m_playerItem seekableTimeRanges].

(WebCore::MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable):

float -> double.

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148289 r148291  
     12013-04-11  Jer Noble  <jer.noble@apple.com>
     2
     3        Add support for MediaPlayer::minTimeSeekable()
     4        https://bugs.webkit.org/show_bug.cgi?id=114484
     5
     6        Reviewed by Eric Carlson.
     7
     8        Plumb a new minTimeSeekable() method through MediaPlayer and
     9        MediaPlayerPrivate and use this new method in the existing
     10        HTMLMediaElement::minTimeSeekable() method.
     11
     12        * html/HTMLMediaElement.cpp:
     13        (WebCore::HTMLMediaElement::minTimeSeekable): Pass to MediaPlayer.
     14        * platform/graphics/MediaPlayer.cpp:
     15        (WebCore::NullMediaPlayerPrivate::minTimeSeekable): Return 0.
     16        (WebCore::MediaPlayer::minTimeSeekable): Pass to MediaPlayerPrivate.
     17        * platform/graphics/MediaPlayer.h:
     18        * platform/graphics/MediaPlayerPrivate.h:
     19        (WebCore::MediaPlayerPrivateInterface::seekable): Define in terms of
     20            minTimeSeekable()
     21        (WebCore::MediaPlayerPrivateInterface::minTimeSeekable): Default to 0.
     22        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     23        (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
     24            Initialize new m_cachedMinTimeSeekable ivar.
     25        (WebCore::MediaPlayerPrivateAVFoundation::maxTimeSeekableDouble):
     26            Renamed from maxTimeSeekable().
     27        (WebCore::MediaPlayerPrivateAVFoundation::minTimeSeekable): Added.
     28            Cache value of platformMinTimeSeekable().
     29        (WebCore::MediaPlayerPrivateAVFoundation::seekableTimeRangesChanged):
     30            Reset m_cachedMinTimeSeekable.
     31        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
     32        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     33        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     34        (WebCore::MediaPlayerPrivateAVFoundationObjC::seekToTime): float -> double.
     35        (WebCore::MediaPlayerPrivateAVFoundationObjC::platformMinTimeSeekable):
     36            Added. Retrieve the lowest value from -[m_playerItem seekableTimeRanges].
     37        (WebCore::MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable):
     38            float -> double.
     39
    1402013-04-12  Commit Queue  <rniwa@webkit.org>
    241
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r148285 r148291  
    37793779double HTMLMediaElement::minTimeSeekable() const
    37803780{
    3781     return 0;
     3781    return m_player ? m_player->minTimeSeekable() : 0;
    37823782}
    37833783
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r148099 r148291  
    136136
    137137    virtual double maxTimeSeekableDouble() const { return 0; }
     138    virtual double minTimeSeekable() const { return 0; }
    138139    virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); }
    139140
     
    682683}
    683684
     685double MediaPlayer::minTimeSeekable()
     686{
     687    return m_private->minTimeSeekable();
     688}
     689
    684690bool MediaPlayer::didLoadingProgress()
    685691{
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r148099 r148291  
    316316    PassRefPtr<TimeRanges> buffered();
    317317    PassRefPtr<TimeRanges> seekable();
     318    double minTimeSeekable();
    318319    double maxTimeSeekable();
    319320
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r148099 r148291  
    106106    virtual MediaPlayer::ReadyState readyState() const = 0;
    107107
    108     virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekable() ? TimeRanges::create(0, maxTimeSeekable()) : TimeRanges::create(); }
     108    virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekableDouble() ? TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble()) : TimeRanges::create(); }
    109109    virtual float maxTimeSeekable() const { return 0; }
    110110    virtual double maxTimeSeekableDouble() const { return maxTimeSeekable(); }
     111    virtual double minTimeSeekable() const { return 0; }
    111112    virtual PassRefPtr<TimeRanges> buffered() const = 0;
    112113
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r148050 r148291  
    5858    , m_cachedMaxTimeLoaded(0)
    5959    , m_cachedMaxTimeSeekable(0)
     60    , m_cachedMinTimeSeekable(0)
    6061    , m_cachedDuration(MediaPlayer::invalidTime())
    6162    , m_reportedDuration(MediaPlayer::invalidTime())
     
    362363}
    363364
    364 float MediaPlayerPrivateAVFoundation::maxTimeSeekable() const
     365double MediaPlayerPrivateAVFoundation::maxTimeSeekableDouble() const
    365366{
    366367    if (!metaDataAvailable())
     
    372373    LOG(Media, "MediaPlayerPrivateAVFoundation::maxTimeSeekable(%p) - returning %f", this, m_cachedMaxTimeSeekable);
    373374    return m_cachedMaxTimeSeekable;   
     375}
     376
     377double MediaPlayerPrivateAVFoundation::minTimeSeekable() const
     378{
     379    if (!metaDataAvailable())
     380        return 0;
     381
     382    if (!m_cachedMinTimeSeekable)
     383        m_cachedMinTimeSeekable = platformMinTimeSeekable();
     384
     385    LOG(Media, "MediaPlayerPrivateAVFoundation::minTimeSeekable(%p) - returning %f", this, m_cachedMinTimeSeekable);
     386    return m_cachedMinTimeSeekable;
    374387}
    375388
     
    571584{
    572585    m_cachedMaxTimeSeekable = 0;
     586    m_cachedMinTimeSeekable = 0;
    573587}
    574588
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r143884 r148291  
    158158    virtual MediaPlayer::NetworkState networkState() const { return m_networkState; }
    159159    virtual MediaPlayer::ReadyState readyState() const { return m_readyState; }
    160     virtual float maxTimeSeekable() const;
     160    virtual double maxTimeSeekableDouble() const;
     161    virtual double minTimeSeekable() const;
    161162    virtual PassRefPtr<TimeRanges> buffered() const;
    162163    virtual bool didLoadingProgress() const;
     
    210211    virtual void updateRate() = 0;
    211212    virtual float rate() const = 0;
    212     virtual void seekToTime(float time) = 0;
     213    virtual void seekToTime(double time) = 0;
    213214    virtual unsigned totalBytes() const = 0;
    214215    virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const = 0;
    215     virtual float platformMaxTimeSeekable() const = 0;
     216    virtual double platformMaxTimeSeekable() const = 0;
     217    virtual double platformMinTimeSeekable() const = 0;
    216218    virtual float platformMaxTimeLoaded() const = 0;
    217219    virtual float platformDuration() const = 0;
     
    286288    IntSize m_cachedNaturalSize;
    287289    mutable float m_cachedMaxTimeLoaded;
    288     mutable float m_cachedMaxTimeSeekable;
     290    mutable double m_cachedMaxTimeSeekable;
     291    mutable double m_cachedMinTimeSeekable;
    289292    mutable float m_cachedDuration;
    290293    float m_reportedDuration;
    291294    mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
    292     float m_seekTo;
     295    double m_seekTo;
    293296    float m_requestedRate;
    294297    mutable int m_delayCallbacks;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r148123 r148291  
    123123    virtual void updateRate();
    124124    virtual float rate() const;
    125     virtual void seekToTime(float time);
     125    virtual void seekToTime(double time);
    126126    virtual unsigned totalBytes() const;
    127127    virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;
    128     virtual float platformMaxTimeSeekable() const;
     128    virtual double platformMinTimeSeekable() const;
     129    virtual double platformMaxTimeSeekable() const;
    129130    virtual float platformDuration() const;
    130131    virtual float platformMaxTimeLoaded() const;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r148285 r148291  
    602602}
    603603
    604 void MediaPlayerPrivateAVFoundationObjC::seekToTime(float time)
     604void MediaPlayerPrivateAVFoundationObjC::seekToTime(double time)
    605605{
    606606    // setCurrentTime generates several event callbacks, update afterwards.
     
    670670}
    671671
    672 float MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable() const
     672double MediaPlayerPrivateAVFoundationObjC::platformMinTimeSeekable() const
     673{
     674    NSArray *seekableRanges = [m_avPlayerItem.get() seekableTimeRanges];
     675    if (!seekableRanges || ![seekableRanges count])
     676        return 0;
     677
     678    double minTimeSeekable = std::numeric_limits<double>::infinity();
     679    bool hasValidRange = false;
     680    for (NSValue *thisRangeValue in seekableRanges) {
     681        CMTimeRange timeRange = [thisRangeValue CMTimeRangeValue];
     682        if (!CMTIMERANGE_IS_VALID(timeRange) || CMTIMERANGE_IS_EMPTY(timeRange))
     683            continue;
     684
     685        hasValidRange = true;
     686        double startOfRange = CMTimeGetSeconds(timeRange.start);
     687        if (minTimeSeekable > startOfRange)
     688            minTimeSeekable = startOfRange;
     689    }
     690    return hasValidRange ? minTimeSeekable : 0;
     691}
     692
     693double MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable() const
    673694{
    674695    NSArray *seekableRanges = [m_avPlayerItem.get() seekableTimeRanges];
     
    676697        return 0;
    677698
    678     float maxTimeSeekable = 0;
     699    double maxTimeSeekable = 0;
    679700    for (NSValue *thisRangeValue in seekableRanges) {
    680701        CMTimeRange timeRange = [thisRangeValue CMTimeRangeValue];
     
    682703            continue;
    683704       
    684         float endOfRange = narrowPrecisionToFloat(CMTimeGetSeconds(CMTimeRangeGetEnd(timeRange)));
     705        double endOfRange = CMTimeGetSeconds(CMTimeRangeGetEnd(timeRange));
    685706        if (maxTimeSeekable < endOfRange)
    686707            maxTimeSeekable = endOfRange;
    687708    }
    688     return maxTimeSeekable;   
     709    return maxTimeSeekable;
    689710}
    690711
     
    14311452    return m_languageOfPrimaryAudioTrack;
    14321453}
    1433    
     1454
    14341455NSArray* assetMetadataKeyNames()
    14351456{
Note: See TracChangeset for help on using the changeset viewer.