<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[176594] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/176594">176594</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-12-01 11:01:50 -0800 (Mon, 01 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[MSE] Unset timestamps of trackbuffers during Reset Parser State algorithm.
https://bugs.webkit.org/show_bug.cgi?id=139075.

Patch by Bartlomiej Gajda &lt;b.gajda@samsung.com&gt; on 2014-12-01
Reviewed by Jer Noble.

Source/WebCore:

Specification requires from us to unset timestamps for trackBuffers
during abort() method.

Test: media/media-source/media-source-append-nonsync-sample-after-abort.html

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::resetParserState):
(WebCore::SourceBuffer::abort):
* Modules/mediasource/SourceBuffer.h:

LayoutTests:

Specification requires from us to unset timestamps for trackBuffers during abort() method.
Tests appendBuffer() with first sync sample, then aborts after a few more samples, and emits
a few more non-sync samples, so they should be dropped, as trackBuffer will have
needRandomAccessFlag set.

* media/media-source/media-source-append-nonsync-sample-after-abort-expected.txt: Added.
* media/media-source/media-source-append-nonsync-sample-after-abort.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSourceBuffercpp">trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSourceBufferh">trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediamediasourcemediasourceappendnonsyncsampleafterabortexpectedtxt">trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediamediasourcemediasourceappendnonsyncsampleafteraborthtml">trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (176593 => 176594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-12-01 18:42:52 UTC (rev 176593)
+++ trunk/LayoutTests/ChangeLog        2014-12-01 19:01:50 UTC (rev 176594)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-12-01  Bartlomiej Gajda  &lt;b.gajda@samsung.com&gt;
+
+        [MSE] Unset timestamps of trackbuffers during Reset Parser State algorithm.
+        https://bugs.webkit.org/show_bug.cgi?id=139075.
+
+        Reviewed by Jer Noble.
+
+        Specification requires from us to unset timestamps for trackBuffers during abort() method.
+        Tests appendBuffer() with first sync sample, then aborts after a few more samples, and emits
+        a few more non-sync samples, so they should be dropped, as trackBuffer will have
+        needRandomAccessFlag set.
+
+        * media/media-source/media-source-append-nonsync-sample-after-abort-expected.txt: Added.
+        * media/media-source/media-source-append-nonsync-sample-after-abort.html: Added.
+
</ins><span class="cx"> 2014-11-28  Andrzej Badowski  &lt;a.badowski@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [ATK] Allowing the use of AccessibilityUIElement::columnHeaders method for table.
</span></span></pre></div>
<a id="trunkLayoutTestsmediamediasourcemediasourceappendnonsyncsampleafterabortexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort-expected.txt (0 => 176594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort-expected.txt        2014-12-01 19:01:50 UTC (rev 176594)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+
+RUN(video.src = URL.createObjectURL(source))
+RUN(quality = video.getVideoPlaybackQuality())
+EXPECTED (quality.droppedVideoFrames == '0') OK
+EXPECTED (video.duration == '4') OK
+RUN(quality = video.getVideoPlaybackQuality())
+EXPECTED (quality.droppedVideoFrames == '5') OK
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediamediasourcemediasourceappendnonsyncsampleafteraborthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort.html (0 => 176594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort.html                                (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-append-nonsync-sample-after-abort.html        2014-12-01 19:01:50 UTC (rev 176594)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;mock-media-source&lt;/title&gt;
+    &lt;script src=&quot;mock-media-source.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../video-test.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+    var source;
+    var sourceBuffer;
+    var quality;
+
+    var nextRequest = 0;
+    var sampleCount = 10;
+    var abortAfter  = 4;
+    var droppedAmount = sampleCount - abortAfter - 1; // 1 sample will be aborted
+
+    if (window.internals)
+        internals.initializeMockMediaSource();
+
+    function runTest() {
+        findMediaElement();
+        source = new MediaSource();
+        source.addEventListener('sourceopen', startLoad);
+        run('video.src = URL.createObjectURL(source)');
+    }
+
+    function startLoad() {
+        sourceBuffer = source.addSourceBuffer('video/mock; codecs=&quot;mock&quot;');
+        sourceBuffer.addEventListener('updateend', sourceUpdated);
+
+        run('quality = video.getVideoPlaybackQuality()');
+        testExpected('quality.droppedVideoFrames', 0);
+
+        // Make an init segment with 1 video track
+        var init = makeAInit(0, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+        sourceBuffer.appendBuffer(init);
+    }
+
+    function sourceUpdated() {
+        if (nextRequest == sampleCount) {
+            finishTest();
+            return;
+        }
+
+        sourceBuffer.appendBuffer(
+            makeASample(nextRequest, nextRequest, 1, 1,
+            (nextRequest == 0) ? SAMPLE_FLAG.SYNC : SAMPLE_FLAG.NONE
+            ));
+
+        if (nextRequest == abortAfter)
+            sourceBuffer.abort();
+
+        ++nextRequest;
+    }
+
+    function finishTest() {
+        testExpected('video.duration', abortAfter);
+        run('quality = video.getVideoPlaybackQuality()');
+        testExpected('quality.droppedVideoFrames', droppedAmount);
+        endTest();
+    }
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;video&gt;&lt;/video&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176593 => 176594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-12-01 18:42:52 UTC (rev 176593)
+++ trunk/Source/WebCore/ChangeLog        2014-12-01 19:01:50 UTC (rev 176594)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-12-01  Bartlomiej Gajda  &lt;b.gajda@samsung.com&gt;
+
+        [MSE] Unset timestamps of trackbuffers during Reset Parser State algorithm.
+        https://bugs.webkit.org/show_bug.cgi?id=139075.
+
+        Reviewed by Jer Noble.
+
+        Specification requires from us to unset timestamps for trackBuffers
+        during abort() method.
+
+        Test: media/media-source/media-source-append-nonsync-sample-after-abort.html
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::resetParserState):
+        (WebCore::SourceBuffer::abort):
+        * Modules/mediasource/SourceBuffer.h:
+
</ins><span class="cx"> 2014-12-01  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Transform StyleBuilderCustom into a class and mark it as a friend of RenderStyle
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (176593 => 176594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-12-01 18:42:52 UTC (rev 176593)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-12-01 19:01:50 UTC (rev 176594)
</span><span class="lines">@@ -217,6 +217,33 @@
</span><span class="cx">     appendBufferInternal(static_cast&lt;unsigned char*&gt;(data-&gt;baseAddress()), data-&gt;byteLength(), ec);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SourceBuffer::resetParserState()
+{
+    // Section 3.5.2 Reset Parser State algorithm steps.
+    // http://www.w3.org/TR/2014/CR-media-source-20140717/#sourcebuffer-reset-parser-state
+    // 1. If the append state equals PARSING_MEDIA_SEGMENT and the input buffer contains some complete coded frames,
+    //    then run the coded frame processing algorithm until all of these complete coded frames have been processed.
+    // FIXME: If any implementation will work in pulling mode (instead of async push to SourceBufferPrivate, and forget)
+    //     this should be handled somehow either here, or in m_private-&gt;abort();
+
+    // 2. Unset the last decode timestamp on all track buffers.
+    // 3. Unset the last frame duration on all track buffers.
+    // 4. Unset the highest presentation timestamp on all track buffers.
+    // 5. Set the need random access point flag on all track buffers to true.
+    for (auto&amp; trackBufferPair : m_trackBufferMap.values()) {
+        trackBufferPair.lastDecodeTimestamp = MediaTime::invalidTime();
+        trackBufferPair.lastFrameDuration = MediaTime::invalidTime();
+        trackBufferPair.highestPresentationTimestamp = MediaTime::invalidTime();
+        trackBufferPair.needRandomAccessFlag = true;
+    }
+    // 6. Remove all bytes from the input buffer.
+    // Note: this is handled by abortIfUpdating()
+    // 7. Set append state to WAITING_FOR_SEGMENT.
+    m_appendState = WaitingForSegment;
+
+    m_private-&gt;abort();
+}
+
</ins><span class="cx"> void SourceBuffer::abort(ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     // Section 3.2 abort() method steps.
</span><span class="lines">@@ -234,7 +261,7 @@
</span><span class="cx">     abortIfUpdating();
</span><span class="cx"> 
</span><span class="cx">     // 4. Run the reset parser state algorithm.
</span><del>-    m_private-&gt;abort();
</del><ins>+    resetParserState();
</ins><span class="cx"> 
</span><span class="cx">     // FIXME(229408) Add steps 5-6 update appendWindowStart &amp; appendWindowEnd.
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (176593 => 176594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-12-01 18:42:52 UTC (rev 176593)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-12-01 19:01:50 UTC (rev 176594)
</span><span class="lines">@@ -153,6 +153,7 @@
</span><span class="cx"> 
</span><span class="cx">     void appendBufferInternal(unsigned char*, unsigned, ExceptionCode&amp;);
</span><span class="cx">     void appendBufferTimerFired();
</span><ins>+    void resetParserState();
</ins><span class="cx"> 
</span><span class="cx">     void setActive(bool);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>