Changeset 270107 in webkit


Ignore:
Timestamp:
Nov 20, 2020 4:25:32 AM (3 years ago)
Author:
youenn@apple.com
Message:

Add support for RTCRtpScriptTransform
https://bugs.webkit.org/show_bug.cgi?id=219148

Reviewed by Eric Carlson.

Source/WebCore:

We introduce RTCRtpScriptTransform which processes encoded frames in a worker for either RTCRtpSender or RTCRtpReceiver.
The model follows AudioWorkletNode in the sense that we create a RTCRtpScriptTransform object in main thread that is used with RTCRtp objects.
The RTCRtpScriptTransform takes a name and a worker as parameters to create a RTCRtpScriptTransformer counter part in a worker.
Before that, RTCRtpScriptTransformer constructors are registered in the worker with a specific name.
A message port is shared between RTCRtpScriptTransform and RTCRtpScriptTransformer.

RTCRtpScriptTransform keeps a weak pointer to RTCRtpScriptTransformer so that we keep all ref counting of RTCRtpScriptTransformer in the worker thread.
To make sure RTCRtpScriptTransformer stays alive for long enough, we set a pending activity when RTCRtpScriptTransform is linked to its RTCRtpScriptTransformer.
The pending activity is then removed either at worker closure or RTCRtpScriptTransform being no longer doing processing.

We expose individual compressed frames as RTCEncodedAudioFrame and RTCEncodedVideoFrame.
Accessor is limited to the raw data but additional getters should be added later on.

To implement RTCRtpScriptTransformer, we have to be able to create WritableStream with native sinks.
This is why we introduce WritableStreamSink and WritableStream C++ classes.
Binding between native frames and streams is done through RTCRtpReadableStreamSource and RTCRtpWritableStreamSink.

Test: http/wpt/webrtc/webrtc-transform.html and http/wpt/webrtc/sframe-transform.html.

  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/mediastream/RTCEncodedAudioFrame.cpp: Added.

(WebCore::RTCEncodedAudioFrame::RTCEncodedAudioFrame):

  • Modules/mediastream/RTCEncodedAudioFrame.h: Added.

(WebCore::RTCEncodedAudioFrame::create):

  • Modules/mediastream/RTCEncodedAudioFrame.idl: Added.
  • Modules/mediastream/RTCEncodedFrame.h: Added.
  • Modules/mediastream/RTCEncodedFrame.cpp: Added.
  • Modules/mediastream/RTCEncodedVideoFrame.cpp: Added.

(WebCore::RTCEncodedVideoFrame::RTCEncodedVideoFrame):

  • Modules/mediastream/RTCEncodedVideoFrame.h: Added.

(WebCore::RTCEncodedVideoFrame::create):

  • Modules/mediastream/RTCEncodedVideoFrame.idl: Added.
  • Modules/mediastream/RTCRtpReceiver+Transform.idl:
  • Modules/mediastream/RTCRtpReceiver.cpp:

(WebCore::RTCRtpReceiver::setTransform):
(WebCore::RTCRtpReceiver::transform):

  • Modules/mediastream/RTCRtpReceiver.h:
  • Modules/mediastream/RTCRtpReceiverWithTransform.h:

(WebCore::RTCRtpReceiverWithTransform::transform):
(WebCore::RTCRtpReceiverWithTransform::setTransform):

  • Modules/mediastream/RTCRtpSFrameTransform.cpp:

(WebCore::RTCRtpSFrameTransform::initializeTransformer):

  • Modules/mediastream/RTCRtpSFrameTransform.h:

(WebCore::RTCRtpSFrameTransform::isAttached const):

  • Modules/mediastream/RTCRtpSFrameTransform.idl:
  • Modules/mediastream/RTCRtpScriptTransform.cpp: Added.

(WebCore::RTCRtpScriptTransform::create):
(WebCore::RTCRtpScriptTransform::RTCRtpScriptTransform):
(WebCore::RTCRtpScriptTransform::~RTCRtpScriptTransform):
(WebCore::RTCRtpScriptTransform::setTransformer):
(WebCore::RTCRtpScriptTransform::initializeBackendForReceiver):
(WebCore::RTCRtpScriptTransform::initializeBackendForSender):
(WebCore::RTCRtpScriptTransform::willClearBackend):
(WebCore::RTCRtpScriptTransform::initializeTransformer):

  • Modules/mediastream/RTCRtpScriptTransform.h: Added.
  • Modules/mediastream/RTCRtpScriptTransform.idl: Added.
  • Modules/mediastream/RTCRtpScriptTransformProvider.idl: Added.
  • Modules/mediastream/RTCRtpScriptTransformer.cpp: Added.

(WebCore::RTCRtpReadableStreamSource::create):
(WebCore::RTCRtpReadableStreamSource::close):
(WebCore::RTCRtpReadableStreamSource::enqueue):
(WebCore::RTCRtpWritableStreamSink::create):
(WebCore::RTCRtpWritableStreamSink::RTCRtpWritableStreamSink):
(WebCore::RTCRtpWritableStreamSink::write):
(WebCore::RTCRtpScriptTransformer::create):
(WebCore::RTCRtpScriptTransformer::RTCRtpScriptTransformer):
(WebCore::RTCRtpScriptTransformer::~RTCRtpScriptTransformer):
(WebCore::RTCRtpScriptTransformer::start):
(WebCore::RTCRtpScriptTransformer::clear):

  • Modules/mediastream/RTCRtpScriptTransformer.h: Added.

(WebCore::RTCRtpScriptTransformer::setCallback):
(WebCore::RTCRtpScriptTransformer::port):
(WebCore::RTCRtpScriptTransformer::startPendingActivity):
(WebCore::RTCRtpScriptTransformer::activeDOMObjectName const):
(WebCore::RTCRtpScriptTransformer::stopPendingActivity):

  • Modules/mediastream/RTCRtpScriptTransformer.idl: Added.
  • Modules/mediastream/RTCRtpScriptTransformerConstructor.h: Added.
  • Modules/mediastream/RTCRtpScriptTransformerConstructor.idl: Added.
  • Modules/mediastream/RTCRtpSender+Transform.idl:
  • Modules/mediastream/RTCRtpSender.cpp:

(WebCore::RTCRtpSender::setTransform):
(WebCore::RTCRtpSender::transform):

  • Modules/mediastream/RTCRtpSender.h:
  • Modules/mediastream/RTCRtpSenderWithTransform.h:

(WebCore::RTCRtpSenderWithTransform::transform):
(WebCore::RTCRtpSenderWithTransform::setTransform):

  • Modules/mediastream/RTCRtpTransform.cpp:

(WebCore::RTCRtpTransform::from):
(WebCore::RTCRtpTransform::RTCRtpTransform):
(WebCore::RTCRtpTransform::~RTCRtpTransform):
(WebCore::RTCRtpTransform::isAttached const):
(WebCore::RTCRtpTransform::attachToReceiver):
(WebCore::RTCRtpTransform::attachToSender):
(WebCore::RTCRtpTransform::clearBackend):
(WebCore::RTCRtpTransform::detachFromReceiver):
(WebCore::RTCRtpTransform::detachFromSender):

  • Modules/mediastream/RTCRtpTransform.h:

