Diff
Modified: trunk/LayoutTests/ChangeLog (260936 => 260937)
--- trunk/LayoutTests/ChangeLog 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/LayoutTests/ChangeLog 2020-04-30 08:12:01 UTC (rev 260937)
@@ -1,3 +1,12 @@
+2020-04-30 Philippe Normand <[email protected]>
+
+ [GStreamer] fast/mediastream/get-user-media-device-id.html failing
+ https://bugs.webkit.org/show_bug.cgi?id=190576
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ * platform/gtk/TestExpectations: Unskip now-passing mediastream tests.
+
2020-04-29 Noam Rosenthal <[email protected]>
[Mac] http/tests/performance/paint-timing/performance-paint-timing-fcp-after-visually-non-empty-for-num-chars.html is flaky
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (260936 => 260937)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2020-04-30 08:12:01 UTC (rev 260937)
@@ -559,11 +559,6 @@
webkit.org/b/186933 webrtc/peer-connection-createMediaStreamDestination.html
-webkit.org/b/205930 webrtc/audio-peer-connection-webaudio.html [ Failure ]
-webkit.org/b/205930 webrtc/peer-connection-audio-mute2.html [ Failure ]
-webkit.org/b/205930 webrtc/peer-connection-audio-unmute.html [ Failure Slow ]
-webkit.org/b/205930 webrtc/peer-connection-remote-audio-mute2.html [ Failure ]
-
imported/w3c/web-platform-tests/webrtc/ [ Skip ]
http/tests/webrtc [ Skip ]
@@ -581,7 +576,6 @@
webkit.org/b/79203 fast/mediastream/RTCPeerConnection-media-setup-two-dialogs.html [ Pass Failure Crash ]
webkit.org/b/79203 fast/mediastream/RTCPeerConnection-stats.html [ Timeout Crash ]
webkit.org/b/79203 fast/mediastream/RTCRtpSender-replaceTrack.html [ Failure Crash ]
-webkit.org/b/79203 fast/mediastream/constraint-intrinsic-size.html [ Skip ]
webkit.org/b/79203 fast/mediastream/get-display-media-muted.html [ Timeout ]
webkit.org/b/79203 fast/mediastream/getUserMedia-webaudio.html [ Timeout Pass ]
webkit.org/b/79203 fast/mediastream/mock-media-source-webaudio.html [ Timeout Pass ]
@@ -594,7 +588,6 @@
webkit.org/b/207675 fast/mediastream/delayed-permission-allowed.html [ Pass Crash ]
webkit.org/b/208120 fast/mediastream/media-element-current-time.html [ Failure ]
webkit.org/b/209130 fast/mediastream/change-tracks-media-stream-being-played.html [ Crash Pass Timeout ]
-webkit.org/b/210337 fast/mediastream/mediastreamtrack-audio-clone.html [ Failure ]
webkit.org/b/210385 fast/mediastream/audio-track-enabled.html [ Crash Pass ]
webkit.org/b/210385 fast/mediastream/getUserMedia-default.html [ Crash Pass ]
webkit.org/b/210385 fast/mediastream/stream-switch.html [ Crash Pass ]
@@ -606,8 +599,6 @@
webkit.org/b/169811 fast/mediastream/captureStream/canvas2d.html [ Crash Timeout ]
webkit.org/b/169811 fast/mediastream/captureStream/canvas3d.html [ Crash Timeout ]
-webkit.org/b/190576 fast/mediastream/get-user-media-device-id.html [ Failure ]
-
# No support for GPUProcess yet
fast/mediastream/captureInGPUProcess.html [ Skip ]
@@ -1285,10 +1276,8 @@
webkit.org/b/206655 [ Release ] inspector/page/overrideSetting-MockCaptureDevicesEnabled.html [ Failure ]
-webkit.org/b/206656 imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-MediaElement-firstframe.https.html [ Failure ]
webkit.org/b/206656 imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-removetrack.https.html [ Failure Crash ]
webkit.org/b/206656 imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-video-is-black.https.html [ Failure ]
-webkit.org/b/206656 imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-getSettings.https.html [ Failure ]
webkit.org/b/206656 imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-MediaElement-preload-none-manual.https.html [ Crash Failure Pass ]
# LFC (LayoutFormatingContext is disabled by default).
@@ -1580,9 +1569,9 @@
webkit.org/b/209533 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_loadstart_noautoplay.html [ Crash Pass ]
webkit.org/b/209533 media/track/track-automatic-subtitles.html [ Crash Pass ]
-webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints1.html [ Crash ]
-webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints2.html [ Crash ]
-webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints3.html [ Crash ]
+webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints1.html [ Skip ]
+webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints2.html [ Skip ]
+webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints3.html [ Skip ]
#////////////////////////////////////////////////////////////////////////////////////////
# End of Crashing tests
@@ -3330,8 +3319,6 @@
webkit.org/b/206148 http/tests/local/file-url-host.html [ Timeout ]
-webkit.org/b/206149 webrtc/peer-connection-remote-audio-mute.html [ Timeout ]
-
webkit.org/b/202736 http/tests/appcache/remove-cache.html [ Failure Timeout Pass ]
webkit.org/b/202736 [ Release ] http/wpt/cache-storage/quota-third-party.https.html [ Failure Timeout Pass ]
@@ -4441,7 +4428,6 @@
webkit.org/b/192883 fast/cookies/cookie-averse-document.html [ Failure ]
webkit.org/b/192883 fast/cookies/local-file-can-set-cookies.html [ Failure ]
-webkit.org/b/192886 fast/mediastream/media-stream-renders-first-frame.html [ Failure ]
webkit.org/b/192888 fast/mediastream/resize-trim.html [ Failure ]
webkit.org/b/192900 imported/w3c/web-platform-tests/eventsource/format-mime-bogus.htm [ Failure ]
@@ -4671,8 +4657,6 @@
webkit.org/b/207678 imported/w3c/web-platform-tests/url/a-element-xhtml.xhtml [ Failure ]
webkit.org/b/207678 imported/w3c/web-platform-tests/url/a-element.html [ Failure ]
-webkit.org/b/210843 fast/mediastream/mediastreamtrack-video-frameRate-clone-increasing.html [ Failure ]
-
#////////////////////////////////////////////////////////////////////////////////////////
# End of non-crashing, non-flaky tests failing
#////////////////////////////////////////////////////////////////////////////////////////
Modified: trunk/Source/WebCore/ChangeLog (260936 => 260937)
--- trunk/Source/WebCore/ChangeLog 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/ChangeLog 2020-04-30 08:12:01 UTC (rev 260937)
@@ -1,3 +1,40 @@
+2020-04-30 Philippe Normand <[email protected]>
+
+ [GStreamer] fast/mediastream/get-user-media-device-id.html failing
+ https://bugs.webkit.org/show_bug.cgi?id=190576
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ The test was failing due to deviceId invalid constraint, which led
+ me to rewrite the GStreamer Mock sources, removing various hacks
+ and appsrc usage, which is not needed because we rely on
+ audioSamplesAvailable and videoSamplesAvailable notifications.
+
+ This patch also fixes the audio mock, which was generating silence
+ until now.
+
+ * platform/GStreamer.cmake:
+ * platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp:
+ (WebCore::WebKitMediaStreamTrackObserver::WebKitMediaStreamTrackObserver):
+ * platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp: Removed.
+ * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp: Removed.
+ * platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h: Removed.
+ * platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp: Added.
+ (WebCore::MockRealtimeAudioSource::create):
+ (WebCore::MockRealtimeAudioSourceGStreamer::createForMockAudioCapturer):
+ (WebCore::MockRealtimeAudioSourceGStreamer::MockRealtimeAudioSourceGStreamer):
+ (WebCore::MockRealtimeAudioSourceGStreamer::render):
+ (WebCore::MockRealtimeAudioSourceGStreamer::addHum):
+ (WebCore::MockRealtimeAudioSourceGStreamer::reconfigure):
+ * platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.h: Copied from Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h.
+ * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp: Added.
+ (WebCore::MockRealtimeVideoSource::create):
+ (WebCore::MockRealtimeVideoSourceGStreamer::createForMockDisplayCapturer):
+ (WebCore::MockRealtimeVideoSourceGStreamer::MockRealtimeVideoSourceGStreamer):
+ (WebCore::MockRealtimeVideoSourceGStreamer::updateSampleBuffer):
+ * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h: Renamed from Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h.
+ * platform/mock/MockRealtimeVideoSource.h:
+
2020-04-29 Simon Fraser <[email protected]>
Use initializers in PlatformMouseEvent and WebEvent
Modified: trunk/Source/WebCore/platform/GStreamer.cmake (260936 => 260937)
--- trunk/Source/WebCore/platform/GStreamer.cmake 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/GStreamer.cmake 2020-04-30 08:12:01 UTC (rev 260937)
@@ -50,8 +50,8 @@
platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp
platform/mediastream/gstreamer/GStreamerVideoCapturer.cpp
platform/mediastream/gstreamer/GStreamerVideoFrameLibWebRTC.cpp
- platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp
- platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp
+ platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp
+ platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp
platform/mediastream/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp
platform/mediastream/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp
platform/mediastream/gstreamer/RealtimeMediaSourceCenterLibWebRTC.cpp
Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp (260936 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp 2020-04-30 08:12:01 UTC (rev 260937)
@@ -112,7 +112,8 @@
public:
virtual ~WebKitMediaStreamTrackObserver() { };
WebKitMediaStreamTrackObserver(WebKitMediaStreamSrc* src)
- : m_mediaStreamSrc(src) { }
+ : m_mediaStreamSrc(src)
+ , m_enabled(true) { }
void trackStarted(MediaStreamTrackPrivate&) final { };
void trackEnded(MediaStreamTrackPrivate& track) final
@@ -120,27 +121,36 @@
webkitMediaStreamSrcTrackEnded(m_mediaStreamSrc, track);
}
+ void trackEnabledChanged(MediaStreamTrackPrivate& track) final
+ {
+ m_enabled = track.enabled();
+ }
+
void trackMutedChanged(MediaStreamTrackPrivate&) final { };
void trackSettingsChanged(MediaStreamTrackPrivate&) final { };
- void trackEnabledChanged(MediaStreamTrackPrivate&) final { };
void readyStateChanged(MediaStreamTrackPrivate&) final { };
void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample& sample) final
{
- auto gstsample = static_cast<MediaSampleGStreamer*>(&sample)->platformSample().sample.gstSample;
+ if (!m_enabled)
+ return;
- webkitMediaStreamSrcPushVideoSample(m_mediaStreamSrc, gstsample);
+ auto gstSample = static_cast<MediaSampleGStreamer*>(&sample)->platformSample().sample.gstSample;
+ webkitMediaStreamSrcPushVideoSample(m_mediaStreamSrc, gstSample);
}
void audioSamplesAvailable(const MediaTime&, const PlatformAudioData& audioData, const AudioStreamDescription&, size_t) final
{
- auto audiodata = static_cast<const GStreamerAudioData&>(audioData);
+ if (!m_enabled)
+ return;
- webkitMediaStreamSrcPushAudioSample(m_mediaStreamSrc, audiodata.getSample());
+ auto data = "" GStreamerAudioData&>(audioData);
+ webkitMediaStreamSrcPushAudioSample(m_mediaStreamSrc, data.getSample());
}
private:
WebKitMediaStreamSrc* m_mediaStreamSrc;
+ bool m_enabled;
};
class WebKitMediaStreamObserver
@@ -198,7 +208,6 @@
self->setEnoughData(true);
}
-
void setSrc(GstElement *src)
{
m_src = adoptGRef(GST_ELEMENT(g_object_ref_sink(src)));
Deleted: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp (260936 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.cpp 2020-04-30 08:12:01 UTC (rev 260937)
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Author: Thibault Saunier <[email protected]>
- * Author: Alejandro G. Castro <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
-#include "MockGStreamerAudioCaptureSource.h"
-
-#include "GStreamerAudioStreamDescription.h"
-#include "MockRealtimeAudioSource.h"
-
-#include <gst/app/gstappsrc.h>
-
-namespace WebCore {
-
-static const double s_Tau = 2 * M_PI;
-static const double s_BipBopDuration = 0.07;
-static const double s_BipBopVolume = 0.5;
-static const double s_BipFrequency = 1500;
-static const double s_BopFrequency = 500;
-static const double s_HumFrequency = 150;
-static const double s_HumVolume = 0.1;
-
-// FIXME: Add noise of frequency 3000 in case echoCancellation is false.
-class WrappedMockRealtimeAudioSource : public MockRealtimeAudioSource {
-public:
- 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;
- if (m_streamFormat)
- gst_app_src_set_caps(GST_APP_SRC(m_src.get()), m_streamFormat->caps());
- MockRealtimeAudioSource::start();
- }
-
- void addHum(float amplitude, float frequency, float sampleRate, uint64_t start, float *p, uint64_t count)
- {
- if (echoCancellation()) {
- GST_DEBUG("echo cancel..., no hum");
- return;
- }
- float humPeriod = sampleRate / frequency;
- for (uint64_t i = start, end = start + count; i < end; ++i) {
- float a = amplitude * sin(i * s_Tau / humPeriod);
- a += *p;
- *p++ = a;
- }
- }
-
- void render(Seconds delta)
- {
- ASSERT(m_src);
-
- if (!m_bipBopBuffer.size())
- reconfigure();
-
- uint32_t totalFrameCount = GST_ROUND_UP_16(static_cast<size_t>(delta.seconds() * sampleRate()));
- uint32_t frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
- while (frameCount) {
- uint32_t bipBopStart = m_samplesRendered % m_bipBopBuffer.size();
- uint32_t bipBopRemain = m_bipBopBuffer.size() - bipBopStart;
- uint32_t bipBopCount = std::min(frameCount, bipBopRemain);
-
- GstBuffer* buffer = gst_buffer_new_allocate(nullptr, bipBopCount * m_streamFormat->bytesPerFrame(), nullptr);
- {
- auto map = GstMappedBuffer::create(buffer, GST_MAP_WRITE);
-
- if (!muted()) {
- memcpy(map->data(), &m_bipBopBuffer[bipBopStart], sizeof(float) * bipBopCount);
- addHum(s_HumVolume, s_HumFrequency, sampleRate(), m_samplesRendered, (float*)map->data(), bipBopCount);
- } else
- memset(map->data(), 0, sizeof(float) * bipBopCount);
- }
-
- gst_app_src_push_buffer(GST_APP_SRC(m_src.get()), buffer);
- m_samplesRendered += bipBopCount;
- totalFrameCount -= bipBopCount;
- frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
- }
- }
-
- void reconfigure()
- {
- GstAudioInfo info;
- auto rate = sampleRate();
- size_t sampleCount = 2 * rate;
-
- m_maximiumFrameCount = WTF::roundUpToPowerOfTwo(renderInterval().seconds() * sampleRate());
- gst_audio_info_set_format(&info, GST_AUDIO_FORMAT_F32LE, rate, 1, nullptr);
- m_streamFormat = GStreamerAudioStreamDescription(info);
-
- if (m_src)
- gst_app_src_set_caps(GST_APP_SRC(m_src.get()), m_streamFormat->caps());
-
- m_bipBopBuffer.resize(sampleCount);
- m_bipBopBuffer.fill(0);
-
- size_t bipBopSampleCount = ceil(s_BipBopDuration * rate);
- size_t bipStart = 0;
- size_t bopStart = rate;
-
- addHum(s_BipBopVolume, s_BipFrequency, rate, 0, static_cast<float*>(m_bipBopBuffer.data() + bipStart), bipBopSampleCount);
- addHum(s_BipBopVolume, s_BopFrequency, rate, 0, static_cast<float*>(m_bipBopBuffer.data() + bopStart), bipBopSampleCount);
- }
-
- void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag> settings)
- {
- if (settings.contains(RealtimeMediaSourceSettings::Flag::SampleRate))
- reconfigure();
-
- MockRealtimeAudioSource::settingsDidChange(settings);
- }
-
- GRefPtr<GstElement> m_src;
- Optional<GStreamerAudioStreamDescription> m_streamFormat;
- Vector<float> m_bipBopBuffer;
- 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,
- String&& name, String&& hashSalt, const MediaConstraints* constraints)
-{
- auto source = adoptRef(*new MockGStreamerAudioCaptureSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
-
- if (constraints && source->applyConstraints(*constraints))
- return { };
-
- return CaptureSourceOrError(WTFMove(source));
-}
-
-Optional<RealtimeMediaSource::ApplyConstraintsError> MockGStreamerAudioCaptureSource::applyConstraints(const MediaConstraints& constraints)
-{
- m_wrappedSource->applyConstraints(constraints);
- return GStreamerAudioCaptureSource::applyConstraints(constraints);
-}
-
-void MockGStreamerAudioCaptureSource::applyConstraints(const MediaConstraints& constraints, ApplyConstraintsHandler&& completionHandler)
-{
- m_wrappedSource->applyConstraints(constraints, WTFMove(completionHandler));
-}
-
-MockGStreamerAudioCaptureSource::MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
- : GStreamerAudioCaptureSource(String { deviceID }, String { name }, String { hashSalt })
- , m_wrappedSource(WrappedMockRealtimeAudioSource::create(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
-{
- m_wrappedSource->addObserver(*this);
-}
-
-MockGStreamerAudioCaptureSource::~MockGStreamerAudioCaptureSource()
-{
- m_wrappedSource->removeObserver(*this);
-}
-
-void MockGStreamerAudioCaptureSource::stopProducingData()
-{
- m_wrappedSource->stop();
-
- GStreamerAudioCaptureSource::stopProducingData();
-}
-
-void MockGStreamerAudioCaptureSource::startProducingData()
-{
- GStreamerAudioCaptureSource::startProducingData();
- static_cast<WrappedMockRealtimeAudioSource&>(m_wrappedSource.get()).start(capturer()->source());
-}
-
-const RealtimeMediaSourceSettings& MockGStreamerAudioCaptureSource::settings()
-{
- return m_wrappedSource->asRealtimeMediaSource().settings();
-}
-
-const RealtimeMediaSourceCapabilities& MockGStreamerAudioCaptureSource::capabilities()
-{
- m_capabilities = m_wrappedSource->asRealtimeMediaSource().capabilities();
- m_currentSettings = m_wrappedSource->asRealtimeMediaSource().settings();
- return m_wrappedSource->asRealtimeMediaSource().capabilities();
-}
-
-void MockGStreamerAudioCaptureSource::captureFailed()
-{
- stop();
- RealtimeMediaSource::captureFailed();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Deleted: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h (260936 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h 2020-04-30 08:12:01 UTC (rev 260937)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Author: Thibault Saunier <[email protected]>
- * Author: Alejandro G. Castro <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
-
-#include "GStreamerAudioCaptureSource.h"
-
-namespace WebCore {
-
-class WrappedMockRealtimeAudioSource;
-class MockGStreamerAudioCaptureSource final : public GStreamerAudioCaptureSource, RealtimeMediaSource::Observer {
-public:
- MockGStreamerAudioCaptureSource(String&& deviceID, String&& name, String&& hashSalt);
- ~MockGStreamerAudioCaptureSource();
- Optional<ApplyConstraintsError> applyConstraints(const MediaConstraints&);
- void applyConstraints(const MediaConstraints&, ApplyConstraintsHandler&&) final;
-
-private:
- void stopProducingData() final;
- void startProducingData() final;
- const RealtimeMediaSourceSettings& settings() final;
- const RealtimeMediaSourceCapabilities& capabilities() final;
- void captureFailed() final;
- void videoSampleAvailable(MediaSample&) final { };
-
- Ref<WrappedMockRealtimeAudioSource> m_wrappedSource;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Deleted: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp (260936 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.cpp 2020-04-30 08:12:01 UTC (rev 260937)
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Author: Thibault Saunier <[email protected]>
- * Author: Alejandro G. Castro <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
-#include "MockGStreamerVideoCaptureSource.h"
-
-#include "MediaSampleGStreamer.h"
-#include "MockRealtimeVideoSource.h"
-
-#include <gst/app/gstappsrc.h>
-
-namespace WebCore {
-
-class WrappedMockRealtimeVideoSource : public MockRealtimeVideoSource {
-public:
- static Ref<WrappedMockRealtimeVideoSource> create(String&& deviceID, String&& name, String&& hashSalt)
- {
- return adoptRef(*new WrappedMockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
- }
-
- RealtimeMediaSource& asRealtimeMediaSource()
- {
- return *this;
- }
-
- const Vector<Ref<VideoPreset>>& presets()
- {
- return MockRealtimeVideoSource::presets();
- }
-
- bool canResizeVideoFrames() const final { return true; }
-
- void updateSampleBuffer()
- {
- auto imageBuffer = this->imageBuffer();
- if (!imageBuffer)
- return;
-
- int fpsNumerator, fpsDenominator;
- gst_util_double_to_fraction(frameRate(), &fpsNumerator, &fpsDenominator);
- auto imageSize = imageBuffer->backendSize();
- auto caps = adoptGRef(gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, "BGRA",
- "width", G_TYPE_INT, imageSize.width(),
- "height", G_TYPE_INT, imageSize.height(),
- "framerate", GST_TYPE_FRACTION, fpsNumerator, fpsDenominator, nullptr));
- auto data = ""
- auto size = data.size();
- auto buffer = adoptGRef(gst_buffer_new_wrapped(g_memdup(data.releaseBuffer().get(), size), size));
- auto gstSample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
-
- 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,
- String&& name, String&& hashSalt, const MediaConstraints* constraints)
-{
- auto source = adoptRef(*new MockGStreamerVideoCaptureSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
-
- if (constraints && source->applyConstraints(*constraints))
- return { };
-
- return CaptureSourceOrError(WTFMove(source));
-}
-
-void MockGStreamerVideoCaptureSource::startProducingData()
-{
- GStreamerVideoCaptureSource::startProducingData();
- m_wrappedSource->start();
-}
-
-void MockGStreamerVideoCaptureSource::stopProducingData()
-{
- m_wrappedSource->stop();
-
- GStreamerVideoCaptureSource::stopProducingData();
-}
-
-void MockGStreamerVideoCaptureSource::videoSampleAvailable(MediaSample& sample)
-{
- auto src = ""
-
- if (src) {
- auto gstsample = static_cast<MediaSampleGStreamer*>(&sample)->platformSample().sample.gstSample;
- gst_app_src_push_sample(GST_APP_SRC(src), gstsample);
- }
-}
-
-MockGStreamerVideoCaptureSource::MockGStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt)
- : GStreamerVideoCaptureSource(String { deviceID }, String { name }, String { hashSalt }, "appsrc")
- , m_wrappedSource(WrappedMockRealtimeVideoSource::create(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)))
-{
- m_wrappedSource->addObserver(*this);
-}
-
-MockGStreamerVideoCaptureSource::~MockGStreamerVideoCaptureSource()
-{
- m_wrappedSource->removeObserver(*this);
-}
-
-Optional<RealtimeMediaSource::ApplyConstraintsError> MockGStreamerVideoCaptureSource::applyConstraints(const MediaConstraints& constraints)
-{
- m_wrappedSource->applyConstraints(constraints);
- return GStreamerVideoCaptureSource::applyConstraints(constraints);
-}
-
-void MockGStreamerVideoCaptureSource::applyConstraints(const MediaConstraints& constraints, ApplyConstraintsHandler&& completionHandler)
-{
- m_wrappedSource->applyConstraints(constraints, WTFMove(completionHandler));
-}
-
-const RealtimeMediaSourceSettings& MockGStreamerVideoCaptureSource::settings()
-{
- return m_wrappedSource->asRealtimeMediaSource().settings();
-}
-
-const RealtimeMediaSourceCapabilities& MockGStreamerVideoCaptureSource::capabilities()
-{
- m_capabilities = m_wrappedSource->asRealtimeMediaSource().capabilities();
- m_currentSettings = m_wrappedSource->asRealtimeMediaSource().settings();
- return m_capabilities.value();
-}
-
-void MockGStreamerVideoCaptureSource::generatePresets()
-{
- setSupportedPresets(m_wrappedSource->presets());
-}
-
-void MockGStreamerVideoCaptureSource::captureFailed()
-{
- stop();
-
- RealtimeMediaSource::captureFailed();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Deleted: trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h (260936 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerVideoCaptureSource.h 2020-04-30 08:12:01 UTC (rev 260937)
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Author: Thibault Saunier <[email protected]>
- * Author: Alejandro G. Castro <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
-
-#include "GStreamerVideoCaptureSource.h"
-
-namespace WebCore {
-
-class WrappedMockRealtimeVideoSource;
-// We are subclassing GStreamerVideoCaptureSource and not MockRealtimeMediaSource
-// because the MediaPlayer expects GStreamerVideoCaptureSource to be able to properly
-// build the GStreamer pipeline. Still we make it so that it behaves as closely as possible
-// to the MockRealtimeMediaSource class by wrapping our own subclass of it.
-class MockGStreamerVideoCaptureSource final : public GStreamerVideoCaptureSource, RealtimeMediaSource::Observer {
-public:
- MockGStreamerVideoCaptureSource(String&& deviceID, String&& name, String&& hashSalt);
- ~MockGStreamerVideoCaptureSource();
- Optional<ApplyConstraintsError> applyConstraints(const MediaConstraints&);
- void applyConstraints(const MediaConstraints&, ApplyConstraintsHandler&&) final;
-
-private:
- void generatePresets() final;
- void stopProducingData() final;
- void startProducingData() final;
- const RealtimeMediaSourceSettings& settings() final;
- const RealtimeMediaSourceCapabilities& capabilities() final;
- void captureFailed() final;
- void videoSampleAvailable(MediaSample&) final;
-
- Ref<WrappedMockRealtimeVideoSource> m_wrappedSource;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Added: trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp (0 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp 2020-04-30 08:12:01 UTC (rev 260937)
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2020 Igalia S.L.
+ * Author: Thibault Saunier <[email protected]>
+ * Author: Alejandro G. Castro <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
+#include "MockRealtimeAudioSourceGStreamer.h"
+
+#include "MockRealtimeMediaSourceCenter.h"
+
+namespace WebCore {
+
+static const double s_Tau = 2 * M_PI;
+static const double s_BipBopDuration = 0.07;
+static const double s_BipBopVolume = 0.5;
+static const double s_BipFrequency = 1500;
+static const double s_BopFrequency = 500;
+static const double s_HumFrequency = 150;
+static const double s_HumVolume = 0.1;
+static const double s_NoiseFrequency = 3000;
+static const double s_NoiseVolume = 0.05;
+
+CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
+{
+#ifndef NDEBUG
+ auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
+ ASSERT(device);
+ if (!device)
+ return { "No mock microphone device"_s };
+#endif
+
+ auto source = adoptRef(*new MockRealtimeAudioSourceGStreamer(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
+ if (constraints) {
+ if (auto error = source->applyConstraints(*constraints))
+ return WTFMove(error->message);
+ }
+
+ return CaptureSourceOrError(WTFMove(source));
+}
+
+Ref<MockRealtimeAudioSource> MockRealtimeAudioSourceGStreamer::createForMockAudioCapturer(String&& deviceID, String&& name, String&& hashSalt)
+{
+ return adoptRef(*new MockRealtimeAudioSourceGStreamer(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
+}
+
+MockRealtimeAudioSourceGStreamer::MockRealtimeAudioSourceGStreamer(String&& deviceID, String&& name, String&& hashSalt)
+ : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
+{
+}
+
+void MockRealtimeAudioSourceGStreamer::render(Seconds delta)
+{
+ if (!m_bipBopBuffer.size())
+ reconfigure();
+
+ uint32_t totalFrameCount = GST_ROUND_UP_16(static_cast<size_t>(delta.seconds() * sampleRate()));
+ uint32_t frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
+
+ while (frameCount) {
+ uint32_t bipBopStart = m_samplesRendered % m_bipBopBuffer.size();
+ uint32_t bipBopRemain = m_bipBopBuffer.size() - bipBopStart;
+ uint32_t bipBopCount = std::min(frameCount, bipBopRemain);
+
+ ASSERT(m_streamFormat);
+ GstAudioInfo* info = m_streamFormat->getInfo();
+ GRefPtr<GstBuffer> buffer = adoptGRef(gst_buffer_new_allocate(nullptr, bipBopCount * m_streamFormat->bytesPerFrame(), nullptr));
+ {
+ auto map = GstMappedBuffer::create(buffer.get(), GST_MAP_WRITE);
+
+ if (muted())
+ gst_audio_format_fill_silence(info->finfo, map->data(), map->size());
+ else {
+ memcpy(map->data(), &m_bipBopBuffer[bipBopStart], sizeof(float) * bipBopCount);
+ addHum(s_HumVolume, s_HumFrequency, sampleRate(), m_samplesRendered, reinterpret_cast<float*>(map->data()), bipBopCount);
+ }
+ }
+
+ m_samplesRendered += bipBopCount;
+ totalFrameCount -= bipBopCount;
+ frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
+
+ GRefPtr<GstCaps> caps = adoptGRef(gst_audio_info_to_caps(info));
+ auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
+ auto data(std::unique_ptr<GStreamerAudioData>(new GStreamerAudioData(WTFMove(sample), *info)));
+ auto mediaTime = MediaTime((m_samplesRendered * G_USEC_PER_SEC) / sampleRate(), G_USEC_PER_SEC);
+ audioSamplesAvailable(mediaTime, *data.get(), *m_streamFormat, bipBopCount);
+ }
+}
+
+void MockRealtimeAudioSourceGStreamer::addHum(float amplitude, float frequency, float sampleRate, uint64_t start, float *p, uint64_t count)
+{
+ float humPeriod = sampleRate / frequency;
+ for (uint64_t i = start, end = start + count; i < end; ++i) {
+ float a = amplitude * sin(i * s_Tau / humPeriod);
+ a += *p;
+ *p++ = a;
+ }
+}
+
+void MockRealtimeAudioSourceGStreamer::reconfigure()
+{
+ GstAudioInfo info;
+ auto rate = sampleRate();
+ size_t sampleCount = 2 * rate;
+
+ m_maximiumFrameCount = WTF::roundUpToPowerOfTwo(renderInterval().seconds() * sampleRate());
+ gst_audio_info_set_format(&info, GST_AUDIO_FORMAT_F32LE, rate, 1, nullptr);
+ m_streamFormat = GStreamerAudioStreamDescription(info);
+
+ m_bipBopBuffer.resize(sampleCount);
+ m_bipBopBuffer.fill(0);
+
+ size_t bipBopSampleCount = ceil(s_BipBopDuration * rate);
+ size_t bipStart = 0;
+ size_t bopStart = rate;
+
+ addHum(s_BipBopVolume, s_BipFrequency, rate, 0, m_bipBopBuffer.data() + bipStart, bipBopSampleCount);
+ addHum(s_BipBopVolume, s_BopFrequency, rate, 0, m_bipBopBuffer.data() + bopStart, bipBopSampleCount);
+ if (!echoCancellation())
+ addHum(s_NoiseVolume, s_NoiseFrequency, rate, 0, m_bipBopBuffer.data(), sampleCount);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Copied: trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.h (from rev 260936, trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h) (0 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.h (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.h 2020-04-30 08:12:01 UTC (rev 260937)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2020 Igalia S.L.
+ * Author: Thibault Saunier <[email protected]>
+ * Author: Alejandro G. Castro <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
+
+#include "GStreamerAudioData.h"
+#include "GStreamerAudioStreamDescription.h"
+#include "MockRealtimeAudioSource.h"
+
+namespace WebCore {
+
+class MockRealtimeAudioSourceGStreamer final : public MockRealtimeAudioSource {
+public:
+ static Ref<MockRealtimeAudioSource> createForMockAudioCapturer(String&& deviceID, String&& name, String&& hashSalt);
+
+ ~MockRealtimeAudioSourceGStreamer() = default;
+
+protected:
+ void render(Seconds) final;
+
+private:
+ friend class MockRealtimeAudioSource;
+ MockRealtimeAudioSourceGStreamer(String&& deviceID, String&& name, String&& hashSalt);
+ void reconfigure();
+ void addHum(float amplitude, float frequency, float sampleRate, uint64_t start, float *p, uint64_t count);
+
+ Optional<GStreamerAudioStreamDescription> m_streamFormat;
+ Vector<float> m_bipBopBuffer;
+ uint32_t m_maximiumFrameCount;
+ uint64_t m_samplesEmitted { 0 };
+ uint64_t m_samplesRendered { 0 };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Added: trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp (0 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp 2020-04-30 08:12:01 UTC (rev 260937)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2020 Igalia S.L.
+ * Author: Thibault Saunier <[email protected]>
+ * Author: Alejandro G. Castro <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
+#include "MockRealtimeVideoSourceGStreamer.h"
+
+#include "MediaSampleGStreamer.h"
+#include "MockRealtimeMediaSourceCenter.h"
+
+namespace WebCore {
+
+CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
+{
+#ifndef NDEBUG
+ auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
+ ASSERT(device);
+ if (!device)
+ return { "No mock camera device"_s };
+#endif
+
+ auto source = adoptRef(*new MockRealtimeVideoSourceGStreamer(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
+ if (constraints) {
+ if (auto error = source->applyConstraints(*constraints))
+ return WTFMove(error->message);
+ }
+
+ return CaptureSourceOrError(RealtimeVideoSource::create(WTFMove(source)));
+}
+
+Ref<MockRealtimeVideoSource> MockRealtimeVideoSourceGStreamer::createForMockDisplayCapturer(String&& deviceID, String&& name, String&& hashSalt)
+{
+ return adoptRef(*new MockRealtimeVideoSourceGStreamer(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt)));
+}
+
+MockRealtimeVideoSourceGStreamer::MockRealtimeVideoSourceGStreamer(String&& deviceID, String&& name, String&& hashSalt)
+ : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
+{
+}
+
+void MockRealtimeVideoSourceGStreamer::updateSampleBuffer()
+{
+ auto imageBuffer = this->imageBuffer();
+ if (!imageBuffer)
+ return;
+
+ auto imageSize = size();
+ auto caps = adoptGRef(gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "BGRA",
+ "width", G_TYPE_INT, imageSize.width(), "height", G_TYPE_INT, imageSize.height(), nullptr));
+
+ auto data = ""
+ auto size = data.size();
+ auto buffer = adoptGRef(gst_buffer_new_wrapped(g_memdup(data.releaseBuffer().get(), size), size));
+ auto sampleTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds());
+ GST_BUFFER_PTS(buffer.get()) = toGstClockTime(sampleTime);
+ auto gstSample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
+ auto sample = MediaSampleGStreamer::create(WTFMove(gstSample), imageSize, { });
+ dispatchMediaSampleToObservers(sample.get());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Copied: trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h (from rev 260936, trunk/Source/WebCore/platform/mediastream/gstreamer/MockGStreamerAudioCaptureSource.h) (0 => 260937)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h 2020-04-30 08:12:01 UTC (rev 260937)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2020 Igalia S.L.
+ * Author: Thibault Saunier <[email protected]>
+ * Author: Alejandro G. Castro <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#if ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
+
+#include "MockRealtimeVideoSource.h"
+
+namespace WebCore {
+
+class MockRealtimeVideoSourceGStreamer final : public MockRealtimeVideoSource {
+public:
+ static Ref<MockRealtimeVideoSource> createForMockDisplayCapturer(String&& deviceID, String&& name, String&& hashSalt);
+
+ ~MockRealtimeVideoSourceGStreamer() = default;
+
+private:
+ friend class MockRealtimeVideoSource;
+ MockRealtimeVideoSourceGStreamer(String&& deviceID, String&& name, String&& hashSalt);
+
+ void updateSampleBuffer() final;
+ bool canResizeVideoFrames() const final { return true; }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM) && USE(LIBWEBRTC) && USE(GSTREAMER)
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h (260936 => 260937)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h 2020-04-30 08:02:16 UTC (rev 260936)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h 2020-04-30 08:12:01 UTC (rev 260937)
@@ -57,8 +57,6 @@
virtual void updateSampleBuffer() = 0;
- void setCurrentFrame(MediaSample&);
-
Seconds elapsedTime();
void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override;
MediaSample::VideoRotation sampleRotation() const final { return m_deviceOrientation; }