Changeset 280972 in webkit
- Timestamp:
- Aug 12, 2021, 10:13:11 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/RTCEncodedFrame.cpp (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp (modified) (5 diffs)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h (modified) (2 diffs)
-
Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/RTCRtpTransformableFrame.h (modified) (2 diffs)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.cpp (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r280968 r280972 1 2021-08-12 Youenn Fablet <youenn@apple.com> 2 3 Adopt span in RTCRtpSFrameTransform 4 https://bugs.webkit.org/show_bug.cgi?id=229029 5 6 Reviewed by Eric Carlson. 7 8 Transition to Span for improved readability, no change of behavior. 9 10 * Modules/mediastream/RTCEncodedFrame.cpp: 11 (WebCore::RTCEncodedFrame::data const): 12 * Modules/mediastream/RTCRtpSFrameTransform.cpp: 13 (WebCore::processFrame): 14 (WebCore::RTCRtpSFrameTransform::initializeTransformer): 15 (WebCore::transformFrame): 16 (WebCore::RTCRtpSFrameTransform::createStreams): 17 * Modules/mediastream/RTCRtpSFrameTransformer.cpp: 18 (WebCore::RTCRtpSFrameTransformer::decryptFrame): 19 (WebCore::RTCRtpSFrameTransformer::encryptFrame): 20 (WebCore::RTCRtpSFrameTransformer::transform): 21 * Modules/mediastream/RTCRtpSFrameTransformer.h: 22 * Modules/mediastream/RTCRtpScriptTransformer.cpp: 23 (WebCore::RTCRtpScriptTransformer::writable): 24 * Modules/mediastream/RTCRtpTransformableFrame.h: 25 (): Deleted. 26 * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.cpp: 27 (WebCore::LibWebRTCRtpTransformableFrame::data const): 28 (WebCore::LibWebRTCRtpTransformableFrame::setData): 29 * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.h: 30 1 31 2021-08-12 Johnson Zhou <qiaosong_zhou@apple.com> 2 32 -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedFrame.cpp
r270290 r280972 42 42 { 43 43 auto data = m_frame->data(); 44 return JSC::ArrayBuffer::create(data.data , data.size);44 return JSC::ArrayBuffer::create(data.data(), data.size()); 45 45 } 46 46 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp
r280958 r280972 116 116 } 117 117 118 static std::optional<Vector<uint8_t>> processFrame( const uint8_t* data, size_t size, RTCRtpSFrameTransformer& transformer, ScriptExecutionContextIdentifier identifier, const WeakPtr<RTCRtpSFrameTransform>& weakTransform)119 { 120 auto result = transformer.transform(data , size);118 static std::optional<Vector<uint8_t>> processFrame(Span<const uint8_t> data, RTCRtpSFrameTransformer& transformer, ScriptExecutionContextIdentifier identifier, const WeakPtr<RTCRtpSFrameTransform>& weakTransform) 119 { 120 auto result = transformer.transform(data); 121 121 if (!result.has_value()) { 122 122 auto errorInformation = WTFMove(result.error()); … … 160 160 backend.setTransformableFrameCallback([transformer = m_transformer, identifier = context->contextIdentifier(), backend = makeRef(backend), weakThis = makeWeakPtr(this)](auto&& frame) { 161 161 auto chunk = frame->data(); 162 if (!chunk.data || !chunk.size)162 if (!chunk.data() || !chunk.size()) 163 163 return; 164 auto result = processFrame(chunk .data, chunk.size, transformer.get(), identifier, weakThis);164 auto result = processFrame(chunk, transformer.get(), identifier, weakThis); 165 165 166 166 if (!result) … … 188 188 } 189 189 190 static void transformFrame( const uint8_t* data, size_t size, JSDOMGlobalObject& globalObject, RTCRtpSFrameTransformer& transformer, SimpleReadableStreamSource& source, ScriptExecutionContextIdentifier identifier, const WeakPtr<RTCRtpSFrameTransform>& weakTransform)191 { 192 auto result = processFrame(data, size,transformer, identifier, weakTransform);190 static void transformFrame(Span<const uint8_t> data, JSDOMGlobalObject& globalObject, RTCRtpSFrameTransformer& transformer, SimpleReadableStreamSource& source, ScriptExecutionContextIdentifier identifier, const WeakPtr<RTCRtpSFrameTransform>& weakTransform) 191 { 192 auto result = processFrame(data, transformer, identifier, weakTransform); 193 193 auto buffer = result ? SharedBuffer::create(WTFMove(*result)) : SharedBuffer::create(); 194 194 source.enqueue(toJS(&globalObject, &globalObject, buffer->tryCreateArrayBuffer().get())); … … 199 199 { 200 200 auto chunk = frame.rtcFrame().data(); 201 auto result = processFrame(chunk .data, chunk.size, transformer, identifier, weakTransform);202 RTCRtpTransformableFrame::DatatransformedChunk;201 auto result = processFrame(chunk, transformer, identifier, weakTransform); 202 Span<const uint8_t> transformedChunk; 203 203 if (result) 204 204 transformedChunk = { result->data(), result->size() }; … … 230 230 transformFrame(*value, globalObject, transformer.get(), *readableStreamSource, context.contextIdentifier(), weakThis); 231 231 }, [&](RefPtr<ArrayBuffer>& value) { 232 transformFrame( static_cast<const uint8_t*>(value->data()), value->byteLength(), globalObject, transformer.get(), *readableStreamSource, context.contextIdentifier(), weakThis);232 transformFrame({ static_cast<const uint8_t*>(value->data()), value->byteLength() }, globalObject, transformer.get(), *readableStreamSource, context.contextIdentifier(), weakThis); 233 233 }, [&](RefPtr<ArrayBufferView>& value) { 234 transformFrame( static_cast<const uint8_t*>(value->data()), value->byteLength(), globalObject, transformer.get(), *readableStreamSource, context.contextIdentifier(), weakThis);234 transformFrame({ static_cast<const uint8_t*>(value->data()), value->byteLength() }, globalObject, transformer.get(), *readableStreamSource, context.contextIdentifier(), weakThis); 235 235 }); 236 236 return { }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.cpp
r280958 r280972 207 207 } 208 208 209 RTCRtpSFrameTransformer::TransformResult RTCRtpSFrameTransformer::decryptFrame(const uint8_t* frameData, size_t frameSize) 210 { 209 RTCRtpSFrameTransformer::TransformResult RTCRtpSFrameTransformer::decryptFrame(Span<const uint8_t> data) 210 { 211 auto* frameData = data.data(); 212 auto frameSize = data.size(); 213 211 214 Vector<uint8_t> buffer; 212 215 switch (m_compatibilityMode) { … … 277 280 } 278 281 279 RTCRtpSFrameTransformer::TransformResult RTCRtpSFrameTransformer::encryptFrame(const uint8_t* frameData, size_t frameSize) 280 { 282 RTCRtpSFrameTransformer::TransformResult RTCRtpSFrameTransformer::encryptFrame(Span<const uint8_t> data) 283 { 284 auto* frameData = data.data(); 285 auto frameSize = data.size(); 286 281 287 static const unsigned MaxHeaderSize = 17; 282 288 … … 338 344 } 339 345 340 RTCRtpSFrameTransformer::TransformResult RTCRtpSFrameTransformer::transform( const uint8_t* data, size_t size)346 RTCRtpSFrameTransformer::TransformResult RTCRtpSFrameTransformer::transform(Span<const uint8_t> data) 341 347 { 342 348 if (!m_hasKey) 343 349 return makeUnexpected(ErrorInformation { Error::KeyID, "Key is not initialized", 0 }); 344 350 345 return m_isEncrypting ? encryptFrame(data , size) : decryptFrame(data, size);351 return m_isEncrypting ? encryptFrame(data) : decryptFrame(data); 346 352 } 347 353 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h
r280958 r280972 57 57 }; 58 58 using TransformResult = Expected<Vector<uint8_t>, ErrorInformation>; 59 WEBCORE_EXPORT TransformResult transform( const uint8_t*, size_t);59 WEBCORE_EXPORT TransformResult transform(Span<const uint8_t>); 60 60 61 61 const Vector<uint8_t>& authenticationKey() const { return m_authenticationKey; } … … 72 72 WEBCORE_EXPORT explicit RTCRtpSFrameTransformer(CompatibilityMode); 73 73 74 TransformResult decryptFrame( const uint8_t*, size_t);75 TransformResult encryptFrame( const uint8_t*, size_t);74 TransformResult decryptFrame(Span<const uint8_t>); 75 TransformResult encryptFrame(Span<const uint8_t>); 76 76 77 77 enum class ShouldUpdateKeys { No, Yes }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp
r277589 r280972 107 107 108 108 // If no data, skip the frame since there is nothing to packetize or decode. 109 if (rtcFrame->data().data )109 if (rtcFrame->data().data()) 110 110 transformer->m_backend->processTransformedFrame(rtcFrame.get()); 111 111 return { }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransformableFrame.h
r278253 r280972 28 28 29 29 #include <wtf/RefCounted.h> 30 #include <wtf/Span.h> 30 31 #include <wtf/Vector.h> 31 32 … … 51 52 virtual ~RTCRtpTransformableFrame() = default; 52 53 53 struct Data { 54 const uint8_t* data { nullptr }; 55 size_t size { 0 }; 56 }; 57 virtual Data data() const = 0; 58 virtual void setData(Data) = 0; 54 virtual Span<const uint8_t> data() const = 0; 55 virtual void setData(Span<const uint8_t>) = 0; 59 56 60 57 virtual uint64_t timestamp() const = 0; -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.cpp
r278253 r280972 53 53 } 54 54 55 RTCRtpTransformableFrame::DataLibWebRTCRtpTransformableFrame::data() const55 Span<const uint8_t> LibWebRTCRtpTransformableFrame::data() const 56 56 { 57 57 if (!m_rtcFrame) 58 return { nullptr, 0};58 return { }; 59 59 auto data = m_rtcFrame->GetData(); 60 60 return { data.begin(), data.size() }; 61 61 } 62 62 63 void LibWebRTCRtpTransformableFrame::setData( Datadata)63 void LibWebRTCRtpTransformableFrame::setData(Span<const uint8_t> data) 64 64 { 65 65 if (m_rtcFrame) 66 m_rtcFrame->SetData({ data.data , data.size});66 m_rtcFrame->SetData({ data.data(), data.size() }); 67 67 } 68 68 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.h
r275830 r280972 48 48 49 49 // RTCRtpTransformableFrame 50 Datadata() const final;51 void setData( Data) final;50 Span<const uint8_t> data() const final; 51 void setData(Span<const uint8_t>) final; 52 52 bool isKeyFrame() const final; 53 53 uint64_t timestamp() const final; -
trunk/Tools/ChangeLog
r280969 r280972 1 2021-08-12 Youenn Fablet <youenn@apple.com> 2 3 Adopt span in RTCRtpSFrameTransform 4 https://bugs.webkit.org/show_bug.cgi?id=229029 5 6 Reviewed by Eric Carlson. 7 8 * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: 9 (TestWebKitAPI::TEST): 10 1 11 2021-08-12 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp
r280958 r280972 200 200 auto frame = Vector<uint8_t>::from(135, 89, 51, 166, 248, 129, 157, 111, 190, 134, 220); 201 201 202 auto encryptedResult = encryptor->transform( frame.data(), frame.size());202 auto encryptedResult = encryptor->transform({ frame.data(), frame.size() }); 203 203 EXPECT_TRUE(encryptedResult.has_value()); 204 204 205 205 auto encrypted = WTFMove(encryptedResult.value()); 206 auto decryptedResult = decryptor->transform( encrypted.data(), encrypted.size());206 auto decryptedResult = decryptor->transform({ encrypted.data(), encrypted.size() }); 207 207 EXPECT_TRUE(decryptedResult.has_value()); 208 208 … … 220 220 auto frame = Vector<uint8_t>::from(135, 89, 51, 166, 248, 129, 157, 111, 190, 134, 220); 221 221 222 auto encryptedResult = encryptor->transform( frame.data(), frame.size());222 auto encryptedResult = encryptor->transform({ frame.data(), frame.size() }); 223 223 EXPECT_TRUE(encryptedResult.has_value()); 224 224 225 225 auto encrypted = WTFMove(encryptedResult.value()); 226 auto decryptedResult = decryptor->transform( encrypted.data(), encrypted.size());226 auto decryptedResult = decryptor->transform({ encrypted.data(), encrypted.size() }); 227 227 EXPECT_TRUE(decryptedResult.has_value()); 228 228 … … 242 242 auto frame = Vector<uint8_t>::from(135, 89, 51, 166, 248, 129, 157, 111, 190, 134, 220, 56); 243 243 244 auto encryptedResult = encryptor->transform( frame.data(), frame.size());244 auto encryptedResult = encryptor->transform({ frame.data(), frame.size() }); 245 245 EXPECT_TRUE(encryptedResult.has_value()); 246 246 247 247 auto encrypted = WTFMove(encryptedResult.value()); 248 auto decryptedResult = decryptor->transform( encrypted.data(), encrypted.size());248 auto decryptedResult = decryptor->transform({ encrypted.data(), encrypted.size() }); 249 249 EXPECT_TRUE(decryptedResult.has_value()); 250 250 … … 257 257 258 258 uint8_t frame1[] = { 135, 89, 51, 166, 248, 129, 157, 111, 190, 134, 220 }; 259 auto result = transformer->transform( frame1, sizeof(frame1));259 auto result = transformer->transform({ frame1, sizeof(frame1) }); 260 260 EXPECT_TRUE(result.has_value()); 261 261 … … 300 300 301 301 uint8_t frame1[] = { 8, 164, 189, 18, 61, 117, 132, 43, 117, 169, 42 }; 302 auto result = transformer->transform( frame1, sizeof(frame1));302 auto result = transformer->transform({ frame1, sizeof(frame1) }); 303 303 EXPECT_TRUE(result.has_value()); 304 304 for (size_t cptr = 0; cptr < 256; ++cptr) { 305 result = transformer->transform( frame1, sizeof(frame1));305 result = transformer->transform({ frame1, sizeof(frame1) }); 306 306 EXPECT_TRUE(result.has_value()); 307 307 } … … 349 349 350 350 uint8_t frame1[] = { 0, 33, 244, 24, 236, 156, 127, 8, 48, 88, 220 }; 351 auto result = transformer->transform( frame1, sizeof(frame1));351 auto result = transformer->transform({ frame1, sizeof(frame1) }); 352 352 EXPECT_TRUE(result.has_value()); 353 353
Note:
See TracChangeset
for help on using the changeset viewer.