[MediaStream] Clean up capture source factory management
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Oct 2018 21:06:31 +0000 (21:06 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Oct 2018 21:06:31 +0000 (21:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190502
<rdar://problem/45212447>

Reviewed by Youenn Fablet.

No new tests, no functional change.

* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::setAudioFactory):
(WebCore::RealtimeMediaSourceCenter::unsetAudioFactory):
(WebCore::RealtimeMediaSourceCenter::audioFactory):
(WebCore::RealtimeMediaSourceCenter::setVideoFactory):
(WebCore::RealtimeMediaSourceCenter::unsetVideoFactory):
(WebCore::RealtimeMediaSourceCenter::videoFactory):
(WebCore::RealtimeMediaSourceCenter::setDisplayCaptureFactory):
(WebCore::RealtimeMediaSourceCenter::unsetDisplayCaptureFactory):
(WebCore::RealtimeMediaSourceCenter::displayCaptureFactory):
* platform/mediastream/RealtimeMediaSourceCenter.h:
(WebCore::RealtimeMediaSourceCenter::setAudioFactory): Deleted.
(WebCore::RealtimeMediaSourceCenter::unsetAudioFactory): Deleted.
(): Deleted.
* platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.cpp:
(WebCore::RealtimeMediaSourceCenterLibWebRTC::audioFactoryPrivate):
(WebCore::RealtimeMediaSourceCenterLibWebRTC::videoFactoryPrivate):
(WebCore::RealtimeMediaSourceCenterLibWebRTC::displayCaptureFactoryPrivate):
(WebCore::RealtimeMediaSourceCenterLibWebRTC::audioCaptureSourceFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterLibWebRTC::audioFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterLibWebRTC::videoFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterLibWebRTC::displayCaptureFactory): Deleted.
* platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.h:
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
(WebCore::RealtimeMediaSourceCenterMac::audioFactoryPrivate):
(WebCore::RealtimeMediaSourceCenterMac::videoFactoryPrivate):
(WebCore::RealtimeMediaSourceCenterMac::displayCaptureFactoryPrivate):
(WebCore::RealtimeMediaSourceCenterMac::videoCaptureSourceFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterMac::displayCaptureSourceFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterMac::audioCaptureSourceFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterMac::audioFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterMac::videoFactory): Deleted.
(WebCore::RealtimeMediaSourceCenterMac::displayCaptureFactory): Deleted.
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
* platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::MockRealtimeMediaSourceCenter::audioFactoryPrivate):
(WebCore::MockRealtimeMediaSourceCenter::videoFactoryPrivate):
(WebCore::MockRealtimeMediaSourceCenter::displayCaptureFactoryPrivate):
(WebCore::MockRealtimeMediaSourceCenter::audioFactory): Deleted.
(WebCore::MockRealtimeMediaSourceCenter::videoFactory): Deleted.
(WebCore::MockRealtimeMediaSourceCenter::displayCaptureFactory): Deleted.
* platform/mock/MockRealtimeMediaSourceCenter.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h
Source/WebCore/platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.cpp
Source/WebCore/platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.h
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.h
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.h

