Title: [288092] trunk
Revision
288092
Author
[email protected]
Date
2022-01-17 01:50:12 -0800 (Mon, 17 Jan 2022)

Log Message

[GStreamer] tests media/track/audio-track-configuration.html and media/track/video-track-configuration.html fail
https://bugs.webkit.org/show_bug.cgi?id=234084

Patch by Philippe Normand <[email protected]> on 2022-01-17
Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

The known caps and tags of the track GstStream are now exposed through the corresponding
Platform{Audio,Video}TrackConfiguration. This is supported only when playbin3 is used at
runtime. Supporting playbin2 would be some work (pad probes upfront of decoders?) that could
be done as a follow-up. The codec string is generated with the new GStreamer API
gst_codec_utils_caps_get_mime_codec(), which will ship in 1.20.

* platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp:
(WebCore::AudioTrackPrivateGStreamer::AudioTrackPrivateGStreamer):
* platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp:
(WebCore::VideoTrackPrivateGStreamer::VideoTrackPrivateGStreamer):

LayoutTests:

* media/track/audio-track-configuration.html: Add a timeout to each promise, allowing for
nicer actual results when a sub-set of the promises time out. Without this a single promise
timeout would make the entire test time out and the actual results would not be reported
properly.
* media/track/video-track-configuration.html: Ditto.
* platform/glib/TestExpectations: Update {audio,video}-track expectations, tests still
expected to fail but some improvements will be available when we switch to playbin3.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (288091 => 288092)


--- trunk/LayoutTests/ChangeLog	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/LayoutTests/ChangeLog	2022-01-17 09:50:12 UTC (rev 288092)
@@ -1,3 +1,18 @@
+2022-01-17  Philippe Normand  <[email protected]>
+
+        [GStreamer] tests media/track/audio-track-configuration.html and media/track/video-track-configuration.html fail
+        https://bugs.webkit.org/show_bug.cgi?id=234084
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * media/track/audio-track-configuration.html: Add a timeout to each promise, allowing for
+        nicer actual results when a sub-set of the promises time out. Without this a single promise
+        timeout would make the entire test time out and the actual results would not be reported
+        properly.
+        * media/track/video-track-configuration.html: Ditto.
+        * platform/glib/TestExpectations: Update {audio,video}-track expectations, tests still
+        expected to fail but some improvements will be available when we switch to playbin3.
+
 2022-01-17  Youenn Fablet  <[email protected]>
 
         Transmit network load metrics when service worker is using one of its network load to respond to FetchEvents

Modified: trunk/LayoutTests/media/track/audio-track-configuration.html (288091 => 288092)


--- trunk/LayoutTests/media/track/audio-track-configuration.html	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/LayoutTests/media/track/audio-track-configuration.html	2022-01-17 09:50:12 UTC (rev 288092)
@@ -5,21 +5,22 @@
 	<title>video-track-configuration</title>
 	<script src=""
 	<script>
-		window.addEventListener('load', async event => {
-			findMediaElement();
-			run('video.src = ""
-			await waitFor(video, 'canplay');
-			await testExpectedEventually('video.audioTracks.length', 0, '>');
-			await testExpectedEventually('video.audioTracks[0].configuration', null, '!=');
-			await testExpectedEventually('video.audioTracks[0].configuration.codec', 'mp4a.40.2');
-			await testExpectedEventually('video.audioTracks[0].configuration.sampleRate', 44100);
-			await testExpectedEventually('video.audioTracks[0].configuration.numberOfChannels', 2);
-			await testExpectedEventually('video.audioTracks[0].configuration.bitrate', 100000, '>=');
-			endTest();
-		});
+    window.addEventListener('load', async event => {
+      findMediaElement();
+      const timeout = 100;
+      run('video.src = ""
+      await waitFor(video, 'canplay');
+      await testExpectedEventually('video.audioTracks.length', 0, '>', timeout);
+      await testExpectedEventually('video.audioTracks[0].configuration', null, '!=', timeout);
+      await testExpectedEventually('video.audioTracks[0].configuration.codec', 'mp4a.40.2', '==', timeout);
+      await testExpectedEventually('video.audioTracks[0].configuration.sampleRate', 44100, '==', timeout);
+      await testExpectedEventually('video.audioTracks[0].configuration.numberOfChannels', 2, '==', timeout);
+      await testExpectedEventually('video.audioTracks[0].configuration.bitrate', 100000, '>=', timeout);
+      endTest();
+	  });
 	</script>
 </head>
 <body>
 	<video controls muted></video>
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/media/track/video-track-configuration.html (288091 => 288092)


--- trunk/LayoutTests/media/track/video-track-configuration.html	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/LayoutTests/media/track/video-track-configuration.html	2022-01-17 09:50:12 UTC (rev 288092)
@@ -5,35 +5,36 @@
 	<title>video-track-configuration</title>
 	<script src=""
 	<script>
-		window.addEventListener('load', async event => {
-			findMediaElement();
-			run('video.src = ""
-			await waitFor(video, 'canplay');
-			await testExpectedEventually('video.videoTracks.length', 1);
-			await testExpectedEventually('video.videoTracks[0].configuration', null, '!=');
-			await testExpectedEventually('video.videoTracks[0].configuration.codec', 'avc1.4D400D');
-			await testExpectedEventually('video.videoTracks[0].configuration.width', 320);
-			await testExpectedEventually('video.videoTracks[0].configuration.height', 240);
-			await testExpectedEventually('video.videoTracks[0].configuration.bitrate', 240000, '>=');
-			await testExpectedEventually('video.videoTracks[0].configuration.framerate', 30, '>=');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace', null, '!=');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.matrix', 'bt470bg');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.primaries', 'smpte170m');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.transfer', 'bt709');
-			run('video.src = ""
-			await waitFor(video, 'canplay');
-			await testExpectedEventually('video.videoTracks.length', 1);
-			await testExpectedEventually('video.videoTracks[0].configuration', null, '!=');
-			await testExpectedEventually('video.videoTracks[0].configuration.codec', 'hvc1.1.6.L93.B0');
-			await testExpectedEventually('video.videoTracks[0].configuration.width', 320);
-			await testExpectedEventually('video.videoTracks[0].configuration.height', 240);
-			await testExpectedEventually('video.videoTracks[0].configuration.bitrate', 150000, '>=');
-			await testExpectedEventually('video.videoTracks[0].configuration.framerate', 30, '>=');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace', null, '!=');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.matrix', 'bt709');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.primaries', 'bt709');
-			await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.transfer', 'bt709');
-			endTest();
+    window.addEventListener('load', async event => {
+      findMediaElement();
+      run('video.src = ""
+      const timeout = 100;
+      await waitFor(video, 'canplay');
+      await testExpectedEventually('video.videoTracks.length', 1, '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration', null, '!=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.codec', 'avc1.4D400D', '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.width', 320, '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.height', 240, '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.bitrate', 240000, '>=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.framerate', 30, '>=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace', null, '!=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.matrix', 'bt470bg', '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.primaries', 'smpte170m', '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.transfer', 'bt709', '==', timeout);
+      run('video.src = ""
+      await waitFor(video, 'canplay');
+      await testExpectedEventually('video.videoTracks.length', 1,  '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration', null, '!=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.codec', 'hvc1.1.6.L93.B0', '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.width', 320, '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.height', 240, '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.bitrate', 150000, '>=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.framerate', 30, '>=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace', null, '!=', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.matrix', 'bt709', '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.primaries', 'bt709', '==', timeout);
+      await testExpectedEventually('video.videoTracks[0].configuration.colorSpace.transfer', 'bt709', '==', timeout);
+      endTest();
 		});
 	</script>
 </head>

Modified: trunk/LayoutTests/platform/glib/TestExpectations (288091 => 288092)


--- trunk/LayoutTests/platform/glib/TestExpectations	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2022-01-17 09:50:12 UTC (rev 288092)
@@ -802,9 +802,15 @@
 
 webkit.org/b/233836 http/tests/media/media-blocked-by-willsendrequest.html [ Timeout ]
 
-webkit.org/b/234084 media/track/audio-track-configuration.html [ Timeout ]
-webkit.org/b/234084 media/track/video-track-configuration.html [ Timeout ]
+# Expected to pass when we enable playbin3 by default and update the SDK to GStreamer 1.20.
+webkit.org/b/234084 media/track/audio-track-configuration.html [ Failure ]
 
+# Even with playbin3 enabled there is still a failure here, h264parse is unable
+# to calculate the framerate of test.mp4 and the calculated bitrate tag is too
+# low, probably because we would need a playing pipeline to have better average
+# bitrate estimation.
+webkit.org/b/234084 media/track/video-track-configuration.html [ Failure ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of GStreamer-related bugs
 #////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/Source/WebCore/ChangeLog (288091 => 288092)


--- trunk/Source/WebCore/ChangeLog	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/Source/WebCore/ChangeLog	2022-01-17 09:50:12 UTC (rev 288092)
@@ -1,5 +1,23 @@
 2022-01-17  Philippe Normand  <[email protected]>
 
+        [GStreamer] tests media/track/audio-track-configuration.html and media/track/video-track-configuration.html fail
+        https://bugs.webkit.org/show_bug.cgi?id=234084
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The known caps and tags of the track GstStream are now exposed through the corresponding
+        Platform{Audio,Video}TrackConfiguration. This is supported only when playbin3 is used at
+        runtime. Supporting playbin2 would be some work (pad probes upfront of decoders?) that could
+        be done as a follow-up. The codec string is generated with the new GStreamer API
+        gst_codec_utils_caps_get_mime_codec(), which will ship in 1.20.
+
+        * platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp:
+        (WebCore::AudioTrackPrivateGStreamer::AudioTrackPrivateGStreamer):
+        * platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp:
+        (WebCore::VideoTrackPrivateGStreamer::VideoTrackPrivateGStreamer):
+
+2022-01-17  Philippe Normand  <[email protected]>
+
         [Debug][GStreamer] Crash in fast/mediastream/get-display-media-settings.html
         https://bugs.webkit.org/show_bug.cgi?id=235221
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp (288091 => 288092)


--- trunk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp	2022-01-17 09:50:12 UTC (rev 288092)
@@ -30,6 +30,7 @@
 #include "AudioTrackPrivateGStreamer.h"
 
 #include "MediaPlayerPrivateGStreamer.h"
+#include <gst/pbutils/pbutils.h>
 
 namespace WebCore {
 
@@ -50,8 +51,55 @@
         auto streamFlags = gst_stream_get_stream_flags(m_stream.get());
         gst_stream_set_stream_flags(m_stream.get(), static_cast<GstStreamFlags>(streamFlags | GST_STREAM_FLAG_SELECT));
     }
+
+    g_signal_connect_swapped(m_stream.get(), "notify::caps", G_CALLBACK(+[](AudioTrackPrivateGStreamer* track) {
+        track->updateConfigurationFromCaps();
+    }), this);
+    g_signal_connect_swapped(m_stream.get(), "notify::tags", G_CALLBACK(+[](AudioTrackPrivateGStreamer* track) {
+        track->updateConfigurationFromTags();
+    }), this);
+
+    updateConfigurationFromCaps();
+    updateConfigurationFromTags();
 }
 
+void AudioTrackPrivateGStreamer::updateConfigurationFromTags()
+{
+    auto tags = adoptGRef(gst_stream_get_tags(m_stream.get()));
+    unsigned bitrate;
+    if (!tags || !gst_tag_list_get_uint(tags.get(), GST_TAG_BITRATE, &bitrate))
+        return;
+
+    auto configuration = this->configuration();
+    configuration.bitrate = bitrate;
+    callOnMainThreadAndWait([&] {
+        setConfiguration(WTFMove(configuration));
+    });
+}
+
+void AudioTrackPrivateGStreamer::updateConfigurationFromCaps()
+{
+    auto caps = adoptGRef(gst_stream_get_caps(m_stream.get()));
+    if (!caps || !gst_caps_is_fixed(caps.get()))
+        return;
+
+    auto configuration = this->configuration();
+    GstAudioInfo info;
+    if (gst_audio_info_from_caps(&info, caps.get())) {
+        configuration.sampleRate = GST_AUDIO_INFO_RATE(&info);
+        configuration.numberOfChannels = GST_AUDIO_INFO_CHANNELS(&info);
+    }
+
+#if GST_CHECK_VERSION(1, 19, 0)
+    GUniquePtr<char> codec(gst_codec_utils_caps_get_mime_codec(caps.get()));
+    configuration.codec = codec.get();
+#endif
+
+    callOnMainThreadAndWait([&] {
+        setConfiguration(WTFMove(configuration));
+    });
+}
+
 AudioTrackPrivate::Kind AudioTrackPrivateGStreamer::kind() const
 {
     if (m_stream.get() && gst_stream_get_stream_flags(m_stream.get()) & GST_STREAM_FLAG_SELECT)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h (288091 => 288092)


--- trunk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h	2022-01-17 09:50:12 UTC (rev 288092)
@@ -60,6 +60,10 @@
     AtomString label() const final { return m_label; }
     AtomString language() const final { return m_language; }
 
+protected:
+    void updateConfigurationFromCaps();
+    void updateConfigurationFromTags();
+
 private:
     AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstPad>&&, bool shouldHandleStreamStartEvent);
     AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstStream>&&);

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp (288091 => 288092)


--- trunk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp	2022-01-17 09:50:12 UTC (rev 288092)
@@ -30,6 +30,7 @@
 #include "VideoTrackPrivateGStreamer.h"
 
 #include "MediaPlayerPrivateGStreamer.h"
+#include <gst/pbutils/pbutils.h>
 
 namespace WebCore {
 
@@ -50,8 +51,118 @@
         auto streamFlags = gst_stream_get_stream_flags(m_stream.get());
         gst_stream_set_stream_flags(m_stream.get(), static_cast<GstStreamFlags>(streamFlags | GST_STREAM_FLAG_SELECT));
     }
+
+    g_signal_connect_swapped(m_stream.get(), "notify::caps", G_CALLBACK(+[](VideoTrackPrivateGStreamer* track) {
+        track->updateConfigurationFromCaps();
+    }), this);
+    g_signal_connect_swapped(m_stream.get(), "notify::tags", G_CALLBACK(+[](VideoTrackPrivateGStreamer* track) {
+        track->updateConfigurationFromTags();
+    }), this);
+
+    updateConfigurationFromCaps();
+    updateConfigurationFromTags();
 }
 
+void VideoTrackPrivateGStreamer::updateConfigurationFromTags()
+{
+    auto tags = adoptGRef(gst_stream_get_tags(m_stream.get()));
+    unsigned bitrate;
+    if (!tags || !gst_tag_list_get_uint(tags.get(), GST_TAG_BITRATE, &bitrate))
+        return;
+
+    auto configuration = this->configuration();
+    configuration.bitrate = bitrate;
+    callOnMainThreadAndWait([&] {
+        setConfiguration(WTFMove(configuration));
+    });
+}
+
+void VideoTrackPrivateGStreamer::updateConfigurationFromCaps()
+{
+    auto caps = adoptGRef(gst_stream_get_caps(m_stream.get()));
+    if (!caps || !gst_caps_is_fixed(caps.get()))
+        return;
+
+    auto configuration = this->configuration();
+    GstVideoInfo info;
+    if (gst_video_info_from_caps(&info, caps.get())) {
+        if (GST_VIDEO_INFO_FPS_N(&info)) {
+            double framerate;
+            gst_util_fraction_to_double(GST_VIDEO_INFO_FPS_N(&info), GST_VIDEO_INFO_FPS_D(&info), &framerate);
+            configuration.framerate = framerate;
+        }
+        configuration.width = GST_VIDEO_INFO_WIDTH(&info);
+        configuration.height = GST_VIDEO_INFO_HEIGHT(&info);
+
+#ifndef GST_DISABLE_GST_DEBUG
+        GUniquePtr<char> colorimetry(gst_video_colorimetry_to_string(&GST_VIDEO_INFO_COLORIMETRY(&info)));
+#endif
+        PlatformVideoColorSpace colorSpace;
+        switch (GST_VIDEO_INFO_COLORIMETRY(&info).matrix) {
+        case GST_VIDEO_COLOR_MATRIX_RGB:
+            colorSpace.matrix = PlatformVideoMatrixCoefficients::Rgb;
+            break;
+        case GST_VIDEO_COLOR_MATRIX_BT709:
+            colorSpace.matrix = PlatformVideoMatrixCoefficients::Bt709;
+            break;
+        case GST_VIDEO_COLOR_MATRIX_BT601:
+            colorSpace.matrix = PlatformVideoMatrixCoefficients::Bt470bg;
+            break;
+        default:
+#ifndef GST_DISABLE_GST_DEBUG
+            GST_DEBUG("Unhandled colorspace matrix from %s", colorimetry.get());
+#endif
+            break;
+        }
+
+        switch (GST_VIDEO_INFO_COLORIMETRY(&info).transfer) {
+        case GST_VIDEO_TRANSFER_SRGB:
+            colorSpace.transfer = PlatformVideoTransferCharacteristics::Iec6196621;
+            break;
+        case GST_VIDEO_TRANSFER_BT709:
+            colorSpace.transfer = PlatformVideoTransferCharacteristics::Bt709;
+            break;
+#if GST_CHECK_VERSION(1, 18, 0)
+        case GST_VIDEO_TRANSFER_BT601:
+            colorSpace.transfer = PlatformVideoTransferCharacteristics::Smpte170m;
+            break;
+#endif
+        default:
+#ifndef GST_DISABLE_GST_DEBUG
+            GST_DEBUG("Unhandled colorspace transfer from %s", colorimetry.get());
+#endif
+            break;
+        }
+
+        switch (GST_VIDEO_INFO_COLORIMETRY(&info).primaries) {
+        case GST_VIDEO_COLOR_PRIMARIES_BT709:
+            colorSpace.primaries = PlatformVideoColorPrimaries::Bt709;
+            break;
+        case GST_VIDEO_COLOR_PRIMARIES_BT470BG:
+            colorSpace.primaries = PlatformVideoColorPrimaries::Bt470bg;
+            break;
+        case GST_VIDEO_COLOR_PRIMARIES_SMPTE170M:
+            colorSpace.primaries = PlatformVideoColorPrimaries::Smpte170m;
+            break;
+        default:
+#ifndef GST_DISABLE_GST_DEBUG
+            GST_DEBUG("Unhandled colorspace primaries from %s", colorimetry.get());
+#endif
+            break;
+        }
+        configuration.colorSpace = WTFMove(colorSpace);
+    }
+
+#if GST_CHECK_VERSION(1, 19, 0)
+    GUniquePtr<char> codec(gst_codec_utils_caps_get_mime_codec(caps.get()));
+    configuration.codec = codec.get();
+#endif
+
+    callOnMainThreadAndWait([&] {
+        setConfiguration(WTFMove(configuration));
+    });
+}
+
 VideoTrackPrivate::Kind VideoTrackPrivateGStreamer::kind() const
 {
     if (m_stream.get() && gst_stream_get_stream_flags(m_stream.get()) & GST_STREAM_FLAG_SELECT)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h (288091 => 288092)


--- trunk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h	2022-01-17 09:29:06 UTC (rev 288091)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h	2022-01-17 09:50:12 UTC (rev 288092)
@@ -61,6 +61,10 @@
     AtomString label() const final { return m_label; }
     AtomString language() const final { return m_language; }
 
+protected:
+    void updateConfigurationFromCaps();
+    void updateConfigurationFromTags();
+
 private:
     VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstPad>&&, bool shouldHandleStreamStartEvent);
     VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, unsigned index, GRefPtr<GstStream>&&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to