Changeset 205820 in webkit


Ignore:
Timestamp:
Sep 12, 2016 2:09:15 PM (8 years ago)
Author:
jer.noble@apple.com
Message:

Fix failing mediasource-play.html and mediasource-config-change-mp4-v-bitrate.html tests
https://bugs.webkit.org/show_bug.cgi?id=161819

Reviewed by Eric Carlson.

Source/WebCore:

Fixes tests: imported/w3c/web-platform-tests/media-source/mediasource-play.html

imported/w3c/web-platform-tests/media-source/mediasource-sourcebuffer-mode.html

The newest revision of the web-platform-test suite for Media Source tests new behavior
added to the MSE specification. Specifically, setting a MediaSource's duration will no
longer implicitly truncate the source's active SourceBuffer objects.

  • Modules/mediasource/MediaSource.cpp:

(WebCore::MediaSource::setDuration): Return exception if issued by setDurationInternal.
(WebCore::MediaSource::setDurationInternal): Bring "duration change" algorithm up to spec.

  • Modules/mediasource/MediaSource.h:
  • Modules/mediasource/SampleMap.h:

(WebCore::PresentationOrderSampleMap::begin): Add const accessor.
(WebCore::PresentationOrderSampleMap::end): Ditto.
(WebCore::PresentationOrderSampleMap::rbegin): Ditto.
(WebCore::PresentationOrderSampleMap::rend): DItto.
(WebCore::DecodeOrderSampleMap::begin): Ditto.
(WebCore::DecodeOrderSampleMap::end): Ditto.
(WebCore::DecodeOrderSampleMap::rbegin): Ditto.
(WebCore::DecodeOrderSampleMap::rend): Ditto.

  • Modules/mediasource/SourceBuffer.cpp:

(WebCore::SourceBuffer::highestPresentationTimestamp): Added convenience method.
(WebCore::SourceBuffer::removeCodedFrames): Drive-by fix; use .values() rather than

pulling the value out of each HashMap iterator.

  • Modules/mediasource/SourceBuffer.h:

