Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 6de874e

Browse files
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: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@255085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 0511aa3 commit 6de874e

File tree

8 files changed

+76
-10
lines changed

8 files changed

+76
-10
lines changed

LayoutTests/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2020-01-24 youenn fablet <[email protected]>
2+
3+
Add support for MediaRecorder.requestData
4+
https://bugs.webkit.org/show_bug.cgi?id=206731
5+
6+
Reviewed by Eric Carlson.
7+
8+
* http/wpt/mediarecorder/MediaRecorder-dataavailable.html:
9+
110
2020-01-24 Jack Lee <[email protected]>
211

312
Nullptr deref in WebCore::RenderTreeBuilder::Block::attachIgnoringContinuation when an element is inserted before legend under multi-column layout.

LayoutTests/http/wpt/mediarecorder/MediaRecorder-dataavailable.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,32 @@
3737
async_test(t => {
3838
const video = createVideoStream();
3939
const recorder = new MediaRecorder(video);
40+
let state = 0;
41+
42+
assert_equals(recorder.stream, video);
4043

4144
recorder.ondataavailable = t.step_func(blobEvent => {
45+
if (!state) {
46+
assert_true(blobEvent instanceof BlobEvent, 'the type of event should be BlobEvent');
47+
assert_equals(blobEvent.type, 'dataavailable', 'the event type should be dataavailable');
48+
assert_true(blobEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
49+
assert_true(blobEvent.data instanceof Blob, 'the type of data should be Blob');
50+
51+
state = 1;
52+
setTimeout(() => {
53+
// Stopping the recorder will trigger another dataavailable event.
54+
recorder.stop();
55+
}, 1000);
56+
return;
57+
}
4258
dataAvailableAssertions(blobEvent);
4359
t.done();
4460
});
4561
recorder.start();
4662
assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
4763
drawSomethingOnCanvas();
48-
setTimeout(() => {
49-
recorder.stop();
50-
}, 1000)
64+
65+
recorder.requestData();
5166
}, 'MediaRecorder will fire a dataavailable event with a blob data for a video-only stream when stop() is called');
5267

5368
async_test(t => {
@@ -101,4 +116,4 @@
101116

102117
</script>
103118
</body>
104-
</html>
119+
</html>

LayoutTests/imported/w3c/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2020-01-24 Youenn Fablet <[email protected]>
2+
3+
Add support for MediaRecorder.requestData
4+
https://bugs.webkit.org/show_bug.cgi?id=206731
5+
6+
Reviewed by Eric Carlson.
7+
8+
* web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
9+
110
2020-01-23 Antoine Quint <[email protected]>
211

312
[Web Animations] Support multiple CSS Animations with the same name in animation-name

LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/idlharness.window-expected.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PASS MediaRecorder interface object name
77
PASS MediaRecorder interface: existence and properties of interface prototype object
88
PASS MediaRecorder interface: existence and properties of interface prototype object's "constructor" property
99
PASS MediaRecorder interface: existence and properties of interface prototype object's @@unscopables property
10-
FAIL MediaRecorder interface: attribute stream assert_true: The prototype object must have a property "stream" expected true got false
10+
PASS MediaRecorder interface: attribute stream
1111
FAIL MediaRecorder interface: attribute mimeType assert_true: The prototype object must have a property "mimeType" expected true got false
1212
PASS MediaRecorder interface: attribute state
1313
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 start(unsigned long)
2222
PASS MediaRecorder interface: operation stop()
2323
FAIL MediaRecorder interface: operation pause() assert_own_property: interface prototype object missing non-static operation expected property "pause" missing
2424
FAIL MediaRecorder interface: operation resume() assert_own_property: interface prototype object missing non-static operation expected property "resume" missing
25-
FAIL MediaRecorder interface: operation requestData() assert_own_property: interface prototype object missing non-static operation expected property "requestData" missing
25+
PASS MediaRecorder interface: operation requestData()
2626
FAIL MediaRecorder interface: operation isTypeSupported(DOMString) assert_own_property: interface object missing static operation expected property "isTypeSupported" missing
2727
PASS MediaRecorder must be primary interface of [object MediaRecorder]
2828
PASS Stringification of [object MediaRecorder]
29-
FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "stream" with the proper type assert_inherits: property "stream" not found in prototype chain
29+
PASS MediaRecorder interface: [object MediaRecorder] must inherit property "stream" with the proper type
3030
FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "mimeType" with the proper type assert_inherits: property "mimeType" not found in prototype chain
3131
PASS MediaRecorder interface: [object MediaRecorder] must inherit property "state" with the proper type
3232
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: calling start(unsigned long) on [object MediaRecor
4242
PASS MediaRecorder interface: [object MediaRecorder] must inherit property "stop()" with the proper type
4343
FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "pause()" with the proper type assert_inherits: property "pause" not found in prototype chain
4444
FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "resume()" with the proper type assert_inherits: property "resume" not found in prototype chain
45-
FAIL MediaRecorder interface: [object MediaRecorder] must inherit property "requestData()" with the proper type assert_inherits: property "requestData" not found in prototype chain
45+
PASS MediaRecorder interface: [object MediaRecorder] must inherit property "requestData()" with the proper type
4646
PASS MediaRecorder interface: [object MediaRecorder] must inherit property "isTypeSupported(DOMString)" with the proper type
4747
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
4848
PASS BlobEvent interface: existence and properties of interface object

Source/WebCore/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2020-01-24 youenn fablet <[email protected]>
2+
3+
Add support for MediaRecorder.requestData
4+
https://bugs.webkit.org/show_bug.cgi?id=206731
5+
6+
Reviewed by Eric Carlson.
7+
8+
Add support for requestData that fetches any available data.
9+
Expose MediaRecorder stream.
10+
Covered by updated tests.
11+
12+
* Modules/mediarecorder/MediaRecorder.cpp:
13+
(WebCore::MediaRecorder::requestData):
14+
* Modules/mediarecorder/MediaRecorder.h:
15+
* Modules/mediarecorder/MediaRecorder.idl:
16+
117
2020-01-24 Jack Lee <[email protected]>
218

319
Nullptr deref in WebCore::RenderTreeBuilder::Block::attachIgnoringContinuation when an element is inserted before legend under multi-column layout.

Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ ExceptionOr<void> MediaRecorder::stopRecording()
170170
return { };
171171
}
172172

173+
ExceptionOr<void> MediaRecorder::requestData()
174+
{
175+
if (state() == RecordingState::Inactive)
176+
return Exception { InvalidStateError, "The MediaRecorder's state cannot be inactive"_s };
177+
178+
m_private->fetchData([this, protectedThis = makeRef(*this)](auto&& buffer, auto& mimeType) {
179+
if (!m_isActive)
180+
return;
181+
182+
dispatchEvent(BlobEvent::create(eventNames().dataavailableEvent, Event::CanBubble::No, Event::IsCancelable::No, buffer ? Blob::create(buffer.releaseNonNull(), mimeType) : Blob::create()));
183+
});
184+
return { };
185+
}
186+
173187
void MediaRecorder::stopRecordingInternal()
174188
{
175189
if (state() != RecordingState::Recording)

Source/WebCore/Modules/mediarecorder/MediaRecorder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class MediaRecorder final
7171

7272
ExceptionOr<void> startRecording(Optional<int>);
7373
ExceptionOr<void> stopRecording();
74+
ExceptionOr<void> requestData();
75+
76+
MediaStream& stream() { return m_stream.get(); }
7477

7578
private:
7679
MediaRecorder(Document&, Ref<MediaStream>&&, std::unique_ptr<MediaRecorderPrivate>&&, Options&& = { });

Source/WebCore/Modules/mediarecorder/MediaRecorder.idl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ enum RecordingState { "inactive", "recording", "paused" };
3434
Exposed=Window
3535
] interface MediaRecorder : EventTarget {
3636
readonly attribute RecordingState state;
37+
readonly attribute MediaStream stream;
3738
// FIXME: Implement these:
38-
// readonly attribute MediaStream stream;
3939
// readonly attribute DOMString mimeType;
4040
// attribute EventHandler onstart;
4141
attribute EventHandler onstop;
@@ -50,7 +50,7 @@ enum RecordingState { "inactive", "recording", "paused" };
5050
[ImplementedAs=stopRecording] void stop();
5151
// void pause();
5252
// void resume();
53-
// void requestData();
53+
void requestData();
5454

5555
// static boolean isTypeSupported(DOMString type);
5656
};

0 commit comments

Comments
 (0)