Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp (269100 => 269101)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp 2020-10-28 13:13:28 UTC (rev 269100)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp 2020-10-28 13:13:34 UTC (rev 269101)
@@ -97,7 +97,7 @@
return adoptRef(*gstreamerMediaSample);
}
-Ref<MediaSampleGStreamer> MediaSampleGStreamer::createImageSample(Vector<uint8_t>&& bgraData, unsigned width, unsigned height)
+Ref<MediaSampleGStreamer> MediaSampleGStreamer::createImageSample(Vector<uint8_t>&& bgraData, unsigned width, unsigned height, double frameRate)
{
size_t size = bgraData.sizeInBytes();
auto* data = ""
@@ -105,7 +105,12 @@
WTF::VectorMalloc::free(data);
}));
gst_buffer_add_video_meta(buffer.get(), GST_VIDEO_FRAME_FLAG_NONE, GST_VIDEO_FORMAT_BGRA, width, height);
- auto caps = adoptGRef(gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "BGRA", "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, "framerate", GST_TYPE_FRACTION, 1, 1, nullptr));
+
+ int frameRateNumerator, frameRateDenominator;
+ gst_util_double_to_fraction(frameRate, &frameRateNumerator, &frameRateDenominator);
+
+ auto caps = adoptGRef(gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "BGRA", "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", GST_TYPE_FRACTION, frameRateNumerator, frameRateDenominator, nullptr));
auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
return create(WTFMove(sample), FloatSize(width, height), { });
}
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h (269100 => 269101)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h 2020-10-28 13:13:28 UTC (rev 269100)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h 2020-10-28 13:13:34 UTC (rev 269101)
@@ -37,7 +37,7 @@
}
static Ref<MediaSampleGStreamer> createFakeSample(GstCaps*, MediaTime pts, MediaTime dts, MediaTime duration, const FloatSize& presentationSize, const AtomString& trackId);
- static Ref<MediaSampleGStreamer> createImageSample(Vector<uint8_t>&&, unsigned width, unsigned height);
+ static Ref<MediaSampleGStreamer> createImageSample(Vector<uint8_t>&&, unsigned width, unsigned height, double frameRate = 1);
void extendToTheBeginning();
MediaTime presentationTime() const override { return m_pts; }
Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp (269100 => 269101)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp 2020-10-28 13:13:28 UTC (rev 269100)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp 2020-10-28 13:13:34 UTC (rev 269101)
@@ -65,16 +65,8 @@
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, { });
+ auto sample = MediaSampleGStreamer::createImageSample(imageBuffer->toBGRAData(), imageSize.width(), imageSize.height(), frameRate());
+ sample->offsetTimestampsBy(MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds()));
dispatchMediaSampleToObservers(sample.get());
}