Commit c2d132c5 authored by annacc@chromium.org's avatar annacc@chromium.org

Add the timestampOffset attribute to SourceBuffer.

https://bugs.webkit.org/show_bug.cgi?id=93303

Reviewed by Dimitri Glazkov.

On the 30 July 2012 version of the Media Source Extensions spec, a timestampOffset
attribute was added to the SourceBuffer object:
http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-timestampoffset

Source/WebCore:

Tests: additions to http/tests/media/media-source/video-media-source-objects.html

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::setTimestampOffset): Set the timestampOffset on MediaPlayer.
(WebCore):
* Modules/mediasource/MediaSource.h:
(MediaSource):
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::SourceBuffer): Let the timestampOffset be 0 initially
(WebCore::SourceBuffer::timestampOffset): Return the last value set.
(WebCore):
(WebCore::SourceBuffer::setTimestampOffset): Forward the call onto MediaSouce.
* Modules/mediasource/SourceBuffer.h:
(SourceBuffer):
* Modules/mediasource/SourceBuffer.idl: Create the new timestampOffset attr.
* platform/graphics/MediaPlayer.cpp:
(WebCore::NullMediaPlayerPrivate::sourceSetTimestampOffset): A null media player
    should just return false (nothing to set).
(WebCore):
(WebCore::MediaPlayer::sourceSetTimestampOffset):  Forward the call.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::sourceSetTimestampOffset):

Source/WebKit/chromium:

* public/WebMediaPlayer.h:
(WebKit::WebMediaPlayer::sourceSetTimestampOffset): Add the new method.
* src/WebMediaPlayerClientImpl.cpp:
(WebKit):
(WebKit::WebMediaPlayerClientImpl::sourceSetTimestampOffset): Forward the call.
* src/WebMediaPlayerClientImpl.h:
(WebMediaPlayerClientImpl):

LayoutTests:

