Diff
Modified: trunk/Source/WebCore/ChangeLog (236421 => 236422)
--- trunk/Source/WebCore/ChangeLog 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/ChangeLog 2018-09-24 20:12:57 UTC (rev 236422)
@@ -1,3 +1,43 @@
+2018-09-24 Eric Carlson <[email protected]>
+
+ [MediaStream] Add mock window capture source
+ https://bugs.webkit.org/show_bug.cgi?id=189843
+ <rdar://problem/44687445>
+
+ Reviewed by Youenn Fablet.
+
+ No new tests, the API is disabled and it isn't possible to test yet.
+
+ * platform/mediastream/mac/AVVideoCaptureSource.mm:
+ (WebCore::AVVideoCaptureSource::processNewFrame): Remove an extra blank line.
+
+ * platform/mock/MockMediaDevice.h:
+ (WebCore::MockDisplayProperties::encode const): Get rid of defaultFrameRate, add type.
+ (WebCore::MockDisplayProperties::decode): Ditto.
+ (WebCore::MockMediaDevice::type const):
+
+ * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+ (WebCore::defaultDevices): Add mock window devices.
+ (WebCore::MockRealtimeMediaSourceCenter::audioDevices): Cleanup.
+ (WebCore::MockRealtimeMediaSourceCenter::videoDevices): Cleanup.
+ (WebCore::MockRealtimeMediaSourceCenter::displayDevices): New.
+
+ * platform/mock/MockRealtimeVideoSource.cpp:
+ (WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource): Set default size on displays.
+ (WebCore::MockRealtimeVideoSource::supportsSizeAndFrameRate): Call RealtimeVideoSource for
+ mock camera, base class for device.
+ (WebCore::MockRealtimeVideoSource::setSizeAndFrameRate): Ditto.
+ (WebCore::MockRealtimeVideoSource::generatePresets): ASSERT if called as a camera.
+ (WebCore::MockRealtimeVideoSource::capabilities): updateCapabilities is only appropriate for cameras.
+ (WebCore::MockRealtimeVideoSource::settings): Camera and Device are different surface types.
+ (WebCore::MockRealtimeVideoSource::drawText): Render name, not ID.
+ (WebCore::MockRealtimeVideoSource::mockDisplayType const):
+
+ * platform/mock/MockRealtimeVideoSource.h:
+ (WebCore::MockRealtimeVideoSource::mockDisplay const):
+ (WebCore::MockRealtimeVideoSource::mockScreen const):
+ (WebCore::MockRealtimeVideoSource::mockWindow const):
+
2018-09-24 Daniel Bates <[email protected]>
[iOS] Key code is 0 for many hardware keyboard keys
Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (236421 => 236422)
--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp 2018-09-24 20:12:57 UTC (rev 236422)
@@ -228,6 +228,7 @@
return;
if (!privateStream) {
+ RELEASE_LOG(MediaStream, "UserMediaRequest::allow failed to create media stream!");
deny(MediaAccessDenialReason::HardwareError);
return;
}
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h (236421 => 236422)
--- trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h 2018-09-24 20:12:57 UTC (rev 236422)
@@ -45,8 +45,8 @@
RealtimeVideoSource(const String& id, const String& name);
void prepareToProduceData();
- bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
- void setSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
+ bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) override;
+ void setSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) override;
virtual void generatePresets() = 0;
virtual bool prefersPreset(VideoPreset&) { return true; }
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (236421 => 236422)
--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm 2018-09-24 20:12:57 UTC (rev 236422)
@@ -518,7 +518,6 @@
if (!isProducingData() || muted())
return;
-
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer.get());
if (!formatDescription)
return;
Modified: trunk/Source/WebCore/platform/mock/MockMediaDevice.h (236421 => 236422)
--- trunk/Source/WebCore/platform/mock/MockMediaDevice.h 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/platform/mock/MockMediaDevice.h 2018-09-24 20:12:57 UTC (rev 236422)
@@ -102,16 +102,16 @@
template<class Encoder>
void encode(Encoder& encoder) const
{
- encoder << defaultFrameRate;
+ encoder.encodeEnum(type);
encoder << fillColor;
+ encoder << defaultSize;
}
template <class Decoder>
static std::optional<MockDisplayProperties> decode(Decoder& decoder)
{
- std::optional<double> defaultFrameRate;
- decoder >> defaultFrameRate;
- if (!defaultFrameRate)
+ std::optional<CaptureDevice::DeviceType> type;
+ decoder >> type;
return std::nullopt;
std::optional<Color> fillColor;
@@ -119,11 +119,17 @@
if (!fillColor)
return std::nullopt;
- return MockDisplayProperties { *defaultFrameRate, *fillColor };
+ std::optional<IntSize> defaultSize;
+ decoder >> defaultSize;
+ if (!defaultSize)
+ return std::nullopt;
+
+ return MockDisplayProperties { *type, *fillColor, *defaultSize };
}
- double defaultFrameRate { 30 };
+ CaptureDevice::DeviceType type;
Color fillColor { Color::lightGray };
+ IntSize defaultSize;
};
struct MockMediaDevice {
@@ -137,8 +143,9 @@
return CaptureDevice::DeviceType::Microphone;
if (isCamera())
return CaptureDevice::DeviceType::Camera;
+
ASSERT(isDisplay());
- return CaptureDevice::DeviceType::Screen;
+ return WTF::get<MockDisplayProperties>(properties).type;
}
template<class Encoder>
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp (236421 => 236422)
--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp 2018-09-24 20:12:57 UTC (rev 236422)
@@ -75,8 +75,11 @@
Color::darkGray,
} },
- MockMediaDevice { "SCREEN-1"_s, "Mock screen device 1"_s, MockDisplayProperties { 30, Color::lightGray } },
- MockMediaDevice { "SCREEN-2"_s, "Mock screen device 2"_s, MockDisplayProperties { 10, Color::yellow } }
+ MockMediaDevice { "SCREEN-1"_s, "Mock screen device 1"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, Color::lightGray, { 3840, 2160 } } },
+ MockMediaDevice { "SCREEN-2"_s, "Mock screen device 2"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, Color::yellow, { 1920, 1080 } } },
+
+ MockMediaDevice { "WINDOW-2"_s, "Mock window 1"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, 0xfff1b5, { 640, 480 } } },
+ MockMediaDevice { "WINDOW-2"_s, "Mock window 2"_s, MockDisplayProperties { CaptureDevice::DeviceType::Screen, 0xffd0b5, { 1280, 600 } } },
};
}
@@ -214,7 +217,7 @@
static auto audioDevices = makeNeverDestroyed([] {
Vector<CaptureDevice> audioDevices;
for (const auto& device : devices()) {
- if (device.type() == CaptureDevice::DeviceType::Microphone)
+ if (device.isMicrophone())
audioDevices.append(captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId).value());
}
return audioDevices;
@@ -228,7 +231,7 @@
static auto videoDevices = makeNeverDestroyed([] {
Vector<CaptureDevice> videoDevices;
for (const auto& device : devices()) {
- if (device.type() == CaptureDevice::DeviceType::Camera)
+ if (device.isCamera())
videoDevices.append(captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId).value());
}
return videoDevices;
@@ -242,7 +245,7 @@
static auto displayDevices = makeNeverDestroyed([] {
Vector<CaptureDevice> displayDevices;
for (const auto& device : devices()) {
- if (device.type() == CaptureDevice::DeviceType::Screen)
+ if (device.isDisplay())
displayDevices.append(captureDeviceWithPersistentID(CaptureDevice::DeviceType::Screen, device.persistentId).value());
}
return displayDevices;
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (236421 => 236422)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2018-09-24 20:12:57 UTC (rev 236422)
@@ -58,10 +58,10 @@
switch (device.type()) {
case CaptureDevice::DeviceType::Camera:
case CaptureDevice::DeviceType::Screen:
+ case CaptureDevice::DeviceType::Window:
return MockRealtimeVideoSource::create(device.persistentId(), device.label(), constraints);
break;
case CaptureDevice::DeviceType::Application:
- case CaptureDevice::DeviceType::Window:
case CaptureDevice::DeviceType::Browser:
case CaptureDevice::DeviceType::Microphone:
case CaptureDevice::DeviceType::Unknown:
@@ -121,9 +121,9 @@
m_dashWidths.uncheckedAppend(6);
m_dashWidths.uncheckedAppend(6);
- if (mockScreen()) {
+ if (mockDisplay()) {
auto& properties = WTF::get<MockDisplayProperties>(m_device.properties);
- setFrameRate(properties.defaultFrameRate);
+ setSize(properties.defaultSize);
m_fillColor = properties.fillColor;
return;
}
@@ -134,8 +134,29 @@
m_fillColor = properties.fillColor;
}
+bool MockRealtimeVideoSource::supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> rate)
+{
+ // FIXME: consider splitting mock display into another class so we don't don't have to do this silly dance
+ // because of the RealtimeVideoSource inheritance.
+ if (mockCamera())
+ return RealtimeVideoSource::supportsSizeAndFrameRate(width, height, rate);
+
+ return RealtimeMediaSource::supportsSizeAndFrameRate(width, height, rate);
+}
+
+void MockRealtimeVideoSource::setSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double> rate)
+{
+ // FIXME: consider splitting mock display into another class so we don't don't have to do this silly dance
+ // because of the RealtimeVideoSource inheritance.
+ if (mockCamera())
+ return RealtimeVideoSource::setSizeAndFrameRate(width, height, rate);
+
+ return RealtimeMediaSource::setSizeAndFrameRate(width, height, rate);
+}
+
void MockRealtimeVideoSource::generatePresets()
{
+ ASSERT(mockCamera());
setSupportedPresets(WTFMove(WTF::get<MockCameraProperties>(m_device.properties).presets));
}
@@ -145,17 +166,18 @@
RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints());
capabilities.setDeviceId(id());
- if (mockCamera())
+ if (mockCamera()) {
capabilities.addFacingMode(WTF::get<MockCameraProperties>(m_device.properties).facingMode);
- else {
+ updateCapabilities(capabilities);
+ } else {
capabilities.setWidth(CapabilityValueOrRange(72, 2880));
capabilities.setHeight(CapabilityValueOrRange(45, 1800));
capabilities.setFrameRate(CapabilityValueOrRange(.01, 60.0));
}
- updateCapabilities(capabilities);
m_capabilities = WTFMove(capabilities);
}
+
return m_capabilities.value();
}
@@ -168,8 +190,8 @@
if (mockCamera())
settings.setFacingMode(facingMode());
else {
- settings.setDisplaySurface(RealtimeMediaSourceSettings::DisplaySurfaceType::Monitor);
- settings.setLogicalSurface(true);
+ settings.setDisplaySurface(mockScreen() ? RealtimeMediaSourceSettings::DisplaySurfaceType::Monitor : RealtimeMediaSourceSettings::DisplaySurfaceType::Window);
+ settings.setLogicalSurface(false);
}
settings.setFrameRate(frameRate());
auto& size = this->size();
@@ -187,6 +209,10 @@
supportedConstraints.setSupportsAspectRatio(true);
if (mockCamera())
supportedConstraints.setSupportsFacingMode(true);
+ else {
+ supportedConstraints.setSupportsDisplaySurface(true);
+ supportedConstraints.setSupportsLogicalSurface(true);
+ }
settings.setSupportedConstraints(supportedConstraints);
m_currentSettings = WTFMove(settings);
@@ -395,7 +421,7 @@
context.drawText(statsFont, TextRun((StringView(string))), statsLocation);
} else {
statsLocation.move(0, m_statsFontSize);
- context.drawText(statsFont, TextRun { id() }, statsLocation);
+ context.drawText(statsFont, TextRun { name() }, statsLocation);
}
FloatPoint bipBopLocation(size.width() * .6, size.height() * .6);
@@ -460,6 +486,14 @@
return m_imageBuffer.get();
}
+bool MockRealtimeVideoSource::mockDisplayType(CaptureDevice::DeviceType type) const
+{
+ if (!WTF::holds_alternative<MockDisplayProperties>(m_device.properties))
+ return false;
+
+ return WTF::get<MockDisplayProperties>(m_device.properties).type == type;
+}
+
} // namespace WebCore
#endif // ENABLE(MEDIA_STREAM)
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h (236421 => 236422)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h 2018-09-24 20:12:26 UTC (rev 236421)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h 2018-09-24 20:12:57 UTC (rev 236422)
@@ -69,6 +69,8 @@
void startProducingData() final;
void stopProducingData() final;
bool isCaptureSource() const final { return true; }
+ bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
+ void setSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final;
void generatePresets() final;
@@ -82,7 +84,10 @@
void delaySamples(Seconds) override;
bool mockCamera() const { return WTF::holds_alternative<MockCameraProperties>(m_device.properties); }
- bool mockScreen() const { return WTF::holds_alternative<MockDisplayProperties>(m_device.properties); }
+ bool mockDisplay() const { return WTF::holds_alternative<MockDisplayProperties>(m_device.properties); }
+ bool mockScreen() const { return mockDisplayType(CaptureDevice::DeviceType::Screen); }
+ bool mockWindow() const { return mockDisplayType(CaptureDevice::DeviceType::Window); }
+ bool mockDisplayType(CaptureDevice::DeviceType) const;
float m_baseFontSize { 0 };
float m_bipBopFontSize { 0 };