Title: [268092] branches/safari-610-branch
Revision
268092
Author
[email protected]
Date
2020-10-06 17:09:24 -0700 (Tue, 06 Oct 2020)

Log Message

Cherry-pick r267825. rdar://problem/70024248

    MediaRecorder should support isTypeSupported
    https://bugs.webkit.org/show_bug.cgi?id=216856
    LayoutTests/imported/w3c:

    Reviewed by Darin Adler.

    * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt:
    * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt:
    * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt:
    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html:
    Remove JS console log error line.

    Source/WebCore:

    <rdar://problem/69767695>

    Reviewed by Darin Adler.

    Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported.
    Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs.
    Add a routine to get the mime type from the MediaRecorderPrivate.
    Store it in MediaRecorder and add a mimeType getter.

    Test: http/wpt/mediarecorder/mimeType.html

    * Modules/mediarecorder/MediaRecorder.cpp:
    (WebCore::MediaRecorder::isTypeSupported):
    (WebCore::MediaRecorder::create):
    * Modules/mediarecorder/MediaRecorder.h:
    * Modules/mediarecorder/MediaRecorder.idl:
    * Modules/mediarecorder/MediaRecorderProvider.cpp:
    (WebCore::MediaRecorderProvider::isSupported):
    * Modules/mediarecorder/MediaRecorderProvider.h:
    * platform/mediarecorder/MediaRecorderPrivate.h:
    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
    (WebCore::MediaRecorderPrivateAVFImpl::mimeType const):
    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
    * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
    (WebCore::MediaRecorderPrivateMock::mimeType const):
    * platform/mediarecorder/MediaRecorderPrivateMock.h:
    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
    (WebCore::MediaRecorderPrivateWriter::mimeType const):
    * platform/mediastream/MediaStreamPrivate.h:

    Source/WebKit:

    <rdar://problem/69767695>

    Reviewed by Darin Adler.

    Stop passing mimeType for each data blob.
    Instead, compute it on WebProcess side.

    * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
    (WebKit::RemoteMediaRecorder::fetchData):
    * GPUProcess/webrtc/RemoteMediaRecorder.h:
    * GPUProcess/webrtc/RemoteMediaRecorder.messages.in:
    * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
    (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
    (WebKit::MediaRecorderPrivate::fetchData):
    (WebKit::MediaRecorderPrivate::mimeType const):
    * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:

    LayoutTests:

    Reviewed by Darin Adler.

    * http/wpt/mediarecorder/mimeType-expected.txt: Added.
    * http/wpt/mediarecorder/mimeType.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267825 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-610-branch/LayoutTests/ChangeLog (268091 => 268092)


--- branches/safari-610-branch/LayoutTests/ChangeLog	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/LayoutTests/ChangeLog	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,5 +1,93 @@
 2020-10-06  Alan Coon  <[email protected]>
 
+        Cherry-pick r267825. rdar://problem/70024248
+
+    MediaRecorder should support isTypeSupported
+    https://bugs.webkit.org/show_bug.cgi?id=216856
+    LayoutTests/imported/w3c:
+    
+    Reviewed by Darin Adler.
+    
+    * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt:
+    * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt:
+    * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html:
+    Remove JS console log error line.
+    
+    Source/WebCore:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported.
+    Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs.
+    Add a routine to get the mime type from the MediaRecorderPrivate.
+    Store it in MediaRecorder and add a mimeType getter.
+    
+    Test: http/wpt/mediarecorder/mimeType.html
+    
+    * Modules/mediarecorder/MediaRecorder.cpp:
+    (WebCore::MediaRecorder::isTypeSupported):
+    (WebCore::MediaRecorder::create):
+    * Modules/mediarecorder/MediaRecorder.h:
+    * Modules/mediarecorder/MediaRecorder.idl:
+    * Modules/mediarecorder/MediaRecorderProvider.cpp:
+    (WebCore::MediaRecorderProvider::isSupported):
+    * Modules/mediarecorder/MediaRecorderProvider.h:
+    * platform/mediarecorder/MediaRecorderPrivate.h:
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+    (WebCore::MediaRecorderPrivateAVFImpl::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
+    * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
+    (WebCore::MediaRecorderPrivateMock::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateMock.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+    (WebCore::MediaRecorderPrivateWriter::mimeType const):
+    * platform/mediastream/MediaStreamPrivate.h:
+    
+    Source/WebKit:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Stop passing mimeType for each data blob.
+    Instead, compute it on WebProcess side.
+    
+    * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+    (WebKit::RemoteMediaRecorder::fetchData):
+    * GPUProcess/webrtc/RemoteMediaRecorder.h:
+    * GPUProcess/webrtc/RemoteMediaRecorder.messages.in:
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
+    (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
+    (WebKit::MediaRecorderPrivate::fetchData):
+    (WebKit::MediaRecorderPrivate::mimeType const):
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:
+    
+    LayoutTests:
+    
+    Reviewed by Darin Adler.
+    
+    * http/wpt/mediarecorder/mimeType-expected.txt: Added.
+    * http/wpt/mediarecorder/mimeType.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-10-01  Youenn Fablet  <[email protected]>
+
+            MediaRecorder should support isTypeSupported
+            https://bugs.webkit.org/show_bug.cgi?id=216856
+
+            Reviewed by Darin Adler.
+
+            * http/wpt/mediarecorder/mimeType-expected.txt: Added.
+            * http/wpt/mediarecorder/mimeType.html: Added.
+
+2020-10-06  Alan Coon  <[email protected]>
+
         Cherry-pick r267366. rdar://problem/70023908
 
     [iOS] MediaRecorder incorrect screen orientation handling

Added: branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/mimeType-expected.txt (0 => 268092)


--- branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/mimeType-expected.txt	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/mimeType-expected.txt	2020-10-07 00:09:24 UTC (rev 268092)
@@ -0,0 +1,12 @@
+
+PASS MediaRecorder.isTypeSupported - 'auDio/mp4'
+PASS MediaRecorder.isTypeSupported - 'video/mp4'
+PASS MediaRecorder.isTypeSupported - 'audio/MP4;codecs=" avc1.4d002a   ,mp4a.40.1"'
+PASS MediaRecorder.isTypeSupported - 'video/mp4;codecs="AVC1.4d002a,   mp4a.40.1"'
+PASS MediaRecorder.isTypeSupported - 'video/mp4;codecs="mP4a.40.1"'
+PASS MediaRecorder.isTypeSupported - 'audio/mp4;codecs="avc1.4d002a, opus"'
+PASS MediaRecorder.isTypeSupported - 'audio/mp4;codecs="opus"'
+PASS MediaRecorder.isTypeSupported - 'audio/webm'
+PASS MediaRecorder.isTypeSupported - 'video/webm'
+PASS MediaRecorder mimeType
+

Added: branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/mimeType.html (0 => 268092)


--- branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/mimeType.html	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/mimeType.html	2020-10-07 00:09:24 UTC (rev 268092)
@@ -0,0 +1,43 @@
+<!doctype html>
+<html>
+<head>
+    <title>MediaRecorder mimeType handling</title
+    <link rel="help" href=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script>
+const mimeTypeTests = [
+    ['auDio/mp4', true],
+    ['video/mp4', true],
+    ['audio/MP4;codecs=" avc1.4d002a   ,mp4a.40.1"', true],
+    ['video/mp4;codecs="AVC1.4d002a,   mp4a.40.1"', true],
+    ['video/mp4;codecs="mP4a.40.1"', true],
+    ['audio/mp4;codecs="avc1.4d002a, opus"', false],
+    ['audio/mp4;codecs="opus"', false],
+    ['audio/webm', false],
+    ['video/webm', false],
+];
+
+mimeTypeTests.forEach(mimeTypeTest => {
+    test(() => {
+        assert_equals(MediaRecorder.isTypeSupported(mimeTypeTest[0]), mimeTypeTest[1]);
+    }, "MediaRecorder.isTypeSupported - '" + mimeTypeTest[0] + "'");
+});
+
+promise_test(async () => {
+    const mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
+
+    let recorder = new MediaRecorder(mediaStream);
+    assert_equals(recorder.mimeType, "video/mp4");
+
+    recorder = new MediaRecorder(new MediaStream([mediaStream.getVideoTracks()[0]]));
+    assert_equals(recorder.mimeType, "video/mp4");
+
+    recorder = new MediaRecorder(new MediaStream([mediaStream.getAudioTracks()[0]]));
+    assert_equals(recorder.mimeType, "audio/mp4");
+}, "MediaRecorder mimeType");
+</script>
+</body>
+</html>

Modified: branches/safari-610-branch/LayoutTests/imported/w3c/ChangeLog (268091 => 268092)


--- branches/safari-610-branch/LayoutTests/imported/w3c/ChangeLog	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/LayoutTests/imported/w3c/ChangeLog	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,3 +1,95 @@
+2020-10-06  Alan Coon  <[email protected]>
+
+        Cherry-pick r267825. rdar://problem/70024248
+
+    MediaRecorder should support isTypeSupported
+    https://bugs.webkit.org/show_bug.cgi?id=216856
+    LayoutTests/imported/w3c:
+    
+    Reviewed by Darin Adler.
+    
+    * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt:
+    * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt:
+    * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html:
+    Remove JS console log error line.
+    
+    Source/WebCore:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported.
+    Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs.
+    Add a routine to get the mime type from the MediaRecorderPrivate.
+    Store it in MediaRecorder and add a mimeType getter.
+    
+    Test: http/wpt/mediarecorder/mimeType.html
+    
+    * Modules/mediarecorder/MediaRecorder.cpp:
+    (WebCore::MediaRecorder::isTypeSupported):
+    (WebCore::MediaRecorder::create):
+    * Modules/mediarecorder/MediaRecorder.h:
+    * Modules/mediarecorder/MediaRecorder.idl:
+    * Modules/mediarecorder/MediaRecorderProvider.cpp:
+    (WebCore::MediaRecorderProvider::isSupported):
+    * Modules/mediarecorder/MediaRecorderProvider.h:
+    * platform/mediarecorder/MediaRecorderPrivate.h:
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+    (WebCore::MediaRecorderPrivateAVFImpl::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
+    * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
+    (WebCore::MediaRecorderPrivateMock::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateMock.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+    (WebCore::MediaRecorderPrivateWriter::mimeType const):
+    * platform/mediastream/MediaStreamPrivate.h:
+    
+    Source/WebKit:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Stop passing mimeType for each data blob.
+    Instead, compute it on WebProcess side.
+    
+    * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+    (WebKit::RemoteMediaRecorder::fetchData):
+    * GPUProcess/webrtc/RemoteMediaRecorder.h:
+    * GPUProcess/webrtc/RemoteMediaRecorder.messages.in:
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
+    (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
+    (WebKit::MediaRecorderPrivate::fetchData):
+    (WebKit::MediaRecorderPrivate::mimeType const):
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:
+    
+    LayoutTests:
+    
+    Reviewed by Darin Adler.
+    
+    * http/wpt/mediarecorder/mimeType-expected.txt: Added.
+    * http/wpt/mediarecorder/mimeType.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-10-01  Youenn Fablet  <[email protected]>
+
+            MediaRecorder should support isTypeSupported
+            https://bugs.webkit.org/show_bug.cgi?id=216856
+
+            Reviewed by Darin Adler.
+
+            * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt:
+            * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt:
+            * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
+            * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt:
+            * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html:
+            Remove JS console log error line.
+
 2020-09-16  Ryan Haddad  <[email protected]>
 
         Cherry-pick r266098. rdar://problem/67703327

Modified: branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt (268091 => 268092)


--- branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,12 +1,38 @@
-CONSOLE MESSAGE: TypeError: MediaRecorder.isTypeSupported is not a function. (In 'MediaRecorder.isTypeSupported(mimeType)', 'MediaRecorder.isTypeSupported' is undefined)
 
-Harness Error (FAIL), message = TypeError: MediaRecorder.isTypeSupported is not a function. (In 'MediaRecorder.isTypeSupported(mimeType)', 'MediaRecorder.isTypeSupported' is undefined)
+FAIL MediaRecorder sets no default mimeType in the constructor for audio assert_equals: MediaRecorder has no default mimeType expected "" but got "audio/mp4"
+FAIL MediaRecorder sets no default mimeType in the constructor for video assert_equals: MediaRecorder has no default mimeType expected "" but got "video/mp4"
+FAIL MediaRecorder sets no default mimeType in the constructor for audio/video assert_equals: MediaRecorder has no default mimeType expected "" but got "video/mp4"
+PASS MediaRecorder invalid audio mimeType throws
+PASS MediaRecorder invalid audio mimeType is unsupported
+PASS MediaRecorder invalid video mimeType throws
+PASS MediaRecorder invalid video mimeType is unsupported
+PASS Supported mimeType audio/mp4 is set immediately after constructing
+FAIL Supported mimeType video/mp4 is set immediately after constructing assert_equals: Supported mimeType is set expected "video/mp4" but got "audio/mp4"
+PASS Unsupported mimeType audio/ogg throws
+PASS Unsupported mimeType audio/ogg; codecs="vorbis" throws
+PASS Unsupported mimeType audio/ogg; codecs="opus" throws
+PASS Unsupported mimeType audio/webm throws
+PASS Unsupported mimeType audio/webm; codecs="vorbis" throws
+PASS Unsupported mimeType audio/webm; codecs="opus" throws
+PASS Unsupported mimeType video/webm throws
+PASS Unsupported mimeType video/webm; codecs="vp8" throws
+PASS Unsupported mimeType video/webm; codecs="vp8, vorbis" throws
+PASS Unsupported mimeType video/webm; codecs="vp8, opus" throws
+PASS Unsupported mimeType video/webm; codecs="vp9" throws
+PASS Unsupported mimeType video/webm; codecs="vp9, vorbis" throws
+PASS Unsupported mimeType video/webm; codecs="vp9, opus" throws
+PASS Unsupported mimeType video/webm; codecs="av1" throws
+PASS Unsupported mimeType video/webm; codecs="av1, opus" throws
+PASS MediaRecorder sets a nonempty mimeType on 'onstart' for audio
+PASS MediaRecorder sets a nonempty mimeType on 'onstart' for video
+PASS MediaRecorder sets a nonempty mimeType on 'onstart' for audio/video
+FAIL MediaRecorder mimeType is not set before 'onstart' for audio assert_equals: expected "" but got "audio/mp4"
+FAIL MediaRecorder mimeType is not set before 'onstart' for video assert_equals: expected "" but got "video/mp4"
+FAIL MediaRecorder mimeType is not set before 'onstart' for audio/video assert_equals: expected "" but got "video/mp4"
+PASS MediaRecorder doesn't fire 'onstart' multiple times for audio
+PASS MediaRecorder doesn't fire 'onstart' multiple times for video
+PASS MediaRecorder doesn't fire 'onstart' multiple times for audio/video
+FAIL MediaRecorder formats mimeType well after 'start' for audio assert_regexp_match: mimeType has one codec a expected object "/^[a-z]+\/[a-z]+;[ ]*codecs=[^,]+$/" but got "audio/mp4"
+FAIL MediaRecorder formats mimeType well after 'start' for video assert_regexp_match: mimeType has one codec a expected object "/^[a-z]+\/[a-z]+;[ ]*codecs=[^,]+$/" but got "video/mp4"
+FAIL MediaRecorder formats mimeType well after 'start' for audio/video assert_regexp_match: mimeType has two codecs expected object "/^[a-z]+\/[a-z]+;[ ]*codecs=[^,]+,[^,]+$/" but got "video/mp4"
 
-FAIL MediaRecorder sets no default mimeType in the constructor for audio assert_equals: MediaRecorder has no default mimeType expected (string) "" but got (undefined) undefined
-FAIL MediaRecorder sets no default mimeType in the constructor for video assert_equals: MediaRecorder has no default mimeType expected (string) "" but got (undefined) undefined
-FAIL MediaRecorder sets no default mimeType in the constructor for audio/video assert_equals: MediaRecorder has no default mimeType expected (string) "" but got (undefined) undefined
-FAIL MediaRecorder invalid audio mimeType throws assert_throws_dom: function "() => new MediaRecorder(new MediaStream(), {mimeType: "audio/banana"})" did not throw
-FAIL MediaRecorder invalid audio mimeType is unsupported MediaRecorder.isTypeSupported is not a function. (In 'MediaRecorder.isTypeSupported("audio/banana")', 'MediaRecorder.isTypeSupported' is undefined)
-FAIL MediaRecorder invalid video mimeType throws assert_throws_dom: function "() => new MediaRecorder(new MediaStream(), {mimeType: "video/pineapple"})" did not throw
-FAIL MediaRecorder invalid video mimeType is unsupported MediaRecorder.isTypeSupported is not a function. (In 'MediaRecorder.isTypeSupported("video/pineapple")', 'MediaRecorder.isTypeSupported' is undefined)
-

Modified: branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt (268091 => 268092)


--- branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt	2020-10-07 00:09:24 UTC (rev 268092)
@@ -18,4 +18,3 @@
 PASS PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":false} with format video/webm;codecs=vp9. 
 PASS PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":true} with format video/webm;codecs=vp9. 
 PASS PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format video/webm;codecs=vp9. 
-

Modified: branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt (268091 => 268092)


--- branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,21 +1,18 @@
-CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
-CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
-CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
 
 
 Harness Error (FAIL), message = Unhandled rejection: The object is in an invalid state.
 
-FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got undefined
-FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got undefined
-FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got undefined
-FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got undefined
+FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got "video/mp4"
+FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got "video/mp4"
+FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got "video/mp4"
+FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got "video/mp4"
 TIMEOUT PeerConnection passthrough MediaRecorder should be prepared to handle the codec switching from VP8 to VP9 Test timed out
 
 Harness Error (FAIL), message = Unhandled rejection: The object is in an invalid state.
 
-FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got undefined
-FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got undefined
-FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got undefined
-FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got undefined
+FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got "video/mp4"
+FAIL PeerConnection passthrough MediaRecorder receives VP8 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP8 in case of passthrough. expected object "/.*vp8.*/" but got "video/mp4"
+FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got "video/mp4"
+FAIL PeerConnection passthrough MediaRecorder receives VP9 after onstart with a audio/video stream. assert_regexp_match: mimeType is matching VP9 in case of passthrough. expected object "/.*vp9.*/" but got "video/mp4"
 TIMEOUT PeerConnection passthrough MediaRecorder should be prepared to handle the codec switching from VP8 to VP9 Test timed out
 

Modified: branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html (268091 => 268092)


--- branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/LayoutTests/imported/w3c/web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,4 +1,4 @@
-<!doctype html>
+<!doctype html><!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
 <html>
 
 <head>

Modified: branches/safari-610-branch/Source/WebCore/ChangeLog (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/ChangeLog	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,5 +1,118 @@
 2020-10-06  Alan Coon  <[email protected]>
 
+        Cherry-pick r267825. rdar://problem/70024248
+
+    MediaRecorder should support isTypeSupported
+    https://bugs.webkit.org/show_bug.cgi?id=216856
+    LayoutTests/imported/w3c:
+    
+    Reviewed by Darin Adler.
+    
+    * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt:
+    * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt:
+    * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html:
+    Remove JS console log error line.
+    
+    Source/WebCore:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported.
+    Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs.
+    Add a routine to get the mime type from the MediaRecorderPrivate.
+    Store it in MediaRecorder and add a mimeType getter.
+    
+    Test: http/wpt/mediarecorder/mimeType.html
+    
+    * Modules/mediarecorder/MediaRecorder.cpp:
+    (WebCore::MediaRecorder::isTypeSupported):
+    (WebCore::MediaRecorder::create):
+    * Modules/mediarecorder/MediaRecorder.h:
+    * Modules/mediarecorder/MediaRecorder.idl:
+    * Modules/mediarecorder/MediaRecorderProvider.cpp:
+    (WebCore::MediaRecorderProvider::isSupported):
+    * Modules/mediarecorder/MediaRecorderProvider.h:
+    * platform/mediarecorder/MediaRecorderPrivate.h:
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+    (WebCore::MediaRecorderPrivateAVFImpl::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
+    * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
+    (WebCore::MediaRecorderPrivateMock::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateMock.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+    (WebCore::MediaRecorderPrivateWriter::mimeType const):
+    * platform/mediastream/MediaStreamPrivate.h:
+    
+    Source/WebKit:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Stop passing mimeType for each data blob.
+    Instead, compute it on WebProcess side.
+    
+    * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+    (WebKit::RemoteMediaRecorder::fetchData):
+    * GPUProcess/webrtc/RemoteMediaRecorder.h:
+    * GPUProcess/webrtc/RemoteMediaRecorder.messages.in:
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
+    (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
+    (WebKit::MediaRecorderPrivate::fetchData):
+    (WebKit::MediaRecorderPrivate::mimeType const):
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:
+    
+    LayoutTests:
+    
+    Reviewed by Darin Adler.
+    
+    * http/wpt/mediarecorder/mimeType-expected.txt: Added.
+    * http/wpt/mediarecorder/mimeType.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-10-01  Youenn Fablet  <[email protected]>
+
+            MediaRecorder should support isTypeSupported
+            https://bugs.webkit.org/show_bug.cgi?id=216856
+            <rdar://problem/69767695>
+
+            Reviewed by Darin Adler.
+
+            Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported.
+            Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs.
+            Add a routine to get the mime type from the MediaRecorderPrivate.
+            Store it in MediaRecorder and add a mimeType getter.
+
+            Test: http/wpt/mediarecorder/mimeType.html
+
+            * Modules/mediarecorder/MediaRecorder.cpp:
+            (WebCore::MediaRecorder::isTypeSupported):
+            (WebCore::MediaRecorder::create):
+            * Modules/mediarecorder/MediaRecorder.h:
+            * Modules/mediarecorder/MediaRecorder.idl:
+            * Modules/mediarecorder/MediaRecorderProvider.cpp:
+            (WebCore::MediaRecorderProvider::isSupported):
+            * Modules/mediarecorder/MediaRecorderProvider.h:
+            * platform/mediarecorder/MediaRecorderPrivate.h:
+            * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+            (WebCore::MediaRecorderPrivateAVFImpl::mimeType const):
+            * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
+            * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
+            (WebCore::MediaRecorderPrivateMock::mimeType const):
+            * platform/mediarecorder/MediaRecorderPrivateMock.h:
+            * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+            * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+            (WebCore::MediaRecorderPrivateWriter::mimeType const):
+            * platform/mediastream/MediaStreamPrivate.h:
+
+2020-10-06  Alan Coon  <[email protected]>
+
         Cherry-pick r267828. rdar://problem/70023908
 
     [iOS] MediaRecorder incorrect screen orientation handling

Modified: branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-10-07 00:09:24 UTC (rev 268092)
@@ -46,12 +46,28 @@
 
 MediaRecorder::CreatorFunction MediaRecorder::m_customCreator = nullptr;
 
+bool MediaRecorder::isTypeSupported(Document& document, const String& value)
+{
+#if PLATFORM(COCOA)
+    auto* page = document.page();
+    return page && page->mediaRecorderProvider().isSupported(value);
+#else
+    UNUSED_PARAM(document);
+    return false;
+#endif
+
+}
+
 ExceptionOr<Ref<MediaRecorder>> MediaRecorder::create(Document& document, Ref<MediaStream>&& stream, Options&& options)
 {
+    if (!isTypeSupported(document, options.mimeType))
+        return Exception { NotSupportedError, "mimeType is not supported" };
+
     auto result = MediaRecorder::createMediaRecorderPrivate(document, stream->privateStream(), options);
     if (result.hasException())
         return result.releaseException();
 
+    options.mimeType = result.returnValue()->mimeType();
     auto recorder = adoptRef(*new MediaRecorder(document, WTFMove(stream), WTFMove(options)));
     recorder->suspendIfNeeded();
     return recorder;

Modified: branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -53,15 +53,18 @@
     
     ~MediaRecorder();
     
+    static bool isTypeSupported(Document&, const String&);
+
     using Options = MediaRecorderPrivateOptions;
     static ExceptionOr<Ref<MediaRecorder>> create(Document&, Ref<MediaStream>&&, Options&& = { });
-    
+
     using CreatorFunction = ExceptionOr<std::unique_ptr<MediaRecorderPrivate>> (*)(MediaStreamPrivate&, const Options&);
 
     WEBCORE_EXPORT static void setCustomPrivateRecorderCreator(CreatorFunction);
-    
+
     RecordingState state() const { return m_state; }
-    
+    const String& mimeType() const { return m_options.mimeType; }
+
     using RefCounted::ref;
     using RefCounted::deref;
     

Modified: branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.idl	2020-10-07 00:09:24 UTC (rev 268092)
@@ -35,7 +35,7 @@
     // FIXME: Implement commented out methods/attributes.
 
     readonly attribute MediaStream stream;
-    // readonly attribute DOMString mimeType;
+    readonly attribute DOMString mimeType;
     readonly attribute RecordingState state;
     attribute EventHandler onstart;
     attribute EventHandler onstop;
@@ -53,7 +53,7 @@
     // void resume();
     void requestData();
 
-    // static boolean isTypeSupported(DOMString type);
+    [CallWith=Document] static boolean isTypeSupported(DOMString type);
 };
 
 dictionary MediaRecorderOptions {

Modified: branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.cpp (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.cpp	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.cpp	2020-10-07 00:09:24 UTC (rev 268092)
@@ -28,6 +28,8 @@
 
 #if ENABLE(MEDIA_STREAM) && PLATFORM(COCOA)
 
+#include "ContentType.h"
+#include "HTMLParserIdioms.h"
 #include "MediaRecorderPrivateAVFImpl.h"
 
 namespace WebCore {
@@ -43,6 +45,26 @@
 #endif
 }
 
+bool MediaRecorderProvider::isSupported(const String& value)
+{
+    if (value.isEmpty())
+        return true;
+
+    ContentType mimeType(value);
+
+    auto containerType = mimeType.containerType();
+    if (!equalLettersIgnoringASCIICase(containerType, "audio/mp4") && !equalLettersIgnoringASCIICase(containerType, "video/mp4"))
+        return false;
+
+    for (auto& item : mimeType.codecs()) {
+        auto codec = StringView(item).stripLeadingAndTrailingMatchedCharacters(isHTMLSpace<UChar>);
+        // FIXME: We should further validate paramters.
+        if (!startsWithLettersIgnoringASCIICase(codec, "avc1") && !startsWithLettersIgnoringASCIICase(codec, "mp4a"))
+            return false;
+    }
+    return true;
 }
 
+}
+
 #endif

Modified: branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/Modules/mediarecorder/MediaRecorderProvider.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -39,6 +39,7 @@
 
 #if ENABLE(MEDIA_STREAM) && PLATFORM(COCOA)
     virtual std::unique_ptr<MediaRecorderPrivate> createMediaRecorderPrivate(MediaStreamPrivate&, const MediaRecorderPrivateOptions&);
+    virtual bool isSupported(const String&);
 #endif
 
     void setUseGPUProcess(bool value) { m_useGPUProcess = value; }

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -60,6 +60,7 @@
     using FetchDataCallback = CompletionHandler<void(RefPtr<SharedBuffer>&&, const String& mimeType)>;
     virtual void fetchData(FetchDataCallback&&) = 0;
     virtual void stopRecording() = 0;
+    virtual const String& mimeType() const = 0;
 
     using ErrorCallback = CompletionHandler<void(Optional<Exception>&&)>;
     virtual void startRecording(ErrorCallback&& callback) { callback({ }); }

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp	2020-10-07 00:09:24 UTC (rev 268092)
@@ -94,11 +94,9 @@
     });
 }
 
-const String& MediaRecorderPrivateAVFImpl::mimeType()
+const String& MediaRecorderPrivateAVFImpl::mimeType() const
 {
-    static NeverDestroyed<const String> mp4MimeType(MAKE_STATIC_STRING_IMPL("video/mp4"));
-    // FIXME: we will need to support more MIME types.
-    return mp4MimeType;
+    return m_writer->mimeType();
 }
 
 } // namespace WebCore

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -47,8 +47,8 @@
     void videoSampleAvailable(MediaSample&) final;
     void fetchData(FetchDataCallback&&) final;
     void audioSamplesAvailable(const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
+    const String& mimeType() const final;
 
-    const String& mimeType();
     void stopRecording();
 
     Ref<MediaRecorderPrivateWriter> m_writer;

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp	2020-10-07 00:09:24 UTC (rev 268092)
@@ -94,7 +94,7 @@
     completionHandler(WTFMove(buffer), mimeType());
 }
 
-const String& MediaRecorderPrivateMock::mimeType()
+const String& MediaRecorderPrivateMock::mimeType() const
 {
     static NeverDestroyed<const String> textPlainMimeType(MAKE_STATIC_STRING_IMPL("text/plain"));
     return textPlainMimeType;

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -46,8 +46,8 @@
     void fetchData(FetchDataCallback&&) final;
     void audioSamplesAvailable(const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
     void stopRecording() final;
+    const String& mimeType() const final;
 
-    const String& mimeType();
     void generateMockCounterString();
 
     mutable Lock m_bufferLock;

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -75,6 +75,8 @@
     void appendData(const char*, size_t);
     void appendData(Ref<SharedBuffer>&&);
 
+    const String& mimeType() const;
+
 private:
     MediaRecorderPrivateWriter(bool hasAudio, bool hasVideo);
     void clear();

Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm	2020-10-07 00:09:24 UTC (rev 268092)
@@ -596,6 +596,14 @@
     m_data->append(WTFMove(buffer));
 }
 
+const String& MediaRecorderPrivateWriter::mimeType() const
+{
+    static NeverDestroyed<const String> audioMP4(MAKE_STATIC_STRING_IMPL("audio/mp4"));
+    static NeverDestroyed<const String> videoMP4(MAKE_STATIC_STRING_IMPL("video/mp4"));
+    // FIXME: we will need to support MIME type codecs parameter values.
+    return m_hasVideo ? videoMP4 : audioMP4;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM) && HAVE(AVASSETWRITERDELEGATE)

Modified: branches/safari-610-branch/Source/WebCore/platform/mediastream/MediaStreamPrivate.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -96,7 +96,7 @@
     void stopProducingData();
     bool isProducingData() const;
 
-    bool hasVideo() const;
+    WEBCORE_EXPORT bool hasVideo() const;
     bool hasAudio() const;
     bool muted() const;
 

Modified: branches/safari-610-branch/Source/WebKit/ChangeLog (268091 => 268092)


--- branches/safari-610-branch/Source/WebKit/ChangeLog	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog	2020-10-07 00:09:24 UTC (rev 268092)
@@ -1,5 +1,104 @@
 2020-10-06  Alan Coon  <[email protected]>
 
+        Cherry-pick r267825. rdar://problem/70024248
+
+    MediaRecorder should support isTypeSupported
+    https://bugs.webkit.org/show_bug.cgi?id=216856
+    LayoutTests/imported/w3c:
+    
+    Reviewed by Darin Adler.
+    
+    * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt:
+    * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt:
+    * web-platform-tests/mediacapture-record/idlharness.window-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt:
+    * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html:
+    Remove JS console log error line.
+    
+    Source/WebCore:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported.
+    Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs.
+    Add a routine to get the mime type from the MediaRecorderPrivate.
+    Store it in MediaRecorder and add a mimeType getter.
+    
+    Test: http/wpt/mediarecorder/mimeType.html
+    
+    * Modules/mediarecorder/MediaRecorder.cpp:
+    (WebCore::MediaRecorder::isTypeSupported):
+    (WebCore::MediaRecorder::create):
+    * Modules/mediarecorder/MediaRecorder.h:
+    * Modules/mediarecorder/MediaRecorder.idl:
+    * Modules/mediarecorder/MediaRecorderProvider.cpp:
+    (WebCore::MediaRecorderProvider::isSupported):
+    * Modules/mediarecorder/MediaRecorderProvider.h:
+    * platform/mediarecorder/MediaRecorderPrivate.h:
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+    (WebCore::MediaRecorderPrivateAVFImpl::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
+    * platform/mediarecorder/MediaRecorderPrivateMock.cpp:
+    (WebCore::MediaRecorderPrivateMock::mimeType const):
+    * platform/mediarecorder/MediaRecorderPrivateMock.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+    * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+    (WebCore::MediaRecorderPrivateWriter::mimeType const):
+    * platform/mediastream/MediaStreamPrivate.h:
+    
+    Source/WebKit:
+    
+    <rdar://problem/69767695>
+    
+    Reviewed by Darin Adler.
+    
+    Stop passing mimeType for each data blob.
+    Instead, compute it on WebProcess side.
+    
+    * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+    (WebKit::RemoteMediaRecorder::fetchData):
+    * GPUProcess/webrtc/RemoteMediaRecorder.h:
+    * GPUProcess/webrtc/RemoteMediaRecorder.messages.in:
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
+    (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
+    (WebKit::MediaRecorderPrivate::fetchData):
+    (WebKit::MediaRecorderPrivate::mimeType const):
+    * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:
+    
+    LayoutTests:
+    
+    Reviewed by Darin Adler.
+    
+    * http/wpt/mediarecorder/mimeType-expected.txt: Added.
+    * http/wpt/mediarecorder/mimeType.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-10-01  Youenn Fablet  <[email protected]>
+
+            MediaRecorder should support isTypeSupported
+            https://bugs.webkit.org/show_bug.cgi?id=216856
+            <rdar://problem/69767695>
+
+            Reviewed by Darin Adler.
+
+            Stop passing mimeType for each data blob.
+            Instead, compute it on WebProcess side.
+
+            * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+            (WebKit::RemoteMediaRecorder::fetchData):
+            * GPUProcess/webrtc/RemoteMediaRecorder.h:
+            * GPUProcess/webrtc/RemoteMediaRecorder.messages.in:
+            * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
+            (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
+            (WebKit::MediaRecorderPrivate::fetchData):
+            (WebKit::MediaRecorderPrivate::mimeType const):
+            * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:
+
+2020-10-06  Alan Coon  <[email protected]>
+
         Cherry-pick r267366. rdar://problem/70023908
 
     [iOS] MediaRecorder incorrect screen orientation handling

Modified: branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp (268091 => 268092)


--- branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp	2020-10-07 00:09:24 UTC (rev 268092)
@@ -121,12 +121,11 @@
     m_writer->appendVideoSampleBuffer(*sampleBuffer);
 }
 
-void RemoteMediaRecorder::fetchData(CompletionHandler<void(IPC::DataReference&&, const String& mimeType)>&& completionHandler)
+void RemoteMediaRecorder::fetchData(CompletionHandler<void(IPC::DataReference&&)>&& completionHandler)
 {
-    static NeverDestroyed<const String> mp4MimeType(MAKE_STATIC_STRING_IMPL("video/mp4"));
-    m_writer->fetchData([&mp4MimeType = mp4MimeType.get(), completionHandler = WTFMove(completionHandler)](auto&& data) mutable {
+    m_writer->fetchData([completionHandler = WTFMove(completionHandler)](auto&& data) mutable {
         auto* pointer = reinterpret_cast<const uint8_t*>(data ? data->data() : nullptr);
-        completionHandler(IPC::DataReference { pointer, data ? data->size() : 0 }, mp4MimeType);
+        completionHandler(IPC::DataReference { pointer, data ? data->size() : 0 });
     });
 }
 

Modified: branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -68,7 +68,7 @@
     void audioSamplesStorageChanged(const SharedMemory::IPCHandle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames);
     void audioSamplesAvailable(MediaTime, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame);
     void videoSampleAvailable(WebCore::RemoteVideoSample&&);
-    void fetchData(CompletionHandler<void(IPC::DataReference&&, const String& mimeType)>&&);
+    void fetchData(CompletionHandler<void(IPC::DataReference&&)>&&);
     void stopRecording();
 
     SharedRingBufferStorage& storage();

Modified: branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.messages.in (268091 => 268092)


--- branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.messages.in	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.messages.in	2020-10-07 00:09:24 UTC (rev 268092)
@@ -27,7 +27,7 @@
     AudioSamplesStorageChanged(WebKit::SharedMemory::IPCHandle storageHandle, WebCore::CAAudioStreamDescription description, uint64_t numberOfFrames)
     AudioSamplesAvailable(MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
     VideoSampleAvailable(WebCore::RemoteVideoSample sample)
-    FetchData() -> (IPC::DataReference buffer, String mimeType) Async
+    FetchData() -> (IPC::DataReference buffer) Async
     StopRecording()
 }
 

Modified: branches/safari-610-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp (268091 => 268092)


--- branches/safari-610-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp	2020-10-07 00:09:24 UTC (rev 268092)
@@ -48,6 +48,7 @@
     , m_stream(makeRef(stream))
     , m_connection(WebProcess::singleton().ensureGPUProcessConnection().connection())
     , m_options(options)
+    , m_hasVideo(stream.hasVideo())
 {
 }
 
@@ -126,7 +127,7 @@
 
 void MediaRecorderPrivate::fetchData(CompletionHandler<void(RefPtr<WebCore::SharedBuffer>&&, const String& mimeType)>&& completionHandler)
 {
-    m_connection->sendWithAsyncReply(Messages::RemoteMediaRecorder::FetchData { }, [completionHandler = WTFMove(completionHandler)](auto&& data, auto&& mimeType) mutable {
+    m_connection->sendWithAsyncReply(Messages::RemoteMediaRecorder::FetchData { }, [completionHandler = WTFMove(completionHandler), mimeType = mimeType()](auto&& data) mutable {
         RefPtr<SharedBuffer> buffer;
         if (data.size())
             buffer = SharedBuffer::create(data.data(), data.size());
@@ -141,6 +142,13 @@
     m_connection->send(Messages::RemoteMediaRecorder::StopRecording { }, m_identifier);
 }
 
+const String& MediaRecorderPrivate::mimeType() const
+{
+    static NeverDestroyed<const String> audioMP4(MAKE_STATIC_STRING_IMPL("audio/mp4"));
+    static NeverDestroyed<const String> videoMP4(MAKE_STATIC_STRING_IMPL("video/mp4"));
+    return m_hasVideo ? videoMP4 : audioMP4;
 }
 
+}
+
 #endif // PLATFORM(COCOA) && ENABLE(GPU_PROCESS) && ENABLE(MEDIA_STREAM) && HAVE(AVASSETWRITERDELEGATE)

Modified: branches/safari-610-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h (268091 => 268092)


--- branches/safari-610-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h	2020-10-07 00:09:17 UTC (rev 268091)
+++ branches/safari-610-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h	2020-10-07 00:09:24 UTC (rev 268092)
@@ -60,6 +60,7 @@
     void stopRecording() final;
     void startRecording(ErrorCallback&&) final;
     void audioSamplesAvailable(const WTF::MediaTime&, const WebCore::PlatformAudioData&, const WebCore::AudioStreamDescription&, size_t) final;
+    const String& mimeType() const final;
 
     // SharedRingBufferStorage::Client
     void storageChanged(SharedMemory*);
@@ -72,6 +73,7 @@
     WebCore::CAAudioStreamDescription m_description { };
     int64_t m_numberOfFrames { 0 };
     WebCore::MediaRecorderPrivateOptions m_options;
+    bool m_hasVideo { false };
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to