* http/tests/media/media-source/video-media-source-objects-expected.txt:
* http/tests/media/media-source/video-media-source-objects.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dcc56abd
2012-08-15 Anna Cavender <annacc@chromium.org>
Add the timestampOffset attribute to SourceBuffer.
https://bugs.webkit.org/show_bug.cgi?id=93303
Reviewed by Dimitri Glazkov.
On the 30 July 2012 version of the Media Source Extensions spec, a timestampOffset
attribute was added to the SourceBuffer object:
http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-timestampoffset
* http/tests/media/media-source/video-media-source-objects-expected.txt:
* http/tests/media/media-source/video-media-source-objects.html:
2012-08-15 Pavel Chadnov <chadnov@google.com>
Web Inspector: Incorrect XHR responses when two async xhrs are sent synchronously
......@@ -26,6 +26,16 @@ EXPECTED (mediaSource.sourceBuffers[0].buffered.length == '1') OK
EXPECTED (mediaSource.sourceBuffers[0].buffered.start(0) == '0') OK
EXPECTED (mediaSource.sourceBuffers[0].buffered.end(0) > '1') OK
Set timestampOffset.
EXPECTED (segmentHelper.sourceBuffer.timestampOffset == '0') OK
RUN(segmentHelper.sourceBuffer.timestampOffset = 5)
EXPECTED (segmentHelper.sourceBuffer.timestampOffset == '5') OK
Append 1 second of data.
EXPECTED (mediaSource.sourceBuffers[0].buffered.length == '2') OK
EXPECTED (mediaSource.sourceBuffers[0].buffered.start(1) == '5') OK
EXPECTED (mediaSource.sourceBuffers[0].buffered.end(1) > '1') OK
Remove SourceBuffer
RUN(mediaSource.removeSourceBuffer(segmentHelper.sourceBuffer))
EXPECTED (mediaSource.sourceBuffers.length == '0') OK
......@@ -38,5 +48,7 @@ Got expected exception Error: INVALID_STATE_ERR: DOM Exception 11
EXPECTED (mediaSource.sourceBuffers.length == '0') OK
Test that addSourceBuffer() throws and error when the MediaSource is not associated with a media element.
Got expected exception Error: INVALID_STATE_ERR: DOM Exception 11
Test that setting timestampOffset throws an error when the MediaSource is not associated with a media element.
Got expected exception Error: INVALID_STATE_ERR: DOM Exception 11
END OF TEST
......@@ -42,6 +42,22 @@
testExpected("mediaSource.sourceBuffers[0].buffered.start(0)", 0);
testExpected("mediaSource.sourceBuffers[0].buffered.end(0)", 1, '>');
consoleWrite("");
consoleWrite("Set timestampOffset.");
testExpected("segmentHelper.sourceBuffer.timestampOffset", 0);
run("segmentHelper.sourceBuffer.timestampOffset = 5");
testExpected("segmentHelper.sourceBuffer.timestampOffset", 5);
// Append another 1 second of media data.
consoleWrite("");
consoleWrite("Append 1 second of data.");
var endIndex = segmentHelper.getMediaSegmentIndexForTimestamp(1);
for (var i = 0; i <= endIndex; i++)
segmentHelper.appendMediaSegment(i);
testExpected("mediaSource.sourceBuffers[0].buffered.length", 2);
testExpected("mediaSource.sourceBuffers[0].buffered.start(1)", 5);
testExpected("mediaSource.sourceBuffers[0].buffered.end(1)", 1, '>');
consoleWrite("");
consoleWrite("Remove SourceBuffer");
......@@ -58,6 +74,13 @@
consoleWrite("Got expected exception " + e);
}
consoleWrite("Test that setting timestampOffset throws an error when the MediaSource is not associated with a media element.");
try {
segmentHelper.sourceBuffer.timestampOffset = 10;
} catch (e) {
consoleWrite("Got expected exception " + e);
}
endTest();
}
......
2012-08-15 Anna Cavender <annacc@chromium.org>
Add the timestampOffset attribute to SourceBuffer.
https://bugs.webkit.org/show_bug.cgi?id=93303
Reviewed by Dimitri Glazkov.
On the 30 July 2012 version of the Media Source Extensions spec, a timestampOffset
attribute was added to the SourceBuffer object:
http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-timestampoffset
Tests: additions to http/tests/media/media-source/video-media-source-objects.html
* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::setTimestampOffset): Set the timestampOffset on MediaPlayer.
(WebCore):
* Modules/mediasource/MediaSource.h:
(MediaSource):
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::SourceBuffer): Let the timestampOffset be 0 initially
(WebCore::SourceBuffer::timestampOffset): Return the last value set.
(WebCore):
(WebCore::SourceBuffer::setTimestampOffset): Forward the call onto MediaSouce.
* Modules/mediasource/SourceBuffer.h:
(SourceBuffer):
* Modules/mediasource/SourceBuffer.idl: Create the new timestampOffset attr.
* platform/graphics/MediaPlayer.cpp:
(WebCore::NullMediaPlayerPrivate::sourceSetTimestampOffset): A null media player
should just return false (nothing to set).
(WebCore):
(WebCore::MediaPlayer::sourceSetTimestampOffset): Forward the call.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::sourceSetTimestampOffset):
2012-08-15 Pavel Chadnov <chadnov@google.com>
Web Inspector: Incorrect XHR responses when two async xhrs are sent synchronously
......@@ -267,6 +267,20 @@ void MediaSource::abort(const String& id, ExceptionCode& ec)
ASSERT_NOT_REACHED();
}
bool MediaSource::setTimestampOffset(const String& id, double offset, ExceptionCode& ec)
{
if (!m_player || m_readyState != openKeyword()) {
ec = INVALID_STATE_ERR;
return false;
}
if (!m_player->sourceSetTimestampOffset(id, offset)) {
ec = INVALID_STATE_ERR;
return false;
}
return true;
}
const AtomicString& MediaSource::interfaceName() const
{
return eventNames().interfaceForMediaSource;
......
......@@ -80,6 +80,7 @@ public:
PassRefPtr<TimeRanges> buffered(const String& id, ExceptionCode&) const;
void append(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode&);
void abort(const String& id, ExceptionCode&);
bool setTimestampOffset(const String& id, double, ExceptionCode&);
// EventTarget interface
virtual const AtomicString& interfaceName() const OVERRIDE;
......
......@@ -41,6 +41,7 @@ namespace WebCore {
SourceBuffer::SourceBuffer(const String& id, PassRefPtr<MediaSource> source)
: m_id(id)
, m_source(source)
, m_timestampOffset(0)
{
}
......@@ -58,6 +59,22 @@ PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const
return m_source->buffered(id(), ec);
}
double SourceBuffer::timestampOffset() const
{
return m_timestampOffset;
}
void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
{
if (!m_source) {
ec = INVALID_STATE_ERR;
return;
}
if (m_source->setTimestampOffset(id(), offset, ec))
m_timestampOffset = offset;
}
void SourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec)
{
if (!m_source) {
......
......@@ -54,6 +54,9 @@ public:
PassRefPtr<TimeRanges> buffered(ExceptionCode&) const;
double timestampOffset() const;
void setTimestampOffset(double, ExceptionCode&);
void append(PassRefPtr<Uint8Array> data, ExceptionCode&);
void abort(ExceptionCode&);
......@@ -67,6 +70,8 @@ private:
String m_id;
RefPtr<MediaSource> m_source;
double m_timestampOffset;
};
} // namespace WebCore
......
......@@ -39,6 +39,10 @@ module html {
readonly attribute TimeRanges buffered
getter raises(DOMException);
// Applies an offset to media segment timestamps.
attribute double timestampOffset
setter raises(DOMException);
// Append segment data.
void append(in Uint8Array data) raises (DOMException);
......
......@@ -155,6 +155,7 @@ public:
virtual bool sourceAppend(const String&, const unsigned char*, unsigned) { return false; }
virtual bool sourceAbort(const String&) { return false; }
virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { }
virtual bool sourceSetTimestampOffset(const String&, double) { return false; }
#endif
#if ENABLE(ENCRYPTED_MEDIA)
......@@ -492,6 +493,11 @@ void MediaPlayer::sourceEndOfStream(MediaPlayer::EndOfStreamStatus status)
{
return m_private->sourceEndOfStream(status);
}
bool MediaPlayer::sourceSetTimestampOffset(const String& id, double offset)
{
return m_private->sourceSetTimestampOffset(id, offset);
}
#endif
#if ENABLE(ENCRYPTED_MEDIA)
......
......@@ -256,6 +256,7 @@ public:
bool sourceAbort(const String& id);
enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
void sourceEndOfStream(EndOfStreamStatus);
bool sourceSetTimestampOffset(const String& id, double offset);
#endif
#if ENABLE(ENCRYPTED_MEDIA)
......
......@@ -174,6 +174,7 @@ public:
virtual bool sourceAppend(const String& id, const unsigned char* data, unsigned length) { return false; }
virtual bool sourceAbort(const String& id) { return false; }
virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { };
virtual bool sourceSetTimestampOffset(const String& id, double offset) { return false; }
#endif
#if ENABLE(ENCRYPTED_MEDIA)
......
2012-08-15 Anna Cavender <annacc@chromium.org>
Add the timestampOffset attribute to SourceBuffer.
https://bugs.webkit.org/show_bug.cgi?id=93303
Reviewed by Dimitri Glazkov.
On the 30 July 2012 version of the Media Source Extensions spec, a timestampOffset
attribute was added to the SourceBuffer object:
http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-timestampoffset
* public/WebMediaPlayer.h:
(WebKit::WebMediaPlayer::sourceSetTimestampOffset): Add the new method.
* src/WebMediaPlayerClientImpl.cpp:
(WebKit):
(WebKit::WebMediaPlayerClientImpl::sourceSetTimestampOffset): Forward the call.
* src/WebMediaPlayerClientImpl.h:
(WebMediaPlayerClientImpl):
2012-08-15 Peter Beverloo <peter@chromium.org>
[Chromium] Roll WebKit Chromium DEPS to r151672
......
......@@ -187,6 +187,7 @@ public:
virtual bool sourceAppend(const WebString& id, const unsigned char* data, unsigned length) { return false; }
virtual bool sourceAbort(const WebString& id) { return false; }
virtual void sourceEndOfStream(EndOfStreamStatus) { }
virtual bool sourceSetTimestampOffset(const WebString& id, double offset) { return false; }
// Returns whether keySystem is supported. If true, the result will be
// reported by an event.
......
......@@ -435,6 +435,13 @@ void WebMediaPlayerClientImpl::sourceEndOfStream(WebCore::MediaPlayer::EndOfStre
if (m_webMediaPlayer)
m_webMediaPlayer->sourceEndOfStream(static_cast<WebMediaPlayer::EndOfStreamStatus>(status));
}
bool WebMediaPlayerClientImpl::sourceSetTimestampOffset(const String& id, double offset)
{
if (!m_webMediaPlayer)
return false;
return m_webMediaPlayer->sourceSetTimestampOffset(id, offset);
}
#endif
#if ENABLE(ENCRYPTED_MEDIA)
......
......@@ -164,6 +164,7 @@ public:
virtual bool sourceAppend(const String&, const unsigned char* data, unsigned length);
virtual bool sourceAbort(const String&);
virtual void sourceEndOfStream(WebCore::MediaPlayer::EndOfStreamStatus);
virtual bool sourceSetTimestampOffset(const String&, double offset);
#endif
#if ENABLE(ENCRYPTED_MEDIA)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment