Title: [277175] trunk
Revision
277175
Author
[email protected]
Date
2021-05-07 08:51:36 -0700 (Fri, 07 May 2021)

Log Message

[GStreamer][MediaStream] Emit black frames for disabled video tracks
https://bugs.webkit.org/show_bug.cgi?id=225511

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

In case the video track is disabled, emit a black I420 frame. For disabled audio tracks we
might need to silence the corresponding audio frames, this will be investigated in a
follow-up patch.

* platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp:

LayoutTests:

* platform/glib/TestExpectations: Unflag mediastream test now passing.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (277174 => 277175)


--- trunk/LayoutTests/ChangeLog	2021-05-07 15:23:51 UTC (rev 277174)
+++ trunk/LayoutTests/ChangeLog	2021-05-07 15:51:36 UTC (rev 277175)
@@ -1,3 +1,12 @@
+2021-05-07  Philippe Normand  <[email protected]>
+
+        [GStreamer][MediaStream] Emit black frames for disabled video tracks
+        https://bugs.webkit.org/show_bug.cgi?id=225511
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * platform/glib/TestExpectations: Unflag mediastream test now passing.
+
 2021-05-07  Frédéric Wang  <[email protected]>
 
         Crash in ApplyStyleCommand::applyRelativeFontStyleChange

Modified: trunk/LayoutTests/platform/glib/TestExpectations (277174 => 277175)


--- trunk/LayoutTests/platform/glib/TestExpectations	2021-05-07 15:23:51 UTC (rev 277174)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2021-05-07 15:51:36 UTC (rev 277175)
@@ -1158,7 +1158,6 @@
 webkit.org/b/224074 webrtc/concurrentVideoPlayback.html [ Timeout Pass ]
 
 webkit.org/b/206656 imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-removetrack.https.html [ Crash Failure Timeout ]
-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/MediaStream-MediaElement-preload-none-manual.https.html [ Crash Failure Pass ]
 webkit.org/b/210385 imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-MediaElement-firstframe.https.html [ Failure Crash Pass ]
 webkit.org/b/223508 imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (277174 => 277175)


--- trunk/Source/WebCore/ChangeLog	2021-05-07 15:23:51 UTC (rev 277174)
+++ trunk/Source/WebCore/ChangeLog	2021-05-07 15:51:36 UTC (rev 277175)
@@ -1,3 +1,16 @@
+2021-05-07  Philippe Normand  <[email protected]>
+
+        [GStreamer][MediaStream] Emit black frames for disabled video tracks
+        https://bugs.webkit.org/show_bug.cgi?id=225511
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        In case the video track is disabled, emit a black I420 frame. For disabled audio tracks we
+        might need to silence the corresponding audio frames, this will be investigated in a
+        follow-up patch.
+
+        * platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp:
+
 2021-05-07  Frédéric Wang  <[email protected]>
 
         Crash in ApplyStyleCommand::applyRelativeFontStyleChange

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp (277174 => 277175)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp	2021-05-07 15:23:51 UTC (rev 277174)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp	2021-05-07 15:51:36 UTC (rev 277175)
@@ -240,12 +240,7 @@
 
     void trackStarted(MediaStreamTrackPrivate&) final { };
     void trackEnded(MediaStreamTrackPrivate&) final;
-
-    void trackEnabledChanged(MediaStreamTrackPrivate& track) final
-    {
-        m_enabled = track.enabled();
-    }
-
+    void trackEnabledChanged(MediaStreamTrackPrivate&) final { };
     void trackMutedChanged(MediaStreamTrackPrivate&) final { };
     void trackSettingsChanged(MediaStreamTrackPrivate&) final { };
     void readyStateChanged(MediaStreamTrackPrivate&) final { };
@@ -252,16 +247,39 @@
 
     void videoSampleAvailable(MediaSample& sample) final
     {
-        if (!m_enabled || !m_parent)
+        if (!m_parent)
             return;
 
         auto* gstSample = static_cast<MediaSampleGStreamer*>(&sample)->platformSample().sample.gstSample;
-        pushSample(gstSample);
+        if (m_track.enabled()) {
+            pushSample(gstSample);
+            return;
+        }
+
+        // In case the track is disabled, emit a black I420 frame.
+        auto caps = adoptGRef(gst_caps_copy(gst_sample_get_caps(gstSample)));
+        gst_caps_set_simple(caps.get(), "format", G_TYPE_STRING, "I420", nullptr);
+
+        GstVideoInfo info;
+        gst_video_info_from_caps(&info, caps.get());
+
+        auto buffer = adoptGRef(gst_buffer_new_allocate(nullptr, GST_VIDEO_INFO_SIZE(&info), nullptr));
+        {
+            GstMappedBuffer data(buffer, GST_MAP_WRITE);
+            auto yOffset = GST_VIDEO_INFO_PLANE_OFFSET(&info, 1);
+            auto uOffset = GST_VIDEO_INFO_PLANE_OFFSET(&info, 2);
+            memset(data.data(), 0, yOffset);
+            memset(data.data() + yOffset, 128, uOffset);
+        }
+        gst_buffer_add_video_meta_full(buffer.get(), GST_VIDEO_FRAME_FLAG_NONE, GST_VIDEO_FORMAT_I420, GST_VIDEO_INFO_WIDTH(&info), GST_VIDEO_INFO_HEIGHT(&info), 3, info.offset, info.stride);
+        auto blackSample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
+        pushSample(blackSample.get());
     }
 
     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData& audioData, const AudioStreamDescription&, size_t) final
     {
-        if (!m_enabled || !m_parent)
+        // TODO: We likely need to emit silent audio frames in case the track is disabled.
+        if (!m_track.enabled() || !m_parent)
             return;
 
         const auto& data = "" GStreamerAudioData&>(audioData);
@@ -273,7 +291,6 @@
     GstElement* m_parent { nullptr };
     MediaStreamTrackPrivate& m_track;
     GRefPtr<GstElement> m_src;
-    bool m_enabled { true };
     GstClockTime m_firstBufferPts { GST_CLOCK_TIME_NONE };
     bool m_enoughData { false };
     bool m_needsDiscont { false };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to