Title: [255085] trunk
Revision
255085
Author
[email protected]
Date
2020-01-24 11:33:24 -0800 (Fri, 24 Jan 2020)

Log Message

Add support for MediaRecorder.requestData
https://bugs.webkit.org/show_bug.cgi?id=206731

LayoutTests/imported/w3c:

Reviewed by Eric Carlson.

* web-platform-tests/mediacapture-record/idlharness.window-expected.txt:

Source/WebCore:

Reviewed by Eric Carlson.

Add support for requestData that fetches any available data.
Expose MediaRecorder stream.
Covered by updated tests.

* Modules/mediarecorder/MediaRecorder.cpp:
(WebCore::MediaRecorder::requestData):
* Modules/mediarecorder/MediaRecorder.h:
* Modules/mediarecorder/MediaRecorder.idl:

LayoutTests:

Reviewed by Eric Carlson.

* http/wpt/mediarecorder/MediaRecorder-dataavailable.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (255084 => 255085)


--- trunk/LayoutTests/ChangeLog	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/LayoutTests/ChangeLog	2020-01-24 19:33:24 UTC (rev 255085)
@@ -1,3 +1,12 @@
+2020-01-24  youenn fablet  <[email protected]>
+
+        Add support for MediaRecorder.requestData
+        https://bugs.webkit.org/show_bug.cgi?id=206731
+
+        Reviewed by Eric Carlson.
+
+        * http/wpt/mediarecorder/MediaRecorder-dataavailable.html:
+
 2020-01-24  Jack Lee  <[email protected]>
 
         Nullptr deref in WebCore::RenderTreeBuilder::Block::attachIgnoringContinuation when an element is inserted before legend under multi-column layout.

Modified: trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-dataavailable.html (255084 => 255085)


--- trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-dataavailable.html	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-dataavailable.html	2020-01-24 19:33:24 UTC (rev 255085)
@@ -37,8 +37,24 @@
     async_test(t => {
         const video = createVideoStream();
         const recorder = new MediaRecorder(video);
+        let state = 0;
 
+        assert_equals(recorder.stream, video);
+
         recorder._ondataavailable_ = t.step_func(blobEvent => {
+            if (!state) {
+                assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
+                assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
+                assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
+                assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
+
+                state = 1;
+                setTimeout(() => {
+                   // Stopping the recorder will trigger another dataavailable event.
+                   recorder.stop();
+                }, 1000);
+                return;
+            }
             dataAvailableAssertions(blobEvent);
             t.done();
         });
@@ -45,9 +61,8 @@
         recorder.start();
         assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
         drawSomethingOnCanvas();
-        setTimeout(() => {
-            recorder.stop();
-        }, 1000)
+
+        recorder.requestData();
     }, 'MediaRecorder will fire a dataavailable event with a blob data for a video-only stream when stop() is called');
 
     async_test(t => {
@@ -101,4 +116,4 @@
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (255084 => 255085)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-01-24 19:33:24 UTC (rev 255085)
@@ -1,3 +1,12 @@
+2020-01-24  Youenn Fablet  <[email protected]>
+
+        Add support for MediaRecorder.requestData
+        https://bugs.webkit.org/show_bug.cgi?id=206731
+
+        Reviewed by Eric Carlson.
+
+        * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
+
 2020-01-23  Antoine Quint  <[email protected]>
 
         [Web Animations] Support multiple CSS Animations with the same name in animation-name

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/idlharness.window-expected.txt (255084 => 255085)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/idlharness.window-expected.txt	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/idlharness.window-expected.txt	2020-01-24 19:33:24 UTC (rev 255085)
@@ -7,7 +7,7 @@
 PASS MediaRecorder interface: existence and properties of interface prototype object 
 PASS MediaRecorder interface: existence and properties of interface prototype object's "constructor" property 
 PASS MediaRecorder interface: existence and properties of interface prototype object's @@unscopables property 
-FAIL MediaRecorder interface: attribute stream assert_true: The prototype object must have a property "stream" expected true got false
+PASS MediaRecorder interface: attribute stream 
 FAIL MediaRecorder interface: attribute mimeType assert_true: The prototype object must have a property "mimeType" expected true got false
 PASS MediaRecorder interface: attribute state 
 FAIL MediaRecorder interface: attribute onstart assert_true: The prototype object must have a property "onstart" expected true got false
@@ -22,11 +22,11 @@
 PASS MediaRecorder interface: operation stop() 
 FAIL MediaRecorder interface: operation pause() assert_own_property: interface prototype object missing non-static operation expected property "pause" missing
 FAIL MediaRecorder interface: operation resume() assert_own_property: interface prototype object missing non-static operation expected property "resume" missing
-FAIL MediaRecorder interface: operation requestData() assert_own_property: interface prototype object missing non-static operation expected property "requestData" missing
+PASS MediaRecorder interface: operation requestData() 
 FAIL MediaRecorder interface: operation isTypeSupported(DOMString) assert_own_property: interface object missing static operation expected property "isTypeSupported" missing
 PASS MediaRecorder must be primary interface of [object MediaRecorder] 
 PASS Stringification of [object MediaRecorder] 
-FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "stream" with the proper type assert_inherits: property "stream" not found in prototype chain
+PASS MediaRecorder interface: [object MediaRecorder] must inherit property "stream" with the proper type 
 FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "mimeType" with the proper type assert_inherits: property "mimeType" not found in prototype chain
 PASS MediaRecorder interface: [object MediaRecorder] must inherit property "state" with the proper type 
 FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "onstart" with the proper type assert_inherits: property "onstart" not found in prototype chain
@@ -42,7 +42,7 @@
 PASS MediaRecorder interface: [object MediaRecorder] must inherit property "stop()" with the proper type 
 FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "pause()" with the proper type assert_inherits: property "pause" not found in prototype chain
 FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "resume()" with the proper type assert_inherits: property "resume" not found in prototype chain
-FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "requestData()" with the proper type assert_inherits: property "requestData" not found in prototype chain
+PASS MediaRecorder interface: [object MediaRecorder] must inherit property "requestData()" with the proper type 
 PASS MediaRecorder interface: [object MediaRecorder] must inherit property "isTypeSupported(DOMString)" with the proper type 
 FAIL MediaRecorder interface: calling isTypeSupported(DOMString) on [object MediaRecorder] with too few arguments must throw TypeError assert_own_property: interface object must have static operation as own property expected property "isTypeSupported" missing
 PASS BlobEvent interface: existence and properties of interface object 

Modified: trunk/Source/WebCore/ChangeLog (255084 => 255085)


--- trunk/Source/WebCore/ChangeLog	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/Source/WebCore/ChangeLog	2020-01-24 19:33:24 UTC (rev 255085)
@@ -1,3 +1,19 @@
+2020-01-24  youenn fablet  <[email protected]>
+
+        Add support for MediaRecorder.requestData
+        https://bugs.webkit.org/show_bug.cgi?id=206731
+
+        Reviewed by Eric Carlson.
+
+        Add support for requestData that fetches any available data.
+        Expose MediaRecorder stream.
+        Covered by updated tests.
+
+        * Modules/mediarecorder/MediaRecorder.cpp:
+        (WebCore::MediaRecorder::requestData):
+        * Modules/mediarecorder/MediaRecorder.h:
+        * Modules/mediarecorder/MediaRecorder.idl:
+
 2020-01-24  Jack Lee  <[email protected]>
 
         Nullptr deref in WebCore::RenderTreeBuilder::Block::attachIgnoringContinuation when an element is inserted before legend under multi-column layout.

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp (255084 => 255085)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-01-24 19:33:24 UTC (rev 255085)
@@ -170,6 +170,20 @@
     return { };
 }
 
+ExceptionOr<void> MediaRecorder::requestData()
+{
+    if (state() == RecordingState::Inactive)
+        return Exception { InvalidStateError, "The MediaRecorder's state cannot be inactive"_s };
+
+    m_private->fetchData([this, protectedThis = makeRef(*this)](auto&& buffer, auto& mimeType) {
+        if (!m_isActive)
+            return;
+
+        dispatchEvent(BlobEvent::create(eventNames().dataavailableEvent, Event::CanBubble::No, Event::IsCancelable::No, buffer ? Blob::create(buffer.releaseNonNull(), mimeType) : Blob::create()));
+    });
+    return { };
+}
+
 void MediaRecorder::stopRecordingInternal()
 {
     if (state() != RecordingState::Recording)

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h (255084 => 255085)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-01-24 19:33:24 UTC (rev 255085)
@@ -71,7 +71,10 @@
     
     ExceptionOr<void> startRecording(Optional<int>);
     ExceptionOr<void> stopRecording();
+    ExceptionOr<void> requestData();
 
+    MediaStream& stream() { return m_stream.get(); }
+
 private:
     MediaRecorder(Document&, Ref<MediaStream>&&, std::unique_ptr<MediaRecorderPrivate>&&, Options&& = { });
 

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl (255084 => 255085)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2020-01-24 19:30:58 UTC (rev 255084)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2020-01-24 19:33:24 UTC (rev 255085)
@@ -34,8 +34,8 @@
     Exposed=Window
 ] interface MediaRecorder : EventTarget {
     readonly attribute RecordingState state;
+    readonly attribute MediaStream stream;
     // FIXME: Implement these:
-    // readonly attribute MediaStream stream;
     // readonly attribute DOMString mimeType;
     // attribute EventHandler onstart;
     attribute EventHandler onstop;
@@ -50,7 +50,7 @@
     [ImplementedAs=stopRecording] void stop();
     // void pause();
     // void resume();
-    // void requestData();
+    void requestData();
 
     // static boolean isTypeSupported(DOMString type);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to