Changeset 223596 in webkit
- Timestamp:
- Oct 18, 2017 1:30:13 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r223590 r223596 1 2017-10-18 Zan Dobersek <zdobersek@igalia.com> 2 3 [MSE] Move SourceBuffer's pending append data into the platform implementations 4 https://bugs.webkit.org/show_bug.cgi?id=178003 5 6 Reviewed by Jer Noble. 7 8 In SourceBuffer::appendBufferTimerFired(), we can use move semantics to 9 pass the pending append data into the platform layer, where it can then 10 be used more efficiently. 11 12 Resources in the m_pendingAppendData member are moved into the append() 13 call on the SourceBufferPrivate object. The m_pendingAppendData is still 14 cleared out manually in case the underlying implementation doesn't clear 15 it out through a move operation. The SourceBufferPrivate interface is 16 updated to accept a Vector rvalue reference as the only parameter of the 17 append() method. 18 19 For the GStreamer implementation, signature of the append() method in 20 MediaSourceClientGStreamerMSE class is also updated. The implementation 21 now moves the Vector resources over to a on-heap Vector object that is 22 then wrapped into a GstBuffer object by using the 23 gst_buffer_new_wrapped_full() API and specifying the custom deleter. 24 25 The AVFoundation implementation of SourceBufferPrivate is only updated 26 to reflect the changes in the interface. The Vector data that is passed 27 in is still copied into the NSData allocation. 28 29 MockSourceBufferPrivate is also updated, with the append data still 30 being copied into the m_inputBuffer Vector. 31 32 No new tests -- no change in behavior. 33 34 * Modules/mediasource/SourceBuffer.cpp: 35 (WebCore::SourceBuffer::appendBufferTimerFired): 36 * platform/graphics/SourceBufferPrivate.h: 37 * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: 38 * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: 39 (WebCore::SourceBufferPrivateAVFObjC::append): 40 * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp: 41 (WebCore::MediaSourceClientGStreamerMSE::append): 42 * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.h: 43 * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp: 44 (WebCore::SourceBufferPrivateGStreamer::append): 45 * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h: 46 * platform/mock/mediasource/MockSourceBufferPrivate.cpp: 47 (WebCore::MockSourceBufferPrivate::append): 48 * platform/mock/mediasource/MockSourceBufferPrivate.h: 49 1 50 2017-10-17 Zalan Bujtas <zalan@apple.com> 2 51 -
trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp
r223029 r223596 559 559 } 560 560 561 m_private->append(m_pendingAppendData.data(), m_pendingAppendData.size()); 561 // Manually clear out the m_pendingAppendData Vector, in case the platform implementation 562 // rejects appending the buffer for whatever reason. 563 // FIXME: The implementation should guarantee the move from this Vector, and we should 564 // assert here to confirm that. See https://bugs.webkit.org/show_bug.cgi?id=178003. 565 m_private->append(WTFMove(m_pendingAppendData)); 562 566 m_pendingAppendData.clear(); 563 567 } -
trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h
r210319 r223596 47 47 virtual void setClient(SourceBufferPrivateClient*) = 0; 48 48 49 virtual void append( const unsigned char* data, unsigned length) = 0;49 virtual void append(Vector<unsigned char>&&) = 0; 50 50 virtual void abort() = 0; 51 51 virtual void resetParserState() = 0; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
r222422 r223596 130 130 // SourceBufferPrivate overrides 131 131 void setClient(SourceBufferPrivateClient*) final; 132 void append( const unsigned char* data, unsigned length) final;132 void append(Vector<unsigned char>&&) final; 133 133 void abort() final; 134 134 void resetParserState() final; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
r223476 r223596 670 670 } 671 671 672 void SourceBufferPrivateAVFObjC::append(const unsigned char* data, unsigned length) 673 { 674 LOG(MediaSource, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data, length); 675 676 RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data length:length]); 672 void SourceBufferPrivateAVFObjC::append(Vector<unsigned char>&& data) 673 { 674 LOG(MediaSource, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data.data(), data.size()); 675 676 // FIXME: Avoid the data copy by wrapping around the Vector<> object. 677 RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data.data() length:data.size()]); 677 678 WeakPtr<SourceBufferPrivateAVFObjC> weakThis = m_appendWeakFactory.createWeakPtr(*this); 678 679 RetainPtr<AVStreamDataParser> parser = m_parser; -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp
r216702 r223596 125 125 } 126 126 127 bool MediaSourceClientGStreamerMSE::append(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, const unsigned char* data, unsigned length)128 { 129 ASSERT(WTF::isMainThread()); 130 131 GST_DEBUG("Appending %u bytes", length);127 bool MediaSourceClientGStreamerMSE::append(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, Vector<unsigned char>&& data) 128 { 129 ASSERT(WTF::isMainThread()); 130 131 GST_DEBUG("Appending %u bytes", data.size()); 132 132 133 133 if (!m_playerPrivate) … … 138 138 ASSERT(appendPipeline); 139 139 140 void* bufferData = fastMalloc(length); 141 GstBuffer* buffer = gst_buffer_new_wrapped_full(static_cast<GstMemoryFlags>(0), bufferData, length, 0, length, bufferData, fastFree); 142 gst_buffer_fill(buffer, 0, data, length); 140 // Wrap the whole Vector object in case the data is stored in the inlined buffer. 141 auto* bufferData = data.data(); 142 auto bufferLength = data.size(); 143 GstBuffer* buffer = gst_buffer_new_wrapped_full(static_cast<GstMemoryFlags>(0), bufferData, bufferLength, 0, bufferLength, new Vector<unsigned char>(WTFMove(data)), 144 [](gpointer data) 145 { 146 delete static_cast<Vector<unsigned char>*>(data); 147 }); 143 148 144 149 return appendPipeline->pushNewBuffer(buffer) == GST_FLOW_OK; -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.h
r216702 r223596 49 49 void abort(RefPtr<SourceBufferPrivateGStreamer>); 50 50 void resetParserState(RefPtr<SourceBufferPrivateGStreamer>); 51 bool append(RefPtr<SourceBufferPrivateGStreamer>, const unsigned char*, unsigned);51 bool append(RefPtr<SourceBufferPrivateGStreamer>, Vector<unsigned char>&&); 52 52 void removedFromMediaSource(RefPtr<SourceBufferPrivateGStreamer>); 53 53 void flush(AtomicString); -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp
r210319 r223596 67 67 } 68 68 69 void SourceBufferPrivateGStreamer::append( const unsigned char* data, unsigned length)69 void SourceBufferPrivateGStreamer::append(Vector<unsigned char>&& data) 70 70 { 71 71 ASSERT(m_mediaSource); … … 74 74 return; 75 75 76 if (m_client->append(this, data, length))76 if (m_client->append(this, WTFMove(data))) 77 77 return; 78 78 -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h
r222550 r223596 56 56 57 57 void setClient(SourceBufferPrivateClient*) final; 58 void append( const unsigned char*, unsigned) final;58 void append(Vector<unsigned char>&&) final; 59 59 void abort() final; 60 60 void resetParserState() final; -
trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
r210319 r223596 140 140 } 141 141 142 void MockSourceBufferPrivate::append( const unsigned char* data, unsigned length)143 { 144 m_inputBuffer.append (data, length);142 void MockSourceBufferPrivate::append(Vector<unsigned char>&& data) 143 { 144 m_inputBuffer.appendVector(data); 145 145 SourceBufferPrivateClient::AppendResult result = SourceBufferPrivateClient::AppendSucceeded; 146 146 -
trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h
r210319 r223596 58 58 // SourceBufferPrivate overrides 59 59 void setClient(SourceBufferPrivateClient*) final; 60 void append( const unsigned char* data, unsigned length) final;60 void append(Vector<unsigned char>&&) final; 61 61 void abort() final; 62 62 void resetParserState() final;
Note: See TracChangeset
for help on using the changeset viewer.