Title: [247407] trunk/Source/WebCore
Revision
247407
Author
commit-qu...@webkit.org
Date
2019-07-12 17:05:18 -0700 (Fri, 12 Jul 2019)

Log Message

[GStreamer] Mock GStreamer realtime sources should keep a Ref of their mock realtime media sources
https://bugs.webkit.org/show_bug.cgi?id=194326

WrappedMockRealtimeVideoSource is a subclass of RealtimeMediaSource which is refcounted, we can't
use a unique_ptr on those.

Also changed m_wrappedSource type to its actual type so it is cleaner even if needed
to upcast it to RealtimeMediaSource so some method that are made private in the mock
can still be called.

Patch by Thibault Saunier <tsaun...@igalia.com> on 2019-07-12
Reviewed by Youenn Fablet.

This fixes MediaStream tests

* platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:
(WebCore::WrappedMockRealtimeAudioSource::create):
(WebCore::WrappedMockRealtimeAudioSource::asRealtimeMediaSource):
(WebCore::WrappedMockRealtimeAudioSource::WrappedMockRealtimeAudioSource):
(WebCore::m_wrappedSource):
(WebCore::MockGStreamerAudioCaptureSource::startProducingData):
(WebCore::MockGStreamerAudioCaptureSource::settings):
(WebCore::MockGStreamerAudioCaptureSource::capabilities):
* platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h:
* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp:
(WebCore::WrappedMockRealtimeVideoSource::create):
(WebCore::WrappedMockRealtimeVideoSource::asRealtimeMediaSource):
(WebCore::WrappedMockRealtimeVideoSource::WrappedMockRealtimeVideoSource):
(WebCore::m_wrappedSource):
(WebCore::MockGStreamerVideoCaptureSource::settings):
(WebCore::MockGStreamerVideoCaptureSource::capabilities):
* platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (247406 => 247407)


--- trunk/Source/WebCore/ChangeLog	2019-07-12 23:21:32 UTC (rev 247406)
+++ trunk/Source/WebCore/ChangeLog	2019-07-13 00:05:18 UTC (rev 247407)
@@ -1,3 +1,37 @@
+2019-07-12  Thibault Saunier  <tsaun...@igalia.com>
+
+        [GStreamer] Mock GStreamer realtime sources should keep a Ref of their mock realtime media sources
+        https://bugs.webkit.org/show_bug.cgi?id=194326
+
+        WrappedMockRealtimeVideoSource is a subclass of RealtimeMediaSource which is refcounted, we can't
+        use a unique_ptr on those.
+
+        Also changed m_wrappedSource type to its actual type so it is cleaner even if needed
+        to upcast it to RealtimeMediaSource so some method that are made private in the mock
+        can still be called.
+
+        Reviewed by Youenn Fablet.
+
+        This fixes MediaStream tests
+
+        * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:
+        (WebCore::WrappedMockRealtimeAudioSource::create):
+        (WebCore::WrappedMockRealtimeAudioSource::asRealtimeMediaSource):
+        (WebCore::WrappedMockRealtimeAudioSource::WrappedMockRealtimeAudioSource):
+        (WebCore::m_wrappedSource):
+        (WebCore::MockGStreamerAudioCaptureSource::startProducingData):
+        (WebCore::MockGStreamerAudioCaptureSource::settings):
+        (WebCore::MockGStreamerAudioCaptureSource::capabilities):
+        * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h:
+        * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp:
+        (WebCore::WrappedMockRealtimeVideoSource::create):
+        (WebCore::WrappedMockRealtimeVideoSource::asRealtimeMediaSource):
+        (WebCore::WrappedMockRealtimeVideoSource::WrappedMockRealtimeVideoSource):
+        (WebCore::m_wrappedSource):
+        (WebCore::MockGStreamerVideoCaptureSource::settings):
+        (WebCore::MockGStreamerVideoCaptureSource::capabilities):
+        * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h:
+
 2019-07-12  Alex Christensen  <achristen...@webkit.org>
 
         Change RELEASE_ASSERT in DocumentWriter::addData to ASSERT and early return

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp (247406 => 247407)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp	2019-07-12 23:21:32 UTC (rev 247406)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp	2019-07-13 00:05:18 UTC (rev 247407)
@@ -41,12 +41,16 @@
 
 class WrappedMockRealtimeAudioSource : public MockRealtimeAudioSource {
 public:
-    WrappedMockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt)
-        : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
-        , m_src(nullptr)
+    static Ref<WrappedMockRealtimeAudioSource> create(String&& deviceID, String&& name, String&& hashSalt)
     {
+        return adoptRef(*new WrappedMockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     }
 
+    RealtimeMediaSource& asRealtimeMediaSource()
+    {
+        return *this;
+    }
+
     void start(GRefPtr<GstElement> src)
     {
         m_src = src;
@@ -128,6 +132,12 @@
     uint32_t m_maximiumFrameCount;
     uint64_t m_samplesEmitted { 0 };
     uint64_t m_samplesRendered { 0 };
+
+private:
+    WrappedMockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt)
+        : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
+    {
+    }
 };
 
 CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID,
@@ -154,7 +164,7 @@
 
 MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
     : GStreamerAudioCaptureSource(String { deviceID }, String { name }, String { hashSalt })
