Title: [263892] trunk
Revision
263892
Author
[email protected]
Date
2020-07-03 05:58:24 -0700 (Fri, 03 Jul 2020)

Log Message

MediaRecorder.start() Method is Ignoring the "timeslice" Parameter
https://bugs.webkit.org/show_bug.cgi?id=202233
<rdar://problem/55720555>

Reviewed by Eric Carlson.

Source/WebCore:

Use a timer to implement timeSlice parameter.
Schedule timer either when start is called or as part of requestData callback.
This should ensure that, if requestData is called by the application, the timer will be rescheduled appropriately.

Test: http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html

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

LayoutTests:

* http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt: Added.
* http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (263891 => 263892)


--- trunk/LayoutTests/ChangeLog	2020-07-03 12:01:41 UTC (rev 263891)
+++ trunk/LayoutTests/ChangeLog	2020-07-03 12:58:24 UTC (rev 263892)
@@ -1,5 +1,16 @@
 2020-07-03  Youenn Fablet  <[email protected]>
 
+        MediaRecorder.start() Method is Ignoring the "timeslice" Parameter
+        https://bugs.webkit.org/show_bug.cgi?id=202233
+        <rdar://problem/55720555>
+
+        Reviewed by Eric Carlson.
+
+        * http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt: Added.
+        * http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html: Added.
+
+2020-07-03  Youenn Fablet  <[email protected]>
+
         MediaRecorder stopRecorder() returns empty Blob after first use
         https://bugs.webkit.org/show_bug.cgi?id=212274
         <rdar://problem/63601298>

Added: trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt (0 => 263892)


--- trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt	2020-07-03 12:58:24 UTC (rev 263892)
@@ -0,0 +1,3 @@
+
+PASS Make sure that MediaRecorder timeSlice triggers regular ondataavailable events 
+

Added: trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html (0 => 263892)


--- trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html	2020-07-03 12:58:24 UTC (rev 263892)
@@ -0,0 +1,28 @@
+<!doctype html>
+<html>
+<head>
+    <title>MediaRecorder start timeSlice option</title>
+    <link rel="help" href=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<canvas id="canvas" width="200" height="200">
+</canvas>
+<script>
+    promise_test(async t => {
+        const video = await navigator.mediaDevices.getUserMedia({ audio : true, video : true });
+        const recorder = new MediaRecorder(video);
+
+        assert_equals(recorder.stream, video);
+
+        let promise = new Promise(resolve => recorder._ondataavailable_ = resolve);
+        recorder.start(100);
+        await promise;
+
+        promise = new Promise(resolve => recorder._ondataavailable_ = resolve);
+        await promise;
+    }, 'Make sure that MediaRecorder timeSlice triggers regular ondataavailable events');
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (263891 => 263892)


--- trunk/Source/WebCore/ChangeLog	2020-07-03 12:01:41 UTC (rev 263891)
+++ trunk/Source/WebCore/ChangeLog	2020-07-03 12:58:24 UTC (rev 263892)
@@ -1,5 +1,25 @@
 2020-07-03  Youenn Fablet  <[email protected]>
 
+        MediaRecorder.start() Method is Ignoring the "timeslice" Parameter
+        https://bugs.webkit.org/show_bug.cgi?id=202233
+        <rdar://problem/55720555>
+
+        Reviewed by Eric Carlson.
+
+        Use a timer to implement timeSlice parameter.
+        Schedule timer either when start is called or as part of requestData callback.
+        This should ensure that, if requestData is called by the application, the timer will be rescheduled appropriately.
+
+        Test: http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html
+
+        * Modules/mediarecorder/MediaRecorder.cpp:
+        (WebCore::MediaRecorder::MediaRecorder):
+        (WebCore::MediaRecorder::startRecording):
+        (WebCore::MediaRecorder::requestData):
+        * Modules/mediarecorder/MediaRecorder.h:
+
+2020-07-03  Youenn Fablet  <[email protected]>
+
         MediaRecorder stopRecorder() returns empty Blob after first use
         https://bugs.webkit.org/show_bug.cgi?id=212274
         <rdar://problem/63601298>

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp (263891 => 263892)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-07-03 12:01:41 UTC (rev 263891)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-07-03 12:58:24 UTC (rev 263892)
@@ -83,6 +83,7 @@
     : ActiveDOMObject(document)
     , m_options(WTFMove(option))
     , m_stream(WTFMove(stream))
+    , m_timeSliceTimer([this] { requestData(); })
 {
     m_tracks = WTF::map(m_stream->getTracks(), [] (auto&& track) -> Ref<MediaStreamTrackPrivate> {
         return track->privateTrack();
@@ -125,9 +126,8 @@
     return "MediaRecorder";
 }
 
-ExceptionOr<void> MediaRecorder::startRecording(Optional<int> timeslice)
+ExceptionOr<void> MediaRecorder::startRecording(Optional<int> timeSlice)
 {
-    UNUSED_PARAM(timeslice);
     if (!m_isActive)
         return Exception { InvalidStateError, "The MediaRecorder is not active"_s };
 
@@ -152,6 +152,9 @@
         track->addObserver(*this);
 
     m_state = RecordingState::Recording;
+    m_timeSlice = timeSlice;
+    if (m_timeSlice)
+        m_timeSliceTimer.startOneShot(Seconds::fromMilliseconds(*m_timeSlice));
     return { };
 }
 
@@ -181,6 +184,8 @@
     if (state() == RecordingState::Inactive)
         return Exception { InvalidStateError, "The MediaRecorder's state cannot be inactive"_s };
 
+    if (m_timeSliceTimer.isActive())
+        m_timeSliceTimer.stop();
     m_private->fetchData([this, pendingActivity = makePendingActivity(*this)](auto&& buffer, auto& mimeType) {
         queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, buffer = WTFMove(buffer), mimeType]() mutable {
             if (!m_isActive)
@@ -187,6 +192,9 @@
                 return;
 
             dispatchEvent(BlobEvent::create(eventNames().dataavailableEvent, Event::CanBubble::No, Event::IsCancelable::No, buffer ? Blob::create(buffer.releaseNonNull(), mimeType) : Blob::create()));
+
+            if (m_timeSlice)
+                m_timeSliceTimer.startOneShot(Seconds::fromMilliseconds(*m_timeSlice));
         });
     });
     return { };

Modified: trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h (263891 => 263892)


--- trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-07-03 12:01:41 UTC (rev 263891)
+++ trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-07-03 12:58:24 UTC (rev 263892)
@@ -30,6 +30,7 @@
 #include "EventTarget.h"
 #include "MediaStream.h"
 #include "MediaStreamTrackPrivate.h"
+#include "Timer.h"
 #include <wtf/UniqueRef.h>
 
 namespace WebCore {
@@ -116,6 +117,8 @@
     std::unique_ptr<MediaRecorderPrivate> m_private;
     RecordingState m_state { RecordingState::Inactive };
     Vector<Ref<MediaStreamTrackPrivate>> m_tracks;
+    Optional<int> m_timeSlice;
+    Timer m_timeSliceTimer;
     
     bool m_isActive { true };
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to