index 3b7f61f..a80961b 100644 (file)
@@ -1,3 +1,56 @@
+2018-10-17  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Clean up capture source factory management
+        https://bugs.webkit.org/show_bug.cgi?id=190502
+        <rdar://problem/45212447>
+
+        Reviewed by Youenn Fablet.
+
+        No new tests, no functional change.
+
+        * platform/mediastream/RealtimeMediaSourceCenter.cpp:
+        (WebCore::RealtimeMediaSourceCenter::setAudioFactory):
+        (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory):
+        (WebCore::RealtimeMediaSourceCenter::audioFactory):
+        (WebCore::RealtimeMediaSourceCenter::setVideoFactory):
+        (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory):
+        (WebCore::RealtimeMediaSourceCenter::videoFactory):
+        (WebCore::RealtimeMediaSourceCenter::setDisplayCaptureFactory):
+        (WebCore::RealtimeMediaSourceCenter::unsetDisplayCaptureFactory):
+        (WebCore::RealtimeMediaSourceCenter::displayCaptureFactory):
+        * platform/mediastream/RealtimeMediaSourceCenter.h:
+        (WebCore::RealtimeMediaSourceCenter::setAudioFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory): Deleted.
+        (): Deleted.
+        * platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.cpp:
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::audioFactoryPrivate):
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::videoFactoryPrivate):
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::displayCaptureFactoryPrivate):
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::audioCaptureSourceFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::audioFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::videoFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterLibWebRTC::displayCaptureFactory): Deleted.
+        * platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.h:
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
+        (WebCore::RealtimeMediaSourceCenterMac::audioFactoryPrivate):
+        (WebCore::RealtimeMediaSourceCenterMac::videoFactoryPrivate):
+        (WebCore::RealtimeMediaSourceCenterMac::displayCaptureFactoryPrivate):
+        (WebCore::RealtimeMediaSourceCenterMac::videoCaptureSourceFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterMac::displayCaptureSourceFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterMac::audioCaptureSourceFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterMac::audioFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterMac::videoFactory): Deleted.
+        (WebCore::RealtimeMediaSourceCenterMac::displayCaptureFactory): Deleted.
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
+        * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+        (WebCore::MockRealtimeMediaSourceCenter::audioFactoryPrivate):
+        (WebCore::MockRealtimeMediaSourceCenter::videoFactoryPrivate):
+        (WebCore::MockRealtimeMediaSourceCenter::displayCaptureFactoryPrivate):
+        (WebCore::MockRealtimeMediaSourceCenter::audioFactory): Deleted.
+        (WebCore::MockRealtimeMediaSourceCenter::videoFactory): Deleted.
+        (WebCore::MockRealtimeMediaSourceCenter::displayCaptureFactory): Deleted.
+        * platform/mock/MockRealtimeMediaSourceCenter.h:
+
 2018-10-17  Alex Christensen  <achristensen@webkit.org>
 
         BackForwardClient needs to be able to support UIProcess-only back/forward lists
index a6f8ff3..0bfe85d 100644 (file)
@@ -333,6 +333,54 @@ std::optional<CaptureDevice> RealtimeMediaSourceCenter::captureDeviceWithPersist
     return std::nullopt;
 }
 
