Changeset 138017 in webkit


Ignore:
Timestamp:
Dec 18, 2012 7:23:29 AM (11 years ago)
Author:
eric.carlson@apple.com
Message:

Add in-band text track cues only once
https://bugs.webkit.org/show_bug.cgi?id=104593

Reviewed by Dean Jackson.

Source/WebCore:

Test: media/track/track-in-band-cues-added-once.html

  • html/track/InbandTextTrack.cpp:

(WebCore::InbandTextTrack::hasCue): New.

  • html/track/InbandTextTrack.h:
  • html/track/TextTrackCue.cpp:

(WebCore::TextTrackCue::setCueSettings): Remember the raw cue settings so they can be accessed later.

  • html/track/TextTrackCue.h:
  • platform/graphics/InbandTextTrackPrivateClient.h: Declare hasCue.
  • platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:

(WebCore::InbandTextTrackPrivateAVF::processCue): Early return if m_player has been cleared.
(WebCore::InbandTextTrackPrivateAVF::setMode): Ditto.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::seek): Clear the partially accumulated cue when the seek

starts, not when it completes.

(WebCore::MediaPlayerPrivateAVFoundation::seekCompleted): Ditto.
(WebCore::MediaPlayerPrivateAVFoundation::flushCurrentCue): Don't add a cue if it is already in the

text track cue list.

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

(WebCore::MediaPlayerPrivateAVFoundationObjC::clearTextTracks): Drive-by cleanup, clear the track list completely.

LayoutTests:

