<!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>[178501] branches/safari-600.5-branch</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/178501">178501</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-01-15 02:28:05 -0800 (Thu, 15 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/177225">r177225</a>. rdar://problem/19424175</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6005branchLayoutTestsChangeLog">branches/safari-600.5-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6005branchLayoutTestshttptestsmediamediasourcemediasourceutiljs">branches/safari-600.5-branch/LayoutTests/http/tests/media/media-source/mediasource-util.js</a></li>
<li><a href="#branchessafari6005branchLayoutTestsplatformmacTestExpectations">branches/safari-600.5-branch/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreChangeLog">branches/safari-600.5-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreModulesmediasourceMediaSourcecpp">branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/MediaSource.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreModulesmediasourceSourceBuffercpp">branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreModulesmediasourceSourceBufferh">branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreModulesmediasourceSourceBufferidl">branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>branches/safari-600.5-branch/LayoutTests/platform/mac/http/tests/media/media-source/</li>
<li><a href="#branchessafari6005branchLayoutTestsplatformmachttptestsmediamediasourcemediasourcesourcebuffermodeexpectedtxt">branches/safari-600.5-branch/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6005branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/LayoutTests/ChangeLog (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/ChangeLog        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/LayoutTests/ChangeLog        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-01-15 Matthew Hanson <matthew_hanson@apple.com>
+
+ Merge r177225. rdar://problem/19424175
+
+ 2014-12-12 Jer Noble <jer.noble@apple.com>
+
+ [MSE] Add support for SourceBuffer.mode.
+ https://bugs.webkit.org/show_bug.cgi?id=139265
+
+ Reviewed by Eric Carlson.
+
+ * http/tests/media/media-source/mediasource-util.js:
+ * platform/mac/TestExpectations:
+
+ Add an expected-failure; the test fails due to lack of support for a non-DOM-visible
+ algorithm variable unsupported by the Mac port.
+ * platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt: Added.
+
</ins><span class="cx"> 2015-01-14 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><span class="cx"> Merged r174823. <rdar://problem/19424155>
</span></span></pre></div>
<a id="branchessafari6005branchLayoutTestshttptestsmediamediasourcemediasourceutiljs"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/LayoutTests/http/tests/media/media-source/mediasource-util.js (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/http/tests/media/media-source/mediasource-util.js        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/LayoutTests/http/tests/media/media-source/mediasource-util.js        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -28,18 +28,18 @@
</span><span class="cx"> },
</span><span class="cx"> {
</span><span class="cx"> url: 'mp4/test.mp4',
</span><del>- type: 'video/mp4; codecs="mp4a.40.2, avc1.4D401E"',
</del><ins>+ type: 'video/mp4; codecs="mp4a.40.2,avc1.4d400d"',
</ins><span class="cx"> duration: 6.0424,
</span><span class="cx"> init: { offset: 0, size: 1279 },
</span><span class="cx"> media: [
</span><del>- { offset: 1406, size: 23863, timecode: 0 },
- { offset: 25270, size: 25435, timecode: 0.797 },
- { offset: 50705, size: 24796, timecode: 1.594 },
- { offset: 75501, size: 25167, timecode: 2.390 },
- { offset: 100668, size: 22976, timecode: 3.187 },
- { offset: 123644, size: 25030, timecode: 3.984},
- { offset: 148674, size: 24929, timecode: 4.781 },
- { offset: 173603, size: 19271, timecode: 5.578 },
</del><ins>+ { offset: 1407, size: 23863, timecode: 0 },
+ { offset: 25270, size: 25435, timecode: 0.7968 },
+ { offset: 50705, size: 24796, timecode: 1.5936 },
+ { offset: 75501, size: 25167, timecode: 2.3904 },
+ { offset: 100668, size: 22976, timecode: 3.1872 },
+ { offset: 123644, size: 25030, timecode: 3.984 },
+ { offset: 148674, size: 24929, timecode: 4.7808 },
+ { offset: 173603, size: 19271, timecode: 5.5776 },
</ins><span class="cx"> ],
</span><span class="cx"> }
</span><span class="cx"> ];
</span></span></pre></div>
<a id="branchessafari6005branchLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/LayoutTests/platform/mac/TestExpectations (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/platform/mac/TestExpectations        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/LayoutTests/platform/mac/TestExpectations        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -1488,3 +1488,6 @@
</span><span class="cx">
</span><span class="cx"> webkit.org/b/136532 [ MountainLion ] media/audio-data-url.html [ Failure ]
</span><span class="cx"> webkit.org/b/136532 [ MountainLion ] media/sources-fallback-codecs.html [ Failure ]
</span><ins>+
+# Passing Media Source tests
+[ Yosemite+ ] http/tests/media/media-source/mediasource-sourcebuffer-mode.html [ Pass ]
</ins></span></pre></div>
<a id="branchessafari6005branchLayoutTestsplatformmachttptestsmediamediasourcemediasourcesourcebuffermodeexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.5-branch/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt (0 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt         (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+
+PASS Test initial value of SourceBuffer.mode is "segments"
+PASS Test setting SourceBuffer.mode
+PASS Test setting a removed SourceBuffer's mode
+PASS Test setting SourceBuffer.mode while still updating
+PASS Test setting SourceBuffer.mode triggers parent MediaSource 'ended' to 'open' transition.
+FAIL Test setting SourceBuffer.mode and SourceBuffer.timestampOffset while parsing media segment. assert_throws: Setting valid sourceBuffer.mode while still parsing media segment threw InvalidStateError. function "function () { sourceBuffer.mode = 'segments'; }" did not throw(stack: assert@http://127.0.0.1:8000/w3c/resources/testharness.js:2060:73
+assert_throws@http://127.0.0.1:8000/w3c/resources/testharness.js:946:19
+http://127.0.0.1:8000/media/media-source/mediasource-sourcebuffer-mode.html:114:32
+handleWaitCallback_@http://127.0.0.1:8000/media/media-source/mediasource-util.js:97:17
+[native code]
+step@http://127.0.0.1:8000/w3c/resources/testharness.js:1159:30
+http://127.0.0.1:8000/w3c/resources/testharness.js:1188:33)
+
</ins></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/ChangeLog (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/ChangeLog        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/Source/WebCore/ChangeLog        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2015-01-15 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r177225. rdar://problem/19424175
+
+ 2014-12-12 Jer Noble <jer.noble@apple.com>
+
+ [MSE] Add support for SourceBuffer.mode.
+ https://bugs.webkit.org/show_bug.cgi?id=139265
+
+ Reviewed by Eric Carlson.
+
+ Support setting SourceBuffer's mode property, and add support for "sequence" mode. Prior
+ to this change, "segments" mode was implied.
+
+ * Modules/mediasource/MediaSource.cpp:
+ (WebCore::MediaSource::addSourceBuffer):
+ (WebCore::MediaSource::regenerateActiveSourceBuffers):
+ * Modules/mediasource/SourceBuffer.cpp:
+ (WebCore::SourceBuffer::segmentsKeyword):
+ (WebCore::SourceBuffer::sequenceKeyword):
+ (WebCore::SourceBuffer::SourceBuffer):
+ (WebCore::SourceBuffer::setTimestampOffset):
+ (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
+ (WebCore::SourceBuffer::setMode):
+ * Modules/mediasource/SourceBuffer.h:
+ * Modules/mediasource/SourceBuffer.idl:
+
+2015-01-15 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r176879. rdar://problem/19424174
</span><span class="cx">
</span><span class="cx"> 2014-12-05 Jer Noble <jer.noble@apple.com>
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreModulesmediasourceMediaSourcecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/MediaSource.cpp (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/MediaSource.cpp        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/MediaSource.cpp        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2013 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -502,7 +503,9 @@
</span><span class="cx"> {
</span><span class="cx"> LOG(MediaSource, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this);
</span><span class="cx">
</span><del>- // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
</del><ins>+ // 2.2 http://www.w3.org/TR/media-source/#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
+ // When this method is invoked, the user agent must run the following steps:
+
</ins><span class="cx"> // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and
</span><span class="cx"> // abort these steps.
</span><span class="cx"> if (type.isNull() || type.isEmpty()) {
</span><span class="lines">@@ -536,11 +539,25 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.releaseNonNull(), this);
</span><del>- // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
</del><ins>+
+ // 6. Set the generate timestamps flag on the new object to the value in the "Generate Timestamps Flag"
+ // column of the byte stream format registry [MSE-REGISTRY] entry that is associated with type.
+ // NOTE: In the current byte stream format registry <http://www.w3.org/2013/12/byte-stream-format-registry/>
+ // only the "MPEG Audio Byte Stream Format" has the "Generate Timestamps Flag" value set.
+ bool shouldGenerateTimestamps = contentType.type() == "audio/aac" || contentType.type() == "audio/mpeg";
+ buffer->setShouldGenerateTimestamps(shouldGenerateTimestamps);
+
+ // 7. If the generate timestamps flag equals true:
+ // ↳ Set the mode attribute on the new object to "sequence".
+ // Otherwise:
+ // ↳ Set the mode attribute on the new object to "segments".
+ buffer->setMode(shouldGenerateTimestamps ? SourceBuffer::sequenceKeyword() : SourceBuffer::segmentsKeyword(), IGNORE_EXCEPTION);
+
+ // 8. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
</ins><span class="cx"> m_sourceBuffers->add(buffer);
</span><span class="cx"> regenerateActiveSourceBuffers();
</span><span class="cx">
</span><del>- // 7. Return the new object to the caller.
</del><ins>+ // 9. Return the new object to the caller.
</ins><span class="cx"> return buffer.get();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -71,6 +71,18 @@
</span><span class="cx"> return fudgeFactor;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+const AtomicString& SourceBuffer::segmentsKeyword()
+{
+ static NeverDestroyed<AtomicString> segments("segments");
+ return segments.get();
+}
+
+const AtomicString& SourceBuffer::sequenceKeyword()
+{
+ static NeverDestroyed<AtomicString> segments("sequence");
+ return segments.get();
+}
+
</ins><span class="cx"> struct SourceBuffer::TrackBuffer {
</span><span class="cx"> MediaTime lastDecodeTimestamp;
</span><span class="cx"> MediaTime lastFrameDuration;
</span><span class="lines">@@ -109,8 +121,10 @@
</span><span class="cx"> , m_private(WTF::move(sourceBufferPrivate))
</span><span class="cx"> , m_source(source)
</span><span class="cx"> , m_asyncEventQueue(*this)
</span><ins>+ , m_mode(segmentsKeyword())
</ins><span class="cx"> , m_appendBufferTimer(this, &SourceBuffer::appendBufferTimerFired)
</span><del>- , m_highestPresentationEndTimestamp(MediaTime::invalidTime())
</del><ins>+ , m_groupStartTimestamp(MediaTime::invalidTime())
+ , m_groupEndTimestamp(MediaTime::zeroTime())
</ins><span class="cx"> , m_buffered(TimeRanges::create())
</span><span class="cx"> , m_appendState(WaitingForSegment)
</span><span class="cx"> , m_timeOfBufferingMonitor(monotonicallyIncreasingTime())
</span><span class="lines">@@ -124,6 +138,7 @@
</span><span class="cx"> , m_receivedFirstInitializationSegment(false)
</span><span class="cx"> , m_active(false)
</span><span class="cx"> , m_bufferFull(false)
</span><ins>+ , m_shouldGenerateTimestamps(false)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(m_source);
</span><span class="cx">
</span><span class="lines">@@ -186,9 +201,14 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // FIXME: Add step 6 text when mode attribute is implemented.
</del><ins>+ MediaTime newTimestampOffset = MediaTime::createWithDouble(offset);
+
+ // 6. If the mode attribute equals "sequence", then set the group start timestamp to new timestamp offset.
+ if (m_mode == sequenceKeyword())
+ m_groupStartTimestamp = newTimestampOffset;
+
</ins><span class="cx"> // 7. Update the attribute to the new value.
</span><del>- m_timestampOffset = MediaTime::createWithDouble(offset);
</del><ins>+ m_timestampOffset = newTimestampOffset;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionCode& ec)
</span><span class="lines">@@ -1166,92 +1186,126 @@
</span><span class="cx"> RefPtr<MediaSample> sample = prpSample;
</span><span class="cx">
</span><span class="cx"> // 3.5.8 Coded Frame Processing
</span><ins>+ // http://www.w3.org/TR/media-source/#sourcebuffer-coded-frame-processing
+
</ins><span class="cx"> // When complete coded frames have been parsed by the segment parser loop then the following steps
</span><span class="cx"> // are run:
</span><span class="cx"> // 1. For each coded frame in the media segment run the following steps:
</span><span class="cx"> // 1.1. Loop Top
</span><span class="cx"> do {
</span><del>- // 1.1 (ctd) Let presentation timestamp be a double precision floating point representation of
- // the coded frame's presentation timestamp in seconds.
- MediaTime presentationTimestamp = sample->presentationTime();
</del><ins>+ MediaTime presentationTimestamp;
+ MediaTime decodeTimestamp;
</ins><span class="cx">
</span><del>- // 1.2 Let decode timestamp be a double precision floating point representation of the coded frame's
- // decode timestamp in seconds.
- MediaTime decodeTimestamp = sample->decodeTime();
</del><ins>+ if (m_shouldGenerateTimestamps) {
+ // ↳ If generate timestamps flag equals true:
+ // 1. Let presentation timestamp equal 0.
+ presentationTimestamp = MediaTime::zeroTime();
</ins><span class="cx">
</span><del>- // 1.3 Let frame duration be a double precision floating point representation of the coded frame's
</del><ins>+ // 2. Let decode timestamp equal 0.
+ decodeTimestamp = MediaTime::zeroTime();
+ } else {
+ // ↳ Otherwise:
+ // 1. Let presentation timestamp be a double precision floating point representation of
+ // the coded frame's presentation timestamp in seconds.
+ presentationTimestamp = sample->presentationTime();
+
+ // 2. Let decode timestamp be a double precision floating point representation of the coded frame's
+ // decode timestamp in seconds.
+ decodeTimestamp = sample->decodeTime();
+ }
+
+ // 1.2 Let frame duration be a double precision floating point representation of the coded frame's
</ins><span class="cx"> // duration in seconds.
</span><span class="cx"> MediaTime frameDuration = sample->duration();
</span><span class="cx">
</span><del>- // 1.4 If mode equals "sequence" and group start timestamp is set, then run the following steps:
- // FIXME: add support for "sequence" mode
</del><ins>+ // 1.3 If mode equals "sequence" and group start timestamp is set, then run the following steps:
+ if (m_mode == sequenceKeyword()) {
+ // 1.3.1 Set timestampOffset equal to group start timestamp - presentation timestamp.
+ m_timestampOffset = m_groupStartTimestamp;
</ins><span class="cx">
</span><del>- // 1.5 If timestampOffset is not 0, then run the following steps:
</del><ins>+ // 1.3.2 Set group end timestamp equal to group start timestamp.
+ m_groupEndTimestamp = m_groupStartTimestamp;
+
+ // 1.3.3 Set the need random access point flag on all track buffers to true.
+ for (auto& trackBuffer : m_trackBufferMap.values())
+ trackBuffer.needRandomAccessFlag = true;
+
+ // 1.3.4 Unset group start timestamp.
+ m_groupStartTimestamp = MediaTime::invalidTime();
+ }
+
+ // 1.4 If timestampOffset is not 0, then run the following steps:
</ins><span class="cx"> if (m_timestampOffset) {
</span><del>- // 1.5.1 Add timestampOffset to the presentation timestamp.
</del><ins>+ // 1.4.1 Add timestampOffset to the presentation timestamp.
</ins><span class="cx"> presentationTimestamp += m_timestampOffset;
</span><span class="cx">
</span><del>- // 1.5.2 Add timestampOffset to the decode timestamp.
</del><ins>+ // 1.4.2 Add timestampOffset to the decode timestamp.
</ins><span class="cx"> decodeTimestamp += m_timestampOffset;
</span><del>-
- // 1.5.3 If the presentation timestamp or decode timestamp is less than the presentation start
- // time, then run the end of stream algorithm with the error parameter set to "decode", and
- // abort these steps.
- MediaTime presentationStartTime = MediaTime::zeroTime();
- if (presentationTimestamp < presentationStartTime || decodeTimestamp < presentationStartTime) {
- m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
- return;
- }
</del><span class="cx"> }
</span><span class="cx">
</span><del>- // 1.6 Let track buffer equal the track buffer that the coded frame will be added to.
</del><ins>+ // 1.5 Let track buffer equal the track buffer that the coded frame will be added to.
</ins><span class="cx"> AtomicString trackID = sample->trackID();
</span><span class="cx"> auto it = m_trackBufferMap.find(trackID);
</span><span class="cx"> if (it == m_trackBufferMap.end())
</span><span class="cx"> it = m_trackBufferMap.add(trackID, TrackBuffer()).iterator;
</span><span class="cx"> TrackBuffer& trackBuffer = it->value;
</span><span class="cx">
</span><del>- // 1.7 If last decode timestamp for track buffer is set and decode timestamp is less than last
</del><ins>+ // 1.6 ↳ If last decode timestamp for track buffer is set and decode timestamp is less than last
</ins><span class="cx"> // decode timestamp:
</span><span class="cx"> // OR
</span><del>- // If last decode timestamp for track buffer is set and the difference between decode timestamp and
</del><ins>+ // ↳ If last decode timestamp for track buffer is set and the difference between decode timestamp and
</ins><span class="cx"> // last decode timestamp is greater than 2 times last frame duration:
</span><span class="cx"> if (trackBuffer.lastDecodeTimestamp.isValid() && (decodeTimestamp < trackBuffer.lastDecodeTimestamp
</span><span class="cx"> || abs(decodeTimestamp - trackBuffer.lastDecodeTimestamp) > (trackBuffer.lastFrameDuration * 2))) {
</span><del>- // 1.7.1 If mode equals "segments":
- // Set highest presentation end timestamp to presentation timestamp.
- m_highestPresentationEndTimestamp = presentationTimestamp;
</del><span class="cx">
</span><del>- // If mode equals "sequence":
- // Set group start timestamp equal to the highest presentation end timestamp.
- // FIXME: Add support for "sequence" mode.
</del><ins>+ // 1.6.1:
+ if (m_mode == segmentsKeyword()) {
+ // ↳ If mode equals "segments":
+ // Set group end timestamp to presentation timestamp.
+ m_groupEndTimestamp = presentationTimestamp;
+ } else if (m_mode == sequenceKeyword()) {
+ // ↳ If mode equals "sequence":
+ // Set group start timestamp equal to the group end timestamp.
+ m_groupStartTimestamp = m_groupEndTimestamp;
+ }
</ins><span class="cx">
</span><span class="cx"> for (auto& trackBuffer : m_trackBufferMap.values()) {
</span><del>- // 1.7.2 Unset the last decode timestamp on all track buffers.
</del><ins>+ // 1.6.2 Unset the last decode timestamp on all track buffers.
</ins><span class="cx"> trackBuffer.lastDecodeTimestamp = MediaTime::invalidTime();
</span><del>- // 1.7.3 Unset the last frame duration on all track buffers.
</del><ins>+ // 1.6.3 Unset the last frame duration on all track buffers.
</ins><span class="cx"> trackBuffer.lastFrameDuration = MediaTime::invalidTime();
</span><del>- // 1.7.4 Unset the highest presentation timestamp on all track buffers.
</del><ins>+ // 1.6.4 Unset the highest presentation timestamp on all track buffers.
</ins><span class="cx"> trackBuffer.highestPresentationTimestamp = MediaTime::invalidTime();
</span><del>- // 1.7.5 Set the need random access point flag on all track buffers to true.
</del><ins>+ // 1.6.5 Set the need random access point flag on all track buffers to true.
</ins><span class="cx"> trackBuffer.needRandomAccessFlag = true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // 1.7.6 Jump to the Loop Top step above to restart processing of the current coded frame.
</del><ins>+ // 1.6.6 Jump to the Loop Top step above to restart processing of the current coded frame.
</ins><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // 1.8 Let frame end timestamp equal the sum of presentation timestamp and frame duration.
</del><ins>+ // 1.7 Let frame end timestamp equal the sum of presentation timestamp and frame duration.
</ins><span class="cx"> MediaTime frameEndTimestamp = presentationTimestamp + frameDuration;
</span><span class="cx">
</span><del>- // 1.9 If presentation timestamp is less than appendWindowStart, then set the need random access
</del><ins>+ // 1.8 If presentation timestamp is less than appendWindowStart, then set the need random access
</ins><span class="cx"> // point flag to true, drop the coded frame, and jump to the top of the loop to start processing
</span><span class="cx"> // the next coded frame.
</span><del>- // 1.10 If frame end timestamp is greater than appendWindowEnd, then set the need random access
</del><ins>+ // 1.9 If frame end timestamp is greater than appendWindowEnd, then set the need random access
</ins><span class="cx"> // point flag to true, drop the coded frame, and jump to the top of the loop to start processing
</span><span class="cx"> // the next coded frame.
</span><span class="cx"> // FIXME: implement append windows
</span><span class="cx">
</span><ins>+ // 1.10 If the decode timestamp is less than the presentation start time, then run the end of stream
+ // algorithm with the error parameter set to "decode", and abort these steps.
+ // NOTE: Until <https://www.w3.org/Bugs/Public/show_bug.cgi?id=27487> is resolved, we will only check
+ // the presentation timestamp.
+ MediaTime presentationStartTime = MediaTime::zeroTime();
+ if (presentationTimestamp < presentationStartTime) {
+ LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveSample(%p) - failing because presentationTimestamp < presentationStartTime", this);
+ m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
+ return;
+ }
+
</ins><span class="cx"> // 1.11 If the need random access point flag on track buffer equals true, then run the following steps:
</span><span class="cx"> if (trackBuffer.needRandomAccessFlag) {
</span><span class="cx"> // 1.11.1 If the coded frame is not a random access point, then drop the coded frame and jump
</span><span class="lines">@@ -1318,7 +1372,7 @@
</span><span class="cx"> erasedSamples.addRange(iter_pair.first, iter_pair.second);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // If highest presentation timestamp for track buffer is set and less than presentation timestamp
</del><ins>+ // If highest presentation timestamp for track buffer is set and less than or equal to presentation timestamp
</ins><span class="cx"> if (trackBuffer.highestPresentationTimestamp.isValid() && trackBuffer.highestPresentationTimestamp <= 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><span class="lines">@@ -1333,8 +1387,7 @@
</span><span class="cx"> if (!bufferedLength)
</span><span class="cx"> break;
</span><span class="cx">
</span><del>- bool ignoreValid;
- MediaTime highestBufferedTime = m_buffered->ranges().end(bufferedLength - 1, ignoreValid);
</del><ins>+ MediaTime highestBufferedTime = m_buffered->ranges().maximumBufferedTime();
</ins><span class="cx">
</span><span class="cx"> PresentationOrderSampleMap::iterator_range range;
</span><span class="cx"> if (highestBufferedTime - trackBuffer.highestPresentationTimestamp < trackBuffer.lastFrameDuration)
</span><span class="lines">@@ -1403,11 +1456,15 @@
</span><span class="cx"> if (trackBuffer.highestPresentationTimestamp.isInvalid() || frameEndTimestamp > trackBuffer.highestPresentationTimestamp)
</span><span class="cx"> trackBuffer.highestPresentationTimestamp = frameEndTimestamp;
</span><span class="cx">
</span><del>- // 1.21 If highest presentation end timestamp is unset or frame end timestamp is greater than highest
- // presentation end timestamp, then set highest presentation end timestamp equal to frame end timestamp.
- if (m_highestPresentationEndTimestamp.isInvalid() || frameEndTimestamp > m_highestPresentationEndTimestamp)
- m_highestPresentationEndTimestamp = frameEndTimestamp;
</del><ins>+ // 1.21 If frame end timestamp is greater than group end timestamp, then set group end timestamp equal
+ // to frame end timestamp.
+ if (m_groupEndTimestamp.isInvalid() || frameEndTimestamp > m_groupEndTimestamp)
+ m_groupEndTimestamp = frameEndTimestamp;
</ins><span class="cx">
</span><ins>+ // 1.22 If generate timestamps flag equals true, then set timestampOffset equal to frame end timestamp.
+ if (m_shouldGenerateTimestamps)
+ m_timestampOffset = frameEndTimestamp;
+
</ins><span class="cx"> m_buffered->add(presentationTimestamp.toDouble(), (presentationTimestamp + frameDuration + microsecond).toDouble());
</span><span class="cx"> m_bufferedSinceLastMonitor += frameDuration.toDouble();
</span><span class="cx">
</span><span class="lines">@@ -1417,9 +1474,9 @@
</span><span class="cx"> // Steps 2-4 will be handled by MediaSource::monitorSourceBuffers()
</span><span class="cx">
</span><span class="cx"> // 5. If the media segment contains data beyond the current duration, then run the duration change algorithm with new
</span><del>- // duration set to the maximum of the current duration and the highest end timestamp reported by HTMLMediaElement.buffered.
- if (highestPresentationEndTimestamp() > m_source->duration())
- m_source->setDurationInternal(highestPresentationEndTimestamp());
</del><ins>+ // duration set to the maximum of the current duration and the group end timestamp.
+ if (m_groupEndTimestamp > m_source->duration())
+ m_source->setDurationInternal(m_groupEndTimestamp);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool SourceBuffer::hasAudio() const
</span><span class="lines">@@ -1792,6 +1849,48 @@
</span><span class="cx"> return *static_cast<Document*>(scriptExecutionContext());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SourceBuffer::setMode(const AtomicString& newMode, ExceptionCode& ec)
+{
+ // 3.1 Attributes - mode
+ // http://www.w3.org/TR/media-source/#widl-SourceBuffer-mode
+
+ // On setting, run the following steps:
+
+ // 1. Let new mode equal the new value being assigned to this attribute.
+ // 2. If generate timestamps flag equals true and new mode equals "segments", then throw an INVALID_ACCESS_ERR exception and abort these steps.
+ if (m_shouldGenerateTimestamps && newMode == segmentsKeyword()) {
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+
+ // 3. If this object has been removed from the sourceBuffers attribute of the parent media source, then throw an INVALID_STATE_ERR exception and abort these steps.
+ // 4. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
+ if (isRemoved() || m_updating) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ // 5. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
+ if (m_source->readyState() == MediaSource::endedKeyword()) {
+ // 5.1. Set the readyState attribute of the parent media source to "open"
+ // 5.2. Queue a task to fire a simple event named sourceopen at the parent media source.
+ m_source->openIfInEndedState();
+ }
+
+ // 6. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALID_STATE_ERR and abort these steps.
+ if (m_appendState == ParsingMediaSegment) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ // 7. If the new mode equals "sequence", then set the group start timestamp to the group end timestamp.
+ if (newMode == sequenceKeyword())
+ m_groupStartTimestamp = m_groupEndTimestamp;
+
+ // 8. Update the attribute to new mode.
+ m_mode = newMode;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreModulesmediasourceSourceBufferh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -63,6 +63,9 @@
</span><span class="cx"> public:
</span><span class="cx"> static PassRef<SourceBuffer> create(PassRef<SourceBufferPrivate>, MediaSource*);
</span><span class="cx">
</span><ins>+ static const AtomicString& segmentsKeyword();
+ static const AtomicString& sequenceKeyword();
+
</ins><span class="cx"> virtual ~SourceBuffer();
</span><span class="cx">
</span><span class="cx"> // SourceBuffer.idl methods
</span><span class="lines">@@ -79,7 +82,6 @@
</span><span class="cx">
</span><span class="cx"> void abortIfUpdating();
</span><span class="cx"> void removedFromMediaSource();
</span><del>- const MediaTime& highestPresentationEndTimestamp() const { return m_highestPresentationEndTimestamp; }
</del><span class="cx"> void seekToTime(const MediaTime&);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="lines">@@ -112,6 +114,12 @@
</span><span class="cx">
</span><span class="cx"> Document& document() const;
</span><span class="cx">
</span><ins>+ const AtomicString& mode() const { return m_mode; }
+ void setMode(const AtomicString&, ExceptionCode&);
+
+ bool shouldGenerateTimestamps() const { return m_shouldGenerateTimestamps; }
+ void setShouldGenerateTimestamps(bool flag) { m_shouldGenerateTimestamps = flag; }
+
</ins><span class="cx"> protected:
</span><span class="cx"> // EventTarget interface
</span><span class="cx"> virtual void refEventTarget() override { ref(); }
</span><span class="lines">@@ -181,6 +189,7 @@
</span><span class="cx"> Ref<SourceBufferPrivate> m_private;
</span><span class="cx"> MediaSource* m_source;
</span><span class="cx"> GenericEventQueue m_asyncEventQueue;
</span><ins>+ AtomicString m_mode;
</ins><span class="cx">
</span><span class="cx"> Vector<unsigned char> m_pendingAppendData;
</span><span class="cx"> Timer<SourceBuffer> m_appendBufferTimer;
</span><span class="lines">@@ -194,7 +203,8 @@
</span><span class="cx"> Vector<AtomicString> m_textCodecs;
</span><span class="cx">
</span><span class="cx"> MediaTime m_timestampOffset;
</span><del>- MediaTime m_highestPresentationEndTimestamp;
</del><ins>+ MediaTime m_groupStartTimestamp;
+ MediaTime m_groupEndTimestamp;
</ins><span class="cx">
</span><span class="cx"> HashMap<AtomicString, TrackBuffer> m_trackBufferMap;
</span><span class="cx"> RefPtr<TimeRanges> m_buffered;
</span><span class="lines">@@ -216,6 +226,7 @@
</span><span class="cx"> bool m_receivedFirstInitializationSegment;
</span><span class="cx"> bool m_active;
</span><span class="cx"> bool m_bufferFull;
</span><ins>+ bool m_shouldGenerateTimestamps;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreModulesmediasourceSourceBufferidl"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.idl (178500 => 178501)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.idl        2015-01-15 10:27:50 UTC (rev 178500)
+++ branches/safari-600.5-branch/Source/WebCore/Modules/mediasource/SourceBuffer.idl        2015-01-15 10:28:05 UTC (rev 178501)
</span><span class="lines">@@ -28,6 +28,11 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+[Conditional=MEDIA_SOURCE] enum AppendMode {
+ "segments",
+ "sequence"
+};
+
</ins><span class="cx"> [
</span><span class="cx"> Conditional=MEDIA_SOURCE,
</span><span class="cx"> NoInterfaceObject,
</span><span class="lines">@@ -37,6 +42,8 @@
</span><span class="cx"> JSGenerateToNativeObject,
</span><span class="cx"> ] interface SourceBuffer : EventTarget {
</span><span class="cx">
</span><ins>+ [SetterRaisesException] attribute AppendMode mode;
+
</ins><span class="cx"> readonly attribute boolean updating;
</span><span class="cx">
</span><span class="cx"> // Returns the time ranges buffered.
</span></span></pre>
</div>
</div>
</body>
</html>