+static AudioCaptureFactory* audioFactoryOverride;
+void RealtimeMediaSourceCenter::setAudioFactory(AudioCaptureFactory& factory)
+{
+    audioFactoryOverride = &factory;
+}
+void RealtimeMediaSourceCenter::unsetAudioFactory(AudioCaptureFactory& oldOverride)
+{
+    ASSERT_UNUSED(oldOverride, audioFactoryOverride == &oldOverride);
+    audioFactoryOverride = nullptr;
+}
+
+AudioCaptureFactory& RealtimeMediaSourceCenter::audioFactory()
+{
+    return audioFactoryOverride ? *audioFactoryOverride : RealtimeMediaSourceCenter::singleton().audioFactoryPrivate();
+}
+
+static VideoCaptureFactory* videoFactoryOverride;
+void RealtimeMediaSourceCenter::setVideoFactory(VideoCaptureFactory& factory)
+{
+    videoFactoryOverride = &factory;
+}
+void RealtimeMediaSourceCenter::unsetVideoFactory(VideoCaptureFactory& oldOverride)
+{
+    ASSERT_UNUSED(oldOverride, videoFactoryOverride == &oldOverride);
+    videoFactoryOverride = nullptr;
+}
+
+VideoCaptureFactory& RealtimeMediaSourceCenter::videoFactory()
+{
+    return videoFactoryOverride ? *videoFactoryOverride : RealtimeMediaSourceCenter::singleton().videoFactoryPrivate();
+}
+
+static DisplayCaptureFactory* displayCaptureFactoryOverride;
+void RealtimeMediaSourceCenter::setDisplayCaptureFactory(DisplayCaptureFactory& factory)
+{
+    displayCaptureFactoryOverride = &factory;
+}
+void RealtimeMediaSourceCenter::unsetDisplayCaptureFactory(DisplayCaptureFactory& oldOverride)
+{
+    ASSERT_UNUSED(oldOverride, displayCaptureFactoryOverride == &oldOverride);
+    displayCaptureFactoryOverride = nullptr;
+}
+
+DisplayCaptureFactory& RealtimeMediaSourceCenter::displayCaptureFactory()
+{
+    return displayCaptureFactoryOverride ? *displayCaptureFactoryOverride : RealtimeMediaSourceCenter::singleton().displayCaptureFactoryPrivate();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 4e17027..1efffdb 100644 (file)
@@ -72,13 +72,17 @@ public:
     
     const RealtimeMediaSourceSupportedConstraints& supportedConstraints() { return m_supportedConstraints; }
 
-    virtual void setAudioFactory(AudioCaptureFactory&) { }
-    virtual void unsetAudioFactory(AudioCaptureFactory&) { }
-    WEBCORE_EXPORT virtual AudioCaptureFactory& audioFactory() = 0;
+    WEBCORE_EXPORT static AudioCaptureFactory& audioFactory();
+    WEBCORE_EXPORT static void setAudioFactory(AudioCaptureFactory&);
+    WEBCORE_EXPORT static void unsetAudioFactory(AudioCaptureFactory&);
 
-    virtual VideoCaptureFactory& videoFactory() = 0;
+    WEBCORE_EXPORT static VideoCaptureFactory& videoFactory();
+    WEBCORE_EXPORT static void setVideoFactory(VideoCaptureFactory&);
+    WEBCORE_EXPORT static void unsetVideoFactory(VideoCaptureFactory&);
 
-    virtual DisplayCaptureFactory& displayCaptureFactory() = 0;
+    WEBCORE_EXPORT static DisplayCaptureFactory& displayCaptureFactory();
+    WEBCORE_EXPORT static void setDisplayCaptureFactory(DisplayCaptureFactory&);
+    WEBCORE_EXPORT static void unsetDisplayCaptureFactory(DisplayCaptureFactory&);
 
     virtual CaptureDeviceManager& audioCaptureDeviceManager() = 0;
     virtual CaptureDeviceManager& videoCaptureDeviceManager() = 0;
@@ -100,8 +104,9 @@ protected:
     static RealtimeMediaSourceCenter& platformCenter();
     RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
 
-    CaptureDeviceManager* m_audioCaptureDeviceManager { nullptr };
-    CaptureDeviceManager* m_videoCaptureDeviceManager { nullptr };
+    WEBCORE_EXPORT virtual AudioCaptureFactory& audioFactoryPrivate() = 0;
+    WEBCORE_EXPORT virtual VideoCaptureFactory& videoFactoryPrivate() = 0;
+    WEBCORE_EXPORT virtual DisplayCaptureFactory& displayCaptureFactoryPrivate() = 0;
 
 private:
     struct DeviceInfo {
index ad844ab..6caec13 100644 (file)
 
 namespace WebCore {
 
-AudioCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::audioCaptureSourceFactory()
-{
-    return RealtimeMediaSourceCenterLibWebRTC::singleton().audioFactory();
-}
-
 RealtimeMediaSourceCenterLibWebRTC& RealtimeMediaSourceCenterLibWebRTC::singleton()
 {
     ASSERT(isMainThread());
@@ -57,20 +52,17 @@ RealtimeMediaSourceCenterLibWebRTC::~RealtimeMediaSourceCenterLibWebRTC()
 {
 }
 
-AudioCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::audioFactory()
+AudioCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::audioFactoryPrivate()
 {
-    if (m_audioFactoryOverride)
-        return *m_audioFactoryOverride;
-
     return GStreamerAudioCaptureSource::factory();
 }
 
-VideoCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::videoFactory()
+VideoCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::videoFactoryPrivate()
 {
     return GStreamerVideoCaptureSource::factory();
 }
 
-DisplayCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::displayCaptureFactory()
+DisplayCaptureFactory& RealtimeMediaSourceCenterLibWebRTC::displayCaptureFactoryPrivate()
 {
     return GStreamerVideoCaptureSource::displayFactory();
 }
index 37aa4fe..10e4fb8 100644 (file)
@@ -38,20 +38,14 @@ class RealtimeMediaSourceCenterLibWebRTC final : public RealtimeMediaSourceCente
 public:
     WEBCORE_EXPORT static RealtimeMediaSourceCenterLibWebRTC& singleton();
 
-    static VideoCaptureFactory& videoCaptureSourceFactory();
-    static AudioCaptureFactory& audioCaptureSourceFactory();
-
 private:
     friend class NeverDestroyed<RealtimeMediaSourceCenterLibWebRTC>;
     RealtimeMediaSourceCenterLibWebRTC();
     ~RealtimeMediaSourceCenterLibWebRTC();
 
-    void setAudioFactory(AudioCaptureFactory& factory) final { m_audioFactoryOverride = &factory; }
-    void unsetAudioFactory(AudioCaptureFactory&) final { m_audioFactoryOverride = nullptr; }
-
-    AudioCaptureFactory& audioFactory() final;
-    VideoCaptureFactory& videoFactory() final;
-    DisplayCaptureFactory& displayCaptureFactory() final;
+    AudioCaptureFactory& audioFactoryPrivate() final;
+    VideoCaptureFactory& videoFactoryPrivate() final;
+    DisplayCaptureFactory& displayCaptureFactoryPrivate() final;
 
     CaptureDeviceManager& audioCaptureDeviceManager() final;
     CaptureDeviceManager& videoCaptureDeviceManager() final;
index bca6dd1..20abf66 100644 (file)
@@ -95,23 +95,6 @@ public:
     }
 };
 
-VideoCaptureFactory& RealtimeMediaSourceCenterMac::videoCaptureSourceFactory()
-{
-    static NeverDestroyed<VideoCaptureSourceFactoryMac> factory;
-    return factory.get();
-}
-
-DisplayCaptureFactory& RealtimeMediaSourceCenterMac::displayCaptureSourceFactory()
-{
-    static NeverDestroyed<DisplayCaptureSourceFactoryMac> factory;
-    return factory.get();
-}
-
-AudioCaptureFactory& RealtimeMediaSourceCenterMac::audioCaptureSourceFactory()
-{
-    return RealtimeMediaSourceCenterMac::singleton().audioFactory();
-}
-
 RealtimeMediaSourceCenterMac& RealtimeMediaSourceCenterMac::singleton()
 {
     ASSERT(isMainThread());
@@ -129,22 +112,21 @@ RealtimeMediaSourceCenterMac::RealtimeMediaSourceCenterMac() = default;
 RealtimeMediaSourceCenterMac::~RealtimeMediaSourceCenterMac() = default;
 
 
-AudioCaptureFactory& RealtimeMediaSourceCenterMac::audioFactory()
+AudioCaptureFactory& RealtimeMediaSourceCenterMac::audioFactoryPrivate()
 {
-    if (m_audioFactoryOverride)
-        return *m_audioFactoryOverride;
-
     return CoreAudioCaptureSource::factory();
 }
 
-VideoCaptureFactory& RealtimeMediaSourceCenterMac::videoFactory()
+VideoCaptureFactory& RealtimeMediaSourceCenterMac::videoFactoryPrivate()
 {
-    return videoCaptureSourceFactory();
+    static NeverDestroyed<VideoCaptureSourceFactoryMac> factory;
+    return factory.get();
 }
 
-DisplayCaptureFactory& RealtimeMediaSourceCenterMac::displayCaptureFactory()
+DisplayCaptureFactory& RealtimeMediaSourceCenterMac::displayCaptureFactoryPrivate()
 {
-    return displayCaptureSourceFactory();
+    static NeverDestroyed<DisplayCaptureSourceFactoryMac> factory;
+    return factory.get();
 }
 
 CaptureDeviceManager& RealtimeMediaSourceCenterMac::audioCaptureDeviceManager()
index 58f4a18..c26ec73 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2017 Apple, Inc. All rights reserved.
+ * Copyright (C) 2013-2018 Apple, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -44,21 +44,14 @@ class RealtimeMediaSourceCenterMac final : public RealtimeMediaSourceCenter {
 public:
     WEBCORE_EXPORT static RealtimeMediaSourceCenterMac& singleton();
 
-    static VideoCaptureFactory& videoCaptureSourceFactory();
-    static AudioCaptureFactory& audioCaptureSourceFactory();
-    static DisplayCaptureFactory& displayCaptureSourceFactory();
-
 private:
     friend class NeverDestroyed<RealtimeMediaSourceCenterMac>;
     RealtimeMediaSourceCenterMac();
     ~RealtimeMediaSourceCenterMac();
 
-    void setAudioFactory(AudioCaptureFactory& factory) final { m_audioFactoryOverride = &factory; }
-    void unsetAudioFactory(AudioCaptureFactory&) final { m_audioFactoryOverride = nullptr; }
-
-    AudioCaptureFactory& audioFactory() final;
-    VideoCaptureFactory& videoFactory() final;
-    DisplayCaptureFactory& displayCaptureFactory() final;
+    AudioCaptureFactory& audioFactoryPrivate() final;
+    VideoCaptureFactory& videoFactoryPrivate() final;
+    DisplayCaptureFactory& displayCaptureFactoryPrivate() final;
 
     CaptureDeviceManager& audioCaptureDeviceManager() final;
     CaptureDeviceManager& videoCaptureDeviceManager() final;
index 41fd1d6..7749d22 100644 (file)
@@ -310,19 +310,19 @@ Vector<CaptureDevice>& MockRealtimeMediaSourceCenter::displayDevices()
     return displayDevices;
 }
 
-AudioCaptureFactory& MockRealtimeMediaSourceCenter::audioFactory()
+AudioCaptureFactory& MockRealtimeMediaSourceCenter::audioFactoryPrivate()
 {
     static NeverDestroyed<MockRealtimeAudioSourceFactory> factory;
     return factory.get();
 }
 
-VideoCaptureFactory& MockRealtimeMediaSourceCenter::videoFactory()
+VideoCaptureFactory& MockRealtimeMediaSourceCenter::videoFactoryPrivate()
 {
     static NeverDestroyed<MockRealtimeVideoSourceFactory> factory;
     return factory.get();
 }
 
-DisplayCaptureFactory& MockRealtimeMediaSourceCenter::displayCaptureFactory()
+DisplayCaptureFactory& MockRealtimeMediaSourceCenter::displayCaptureFactoryPrivate()
 {
     static NeverDestroyed<MockRealtimeDisplaySourceFactory> factory;
     return factory.get();
index bfc5e22..f491140 100644 (file)
@@ -58,9 +58,9 @@ private:
 
     static MockRealtimeMediaSourceCenter& singleton();
 
-    AudioCaptureFactory& audioFactory() final;
-    VideoCaptureFactory& videoFactory() final;
-    DisplayCaptureFactory& displayCaptureFactory() final;
+    AudioCaptureFactory& audioFactoryPrivate() final;
+    VideoCaptureFactory& videoFactoryPrivate() final;
+    DisplayCaptureFactory& displayCaptureFactoryPrivate() final;
 
     CaptureDeviceManager& audioCaptureDeviceManager() final { return m_audioCaptureDeviceManager; }
     CaptureDeviceManager& videoCaptureDeviceManager() final { return m_videoCaptureDeviceManager; }