Commit db146b4c authored by jer.noble@apple.com's avatar jer.noble@apple.com

[MSE] Remove legacy Media Source APIs (WebKitMediaSource, WebKitSourceBuffer,...

[MSE] Remove legacy Media Source APIs (WebKitMediaSource, WebKitSourceBuffer, WebKitSourceBufferList)
https://bugs.webkit.org/show_bug.cgi?id=123463

Reviewed by Eric Carlson.

Source/WebCore:

No new tests; updated test results.

Remove all reference to WebKitMediaSource, WebKitSourceBuffer, and WebKitSourceBufferList.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.list.am:
* Modules/mediasource/DOMURLMediaSource.idl:
* Modules/mediasource/WebKitMediaSource.cpp: Removed.
* Modules/mediasource/WebKitMediaSource.h: Removed.
* Modules/mediasource/WebKitMediaSource.idl: Removed.
* Modules/mediasource/WebKitSourceBuffer.cpp: Removed.
* Modules/mediasource/WebKitSourceBuffer.h: Removed.
* Modules/mediasource/WebKitSourceBuffer.idl: Removed.
* Modules/mediasource/WebKitSourceBufferList.cpp: Removed.
* Modules/mediasource/WebKitSourceBufferList.h: Removed.
* Modules/mediasource/WebKitSourceBufferList.idl: Removed.
* WebCore.xcodeproj/project.pbxproj:
* dom/EventTargetFactory.in:

LayoutTests:

* platform/mac/js/dom/global-constructors-attributes-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fc5554c0
2013-10-29 Jer Noble <jer.noble@apple.com>
[MSE] Remove legacy Media Source APIs (WebKitMediaSource, WebKitSourceBuffer, WebKitSourceBufferList)
https://bugs.webkit.org/show_bug.cgi?id=123463
Reviewed by Eric Carlson.
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
2013-10-29 Simon Fraser <simon.fraser@apple.com>
A WebGL test times out sometimes.
......
......@@ -1958,11 +1958,6 @@ PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeys').hasOwnProperty('
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeys').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeys').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeys').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaSource').value is WebKitMediaSource
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaSource').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaSource').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaSource').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaSource').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMutationObserver').value is WebKitMutationObserver
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMutationObserver').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitMutationObserver').hasOwnProperty('set') is false
......@@ -1973,16 +1968,6 @@ PASS Object.getOwnPropertyDescriptor(global, 'WebKitPoint').hasOwnProperty('get'
PASS Object.getOwnPropertyDescriptor(global, 'WebKitPoint').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitPoint').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitPoint').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBuffer').value is WebKitSourceBuffer
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBuffer').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBuffer').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBuffer').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBuffer').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBufferList').value is WebKitSourceBufferList
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBufferList').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBufferList').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBufferList').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitSourceBufferList').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WebKitTransitionEvent').value is WebKitTransitionEvent
PASS Object.getOwnPropertyDescriptor(global, 'WebKitTransitionEvent').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitTransitionEvent').hasOwnProperty('set') is false
......
......@@ -183,9 +183,6 @@ set(WebCore_IDL_FILES
Modules/mediasource/MediaSource.idl
Modules/mediasource/SourceBuffer.idl
Modules/mediasource/SourceBufferList.idl
Modules/mediasource/WebKitMediaSource.idl
Modules/mediasource/WebKitSourceBuffer.idl
Modules/mediasource/WebKitSourceBufferList.idl
Modules/mediastream/AllAudioCapabilities.idl
Modules/mediastream/AllVideoCapabilities.idl
......
2013-10-29 Jer Noble <jer.noble@apple.com>
[MSE] Remove legacy Media Source APIs (WebKitMediaSource, WebKitSourceBuffer, WebKitSourceBufferList)
https://bugs.webkit.org/show_bug.cgi?id=123463
Reviewed by Eric Carlson.
No new tests; updated test results.
Remove all reference to WebKitMediaSource, WebKitSourceBuffer, and WebKitSourceBufferList.
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.list.am:
* Modules/mediasource/DOMURLMediaSource.idl:
* Modules/mediasource/WebKitMediaSource.cpp: Removed.
* Modules/mediasource/WebKitMediaSource.h: Removed.
* Modules/mediasource/WebKitMediaSource.idl: Removed.
* Modules/mediasource/WebKitSourceBuffer.cpp: Removed.
* Modules/mediasource/WebKitSourceBuffer.h: Removed.
* Modules/mediasource/WebKitSourceBuffer.idl: Removed.
* Modules/mediasource/WebKitSourceBufferList.cpp: Removed.
* Modules/mediasource/WebKitSourceBufferList.h: Removed.
* Modules/mediasource/WebKitSourceBufferList.idl: Removed.
* WebCore.xcodeproj/project.pbxproj:
* dom/EventTargetFactory.in:
2013-10-30 Antti Koivisto <antti@apple.com>
Unbreak the release build.
......
......@@ -249,9 +249,6 @@
#include "JSMediaList.cpp"
#include "JSMediaQueryList.cpp"
#include "JSMediaQueryListListener.cpp"
#if ENABLE(MEDIA_SOURCE)
#include "JSWebKitMediaSource.cpp"
#endif
#include "JSMessageChannel.cpp"
#include "JSMessageEvent.cpp"
#include "JSMessagePort.cpp"
......@@ -291,10 +288,6 @@
#include "JSShadowRoot.cpp"
#include "JSSharedWorker.cpp"
#include "JSSharedWorkerGlobalScope.cpp"
#if ENABLE(MEDIA_SOURCE)
#include "JSWebKitSourceBuffer.cpp"
#include "JSWebKitSourceBufferList.cpp"
#endif
#include "JSSQLError.cpp"
#include "JSSQLException.cpp"
#include "JSSQLResultSet.cpp"
......
......@@ -97,11 +97,6 @@ BINDING_IDLS = \
$(WebCore)/Modules/mediasource/MediaSource.idl \
$(WebCore)/Modules/mediasource/SourceBuffer.idl \
$(WebCore)/Modules/mediasource/SourceBufferList.idl \
$(WebCore)/Modules/mediasource/WebKitMediaSource.idl \
$(WebCore)/Modules/mediasource/WebKitSourceBuffer.idl \
$(WebCore)/Modules/mediasource/WebKitSourceBufferList.idl \
$(WebCore)/Modules/mediasource/SourceBuffer.idl \
$(WebCore)/Modules/mediasource/SourceBufferList.idl \
$(WebCore)/Modules/mediastream/AllVideoCapabilities.idl \
$(WebCore)/Modules/mediastream/AllAudioCapabilities.idl \
$(WebCore)/Modules/mediastream/AudioStreamTrack.idl \
......
......@@ -465,8 +465,6 @@ webcore_built_sources += \
DerivedSources/WebCore/JSMediaList.h \
DerivedSources/WebCore/JSMediaSource.cpp \
DerivedSources/WebCore/JSMediaSource.h \
DerivedSources/WebCore/JSWebKitMediaSource.cpp \
DerivedSources/WebCore/JSWebKitMediaSource.h \
DerivedSources/WebCore/JSMediaSourceStates.cpp \
DerivedSources/WebCore/JSMediaSourceStates.h \
DerivedSources/WebCore/JSMediaStream.cpp \
......@@ -643,10 +641,6 @@ webcore_built_sources += \
DerivedSources/WebCore/JSSourceBufferList.h \
DerivedSources/WebCore/JSSourceInfo.cpp \
DerivedSources/WebCore/JSSourceInfo.h \
DerivedSources/WebCore/JSWebKitSourceBuffer.cpp \
DerivedSources/WebCore/JSWebKitSourceBuffer.h \
DerivedSources/WebCore/JSWebKitSourceBufferList.cpp \
DerivedSources/WebCore/JSWebKitSourceBufferList.h \
DerivedSources/WebCore/JSSpeechInputEvent.cpp \
DerivedSources/WebCore/JSSpeechInputEvent.h \
DerivedSources/WebCore/JSSpeechInputResult.cpp \
......@@ -1200,9 +1194,6 @@ dom_binding_idls += \
$(WebCore)/Modules/mediasource/MediaSource.idl \
$(WebCore)/Modules/mediasource/SourceBuffer.idl \
$(WebCore)/Modules/mediasource/SourceBufferList.idl \
$(WebCore)/Modules/mediasource/WebKitMediaSource.idl \
$(WebCore)/Modules/mediasource/WebKitSourceBuffer.idl \
$(WebCore)/Modules/mediasource/WebKitSourceBufferList.idl \
$(WebCore)/Modules/mediastream/AllVideoCapabilities.idl \
$(WebCore)/Modules/mediastream/AllAudioCapabilities.idl \
$(WebCore)/Modules/mediastream/AudioStreamTrack.idl \
......@@ -1874,12 +1865,6 @@ webcore_modules_sources += \
Source/WebCore/Modules/mediasource/SourceBufferList.h \
Source/WebCore/Modules/mediasource/DOMURLMediaSource.cpp \
Source/WebCore/Modules/mediasource/DOMURLMediaSource.h \
Source/WebCore/Modules/mediasource/WebKitMediaSource.cpp \
Source/WebCore/Modules/mediasource/WebKitMediaSource.h \
Source/WebCore/Modules/mediasource/WebKitSourceBuffer.cpp \
Source/WebCore/Modules/mediasource/WebKitSourceBuffer.h \
Source/WebCore/Modules/mediasource/WebKitSourceBufferList.cpp \
Source/WebCore/Modules/mediasource/WebKitSourceBufferList.h \
Source/WebCore/Modules/mediastream/AllAudioCapabilities.h \
Source/WebCore/Modules/mediastream/AllVideoCapabilities.h \
Source/WebCore/Modules/mediastream/AudioStreamTrack.cpp \
......
......@@ -32,5 +32,4 @@
]
partial interface DOMURL {
[CallWith=ScriptExecutionContext,TreatReturnedNullStringAs=Null] static DOMString createObjectURL(MediaSource? source);
[CallWith=ScriptExecutionContext,TreatReturnedNullStringAs=Null] static DOMString createObjectURL(WebKitMediaSource? source);
};
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebKitMediaSource.h"
#if ENABLE(MEDIA_SOURCE)
#include "ContentType.h"
#include "ExceptionCodePlaceholder.h"
#include "MIMETypeRegistry.h"
#include "MediaSourceRegistry.h"
#include "SourceBufferPrivate.h"
#include "TimeRanges.h"
#include <runtime/Uint8Array.h>
namespace WebCore {
PassRefPtr<WebKitMediaSource> WebKitMediaSource::create(ScriptExecutionContext* context)
{
RefPtr<WebKitMediaSource> mediaSource(adoptRef(new WebKitMediaSource(context)));
mediaSource->suspendIfNeeded();
return mediaSource.releaseNonNull();
}
WebKitMediaSource::WebKitMediaSource(ScriptExecutionContext* context)
: MediaSourceBase(context)
, m_asyncEventQueue(*this)
, m_sourceBuffers(WebKitSourceBufferList::create(scriptExecutionContext()))
, m_activeSourceBuffers(WebKitSourceBufferList::create(scriptExecutionContext()))
{
}
WebKitSourceBufferList* WebKitMediaSource::sourceBuffers()
{
return m_sourceBuffers.get();
}
WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers()
{
// FIXME(91649): support track selection
return m_activeSourceBuffers.get();
}
WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, ExceptionCode& ec)
{
// 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-addsourcebuffer
// 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and
// abort these steps.
if (type.isNull() || type.isEmpty()) {
ec = INVALID_ACCESS_ERR;
return 0;
}
// 2. If type contains a MIME type that is not supported ..., then throw a
// NOT_SUPPORTED_ERR exception and abort these steps.
if (!isTypeSupported(type)) {
ec = NOT_SUPPORTED_ERR;
return 0;
}
// 4. If the readyState attribute is not in the "open" state then throw an
// INVALID_STATE_ERR exception and abort these steps.
if (!isOpen()) {
ec = INVALID_STATE_ERR;
return 0;
}
// 5. Create a new SourceBuffer object and associated resources.
ContentType contentType(type);
Vector<String> codecs = contentType.codecs();
RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec);
if (!sourceBufferPrivate)
return 0;
RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferPrivate.releaseNonNull(), *this);
// 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
m_sourceBuffers->add(buffer);
m_activeSourceBuffers->add(buffer);
// 7. Return the new object to the caller.
return buffer.get();
}
void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, ExceptionCode& ec)
{
// 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-removesourcebuffer
// 1. If sourceBuffer is null then throw an INVALID_ACCESS_ERR exception and
// abort these steps.
if (!buffer) {
ec = INVALID_ACCESS_ERR;
return;
}
// 2. If sourceBuffers is empty then throw an INVALID_STATE_ERR exception and
// abort these steps.
if (isClosed() || !m_sourceBuffers->length()) {
ec = INVALID_STATE_ERR;
return;
}
// 3. If sourceBuffer specifies an object that is not in sourceBuffers then
// throw a NOT_FOUND_ERR exception and abort these steps.
// 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event
// on that object.
if (!m_sourceBuffers->remove(buffer)) {
ec = NOT_FOUND_ERR;
return;
}
// 7. Destroy all resources for sourceBuffer.
m_activeSourceBuffers->remove(buffer);
// 4. Remove track information from audioTracks, videoTracks, and textTracks for all tracks
// associated with sourceBuffer and fire a simple event named change on the modified lists.
// FIXME(91649): support track selection
// 5. If sourceBuffer is in activeSourceBuffers, then remove it from that list and fire a
// removesourcebuffer event on that object.
// FIXME(91649): support track selection
}
void WebKitMediaSource::onReadyStateChange(const AtomicString& oldState, const AtomicString& newState)
{
if (isClosed()) {
m_sourceBuffers->clear();
m_activeSourceBuffers->clear();
scheduleEvent(eventNames().webkitsourcecloseEvent);
return;
}
if (oldState == openKeyword() && newState == endedKeyword()) {
scheduleEvent(eventNames().webkitsourceendedEvent);
return;
}
if (isOpen()) {
scheduleEvent(eventNames().webkitsourceopenEvent);
return;
}
}
Vector<RefPtr<TimeRanges>> WebKitMediaSource::activeRanges() const
{
Vector<RefPtr<TimeRanges>> activeRanges(m_activeSourceBuffers->length());
for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i)
activeRanges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXCEPTION);
return activeRanges;
}
bool WebKitMediaSource::isTypeSupported(const String& type)
{
// Section 2.1 isTypeSupported() method steps.
// https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
// 1. If type is an empty string, then return false.
if (type.isNull() || type.isEmpty())
return false;
ContentType contentType(type);
String codecs = contentType.parameter("codecs");
// 2. If type does not contain a valid MIME type string, then return false.
if (contentType.type().isEmpty() || codecs.isEmpty())
return false;
// 3. If type contains a media type or media subtype that the MediaSource does not support, then return false.
// 4. If type contains at a codec that the MediaSource does not support, then return false.
// 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
// 6. Return true.
return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(), codecs);
}
EventTargetInterface WebKitMediaSource::eventTargetInterface() const
{
return WebKitMediaSourceEventTargetInterfaceType;
}
} // namespace WebCore
#endif
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebKitMediaSource_h
#define WebKitMediaSource_h
#if ENABLE(MEDIA_SOURCE)
#include "MediaSourceBase.h"
#include "ScriptWrappable.h"
#include "WebKitSourceBuffer.h"
#include "WebKitSourceBufferList.h"
#include <wtf/RefCounted.h>
namespace WebCore {
class WebKitMediaSource : public MediaSourceBase, public ScriptWrappable {
public:
static PassRefPtr<WebKitMediaSource> create(ScriptExecutionContext*);
virtual ~WebKitMediaSource() { }
// WebKitMediaSource.idl methods
WebKitSourceBufferList* sourceBuffers();
WebKitSourceBufferList* activeSourceBuffers();
WebKitSourceBuffer* addSourceBuffer(const String& type, ExceptionCode&);
void removeSourceBuffer(WebKitSourceBuffer*, ExceptionCode&);
static bool isTypeSupported(const String& type);
// EventTarget interface
virtual EventTargetInterface eventTargetInterface() const OVERRIDE;
using RefCounted<MediaSourceBase>::ref;
using RefCounted<MediaSourceBase>::deref;
private:
explicit WebKitMediaSource(ScriptExecutionContext*);
// MediaSourceBase interface
virtual void onReadyStateChange(const AtomicString&, const AtomicString&) OVERRIDE;
virtual Vector<RefPtr<TimeRanges>> activeRanges() const OVERRIDE;
GenericEventQueue m_asyncEventQueue;
RefPtr<WebKitSourceBufferList> m_sourceBuffers;
RefPtr<WebKitSourceBufferList> m_activeSourceBuffers;
};
} // namespace WebCore
#endif
#endif
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
[
Conditional=MEDIA_SOURCE,
ActiveDOMObject,
EventTarget,
JSGenerateToJSObject,
JSGenerateToNativeObject,
Constructor,
ConstructorCallWith=ScriptExecutionContext,
OperationsNotDeletable
] interface WebKitMediaSource : EventTarget {
// All the source buffers created by this object.
readonly attribute WebKitSourceBufferList sourceBuffers;
// Subset of sourceBuffers that provide data for the selected/enabled tracks.
readonly attribute WebKitSourceBufferList activeSourceBuffers;
[SetterRaisesException] attribute double duration;
[RaisesException] WebKitSourceBuffer addSourceBuffer(DOMString type);
[RaisesException] void removeSourceBuffer(WebKitSourceBuffer buffer);
readonly attribute DOMString readyState;
[RaisesException] void endOfStream([Default=NullString] optional DOMString error);
static boolean isTypeSupported (DOMString type);
};
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebKitSourceBuffer.h"
#if ENABLE(MEDIA_SOURCE)
#include "SourceBufferPrivate.h"
#include "TimeRanges.h"
#include "WebKitMediaSource.h"
#include <runtime/Uint8Array.h>
namespace WebCore {
PassRef<WebKitSourceBuffer> WebKitSourceBuffer::create(PassRef<SourceBufferPrivate> sourceBufferPrivate, PassRef<WebKitMediaSource> source)
{
return adoptRef(*new WebKitSourceBuffer(std::move(sourceBufferPrivate), std::move(source)));
}
WebKitSourceBuffer::WebKitSourceBuffer(PassRef<SourceBufferPrivate> sourceBufferPrivate, PassRef<WebKitMediaSource> source)
: m_private(std::move(sourceBufferPrivate))
, m_source(std::move(source))
, m_timestampOffset(0)
{
ASSERT(m_private);
ASSERT(m_source);
}
WebKitSourceBuffer::~WebKitSourceBuffer()
{
}
PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionCode& ec) const
{
// Section 3.1 buffered attribute steps.
// 1. 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.
if (isRemoved()) {
ec = INVALID_STATE_ERR;
return 0;
}
// 2. Return a new static normalized TimeRanges object for the media segments buffered.
return m_private->buffered();
}
double WebKitSourceBuffer::timestampOffset() const
{
return m_timestampOffset;
}
void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
{
// Section 3.1 timestampOffset attribute setter steps.
// 1. 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.
if (isRemoved()) {
ec = INVALID_STATE_ERR;
return;
}
// 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
// 4.1 Set the readyState attribute of the parent media source to "open"
// 4.2 Queue a task to fire a simple event named sourceopen at the parent media source.
m_source->openIfInEndedState();
// 5. If this object is waiting for the end of a media segment to be appended, then throw an INVALID_STATE_ERR
// and abort these steps.
if (!m_private->setTimestampOffset(offset)) {
ec = INVALID_STATE_ERR;
return;
}
// 6. Update the attribute to the new value.
m_timestampOffset = offset;
}