Changeset 263671 in webkit


Ignore:
Timestamp:
Jun 29, 2020 11:32:10 AM (4 years ago)
Author:
youenn@apple.com
Message:

Support MediaRecorder.onstart
https://bugs.webkit.org/show_bug.cgi?id=213720

Reviewed by Darin Adler.

Source/WebCore:

Fire start event if MediaRecorder.start is successful.
Do some WebIDL clean-up, in particular change timeSlice from long to unsigned long, as per spec.
Covered by added test.

  • Modules/mediarecorder/MediaRecorder.cpp:

(WebCore::MediaRecorder::startRecording):

  • Modules/mediarecorder/MediaRecorder.h:
  • Modules/mediarecorder/MediaRecorder.idl:

LayoutTests:

  • http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt:
  • http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r263669 r263671  
     12020-06-29  Youenn Fablet  <youenn@apple.com>
     2
     3        Support MediaRecorder.onstart
     4        https://bugs.webkit.org/show_bug.cgi?id=213720
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt:
     9        * http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html:
     10
    1112020-06-29  Karl Rackler  <rackler@apple.com>
    212
  • trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-expected.txt

    r263651 r263671  
    11
    22PASS Make sure that MediaRecorder timeSlice triggers regular ondataavailable events
     3PASS Make sure that MediaRecorder fires onstart on successful start call
    34
  • trunk/LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice.html

    r263651 r263671  
    2424        await promise;
    2525    }, 'Make sure that MediaRecorder timeSlice triggers regular ondataavailable events');
     26
     27    promise_test(async t => {
     28        const video = await navigator.mediaDevices.getUserMedia({ audio : true, video : true });
     29        const recorder = new MediaRecorder(video);
     30
     31        let promise = new Promise(resolve => recorder.onstart = resolve);
     32        // We cover the case of invalid ignored timeSlice value by passing -1 here.
     33        recorder.start(-1);
     34
     35        return promise;
     36    }, 'Make sure that MediaRecorder fires onstart on successful start call');
    2637</script>
    2738</body>
  • trunk/Source/WebCore/ChangeLog

    r263662 r263671  
     12020-06-29  Youenn Fablet  <youenn@apple.com>
     2
     3        Support MediaRecorder.onstart
     4        https://bugs.webkit.org/show_bug.cgi?id=213720
     5
     6        Reviewed by Darin Adler.
     7
     8        Fire start event if MediaRecorder.start is successful.
     9        Do some WebIDL clean-up, in particular change timeSlice from long to unsigned long, as per spec.
     10        Covered by added test.
     11
     12        * Modules/mediarecorder/MediaRecorder.cpp:
     13        (WebCore::MediaRecorder::startRecording):
     14        * Modules/mediarecorder/MediaRecorder.h:
     15        * Modules/mediarecorder/MediaRecorder.idl:
     16
    1172020-06-29  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp

    r263651 r263671  
    127127}
    128128
    129 ExceptionOr<void> MediaRecorder::startRecording(Optional<int> timeSlice)
     129ExceptionOr<void> MediaRecorder::startRecording(Optional<unsigned> timeSlice)
    130130{
    131131    if (!m_isActive)
     
    142142
    143143    m_private->startRecording([this, pendingActivity = makePendingActivity(*this)](auto&& exception) mutable {
    144         if (!m_isActive || !exception)
     144        if (!m_isActive)
    145145            return;
    146146
    147         stopRecordingInternal();
    148         dispatchError(WTFMove(*exception));
     147        if (exception) {
     148            stopRecordingInternal();
     149            dispatchError(WTFMove(*exception));
     150            return;
     151        }
     152
     153        dispatchEvent(Event::create(eventNames().startEvent, Event::CanBubble::No, Event::IsCancelable::No));
    149154    });
    150155
  • trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.h

    r263651 r263671  
    7070    using RefCounted::deref;
    7171   
    72     ExceptionOr<void> startRecording(Optional<int>);
     72    ExceptionOr<void> startRecording(Optional<unsigned>);
    7373    ExceptionOr<void> stopRecording();
    7474    ExceptionOr<void> requestData();
     
    118118    RecordingState m_state { RecordingState::Inactive };
    119119    Vector<Ref<MediaStreamTrackPrivate>> m_tracks;
    120     Optional<int> m_timeSlice;
     120    Optional<unsigned> m_timeSlice;
    121121    Timer m_timeSliceTimer;
    122122   
  • trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl

    r263160 r263671  
    3333    [CallWith=Document, MayThrowException] constructor(MediaStream stream, optional MediaRecorderOptions options);
    3434
     35    // FIXME: Implement commented out methods/attributes.
     36
     37    readonly attribute MediaStream stream;
     38    // readonly attribute DOMString mimeType;
    3539    readonly attribute RecordingState state;
    36     readonly attribute MediaStream stream;
    37     // FIXME: Implement these:
    38     // readonly attribute DOMString mimeType;
    39     // attribute EventHandler onstart;
     40    attribute EventHandler onstart;
    4041    attribute EventHandler onstop;
    4142    attribute EventHandler ondataavailable;
     
    4546    // readonly attribute unsigned long videoBitsPerSecond;
    4647    // readonly attribute unsigned long audioBitsPerSecond;
     48    // readonly attribute BitrateMode audioBitrateMode;
    4749
    48     [MayThrowException, ImplementedAs=startRecording] void start(optional long timeslice);
     50    [MayThrowException, ImplementedAs=startRecording] void start(optional unsigned long timeslice);
    4951    [ImplementedAs=stopRecording] void stop();
    5052    // void pause();
Note: See TracChangeset for help on using the changeset viewer.