Changeset 247165 in webkit
- Timestamp:
- Jul 5, 2019 11:54:14 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r247164 r247165 1 2019-07-05 Youenn Fablet <youenn@apple.com> 2 3 [iOS] Local capture MediaStreamTrack does not render in portrait mode 4 https://bugs.webkit.org/show_bug.cgi?id=199519 5 <rdar://problem/52689720> 6 7 Reviewed by Eric Carlson. 8 9 * webrtc/video-rotation-expected.txt: 10 * webrtc/video-rotation.html: 11 1 12 2019-07-05 Ryan Haddad <ryanhaddad@apple.com> 2 13 -
trunk/LayoutTests/webrtc/video-rotation-expected.txt
r245033 r247165 1 1 2 2 3 3 PASS Setting video exchange 4 4 PASS Track is enabled, video should not be black 5 PASS Track is enabled and rotated, video should not be black and should change size 5 PASS Track is enabled and rotated, local video should not be black and should change size 6 PASS Track is enabled and rotated, remote video should not be black and should change size 6 7 PASS Track is enabled and rotated again, video should not be black and should change size 7 8 -
trunk/LayoutTests/webrtc/video-rotation.html
r245033 r247165 8 8 </head> 9 9 <body> 10 <video id="video" autoplay playsInline width="320" height="240"></video> 10 <video id="localVideo" autoplay playsInline width="320" height="240"></video> 11 <video id="remoteVideo" autoplay playsInline width="320" height="240"></video> 12 <canvas id="canvas0" width="320" height="240"></canvas> 11 13 <canvas id="canvas1" width="320" height="240"></canvas> 12 14 <canvas id="canvas2" width="320" height="240"></canvas> … … 14 16 <script src ="routines.js"></script> 15 17 <script> 16 function isVideoBlack( id)18 function isVideoBlack(video, canvasId) 17 19 { 18 var canvas = document.getElementById( id);20 var canvas = document.getElementById(canvasId); 19 21 canvas.width = video.videoWidth; 20 22 canvas.height = video.videoHeight; … … 31 33 } 32 34 33 function pollVideoBlackCheck(expected, id, resolve)35 function pollVideoBlackCheck(expected, video, canvasId, resolve) 34 36 { 35 if (isVideoBlack( id) === expected) {37 if (isVideoBlack(video, canvasId) === expected) { 36 38 resolve(); 37 39 return; 38 40 } 39 41 40 setTimeout(() => pollVideoBlackCheck(expected, id, resolve), 100);42 setTimeout(() => pollVideoBlackCheck(expected, video, canvasId, resolve), 100); 41 43 } 42 44 43 function checkVideoBlack(expected, id)45 function checkVideoBlack(expected, video, canvasId) 44 46 { 45 47 return new Promise((resolve, reject) => { 46 pollVideoBlackCheck(expected, id, resolve);47 setTimeout(() => reject("checkVideoBlack timed out for '" + id + "', expected " + expected), 5000);48 pollVideoBlackCheck(expected, video, canvasId, resolve); 49 setTimeout(() => reject("checkVideoBlack timed out for '" + canvasId + "', expected " + expected), 5000); 48 50 }); 49 51 } … … 55 57 56 58 return navigator.mediaDevices.getUserMedia({video: {width: 320, height: 240, facingMode: "environment"}}).then((localStream) => { 59 localVideo.srcObject = localStream; 57 60 return new Promise((resolve, reject) => { 58 61 track = localStream.getVideoTracks()[0]; … … 70 73 }); 71 74 }).then((remoteStream) => { 72 video.srcObject = remoteStream;73 return video.play();75 remoteVideo.srcObject = remoteStream; 76 return remoteVideo.play(); 74 77 }); 75 78 }, "Setting video exchange"); 76 79 77 promise_test((test) => { 78 return checkVideoBlack(false, "canvas1"); 80 promise_test(async (test) => { 81 await checkVideoBlack(false, remoteVideo, "canvas0"); 82 await waitForVideoSize(remoteVideo, 320, 240); 79 83 }, "Track is enabled, video should not be black"); 84 85 promise_test(async (test) => { 86 await checkVideoBlack(false, localVideo, "canvas0"); 87 await waitForVideoSize(localVideo, 320, 240); 88 89 if (window.internals) 90 window.internals.setCameraMediaStreamTrackOrientation(track, 90); 91 92 await checkVideoBlack(false, localVideo, "canvas1"); 93 await waitForVideoSize(localVideo, 240, 320); 94 }, "Track is enabled and rotated, local video should not be black and should change size"); 80 95 81 96 promise_test((test) => { … … 83 98 window.internals.setCameraMediaStreamTrackOrientation(track, 90); 84 99 85 return checkVideoBlack(false, "canvas1").then(() => {86 return waitForVideoSize( video, 240, 320);100 return checkVideoBlack(false, remoteVideo, "canvas2").then(() => { 101 return waitForVideoSize(remoteVideo, 240, 320); 87 102 }); 88 }, "Track is enabled and rotated, video should not be black and should change size");103 }, "Track is enabled and rotated, remote video should not be black and should change size"); 89 104 90 105 promise_test((test) => { … … 92 107 window.internals.setCameraMediaStreamTrackOrientation(track, 180); 93 108 94 return checkVideoBlack(false, "canvas1").then(() => {95 return waitForVideoSize( video, 320, 240);109 return checkVideoBlack(false, remoteVideo, "canvas3").then(() => { 110 return waitForVideoSize(remoteVideo, 320, 240); 96 111 }); 97 112 }, "Track is enabled and rotated again, video should not be black and should change size"); -
trunk/Source/WebCore/ChangeLog
r247164 r247165 1 2019-07-05 Youenn Fablet <youenn@apple.com> 2 3 [iOS] Local capture MediaStreamTrack does not render in portrait mode 4 https://bugs.webkit.org/show_bug.cgi?id=199519 5 <rdar://problem/52689720> 6 7 Reviewed by Eric Carlson. 8 9 RealtimeVideoSource was badly computing its size in case of rotation. 10 Whenever its underlying source is notifying of settings change, 11 compute the size and transpose it only in left/right case. 12 13 Update mock video source to cover that case. 14 Covered by updated test. 15 16 * platform/mediastream/RealtimeVideoSource.cpp: 17 (WebCore::RealtimeVideoSource::sourceSettingsChanged): 18 * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: 19 * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: 20 (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer): 21 * platform/mock/MockRealtimeVideoSource.cpp: 22 (WebCore::MockRealtimeVideoSource::settings): 23 (WebCore::MockRealtimeVideoSource::orientationChanged): 24 (WebCore::MockRealtimeVideoSource::monitorOrientation): 25 * platform/mock/MockRealtimeVideoSource.h: 26 1 27 2019-07-05 Ryan Haddad <ryanhaddad@apple.com> 2 28 -
trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp
r246644 r247165 93 93 { 94 94 auto rotation = m_source->sampleRotation(); 95 if (rotation == MediaSample::VideoRotation::Left || rotation == MediaSample::VideoRotation::Right) { 96 auto size = this->size(); 95 auto size = this->size(); 96 if (size.isEmpty()) 97 size = m_source->size(); 98 if (rotation == MediaSample::VideoRotation::Left || rotation == MediaSample::VideoRotation::Right) 97 99 size = size.transposedSize(); 98 m_currentSettings.setWidth(size.width()); 99 m_currentSettings.setHeight(size.height()); 100 } 100 m_currentSettings.setWidth(size.width()); 101 m_currentSettings.setHeight(size.height()); 101 102 102 103 forEachObserver([&](auto& observer) { -
trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h
r246644 r247165 34 34 35 35 #include "MockRealtimeVideoSource.h" 36 #include "OrientationNotifier.h"37 36 #include "PixelBufferConformerCV.h" 38 37 … … 46 45 class ImageTransferSessionVT; 47 46 48 class MockRealtimeVideoSourceMac final : public MockRealtimeVideoSource , private OrientationNotifier::Observer{47 class MockRealtimeVideoSourceMac final : public MockRealtimeVideoSource { 49 48 public: 50 49 virtual ~MockRealtimeVideoSourceMac() = default; … … 58 57 bool canResizeVideoFrames() const final { return true; } 59 58 60 void orientationChanged(int orientation) final;61 void monitorOrientation(OrientationNotifier&) final;62 MediaSample::VideoRotation sampleRotation() const final { return m_deviceOrientation; }63 64 MediaSample::VideoRotation m_deviceOrientation { MediaSample::VideoRotation::None };65 59 std::unique_ptr<ImageTransferSessionVT> m_imageTransferSession; 66 60 IntSize m_presetSize; -
trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
r246644 r247165 86 86 87 87 auto sampleTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds()); 88 auto sampleBuffer = m_imageTransferSession->createMediaSample(imageBuffer->copyImage()->nativeImage().get(), sampleTime, size(), m_deviceOrientation);88 auto sampleBuffer = m_imageTransferSession->createMediaSample(imageBuffer->copyImage()->nativeImage().get(), sampleTime, size(), sampleRotation()); 89 89 if (!sampleBuffer) 90 90 return; 91 91 92 // We use m_deviceOrientation to emulate sensor orientation93 92 dispatchMediaSampleToObservers(*sampleBuffer); 94 }95 96 void MockRealtimeVideoSourceMac::orientationChanged(int orientation)97 {98 // FIXME: Do something with m_deviceOrientation. See bug 169822.99 switch (orientation) {100 case 0:101 m_deviceOrientation = MediaSample::VideoRotation::None;102 break;103 case 90:104 m_deviceOrientation = MediaSample::VideoRotation::Right;105 break;106 case -90:107 m_deviceOrientation = MediaSample::VideoRotation::Left;108 break;109 case 180:110 m_deviceOrientation = MediaSample::VideoRotation::UpsideDown;111 break;112 default:113 return;114 }115 }116 117 void MockRealtimeVideoSourceMac::monitorOrientation(OrientationNotifier& notifier)118 {119 notifier.addObserver(*this);120 orientationChanged(notifier.orientation());121 93 } 122 94 -
trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
r246644 r247165 158 158 } 159 159 settings.setFrameRate(frameRate()); 160 auto& size = this->size(); 160 auto size = this->size(); 161 if (mockCamera()) { 162 if (m_deviceOrientation == MediaSample::VideoRotation::Left || m_deviceOrientation == MediaSample::VideoRotation::Right) 163 size = size.transposedSize(); 164 } 161 165 settings.setWidth(size.width()); 162 166 settings.setHeight(size.height()); … … 473 477 } 474 478 479 void MockRealtimeVideoSource::orientationChanged(int orientation) 480 { 481 auto deviceOrientation = m_deviceOrientation; 482 switch (orientation) { 483 case 0: 484 m_deviceOrientation = MediaSample::VideoRotation::None; 485 break; 486 case 90: 487 m_deviceOrientation = MediaSample::VideoRotation::Right; 488 break; 489 case -90: 490 m_deviceOrientation = MediaSample::VideoRotation::Left; 491 break; 492 case 180: 493 m_deviceOrientation = MediaSample::VideoRotation::UpsideDown; 494 break; 495 default: 496 return; 497 } 498 499 if (deviceOrientation == m_deviceOrientation) 500 return; 501 502 notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }); 503 } 504 505 void MockRealtimeVideoSource::monitorOrientation(OrientationNotifier& notifier) 506 { 507 if (!mockCamera()) 508 return; 509 510 notifier.addObserver(*this); 511 orientationChanged(notifier.orientation()); 512 } 513 475 514 } // namespace WebCore 476 515 -
trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h
r246644 r247165 37 37 #include "ImageBuffer.h" 38 38 #include "MockMediaDevice.h" 39 #include "OrientationNotifier.h" 39 40 #include "RealtimeMediaSourceFactory.h" 40 41 #include "RealtimeVideoCaptureSource.h" … … 46 47 class GraphicsContext; 47 48 48 class MockRealtimeVideoSource : public RealtimeVideoCaptureSource {49 class MockRealtimeVideoSource : public RealtimeVideoCaptureSource, private OrientationNotifier::Observer { 49 50 public: 50 51 … … 61 62 Seconds elapsedTime(); 62 63 void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override; 64 MediaSample::VideoRotation sampleRotation() const final { return m_deviceOrientation; } 63 65 64 66 private: … … 77 79 void generatePresets() final; 78 80 81 // OrientationNotifier::Observer 82 void orientationChanged(int orientation) final; 83 void monitorOrientation(OrientationNotifier&) final; 84 79 85 void drawAnimation(GraphicsContext&); 80 86 void drawText(GraphicsContext&); … … 84 90 void startCaptureTimer(); 85 91 86 void delaySamples(Seconds) override;92 void delaySamples(Seconds) final; 87 93 88 94 bool mockCamera() const { return WTF::holds_alternative<MockCameraProperties>(m_device.properties); } … … 113 119 MockMediaDevice m_device; 114 120 RefPtr<VideoPreset> m_preset; 121 MediaSample::VideoRotation m_deviceOrientation { MediaSample::VideoRotation::None }; 115 122 }; 116 123
Note: See TracChangeset
for help on using the changeset viewer.