Skip to content

Commit

Permalink
[GStreamer] test fast/mediastream/getDisplayMedia-size.html fails
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=233731

Reviewed by Xabier Rodriguez-Calvar.

The main fix here is to wrap the MockDisplayCaptureSourceGStreamer in a RealtimeVideoSource, same
logic as the MockRealtimeVideoSourceGStreamer.

This patch also fixes fast/mediastream/getDisplayMedia-displaySurface.html by adjusting the source
settings displaySurface, depending on which surface we're behaving as. The non-mock GStreamer
DisplayCapture source will need to set this setting too, but that's going to be addressed in a
follow-up patch.

* LayoutTests/platform/glib/TestExpectations:
* Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp:
(WebCore::MockDisplayCaptureSourceGStreamer::create):
(WebCore::MockDisplayCaptureSourceGStreamer::MockDisplayCaptureSourceGStreamer):
(WebCore::MockDisplayCaptureSourceGStreamer::settings):
* Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h:
* Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp:
* Source/WebCore/platform/mock/MockRealtimeVideoSource.h:

Canonical link: https://commits.webkit.org/262825@main
  • Loading branch information
philn committed Apr 11, 2023
1 parent e04108f commit e5975bd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
6 changes: 3 additions & 3 deletions LayoutTests/platform/glib/TestExpectations
Expand Up @@ -1669,9 +1669,9 @@ webkit.org/b/79203 fast/mediastream/RTCPeerConnection-stats.html [ Timeout Crash
webkit.org/b/79203 webkit.org/b/186678 fast/mediastream/MediaStream-video-element-track-stop.html [ Timeout Failure Crash ]
webkit.org/b/230415 fast/mediastream/RTCPeerConnection-iceconnectionstatechange-event.html [ Timeout ]
webkit.org/b/187603 fast/mediastream/media-stream-track-source-failure.html [ Timeout Failure Pass ]
webkit.org/b/233731 fast/mediastream/getDisplayMedia-size.html [ Failure ]
fast/mediastream/mediastreamtrack-configurationchange.html [ Failure ]
fast/mediastream/getDisplayMedia-displaySurface.html [ Failure ]

# This ends up calling WKPageTriggerMockMicrophoneConfigurationChange which is specific to GPUProcess.
fast/mediastream/mediastreamtrack-configurationchange.html [ Skip ]

fast/mediastream/MediaDevices-addEventListener.html [ DumpJSConsoleLogInStdErr ]

Expand Down
@@ -0,0 +1,7 @@


PASS Ensure getDisplayMedia size can be reduced with applyConstraints
PASS Ensure getDisplayMedia size can be increased with applyConstraints
PASS original source should stay at a small size
PASS original source should stay at a big size

Expand Up @@ -50,7 +50,7 @@ CaptureSourceOrError MockRealtimeVideoSource::create(String&& deviceID, AtomStri
return CaptureSourceOrError(RealtimeVideoSource::create(WTFMove(source)));
}

CaptureSourceOrError MockDisplayCaptureSourceGStreamer::create(const CaptureDevice& device, MediaDeviceHashSalts&& hashSalts, const MediaConstraints* constraints)
CaptureSourceOrError MockDisplayCaptureSourceGStreamer::create(const CaptureDevice& device, MediaDeviceHashSalts&& hashSalts, const MediaConstraints* constraints, PageIdentifier pageIdentifier)
{
auto mockSource = adoptRef(*new MockRealtimeVideoSourceGStreamer(String { device.persistentId() }, AtomString { device.label() }, MediaDeviceHashSalts { hashSalts }));

Expand All @@ -59,12 +59,12 @@ CaptureSourceOrError MockDisplayCaptureSourceGStreamer::create(const CaptureDevi
return WTFMove(error.value().badConstraint);
}

auto source = adoptRef(*new MockDisplayCaptureSourceGStreamer(device, WTFMove(mockSource), WTFMove(hashSalts)));
return CaptureSourceOrError(WTFMove(source));
auto source = adoptRef(*new MockDisplayCaptureSourceGStreamer(device, WTFMove(mockSource), WTFMove(hashSalts), pageIdentifier));
return CaptureSourceOrError(RealtimeVideoSource::create(WTFMove(source)));
}

MockDisplayCaptureSourceGStreamer::MockDisplayCaptureSourceGStreamer(const CaptureDevice& device, Ref<MockRealtimeVideoSourceGStreamer>&& source, MediaDeviceHashSalts&& hashSalts)
: RealtimeMediaSource(device, WTFMove(hashSalts))
MockDisplayCaptureSourceGStreamer::MockDisplayCaptureSourceGStreamer(const CaptureDevice& device, Ref<MockRealtimeVideoSourceGStreamer>&& source, MediaDeviceHashSalts&& hashSalts, PageIdentifier pageIdentifier)
: RealtimeVideoCaptureSource(device, WTFMove(hashSalts), pageIdentifier)
, m_source(WTFMove(source))
, m_deviceType(device.type())
{
Expand Down Expand Up @@ -127,7 +127,7 @@ const RealtimeMediaSourceSettings& MockDisplayCaptureSourceGStreamer::settings()
settings.setWidth(size.width());
settings.setHeight(size.height());
settings.setDeviceId(hashedId());

settings.setDisplaySurface(m_source->mockScreen() ? DisplaySurfaceType::Monitor : DisplaySurfaceType::Window);
settings.setLogicalSurface(false);

RealtimeMediaSourceSupportedConstraints supportedConstraints;
Expand Down
Expand Up @@ -40,9 +40,9 @@ class MockRealtimeVideoSourceGStreamer final : public MockRealtimeVideoSource {
bool canResizeVideoFrames() const final { return true; }
};

class MockDisplayCaptureSourceGStreamer final : public RealtimeMediaSource, RealtimeMediaSource::VideoFrameObserver {
class MockDisplayCaptureSourceGStreamer : public RealtimeVideoCaptureSource, RealtimeMediaSource::VideoFrameObserver {
public:
static CaptureSourceOrError create(const CaptureDevice&, MediaDeviceHashSalts&&, const MediaConstraints*);
static CaptureSourceOrError create(const CaptureDevice&, MediaDeviceHashSalts&&, const MediaConstraints*, PageIdentifier);

void requestToEnd(Observer&) final;
bool isProducingData() const final { return m_source->isProducingData(); }
Expand All @@ -52,8 +52,10 @@ class MockDisplayCaptureSourceGStreamer final : public RealtimeMediaSource, Real
// RealtimeMediaSource::VideoFrameObserver
void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final;

void generatePresets() override { };

private:
MockDisplayCaptureSourceGStreamer(const CaptureDevice&, Ref<MockRealtimeVideoSourceGStreamer>&&, MediaDeviceHashSalts&&);
MockDisplayCaptureSourceGStreamer(const CaptureDevice&, Ref<MockRealtimeVideoSourceGStreamer>&&, MediaDeviceHashSalts&&, PageIdentifier);
~MockDisplayCaptureSourceGStreamer();

void startProducingData() final { m_source->start(); }
Expand All @@ -62,7 +64,7 @@ class MockDisplayCaptureSourceGStreamer final : public RealtimeMediaSource, Real
bool isCaptureSource() const final { return true; }
const RealtimeMediaSourceCapabilities& capabilities() final;
const RealtimeMediaSourceSettings& settings() final;
CaptureDevice::DeviceType deviceType() const { return m_deviceType; }
CaptureDevice::DeviceType deviceType() const final { return m_deviceType; }

#if !RELEASE_LOG_DISABLED
const char* logClassName() const final { return "MockDisplayCaptureSourceGStreamer"; }
Expand Down
Expand Up @@ -189,8 +189,7 @@ class MockRealtimeDisplaySourceFactory : public DisplayCaptureFactory {
#if PLATFORM(MAC)
return DisplayCaptureSourceCocoa::create(UniqueRef<DisplayCaptureSourceCocoa::Capturer>(makeUniqueRef<MockDisplayCapturer>(device, pageIdentifier)), device, WTFMove(hashSalts), constraints, pageIdentifier);
#elif USE(GSTREAMER)
UNUSED_PARAM(pageIdentifier);
return MockDisplayCaptureSourceGStreamer::create(device, WTFMove(hashSalts), constraints);
return MockDisplayCaptureSourceGStreamer::create(device, WTFMove(hashSalts), constraints, pageIdentifier);
#else
return MockRealtimeVideoSource::create(String { device.persistentId() }, AtomString { device.label() }, WTFMove(hashSalts), constraints, pageIdentifier);
#endif
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/platform/mock/MockRealtimeVideoSource.h
Expand Up @@ -70,6 +70,8 @@ class MockRealtimeVideoSource : public RealtimeVideoCaptureSource, private Orien
IntSize captureSize() const;

private:
friend class MockDisplayCaptureSourceGStreamer;

const RealtimeMediaSourceCapabilities& capabilities() final;
const RealtimeMediaSourceSettings& settings() final;

Expand Down

0 comments on commit e5975bd

Please sign in to comment.