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

Reviewed by Youenn Fablet.

No new tests, no change in functionality.

* platform/mediastream/RealtimeMediaSource.cpp:
(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):
(WebCore::RealtimeMediaSource::settingsDidChange): Deleted.
* platform/mediastream/RealtimeMediaSource.h:
* 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/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::settingsDidChange):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::settingsDidChange):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp
Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp
Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp

index 5d0e95c..5229a81 100644 (file)
@@ -1,3 +1,36 @@
+2018-09-26  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, no change in functionality.
+
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (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):
+        (WebCore::RealtimeMediaSource::settingsDidChange): Deleted.
+        * platform/mediastream/RealtimeMediaSource.h:
+        * 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/mock/MockRealtimeAudioSource.cpp:
+        (WebCore::MockRealtimeAudioSource::settingsDidChange):
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::settingsDidChange):
+
 2018-09-26  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Ensure renderers with accelerated animations have layers
index b3ab3e0..35bfdde 100644 (file)
@@ -133,12 +133,18 @@ void RealtimeMediaSource::notifyMutedObservers() const
 
 void RealtimeMediaSource::settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>)
 {
+}
+
+void RealtimeMediaSource::notifySettingsDidChangeObservers(OptionSet<RealtimeMediaSourceSettings::Flag> flags)
+{
     ASSERT(isMainThread());
 
     if (m_pendingSettingsDidChangeNotification)
         return;
     m_pendingSettingsDidChangeNotification = true;
 
+    settingsDidChange(flags);
+
     scheduleDeferredTask([this] {
         m_pendingSettingsDidChangeNotification = false;
         forEachObserver([](auto& observer) {
@@ -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 6d8b962..3d87c4d 100644 (file)
@@ -247,6 +247,8 @@ private:
     virtual void startProducingData() { }
     virtual void stopProducingData() { }
 
+    void notifySettingsDidChangeObservers(OptionSet<RealtimeMediaSourceSettings::Flag>);
+
     void forEachObserver(const WTF::Function<void(Observer&)>&) const;
 
     bool m_muted { false };
index 7425f37..1a4d8cc 100644 (file)
@@ -229,10 +229,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 e6cc41f..0b6f3a3 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 2e8e55c..4a21fb5 100644 (file)
@@ -134,10 +134,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 bdb27ba..a5033ad 100644 (file)
@@ -229,8 +229,6 @@ void MockRealtimeVideoSource::settingsDidChange(OptionSet<RealtimeMediaSourceSet
         m_statsFontSize = m_baseFontSize * .5;
         m_imageBuffer = nullptr;
     }
-
-    RealtimeVideoSource::settingsDidChange(settings);
 }
 
 void MockRealtimeVideoSource::startCaptureTimer()