<!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>[169523] 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/169523">169523</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-06-01 22:16:46 -0700 (Sun, 01 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[MSE] Appends of overlapping sample data do not clear existing samples properly.
https://bugs.webkit.org/show_bug.cgi?id=133435

Reviewed by Darin Adler.

Source/WebCore:
Test: media/media-source/media-source-overlapping-append.html

The MSE spec has a spec error in how it removes overlapping frames. The intention seems to be
to check for overlapping samples only when the incoming sample increases the highest presentation time
field. But due to a mismatch in the range of a sample, defined as [start, end), and the check, which
treats the end as inclusive, the overlapping check is almost never run.

Add the sample comparison logic to match [start, end) ranges, and rename the existing check to differentiate
it from the new one:
* Modules/mediasource/SampleMap.cpp:
(WebCore::SamplePresentationTimeIsInsideRangeComparator::operator()):
(WebCore::SamplePresentationTimeIsWithinRangeComparator::operator()):
(WebCore::SampleMap::findSamplesBetweenPresentationTimes):
(WebCore::SampleMap::findSamplesWithinPresentationRange):
* Modules/mediasource/SampleMap.h:

Update the overlapping check to occur whenever the highest presentation time increases, and update the
logic within that check to catch all overlapping frames.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
(WebCore::SourceBuffer::bufferedSamplesForTrackID):
* Modules/mediasource/SourceBuffer.h:
* WebCore.exp.in:

Add a dump method to MediaSample so that samples can be easily converted to a string for testing.
* platform/MediaSample.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::presentationSize):
(WebCore::MediaSampleAVFObjC::dump):

Update the Mock MSE implementation to pass along a &quot;generation&quot; field, to aid in testing.
* platform/mock/mediasource/MockBox.cpp:
(WebCore::MockSampleBox::MockSampleBox):
* platform/mock/mediasource/MockBox.h:
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockMediaSample::dump):

Add a method to internals to dump the buffered samples to string.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::bufferedSamplesForTrackID):
* Modules/mediasource/SourceBuffer.h:
* testing/Internals.cpp:
(WebCore::Internals::bufferedSamplesForTrackID):
* testing/Internals.h:
* testing/Internals.idl:

Source/WTF:
Add a dump method to MediaTime, so that MediaTimes can be easily converted to strings (for logging purposes).

* wtf/MediaTime.cpp:
(WTF::MediaTime::dump):
* wtf/MediaTime.h:

LayoutTests:
* media/media-source/media-source-overlapping-append-expected.txt: Added.
* media/media-source/media-source-overlapping-append.html: Added.
* media/media-source/mock-media-source.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmediamediasourcemockmediasourcejs">trunk/LayoutTests/media/media-source/mock-media-source.js</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfMediaTimecpp">trunk/Source/WTF/wtf/MediaTime.cpp</a></li>
<li><a href="#trunkSourceWTFwtfMediaTimeh">trunk/Source/WTF/wtf/MediaTime.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSampleMapcpp">trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSampleMaph">trunk/Source/WebCore/Modules/mediasource/SampleMap.h</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>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformMediaSampleh">trunk/Source/WebCore/platform/MediaSample.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmockmediasourceMockBoxcpp">trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockmediasourceMockBoxh">trunk/Source/WebCore/platform/mock/mediasource/MockBox.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockmediasourceMockSourceBufferPrivatecpp">trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediamediasourcemediasourceoverlappingappendexpectedtxt">trunk/LayoutTests/media/media-source/media-source-overlapping-append-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediamediasourcemediasourceoverlappingappendhtml">trunk/LayoutTests/media/media-source/media-source-overlapping-append.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/LayoutTests/ChangeLog        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-06-01  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [MSE] Appends of overlapping sample data do not clear existing samples properly.
+        https://bugs.webkit.org/show_bug.cgi?id=133435
+
+        Reviewed by Darin Adler.
+
+        * media/media-source/media-source-overlapping-append-expected.txt: Added.
+        * media/media-source/media-source-overlapping-append.html: Added.
+        * media/media-source/mock-media-source.js:
+
</ins><span class="cx"> 2014-06-01  Nikos Andronikos  &lt;nikos.andronikos-webkit@cisra.canon.com.au&gt;
</span><span class="cx"> 
</span><span class="cx">         getBBox() returns (0,0) when width or height is zero.
</span></span></pre></div>
<a id="trunkLayoutTestsmediamediasourcemediasourceoverlappingappendexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/media-source/media-source-overlapping-append-expected.txt (0 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-source/media-source-overlapping-append-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-overlapping-append-expected.txt        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+
+RUN(video.src = URL.createObjectURL(source))
+EVENT(sourceopen)
+RUN(sourceBuffer = source.addSourceBuffer(&quot;video/mock; codecs=mock&quot;))
+RUN(sourceBuffer.appendBuffer(initSegment))
+EVENT(updateend)
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+EXPECTED (bufferedSamples.length == '6') OK
+{PTS({0/1000, 0.000000}), DTS({0/1000, 0.000000}), duration({1000/1000, 1.000000}), flags(1), generation(0)}
+{PTS({1000/1000, 1.000000}), DTS({1000/1000, 1.000000}), duration({1000/1000, 1.000000}), flags(0), generation(0)}
+{PTS({2000/1000, 2.000000}), DTS({2000/1000, 2.000000}), duration({1000/1000, 1.000000}), flags(0), generation(0)}
+{PTS({3000/1000, 3.000000}), DTS({3000/1000, 3.000000}), duration({1000/1000, 1.000000}), flags(1), generation(0)}
+{PTS({4000/1000, 4.000000}), DTS({4000/1000, 4.000000}), duration({1000/1000, 1.000000}), flags(0), generation(0)}
+{PTS({5000/1000, 5.000000}), DTS({5000/1000, 5.000000}), duration({1000/1000, 1.000000}), flags(0), generation(0)}
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+EXPECTED (bufferedSamples.length == '6') OK
+{PTS({0/1000, 0.000000}), DTS({0/1000, 0.000000}), duration({1000/1000, 1.000000}), flags(1), generation(1)}
+{PTS({1000/1000, 1.000000}), DTS({1000/1000, 1.000000}), duration({1000/1000, 1.000000}), flags(0), generation(1)}
+{PTS({2000/1000, 2.000000}), DTS({2000/1000, 2.000000}), duration({1000/1000, 1.000000}), flags(0), generation(1)}
+{PTS({3000/1000, 3.000000}), DTS({3000/1000, 3.000000}), duration({1000/1000, 1.000000}), flags(1), generation(1)}
+{PTS({4000/1000, 4.000000}), DTS({4000/1000, 4.000000}), duration({1000/1000, 1.000000}), flags(0), generation(1)}
+{PTS({5000/1000, 5.000000}), DTS({5000/1000, 5.000000}), duration({1000/1000, 1.000000}), flags(0), generation(1)}
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+EXPECTED (bufferedSamples.length == '6') OK
+{PTS({0/1000, 0.000000}), DTS({0/1000, 0.000000}), duration({1000/1000, 1.000000}), flags(1), generation(2)}
+{PTS({2000/1000, 2.000000}), DTS({1000/1000, 1.000000}), duration({1000/1000, 1.000000}), flags(0), generation(2)}
+{PTS({1000/1000, 1.000000}), DTS({2000/1000, 2.000000}), duration({1000/1000, 1.000000}), flags(0), generation(2)}
+{PTS({3000/1000, 3.000000}), DTS({3000/1000, 3.000000}), duration({1000/1000, 1.000000}), flags(1), generation(2)}
+{PTS({5000/1000, 5.000000}), DTS({4000/1000, 4.000000}), duration({1000/1000, 1.000000}), flags(0), generation(2)}
+{PTS({4000/1000, 4.000000}), DTS({5000/1000, 5.000000}), duration({1000/1000, 1.000000}), flags(0), generation(2)}
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediamediasourcemediasourceoverlappingappendhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/media-source/media-source-overlapping-append.html (0 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-source/media-source-overlapping-append.html                                (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-overlapping-append.html        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -0,0 +1,96 @@
</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 initSegment;
+    var samples;
+    var bufferedSamples;
+
+    if (window.internals)
+        internals.initializeMockMediaSource();
+
+    function runTest()
+    {
+        findMediaElement();
+
+        source = new MediaSource();
+        waitForEventOn(source, 'sourceopen', sourceOpen);
+        run('video.src = URL.createObjectURL(source)');
+    }
+
+    function sourceOpen()
+    {
+        run('sourceBuffer = source.addSourceBuffer(&quot;video/mock; codecs=mock&quot;)');
+        waitForEventOn(sourceBuffer, 'updateend', loadOrderedSamples, false, true);
+        initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+        run('sourceBuffer.appendBuffer(initSegment)');
+    }
+
+    function loadOrderedSamples()
+    {
+       samples = concatenateSamples([
+            makeASample(0, 0, 1, 1, SAMPLE_FLAG.SYNC, 0),
+            makeASample(1, 1, 1, 1, SAMPLE_FLAG.NONE, 0),
+            makeASample(2, 2, 1, 1, SAMPLE_FLAG.NONE, 0),
+            makeASample(3, 3, 1, 1, SAMPLE_FLAG.SYNC, 0),
+            makeASample(4, 4, 1, 1, SAMPLE_FLAG.NONE, 0),
+            makeASample(5, 5, 1, 1, SAMPLE_FLAG.NONE, 0),
+        ]);
+        waitForEventOn(sourceBuffer, 'updateend', loadMoreOrderedSamples, false, true);
+        run('sourceBuffer.appendBuffer(samples)');
+    }
+
+    function loadMoreOrderedSamples()
+    {
+        bufferedSamples = internals.bufferedSamplesForTrackID(sourceBuffer, 1);
+        testExpected(&quot;bufferedSamples.length&quot;, 6);
+        bufferedSamples.forEach(consoleWrite);
+
+        samples = concatenateSamples([
+            makeASample(0, 0, 1, 1, SAMPLE_FLAG.SYNC, 1),
+            makeASample(1, 1, 1, 1, SAMPLE_FLAG.NONE, 1),
+            makeASample(2, 2, 1, 1, SAMPLE_FLAG.NONE, 1),
+            makeASample(3, 3, 1, 1, SAMPLE_FLAG.SYNC, 1),
+            makeASample(4, 4, 1, 1, SAMPLE_FLAG.NONE, 1),
+            makeASample(5, 5, 1, 1, SAMPLE_FLAG.NONE, 1),
+        ]);
+        waitForEventOn(sourceBuffer, 'updateend', loadUnorderedSamples, false, true);
+        run('sourceBuffer.appendBuffer(samples)');
+    }
+
+    function loadUnorderedSamples()
+    {
+        bufferedSamples = internals.bufferedSamplesForTrackID(sourceBuffer, 1);
+        testExpected(&quot;bufferedSamples.length&quot;, 6);
+        bufferedSamples.forEach(consoleWrite);
+
+        samples = concatenateSamples([
+            makeASample(0, 0, 1, 1, SAMPLE_FLAG.SYNC, 2),
+            makeASample(2, 1, 1, 1, SAMPLE_FLAG.NONE, 2),
+            makeASample(1, 2, 1, 1, SAMPLE_FLAG.NONE, 2),
+            makeASample(3, 3, 1, 1, SAMPLE_FLAG.SYNC, 2),
+            makeASample(5, 4, 1, 1, SAMPLE_FLAG.NONE, 2),
+            makeASample(4, 5, 1, 1, SAMPLE_FLAG.NONE, 2),
+        ]);
+        waitForEventOn(sourceBuffer, 'updateend', samplesAdded, false, true);
+        run('sourceBuffer.appendBuffer(samples)');
+    }
+
+     function samplesAdded()
+    {
+        bufferedSamples = internals.bufferedSamplesForTrackID(sourceBuffer, 1);
+        testExpected(&quot;bufferedSamples.length&quot;, 6);
+        bufferedSamples.forEach(consoleWrite);
+
+        endTest();
+    }
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;video&gt;&lt;/video&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsmediamediasourcemockmediasourcejs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/media-source/mock-media-source.js (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/media-source/mock-media-source.js        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/LayoutTests/media/media-source/mock-media-source.js        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -16,8 +16,8 @@
</span><span class="cx">     DELAYED: 1 &lt;&lt; 3,
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-function makeASample(presentationTime, decodeTime, duration, trackID, flags) {
-    var byteLength = 29;
</del><ins>+function makeASample(presentationTime, decodeTime, duration, trackID, flags, generation) {
+    var byteLength = 30;
</ins><span class="cx">     var buffer = new ArrayBuffer(byteLength);
</span><span class="cx">     var array = new Uint8Array(buffer);
</span><span class="cx">     array.set(stringToArray('smpl'));
</span><span class="lines">@@ -32,8 +32,9 @@
</span><span class="cx">     view.setInt32(20, duration * timeScale, true);
</span><span class="cx">     view.setInt32(24, trackID, true);
</span><span class="cx">     view.setUint8(28, flags);
</span><ins>+    view.setUint8(29, generation);
</ins><span class="cx"> 
</span><del>-    return buffer;
</del><ins>+    return buffer
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function concatenateSamples(samples) {
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WTF/ChangeLog        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-06-01  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [MSE] Appends of overlapping sample data do not clear existing samples properly.
+        https://bugs.webkit.org/show_bug.cgi?id=133435
+
+        Reviewed by Darin Adler.
+
+        Add a dump method to MediaTime, so that MediaTimes can be easily converted to strings (for logging purposes).
+
+        * wtf/MediaTime.cpp:
+        (WTF::MediaTime::dump):
+        * wtf/MediaTime.h:
+
</ins><span class="cx"> 2014-05-31  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a LazyNeverDestroyed class template and use it
</span></span></pre></div>
<a id="trunkSourceWTFwtfMediaTimecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MediaTime.cpp (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MediaTime.cpp        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WTF/wtf/MediaTime.cpp        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &lt;algorithm&gt;
</span><span class="cx"> #include &lt;wtf/CheckedArithmetic.h&gt;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><ins>+#include &lt;wtf/PrintStream.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><span class="lines">@@ -374,6 +375,11 @@
</span><span class="cx">     m_timeScale = timeScale;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaTime::dump(PrintStream &amp;out) const
+{
+    out.print(&quot;{&quot;, m_timeValue, &quot;/&quot;, m_timeScale, &quot;, &quot;, toDouble(), &quot;}&quot;);
+}
+
</ins><span class="cx"> MediaTime abs(const MediaTime&amp; rhs)
</span><span class="cx"> {
</span><span class="cx">     if (rhs.isInvalid())
</span></span></pre></div>
<a id="trunkSourceWTFwtfMediaTimeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MediaTime.h (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MediaTime.h        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WTF/wtf/MediaTime.h        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><ins>+class PrintStream;
+
</ins><span class="cx"> class WTF_EXPORT_PRIVATE MediaTime {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="lines">@@ -97,9 +99,11 @@
</span><span class="cx">     const int64_t&amp; timeValue() const { return m_timeValue; }
</span><span class="cx">     const int32_t&amp; timeScale() const { return m_timeScale; }
</span><span class="cx"> 
</span><ins>+    void dump(PrintStream&amp; out) const;
+
</ins><span class="cx">     friend WTF_EXPORT_PRIVATE MediaTime abs(const MediaTime&amp; rhs);
</span><span class="cx"> private:
</span><del>-    static const int32_t DefaultTimeScale = 6000;
</del><ins>+    static const int32_t DefaultTimeScale = 10000000;
</ins><span class="cx">     static const int32_t MaximumTimeScale;
</span><span class="cx"> 
</span><span class="cx">     void setTimeScale(int32_t);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/ChangeLog        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2014-06-01  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [MSE] Appends of overlapping sample data do not clear existing samples properly.
+        https://bugs.webkit.org/show_bug.cgi?id=133435
+
+        Reviewed by Darin Adler.
+
+        Test: media/media-source/media-source-overlapping-append.html
+
+        The MSE spec has a spec error in how it removes overlapping frames. The intention seems to be
+        to check for overlapping samples only when the incoming sample increases the highest presentation time
+        field. But due to a mismatch in the range of a sample, defined as [start, end), and the check, which 
+        treats the end as inclusive, the overlapping check is almost never run.
+
+        Add the sample comparison logic to match [start, end) ranges, and rename the existing check to differentiate
+        it from the new one:
+        * Modules/mediasource/SampleMap.cpp:
+        (WebCore::SamplePresentationTimeIsInsideRangeComparator::operator()):
+        (WebCore::SamplePresentationTimeIsWithinRangeComparator::operator()):
+        (WebCore::SampleMap::findSamplesBetweenPresentationTimes):
+        (WebCore::SampleMap::findSamplesWithinPresentationRange):
+        * Modules/mediasource/SampleMap.h:
+
+        Update the overlapping check to occur whenever the highest presentation time increases, and update the
+        logic within that check to catch all overlapping frames.
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
+        (WebCore::SourceBuffer::bufferedSamplesForTrackID):
+        * Modules/mediasource/SourceBuffer.h:
+        * WebCore.exp.in:
+
+        Add a dump method to MediaSample so that samples can be easily converted to a string for testing.
+        * platform/MediaSample.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::MediaSampleAVFObjC::presentationSize):
+        (WebCore::MediaSampleAVFObjC::dump):
+
+        Update the Mock MSE implementation to pass along a &quot;generation&quot; field, to aid in testing.
+        * platform/mock/mediasource/MockBox.cpp:
+        (WebCore::MockSampleBox::MockSampleBox):
+        * platform/mock/mediasource/MockBox.h:
+        * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+        (WebCore::MockMediaSample::dump):
+
+        Add a method to internals to dump the buffered samples to string.
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::bufferedSamplesForTrackID):
+        * Modules/mediasource/SourceBuffer.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::bufferedSamplesForTrackID):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2014-06-01  Nikos Andronikos  &lt;nikos.andronikos-webkit@cisra.canon.com.au&gt;
</span><span class="cx"> 
</span><span class="cx">         getBBox() returns (0,0) when width or height is zero.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSampleMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -68,14 +68,26 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class SamplePresentationTimeIsWithinRangeComparator {
-public:
-    bool operator()(std::pair&lt;MediaTime, MediaTime&gt; range, std::pair&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt; value)
</del><ins>+// SamplePresentationTimeIsInsideRangeComparator matches (range.first, range.second]
+struct SamplePresentationTimeIsInsideRangeComparator {
+    bool operator()(std::pair&lt;MediaTime, MediaTime&gt; range, const std::pair&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt;&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         return range.second &lt; value.first;
</span><span class="cx">     }
</span><del>-    bool operator()(std::pair&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt; value, std::pair&lt;MediaTime, MediaTime&gt; range)
</del><ins>+    bool operator()(const std::pair&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt;&amp; value, std::pair&lt;MediaTime, MediaTime&gt; range)
</ins><span class="cx">     {
</span><ins>+        return value.first &lt;= range.first;
+    }
+};
+
+// SamplePresentationTimeIsWithinRangeComparator matches [range.first, range.second)
+struct SamplePresentationTimeIsWithinRangeComparator {
+    bool operator()(std::pair&lt;MediaTime, MediaTime&gt; range, const std::pair&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt;&amp; value)
+    {
+        return range.second &lt;= value.first;
+    }
+    bool operator()(const std::pair&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt;&amp; value, std::pair&lt;MediaTime, MediaTime&gt; range)
+    {
</ins><span class="cx">         return value.first &lt; range.first;
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="lines">@@ -191,6 +203,12 @@
</span><span class="cx"> SampleMap::iterator_range SampleMap::findSamplesBetweenPresentationTimes(const MediaTime&amp; begin, const MediaTime&amp; end)
</span><span class="cx"> {
</span><span class="cx">     std::pair&lt;MediaTime, MediaTime&gt; range(begin, end);
</span><ins>+    return std::equal_range(presentationBegin(), presentationEnd(), range, SamplePresentationTimeIsInsideRangeComparator());
+}
+
+SampleMap::iterator_range SampleMap::findSamplesWithinPresentationRange(const MediaTime&amp; begin, const MediaTime&amp; end)
+{
+    std::pair&lt;MediaTime, MediaTime&gt; range(begin, end);
</ins><span class="cx">     return std::equal_range(presentationBegin(), presentationEnd(), range, SamplePresentationTimeIsWithinRangeComparator());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSampleMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SampleMap.h (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SampleMap.h        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/Modules/mediasource/SampleMap.h        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx">     iterator findSyncSampleAfterDecodeIterator(iterator);
</span><span class="cx"> 
</span><span class="cx">     iterator_range findSamplesBetweenPresentationTimes(const MediaTime&amp;, const MediaTime&amp;);
</span><ins>+    iterator_range findSamplesWithinPresentationRange(const MediaTime&amp;, const MediaTime&amp;);
</ins><span class="cx">     reverse_iterator_range findDependentSamples(MediaSample*);
</span><span class="cx">     
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -731,6 +731,9 @@
</span><span class="cx">             ASSERT(textTrack);
</span><span class="cx">             toInbandTextTrack(textTrack)-&gt;setPrivate(textTrackInfo.track);
</span><span class="cx">         }
</span><ins>+
+        for (auto&amp; trackBuffer : m_trackBufferMap.values())
+            trackBuffer.needRandomAccessFlag = true;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // 4. Let active track flag equal false.
</span><span class="lines">@@ -1074,10 +1077,9 @@
</span><span class="cx">         SampleMap::MapType erasedSamples;
</span><span class="cx">         MediaTime microsecond(1, 1000000);
</span><span class="cx"> 
</span><del>-        // 1.14 If last decode timestamp for track buffer is unset and there is a coded frame in
-        // track buffer with a presentation timestamp less than or equal to presentation timestamp
-        // and presentation timestamp is less than this coded frame's presentation timestamp plus
-        // its frame duration, then run the following steps:
</del><ins>+        // 1.14 If last decode timestamp for track buffer is unset and presentation timestamp falls
+        // falls within the presentation interval of a coded frame in track buffer, then run the
+        // following steps:
</ins><span class="cx">         if (trackBuffer.lastDecodeTimestamp.isInvalid()) {
</span><span class="cx">             auto iter = trackBuffer.samples.findSampleContainingPresentationTime(presentationTimestamp);
</span><span class="cx">             if (iter != trackBuffer.samples.presentationEnd()) {
</span><span class="lines">@@ -1122,10 +1124,10 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // If highest presentation timestamp for track buffer is set and less than presentation timestamp
</span><del>-        if (trackBuffer.highestPresentationTimestamp.isValid() &amp;&amp; trackBuffer.highestPresentationTimestamp &lt; presentationTimestamp) {
</del><ins>+        if (trackBuffer.highestPresentationTimestamp.isValid() &amp;&amp; trackBuffer.highestPresentationTimestamp &lt;= presentationTimestamp) {
</ins><span class="cx">             // Remove all coded frames from track buffer that have a presentation timestamp greater than highest
</span><span class="cx">             // presentation timestamp and less than or equal to frame end timestamp.
</span><del>-            auto iter_pair = trackBuffer.samples.findSamplesBetweenPresentationTimes(trackBuffer.highestPresentationTimestamp, frameEndTimestamp);
</del><ins>+            auto iter_pair = trackBuffer.samples.findSamplesWithinPresentationRange(trackBuffer.highestPresentationTimestamp, frameEndTimestamp);
</ins><span class="cx">             if (iter_pair.first != trackBuffer.samples.presentationEnd())
</span><span class="cx">                 erasedSamples.insert(iter_pair.first, iter_pair.second);
</span><span class="cx">         }
</span><span class="lines">@@ -1454,6 +1456,20 @@
</span><span class="cx">         scriptExecutionContext()-&gt;vm().heap.reportExtraMemoryCost(extraMemoryCostDelta);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;String&gt; SourceBuffer::bufferedSamplesForTrackID(const AtomicString&amp; trackID)
+{
+    auto it = m_trackBufferMap.find(trackID);
+    if (it == m_trackBufferMap.end())
+        return Vector&lt;String&gt;();
+
+    TrackBuffer&amp; trackBuffer = it-&gt;value;
+    Vector&lt;String&gt; sampleDescriptions;
+    for (auto sampleIter = trackBuffer.samples.decodeBegin(); sampleIter != trackBuffer.samples.decodeEnd(); ++sampleIter)
+        sampleDescriptions.append(toString(*sampleIter-&gt;second));
+
+    return sampleDescriptions;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -158,6 +158,10 @@
</span><span class="cx"> 
</span><span class="cx">     void reportExtraMemoryCost();
</span><span class="cx"> 
</span><ins>+    // Internals
+    friend class Internals;
+    Vector&lt;String&gt; bufferedSamplesForTrackID(const AtomicString&amp;);
+
</ins><span class="cx">     Ref&lt;SourceBufferPrivate&gt; m_private;
</span><span class="cx">     MediaSource* m_source;
</span><span class="cx">     GenericEventQueue m_asyncEventQueue;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -3157,6 +3157,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE)
</span><ins>+__ZN7WebCore12SourceBuffer25bufferedSamplesForTrackIDERKN3WTF12AtomicStringE
+__ZN7WebCore14toSourceBufferEN3JSC7JSValueE
</ins><span class="cx"> __ZN7WebCore26MockMediaPlayerMediaSource19registerMediaEngineEPFvPFN3WTF10PassOwnPtrINS_27MediaPlayerPrivateInterfaceEEEPNS_11MediaPlayerEEPFvRNS1_7HashSetINS1_6StringENS1_10StringHashENS1_10HashTraitsISA_EEEEEPFNS5_12SupportsTypeERKNS_28MediaEngineSupportParametersEEPFvRNS1_6VectorISA_Lm0ENS1_15CrashOnOverflowEEEEPFvvEPFvRKSA_EPFbSX_SX_EE
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMediaSampleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MediaSample.h (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MediaSample.h        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/platform/MediaSample.h        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef MediaSample_h
</span><span class="cx"> #define MediaSample_h
</span><span class="cx"> 
</span><ins>+#include &quot;FloatSize.h&quot;
</ins><span class="cx"> #include &lt;wtf/MediaTime.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/text/AtomicString.h&gt;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx">     virtual MediaTime duration() const = 0;
</span><span class="cx">     virtual AtomicString trackID() const = 0;
</span><span class="cx">     virtual size_t sizeInBytes() const = 0;
</span><ins>+    virtual FloatSize presentationSize() const = 0;
</ins><span class="cx"> 
</span><span class="cx">     enum SampleFlags {
</span><span class="cx">         None = 0,
</span><span class="lines">@@ -67,6 +69,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool isSync() const { return flags() &amp; IsSync; }
</span><span class="cx">     bool isNonDisplaying() const { return flags() &amp; NonDisplaying; }
</span><ins>+
+    virtual void dump(PrintStream&amp;) const = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -289,22 +289,24 @@
</span><span class="cx">     static RefPtr&lt;MediaSampleAVFObjC&gt; create(CMSampleBufferRef sample, int trackID) { return adoptRef(new MediaSampleAVFObjC(sample, trackID)); }
</span><span class="cx">     virtual ~MediaSampleAVFObjC() { }
</span><span class="cx"> 
</span><ins>+private:
+    MediaSampleAVFObjC(CMSampleBufferRef sample, int trackID)
+        : m_sample(sample)
+        , m_id(String::format(&quot;%d&quot;, trackID))
+    {
+    }
+
</ins><span class="cx">     virtual MediaTime presentationTime() const override { return toMediaTime(CMSampleBufferGetPresentationTimeStamp(m_sample.get())); }
</span><span class="cx">     virtual MediaTime decodeTime() const override { return toMediaTime(CMSampleBufferGetDecodeTimeStamp(m_sample.get())); }
</span><span class="cx">     virtual MediaTime duration() const override { return toMediaTime(CMSampleBufferGetDuration(m_sample.get())); }
</span><span class="cx">     virtual AtomicString trackID() const override { return m_id; }
</span><span class="cx">     virtual size_t sizeInBytes() const override { return CMSampleBufferGetTotalSampleSize(m_sample.get()); }
</span><ins>+    virtual FloatSize presentationSize() const override;
</ins><span class="cx"> 
</span><span class="cx">     virtual SampleFlags flags() const override;
</span><span class="cx">     virtual PlatformSample platformSample() override;
</span><ins>+    virtual void dump(PrintStream&amp;) const override;
</ins><span class="cx"> 
</span><del>-protected:
-    MediaSampleAVFObjC(CMSampleBufferRef sample, int trackID)
-        : m_sample(sample)
-        , m_id(String::format(&quot;%d&quot;, trackID))
-    {
-    }
-
</del><span class="cx">     RetainPtr&lt;CMSampleBufferRef&gt; m_sample;
</span><span class="cx">     AtomicString m_id;
</span><span class="cx"> };
</span><span class="lines">@@ -339,6 +341,20 @@
</span><span class="cx">     return SampleFlags(returnValue);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+FloatSize MediaSampleAVFObjC::presentationSize() const
+{
+    CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(m_sample.get());
+    if (CMFormatDescriptionGetMediaType(formatDescription) != kCMMediaType_Video)
+        return FloatSize();
+
+    return FloatSize(CMVideoFormatDescriptionGetPresentationDimensions(formatDescription, true, true)); 
+}
+
+void MediaSampleAVFObjC::dump(PrintStream&amp; out) const
+{
+    out.print(&quot;{PTS(&quot;, presentationTime(), &quot;), DTS(&quot;, decodeTime(), &quot;), duration(&quot;, duration(), &quot;), flags(&quot;, (int)flags(), &quot;), presentationSize(&quot;, presentationSize(), &quot;)}&quot;);
+}
+
</ins><span class="cx"> #pragma mark -
</span><span class="cx"> #pragma mark MediaDescriptionAVFObjC
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockmediasourceMockBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -112,7 +112,7 @@
</span><span class="cx"> MockSampleBox::MockSampleBox(ArrayBuffer* data)
</span><span class="cx">     : MockBox(data)
</span><span class="cx"> {
</span><del>-    ASSERT(m_length == 29);
</del><ins>+    ASSERT(m_length == 30);
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;JSC::DataView&gt; view = JSC::DataView::create(data, 0, data-&gt;byteLength());
</span><span class="cx">     int32_t timeScale = view-&gt;get&lt;int32_t&gt;(8, true);
</span><span class="lines">@@ -128,6 +128,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_trackID = view-&gt;get&lt;int32_t&gt;(24, true);
</span><span class="cx">     m_flags = view-&gt;get&lt;uint8_t&gt;(28, true);
</span><ins>+    m_generation = view-&gt;get&lt;uint8_t&gt;(29, true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const String&amp; MockSampleBox::type()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockmediasourceMockBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/mediasource/MockBox.h (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/mediasource/MockBox.h        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockBox.h        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -117,6 +117,7 @@
</span><span class="cx"> // 4 bytes : signed : duration time value
</span><span class="cx"> // 4 bytes : signed : track ID
</span><span class="cx"> // 1 byte  : unsigned : flags
</span><ins>+// 1 byte  : unsigned : generation
</ins><span class="cx"> //
</span><span class="cx"> class MockSampleBox final : public MockBox {
</span><span class="cx"> public:
</span><span class="lines">@@ -128,6 +129,7 @@
</span><span class="cx">     MediaTime duration() const { return m_duration; }
</span><span class="cx">     int32_t trackID() const { return m_trackID; }
</span><span class="cx">     uint8_t flags() const { return m_flags; }
</span><ins>+    uint8_t generation() const { return m_generation; }
</ins><span class="cx"> 
</span><span class="cx">     enum {
</span><span class="cx">         IsSync = 1 &lt;&lt; 0,
</span><span class="lines">@@ -146,6 +148,7 @@
</span><span class="cx">     MediaTime m_duration;
</span><span class="cx">     int32_t m_trackID;
</span><span class="cx">     uint8_t m_flags;
</span><ins>+    uint8_t m_generation;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockmediasourceMockSourceBufferPrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;SourceBufferPrivateClient.h&quot;
</span><span class="cx"> #include &lt;map&gt;
</span><span class="cx"> #include &lt;runtime/ArrayBuffer.h&gt;
</span><ins>+#include &lt;wtf/PrintStream.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -46,21 +47,24 @@
</span><span class="cx">     static RefPtr&lt;MockMediaSample&gt; create(const MockSampleBox&amp; box) { return adoptRef(new MockMediaSample(box)); }
</span><span class="cx">     virtual ~MockMediaSample() { }
</span><span class="cx"> 
</span><ins>+private:
+    MockMediaSample(const MockSampleBox&amp; box)
+        : m_box(box)
+        , m_id(String::format(&quot;%d&quot;, box.trackID()))
+    {
+    }
+
</ins><span class="cx">     virtual MediaTime presentationTime() const override { return m_box.presentationTimestamp(); }
</span><span class="cx">     virtual MediaTime decodeTime() const override { return m_box.decodeTimestamp(); }
</span><span class="cx">     virtual MediaTime duration() const override { return m_box.duration(); }
</span><span class="cx">     virtual AtomicString trackID() const override { return m_id; }
</span><span class="cx">     virtual size_t sizeInBytes() const override { return sizeof(m_box); }
</span><del>-
</del><span class="cx">     virtual SampleFlags flags() const override;
</span><span class="cx">     virtual PlatformSample platformSample() override;
</span><ins>+    virtual FloatSize presentationSize() const override { return FloatSize(); }
+    virtual void dump(PrintStream&amp;) const override;
</ins><span class="cx"> 
</span><del>-protected:
-    MockMediaSample(const MockSampleBox&amp; box)
-        : m_box(box)
-        , m_id(String::format(&quot;%d&quot;, box.trackID()))
-    {
-    }
</del><ins>+    unsigned generation() const { return m_box.generation(); }
</ins><span class="cx"> 
</span><span class="cx">     MockSampleBox m_box;
</span><span class="cx">     AtomicString m_id;
</span><span class="lines">@@ -80,6 +84,11 @@
</span><span class="cx">     return sample;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MockMediaSample::dump(PrintStream&amp; out) const
+{
+    out.print(&quot;{PTS(&quot;, presentationTime(), &quot;), DTS(&quot;, decodeTime(), &quot;), duration(&quot;, duration(), &quot;), flags(&quot;, (int)flags(), &quot;), generation(&quot;, generation(), &quot;)}&quot;);
+}
+
</ins><span class="cx"> class MockMediaDescription final : public MediaDescription {
</span><span class="cx"> public:
</span><span class="cx">     static RefPtr&lt;MockMediaDescription&gt; create(const MockTrackBox&amp; box) { return adoptRef(new MockMediaDescription(box)); }
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/testing/Internals.cpp        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx"> #include &quot;SerializedScriptValue.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><ins>+#include &quot;SourceBuffer.h&quot;
</ins><span class="cx"> #include &quot;SpellChecker.h&quot;
</span><span class="cx"> #include &quot;StaticNodeList.h&quot;
</span><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="lines">@@ -2244,6 +2245,14 @@
</span><span class="cx"> #endif
</span><span class="cx">     MediaPlayerFactorySupport::callRegisterMediaEngine(MockMediaPlayerMediaSource::registerMediaEngine);
</span><span class="cx"> }
</span><ins>+
+Vector&lt;String&gt; Internals::bufferedSamplesForTrackID(SourceBuffer* buffer, const AtomicString&amp; trackID)
+{
+    if (!buffer)
+        return Vector&lt;String&gt;();
+
+    return buffer-&gt;bufferedSamplesForTrackID(trackID);
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/testing/Internals.h        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> class Range;
</span><span class="cx"> class ScriptExecutionContext;
</span><span class="cx"> class SerializedScriptValue;
</span><ins>+class SourceBuffer;
</ins><span class="cx"> class TimeRanges;
</span><span class="cx"> class TypeConversions;
</span><span class="cx"> 
</span><span class="lines">@@ -326,6 +327,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE)
</span><span class="cx">     void initializeMockMediaSource();
</span><ins>+    Vector&lt;String&gt; bufferedSamplesForTrackID(SourceBuffer*, const AtomicString&amp;);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (169522 => 169523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2014-06-02 05:01:12 UTC (rev 169522)
+++ trunk/Source/WebCore/testing/Internals.idl        2014-06-02 05:16:46 UTC (rev 169523)
</span><span class="lines">@@ -276,8 +276,9 @@
</span><span class="cx">     [RaisesException] boolean isPluginSnapshotted(Element element);
</span><span class="cx"> 
</span><span class="cx">     [RaisesException] ClientRect selectionBounds();
</span><del>-    
</del><ins>+
</ins><span class="cx">     [Conditional=MEDIA_SOURCE] void initializeMockMediaSource();
</span><ins>+    [Conditional=MEDIA_SOURCE] DOMString[] bufferedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
</ins><span class="cx"> 
</span><span class="cx">     [Conditional=VIDEO] void beginMediaSessionInterruption();
</span><span class="cx">     [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
</span></span></pre>
</div>
</div>

</body>
</html>