[MediaStream] Clean up RealtimeMediaSource settings change handling
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Sep 2018 14:32:15 +0000 (14:32 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Sep 2018 14:32:15 +0000 (14:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189998
<rdar://problem/44797884>

Reviewed by Youenn Fablet.

Source/WebCore:

No new tests, updated webrtc/video-disabled-black.html.

* Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
(WebCore::CanvasCaptureMediaStreamTrack::Source::Source):
(WebCore::CanvasCaptureMediaStreamTrack::Source::settings):
(WebCore::CanvasCaptureMediaStreamTrack::Source::settingsDidChange):
(WebCore::CanvasCaptureMediaStreamTrack::Source::canvasResized):
* Modules/mediastream/CanvasCaptureMediaStreamTrack.h:
* platform/mediastream/RealtimeIncomingVideoSource.cpp:
(WebCore::RealtimeIncomingVideoSource::RealtimeIncomingVideoSource):
(WebCore::RealtimeIncomingVideoSource::settings):
(WebCore::RealtimeIncomingVideoSource::settingsDidChange):
* platform/mediastream/RealtimeIncomingVideoSource.h:
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::settingsDidChange):
(WebCore::RealtimeMediaSource::notifySettingsDidChangeObservers):
(WebCore::RealtimeMediaSource::setSize):
(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/gstreamer/GStreamerAudioCaptureSource.cpp:
(WebCore::GStreamerAudioCaptureSource::settingsDidChange):
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
(WebCore::GStreamerVideoCaptureSource::settingsDidChange):
* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::settingsDidChange):
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioCaptureSource::settingsDidChange):
* platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
(WebCore::DisplayCaptureSourceCocoa::settingsDidChange):
* platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
(WebCore::RealtimeIncomingVideoSourceCocoa::processNewSample):
* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::settingsDidChange):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::settingsDidChange):

Source/WebKit:

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

LayoutTests:

* webrtc/video-disabled-black.html:

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/video-disabled-black.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.h
Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp
Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm
Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp
Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp

index dfc721d..722daf4 100644 (file)
@@ -1,3 +1,13 @@
+2018-09-30  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Clean up RealtimeMediaSource settings change handling
+        https://bugs.webkit.org/show_bug.cgi?id=189998
+        <rdar://problem/44797884>
+
+        Reviewed by Youenn Fablet.
+
+        * webrtc/video-disabled-black.html:
+
 2018-09-29  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r236631.
index a825ea2..be1085e 100644 (file)
@@ -7,7 +7,7 @@
         <script src="../resources/testharnessreport.js"></script>
     </head>
     <body>
-        <video id="video" autoplay=""></video>
+        <video id="video" autoplay playsinline></video>
         <canvas id="canvas" width="640" height="480"></canvas>
         <script src ="routines.js"></script>
         <script>
@@ -21,6 +21,9 @@ canvas = document.getElementById("canvas");
 function testImage()
 {
     try {
+        if (!video.videoWidth || !video.videoHeight)
+            throw `Video size invalid: ${video.videoWidth}x${video.videoHeight}`;
+
         canvas.width = video.videoWidth;
         canvas.height = video.videoHeight;
         canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
@@ -44,7 +47,7 @@ function testStream(stream)
         setTimeout(() => {
             testImage();
         }, 0);
-    }, 500);
+    }, 2000);
 }
 
 var finishTest, errorTest;
index 2fa2185..2f08fab 100644 (file)
@@ -1,5 +1,55 @@
 2018-09-30  Eric Carlson  <eric.carlson@apple.com>
 
