<!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>[235670] trunk/Source</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/235670">235670</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2018-09-05 08:56:44 -0700 (Wed, 05 Sep 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[MediaStream] Simplify logic when changing RealtimeMediaSource settings
https://bugs.webkit.org/show_bug.cgi?id=189284
<rdar://problem/44117948>

Reviewed by Youenn Fablet.

Source/WebCore:

Remove all "apply<setting>" methods from RealtimeMediaSource and derived classes, and
add a bitfield to settingsDidChange so classes can do setting-specific setup and
configuration by overriding settingsDidChange.

No new tests, no functionality changed.

* Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
(WebCore::CanvasCaptureMediaStreamTrack::Source::canvasResized):
* Modules/mediastream/CanvasCaptureMediaStreamTrack.h:
* platform/mediastream/MediaConstraints.h:
(WebCore::NumericConstraint::fitnessDistance const):
(WebCore::NumericConstraint::valueForDiscreteCapabilityValues const):
* platform/mediastream/RealtimeIncomingVideoSource.h:
(): Deleted.
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::RealtimeMediaSource):
(WebCore::RealtimeMediaSource::settingsDidChange):
(WebCore::RealtimeMediaSource::fitnessDistance):
(WebCore::applyNumericConstraint):
(WebCore::RealtimeMediaSource::applyConstraint):
(WebCore::RealtimeMediaSource::applyConstraints):
(WebCore::RealtimeMediaSource::setSize):
(WebCore::RealtimeMediaSource::setWidth):
(WebCore::RealtimeMediaSource::setHeight):
(WebCore::RealtimeMediaSource::setFrameRate):
(WebCore::RealtimeMediaSource::setAspectRatio):
(WebCore::RealtimeMediaSource::setFacingMode):
(WebCore::RealtimeMediaSource::setVolume):
(WebCore::RealtimeMediaSource::setSampleRate):
(WebCore::RealtimeMediaSource::setSampleSize):
(WebCore::RealtimeMediaSource::setEchoCancellation):
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/RealtimeMediaSourceSettings.cpp:
(WebCore::RealtimeMediaSourceSettings::diff const):
* platform/mediastream/RealtimeMediaSourceSettings.h:
(WebCore::RealtimeMediaSourceSettings::allFlags):
* platform/mediastream/RealtimeVideoSource.cpp:
(WebCore::RealtimeVideoSource::applySize): Deleted.
(WebCore::RealtimeVideoSource::applyFrameRate): Deleted.
* platform/mediastream/RealtimeVideoSource.h:
* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp:
(WebCore::GStreamerAudioCaptureSource::settingsDidChange):
(WebCore::GStreamerAudioCaptureSource::applySampleRate): Deleted.
* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h:
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
(WebCore::GStreamerVideoCaptureSource::settingsDidChange):
(WebCore::GStreamerVideoCaptureSource::applySize): Deleted.
(WebCore::GStreamerVideoCaptureSource::applyFrameRate): Deleted.
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h:
* platform/mediastream/mac/AVVideoCaptureSource.h:
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::settingsDidChange):
(WebCore::AVVideoCaptureSource::setPreset):
(WebCore::AVVideoCaptureSource::setFrameRate):
(WebCore::AVVideoCaptureSource::applySizeAndFrameRate):
(WebCore::AVVideoCaptureSource::processNewFrame):
(WebCore::AVVideoCaptureSource::applySize): Deleted.
(WebCore::AVVideoCaptureSource::applyFrameRate): Deleted.
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioCaptureSource::settingsDidChange):
(WebCore::CoreAudioCaptureSource::applySampleRate): Deleted.
(WebCore::CoreAudioCaptureSource::applyEchoCancellation): Deleted.
* platform/mediastream/mac/CoreAudioCaptureSource.h:
* platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
(WebCore::DisplayCaptureSourceCocoa::settingsDidChange):
(WebCore::DisplayCaptureSourceCocoa::startProducingData):
(WebCore::DisplayCaptureSourceCocoa::applySize): Deleted.
(WebCore::DisplayCaptureSourceCocoa::applyFrameRate): Deleted.
* platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::settingsDidChange):
(WebCore::MockRealtimeAudioSourceMac::applySampleRate): Deleted.
* platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
* platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
(WebCore::MockRealtimeVideoSourceMac::settingsDidChange):
(WebCore::MockRealtimeVideoSourceMac::applySize): Deleted.
* platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
(WebCore::RealtimeIncomingVideoSourceCocoa::processNewSample):
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
(WebCore::ScreenDisplayCaptureSourceMac::settingsDidChange):
(WebCore::ScreenDisplayCaptureSourceMac::applySize): Deleted.
(WebCore::ScreenDisplayCaptureSourceMac::applyFrameRate): Deleted.
* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::settingsDidChange):
* platform/mock/MockRealtimeAudioSource.h:
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::settingsDidChange):
(WebCore::MockRealtimeVideoSource::applySize): Deleted.
* platform/mock/MockRealtimeVideoSource.h:

Source/WebKit:

* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::Source::setSettings):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamCanvasCaptureMediaStreamTrackcpp">trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamCanvasCaptureMediaStreamTrackh">trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamMediaConstraintsh">trunk/Source/WebCore/platform/mediastream/MediaConstraints.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeIncomingVideoSourceh">trunk/Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceh">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceSettingscpp">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceSettingsh">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeVideoSourcecpp">trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeVideoSourceh">trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamgstreamerGStreamerAudioCaptureSourcecpp">trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamgstreamerGStreamerAudioCaptureSourceh">trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamgstreamerGStreamerVideoCaptureSourcecpp">trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamgstreamerGStreamerVideoCaptureSourceh">trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h</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>
<li><a href="#trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourceh">trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacDisplayCaptureSourceCocoacpp">trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacDisplayCaptureSourceCocoah">trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMach">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMach">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMacmm">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeIncomingVideoSourceCocoamm">trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacScreenDisplayCaptureSourceMach">trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacScreenDisplayCaptureSourceMacmm">trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeAudioSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh">trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeVideoSourceh">trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcesscocoaUserMediaCaptureManagercpp">trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/ChangeLog      2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,3 +1,103 @@
</span><ins>+2018-09-05  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Simplify logic when changing RealtimeMediaSource settings
+        https://bugs.webkit.org/show_bug.cgi?id=189284
+        <rdar://problem/44117948>
+
+        Reviewed by Youenn Fablet.
+
+        Remove all "apply<setting>" methods from RealtimeMediaSource and derived classes, and
+        add a bitfield to settingsDidChange so classes can do setting-specific setup and
+        configuration by overriding settingsDidChange.
+
+        No new tests, no functionality changed.
+
+        * Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
+        (WebCore::CanvasCaptureMediaStreamTrack::Source::canvasResized):
+        * Modules/mediastream/CanvasCaptureMediaStreamTrack.h:
+        * platform/mediastream/MediaConstraints.h:
+        (WebCore::NumericConstraint::fitnessDistance const):
+        (WebCore::NumericConstraint::valueForDiscreteCapabilityValues const):
+        * platform/mediastream/RealtimeIncomingVideoSource.h:
+        (): Deleted.
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::RealtimeMediaSource):
+        (WebCore::RealtimeMediaSource::settingsDidChange):
+        (WebCore::RealtimeMediaSource::fitnessDistance):
+        (WebCore::applyNumericConstraint):
+        (WebCore::RealtimeMediaSource::applyConstraint):
+        (WebCore::RealtimeMediaSource::applyConstraints):
+        (WebCore::RealtimeMediaSource::setSize):
+        (WebCore::RealtimeMediaSource::setWidth):
+        (WebCore::RealtimeMediaSource::setHeight):
+        (WebCore::RealtimeMediaSource::setFrameRate):
+        (WebCore::RealtimeMediaSource::setAspectRatio):
+        (WebCore::RealtimeMediaSource::setFacingMode):
+        (WebCore::RealtimeMediaSource::setVolume):
+        (WebCore::RealtimeMediaSource::setSampleRate):
+        (WebCore::RealtimeMediaSource::setSampleSize):
+        (WebCore::RealtimeMediaSource::setEchoCancellation):
+        * platform/mediastream/RealtimeMediaSource.h:
+        * platform/mediastream/RealtimeMediaSourceSettings.cpp:
+        (WebCore::RealtimeMediaSourceSettings::diff const):
+        * platform/mediastream/RealtimeMediaSourceSettings.h:
+        (WebCore::RealtimeMediaSourceSettings::allFlags):
+        * platform/mediastream/RealtimeVideoSource.cpp:
+        (WebCore::RealtimeVideoSource::applySize): Deleted.
+        (WebCore::RealtimeVideoSource::applyFrameRate): Deleted.
+        * platform/mediastream/RealtimeVideoSource.h:
+        * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp:
+        (WebCore::GStreamerAudioCaptureSource::settingsDidChange):
+        (WebCore::GStreamerAudioCaptureSource::applySampleRate): Deleted.
+        * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h:
+        * platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
+        (WebCore::GStreamerVideoCaptureSource::settingsDidChange):
+        (WebCore::GStreamerVideoCaptureSource::applySize): Deleted.
+        (WebCore::GStreamerVideoCaptureSource::applyFrameRate): Deleted.
+        * platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h:
+        * platform/mediastream/mac/AVVideoCaptureSource.h:
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::settingsDidChange):
+        (WebCore::AVVideoCaptureSource::setPreset):
+        (WebCore::AVVideoCaptureSource::setFrameRate):
+        (WebCore::AVVideoCaptureSource::applySizeAndFrameRate):
+        (WebCore::AVVideoCaptureSource::processNewFrame):
+        (WebCore::AVVideoCaptureSource::applySize): Deleted.
+        (WebCore::AVVideoCaptureSource::applyFrameRate): Deleted.
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::CoreAudioCaptureSource::settingsDidChange):
+        (WebCore::CoreAudioCaptureSource::applySampleRate): Deleted.
+        (WebCore::CoreAudioCaptureSource::applyEchoCancellation): Deleted.
+        * platform/mediastream/mac/CoreAudioCaptureSource.h:
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
+        (WebCore::DisplayCaptureSourceCocoa::settingsDidChange):
+        (WebCore::DisplayCaptureSourceCocoa::startProducingData):
+        (WebCore::DisplayCaptureSourceCocoa::applySize): Deleted.
+        (WebCore::DisplayCaptureSourceCocoa::applyFrameRate): Deleted.
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+        (WebCore::MockRealtimeAudioSourceMac::settingsDidChange):
+        (WebCore::MockRealtimeAudioSourceMac::applySampleRate): Deleted.
+        * platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
+        (WebCore::MockRealtimeVideoSourceMac::settingsDidChange):
+        (WebCore::MockRealtimeVideoSourceMac::applySize): Deleted.
+        * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+        (WebCore::RealtimeIncomingVideoSourceCocoa::processNewSample):
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
+        (WebCore::ScreenDisplayCaptureSourceMac::settingsDidChange):
+        (WebCore::ScreenDisplayCaptureSourceMac::applySize): Deleted.
+        (WebCore::ScreenDisplayCaptureSourceMac::applyFrameRate): Deleted.
+        * platform/mock/MockRealtimeAudioSource.cpp:
+        (WebCore::MockRealtimeAudioSource::settingsDidChange):
+        * platform/mock/MockRealtimeAudioSource.h:
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::settingsDidChange):
+        (WebCore::MockRealtimeVideoSource::applySize): Deleted.
+        * platform/mock/MockRealtimeVideoSource.h:
+
</ins><span class="cx"> 2018-09-05  Zalan Bujtas <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [LFC][BFC] Move MarginCollapse class under BlockFormattingContext::Geometry
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamCanvasCaptureMediaStreamTrackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp       2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp  2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -114,10 +114,16 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(canvas, m_canvas == &canvas);
</span><span class="cx"> 
</span><ins>+    OptionSet<RealtimeMediaSourceSettings::Flag> changed;
+    if (m_canvas->width() != m_settings.width())
+        changed.add(RealtimeMediaSourceSettings::Flag::Width);
+    if (m_canvas->height() != m_settings.height())
+        changed.add(RealtimeMediaSourceSettings::Flag::Height);
+
</ins><span class="cx">     m_settings.setWidth(m_canvas->width());
</span><span class="cx">     m_settings.setHeight(m_canvas->height());
</span><span class="cx"> 
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(changed);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasCaptureMediaStreamTrack::Source::canvasChanged(CanvasBase& canvas, const FloatRect&)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamCanvasCaptureMediaStreamTrackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.h 2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.h    2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -67,7 +67,6 @@
</span><span class="cx">         void stopProducingData()  final;
</span><span class="cx">         const RealtimeMediaSourceCapabilities& capabilities() const final { return RealtimeMediaSourceCapabilities::emptyCapabilities(); }
</span><span class="cx">         const RealtimeMediaSourceSettings& settings() const final { return m_settings; }
</span><del>-        bool applySize(const IntSize&) final { return true; }
</del><span class="cx"> 
</span><span class="cx">         void captureCanvas();
</span><span class="cx">         void requestFrameTimerFired();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaConstraintsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.h     2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.h        2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -193,6 +193,19 @@
</span><span class="cx">         return static_cast<double>(std::abs(ideal - m_ideal.value())) / std::max(std::abs(ideal), std::abs(m_ideal.value()));
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    double fitnessDistance(const Vector<ValueType>& discreteCapabilityValues) const
+    {
+        double minDistance = std::numeric_limits<double>::infinity();
+
+        for (auto& value : discreteCapabilityValues) {
+            auto distance = fitnessDistance(value, value);
+            if (distance < minDistance)
+                minDistance = distance;
+        }
+
+        return minDistance;
+    }
+
</ins><span class="cx">     bool validForRange(ValueType rangeMin, ValueType rangeMax) const
</span><span class="cx">     {
</span><span class="cx">         if (isEmpty())
</span><span class="lines">@@ -277,6 +290,46 @@
</span><span class="cx">         return value;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    ValueType valueForDiscreteCapabilityValues(ValueType current, const Vector<ValueType>& discreteCapabilityValues) const
+    {
+        ValueType value { 0 };
+        std::optional<ValueType> min;
+        std::optional<ValueType> max;
+
+        if (m_exact) {
+            ASSERT(discreteCapabilityValues.contains(m_exact.value()));
+            return m_exact.value();
+        }
+
+        if (m_min) {
+            auto index = discreteCapabilityValues.findMatching([&](ValueType value) { return m_min.value() >= value; });
+            if (index != notFound) {
+                min = value = discreteCapabilityValues[index];
+
+                // If there is no ideal, don't change if minimum is smaller than current.
+                if (!m_ideal && value < current)
+                    value = current;
+            }
+        }
+
+        if (m_max && m_max.value() >= discreteCapabilityValues[0]) {
+            for (auto& discreteValue : discreteCapabilityValues) {
+                if (m_max.value() <= discreteValue)
+                    max = value = discreteValue;
+            }
+        }
+
+        if (m_ideal && discreteCapabilityValues.contains(m_ideal.value())) {
+            value = m_ideal.value();
+            if (max)
+                value = std::min(max.value(), value);
+            if (min)
+                value = std::max(min.value(), value);
+        }
+
+        return value;
+    }
+
</ins><span class="cx">     bool isEmpty() const { return !m_min && !m_max && !m_exact && !m_ideal; }
</span><span class="cx">     bool isMandatory() const { return m_min || m_max || m_exact; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeIncomingVideoSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h  2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h     2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -71,8 +71,6 @@
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><span class="cx"> 
</span><del>-    bool applySize(const IntSize&) final { return true; }
-
</del><span class="cx">     rtc::scoped_refptr<webrtc::VideoTrackInterface> m_videoTrack;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
</span><span class="cx">  * Copyright (C) 2015 Ericsson AB. All rights reserved.
</span><span class="cx">  *
</span><span class="lines">@@ -52,8 +52,6 @@
</span><span class="cx">     , m_type(type)
</span><span class="cx">     , m_name(name)
</span><span class="cx"> {
</span><del>-    // FIXME(147205): Need to implement fitness score for constraints
-
</del><span class="cx">     if (m_id.isEmpty())
</span><span class="cx">         m_id = createCanonicalUUIDString();
</span><span class="cx">     m_persistentID = m_id;
</span><span class="lines">@@ -133,13 +131,12 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RealtimeMediaSource::settingsDidChange()
</del><ins>+void RealtimeMediaSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx"> 
</span><span class="cx">     if (m_pendingSettingsDidChangeNotification)
</span><span class="cx">         return;
</span><del>-
</del><span class="cx">     m_pendingSettingsDidChangeNotification = true;
</span><span class="cx"> 
</span><span class="cx">     scheduleDeferredTask([this] {
</span><span class="lines">@@ -356,6 +353,9 @@
</span><span class="cx">         if (!capabilities.supportsSampleRate())
</span><span class="cx">             return 0;
</span><span class="cx"> 
</span><ins>+        if (auto discreteRates = discreteSampleRates())
+            return downcast<IntConstraint>(constraint).fitnessDistance(*discreteRates);
+
</ins><span class="cx">         auto range = capabilities.sampleRate();
</span><span class="cx">         return downcast<IntConstraint>(constraint).fitnessDistance(range.rangeMin().asInt, range.rangeMax().asInt);
</span><span class="cx">         break;
</span><span class="lines">@@ -366,6 +366,9 @@
</span><span class="cx">         if (!capabilities.supportsSampleSize())
</span><span class="cx">             return 0;
</span><span class="cx"> 
</span><ins>+        if (auto discreteSizes = discreteSampleSizes())
+            return downcast<IntConstraint>(constraint).fitnessDistance(*discreteSizes);
+
</ins><span class="cx">         auto range = capabilities.sampleSize();
</span><span class="cx">         return downcast<IntConstraint>(constraint).fitnessDistance(range.rangeMin().asInt, range.rangeMax().asInt);
</span><span class="cx">         break;
</span><span class="lines">@@ -421,11 +424,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template <typename ValueType>
</span><del>-static void applyNumericConstraint(const NumericConstraint<ValueType>& constraint, ValueType current, ValueType capabilityMin, ValueType capabilityMax, RealtimeMediaSource* source, void (RealtimeMediaSource::*applier)(ValueType))
</del><ins>+static void applyNumericConstraint(const NumericConstraint<ValueType>& constraint, ValueType current, std::optional<Vector<ValueType>> discreteCapabilityValues, ValueType capabilityMin, ValueType capabilityMax, RealtimeMediaSource& source, void (RealtimeMediaSource::*applier)(ValueType))
</ins><span class="cx"> {
</span><ins>+    if (discreteCapabilityValues) {
+        int value = constraint.valueForDiscreteCapabilityValues(current, *discreteCapabilityValues);
+        if (value != current)
+            (source.*applier)(value);
+        return;
+    }
+
</ins><span class="cx">     ValueType value = constraint.valueForCapabilityRange(current, capabilityMin, capabilityMax);
</span><span class="cx">     if (value != current)
</span><del>-        (source->*applier)(value);
</del><ins>+        (source.*applier)(value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::applySizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> frameRate)
</span><span class="lines">@@ -442,35 +452,17 @@
</span><span class="cx"> {
</span><span class="cx">     auto& capabilities = this->capabilities();
</span><span class="cx">     switch (constraint.constraintType()) {
</span><del>-    case MediaConstraintType::Width: {
-        ASSERT(constraint.isInt());
-        if (!capabilities.supportsWidth())
-            return;
-
-        auto range = capabilities.width();
-        applyNumericConstraint(downcast<IntConstraint>(constraint), size().width(), range.rangeMin().asInt, range.rangeMax().asInt, this, &RealtimeMediaSource::setWidth);
</del><ins>+    case MediaConstraintType::Width:
+        ASSERT_NOT_REACHED();
</ins><span class="cx">         break;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    case MediaConstraintType::Height: {
-        ASSERT(constraint.isInt());
-        if (!capabilities.supportsHeight())
-            return;
-
-        auto range = capabilities.height();
-        applyNumericConstraint(downcast<IntConstraint>(constraint), size().height(), range.rangeMin().asInt, range.rangeMax().asInt, this, &RealtimeMediaSource::setHeight);
</del><ins>+    case MediaConstraintType::Height:
+        ASSERT_NOT_REACHED();
</ins><span class="cx">         break;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    case MediaConstraintType::FrameRate: {
-        ASSERT(constraint.isDouble());
-        if (!capabilities.supportsFrameRate())
-            return;
-
-        auto range = capabilities.frameRate();
-        applyNumericConstraint(downcast<DoubleConstraint>(constraint), frameRate(), range.rangeMin().asDouble, range.rangeMax().asDouble, this, &RealtimeMediaSource::setFrameRate);
</del><ins>+    case MediaConstraintType::FrameRate:
+        ASSERT_NOT_REACHED();
</ins><span class="cx">         break;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     case MediaConstraintType::AspectRatio: {
</span><span class="cx">         ASSERT(constraint.isDouble());
</span><span class="lines">@@ -478,7 +470,7 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         auto range = capabilities.aspectRatio();
</span><del>-        applyNumericConstraint(downcast<DoubleConstraint>(constraint), aspectRatio(), range.rangeMin().asDouble, range.rangeMax().asDouble, this, &RealtimeMediaSource::setAspectRatio);
</del><ins>+        applyNumericConstraint(downcast<DoubleConstraint>(constraint), aspectRatio(), { }, range.rangeMin().asDouble, range.rangeMax().asDouble, *this, &RealtimeMediaSource::setAspectRatio);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -488,7 +480,7 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         auto range = capabilities.volume();
</span><del>-        applyNumericConstraint(downcast<DoubleConstraint>(constraint), volume(), range.rangeMin().asDouble, range.rangeMax().asDouble, this, &RealtimeMediaSource::setVolume);
</del><ins>+        applyNumericConstraint(downcast<DoubleConstraint>(constraint), volume(), { }, range.rangeMin().asDouble, range.rangeMax().asDouble, *this, &RealtimeMediaSource::setVolume);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -498,7 +490,7 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         auto range = capabilities.sampleRate();
</span><del>-        applyNumericConstraint(downcast<IntConstraint>(constraint), sampleRate(), range.rangeMin().asInt, range.rangeMax().asInt, this, &RealtimeMediaSource::setSampleRate);
</del><ins>+        applyNumericConstraint(downcast<IntConstraint>(constraint), sampleRate(), discreteSampleRates(), range.rangeMin().asInt, range.rangeMax().asInt, *this, &RealtimeMediaSource::setSampleRate);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -508,7 +500,7 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         auto range = capabilities.sampleSize();
</span><del>-        applyNumericConstraint(downcast<IntConstraint>(constraint), sampleSize(), range.rangeMin().asInt, range.rangeMax().asInt, this, &RealtimeMediaSource::setSampleSize);
</del><ins>+        applyNumericConstraint(downcast<IntConstraint>(constraint), sampleSize(), { }, range.rangeMin().asInt, range.rangeMax().asInt, *this, &RealtimeMediaSource::setSampleSize);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -823,8 +815,6 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: applySizeAndFrameRate should take MediaConstraint* instead of std::optional<> so it can see if a constraint is an exact, min, max,
-    // or ideal, and choose the correct value for properties with non-discreet capabilities when necessary.
</del><span class="cx">     if (width || height || frameRate)
</span><span class="cx">         applySizeAndFrameRate(WTFMove(width), WTFMove(height), WTFMove(frameRate));
</span><span class="cx"> 
</span><span class="lines">@@ -865,11 +855,14 @@
</span><span class="cx">     if (size == m_size)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (!applySize(size))
-        return;
</del><ins>+    OptionSet<RealtimeMediaSourceSettings::Flag> changed;
+    if (m_size.width() != size.width())
+        changed.add(RealtimeMediaSourceSettings::Flag::Width);
+    if (m_size.height() != size.height())
+        changed.add(RealtimeMediaSourceSettings::Flag::Height);
</ins><span class="cx"> 
</span><span class="cx">     m_size = size;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(changed);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setWidth(int width)
</span><span class="lines">@@ -877,15 +870,11 @@
</span><span class="cx">     if (width == m_size.width())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    int height = m_aspectRatio ? width / m_aspectRatio : m_size.height();
-    if (!applySize(IntSize(width, height)))
-        return;
-
</del><span class="cx">     m_size.setWidth(width);
</span><span class="cx">     if (m_aspectRatio)
</span><span class="cx">         m_size.setHeight(width / m_aspectRatio);
</span><span class="cx"> 
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setHeight(int height)
</span><span class="lines">@@ -893,79 +882,85 @@
</span><span class="cx">     if (height == m_size.height())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    int width = m_aspectRatio ? height * m_aspectRatio : m_size.width();
-    if (!applySize(IntSize(width, height)))
-        return;
-
</del><span class="cx">     if (m_aspectRatio)
</span><del>-        m_size.setWidth(width);
</del><ins>+        m_size.setWidth(height * m_aspectRatio);
</ins><span class="cx">     m_size.setHeight(height);
</span><span class="cx"> 
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setFrameRate(double rate)
</span><span class="cx"> {
</span><del>-    if (m_frameRate == rate || !applyFrameRate(rate))
</del><ins>+    if (m_frameRate == rate)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_frameRate = rate;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(RealtimeMediaSourceSettings::Flag::FrameRate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setAspectRatio(double ratio)
</span><span class="cx"> {
</span><del>-    if (m_aspectRatio == ratio || !applyAspectRatio(ratio))
</del><ins>+    if (m_aspectRatio == ratio)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_aspectRatio = ratio;
</span><span class="cx">     m_size.setHeight(m_size.width() / ratio);
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange({ RealtimeMediaSourceSettings::Flag::AspectRatio, RealtimeMediaSourceSettings::Flag::Height });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setFacingMode(RealtimeMediaSourceSettings::VideoFacingMode mode)
</span><span class="cx"> {
</span><del>-    if (m_facingMode == mode || !applyFacingMode(mode))
</del><ins>+    if (m_facingMode == mode)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_facingMode = mode;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(RealtimeMediaSourceSettings::Flag::FacingMode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setVolume(double volume)
</span><span class="cx"> {
</span><del>-    if (m_volume == volume || !applyVolume(volume))
</del><ins>+    if (m_volume == volume)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_volume = volume;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(RealtimeMediaSourceSettings::Flag::Volume);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::setSampleRate(int rate)
</span><span class="cx"> {
</span><del>-    if (m_sampleRate == rate || !applySampleRate(rate))
</del><ins>+    if (m_sampleRate == rate)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_sampleRate = rate;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(RealtimeMediaSourceSettings::Flag::SampleRate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::optional<Vector<int>> RealtimeMediaSource::discreteSampleRates() const
+{
+    return std::nullopt;
+}
+
</ins><span class="cx"> void RealtimeMediaSource::setSampleSize(int size)
</span><span class="cx"> {
</span><del>-    if (m_sampleSize == size || !applySampleSize(size))
</del><ins>+    if (m_sampleSize == size)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_sampleSize = size;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(RealtimeMediaSourceSettings::Flag::SampleSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::optional<Vector<int>> RealtimeMediaSource::discreteSampleSizes() const
+{
+    return std::nullopt;
+}
+
</ins><span class="cx"> void RealtimeMediaSource::setEchoCancellation(bool echoCancellation)
</span><span class="cx"> {
</span><del>-    if (m_echoCancellation == echoCancellation || !applyEchoCancellation(echoCancellation))
</del><ins>+    if (m_echoCancellation == echoCancellation)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_echoCancellation = echoCancellation;
</span><del>-    settingsDidChange();
</del><ins>+    settingsDidChange(RealtimeMediaSourceSettings::Flag::EchoCancellation);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeMediaSource::scheduleDeferredTask(WTF::Function<void()>&& function)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h  2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h     2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2011 Ericsson AB. All rights reserved.
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -169,35 +169,29 @@
</span><span class="cx">     void setHeight(int);
</span><span class="cx">     void setSize(const IntSize&);
</span><span class="cx">     const IntSize& size() const { return m_size; }
</span><del>-    virtual bool applySize(const IntSize&) { return false; }
</del><span class="cx"> 
</span><span class="cx">     double frameRate() const { return m_frameRate; }
</span><span class="cx">     void setFrameRate(double);
</span><del>-    virtual bool applyFrameRate(double) { return false; }
</del><span class="cx"> 
</span><span class="cx">     double aspectRatio() const { return m_aspectRatio; }
</span><span class="cx">     void setAspectRatio(double);
</span><del>-    virtual bool applyAspectRatio(double) { return false; }
</del><span class="cx"> 
</span><span class="cx">     RealtimeMediaSourceSettings::VideoFacingMode facingMode() const { return m_facingMode; }
</span><span class="cx">     void setFacingMode(RealtimeMediaSourceSettings::VideoFacingMode);
</span><del>-    virtual bool applyFacingMode(RealtimeMediaSourceSettings::VideoFacingMode) { return false; }
</del><span class="cx"> 
</span><span class="cx">     double volume() const { return m_volume; }
</span><span class="cx">     void setVolume(double);
</span><del>-    virtual bool applyVolume(double) { return false; }
</del><span class="cx"> 
</span><span class="cx">     int sampleRate() const { return m_sampleRate; }
</span><span class="cx">     void setSampleRate(int);
</span><del>-    virtual bool applySampleRate(int) { return false; }
</del><ins>+    virtual std::optional<Vector<int>> discreteSampleRates() const;
</ins><span class="cx"> 
</span><span class="cx">     int sampleSize() const { return m_sampleSize; }
</span><span class="cx">     void setSampleSize(int);
</span><del>-    virtual bool applySampleSize(int) { return false; }
</del><ins>+    virtual std::optional<Vector<int>> discreteSampleSizes() const;
</ins><span class="cx"> 
</span><span class="cx">     bool echoCancellation() const { return m_echoCancellation; }
</span><span class="cx">     void setEchoCancellation(bool);
</span><del>-    virtual bool applyEchoCancellation(bool) { return false; }
</del><span class="cx"> 
</span><span class="cx">     virtual const RealtimeMediaSourceCapabilities& capabilities() const = 0;
</span><span class="cx">     virtual const RealtimeMediaSourceSettings& settings() const = 0;
</span><span class="lines">@@ -210,7 +204,7 @@
</span><span class="cx">     bool supportsConstraints(const MediaConstraints&, String&);
</span><span class="cx">     bool supportsConstraint(const MediaConstraint&) const;
</span><span class="cx"> 
</span><del>-    virtual void settingsDidChange();
</del><ins>+    virtual void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>);
</ins><span class="cx"> 
</span><span class="cx">     virtual bool isIsolated() const { return false; }
</span><span class="cx"> 
</span><span class="lines">@@ -274,8 +268,8 @@
</span><span class="cx">     double m_fitnessScore { std::numeric_limits<double>::infinity() };
</span><span class="cx">     RealtimeMediaSourceSettings::VideoFacingMode m_facingMode { RealtimeMediaSourceSettings::User};
</span><span class="cx"> 
</span><ins>+    bool m_pendingSettingsDidChangeNotification { false };
</ins><span class="cx">     bool m_echoCancellation { false };
</span><del>-    bool m_pendingSettingsDidChangeNotification { false };
</del><span class="cx">     bool m_isProducingData { false };
</span><span class="cx">     bool m_interrupted { false };
</span><span class="cx">     bool m_captureDidFailed { false };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -69,6 +69,43 @@
</span><span class="cx">     return RealtimeMediaSourceSettings::Unknown;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+OptionSet<RealtimeMediaSourceSettings::Flag> RealtimeMediaSourceSettings::difference(const RealtimeMediaSourceSettings& that) const
+{
+    OptionSet<RealtimeMediaSourceSettings::Flag> difference;
+
+    if (width() != that.width())
+        difference.add(RealtimeMediaSourceSettings::Width);
+    if (height() != that.height())
+        difference.add(RealtimeMediaSourceSettings::Height);
+    if (aspectRatio() != that.aspectRatio())
+        difference.add(RealtimeMediaSourceSettings::AspectRatio);
+    if (frameRate() != that.frameRate())
+        difference.add(RealtimeMediaSourceSettings::FrameRate);
+    if (facingMode() != that.facingMode())
+        difference.add(RealtimeMediaSourceSettings::FacingMode);
+    if (volume() != that.volume())
+        difference.add(RealtimeMediaSourceSettings::Volume);
+    if (sampleRate() != that.sampleRate())
+        difference.add(RealtimeMediaSourceSettings::SampleRate);
+    if (sampleSize() != that.sampleSize())
+        difference.add(RealtimeMediaSourceSettings::SampleSize);
+    if (echoCancellation() != that.echoCancellation())
+        difference.add(RealtimeMediaSourceSettings::EchoCancellation);
+    if (deviceId() != that.deviceId())
+        difference.add(RealtimeMediaSourceSettings::DeviceId);
+    if (groupId() != that.groupId())
+        difference.add(RealtimeMediaSourceSettings::GroupId);
+    if (label() != that.label())
+        difference.add(RealtimeMediaSourceSettings::Label);
+    if (displaySurface() != that.displaySurface())
+        difference.add(RealtimeMediaSourceSettings::DisplaySurface);
+    if (logicalSurface() != that.logicalSurface())
+        difference.add(RealtimeMediaSourceSettings::LogicalSurface);
+
+    return difference;
+}
+
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(MEDIA_STREAM)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.h  2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.h     2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "RealtimeMediaSourceSupportedConstraints.h"
</span><span class="cx"> #include <wtf/EnumTraits.h>
</span><ins>+#include <wtf/OptionSet.h>
</ins><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx"> #include <wtf/text/AtomicString.h>
</span><span class="lines">@@ -43,6 +44,27 @@
</span><span class="cx">     static String facingMode(RealtimeMediaSourceSettings::VideoFacingMode);
</span><span class="cx">     static RealtimeMediaSourceSettings::VideoFacingMode videoFacingModeEnum(const String&);
</span><span class="cx"> 
</span><ins>+    enum Flag {
+        Width = 1 << 0,
+        Height = 1 << 1,
+        AspectRatio = 1 << 2,
+        FrameRate = 1 << 3,
+        FacingMode = 1 << 4,
+        Volume = 1 << 5,
+        SampleRate = 1 << 6,
+        SampleSize = 1 << 7,
+        EchoCancellation = 1 << 8,
+        DeviceId = 1 << 9,
+        GroupId = 1 << 10,
+        Label = 1 << 11,
+        DisplaySurface = 1 << 12,
+        LogicalSurface = 1 << 13,
+    };
+
+    static constexpr OptionSet<Flag> allFlags() { return { Width, Height, AspectRatio, FrameRate, FacingMode, Volume, SampleRate, SampleSize, EchoCancellation, DeviceId, GroupId, Label, DisplaySurface, LogicalSurface }; }
+
+    WEBCORE_EXPORT OptionSet<RealtimeMediaSourceSettings::Flag> difference(const RealtimeMediaSourceSettings&) const;
+
</ins><span class="cx">     explicit RealtimeMediaSourceSettings() = default;
</span><span class="cx"> 
</span><span class="cx">     bool supportsWidth() const { return m_supportedConstraints.supportsWidth(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -125,17 +125,6 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RealtimeVideoSource::applySize(const IntSize& size)
-{
-    IntSize supportedSize = bestSupportedCaptureSizeForWidthAndHeight(size.width(), size.height());
-    if (supportedSize.isEmpty()) {
-        LOG(Media, "RealtimeVideoSource::applySize(%p), unable find or set preset for width: %i, height: %i", this, size.width(), size.height());
-        return false;
-    }
-
-    return true;
-}
-
</del><span class="cx"> void RealtimeVideoSource::applySizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> frameRate)
</span><span class="cx"> {
</span><span class="cx">     if (width || height) {
</span><span class="lines">@@ -168,11 +157,6 @@
</span><span class="cx">     videoSampleAvailable(sample);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RealtimeVideoSource::applyFrameRate(double rate)
-{
-    return supportsFrameRate(rate);
-}
-
</del><span class="cx"> bool RealtimeVideoSource::supportsFrameRate(double frameRate)
</span><span class="cx"> {
</span><span class="cx">     double epsilon = 0.001;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeVideoSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h  2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h     2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -46,8 +46,6 @@
</span><span class="cx">     void prepareToProduceData();
</span><span class="cx">     bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
</span><span class="cx">     void applySizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
</span><del>-    bool applySize(const IntSize&) override;
-    bool applyFrameRate(double) final;
</del><span class="cx"> 
</span><span class="cx">     void setSupportedFrameRates(Vector<double>&&);
</span><span class="cx">     void setSupportedCaptureSizes(const Vector<IntSize>&& sizes) { m_supportedCaptureSizes = sizes; }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamgstreamerGStreamerAudioCaptureSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp      2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp 2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -172,9 +172,12 @@
</span><span class="cx">     return m_capabilities.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GStreamerAudioCaptureSource::applySampleRate(int sampleRate)
</del><ins>+void GStreamerAudioCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><del>-    return m_capturer->setSampleRate(sampleRate);
</del><ins>+    if (settings.contains(RealtimeMediaSourceSettings::Flag::SampleRate))
+        m_capturer->setSampleRate(sampleRate());
+
+    RealtimeMediaSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const RealtimeMediaSourceSettings& GStreamerAudioCaptureSource::settings() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamgstreamerGStreamerAudioCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.h   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -50,9 +50,8 @@
</span><span class="cx">     mutable std::optional<RealtimeMediaSourceSettings> m_currentSettings;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    bool applySampleRate(int) final;
</del><span class="cx">     bool isCaptureSource() const final { return true; }
</span><del>-    bool applyVolume(double) final { return true; }
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr<GStreamerAudioCapturer> m_capturer;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamgstreamerGStreamerVideoCaptureSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp      2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp 2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -107,20 +107,16 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GStreamerVideoCaptureSource::applySize(const IntSize &size)
</del><ins>+void GStreamerVideoCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><del>-    m_capturer->setSize(size.width(), size.height());
</del><ins>+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }))
+        m_capturer->setSize(size().width(), size().height());
+    if (settings.contains(RealtimeMediaSourceSettings::Flag::FrameRate))
+        m_capturer->setFrameRate(frameRate());
</ins><span class="cx"> 
</span><del>-    return true;
</del><ins>+    RealtimeMediaSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GStreamerVideoCaptureSource::applyFrameRate(double framerate)
-{
-    m_capturer->setFrameRate(framerate);
-
-    return true;
-}
-
</del><span class="cx"> void GStreamerVideoCaptureSource::startProducingData()
</span><span class="cx"> {
</span><span class="cx">     m_capturer->setupPipeline();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamgstreamerGStreamerVideoCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.h   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -37,7 +37,6 @@
</span><span class="cx">     GstElement* pipeline() { return m_capturer->pipeline(); }
</span><span class="cx">     GStreamerCapturer* capturer() { return m_capturer.get(); }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> protected:
</span><span class="cx">     GStreamerVideoCaptureSource(const String& deviceID, const String& name, const gchar * source_factory);
</span><span class="cx">     GStreamerVideoCaptureSource(GStreamerCaptureDevice);
</span><span class="lines">@@ -52,9 +51,7 @@
</span><span class="cx">     static GstFlowReturn newSampleCallback(GstElement*, GStreamerVideoCaptureSource*);
</span><span class="cx"> 
</span><span class="cx">     bool isCaptureSource() const final { return true; }
</span><del>-    bool applySize(const IntSize&) final;
-    bool applyFrameRate(double) final;
-    bool applyAspectRatio(double) final { return true; }
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr<GStreamerVideoCapturer> m_capturer;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h     2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h        2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -73,13 +73,12 @@
</span><span class="cx"> 
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     void applySizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
</span><del>-    bool applySize(const IntSize&) final;
-    bool applyFrameRate(double) final;
</del><ins>+    void setFrameRate(double);
</ins><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><span class="cx">     void startProducingData() final;
</span><span class="cx">     void stopProducingData() final;
</span><span class="cx">     bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
</span><del>-    void settingsDidChange() final;
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
</ins><span class="cx">     void monitorOrientation(OrientationNotifier&) final;
</span><span class="cx">     void beginConfiguration() final;
</span><span class="cx">     void commitConfiguration() final;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVVideoCaptureSourcemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm    2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm       2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -270,10 +270,10 @@
</span><span class="cx">         [m_session commitConfiguration];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AVVideoCaptureSource::settingsDidChange()
</del><ins>+void AVVideoCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><span class="cx">     m_currentSettings = std::nullopt;
</span><del>-    RealtimeMediaSource::settingsDidChange();
</del><ins>+    RealtimeMediaSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const RealtimeMediaSourceSettings& AVVideoCaptureSource::settings() const
</span><span class="lines">@@ -357,17 +357,6 @@
</span><span class="cx">     return *m_capabilities;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool AVVideoCaptureSource::applySize(const IntSize& size)
-{
-    NSString *preset = bestSessionPresetForVideoDimensions(size.width(), size.height());
-    if (!preset || ![session() canSetSessionPreset:preset]) {
-        LOG(Media, "AVVideoCaptureSource::applySize(%p), unable find or set preset for width: %i, height: %i", this, size.width(), size.height());
-        return false;
-    }
-
-    return setPreset(preset);
-}
-
</del><span class="cx"> IntSize AVVideoCaptureSource::sizeForPreset(NSString* preset)
</span><span class="cx"> {
</span><span class="cx">     if (!preset)
</span><span class="lines">@@ -405,7 +394,7 @@
</span><span class="cx">         [m_videoOutput setVideoSettings:settingsDictionary];
</span><span class="cx"> #endif
</span><span class="cx">     } @catch(NSException *exception) {
</span><del>-        LOG(Media, "AVVideoCaptureSource::applySize(%p), exception thrown configuring device: <%s> %s", this, [[exception name] UTF8String], [[exception reason] UTF8String]);
</del><ins>+        LOG(Media, "AVVideoCaptureSource::setPreset(%p), exception thrown configuring device: <%s> %s", this, [[exception name] UTF8String], [[exception reason] UTF8String]);
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -412,7 +401,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool AVVideoCaptureSource::applyFrameRate(double rate)
</del><ins>+void AVVideoCaptureSource::setFrameRate(double rate)
</ins><span class="cx"> {
</span><span class="cx">     using namespace PAL;
</span><span class="cx">     double epsilon = 0.00001;
</span><span class="lines">@@ -425,8 +414,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!bestFrameRateRange || !isFrameRateSupported(rate)) {
</span><del>-        LOG(Media, "AVVideoCaptureSource::applyFrameRate(%p), frame rate %f not supported by video device", this, rate);
-        return false;
</del><ins>+        LOG(Media, "AVVideoCaptureSource::setFrameRate(%p), frame rate %f not supported by video device", this, rate);
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     NSError *error = nil;
</span><span class="lines">@@ -442,17 +431,17 @@
</span><span class="cx">             [device() unlockForConfiguration];
</span><span class="cx">         }
</span><span class="cx">     } @catch(NSException *exception) {
</span><del>-        LOG(Media, "AVVideoCaptureSource::applyFrameRate(%p), exception thrown configuring device: <%s> %s", this, [[exception name] UTF8String], [[exception reason] UTF8String]);
-        return false;
</del><ins>+        LOG(Media, "AVVideoCaptureSource::setFrameRate(%p), exception thrown configuring device: <%s> %s", this, [[exception name] UTF8String], [[exception reason] UTF8String]);
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (error) {
</span><del>-        LOG(Media, "AVVideoCaptureSource::applyFrameRate(%p), failed to lock video device for configuration: %s", this, [[error localizedDescription] UTF8String]);
-        return false;
</del><ins>+        LOG(Media, "AVVideoCaptureSource::setFrameRate(%p), failed to lock video device for configuration: %s", this, [[error localizedDescription] UTF8String]);
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LOG(Media, "AVVideoCaptureSource::applyFrameRate(%p) - set frame rate range to %f", this, rate);
-    return true;
</del><ins>+    LOG(Media, "AVVideoCaptureSource::setFrameRate(%p) - set frame rate range to %f", this, rate);
+    return;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void AVVideoCaptureSource::applySizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> frameRate)
</span><span class="lines">@@ -461,7 +450,7 @@
</span><span class="cx">         setPreset(bestSessionPresetForVideoDimensions(WTFMove(width), WTFMove(height)));
</span><span class="cx"> 
</span><span class="cx">     if (frameRate)
</span><del>-        applyFrameRate(frameRate.value());
</del><ins>+        setFrameRate(frameRate.value());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline int sensorOrientation(AVCaptureVideoOrientation videoOrientation)
</span><span class="lines">@@ -627,10 +616,15 @@
</span><span class="cx">         std::swap(dimensions.width, dimensions.height);
</span><span class="cx"> 
</span><span class="cx">     if (dimensions.width != m_width || dimensions.height != m_height) {
</span><ins>+        OptionSet<RealtimeMediaSourceSettings::Flag> changed;
+        if (m_width != dimensions.width)
+            changed.add(RealtimeMediaSourceSettings::Flag::Width);
+        if (m_height != dimensions.height)
+            changed.add(RealtimeMediaSourceSettings::Flag::Height);
+
</ins><span class="cx">         m_width = dimensions.width;
</span><span class="cx">         m_height = dimensions.height;
</span><del>-
-        settingsDidChange();
</del><ins>+        settingsDidChange(changed);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     videoSampleAvailable(MediaSampleAVFObjC::create(m_buffer.get(), m_sampleRotation, [connection isVideoMirrored]));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp 2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp    2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -876,41 +876,21 @@
</span><span class="cx">     return m_currentSettings.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CoreAudioCaptureSource::settingsDidChange()
</del><ins>+void CoreAudioCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><del>-    m_currentSettings = std::nullopt;
-    RealtimeMediaSource::settingsDidChange();
-}
-
-bool CoreAudioCaptureSource::applySampleRate(int sampleRate)
-{
-    // FIXME: We should be able to describe sample rate as a discreet range constraint so that we only enter here with values that can be applied.
-    switch (sampleRate) {
-    case 8000:
-    case 16000:
-    case 32000:
-    case 44100:
-    case 48000:
-    case 96000:
-        break;
-    default:
-        return false;
</del><ins>+    if (settings.contains(RealtimeMediaSourceSettings::Flag::EchoCancellation)) {
+        CoreAudioSharedUnit::singleton().setEnableEchoCancellation(echoCancellation());
+        scheduleReconfiguration();
</ins><span class="cx">     }
</span><ins>+    if (settings.contains(RealtimeMediaSourceSettings::Flag::SampleRate)) {
+        CoreAudioSharedUnit::singleton().setSampleRate(sampleRate());
+        scheduleReconfiguration();
+    }
</ins><span class="cx"> 
</span><del>-    CoreAudioSharedUnit::singleton().setSampleRate(sampleRate);
-
-    scheduleReconfiguration();
-    return true;
</del><ins>+    m_currentSettings = std::nullopt;
+    RealtimeMediaSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CoreAudioCaptureSource::applyEchoCancellation(bool enableEchoCancellation)
-{
-    CoreAudioSharedUnit::singleton().setEnableEchoCancellation(enableEchoCancellation);
-
-    scheduleReconfiguration();
-    return true;
-}
-
</del><span class="cx"> void CoreAudioCaptureSource::scheduleReconfiguration()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h   2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h      2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -84,13 +84,11 @@
</span><span class="cx">     void startProducingData() final;
</span><span class="cx">     void stopProducingData() final;
</span><span class="cx"> 
</span><del>-    bool applyVolume(double) final { return true; }
-    bool applySampleRate(int) final;
-    bool applyEchoCancellation(bool) final;
</del><ins>+    std::optional<Vector<int>> discreteSampleRates() const final { return { { 8000, 16000, 32000, 44100, 48000, 96000 } }; }
</ins><span class="cx"> 
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><del>-    void settingsDidChange() final;
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
</ins><span class="cx"> 
</span><span class="cx">     bool interrupted() const final;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacDisplayCaptureSourceCocoacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp      2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp 2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -98,10 +98,17 @@
</span><span class="cx">     return m_currentSettings.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DisplayCaptureSourceCocoa::settingsDidChange()
</del><ins>+void DisplayCaptureSourceCocoa::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><ins>+    if (settings.contains(RealtimeMediaSourceSettings::Flag::FrameRate) && m_timer.isActive())
+        m_timer.startRepeating(1_s / frameRate());
+
+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }))
+        m_bufferAttributes = nullptr;
+
</ins><span class="cx">     m_currentSettings = std::nullopt;
</span><del>-    RealtimeMediaSource::settingsDidChange();
</del><ins>+
+    RealtimeMediaSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DisplayCaptureSourceCocoa::startProducingData()
</span><span class="lines">@@ -111,7 +118,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     m_startTime = MonotonicTime::now();
</span><del>-    m_timer.startRepeating(1_ms * lround(1000 / frameRate()));
</del><ins>+    m_timer.startRepeating(1_s / frameRate());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DisplayCaptureSourceCocoa::stopProducingData()
</span><span class="lines">@@ -129,23 +136,6 @@
</span><span class="cx">     return m_elapsedTime + (MonotonicTime::now() - m_startTime);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool DisplayCaptureSourceCocoa::applySize(const IntSize& newSize)
-{
-    if (size() == newSize)
-        return true;
-
-    m_bufferAttributes = nullptr;
-    return true;
-}
-
-bool DisplayCaptureSourceCocoa::applyFrameRate(double rate)
-{
-    if (m_timer.isActive())
-        m_timer.startRepeating(1_ms * lround(1000 / rate));
-
-    return true;
-}
-
</del><span class="cx"> void DisplayCaptureSourceCocoa::emitFrame()
</span><span class="cx"> {
</span><span class="cx">     if (muted())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacDisplayCaptureSourceCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -54,8 +54,6 @@
</span><span class="cx">     void stopProducingData() override;
</span><span class="cx"> 
</span><span class="cx">     Seconds elapsedTime();
</span><del>-    bool applyFrameRate(double) override;
-    bool applySize(const IntSize&) override;
</del><span class="cx"> 
</span><span class="cx">     RetainPtr<CMSampleBufferRef> sampleBufferFromPixelBuffer(CVPixelBufferRef);
</span><span class="cx"> #if HAVE(IOSURFACE)
</span><span class="lines">@@ -62,6 +60,8 @@
</span><span class="cx">     RetainPtr<CVPixelBufferRef> pixelBufferFromIOSurface(IOSurfaceRef);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override;
+
</ins><span class="cx"> private:
</span><span class="cx"> 
</span><span class="cx">     bool isCaptureSource() const final { return true; }
</span><span class="lines">@@ -68,7 +68,6 @@
</span><span class="cx"> 
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><del>-    void settingsDidChange() final;
</del><span class="cx"> 
</span><span class="cx">     void emitFrame();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h       2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h  2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -50,8 +50,8 @@
</span><span class="cx">     friend class MockRealtimeAudioSource;
</span><span class="cx">     MockRealtimeAudioSourceMac(const String& deviceID, const String& name);
</span><span class="cx"> 
</span><del>-    bool applySampleRate(int) final;
-    bool applySampleSize(int) final { return false; }
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
+    std::optional<Vector<int>> discreteSampleRates() const final { return { { 44100, 48000 } }; }
</ins><span class="cx"> 
</span><span class="cx">     void emitSampleBuffers(uint32_t);
</span><span class="cx">     void render(Seconds) final;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm      2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm 2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -158,30 +158,27 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MockRealtimeAudioSourceMac::applySampleRate(int sampleRate)
</del><ins>+void MockRealtimeAudioSourceMac::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><del>-    if (sampleRate < 44100 || sampleRate > 48000)
-        return false;
</del><ins>+    if (settings.contains(RealtimeMediaSourceSettings::Flag::SampleRate)) {
+        m_formatDescription = nullptr;
+        m_audioBufferList = nullptr;
</ins><span class="cx"> 
</span><del>-    if (sampleRate == this->sampleRate())
-        return true;
</del><ins>+        auto rate = sampleRate();
+        size_t sampleCount = 2 * rate;
</ins><span class="cx"> 
</span><del>-    m_formatDescription = nullptr;
-    m_audioBufferList = nullptr;
</del><ins>+        m_bipBopBuffer.grow(sampleCount);
+        m_bipBopBuffer.fill(0);
</ins><span class="cx"> 
</span><del>-    size_t sampleCount = 2 * sampleRate;
</del><ins>+        size_t bipBopSampleCount = ceil(BipBopDuration * rate);
+        size_t bipStart = 0;
+        size_t bopStart = rate;
</ins><span class="cx"> 
</span><del>-    m_bipBopBuffer.grow(sampleCount);
-    m_bipBopBuffer.fill(0);
</del><ins>+        addHum(BipBopVolume, BipFrequency, rate, 0, m_bipBopBuffer.data() + bipStart, bipBopSampleCount);
+        addHum(BipBopVolume, BopFrequency, rate, 0, m_bipBopBuffer.data() + bopStart, bipBopSampleCount);
+    }
</ins><span class="cx"> 
</span><del>-    size_t bipBopSampleCount = ceil(BipBopDuration * sampleRate);
-    size_t bipStart = 0;
-    size_t bopStart = sampleRate;
-
-    addHum(BipBopVolume, BipFrequency, sampleRate, 0, m_bipBopBuffer.data() + bipStart, bipBopSampleCount);
-    addHum(BipBopVolume, BopFrequency, sampleRate, 0, m_bipBopBuffer.data() + bopStart, bipBopSampleCount);
-
-    return true;
</del><ins>+    MockRealtimeAudioSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h       2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h  2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> 
</span><span class="cx">     PlatformLayer* platformLayer() const;
</span><span class="cx">     void updateSampleBuffer() final;
</span><del>-    bool applySize(const IntSize&) final;
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
</ins><span class="cx"> 
</span><span class="cx">     void orientationChanged(int orientation) final;
</span><span class="cx">     void monitorOrientation(OrientationNotifier&) final;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm      2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm 2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -154,13 +154,11 @@
</span><span class="cx">     dispatchMediaSampleToObservers(MediaSampleAVFObjC::create(sampleBuffer.get(), m_deviceOrientation));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MockRealtimeVideoSourceMac::applySize(const IntSize& newSize)
</del><ins>+void MockRealtimeVideoSourceMac::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><del>-    if (!MockRealtimeVideoSource::applySize(newSize))
-        return false;
-
-    m_bufferPool = nullptr;
-    return true;
</del><ins>+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }))
+        m_bufferPool = nullptr;
+    MockRealtimeVideoSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MockRealtimeVideoSourceMac::orientationChanged(int orientation)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeIncomingVideoSourceCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm        2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm   2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -173,9 +173,15 @@
</span><span class="cx"> {
</span><span class="cx">     m_buffer = sample;
</span><span class="cx">     if (width != m_currentSettings.width() || height != m_currentSettings.height()) {
</span><ins>+        OptionSet<RealtimeMediaSourceSettings::Flag> changed;
+        if (width != m_currentSettings.width())
+            changed.add(RealtimeMediaSourceSettings::Flag::Width);
+        if (height != m_currentSettings.height())
+            changed.add(RealtimeMediaSourceSettings::Flag::Height);
+
</ins><span class="cx">         m_currentSettings.setWidth(width);
</span><span class="cx">         m_currentSettings.setHeight(height);
</span><del>-        settingsDidChange();
</del><ins>+        settingsDidChange(changed);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     videoSampleAvailable(MediaSampleAVFObjC::create(sample, rotation));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacScreenDisplayCaptureSourceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h    2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h       2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -59,8 +59,7 @@
</span><span class="cx">     void generateFrame() final;
</span><span class="cx">     void startProducingData() final;
</span><span class="cx">     void stopProducingData() final;
</span><del>-    bool applySize(const IntSize&) final;
-    bool applyFrameRate(double) final;
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
</ins><span class="cx">     void commitConfiguration() final;
</span><span class="cx"> 
</span><span class="cx">     bool createDisplayStream();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacScreenDisplayCaptureSourceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm   2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm      2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -253,21 +253,12 @@
</span><span class="cx">     m_isRunning = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ScreenDisplayCaptureSourceMac::applySize(const IntSize& newSize)
</del><ins>+void ScreenDisplayCaptureSourceMac::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><del>-    if (!DisplayCaptureSourceCocoa::applySize(newSize))
-        return false;
-
-    m_displayStream = nullptr;
-    return true;
-}
-
-bool ScreenDisplayCaptureSourceMac::applyFrameRate(double rate)
-{
-    if (frameRate() != rate)
</del><ins>+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height, RealtimeMediaSourceSettings::Flag::FrameRate }))
</ins><span class="cx">         m_displayStream = nullptr;
</span><span class="cx"> 
</span><del>-    return DisplayCaptureSourceCocoa::applyFrameRate(rate);
</del><ins>+    return DisplayCaptureSourceCocoa::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScreenDisplayCaptureSourceMac::commitConfiguration()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp   2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp      2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -134,10 +134,10 @@
</span><span class="cx">     return m_capabilities.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MockRealtimeAudioSource::settingsDidChange()
</del><ins>+void MockRealtimeAudioSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><span class="cx">     m_currentSettings = std::nullopt;
</span><del>-    RealtimeMediaSource::settingsDidChange();
</del><ins>+    RealtimeMediaSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MockRealtimeAudioSource::startProducingData()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h     2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h        2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -54,18 +54,13 @@
</span><span class="cx">     void stopProducingData() final;
</span><span class="cx"> 
</span><span class="cx">     virtual void render(Seconds) { }
</span><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override;
</ins><span class="cx"> 
</span><span class="cx">     static Seconds renderInterval() { return 60_ms; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    bool applyVolume(double) override { return true; }
-    bool applySampleRate(int) override { return true; }
-    bool applySampleSize(int) override { return true; }
-    bool applyEchoCancellation(bool) override { return true; }
-
</del><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><del>-    void settingsDidChange() final;
</del><span class="cx"> 
</span><span class="cx">     void tick();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp   2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp      2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -192,10 +192,17 @@
</span><span class="cx">     return m_currentSettings.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MockRealtimeVideoSource::settingsDidChange()
</del><ins>+void MockRealtimeVideoSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
</ins><span class="cx"> {
</span><span class="cx">     m_currentSettings = std::nullopt;
</span><del>-    RealtimeVideoSource::settingsDidChange();
</del><ins>+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height })) {
+        m_baseFontSize = size().height() * .08;
+        m_bipBopFontSize = m_baseFontSize * 2.5;
+        m_statsFontSize = m_baseFontSize * .5;
+        m_imageBuffer = nullptr;
+    }
+
+    RealtimeVideoSource::settingsDidChange(settings);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MockRealtimeVideoSource::startCaptureTimer()
</span><span class="lines">@@ -225,19 +232,6 @@
</span><span class="cx">     return m_elapsedTime + (MonotonicTime::now() - m_startTime);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MockRealtimeVideoSource::applySize(const IntSize& size)
-{
-    if (!RealtimeVideoSource::applySize(size))
-        return false;
-
-    m_baseFontSize = size.height() * .08;
-    m_bipBopFontSize = m_baseFontSize * 2.5;
-    m_statsFontSize = m_baseFontSize * .5;
-    m_imageBuffer = nullptr;
-
-    return true;
-}
-
</del><span class="cx"> void MockRealtimeVideoSource::drawAnimation(GraphicsContext& context)
</span><span class="cx"> {
</span><span class="cx">     float radius = size().width() * .09;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeVideoSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h     2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h        2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -60,12 +60,11 @@
</span><span class="cx">     ImageBuffer* imageBuffer() const;
</span><span class="cx"> 
</span><span class="cx">     Seconds elapsedTime();
</span><del>-    bool applySize(const IntSize&) override;
</del><ins>+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><del>-    void settingsDidChange() final;
</del><span class="cx"> 
</span><span class="cx">     void startProducingData() final;
</span><span class="cx">     void stopProducingData() final;
</span><span class="lines">@@ -74,9 +73,6 @@
</span><span class="cx">     void drawText(GraphicsContext&);
</span><span class="cx">     void drawBoxes(GraphicsContext&);
</span><span class="cx"> 
</span><del>-    bool applyFacingMode(RealtimeMediaSourceSettings::VideoFacingMode) override { return true; }
-    bool applyAspectRatio(double) override { return true; }
-
</del><span class="cx">     bool isCaptureSource() const final { return true; }
</span><span class="cx"> 
</span><span class="cx">     void generateFrame();
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebKit/ChangeLog       2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2018-09-05  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Simplify logic when changing RealtimeMediaSource settings
+        https://bugs.webkit.org/show_bug.cgi?id=189284
+        <rdar://problem/44117948>
+
+        Reviewed by Youenn Fablet.
+
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::Source::setSettings):
+
</ins><span class="cx"> 2018-09-04  Frederic Wang  <fwang@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Add basic support for ScrollIntoViewOptions
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcesscocoaUserMediaCaptureManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (235669 => 235670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp 2018-09-05 15:22:15 UTC (rev 235669)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp    2018-09-05 15:56:44 UTC (rev 235670)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -74,8 +74,9 @@
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final { return m_settings; }
</span><span class="cx">     void setSettings(RealtimeMediaSourceSettings&& settings)
</span><span class="cx">     {
</span><ins>+        auto changed = m_settings.difference(settings);
</ins><span class="cx">         m_settings = WTFMove(settings);
</span><del>-        settingsDidChange();
</del><ins>+        settingsDidChange(changed);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     const CAAudioStreamDescription& description() const { return m_description; }
</span></span></pre>
</div>
</div>

</body>
</html>