<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[238053] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/238053">238053</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2018-11-09 13:26:16 -0800 (Fri, 09 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[MediaStream] AVVideoCaptureSource reports incorrect size when frames are scaled
https://bugs.webkit.org/show_bug.cgi?id=191479
<rdar://problem/45952201>

Reviewed by Jer Noble.

No new tests, tested manually.

* platform/mediastream/RealtimeVideoSource.cpp:
(WebCore::RealtimeVideoSource::standardVideoSizes): Drive-by fix: add a few more standard
video frame sizes, correct a typo.
(WebCore::RealtimeVideoSource::bestSupportedSizeAndFrameRate): Drive-by fix: don't consider
rescaled sized when we already have an exact or aspect ratio match because it won't be used.

* platform/mediastream/mac/AVVideoCaptureSource.h:
(WebCore::AVVideoCaptureSource::width const): Deleted.
(WebCore::AVVideoCaptureSource::height const): Deleted.
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset): Delete m_requestedSize.
(WebCore::AVVideoCaptureSource::shutdownCaptureSession): Delete m_width and m_height.
(WebCore::AVVideoCaptureSource::processNewFrame): Don't call setSize with captured size,
the frame may be resized before deliver.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeVideoSourcecpp">trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourceh">trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourcemm">trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (238052 => 238053)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-11-09 21:10:26 UTC (rev 238052)
+++ trunk/Source/WebCore/ChangeLog      2018-11-09 21:26:16 UTC (rev 238053)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2018-11-09  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] AVVideoCaptureSource reports incorrect size when frames are scaled
+        https://bugs.webkit.org/show_bug.cgi?id=191479
+        <rdar://problem/45952201>
+
+        Reviewed by Jer Noble.
+
+        No new tests, tested manually.
+
+        * platform/mediastream/RealtimeVideoSource.cpp:
+        (WebCore::RealtimeVideoSource::standardVideoSizes): Drive-by fix: add a few more standard
+        video frame sizes, correct a typo.
+        (WebCore::RealtimeVideoSource::bestSupportedSizeAndFrameRate): Drive-by fix: don't consider
+        rescaled sized when we already have an exact or aspect ratio match because it won't be used.
+
+        * platform/mediastream/mac/AVVideoCaptureSource.h:
+        (WebCore::AVVideoCaptureSource::width const): Deleted.
+        (WebCore::AVVideoCaptureSource::height const): Deleted.
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::setSizeAndFrameRateWithPreset): Delete m_requestedSize.
+        (WebCore::AVVideoCaptureSource::shutdownCaptureSession): Delete m_width and m_height.
+        (WebCore::AVVideoCaptureSource::processNewFrame): Don't call setSize with captured size,
+        the frame may be resized before deliver.
+
</ins><span class="cx"> 2018-11-09  Ross Kirsling  <ross.kirsling@sony.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed MSVC build fix after r238039 (and r238046).
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp (238052 => 238053)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp        2018-11-09 21:10:26 UTC (rev 238052)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp   2018-11-09 21:26:16 UTC (rev 238053)
</span><span class="lines">@@ -103,6 +103,7 @@
</span><span class="cx">             { 112, 112 },
</span><span class="cx">             { 160, 160 },
</span><span class="cx">             { 160, 120 }, // 4:3, QQVGA
</span><ins>+            { 176, 144 }, // 4:3, QCIF
</ins><span class="cx">             { 192, 192 },
</span><span class="cx">             { 192, 112 }, // 16:9
</span><span class="cx">             { 192, 144 }, // 3:4
</span><span class="lines">@@ -109,7 +110,7 @@
</span><span class="cx">             { 240, 240 },
</span><span class="cx">             { 240, 160 }, // 3:2, HQVGA
</span><span class="cx">             { 320, 320 },
</span><del>-            { 320, 176 }, // 16:9
</del><ins>+            { 320, 180 }, // 16:9
</ins><span class="cx">             { 320, 240 }, // 4:3, QVGA
</span><span class="cx">             { 352, 288 }, // CIF
</span><span class="cx">             { 480, 272 }, // 16:9
</span><span class="lines">@@ -116,7 +117,7 @@
</span><span class="cx">             { 480, 360 }, // 4:3
</span><span class="cx">             { 480, 480 },
</span><span class="cx">             { 640, 640 },
</span><del>-            { 640, 368 }, // 16:9
</del><ins>+            { 640, 360 }, // 16:9, 360p nHD
</ins><span class="cx">             { 640, 480 }, // 4:3
</span><span class="cx">             { 720, 720 },
</span><span class="cx">             { 800, 600 }, // 4:3, SVGA
</span><span class="lines">@@ -127,7 +128,8 @@
</span><span class="cx">             { 1280, 1024 }, // 5:4, SXGA
</span><span class="cx">             { 1280, 720 }, // 16:9, WXGA
</span><span class="cx">             { 1366, 768 }, // 16:9, HD
</span><del>-            { 1920, 1080 }, // 16:9, FHD
</del><ins>+            { 1600, 1200}, // 4:3, UXGA
+            { 1920, 1080 }, // 16:9, 1080p FHD
</ins><span class="cx">             { 2560, 1440 }, // 16:9, QHD
</span><span class="cx">             { 2592, 1936 },
</span><span class="cx">             { 3264, 2448 }, // 3:4
</span><span class="lines">@@ -301,6 +303,9 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (exactSizePreset || aspectRatioPreset)
+            continue;
+
</ins><span class="cx">         if (requestedWidth && requestedHeight) {
</span><span class="cx">             const auto& minStandardSize = standardVideoSizes()[0];
</span><span class="cx">             if (requestedWidth.value() >= minStandardSize.width() && requestedHeight.value() >= minStandardSize.height()) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h (238052 => 238053)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h     2018-11-09 21:10:26 UTC (rev 238052)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h        2018-11-09 21:26:16 UTC (rev 238053)
</span><span class="lines">@@ -57,9 +57,6 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static VideoCaptureFactory& factory();
</span><span class="cx"> 
</span><del>-    int32_t width() const { return m_width; }
-    int32_t height() const { return m_height; }
-
</del><span class="cx">     enum class InterruptionReason { None, VideoNotAllowedInBackground, AudioInUse, VideoInUse, VideoNotAllowedInSideBySide };
</span><span class="cx">     void captureSessionBeginInterruption(RetainPtr<NSNotification>);
</span><span class="cx">     void captureSessionEndInterruption(RetainPtr<NSNotification>);
</span><span class="lines">@@ -112,9 +109,6 @@
</span><span class="cx">     RetainPtr<AVCaptureVideoDataOutput> m_videoOutput;
</span><span class="cx">     std::unique_ptr<ImageTransferSessionVT> m_imageTransferSession;
</span><span class="cx"> 
</span><del>-    IntSize m_requestedSize;
-    int32_t m_width { 0 };
-    int32_t m_height { 0 };
</del><span class="cx">     int m_sensorOrientation { 0 };
</span><span class="cx">     int m_deviceOrientation { 0 };
</span><span class="cx">     MediaSample::VideoRotation m_sampleRotation { MediaSample::VideoRotation::None };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourcemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (238052 => 238053)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm    2018-11-09 21:10:26 UTC (rev 238052)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm       2018-11-09 21:26:16 UTC (rev 238053)
</span><span class="lines">@@ -331,8 +331,6 @@
</span><span class="cx"> 
</span><span class="cx">     ASSERT(avPreset->format);
</span><span class="cx"> 
</span><del>-    m_requestedSize = requestedSize;
-
</del><span class="cx">     NSError *error = nil;
</span><span class="cx">     [m_session beginConfiguration];
</span><span class="cx">     @try {
</span><span class="lines">@@ -474,8 +472,6 @@
</span><span class="cx"> void AVVideoCaptureSource::shutdownCaptureSession()
</span><span class="cx"> {
</span><span class="cx">     m_buffer = nullptr;
</span><del>-    m_width = 0;
-    m_height = 0;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void AVVideoCaptureSource::monitorOrientation(OrientationNotifier& notifier)
</span><span class="lines">@@ -525,16 +521,6 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_buffer = &sample.get();
</span><del>-    auto dimensions = roundedIntSize(sample->presentationSize());
-    if (m_sampleRotation == MediaSample::VideoRotation::Left || m_sampleRotation == MediaSample::VideoRotation::Right)
-        dimensions = { dimensions.height(), dimensions.width() };
-
-    if (dimensions.width() != m_width || dimensions.height() != m_height) {
-        m_width = dimensions.width();
-        m_height = dimensions.height();
-        setSize(dimensions);
-    }
-
</del><span class="cx">     dispatchMediaSampleToObservers(WTFMove(sample));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>