Title: [269101] trunk/Source/WebCore
Revision
269101
Author
[email protected]
Date
2020-10-28 06:13:34 -0700 (Wed, 28 Oct 2020)

Log Message

[GStreamer] Mock video source doesn't set framerate on its caps
https://bugs.webkit.org/show_bug.cgi?id=218248

Patch by Philippe Normand <[email protected]> on 2020-10-28
Reviewed by Xabier Rodriguez-Calvar.

Set framerate on the sample caps and reduce code duplication.

* platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
(WebCore::MediaSampleGStreamer::createImageSample):
* platform/graphics/gstreamer/MediaSampleGStreamer.h:
* platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp:
(WebCore::MockRealtimeVideoSourceGStreamer::updateSampleBuffer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269100 => 269101)


--- trunk/Source/WebCore/ChangeLog	2020-10-28 13:13:28 UTC (rev 269100)
+++ trunk/Source/WebCore/ChangeLog	2020-10-28 13:13:34 UTC (rev 269101)
@@ -1,5 +1,20 @@
 2020-10-28  Philippe Normand  <[email protected]>
 
+        [GStreamer] Mock video source doesn't set framerate on its caps
+        https://bugs.webkit.org/show_bug.cgi?id=218248
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Set framerate on the sample caps and reduce code duplication.
+        
+        * platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
+        (WebCore::MediaSampleGStreamer::createImageSample):
+        * platform/graphics/gstreamer/MediaSampleGStreamer.h:
+        * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp:
+        (WebCore::MockRealtimeVideoSourceGStreamer::updateSampleBuffer):
+
+2020-10-28  Philippe Normand  <[email protected]>
+
         [GStreamer] Using audio files for the <img> tag triggers warnings
         https://bugs.webkit.org/show_bug.cgi?id=218245
 

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());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to