Diff
Modified: trunk/LayoutTests/ChangeLog (274384 => 274385)
--- trunk/LayoutTests/ChangeLog 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/ChangeLog 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,3 +1,26 @@
+2021-03-13 Youenn Fablet <you...@apple.com>
+
+ Update RTCRtpScriptTransform to the latest version of the spec
+ https://bugs.webkit.org/show_bug.cgi?id=222982
+
+ Reviewed by Eric Carlson.
+
+ * http/wpt/webrtc/audio-script-transform.html:
+ * http/wpt/webrtc/context-transform.js:
+ (MockRTCRtpTransformer):
+ (MockRTCRtpTransformer.prototype.start):
+ (MockRTCRtpTransformer.prototype.process):
+ (onrtctransform):
+ * http/wpt/webrtc/no-transform.js:
+ * http/wpt/webrtc/no-webrtc-transform-expected.txt:
+ * http/wpt/webrtc/no-webrtc-transform.html:
+ * http/wpt/webrtc/script-transform.js:
+ (onrtctransform.process):
+ (onrtctransform):
+ * http/wpt/webrtc/sframe-transform.js:
+ (onrtctransform):
+ * http/wpt/webrtc/video-script-transform.html:
+
2021-03-13 Martin Robinson <mrobin...@webkit.org>
Add basic (non-momentum) wheel event handling for scroll snap
Modified: trunk/LayoutTests/http/wpt/webrtc/audio-script-transform.html (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/audio-script-transform.html 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/audio-script-transform.html 2021-03-13 11:11:28 UTC (rev 274385)
@@ -33,8 +33,8 @@
const localStream = await navigator.mediaDevices.getUserMedia({audio: true});
let sender, receiver;
- senderTransform = new RTCRtpScriptTransform(worker, 'MockRTCRtpTransform');
- receiverTransform = new RTCRtpScriptTransform(worker, 'MockRTCRtpTransform');
+ senderTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', mediaType:'audio', side:'sender'});
+ receiverTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', mediaType:'audio', side:'receiver'});
promise1 = waitForMessage(senderTransform.port, "started audio sender");
promise2 = waitForMessage(receiverTransform.port, "started audio receiver");
Modified: trunk/LayoutTests/http/wpt/webrtc/context-transform.js (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/context-transform.js 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/context-transform.js 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,21 +1,21 @@
-class MockRTCRtpTransformer extends RTCRtpScriptTransformer {
- constructor() {
- super();
+class MockRTCRtpTransformer {
+ constructor(transformer) {
this.askKeyFrame = false;
- this.port._onmessage_ = (event) => {
+ this.context = transformer;
+ this.context.port._onmessage_ = (event) => {
if (event.data ="" "startKeyFrames")
this.askKeyFrame = true;
else if (event.data ="" "endKeyFrames")
this.askKeyFrame = false;
};
+ this.start();
}
- start(readableStream, writableStream, context)
+ start()
{
- this.reader = readableStream.getReader();
- this.writer = writableStream.getWriter();
+ this.reader = this.context.readable.getReader();
+ this.writer = this.context.writable.getWriter();
this.process();
- this.context = context;
- this.port.postMessage("started " + context.mediaType + " " + context.side);
+ this.context.port.postMessage("started " + this.context.options.mediaType + " " + this.context.options.side);
}
process()
@@ -26,9 +26,9 @@
this.writer.write(chunk.value);
- if (this.context.mediaType === "video") {
+ if (this.context.options.mediaType === "video") {
if (chunk.value instanceof RTCEncodedVideoFrame)
- this.port.postMessage("video frame " + chunk.value.type);
+ this.context.port.postMessage("video frame " + chunk.value.type);
if (this.askKeyFrame)
this.context.requestKeyFrame();
@@ -39,5 +39,8 @@
}
};
-registerRTCRtpScriptTransformer("MockRTCRtpTransform", MockRTCRtpTransformer);
+_onrtctransform_ = (event) => {
+ new MockRTCRtpTransformer(event.transformer);
+};
+
self.postMessage("registered");
Modified: trunk/LayoutTests/http/wpt/webrtc/no-transform.js (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/no-transform.js 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/no-transform.js 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1 +1 @@
-self.postMessage(self.registerRTCRtpScriptTransformer ? "on" : "off");
+self.postMessage(self.RTCRtpScriptTransformer ? "on" : "off");
Modified: trunk/LayoutTests/http/wpt/webrtc/no-webrtc-transform-expected.txt (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/no-webrtc-transform-expected.txt 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/no-webrtc-transform-expected.txt 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,4 +1,4 @@
-PASS registerRTCRtpScriptTransformer if insertable stream flag is on
-PASS no registerRTCRtpScriptTransformer if insertable stream flag is off
+PASS RTCRtpScriptTransformer if insertable stream flag is on
+PASS no RTCRtpScriptTransformer if insertable stream flag is off
Modified: trunk/LayoutTests/http/wpt/webrtc/no-webrtc-transform.html (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/no-webrtc-transform.html 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/no-webrtc-transform.html 2021-03-13 11:11:28 UTC (rev 274385)
@@ -14,7 +14,7 @@
const worker = new Worker('no-transform.js');
const data = "" new Promise(resolve => worker._onmessage_ = (event) => resolve(event.data));
assert_equals(data, "on");
-}, "registerRTCRtpScriptTransformer if insertable stream flag is on");
+}, "RTCRtpScriptTransformer if insertable stream flag is on");
promise_test(async (test) => {
if (window.internals)
@@ -23,7 +23,7 @@
const worker = new Worker('no-transform.js');
const data = "" new Promise(resolve => worker._onmessage_ = (event) => resolve(event.data));
assert_equals(data, "off");
-}, "no registerRTCRtpScriptTransformer if insertable stream flag is off");
+}, "no RTCRtpScriptTransformer if insertable stream flag is off");
</script>
</body>
</html>
Modified: trunk/LayoutTests/http/wpt/webrtc/script-transform.js (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/script-transform.js 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/script-transform.js 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,19 +1,14 @@
-class MockRTCRtpTransformer extends RTCRtpScriptTransformer {
- constructor() {
- super();
- this.port._onmessage_ = (event) => this.port.postMessage(event.data);
- }
- start(readableStream, writableStream)
- {
- self.postMessage("started");
- this.reader = readableStream.getReader();
- this.writer = writableStream.getWriter();
- this.process();
- }
+_onrtctransform_ = (event) => {
+ const transformer = event.transformer;
+ transformer.port._onmessage_ = (event) => transformer.port.postMessage(event.data);
- process()
+ self.postMessage("started");
+ transformer.reader = transformer.readable.getReader();
+ transformer.writer = transformer.writable.getWriter();
+
+ function process(transformer)
{
- this.reader.read().then(chunk => {
+ transformer.reader.read().then(chunk => {
if (chunk.done)
return;
if (chunk.value instanceof RTCEncodedVideoFrame)
@@ -20,11 +15,11 @@
self.postMessage("video chunk");
else if (chunk.value instanceof RTCEncodedAudioFrame)
self.postMessage("audio chunk");
- this.writer.write(chunk.value);
- this.process();
+ transformer.writer.write(chunk.value);
+ process(transformer);
});
}
+
+ process(transformer);
};
-
-registerRTCRtpScriptTransformer("MockRTCRtpTransform", MockRTCRtpTransformer);
self.postMessage("registered");
Modified: trunk/LayoutTests/http/wpt/webrtc/sframe-transform.js (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/sframe-transform.js 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/sframe-transform.js 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,14 +1,7 @@
-class SFrameRTCRtpTransformer extends RTCRtpScriptTransformer {
- constructor() {
- super();
- this.sframeTransform = new SFrameTransform({ role : "decrypt", authenticationSize: "10", compatibilityMode: "H264" });
- crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]).then(key => this.sframeTransform.setEncryptionKey(key));
- }
- start(readableStream, writableStream)
- {
- readableStream.pipeThrough(this.sframeTransform).pipeTo(writableStream);
- }
-};
-
-registerRTCRtpScriptTransformer("SFrameRTCRtpTransform", SFrameRTCRtpTransformer);
+_onrtctransform_ = (event) => {
+ const sframeTransform = new SFrameTransform({ role : "decrypt", authenticationSize: "10", compatibilityMode: "H264" });
+ crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]).then(key => sframeTransform.setEncryptionKey(key));
+ const transformer = event.transformer;
+ transformer.readable.pipeThrough(sframeTransform).pipeTo(transformer.writable);
+}
self.postMessage("registered");
Modified: trunk/LayoutTests/http/wpt/webrtc/video-script-transform.html (274384 => 274385)
--- trunk/LayoutTests/http/wpt/webrtc/video-script-transform.html 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/LayoutTests/http/wpt/webrtc/video-script-transform.html 2021-03-13 11:11:28 UTC (rev 274385)
@@ -33,8 +33,8 @@
const localStream = await navigator.mediaDevices.getUserMedia({video: true});
let sender, receiver;
- senderTransform = new RTCRtpScriptTransform(worker, 'MockRTCRtpTransform');
- receiverTransform = new RTCRtpScriptTransform(worker, 'MockRTCRtpTransform');
+ senderTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', mediaType:'video', side:'sender'});
+ receiverTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', mediaType:'video', side:'receiver'});
promise1 = waitForMessage(senderTransform.port, "started video sender");
promise2 = waitForMessage(receiverTransform.port, "started video receiver");
Modified: trunk/Source/WebCore/CMakeLists.txt (274384 => 274385)
--- trunk/Source/WebCore/CMakeLists.txt 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/CMakeLists.txt 2021-03-13 11:11:28 UTC (rev 274385)
@@ -407,8 +407,6 @@
Modules/mediastream/RTCRtpScriptTransform.idl
Modules/mediastream/RTCRtpScriptTransformProvider.idl
Modules/mediastream/RTCRtpScriptTransformer.idl
- Modules/mediastream/RTCRtpScriptTransformerConstructor.idl
- Modules/mediastream/RTCRtpScriptTransformerContext.idl
Modules/mediastream/RTCRtpSendParameters.idl
Modules/mediastream/RTCRtpSender+Transform.idl
Modules/mediastream/RTCRtpSender.idl
@@ -421,6 +419,7 @@
Modules/mediastream/RTCSignalingState.idl
Modules/mediastream/RTCStatsReport.idl
Modules/mediastream/RTCTrackEvent.idl
+ Modules/mediastream/RTCTransformEvent.idl
Modules/model-element/HTMLModelElement.idl
Modified: trunk/Source/WebCore/ChangeLog (274384 => 274385)
--- trunk/Source/WebCore/ChangeLog 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/ChangeLog 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,3 +1,62 @@
+2021-03-13 Youenn Fablet <you...@apple.com>
+
+ Update RTCRtpScriptTransform to the latest version of the spec
+ https://bugs.webkit.org/show_bug.cgi?id=222982
+
+ Reviewed by Eric Carlson.
+
+ Move from AudioWorklet model to an event based model as per latest specification.
+ RTCRtpScriptTransformer concentrates all the API and is exposed to worker using a new rtctransform event.
+ Add support for options parameter provided in RTCRtpScriptTransform constructor.
+
+ Covered by existing tests.
+
+ * CMakeLists.txt:
+ * DerivedSources-input.xcfilelist:
+ * DerivedSources-output.xcfilelist:
+ * DerivedSources.make:
+ * Modules/mediastream/RTCRtpScriptTransform.cpp:
+ (WebCore::RTCRtpScriptTransform::create):
+ (WebCore::RTCRtpScriptTransform::setTransformer):
+ * Modules/mediastream/RTCRtpScriptTransform.h:
+ * Modules/mediastream/RTCRtpScriptTransform.idl:
+ * Modules/mediastream/RTCRtpScriptTransformProvider.idl:
+ * Modules/mediastream/RTCRtpScriptTransformer.cpp:
+ (WebCore::RTCRtpScriptTransformer::create):
+ (WebCore::RTCRtpScriptTransformer::RTCRtpScriptTransformer):
+ (WebCore::RTCRtpScriptTransformer::readable):
+ (WebCore::RTCRtpScriptTransformer::writable):
+ (WebCore::RTCRtpScriptTransformer::start):
+ (WebCore::RTCRtpScriptTransformer::requestKeyFrame):
+ (WebCore::RTCRtpScriptTransformer::options):
+ * Modules/mediastream/RTCRtpScriptTransformer.h:
+ (WebCore::RTCRtpScriptTransformer::startPendingActivity):
+ * Modules/mediastream/RTCRtpScriptTransformer.idl:
+ * Modules/mediastream/RTCRtpScriptTransformerConstructor.h: Removed.
+ * Modules/mediastream/RTCRtpScriptTransformerConstructor.idl: Removed.
+ * Modules/mediastream/RTCRtpScriptTransformerContext.h: Removed.
+ * Modules/mediastream/RTCRtpScriptTransformerContext.idl: Removed.
+ * Modules/mediastream/RTCTransformEvent.cpp: Added.
+ * Modules/mediastream/RTCTransformEvent.h: Added.
+ * Modules/mediastream/RTCTransformEvent.idl: Added.
+ * Modules/model-element/HTMLModelElement.cpp:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/ReadableStream.h:
+ (WebCore::toJS):
+ * bindings/js/WebCoreBuiltinNames.h:
+ * bindings/js/WritableStream.h:
+ (WebCore::toJS):
+ * dom/EventNames.h:
+ * dom/EventNames.in:
+ * workers/DedicatedWorkerGlobalScope.cpp:
+ (WebCore::DedicatedWorkerGlobalScope::prepareForDestruction):
+ (WebCore::DedicatedWorkerGlobalScope::createRTCRtpScriptTransformer):
+ * workers/DedicatedWorkerGlobalScope.h:
+ * workers/Worker.cpp:
+ (WebCore::Worker::createRTCRtpScriptTransformer):
+ * workers/Worker.h:
+
2021-03-12 Antoine Quint <grao...@webkit.org>
Fix interpolation of orphans and widows CSS properties
Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (274384 => 274385)
--- trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-03-13 11:11:28 UTC (rev 274385)
@@ -249,8 +249,6 @@
$(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransform.idl
$(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformProvider.idl
$(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformer.idl
-$(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl
-$(PROJECT_DIR)/Modules/mediastream/RTCRtpScriptTransformerContext.idl
$(PROJECT_DIR)/Modules/mediastream/RTCRtpSendParameters.idl
$(PROJECT_DIR)/Modules/mediastream/RTCRtpSender+Transform.idl
$(PROJECT_DIR)/Modules/mediastream/RTCRtpSender.idl
@@ -264,6 +262,7 @@
$(PROJECT_DIR)/Modules/mediastream/RTCSignalingState.idl
$(PROJECT_DIR)/Modules/mediastream/RTCStatsReport.idl
$(PROJECT_DIR)/Modules/mediastream/RTCTrackEvent.idl
+$(PROJECT_DIR)/Modules/mediastream/RTCTransformEvent.idl
$(PROJECT_DIR)/Modules/model-element/HTMLModelElement.idl
$(PROJECT_DIR)/Modules/notifications/Notification.idl
$(PROJECT_DIR)/Modules/notifications/NotificationPermission.idl
Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (274384 => 274385)
--- trunk/Source/WebCore/DerivedSources-output.xcfilelist 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1734,10 +1734,6 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformProvider.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformer.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformer.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformerConstructor.cpp
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformerConstructor.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformerContext.cpp
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpScriptTransformerContext.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSendParameters.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSendParameters.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCRtpSender+Transform.cpp
@@ -1764,6 +1760,8 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCStatsReport.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCTrackEvent.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCTrackEvent.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCTransformEvent.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCTransformEvent.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRadioNodeList.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRadioNodeList.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRange+CSSOMView.cpp
Modified: trunk/Source/WebCore/DerivedSources.make (274384 => 274385)
--- trunk/Source/WebCore/DerivedSources.make 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/DerivedSources.make 2021-03-13 11:11:28 UTC (rev 274385)
@@ -276,8 +276,6 @@
$(WebCore)/Modules/mediastream/RTCRtpScriptTransform.idl \
$(WebCore)/Modules/mediastream/RTCRtpScriptTransformProvider.idl \
$(WebCore)/Modules/mediastream/RTCRtpScriptTransformer.idl \
- $(WebCore)/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl \
- $(WebCore)/Modules/mediastream/RTCRtpScriptTransformerContext.idl \
$(WebCore)/Modules/mediastream/RTCRtpSynchronizationSource.idl \
$(WebCore)/Modules/mediastream/RTCRtpTransceiver.idl \
$(WebCore)/Modules/mediastream/RTCRtpTransceiverDirection.idl \
@@ -287,6 +285,7 @@
$(WebCore)/Modules/mediastream/RTCSignalingState.idl \
$(WebCore)/Modules/mediastream/RTCStatsReport.idl \
$(WebCore)/Modules/mediastream/RTCTrackEvent.idl \
+ $(WebCore)/Modules/mediastream/RTCTransformEvent.idl \
$(WebCore)/Modules/model-element/HTMLModelElement.idl \
$(WebCore)/Modules/notifications/Notification.idl \
$(WebCore)/Modules/notifications/NotificationPermission.idl \
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.cpp (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.cpp 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.cpp 2021-03-13 11:11:28 UTC (rev 274385)
@@ -30,6 +30,7 @@
#include "ErrorEvent.h"
#include "EventNames.h"
+#include "JSDOMGlobalObject.h"
#include "MessageChannel.h"
#include "RTCRtpScriptTransformer.h"
#include "RTCRtpTransformBackend.h"
@@ -41,22 +42,27 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(RTCRtpScriptTransform);
-ExceptionOr<Ref<RTCRtpScriptTransform>> RTCRtpScriptTransform::create(ScriptExecutionContext& context, Worker& worker, String&& name)
+ExceptionOr<Ref<RTCRtpScriptTransform>> RTCRtpScriptTransform::create(JSC::JSGlobalObject& state, Worker& worker, JSC::JSValue options)
{
- if (!worker.hasRTCRtpScriptTransformer(name))
- return Exception { InvalidStateError, "No RTCRtpScriptTransformer was registered with this name"_s };
-
if (!worker.scriptExecutionContext())
return Exception { InvalidStateError, "Worker frame is detached"_s };
+ auto* context = JSC::jsCast<JSDOMGlobalObject*>(&state)->scriptExecutionContext();
+ if (!context)
+ return Exception { InvalidStateError, "Invalid context"_s };
+
+ auto serializedOptions = SerializedScriptValue::create(state, options);
+ if (!serializedOptions)
+ return Exception { ExistingExceptionError };
+
auto messageChannel = MessageChannel::create(*worker.scriptExecutionContext());
auto transformMessagePort = messageChannel->port1();
auto transformerMessagePort = messageChannel->port2();
- auto transform = adoptRef(*new RTCRtpScriptTransform(context, makeRef(worker), makeRef(*transformMessagePort)));
+ auto transform = adoptRef(*new RTCRtpScriptTransform(*context, makeRef(worker), makeRef(*transformMessagePort)));
transform->suspendIfNeeded();
- worker.createRTCRtpScriptTransformer(name, transformerMessagePort->disentangle(), transform);
+ worker.createRTCRtpScriptTransformer(transform, serializedOptions.releaseNonNull(), transformerMessagePort->disentangle());
return transform;
}
@@ -73,23 +79,16 @@
clear();
}
-void RTCRtpScriptTransform::setTransformer(RefPtr<RTCRtpScriptTransformer>&& transformer)
+void RTCRtpScriptTransform::setTransformer(RTCRtpScriptTransformer& transformer)
{
ASSERT(!isMainThread());
- if (!transformer) {
- callOnMainThread([this, protectedThis = makeRef(*this)]() mutable {
- queueTaskToDispatchEvent(*this, TaskSource::MediaElement, ErrorEvent::create(eventNames().errorEvent, "An error was thrown from RTCRtpScriptTransformer constructor"_s, { }, 0, 0, { }));
- });
- return;
- }
-
{
auto locker = holdLock(m_transformerLock);
ASSERT(!m_isTransformerInitialized);
m_isTransformerInitialized = true;
- m_transformer = makeWeakPtr(transformer.get());
+ m_transformer = makeWeakPtr(transformer);
}
- transformer->startPendingActivity();
+ transformer.startPendingActivity();
callOnMainThread([this, protectedThis = makeRef(*this)]() mutable {
if (m_backend)
setupTransformer(m_backend.releaseNonNull());
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.h (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -30,6 +30,7 @@
#include "ActiveDOMObject.h"
#include "EventTarget.h"
#include "MessagePort.h"
+#include <_javascript_Core/JSCJSValue.h>
#include <wtf/Lock.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -45,12 +46,12 @@
, public EventTargetWithInlineData {
WTF_MAKE_ISO_ALLOCATED(RTCRtpScriptTransform);
public:
- static ExceptionOr<Ref<RTCRtpScriptTransform>> create(ScriptExecutionContext&, Worker&, String&& name);
+ static ExceptionOr<Ref<RTCRtpScriptTransform>> create(JSC::JSGlobalObject&, Worker&, JSC::JSValue);
~RTCRtpScriptTransform();
MessagePort& port() { return m_port.get(); }
- void setTransformer(RefPtr<RTCRtpScriptTransformer>&&);
+ void setTransformer(RTCRtpScriptTransformer&);
bool isAttached() const { return m_isAttached; }
void initializeBackendForReceiver(RTCRtpTransformBackend&);
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.idl (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.idl 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransform.idl 2021-03-13 11:11:28 UTC (rev 274385)
@@ -30,7 +30,7 @@
Exposed=Window,
JSGenerateToNativeObject,
] interface RTCRtpScriptTransform : EventTarget {
- [CallWith=ScriptExecutionContext] constructor(Worker worker, DOMString name);
+ [CallWith=GlobalObject] constructor(Worker worker, any options);
readonly attribute MessagePort port;
};
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformProvider.idl (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformProvider.idl 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformProvider.idl 2021-03-13 11:11:28 UTC (rev 274385)
@@ -24,5 +24,5 @@
*/
interface mixin RTCRtpScriptTransformProvider {
- [MayThrowException] undefined registerRTCRtpScriptTransformer(DOMString name, RTCRtpScriptTransformerConstructor processorConstructor);
+ attribute EventHandler onrtctransform;
};
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp 2021-03-13 11:11:28 UTC (rev 274385)
@@ -31,29 +31,38 @@
#include "DedicatedWorkerGlobalScope.h"
#include "JSRTCEncodedAudioFrame.h"
#include "JSRTCEncodedVideoFrame.h"
-#include "JSRTCRtpScriptTransformerContext.h"
#include "RTCRtpTransformableFrame.h"
#include "ReadableStream.h"
#include "ReadableStreamSource.h"
+#include "SerializedScriptValue.h"
#include "WritableStream.h"
#include "WritableStreamSink.h"
namespace WebCore {
-ExceptionOr<Ref<RTCRtpScriptTransformer>> RTCRtpScriptTransformer::create(ScriptExecutionContext& context)
+ExceptionOr<Ref<RTCRtpScriptTransformer>> RTCRtpScriptTransformer::create(ScriptExecutionContext& context, Ref<SerializedScriptValue>&& options, Ref<MessagePort>&& port)
{
- auto port = downcast<DedicatedWorkerGlobalScope>(context).takePendingRTCTransfomerMessagePort();
- if (!port)
- return Exception { TypeError, "No pending construction data for this RTCRtpScriptTransformer"_s };
+ if (!context.globalObject())
+ return Exception { InvalidStateError };
- auto transformer = adoptRef(*new RTCRtpScriptTransformer(context, port.releaseNonNull()));
+ auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(context.globalObject());
+ JSC::JSLockHolder lock(globalObject.vm());
+ auto readableSource = SimpleReadableStreamSource::create();
+ auto readable = ReadableStream::create(globalObject, readableSource.copyRef());
+ if (readable.hasException())
+ return readable.releaseException();
+
+ auto transformer = adoptRef(*new RTCRtpScriptTransformer(context, WTFMove(options), WTFMove(port), readable.releaseReturnValue(), WTFMove(readableSource)));
transformer->suspendIfNeeded();
return transformer;
}
-RTCRtpScriptTransformer::RTCRtpScriptTransformer(ScriptExecutionContext& context, Ref<MessagePort>&& port)
+RTCRtpScriptTransformer::RTCRtpScriptTransformer(ScriptExecutionContext& context, Ref<SerializedScriptValue>&& options, Ref<MessagePort>&& port, Ref<ReadableStream>&& readable, Ref<SimpleReadableStreamSource>&& readableSource)
: ActiveDOMObject(&context)
+ , m_options(WTFMove(options))
, m_port(WTFMove(port))
+ , m_readableSource(WTFMove(readableSource))
+ , m_readable(WTFMove(readable))
{
}
@@ -61,68 +70,51 @@
{
}
-RefPtr<SimpleReadableStreamSource> RTCRtpScriptTransformer::startStreams(RTCRtpTransformBackend& backend)
+ReadableStream& RTCRtpScriptTransformer::readable()
{
- auto callback = WTFMove(m_callback);
- if (!callback)
- return nullptr;
+ return m_readable.get();
+}
- auto& context = downcast<WorkerGlobalScope>(*scriptExecutionContext());
- auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(context.globalObject());
+ExceptionOr<Ref<WritableStream>> RTCRtpScriptTransformer::writable()
+{
+ if (!m_writable) {
+ auto* context = downcast<WorkerGlobalScope>(scriptExecutionContext());
+ if (!context || !context->globalObject())
+ return Exception { InvalidStateError };
- auto& vm = globalObject.vm();
- JSC::JSLockHolder lock(vm);
+ auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(context->globalObject());
+ auto writableOrException = WritableStream::create(globalObject, SimpleWritableStreamSink::create([transformer = makeRef(*this)](auto& context, auto value) -> ExceptionOr<void> {
+ auto& globalObject = *context.globalObject();
- auto readableStreamSource = SimpleReadableStreamSource::create();
- auto readableStream = ReadableStream::create(globalObject, readableStreamSource.copyRef());
- if (readableStream.hasException())
- return nullptr;
+ auto scope = DECLARE_THROW_SCOPE(globalObject.vm());
+ auto frame = convert<IDLUnion<IDLInterface<RTCEncodedAudioFrame>, IDLInterface<RTCEncodedVideoFrame>>>(globalObject, value);
- auto writableStream = WritableStream::create(globalObject, SimpleWritableStreamSink::create([backend = makeRef(backend)](auto& context, auto value) -> ExceptionOr<void> {
- auto& globalObject = *context.globalObject();
+ if (scope.exception())
+ return Exception { ExistingExceptionError };
- auto scope = DECLARE_THROW_SCOPE(globalObject.vm());
- auto frame = convert<IDLUnion<IDLInterface<RTCEncodedAudioFrame>, IDLInterface<RTCEncodedVideoFrame>>>(globalObject, value);
-
- if (scope.exception())
- return Exception { ExistingExceptionError };
-
- auto rtcFrame = WTF::switchOn(frame, [&](RefPtr<RTCEncodedAudioFrame>& value) {
- return makeRef(value->rtcFrame());
- }, [&](RefPtr<RTCEncodedVideoFrame>& value) {
- return makeRef(value->rtcFrame());
- });
- backend->processTransformedFrame(rtcFrame.get());
- return { };
- }));
- if (writableStream.hasException())
- return nullptr;
-
- // Call start callback.
- JSC::MarkedArgumentBuffer args;
- args.append(toJSNewlyCreated(&globalObject, &globalObject, readableStream.releaseReturnValue()));
- args.append(toJSNewlyCreated(&globalObject, &globalObject, writableStream.releaseReturnValue()));
- args.append(toJSNewlyCreated(&globalObject, &globalObject, RTCRtpScriptTransformerContext::create(makeRef(backend))));
-
- NakedPtr<JSC::Exception> returnedException;
- callback->invokeCallback(JSC::jsUndefined(), args, JSCallbackData::CallbackType::Object, JSC::Identifier::fromString(vm, "start"), returnedException);
- // FIXME: Do something in case of exception? We should at least log errors.
-
- return readableStreamSource;
+ auto rtcFrame = WTF::switchOn(frame, [&](RefPtr<RTCEncodedAudioFrame>& value) {
+ return makeRef(value->rtcFrame());
+ }, [&](RefPtr<RTCEncodedVideoFrame>& value) {
+ return makeRef(value->rtcFrame());
+ });
+ transformer->m_backend->processTransformedFrame(rtcFrame.get());
+ return { };
+ }));
+ if (writableOrException.hasException())
+ return writableOrException;
+ m_writable = writableOrException.releaseReturnValue();
+ }
+ return makeRef(*m_writable);
}
void RTCRtpScriptTransformer::start(Ref<RTCRtpTransformBackend>&& backend)
{
- auto readableStreamSource = startStreams(backend.get());
- if (!readableStreamSource)
- return;
-
m_backend = WTFMove(backend);
auto& context = downcast<WorkerGlobalScope>(*scriptExecutionContext());
- m_backend->setTransformableFrameCallback([readableStreamSource = makeWeakPtr(readableStreamSource.get()), isAudio = m_backend->mediaType() == RTCRtpTransformBackend::MediaType::Audio, thread = makeRef(context.thread())](auto&& frame) mutable {
- thread->runLoop().postTaskForMode([readableStreamSource, isAudio, frame = WTFMove(frame)](auto& context) mutable {
- if (!readableStreamSource)
+ m_backend->setTransformableFrameCallback([readableSource = makeWeakPtr(m_readableSource.get()), isAudio = m_backend->mediaType() == RTCRtpTransformBackend::MediaType::Audio, thread = makeRef(context.thread())](auto&& frame) mutable {
+ thread->runLoop().postTaskForMode([readableSource, isAudio, frame = WTFMove(frame)](auto& context) mutable {
+ if (!readableSource)
return;
auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(context.globalObject());
@@ -130,7 +122,7 @@
JSC::JSLockHolder lock(vm);
auto value = isAudio ? toJS(&globalObject, &globalObject, RTCEncodedAudioFrame::create(WTFMove(frame))) : toJS(&globalObject, &globalObject, RTCEncodedVideoFrame::create(WTFMove(frame)));
- readableStreamSource->enqueue(value);
+ readableSource->enqueue(value);
}, WorkerRunLoop::defaultMode());
});
}
@@ -143,6 +135,23 @@
stopPendingActivity();
}
+ExceptionOr<void> RTCRtpScriptTransformer::requestKeyFrame()
+{
+ if (!m_backend)
+ return Exception { InvalidStateError, "Not attached to a receiver or sender"_s };
+
+ if (m_backend->mediaType() != RTCRtpTransformBackend::MediaType::Video)
+ return Exception { InvalidStateError, "Cannot request key frame on audio sender"_s };
+
+ m_backend->requestKeyFrame();
+ return { };
+}
+
+JSC::JSValue RTCRtpScriptTransformer::options(JSC::JSGlobalObject& globalObject)
+{
+ return m_options->deserialize(globalObject, &globalObject);
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.h (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -29,7 +29,8 @@
#include "ActiveDOMObject.h"
#include "ExceptionOr.h"
-#include "JSCallbackData.h"
+#include "RTCRtpTransformBackend.h"
+#include <_javascript_Core/JSCJSValue.h>
#include <wtf/RefCounted.h>
#include <wtf/WeakPtr.h>
@@ -36,9 +37,12 @@
namespace WebCore {
class MessagePort;
+class ReadableStream;
class ScriptExecutionContext;
class RTCRtpTransformBackend;
+class SerializedScriptValue;
class SimpleReadableStreamSource;
+class WritableStream;
class RTCRtpScriptTransformer
: public RefCounted<RTCRtpScriptTransformer>
@@ -45,32 +49,37 @@
, public ActiveDOMObject
, public CanMakeWeakPtr<RTCRtpScriptTransformer> {
public:
- static ExceptionOr<Ref<RTCRtpScriptTransformer>> create(ScriptExecutionContext&);
+ static ExceptionOr<Ref<RTCRtpScriptTransformer>> create(ScriptExecutionContext&, Ref<SerializedScriptValue>&&, Ref<MessagePort>&&);
~RTCRtpScriptTransformer();
- void setCallback(std::unique_ptr<JSCallbackDataStrong>&& callback) { m_callback = WTFMove(callback); }
+ ReadableStream& readable();
+ ExceptionOr<Ref<WritableStream>> writable();
+ JSC::JSValue options(JSC::JSGlobalObject&);
+
+ ExceptionOr<void> requestKeyFrame();
MessagePort& port() { return m_port.get(); }
+ void startPendingActivity() { m_pendingActivity = makePendingActivity(*this); }
void start(Ref<RTCRtpTransformBackend>&&);
void clear();
- void startPendingActivity() { m_pendingActivity = makePendingActivity(*this); }
-
private:
- RTCRtpScriptTransformer(ScriptExecutionContext&, Ref<MessagePort>&&);
+ RTCRtpScriptTransformer(ScriptExecutionContext&, Ref<SerializedScriptValue>&&, Ref<MessagePort>&&, Ref<ReadableStream>&&, Ref<SimpleReadableStreamSource>&&);
- RefPtr<SimpleReadableStreamSource> startStreams(RTCRtpTransformBackend&);
-
// ActiveDOMObject
const char* activeDOMObjectName() const { return "RTCRtpScriptTransformer"; }
void stop() final { stopPendingActivity(); }
void stopPendingActivity() { auto pendingActivity = WTFMove(m_pendingActivity); }
+ Ref<SerializedScriptValue> m_options;
Ref<MessagePort> m_port;
- std::unique_ptr<JSCallbackDataStrong> m_callback;
+
+ Ref<SimpleReadableStreamSource> m_readableSource;
+ Ref<ReadableStream> m_readable;
+ RefPtr<WritableStream> m_writable;
+
RefPtr<RTCRtpTransformBackend> m_backend;
RefPtr<PendingActivity<RTCRtpScriptTransformer>> m_pendingActivity;
-
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.idl (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.idl 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.idl 2021-03-13 11:11:28 UTC (rev 274385)
@@ -30,8 +30,10 @@
Exposed=DedicatedWorker,
JSGenerateToNativeObject,
] interface RTCRtpScriptTransformer {
- [CallWith=ScriptExecutionContext] constructor(/* optional object transformOptions */);
+ readonly attribute ReadableStream readable;
+ readonly attribute WritableStream writable;
+ [CallWith=GlobalObject, CachedAttribute] readonly attribute any options;
- // FIXME: add controller attribute.
readonly attribute MessagePort port;
+ [MayThrowException] undefined requestKeyFrame();
};
Deleted: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.h (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(WEB_RTC)
-
-#include "ActiveDOMCallback.h"
-#include "CallbackResult.h"
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class RTCRtpScriptTransformer;
-
-class RTCRtpScriptTransformerConstructor : public RefCounted<RTCRtpScriptTransformerConstructor>, public ActiveDOMCallback {
-public:
- using ActiveDOMCallback::ActiveDOMCallback;
-
- virtual CallbackResult<RefPtr<RTCRtpScriptTransformer>> handleEvent() = 0;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_RTC)
Deleted: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-[
- Conditional=WEB_RTC,
-] callback RTCRtpScriptTransformerConstructor = RTCRtpScriptTransformer();
Deleted: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerContext.h (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerContext.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerContext.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(WEB_RTC)
-
-#include "RTCRtpTransformBackend.h"
-#include <wtf/Ref.h>
-
-namespace WebCore {
-
-class RTCRtpTransformBackend;
-
-class RTCRtpScriptTransformerContext
- : public RefCounted<RTCRtpScriptTransformerContext> {
-public:
- static Ref<RTCRtpScriptTransformerContext> create(Ref<RTCRtpTransformBackend>&&);
- ~RTCRtpScriptTransformerContext() = default;
-
- using Side = RTCRtpTransformBackend::Side;
- Side side() const { return m_backend->side(); }
-
- using MediaType = RTCRtpTransformBackend::MediaType;
- MediaType mediaType() const { return m_backend->mediaType(); }
-
- ExceptionOr<void> requestKeyFrame();
-
-private:
- explicit RTCRtpScriptTransformerContext(Ref<RTCRtpTransformBackend>&&);
-
- Ref<RTCRtpTransformBackend> m_backend;
-};
-
-inline Ref<RTCRtpScriptTransformerContext> RTCRtpScriptTransformerContext::create(Ref<RTCRtpTransformBackend>&& backend)
-{
- return adoptRef(*new RTCRtpScriptTransformerContext(WTFMove(backend)));
-}
-
-inline RTCRtpScriptTransformerContext::RTCRtpScriptTransformerContext(Ref<RTCRtpTransformBackend>&& backend)
- : m_backend(WTFMove(backend))
-{
-}
-
-inline ExceptionOr<void> RTCRtpScriptTransformerContext::requestKeyFrame()
-{
- switch (mediaType()) {
- case MediaType::Audio:
- return Exception { InvalidStateError, "Cannot request key frame on audio sender"_s };
- case MediaType::Video:
- m_backend->requestKeyFrame();
- return { };
- default:
- return { };
- }
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_RTC)
Deleted: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerContext.idl (274384 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerContext.idl 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerContext.idl 2021-03-13 11:11:28 UTC (rev 274385)
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-enum RTCRtpScriptTransformerContextSide { "receiver", "sender" };
-enum RTCRtpScriptTransformerContextMediaType { "audio", "video" };
-
-[
- Conditional=WEB_RTC,
- EnabledBySetting=WebRTCInsertableStreams,
- Exposed=DedicatedWorker,
- ImplementationLacksVTable,
-] interface RTCRtpScriptTransformerContext {
- readonly attribute RTCRtpScriptTransformerContextSide side;
- readonly attribute RTCRtpScriptTransformerContextMediaType mediaType;
-
- [MayThrowException] undefined requestKeyFrame();
-};
Added: trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.cpp (0 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.cpp 2021-03-13 11:11:28 UTC (rev 274385)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RTCTransformEvent.h"
+
+#if ENABLE(WEB_RTC)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(RTCTransformEvent);
+
+Ref<RTCTransformEvent> RTCTransformEvent::create(const AtomString& type, Ref<RTCRtpScriptTransformer>&& transformer, IsTrusted isTrusted)
+{
+ return adoptRef(*new RTCTransformEvent(type, WTFMove(transformer), isTrusted));
+}
+
+RTCTransformEvent::RTCTransformEvent(const AtomString& type, Ref<RTCRtpScriptTransformer>&& transformer, IsTrusted isTrusted)
+ : Event(type, { }, isTrusted)
+ , m_transformer(WTFMove(transformer))
+{
+}
+
+RTCRtpScriptTransformer& RTCTransformEvent::transformer()
+{
+ return m_transformer.get();
+}
+
+EventInterface RTCTransformEvent::eventInterface() const
+{
+ return RTCTransformEventInterfaceType;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)
+
Copied: trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.h (from rev 274384, trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.h) (0 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.h (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_RTC)
+
+#include "Event.h"
+#include "RTCRtpScriptTransformer.h"
+#include <wtf/text/AtomString.h>
+
+namespace WebCore {
+
+class RTCTransformEvent final : public Event {
+ WTF_MAKE_ISO_ALLOCATED(RTCTransformEvent);
+public:
+ static Ref<RTCTransformEvent> create(const AtomString& type, Ref<RTCRtpScriptTransformer>&&, IsTrusted = IsTrusted::No);
+
+ RTCRtpScriptTransformer& transformer();
+
+ EventInterface eventInterface() const final;
+
+private:
+ RTCTransformEvent(const AtomString& type, Ref<RTCRtpScriptTransformer>&&, IsTrusted);
+
+ Ref<RTCRtpScriptTransformer> m_transformer;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)
Copied: trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.idl (from rev 274384, trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformerConstructor.idl) (0 => 274385)
--- trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.idl (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCTransformEvent.idl 2021-03-13 11:11:28 UTC (rev 274385)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_RTC,
+ EnabledBySetting=WebRTCInsertableStreams,
+ Exposed=Worker,
+ InterfaceName=RTCTransformEvent,
+] interface RTCTransformEvent : Event {
+ constructor(DOMString type, RTCRtpScriptTransformer transformer);
+
+ readonly attribute RTCRtpScriptTransformer transformer;
+};
Modified: trunk/Source/WebCore/Sources.txt (274384 => 274385)
--- trunk/Source/WebCore/Sources.txt 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/Sources.txt 2021-03-13 11:11:28 UTC (rev 274385)
@@ -178,6 +178,7 @@
Modules/mediastream/RTCRtpTransceiver.cpp
Modules/mediastream/RTCSessionDescription.cpp
Modules/mediastream/RTCTrackEvent.cpp
+Modules/mediastream/RTCTransformEvent.cpp
Modules/mediastream/SFrameUtils.cpp
Modules/mediastream/STUNMessageParsing.cpp
Modules/mediastream/UserMediaController.cpp
@@ -3387,8 +3388,6 @@
JSRTCRtpSFrameTransform.cpp
JSRTCRtpScriptTransform.cpp
JSRTCRtpScriptTransformer.cpp
-JSRTCRtpScriptTransformerConstructor.cpp
-JSRTCRtpScriptTransformerContext.cpp
JSRTCRtpSendParameters.cpp
JSRTCRtpSender.cpp
JSRTCRtpSynchronizationSource.cpp
@@ -3400,6 +3399,7 @@
JSRTCSignalingState.cpp
JSRTCStatsReport.cpp
JSRTCTrackEvent.cpp
+JSRTCTransformEvent.cpp
JSRadioNodeList.cpp
JSRange.cpp
JSReadableByteStreamController.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (274384 => 274385)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-13 11:11:28 UTC (rev 274385)
@@ -7718,8 +7718,6 @@
414189F32562E32C00363417 /* RTCRtpScriptTransformer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpScriptTransformer.cpp; sourceTree = "<group>"; };
414189F42562E32C00363417 /* RTCRtpScriptTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCRtpScriptTransform.cpp; sourceTree = "<group>"; };
414189F52562E32D00363417 /* RTCRtpScriptTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpScriptTransformer.h; sourceTree = "<group>"; };
- 414189F62562E67A00363417 /* RTCRtpScriptTransformerConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpScriptTransformerConstructor.h; sourceTree = "<group>"; };
- 414189F72562E67A00363417 /* RTCRtpScriptTransformerConstructor.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpScriptTransformerConstructor.idl; sourceTree = "<group>"; };
414189F92564165000363417 /* RTCEncodedAudioFrame.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCEncodedAudioFrame.idl; sourceTree = "<group>"; };
414189FA2564165100363417 /* RTCEncodedVideoFrame.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCEncodedVideoFrame.idl; sourceTree = "<group>"; };
414189FB2564175700363417 /* RTCEncodedAudioFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCEncodedAudioFrame.h; sourceTree = "<group>"; };
@@ -7893,8 +7891,6 @@
419E6EC42566D211002B5010 /* RTCPeerConnectionIceErrorEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RTCPeerConnectionIceErrorEvent.idl; sourceTree = "<group>"; };
419E6EC62566D213002B5010 /* RTCPeerConnectionIceErrorEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RTCPeerConnectionIceErrorEvent.cpp; sourceTree = "<group>"; };
419E6EC72566D214002B5010 /* RTCPeerConnectionIceErrorEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCPeerConnectionIceErrorEvent.h; sourceTree = "<group>"; };
- 419E6ED22567BF69002B5010 /* RTCRtpScriptTransformerContext.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpScriptTransformerContext.idl; sourceTree = "<group>"; };
- 419E6ED52567BF6A002B5010 /* RTCRtpScriptTransformerContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpScriptTransformerContext.h; sourceTree = "<group>"; };
419FAFAD1ABABCD5005B3572 /* ReadableStreamBYOBReader.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamBYOBReader.idl; sourceTree = "<group>"; };
419FAFAD1ABABCD5005B828B /* ReadableStreamDefaultReader.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultReader.idl; sourceTree = "<group>"; };
41A023ED1A39DB7900F722CF /* ReadableStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStream.idl; sourceTree = "<group>"; };
@@ -7934,6 +7930,9 @@
41B8776023DE1042003638B8 /* RealtimeMediaSourceIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeMediaSourceIdentifier.h; sourceTree = "<group>"; };
41B9137623584D0E0025BFA3 /* MockAudioDestinationCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockAudioDestinationCocoa.h; sourceTree = "<group>"; };
41B9137823584D0F0025BFA3 /* MockAudioDestinationCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockAudioDestinationCocoa.cpp; sourceTree = "<group>"; };
+ 41BCE87525F7A6790046C2E5 /* RTCTransformEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCTransformEvent.idl; sourceTree = "<group>"; };
+ 41BCE87625F7A67A0046C2E5 /* RTCTransformEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCTransformEvent.cpp; sourceTree = "<group>"; };
+ 41BCE87725F7A67A0046C2E5 /* RTCTransformEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCTransformEvent.h; sourceTree = "<group>"; };
41BF204022B947160004F812 /* RealtimeVideoSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RealtimeVideoSource.h; sourceTree = "<group>"; };
41BF204222B947170004F812 /* RealtimeVideoSource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeVideoSource.cpp; sourceTree = "<group>"; };
41C760B00EDE03D300C1655F /* ScriptState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptState.h; sourceTree = "<group>"; };
@@ -17380,10 +17379,6 @@
414189F32562E32C00363417 /* RTCRtpScriptTransformer.cpp */,
414189F52562E32D00363417 /* RTCRtpScriptTransformer.h */,
414189F12562DF5600363417 /* RTCRtpScriptTransformer.idl */,
- 414189F62562E67A00363417 /* RTCRtpScriptTransformerConstructor.h */,
- 414189F72562E67A00363417 /* RTCRtpScriptTransformerConstructor.idl */,
- 419E6ED52567BF6A002B5010 /* RTCRtpScriptTransformerContext.h */,
- 419E6ED22567BF69002B5010 /* RTCRtpScriptTransformerContext.idl */,
414189EF2562DF0C00363417 /* RTCRtpScriptTransformProvider.idl */,
413C8B262552EEA900E65055 /* RTCRtpSender+Transform.idl */,
5E2C43591BCEE30D0001E2BC /* RTCRtpSender.cpp */,
@@ -17422,6 +17417,9 @@
5E2C43641BCEE3720001E2BC /* RTCTrackEvent.cpp */,
5E2C43651BCEE3720001E2BC /* RTCTrackEvent.h */,
5E2C43661BCEE3720001E2BC /* RTCTrackEvent.idl */,
+ 41BCE87625F7A67A0046C2E5 /* RTCTransformEvent.cpp */,
+ 41BCE87725F7A67A0046C2E5 /* RTCTransformEvent.h */,
+ 41BCE87525F7A6790046C2E5 /* RTCTransformEvent.idl */,
41209E26257A2FBB00120ACA /* SFrameUtils.cpp */,
41209E24257A2FBB00120ACA /* SFrameUtils.h */,
41E67A7F25D16846007B0A4C /* STUNMessageParsing.cpp */,
Modified: trunk/Source/WebCore/bindings/js/ReadableStream.h (274384 => 274385)
--- trunk/Source/WebCore/bindings/js/ReadableStream.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/bindings/js/ReadableStream.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -84,6 +84,11 @@
return stream ? stream->readableStream() : JSC::jsUndefined();
}
+inline JSC::JSValue toJS(JSC::JSGlobalObject*, JSC::JSGlobalObject*, ReadableStream& stream)
+{
+ return stream.readableStream();
+}
+
inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<ReadableStream>&& stream)
{
return stream->readableStream();
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (274384 => 274385)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -232,6 +232,7 @@
macro(RTCSessionDescription) \
macro(RTCStatsReport) \
macro(RTCTrackEvent) \
+ macro(RTCTransformEvent) \
macro(ReadableByteStreamController) \
macro(ReadableStream) \
macro(ReadableStreamBYOBReader) \
@@ -381,6 +382,7 @@
macro(matchingElementInFlatTree) \
macro(mediaStreamTrackConstraints) \
macro(openDatabase) \
+ macro(onrtctransform) \
macro(ontouchcancel) \
macro(ontouchend) \
macro(ontouchmove) \
@@ -419,7 +421,6 @@
macro(reader) \
macro(readyPromise) \
macro(readyPromiseCapability) \
- macro(registerRTCRtpScriptTransformer) \
macro(requestAnimationFrame) \
macro(requestIdleCallback) \
macro(response) \
Modified: trunk/Source/WebCore/bindings/js/WritableStream.h (274384 => 274385)
--- trunk/Source/WebCore/bindings/js/WritableStream.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/bindings/js/WritableStream.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -81,6 +81,11 @@
return stream ? stream->writableStream() : JSC::jsUndefined();
}
+inline JSC::JSValue toJS(JSC::JSGlobalObject*, JSC::JSGlobalObject*, WritableStream& stream)
+{
+ return stream.writableStream();
+}
+
inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<WritableStream>&& stream)
{
return stream->writableStream();
Modified: trunk/Source/WebCore/dom/EventNames.h (274384 => 274385)
--- trunk/Source/WebCore/dom/EventNames.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/dom/EventNames.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -232,6 +232,7 @@
macro(resourcetimingbufferfull) \
macro(result) \
macro(resume) \
+ macro(rtctransform) \
macro(scroll) \
macro(search) \
macro(securitypolicyviolation) \
Modified: trunk/Source/WebCore/dom/EventNames.in (274384 => 274385)
--- trunk/Source/WebCore/dom/EventNames.in 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/dom/EventNames.in 2021-03-13 11:11:28 UTC (rev 274385)
@@ -62,6 +62,7 @@
RTCDataChannelEvent conditional=WEB_RTC
RTCDTMFToneChangeEvent conditional=WEB_RTC
RTCTrackEvent conditional=WEB_RTC
+RTCTransformEvent conditional=WEB_RTC
SpeechRecognitionErrorEvent
SpeechRecognitionEvent
SpeechSynthesisEvent conditional=SPEECH_SYNTHESIS
Modified: trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp (274384 => 274385)
--- trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp 2021-03-13 11:11:28 UTC (rev 274385)
@@ -39,6 +39,7 @@
#include "GraphicsContextGL.h"
#include "WebGLProgram.h"
#include "WebGLRenderingContextBase.h"
+#include "WebGLSampler.h"
#include "WebGLShader.h"
#endif
Modified: trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp (274384 => 274385)
--- trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp 2021-03-13 11:11:28 UTC (rev 274385)
@@ -35,10 +35,10 @@
#include "ContentSecurityPolicyResponseHeaders.h"
#include "DOMWindow.h"
#include "DedicatedWorkerThread.h"
+#include "EventNames.h"
#include "JSRTCRtpScriptTransformer.h"
-#include "JSRTCRtpScriptTransformerConstructor.h"
#include "MessageEvent.h"
-#include "RTCRtpScriptTransformer.h"
+#include "RTCTransformEvent.h"
#include "RequestAnimationFrameCallback.h"
#include "SecurityOrigin.h"
#include "Worker.h"
@@ -76,10 +76,6 @@
void DedicatedWorkerGlobalScope::prepareForDestruction()
{
WorkerGlobalScope::prepareForDestruction();
-
-#if ENABLE(WEB_RTC)
- m_rtcRtpTransformerConstructorMap.clear();
-#endif
}
ExceptionOr<void> DedicatedWorkerGlobalScope::postMessage(JSC::JSGlobalObject& state, JSC::JSValue messageValue, PostMessageOptions&& options)
@@ -126,71 +122,15 @@
#endif
#if ENABLE(WEB_RTC)
-ExceptionOr<void> DedicatedWorkerGlobalScope::registerRTCRtpScriptTransformer(String&& name, Ref<JSRTCRtpScriptTransformerConstructor>&& transformerConstructor)
+RefPtr<RTCRtpScriptTransformer> DedicatedWorkerGlobalScope::createRTCRtpScriptTransformer(Ref<SerializedScriptValue>&& options, TransferredMessagePort&& port)
{
- ASSERT(!isMainThread());
-
- if (name.isEmpty())
- return Exception { NotSupportedError, "Name cannot be the empty string"_s };
-
- if (m_rtcRtpTransformerConstructorMap.contains(name))
- return Exception { NotSupportedError, "A transformer was already registered with this name"_s };
-
- JSC::JSObject* jsConstructor = transformerConstructor->callbackData()->callback();
- auto* globalObject = jsConstructor->globalObject();
- auto& vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- if (!jsConstructor->isConstructor(vm))
- return Exception { TypeError, "Class definitition passed to registerRTCRtpScriptTransformer() is not a constructor"_s };
-
- auto prototype = jsConstructor->getPrototype(vm, globalObject);
- RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
-
- if (!prototype.isObject())
- return Exception { TypeError, "Class definitition passed to registerRTCRtpScriptTransformer() has invalid prototype"_s };
-
- m_rtcRtpTransformerConstructorMap.add(name, WTFMove(transformerConstructor));
-
- thread().workerObjectProxy().postTaskToWorkerObject([name = name.isolatedCopy()](auto& worker) mutable {
- worker.addRTCRtpScriptTransformer(WTFMove(name));
- });
-
- return { };
-}
-
-RefPtr<RTCRtpScriptTransformer> DedicatedWorkerGlobalScope::createRTCRtpScriptTransformer(String&& name, TransferredMessagePort port)
-{
- auto constructor = m_rtcRtpTransformerConstructorMap.get(name);
- ASSERT(constructor);
- if (!constructor)
+ auto transformerOrException = RTCRtpScriptTransformer::create(*this, WTFMove(options), MessagePort::entangle(*this, WTFMove(port)));
+ if (transformerOrException.hasException())
return nullptr;
-
- auto* jsConstructor = constructor->callbackData()->callback();
- auto* globalObject = constructor->callbackData()->globalObject();
- auto& vm = globalObject->vm();
- auto scope = DECLARE_CATCH_SCOPE(vm);
- JSC::JSLockHolder lock { globalObject };
-
- m_pendingRTCTransfomerMessagePort = MessagePort::entangle(*this, WTFMove(port));
-
- JSC::MarkedArgumentBuffer args;
- auto* object = JSC::construct(globalObject, jsConstructor, args, "Failed to construct RTCRtpScriptTransformer");
- ASSERT(!!scope.exception() == !object);
-
- if (scope.exception()) {
- scope.clearException();
- return nullptr;
- }
- RETURN_IF_EXCEPTION(scope, nullptr);
-
- auto& jsTransformer = *JSC::jsCast<JSRTCRtpScriptTransformer*>(object);
- auto& transformer = jsTransformer.wrapped();
- transformer.setCallback(makeUnique<JSCallbackDataStrong>(&jsTransformer, globalObject));
-
- return &transformer;
+ auto transformer = transformerOrException.releaseReturnValue();
+ dispatchEvent(RTCTransformEvent::create(eventNames().rtctransformEvent, transformer.copyRef(), Event::IsTrusted::Yes));
+ return transformer;
}
-
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h (274384 => 274385)
--- trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -76,9 +76,7 @@
#endif
#if ENABLE(WEB_RTC)
- RefPtr<RTCRtpScriptTransformer> createRTCRtpScriptTransformer(String&&, TransferredMessagePort);
- ExceptionOr<void> registerRTCRtpScriptTransformer(String&&, Ref<JSRTCRtpScriptTransformerConstructor>&&);
- RefPtr<MessagePort> takePendingRTCTransfomerMessagePort() { return WTFMove(m_pendingRTCTransfomerMessagePort); }
+ RefPtr<RTCRtpScriptTransformer> createRTCRtpScriptTransformer(Ref<SerializedScriptValue>&&, TransferredMessagePort&&);
#endif
FetchOptions::Destination destination() const final { return FetchOptions::Destination::Worker; }
@@ -99,10 +97,6 @@
#if ENABLE(OFFSCREEN_CANVAS)
RefPtr<WorkerAnimationController> m_workerAnimationController;
#endif
-#if ENABLE(WEB_RTC)
- HashMap<String, RefPtr<JSRTCRtpScriptTransformerConstructor>> m_rtcRtpTransformerConstructorMap;
- RefPtr<MessagePort> m_pendingRTCTransfomerMessagePort;
-#endif
};
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/Worker.cpp (274384 => 274385)
--- trunk/Source/WebCore/workers/Worker.cpp 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/workers/Worker.cpp 2021-03-13 11:11:28 UTC (rev 274385)
@@ -249,18 +249,14 @@
}
#if ENABLE(WEB_RTC)
-void Worker::addRTCRtpScriptTransformer(String&& name)
+void Worker::createRTCRtpScriptTransformer(RTCRtpScriptTransform& transform, Ref<SerializedScriptValue>&& options, TransferredMessagePort&& port)
{
- m_transformers.add(WTFMove(name));
-}
-
-void Worker::createRTCRtpScriptTransformer(const String& name, TransferredMessagePort port, RTCRtpScriptTransform& transform)
-{
if (!scriptExecutionContext())
return;
- m_contextProxy.postTaskToWorkerGlobalScope([name = name.isolatedCopy(), port, transform = makeRef(transform)](auto& context) mutable {
- transform->setTransformer(downcast<DedicatedWorkerGlobalScope>(context).createRTCRtpScriptTransformer(WTFMove(name), port));
+ m_contextProxy.postTaskToWorkerGlobalScope([transform = makeRef(transform), options = WTFMove(options), port = WTFMove(port)](auto& context) mutable {
+ if (auto transformer = downcast<DedicatedWorkerGlobalScope>(context).createRTCRtpScriptTransformer(WTFMove(options), WTFMove(port)))
+ transform->setTransformer(*transformer);
callOnMainThread([transform = WTFMove(transform)] { });
});
Modified: trunk/Source/WebCore/workers/Worker.h (274384 => 274385)
--- trunk/Source/WebCore/workers/Worker.h 2021-03-13 11:03:39 UTC (rev 274384)
+++ trunk/Source/WebCore/workers/Worker.h 2021-03-13 11:11:28 UTC (rev 274385)
@@ -77,9 +77,7 @@
void dispatchEvent(Event&) final;
#if ENABLE(WEB_RTC)
- void addRTCRtpScriptTransformer(String&&);
- bool hasRTCRtpScriptTransformer(const String& name) { return m_transformers.contains(name); }
- void createRTCRtpScriptTransformer(const String&, TransferredMessagePort, RTCRtpScriptTransform&);
+ void createRTCRtpScriptTransformer(RTCRtpScriptTransform&, Ref<SerializedScriptValue>&&, TransferredMessagePort&&);
void postTaskToWorkerGlobalScope(Function<void(ScriptExecutionContext&)>&&);
#endif