(WebCore::RTCRtpTransform::internalTransform):

  • Modules/mediastream/RTCRtpTransformBackend.h:
  • Modules/mediastream/RTCRtpTransformableFrame.h:
  • Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp:

(WebCore::LibWebRTCRtpTransformBackend::setInputCallback):
(WebCore::LibWebRTCRtpTransformBackend::Transform):

  • Modules/streams/WritableStreamSink.h: Added.
  • Modules/streams/WritableStreamSink.idl: Added.
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/ReadableStreamDefaultController.cpp:

(WebCore::ReadableStreamDefaultController::enqueue):

  • bindings/js/ReadableStreamDefaultController.h:
  • bindings/js/WebCoreBuiltinNames.h:
  • bindings/js/WritableStream.cpp: Added.

(WebCore::WritableStream::create):

  • bindings/js/WritableStream.h: Added.

(WebCore::JSWritableStreamWrapperConverter::toWrapped):
(WebCore::WritableStream::WritableStream):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):

  • dom/EventTargetFactory.in:
  • testing/Internals.cpp:
  • testing/Internals.h:
  • testing/Internals.idl:
  • testing/MockRTCRtpTransform.cpp:

(WebCore::MockRTCRtpTransformer::transform):

  • workers/DedicatedWorkerGlobalScope.cpp:

(WebCore::DedicatedWorkerGlobalScope::registerRTCRtpScriptTransformer):
(WebCore::DedicatedWorkerGlobalScope::createRTCRtpScriptTransformer):

  • workers/DedicatedWorkerGlobalScope.h:
  • workers/DedicatedWorkerGlobalScope.idl:
  • workers/Worker.cpp:

(WebCore::Worker::addRTCRtpScriptTransformer):
(WebCore::Worker::createRTCRtpScriptTransformer):
(WebCore::Worker::postTaskToWorkerGlobalScope):

  • workers/Worker.h:
  • workers/WorkerGlobalScopeProxy.h:
  • workers/WorkerMessagingProxy.cpp:

