Changeset 239921 in webkit
- Timestamp:
- Jan 14, 2019 4:31:13 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239919 r239921 1 2019-01-14 Charlie Turner <cturner@igalia.com> 2 3 [GStreamer] Add sharedBuffer utility to GstMappedBuffer, and a testsuite 4 https://bugs.webkit.org/show_bug.cgi?id=192977 5 6 Reviewed by Carlos Garcia Campos. 7 8 Add a utility method on GstMappedBuffer to return a SharedBuffer 9 view over the mapped data with no copies. 10 11 This patch also introduces a new gstreamer port API test 12 directory, and includes some tests for GstMappedBuffer. 13 14 New tests in the API section. 15 16 * platform/SharedBuffer.cpp: Add a new overload for 17 GstMappedBuffer that allows sharing the mapped GStreamer buffers 18 with zero copies. 19 (WebCore::SharedBuffer::create): 20 (WebCore::SharedBuffer::SharedBuffer): 21 (WebCore::SharedBuffer::DataSegment::data const): 22 (WebCore::SharedBuffer::DataSegment::size const): 23 * platform/SharedBuffer.h: 24 * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp: 25 (webKitWebAudioSrcAllocateBuffersAndRenderAudio): Update to new 26 API. 27 * platform/graphics/gstreamer/GStreamerCommon.cpp: 28 (WebCore::GstMappedBuffer::createSharedBuffer): Return a shared 29 buffer sharing this mapped buffer. The buffer must be shareable to 30 use this method. 31 * platform/graphics/gstreamer/GStreamerCommon.h: 32 (WebCore::GstMappedBuffer::create): Make GstMappedBuffer RefCounted 33 (WebCore::GstMappedBuffer::~GstMappedBuffer): 34 (WebCore::GstMappedBuffer::data): 35 (WebCore::GstMappedBuffer::data const): 36 (WebCore::GstMappedBuffer::size const): 37 (WebCore::GstMappedBuffer::isSharable const): New predicate to 38 check whether this buffer can be shared (i.e., is not writable) 39 (WebCore::GstMappedBuffer::GstMappedBuffer): 40 (WebCore::GstMappedBuffer::operator bool const): Deleted. 41 * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp: 42 (WebCore::InbandTextTrackPrivateGStreamer::notifyTrackOfSample): 43 Update to use new API. 44 * platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h: 45 (WebCore::InitData::InitData): Ditto. 46 * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp: 47 (webKitMediaClearKeyDecryptorFindAndSetKey): Ditto. 48 (webKitMediaClearKeyDecryptorDecrypt): Ditto. 49 * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp: 50 (WebCore::WrappedMockRealtimeAudioSource::render): Ditto. 51 * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp: 52 (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::pullAudioData): Ditto. 53 * platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp: 54 (WebCore::RealtimeOutgoingVideoSourceLibWebRTC::createBlackFrame): Ditto. 55 * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: 56 (WebCore::GStreamerVideoEncoder::Fragmentize): Ditto. 57 1 58 2019-01-14 Karl Leplat <karl.leplat_ext@softathome.com> 2 59 -
trunk/Source/WebCore/platform/SharedBuffer.cpp
r239535 r239921 55 55 } 56 56 57 #if USE(GSTREAMER) 58 Ref<SharedBuffer> SharedBuffer::create(GstMappedBuffer& mappedBuffer) 59 { 60 ASSERT(mappedBuffer.isSharable()); 61 return adoptRef(*new SharedBuffer(mappedBuffer)); 62 } 63 64 SharedBuffer::SharedBuffer(GstMappedBuffer& mappedBuffer) 65 : m_size(mappedBuffer.size()) 66 { 67 m_segments.append({0, DataSegment::create(&mappedBuffer)}); 68 } 69 #endif 70 57 71 RefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath) 58 72 { … … 212 226 [](const GRefPtr<GBytes>& data) { return reinterpret_cast<const char*>(g_bytes_get_data(data.get(), nullptr)); }, 213 227 #endif 228 #if USE(GSTREAMER) 229 [](const RefPtr<GstMappedBuffer>& data) { return reinterpret_cast<const char*>(data->data()); }, 230 #endif 214 231 [](const FileSystem::MappedFileData& data) { return reinterpret_cast<const char*>(data.data()); } 215 232 ); … … 284 301 #if USE(GLIB) 285 302 [](const GRefPtr<GBytes>& data) { return g_bytes_get_size(data.get()); }, 303 #endif 304 #if USE(GSTREAMER) 305 [](const RefPtr<GstMappedBuffer>& data) { return data->size(); }, 286 306 #endif 287 307 [](const FileSystem::MappedFileData& data) { return data.size(); } -
trunk/Source/WebCore/platform/SharedBuffer.h
r238851 r239921 49 49 #endif 50 50 51 #if USE(GSTREAMER) 52 #include "GStreamerCommon.h" 53 #endif 54 51 55 #if USE(FOUNDATION) 52 56 OBJC_CLASS NSArray; … … 89 93 #endif 90 94 95 #if USE(GSTREAMER) 96 static Ref<SharedBuffer> create(GstMappedBuffer&); 97 #endif 91 98 // Calling data() causes all the data segments to be copied into one segment if they are not already. 92 99 // Iterate the segments using begin() and end() instead. … … 127 134 static Ref<DataSegment> create(GRefPtr<GBytes>&& data) { return adoptRef(*new DataSegment(WTFMove(data))); } 128 135 #endif 136 #if USE(GSTREAMER) 137 static Ref<DataSegment> create(RefPtr<GstMappedBuffer>&& data) { return adoptRef(*new DataSegment(WTFMove(data))); } 138 #endif 129 139 static Ref<DataSegment> create(FileSystem::MappedFileData&& data) { return adoptRef(*new DataSegment(WTFMove(data))); } 130 140 … … 144 154 : m_immutableData(WTFMove(data)) { } 145 155 #endif 156 #if USE(GSTREAMER) 157 DataSegment(RefPtr<GstMappedBuffer>&& data) 158 : m_immutableData(WTFMove(data)) { } 159 #endif 146 160 DataSegment(FileSystem::MappedFileData&& data) 147 161 : m_immutableData(WTFMove(data)) { } … … 156 170 #if USE(GLIB) 157 171 GRefPtr<GBytes>, 172 #endif 173 #if USE(GSTREAMER) 174 RefPtr<GstMappedBuffer>, 158 175 #endif 159 176 FileSystem::MappedFileData> m_immutableData; … … 192 209 explicit SharedBuffer(GBytes*); 193 210 #endif 211 #if USE(GSTREAMER) 212 explicit SharedBuffer(GstMappedBuffer&); 213 #endif 194 214 195 215 void combineIntoOneSegment() const; -
trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
r239427 r239921 328 328 Vector<GRefPtr<GstBuffer>> channelBufferList; 329 329 channelBufferList.reserveInitialCapacity(priv->sources.size()); 330 Vector< GstMappedBuffer> mappedBuffers;330 Vector<RefPtr<GstMappedBuffer>> mappedBuffers; 331 331 mappedBuffers.reserveInitialCapacity(priv->sources.size()); 332 332 for (unsigned i = 0; i < priv->sources.size(); ++i) { … … 343 343 GST_BUFFER_TIMESTAMP(buffer.get()) = timestamp; 344 344 GST_BUFFER_DURATION(buffer.get()) = duration; 345 GstMappedBuffer mappedBuffer(buffer.get(), GST_MAP_READWRITE);345 auto mappedBuffer = GstMappedBuffer::create(buffer.get(), GST_MAP_READWRITE); 346 346 ASSERT(mappedBuffer); 347 347 mappedBuffers.uncheckedAppend(WTFMove(mappedBuffer)); 348 priv->bus->setChannelMemory(i, reinterpret_cast<float*>(mappedBuffers[i] .data()), priv->framesToPull);348 priv->bus->setChannelMemory(i, reinterpret_cast<float*>(mappedBuffers[i]->data()), priv->framesToPull); 349 349 channelBufferList.uncheckedAppend(WTFMove(buffer)); 350 350 } -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
r239461 r239921 26 26 #include "GstAllocatorFastMalloc.h" 27 27 #include "IntSize.h" 28 #include "SharedBuffer.h" 28 29 #include <gst/audio/audio-info.h> 29 30 #include <gst/gst.h> … … 358 359 } 359 360 361 Ref<SharedBuffer> GstMappedBuffer::createSharedBuffer() 362 { 363 // SharedBuffer provides a read-only view on what it expects are 364 // immutable data. Do not create one is writable and hence mutable. 365 RELEASE_ASSERT(isSharable()); 366 367 return SharedBuffer::create(*this); 368 } 369 360 370 } 361 371 -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h
r239427 r239921 28 28 #include <gst/video/video-info.h> 29 29 #include <wtf/MediaTime.h> 30 #include <wtf/ThreadSafeRefCounted.h> 30 31 31 32 namespace WebCore { 32 33 33 34 class IntSize; 35 class SharedBuffer; 34 36 35 37 inline bool webkitGstCheckVersion(guint major, guint minor, guint micro) … … 78 80 } 79 81 80 class GstMappedBuffer { 81 WTF_MAKE_NONCOPYABLE(GstMappedBuffer); 82 class GstMappedBuffer : public ThreadSafeRefCounted<GstMappedBuffer> { 82 83 public: 83 84 GstMappedBuffer(GstMappedBuffer&& other) 85 : m_buffer(other.m_buffer) 86 , m_info(other.m_info) 87 , m_isValid(other.m_isValid) 88 { 89 other.m_isValid = false; 90 } 91 92 GstMappedBuffer(GstBuffer* buffer, GstMapFlags flags) 93 : m_buffer(buffer) 94 { 95 m_isValid = gst_buffer_map(m_buffer, &m_info, flags); 84 static RefPtr<GstMappedBuffer> create(GstBuffer* buffer, GstMapFlags flags) 85 { 86 GstMapInfo info; 87 if (!gst_buffer_map(buffer, &info, flags)) 88 return nullptr; 89 return adoptRef(new GstMappedBuffer(buffer, WTFMove(info))); 96 90 } 97 91 98 92 // Unfortunately, GST_MAP_READWRITE is defined out of line from the MapFlags 99 93 // enum as an int, and C++ is careful to not implicity convert it to an enum. 100 GstMappedBuffer(GstBuffer* buffer, int flags) 101 : GstMappedBuffer(buffer, static_cast<GstMapFlags>(flags)) { } 94 static RefPtr<GstMappedBuffer> create(GstBuffer* buffer, int flags) 95 { 96 return GstMappedBuffer::create(buffer, static_cast<GstMapFlags>(flags)); 97 } 102 98 103 99 ~GstMappedBuffer() 104 100 { 105 if (m_isValid) 106 gst_buffer_unmap(m_buffer, &m_info); 107 m_isValid = false; 108 } 109 110 uint8_t* data() { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); } 111 const uint8_t* data() const { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); } 112 113 size_t size() const { ASSERT(m_isValid); return static_cast<size_t>(m_info.size); } 114 115 explicit operator bool() const { return m_isValid; } 101 gst_buffer_unmap(m_buffer, &m_info); 102 } 103 104 uint8_t* data() { return static_cast<uint8_t*>(m_info.data); } 105 const uint8_t* data() const { return static_cast<uint8_t*>(m_info.data); } 106 size_t size() const { return static_cast<size_t>(m_info.size); } 107 bool isSharable() const { return !(m_info.flags & GST_MAP_WRITE); } 108 Ref<SharedBuffer> createSharedBuffer(); 116 109 117 110 private: 111 GstMappedBuffer(GstBuffer* buffer, GstMapInfo&& info) 112 : m_buffer(buffer) 113 , m_info(WTFMove(info)) 114 { 115 } 116 118 117 friend bool operator==(const GstMappedBuffer&, const GstMappedBuffer&); 119 118 friend bool operator==(const GstMappedBuffer&, const GstBuffer*); … … 122 121 GstBuffer* m_buffer { nullptr }; 123 122 GstMapInfo m_info; 124 bool m_isValid { false };125 123 }; 126 124 -
trunk/Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
r233796 r239921 113 113 continue; 114 114 } 115 GstMappedBuffer mappedBuffer(buffer, GST_MAP_READ);115 auto mappedBuffer = GstMappedBuffer::create(buffer, GST_MAP_READ); 116 116 ASSERT(mappedBuffer); 117 117 if (!mappedBuffer) { … … 120 120 } 121 121 122 GST_INFO("Track %d parsing sample: %.*s", m_index, static_cast<int>(mappedBuffer .size()),123 reinterpret_cast<char*>(mappedBuffer .data()));124 client()->parseWebVTTCueData(reinterpret_cast<char*>(mappedBuffer .data()), mappedBuffer.size());122 GST_INFO("Track %d parsing sample: %.*s", m_index, static_cast<int>(mappedBuffer->size()), 123 reinterpret_cast<char*>(mappedBuffer->data())); 124 client()->parseWebVTTCueData(reinterpret_cast<char*>(mappedBuffer->data()), mappedBuffer->size()); 125 125 } 126 126 } -
trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h
r238131 r239921 41 41 : m_systemId(systemId) 42 42 { 43 GstMappedBuffer mappedInitData(initData, GST_MAP_READ);43 auto mappedInitData = GstMappedBuffer::create(initData, GST_MAP_READ); 44 44 if (!mappedInitData) { 45 45 GST_ERROR("cannot map %s protection data", systemId.utf8().data()); 46 46 ASSERT_NOT_REACHED(); 47 47 } 48 m_payload = SharedBuffer::create(mappedInitData.data(), mappedInitData.size());48 m_payload = mappedInitData->createSharedBuffer(); 49 49 } 50 50 -
trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp
r238083 r239921 151 151 } 152 152 153 static gboolean webKitMediaClearKeyDecryptorFindAndSetKey(WebKitMediaClearKeyDecryptPrivate* priv, const WebCore::GstMappedBuffer& keyIDBuffer)153 static gboolean webKitMediaClearKeyDecryptorFindAndSetKey(WebKitMediaClearKeyDecryptPrivate* priv, RefPtr<WebCore::GstMappedBuffer>&& keyIDBuffer) 154 154 { 155 155 GRefPtr<GstBuffer> keyBuffer; 156 156 for (auto& key : priv->keys) { 157 if (key.keyID.get() == keyIDBuffer) {157 if (key.keyID.get() == *keyIDBuffer) { 158 158 keyBuffer = key.keyValue; 159 159 break; … … 166 166 } 167 167 168 WebCore::GstMappedBuffer mappedKeyValueBuffer(keyBuffer.get(), GST_MAP_READ);168 auto mappedKeyValueBuffer = WebCore::GstMappedBuffer::create(keyBuffer.get(), GST_MAP_READ); 169 169 if (!mappedKeyValueBuffer) { 170 170 GST_ERROR_OBJECT(priv, "Failed to map decryption key"); … … 172 172 } 173 173 174 ASSERT(mappedKeyValueBuffer .size() == CLEARKEY_SIZE);175 if (gcry_error_t error = gcry_cipher_setkey(priv->handle, mappedKeyValueBuffer .data(), mappedKeyValueBuffer.size())) {174 ASSERT(mappedKeyValueBuffer->size() == CLEARKEY_SIZE); 175 if (gcry_error_t error = gcry_cipher_setkey(priv->handle, mappedKeyValueBuffer->data(), mappedKeyValueBuffer->size())) { 176 176 GST_ERROR_OBJECT(priv, "gcry_cipher_setkey failed: %s", gpg_strerror(error)); 177 177 return false; … … 189 189 } 190 190 191 WebCore::GstMappedBuffer mappedIVBuffer(ivBuffer, GST_MAP_READ);191 auto mappedIVBuffer = WebCore::GstMappedBuffer::create(ivBuffer, GST_MAP_READ); 192 192 if (!mappedIVBuffer) { 193 193 GST_ERROR_OBJECT(self, "Failed to map IV"); … … 196 196 197 197 uint8_t ctr[CLEARKEY_SIZE]; 198 if (mappedIVBuffer .size() == 8) {198 if (mappedIVBuffer->size() == 8) { 199 199 memset(ctr + 8, 0, 8); 200 memcpy(ctr, mappedIVBuffer .data(), 8);200 memcpy(ctr, mappedIVBuffer->data(), 8); 201 201 } else { 202 202 ASSERT(mappedIVBuffer.size() == CLEARKEY_SIZE); 203 memcpy(ctr, mappedIVBuffer .data(), CLEARKEY_SIZE);203 memcpy(ctr, mappedIVBuffer->data(), CLEARKEY_SIZE); 204 204 } 205 205 … … 217 217 } 218 218 219 WebCore::GstMappedBuffer mappedKeyIdBuffer(keyIDBuffer, GST_MAP_READ);219 auto mappedKeyIdBuffer = WebCore::GstMappedBuffer::create(keyIDBuffer, GST_MAP_READ); 220 220 if (!mappedKeyIdBuffer) { 221 221 GST_ERROR_OBJECT(self, "Failed to map key id buffer"); … … 223 223 } 224 224 225 WebCore::GstMappedBuffer mappedBuffer(buffer, GST_MAP_READWRITE);225 auto mappedBuffer = WebCore::GstMappedBuffer::create(buffer, GST_MAP_READWRITE); 226 226 if (!mappedBuffer) { 227 227 GST_ERROR_OBJECT(self, "Failed to map buffer"); … … 229 229 } 230 230 231 webKitMediaClearKeyDecryptorFindAndSetKey(priv, mappedKeyIdBuffer);231 webKitMediaClearKeyDecryptorFindAndSetKey(priv, WTFMove(mappedKeyIdBuffer)); 232 232 233 233 unsigned position = 0; … … 236 236 if (!subSampleCount) { 237 237 // Full sample encryption. 238 GST_TRACE_OBJECT(self, "full sample encryption: %zu encrypted bytes", mappedBuffer .size());238 GST_TRACE_OBJECT(self, "full sample encryption: %zu encrypted bytes", mappedBuffer->size()); 239 239 240 240 // Check if the buffer is empty. 241 if (mappedBuffer .size()) {242 cipherError = gcry_cipher_decrypt(priv->handle, mappedBuffer .data(), mappedBuffer.size(), 0, 0);241 if (mappedBuffer->size()) { 242 cipherError = gcry_cipher_decrypt(priv->handle, mappedBuffer->data(), mappedBuffer->size(), 0, 0); 243 243 if (cipherError) { 244 244 GST_ERROR_OBJECT(self, "full sample decryption failed: %s", gpg_strerror(cipherError)); … … 256 256 257 257 // Subsample encryption. 258 WebCore::GstMappedBuffer mappedSubSamplesBuffer(subSamplesBuffer, GST_MAP_READ);258 auto mappedSubSamplesBuffer = WebCore::GstMappedBuffer::create(subSamplesBuffer, GST_MAP_READ); 259 259 if (!mappedSubSamplesBuffer) { 260 260 GST_ERROR_OBJECT(self, "Failed to map subsample buffer"); … … 262 262 } 263 263 264 GUniquePtr<GstByteReader> reader(gst_byte_reader_new(mappedSubSamplesBuffer .data(), mappedSubSamplesBuffer.size()));265 GST_DEBUG_OBJECT(self, "position: %d, size: %zu", position, mappedBuffer .size());266 267 while (position < mappedBuffer .size()) {264 GUniquePtr<GstByteReader> reader(gst_byte_reader_new(mappedSubSamplesBuffer->data(), mappedSubSamplesBuffer->size())); 265 GST_DEBUG_OBJECT(self, "position: %d, size: %zu", position, mappedBuffer->size()); 266 267 while (position < mappedBuffer->size()) { 268 268 guint16 nBytesClear = 0; 269 269 guint32 nBytesEncrypted = 0; … … 278 278 } else { 279 279 nBytesClear = 0; 280 nBytesEncrypted = mappedBuffer .size() - position;281 } 282 283 GST_TRACE_OBJECT(self, "subsample index %u - %hu bytes clear (todo=%zu)", sampleIndex, nBytesClear, mappedBuffer .size() - position);280 nBytesEncrypted = mappedBuffer->size() - position; 281 } 282 283 GST_TRACE_OBJECT(self, "subsample index %u - %hu bytes clear (todo=%zu)", sampleIndex, nBytesClear, mappedBuffer->size() - position); 284 284 position += nBytesClear; 285 285 if (nBytesEncrypted) { 286 GST_TRACE_OBJECT(self, "subsample index %u - %u bytes encrypted (todo=%zu)", sampleIndex, nBytesEncrypted, mappedBuffer .size() - position);287 cipherError = gcry_cipher_decrypt(priv->handle, mappedBuffer .data() + position, nBytesEncrypted, 0, 0);286 GST_TRACE_OBJECT(self, "subsample index %u - %u bytes encrypted (todo=%zu)", sampleIndex, nBytesEncrypted, mappedBuffer->size() - position); 287 cipherError = gcry_cipher_decrypt(priv->handle, mappedBuffer->data() + position, nBytesEncrypted, 0, 0); 288 288 if (cipherError) { 289 289 GST_ERROR_OBJECT(self, "sub sample index %u decryption failed: %s", sampleIndex, gpg_strerror(cipherError)); -
trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp
r239427 r239921 79 79 GstBuffer* buffer = gst_buffer_new_allocate(nullptr, bipBopCount * m_streamFormat->bytesPerFrame(), nullptr); 80 80 { 81 GstMappedBuffer map(buffer, GST_MAP_WRITE);81 auto map = GstMappedBuffer::create(buffer, GST_MAP_WRITE); 82 82 83 83 if (!muted()) { 84 memcpy(map .data(), &m_bipBopBuffer[bipBopStart], sizeof(float) * bipBopCount);85 addHum(s_HumVolume, s_HumFrequency, sampleRate(), m_samplesRendered, (float*)map .data(), bipBopCount);84 memcpy(map->data(), &m_bipBopBuffer[bipBopStart], sizeof(float) * bipBopCount); 85 addHum(s_HumVolume, s_HumFrequency, sampleRate(), m_samplesRendered, (float*)map->data(), bipBopCount); 86 86 } else 87 memset(map .data(), 0, sizeof(float) * bipBopCount);87 memset(map->data(), 0, sizeof(float) * bipBopCount); 88 88 } 89 89 -
trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp
r238951 r239921 115 115 gst_audio_format_fill_silence(m_outputStreamDescription->getInfo()->finfo, m_audioBuffer.data(), outBufferSize); 116 116 else { 117 GstMappedBuffer inMap(inBuffer.get(), GST_MAP_READ);117 auto inMap = GstMappedBuffer::create(inBuffer.get(), GST_MAP_READ); 118 118 119 gpointer in[1] = { inMap .data() };119 gpointer in[1] = { inMap->data() }; 120 120 gpointer out[1] = { m_audioBuffer.data() }; 121 121 if (!gst_audio_converter_samples(m_sampleConverter.get(), static_cast<GstAudioConverterFlags>(0), in, inChunkSampleCount, out, outChunkSampleCount)) { -
trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp
r238102 r239921 87 87 GRefPtr<GstCaps> caps = adoptGRef(gst_video_info_to_caps(&info)); 88 88 89 GstMappedBuffer map(buffer.get(), GST_MAP_WRITE);90 memset(map .data(), 0, info.size);89 auto map = GstMappedBuffer::create(buffer.get(), GST_MAP_WRITE); 90 memset(map->data(), 0, info.size); 91 91 92 92 return GStreamerVideoFrameLibWebRTC::create(gst_sample_new(buffer.get(), caps.get(), NULL, NULL)); -
trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp
r238967 r239921 343 343 size_t* bufferSize, GstBuffer* buffer, webrtc::RTPFragmentationHeader* fragmentationInfo) 344 344 { 345 GstMappedBuffer map(buffer, GST_MAP_READ);346 347 if (*bufferSize < map .size()) {348 encodedImage->_size = map .size();345 auto map = GstMappedBuffer::create(buffer, GST_MAP_READ); 346 347 if (*bufferSize < map->size()) { 348 encodedImage->_size = map->size(); 349 349 encodedImage->_buffer = new uint8_t[encodedImage->_size]; 350 350 encodedImageBuffer->reset(encodedImage->_buffer); 351 *bufferSize = map .size();352 } 353 354 memcpy(encodedImage->_buffer, map .data(), map.size());355 encodedImage->_length = map .size();356 encodedImage->_size = map .size();351 *bufferSize = map->size(); 352 } 353 354 memcpy(encodedImage->_buffer, map->data(), map->size()); 355 encodedImage->_length = map->size(); 356 encodedImage->_size = map->size(); 357 357 358 358 fragmentationInfo->VerifyAndAllocateFragmentationHeader(1); 359 359 fragmentationInfo->fragmentationOffset[0] = 0; 360 fragmentationInfo->fragmentationLength[0] = map .size();360 fragmentationInfo->fragmentationLength[0] = map->size(); 361 361 fragmentationInfo->fragmentationPlType[0] = 0; 362 362 fragmentationInfo->fragmentationTimeDiff[0] = 0; … … 439 439 440 440 const uint8_t startCode[4] = { 0, 0, 0, 1 }; 441 GstMappedBuffer map(gstbuffer, GST_MAP_READ);441 auto map = GstMappedBuffer::create(gstbuffer, GST_MAP_READ); 442 442 while (parserResult == GST_H264_PARSER_OK) { 443 parserResult = gst_h264_parser_identify_nalu(m_parser, map .data(), offset, map.size(), &nalu);443 parserResult = gst_h264_parser_identify_nalu(m_parser, map->data(), offset, map->size(), &nalu); 444 444 445 445 nalu.sc_offset = offset; … … 457 457 encodedImage->_buffer = new uint8_t[encodedImage->_size]; 458 458 encodedImageBuffer->reset(encodedImage->_buffer); 459 *bufferSize = map .size();459 *bufferSize = map->size(); 460 460 } 461 461 … … 466 466 for (std::vector<GstH264NalUnit>::iterator nal = nals.begin(); nal != nals.end(); ++nal, fragmentIndex++) { 467 467 468 ASSERT(map .data()[nal->sc_offset + 0] == startCode[0]);469 ASSERT(map .data()[nal->sc_offset + 1] == startCode[1]);470 ASSERT(map .data()[nal->sc_offset + 2] == startCode[2]);471 ASSERT(map .data()[nal->sc_offset + 3] == startCode[3]);468 ASSERT(map->data()[nal->sc_offset + 0] == startCode[0]); 469 ASSERT(map->data()[nal->sc_offset + 1] == startCode[1]); 470 ASSERT(map->data()[nal->sc_offset + 2] == startCode[2]); 471 ASSERT(map->data()[nal->sc_offset + 3] == startCode[3]); 472 472 473 473 fragmentationHeader->fragmentationOffset[fragmentIndex] = nal->offset; 474 474 fragmentationHeader->fragmentationLength[fragmentIndex] = nal->size; 475 475 476 memcpy(encodedImage->_buffer + encodedImage->_length, &map .data()[nal->sc_offset],476 memcpy(encodedImage->_buffer + encodedImage->_length, &map->data()[nal->sc_offset], 477 477 sizeof(startCode) + nal->size); 478 478 encodedImage->_length += nal->size + sizeof(startCode); -
trunk/Tools/ChangeLog
r239920 r239921 1 2019-01-14 Charlie Turner <cturner@igalia.com> 2 3 [GStreamer] Add sharedBuffer utility to GstMappedBuffer, and a testsuite 4 https://bugs.webkit.org/show_bug.cgi?id=192977 5 6 Reviewed by Carlos Garcia Campos. 7 8 * TestWebKitAPI/PlatformGTK.cmake: Build the new GStreamer test harness 9 * TestWebKitAPI/PlatformWPE.cmake: Ditto. 10 * TestWebKitAPI/Tests/WebCore/gstreamer/GStreamerTest.cpp: Added. 11 (TestWebKitAPI::GStreamerTest::SetUp): 12 (TestWebKitAPI::GStreamerTest::TearDown): 13 * TestWebKitAPI/Tests/WebCore/gstreamer/GStreamerTest.h: Added. 14 * TestWebKitAPI/Tests/WebCore/gstreamer/GstMappedBuffer.cpp: Added. 15 (TestWebKitAPI::TEST_F): 16 1 17 2019-01-14 Charlie Turner <cturner@igalia.com> 2 18 -
trunk/Tools/TestWebKitAPI/PlatformGTK.cmake
r238779 r239921 26 26 ${GDK3_INCLUDE_DIRS} 27 27 ${GLIB_INCLUDE_DIRS} 28 ${GSTREAMER_INCLUDE_DIRS} 28 29 ${GTK3_INCLUDE_DIRS} 29 30 ${LIBSOUP_INCLUDE_DIRS} … … 94 95 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp 95 96 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp 97 ${TESTWEBKITAPI_DIR}/Tests/WebCore/gstreamer/GstMappedBuffer.cpp 98 ${TESTWEBKITAPI_DIR}/Tests/WebCore/gstreamer/GStreamerTest.cpp 96 99 ${TESTWEBKITAPI_DIR}/Tests/WebCore/GridPosition.cpp 97 100 ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp -
trunk/Tools/TestWebKitAPI/PlatformWPE.cmake
r238779 r239921 24 24 ${CAIRO_INCLUDE_DIRS} 25 25 ${GLIB_INCLUDE_DIRS} 26 ${GSTREAMER_INCLUDE_DIRS} 26 27 ${LIBSOUP_INCLUDE_DIRS} 27 28 ${WPE_INCLUDE_DIRS} … … 61 62 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp 62 63 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp 64 ${TESTWEBKITAPI_DIR}/Tests/WebCore/gstreamer/GstMappedBuffer.cpp 65 ${TESTWEBKITAPI_DIR}/Tests/WebCore/gstreamer/GStreamerTest.cpp 63 66 ${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp 64 67 ${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
Note: See TracChangeset
for help on using the changeset viewer.