Align MockRealtimeMediaSourceCenter with RealtimeMediaSourceCenter
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 21:41:50 +0000 (21:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 21:41:50 +0000 (21:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172324

Patch by Youenn Fablet <youenn@apple.com> on 2017-05-19
Reviewed by Eric Carlson.

Source/WebCore:

No change of behavior.
Remove most of MockRealtimeMediaSourceCenter implementation.
Next step should be to remove it entirely and use the factory setters instead.

* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::RealtimeMediaSourceCenter):
(WebCore::RealtimeMediaSourceCenter::createMediaStream):
(WebCore::RealtimeMediaSourceCenter::getMediaStreamDevices):
(WebCore::RealtimeMediaSourceCenter::setDeviceEnabled):
* platform/mediastream/RealtimeMediaSourceCenter.h:
(WebCore::RealtimeMediaSourceCenter::supportedConstraints):
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
(WebCore::RealtimeMediaSourceCenterMac::RealtimeMediaSourceCenterMac):
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
* platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::MockRealtimeMediaSourceCenter::MockCaptureDeviceManager::captureDevices):
* platform/mock/MockRealtimeMediaSourceCenter.h:

LayoutTests:

* fast/mediastream/mock-media-source-webaudio.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/mock-media-source-webaudio.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.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 0e62d94..c562fdc 100644 (file)
@@ -1,3 +1,12 @@
+2017-05-19  Youenn Fablet  <youenn@apple.com>
+
+        Align MockRealtimeMediaSourceCenter with RealtimeMediaSourceCenter
+        https://bugs.webkit.org/show_bug.cgi?id=172324
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/mock-media-source-webaudio.html:
+
 2017-05-19  Alexey Proskuryakov  <ap@apple.com>
 
         Many CSS js-tests use waitUntilDone
index 0f39705..ce8abef 100644 (file)
@@ -64,8 +64,8 @@
                 test.done();
             };
 
-            var timeout = setTimeout(done, 3000);
-            var interval = setInterval(analyse, 1000 / 30);
+            var timeout = setTimeout(() => { done(); }, 3000);
+            var interval = setInterval(() => { analyse(); }, 1000 / 30);
             analyse();
         });
     }, "Basic getUserMedia to Web Audio test");
index df9de2e..7fb73d3 100644 (file)
@@ -1,3 +1,28 @@
+2017-05-19  Youenn Fablet  <youenn@apple.com>
+
+        Align MockRealtimeMediaSourceCenter with RealtimeMediaSourceCenter
+        https://bugs.webkit.org/show_bug.cgi?id=172324
+
+        Reviewed by Eric Carlson.
+
+        No change of behavior.
+        Remove most of MockRealtimeMediaSourceCenter implementation.
+        Next step should be to remove it entirely and use the factory setters instead.
+
+        * platform/mediastream/RealtimeMediaSourceCenter.cpp:
+        (WebCore::RealtimeMediaSourceCenter::RealtimeMediaSourceCenter):
+        (WebCore::RealtimeMediaSourceCenter::createMediaStream):
+        (WebCore::RealtimeMediaSourceCenter::getMediaStreamDevices):
+        (WebCore::RealtimeMediaSourceCenter::setDeviceEnabled):
+        * platform/mediastream/RealtimeMediaSourceCenter.h:
+        (WebCore::RealtimeMediaSourceCenter::supportedConstraints):
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
+        (WebCore::RealtimeMediaSourceCenterMac::RealtimeMediaSourceCenterMac):
+        * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
+        * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+        (WebCore::MockRealtimeMediaSourceCenter::MockCaptureDeviceManager::captureDevices):
+        * platform/mock/MockRealtimeMediaSourceCenter.h:
+
 2017-05-19  Zalan Bujtas  <zalan@apple.com>
 
         Update SameSizeAsInlineBox with the correct InlineBoxBitfields bits.