(WebCore::WorkerMessagingProxy::postTaskToWorkerObject):
(WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
(WebCore::WorkerMessagingProxy::postTaskToWorkerGlobalScope):

  • workers/WorkerMessagingProxy.h:
  • workers/WorkerObjectProxy.h:

(WebCore::WorkerObjectProxy::postTaskToWorkerObject):

LayoutTests:

  • http/wpt/webrtc/routines.js: Added.

(createConnections):

  • http/wpt/webrtc/script-transform.js: Added.

(MockRTCRtpTransformer):
(MockRTCRtpTransformer.prototype.start):
(MockRTCRtpTransformer.prototype.process):

  • http/wpt/webrtc/sframe-transform-expected.txt: Added.
  • http/wpt/webrtc/sframe-transform.html: Added.
  • http/wpt/webrtc/webrtc-transform-expected.txt: Renamed from LayoutTests/webrtc/webrtc-transform-expected.txt.
  • http/wpt/webrtc/webrtc-transform.html: Renamed from LayoutTests/webrtc/webrtc-transform.html.
  • platform/glib/TestExpectations:
  • webrtc/script-transform.js: Added.

(MockRTCRtpTransformer):
(MockRTCRtpTransformer.prototype.start):

Location:
trunk
Files:
11 added
2 deleted
41 edited
13 copied
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r270106 r270107  
     12020-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
    1232020-11-20  Philippe Normand  <pnormand@igalia.com>
    224
  • trunk/LayoutTests/http/wpt/webrtc/webrtc-transform-expected.txt

    r270106 r270107  
    11
    22
     3PASS transform messaging
     4PASS Cannot reuse attached transforms
    35PASS audio exchange with transform
    46PASS video exchange with transform
  • trunk/LayoutTests/platform/glib/TestExpectations

    r270102 r270107  
    917917webkit.org/b/218787 webrtc/concurrentVideoPlayback.html [ Timeout ]
    918918webkit.org/b/218787 webrtc/ice-candidate-sdpMLineIndex.html [ Timeout ]
    919 webkit.org/b/218787 webrtc/webrtc-transform.html [ Failure ]
     919webkit.org/b/218787 http/wpt/webrtc/webrtc-transform.html [ Failure ]
    920920
    921921webkit.org/b/219066 webrtc/audio-sframe.html [ Failure Crash ]
  • trunk/Source/WebCore/CMakeLists.txt

    r270101 r270107  
    376376    Modules/mediastream/RTCDegradationPreference.idl
    377377    Modules/mediastream/RTCDtxStatus.idl
     378    Modules/mediastream/RTCEncodedAudioFrame.idl
     379    Modules/mediastream/RTCEncodedVideoFrame.idl
    378380    Modules/mediastream/RTCIceCandidate.idl
    379381    Modules/mediastream/RTCIceCandidateInit.idl
     
    407409    Modules/mediastream/RTCRtpRtxParameters.idl
    408410    Modules/mediastream/RTCRtpSFrameTransform.idl
     411    Modules/mediastream/RTCRtpScriptTransform.idl
     412    Modules/mediastream/RTCRtpScriptTransformProvider.idl
     413    Modules/mediastream/RTCRtpScriptTransformer.idl
     414    Modules/mediastream/RTCRtpScriptTransformerConstructor.idl
    409415    Modules/mediastream/RTCRtpSendParameters.idl
    410416    Modules/mediastream/RTCRtpSender+Transform.idl
     
    413419    Modules/mediastream/RTCRtpTransceiver.idl
    414420    Modules/mediastream/RTCRtpTransceiverDirection.idl
    415     Modules/mediastream/RTCRtpTransform.idl
    416421    Modules/mediastream/RTCSdpType.idl
    417422    Modules/mediastream/RTCSessionDescription.idl
     
    487492    Modules/streams/WritableStreamDefaultController.idl
    488493    Modules/streams/WritableStreamDefaultWriter.idl
     494    Modules/streams/WritableStreamSink.idl
    489495
    490496    Modules/webaudio/AnalyserNode.idl
     
    17591765    testing/MockContentFilterSettings.idl
    17601766    testing/MockPageOverlay.idl
    1761     testing/MockRTCRtpTransform.idl
    17621767    testing/ServiceWorkerInternals.idl
    17631768    testing/TypeConversions.idl
     
    17831788    testing/MockPageOverlay.cpp
    17841789    testing/MockPageOverlayClient.cpp
    1785     testing/MockRTCRtpTransform.cpp
    17861790    testing/ServiceWorkerInternals.cpp
    17871791    testing/js/WebCoreTestSupport.cpp
  • trunk/Source/WebCore/ChangeLog

    r270106 r270107  
     12020-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
    11542020-11-20  Philippe Normand  <pnormand@igalia.com>
    2155
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r270101 r270107  
    206206$(PROJECT_DIR)/Modules/mediastream/RTCDegradationPreference.idl
    207207$(PROJECT_DIR)/Modules/mediastream/RTCDtxStatus.idl
     208$(PROJECT_DIR)/Modules/mediastream/RTCEncodedAudioFrame.idl
     209$(PROJECT_DIR)/Modules/mediastream/RTCEncodedVideoFrame.idl
    208210$(PROJECT_DIR)/Modules/mediastream/RTCIceCandidate.idl
    209211$(PROJECT_DIR)/Modules/mediastream/RTCIceCandidateInit.idl
     
    239241$(PROJECT_DIR)/Modules/mediastream/RTCRtpRtxParameters.idl
    240242$(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
    241247$(PROJECT_DIR)/Modules/mediastream/RTCRtpSendParameters.idl
    242248$(PROJECT_DIR)/Modules/mediastream/RTCRtpSender+Transform.idl
     
    341347$(PROJECT_DIR)/Modules/streams/WritableStreamDefaultWriter.js
    342348$(PROJECT_DIR)/Modules/streams/WritableStreamInternals.js
     349$(PROJECT_DIR)/Modules/streams/WritableStreamSink.idl
    343350$(PROJECT_DIR)/Modules/webaudio/AnalyserNode.idl
    344351$(PROJECT_DIR)/Modules/webaudio/AnalyserOptions.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r270101 r270107  
    16501650$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCDtxStatus.cpp
    16511651$(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
    16521656$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCIceCandidate.cpp
    16531657$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCIceCandidate.h
     
    17121716$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSFrameTransform.cpp
    17131717$(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
    17141726$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSendParameters.cpp
    17151727$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSendParameters.h
     
    25742586$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamDefaultWriter.cpp
    25752587$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamDefaultWriter.h
     2588$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamSink.cpp
     2589$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWritableStreamSink.h
    25762590$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSXMLDocument.cpp
    25772591$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSXMLDocument.h
  • trunk/Source/WebCore/DerivedSources.make

    r270101 r270107  
    232232    $(WebCore)/Modules/mediastream/RTCDegradationPreference.idl \
    233233    $(WebCore)/Modules/mediastream/RTCDtxStatus.idl \
     234    $(WebCore)/Modules/mediastream/RTCEncodedAudioFrame.idl \
     235    $(WebCore)/Modules/mediastream/RTCEncodedVideoFrame.idl \
    234236    $(WebCore)/Modules/mediastream/RTCIceCandidate.idl \
    235237    $(WebCore)/Modules/mediastream/RTCIceCandidateInit.idl \
     
    266268    $(WebCore)/Modules/mediastream/RTCRtpSender+Transform.idl \
    267269    $(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 \
    268274    $(WebCore)/Modules/mediastream/RTCRtpSynchronizationSource.idl \
    269275    $(WebCore)/Modules/mediastream/RTCRtpTransceiver.idl \
    270276    $(WebCore)/Modules/mediastream/RTCRtpTransceiverDirection.idl \
    271     $(WebCore)/Modules/mediastream/RTCRtpTransform.idl \
    272277    $(WebCore)/Modules/mediastream/RTCSdpType.idl \
    273278    $(WebCore)/Modules/mediastream/RTCSessionDescription.idl \
     
    345350    $(WebCore)/Modules/streams/WritableStreamDefaultController.idl \
    346351    $(WebCore)/Modules/streams/WritableStreamDefaultWriter.idl \
     352    $(WebCore)/Modules/streams/WritableStreamSink.idl \
    347353    $(WebCore)/Modules/webaudio/AnalyserNode.idl \
    348354    $(WebCore)/Modules/webaudio/AnalyserOptions.idl \
     
    12331239    $(WebCore)/testing/MockPaymentCoordinator.idl \
    12341240    $(WebCore)/testing/MockPaymentError.idl \
    1235     $(WebCore)/testing/MockRTCRtpTransform.idl \
    12361241    $(WebCore)/testing/MockWebAuthenticationConfiguration.idl \
    12371242    $(WebCore)/testing/ServiceWorkerInternals.idl \
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedAudioFrame.cpp

    r270106 r270107  
    2424 */
    2525
    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
     31namespace WebCore {
     32
     33RTCEncodedAudioFrame::RTCEncodedAudioFrame(UniqueRef<RTCRtpTransformableFrame>&& frame)
     34    : RTCEncodedFrame(WTFMove(frame))
     35{
     36}
     37
     38RTCEncodedAudioFrame::~RTCEncodedAudioFrame() = default;
     39
     40} // namespace WebCore
     41
     42#endif // ENABLE(WEB_RTC)
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedAudioFrame.h

    r270106 r270107  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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.
    2424 */
    2525
     
    2828#if ENABLE(WEB_RTC)
    2929
    30 #include "RTCRtpSender.h"
    31 #include "RTCRtpTransform.h"
     30#include "RTCEncodedFrame.h"
    3231
    3332namespace WebCore {
    3433
    35 class RTCRtpTransform;
     34class RTCEncodedAudioFrame : public RTCEncodedFrame {
     35public:
     36    static Ref<RTCEncodedAudioFrame> create(UniqueRef<RTCRtpTransformableFrame>&& frame) { return adoptRef(*new RTCEncodedAudioFrame(WTFMove(frame))); }
     37    ~RTCEncodedAudioFrame();
    3638
    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)); }
     39private:
     40    explicit RTCEncodedAudioFrame(UniqueRef<RTCRtpTransformableFrame>&&);
    4141};
    4242
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedAudioFrame.idl

    r270106 r270107  
    2626[
    2727    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();
    3334};
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedFrame.cpp

    r270106 r270107  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "RTCEncodedFrame.h"
    2728
    2829#if ENABLE(WEB_RTC)
    2930
    30 #include "RTCRtpReceiver.h"
    31 #include "RTCRtpTransform.h"
     31#include <JavaScriptCore/JSCInlines.h>
     32#include <JavaScriptCore/StrongInlines.h>
    3233
    3334namespace WebCore {
    3435
    35 class RTCRtpTransform;
     36RTCEncodedFrame::RTCEncodedFrame(UniqueRef<RTCRtpTransformableFrame>&& frame)
     37    : m_frame(WTFMove(frame))
     38{
     39}
    3640
    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 };
     41RefPtr<JSC::ArrayBuffer> RTCEncodedFrame::data() const
     42{
     43    auto data = m_frame->data();
     44    return JSC::ArrayBuffer::create(data.data, data.size);
     45}
     46
     47void RTCEncodedFrame::setData(JSC::ArrayBuffer& buffer)
     48{
     49    m_frame->setData({ static_cast<const uint8_t*>(buffer.data()), buffer.byteLength() });
     50}
    4251
    4352} // namespace WebCore
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedFrame.h

    r270106 r270107  
    2828#if ENABLE(WEB_RTC)
    2929
    30 #include "RTCRtpTransform.h"
     30#include "RTCRtpTransformableFrame.h"
     31#include <wtf/Ref.h>
     32#include <wtf/RefCounted.h>
     33#include <wtf/UniqueRef.h>
     34
     35namespace JSC {
     36class ArrayBuffer;
     37}
    3138
    3239namespace WebCore {
    3340
    34 class MockRTCRtpTransformer;
     41class RTCEncodedFrame : public RefCounted<RTCEncodedFrame> {
     42public:
     43    RefPtr<JSC::ArrayBuffer> data() const;
     44    void setData(JSC::ArrayBuffer&);
    3545
    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); }
    4047
    41     bool isProcessing() const;
     48protected:
     49    explicit RTCEncodedFrame(UniqueRef<RTCRtpTransformableFrame>&&);
    4250
    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;
    5152};
    5253
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedVideoFrame.cpp

    r270106 r270107  
    2424 */
    2525
    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
     31namespace WebCore {
     32
     33RTCEncodedVideoFrame::RTCEncodedVideoFrame(UniqueRef<RTCRtpTransformableFrame>&& frame)
     34    : RTCEncodedFrame(WTFMove(frame))
     35{
     36}
     37
     38RTCEncodedVideoFrame::~RTCEncodedVideoFrame() = default;
     39
     40} // namespace WebCore
     41
     42#endif // ENABLE(WEB_RTC)
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedVideoFrame.h

    r270106 r270107  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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.
    2424 */
    2525
     
    2828#if ENABLE(WEB_RTC)
    2929
    30 #include "RTCRtpSender.h"
    31 #include "RTCRtpTransform.h"
     30#include "RTCEncodedFrame.h"
    3231
    3332namespace WebCore {
    3433
    35 class RTCRtpTransform;
     34class RTCEncodedVideoFrame : public RTCEncodedFrame {
     35public:
     36    static Ref<RTCEncodedVideoFrame> create(UniqueRef<RTCRtpTransformableFrame>&& frame) { return adoptRef(*new RTCEncodedVideoFrame(WTFMove(frame))); }
     37    ~RTCEncodedVideoFrame();
    3638
    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)); }
     39private:
     40    explicit RTCEncodedVideoFrame(UniqueRef<RTCRtpTransformableFrame>&&);
    4141};
    4242
  • trunk/Source/WebCore/Modules/mediastream/RTCEncodedVideoFrame.idl

    r270106 r270107  
    2626[
    2727    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();
    3335};
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver+Transform.idl

    r269764 r270107  
    2424 */
    2525
     26typedef (RTCRtpSFrameTransform or RTCRtpScriptTransform) RTCRtpTransform;
     27
    2628[
    2729    Conditional=WEB_RTC,
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp

    r269764 r270107  
    8282}
    8383
    84 ExceptionOr<void> RTCRtpReceiver::setTransform(RefPtr<RTCRtpTransform>&& transform)
     84ExceptionOr<void> RTCRtpReceiver::setTransform(Optional<RTCRtpTransform>&& transform)
    8585{
     86    if (transform && m_transform && *transform == *m_transform)
     87        return { };
    8688    if (transform && transform->isAttached())
    8789        return Exception { InvalidStateError, "transform is already in use"_s };
     
    9698}
    9799
     100Optional<RTCRtpTransform::Internal> RTCRtpReceiver::transform()
     101{
     102    if (!m_transform)
     103        return { };
     104    return m_transform->internalTransform();
     105}
     106
    98107} // namespace WebCore
    99108
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h

    r269764 r270107  
    6868    void getStats(Ref<DeferredPromise>&&);
    6969
    70     RTCRtpTransform* transform() { return m_transform.get(); }
    71     ExceptionOr<void> setTransform(RefPtr<RTCRtpTransform>&&);
     70    Optional<RTCRtpTransform::Internal> transform();
     71    ExceptionOr<void> setTransform(Optional<RTCRtpTransform>&&);
    7272
    7373private:
     
    7777    std::unique_ptr<RTCRtpReceiverBackend> m_backend;
    7878    WeakPtr<PeerConnectionBackend> m_connection;
    79     RefPtr<RTCRtpTransform> m_transform;
     79    Optional<RTCRtpTransform> m_transform;
    8080};
    8181
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiverWithTransform.h

    r269764 r270107  
    3737class RTCRtpReceiverWithTransform {
    3838public:
    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))); }
    4141};
    4242
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp

    r269830 r270107  
    3232#include "Logging.h"
    3333#include "RTCRtpSFrameTransformer.h"
     34#include "RTCRtpTransformBackend.h"
    3435#include "RTCRtpTransformableFrame.h"
    3536
     
    6970void RTCRtpSFrameTransform::initializeTransformer(RTCRtpTransformBackend& backend, Side side)
    7071{
     72    m_isAttached = true;
    7173    m_transformer->setIsSending(side == Side::Sender);
    7274    m_transformer->setIsProcessingAudio(backend.mediaType() == RTCRtpTransformBackend::MediaType::Audio);
    7375
    7476    backend.setTransformableFrameCallback([transformer = m_transformer, backend = makeRef(backend)](auto&& frame) {
    75         auto chunk = frame.data();
     77        auto chunk = frame->data();
    7678        auto result = transformer->transform(chunk.data, chunk.size);
    7779
     
    8183        }
    8284
    83         frame.setData({ result.returnValue().data(), result.returnValue().size() });
     85        frame->setData({ result.returnValue().data(), result.returnValue().size() });
    8486
    85         backend->processTransformedFrame(WTFMove(frame));
     87        backend->processTransformedFrame(WTFMove(frame.get()));
    8688    });
    8789}
     
    101103{
    102104    backend.clearTransformableFrameCallback();
     105    m_isAttached = false;
    103106}
    104107
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.h

    r269830 r270107  
    2929
    3030#include "JSDOMPromiseDeferred.h"
    31 #include "RTCRtpTransform.h"
    3231
    3332namespace WebCore {
     
    3534class CryptoKey;
    3635class RTCRtpSFrameTransformer;
     36class RTCRtpTransformBackend;
    3737
    38 class RTCRtpSFrameTransform final : public RTCRtpTransform {
     38class RTCRtpSFrameTransform : public RefCounted<RTCRtpSFrameTransform> {
    3939public:
    4040    static Ref<RTCRtpSFrameTransform> create() { return adoptRef(*new RTCRtpSFrameTransform); }
     
    4343    void setEncryptionKey(CryptoKey&, Optional<uint64_t>, DOMPromiseDeferred<void>&&);
    4444
     45    bool isAttached() const { return m_isAttached; }
     46    void initializeBackendForReceiver(RTCRtpTransformBackend&);
     47    void initializeBackendForSender(RTCRtpTransformBackend&);
     48    void willClearBackend(RTCRtpTransformBackend&);
     49
    4550    WEBCORE_EXPORT uint64_t counterForTesting() const;
    4651
     
    4853    RTCRtpSFrameTransform();
    4954
    50     void initializeBackendForReceiver(RTCRtpTransformBackend&) final;
    51     void initializeBackendForSender(RTCRtpTransformBackend&) final;
    52     void willClearBackend(RTCRtpTransformBackend&) final;
    53 
    5455    enum class Side { Sender, Receiver };
    5556    void initializeTransformer(RTCRtpTransformBackend&, Side);
    5657
     58    bool m_isAttached { false };
    5759    Ref<RTCRtpSFrameTransformer> m_transformer;
    5860};
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.idl

    r269830 r270107  
    2929    ExportMacro=WEBCORE_EXPORT,
    3030    Exposed=Window,
     31    ImplementationLacksVTable,
    3132    JSGenerateToNativeObject,
    32 ] interface RTCRtpSFrameTransform : RTCRtpTransform {
     33] interface RTCRtpSFrameTransform {
    3334    constructor();
    3435
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.idl

    r270106 r270107  
    2525
    2626[
     27    ActiveDOMObject,
    2728    Conditional=WEB_RTC,
    2829    EnabledBySetting=WebRTCInsertableStreams,
    2930    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;
    3336};
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformProvider.idl

    r270106 r270107  
    2424 */
    2525
    26 [
    27     Conditional=WEB_RTC,
    28     EnabledBySetting=WebRTCInsertableStreams,
    29     Exposed=Window,
    30     ImplementedBy=RTCRtpSenderWithTransform,
    31 ] partial interface RTCRtpSender {
    32     [MayThrowException] attribute RTCRtpTransform? transform;
     26interface mixin RTCRtpScriptTransformProvider {
     27    [MayThrowException] undefined registerRTCRtpScriptTransformer(DOMString name, RTCRtpScriptTransformerConstructor processorConstructor);
    3328};
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.h

    r270106 r270107  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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.
    2424 */
    2525
     
    2828#if ENABLE(WEB_RTC)
    2929
    30 #include "RTCRtpTransformBackend.h"
     30#include "ActiveDOMObject.h"
     31#include "ExceptionOr.h"
    3132#include <wtf/RefCounted.h>
    32 #include <wtf/RefPtr.h>
     33#include <wtf/WeakPtr.h>
    3334
    3435namespace WebCore {
    3536
    36 class RTCRtpReceiver;
    37 class RTCRtpSender;
     37class JSCallbackDataStrong;
     38class MessagePort;
     39class ScriptExecutionContext;
     40class RTCRtpTransformBackend;
     41class RTCRtpReadableStreamSource;
    3842
    39 class WEBCORE_EXPORT RTCRtpTransform : public RefCounted<RTCRtpTransform> {
     43class RTCRtpScriptTransformer
     44    : public RefCounted<RTCRtpScriptTransformer>
     45    , public ActiveDOMObject
     46    , public CanMakeWeakPtr<RTCRtpScriptTransformer> {
    4047public:
    41     virtual ~RTCRtpTransform();
     48    static ExceptionOr<Ref<RTCRtpScriptTransformer>> create(ScriptExecutionContext&);
     49    ~RTCRtpScriptTransformer();
    4250
    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); }
    4858
    4959private:
    50     virtual void initializeBackendForSender(RTCRtpTransformBackend&);
    51     virtual void initializeBackendForReceiver(RTCRtpTransformBackend&);
    52     virtual void willClearBackend(RTCRtpTransformBackend&);
     60    RTCRtpScriptTransformer(ScriptExecutionContext&, Ref<MessagePort>&&);
    5361
    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;
    5571    RefPtr<RTCRtpTransformBackend> m_backend;
     72    RefPtr<PendingActivity<RTCRtpScriptTransformer>> m_pendingActivity;
     73
    5674};
    57 
    58 inline bool RTCRtpTransform::isAttached() const
    59 {
    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 }
    7475
    7576} // namespace WebCore
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.idl

    r270106 r270107  
    2424 */
    2525
     26// FIXME: Add EnabledBySetting=WebRTCInsertableStreams,
    2627[
     28    ActiveDOMObject,
    2729    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;
    3337};
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.h

    r270106 r270107  
    11/*
    2  * Copyright (C) 2020 Apple Inc.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions
    66 * are met:
     7 *
    78 * 1.  Redistributions of source code must retain the above copyright
    89 *     notice, this list of conditions and the following disclaimer.
     
    1011 *     notice, this list of conditions and the following disclaimer in the
    1112 *     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.
    1216 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    1418 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1519 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    1721 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1822 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    22  * 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.
    2327 */
    2428
     
    2731#if ENABLE(WEB_RTC)
    2832
     33#include "ActiveDOMCallback.h"
     34#include "CallbackResult.h"
     35#include <wtf/RefCounted.h>
     36
    2937namespace WebCore {
    3038
    31 class RTCRtpTransformableFrame {
     39class RTCRtpScriptTransformer;
     40
     41class RTCRtpScriptTransformerConstructor : public RefCounted<RTCRtpScriptTransformerConstructor>, public ActiveDOMCallback {
    3242public:
    33     virtual ~RTCRtpTransformableFrame() = default;
     43    using ActiveDOMCallback::ActiveDOMCallback;
    3444
    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;
    4146};
    4247
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl

    r270106 r270107  
    11/*
    2  * Copyright (C) 2020 Apple Inc.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions
    66 * are met:
     7 *
    78 * 1.  Redistributions of source code must retain the above copyright
    89 *     notice, this list of conditions and the following disclaimer.
     
    1011 *     notice, this list of conditions and the following disclaimer in the
    1112 *     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.
    1216 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    1418 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1519 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    1721 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1822 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    22  * 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.
    2327 */
    2428
    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  
    2424 */
    2525
     26typedef (RTCRtpSFrameTransform or RTCRtpScriptTransform) RTCRtpTransform;
     27
    2628[
    2729    Conditional=WEB_RTC,
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp

    r269764 r270107  
    194194}
    195195
    196 ExceptionOr<void> RTCRtpSender::setTransform(RefPtr<RTCRtpTransform>&& transform)
    197 {
     196ExceptionOr<void> RTCRtpSender::setTransform(Optional<RTCRtpTransform>&& transform)
     197{
     198    if (transform && m_transform && *transform == *m_transform)
     199        return { };
    198200    if (transform && transform->isAttached())
    199201        return Exception { InvalidStateError, "transform is already in use"_s };
     
    208210}
    209211
     212Optional<RTCRtpTransform::Internal> RTCRtpSender::transform()
     213{
     214    if (!m_transform)
     215        return { };
     216    return m_transform->internalTransform();
     217}
     218
    210219} // namespace WebCore
    211220
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.h

    r269764 r270107  
    8383    Optional<RTCRtpTransceiverDirection> currentTransceiverDirection() const;
    8484
    85     RTCRtpTransform* transform() { return m_transform.get(); }
    86     ExceptionOr<void> setTransform(RefPtr<RTCRtpTransform>&&);
     85    Optional<RTCRtpTransform::Internal> transform();
     86    ExceptionOr<void> setTransform(Optional<RTCRtpTransform>&&);
    8787
    8888private:
     
    9696    WeakPtr<RTCPeerConnection> m_connection;
    9797    RefPtr<RTCDTMFSender> m_dtmfSender;
    98     RefPtr<RTCRtpTransform> m_transform;
     98    Optional<RTCRtpTransform> m_transform;
    9999};
    100100
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpSenderWithTransform.h

    r269764 r270107  
    3737class RTCRtpSenderWithTransform {
    3838public:
    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))); }
    4141};
    4242
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpTransform.cpp

    r269764 r270107  
    3434namespace WebCore {
    3535
     36Optional<RTCRtpTransform> RTCRtpTransform::from(Optional<Internal>&& internal)
     37{
     38    if (!internal)
     39        return { };
     40    return RTCRtpTransform(WTFMove(*internal));
     41}
     42
     43RTCRtpTransform::RTCRtpTransform(Internal&& transform)
     44    : m_transform(WTFMove(transform))
     45{
     46}
     47
    3648RTCRtpTransform::~RTCRtpTransform()
    3749{
    38     if (m_backend)
    39         willClearBackend(*m_backend);
     50    clearBackend();
     51}
     52
     53bool 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    });
    4060}
    4161
     
    4565    if (auto* backend = receiver.backend())
    4666        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    }
    4974}
    5075
     
    5479    if (auto* backend = sender.backend())
    5580        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
     90void 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;
    58102}
    59103
    60104void RTCRtpTransform::detachFromReceiver(RTCRtpReceiver&)
    61105{
    62     if (!m_backend)
    63         return;
    64 
    65     willClearBackend(*m_backend);
    66     m_backend = nullptr;
     106    clearBackend();
    67107}
    68108
    69109void RTCRtpTransform::detachFromSender(RTCRtpSender&)
    70110{
    71     if (!m_backend)
    72         return;
     111    clearBackend();
     112}
    73113
    74     willClearBackend(*m_backend);
    75     m_backend = nullptr;
     114bool 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    });
    76129}
    77130
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpTransform.h

    r269764 r270107  
    2828#if ENABLE(WEB_RTC)
    2929
     30#include "RTCRtpSFrameTransform.h"
     31#include "RTCRtpScriptTransform.h"
    3032#include "RTCRtpTransformBackend.h"
    31 #include <wtf/RefCounted.h>
    32 #include <wtf/RefPtr.h>
    3333
    3434namespace WebCore {
     
    3737class RTCRtpSender;
    3838
    39 class WEBCORE_EXPORT RTCRtpTransform : public RefCounted<RTCRtpTransform> {
     39class RTCRtpTransform {
    4040public:
    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();
    4246
    4347    bool isAttached() const;
     
    4751    void detachFromSender(RTCRtpSender&);
    4852
     53    Internal internalTransform() { return m_transform; }
     54
     55    friend bool operator==(const RTCRtpTransform&, const RTCRtpTransform&);
     56
    4957private:
    50     virtual void initializeBackendForSender(RTCRtpTransformBackend&);
    51     virtual void initializeBackendForReceiver(RTCRtpTransformBackend&);
    52     virtual void willClearBackend(RTCRtpTransformBackend&);
     58    void clearBackend();
    5359
    54 protected:
    5560    RefPtr<RTCRtpTransformBackend> m_backend;
     61    Internal m_transform;
    5662};
    5763
    58 inline bool RTCRtpTransform::isAttached() const
     64bool operator==(const RTCRtpTransform&, const RTCRtpTransform&);
     65inline bool operator!=(const RTCRtpTransform& a, const RTCRtpTransform& b)
    5966{
    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);
    7368}
    7469
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpTransformBackend.h

    r269764 r270107  
    3737    virtual ~RTCRtpTransformBackend() = default;
    3838
    39     using Callback = Function<void(RTCRtpTransformableFrame&&)>;
     39    using Callback = Function<void(UniqueRef<RTCRtpTransformableFrame>&&)>;
    4040    virtual void setTransformableFrameCallback(Callback&&) = 0;
    4141    virtual void clearTransformableFrameCallback() = 0;
  • trunk/Source/WebCore/Modules/mediastream/RTCRtpTransformableFrame.h

    r269764 r270107  
    3030
    3131class RTCRtpTransformableFrame {
     32    WTF_MAKE_FAST_ALLOCATED;
    3233public:
    3334    virtual ~RTCRtpTransformableFrame() = default;
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp

    r269764 r270107  
    2929
    3030#include "LibWebRTCRtpTransformableFrame.h"
     31#include <wtf/UniqueRef.h>
    3132
    3233namespace WebCore {
     
    3435void LibWebRTCRtpTransformBackend::setInputCallback(Callback&& callback)
    3536{
    36     ASSERT(isMainThread());
    3737    auto locker = holdLock(m_inputCallbackLock);
    3838    m_inputCallback = WTFMove(callback);
     
    6262        auto locker = holdLock(m_inputCallbackLock);
    6363        if (m_inputCallback) {
    64             m_inputCallback(LibWebRTCRtpTransformableFrame(WTFMove(rtcFrame)));
     64            m_inputCallback(makeUniqueRef<LibWebRTCRtpTransformableFrame>(WTFMove(rtcFrame)));
    6565            return;
    6666        }
  • trunk/Source/WebCore/Modules/streams/WritableStreamSink.h

    r270106 r270107  
    2424 */
    2525
    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
     33namespace JSC {
     34class JSValue;
     35}
     36
     37namespace WebCore {
     38
     39class WritableStreamSink : public RefCounted<WritableStreamSink> {
     40public:
     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;
    3346};
     47
     48} // namespace WebCore
  • trunk/Source/WebCore/Modules/streams/WritableStreamSink.idl

    r270106 r270107  
    2424 */
    2525
     26
    2627[
    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);
    3334};
  • trunk/Source/WebCore/Sources.txt

    r270101 r270107  
    159159Modules/mediastream/RTCDataChannel.cpp
    160160Modules/mediastream/RTCDataChannelEvent.cpp
     161Modules/mediastream/RTCEncodedAudioFrame.cpp
     162Modules/mediastream/RTCEncodedFrame.cpp
     163Modules/mediastream/RTCEncodedVideoFrame.cpp
    161164Modules/mediastream/RTCIceCandidate.cpp
    162165Modules/mediastream/RTCIceTransport.cpp
     
    167170Modules/mediastream/RTCRtpSFrameTransform.cpp
    168171Modules/mediastream/RTCRtpSFrameTransformer.cpp
     172Modules/mediastream/RTCRtpScriptTransform.cpp
     173Modules/mediastream/RTCRtpScriptTransformer.cpp
    169174Modules/mediastream/RTCRtpSender.cpp
    170175Modules/mediastream/RTCRtpTransform.cpp
     
    625630bindings/js/WebCoreTypedArrayController.cpp
    626631bindings/js/WindowProxy.cpp
     632bindings/js/WritableStream.cpp
    627633bridge/IdentifierRep.cpp
    628634bridge/NP_jsobject.cpp
     
    32983304JSRTCDegradationPreference.cpp
    32993305JSRTCDtxStatus.cpp
     3306JSRTCEncodedAudioFrame.cpp
     3307JSRTCEncodedVideoFrame.cpp
    33003308JSRTCIceCandidate.cpp
    33013309JSRTCIceCandidateInit.cpp
     
    33273335JSRTCRtpRtxParameters.cpp
    33283336JSRTCRtpSFrameTransform.cpp
     3337JSRTCRtpScriptTransform.cpp
     3338JSRTCRtpScriptTransformer.cpp
     3339JSRTCRtpScriptTransformerConstructor.cpp
    33293340JSRTCRtpSendParameters.cpp
    33303341JSRTCRtpSender.cpp
     
    33323343JSRTCRtpTransceiver.cpp
    33333344JSRTCRtpTransceiverDirection.cpp
    3334 JSRTCRtpTransform.cpp
    33353345JSRTCSdpType.cpp
    33363346JSRTCSessionDescription.cpp
     
    37253735JSWritableStreamDefaultController.cpp
    37263736JSWritableStreamDefaultWriter.cpp
     3737JSWritableStreamSink.cpp
    37273738JSXMLDocument.cpp
    37283739JSXMLHttpRequest.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r270101 r270107  
    11061106                4181C5CD2555836900AEB0FF /* LibWebRTCRtpTransformableFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5CC2555836800AEB0FF /* LibWebRTCRtpTransformableFrame.h */; };
    11071107                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 */; };
    11111108                4181C648255B4C2800AEB0FF /* RTCRtpSFrameTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C642255B4C2600AEB0FF /* RTCRtpSFrameTransformer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11121109                4181C64A255B4C2800AEB0FF /* RTCRtpSFrameTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C644255B4C2700AEB0FF /* RTCRtpSFrameTransform.h */; };
     
    76057602                413C8B242552EEA900E65055 /* RTCRtpReceiver+Transform.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "RTCRtpReceiver+Transform.idl"; sourceTree = "<group>"; };
    76067603                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>"; };
    76087604                413C8B2E2552F27B00E65055 /* RTCRtpSenderWithTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpSenderWithTransform.h; sourceTree = "<group>"; };
    76097605                413C8B2F2552F27B00E65055 /* RTCRtpTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpTransform.h; sourceTree = "<group>"; };
     
    76147610                413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryReleaseCocoa.mm; sourceTree = "<group>"; };
    76157611                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>"; };
    76167633                414460A02412994100814BE7 /* MediaSessionIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionIdentifier.h; sourceTree = "<group>"; };
    76177634                414598BE23C8AAB8002B9CC8 /* SampleBufferDisplayLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleBufferDisplayLayer.h; sourceTree = "<group>"; };
     
    77297746                4181C5CE2555895500AEB0FF /* LibWebRTCRtpTransformBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCRtpTransformBackend.cpp; path = libwebrtc/LibWebRTCRtpTransformBackend.cpp; sourceTree = "<group>"; };
    77307747                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>"; };
    77347748                4181C63F255B4C2500AEB0FF /* RTCRtpSFrameTransformerCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpSFrameTransformerCocoa.cpp; sourceTree = "<group>"; };
    77357749                4181C641255B4C2600AEB0FF /* RTCRtpSFrameTransformer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpSFrameTransformer.cpp; sourceTree = "<group>"; };
     
    1709717111                                41FCB75E214866FF0038ADC6 /* RTCDtxStatus.h */,
    1709817112                                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 */,
    1709917121                                07221B7117CEC32700848E51 /* RTCIceCandidate.cpp */,
    1710017122                                07221B7217CEC32700848E51 /* RTCIceCandidate.h */,
     
    1716017182                                41FCB760214867000038ADC6 /* RTCRtpRtxParameters.h */,
    1716117183                                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 */,
    1716217193                                413C8B262552EEA900E65055 /* RTCRtpSender+Transform.idl */,
    1716317194                                5E2C43591BCEE30D0001E2BC /* RTCRtpSender.cpp */,
     
    1718317214                                4181C5C62555735100AEB0FF /* RTCRtpTransform.cpp */,
    1718417215                                413C8B2F2552F27B00E65055 /* RTCRtpTransform.h */,
    17185                                 413C8B292552F01300E65055 /* RTCRtpTransform.idl */,
    1718617216                                4181C5CA255582E300AEB0FF /* RTCRtpTransformableFrame.h */,
    1718717217                                4181C5C8255573DF00AEB0FF /* RTCRtpTransformBackend.h */,
     
    1934019370                                A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */,
    1934119371                                A140618A1E2ECA0A0032B34E /* MockPreviewLoaderClient.h */,
    19342                                 4181C5D32555C1B100AEB0FF /* MockRTCRtpTransform.cpp */,
    19343                                 4181C5D52555C1B900AEB0FF /* MockRTCRtpTransform.h */,
    19344                                 4181C636255AE26100AEB0FF /* MockRTCRtpTransform.idl */,
    1934519372                                57156108234C1B31008FC7AB /* MockWebAuthenticationConfiguration.h */,
    1934619373                                5715610D234C7481008FC7AB /* MockWebAuthenticationConfiguration.idl */,
     
    1946819495                                4176673224DC08EB008BFE28 /* WritableStreamDefaultWriter.js */,
    1946919496                                9908B0F11BCACF9100ED0F75 /* WritableStreamInternals.js */,
     19497                                41418A022564359800363417 /* WritableStreamSink.h */,
     19498                                41418A002564359700363417 /* WritableStreamSink.idl */,
    1947019499                        );
    1947119500                        path = streams;
     
    2693426963                                463521AC2081090E00C28922 /* WindowProxy.cpp */,
    2693526964                                463521AA2081090B00C28922 /* WindowProxy.h */,
     26965                                41418A0325643E1200363417 /* WritableStream.cpp */,
     26966                                41418A0425643E1300363417 /* WritableStream.h */,
    2693626967                        );
    2693726968                        path = js;
     
    3360933640                                07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */,
    3361033641                                07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */,
    33611                                 4181C5D62555C1B900AEB0FF /* MockRTCRtpTransform.h in Headers */,
    3361233642                                CDF2B0171820540700F2B424 /* MockSourceBufferPrivate.h in Headers */,
    3361333643                                CDF2B0191820540700F2B424 /* MockTracks.h in Headers */,
     
    3573635766                                A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
    3573735767                                A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */,
    35738                                 4181C639255AE90F00AEB0FF /* JSMockRTCRtpTransform.cpp in Sources */,
    3573935768                                57156114234C7FD6008FC7AB /* JSMockWebAuthenticationConfiguration.cpp in Sources */,
    3574035769                                427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
     
    3575635785                                A1AFEDE71F8BFF6D0087013F /* MockPaymentCoordinator.cpp in Sources */,
    3575735786                                A140618B1E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp in Sources */,
    35758                                 4181C5D72555C49A00AEB0FF /* MockRTCRtpTransform.cpp in Sources */,
    3575935787                                AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */,
    3576035788                                417F0D821FFEE979008EF303 /* ServiceWorkerInternals.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp

    r265039 r270107  
    9090}
    9191
     92bool 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
    92108bool ReadableStreamDefaultController::enqueue(RefPtr<JSC::ArrayBuffer>&& buffer)
    93109{
     
    110126    }
    111127
    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);
    120129}
    121130
  • trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.h

    r264967 r270107  
    4545
    4646    bool enqueue(RefPtr<JSC::ArrayBuffer>&&);
     47    bool enqueue(JSC::JSValue);
    4748    void error(const Exception&);
    4849    void close();
  • trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h

    r270101 r270107  
    223223    macro(RTCRtpReceiver) \
    224224    macro(RTCRtpSFrameTransform) \
     225    macro(RTCRtpScriptTransform) \
    225226    macro(RTCRtpSender) \
    226227    macro(RTCRtpTransceiver) \
  • trunk/Source/WebCore/dom/EventTargetFactory.in

    r268762 r270107  
    3939RTCDTMFSender conditional=WEB_RTC
    4040RTCPeerConnection conditional=WEB_RTC
     41RTCRtpScriptTransform conditional=WEB_RTC
    4142ServiceWorker conditional=SERVICE_WORKER
    4243ServiceWorkerContainer conditional=SERVICE_WORKER
  • trunk/Source/WebCore/testing/Internals.cpp

    r269830 r270107  
    139139#include "MockPageOverlay.h"
    140140#include "MockPageOverlayClient.h"
    141 #include "MockRTCRtpTransform.h"
    142141#include "NavigatorBeacon.h"
    143142#include "NavigatorMediaDevices.h"
     
    15781577}
    15791578
    1580 Ref<MockRTCRtpTransform> Internals::createMockRTCRtpTransform()
    1581 {
    1582     return MockRTCRtpTransform::create();
    1583 }
    1584 
    15851579uint64_t Internals::sframeCounter(const RTCRtpSFrameTransform& transform)
    15861580{
  • trunk/Source/WebCore/testing/Internals.h

    r269830 r270107  
    3333#include "HEVCUtilities.h"
    3434#include "IDLTypes.h"
    35 #include "MockRTCRtpTransform.h"
    3635#include "OrientationNotifier.h"
    3736#include "PageConsoleClient.h"
     
    611610    void setWebRTCVP9Support(bool);
    612611    void setWebRTCVP9VTBSupport(bool);
    613     Ref<MockRTCRtpTransform> createMockRTCRtpTransform();
    614612    uint64_t sframeCounter(const RTCRtpSFrameTransform&);
    615613    void setEnableWebRTCEncryption(bool);
  • trunk/Source/WebCore/testing/Internals.idl

    r269830 r270107  
    803803    [Conditional=WEB_RTC] undefined setWebRTCVP9Support(boolean allowed);
    804804    [Conditional=WEB_RTC] undefined setWebRTCVP9VTBSupport(boolean allowed);
    805     [Conditional=WEB_RTC] MockRTCRtpTransform createMockRTCRtpTransform();
    806805    [Conditional=WEB_RTC] unsigned long long sframeCounter(RTCRtpSFrameTransform transform);
    807806
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp

    r269974 r270107  
    3636#include "DOMWindow.h"
    3737#include "DedicatedWorkerThread.h"
     38#include "JSRTCRtpScriptTransformer.h"
     39#include "JSRTCRtpScriptTransformerConstructor.h"
    3840#include "MessageEvent.h"
     41#include "RTCRtpScriptTransformer.h"
    3942#include "RequestAnimationFrameCallback.h"
    4043#include "SecurityOrigin.h"
     
    113116#endif
    114117
     118#if ENABLE(WEB_RTC)
     119ExceptionOr<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
     152RefPtr<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
    115186} // namespace WebCore
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h

    r268775 r270107  
    3232#pragma once
    3333
     34#include "MessagePort.h"
    3435#include "PostMessageOptions.h"
    3536#include "WorkerGlobalScope.h"
     
    4546class ContentSecurityPolicyResponseHeaders;
    4647class DedicatedWorkerThread;
    47 class MessagePort;
     48class JSRTCRtpScriptTransformerConstructor;
     49class RTCRtpScriptTransformer;
    4850class RequestAnimationFrameCallback;
    4951class SerializedScriptValue;
     
    5456using CallbackId = int;
    5557#endif
     58
     59using TransferredMessagePort = std::pair<WebCore::MessagePortIdentifier, WebCore::MessagePortIdentifier>;
    5660
    5761class DedicatedWorkerGlobalScope final : public WorkerGlobalScope {
     
    7276#endif
    7377
     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
    7484private:
    7585    using Base = WorkerGlobalScope;
     
    8696    RefPtr<WorkerAnimationController> m_workerAnimationController;
    8797#endif
     98#if ENABLE(WEB_RTC)
     99    HashMap<String, RefPtr<JSRTCRtpScriptTransformerConstructor>> m_rtcRtpTransformerConstructorMap;
     100    RefPtr<MessagePort> m_pendingRTCTransfomerMessagePort;
     101#endif
    88102};
    89103
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl

    r266706 r270107  
    4949
    5050[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  
    3535#include "LoaderStrategy.h"
    3636#include "PlatformStrategies.h"
     37#include "RTCRtpScriptTransform.h"
    3738#include "ResourceResponse.h"
    3839#include "SecurityOrigin.h"
     
    231232}
    232233
     234#if ENABLE(WEB_RTC)
     235void Worker::addRTCRtpScriptTransformer(String&& name)
     236{
     237    m_transformers.add(WTFMove(name));
     238}
     239
     240void 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
     252void Worker::postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&& task)
     253{
     254    m_contextProxy.postTaskToWorkerGlobalScope(WTFMove(task));
     255}
     256#endif
     257
    233258} // namespace WebCore
  • trunk/Source/WebCore/workers/Worker.h

    r261499 r270107  
    4646namespace WebCore {
    4747
     48class RTCRtpScriptTransform;
     49class RTCRtpScriptTransformer;
    4850class ScriptExecutionContext;
    4951class WorkerGlobalScopeProxy;
     
    7072
    7173    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
    7281
    7382private:
     
    101110    Deque<RefPtr<Event>> m_pendingEvents;
    102111    bool m_wasTerminated { false };
     112#if ENABLE(WEB_RTC)
     113    HashSet<String> m_transformers;
     114#endif
    103115};
    104116
  • trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h

    r256012 r270107  
    3434#include "MessageWithMessagePorts.h"
    3535#include <JavaScriptCore/RuntimeFlags.h>
     36#include <wtf/Function.h>
    3637#include <wtf/MonotonicTime.h>
    3738
     
    3940
    4041class ContentSecurityPolicyResponseHeaders;
     42class ScriptExecutionContext;
    4143class Worker;
    4244enum class ReferrerPolicy : uint8_t;
     
    5052    virtual void terminateWorkerGlobalScope() = 0;
    5153    virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0;
     54    virtual void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) = 0;
    5255    virtual bool hasPendingActivity() const = 0;
    5356    virtual void workerObjectDestroyed() = 0;
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp

    r268057 r270107  
    111111}
    112112
     113void 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
    113123void WorkerMessagingProxy::postMessageToWorkerGlobalScope(MessageWithMessagePorts&& message)
    114124{
    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 {
    119126        ASSERT_WITH_SECURITY_IMPLICATION(scriptContext.isWorkerGlobalScope());
    120127        auto& context = static_cast<DedicatedWorkerGlobalScope&>(scriptContext);
     
    123130        context.thread().workerObjectProxy().confirmMessageFromWorkerObject(context.hasPendingActivity());
    124131    });
    125 
    126     if (m_workerThread) {
    127         ++m_unconfirmedMessageCount;
    128         m_workerThread->runLoop().postTask(WTFMove(task));
    129     } else
     132}
     133
     134void WorkerMessagingProxy::postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&& task)
     135{
     136    if (m_askedToTerminate)
     137        return;
     138
     139    if (!m_workerThread) {
    130140        m_queuedEarlyTasks.append(makeUnique<ScriptExecutionContext::Task>(WTFMove(task)));
     141        return;
     142    }
     143    ++m_unconfirmedMessageCount;
     144    m_workerThread->runLoop().postTask(WTFMove(task));
    131145}
    132146
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.h

    r268057 r270107  
    5454    void terminateWorkerGlobalScope() final;
    5555    void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
     56    void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&) final;
    5657    bool hasPendingActivity() const final;
    5758    void workerObjectDestroyed() final;
     
    6364    // (Only use these functions in the worker context thread.)
    6465    void postMessageToWorkerObject(MessageWithMessagePorts&&) final;
     66    void postTaskToWorkerObject(Function<void(Worker&)>&&) final;
    6567    void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) final;
    6668    void confirmMessageFromWorkerObject(bool hasPendingActivity) final;
  • trunk/Source/WebCore/workers/WorkerObjectProxy.h

    r227190 r270107  
    3333#include "MessageWithMessagePorts.h"
    3434#include "WorkerReportingProxy.h"
     35
    3536#include <memory>
     37#include <wtf/Function.h>
    3638
    3739namespace WebCore {
     40
     41class Worker;
    3842
    3943// A proxy to talk to the worker object.
     
    4145public:
    4246    virtual void postMessageToWorkerObject(MessageWithMessagePorts&&) = 0;
     47    virtual void postTaskToWorkerObject(Function<void(Worker&)>&&) { };
    4348
    4449    virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
Note: See TracChangeset for help on using the changeset viewer.