+        [MediaStream] Clean up RealtimeMediaSource settings change handling
+        https://bugs.webkit.org/show_bug.cgi?id=189998
+        <rdar://problem/44797884>
+
+        Reviewed by Youenn Fablet.
+
+        No new tests, updated webrtc/video-disabled-black.html.
+
+        * Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
+        (WebCore::CanvasCaptureMediaStreamTrack::Source::Source):
+        (WebCore::CanvasCaptureMediaStreamTrack::Source::settings):
+        (WebCore::CanvasCaptureMediaStreamTrack::Source::settingsDidChange):
+        (WebCore::CanvasCaptureMediaStreamTrack::Source::canvasResized):
+        * Modules/mediastream/CanvasCaptureMediaStreamTrack.h:
+        * platform/mediastream/RealtimeIncomingVideoSource.cpp:
+        (WebCore::RealtimeIncomingVideoSource::RealtimeIncomingVideoSource):
+        (WebCore::RealtimeIncomingVideoSource::settings):
+        (WebCore::RealtimeIncomingVideoSource::settingsDidChange):
+        * platform/mediastream/RealtimeIncomingVideoSource.h:
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::settingsDidChange):
+        (WebCore::RealtimeMediaSource::notifySettingsDidChangeObservers):
+        (WebCore::RealtimeMediaSource::setSize):
+        (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/gstreamer/GStreamerAudioCaptureSource.cpp:
+        (WebCore::GStreamerAudioCaptureSource::settingsDidChange):
+        * platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
+        (WebCore::GStreamerVideoCaptureSource::settingsDidChange):
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::settingsDidChange):
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::CoreAudioCaptureSource::settingsDidChange):
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
+        (WebCore::DisplayCaptureSourceCocoa::settingsDidChange):
+        * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
+        (WebCore::RealtimeIncomingVideoSourceCocoa::processNewSample):
+        * platform/mock/MockRealtimeAudioSource.cpp:
+        (WebCore::MockRealtimeAudioSource::settingsDidChange):
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::settingsDidChange):
+
+2018-09-30  Eric Carlson  <eric.carlson@apple.com>
+
         [MediaStream] Use display-specific capture factories
         https://bugs.webkit.org/show_bug.cgi?id=190043
         <rdar://problem/44834412>
index 8581b4f..78f9fb2 100644 (file)
@@ -72,12 +72,6 @@ CanvasCaptureMediaStreamTrack::Source::Source(HTMLCanvasElement& canvas, std::op
     , m_canvasChangedTimer(*this, &Source::captureCanvas)
     , m_canvas(&canvas)
 {
-    m_settings.setWidth(canvas.width());
-    m_settings.setHeight(canvas.height());
-    RealtimeMediaSourceSupportedConstraints constraints;
-    constraints.setSupportsWidth(true);
-    constraints.setSupportsHeight(true);
-    m_settings.setSupportedConstraints(constraints);
 }
 
 void CanvasCaptureMediaStreamTrack::Source::startProducingData()
@@ -115,20 +109,34 @@ void CanvasCaptureMediaStreamTrack::Source::canvasDestroyed(CanvasBase& canvas)
     m_canvas = nullptr;
 }
 
-void CanvasCaptureMediaStreamTrack::Source::canvasResized(CanvasBase& canvas)
+const RealtimeMediaSourceSettings& CanvasCaptureMediaStreamTrack::Source::settings()
 {
-    ASSERT_UNUSED(canvas, m_canvas == &canvas);
+    if (m_currentSettings)
+        return m_currentSettings.value();
+
+    RealtimeMediaSourceSupportedConstraints constraints;
+    constraints.setSupportsWidth(true);
+    constraints.setSupportsHeight(true);
+
+    RealtimeMediaSourceSettings settings;
+    settings.setWidth(m_canvas->width());
+    settings.setHeight(m_canvas->height());
+    settings.setSupportedConstraints(constraints);
 
-    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);
+    m_currentSettings = WTFMove(settings);
+    return m_currentSettings.value();
+}
 
-    m_settings.setWidth(m_canvas->width());
-    m_settings.setHeight(m_canvas->height());
+void CanvasCaptureMediaStreamTrack::Source::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
+{
+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }))
+        m_currentSettings = std::nullopt;
+}
 
-    settingsDidChange(changed);
+void CanvasCaptureMediaStreamTrack::Source::canvasResized(CanvasBase& canvas)
+{
+    ASSERT_UNUSED(canvas, m_canvas == &canvas);
+    setSize(IntSize(m_canvas->width(), m_canvas->height()));
 }
 
 void CanvasCaptureMediaStreamTrack::Source::canvasChanged(CanvasBase& canvas, const FloatRect&)
index b37c9c5..87d725b 100644 (file)
@@ -66,7 +66,8 @@ private:
         void startProducingData() final;
         void stopProducingData()  final;
         const RealtimeMediaSourceCapabilities& capabilities() final { return RealtimeMediaSourceCapabilities::emptyCapabilities(); }