index bd52b2e..041948f 100644 (file)
                07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07D637411BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */; };
                07D6A4EF1BECF2D200174146 /* MockRealtimeMediaSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D6A4ED1BECF2D200174146 /* MockRealtimeMediaSource.cpp */; };
-               07D6A4F01BECF2D200174146 /* MockRealtimeMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4EE1BECF2D200174146 /* MockRealtimeMediaSource.h */; };
+               07D6A4F01BECF2D200174146 /* MockRealtimeMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4EE1BECF2D200174146 /* MockRealtimeMediaSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07D6A4F31BED5F8800174146 /* MockRealtimeAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D6A4F11BED5F8800174146 /* MockRealtimeAudioSource.cpp */; };
-               07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */; };
+               07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07D6A4F81BF2307D00174146 /* AudioTrackPrivateMediaStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4F61BF2307D00174146 /* AudioTrackPrivateMediaStream.h */; };
                07E116B11489C9A100EC5ACE /* JSTextTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */; };
                07E117071489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */; };
                07E9E13018F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */; };
                07EDC3EE1AACB75D00983EB5 /* MediaSessionManagerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.mm */; };
                07EE76EB1BE96DB000F89133 /* MockRealtimeVideoSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */; };
-               07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */; };
+               07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */; };
                07EE76F01BEA619800F89133 /* MockRealtimeVideoSourceMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */; };
                07F0B97A1AC5DB3300E535D9 /* AVKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
index 37d468b..025c4ec 100644 (file)
@@ -35,6 +35,8 @@
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "CaptureDeviceManager.h"
+#include "Logging.h"
 #include "MediaStreamPrivate.h"
 #include <wtf/SHA1.h>
 
@@ -68,12 +70,65 @@ void RealtimeMediaSourceCenter::setSharedStreamCenterOverride(RealtimeMediaSourc
 
 RealtimeMediaSourceCenter::RealtimeMediaSourceCenter()
 {
+    m_supportedConstraints.setSupportsWidth(true);
+    m_supportedConstraints.setSupportsHeight(true);
+    m_supportedConstraints.setSupportsAspectRatio(true);
+    m_supportedConstraints.setSupportsFrameRate(true);
+    m_supportedConstraints.setSupportsFacingMode(true);
+    m_supportedConstraints.setSupportsVolume(true);
+    m_supportedConstraints.setSupportsDeviceId(true);
 }
 
 RealtimeMediaSourceCenter::~RealtimeMediaSourceCenter()
 {
 }
 
+void RealtimeMediaSourceCenter::createMediaStream(NewMediaStreamHandler&& completionHandler, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints)
+{
+    Vector<Ref<RealtimeMediaSource>> audioSources;
+    Vector<Ref<RealtimeMediaSource>> videoSources;
+    String invalidConstraint;
+
+    if (!audioDeviceID.isEmpty()) {
+        auto audioSource = audioFactory().createAudioCaptureSource(audioDeviceID, audioConstraints);
+        if (audioSource)
+            audioSources.append(audioSource.source());
+        else {
+#if !LOG_DISABLED
+            if (!audioSource.errorMessage.isEmpty())
+                LOG(Media, "RealtimeMediaSourceCenter::createMediaStream(%p), audio constraints failed to apply: %s", this, audioSource.errorMessage.utf8().data());
+#endif
+            completionHandler(nullptr);
+            return;
+        }
+    }
+    if (!videoDeviceID.isEmpty()) {
+        auto videoSource = videoFactory().createVideoCaptureSource(videoDeviceID, videoConstraints);
+        if (videoSource)
+            videoSources.append(videoSource.source());
+        else {
+#if !LOG_DISABLED
+            if (!videoSource.errorMessage.isEmpty())
+                LOG(Media, "RealtimeMediaSourceCenter::createMediaStream(%p), video constraints failed to apply: %s", this, videoSource.errorMessage.utf8().data());
+#endif
+            completionHandler(nullptr);
+            return;
+        }
+    }
+
+    completionHandler(MediaStreamPrivate::create(audioSources, videoSources));
+}
+
+Vector<CaptureDevice> RealtimeMediaSourceCenter::getMediaStreamDevices()
+{
+    Vector<CaptureDevice> result;
+
+    result.appendVector(audioCaptureDeviceManager().getAudioSourcesInfo());
+    result.appendVector(videoCaptureDeviceManager().getVideoSourcesInfo());
+
+    return result;
+}
+
 void RealtimeMediaSourceCenter::setAudioFactory(RealtimeMediaSource::AudioCaptureFactory& factory)
 {
     m_audioFactory = &factory;
@@ -180,9 +235,20 @@ std::optional<CaptureDevice> RealtimeMediaSourceCenter::captureDeviceWithUniqueI
     return std::nullopt;
 }
 
-ExceptionOr<void> RealtimeMediaSourceCenter::setDeviceEnabled(const String&, bool)
+ExceptionOr<void> RealtimeMediaSourceCenter::setDeviceEnabled(const String& id, bool enabled)
 {
-    return Exception { NOT_FOUND_ERR, ASCIILiteral("Not implemented!") };
+    for (auto& captureDevice : getMediaStreamDevices()) {
+        if (id == captureDevice.persistentId()) {
+            if (enabled != captureDevice.enabled()) {
+                captureDevice.setEnabled(enabled);
+                captureDevicesChanged();
+            }
+
+            return { };
+        }
+    }
+
+    return Exception { NOT_FOUND_ERR };
 }
 
 RealtimeMediaSourceCenter::DevicesChangedObserverToken RealtimeMediaSourceCenter::addDevicesChangedObserver(std::function<void()>&& observer)
index 9ba14b5..121a7f1 100644 (file)
@@ -63,15 +63,18 @@ public:
     virtual void validateRequestConstraints(ValidConstraintsHandler&&, InvalidConstraintsHandler&&, const MediaConstraints& audioConstraints, const MediaConstraints& videoConstraints, String&&);
 
     using NewMediaStreamHandler = std::function<void(RefPtr<MediaStreamPrivate>&&)>;
-    virtual void createMediaStream(NewMediaStreamHandler&&, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints) = 0;
+    virtual void createMediaStream(NewMediaStreamHandler&&, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints);
 
-    virtual Vector<CaptureDevice> getMediaStreamDevices() = 0;
+    WEBCORE_EXPORT virtual Vector<CaptureDevice> getMediaStreamDevices();
     
-    virtual const RealtimeMediaSourceSupportedConstraints& supportedConstraints() { return m_supportedConstraints; }
+    const RealtimeMediaSourceSupportedConstraints& supportedConstraints() { return m_supportedConstraints; }
 
     virtual RealtimeMediaSource::AudioCaptureFactory& defaultAudioFactory() = 0;
     virtual RealtimeMediaSource::VideoCaptureFactory& defaultVideoFactory() = 0;
 
+    virtual CaptureDeviceManager& defaultAudioCaptureDeviceManager() = 0;
+    virtual CaptureDeviceManager& defaultVideoCaptureDeviceManager() = 0;
+
     WEBCORE_EXPORT void setAudioFactory(RealtimeMediaSource::AudioCaptureFactory&);
     WEBCORE_EXPORT void unsetAudioFactory(RealtimeMediaSource::AudioCaptureFactory&);
     WEBCORE_EXPORT RealtimeMediaSource::AudioCaptureFactory& audioFactory();
@@ -80,9 +83,6 @@ public:
     WEBCORE_EXPORT void unsetVideoFactory(RealtimeMediaSource::VideoCaptureFactory&);
     WEBCORE_EXPORT RealtimeMediaSource::VideoCaptureFactory& videoFactory();
 
-    virtual CaptureDeviceManager& defaultAudioCaptureDeviceManager() = 0;
-    virtual CaptureDeviceManager& defaultVideoCaptureDeviceManager() = 0;
-
     WEBCORE_EXPORT void setAudioCaptureDeviceManager(CaptureDeviceManager&);
     WEBCORE_EXPORT void unsetAudioCaptureDeviceManager(CaptureDeviceManager&);
     CaptureDeviceManager& audioCaptureDeviceManager();
@@ -93,7 +93,7 @@ public:
 
     String hashStringWithSalt(const String& id, const String& hashSalt);
     WEBCORE_EXPORT std::optional<CaptureDevice> captureDeviceWithUniqueID(const String& id, const String& hashSalt);
-    virtual ExceptionOr<void> setDeviceEnabled(const String&, bool);
+    WEBCORE_EXPORT ExceptionOr<void> setDeviceEnabled(const String&, bool);
 
     using DevicesChangedObserverToken = unsigned;
     DevicesChangedObserverToken addDevicesChangedObserver(std::function<void()>&&);
index 2ef950b..d7d7389 100644 (file)
@@ -64,16 +64,9 @@ RealtimeMediaSourceCenter& RealtimeMediaSourceCenter::platformCenter()
 
 RealtimeMediaSourceCenterMac::RealtimeMediaSourceCenterMac()
 {
-    m_supportedConstraints.setSupportsWidth(true);
-    m_supportedConstraints.setSupportsHeight(true);
-    m_supportedConstraints.setSupportsAspectRatio(true);
-    m_supportedConstraints.setSupportsFrameRate(true);
-    m_supportedConstraints.setSupportsFacingMode(true);
-    m_supportedConstraints.setSupportsVolume(true);
     m_supportedConstraints.setSupportsSampleRate(false);
     m_supportedConstraints.setSupportsSampleSize(false);
     m_supportedConstraints.setSupportsEchoCancellation(false);
-    m_supportedConstraints.setSupportsDeviceId(true);
     m_supportedConstraints.setSupportsGroupId(true);
 }
 
@@ -81,51 +74,6 @@ RealtimeMediaSourceCenterMac::~RealtimeMediaSourceCenterMac()
 {
 }
 
-void RealtimeMediaSourceCenterMac::createMediaStream(NewMediaStreamHandler&& completionHandler, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints)
-{
-    Vector<Ref<RealtimeMediaSource>> audioSources;
-    Vector<Ref<RealtimeMediaSource>> videoSources;
-    String invalidConstraint;
-
-    if (!audioDeviceID.isEmpty()) {
-        auto audioSource = audioFactory().createAudioCaptureSource(audioDeviceID, audioConstraints);
-        if (audioSource)
-            audioSources.append(audioSource.source());
-        else {
-#if !LOG_DISABLED
-            if (!audioSource.errorMessage.isEmpty())
-                LOG(Media, "RealtimeMediaSourceCenterMac::createMediaStream(%p), audio constraints failed to apply: %s", this, audioSource.errorMessage.utf8().data());
-#endif
-            completionHandler(nullptr);
-            return;
-        }
-    }
-    if (!videoDeviceID.isEmpty()) {
-        auto videoSource = videoFactory().createVideoCaptureSource(videoDeviceID, videoConstraints);
-        if (videoSource)
-            videoSources.append(videoSource.source());
-        else {
-#if !LOG_DISABLED
-            if (!videoSource.errorMessage.isEmpty())
-                LOG(Media, "RealtimeMediaSourceCenterMac::createMediaStream(%p), video constraints failed to apply: %s", this, videoSource.errorMessage.utf8().data());
-#endif
-            completionHandler(nullptr);
-            return;
-        }
-    }
-
-    completionHandler(MediaStreamPrivate::create(audioSources, videoSources));
-}
-
-Vector<CaptureDevice> RealtimeMediaSourceCenterMac::getMediaStreamDevices()
-{
-    Vector<CaptureDevice> result;
-
-    result.appendVector(audioCaptureDeviceManager().getAudioSourcesInfo());
-    result.appendVector(videoCaptureDeviceManager().getVideoSourcesInfo());
-
-    return result;
-}
 
 RealtimeMediaSource::AudioCaptureFactory& RealtimeMediaSourceCenterMac::defaultAudioFactory()
 {
index d0f8092..85bbfe4 100644 (file)
@@ -50,9 +50,6 @@ private:
     RealtimeMediaSourceCenterMac();
     ~RealtimeMediaSourceCenterMac();
 
-    void createMediaStream(NewMediaStreamHandler&&, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints) final;
-    Vector<CaptureDevice> getMediaStreamDevices() final;
-
     RealtimeMediaSource::AudioCaptureFactory& defaultAudioFactory() final;
     RealtimeMediaSource::VideoCaptureFactory& defaultVideoFactory() final;
 
index 7fc2d7c..4efdf72 100644 (file)
@@ -54,111 +54,6 @@ void MockRealtimeMediaSourceCenter::setMockRealtimeMediaSourceCenterEnabled(bool
     }
 }
 
-MockRealtimeMediaSourceCenter::MockRealtimeMediaSourceCenter()
-{
-    m_supportedConstraints.setSupportsWidth(true);
-    m_supportedConstraints.setSupportsHeight(true);
-    m_supportedConstraints.setSupportsAspectRatio(true);
-    m_supportedConstraints.setSupportsFrameRate(true);
-    m_supportedConstraints.setSupportsFacingMode(true);
-    m_supportedConstraints.setSupportsVolume(true);
-    m_supportedConstraints.setSupportsDeviceId(true);
-}
-
-void MockRealtimeMediaSourceCenter::createMediaStream(NewMediaStreamHandler&& completionHandler, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints)
-{
-    Vector<Ref<RealtimeMediaSource>> audioSources;
-    Vector<Ref<RealtimeMediaSource>> videoSources;
-
-    if (!audioDeviceID.isEmpty()) {
-        for (auto& captureDevice : MockRealtimeMediaSource::audioDevices()) {
-            if (!captureDevice.enabled())
-                continue;
-
-            if (audioDeviceID == captureDevice.persistentId()) {
-                auto sourceOrError = MockRealtimeAudioSource::create(captureDevice.label(), audioConstraints);
-                if (sourceOrError)
-                    audioSources.append(sourceOrError.source());
-            }
-        }
-    }
-
-    if (!videoDeviceID.isEmpty()) {
-        for (auto& captureDevice : MockRealtimeMediaSource::videoDevices()) {
-            if (!captureDevice.enabled())
-                continue;
-
-            if (videoDeviceID == captureDevice.persistentId()) {
-                auto sourceOrError = MockRealtimeVideoSource::create(captureDevice.label(), videoConstraints);
-                if (sourceOrError)
-                    videoSources.append(sourceOrError.source());
-            }
-        }
-    }
-
-    if (videoSources.isEmpty() && audioSources.isEmpty())
-        completionHandler(nullptr);
-    else
-        completionHandler(MediaStreamPrivate::create(audioSources, videoSources));
-}
-
-Vector<CaptureDevice> MockRealtimeMediaSourceCenter::getMediaStreamDevices()
-{
-    Vector<CaptureDevice> sources;
-
-    for (auto& captureDevice : MockRealtimeMediaSource::audioDevices()) {
-        if (!captureDevice.enabled())
-            continue;
-
-        sources.append(captureDevice);
-    }
-
-    for (auto& captureDevice : MockRealtimeMediaSource::videoDevices()) {
-        if (!captureDevice.enabled())
-            continue;
-
-        sources.append(captureDevice);
-    }
-
-    return sources;
-}
-
-RealtimeMediaSource::AudioCaptureFactory& MockRealtimeMediaSourceCenter::defaultAudioFactory()
-{
-    return MockRealtimeAudioSource::factory();
-}
-
-RealtimeMediaSource::VideoCaptureFactory& MockRealtimeMediaSourceCenter::defaultVideoFactory()
-{
-    return MockRealtimeVideoSource::factory();
-}
-
-CaptureDeviceManager& MockRealtimeMediaSourceCenter::defaultAudioCaptureDeviceManager()
-{
-    return m_defaultAudioCaptureDeviceManager;
-}
-
-CaptureDeviceManager& MockRealtimeMediaSourceCenter::defaultVideoCaptureDeviceManager()
-{
-    return m_defaultVideoCaptureDeviceManager;
-}
-
-ExceptionOr<void> MockRealtimeMediaSourceCenter::setDeviceEnabled(const String& id, bool enabled)
-{
-    for (auto& captureDevice : getMediaStreamDevices()) {
-        if (id == captureDevice.persistentId()) {
-            if (enabled != captureDevice.enabled()) {
-                captureDevice.setEnabled(enabled);
-                captureDevicesChanged();
-            }
-
-            return { };
-        }
-    }
-
-    return Exception { NOT_FOUND_ERR };
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 7ce2591..dfa5ee0 100644 (file)
@@ -29,6 +29,8 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "CaptureDeviceManager.h"
+#include "MockRealtimeAudioSource.h"
+#include "MockRealtimeVideoSource.h"
 #include "RealtimeMediaSourceCenter.h"
 
 namespace WebCore {
@@ -38,28 +40,25 @@ public:
     WEBCORE_EXPORT static void setMockRealtimeMediaSourceCenterEnabled(bool);
 
 private:
+    MockRealtimeMediaSourceCenter() = default;
     friend NeverDestroyed<MockRealtimeMediaSourceCenter>;
-    MockRealtimeMediaSourceCenter();
 
-    Vector<CaptureDevice> getMediaStreamDevices() final;
-    void createMediaStream(NewMediaStreamHandler&&, const String& audioDeviceID, const String& videoDeviceID, const MediaConstraints* audioConstraints, const MediaConstraints* videoConstraints) final;
+    RealtimeMediaSource::AudioCaptureFactory& defaultAudioFactory() final { return MockRealtimeAudioSource::factory(); }
+    RealtimeMediaSource::VideoCaptureFactory& defaultVideoFactory() final { return MockRealtimeVideoSource::factory(); }
+    CaptureDeviceManager& defaultAudioCaptureDeviceManager() final { return m_defaultAudioCaptureDeviceManager; }
+    CaptureDeviceManager& defaultVideoCaptureDeviceManager() final { return m_defaultVideoCaptureDeviceManager; }
 
-    RealtimeMediaSource::AudioCaptureFactory& defaultAudioFactory() final;
-    RealtimeMediaSource::VideoCaptureFactory& defaultVideoFactory() final;
-    CaptureDeviceManager& defaultAudioCaptureDeviceManager() final;
-    CaptureDeviceManager& defaultVideoCaptureDeviceManager() final;
-
-    ExceptionOr<void> setDeviceEnabled(const String& persistentID, bool) final;
-
-    class MockCaptureDeviceManager final : public CaptureDeviceManager {
+    class MockAudioCaptureDeviceManager final : public CaptureDeviceManager {
     private:
-        Vector<CaptureDevice>& captureDevices() final { return m_devices; }
-
-        Vector<CaptureDevice> m_devices;
+        Vector<CaptureDevice>& captureDevices() final { return MockRealtimeMediaSource::audioDevices(); }
+    };
+    class MockVideoCaptureDeviceManager final : public CaptureDeviceManager {
+    private:
+        Vector<CaptureDevice>& captureDevices() final { return MockRealtimeMediaSource::videoDevices(); }
     };
 
-    MockCaptureDeviceManager m_defaultAudioCaptureDeviceManager;
-    MockCaptureDeviceManager m_defaultVideoCaptureDeviceManager;
+    MockAudioCaptureDeviceManager m_defaultAudioCaptureDeviceManager;
+    MockVideoCaptureDeviceManager m_defaultVideoCaptureDeviceManager;
 };
 
 }