Diff
Modified: trunk/Source/WebCore/ChangeLog (158269 => 158270)
--- trunk/Source/WebCore/ChangeLog 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/ChangeLog 2013-10-30 15:53:49 UTC (rev 158270)
@@ -1,3 +1,36 @@
+2013-10-30 Jer Noble <jer.no...@apple.com>
+
+ [MSE] Make MediaSourcePrivate, SourceBufferPrivate classes RefCounted.
+ https://bugs.webkit.org/show_bug.cgi?id=123350
+
+ Reviewed by Darin Adler.
+
+ Make the MediaSourcePrivate and SourceBufferPrivate classes RefCounted so that
+ they can be referenced both by MediaSource/SourceBuffer, and by the MediaPlayerPrivate
+ which creates them.
+
+ Change OwnPtr -> RefPtr everywhere:
+ * Modules/mediasource/MediaSource.cpp:
+ (WebCore::MediaSource::addSourceBuffer):
+ * Modules/mediasource/MediaSourceBase.cpp:
+ (WebCore::MediaSourceBase::setPrivateAndOpen):
+ (WebCore::MediaSourceBase::createSourceBufferPrivate):
+ * Modules/mediasource/MediaSourceBase.h:
+ * Modules/mediasource/SourceBuffer.cpp:
+ (WebCore::SourceBuffer::create):
+ (WebCore::SourceBuffer::SourceBuffer):
+ * Modules/mediasource/SourceBuffer.h:
+ * Modules/mediasource/WebKitMediaSource.cpp:
+ (WebCore::WebKitMediaSource::addSourceBuffer):
+ * Modules/mediasource/WebKitSourceBuffer.cpp:
+ (WebCore::WebKitSourceBuffer::create):
+ (WebCore::WebKitSourceBuffer::WebKitSourceBuffer):
+ * Modules/mediasource/WebKitSourceBuffer.h:
+ * html/HTMLMediaSource.h:
+ * platform/graphics/MediaSourcePrivate.h:
+ * platform/graphics/SourceBufferPrivate.h:
+ (WebCore::SourceBufferPrivate::SourceBufferPrivate):
+
2013-10-30 Allan Sandfeld Jensen <allan.jen...@digia.com>
Remove unused runtime enabled
Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp 2013-10-30 15:53:49 UTC (rev 158270)
@@ -96,7 +96,7 @@
// 5. Create a new SourceBuffer object and associated resources.
ContentType contentType(type);
Vector<String> codecs = contentType.codecs();
- OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType.type(), codecs, ec);
+ RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec);
if (!sourceBufferPrivate) {
ASSERT(ec == NOT_SUPPORTED_ERR || ec == QUOTA_EXCEEDED_ERR);
@@ -105,7 +105,7 @@
return 0;
}
- RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.release(), this);
+ RefPtr<SourceBuffer> buffer = SourceBuffer::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);
Modified: trunk/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp 2013-10-30 15:53:49 UTC (rev 158270)
@@ -75,12 +75,11 @@
return ended;
}
-void MediaSourceBase::setPrivateAndOpen(PassOwnPtr<MediaSourcePrivate> mediaSourcePrivate)
+void MediaSourceBase::setPrivateAndOpen(PassRef<MediaSourcePrivate> mediaSourcePrivate)
{
- ASSERT(mediaSourcePrivate);
ASSERT(!m_private);
ASSERT(m_attached);
- m_private = mediaSourcePrivate;
+ m_private = std::move(mediaSourcePrivate);
setReadyState(openKeyword());
}
@@ -257,12 +256,12 @@
m_private.clear();
}
-PassOwnPtr<SourceBufferPrivate> MediaSourceBase::createSourceBufferPrivate(const String& type, const MediaSourcePrivate::CodecsArray& codecs, ExceptionCode& ec)
+RefPtr<SourceBufferPrivate> MediaSourceBase::createSourceBufferPrivate(const ContentType& type, ExceptionCode& ec)
{
- OwnPtr<SourceBufferPrivate> sourceBufferPrivate;
- switch (m_private->addSourceBuffer(type, codecs, &sourceBufferPrivate)) {
+ RefPtr<SourceBufferPrivate> sourceBufferPrivate;
+ switch (m_private->addSourceBuffer(type, sourceBufferPrivate)) {
case MediaSourcePrivate::Ok: {
- return sourceBufferPrivate.release();
+ return sourceBufferPrivate;
}
case MediaSourcePrivate::NotSupported:
// 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
Modified: trunk/Source/WebCore/Modules/mediasource/MediaSourceBase.h (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/MediaSourceBase.h 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSourceBase.h 2013-10-30 15:53:49 UTC (rev 158270)
@@ -62,7 +62,7 @@
// HTMLMediaSource
virtual bool attachToElement() OVERRIDE;
- virtual void setPrivateAndOpen(PassOwnPtr<MediaSourcePrivate>) OVERRIDE;
+ virtual void setPrivateAndOpen(PassRef<MediaSourcePrivate>) OVERRIDE;
virtual void close() OVERRIDE;
virtual bool isClosed() const OVERRIDE;
virtual double duration() const OVERRIDE;
@@ -97,12 +97,12 @@
virtual void onReadyStateChange(const AtomicString& oldState, const AtomicString& newState) = 0;
virtual Vector<RefPtr<TimeRanges>> activeRanges() const = 0;
- PassOwnPtr<SourceBufferPrivate> createSourceBufferPrivate(const String& type, const MediaSourcePrivate::CodecsArray&, ExceptionCode&);
+ RefPtr<SourceBufferPrivate> createSourceBufferPrivate(const ContentType&, ExceptionCode&);
void scheduleEvent(const AtomicString& eventName);
GenericEventQueue& asyncEventQueue() { return m_asyncEventQueue; }
private:
- OwnPtr<MediaSourcePrivate> m_private;
+ RefPtr<MediaSourcePrivate> m_private;
AtomicString m_readyState;
GenericEventQueue m_asyncEventQueue;
bool m_attached;
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2013-10-30 15:53:49 UTC (rev 158270)
@@ -42,16 +42,16 @@
namespace WebCore {
-PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, MediaSource* source)
+PassRef<SourceBuffer> SourceBuffer::create(PassRef<SourceBufferPrivate> sourceBufferPrivate, MediaSource* source)
{
- RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(sourceBufferPrivate, source)));
+ RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(std::move(sourceBufferPrivate), source)));
sourceBuffer->suspendIfNeeded();
- return sourceBuffer.release();
+ return sourceBuffer.releaseNonNull();
}
-SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, MediaSource* source)
+SourceBuffer::SourceBuffer(PassRef<SourceBufferPrivate> sourceBufferPrivate, MediaSource* source)
: ActiveDOMObject(source->scriptExecutionContext())
- , m_private(sourceBufferPrivate)
+ , m_private(std::move(sourceBufferPrivate))
, m_source(source)
, m_asyncEventQueue(*this)
, m_updating(false)
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h 2013-10-30 15:53:49 UTC (rev 158270)
@@ -51,7 +51,7 @@
class SourceBuffer FINAL : public RefCounted<SourceBuffer>, public ActiveDOMObject, public EventTargetWithInlineData, public ScriptWrappable {
public:
- static PassRefPtr<SourceBuffer> create(PassOwnPtr<SourceBufferPrivate>, MediaSource*);
+ static PassRef<SourceBuffer> create(PassRef<SourceBufferPrivate>, MediaSource*);
virtual ~SourceBuffer();
@@ -84,7 +84,7 @@
virtual void derefEventTarget() OVERRIDE { deref(); }
private:
- SourceBuffer(PassOwnPtr<SourceBufferPrivate>, MediaSource*);
+ SourceBuffer(PassRef<SourceBufferPrivate>, MediaSource*);
bool isRemoved() const;
void scheduleEvent(const AtomicString& eventName);
@@ -92,7 +92,7 @@
void appendBufferInternal(unsigned char*, unsigned, ExceptionCode&);
void appendBufferTimerFired(Timer<SourceBuffer>*);
- OwnPtr<SourceBufferPrivate> m_private;
+ RefPtr<SourceBufferPrivate> m_private;
MediaSource* m_source;
GenericEventQueue m_asyncEventQueue;
Modified: trunk/Source/WebCore/Modules/mediasource/WebKitMediaSource.cpp (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/WebKitMediaSource.cpp 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/WebKitMediaSource.cpp 2013-10-30 15:53:49 UTC (rev 158270)
@@ -47,7 +47,7 @@
{
RefPtr<WebKitMediaSource> mediaSource(adoptRef(new WebKitMediaSource(context)));
mediaSource->suspendIfNeeded();
- return mediaSource.release();
+ return mediaSource.releaseNonNull();
}
WebKitMediaSource::WebKitMediaSource(ScriptExecutionContext* context)
@@ -96,11 +96,11 @@
// 5. Create a new SourceBuffer object and associated resources.
ContentType contentType(type);
Vector<String> codecs = contentType.codecs();
- OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType.type(), codecs, ec);
+ RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec);
if (!sourceBufferPrivate)
return 0;
- RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferPrivate.release(), this);
+ 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);
Modified: trunk/Source/WebCore/Modules/mediasource/WebKitSourceBuffer.cpp (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/WebKitSourceBuffer.cpp 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/WebKitSourceBuffer.cpp 2013-10-30 15:53:49 UTC (rev 158270)
@@ -40,14 +40,14 @@
namespace WebCore {
-PassRefPtr<WebKitSourceBuffer> WebKitSourceBuffer::create(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, PassRefPtr<WebKitMediaSource> source)
+PassRef<WebKitSourceBuffer> WebKitSourceBuffer::create(PassRef<SourceBufferPrivate> sourceBufferPrivate, PassRef<WebKitMediaSource> source)
{
- return adoptRef(new WebKitSourceBuffer(sourceBufferPrivate, source));
+ return adoptRef(*new WebKitSourceBuffer(std::move(sourceBufferPrivate), std::move(source)));
}
-WebKitSourceBuffer::WebKitSourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, PassRefPtr<WebKitMediaSource> source)
- : m_private(sourceBufferPrivate)
- , m_source(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);
Modified: trunk/Source/WebCore/Modules/mediasource/WebKitSourceBuffer.h (158269 => 158270)
--- trunk/Source/WebCore/Modules/mediasource/WebKitSourceBuffer.h 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/Modules/mediasource/WebKitSourceBuffer.h 2013-10-30 15:53:49 UTC (rev 158270)
@@ -47,7 +47,7 @@
class WebKitSourceBuffer : public RefCounted<WebKitSourceBuffer>, public ScriptWrappable {
public:
- static PassRefPtr<WebKitSourceBuffer> create(PassOwnPtr<SourceBufferPrivate>, PassRefPtr<WebKitMediaSource>);
+ static PassRef<WebKitSourceBuffer> create(PassRef<SourceBufferPrivate>, PassRef<WebKitMediaSource>);
virtual ~WebKitSourceBuffer();
@@ -61,11 +61,11 @@
void removedFromMediaSource();
private:
- WebKitSourceBuffer(PassOwnPtr<SourceBufferPrivate>, PassRefPtr<WebKitMediaSource>);
+ WebKitSourceBuffer(PassRef<SourceBufferPrivate>, PassRef<WebKitMediaSource>);
bool isRemoved() const;
- OwnPtr<SourceBufferPrivate> m_private;
+ RefPtr<SourceBufferPrivate> m_private;
RefPtr<WebKitMediaSource> m_source;
double m_timestampOffset;
Modified: trunk/Source/WebCore/html/HTMLMediaSource.h (158269 => 158270)
--- trunk/Source/WebCore/html/HTMLMediaSource.h 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/html/HTMLMediaSource.h 2013-10-30 15:53:49 UTC (rev 158270)
@@ -53,7 +53,7 @@
// 'closed' state, and returns true to indicate attachment success.
// Reattachment allowed by first calling close() (even if already in 'closed').
virtual bool attachToElement() = 0;
- virtual void setPrivateAndOpen(PassOwnPtr<MediaSourcePrivate>) = 0;
+ virtual void setPrivateAndOpen(PassRef<MediaSourcePrivate>) = 0;
virtual void close() = 0;
virtual bool isClosed() const = 0;
virtual double duration() const = 0;
Modified: trunk/Source/WebCore/platform/graphics/MediaSourcePrivate.h (158269 => 158270)
--- trunk/Source/WebCore/platform/graphics/MediaSourcePrivate.h 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/platform/graphics/MediaSourcePrivate.h 2013-10-30 15:53:49 UTC (rev 158270)
@@ -33,20 +33,23 @@
#if ENABLE(MEDIA_SOURCE)
#include <wtf/Forward.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
namespace WebCore {
+class ContentType;
class SourceBufferPrivate;
-class MediaSourcePrivate {
+class MediaSourcePrivate : public RefCounted<MediaSourcePrivate> {
public:
- typedef Vector<String, 0> CodecsArray;
+ typedef Vector<String> CodecsArray;
MediaSourcePrivate() { }
virtual ~MediaSourcePrivate() { }
enum AddStatus { Ok, NotSupported, ReachedIdLimit };
- virtual AddStatus addSourceBuffer(const String& type, const CodecsArray&, OwnPtr<SourceBufferPrivate>*) = 0;
+ virtual AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) = 0;
virtual double duration() = 0;
virtual void setDuration(double) = 0;
enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h (158269 => 158270)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h 2013-10-30 15:50:58 UTC (rev 158269)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h 2013-10-30 15:53:49 UTC (rev 158270)
@@ -33,12 +33,12 @@
#if ENABLE(MEDIA_SOURCE)
#include "TimeRanges.h"
+#include <wtf/RefCounted.h>
namespace WebCore {
-class SourceBufferPrivate {
+class SourceBufferPrivate : public RefCounted<SourceBufferPrivate> {
public:
- SourceBufferPrivate() { }
virtual ~SourceBufferPrivate() { }
virtual PassRefPtr<TimeRanges> buffered() = 0;