-    , m_wrappedSource(std::make_unique<WrappedMockRealtimeAudioSource>(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
+    , m_wrappedSource(WrappedMockRealtimeAudioSource::create(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
 {
     m_wrappedSource->addObserver(*this);
 }
@@ -174,19 +184,19 @@
 void MockGStreamerAudioCaptureSource::startProducingData()
 {
     GStreamerAudioCaptureSource::startProducingData();
-    static_cast<WrappedMockRealtimeAudioSource*>(m_wrappedSource.get())->start(capturer()->source());
+    static_cast<WrappedMockRealtimeAudioSource&>(m_wrappedSource.get()).start(capturer()->source());
 }
 
 const RealtimeMediaSourceSettings& MockGStreamerAudioCaptureSource::settings()
 {
-    return m_wrappedSource->settings();
+    return m_wrappedSource->asRealtimeMediaSource().settings();
 }
 
 const RealtimeMediaSourceCapabilities& MockGStreamerAudioCaptureSource::capabilities()
 {
-    m_capabilities = m_wrappedSource->capabilities();
-    m_currentSettings = m_wrappedSource->settings();
-    return m_wrappedSource->capabilities();
+    m_capabilities = m_wrappedSource->asRealtimeMediaSource().capabilities();
+    m_currentSettings = m_wrappedSource->asRealtimeMediaSource().settings();
+    return m_wrappedSource->asRealtimeMediaSource().capabilities();
 }
 
 void MockGStreamerAudioCaptureSource::captureFailed()

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h (247406 => 247407)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h	2019-07-12 23:21:32 UTC (rev 247406)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h	2019-07-13 00:05:18 UTC (rev 247407)
@@ -27,6 +27,7 @@
 
 namespace WebCore {
 
+class WrappedMockRealtimeAudioSource;
 class MockGStreamerAudioCaptureSource final : public GStreamerAudioCaptureSource, RealtimeMediaSource::Observer {
 public:
     MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt);
@@ -39,11 +40,10 @@
     void startProducingData() final;
     const RealtimeMediaSourceSettings& settings() final;
     const RealtimeMediaSourceCapabilities& capabilities() final;
+    void captureFailed() final;
+    void videoSampleAvailable(MediaSample&) final { };
 
-    void captureFailed();
-    std::unique_ptr<RealtimeMediaSource> m_wrappedSource;
-
-    void videoSampleAvailable(MediaSample&) override { };
+    Ref<WrappedMockRealtimeAudioSource> m_wrappedSource;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp (247406 => 247407)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp	2019-07-12 23:21:32 UTC (rev 247406)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp	2019-07-13 00:05:18 UTC (rev 247407)
@@ -33,11 +33,16 @@
 
 class WrappedMockRealtimeVideoSource : public MockRealtimeVideoSource {
 public:
-    WrappedMockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt)
-        : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
+    static Ref<WrappedMockRealtimeVideoSource> create(String&& deviceID, String&& name, String&& hashSalt)
     {
+        return adoptRef(*new WrappedMockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     }
 
+    RealtimeMediaSource& asRealtimeMediaSource()
+    {
+        return *this;
+    }
+
     void updateSampleBuffer()
     {
         auto imageBuffer = this->imageBuffer();
@@ -59,6 +64,12 @@
 
         videoSampleAvailable(MediaSampleGStreamer::create(WTFMove(gstSample), FloatSize(), String()));
     }
+
+private:
+    WrappedMockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt)
+        : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
+    {
+    }
 };
 
 CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID,
@@ -97,7 +108,7 @@
 
 MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
     : GStreamerVideoCaptureSource(String { deviceID }, String { name }, String { hashSalt }, "appsrc")
-    , m_wrappedSource(std::make_unique<WrappedMockRealtimeVideoSource>(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
+    , m_wrappedSource(WrappedMockRealtimeVideoSource::create(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
 {
     m_wrappedSource->addObserver(*this);
 }
@@ -120,13 +131,13 @@
 
 const RealtimeMediaSourceSettings& MockGStreamerVideoCaptureSource::settings()
 {
-    return m_wrappedSource->settings();
+    return m_wrappedSource->asRealtimeMediaSource().settings();
 }
 
 const RealtimeMediaSourceCapabilities& MockGStreamerVideoCaptureSource::capabilities()
 {
-    m_capabilities = m_wrappedSource->capabilities();
-    m_currentSettings = m_wrappedSource->settings();
+    m_capabilities = m_wrappedSource->asRealtimeMediaSource().capabilities();
+    m_currentSettings = m_wrappedSource->asRealtimeMediaSource().settings();
     return m_capabilities.value();
 }
 

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h (247406 => 247407)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h	2019-07-12 23:21:32 UTC (rev 247406)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h	2019-07-13 00:05:18 UTC (rev 247407)
@@ -43,11 +43,11 @@
     void stopProducingData() final;
     void startProducingData() final;
     const RealtimeMediaSourceSettings& settings() final;
-    std::unique_ptr<RealtimeMediaSource> m_wrappedSource;
     const RealtimeMediaSourceCapabilities& capabilities() final;
-    void captureFailed() override;
+    void captureFailed() final;
+    void videoSampleAvailable(MediaSample&) final;
 
-    void videoSampleAvailable(MediaSample&) override;
+    Ref<WrappedMockRealtimeVideoSource> m_wrappedSource;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to