Changeset 247407 in webkit


Ignore:
Timestamp:
Jul 12, 2019 5:05:18 PM (5 years ago)
Author:
commit-queue@webkit.org
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 <tsaunier@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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247399 r247407  
     12019-07-12  Thibault Saunier  <tsaunier@igalia.com>
     2
     3        [GStreamer] Mock GStreamer realtime sources should keep a Ref of their mock realtime media sources
     4        https://bugs.webkit.org/show_bug.cgi?id=194326
     5
     6        WrappedMockRealtimeVideoSource is a subclass of RealtimeMediaSource which is refcounted, we can't
     7        use a unique_ptr on those.
     8
     9        Also changed m_wrappedSource type to its actual type so it is cleaner even if needed
     10        to upcast it to RealtimeMediaSource so some method that are made private in the mock
     11        can still be called.
     12
     13        Reviewed by Youenn Fablet.
     14
     15        This fixes MediaStream tests
     16
     17        * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp:
     18        (WebCore::WrappedMockRealtimeAudioSource::create):
     19        (WebCore::WrappedMockRealtimeAudioSource::asRealtimeMediaSource):
     20        (WebCore::WrappedMockRealtimeAudioSource::WrappedMockRealtimeAudioSource):
     21        (WebCore::m_wrappedSource):
     22        (WebCore::MockGStreamerAudioCaptureSource::startProducingData):
     23        (WebCore::MockGStreamerAudioCaptureSource::settings):
     24        (WebCore::MockGStreamerAudioCaptureSource::capabilities):
     25        * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h:
     26        * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp:
     27        (WebCore::WrappedMockRealtimeVideoSource::create):
     28        (WebCore::WrappedMockRealtimeVideoSource::asRealtimeMediaSource):
     29        (WebCore::WrappedMockRealtimeVideoSource::WrappedMockRealtimeVideoSource):
     30        (WebCore::m_wrappedSource):
     31        (WebCore::MockGStreamerVideoCaptureSource::settings):
     32        (WebCore::MockGStreamerVideoCaptureSource::capabilities):
     33        * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h:
     34
    1352019-07-12  Alex Christensen  <achristensen@webkit.org>
    236
  • trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp

    r241145 r247407  
    4242class WrappedMockRealtimeAudioSource : public MockRealtimeAudioSource {
    4343public:
    44     WrappedMockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt)
    45         : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
    46         , m_src(nullptr)
    47     {
     44    static Ref<WrappedMockRealtimeAudioSource> create(String&& deviceID, String&& name, String&& hashSalt)
     45    {
     46        return adoptRef(*new WrappedMockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     47    }
     48
     49    RealtimeMediaSource& asRealtimeMediaSource()
     50    {
     51        return *this;
    4852    }
    4953
     
    129133    uint64_t m_samplesEmitted { 0 };
    130134    uint64_t m_samplesRendered { 0 };
     135
     136private:
     137    WrappedMockRealtimeAudioSource(String&& deviceID, String&& name, String&& hashSalt)
     138        : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     139    {
     140    }
    131141};
    132142
     
    155165MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
    156166    : GStreamerAudioCaptureSource(String { deviceID }, String { name }, String { hashSalt })
    157     , m_wrappedSource(std::make_unique<WrappedMockRealtimeAudioSource>(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
     167    , m_wrappedSource(WrappedMockRealtimeAudioSource::create(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
    158168{
    159169    m_wrappedSource->addObserver(*this);
     
    175185{
    176186    GStreamerAudioCaptureSource::startProducingData();
    177     static_cast<WrappedMockRealtimeAudioSource*>(m_wrappedSource.get())->start(capturer()->source());
     187    static_cast<WrappedMockRealtimeAudioSource&>(m_wrappedSource.get()).start(capturer()->source());
    178188}
    179189
    180190const RealtimeMediaSourceSettings& MockGStreamerAudioCaptureSource::settings()
    181191{
    182     return m_wrappedSource->settings();
     192    return m_wrappedSource->asRealtimeMediaSource().settings();
    183193}
    184194
    185195const RealtimeMediaSourceCapabilities& MockGStreamerAudioCaptureSource::capabilities()
    186196{
    187     m_capabilities = m_wrappedSource->capabilities();
    188     m_currentSettings = m_wrappedSource->settings();
    189     return m_wrappedSource->capabilities();
     197    m_capabilities = m_wrappedSource->asRealtimeMediaSource().capabilities();
     198    m_currentSettings = m_wrappedSource->asRealtimeMediaSource().settings();
     199    return m_wrappedSource->asRealtimeMediaSource().capabilities();
    190200}
    191201
  • trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h

    r241145 r247407  
    2828namespace WebCore {
    2929
     30class WrappedMockRealtimeAudioSource;
    3031class MockGStreamerAudioCaptureSource final : public GStreamerAudioCaptureSource, RealtimeMediaSource::Observer {
    3132public:
     
    4041    const RealtimeMediaSourceSettings& settings() final;
    4142    const RealtimeMediaSourceCapabilities& capabilities() final;
     43    void captureFailed() final;
     44    void videoSampleAvailable(MediaSample&) final { };
    4245
    43     void captureFailed();
    44     std::unique_ptr<RealtimeMediaSource> m_wrappedSource;
    45 
    46     void videoSampleAvailable(MediaSample&) override { };
     46    Ref<WrappedMockRealtimeAudioSource> m_wrappedSource;
    4747};
    4848
  • trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp

    r241145 r247407  
    3434class WrappedMockRealtimeVideoSource : public MockRealtimeVideoSource {
    3535public:
    36     WrappedMockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt)
    37         : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     36    static Ref<WrappedMockRealtimeVideoSource> create(String&& deviceID, String&& name, String&& hashSalt)
    3837    {
     38        return adoptRef(*new WrappedMockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
     39    }
     40
     41    RealtimeMediaSource& asRealtimeMediaSource()
     42    {
     43        return *this;
    3944    }
    4045
     
    5964
    6065        videoSampleAvailable(MediaSampleGStreamer::create(WTFMove(gstSample), FloatSize(), String()));
     66    }
     67
     68private:
     69    WrappedMockRealtimeVideoSource(String&& deviceID, String&& name, String&& hashSalt)
     70        : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
     71    {
    6172    }
    6273};
     
    98109MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
    99110    : GStreamerVideoCaptureSource(String { deviceID }, String { name }, String { hashSalt }, "appsrc")
    100     , m_wrappedSource(std::make_unique<WrappedMockRealtimeVideoSource>(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
     111    , m_wrappedSource(WrappedMockRealtimeVideoSource::create(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
    101112{
    102113    m_wrappedSource->addObserver(*this);
     
    121132const RealtimeMediaSourceSettings& MockGStreamerVideoCaptureSource::settings()
    122133{
    123     return m_wrappedSource->settings();
     134    return m_wrappedSource->asRealtimeMediaSource().settings();
    124135}
    125136
    126137const RealtimeMediaSourceCapabilities& MockGStreamerVideoCaptureSource::capabilities()
    127138{
    128     m_capabilities = m_wrappedSource->capabilities();
    129     m_currentSettings = m_wrappedSource->settings();
     139    m_capabilities = m_wrappedSource->asRealtimeMediaSource().capabilities();
     140    m_currentSettings = m_wrappedSource->asRealtimeMediaSource().settings();
    130141    return m_capabilities.value();
    131142}
  • trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h

    r241145 r247407  
    4444    void startProducingData() final;
    4545    const RealtimeMediaSourceSettings& settings() final;
    46     std::unique_ptr<RealtimeMediaSource> m_wrappedSource;
    4746    const RealtimeMediaSourceCapabilities& capabilities() final;
    48     void captureFailed() override;
     47    void captureFailed() final;
     48    void videoSampleAvailable(MediaSample&) final;
    4949
    50     void videoSampleAvailable(MediaSample&) override;
     50    Ref<WrappedMockRealtimeVideoSource> m_wrappedSource;
    5151};
    5252
Note: See TracChangeset for help on using the changeset viewer.