Test to ensure that in-band text track cues are not added to the the cue list more than once.

  • media/track/track-in-band-cues-added-once-expected.txt: Added.
  • media/track/track-in-band-cues-added-once.html: Added.
  • platform/chromium/TestExpectations:
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:
  • platform/mac/TestExpectations:
  • platform/qt/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138014 r138017  
     12012-12-18  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Add in-band text track cues only once
     4        https://bugs.webkit.org/show_bug.cgi?id=104593
     5
     6        Reviewed by Dean Jackson.
     7
     8        Test to ensure that in-band text track cues are not added to the the cue list more than once.
     9
     10        * media/track/track-in-band-cues-added-once-expected.txt: Added.
     11        * media/track/track-in-band-cues-added-once.html: Added.
     12        * platform/chromium/TestExpectations:
     13        * platform/efl/TestExpectations:
     14        * platform/gtk/TestExpectations:
     15        * platform/mac/TestExpectations:
     16        * platform/qt/TestExpectations:
     17        * platform/win/TestExpectations:
     18
    1192012-12-18  Thiago Marcos P. Santos  <thiago.santos@intel.com>
    220
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r137966 r138017  
    42324232# No support for exposing in-band text tracks
    42334233webkit.org/b/103767  [ Win Mac Linux ] media/track/track-in-band.html [ Skip ]
     4234webkit.org/b/103767  [ Win Mac Linux ] media/track/track-in-band-cues-added-once.html [ Skip ]
    42344235
    42354236# Flaky on Win (perhaps due to lighttpd?)
  • trunk/LayoutTests/platform/efl/TestExpectations

    r137966 r138017  
    16541654# No support for exposing in-band text tracks
    16551655Bug(EFL) media/track/track-in-band.html [ Skip ]
     1656Bug(EFL) media/track/track-in-band-cues-added-once.html [ Skip ]
    16561657
    16571658# Newly added test in r136225 fails on GTK bot too.
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r137995 r138017  
    458458# No support for exposing in-band text tracks
    459459webkit.org/b/103771 media/track/track-in-band.html [ Failure ]
     460webkit.org/b/103771 media/track/track-in-band-cues-added-once.html [ Failure ]
    460461
    461462#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/platform/mac/TestExpectations

    r137762 r138017  
    12421242# Mountain Lion and prior do not allow access to in-band text tracks
    12431243webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band.html
     1244webkit.org/b/103663 [ MountainLion Lion SnowLeopard ] media/track/track-in-band-cues-added-once.html
    12441245
    12451246webkit.org/b/104104 fast/overflow/scrollbar-click-retains-focus.html [ Failure ]
  • trunk/LayoutTests/platform/qt/TestExpectations

    r137966 r138017  
    24432443# No support for exposing in-band text tracks
    24442444webkit.org/b/103769 media/track/track-in-band.html [ Skip ]
     2445webkit.org/b/103769 media/track/track-in-band-cues-added-once.html [ Skip ]
    24452446
    24462447webkit.org/b/104150 fast/media/implicit-media-all.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r137662 r138017  
    24772477# No support for exposing in-band text tracks
    24782478webkit.org/b/103770 media/track/track-in-band.html [ Skip ]
     2479webkit.org/b/103770 media/track/track-in-band-cues-added-once.html [ Skip ]
    24792480
    24802481# https://bugs.webkit.org/show_bug.cgi?id=97026
  • trunk/Source/WebCore/ChangeLog

    r138016 r138017  
     12012-12-18  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Add in-band text track cues only once
     4        https://bugs.webkit.org/show_bug.cgi?id=104593
     5
     6        Reviewed by Dean Jackson.
     7
     8        Test: media/track/track-in-band-cues-added-once.html
     9
     10        * html/track/InbandTextTrack.cpp:
     11        (WebCore::InbandTextTrack::hasCue): New.
     12        * html/track/InbandTextTrack.h:
     13
     14        * html/track/TextTrackCue.cpp:
     15        (WebCore::TextTrackCue::setCueSettings): Remember the raw cue settings so they can be accessed later.
     16        * html/track/TextTrackCue.h:
     17
     18        * platform/graphics/InbandTextTrackPrivateClient.h: Declare hasCue.
     19
     20        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
     21        (WebCore::InbandTextTrackPrivateAVF::processCue): Early return if m_player has been cleared.
     22        (WebCore::InbandTextTrackPrivateAVF::setMode): Ditto.
     23
     24        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     25        (WebCore::MediaPlayerPrivateAVFoundation::seek): Clear the partially accumulated cue when the seek
     26            starts, not when it completes.
     27        (WebCore::MediaPlayerPrivateAVFoundation::seekCompleted): Ditto.
     28        (WebCore::MediaPlayerPrivateAVFoundation::flushCurrentCue): Don't add a cue if it is already in the
     29            text track cue list.
     30        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     31        (WebCore::MediaPlayerPrivateAVFoundationObjC::clearTextTracks): Drive-by cleanup, clear the track list completely.
     32
    1332012-12-18  Eugene Klyuchnikov  <eustas@chromium.org>
    234
  • trunk/Source/WebCore/html/track/InbandTextTrack.cpp

    r137161 r138017  
    116116        client()->textTrackAddCues(this, m_cues.get());
    117117}
     118
     119bool InbandTextTrack::hasCue(InbandTextTrackPrivate*, double startTime, double endTime, const String& id, const String& content, const String& settings)
     120{
     121
     122    if (startTime < 0 || endTime < 0)
     123        return false;
     124
     125    if (!cues()->length())
     126        return false;
     127
     128    size_t searchStart = 0;
     129    size_t searchEnd = cues()->length();
     130
     131    while (1) {
     132        ASSERT(searchStart <= cues()->length());
     133        ASSERT(searchEnd <= cues()->length());
     134       
     135        TextTrackCue* cue;
     136       
     137        // Cues in the TextTrackCueList are maintained in start time order.
     138        if (searchStart == searchEnd) {
     139            if (!searchStart)
     140                return false;
     141           
     142            cue = cues()->item(searchStart - 1);
     143            if (!cue)
     144                return false;
     145            if (cue->startTime() != startTime)
     146                return false;
     147            if (cue->endTime() != endTime)
     148                return false;
     149            if (cue->text() != content)
     150                return false;
     151            if (cue->cueSettings() != settings)
     152                return false;
     153            if (cue->id() != id)
     154                return false;
     155           
     156            return true;
     157        }
     158       
     159        size_t index = (searchStart + searchEnd) / 2;
     160        cue = cues()->item(index);
     161        if (startTime < cue->startTime() || (startTime == cue->startTime() && endTime > cue->endTime()))
     162            searchEnd = index;
     163        else
     164            searchStart = index + 1;
     165    }
    118166   
     167    ASSERT_NOT_REACHED();
     168    return false;
     169}
     170
    119171} // namespace WebCore
    120172
  • trunk/Source/WebCore/html/track/InbandTextTrack.h

    r137161 r138017  
    5353
    5454    virtual void addCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
     55    virtual bool hasCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
    5556
    5657    RefPtr<InbandTextTrackPrivate> m_private;
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r137955 r138017  
    836836void TextTrackCue::setCueSettings(const String& input)
    837837{
     838    m_settings = input;
    838839    unsigned position = 0;
    839840
  • trunk/Source/WebCore/html/track/TextTrackCue.h

    r137955 r138017  
    120120    void setText(const String&);
    121121
     122    const String& cueSettings() const { return m_settings; }
    122123    void setCueSettings(const String&);
    123124
     
    186187    double m_endTime;
    187188    String m_content;
     189    String m_settings;
    188190    int m_linePosition;
    189191    int m_computedLinePosition;
  • trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h

    r137161 r138017  
    4040   
    4141    virtual void addCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
     42    virtual bool hasCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
    4243};
    4344
  • trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp

    r137161 r138017  
    223223void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)
    224224{
     225    if (!m_player)
     226        return;
     227   
    225228    if (m_havePartialCue) {
    226229        // Cues do not have an explicit duration, they are displayed until the next "cue" (which might be empty) is emitted.
     
    269272void InbandTextTrackPrivateAVF::setMode(InbandTextTrackPrivate::Mode newMode)
    270273{
     274    if (!m_player)
     275        return;
     276
    271277    InbandTextTrackPrivate::Mode oldMode = mode();
    272278    InbandTextTrackPrivate::setMode(newMode);
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r137707 r138017  
    267267        return;
    268268
     269#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
     270    // Forget any partially accumulated cue data as the seek could be to a time outside of the cue's
     271    // range, which will mean that the next cue delivered will result in the current cue getting the
     272    // incorrect duration.
     273    if (currentTrack())
     274        currentTrack()->resetCueValues();
     275#endif
     276   
    269277    LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);
    270278    m_seekTo = time;
     
    575583    UNUSED_PARAM(finished);
    576584
    577 #if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
    578     // Forget any partially accumulated cue data as the seek could be to a time outside of the cue's
    579     // range, which will mean that the next cue delivered will result in the current cue getting the
    580     // incorrect duration.
    581     if (currentTrack())
    582         currentTrack()->resetCueValues();
    583 #endif
    584 
    585585    m_seekTo = MediaPlayer::invalidTime();
    586586    updateStates();
     
    817817        return;
    818818
     819    // AVFoundation returns a cue every time the data is buffered, only add it once.
     820    if (track->client()->hasCue(track, track->start(), track->end(), track->id(), track->content(), track->settings())) {
     821        LOG(Media, "MediaPlayerPrivateAVFoundation::flushCurrentCue(%p) - already have cue for time %.2f", this, track->start());
     822        return;
     823    }
     824
     825    LOG(Media, "MediaPlayerPrivateAVFoundation::flushCurrentCue(%p) - adding cue for time %.2f", this, track->start());
    819826    track->client()->addCue(track, track->start(), track->end(), track->id(), track->content(), track->settings());
    820827}
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r137844 r138017  
    11981198void MediaPlayerPrivateAVFoundationObjC::clearTextTracks()
    11991199{
    1200     for (unsigned i = 0; i < m_textTracks.size(); ++i)
    1201         player()->removeTextTrack(m_textTracks[i].get());
     1200    for (unsigned i = 0; i < m_textTracks.size(); ++i) {
     1201        RefPtr<InbandTextTrackPrivateAVF> track = m_textTracks[i];
     1202        player()->removeTextTrack(track);
     1203        track->disconnect();
     1204    }
     1205    m_textTracks.clear();
    12021206}
    12031207
Note: See TracChangeset for help on using the changeset viewer.