From c637330030c11a1269c6fd6fe4cbf36dcab6c74a Mon Sep 17 00:00:00 2001 From: "annacc@chromium.org" Date: Tue, 24 Jul 2012 20:44:43 +0000 Subject: [PATCH] Create SourceBuffer and SourceBufferList objects https://bugs.webkit.org/show_bug.cgi?id=91771 Reviewed by Eric Carlson. SourceBuffer and SourceBufferList objects are needed in order to implement the new object-oriented MediaSource API: http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html No new tests - will be able to test after landing BUGWK91775 Adding new files to build files: * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * DerivedSources.pri: * GNUmakefile.am: * GNUmakefile.list.am: * Target.pri: * WebCore.gyp/WebCore.gyp: * WebCore.gypi: * WebCore.vcproj/WebCore.vcproj: * WebCore.vcproj/WebCoreCommon.vsprops: * WebCore.vcproj/copyForwardingHeaders.cmd: * WebCore.xcodeproj/project.pbxproj: New objects: * Modules/mediasource/SourceBuffer.cpp: Added. * Modules/mediasource/SourceBuffer.h: Added. * Modules/mediasource/SourceBuffer.idl: Added. * Modules/mediasource/SourceBufferList.cpp: Added. * Modules/mediasource/SourceBufferList.h: Added. * Modules/mediasource/SourceBufferList.idl: Added. New events: * dom/EventNames.h: (WebCore): * dom/EventTarget.h: (WebCore): * dom/EventTargetFactory.in: Object constructors: * page/DOMWindow.idl: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123522 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/CMakeLists.txt | 14 +++ Source/WebCore/ChangeLog | 46 ++++++++ Source/WebCore/DerivedSources.cpp | 4 + Source/WebCore/DerivedSources.make | 4 + Source/WebCore/DerivedSources.pri | 6 + Source/WebCore/GNUmakefile.am | 3 + Source/WebCore/GNUmakefile.list.am | 10 ++ .../Modules/mediasource/SourceBuffer.cpp | 68 +++++++++++ .../Modules/mediasource/SourceBuffer.h | 73 ++++++++++++ .../Modules/mediasource/SourceBuffer.idl | 49 ++++++++ .../Modules/mediasource/SourceBufferList.cpp | 111 ++++++++++++++++++ .../Modules/mediasource/SourceBufferList.h | 86 ++++++++++++++ .../Modules/mediasource/SourceBufferList.idl | 54 +++++++++ Source/WebCore/Target.pri | 9 ++ Source/WebCore/WebCore.gyp/WebCore.gyp | 2 + Source/WebCore/WebCore.gypi | 6 + Source/WebCore/WebCore.vcproj/WebCore.vcproj | 20 ++++ .../WebCore.vcproj/WebCoreCommon.vsprops | 2 +- .../WebCore.vcproj/copyForwardingHeaders.cmd | 1 + .../WebCore/WebCore.xcodeproj/project.pbxproj | 21 ++++ Source/WebCore/dom/EventNames.h | 2 + Source/WebCore/dom/EventTarget.h | 1 + Source/WebCore/dom/EventTargetFactory.in | 1 + Source/WebCore/page/DOMWindow.idl | 3 + 24 files changed, 595 insertions(+), 1 deletion(-) create mode 100644 Source/WebCore/Modules/mediasource/SourceBuffer.cpp create mode 100644 Source/WebCore/Modules/mediasource/SourceBuffer.h create mode 100644 Source/WebCore/Modules/mediasource/SourceBuffer.idl create mode 100644 Source/WebCore/Modules/mediasource/SourceBufferList.cpp create mode 100644 Source/WebCore/Modules/mediasource/SourceBufferList.h create mode 100644 Source/WebCore/Modules/mediasource/SourceBufferList.idl diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index 352b54e6d3d..28b69e3a54a 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -2636,6 +2636,20 @@ SET(WebCoreTestSupport_SOURCES testing/InternalSettings.cpp ) +IF (ENABLE_MEDIA_SOURCE) + LIST(APPEND WebCore_INCLUDE_DIRECTORIES + ${WEBCORE_DIR}/Modules/mediasource + ) + LIST(APPEND WebCore_IDL_FILES + Modules/mediasource/SourceBuffer.idl + Modules/mediasource/SourceBufferList.idl + ) + LIST(APPEND WebCore_SOURCES + Modules/mediasource/SourceBuffer.cpp + Modules/mediasource/SourceBufferList.cpp + ) +ENDIF() + # Modules that the bindings generator scripts may use SET(SCRIPTS_RESOLVE_SUPPLEMENTAL ${WEBCORE_DIR}/bindings/scripts/IDLParser.pm diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 3796872368c..310ea45633e 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,49 @@ +2012-07-24 Anna Cavender + + Create SourceBuffer and SourceBufferList objects + https://bugs.webkit.org/show_bug.cgi?id=91771 + + Reviewed by Eric Carlson. + + SourceBuffer and SourceBufferList objects are needed in order to + implement the new object-oriented MediaSource API: + http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html + + No new tests - will be able to test after landing BUGWK91775 + + Adding new files to build files: + * CMakeLists.txt: + * DerivedSources.cpp: + * DerivedSources.make: + * DerivedSources.pri: + * GNUmakefile.am: + * GNUmakefile.list.am: + * Target.pri: + * WebCore.gyp/WebCore.gyp: + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.vcproj/WebCoreCommon.vsprops: + * WebCore.vcproj/copyForwardingHeaders.cmd: + * WebCore.xcodeproj/project.pbxproj: + + New objects: + * Modules/mediasource/SourceBuffer.cpp: Added. + * Modules/mediasource/SourceBuffer.h: Added. + * Modules/mediasource/SourceBuffer.idl: Added. + * Modules/mediasource/SourceBufferList.cpp: Added. + * Modules/mediasource/SourceBufferList.h: Added. + * Modules/mediasource/SourceBufferList.idl: Added. + + New events: + * dom/EventNames.h: + (WebCore): + * dom/EventTarget.h: + (WebCore): + * dom/EventTargetFactory.in: + + Object constructors: + * page/DOMWindow.idl: + 2012-07-24 Patrick Gansterer Store the full year in GregorianDateTime diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp index a4d374152ec..608386a5049 100644 --- a/Source/WebCore/DerivedSources.cpp +++ b/Source/WebCore/DerivedSources.cpp @@ -280,6 +280,10 @@ #include "JSShadowRoot.cpp" #include "JSSharedWorker.cpp" #include "JSSharedWorkerContext.cpp" +#if ENABLE(MEDIA_SOURCE) +#include "JSSourceBuffer.cpp" +#include "JSSourceBufferList.cpp" +#endif #include "JSSQLError.cpp" #include "JSSQLException.cpp" #include "JSSQLResultSet.cpp" diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make index 50e630af211..70c946dabaf 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -31,6 +31,7 @@ VPATH = \ $(WebCore)/Modules/filesystem \ $(WebCore)/Modules/geolocation \ $(WebCore)/Modules/indexeddb \ + $(WebCore)/Modules/mediasource \ $(WebCore)/Modules/notifications \ $(WebCore)/Modules/quota \ $(WebCore)/Modules/webaudio \ @@ -105,6 +106,8 @@ BINDING_IDLS = \ $(WebCore)/Modules/indexeddb/IDBVersionChangeEvent.idl \ $(WebCore)/Modules/indexeddb/IDBVersionChangeRequest.idl \ $(WebCore)/Modules/indexeddb/WorkerContextIndexedDatabase.idl \ + $(WebCore)/Modules/mediasource/SourceBuffer.idl \ + $(WebCore)/Modules/mediasource/SourceBufferList.idl \ $(WebCore)/Modules/notifications/DOMWindowNotifications.idl \ $(WebCore)/Modules/notifications/Notification.idl \ $(WebCore)/Modules/notifications/NotificationCenter.idl \ @@ -946,6 +949,7 @@ IDL_INCLUDES = \ $(WebCore)/fileapi \ $(WebCore)/html \ $(WebCore)/css \ + $(WebCore)/Modules/mediasource \ $(WebCore)/Modules/notifications \ $(WebCore)/page \ $(WebCore)/xml \ diff --git a/Source/WebCore/DerivedSources.pri b/Source/WebCore/DerivedSources.pri index 97178edf742..f29faeb7d2c 100644 --- a/Source/WebCore/DerivedSources.pri +++ b/Source/WebCore/DerivedSources.pri @@ -620,6 +620,12 @@ contains(DEFINES, ENABLE_VIDEO_TRACK=1) { $$PWD/html/track/TrackEvent.idl \ } +contains(DEFINES, ENABLE_MEDIA_SOURCE=1) { + IDL_BINDINGS += \ + $$PWD/Modules/mediasource/SourceBuffer.idl \ + $$PWD/Modules/mediasource/SourceBufferList.idl +} + mathmlnames.output = MathMLNames.cpp mathmlnames.input = MATHML_NAMES mathmlnames.depends = $$PWD/mathml/mathattrs.in diff --git a/Source/WebCore/GNUmakefile.am b/Source/WebCore/GNUmakefile.am index 5871c6bcb35..a86da73a252 100644 --- a/Source/WebCore/GNUmakefile.am +++ b/Source/WebCore/GNUmakefile.am @@ -15,6 +15,7 @@ webcore_cppflags += \ -I$(srcdir)/Source/WebCore/Modules/gamepad \ -I$(srcdir)/Source/WebCore/Modules/geolocation \ -I$(srcdir)/Source/WebCore/Modules/indexeddb \ + -I$(srcdir)/Source/WebCore/Modules/mediasource \ -I$(srcdir)/Source/WebCore/Modules/mediastream \ -I$(srcdir)/Source/WebCore/Modules/notifications \ -I$(srcdir)/Source/WebCore/Modules/protocolhandler \ @@ -881,6 +882,7 @@ IDL_PATH := \ $(WebCore)/Modules/gamepad \ $(WebCore)/Modules/geolocation \ $(WebCore)/Modules/indexeddb \ + $(WebCore)/Modules/mediasource \ $(WebCore)/Modules/mediastream \ $(WebCore)/Modules/notifications \ $(WebCore)/Modules/webaudio \ @@ -1049,6 +1051,7 @@ EXTRA_DIST += \ $(shell ls $(srcdir)/Source/WebCore/Modules/gamepad/*.idl) \ $(shell ls $(srcdir)/Source/WebCore/Modules/geolocation/*.idl) \ $(shell ls $(srcdir)/Source/WebCore/Modules/indexeddb/*.idl) \ + $(shell ls $(srcdir)/Source/WebCore/Modules/mediasource/*.idl) \ $(shell ls $(srcdir)/Source/WebCore/Modules/mediastream/*.idl) \ $(shell ls $(srcdir)/Source/WebCore/Modules/notifications/*.idl) \ $(shell ls $(srcdir)/Source/WebCore/Modules/protocolhandler/*.idl) \ diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index 873acbcd9e0..5f1c47b2c81 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -507,6 +507,10 @@ webcore_built_sources += \ DerivedSources/WebCore/JSSharedWorker.h \ DerivedSources/WebCore/JSSignalingCallback.cpp \ DerivedSources/WebCore/JSSignalingCallback.h \ + DerivedSources/WebCore/JSSourceBuffer.cpp \ + DerivedSources/WebCore/JSSourceBuffer.h \ + DerivedSources/WebCore/JSSourceBufferList.cpp \ + DerivedSources/WebCore/JSSourceBufferList.h \ DerivedSources/WebCore/JSSpeechInputEvent.cpp \ DerivedSources/WebCore/JSSpeechInputEvent.h \ DerivedSources/WebCore/JSSpeechInputResult.cpp \ @@ -696,6 +700,8 @@ dom_binding_idls += \ $(WebCore)/Modules/geolocation/PositionCallback.idl \ $(WebCore)/Modules/geolocation/PositionError.idl \ $(WebCore)/Modules/geolocation/PositionErrorCallback.idl \ + $(WebCore)/Modules/mediasource/SourceBuffer.idl \ + $(WebCore)/Modules/mediasource/SourceBufferList.idl \ $(WebCore)/Modules/mediastream/DeprecatedPeerConnection.idl \ $(WebCore)/Modules/mediastream/DOMWindowMediaStream.idl \ $(WebCore)/Modules/mediastream/IceCallback.idl \ @@ -1165,6 +1171,10 @@ webcore_modules_sources += \ Source/WebCore/Modules/indexeddb/PageGroupIndexedDatabase.h \ Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.cpp \ Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.h \ + Source/WebCore/Modules/mediasource/SourceBuffer.cpp \ + Source/WebCore/Modules/mediasource/SourceBuffer.h \ + Source/WebCore/Modules/mediasource/SourceBufferList.cpp \ + Source/WebCore/Modules/mediasource/SourceBufferList.h \ Source/WebCore/Modules/mediastream/DeprecatedPeerConnection.cpp \ Source/WebCore/Modules/mediastream/DeprecatedPeerConnection.h \ Source/WebCore/Modules/mediastream/IceCallback.h \ diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp new file mode 100644 index 00000000000..7b368216a62 --- /dev/null +++ b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp @@ -0,0 +1,68 @@ +/* + * 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 "SourceBuffer.h" + +#if ENABLE(MEDIA_SOURCE) + +#include "TimeRanges.h" +#include + +namespace WebCore { + +SourceBuffer::SourceBuffer(const String& id) + : m_id(id) +{ +} + +SourceBuffer::~SourceBuffer() +{ +} + +PassRefPtr SourceBuffer::buffered(ExceptionCode&) const +{ + // FIXME(91773): return buffered data from media source. + return 0; +} + +void SourceBuffer::append(PassRefPtr, ExceptionCode&) +{ + // FIXME(91773): append the data to the media source. +} + +void SourceBuffer::abort(ExceptionCode&) +{ + // FIXME(91773): signal the media source to abort this source buffer. +} + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.h b/Source/WebCore/Modules/mediasource/SourceBuffer.h new file mode 100644 index 00000000000..0cbff3e13fd --- /dev/null +++ b/Source/WebCore/Modules/mediasource/SourceBuffer.h @@ -0,0 +1,73 @@ +/* + * 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 SourceBuffer_h +#define SourceBuffer_h + +#if ENABLE(MEDIA_SOURCE) + +#include "ExceptionCode.h" +#include +#include +#include + +namespace WebCore { + +class TimeRanges; + +class SourceBuffer : public RefCounted { +public: + static PassRefPtr create(const String& id) + { + return adoptRef(new SourceBuffer(id)); + } + + virtual ~SourceBuffer(); + + PassRefPtr buffered(ExceptionCode&) const; + + void append(PassRefPtr data, ExceptionCode&); + + void abort(ExceptionCode&); + + const String& id() const { return m_id; } + + void clear() { } + +private: + explicit SourceBuffer(const String& id); + + String m_id; +}; + +} // namespace WebCore + +#endif +#endif diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.idl b/Source/WebCore/Modules/mediasource/SourceBuffer.idl new file mode 100644 index 00000000000..412b9cb618f --- /dev/null +++ b/Source/WebCore/Modules/mediasource/SourceBuffer.idl @@ -0,0 +1,49 @@ +/* + * 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. + */ + +module html { + + interface [ + Conditional=MEDIA_SOURCE, + V8EnabledAtRuntime=mediaSource + ] SourceBuffer { + + // Returns the time ranges buffered. + readonly attribute TimeRanges buffered + getter raises(DOMException); + + // Append segment data. + void append(in Uint8Array data) raises (DOMException); + + // Abort the current segment append sequence. + void abort() raises (DOMException); + }; + +} diff --git a/Source/WebCore/Modules/mediasource/SourceBufferList.cpp b/Source/WebCore/Modules/mediasource/SourceBufferList.cpp new file mode 100644 index 00000000000..3cc467831f5 --- /dev/null +++ b/Source/WebCore/Modules/mediasource/SourceBufferList.cpp @@ -0,0 +1,111 @@ +/* + * 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 "SourceBufferList.h" + +#if ENABLE(MEDIA_SOURCE) + +#include "Event.h" + +namespace WebCore { + +SourceBufferList::SourceBufferList(ScriptExecutionContext* context) + : m_scriptExecutionContext(context) +{ +} + +unsigned long SourceBufferList::length() const +{ + return m_list.size(); +} + +SourceBuffer* SourceBufferList::item(unsigned index) const +{ + if (index >= m_list.size()) + return 0; + return m_list[index].get(); +} + +void SourceBufferList::add(PassRefPtr buffer) +{ + m_list.append(buffer); + createAndFireEvent(eventNames().webkitaddsourcebufferEvent); +} + +bool SourceBufferList::remove(SourceBuffer* buffer) +{ + size_t index = m_list.find(buffer); + if (index == notFound) + return false; + + m_list.remove(index); + buffer->clear(); + createAndFireEvent(eventNames().webkitremovesourcebufferEvent); + return true; +} + +void SourceBufferList::clear() +{ + for (size_t i = 0; i < m_list.size(); ++i) + remove(m_list[i].get()); +} + +void SourceBufferList::createAndFireEvent(const AtomicString& eventName) +{ + RefPtr event = Event::create(eventName, false, false); + event->setTarget(this); + + EventTarget::dispatchEvent(event); +} + +const AtomicString& SourceBufferList::interfaceName() const +{ + return eventNames().interfaceForSourceBufferList; +} + +ScriptExecutionContext* SourceBufferList::scriptExecutionContext() const +{ + return m_scriptExecutionContext; +} + +EventTargetData* SourceBufferList::eventTargetData() +{ + return &m_eventTargetData; +} + +EventTargetData* SourceBufferList::ensureEventTargetData() +{ + return &m_eventTargetData; +} + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/Modules/mediasource/SourceBufferList.h b/Source/WebCore/Modules/mediasource/SourceBufferList.h new file mode 100644 index 00000000000..7e9f8315271 --- /dev/null +++ b/Source/WebCore/Modules/mediasource/SourceBufferList.h @@ -0,0 +1,86 @@ +/* + * 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 SourceBufferList_h +#define SourceBufferList_h + +#if ENABLE(MEDIA_SOURCE) + +#include "EventTarget.h" +#include "SourceBuffer.h" +#include +#include + +namespace WebCore { + +class SourceBufferList : public RefCounted, public EventTarget { +public: + static PassRefPtr create(ScriptExecutionContext* context) + { + return adoptRef(new SourceBufferList(context)); + } + virtual ~SourceBufferList() { } + + unsigned long length() const; + SourceBuffer* item(unsigned index) const; + + void add(PassRefPtr); + bool remove(SourceBuffer*); + void clear(); + + // EventTarget interface + virtual const AtomicString& interfaceName() const OVERRIDE; + virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; + + using RefCounted::ref; + using RefCounted::deref; + +protected: + virtual EventTargetData* eventTargetData() OVERRIDE; + virtual EventTargetData* ensureEventTargetData() OVERRIDE; + +private: + explicit SourceBufferList(ScriptExecutionContext*); + + void createAndFireEvent(const AtomicString&); + + virtual void refEventTarget() OVERRIDE { ref(); } + virtual void derefEventTarget() OVERRIDE { deref(); } + + EventTargetData m_eventTargetData; + ScriptExecutionContext* m_scriptExecutionContext; + + Vector > m_list; +}; + +} // namespace WebCore + +#endif +#endif diff --git a/Source/WebCore/Modules/mediasource/SourceBufferList.idl b/Source/WebCore/Modules/mediasource/SourceBufferList.idl new file mode 100644 index 00000000000..39eddcaa8f5 --- /dev/null +++ b/Source/WebCore/Modules/mediasource/SourceBufferList.idl @@ -0,0 +1,54 @@ +/* + * 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. + */ + +module html { + + interface [ + Conditional=MEDIA_SOURCE, + V8EnabledAtRuntime=mediaSource, + IndexedGetter, + EventTarget, + CallWith=ScriptExecutionContext + ] SourceBufferList { + readonly attribute unsigned long length; + SourceBuffer item(in unsigned long index); + + // EventTarget interface + void addEventListener(in DOMString type, + in EventListener listener, + in [Optional] boolean useCapture); + void removeEventListener(in DOMString type, + in EventListener listener, + in [Optional] boolean useCapture); + boolean dispatchEvent(in Event event) + raises(EventException); + }; + +} diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index d867195169c..ebc3b597f32 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -3008,6 +3008,15 @@ contains(DEFINES, ENABLE_FILE_SYSTEM=1) { platform/AsyncFileSystem.cpp } +contains(DEFINES, ENABLE_MEDIA_SOURCE=1) { + HEADERS += \ + Modules/mediasource/SourceBuffer.h \ + Modules/mediasource/SourceBufferList.h + SOURCES += \ + Modules/mediasource/SourceBuffer.cpp \ + Modules/mediasource/SourceBufferList.cpp +} + contains(DEFINES, ENABLE_ICONDATABASE=1) { SOURCES += \ loader/icon/IconDatabase.cpp \ diff --git a/Source/WebCore/WebCore.gyp/WebCore.gyp b/Source/WebCore/WebCore.gyp/WebCore.gyp index 31e206c64d1..dfb9ffac65b 100644 --- a/Source/WebCore/WebCore.gyp/WebCore.gyp +++ b/Source/WebCore/WebCore.gyp/WebCore.gyp @@ -60,6 +60,7 @@ '../Modules/geolocation', '../Modules/intents', '../Modules/indexeddb', + '../Modules/mediasource', '../Modules/mediastream', '../Modules/notifications', '../Modules/protocolhandler', @@ -1078,6 +1079,7 @@ '--include', '../Modules/filesystem', '--include', '../Modules/indexeddb', '--include', '../Modules/intents', + '--include', '../Modules/mediasource', '--include', '../Modules/mediastream', '--include', '../Modules/notifications', '--include', '../Modules/protocolhandler', diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index 2fe39e2a370..040d8f73bcb 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -828,6 +828,8 @@ 'Modules/intents/Intent.idl', 'Modules/intents/IntentResultCallback.idl', 'Modules/intents/NavigatorIntents.idl', + 'Modules/mediasource/SourceBuffer.idl', + 'Modules/mediasource/SourceBufferList.idl', 'Modules/mediastream/DeprecatedPeerConnection.idl', 'Modules/mediastream/DOMWindowMediaStream.idl', 'Modules/mediastream/IceCallback.idl', @@ -1540,6 +1542,10 @@ 'Modules/intents/IntentResultCallback.h', 'Modules/intents/NavigatorIntents.cpp', 'Modules/intents/NavigatorIntents.h', + 'Modules/mediasource/SourceBuffer.cpp', + 'Modules/mediasource/SourceBuffer.h', + 'Modules/mediasource/SourceBufferList.cpp', + 'Modules/mediasource/SourceBufferList.h', 'Modules/mediastream/DeprecatedPeerConnection.cpp', 'Modules/mediastream/DeprecatedPeerConnection.h', 'Modules/mediastream/IceCallback.h', diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index 8f48353e0a4..a3fe36d6156 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -25082,6 +25082,26 @@ > + + + + + + + + + + diff --git a/Source/WebCore/WebCore.vcproj/WebCoreCommon.vsprops b/Source/WebCore/WebCore.vcproj/WebCoreCommon.vsprops index 12e87676c87..15aa9bf0a87 100644 --- a/Source/WebCore/WebCore.vcproj/WebCoreCommon.vsprops +++ b/Source/WebCore/WebCore.vcproj/WebCoreCommon.vsprops @@ -7,7 +7,7 @@ >