LayoutTests:

  • media/media-source/media-source-end-of-stream-readyState.html:
  • media/media-source/media-source-end-of-stream-readyState-expected.txt:
  • platform/mac/TestExpectations:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r205815 r205820  
     12016-09-12  Jer Noble  <jer.noble@apple.com>
     2
     3        Fix failing mediasource-play.html and mediasource-config-change-mp4-v-bitrate.html tests
     4        https://bugs.webkit.org/show_bug.cgi?id=161819
     5
     6        Reviewed by Eric Carlson.
     7
     8        * media/media-source/media-source-end-of-stream-readyState.html:
     9        * media/media-source/media-source-end-of-stream-readyState-expected.txt:
     10        * platform/mac/TestExpectations:
     11
    1122016-09-12  Matt Baker  <mattbaker@apple.com>
    213
  • trunk/LayoutTests/media/media-source/media-source-end-of-stream-readyState-expected.txt

    r179044 r205820  
    99RUN(source.endOfStream())
    1010EXPECTED (source.duration.toFixed(3) == '5') OK
    11 EVENT(updateend)
     11EXPECTED (sourceBuffer.updating == 'false') OK
    1212END OF TEST
    1313
  • trunk/LayoutTests/media/media-source/media-source-end-of-stream-readyState.html

    r179044 r205820  
    3737
    3838        waitForEventOn(source, 'sourceopen', function() { failTest("Should not transit to 'open' state during endOfStream().") }, false, true);
    39         waitForEventOn(sourceBuffer, 'updateend', endTest, false, true);
    4039        run('source.endOfStream()');
    4140        testExpected('source.duration.toFixed(3)', 5);
     41        testExpected('sourceBuffer.updating', false);
     42        endTest();
    4243    }
    4344
  • trunk/LayoutTests/platform/mac/TestExpectations

    r205777 r205820  
    10481048[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/SourceBuffer-abort.html [ Pass ]
    10491049[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-closed.html [ Pass ]
     1050[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-mp4-v-bitrate.html [ Pass ]
    10501051[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-endofstream-invaliderror.html [ Pass ]
    10511052[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-multiple-attach.html [ Pass ]
     1053[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-play.html [ Pass ]
    10521054[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-sourcebufferlist.html [ Pass ]
    10531055
     
    10611063webkit.org/b/161725 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-mp4-v-bitrate.html [ Failure ]
    10621064webkit.org/b/161725 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported.html [ Failure ]
    1063 webkit.org/b/161725 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-play.html [ Failure ]
    10641065webkit.org/b/161725 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-remove.html [ Failure ]
    10651066webkit.org/b/161725 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-sourcebuffer-mode.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r205818 r205820  
     12016-09-12  Jer Noble  <jer.noble@apple.com>
     2
     3        Fix failing mediasource-play.html and mediasource-config-change-mp4-v-bitrate.html tests
     4        https://bugs.webkit.org/show_bug.cgi?id=161819
     5
     6        Reviewed by Eric Carlson.
     7
     8        Fixes tests: imported/w3c/web-platform-tests/media-source/mediasource-play.html
     9                     imported/w3c/web-platform-tests/media-source/mediasource-sourcebuffer-mode.html
     10
     11        The newest revision of the web-platform-test suite for Media Source tests new behavior
     12        added to the MSE specification. Specifically, setting a MediaSource's duration will no
     13        longer implicitly truncate the source's active SourceBuffer objects.
     14
     15        * Modules/mediasource/MediaSource.cpp:
     16        (WebCore::MediaSource::setDuration): Return exception if issued by setDurationInternal.
     17        (WebCore::MediaSource::setDurationInternal): Bring "duration change" algorithm up to spec.
     18        * Modules/mediasource/MediaSource.h:
     19        * Modules/mediasource/SampleMap.h:
     20        (WebCore::PresentationOrderSampleMap::begin): Add const accessor.
     21        (WebCore::PresentationOrderSampleMap::end): Ditto.
     22        (WebCore::PresentationOrderSampleMap::rbegin): Ditto.
     23        (WebCore::PresentationOrderSampleMap::rend): DItto.
     24        (WebCore::DecodeOrderSampleMap::begin): Ditto.
     25        (WebCore::DecodeOrderSampleMap::end): Ditto.
     26        (WebCore::DecodeOrderSampleMap::rbegin): Ditto.
     27        (WebCore::DecodeOrderSampleMap::rend): Ditto.
     28        * Modules/mediasource/SourceBuffer.cpp:
     29        (WebCore::SourceBuffer::highestPresentationTimestamp): Added convenience method.
     30        (WebCore::SourceBuffer::removeCodedFrames): Drive-by fix; use .values() rather than
     31            pulling the value out of each HashMap iterator.
     32        * Modules/mediasource/SourceBuffer.h:
     33
    1342016-09-12  Chris Dumez  <cdumez@apple.com>
    235
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp

    r202105 r205820  
    358358
    359359    // 4. Run the duration change algorithm with new duration set to the value being assigned to this attribute.
    360     setDurationInternal(MediaTime::createWithDouble(duration));
    361 }
    362 
    363 void MediaSource::setDurationInternal(const MediaTime& duration)
    364 {
    365     // Duration Change Algorithm
    366     // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#duration-change-algorithm
     360    auto result = setDurationInternal(MediaTime::createWithDouble(duration));
     361    if (result)
     362        ec = result.value();
     363}
     364
     365Optional<ExceptionCode> MediaSource::setDurationInternal(const MediaTime& duration)
     366{
     367    // 2.4.6 Duration Change
     368    // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#duration-change-algorithm
     369
     370    MediaTime newDuration = duration;
    367371
    368372    // 1. If the current value of duration is equal to new duration, then return.
    369     if (duration == m_duration)
    370         return;
    371 
    372     // 2. Set old duration to the current value of duration.
    373     MediaTime oldDuration = m_duration;
    374 
    375     // 3. Update duration to new duration.
    376     m_duration = duration;
    377 
    378     // 4. If the new duration is less than old duration, then call remove(new duration, old duration)
    379     // on all objects in sourceBuffers.
    380     if (oldDuration.isValid() && duration < oldDuration) {
    381         for (auto& sourceBuffer : *m_sourceBuffers)
    382             sourceBuffer->rangeRemoval(duration, oldDuration);
    383     }
    384 
    385     // 5. If a user agent is unable to partially render audio frames or text cues that start before and end after the
    386     // duration, then run the following steps:
    387     // 5.1 Update new duration to the highest end time reported by the buffered attribute across all SourceBuffer objects
    388     // in sourceBuffers.
    389     // 5.2 Update duration to new duration.
    390     // NOTE: Assume UA is able to partially render audio frames.
    391 
    392     // 6. Update the media controller duration to new duration and run the HTMLMediaElement duration change algorithm.
     373    if (newDuration == m_duration)
     374        return { };
     375
     376    // 2. If new duration is less than the highest presentation timestamp of any buffered coded frames
     377    // for all SourceBuffer objects in sourceBuffers, then throw an InvalidStateError exception and
     378    // abort these steps.
     379    // 3. Let highest end time be the largest track buffer ranges end time across all the track buffers
     380    // across all SourceBuffer objects in sourceBuffers.
     381    MediaTime highestPresentationTimestamp;
     382    MediaTime highestEndTime;
     383    for (auto& sourceBuffer : *m_sourceBuffers) {
     384        highestPresentationTimestamp = std::max(highestPresentationTimestamp, sourceBuffer->highestPresentationTimestamp());
     385        highestEndTime = std::max(highestEndTime, sourceBuffer->buffered()->ranges().maximumBufferedTime());
     386    }
     387    if (highestPresentationTimestamp.isValid() && newDuration < highestPresentationTimestamp)
     388        return INVALID_STATE_ERR;
     389
     390    // 4. If new duration is less than highest end time, then
     391    // 4.1. Update new duration to equal highest end time.
     392    if (highestEndTime.isValid() && newDuration < highestEndTime)
     393        newDuration = highestEndTime;
     394
     395    // 5. Update duration to new duration.
     396    m_duration = newDuration;
     397
     398    // 6. Update the media duration to new duration and run the HTMLMediaElement duration change algorithm.
    393399    LOG(MediaSource, "MediaSource::setDurationInternal(%p) - duration(%g)", this, duration.toDouble());
    394400    m_private->durationChanged();
     401
     402    return { };
    395403}
    396404
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.h

    r200361 r205820  
    8585
    8686    void setDuration(double, ExceptionCode&);
    87     void setDurationInternal(const MediaTime&);
     87    Optional<ExceptionCode> setDurationInternal(const MediaTime&);
    8888    MediaTime currentTime() const;
    8989    const AtomicString& readyState() const { return m_readyState; }
  • trunk/Source/WebCore/Modules/mediasource/SampleMap.h

    r204239 r205820  
    4343    typedef std::map<MediaTime, RefPtr<MediaSample>> MapType;
    4444    typedef MapType::iterator iterator;
     45    typedef MapType::const_iterator const_iterator;
    4546    typedef MapType::reverse_iterator reverse_iterator;
     47    typedef MapType::const_reverse_iterator const_reverse_iterator;
    4648    typedef std::pair<iterator, iterator> iterator_range;
    4749
    4850    iterator begin() { return m_samples.begin(); }
     51    const_iterator begin() const { return m_samples.begin(); }
    4952    iterator end() { return m_samples.end(); }
     53    const_iterator end() const { return m_samples.end(); }
    5054    reverse_iterator rbegin() { return m_samples.rbegin(); }
     55    const_reverse_iterator rbegin() const { return m_samples.rbegin(); }
    5156    reverse_iterator rend() { return m_samples.rend(); }
     57    const_reverse_iterator rend() const { return m_samples.rend(); }
    5258
    5359    iterator findSampleWithPresentationTime(const MediaTime&);
     
    7076    typedef std::map<KeyType, RefPtr<MediaSample>> MapType;
    7177    typedef MapType::iterator iterator;
     78    typedef MapType::const_iterator const_iterator;
    7279    typedef MapType::reverse_iterator reverse_iterator;
     80    typedef MapType::const_reverse_iterator const_reverse_iterator;
    7381    typedef std::pair<reverse_iterator, reverse_iterator> reverse_iterator_range;
    7482
    7583    iterator begin() { return m_samples.begin(); }
     84    const_iterator begin() const { return m_samples.begin(); }
    7685    iterator end() { return m_samples.end(); }
     86    const_iterator end() const { return m_samples.end(); }
    7787    reverse_iterator rbegin() { return m_samples.rbegin(); }
     88    const_reverse_iterator rbegin() const { return m_samples.rbegin(); }
    7889    reverse_iterator rend() { return m_samples.rend(); }
     90    const_reverse_iterator rend() const { return m_samples.rend(); }
    7991
    8092    iterator findSampleWithDecodeKey(const KeyType&);
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp

    r204239 r205820  
    396396}
    397397
     398MediaTime SourceBuffer::highestPresentationTimestamp() const
     399{
     400    MediaTime highestTime;
     401    for (auto& trackBuffer : m_trackBufferMap.values()) {
     402        auto lastSampleIter = trackBuffer.samples.presentationOrder().rbegin();
     403        if (lastSampleIter == trackBuffer.samples.presentationOrder().rend())
     404            continue;
     405        highestTime = std::max(highestTime, lastSampleIter->first);
     406    }
     407    return highestTime;
     408}
     409
    398410void SourceBuffer::removedFromMediaSource()
    399411{
     
    742754    // 2. Let end be the end presentation timestamp for the removal range.
    743755    // 3. For each track buffer in this source buffer, run the following steps:
    744     for (auto& iter : m_trackBufferMap) {
    745         TrackBuffer& trackBuffer = iter.value;
    746 
     756    for (auto& trackBuffer : m_trackBufferMap.values()) {
    747757        // 3.1. Let remove end timestamp be the current value of duration
    748758        // 3.2 If this track buffer has a random access point timestamp that is greater than or equal to end, then update
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h

    r204239 r205820  
    125125    void setBufferedDirty(bool flag) { m_bufferedDirty = flag; }
    126126
     127    MediaTime highestPresentationTimestamp() const;
     128
    127129    // ActiveDOMObject API.
    128130    bool hasPendingActivity() const override;
Note: See TracChangeset for help on using the changeset viewer.