Change MediaSource WebCore to return NewObject for SourceBuffers
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 16:01:09 +0000 (16:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 16:01:09 +0000 (16:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184642

Patch by Eric Stobbart <ericstobbart@gmail.com> on 2018-04-19
Reviewed by Chris Dumez.

Minor change inline with IDL documentation

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::addSourceBuffer):
(): Deleted.
* Modules/mediasource/MediaSource.h:
* Modules/mediasource/MediaSource.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230805 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/MediaSource.h
Source/WebCore/Modules/mediasource/MediaSource.idl

index 86a14ac..3accd1a 100644 (file)
@@ -1,3 +1,18 @@
+2018-04-19  Eric Stobbart  <ericstobbart@gmail.com>
+
+        Change MediaSource WebCore to return NewObject for SourceBuffers
+        https://bugs.webkit.org/show_bug.cgi?id=184642
+
+        Reviewed by Chris Dumez.
+
+        Minor change inline with IDL documentation
+
+        * Modules/mediasource/MediaSource.cpp:
+        (WebCore::MediaSource::addSourceBuffer):
+        (): Deleted.
+        * Modules/mediasource/MediaSource.h:
+        * Modules/mediasource/MediaSource.idl:
+
 2018-04-19  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Unreviewed, build fix for Ubuntu LTS GCC
index d2349e9..d7afbb3 100644 (file)
@@ -623,7 +623,7 @@ void MediaSource::streamEndedWithError(std::optional<EndOfStreamError> error)
     }
 }
 
-ExceptionOr<SourceBuffer&> MediaSource::addSourceBuffer(const String& type)
+ExceptionOr<Ref<SourceBuffer>> MediaSource::addSourceBuffer(const String& type)
 {
     LOG(MediaSource, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this);
 
@@ -669,14 +669,12 @@ ExceptionOr<SourceBuffer&> MediaSource::addSourceBuffer(const String& type)
     // ↳ Set the mode attribute on the new object to "segments".
     buffer->setMode(shouldGenerateTimestamps ? SourceBuffer::AppendMode::Sequence : SourceBuffer::AppendMode::Segments);
 
-    auto& result = buffer.get();
-
     // 8. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
-    m_sourceBuffers->add(WTFMove(buffer));
+    m_sourceBuffers->add(buffer.copyRef());
     regenerateActiveSourceBuffers();
 
     // 9. Return the new object to the caller.
-    return result;
+    return WTFMove(buffer);
 }
 
 ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
index 204287b..2934657 100644 (file)
@@ -91,7 +91,7 @@ public:
 
     SourceBufferList* sourceBuffers() { return m_sourceBuffers.get(); }
     SourceBufferList* activeSourceBuffers() { return m_activeSourceBuffers.get(); }
-    ExceptionOr<SourceBuffer&> addSourceBuffer(const String& type);
+    ExceptionOr<Ref<SourceBuffer>> addSourceBuffer(const String& type);
     ExceptionOr<void> removeSourceBuffer(SourceBuffer&);
     static bool isTypeSupported(const String& type);
 
index ce9626a..9698969 100644 (file)
@@ -54,7 +54,7 @@ enum ReadyState {
 
     attribute unrestricted double duration;
 
-    [MayThrowException] SourceBuffer addSourceBuffer(DOMString type);
+    [NewObject, MayThrowException] SourceBuffer addSourceBuffer(DOMString type);
     [MayThrowException] void removeSourceBuffer(SourceBuffer buffer);
 
     readonly attribute ReadyState readyState;