Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1171)

Unified Diff: Source/modules/mediasource/SourceBuffer.cpp

Issue 14876007: Add Blink side support for SourceBuffer.appendWindowStart & SourceBuffer.appendWindowEnd. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: throw DOMException for set appendwindow error Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/mediasource/SourceBuffer.cpp
diff --git a/Source/modules/mediasource/SourceBuffer.cpp b/Source/modules/mediasource/SourceBuffer.cpp
index 20fe0932d3b7c9817e07030cd7014bfd4d2192ec..384071392c9bec56a58ba3fb88982291462bd3dc 100644
--- a/Source/modules/mediasource/SourceBuffer.cpp
+++ b/Source/modules/mediasource/SourceBuffer.cpp
@@ -41,6 +41,9 @@
#include "modules/mediasource/MediaSource.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/ArrayBufferView.h"
+#include "wtf/MathExtras.h"
+
+#include <limits>
namespace WebCore {
@@ -59,6 +62,8 @@ SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate,
, m_updating(false)
, m_timestampOffset(0)
, m_appendBufferTimer(this, &SourceBuffer::appendBufferTimerFired)
+ , m_appendWindowStart(0)
+ , m_appendWindowEnd(std::numeric_limits<double>::infinity())
{
ASSERT(m_private);
ASSERT(m_source);
@@ -115,6 +120,82 @@ void SourceBuffer::setTimestampOffset(double offset, ExceptionState& es)
m_timestampOffset = offset;
}
+double SourceBuffer::appendWindowStart() const
+{
+ return m_appendWindowStart;
+}
+
+void SourceBuffer::setAppendWindowStart(double start, ExceptionState& es)
+{
+ // Section 3.1 appendWindowStart attribute setter steps.
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 You should probably add code along these lines to
+ // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
+ // InvalidStateError exception and abort these steps.
+ if (isRemoved()) {
+ es.throwDOMException(InvalidStateError);
+ return;
+ }
+
+ // 2. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: s/INVALID_STATE_ERR/InvalidStateError
+ if (m_updating) {
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: This could be added to the conditional above.
+ es.throwDOMException(InvalidStateError);
+ return;
+ }
+
+ // 3. If the new value is less than 0 or greater than or equal to appendWindowEnd then throw an InvalidAccessError
+ // exception and abort these steps.
+ if (start < 0 || start >= m_appendWindowEnd) {
+ es.throwDOMException(InvalidAccessError);
+ return;
+ }
+
+ m_private->setAppendWindowStart(start);
+
+ // 4. Update the attribute to the new value.
+ m_appendWindowStart = start;
+}
+
+double SourceBuffer::appendWindowEnd() const
+{
+ return m_appendWindowEnd;
+}
+
+void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& es)
+{
+ // Section 3.1 appendWindowEnd attribute setter steps.
+ // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
+ // InvalidStateError exception and abort these steps.
+ if (isRemoved()) {
+ es.throwDOMException(InvalidStateError);
+ return;
+ }
+
+ // 2. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: s/INVALID_STATE_ERR/InvalidStateError
+ if (m_updating) {
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: this could be added to the conditional above.
+ es.throwDOMException(InvalidStateError);
+ return;
+ }
+
+ // 3. If the new value equals NaN, then throw an INVALID_ACCESS_ERR and abort these steps.
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: s/INVALID_ACCESS_ERR/InvalidAccessError
+ if (std::isnan(end)) {
+ es.throwDOMException(InvalidAccessError);
+ return;
+ }
+
+ // 4. If the new value is less than or equal to appendWindowStart then throw an InvalidAccessError
+ // exception and abort these steps.
+ if (end <= m_appendWindowStart) {
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: This can be added to the conditional above.
+ es.throwDOMException(InvalidAccessError);
+ return;
+ }
+
+ m_private->setAppendWindowEnd(end);
+
+ // 5. Update the attribute to the new value.
+ m_appendWindowEnd = end;
+}
+
+
+
void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& es)
{
// Section 3.2 appendBuffer()
@@ -160,7 +241,11 @@ void SourceBuffer::abort(ExceptionState& es)
// 4. Run the reset parser state algorithm.
m_private->abort();
- // FIXME(229408) Add steps 5-6 update appendWindowStart & appendWindowEnd.
+ // 5. Set appendWindowStart to 0.
+ m_appendWindowStart = 0;
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: This doesn't notify m_private about this chan
+
+ // 6. Set appendWindowEnd to positive Infinity.
+ m_appendWindowEnd = std::numeric_limits<double>::infinity();
acolwell GONE FROM CHROMIUM 2013/08/06 18:10:33 nit: ditto. Call setAppendWindowEnd(std::numeric_l
}

Powered by Google App Engine
This is Rietveld 408576698