Diff
Modified: branches/safari-610-branch/LayoutTests/ChangeLog (268088 => 268089)
--- branches/safari-610-branch/LayoutTests/ChangeLog 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/LayoutTests/ChangeLog 2020-10-07 00:09:11 UTC (rev 268089)
@@ -1,5 +1,52 @@
2020-10-06 Alan Coon <alanc...@apple.com>
+ Cherry-pick r267366. rdar://problem/70023908
+
+ [iOS] MediaRecorder incorrect screen orientation handling
+ https://bugs.webkit.org/show_bug.cgi?id=198912
+ <rdar://problem/51802521>
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation.
+ Set AVAssetWriterInput transform according the first MediaSample rotation value.
+
+ Test: http/wpt/mediarecorder/video-rotation.html
+
+ * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+ (WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable):
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+ (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer):
+
+ Source/WebKit:
+
+ * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+ (WebKit::RemoteMediaRecorder::videoSampleAvailable):
+
+ LayoutTests:
+
+ * http/wpt/mediarecorder/video-rotation-expected.txt: Added.
+ * http/wpt/mediarecorder/video-rotation.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-09-21 Youenn Fablet <you...@apple.com>
+
+ [iOS] MediaRecorder incorrect screen orientation handling
+ https://bugs.webkit.org/show_bug.cgi?id=198912
+ <rdar://problem/51802521>
+
+ Reviewed by Eric Carlson.
+
+ * http/wpt/mediarecorder/video-rotation-expected.txt: Added.
+ * http/wpt/mediarecorder/video-rotation.html: Added.
+
+2020-10-06 Alan Coon <alanc...@apple.com>
+
Apply patch. rdar://problem/70010322
2020-10-06 Youenn Fablet <you...@apple.com>
Added: branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/video-rotation-expected.txt (0 => 268089)
--- branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/video-rotation-expected.txt (rev 0)
+++ branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/video-rotation-expected.txt 2020-10-07 00:09:11 UTC (rev 268089)
@@ -0,0 +1,4 @@
+
+
+PASS Record a rotated video
+
Added: branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/video-rotation.html (0 => 268089)
--- branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/video-rotation.html (rev 0)
+++ branches/safari-610-branch/LayoutTests/http/wpt/mediarecorder/video-rotation.html 2020-10-07 00:09:11 UTC (rev 268089)
@@ -0,0 +1,45 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Testing video rotation in media recorder</title>
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <video id="recordedVideo" autoplay playsInline width="320" height="240"></video>
+ <script>
+promise_test(async (test) => {
+ const stream = await navigator.mediaDevices.getUserMedia({video: true });
+ let expectedWidth = 640;
+ let expectedHeight = 480;
+
+ if (window.internals) {
+ window.internals.setCameraMediaStreamTrackOrientation(stream.getVideoTracks()[0], 90);
+ testRunner.setMockCameraOrientation(90);
+
+ expectedWidth = 480;
+ expectedHeight = 640;
+ }
+
+ const recorder = new MediaRecorder(stream);
+ const promise = new Promise((resolve, reject) => {
+ recorder._ondataavailable_ = (e) => resolve(e.data);
+ setTimeout(() => reject("datavailable event timed out"), 5000);
+ });
+ recorder.start();
+ setTimeout(() => recorder.stop(), 1000);
+ const blob = await promise;
+
+ const url = ""
+ recordedVideo.src = ""
+ await recordedVideo.play();
+
+ URL.revokeObjectURL(url);
+
+ assert_equals(recordedVideo.videoWidth, expectedWidth, "recorded video width");
+ assert_equals(recordedVideo.videoHeight, expectedHeight, "recorded video height");
+}, "Record a rotated video");
+ </script>
+ </body>
+</html>
Modified: branches/safari-610-branch/Source/WebCore/ChangeLog (268088 => 268089)
--- branches/safari-610-branch/Source/WebCore/ChangeLog 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog 2020-10-07 00:09:11 UTC (rev 268089)
@@ -1,5 +1,60 @@
2020-10-06 Alan Coon <alanc...@apple.com>
+ Cherry-pick r267366. rdar://problem/70023908
+
+ [iOS] MediaRecorder incorrect screen orientation handling
+ https://bugs.webkit.org/show_bug.cgi?id=198912
+ <rdar://problem/51802521>
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation.
+ Set AVAssetWriterInput transform according the first MediaSample rotation value.
+
+ Test: http/wpt/mediarecorder/video-rotation.html
+
+ * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+ (WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable):
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+ (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer):
+
+ Source/WebKit:
+
+ * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+ (WebKit::RemoteMediaRecorder::videoSampleAvailable):
+
+ LayoutTests:
+
+ * http/wpt/mediarecorder/video-rotation-expected.txt: Added.
+ * http/wpt/mediarecorder/video-rotation.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-09-21 Youenn Fablet <you...@apple.com>
+
+ [iOS] MediaRecorder incorrect screen orientation handling
+ https://bugs.webkit.org/show_bug.cgi?id=198912
+ <rdar://problem/51802521>
+
+ Reviewed by Eric Carlson.
+
+ Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation.
+ Set AVAssetWriterInput transform according the first MediaSample rotation value.
+
+ Test: http/wpt/mediarecorder/video-rotation.html
+
+ * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+ (WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable):
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+ (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer):
+
+2020-10-06 Alan Coon <alanc...@apple.com>
+
Apply patch. rdar://problem/70010322
2020-10-06 Youenn Fablet <you...@apple.com>
Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp (268088 => 268089)
--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp 2020-10-07 00:09:11 UTC (rev 268089)
@@ -70,7 +70,7 @@
void MediaRecorderPrivateAVFImpl::videoSampleAvailable(MediaSample& sampleBuffer)
{
- m_writer->appendVideoSampleBuffer(sampleBuffer.platformSample().sample.cmSampleBuffer);
+ m_writer->appendVideoSampleBuffer(sampleBuffer);
}
void MediaRecorderPrivateAVFImpl::audioSamplesAvailable(const WTF::MediaTime& mediaTime, const PlatformAudioData& data, const AudioStreamDescription& description, size_t sampleCount)
Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h (268088 => 268089)
--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h 2020-10-07 00:09:11 UTC (rev 268089)
@@ -56,6 +56,7 @@
class AudioSampleBufferCompressor;
class AudioStreamDescription;
+class MediaSample;
class MediaStreamTrackPrivate;
class PlatformAudioData;
class VideoSampleBufferCompressor;
@@ -66,7 +67,7 @@
static RefPtr<MediaRecorderPrivateWriter> create(bool hasAudio, bool hasVideo, const MediaRecorderPrivateOptions&);
~MediaRecorderPrivateWriter();
- void appendVideoSampleBuffer(CMSampleBufferRef);
+ void appendVideoSampleBuffer(MediaSample&);
void appendAudioSampleBuffer(const PlatformAudioData&, const AudioStreamDescription&, const WTF::MediaTime&, size_t);
void stopRecording();
void fetchData(CompletionHandler<void(RefPtr<SharedBuffer>&&)>&&);
@@ -129,6 +130,7 @@
bool m_isFlushingSamples { false };
bool m_shouldStopAfterFlushingSamples { false };
+ bool m_firstVideoFrame { false };
};
} // namespace WebCore
Modified: branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm (268088 => 268089)
--- branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm 2020-10-07 00:09:11 UTC (rev 268089)
@@ -421,10 +421,19 @@
return adoptCF(newBuffer);
}
-void MediaRecorderPrivateWriter::appendVideoSampleBuffer(CMSampleBufferRef sampleBuffer)
+void MediaRecorderPrivateWriter::appendVideoSampleBuffer(MediaSample& sample)
{
+ if (!m_firstVideoFrame) {
+ m_firstVideoFrame = true;
+ if (sample.videoRotation() != MediaSample::VideoRotation::None || sample.videoMirrored()) {
+ auto videoTransform = CGAffineTransformMakeRotation(static_cast<int>(sample.videoRotation()) * M_PI / 180);
+ if (sample.videoMirrored())
+ videoTransform = CGAffineTransformScale(videoTransform, -1, 1);
+ m_videoAssetWriterInput.get().transform = videoTransform;
+ }
+ }
// FIXME: We should not set the timestamps if they are already set.
- if (auto bufferWithCurrentTime = copySampleBufferWithCurrentTimeStamp(sampleBuffer))
+ if (auto bufferWithCurrentTime = copySampleBufferWithCurrentTimeStamp(sample.platformSample().sample.cmSampleBuffer))
m_videoCompressor->addSampleBuffer(bufferWithCurrentTime.get());
}
Modified: branches/safari-610-branch/Source/WebKit/ChangeLog (268088 => 268089)
--- branches/safari-610-branch/Source/WebKit/ChangeLog 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog 2020-10-07 00:09:11 UTC (rev 268089)
@@ -1,5 +1,52 @@
2020-10-06 Alan Coon <alanc...@apple.com>
+ Cherry-pick r267366. rdar://problem/70023908
+
+ [iOS] MediaRecorder incorrect screen orientation handling
+ https://bugs.webkit.org/show_bug.cgi?id=198912
+ <rdar://problem/51802521>
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation.
+ Set AVAssetWriterInput transform according the first MediaSample rotation value.
+
+ Test: http/wpt/mediarecorder/video-rotation.html
+
+ * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+ (WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable):
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+ (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer):
+
+ Source/WebKit:
+
+ * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+ (WebKit::RemoteMediaRecorder::videoSampleAvailable):
+
+ LayoutTests:
+
+ * http/wpt/mediarecorder/video-rotation-expected.txt: Added.
+ * http/wpt/mediarecorder/video-rotation.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-09-21 Youenn Fablet <you...@apple.com>
+
+ [iOS] MediaRecorder incorrect screen orientation handling
+ https://bugs.webkit.org/show_bug.cgi?id=198912
+ <rdar://problem/51802521>
+
+ Reviewed by Eric Carlson.
+
+ * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+ (WebKit::RemoteMediaRecorder::videoSampleAvailable):
+
+2020-10-06 Alan Coon <alanc...@apple.com>
+
Apply patch. rdar://problem/70010322
2020-10-06 Youenn Fablet <you...@apple.com>
Modified: branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp (268088 => 268089)
--- branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp 2020-10-07 00:09:05 UTC (rev 268088)
+++ branches/safari-610-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp 2020-10-07 00:09:11 UTC (rev 268089)
@@ -118,7 +118,7 @@
return;
}
- m_writer->appendVideoSampleBuffer(sampleBuffer->platformSample().sample.cmSampleBuffer);
+ m_writer->appendVideoSampleBuffer(*sampleBuffer);
}
void RemoteMediaRecorder::fetchData(CompletionHandler<void(IPC::DataReference&&, const String& mimeType)>&& completionHandler)