Title: [240373] branches/safari-607-branch/Source/WebCore
Revision
240373
Author
[email protected]
Date
2019-01-23 17:20:59 -0800 (Wed, 23 Jan 2019)

Log Message

Cherry-pick r240000. rdar://problem/47457985

    Correctly handle rotation for local video playback
    https://bugs.webkit.org/show_bug.cgi?id=193412

    Reviewed by Eric Carlson.

    Update AVVideoCaptureSource to compute the size given to settings after rotating the sample.
    This ensures computing the size of video elements appropriately.
    Also makes sure to notify observers of size change whenever rotation happens as settings() call will provide a different size.
    Covered by manual testing as we do not have yet emulation of local capture with rotation.

    * platform/mediastream/RealtimeMediaSource.cpp:
    (WebCore::RealtimeMediaSource::setIntrinsicSize):
    * platform/mediastream/mac/AVVideoCaptureSource.mm:
    (WebCore::AVVideoCaptureSource::settings):
    (WebCore::AVVideoCaptureSource::computeSampleRotation):

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

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (240372 => 240373)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-01-24 01:20:56 UTC (rev 240372)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-01-24 01:20:59 UTC (rev 240373)
@@ -1,5 +1,46 @@
 2019-01-23  Alan Coon  <[email protected]>
 
+        Cherry-pick r240000. rdar://problem/47457985
+
+    Correctly handle rotation for local video playback
+    https://bugs.webkit.org/show_bug.cgi?id=193412
+    
+    Reviewed by Eric Carlson.
+    
+    Update AVVideoCaptureSource to compute the size given to settings after rotating the sample.
+    This ensures computing the size of video elements appropriately.
+    Also makes sure to notify observers of size change whenever rotation happens as settings() call will provide a different size.
+    Covered by manual testing as we do not have yet emulation of local capture with rotation.
+    
+    * platform/mediastream/RealtimeMediaSource.cpp:
+    (WebCore::RealtimeMediaSource::setIntrinsicSize):
+    * platform/mediastream/mac/AVVideoCaptureSource.mm:
+    (WebCore::AVVideoCaptureSource::settings):
+    (WebCore::AVVideoCaptureSource::computeSampleRotation):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240000 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-01-15  Youenn Fablet  <[email protected]>
+
+            Correctly handle rotation for local video playback
+            https://bugs.webkit.org/show_bug.cgi?id=193412
+
+            Reviewed by Eric Carlson.
+
+            Update AVVideoCaptureSource to compute the size given to settings after rotating the sample.
+            This ensures computing the size of video elements appropriately.
+            Also makes sure to notify observers of size change whenever rotation happens as settings() call will provide a different size.
+            Covered by manual testing as we do not have yet emulation of local capture with rotation.
+
+            * platform/mediastream/RealtimeMediaSource.cpp:
+            (WebCore::RealtimeMediaSource::setIntrinsicSize):
+            * platform/mediastream/mac/AVVideoCaptureSource.mm:
+            (WebCore::AVVideoCaptureSource::settings):
+            (WebCore::AVVideoCaptureSource::computeSampleRotation):
+
+2019-01-23  Alan Coon  <[email protected]>
+
         Cherry-pick r239971. rdar://problem/47458229
 
     Only run the node comparison code in FrameSelection::respondToNodeModification() for range selections

Modified: branches/safari-607-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (240372 => 240373)


--- branches/safari-607-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp	2019-01-24 01:20:56 UTC (rev 240372)
+++ branches/safari-607-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp	2019-01-24 01:20:59 UTC (rev 240373)
@@ -890,9 +890,10 @@
     if (m_intrinsicSize == size)
         return;
 
+    auto currentSize = this->size();
     m_intrinsicSize = size;
 
-    if (m_intrinsicSize != m_size)
+    if (currentSize != this->size())
         notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
 }
 

Modified: branches/safari-607-branch/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (240372 => 240373)


--- branches/safari-607-branch/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2019-01-24 01:20:56 UTC (rev 240372)
+++ branches/safari-607-branch/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2019-01-24 01:20:59 UTC (rev 240373)
@@ -260,7 +260,11 @@
         settings.setFacingMode(RealtimeMediaSourceSettings::Unknown);
 
     settings.setFrameRate(frameRate());
-    auto& size = this->size();
+
+    auto size = this->size();
+    if (m_sampleRotation == MediaSample::VideoRotation::Left || m_sampleRotation == MediaSample::VideoRotation::Right)
+        size = size.transposedSize();
+    
     settings.setWidth(size.width());
     settings.setHeight(size.height());
     settings.setDeviceId(hashedId());
@@ -501,25 +505,31 @@
 void AVVideoCaptureSource::computeSampleRotation()
 {
     bool frontCamera = [device() position] == AVCaptureDevicePositionFront;
+    MediaSample::VideoRotation sampleRotation;
     switch (m_sensorOrientation - m_deviceOrientation) {
     case 0:
-        m_sampleRotation = MediaSample::VideoRotation::None;
+        sampleRotation = MediaSample::VideoRotation::None;
         break;
     case 180:
     case -180:
-        m_sampleRotation = MediaSample::VideoRotation::UpsideDown;
+        sampleRotation = MediaSample::VideoRotation::UpsideDown;
         break;
     case 90:
-        m_sampleRotation = frontCamera ? MediaSample::VideoRotation::Left : MediaSample::VideoRotation::Right;
+        sampleRotation = frontCamera ? MediaSample::VideoRotation::Left : MediaSample::VideoRotation::Right;
         break;
     case -90:
     case -270:
-        m_sampleRotation = frontCamera ? MediaSample::VideoRotation::Right : MediaSample::VideoRotation::Left;
+        sampleRotation = frontCamera ? MediaSample::VideoRotation::Right : MediaSample::VideoRotation::Left;
         break;
     default:
         ASSERT_NOT_REACHED();
-        m_sampleRotation = MediaSample::VideoRotation::None;
+        sampleRotation = MediaSample::VideoRotation::None;
     }
+    if (sampleRotation == m_sampleRotation)
+        return;
+
+    m_sampleRotation = sampleRotation;
+    notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
 }
 
 void AVVideoCaptureSource::processNewFrame(Ref<MediaSample>&& sample)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to