-        const RealtimeMediaSourceSettings& settings() final { return m_settings; }
+        const RealtimeMediaSourceSettings& settings() final;
+        void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
 
         void captureCanvas();
         void requestFrameTimerFired();
@@ -75,7 +76,7 @@ private:
         std::optional<double> m_frameRequestRate;
         Timer m_requestFrameTimer;
         Timer m_canvasChangedTimer;
-        RealtimeMediaSourceSettings m_settings;
+        std::optional<RealtimeMediaSourceSettings> m_currentSettings;
         HTMLCanvasElement* m_canvas;
         RefPtr<Image> m_currentImage;
     };
index bda76d3..79f3f9a 100644 (file)
@@ -42,8 +42,6 @@ RealtimeIncomingVideoSource::RealtimeIncomingVideoSource(rtc::scoped_refptr<webr
     , m_videoTrack(WTFMove(videoTrack))
 {
     setName("remote video");
-    m_currentSettings.setWidth(640);
-    m_currentSettings.setHeight(480);
     notifyMutedChange(!m_videoTrack);
 }
 
@@ -77,7 +75,27 @@ const RealtimeMediaSourceCapabilities& RealtimeIncomingVideoSource::capabilities
 
 const RealtimeMediaSourceSettings& RealtimeIncomingVideoSource::settings()
 {
-    return m_currentSettings;
+    if (m_currentSettings)
+        return m_currentSettings.value();
+
+    RealtimeMediaSourceSupportedConstraints constraints;
+    constraints.setSupportsWidth(true);
+    constraints.setSupportsHeight(true);
+
+    RealtimeMediaSourceSettings settings;
+    auto& size = this->size();
+    settings.setWidth(size.width());
+    settings.setHeight(size.height());
+    settings.setSupportedConstraints(constraints);
+
+    m_currentSettings = WTFMove(settings);
+    return m_currentSettings.value();
+}
+
+void RealtimeIncomingVideoSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
+{
+    if (settings.containsAny({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }))
+        m_currentSettings = std::nullopt;
 }
 
 } // namespace WebCore
index 4bbc07d..afdbe05 100644 (file)
@@ -60,16 +60,16 @@ public:
 protected:
     RealtimeIncomingVideoSource(rtc::scoped_refptr<webrtc::VideoTrackInterface>&&, String&&);
 
-    RealtimeMediaSourceSettings m_currentSettings;
-
 private:
     // RealtimeMediaSource API
     void startProducingData() final;
     void stopProducingData()  final;
+    void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) final;
 
     const RealtimeMediaSourceCapabilities& capabilities() final;
     const RealtimeMediaSourceSettings& settings() final;
 
+    std::optional<RealtimeMediaSourceSettings> m_currentSettings;
     rtc::scoped_refptr<webrtc::VideoTrackInterface> m_videoTrack;
 };
 
index f2870f4..4c18f4f 100644 (file)
@@ -133,8 +133,14 @@ void RealtimeMediaSource::notifyMutedObservers() const
 
 void RealtimeMediaSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>)
 {
+}
+
+void RealtimeMediaSource::notifySettingsDidChangeObservers(OptionSet<RealtimeMediaSourceSettings::Flag> flags)
+{
     ASSERT(isMainThread());
 
+    settingsDidChange(flags);
+
     if (m_pendingSettingsDidChangeNotification)
         return;
     m_pendingSettingsDidChangeNotification = true;
@@ -864,7 +870,7 @@ void RealtimeMediaSource::setSize(const IntSize& size)
         changed.add(RealtimeMediaSourceSettings::Flag::Height);
 
     m_size = size;
-    settingsDidChange(changed);
+    notifySettingsDidChangeObservers(changed);
 }
 
 void RealtimeMediaSource::setFrameRate(double rate)
@@ -873,7 +879,7 @@ void RealtimeMediaSource::setFrameRate(double rate)
         return;
 
     m_frameRate = rate;
-    settingsDidChange(RealtimeMediaSourceSettings::Flag::FrameRate);
+    notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::FrameRate);
 }
 
 void RealtimeMediaSource::setAspectRatio(double ratio)
@@ -883,7 +889,7 @@ void RealtimeMediaSource::setAspectRatio(double ratio)
 
     m_aspectRatio = ratio;
     m_size.setHeight(m_size.width() / ratio);
