Changeset 179725 in webkit


Ignore:
Timestamp:
Feb 5, 2015 4:57:41 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

[MSE] Implement Append Error algorithm.
https://bugs.webkit.org/show_bug.cgi?id=139439

Patch by Bartlomiej Gajda <b.gajda@samsung.com> on 2015-02-05
Reviewed by Jer Noble.

If Source Buffer has not received first init segment, then it shall call endOfStream after receiving
Media Segment, as per Media Source spec. (from 17 July 2014) in paragraph 3.5.1 point 6.1.
Source/WebCore:

Based this change on Editor's Draft 12 December 2014, as it clarifies order of events.

Test: media/media-source/media-source-append-media-segment-without-init.html

  • Modules/mediasource/MediaSource.cpp:

(WebCore::MediaSource::streamEndedWithError):

  • Modules/mediasource/MediaSource.h:
  • Modules/mediasource/SourceBuffer.cpp:

(WebCore::SourceBuffer::sourceBufferPrivateAppendComplete):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
(WebCore::SourceBuffer::validateInitializationSegment):
(WebCore::SourceBuffer::appendError):

  • Modules/mediasource/SourceBuffer.h:

LayoutTests:

Added test which after creating SourceBuffer sends media sample, without any init segments.

  • media/media-source/media-source-append-media-segment-without-init-expected.txt: Added.
  • media/media-source/media-source-append-media-segment-without-init.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r179723 r179725  
     12015-02-05  Bartlomiej Gajda  <b.gajda@samsung.com>
     2
     3        [MSE] Implement Append Error algorithm.
     4        https://bugs.webkit.org/show_bug.cgi?id=139439
     5
     6        Reviewed by Jer Noble.
     7
     8        If Source Buffer has not received first init segment, then it shall call endOfStream after receiving
     9        Media Segment, as per Media Source spec. (from 17 July 2014) in paragraph 3.5.1 point 6.1.
     10        Added test which after creating SourceBuffer sends media sample, without any init segments.
     11
     12        * media/media-source/media-source-append-media-segment-without-init-expected.txt: Added.
     13        * media/media-source/media-source-append-media-segment-without-init.html: Added.
     14
    1152015-02-05  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r179706 r179725  
     12015-02-05  Bartlomiej Gajda  <b.gajda@samsung.com>
     2
     3        [MSE] Implement Append Error algorithm.
     4        https://bugs.webkit.org/show_bug.cgi?id=139439
     5
     6        Reviewed by Jer Noble.
     7
     8        If Source Buffer has not received first init segment, then it shall call endOfStream after receiving
     9        Media Segment, as per Media Source spec. (from 17 July 2014) in paragraph 3.5.1 point 6.1.
     10
     11        Based this change on Editor's Draft 12 December 2014, as it clarifies order of events.
     12
     13        Test: media/media-source/media-source-append-media-segment-without-init.html
     14
     15        * Modules/mediasource/MediaSource.cpp:
     16        (WebCore::MediaSource::streamEndedWithError):
     17        * Modules/mediasource/MediaSource.h:
     18        * Modules/mediasource/SourceBuffer.cpp:
     19        (WebCore::SourceBuffer::sourceBufferPrivateAppendComplete):
     20        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
     21        (WebCore::SourceBuffer::validateInitializationSegment):
     22        (WebCore::SourceBuffer::appendError):
     23        * Modules/mediasource/SourceBuffer.h:
     24
    1252015-02-05  Maciej Stachowiak  <mjs@apple.com>
    226
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp

    r179577 r179725  
    617617
    618618    // 2. If the input buffer contains bytes that violate the SourceBuffer byte stream format specification,
    619     // then run the end of stream algorithm with the error parameter set to "decode" and abort this algorithm.
     619    // then run the append error algorithm with the decode error parameter set to true and abort this algorithm.
    620620    if (result == ParsingFailed) {
    621621        LOG(MediaSource, "SourceBuffer::sourceBufferPrivateAppendComplete(%p) - result = ParsingFailed", this);
    622         m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
     622        appendError(true);
    623623        return;
    624624    }
     
    998998    LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(%p)", this);
    999999
    1000     // 3.5.7 Initialization Segment Received
    1001     // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#sourcebuffer-init-segment-received
     1000    // 3.5.8 Initialization Segment Received (ctd)
     1001    // https://rawgit.com/w3c/media-source/c3ad59c7a370d04430969ba73d18dc9bcde57a33/index.html#sourcebuffer-init-segment-received [Editor's Draft 09 January 2015]
     1002
    10021003    // 1. Update the duration attribute if it currently equals NaN:
    10031004    if (m_source->duration().isInvalid()) {
     
    10101011    }
    10111012
    1012     // 2. If the initialization segment has no audio, video, or text tracks, then run the end of stream
    1013     // algorithm with the error parameter set to "decode" and abort these steps.
     1013    // 2. If the initialization segment has no audio, video, or text tracks, then run the append error algorithm
     1014    // with the decode error parameter set to true and abort these steps.
    10141015    if (!segment.audioTracks.size() && !segment.videoTracks.size() && !segment.textTracks.size())
    1015         m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
    1016 
     1016        appendError(true);
    10171017
    10181018    // 3. If the first initialization segment flag is true, then run the following steps:
    10191019    if (m_receivedFirstInitializationSegment) {
     1020
     1021        // 3.1. Verify the following properties. If any of the checks fail then run the append error algorithm
     1022        // with the decode error parameter set to true and abort these steps.
    10201023        if (!validateInitializationSegment(segment)) {
    1021             m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
     1024            appendError(true);
    10221025            return;
    10231026        }
     
    10591062        }
    10601063
     1064        // 3.3 Set the need random access point flag on all track buffers to true.
    10611065        for (auto& trackBuffer : m_trackBufferMap.values())
    10621066            trackBuffer.needRandomAccessFlag = true;
     
    10691073    if (!m_receivedFirstInitializationSegment) {
    10701074        // 5.1 If the initialization segment contains tracks with codecs the user agent does not support,
    1071         // then run the end of stream algorithm with the error parameter set to "decode" and abort these steps.
     1075        // then run the append error algorithm with the decode error parameter set to true and abort these steps.
    10721076        // NOTE: This check is the responsibility of the SourceBufferPrivate.
    10731077
     
    10761080            AudioTrackPrivate* audioTrackPrivate = audioTrackInfo.track.get();
    10771081
     1082            // FIXME: Implement steps 5.2.1-5.2.8.1 as per Editor's Draft 09 January 2015, and reorder this
    10781083            // 5.2.1 Let new audio track be a new AudioTrack object.
    10791084            // 5.2.2 Generate a unique ID and assign it to the id property on new video track.
     
    11161121            VideoTrackPrivate* videoTrackPrivate = videoTrackInfo.track.get();
    11171122
     1123            // FIXME: Implement steps 5.3.1-5.3.8.1 as per Editor's Draft 09 January 2015, and reorder this
    11181124            // 5.3.1 Let new video track be a new VideoTrack object.
    11191125            // 5.3.2 Generate a unique ID and assign it to the id property on new video track.
     
    11561162            InbandTextTrackPrivate* textTrackPrivate = textTrackInfo.track.get();
    11571163
     1164            // FIXME: Implement steps 5.4.1-5.4.8.1 as per Editor's Draft 09 January 2015, and reorder this
    11581165            // 5.4.1 Let new text track be a new TextTrack object with its properties populated with the
    11591166            // appropriate information from the initialization segment.
     
    11901197        if (activeTrackFlag) {
    11911198            // 5.5.1 Add this SourceBuffer to activeSourceBuffers.
     1199            // 5.5.2 Queue a task to fire a simple event named addsourcebuffer at activeSourceBuffers
    11921200            setActive(true);
    11931201        }
     
    12191227bool SourceBuffer::validateInitializationSegment(const InitializationSegment& segment)
    12201228{
    1221     // 3.5.7 Initialization Segment Received (ctd)
    1222     // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#sourcebuffer-init-segment-received
    1223 
    1224     // 3.1. Verify the following properties. If any of the checks fail then run the end of stream
    1225     // algorithm with the error parameter set to "decode" and abort these steps.
     1229    // FIXME: ordering of all 3.5.X (X>=7) functions needs to be updated to post-[24 July 2014 Editor's Draft] version
     1230    // 3.5.8 Initialization Segment Received (ctd)
     1231    // https://rawgit.com/w3c/media-source/c3ad59c7a370d04430969ba73d18dc9bcde57a33/index.html#sourcebuffer-init-segment-received [Editor's Draft 09 January 2015]
     1232
     1233    // Note: those are checks from step 3.1
    12261234    //   * The number of audio, video, and text tracks match what was in the first initialization segment.
    12271235    if (segment.audioTracks.size() != audioTracks()->length()
     
    12901298};
    12911299
     1300void SourceBuffer::appendError(bool decodeErrorParam)
     1301{
     1302    // 3.5.3 Append Error Algorithm
     1303    // https://rawgit.com/w3c/media-source/c3ad59c7a370d04430969ba73d18dc9bcde57a33/index.html#sourcebuffer-append-error [Editor's Draft 09 January 2015]
     1304
     1305    ASSERT(m_updating);
     1306    // 1. Run the reset parser state algorithm.
     1307    resetParserState();
     1308
     1309    // 2. Set the updating attribute to false.
     1310    m_updating = false;
     1311
     1312    // 3. Queue a task to fire a simple event named error at this SourceBuffer object.
     1313    scheduleEvent(eventNames().errorEvent);
     1314
     1315    // 4. Queue a task to fire a simple event named updateend at this SourceBuffer object.
     1316    scheduleEvent(eventNames().updateendEvent);
     1317
     1318    // 5. If decode error is true, then run the end of stream algorithm with the error parameter set to "decode".
     1319    if (decodeErrorParam)
     1320        m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
     1321}
     1322
    12921323void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, PassRefPtr<MediaSample> prpSample)
    12931324{
    12941325    if (isRemoved())
    12951326        return;
     1327
     1328    // 3.5.1 Segment Parser Loop
     1329    // 6.1 If the first initialization segment received flag is false, then run the append error algorithm
     1330    //     with the decode error parameter set to true and abort this algorithm.
     1331    // Note: current design makes SourceBuffer somehow ignorant of append state - it's more a thing
     1332    //  of SourceBufferPrivate. That's why this check can't really be done in appendInternal.
     1333    //  unless we force some kind of design with state machine switching.
     1334    if (!m_receivedFirstInitializationSegment) {
     1335        appendError(true);
     1336        return;
     1337    }
    12961338
    12971339    RefPtr<MediaSample> sample = prpSample;
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h

    r179044 r179725  
    9393    void remove(const MediaTime&, const MediaTime&, ExceptionCode&);
    9494
     95    void appendError(bool);
    9596    void abortIfUpdating();
    9697    void removedFromMediaSource();
Note: See TracChangeset for help on using the changeset viewer.