<!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>[170484] trunk/Source/WebCore</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/170484">170484</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-06-26 11:17:36 -0700 (Thu, 26 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[MSE] Refactoring: Differentiate between SampleMap decode and presentation order methods
https://bugs.webkit.org/show_bug.cgi?id=134349

Reviewed by Geoffrey Garen.

Refactor SampleMap to clarify the distinction between methods which return decode-order
iterators and ones which retun presentation-order iterators.

Add two classes, PresentationOrderSampleMap and DecodeOrderSampleMap, to contain the actual
MediaTime-to-Sample maps, and move the methods returning presentation-order and decode-order
iterators to each, respectively.  Rename the {presentation,decode}{Begin,End}() methods to
begin() and end() so the objects can be used in C++11 for-loops.

Update all the call sites in SourceBuffer to use the new ordered objects.

* Modules/mediasource/SampleMap.cpp:
(WebCore::SampleIsLessThanMediaTimeComparator::operator()): Use new ordered objects.
(WebCore::SampleIsGreaterThanMediaTimeComparator::operator()): Ditto.
(WebCore::SampleMap::clear): Ditto.
(WebCore::SampleMap::addSample): Ditto.
(WebCore::SampleMap::removeSample): Ditto.
(WebCore::PresentationOrderSampleMap::findSampleContainingPresentationTime): Renamed from SampleMap version.
(WebCore::PresentationOrderSampleMap::findSampleAfterPresentationTime): Ditto.
(WebCore::DecodeOrderSampleMap::findSampleWithDecodeTime): Ditto.
(WebCore::PresentationOrderSampleMap::reverseFindSampleContainingPresentationTime): Ditto.
(WebCore::PresentationOrderSampleMap::reverseFindSampleBeforePresentationTime): Ditto.
(WebCore::DecodeOrderSampleMap::reverseFindSampleWithDecodeTime): Ditto.
(WebCore::DecodeOrderSampleMap::findSyncSamplePriorToPresentationTime): Ditto.
(WebCore::DecodeOrderSampleMap::findSyncSamplePriorToDecodeIterator): Ditto.
(WebCore::DecodeOrderSampleMap::findSyncSampleAfterPresentationTime): Ditto.
(WebCore::DecodeOrderSampleMap::findSyncSampleAfterDecodeIterator): Ditto.
(WebCore::PresentationOrderSampleMap::findSamplesBetweenPresentationTimes): Ditto.
(WebCore::PresentationOrderSampleMap::findSamplesWithinPresentationRange): Ditto.
(WebCore::DecodeOrderSampleMap::findDependentSamples): Ditto.
* Modules/mediasource/SampleMap.h:
(WebCore::PresentationOrderSampleMap::begin): Renamed from presentationBegin().
(WebCore::PresentationOrderSampleMap::end): Renamed from presentationEnd().
(WebCore::PresentationOrderSampleMap::rbegin): Renamed from reversePresentationBegin().
(WebCore::PresentationOrderSampleMap::rend): Renamed from reversePresentationEnd().
(WebCore::DecodeOrderSampleMap::begin): Renamed from decodeBegin().
(WebCore::DecodeOrderSampleMap::end): Renamed from decodeEnd().
(WebCore::DecodeOrderSampleMap::rbegin): Renamed from reverseDecodeBegin().
(WebCore::DecodeOrderSampleMap::rend): Renamed from reverseDecodeEnd().
(WebCore::SampleMap::SampleMap): Create new ordered objects.
(WebCore::SampleMap::sizeInBytes): Use new ordered objects.
(WebCore::SampleMap::decodeOrder): Simple accessor.
(WebCore::SampleMap::presentationOrder): Simple accessor.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateSeekToTime): Use new ordered objects.
(WebCore::SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime): Ditto.
(WebCore::SourceBuffer::removeCodedFrames): Ditto.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Ditto.
(WebCore::SourceBuffer::bufferedSamplesForTrackID): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170483 => 170484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-26 17:22:00 UTC (rev 170483)
+++ trunk/Source/WebCore/ChangeLog        2014-06-26 18:17:36 UTC (rev 170484)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2014-06-26  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [MSE] Refactoring: Differentiate between SampleMap decode and presentation order methods
+        https://bugs.webkit.org/show_bug.cgi?id=134349
+
+        Reviewed by Geoffrey Garen.
+
+        Refactor SampleMap to clarify the distinction between methods which return decode-order
+        iterators and ones which retun presentation-order iterators.
+
+        Add two classes, PresentationOrderSampleMap and DecodeOrderSampleMap, to contain the actual
+        MediaTime-to-Sample maps, and move the methods returning presentation-order and decode-order
+        iterators to each, respectively.  Rename the {presentation,decode}{Begin,End}() methods to
+        begin() and end() so the objects can be used in C++11 for-loops.
+
+        Update all the call sites in SourceBuffer to use the new ordered objects.
+
+        * Modules/mediasource/SampleMap.cpp:
+        (WebCore::SampleIsLessThanMediaTimeComparator::operator()): Use new ordered objects.
+        (WebCore::SampleIsGreaterThanMediaTimeComparator::operator()): Ditto.
+        (WebCore::SampleMap::clear): Ditto.
+        (WebCore::SampleMap::addSample): Ditto.
+        (WebCore::SampleMap::removeSample): Ditto.
+        (WebCore::PresentationOrderSampleMap::findSampleContainingPresentationTime): Renamed from SampleMap version.
+        (WebCore::PresentationOrderSampleMap::findSampleAfterPresentationTime): Ditto.
+        (WebCore::DecodeOrderSampleMap::findSampleWithDecodeTime): Ditto.
+        (WebCore::PresentationOrderSampleMap::reverseFindSampleContainingPresentationTime): Ditto.
+        (WebCore::PresentationOrderSampleMap::reverseFindSampleBeforePresentationTime): Ditto.
+        (WebCore::DecodeOrderSampleMap::reverseFindSampleWithDecodeTime): Ditto.
+        (WebCore::DecodeOrderSampleMap::findSyncSamplePriorToPresentationTime): Ditto.
+        (WebCore::DecodeOrderSampleMap::findSyncSamplePriorToDecodeIterator): Ditto.
+        (WebCore::DecodeOrderSampleMap::findSyncSampleAfterPresentationTime): Ditto.
+        (WebCore::DecodeOrderSampleMap::findSyncSampleAfterDecodeIterator): Ditto.
+        (WebCore::PresentationOrderSampleMap::findSamplesBetweenPresentationTimes): Ditto.
+        (WebCore::PresentationOrderSampleMap::findSamplesWithinPresentationRange): Ditto.
+        (WebCore::DecodeOrderSampleMap::findDependentSamples): Ditto.
+        * Modules/mediasource/SampleMap.h:
+        (WebCore::PresentationOrderSampleMap::begin): Renamed from presentationBegin().
+        (WebCore::PresentationOrderSampleMap::end): Renamed from presentationEnd().
+        (WebCore::PresentationOrderSampleMap::rbegin): Renamed from reversePresentationBegin().
+        (WebCore::PresentationOrderSampleMap::rend): Renamed from reversePresentationEnd().
+        (WebCore::DecodeOrderSampleMap::begin): Renamed from decodeBegin().
+        (WebCore::DecodeOrderSampleMap::end): Renamed from decodeEnd().
+        (WebCore::DecodeOrderSampleMap::rbegin): Renamed from reverseDecodeBegin().
+        (WebCore::DecodeOrderSampleMap::rend): Renamed from reverseDecodeEnd().
+        (WebCore::SampleMap::SampleMap): Create new ordered objects.
+        (WebCore::SampleMap::sizeInBytes): Use new ordered objects.
+        (WebCore::SampleMap::decodeOrder): Simple accessor.
+        (WebCore::SampleMap::presentationOrder): Simple accessor.
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::sourceBufferPrivateSeekToTime): Use new ordered objects.
+        (WebCore::SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime): Ditto.
+        (WebCore::SourceBuffer::removeCodedFrames): Ditto.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Ditto.
+        (WebCore::SourceBuffer::bufferedSamplesForTrackID): Ditto.
+
</ins><span class="cx"> 2014-06-26  Chris Fleizach  &lt;cfleizach@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add an undo group for each dictated utterance in WebKit
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSampleMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp (170483 => 170484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp        2014-06-26 17:22:00 UTC (rev 170483)
+++ trunk/Source/WebCore/Modules/mediasource/SampleMap.cpp        2014-06-26 18:17:36 UTC (rev 170484)
</span><span class="lines">@@ -32,28 +32,32 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+template &lt;typename M&gt;
</ins><span class="cx"> class SampleIsLessThanMediaTimeComparator {
</span><span class="cx"> public:
</span><del>-    bool operator()(const SampleMap::MapType::value_type&amp; value, const MediaTime&amp; time)
</del><ins>+    typedef typename M::value_type value_type;
+    bool operator()(const value_type&amp; value, const MediaTime&amp; time)
</ins><span class="cx">     {
</span><span class="cx">         MediaTime presentationEndTime = value.second-&gt;presentationTime() + value.second-&gt;duration();
</span><span class="cx">         return presentationEndTime &lt;= time;
</span><span class="cx">     }
</span><del>-    bool operator()(const MediaTime&amp; time, const SampleMap::MapType::value_type&amp; value)
</del><ins>+    bool operator()(const MediaTime&amp; time, const value_type&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         MediaTime presentationStartTime = value.second-&gt;presentationTime();
</span><span class="cx">         return time &lt; presentationStartTime;
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template &lt;typename M&gt;
</ins><span class="cx"> class SampleIsGreaterThanMediaTimeComparator {
</span><span class="cx"> public:
</span><del>-    bool operator()(const SampleMap::MapType::value_type&amp; value, const MediaTime&amp; time)
</del><ins>+    typedef typename M::value_type value_type;
+    bool operator()(const value_type&amp; value, const MediaTime&amp; time)
</ins><span class="cx">     {
</span><span class="cx">         MediaTime presentationStartTime = value.second-&gt;presentationTime();
</span><span class="cx">         return presentationStartTime &gt; time;
</span><span class="cx">     }
</span><del>-    bool operator()(const MediaTime&amp; time, const SampleMap::MapType::value_type&amp; value)
</del><ins>+    bool operator()(const MediaTime&amp; time, const value_type&amp; value)
</ins><span class="cx">     {
</span><span class="cx">         MediaTime presentationEndTime = value.second-&gt;presentationTime() + value.second-&gt;duration();
</span><span class="cx">         return time &gt;= presentationEndTime;
</span><span class="lines">@@ -94,8 +98,8 @@
</span><span class="cx"> 
</span><span class="cx"> void SampleMap::clear()
</span><span class="cx"> {
</span><del>-    m_presentationSamples.clear();
-    m_decodeSamples.clear();
</del><ins>+    presentationOrder().m_samples.clear();
+    decodeOrder().m_samples.clear();
</ins><span class="cx">     m_totalSize = 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -103,8 +107,8 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;MediaSample&gt; sample = prpSample;
</span><span class="cx">     ASSERT(sample);
</span><del>-    m_presentationSamples.insert(MapType::value_type(sample-&gt;presentationTime(), sample));
-    m_decodeSamples.insert(MapType::value_type(sample-&gt;decodeTime(), sample));
</del><ins>+    presentationOrder().m_samples.insert(PresentationOrderSampleMap::MapType::value_type(sample-&gt;presentationTime(), sample));
+    decodeOrder().m_samples.insert(DecodeOrderSampleMap::MapType::value_type(sample-&gt;decodeTime(), sample));
</ins><span class="cx"> 
</span><span class="cx">     m_totalSize += sample-&gt;sizeInBytes();
</span><span class="cx"> }
</span><span class="lines">@@ -112,107 +116,107 @@
</span><span class="cx"> void SampleMap::removeSample(MediaSample* sample)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(sample);
</span><del>-    m_presentationSamples.erase(sample-&gt;presentationTime());
-    m_decodeSamples.erase(sample-&gt;decodeTime());
</del><ins>+    presentationOrder().m_samples.erase(sample-&gt;presentationTime());
+    decodeOrder().m_samples.erase(sample-&gt;decodeTime());
</ins><span class="cx"> 
</span><span class="cx">     m_totalSize -= sample-&gt;sizeInBytes();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator SampleMap::findSampleContainingPresentationTime(const MediaTime&amp; time)
</del><ins>+PresentationOrderSampleMap::iterator PresentationOrderSampleMap::findSampleContainingPresentationTime(const MediaTime&amp; time)
</ins><span class="cx"> {
</span><del>-    auto range = std::equal_range(presentationBegin(), presentationEnd(), time, SampleIsLessThanMediaTimeComparator());
</del><ins>+    auto range = std::equal_range(begin(), end(), time, SampleIsLessThanMediaTimeComparator&lt;MapType&gt;());
</ins><span class="cx">     if (range.first == range.second)
</span><del>-        return presentationEnd();
</del><ins>+        return end();
</ins><span class="cx">     return range.first;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator SampleMap::findSampleAfterPresentationTime(const MediaTime&amp; time)
</del><ins>+PresentationOrderSampleMap::iterator PresentationOrderSampleMap::findSampleAfterPresentationTime(const MediaTime&amp; time)
</ins><span class="cx"> {
</span><del>-    return std::lower_bound(presentationBegin(), presentationEnd(), time, SampleIsLessThanMediaTimeComparator());
</del><ins>+    return std::lower_bound(begin(), end(), time, SampleIsLessThanMediaTimeComparator&lt;MapType&gt;());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator SampleMap::findSampleWithDecodeTime(const MediaTime&amp; time)
</del><ins>+DecodeOrderSampleMap::iterator DecodeOrderSampleMap::findSampleWithDecodeTime(const MediaTime&amp; time)
</ins><span class="cx"> {
</span><del>-    return m_decodeSamples.find(time);
</del><ins>+    return m_samples.find(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::reverse_iterator SampleMap::reverseFindSampleContainingPresentationTime(const MediaTime&amp; time)
</del><ins>+PresentationOrderSampleMap::reverse_iterator PresentationOrderSampleMap::reverseFindSampleContainingPresentationTime(const MediaTime&amp; time)
</ins><span class="cx"> {
</span><del>-    auto range = std::equal_range(reversePresentationBegin(), reversePresentationEnd(), time, SampleIsGreaterThanMediaTimeComparator());
</del><ins>+    auto range = std::equal_range(rbegin(), rend(), time, SampleIsGreaterThanMediaTimeComparator&lt;MapType&gt;());
</ins><span class="cx">     if (range.first == range.second)
</span><del>-        return reversePresentationEnd();
</del><ins>+        return rend();
</ins><span class="cx">     return range.first;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::reverse_iterator SampleMap::reverseFindSampleBeforePresentationTime(const MediaTime&amp; time)
</del><ins>+PresentationOrderSampleMap::reverse_iterator PresentationOrderSampleMap::reverseFindSampleBeforePresentationTime(const MediaTime&amp; time)
</ins><span class="cx"> {
</span><del>-    return std::lower_bound(reversePresentationBegin(), reversePresentationEnd(), time, SampleIsGreaterThanMediaTimeComparator());
</del><ins>+    return std::lower_bound(rbegin(), rend(), time, SampleIsGreaterThanMediaTimeComparator&lt;MapType&gt;());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::reverse_iterator SampleMap::reverseFindSampleWithDecodeTime(const MediaTime&amp; time)
</del><ins>+DecodeOrderSampleMap::reverse_iterator DecodeOrderSampleMap::reverseFindSampleWithDecodeTime(const MediaTime&amp; time)
</ins><span class="cx"> {
</span><del>-    SampleMap::iterator found = findSampleWithDecodeTime(time);
-    if (found == decodeEnd())
-        return reverseDecodeEnd();
</del><ins>+    DecodeOrderSampleMap::iterator found = findSampleWithDecodeTime(time);
+    if (found == end())
+        return rend();
</ins><span class="cx">     return --reverse_iterator(found);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::reverse_iterator SampleMap::findSyncSamplePriorToPresentationTime(const MediaTime&amp; time, const MediaTime&amp; threshold)
</del><ins>+DecodeOrderSampleMap::reverse_iterator DecodeOrderSampleMap::findSyncSamplePriorToPresentationTime(const MediaTime&amp; time, const MediaTime&amp; threshold)
</ins><span class="cx"> {
</span><del>-    reverse_iterator reverseCurrentSamplePTS = reverseFindSampleBeforePresentationTime(time);
-    if (reverseCurrentSamplePTS == reversePresentationEnd())
-        return reverseDecodeEnd();
</del><ins>+    PresentationOrderSampleMap::reverse_iterator reverseCurrentSamplePTS = m_presentationOrder.reverseFindSampleBeforePresentationTime(time);
+    if (reverseCurrentSamplePTS == m_presentationOrder.rend())
+        return rend();
</ins><span class="cx"> 
</span><span class="cx">     reverse_iterator reverseCurrentSampleDTS = reverseFindSampleWithDecodeTime(reverseCurrentSamplePTS-&gt;second-&gt;decodeTime());
</span><span class="cx"> 
</span><span class="cx">     reverse_iterator foundSample = findSyncSamplePriorToDecodeIterator(reverseCurrentSampleDTS);
</span><del>-    if (foundSample == reverseDecodeEnd())
-        return reverseDecodeEnd();
</del><ins>+    if (foundSample == rend())
+        return rend();
</ins><span class="cx">     if (foundSample-&gt;second-&gt;presentationTime() &lt; time - threshold)
</span><del>-        return reverseDecodeEnd();
</del><ins>+        return rend();
</ins><span class="cx">     return foundSample;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::reverse_iterator SampleMap::findSyncSamplePriorToDecodeIterator(reverse_iterator iterator)
</del><ins>+DecodeOrderSampleMap::reverse_iterator DecodeOrderSampleMap::findSyncSamplePriorToDecodeIterator(reverse_iterator iterator)
</ins><span class="cx"> {
</span><del>-    return std::find_if(iterator, reverseDecodeEnd(), SampleIsRandomAccess());
</del><ins>+    return std::find_if(iterator, rend(), SampleIsRandomAccess());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator SampleMap::findSyncSampleAfterPresentationTime(const MediaTime&amp; time, const MediaTime&amp; threshold)
</del><ins>+DecodeOrderSampleMap::iterator DecodeOrderSampleMap::findSyncSampleAfterPresentationTime(const MediaTime&amp; time, const MediaTime&amp; threshold)
</ins><span class="cx"> {
</span><del>-    iterator currentSamplePTS = findSampleAfterPresentationTime(time);
-    if (currentSamplePTS == presentationEnd())
-        return decodeEnd();
</del><ins>+    PresentationOrderSampleMap::iterator currentSamplePTS = m_presentationOrder.findSampleAfterPresentationTime(time);
+    if (currentSamplePTS == m_presentationOrder.end())
+        return end();
</ins><span class="cx"> 
</span><span class="cx">     iterator currentSampleDTS = findSampleWithDecodeTime(currentSamplePTS-&gt;second-&gt;decodeTime());
</span><span class="cx">     
</span><span class="cx">     MediaTime upperBound = time + threshold;
</span><del>-    iterator foundSample = std::find_if(currentSampleDTS, decodeEnd(), SampleIsRandomAccess());
-    if (foundSample == decodeEnd())
-        return decodeEnd();
</del><ins>+    iterator foundSample = std::find_if(currentSampleDTS, end(), SampleIsRandomAccess());
+    if (foundSample == end())
+        return end();
</ins><span class="cx">     if (foundSample-&gt;second-&gt;presentationTime() &gt; upperBound)
</span><del>-        return decodeEnd();
</del><ins>+        return end();
</ins><span class="cx">     return foundSample;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator SampleMap::findSyncSampleAfterDecodeIterator(iterator currentSampleDTS)
</del><ins>+DecodeOrderSampleMap::iterator DecodeOrderSampleMap::findSyncSampleAfterDecodeIterator(iterator currentSampleDTS)
</ins><span class="cx"> {
</span><del>-    return std::find_if(currentSampleDTS, decodeEnd(), SampleIsRandomAccess());
</del><ins>+    return std::find_if(currentSampleDTS, end(), SampleIsRandomAccess());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator_range SampleMap::findSamplesBetweenPresentationTimes(const MediaTime&amp; begin, const MediaTime&amp; end)
</del><ins>+PresentationOrderSampleMap::iterator_range PresentationOrderSampleMap::findSamplesBetweenPresentationTimes(const MediaTime&amp; beginTime, const MediaTime&amp; endTime)
</ins><span class="cx"> {
</span><del>-    std::pair&lt;MediaTime, MediaTime&gt; range(begin, end);
-    return std::equal_range(presentationBegin(), presentationEnd(), range, SamplePresentationTimeIsInsideRangeComparator());
</del><ins>+    std::pair&lt;MediaTime, MediaTime&gt; range(beginTime, endTime);
+    return std::equal_range(begin(), end(), range, SamplePresentationTimeIsInsideRangeComparator());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::iterator_range SampleMap::findSamplesWithinPresentationRange(const MediaTime&amp; begin, const MediaTime&amp; end)
</del><ins>+PresentationOrderSampleMap::iterator_range PresentationOrderSampleMap::findSamplesWithinPresentationRange(const MediaTime&amp; beginTime, const MediaTime&amp; endTime)
</ins><span class="cx"> {
</span><del>-    std::pair&lt;MediaTime, MediaTime&gt; range(begin, end);
-    return std::equal_range(presentationBegin(), presentationEnd(), range, SamplePresentationTimeIsWithinRangeComparator());
</del><ins>+    std::pair&lt;MediaTime, MediaTime&gt; range(beginTime, endTime);
+    return std::equal_range(begin(), end(), range, SamplePresentationTimeIsWithinRangeComparator());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SampleMap::reverse_iterator_range SampleMap::findDependentSamples(MediaSample* sample)
</del><ins>+DecodeOrderSampleMap::reverse_iterator_range DecodeOrderSampleMap::findDependentSamples(MediaSample* sample)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(sample);
</span><span class="cx">     reverse_iterator currentDecodeIter = reverseFindSampleWithDecodeTime(sample-&gt;decodeTime());
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSampleMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SampleMap.h (170483 => 170484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SampleMap.h        2014-06-26 17:22:00 UTC (rev 170483)
+++ trunk/Source/WebCore/Modules/mediasource/SampleMap.h        2014-06-26 18:17:36 UTC (rev 170484)
</span><span class="lines">@@ -29,21 +29,66 @@
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE)
</span><span class="cx"> 
</span><span class="cx"> #include &lt;map&gt;
</span><del>-#include &lt;wtf/MediaTime.h&gt;
</del><ins>+#include &lt;wtf/MediaTimeHash.h&gt;
</ins><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class MediaSample;
</span><ins>+class SampleMap;
</ins><span class="cx"> 
</span><del>-class SampleMap {
</del><ins>+class PresentationOrderSampleMap {
+    friend class SampleMap;
</ins><span class="cx"> public:
</span><span class="cx">     typedef std::map&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt; MapType;
</span><span class="cx">     typedef MapType::iterator iterator;
</span><span class="cx">     typedef MapType::reverse_iterator reverse_iterator;
</span><span class="cx">     typedef std::pair&lt;iterator, iterator&gt; iterator_range;
</span><ins>+
+    iterator begin() { return m_samples.begin(); }
+    iterator end() { return m_samples.end(); }
+    reverse_iterator rbegin() { return m_samples.rbegin(); }
+    reverse_iterator rend() { return m_samples.rend(); }
+
+    iterator findSampleContainingPresentationTime(const MediaTime&amp;);
+    iterator findSampleAfterPresentationTime(const MediaTime&amp;);
+    reverse_iterator reverseFindSampleContainingPresentationTime(const MediaTime&amp;);
+    reverse_iterator reverseFindSampleBeforePresentationTime(const MediaTime&amp;);
+    iterator_range findSamplesBetweenPresentationTimes(const MediaTime&amp;, const MediaTime&amp;);
+    iterator_range findSamplesWithinPresentationRange(const MediaTime&amp;, const MediaTime&amp;);
+
+private:
+    MapType m_samples;
+};
+
+class DecodeOrderSampleMap {
+    friend class SampleMap;
+public:
+    typedef std::map&lt;MediaTime, RefPtr&lt;MediaSample&gt;&gt; MapType;
+    typedef MapType::iterator iterator;
+    typedef MapType::reverse_iterator reverse_iterator;
</ins><span class="cx">     typedef std::pair&lt;reverse_iterator, reverse_iterator&gt; reverse_iterator_range;
</span><span class="cx"> 
</span><ins>+    iterator begin() { return m_samples.begin(); }
+    iterator end() { return m_samples.end(); }
+    reverse_iterator rbegin() { return m_samples.rbegin(); }
+    reverse_iterator rend() { return m_samples.rend(); }
+
+    iterator findSampleWithDecodeTime(const MediaTime&amp;);
+    reverse_iterator reverseFindSampleWithDecodeTime(const MediaTime&amp;);
+    reverse_iterator findSyncSamplePriorToPresentationTime(const MediaTime&amp;, const MediaTime&amp; threshold = MediaTime::positiveInfiniteTime());
+    reverse_iterator findSyncSamplePriorToDecodeIterator(reverse_iterator);
+    iterator findSyncSampleAfterPresentationTime(const MediaTime&amp;, const MediaTime&amp; threshold = MediaTime::positiveInfiniteTime());
+    iterator findSyncSampleAfterDecodeIterator(iterator);
+    reverse_iterator_range findDependentSamples(MediaSample*);
+
+private:
+    MapType m_samples;
+    PresentationOrderSampleMap m_presentationOrder;
+};
+
+class SampleMap {
+public:
</ins><span class="cx">     SampleMap()
</span><span class="cx">         : m_totalSize(0)
</span><span class="cx">     {
</span><span class="lines">@@ -54,33 +99,11 @@
</span><span class="cx">     void removeSample(MediaSample*);
</span><span class="cx">     size_t sizeInBytes() const { return m_totalSize; }
</span><span class="cx"> 
</span><del>-    iterator presentationBegin() { return m_presentationSamples.begin(); }
-    iterator presentationEnd() { return m_presentationSamples.end(); }
-    iterator decodeBegin() { return m_decodeSamples.begin(); }
-    iterator decodeEnd() { return m_decodeSamples.end(); }
-    reverse_iterator reversePresentationBegin() { return m_presentationSamples.rbegin(); }
-    reverse_iterator reversePresentationEnd() { return m_presentationSamples.rend(); }
-    reverse_iterator reverseDecodeBegin() { return m_decodeSamples.rbegin(); }
-    reverse_iterator reverseDecodeEnd() { return m_decodeSamples.rend(); }
</del><ins>+    DecodeOrderSampleMap&amp; decodeOrder() { return m_decodeOrder; }
+    PresentationOrderSampleMap&amp; presentationOrder() { return m_decodeOrder.m_presentationOrder; }
</ins><span class="cx"> 
</span><del>-    iterator findSampleContainingPresentationTime(const MediaTime&amp;);
-    iterator findSampleAfterPresentationTime(const MediaTime&amp;);
-    iterator findSampleWithDecodeTime(const MediaTime&amp;);
-    reverse_iterator reverseFindSampleContainingPresentationTime(const MediaTime&amp;);
-    reverse_iterator reverseFindSampleBeforePresentationTime(const MediaTime&amp;);
-    reverse_iterator reverseFindSampleWithDecodeTime(const MediaTime&amp;);
-    reverse_iterator findSyncSamplePriorToPresentationTime(const MediaTime&amp;, const MediaTime&amp; threshold = MediaTime::positiveInfiniteTime());
-    reverse_iterator findSyncSamplePriorToDecodeIterator(reverse_iterator);
-    iterator findSyncSampleAfterPresentationTime(const MediaTime&amp;, const MediaTime&amp; threshold = MediaTime::positiveInfiniteTime());
-    iterator findSyncSampleAfterDecodeIterator(iterator);
-
-    iterator_range findSamplesBetweenPresentationTimes(const MediaTime&amp;, const MediaTime&amp;);
-    iterator_range findSamplesWithinPresentationRange(const MediaTime&amp;, const MediaTime&amp;);
-    reverse_iterator_range findDependentSamples(MediaSample*);
-    
</del><span class="cx"> private:
</span><del>-    MapType m_presentationSamples;
-    MapType m_decodeSamples;
</del><ins>+    DecodeOrderSampleMap m_decodeOrder;
</ins><span class="cx">     size_t m_totalSize;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (170483 => 170484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-26 17:22:00 UTC (rev 170483)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-26 18:17:36 UTC (rev 170484)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">     bool needRandomAccessFlag;
</span><span class="cx">     bool enabled;
</span><span class="cx">     SampleMap samples;
</span><del>-    SampleMap::MapType decodeQueue;
</del><ins>+    DecodeOrderSampleMap::MapType decodeQueue;
</ins><span class="cx">     RefPtr&lt;MediaDescription&gt; description;
</span><span class="cx"> 
</span><span class="cx">     TrackBuffer()
</span><span class="lines">@@ -316,9 +316,9 @@
</span><span class="cx">         AtomicString trackID = trackBufferIterator-&gt;key;
</span><span class="cx"> 
</span><span class="cx">         // Find the sample which contains the current presentation time.
</span><del>-        auto currentSamplePTSIterator = trackBuffer.samples.findSampleContainingPresentationTime(time);
</del><ins>+        auto currentSamplePTSIterator = trackBuffer.samples.presentationOrder().findSampleContainingPresentationTime(time);
</ins><span class="cx"> 
</span><del>-        if (currentSamplePTSIterator == trackBuffer.samples.presentationEnd()) {
</del><ins>+        if (currentSamplePTSIterator == trackBuffer.samples.presentationOrder().end()) {
</ins><span class="cx">             trackBuffer.decodeQueue.clear();
</span><span class="cx">             m_private-&gt;flushAndEnqueueNonDisplayingSamples(Vector&lt;RefPtr&lt;MediaSample&gt;&gt;(), trackID);
</span><span class="cx">             continue;
</span><span class="lines">@@ -326,12 +326,12 @@
</span><span class="cx"> 
</span><span class="cx">         // Seach backward for the previous sync sample.
</span><span class="cx">         MediaTime currentSampleDecodeTime = currentSamplePTSIterator-&gt;second-&gt;decodeTime();
</span><del>-        auto currentSampleDTSIterator = trackBuffer.samples.findSampleWithDecodeTime(currentSampleDecodeTime);
-        ASSERT(currentSampleDTSIterator != trackBuffer.samples.decodeEnd());
</del><ins>+        auto currentSampleDTSIterator = trackBuffer.samples.decodeOrder().findSampleWithDecodeTime(currentSampleDecodeTime);
+        ASSERT(currentSampleDTSIterator != trackBuffer.samples.decodeOrder().end());
</ins><span class="cx"> 
</span><del>-        auto reverseCurrentSampleIter = --SampleMap::reverse_iterator(currentSampleDTSIterator);
-        auto reverseLastSyncSampleIter = trackBuffer.samples.findSyncSamplePriorToDecodeIterator(reverseCurrentSampleIter);
-        if (reverseLastSyncSampleIter == trackBuffer.samples.reverseDecodeEnd()) {
</del><ins>+        auto reverseCurrentSampleIter = --DecodeOrderSampleMap::reverse_iterator(currentSampleDTSIterator);
+        auto reverseLastSyncSampleIter = trackBuffer.samples.decodeOrder().findSyncSamplePriorToDecodeIterator(reverseCurrentSampleIter);
+        if (reverseLastSyncSampleIter == trackBuffer.samples.decodeOrder().rend()) {
</ins><span class="cx">             trackBuffer.decodeQueue.clear();
</span><span class="cx">             m_private-&gt;flushAndEnqueueNonDisplayingSamples(Vector&lt;RefPtr&lt;MediaSample&gt;&gt;(), trackID);
</span><span class="cx">             continue;
</span><span class="lines">@@ -345,7 +345,7 @@
</span><span class="cx"> 
</span><span class="cx">         // Fill the decode queue with the remaining samples.
</span><span class="cx">         trackBuffer.decodeQueue.clear();
</span><del>-        for (auto iter = currentSampleDTSIterator; iter != trackBuffer.samples.decodeEnd(); ++iter)
</del><ins>+        for (auto iter = currentSampleDTSIterator; iter != trackBuffer.samples.decodeOrder().end(); ++iter)
</ins><span class="cx">             trackBuffer.decodeQueue.insert(*iter);
</span><span class="cx"> 
</span><span class="cx">         provideMediaData(trackBuffer, trackID);
</span><span class="lines">@@ -364,10 +364,10 @@
</span><span class="cx">         TrackBuffer&amp; trackBuffer = trackBufferIterator-&gt;value;
</span><span class="cx"> 
</span><span class="cx">         // Find the sample which contains the target time time.
</span><del>-        auto futureSyncSampleIterator = trackBuffer.samples.findSyncSampleAfterPresentationTime(targetTime, positiveThreshold);
-        auto pastSyncSampleIterator = trackBuffer.samples.findSyncSamplePriorToPresentationTime(targetTime, negativeThreshold);
-        auto upperBound = trackBuffer.samples.decodeEnd();
-        auto lowerBound = trackBuffer.samples.reverseDecodeEnd();
</del><ins>+        auto futureSyncSampleIterator = trackBuffer.samples.decodeOrder().findSyncSampleAfterPresentationTime(targetTime, positiveThreshold);
+        auto pastSyncSampleIterator = trackBuffer.samples.decodeOrder().findSyncSamplePriorToPresentationTime(targetTime, negativeThreshold);
+        auto upperBound = trackBuffer.samples.decodeOrder().end();
+        auto lowerBound = trackBuffer.samples.decodeOrder().rend();
</ins><span class="cx"> 
</span><span class="cx">         if (futureSyncSampleIterator == upperBound &amp;&amp; pastSyncSampleIterator == lowerBound)
</span><span class="cx">             continue;
</span><span class="lines">@@ -562,16 +562,16 @@
</span><span class="cx">         // 3.2 If this track buffer has a random access point timestamp that is greater than or equal to end, then update
</span><span class="cx">         // remove end timestamp to that random access point timestamp.
</span><span class="cx">         // NOTE: findSyncSampleAfterPresentationTime will return the next sync sample on or after the presentation time
</span><del>-        // or decodeEnd() if no sync sample exists after that presentation time.
-        SampleMap::iterator removeDecodeEnd = trackBuffer.samples.findSyncSampleAfterPresentationTime(end);
</del><ins>+        // or decodeOrder().end() if no sync sample exists after that presentation time.
+        DecodeOrderSampleMap::iterator removeDecodeEnd = trackBuffer.samples.decodeOrder().findSyncSampleAfterPresentationTime(end);
</ins><span class="cx"> 
</span><span class="cx">         // 3.3 Remove all media data, from this track buffer, that contain starting timestamps greater than or equal to
</span><span class="cx">         // start and less than the remove end timestamp.
</span><span class="cx">         // NOTE: frames must be removed in decode order, so that all dependant frames between the frame to be removed
</span><span class="cx">         // and the next sync sample frame are removed.
</span><del>-        SampleMap::iterator removePresentaionStart = trackBuffer.samples.findSampleAfterPresentationTime(start);
-        SampleMap::iterator removeDecodeStart = trackBuffer.samples.findSampleWithDecodeTime(removePresentaionStart-&gt;second-&gt;decodeTime());
-        SampleMap::MapType erasedSamples(removeDecodeStart, removeDecodeEnd);
</del><ins>+        PresentationOrderSampleMap::iterator removePresentaionStart = trackBuffer.samples.presentationOrder().findSampleAfterPresentationTime(start);
+        DecodeOrderSampleMap::iterator removeDecodeStart = trackBuffer.samples.decodeOrder().findSampleWithDecodeTime(removePresentaionStart-&gt;second-&gt;decodeTime());
+        DecodeOrderSampleMap::MapType erasedSamples(removeDecodeStart, removeDecodeEnd);
</ins><span class="cx">         RefPtr&lt;TimeRanges&gt; erasedRanges = TimeRanges::create();
</span><span class="cx">         MediaTime microsecond(1, 1000000);
</span><span class="cx">         for (auto erasedIt : erasedSamples) {
</span><span class="lines">@@ -1089,15 +1089,15 @@
</span><span class="cx">         // 1.13 Let spliced timed text frame be an unset variable for holding timed text splice information
</span><span class="cx">         // FIXME: Add support for sample splicing.
</span><span class="cx"> 
</span><del>-        SampleMap::MapType erasedSamples;
</del><ins>+        DecodeOrderSampleMap::MapType erasedSamples;
</ins><span class="cx">         MediaTime microsecond(1, 1000000);
</span><span class="cx"> 
</span><span class="cx">         // 1.14 If last decode timestamp for track buffer is unset and presentation timestamp falls
</span><span class="cx">         // falls within the presentation interval of a coded frame in track buffer, then run the
</span><span class="cx">         // following steps:
</span><span class="cx">         if (trackBuffer.lastDecodeTimestamp.isInvalid()) {
</span><del>-            auto iter = trackBuffer.samples.findSampleContainingPresentationTime(presentationTimestamp);
-            if (iter != trackBuffer.samples.presentationEnd()) {
</del><ins>+            auto iter = trackBuffer.samples.presentationOrder().findSampleContainingPresentationTime(presentationTimestamp);
+            if (iter != trackBuffer.samples.presentationOrder().end()) {
</ins><span class="cx">                 // 1.14.1 Let overlapped frame be the coded frame in track buffer that matches the condition above.
</span><span class="cx">                 RefPtr&lt;MediaSample&gt; overlappedFrame = iter-&gt;second;
</span><span class="cx"> 
</span><span class="lines">@@ -1133,8 +1133,8 @@
</span><span class="cx">         if (trackBuffer.highestPresentationTimestamp.isInvalid()) {
</span><span class="cx">             // Remove all coded frames from track buffer that have a presentation timestamp greater than or
</span><span class="cx">             // equal to presentation timestamp and less than frame end timestamp.
</span><del>-            auto iter_pair = trackBuffer.samples.findSamplesBetweenPresentationTimes(presentationTimestamp, frameEndTimestamp);
-            if (iter_pair.first != trackBuffer.samples.presentationEnd())
</del><ins>+            auto iter_pair = trackBuffer.samples.presentationOrder().findSamplesBetweenPresentationTimes(presentationTimestamp, frameEndTimestamp);
+            if (iter_pair.first != trackBuffer.samples.presentationOrder().end())
</ins><span class="cx">                 erasedSamples.insert(iter_pair.first, iter_pair.second);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1142,13 +1142,13 @@
</span><span class="cx">         if (trackBuffer.highestPresentationTimestamp.isValid() &amp;&amp; trackBuffer.highestPresentationTimestamp &lt;= presentationTimestamp) {
</span><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.findSamplesWithinPresentationRange(trackBuffer.highestPresentationTimestamp, frameEndTimestamp);
-            if (iter_pair.first != trackBuffer.samples.presentationEnd())
</del><ins>+            auto iter_pair = trackBuffer.samples.presentationOrder().findSamplesWithinPresentationRange(trackBuffer.highestPresentationTimestamp, frameEndTimestamp);
+            if (iter_pair.first != trackBuffer.samples.presentationOrder().end())
</ins><span class="cx">                 erasedSamples.insert(iter_pair.first, iter_pair.second);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // 1.16 Remove decoding dependencies of the coded frames removed in the previous step:
</span><del>-        SampleMap::MapType dependentSamples;
</del><ins>+        DecodeOrderSampleMap::MapType dependentSamples;
</ins><span class="cx">         if (!erasedSamples.empty()) {
</span><span class="cx">             // If detailed information about decoding dependencies is available:
</span><span class="cx">             // FIXME: Add support for detailed dependency information
</span><span class="lines">@@ -1156,8 +1156,8 @@
</span><span class="cx">             // Otherwise: Remove all coded frames between the coded frames removed in the previous step
</span><span class="cx">             // and the next random access point after those removed frames.
</span><span class="cx">             for (auto erasedIt = erasedSamples.begin(), end = erasedSamples.end(); erasedIt != end; ++erasedIt) {
</span><del>-                auto currentDecodeIter = trackBuffer.samples.findSampleWithDecodeTime(erasedIt-&gt;second-&gt;decodeTime());
-                auto nextSyncIter = trackBuffer.samples.findSyncSampleAfterDecodeIterator(currentDecodeIter);
</del><ins>+                auto currentDecodeIter = trackBuffer.samples.decodeOrder().findSampleWithDecodeTime(erasedIt-&gt;second-&gt;decodeTime());
+                auto nextSyncIter = trackBuffer.samples.decodeOrder().findSyncSampleAfterDecodeIterator(currentDecodeIter);
</ins><span class="cx">                 dependentSamples.insert(currentDecodeIter, nextSyncIter);
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -1190,7 +1190,7 @@
</span><span class="cx">         // Otherwise:
</span><span class="cx">         // Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer.
</span><span class="cx">         trackBuffer.samples.addSample(sample);
</span><del>-        trackBuffer.decodeQueue.insert(SampleMap::MapType::value_type(decodeTimestamp, sample));
</del><ins>+        trackBuffer.decodeQueue.insert(DecodeOrderSampleMap::MapType::value_type(decodeTimestamp, sample));
</ins><span class="cx"> 
</span><span class="cx">         // 1.18 Set last decode timestamp for track buffer to decode timestamp.
</span><span class="cx">         trackBuffer.lastDecodeTimestamp = decodeTimestamp;
</span><span class="lines">@@ -1479,8 +1479,8 @@
</span><span class="cx"> 
</span><span class="cx">     TrackBuffer&amp; trackBuffer = it-&gt;value;
</span><span class="cx">     Vector&lt;String&gt; sampleDescriptions;
</span><del>-    for (auto sampleIter = trackBuffer.samples.decodeBegin(); sampleIter != trackBuffer.samples.decodeEnd(); ++sampleIter)
-        sampleDescriptions.append(toString(*sampleIter-&gt;second));
</del><ins>+    for (auto&amp; pair : trackBuffer.samples.decodeOrder())
+        sampleDescriptions.append(toString(*pair.second));
</ins><span class="cx"> 
</span><span class="cx">     return sampleDescriptions;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>