-    settingsDidChange({ RealtimeMediaSourceSettings::Flag::AspectRatio, RealtimeMediaSourceSettings::Flag::Height });
+    notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::AspectRatio, RealtimeMediaSourceSettings::Flag::Height });
 }
 
 void RealtimeMediaSource::setFacingMode(RealtimeMediaSourceSettings::VideoFacingMode mode)
@@ -892,7 +898,7 @@ void RealtimeMediaSource::setFacingMode(RealtimeMediaSourceSettings::VideoFacing
         return;
 
     m_facingMode = mode;
-    settingsDidChange(RealtimeMediaSourceSettings::Flag::FacingMode);
+    notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::FacingMode);
 }
 
 void RealtimeMediaSource::setVolume(double volume)
@@ -901,7 +907,7 @@ void RealtimeMediaSource::setVolume(double volume)
         return;
 
     m_volume = volume;
-    settingsDidChange(RealtimeMediaSourceSettings::Flag::Volume);
+    notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::Volume);
 }
 
 void RealtimeMediaSource::setSampleRate(int rate)
@@ -910,7 +916,7 @@ void RealtimeMediaSource::setSampleRate(int rate)
         return;
 
     m_sampleRate = rate;
-    settingsDidChange(RealtimeMediaSourceSettings::Flag::SampleRate);
+    notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::SampleRate);
 }
 
 std::optional<Vector<int>> RealtimeMediaSource::discreteSampleRates() const
@@ -924,7 +930,7 @@ void RealtimeMediaSource::setSampleSize(int size)
         return;
 
     m_sampleSize = size;
-    settingsDidChange(RealtimeMediaSourceSettings::Flag::SampleSize);
+    notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::SampleSize);
 }
 
 std::optional<Vector<int>> RealtimeMediaSource::discreteSampleSizes() const
@@ -938,7 +944,7 @@ void RealtimeMediaSource::setEchoCancellation(bool echoCancellation)
         return;
 
     m_echoCancellation = echoCancellation;
-    settingsDidChange(RealtimeMediaSourceSettings::Flag::EchoCancellation);
+    notifySettingsDidChangeObservers(RealtimeMediaSourceSettings::Flag::EchoCancellation);
 }
 
 void RealtimeMediaSource::scheduleDeferredTask(WTF::Function<void()>&& function)
index c9604d0..77da308 100644 (file)
@@ -154,8 +154,6 @@ public:
     bool supportsConstraints(const MediaConstraints&, String&);
     bool supportsConstraint(const MediaConstraint&);
 
-    virtual void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>);
-
     virtual bool isIsolated() const { return false; }
 
     virtual bool isCaptureSource() const { return false; }
@@ -187,6 +185,7 @@ protected:
 
     void notifyMutedObservers() const;
     void notifyMutedChange(bool muted);
+    void notifySettingsDidChangeObservers(OptionSet<RealtimeMediaSourceSettings::Flag>);
 
     void initializeVolume(double volume) { m_volume = volume; }
     void initializeSampleRate(int sampleRate) { m_sampleRate = sampleRate; }
@@ -198,6 +197,8 @@ protected:
 private:
     virtual void startProducingData() { }
     virtual void stopProducingData() { }
+    virtual void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>);
+
 
     void forEachObserver(const WTF::Function<void(Observer&)>&) const;
 
index 30a25f4..74fa39c 100644 (file)
@@ -176,8 +176,6 @@ void GStreamerAudioCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourc
 {
     if (settings.contains(RealtimeMediaSourceSettings::Flag::SampleRate))
         m_capturer->setSampleRate(sampleRate());
-
-    RealtimeMediaSource::settingsDidChange(settings);
 }
 
 const RealtimeMediaSourceSettings& GStreamerAudioCaptureSource::settings()
index 1a6afbd..209db65 100644 (file)
@@ -133,8 +133,6 @@ void GStreamerVideoCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourc
         m_capturer->setSize(size().width(), size().height());
     if (settings.contains(RealtimeMediaSourceSettings::Flag::FrameRate))
         m_capturer->setFrameRate(frameRate());
-
-    RealtimeMediaSource::settingsDidChange(settings);
 }
 
 void GStreamerVideoCaptureSource::startProducingData()
index d7bc9ac..4cb2f93 100644 (file)
@@ -238,10 +238,9 @@ void AVVideoCaptureSource::commitConfiguration()
         [m_session commitConfiguration];
 }
 
