Changeset 270107 in webkit
- Timestamp:
- Nov 20, 2020 4:25:32 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 2 deleted
- 41 edited
- 13 copied
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270106 r270107 1 2020-11-20 Youenn Fablet <youenn@apple.com> 2 3 Add support for RTCRtpScriptTransform 4 https://bugs.webkit.org/show_bug.cgi?id=219148 5 6 Reviewed by Eric Carlson. 7 8 * http/wpt/webrtc/routines.js: Added. 9 (createConnections): 10 * http/wpt/webrtc/script-transform.js: Added. 11 (MockRTCRtpTransformer): 12 (MockRTCRtpTransformer.prototype.start): 13 (MockRTCRtpTransformer.prototype.process): 14 * http/wpt/webrtc/sframe-transform-expected.txt: Added. 15 * http/wpt/webrtc/sframe-transform.html: Added. 16 * http/wpt/webrtc/webrtc-transform-expected.txt: Renamed from LayoutTests/webrtc/webrtc-transform-expected.txt. 17 * http/wpt/webrtc/webrtc-transform.html: Renamed from LayoutTests/webrtc/webrtc-transform.html. 18 * platform/glib/TestExpectations: 19 * webrtc/script-transform.js: Added. 20 (MockRTCRtpTransformer): 21 (MockRTCRtpTransformer.prototype.start): 22 1 23 2020-11-20 Philippe Normand <pnormand@igalia.com> 2 24 -
trunk/LayoutTests/http/wpt/webrtc/webrtc-transform-expected.txt
r270106 r270107 1 1 2 2 3 PASS transform messaging 4 PASS Cannot reuse attached transforms 3 5 PASS audio exchange with transform 4 6 PASS video exchange with transform -
trunk/LayoutTests/platform/glib/TestExpectations
r270102 r270107 917 917 webkit.org/b/218787 webrtc/concurrentVideoPlayback.html [ Timeout ] 918 918 webkit.org/b/218787 webrtc/ice-candidate-sdpMLineIndex.html [ Timeout ] 919 webkit.org/b/218787 webrtc/webrtc-transform.html [ Failure ]919 webkit.org/b/218787 http/wpt/webrtc/webrtc-transform.html [ Failure ] 920 920 921 921 webkit.org/b/219066 webrtc/audio-sframe.html [ Failure Crash ] -
trunk/Source/WebCore/CMakeLists.txt
r270101 r270107 376 376 Modules/mediastream/RTCDegradationPreference.idl 377 377 Modules/mediastream/RTCDtxStatus.idl 378 Modules/mediastream/RTCEncodedAudioFrame.idl 379 Modules/mediastream/RTCEncodedVideoFrame.idl 378 380 Modules/mediastream/RTCIceCandidate.idl 379 381 Modules/mediastream/RTCIceCandidateInit.idl … … 407 409 Modules/mediastream/RTCRtpRtxParameters.idl 408 410 Modules/mediastream/RTCRtpSFrameTransform.idl 411 Modules/mediastream/RTCRtpScriptTransform.idl 412 Modules/mediastream/RTCRtpScriptTransformProvider.idl 413 Modules/mediastream/RTCRtpScriptTransformer.idl 414 Modules/mediastream/RTCRtpScriptTransformerConstructor.idl 409 415 Modules/mediastream/RTCRtpSendParameters.idl 410 416 Modules/mediastream/RTCRtpSender+Transform.idl … … 413 419 Modules/mediastream/RTCRtpTransceiver.idl 414 420 Modules/mediastream/RTCRtpTransceiverDirection.idl 415 Modules/mediastream/RTCRtpTransform.idl416 421 Modules/mediastream/RTCSdpType.idl 417 422 Modules/mediastream/RTCSessionDescription.idl … … 487 492 Modules/streams/WritableStreamDefaultController.idl 488 493 Modules/streams/WritableStreamDefaultWriter.idl 494 Modules/streams/WritableStreamSink.idl 489 495 490 496 Modules/webaudio/AnalyserNode.idl … … 1759 1765 testing/MockContentFilterSettings.idl 1760 1766 testing/MockPageOverlay.idl 1761 testing/MockRTCRtpTransform.idl1762 1767 testing/ServiceWorkerInternals.idl 1763 1768 testing/TypeConversions.idl … … 1783 1788 testing/MockPageOverlay.cpp 1784 1789 testing/MockPageOverlayClient.cpp 1785 testing/MockRTCRtpTransform.cpp1786 1790 testing/ServiceWorkerInternals.cpp 1787 1791 testing/js/WebCoreTestSupport.cpp -
trunk/Source/WebCore/ChangeLog
r270106 r270107 1 2020-11-20 Youenn Fablet <youenn@apple.com> 2 3 Add support for RTCRtpScriptTransform 4 https://bugs.webkit.org/show_bug.cgi?id=219148 5 6 Reviewed by Eric Carlson. 7 8 We introduce RTCRtpScriptTransform which processes encoded frames in a worker for either RTCRtpSender or RTCRtpReceiver. 9 The model follows AudioWorkletNode in the sense that we create a RTCRtpScriptTransform object in main thread that is used with RTCRtp objects. 10 The RTCRtpScriptTransform takes a name and a worker as parameters to create a RTCRtpScriptTransformer counter part in a worker. 11 Before that, RTCRtpScriptTransformer constructors are registered in the worker with a specific name. 12 A message port is shared between RTCRtpScriptTransform and RTCRtpScriptTransformer. 13 14 RTCRtpScriptTransform keeps a weak pointer to RTCRtpScriptTransformer so that we keep all ref counting of RTCRtpScriptTransformer in the worker thread. 15 To make sure RTCRtpScriptTransformer stays alive for long enough, we set a pending activity when RTCRtpScriptTransform is linked to its RTCRtpScriptTransformer. 16 The pending activity is then removed either at worker closure or RTCRtpScriptTransform being no longer doing processing. 17 18 We expose individual compressed frames as RTCEncodedAudioFrame and RTCEncodedVideoFrame. 19 Accessor is limited to the raw data but additional getters should be added later on. 20 21 To implement RTCRtpScriptTransformer, we have to be able to create WritableStream with native sinks. 22 This is why we introduce WritableStreamSink and WritableStream C++ classes. 23 Binding between native frames and streams is done through RTCRtpReadableStreamSource and RTCRtpWritableStreamSink. 24 25 Test: http/wpt/webrtc/webrtc-transform.html and http/wpt/webrtc/sframe-transform.html. 26 27 * CMakeLists.txt: 28 * DerivedSources-input.xcfilelist: 29 * DerivedSources-output.xcfilelist: 30 * DerivedSources.make: 31 * Modules/mediastream/RTCEncodedAudioFrame.cpp: Added. 32 (WebCore::RTCEncodedAudioFrame::RTCEncodedAudioFrame): 33 * Modules/mediastream/RTCEncodedAudioFrame.h: Added. 34 (WebCore::RTCEncodedAudioFrame::create): 35 * Modules/mediastream/RTCEncodedAudioFrame.idl: Added. 36 * Modules/mediastream/RTCEncodedFrame.h: Added. 37 * Modules/mediastream/RTCEncodedFrame.cpp: Added. 38 * Modules/mediastream/RTCEncodedVideoFrame.cpp: Added. 39 (WebCore::RTCEncodedVideoFrame::RTCEncodedVideoFrame): 40 * Modules/mediastream/RTCEncodedVideoFrame.h: Added. 41 (WebCore::RTCEncodedVideoFrame::create): 42 * Modules/mediastream/RTCEncodedVideoFrame.idl: Added. 43 * Modules/mediastream/RTCRtpReceiver+Transform.idl: 44 * Modules/mediastream/RTCRtpReceiver.cpp: 45 (WebCore::RTCRtpReceiver::setTransform): 46 (WebCore::RTCRtpReceiver::transform): 47 * Modules/mediastream/RTCRtpReceiver.h: 48 * Modules/mediastream/RTCRtpReceiverWithTransform.h: 49 (WebCore::RTCRtpReceiverWithTransform::transform): 50 (WebCore::RTCRtpReceiverWithTransform::setTransform): 51 * Modules/mediastream/RTCRtpSFrameTransform.cpp: 52 (WebCore::RTCRtpSFrameTransform::initializeTransformer): 53 * Modules/mediastream/RTCRtpSFrameTransform.h: 54 (WebCore::RTCRtpSFrameTransform::isAttached const): 55 * Modules/mediastream/RTCRtpSFrameTransform.idl: 56 * Modules/mediastream/RTCRtpScriptTransform.cpp: Added. 57 (WebCore::RTCRtpScriptTransform::create): 58 (WebCore::RTCRtpScriptTransform::RTCRtpScriptTransform): 59 (WebCore::RTCRtpScriptTransform::~RTCRtpScriptTransform): 60 (WebCore::RTCRtpScriptTransform::setTransformer): 61 (WebCore::RTCRtpScriptTransform::initializeBackendForReceiver): 62 (WebCore::RTCRtpScriptTransform::initializeBackendForSender): 63 (WebCore::RTCRtpScriptTransform::willClearBackend): 64 (WebCore::RTCRtpScriptTransform::initializeTransformer): 65 * Modules/mediastream/RTCRtpScriptTransform.h: Added. 66 * Modules/mediastream/RTCRtpScriptTransform.idl: Added. 67 * Modules/mediastream/RTCRtpScriptTransformProvider.idl: Added. 68 * Modules/mediastream/RTCRtpScriptTransformer.cpp: Added. 69 (WebCore::RTCRtpReadableStreamSource::create): 70 (WebCore::RTCRtpReadableStreamSource::close): 71 (WebCore::RTCRtpReadableStreamSource::enqueue): 72 (WebCore::RTCRtpWritableStreamSink::create): 73 (WebCore::RTCRtpWritableStreamSink::RTCRtpWritableStreamSink): 74 (WebCore::RTCRtpWritableStreamSink::write): 75 (WebCore::RTCRtpScriptTransformer::create): 76 (WebCore::RTCRtpScriptTransformer::RTCRtpScriptTransformer): 77 (WebCore::RTCRtpScriptTransformer::~RTCRtpScriptTransformer): 78 (WebCore::RTCRtpScriptTransformer::start): 79 (WebCore::RTCRtpScriptTransformer::clear): 80 * Modules/mediastream/RTCRtpScriptTransformer.h: Added. 81 (WebCore::RTCRtpScriptTransformer::setCallback): 82 (WebCore::RTCRtpScriptTransformer::port): 83 (WebCore::RTCRtpScriptTransformer::startPendingActivity): 84 (WebCore::RTCRtpScriptTransformer::activeDOMObjectName const): 85 (WebCore::RTCRtpScriptTransformer::stopPendingActivity): 86 * Modules/mediastream/RTCRtpScriptTransformer.idl: Added. 87 * Modules/mediastream/RTCRtpScriptTransformerConstructor.h: Added. 88 * Modules/mediastream/RTCRtpScriptTransformerConstructor.idl: Added. 89 * Modules/mediastream/RTCRtpSender+Transform.idl: 90 * Modules/mediastream/RTCRtpSender.cpp: 91 (WebCore::RTCRtpSender::setTransform): 92 (WebCore::RTCRtpSender::transform): 93 * Modules/mediastream/RTCRtpSender.h: 94 * Modules/mediastream/RTCRtpSenderWithTransform.h: 95 (WebCore::RTCRtpSenderWithTransform::transform): 96 (WebCore::RTCRtpSenderWithTransform::setTransform): 97 * Modules/mediastream/RTCRtpTransform.cpp: 98 (WebCore::RTCRtpTransform::from): 99 (WebCore::RTCRtpTransform::RTCRtpTransform): 100 (WebCore::RTCRtpTransform::~RTCRtpTransform): 101 (WebCore::RTCRtpTransform::isAttached const): 102 (WebCore::RTCRtpTransform::attachToReceiver): 103 (WebCore::RTCRtpTransform::attachToSender): 104 (WebCore::RTCRtpTransform::clearBackend): 105 (WebCore::RTCRtpTransform::detachFromReceiver): 106 (WebCore::RTCRtpTransform::detachFromSender): 107 * Modules/mediastream/RTCRtpTransform.h: 108 (WebCore::RTCRtpTransform::internalTransform): 109 * Modules/mediastream/RTCRtpTransformBackend.h: 110 * Modules/mediastream/RTCRtpTransformableFrame.h: 111 * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp: 112 (WebCore::LibWebRTCRtpTransformBackend::setInputCallback): 113 (WebCore::LibWebRTCRtpTransformBackend::Transform): 114 * Modules/streams/WritableStreamSink.h: Added. 115 * Modules/streams/WritableStreamSink.idl: Added. 116 * Sources.txt: 117 * WebCore.xcodeproj/project.pbxproj: 118 * bindings/js/ReadableStreamDefaultController.cpp: 119 (WebCore::ReadableStreamDefaultController::enqueue): 120 * bindings/js/ReadableStreamDefaultController.h: 121 * bindings/js/WebCoreBuiltinNames.h: 122 * bindings/js/WritableStream.cpp: Added. 123 (WebCore::WritableStream::create): 124 * bindings/js/WritableStream.h: Added. 125 (WebCore::JSWritableStreamWrapperConverter::toWrapped): 126 (WebCore::WritableStream::WritableStream): 127 (WebCore::toJS): 128 (WebCore::toJSNewlyCreated): 129 * dom/EventTargetFactory.in: 130 * testing/Internals.cpp: 131 * testing/Internals.h: 132 * testing/Internals.idl: 133 * testing/MockRTCRtpTransform.cpp: 134 (WebCore::MockRTCRtpTransformer::transform): 135 * workers/DedicatedWorkerGlobalScope.cpp: 136 (WebCore::DedicatedWorkerGlobalScope::registerRTCRtpScriptTransformer): 137 (WebCore::DedicatedWorkerGlobalScope::createRTCRtpScriptTransformer): 138 * workers/DedicatedWorkerGlobalScope.h: 139 * workers/DedicatedWorkerGlobalScope.idl: 140 * workers/Worker.cpp: 141 (WebCore::Worker::addRTCRtpScriptTransformer): 142 (WebCore::Worker::createRTCRtpScriptTransformer): 143 (WebCore::Worker::postTaskToWorkerGlobalScope): 144 * workers/Worker.h: 145 * workers/WorkerGlobalScopeProxy.h: 146 * workers/WorkerMessagingProxy.cpp: 147 (WebCore::WorkerMessagingProxy::postTaskToWorkerObject): 148 (WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope): 149 (WebCore::WorkerMessagingProxy::postTaskToWorkerGlobalScope): 150 * workers/WorkerMessagingProxy.h: 151 * workers/WorkerObjectProxy.h: 152 (WebCore::WorkerObjectProxy::postTaskToWorkerObject): 153 1 154 2020-11-20 Philippe Normand <pnormand@igalia.com> 2 155 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r270101 r270107 206 206 $(PROJECT_DIR)/Modules/mediastream/RTCDegradationPreference.idl 207 207 $(PROJECT_DIR)/Modules/mediastream/RTCDtxStatus.idl 208 $(PROJECT_DIR)/Modules/mediastream/RTCEncodedAudioFrame.idl 209 $(PROJECT_DIR)/Modules/mediastream/RTCEncodedVideoFrame.idl 208 210 $(PROJECT_DIR)/Modules/mediastream/RTCIceCandidate.idl 209 211 $(PROJECT_DIR)/Modules/mediastream/RTCIceCandidateInit.idl … … 239 241 $(PROJECT_DIR)/Modules/mediastream/RTCRtpRtxParameters.idl 240 242 $(PROJECT_DIR)/Modules/mediastream/RTCRtpSFrameTransform.idl 243 $(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransform.idl 244 $(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformProvider.idl 245 $(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformer.idl 246 $(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl 241 247 $(PROJECT_DIR)/Modules/mediastream/RTCRtpSendParameters.idl 242 248 $(PROJECT_DIR)/Modules/mediastream/RTCRtpSender+Transform.idl … … 341 347 $(PROJECT_DIR)/Modules/streams/WritableStreamDefaultWriter.js 342 348 $(PROJECT_DIR)/Modules/streams/WritableStreamInternals.js 349 $(PROJECT_DIR)/Modules/streams/WritableStreamSink.idl 343 350 $(PROJECT_DIR)/Modules/webaudio/AnalyserNode.idl 344 351 $(PROJECT_DIR)/Modules/webaudio/AnalyserOptions.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r270101 r270107 1650 1650 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCDtxStatus.cpp 1651 1651 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCDtxStatus.h 1652 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCEncodedAudioFrame.cpp 1653 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCEncodedAudioFrame.h 1654 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCEncodedVideoFrame.cpp 1655 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCEncodedVideoFrame.h 1652 1656 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCIceCandidate.cpp 1653 1657 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCIceCandidate.h … … 1712 1716 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSFrameTransform.cpp 1713 1717 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSFrameTransform.h 1718 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransform.cpp 1719 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransform.h 1720 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformProvider.cpp 1721 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformProvider.h 1722 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformer.cpp 1723 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformer.h 1724 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformerConstructor.cpp 1725 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformerConstructor.h 1714 1726 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSendParameters.cpp 1715 1727 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSendParameters.h … … 2574 2586 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamDefaultWriter.cpp 2575 2587 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamDefaultWriter.h 2588 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamSink.cpp 2589 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamSink.h 2576 2590 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSXMLDocument.cpp 2577 2591 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSXMLDocument.h -
trunk/Source/WebCore/DerivedSources.make
r270101 r270107 232 232 $(WebCore)/Modules/mediastream/RTCDegradationPreference.idl \ 233 233 $(WebCore)/Modules/mediastream/RTCDtxStatus.idl \ 234 $(WebCore)/Modules/mediastream/RTCEncodedAudioFrame.idl \ 235 $(WebCore)/Modules/mediastream/RTCEncodedVideoFrame.idl \ 234 236 $(WebCore)/Modules/mediastream/RTCIceCandidate.idl \ 235 237 $(WebCore)/Modules/mediastream/RTCIceCandidateInit.idl \ … … 266 268 $(WebCore)/Modules/mediastream/RTCRtpSender+Transform.idl \ 267 269 $(WebCore)/Modules/mediastream/RTCRtpSFrameTransform.idl \ 270 $(WebCore)/Modules/mediastream/RTCRtpScriptTransform.idl \ 271 $(WebCore)/Modules/mediastream/RTCRtpScriptTransformProvider.idl \ 272 $(WebCore)/Modules/mediastream/RTCRtpScriptTransformer.idl \ 273 $(WebCore)/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl \ 268 274 $(WebCore)/Modules/mediastream/RTCRtpSynchronizationSource.idl \ 269 275 $(WebCore)/Modules/mediastream/RTCRtpTransceiver.idl \ 270 276 $(WebCore)/Modules/mediastream/RTCRtpTransceiverDirection.idl \ 271 $(WebCore)/Modules/mediastream/RTCRtpTransform.idl \272 277 $(WebCore)/Modules/mediastream/RTCSdpType.idl \ 273 278 $(WebCore)/Modules/mediastream/RTCSessionDescription.idl \ … … 345 350 $(WebCore)/Modules/streams/WritableStreamDefaultController.idl \ 346 351 $(WebCore)/Modules/streams/WritableStreamDefaultWriter.idl \ 352 $(WebCore)/Modules/streams/WritableStreamSink.idl \ 347 353 $(WebCore)/Modules/webaudio/AnalyserNode.idl \ 348 354 $(WebCore)/Modules/webaudio/AnalyserOptions.idl \ … … 1233 1239 $(WebCore)/testing/MockPaymentCoordinator.idl \ 1234 1240 $(WebCore)/testing/MockPaymentError.idl \ 1235 $(WebCore)/testing/MockRTCRtpTransform.idl \1236 1241 $(WebCore)/testing/MockWebAuthenticationConfiguration.idl \ 1237 1242 $(WebCore)/testing/ServiceWorkerInternals.idl \ -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedAudioFrame.cpp
r270106 r270107 24 24 */ 25 25 26 [ 27 Conditional=WEB_RTC, 28 JSGenerateToJSObject, 29 JSGenerateToNativeObject, 30 LegacyNoInterfaceObject, 31 ] interface MockRTCRtpTransform : RTCRtpTransform { 32 readonly attribute boolean isProcessing; 33 }; 26 #include "config.h" 27 #include "RTCEncodedAudioFrame.h" 28 29 #if ENABLE(WEB_RTC) 30 31 namespace WebCore { 32 33 RTCEncodedAudioFrame::RTCEncodedAudioFrame(UniqueRef<RTCRtpTransformableFrame>&& frame) 34 : RTCEncodedFrame(WTFMove(frame)) 35 { 36 } 37 38 RTCEncodedAudioFrame::~RTCEncodedAudioFrame() = default; 39 40 } // namespace WebCore 41 42 #endif // ENABLE(WEB_RTC) -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedAudioFrame.h
r270106 r270107 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 … … 28 28 #if ENABLE(WEB_RTC) 29 29 30 #include "RTCRtpSender.h" 31 #include "RTCRtpTransform.h" 30 #include "RTCEncodedFrame.h" 32 31 33 32 namespace WebCore { 34 33 35 class RTCRtpTransform; 34 class RTCEncodedAudioFrame : public RTCEncodedFrame { 35 public: 36 static Ref<RTCEncodedAudioFrame> create(UniqueRef<RTCRtpTransformableFrame>&& frame) { return adoptRef(*new RTCEncodedAudioFrame(WTFMove(frame))); } 37 ~RTCEncodedAudioFrame(); 36 38 37 class RTCRtpSenderWithTransform { 38 public: 39 static RTCRtpTransform* transform(RTCRtpSender& sender) { return sender.transform(); } 40 static ExceptionOr<void> setTransform(RTCRtpSender& sender, RefPtr<RTCRtpTransform>&& transform) { return sender.setTransform(WTFMove(transform)); } 39 private: 40 explicit RTCEncodedAudioFrame(UniqueRef<RTCRtpTransformableFrame>&&); 41 41 }; 42 42 -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedAudioFrame.idl
r270106 r270107 26 26 [ 27 27 Conditional=WEB_RTC, 28 EnabledBySetting=WebRTCInsertableStreams, 29 Exposed=Window, 30 ImplementedBy=RTCRtpSenderWithTransform, 31 ] partial interface RTCRtpSender { 32 [MayThrowException] attribute RTCRtpTransform? transform; 28 Exposed=DedicatedWorker, 29 ImplementationLacksVTable, 30 ] interface RTCEncodedAudioFrame { 31 // readonly attribute unsigned long long timestamp; 32 attribute ArrayBuffer data; 33 // RTCAudioFrameMetadata getMetadata(); 33 34 }; -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedFrame.cpp
r270106 r270107 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "RTCEncodedFrame.h" 27 28 28 29 #if ENABLE(WEB_RTC) 29 30 30 #include "RTCRtpReceiver.h"31 #include "RTCRtpTransform.h"31 #include <JavaScriptCore/JSCInlines.h> 32 #include <JavaScriptCore/StrongInlines.h> 32 33 33 34 namespace WebCore { 34 35 35 class RTCRtpTransform; 36 RTCEncodedFrame::RTCEncodedFrame(UniqueRef<RTCRtpTransformableFrame>&& frame) 37 : m_frame(WTFMove(frame)) 38 { 39 } 36 40 37 class RTCRtpReceiverWithTransform { 38 public: 39 static RTCRtpTransform* transform(RTCRtpReceiver& receiver) { return receiver.transform(); } 40 static ExceptionOr<void> setTransform(RTCRtpReceiver& receiver, RefPtr<RTCRtpTransform>&& transform) { return receiver.setTransform(WTFMove(transform)); } 41 }; 41 RefPtr<JSC::ArrayBuffer> RTCEncodedFrame::data() const 42 { 43 auto data = m_frame->data(); 44 return JSC::ArrayBuffer::create(data.data, data.size); 45 } 46 47 void RTCEncodedFrame::setData(JSC::ArrayBuffer& buffer) 48 { 49 m_frame->setData({ static_cast<const uint8_t*>(buffer.data()), buffer.byteLength() }); 50 } 42 51 43 52 } // namespace WebCore -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedFrame.h
r270106 r270107 28 28 #if ENABLE(WEB_RTC) 29 29 30 #include "RTCRtpTransform.h" 30 #include "RTCRtpTransformableFrame.h" 31 #include <wtf/Ref.h> 32 #include <wtf/RefCounted.h> 33 #include <wtf/UniqueRef.h> 34 35 namespace JSC { 36 class ArrayBuffer; 37 } 31 38 32 39 namespace WebCore { 33 40 34 class MockRTCRtpTransformer; 41 class RTCEncodedFrame : public RefCounted<RTCEncodedFrame> { 42 public: 43 RefPtr<JSC::ArrayBuffer> data() const; 44 void setData(JSC::ArrayBuffer&); 35 45 36 class MockRTCRtpTransform final : public RTCRtpTransform { 37 public: 38 static Ref<MockRTCRtpTransform> create() { return adoptRef(*new MockRTCRtpTransform()); } 39 ~MockRTCRtpTransform(); 46 UniqueRef<RTCRtpTransformableFrame> takeRTCFrame() { return WTFMove(m_frame); } 40 47 41 bool isProcessing() const; 48 protected: 49 explicit RTCEncodedFrame(UniqueRef<RTCRtpTransformableFrame>&&); 42 50 43 private: 44 MockRTCRtpTransform(); 45 46 void initializeBackendForReceiver(RTCRtpTransformBackend&) final; 47 void initializeBackendForSender(RTCRtpTransformBackend&) final; 48 void willClearBackend(RTCRtpTransformBackend&) final; 49 50 RefPtr<MockRTCRtpTransformer> m_transformer; 51 UniqueRef<RTCRtpTransformableFrame> m_frame; 51 52 }; 52 53 -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedVideoFrame.cpp
r270106 r270107 24 24 */ 25 25 26 [ 27 Conditional=WEB_RTC, 28 EnabledBySetting=WebRTCInsertableStreams, 29 ExportMacro=WEBCORE_EXPORT, 30 Exposed=Window 31 ] interface RTCRtpTransform { 32 // FIXME: Add readable/writable getters 33 // readonly attribute ReadableStream readable; 34 // readonly attribute WritableStream writable; 35 }; 26 #include "config.h" 27 #include "RTCEncodedVideoFrame.h" 28 29 #if ENABLE(WEB_RTC) 30 31 namespace WebCore { 32 33 RTCEncodedVideoFrame::RTCEncodedVideoFrame(UniqueRef<RTCRtpTransformableFrame>&& frame) 34 : RTCEncodedFrame(WTFMove(frame)) 35 { 36 } 37 38 RTCEncodedVideoFrame::~RTCEncodedVideoFrame() = default; 39 40 } // namespace WebCore 41 42 #endif // ENABLE(WEB_RTC) -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedVideoFrame.h
r270106 r270107 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 … … 28 28 #if ENABLE(WEB_RTC) 29 29 30 #include "RTCRtpSender.h" 31 #include "RTCRtpTransform.h" 30 #include "RTCEncodedFrame.h" 32 31 33 32 namespace WebCore { 34 33 35 class RTCRtpTransform; 34 class RTCEncodedVideoFrame : public RTCEncodedFrame { 35 public: 36 static Ref<RTCEncodedVideoFrame> create(UniqueRef<RTCRtpTransformableFrame>&& frame) { return adoptRef(*new RTCEncodedVideoFrame(WTFMove(frame))); } 37 ~RTCEncodedVideoFrame(); 36 38 37 class RTCRtpSenderWithTransform { 38 public: 39 static RTCRtpTransform* transform(RTCRtpSender& sender) { return sender.transform(); } 40 static ExceptionOr<void> setTransform(RTCRtpSender& sender, RefPtr<RTCRtpTransform>&& transform) { return sender.setTransform(WTFMove(transform)); } 39 private: 40 explicit RTCEncodedVideoFrame(UniqueRef<RTCRtpTransformableFrame>&&); 41 41 }; 42 42 -
trunk/Source/WebCore/Modules/mediastream/RTCEncodedVideoFrame.idl
r270106 r270107 26 26 [ 27 27 Conditional=WEB_RTC, 28 EnabledBySetting=WebRTCInsertableStreams, 29 Exposed=Window, 30 ImplementedBy=RTCRtpReceiverWithTransform, 31 ] partial interface RTCRtpReceiver { 32 [MayThrowException] attribute RTCRtpTransform? transform; 28 Exposed=DedicatedWorker, 29 ImplementationLacksVTable, 30 ] interface RTCEncodedVideoFrame { 31 // readonly attribute RTCEncodedVideoFrameType type; 32 // readonly attribute unsigned long long timestamp; 33 attribute ArrayBuffer data; 34 // RTCVideoFrameMetadata getMetadata(); 33 35 }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver+Transform.idl
r269764 r270107 24 24 */ 25 25 26 typedef (RTCRtpSFrameTransform or RTCRtpScriptTransform) RTCRtpTransform; 27 26 28 [ 27 29 Conditional=WEB_RTC, -
trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp
r269764 r270107 82 82 } 83 83 84 ExceptionOr<void> RTCRtpReceiver::setTransform( RefPtr<RTCRtpTransform>&& transform)84 ExceptionOr<void> RTCRtpReceiver::setTransform(Optional<RTCRtpTransform>&& transform) 85 85 { 86 if (transform && m_transform && *transform == *m_transform) 87 return { }; 86 88 if (transform && transform->isAttached()) 87 89 return Exception { InvalidStateError, "transform is already in use"_s }; … … 96 98 } 97 99 100 Optional<RTCRtpTransform::Internal> RTCRtpReceiver::transform() 101 { 102 if (!m_transform) 103 return { }; 104 return m_transform->internalTransform(); 105 } 106 98 107 } // namespace WebCore 99 108 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h
r269764 r270107 68 68 void getStats(Ref<DeferredPromise>&&); 69 69 70 RTCRtpTransform* transform() { return m_transform.get(); }71 ExceptionOr<void> setTransform( RefPtr<RTCRtpTransform>&&);70 Optional<RTCRtpTransform::Internal> transform(); 71 ExceptionOr<void> setTransform(Optional<RTCRtpTransform>&&); 72 72 73 73 private: … … 77 77 std::unique_ptr<RTCRtpReceiverBackend> m_backend; 78 78 WeakPtr<PeerConnectionBackend> m_connection; 79 RefPtr<RTCRtpTransform> m_transform;79 Optional<RTCRtpTransform> m_transform; 80 80 }; 81 81 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiverWithTransform.h
r269764 r270107 37 37 class RTCRtpReceiverWithTransform { 38 38 public: 39 static RTCRtpTransform*transform(RTCRtpReceiver& receiver) { return receiver.transform(); }40 static ExceptionOr<void> setTransform(RTCRtpReceiver& receiver, RefPtr<RTCRtpTransform>&& transform) { return receiver.setTransform(WTFMove(transform)); }39 static Optional<RTCRtpTransform::Internal> transform(RTCRtpReceiver& receiver) { return receiver.transform(); } 40 static ExceptionOr<void> setTransform(RTCRtpReceiver& receiver, Optional<RTCRtpTransform::Internal>&& transform) { return receiver.setTransform(RTCRtpTransform::from(WTFMove(transform))); } 41 41 }; 42 42 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp
r269830 r270107 32 32 #include "Logging.h" 33 33 #include "RTCRtpSFrameTransformer.h" 34 #include "RTCRtpTransformBackend.h" 34 35 #include "RTCRtpTransformableFrame.h" 35 36 … … 69 70 void RTCRtpSFrameTransform::initializeTransformer(RTCRtpTransformBackend& backend, Side side) 70 71 { 72 m_isAttached = true; 71 73 m_transformer->setIsSending(side == Side::Sender); 72 74 m_transformer->setIsProcessingAudio(backend.mediaType() == RTCRtpTransformBackend::MediaType::Audio); 73 75 74 76 backend.setTransformableFrameCallback([transformer = m_transformer, backend = makeRef(backend)](auto&& frame) { 75 auto chunk = frame .data();77 auto chunk = frame->data(); 76 78 auto result = transformer->transform(chunk.data, chunk.size); 77 79 … … 81 83 } 82 84 83 frame .setData({ result.returnValue().data(), result.returnValue().size() });85 frame->setData({ result.returnValue().data(), result.returnValue().size() }); 84 86 85 backend->processTransformedFrame(WTFMove(frame ));87 backend->processTransformedFrame(WTFMove(frame.get())); 86 88 }); 87 89 } … … 101 103 { 102 104 backend.clearTransformableFrameCallback(); 105 m_isAttached = false; 103 106 } 104 107 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.h
r269830 r270107 29 29 30 30 #include "JSDOMPromiseDeferred.h" 31 #include "RTCRtpTransform.h"32 31 33 32 namespace WebCore { … … 35 34 class CryptoKey; 36 35 class RTCRtpSFrameTransformer; 36 class RTCRtpTransformBackend; 37 37 38 class RTCRtpSFrameTransform final : public RTCRtpTransform{38 class RTCRtpSFrameTransform : public RefCounted<RTCRtpSFrameTransform> { 39 39 public: 40 40 static Ref<RTCRtpSFrameTransform> create() { return adoptRef(*new RTCRtpSFrameTransform); } … … 43 43 void setEncryptionKey(CryptoKey&, Optional<uint64_t>, DOMPromiseDeferred<void>&&); 44 44 45 bool isAttached() const { return m_isAttached; } 46 void initializeBackendForReceiver(RTCRtpTransformBackend&); 47 void initializeBackendForSender(RTCRtpTransformBackend&); 48 void willClearBackend(RTCRtpTransformBackend&); 49 45 50 WEBCORE_EXPORT uint64_t counterForTesting() const; 46 51 … … 48 53 RTCRtpSFrameTransform(); 49 54 50 void initializeBackendForReceiver(RTCRtpTransformBackend&) final;51 void initializeBackendForSender(RTCRtpTransformBackend&) final;52 void willClearBackend(RTCRtpTransformBackend&) final;53 54 55 enum class Side { Sender, Receiver }; 55 56 void initializeTransformer(RTCRtpTransformBackend&, Side); 56 57 58 bool m_isAttached { false }; 57 59 Ref<RTCRtpSFrameTransformer> m_transformer; 58 60 }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.idl
r269830 r270107 29 29 ExportMacro=WEBCORE_EXPORT, 30 30 Exposed=Window, 31 ImplementationLacksVTable, 31 32 JSGenerateToNativeObject, 32 ] interface RTCRtpSFrameTransform : RTCRtpTransform{33 ] interface RTCRtpSFrameTransform { 33 34 constructor(); 34 35 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.idl
r270106 r270107 25 25 26 26 [ 27 ActiveDOMObject, 27 28 Conditional=WEB_RTC, 28 29 EnabledBySetting=WebRTCInsertableStreams, 29 30 Exposed=Window, 30 ImplementedBy=RTCRtpSenderWithTransform, 31 ] partial interface RTCRtpSender { 32 [MayThrowException] attribute RTCRtpTransform? transform; 31 JSGenerateToNativeObject, 32 ] interface RTCRtpScriptTransform : EventTarget { 33 [CallWith=ScriptExecutionContext] constructor(Worker worker, DOMString name); 34 35 readonly attribute MessagePort port; 33 36 }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformProvider.idl
r270106 r270107 24 24 */ 25 25 26 [ 27 Conditional=WEB_RTC, 28 EnabledBySetting=WebRTCInsertableStreams, 29 Exposed=Window, 30 ImplementedBy=RTCRtpSenderWithTransform, 31 ] partial interface RTCRtpSender { 32 [MayThrowException] attribute RTCRtpTransform? transform; 26 interface mixin RTCRtpScriptTransformProvider { 27 [MayThrowException] undefined registerRTCRtpScriptTransformer(DOMString name, RTCRtpScriptTransformerConstructor processorConstructor); 33 28 }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.h
r270106 r270107 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 … … 28 28 #if ENABLE(WEB_RTC) 29 29 30 #include "RTCRtpTransformBackend.h" 30 #include "ActiveDOMObject.h" 31 #include "ExceptionOr.h" 31 32 #include <wtf/RefCounted.h> 32 #include <wtf/ RefPtr.h>33 #include <wtf/WeakPtr.h> 33 34 34 35 namespace WebCore { 35 36 36 class RTCRtpReceiver; 37 class RTCRtpSender; 37 class JSCallbackDataStrong; 38 class MessagePort; 39 class ScriptExecutionContext; 40 class RTCRtpTransformBackend; 41 class RTCRtpReadableStreamSource; 38 42 39 class WEBCORE_EXPORT RTCRtpTransform : public RefCounted<RTCRtpTransform> { 43 class RTCRtpScriptTransformer 44 : public RefCounted<RTCRtpScriptTransformer> 45 , public ActiveDOMObject 46 , public CanMakeWeakPtr<RTCRtpScriptTransformer> { 40 47 public: 41 virtual ~RTCRtpTransform(); 48 static ExceptionOr<Ref<RTCRtpScriptTransformer>> create(ScriptExecutionContext&); 49 ~RTCRtpScriptTransformer(); 42 50 43 bool isAttached() const; 44 void attachToReceiver(RTCRtpReceiver&); 45 void attachToSender(RTCRtpSender&); 46 void detachFromReceiver(RTCRtpReceiver&); 47 void detachFromSender(RTCRtpSender&); 51 void setCallback(std::unique_ptr<JSCallbackDataStrong>&& callback) { m_callback = WTFMove(callback); } 52 MessagePort& port() { return m_port.get(); } 53 54 void start(Ref<RTCRtpTransformBackend>&&); 55 void clear(); 56 57 void startPendingActivity() { m_pendingActivity = makePendingActivity(*this); } 48 58 49 59 private: 50 virtual void initializeBackendForSender(RTCRtpTransformBackend&); 51 virtual void initializeBackendForReceiver(RTCRtpTransformBackend&); 52 virtual void willClearBackend(RTCRtpTransformBackend&); 60 RTCRtpScriptTransformer(ScriptExecutionContext&, Ref<MessagePort>&&); 53 61 54 protected: 62 RefPtr<RTCRtpReadableStreamSource> startStreams(RTCRtpTransformBackend&); 63 64 // ActiveDOMObject 65 const char* activeDOMObjectName() const { return "RTCRtpScriptTransformer"; } 66 void stop() final { stopPendingActivity(); } 67 void stopPendingActivity() { auto pendingActivity = WTFMove(m_pendingActivity); } 68 69 Ref<MessagePort> m_port; 70 std::unique_ptr<JSCallbackDataStrong> m_callback; 55 71 RefPtr<RTCRtpTransformBackend> m_backend; 72 RefPtr<PendingActivity<RTCRtpScriptTransformer>> m_pendingActivity; 73 56 74 }; 57 58 inline bool RTCRtpTransform::isAttached() const59 {60 return !!m_backend;61 }62 63 inline void RTCRtpTransform::initializeBackendForSender(RTCRtpTransformBackend&)64 {65 }66 67 inline void RTCRtpTransform::initializeBackendForReceiver(RTCRtpTransformBackend&)68 {69 }70 71 inline void RTCRtpTransform::willClearBackend(RTCRtpTransformBackend&)72 {73 }74 75 75 76 } // namespace WebCore -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.idl
r270106 r270107 24 24 */ 25 25 26 // FIXME: Add EnabledBySetting=WebRTCInsertableStreams, 26 27 [ 28 ActiveDOMObject, 27 29 Conditional=WEB_RTC, 28 EnabledBySetting=WebRTCInsertableStreams, 29 Exposed=Window, 30 ImplementedBy=RTCRtpReceiverWithTransform, 31 ] partial interface RTCRtpReceiver { 32 [MayThrowException] attribute RTCRtpTransform? transform; 30 Exposed=DedicatedWorker, 31 JSGenerateToNativeObject, 32 ] interface RTCRtpScriptTransformer { 33 [CallWith=ScriptExecutionContext] constructor(/* optional object transformOptions */); 34 35 // FIXME: add controller attribute. 36 readonly attribute MessagePort port; 33 37 }; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.h
r270106 r270107 1 1 /* 2 * Copyright (C) 2020 Apple Inc. 2 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions 6 6 * are met: 7 * 7 8 * 1. Redistributions of source code must retain the above copyright 8 9 * notice, this list of conditions and the following disclaimer. … … 10 11 * notice, this list of conditions and the following disclaimer in the 11 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 12 16 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''AND ANY17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC.OR ITS CONTRIBUTORS BE LIABLE FOR ANY20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 27 */ 24 28 … … 27 31 #if ENABLE(WEB_RTC) 28 32 33 #include "ActiveDOMCallback.h" 34 #include "CallbackResult.h" 35 #include <wtf/RefCounted.h> 36 29 37 namespace WebCore { 30 38 31 class RTCRtpTransformableFrame { 39 class RTCRtpScriptTransformer; 40 41 class RTCRtpScriptTransformerConstructor : public RefCounted<RTCRtpScriptTransformerConstructor>, public ActiveDOMCallback { 32 42 public: 33 virtual ~RTCRtpTransformableFrame() = default;43 using ActiveDOMCallback::ActiveDOMCallback; 34 44 35 struct Data { 36 const uint8_t* data; 37 size_t size; 38 }; 39 virtual Data data() const = 0; 40 virtual void setData(Data) = 0; 45 virtual CallbackResult<RefPtr<RTCRtpScriptTransformer>> handleEvent() = 0; 41 46 }; 42 47 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl
r270106 r270107 1 1 /* 2 * Copyright (C) 2020 Apple Inc. 2 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions 6 6 * are met: 7 * 7 8 * 1. Redistributions of source code must retain the above copyright 8 9 * notice, this list of conditions and the following disclaimer. … … 10 11 * notice, this list of conditions and the following disclaimer in the 11 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 12 16 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''AND ANY17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC.OR ITS CONTRIBUTORS BE LIABLE FOR ANY20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 27 */ 24 28 25 #pragma once 26 27 #if ENABLE(WEB_RTC) 28 29 namespace WebCore { 30 31 class RTCRtpTransformableFrame { 32 public: 33 virtual ~RTCRtpTransformableFrame() = default; 34 35 struct Data { 36 const uint8_t* data; 37 size_t size; 38 }; 39 virtual Data data() const = 0; 40 virtual void setData(Data) = 0; 41 }; 42 43 } // namespace WebCore 44 45 #endif // ENABLE(WEB_RTC) 29 [ 30 Conditional=WEB_RTC, 31 ] callback RTCRtpScriptTransformerConstructor = RTCRtpScriptTransformer(); -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSender+Transform.idl
r269764 r270107 24 24 */ 25 25 26 typedef (RTCRtpSFrameTransform or RTCRtpScriptTransform) RTCRtpTransform; 27 26 28 [ 27 29 Conditional=WEB_RTC, -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp
r269764 r270107 194 194 } 195 195 196 ExceptionOr<void> RTCRtpSender::setTransform(RefPtr<RTCRtpTransform>&& transform) 197 { 196 ExceptionOr<void> RTCRtpSender::setTransform(Optional<RTCRtpTransform>&& transform) 197 { 198 if (transform && m_transform && *transform == *m_transform) 199 return { }; 198 200 if (transform && transform->isAttached()) 199 201 return Exception { InvalidStateError, "transform is already in use"_s }; … … 208 210 } 209 211 212 Optional<RTCRtpTransform::Internal> RTCRtpSender::transform() 213 { 214 if (!m_transform) 215 return { }; 216 return m_transform->internalTransform(); 217 } 218 210 219 } // namespace WebCore 211 220 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.h
r269764 r270107 83 83 Optional<RTCRtpTransceiverDirection> currentTransceiverDirection() const; 84 84 85 RTCRtpTransform* transform() { return m_transform.get(); }86 ExceptionOr<void> setTransform( RefPtr<RTCRtpTransform>&&);85 Optional<RTCRtpTransform::Internal> transform(); 86 ExceptionOr<void> setTransform(Optional<RTCRtpTransform>&&); 87 87 88 88 private: … … 96 96 WeakPtr<RTCPeerConnection> m_connection; 97 97 RefPtr<RTCDTMFSender> m_dtmfSender; 98 RefPtr<RTCRtpTransform> m_transform;98 Optional<RTCRtpTransform> m_transform; 99 99 }; 100 100 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpSenderWithTransform.h
r269764 r270107 37 37 class RTCRtpSenderWithTransform { 38 38 public: 39 static RTCRtpTransform*transform(RTCRtpSender& sender) { return sender.transform(); }40 static ExceptionOr<void> setTransform(RTCRtpSender& sender, RefPtr<RTCRtpTransform>&& transform) { return sender.setTransform(WTFMove(transform)); }39 static Optional<RTCRtpTransform::Internal> transform(RTCRtpSender& sender) { return sender.transform(); } 40 static ExceptionOr<void> setTransform(RTCRtpSender& sender, Optional<RTCRtpTransform::Internal>&& transform) { return sender.setTransform(RTCRtpTransform::from(WTFMove(transform))); } 41 41 }; 42 42 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransform.cpp
r269764 r270107 34 34 namespace WebCore { 35 35 36 Optional<RTCRtpTransform> RTCRtpTransform::from(Optional<Internal>&& internal) 37 { 38 if (!internal) 39 return { }; 40 return RTCRtpTransform(WTFMove(*internal)); 41 } 42 43 RTCRtpTransform::RTCRtpTransform(Internal&& transform) 44 : m_transform(WTFMove(transform)) 45 { 46 } 47 36 48 RTCRtpTransform::~RTCRtpTransform() 37 49 { 38 if (m_backend) 39 willClearBackend(*m_backend); 50 clearBackend(); 51 } 52 53 bool RTCRtpTransform::isAttached() const 54 { 55 return switchOn(m_transform, [&](const RefPtr<RTCRtpSFrameTransform>& sframeTransform) { 56 return sframeTransform->isAttached(); 57 }, [&](const RefPtr<RTCRtpScriptTransform>& scriptTransform) { 58 return scriptTransform->isAttached(); 59 }); 40 60 } 41 61 … … 45 65 if (auto* backend = receiver.backend()) 46 66 m_backend = backend->createRTCRtpTransformBackend(); 47 if (m_backend) 48 initializeBackendForReceiver(*m_backend); 67 if (m_backend) { 68 switchOn(m_transform, [&](RefPtr<RTCRtpSFrameTransform>& sframeTransform) { 69 sframeTransform->initializeBackendForReceiver(*m_backend); 70 }, [&](RefPtr<RTCRtpScriptTransform>& scriptTransform) { 71 scriptTransform->initializeBackendForReceiver(*m_backend); 72 }); 73 } 49 74 } 50 75 … … 54 79 if (auto* backend = sender.backend()) 55 80 m_backend = backend->createRTCRtpTransformBackend(); 56 if (m_backend) 57 initializeBackendForSender(*m_backend); 81 if (m_backend) { 82 switchOn(m_transform, [&](RefPtr<RTCRtpSFrameTransform>& sframeTransform) { 83 sframeTransform->initializeBackendForSender(*m_backend); 84 }, [&](RefPtr<RTCRtpScriptTransform>& scriptTransform) { 85 scriptTransform->initializeBackendForSender(*m_backend); 86 }); 87 } 88 } 89 90 void RTCRtpTransform::clearBackend() 91 { 92 if (!m_backend) 93 return; 94 95 switchOn(m_transform, [&](RefPtr<RTCRtpSFrameTransform>& sframeTransform) { 96 sframeTransform->willClearBackend(*m_backend); 97 }, [&](RefPtr<RTCRtpScriptTransform>& scriptTransform) { 98 scriptTransform->willClearBackend(*m_backend); 99 }); 100 101 m_backend = nullptr; 58 102 } 59 103 60 104 void RTCRtpTransform::detachFromReceiver(RTCRtpReceiver&) 61 105 { 62 if (!m_backend) 63 return; 64 65 willClearBackend(*m_backend); 66 m_backend = nullptr; 106 clearBackend(); 67 107 } 68 108 69 109 void RTCRtpTransform::detachFromSender(RTCRtpSender&) 70 110 { 71 if (!m_backend)72 return; 111 clearBackend(); 112 } 73 113 74 willClearBackend(*m_backend); 75 m_backend = nullptr; 114 bool operator==(const RTCRtpTransform& a, const RTCRtpTransform& b) 115 { 116 return switchOn(a.m_transform, [&](const RefPtr<RTCRtpSFrameTransform>& sframeTransformA) { 117 return switchOn(b.m_transform, [&](const RefPtr<RTCRtpSFrameTransform>& sframeTransformB) { 118 return sframeTransformA.get() == sframeTransformB.get(); 119 }, [&](const RefPtr<RTCRtpScriptTransform>&) { 120 return false; 121 }); 122 }, [&](const RefPtr<RTCRtpScriptTransform>& scriptTransformA) { 123 return switchOn(b.m_transform, [&](const RefPtr<RTCRtpSFrameTransform>&) { 124 return false; 125 }, [&](const RefPtr<RTCRtpScriptTransform>& scriptTransformB) { 126 return scriptTransformA.get() == scriptTransformB.get(); 127 }); 128 }); 76 129 } 77 130 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransform.h
r269764 r270107 28 28 #if ENABLE(WEB_RTC) 29 29 30 #include "RTCRtpSFrameTransform.h" 31 #include "RTCRtpScriptTransform.h" 30 32 #include "RTCRtpTransformBackend.h" 31 #include <wtf/RefCounted.h>32 #include <wtf/RefPtr.h>33 33 34 34 namespace WebCore { … … 37 37 class RTCRtpSender; 38 38 39 class WEBCORE_EXPORT RTCRtpTransform : public RefCounted<RTCRtpTransform>{39 class RTCRtpTransform { 40 40 public: 41 virtual ~RTCRtpTransform(); 41 using Internal = Variant<RefPtr<RTCRtpSFrameTransform>, RefPtr<RTCRtpScriptTransform>>; 42 static Optional<RTCRtpTransform> from(Optional<Internal>&&); 43 44 explicit RTCRtpTransform(Internal&&); 45 ~RTCRtpTransform(); 42 46 43 47 bool isAttached() const; … … 47 51 void detachFromSender(RTCRtpSender&); 48 52 53 Internal internalTransform() { return m_transform; } 54 55 friend bool operator==(const RTCRtpTransform&, const RTCRtpTransform&); 56 49 57 private: 50 virtual void initializeBackendForSender(RTCRtpTransformBackend&); 51 virtual void initializeBackendForReceiver(RTCRtpTransformBackend&); 52 virtual void willClearBackend(RTCRtpTransformBackend&); 58 void clearBackend(); 53 59 54 protected:55 60 RefPtr<RTCRtpTransformBackend> m_backend; 61 Internal m_transform; 56 62 }; 57 63 58 inline bool RTCRtpTransform::isAttached() const 64 bool operator==(const RTCRtpTransform&, const RTCRtpTransform&); 65 inline bool operator!=(const RTCRtpTransform& a, const RTCRtpTransform& b) 59 66 { 60 return !!m_backend; 61 } 62 63 inline void RTCRtpTransform::initializeBackendForSender(RTCRtpTransformBackend&) 64 { 65 } 66 67 inline void RTCRtpTransform::initializeBackendForReceiver(RTCRtpTransformBackend&) 68 { 69 } 70 71 inline void RTCRtpTransform::willClearBackend(RTCRtpTransformBackend&) 72 { 67 return !(a == b); 73 68 } 74 69 -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransformBackend.h
r269764 r270107 37 37 virtual ~RTCRtpTransformBackend() = default; 38 38 39 using Callback = Function<void( RTCRtpTransformableFrame&&)>;39 using Callback = Function<void(UniqueRef<RTCRtpTransformableFrame>&&)>; 40 40 virtual void setTransformableFrameCallback(Callback&&) = 0; 41 41 virtual void clearTransformableFrameCallback() = 0; -
trunk/Source/WebCore/Modules/mediastream/RTCRtpTransformableFrame.h
r269764 r270107 30 30 31 31 class RTCRtpTransformableFrame { 32 WTF_MAKE_FAST_ALLOCATED; 32 33 public: 33 34 virtual ~RTCRtpTransformableFrame() = default; -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp
r269764 r270107 29 29 30 30 #include "LibWebRTCRtpTransformableFrame.h" 31 #include <wtf/UniqueRef.h> 31 32 32 33 namespace WebCore { … … 34 35 void LibWebRTCRtpTransformBackend::setInputCallback(Callback&& callback) 35 36 { 36 ASSERT(isMainThread());37 37 auto locker = holdLock(m_inputCallbackLock); 38 38 m_inputCallback = WTFMove(callback); … … 62 62 auto locker = holdLock(m_inputCallbackLock); 63 63 if (m_inputCallback) { 64 m_inputCallback( LibWebRTCRtpTransformableFrame(WTFMove(rtcFrame)));64 m_inputCallback(makeUniqueRef<LibWebRTCRtpTransformableFrame>(WTFMove(rtcFrame))); 65 65 return; 66 66 } -
trunk/Source/WebCore/Modules/streams/WritableStreamSink.h
r270106 r270107 24 24 */ 25 25 26 [ 27 Conditional=WEB_RTC, 28 EnabledBySetting=WebRTCInsertableStreams, 29 Exposed=Window, 30 ImplementedBy=RTCRtpReceiverWithTransform, 31 ] partial interface RTCRtpReceiver { 32 [MayThrowException] attribute RTCRtpTransform? transform; 26 27 #pragma once 28 29 #include "JSDOMPromiseDeferred.h" 30 #include <wtf/RefCounted.h> 31 #include <wtf/text/WTFString.h> 32 33 namespace JSC { 34 class JSValue; 35 } 36 37 namespace WebCore { 38 39 class WritableStreamSink : public RefCounted<WritableStreamSink> { 40 public: 41 virtual ~WritableStreamSink() = default; 42 43 virtual void write(ScriptExecutionContext&, JSC::JSValue, DOMPromiseDeferred<void>&&) = 0; 44 virtual void close() = 0; 45 virtual void error(String&&) = 0; 33 46 }; 47 48 } // namespace WebCore -
trunk/Source/WebCore/Modules/streams/WritableStreamSink.idl
r270106 r270107 24 24 */ 25 25 26 26 27 [ 27 Conditional=WEB_RTC,28 EnabledBySetting=WebRTCInsertableStreams,29 Exposed=Window, 30 ImplementedBy=RTCRtpSenderWithTransform,31 ] partial interface RTCRtpSender { 32 [MayThrowException] attribute RTCRtpTransform? transform;28 LegacyNoInterfaceObject, 29 SkipVTableValidation 30 ] interface WritableStreamSink { 31 [CallWith=ScriptExecutionContext] Promise<undefined> write(any value); 32 undefined close(); 33 undefined error(DOMString message); 33 34 }; -
trunk/Source/WebCore/Sources.txt
r270101 r270107 159 159 Modules/mediastream/RTCDataChannel.cpp 160 160 Modules/mediastream/RTCDataChannelEvent.cpp 161 Modules/mediastream/RTCEncodedAudioFrame.cpp 162 Modules/mediastream/RTCEncodedFrame.cpp 163 Modules/mediastream/RTCEncodedVideoFrame.cpp 161 164 Modules/mediastream/RTCIceCandidate.cpp 162 165 Modules/mediastream/RTCIceTransport.cpp … … 167 170 Modules/mediastream/RTCRtpSFrameTransform.cpp 168 171 Modules/mediastream/RTCRtpSFrameTransformer.cpp 172 Modules/mediastream/RTCRtpScriptTransform.cpp 173 Modules/mediastream/RTCRtpScriptTransformer.cpp 169 174 Modules/mediastream/RTCRtpSender.cpp 170 175 Modules/mediastream/RTCRtpTransform.cpp … … 625 630 bindings/js/WebCoreTypedArrayController.cpp 626 631 bindings/js/WindowProxy.cpp 632 bindings/js/WritableStream.cpp 627 633 bridge/IdentifierRep.cpp 628 634 bridge/NP_jsobject.cpp … … 3298 3304 JSRTCDegradationPreference.cpp 3299 3305 JSRTCDtxStatus.cpp 3306 JSRTCEncodedAudioFrame.cpp 3307 JSRTCEncodedVideoFrame.cpp 3300 3308 JSRTCIceCandidate.cpp 3301 3309 JSRTCIceCandidateInit.cpp … … 3327 3335 JSRTCRtpRtxParameters.cpp 3328 3336 JSRTCRtpSFrameTransform.cpp 3337 JSRTCRtpScriptTransform.cpp 3338 JSRTCRtpScriptTransformer.cpp 3339 JSRTCRtpScriptTransformerConstructor.cpp 3329 3340 JSRTCRtpSendParameters.cpp 3330 3341 JSRTCRtpSender.cpp … … 3332 3343 JSRTCRtpTransceiver.cpp 3333 3344 JSRTCRtpTransceiverDirection.cpp 3334 JSRTCRtpTransform.cpp3335 3345 JSRTCSdpType.cpp 3336 3346 JSRTCSessionDescription.cpp … … 3725 3735 JSWritableStreamDefaultController.cpp 3726 3736 JSWritableStreamDefaultWriter.cpp 3737 JSWritableStreamSink.cpp 3727 3738 JSXMLDocument.cpp 3728 3739 JSXMLHttpRequest.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r270101 r270107 1106 1106 4181C5CD2555836900AEB0FF /* LibWebRTCRtpTransformableFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5CC2555836800AEB0FF /* LibWebRTCRtpTransformableFrame.h */; }; 1107 1107 4181C5D12555895600AEB0FF /* LibWebRTCRtpTransformBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5CF2555895600AEB0FF /* LibWebRTCRtpTransformBackend.h */; }; 1108 4181C5D62555C1B900AEB0FF /* MockRTCRtpTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5D52555C1B900AEB0FF /* MockRTCRtpTransform.h */; };1109 4181C5D72555C49A00AEB0FF /* MockRTCRtpTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4181C5D32555C1B100AEB0FF /* MockRTCRtpTransform.cpp */; };1110 4181C639255AE90F00AEB0FF /* JSMockRTCRtpTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D6F3E921C1F85550061DBE4 /* JSMockRTCRtpTransform.cpp */; };1111 1108 4181C648255B4C2800AEB0FF /* RTCRtpSFrameTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C642255B4C2600AEB0FF /* RTCRtpSFrameTransformer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1112 1109 4181C64A255B4C2800AEB0FF /* RTCRtpSFrameTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C644255B4C2700AEB0FF /* RTCRtpSFrameTransform.h */; }; … … 7605 7602 413C8B242552EEA900E65055 /* RTCRtpReceiver+Transform.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "RTCRtpReceiver+Transform.idl"; sourceTree = "<group>"; }; 7606 7603 413C8B262552EEA900E65055 /* RTCRtpSender+Transform.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "RTCRtpSender+Transform.idl"; sourceTree = "<group>"; }; 7607 413C8B292552F01300E65055 /* RTCRtpTransform.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpTransform.idl; sourceTree = "<group>"; };7608 7604 413C8B2E2552F27B00E65055 /* RTCRtpSenderWithTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpSenderWithTransform.h; sourceTree = "<group>"; }; 7609 7605 413C8B2F2552F27B00E65055 /* RTCRtpTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpTransform.h; sourceTree = "<group>"; }; … … 7614 7610 413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryReleaseCocoa.mm; sourceTree = "<group>"; }; 7615 7611 413FC4CD1FD1DD8C00541C4B /* ServiceWorkerClientQueryOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerClientQueryOptions.h; sourceTree = "<group>"; }; 7612 414189EF2562DF0C00363417 /* RTCRtpScriptTransformProvider.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpScriptTransformProvider.idl; sourceTree = "<group>"; }; 7613 414189F02562DF5500363417 /* RTCRtpScriptTransform.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpScriptTransform.idl; sourceTree = "<group>"; }; 7614 414189F12562DF5600363417 /* RTCRtpScriptTransformer.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpScriptTransformer.idl; sourceTree = "<group>"; }; 7615 414189F22562E32B00363417 /* RTCRtpScriptTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpScriptTransform.h; sourceTree = "<group>"; }; 7616 414189F32562E32C00363417 /* RTCRtpScriptTransformer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpScriptTransformer.cpp; sourceTree = "<group>"; }; 7617 414189F42562E32C00363417 /* RTCRtpScriptTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpScriptTransform.cpp; sourceTree = "<group>"; }; 7618 414189F52562E32D00363417 /* RTCRtpScriptTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpScriptTransformer.h; sourceTree = "<group>"; }; 7619 414189F62562E67A00363417 /* RTCRtpScriptTransformerConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpScriptTransformerConstructor.h; sourceTree = "<group>"; }; 7620 414189F72562E67A00363417 /* RTCRtpScriptTransformerConstructor.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpScriptTransformerConstructor.idl; sourceTree = "<group>"; }; 7621 414189F92564165000363417 /* RTCEncodedAudioFrame.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCEncodedAudioFrame.idl; sourceTree = "<group>"; }; 7622 414189FA2564165100363417 /* RTCEncodedVideoFrame.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCEncodedVideoFrame.idl; sourceTree = "<group>"; }; 7623 414189FB2564175700363417 /* RTCEncodedAudioFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncodedAudioFrame.h; sourceTree = "<group>"; }; 7624 414189FD2564176600363417 /* RTCEncodedVideoFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncodedVideoFrame.h; sourceTree = "<group>"; }; 7625 414189FE256418E000363417 /* RTCEncodedAudioFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCEncodedAudioFrame.cpp; sourceTree = "<group>"; }; 7626 414189FF256418E700363417 /* RTCEncodedVideoFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCEncodedVideoFrame.cpp; sourceTree = "<group>"; }; 7627 41418A002564359700363417 /* WritableStreamSink.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WritableStreamSink.idl; sourceTree = "<group>"; }; 7628 41418A022564359800363417 /* WritableStreamSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableStreamSink.h; sourceTree = "<group>"; }; 7629 41418A0325643E1200363417 /* WritableStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WritableStream.cpp; sourceTree = "<group>"; }; 7630 41418A0425643E1300363417 /* WritableStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableStream.h; sourceTree = "<group>"; }; 7631 41418A05256660AF00363417 /* RTCEncodedFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCEncodedFrame.cpp; sourceTree = "<group>"; }; 7632 41418A06256660B000363417 /* RTCEncodedFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncodedFrame.h; sourceTree = "<group>"; }; 7616 7633 414460A02412994100814BE7 /* MediaSessionIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionIdentifier.h; sourceTree = "<group>"; }; 7617 7634 414598BE23C8AAB8002B9CC8 /* SampleBufferDisplayLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleBufferDisplayLayer.h; sourceTree = "<group>"; }; … … 7729 7746 4181C5CE2555895500AEB0FF /* LibWebRTCRtpTransformBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCRtpTransformBackend.cpp; path = libwebrtc/LibWebRTCRtpTransformBackend.cpp; sourceTree = "<group>"; }; 7730 7747 4181C5CF2555895600AEB0FF /* LibWebRTCRtpTransformBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCRtpTransformBackend.h; path = libwebrtc/LibWebRTCRtpTransformBackend.h; sourceTree = "<group>"; }; 7731 4181C5D32555C1B100AEB0FF /* MockRTCRtpTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRTCRtpTransform.cpp; sourceTree = "<group>"; };7732 4181C5D52555C1B900AEB0FF /* MockRTCRtpTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRTCRtpTransform.h; sourceTree = "<group>"; };7733 4181C636255AE26100AEB0FF /* MockRTCRtpTransform.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockRTCRtpTransform.idl; sourceTree = "<group>"; };7734 7748 4181C63F255B4C2500AEB0FF /* RTCRtpSFrameTransformerCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpSFrameTransformerCocoa.cpp; sourceTree = "<group>"; }; 7735 7749 4181C641255B4C2600AEB0FF /* RTCRtpSFrameTransformer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpSFrameTransformer.cpp; sourceTree = "<group>"; }; … … 17097 17111 41FCB75E214866FF0038ADC6 /* RTCDtxStatus.h */, 17098 17112 41FCB757214865D10038ADC6 /* RTCDtxStatus.idl */, 17113 414189FE256418E000363417 /* RTCEncodedAudioFrame.cpp */, 17114 414189FB2564175700363417 /* RTCEncodedAudioFrame.h */, 17115 414189F92564165000363417 /* RTCEncodedAudioFrame.idl */, 17116 41418A05256660AF00363417 /* RTCEncodedFrame.cpp */, 17117 41418A06256660B000363417 /* RTCEncodedFrame.h */, 17118 414189FF256418E700363417 /* RTCEncodedVideoFrame.cpp */, 17119 414189FD2564176600363417 /* RTCEncodedVideoFrame.h */, 17120 414189FA2564165100363417 /* RTCEncodedVideoFrame.idl */, 17099 17121 07221B7117CEC32700848E51 /* RTCIceCandidate.cpp */, 17100 17122 07221B7217CEC32700848E51 /* RTCIceCandidate.h */, … … 17160 17182 41FCB760214867000038ADC6 /* RTCRtpRtxParameters.h */, 17161 17183 41FCB758214865D20038ADC6 /* RTCRtpRtxParameters.idl */, 17184 414189F42562E32C00363417 /* RTCRtpScriptTransform.cpp */, 17185 414189F22562E32B00363417 /* RTCRtpScriptTransform.h */, 17186 414189F02562DF5500363417 /* RTCRtpScriptTransform.idl */, 17187 414189F32562E32C00363417 /* RTCRtpScriptTransformer.cpp */, 17188 414189F52562E32D00363417 /* RTCRtpScriptTransformer.h */, 17189 414189F12562DF5600363417 /* RTCRtpScriptTransformer.idl */, 17190 414189F62562E67A00363417 /* RTCRtpScriptTransformerConstructor.h */, 17191 414189F72562E67A00363417 /* RTCRtpScriptTransformerConstructor.idl */, 17192 414189EF2562DF0C00363417 /* RTCRtpScriptTransformProvider.idl */, 17162 17193 413C8B262552EEA900E65055 /* RTCRtpSender+Transform.idl */, 17163 17194 5E2C43591BCEE30D0001E2BC /* RTCRtpSender.cpp */, … … 17183 17214 4181C5C62555735100AEB0FF /* RTCRtpTransform.cpp */, 17184 17215 413C8B2F2552F27B00E65055 /* RTCRtpTransform.h */, 17185 413C8B292552F01300E65055 /* RTCRtpTransform.idl */,17186 17216 4181C5CA255582E300AEB0FF /* RTCRtpTransformableFrame.h */, 17187 17217 4181C5C8255573DF00AEB0FF /* RTCRtpTransformBackend.h */, … … 19340 19370 A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */, 19341 19371 A140618A1E2ECA0A0032B34E /* MockPreviewLoaderClient.h */, 19342 4181C5D32555C1B100AEB0FF /* MockRTCRtpTransform.cpp */,19343 4181C5D52555C1B900AEB0FF /* MockRTCRtpTransform.h */,19344 4181C636255AE26100AEB0FF /* MockRTCRtpTransform.idl */,19345 19372 57156108234C1B31008FC7AB /* MockWebAuthenticationConfiguration.h */, 19346 19373 5715610D234C7481008FC7AB /* MockWebAuthenticationConfiguration.idl */, … … 19468 19495 4176673224DC08EB008BFE28 /* WritableStreamDefaultWriter.js */, 19469 19496 9908B0F11BCACF9100ED0F75 /* WritableStreamInternals.js */, 19497 41418A022564359800363417 /* WritableStreamSink.h */, 19498 41418A002564359700363417 /* WritableStreamSink.idl */, 19470 19499 ); 19471 19500 path = streams; … … 26934 26963 463521AC2081090E00C28922 /* WindowProxy.cpp */, 26935 26964 463521AA2081090B00C28922 /* WindowProxy.h */, 26965 41418A0325643E1200363417 /* WritableStream.cpp */, 26966 41418A0425643E1300363417 /* WritableStream.h */, 26936 26967 ); 26937 26968 path = js; … … 33609 33640 07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */, 33610 33641 07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */, 33611 4181C5D62555C1B900AEB0FF /* MockRTCRtpTransform.h in Headers */,33612 33642 CDF2B0171820540700F2B424 /* MockSourceBufferPrivate.h in Headers */, 33613 33643 CDF2B0191820540700F2B424 /* MockTracks.h in Headers */, … … 35736 35766 A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */, 35737 35767 A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */, 35738 4181C639255AE90F00AEB0FF /* JSMockRTCRtpTransform.cpp in Sources */,35739 35768 57156114234C7FD6008FC7AB /* JSMockWebAuthenticationConfiguration.cpp in Sources */, 35740 35769 427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */, … … 35756 35785 A1AFEDE71F8BFF6D0087013F /* MockPaymentCoordinator.cpp in Sources */, 35757 35786 A140618B1E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp in Sources */, 35758 4181C5D72555C49A00AEB0FF /* MockRTCRtpTransform.cpp in Sources */,35759 35787 AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */, 35760 35788 417F0D821FFEE979008EF303 /* ServiceWorkerInternals.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp
r265039 r270107 90 90 } 91 91 92 bool ReadableStreamDefaultController::enqueue(JSC::JSValue value) 93 { 94 JSC::JSGlobalObject& lexicalGlobalObject = this->globalObject(); 95 auto& vm = lexicalGlobalObject.vm(); 96 JSC::JSLockHolder lock(vm); 97 98 JSC::MarkedArgumentBuffer arguments; 99 arguments.append(&jsController()); 100 arguments.append(value); 101 102 auto* clientData = static_cast<JSVMClientData*>(lexicalGlobalObject.vm().clientData); 103 auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamDefaultControllerEnqueuePrivateName(); 104 105 return invokeReadableStreamDefaultControllerFunction(globalObject(), privateName, arguments); 106 } 107 92 108 bool ReadableStreamDefaultController::enqueue(RefPtr<JSC::ArrayBuffer>&& buffer) 93 109 { … … 110 126 } 111 127 112 JSC::MarkedArgumentBuffer arguments; 113 arguments.append(&jsController()); 114 arguments.append(value); 115 116 auto* clientData = static_cast<JSVMClientData*>(lexicalGlobalObject.vm().clientData); 117 auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamDefaultControllerEnqueuePrivateName(); 118 119 return invokeReadableStreamDefaultControllerFunction(globalObject(), privateName, arguments); 128 return enqueue(value); 120 129 } 121 130 -
trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.h
r264967 r270107 45 45 46 46 bool enqueue(RefPtr<JSC::ArrayBuffer>&&); 47 bool enqueue(JSC::JSValue); 47 48 void error(const Exception&); 48 49 void close(); -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r270101 r270107 223 223 macro(RTCRtpReceiver) \ 224 224 macro(RTCRtpSFrameTransform) \ 225 macro(RTCRtpScriptTransform) \ 225 226 macro(RTCRtpSender) \ 226 227 macro(RTCRtpTransceiver) \ -
trunk/Source/WebCore/dom/EventTargetFactory.in
r268762 r270107 39 39 RTCDTMFSender conditional=WEB_RTC 40 40 RTCPeerConnection conditional=WEB_RTC 41 RTCRtpScriptTransform conditional=WEB_RTC 41 42 ServiceWorker conditional=SERVICE_WORKER 42 43 ServiceWorkerContainer conditional=SERVICE_WORKER -
trunk/Source/WebCore/testing/Internals.cpp
r269830 r270107 139 139 #include "MockPageOverlay.h" 140 140 #include "MockPageOverlayClient.h" 141 #include "MockRTCRtpTransform.h"142 141 #include "NavigatorBeacon.h" 143 142 #include "NavigatorMediaDevices.h" … … 1578 1577 } 1579 1578 1580 Ref<MockRTCRtpTransform> Internals::createMockRTCRtpTransform()1581 {1582 return MockRTCRtpTransform::create();1583 }1584 1585 1579 uint64_t Internals::sframeCounter(const RTCRtpSFrameTransform& transform) 1586 1580 { -
trunk/Source/WebCore/testing/Internals.h
r269830 r270107 33 33 #include "HEVCUtilities.h" 34 34 #include "IDLTypes.h" 35 #include "MockRTCRtpTransform.h"36 35 #include "OrientationNotifier.h" 37 36 #include "PageConsoleClient.h" … … 611 610 void setWebRTCVP9Support(bool); 612 611 void setWebRTCVP9VTBSupport(bool); 613 Ref<MockRTCRtpTransform> createMockRTCRtpTransform();614 612 uint64_t sframeCounter(const RTCRtpSFrameTransform&); 615 613 void setEnableWebRTCEncryption(bool); -
trunk/Source/WebCore/testing/Internals.idl
r269830 r270107 803 803 [Conditional=WEB_RTC] undefined setWebRTCVP9Support(boolean allowed); 804 804 [Conditional=WEB_RTC] undefined setWebRTCVP9VTBSupport(boolean allowed); 805 [Conditional=WEB_RTC] MockRTCRtpTransform createMockRTCRtpTransform();806 805 [Conditional=WEB_RTC] unsigned long long sframeCounter(RTCRtpSFrameTransform transform); 807 806 -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
r269974 r270107 36 36 #include "DOMWindow.h" 37 37 #include "DedicatedWorkerThread.h" 38 #include "JSRTCRtpScriptTransformer.h" 39 #include "JSRTCRtpScriptTransformerConstructor.h" 38 40 #include "MessageEvent.h" 41 #include "RTCRtpScriptTransformer.h" 39 42 #include "RequestAnimationFrameCallback.h" 40 43 #include "SecurityOrigin.h" … … 113 116 #endif 114 117 118 #if ENABLE(WEB_RTC) 119 ExceptionOr<void> DedicatedWorkerGlobalScope::registerRTCRtpScriptTransformer(String&& name, Ref<JSRTCRtpScriptTransformerConstructor>&& transformerConstructor) 120 { 121 ASSERT(!isMainThread()); 122 123 if (name.isEmpty()) 124 return Exception { NotSupportedError, "Name cannot be the empty string"_s }; 125 126 if (m_rtcRtpTransformerConstructorMap.contains(name)) 127 return Exception { NotSupportedError, "A transformer was already registered with this name"_s }; 128 129 JSC::JSObject* jsConstructor = transformerConstructor->callbackData()->callback(); 130 auto* globalObject = jsConstructor->globalObject(); 131 auto& vm = globalObject->vm(); 132 auto scope = DECLARE_THROW_SCOPE(vm); 133 134 if (!jsConstructor->isConstructor(vm)) 135 return Exception { TypeError, "Class definitition passed to registerRTCRtpScriptTransformer() is not a constructor"_s }; 136 137 auto prototype = jsConstructor->getPrototype(vm, globalObject); 138 RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError }); 139 140 if (!prototype.isObject()) 141 return Exception { TypeError, "Class definitition passed to registerRTCRtpScriptTransformer() has invalid prototype"_s }; 142 143 m_rtcRtpTransformerConstructorMap.add(name, WTFMove(transformerConstructor)); 144 145 thread().workerObjectProxy().postTaskToWorkerObject([name = name.isolatedCopy()](auto& worker) mutable { 146 worker.addRTCRtpScriptTransformer(WTFMove(name)); 147 }); 148 149 return { }; 150 } 151 152 RefPtr<RTCRtpScriptTransformer> DedicatedWorkerGlobalScope::createRTCRtpScriptTransformer(String&& name, TransferredMessagePort port) 153 { 154 auto constructor = m_rtcRtpTransformerConstructorMap.get(name); 155 ASSERT(constructor); 156 if (!constructor) 157 return nullptr; 158 159 auto* jsConstructor = constructor->callbackData()->callback(); 160 auto* globalObject = constructor->callbackData()->globalObject(); 161 auto& vm = globalObject->vm(); 162 auto scope = DECLARE_CATCH_SCOPE(vm); 163 JSC::JSLockHolder lock { globalObject }; 164 165 m_pendingRTCTransfomerMessagePort = MessagePort::entangle(*this, WTFMove(port)); 166 167 JSC::MarkedArgumentBuffer args; 168 auto* object = JSC::construct(globalObject, jsConstructor, args, "Failed to construct RTCRtpScriptTransformer"); 169 ASSERT(!!scope.exception() == !object); 170 171 if (scope.exception()) { 172 scope.clearException(); 173 return nullptr; 174 } 175 RETURN_IF_EXCEPTION(scope, nullptr); 176 177 auto& jsTransformer = *JSC::jsCast<JSRTCRtpScriptTransformer*>(object); 178 auto& transformer = jsTransformer.wrapped(); 179 transformer.setCallback(makeUnique<JSCallbackDataStrong>(&jsTransformer, globalObject)); 180 181 return &transformer; 182 } 183 184 #endif 185 115 186 } // namespace WebCore -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h
r268775 r270107 32 32 #pragma once 33 33 34 #include "MessagePort.h" 34 35 #include "PostMessageOptions.h" 35 36 #include "WorkerGlobalScope.h" … … 45 46 class ContentSecurityPolicyResponseHeaders; 46 47 class DedicatedWorkerThread; 47 class MessagePort; 48 class JSRTCRtpScriptTransformerConstructor; 49 class RTCRtpScriptTransformer; 48 50 class RequestAnimationFrameCallback; 49 51 class SerializedScriptValue; … … 54 56 using CallbackId = int; 55 57 #endif 58 59 using TransferredMessagePort = std::pair<WebCore::MessagePortIdentifier, WebCore::MessagePortIdentifier>; 56 60 57 61 class DedicatedWorkerGlobalScope final : public WorkerGlobalScope { … … 72 76 #endif 73 77 78 #if ENABLE(WEB_RTC) 79 RefPtr<RTCRtpScriptTransformer> createRTCRtpScriptTransformer(String&&, TransferredMessagePort); 80 ExceptionOr<void> registerRTCRtpScriptTransformer(String&&, Ref<JSRTCRtpScriptTransformerConstructor>&&); 81 RefPtr<MessagePort> takePendingRTCTransfomerMessagePort() { return WTFMove(m_pendingRTCTransfomerMessagePort); } 82 #endif 83 74 84 private: 75 85 using Base = WorkerGlobalScope; … … 86 96 RefPtr<WorkerAnimationController> m_workerAnimationController; 87 97 #endif 98 #if ENABLE(WEB_RTC) 99 HashMap<String, RefPtr<JSRTCRtpScriptTransformerConstructor>> m_rtcRtpTransformerConstructorMap; 100 RefPtr<MessagePort> m_pendingRTCTransfomerMessagePort; 101 #endif 88 102 }; 89 103 -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl
r266706 r270107 49 49 50 50 [Conditional=OFFSCREEN_CANVAS, EnabledAtRuntime=OffscreenCanvas] DedicatedWorkerGlobalScope includes AnimationFrameProvider; 51 // FIXME: Enable this based on WebRTCInsertableStreams setting. 52 [Conditional=WEB_RTC] DedicatedWorkerGlobalScope includes RTCRtpScriptTransformProvider; -
trunk/Source/WebCore/workers/Worker.cpp
r259252 r270107 35 35 #include "LoaderStrategy.h" 36 36 #include "PlatformStrategies.h" 37 #include "RTCRtpScriptTransform.h" 37 38 #include "ResourceResponse.h" 38 39 #include "SecurityOrigin.h" … … 231 232 } 232 233 234 #if ENABLE(WEB_RTC) 235 void Worker::addRTCRtpScriptTransformer(String&& name) 236 { 237 m_transformers.add(WTFMove(name)); 238 } 239 240 void Worker::createRTCRtpScriptTransformer(const String& name, TransferredMessagePort port, RTCRtpScriptTransform& transform) 241 { 242 if (!scriptExecutionContext()) 243 return; 244 245 m_contextProxy.postTaskToWorkerGlobalScope([name = name.isolatedCopy(), port, transform = makeRef(transform)](auto& context) mutable { 246 transform->setTransformer(downcast<DedicatedWorkerGlobalScope>(context).createRTCRtpScriptTransformer(WTFMove(name), port)); 247 callOnMainThread([transform = WTFMove(transform)] { }); 248 }); 249 250 } 251 252 void Worker::postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&& task) 253 { 254 m_contextProxy.postTaskToWorkerGlobalScope(WTFMove(task)); 255 } 256 #endif 257 233 258 } // namespace WebCore -
trunk/Source/WebCore/workers/Worker.h
r261499 r270107 46 46 namespace WebCore { 47 47 48 class RTCRtpScriptTransform; 49 class RTCRtpScriptTransformer; 48 50 class ScriptExecutionContext; 49 51 class WorkerGlobalScopeProxy; … … 70 72 71 73 void dispatchEvent(Event&) final; 74 75 #if ENABLE(WEB_RTC) 76 void addRTCRtpScriptTransformer(String&&); 77 bool hasRTCRtpScriptTransformer(const String& name) { return m_transformers.contains(name); } 78 void createRTCRtpScriptTransformer(const String&, TransferredMessagePort, RTCRtpScriptTransform&); 79 void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&); 80 #endif 72 81 73 82 private: … … 101 110 Deque<RefPtr<Event>> m_pendingEvents; 102 111 bool m_wasTerminated { false }; 112 #if ENABLE(WEB_RTC) 113 HashSet<String> m_transformers; 114 #endif 103 115 }; 104 116 -
trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h
r256012 r270107 34 34 #include "MessageWithMessagePorts.h" 35 35 #include <JavaScriptCore/RuntimeFlags.h> 36 #include <wtf/Function.h> 36 37 #include <wtf/MonotonicTime.h> 37 38 … … 39 40 40 41 class ContentSecurityPolicyResponseHeaders; 42 class ScriptExecutionContext; 41 43 class Worker; 42 44 enum class ReferrerPolicy : uint8_t; … … 50 52 virtual void terminateWorkerGlobalScope() = 0; 51 53 virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0; 54 virtual void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) = 0; 52 55 virtual bool hasPendingActivity() const = 0; 53 56 virtual void workerObjectDestroyed() = 0; -
trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp
r268057 r270107 111 111 } 112 112 113 void WorkerMessagingProxy::postTaskToWorkerObject(Function<void(Worker&)>&& function) 114 { 115 m_scriptExecutionContext->postTask([this, function = WTFMove(function)](auto&) mutable { 116 auto* workerObject = this->workerObject(); 117 if (!workerObject || askedToTerminate()) 118 return; 119 function(*workerObject); 120 }); 121 } 122 113 123 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(MessageWithMessagePorts&& message) 114 124 { 115 if (m_askedToTerminate) 116 return; 117 118 ScriptExecutionContext::Task task([message = WTFMove(message)] (ScriptExecutionContext& scriptContext) mutable { 125 postTaskToWorkerGlobalScope([message = WTFMove(message)](auto& scriptContext) mutable { 119 126 ASSERT_WITH_SECURITY_IMPLICATION(scriptContext.isWorkerGlobalScope()); 120 127 auto& context = static_cast<DedicatedWorkerGlobalScope&>(scriptContext); … … 123 130 context.thread().workerObjectProxy().confirmMessageFromWorkerObject(context.hasPendingActivity()); 124 131 }); 125 126 if (m_workerThread) { 127 ++m_unconfirmedMessageCount; 128 m_workerThread->runLoop().postTask(WTFMove(task)); 129 } else 132 } 133 134 void WorkerMessagingProxy::postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&& task) 135 { 136 if (m_askedToTerminate) 137 return; 138 139 if (!m_workerThread) { 130 140 m_queuedEarlyTasks.append(makeUnique<ScriptExecutionContext::Task>(WTFMove(task))); 141 return; 142 } 143 ++m_unconfirmedMessageCount; 144 m_workerThread->runLoop().postTask(WTFMove(task)); 131 145 } 132 146 -
trunk/Source/WebCore/workers/WorkerMessagingProxy.h
r268057 r270107 54 54 void terminateWorkerGlobalScope() final; 55 55 void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final; 56 void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) final; 56 57 bool hasPendingActivity() const final; 57 58 void workerObjectDestroyed() final; … … 63 64 // (Only use these functions in the worker context thread.) 64 65 void postMessageToWorkerObject(MessageWithMessagePorts&&) final; 66 void postTaskToWorkerObject(Function<void(Worker&)>&&) final; 65 67 void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) final; 66 68 void confirmMessageFromWorkerObject(bool hasPendingActivity) final; -
trunk/Source/WebCore/workers/WorkerObjectProxy.h
r227190 r270107 33 33 #include "MessageWithMessagePorts.h" 34 34 #include "WorkerReportingProxy.h" 35 35 36 #include <memory> 37 #include <wtf/Function.h> 36 38 37 39 namespace WebCore { 40 41 class Worker; 38 42 39 43 // A proxy to talk to the worker object. … … 41 45 public: 42 46 virtual void postMessageToWorkerObject(MessageWithMessagePorts&&) = 0; 47 virtual void postTaskToWorkerObject(Function<void(Worker&)>&&) { }; 43 48 44 49 virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
Note: See TracChangeset
for help on using the changeset viewer.