-void AVVideoCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
+void AVVideoCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>)
 {
     m_currentSettings = std::nullopt;
-    RealtimeMediaSource::settingsDidChange(settings);
 }
 
 const RealtimeMediaSourceSettings& AVVideoCaptureSource::settings()
index 00f10e2..859d738 100644 (file)
@@ -888,7 +888,6 @@ void CoreAudioCaptureSource::settingsDidChange(OptionSet<RealtimeMediaSourceSett
     }
 
     m_currentSettings = std::nullopt;
-    RealtimeMediaSource::settingsDidChange(settings);
 }
 
 void CoreAudioCaptureSource::scheduleReconfiguration()
index cbe599f..dc6a18b 100644 (file)
@@ -117,8 +117,6 @@ void DisplayCaptureSourceCocoa::settingsDidChange(OptionSet<RealtimeMediaSourceS
     }
 
     m_currentSettings = { };
-
-    RealtimeMediaSource::settingsDidChange(settings);
 }
 
 void DisplayCaptureSourceCocoa::startProducingData()
index 5f3d680..d1d4f5c 100644 (file)
@@ -227,17 +227,9 @@ void RealtimeIncomingVideoSourceCocoa::OnFrame(const webrtc::VideoFrame& frame)
 void RealtimeIncomingVideoSourceCocoa::processNewSample(CMSampleBufferRef sample, unsigned width, unsigned height, MediaSample::VideoRotation rotation)
 {
     m_buffer = sample;
-    if (width != m_currentSettings.width() || height != m_currentSettings.height()) {
-        OptionSet<RealtimeMediaSourceSettings::Flag> changed;
-        if (width != m_currentSettings.width())
-            changed.add(RealtimeMediaSourceSettings::Flag::Width);
-        if (height != m_currentSettings.height())
-            changed.add(RealtimeMediaSourceSettings::Flag::Height);
-
-        m_currentSettings.setWidth(width);
-        m_currentSettings.setHeight(height);
-        settingsDidChange(changed);
-    }
+    auto size = this->size();
+    if (WTF::safeCast<int>(width) != size.width() || WTF::safeCast<int>(height) != size.height())
+        setSize(IntSize(width, height));
 
     videoSampleAvailable(MediaSampleAVFObjC::create(sample, rotation));
 }
index 4c59596..cc35461 100644 (file)
@@ -110,10 +110,9 @@ const RealtimeMediaSourceCapabilities& MockRealtimeAudioSource::capabilities()
     return m_capabilities.value();
 }
 
-void MockRealtimeAudioSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
+void MockRealtimeAudioSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>)
 {
     m_currentSettings = std::nullopt;
-    RealtimeMediaSource::settingsDidChange(settings);
 }
 
 void MockRealtimeAudioSource::startProducingData()
index d9404ad..5d3fb91 100644 (file)
@@ -184,8 +184,6 @@ void MockRealtimeVideoSource::settingsDidChange(OptionSet<RealtimeMediaSourceSet
         m_statsFontSize = m_baseFontSize * .5;
         m_imageBuffer = nullptr;
     }
-
-    RealtimeVideoSource::settingsDidChange(settings);
 }
 
 void MockRealtimeVideoSource::startCaptureTimer()
index 3f611de..af37546 100644 (file)
@@ -1,5 +1,16 @@
 2018-09-30  Eric Carlson  <eric.carlson@apple.com>
 
+        [MediaStream] Clean up RealtimeMediaSource settings change handling
+        https://bugs.webkit.org/show_bug.cgi?id=189998
+        <rdar://problem/44797884>
+
+        Reviewed by Youenn Fablet.
+
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::Source::setSettings):
+
+2018-09-30  Eric Carlson  <eric.carlson@apple.com>
+
         [MediaStream] Use display-specific capture factories
         https://bugs.webkit.org/show_bug.cgi?id=190043
         <rdar://problem/44834412>
index 480bad7..7c7f667 100644 (file)
@@ -78,7 +78,7 @@ public:
     {
         auto changed = m_settings.difference(settings);
         m_settings = WTFMove(settings);
-        settingsDidChange(changed);
+        notifySettingsDidChangeObservers(changed);
     }
 
     const CAAudioStreamDescription& description() const { return m_description; }