Title: [276491] trunk
Revision
276491
Author
[email protected]
Date
2021-04-23 02:23:04 -0700 (Fri, 23 Apr 2021)

Log Message

[LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
https://bugs.webkit.org/show_bug.cgi?id=222795

Patch by Philippe Normand <[email protected]> on 2021-04-23
Reviewed by Xabier Rodriguez-Calvar.

Source/ThirdParty/libwebrtc:

* CMakeLists.txt: Enable NO_MAIN_THREAD_WRAPPING as in the XCode build and harmonize options
between Apple and non-Apple ports.
* Source/webrtc/common_video/h265/h265_pps_parser.h:

Source/WebCore:

Add VP9 encoding and decoding support in the WPE/GTK LibWebRTC backend. The underlying
encoding support is based on LibWebRTC's internal VP9 support. The GStreamer VPx encoders
lack simulcast and high profile support, so can't really be used anyway. The
GStreamerVP8Encoder was removed for this reason as well.

* platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp:
(WebCore::VP9Decoder::VP9Decoder):
(WebCore::VP9Decoder::Create):
(WebCore::GStreamerVideoDecoderFactory::CreateVideoDecoder):
(WebCore::GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory):
(WebCore::GStreamerVideoDecoderFactory::GetSupportedFormats const):
* platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h:
* platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:
* platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
(WebCore::GStreamerVideoEncoder::makeElement):
(WebCore::GStreamerVideoEncoder::createEncoder):
(WebCore::GStreamerVideoEncoder::SetRestrictionCaps):
(WebCore::GStreamerVideoEncoderFactory::CreateVideoEncoder):
(WebCore::GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory):
(WebCore::GStreamerVideoEncoderFactory::GetSupportedFormats const):
* platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h:
* platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp:
(WebCore::LibWebRTCProviderGStreamer::createDecoderFactory):
(WebCore::LibWebRTCProviderGStreamer::createEncoderFactory):

LayoutTests:

Update GLIB baselines for webrtc tests.

* platform/glib/TestExpectations:
* platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-onnegotiationneeded-expected.txt: Added.
* platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https-expected.txt: Added.
* platform/glib/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver-setCodecPreferences-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276490 => 276491)


--- trunk/LayoutTests/ChangeLog	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/LayoutTests/ChangeLog	2021-04-23 09:23:04 UTC (rev 276491)
@@ -1,3 +1,17 @@
+2021-04-23  Philippe Normand  <[email protected]>
+
+        [LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
+        https://bugs.webkit.org/show_bug.cgi?id=222795
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Update GLIB baselines for webrtc tests.
+
+        * platform/glib/TestExpectations:
+        * platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-onnegotiationneeded-expected.txt: Added.
+        * platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https-expected.txt: Added.
+        * platform/glib/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver-setCodecPreferences-expected.txt: Added.
+
 2021-04-22  Diego Pino Garcia  <[email protected]>
 
         [GTK] Unreviewed test gardening. Update baseline after r276448.

Modified: trunk/LayoutTests/platform/glib/TestExpectations (276490 => 276491)


--- trunk/LayoutTests/platform/glib/TestExpectations	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2021-04-23 09:23:04 UTC (rev 276491)
@@ -1120,8 +1120,6 @@
 webkit.org/b/210272 webrtc/datachannel/multiple-connections.html [ Timeout Pass ]
 webkit.org/b/212809 [ Release ] webrtc/datachannel/gather-candidates-networkprocess-crash.html [ Timeout Pass ]
 
-webkit.org/b/213780 webrtc/vp9.html [ Failure ]
-
 webkit.org/b/215005 webkit.org/b/218787 webrtc/h264-baseline.html [ Crash Timeout ]
 # h264-high.html is marked as slow in the root expectation
 webkit.org/b/215007 [ Release ] webrtc/h264-high.html [ Timeout ]
@@ -1138,7 +1136,7 @@
 
 webkit.org/b/216763 webrtc/captureCanvas-webrtc-software-h264-high.html [ Crash Failure ]
 
-webkit.org/b/218221 webrtc/vp9-profile2.html [ Failure ]
+webkit.org/b/218221 webrtc/vp9-profile2.html [ Timeout Failure ]
 
 # Release timing out.
 webkit.org/b/219825 [ Release ] webrtc/sframe-keys.html [ Skip ]
@@ -2027,22 +2025,18 @@
 webkit.org/b/186100 css3/color-filters/color-filter-color-property-list-item.html [ ImageOnlyFailure ]
 webkit.org/b/186100 fast/hidpi/filters-turbulence.html [ ImageOnlyFailure ]
 webkit.org/b/187044 webanimations/opacity-animation-yields-compositing-span.html [ Failure ]
-webkit.org/b/187064 webrtc/audio-peer-connection-g722.html
-webkit.org/b/187064 webrtc/captureCanvas-webrtc.html
+
+webkit.org/b/187064 webrtc/libwebrtc/descriptionGetters.html
 webkit.org/b/187064 webrtc/datachannel/mdns-ice-candidates.html
-webkit.org/b/187064 webrtc/libwebrtc/descriptionGetters.html
-webkit.org/b/187064 webrtc/peer-connection-track-end.html
 webkit.org/b/187064 webrtc/video-addTrack.html
-webkit.org/b/187064 webrtc/video-addTransceiver.html
 webkit.org/b/187064 webrtc/video-disabled-black.html
-webkit.org/b/187064 webrtc/video.html
-webkit.org/b/187064 webrtc/video-mute.html
 webkit.org/b/187064 webrtc/video-remote-mute.html
 webkit.org/b/187064 webrtc/video-replace-muted-track.html
-webkit.org/b/187064 webrtc/video-replace-track.html
 webkit.org/b/187064 webrtc/video-rotation.html
-webkit.org/b/187064 webrtc/video-unmute.html
 webkit.org/b/187064 webrtc/video-with-data-channel.html
+webkit.org/b/187064 webrtc/video-replace-track.html [ Failure Pass ]
+webkit.org/b/187064 imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-getStats.https.html [ Failure Pass ]
+
 webkit.org/b/187271 fast/text/emoji-with-joiner.html [ Failure ]
 webkit.org/b/189343 imported/w3c/web-platform-tests/xhr/sync-no-timeout.any.worker.html [ Failure ]
 webkit.org/b/190707 css-custom-properties-api/length2.html [ Failure ]

Added: trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-onnegotiationneeded-expected.txt (0 => 276491)


--- trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-onnegotiationneeded-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-onnegotiationneeded-expected.txt	2021-04-23 09:23:04 UTC (rev 276491)
@@ -0,0 +1,18 @@
+
+PASS Creating first data channel should fire negotiationneeded event
+PASS calling createDataChannel twice should fire negotiationneeded event once
+PASS addTransceiver() should fire negotiationneeded event
+PASS Calling addTransceiver() twice should fire negotiationneeded event once
+PASS Calling both addTransceiver() and createDataChannel() should fire negotiationneeded event once
+PASS negotiationneeded event should not fire if signaling state is not stable
+PASS negotiationneeded event should fire only after signaling state goes back to stable after setRemoteDescription
+PASS negotiationneeded event should fire only after signaling state goes back to stable after setLocalDescription
+PASS negotiationneeded event should fire only after signalingstatechange event fires from setRemoteDescription
+PASS negotiationneeded event should fire only after signalingstatechange event fires from setLocalDescription
+PASS addTrack should cause negotiationneeded to fire
+PASS removeTrack should cause negotiationneeded to fire on the caller
+PASS removeTrack should cause negotiationneeded to fire on the callee
+PASS Updating the direction of the transceiver should cause negotiationneeded to fire
+PASS Calling setStreams should cause negotiationneeded to fire
+PASS Adding two transceivers, one at a time, results in the expected number of negotiationneeded events
+

Added: trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https-expected.txt (0 => 276491)


--- trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https-expected.txt	2021-04-23 09:23:04 UTC (rev 276491)
@@ -0,0 +1,15 @@
+
+PASS restartIce() does not trigger negotiation ahead of initial negotiation
+PASS restartIce() has no effect on initial negotiation
+PASS restartIce() fires negotiationneeded after initial negotiation
+PASS restartIce() causes fresh ufrags
+PASS restartIce() works in have-local-offer
+PASS restartIce() works in initial have-local-offer
+PASS restartIce() works in have-remote-offer
+PASS restartIce() does nothing in initial have-remote-offer
+PASS restartIce() survives remote offer
+PASS restartIce() is satisfied by remote ICE restart
+PASS restartIce() trumps {iceRestart: false}
+FAIL restartIce() survives rollback promise_test: Unhandled rejection with value: object "InvalidStateError: Local description type 3 is incompatible with current signaling state 1"
+FAIL restartIce() survives remote offer containing partial restart assert_false: Restarted 2 expected false got true
+

Added: trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver-setCodecPreferences-expected.txt (0 => 276491)


--- trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver-setCodecPreferences-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/glib/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver-setCodecPreferences-expected.txt	2021-04-23 09:23:04 UTC (rev 276491)
@@ -0,0 +1,21 @@
+
+PASS setCodecPreferences() on audio transceiver with codecs returned from RTCRtpSender.getCapabilities('audio') should succeed
+PASS setCodecPreferences() on video transceiver with codecs returned from RTCRtpReceiver.getCapabilities('video') should succeed
+PASS setCodecPreferences() with both sender receiver codecs combined should succeed
+PASS setCodecPreferences([]) should succeed
+PASS setCodecPreferences() with reordered codecs should succeed
+PASS setCodecPreferences() with only VP8 should succeed
+PASS setCodecPreferences() with only H264 should succeed
+PASS setCodecPreferences() should allow setting H264 as first codec
+PASS setCodecPreferences() should allow setting VP8 as first codec
+PASS setCodecPreferences() on audio transceiver with codecs returned from getCapabilities('video') should throw InvalidModificationError
+PASS setCodecPreferences() with user defined codec with invalid mimeType should throw InvalidModificationError
+PASS setCodecPreferences() with user defined codec should throw InvalidModificationError
+PASS setCodecPreferences() with user defined codec together with codecs returned from getCapabilities() should throw InvalidModificationError
+PASS setCodecPreferences() with modified codec clock rate should throw InvalidModificationError
+PASS setCodecPreferences() with modified codec channel count should throw InvalidModificationError
+PASS setCodecPreferences() with modified codec parameters should throw InvalidModificationError
+PASS setCodecPreferences() with modified codecs returned from getCapabilities() should throw InvalidModificationError
+PASS setCodecPreferences() modifies the order of audio codecs in createOffer
+PASS setCodecPreferences() modifies the order of video codecs in createOffer
+

Modified: trunk/Source/ThirdParty/libwebrtc/CMakeLists.txt (276490 => 276491)


--- trunk/Source/ThirdParty/libwebrtc/CMakeLists.txt	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/ThirdParty/libwebrtc/CMakeLists.txt	2021-04-23 09:23:04 UTC (rev 276491)
@@ -538,6 +538,10 @@
     Source/webrtc/common_video/h264/pps_parser.cc
     Source/webrtc/common_video/h264/sps_parser.cc
     Source/webrtc/common_video/h264/sps_vui_rewriter.cc
+    Source/webrtc/common_video/h265/h265_common.cc
+    Source/webrtc/common_video/h265/h265_pps_parser.cc
+    Source/webrtc/common_video/h265/h265_sps_parser.cc
+    Source/webrtc/common_video/h265/h265_vps_parser.cc
     Source/webrtc/common_video/incoming_video_stream.cc
     Source/webrtc/common_video/libyuv/webrtc_libyuv.cc
     Source/webrtc/common_video/video_frame_buffer.cc
@@ -1042,8 +1046,9 @@
     Source/webrtc/modules/video_coding/codecs/vp8/temporal_layers_checker.cc
     Source/webrtc/modules/video_coding/codecs/vp9/svc_config.cc
     Source/webrtc/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
+    Source/webrtc/modules/video_coding/codecs/vp9/vp9.cc
+    Source/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc
     Source/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
-    Source/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc
     Source/webrtc/modules/video_coding/codec_timer.cc
     Source/webrtc/modules/video_coding/decoder_database.cc
     Source/webrtc/modules/video_coding/decoding_state.cc
@@ -1057,6 +1062,7 @@
     Source/webrtc/modules/video_coding/generic_decoder.cc
     Source/webrtc/modules/video_coding/h264_sprop_parameter_sets.cc
     Source/webrtc/modules/video_coding/h264_sps_pps_tracker.cc
+    Source/webrtc/modules/video_coding/h265_vps_sps_pps_tracker.cc
     Source/webrtc/modules/video_coding/histogram.cc
     Source/webrtc/modules/video_coding/include/video_codec_interface.cc
     Source/webrtc/modules/video_coding/inter_frame_delay.cc
@@ -1608,19 +1614,25 @@
 set_target_properties(webrtc PROPERTIES C_VISIBILITY_PRESET hidden)
 
 target_compile_definitions(webrtc PRIVATE
-  OPENSSL_NO_ASM
   DYNAMIC_ANNOTATIONS_ENABLED=1
   EXPAT_RELATIVE_PATH
+  HAVE_CONFIG_H
   HAVE_LRINT
   HAVE_LRINTF
   HAVE_NETINET_IN_H
   HAVE_SCTP
+  HAVE_STDINT_H
+  HAVE_STDLIB_H
+  HAVE_UINT64_T
   HAVE_WEBRTC_VIDEO
   HAVE_WEBRTC_VOICE
   JSON_USE_EXCEPTION=0
   NON_WINDOWS_DEFINE
+  NO_MAIN_THREAD_WRAPPING
+  OPENSSL_NO_ASM
   OPUS_BUILD
   OPUS_EXPORT=
+  RTC_ENABLE_VP9
   VAR_ARRAYS
   WEBRTC_APM_DEBUG_DUMP=0
   WEBRTC_CODEC_G711
@@ -1639,19 +1651,16 @@
   WEBRTC_USE_BUILTIN_ISAC_FIX=1
   WEBRTC_USE_BUILTIN_ISAC_FLOAT=0
   WTF_USE_DYNAMIC_ANNOTATIONS=1
-  RTC_DISABLE_VP9
   _GNU_SOURCE
 )
 
 if (APPLE)
     target_compile_definitions(webrtc PRIVATE
-        RTC_ENABLE_VP9
         WEBRTC_ARCH_LITTLE_ENDIAN
         WEBRTC_MAC
     )
 else ()
     target_compile_definitions(webrtc PRIVATE
-        DISABLE_H265
         SCTP_PROCESS_LEVEL_LOCKS
         SCTP_SIMPLE_ALLOCATOR
         SCTP_USE_OPENSSL_SHA1

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (276490 => 276491)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2021-04-23 09:23:04 UTC (rev 276491)
@@ -1,3 +1,14 @@
+2021-04-23  Philippe Normand  <[email protected]>
+
+        [LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
+        https://bugs.webkit.org/show_bug.cgi?id=222795
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * CMakeLists.txt: Enable NO_MAIN_THREAD_WRAPPING as in the XCode build and harmonize options
+        between Apple and non-Apple ports.
+        * Source/webrtc/common_video/h265/h265_pps_parser.h:
+
 2021-04-21  Kimmo Kinnunen  <[email protected]>
 
         WebRTC should be compiled with thread-safe statics

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/common_video/h265/h265_pps_parser.h (276490 => 276491)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/common_video/h265/h265_pps_parser.h	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/common_video/h265/h265_pps_parser.h	2021-04-23 09:23:04 UTC (rev 276491)
@@ -13,6 +13,10 @@
 
 #include "absl/types/optional.h"
 
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
 namespace rtc {
 class BitBuffer;
 }

Modified: trunk/Source/WebCore/ChangeLog (276490 => 276491)


--- trunk/Source/WebCore/ChangeLog	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/ChangeLog	2021-04-23 09:23:04 UTC (rev 276491)
@@ -1,3 +1,35 @@
+2021-04-23  Philippe Normand  <[email protected]>
+
+        [LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
+        https://bugs.webkit.org/show_bug.cgi?id=222795
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Add VP9 encoding and decoding support in the WPE/GTK LibWebRTC backend. The underlying
+        encoding support is based on LibWebRTC's internal VP9 support. The GStreamer VPx encoders
+        lack simulcast and high profile support, so can't really be used anyway. The
+        GStreamerVP8Encoder was removed for this reason as well.
+
+        * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp:
+        (WebCore::VP9Decoder::VP9Decoder):
+        (WebCore::VP9Decoder::Create):
+        (WebCore::GStreamerVideoDecoderFactory::CreateVideoDecoder):
+        (WebCore::GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory):
+        (WebCore::GStreamerVideoDecoderFactory::GetSupportedFormats const):
+        * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h:
+        * platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:
+        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
+        (WebCore::GStreamerVideoEncoder::makeElement):
+        (WebCore::GStreamerVideoEncoder::createEncoder):
+        (WebCore::GStreamerVideoEncoder::SetRestrictionCaps):
+        (WebCore::GStreamerVideoEncoderFactory::CreateVideoEncoder):
+        (WebCore::GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory):
+        (WebCore::GStreamerVideoEncoderFactory::GetSupportedFormats const):
+        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h:
+        * platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp:
+        (WebCore::LibWebRTCProviderGStreamer::createDecoderFactory):
+        (WebCore::LibWebRTCProviderGStreamer::createEncoderFactory):
+
 2021-04-22  Tyler Wilcock  <[email protected]>
 
         [css-counter-styles] Parse @counter-style descriptors

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp (276490 => 276491)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp	2021-04-23 09:23:04 UTC (rev 276491)
@@ -386,6 +386,34 @@
     }
 };
 
+class VP9Decoder : public GStreamerVideoDecoder {
+public:
+    VP9Decoder(bool isSupportingVP9Profile0 = true, bool isSupportingVP9Profile2 = true)
+        : m_isSupportingVP9Profile0(isSupportingVP9Profile0)
+        , m_isSupportingVP9Profile2(isSupportingVP9Profile2) { };
+
+    const gchar* Caps() final { return "video/x-vp9"; }
+    const gchar* Name() final { return cricket::kVp9CodecName; }
+    webrtc::VideoCodecType CodecType() final { return webrtc::kVideoCodecVP9; }
+    static std::unique_ptr<webrtc::VideoDecoder> Create()
+    {
+        return std::unique_ptr<webrtc::VideoDecoder>(new VP9Decoder());
+    }
+
+    std::vector<webrtc::SdpVideoFormat> ConfigureSupportedDecoder() final
+    {
+        std::vector<webrtc::SdpVideoFormat> formats;
+        if (m_isSupportingVP9Profile0)
+            formats.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, { { "profile-id", "0" } }));
+        if (m_isSupportingVP9Profile2)
+            formats.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, { { "profile-id", "2" } }));
+        return formats;
+    }
+private:
+    bool m_isSupportingVP9Profile0;
+    bool m_isSupportingVP9Profile2;
+};
+
 std::unique_ptr<webrtc::VideoDecoder> GStreamerVideoDecoderFactory::CreateVideoDecoder(const webrtc::SdpVideoFormat& format)
 {
     webrtc::VideoDecoder* dec;
@@ -394,6 +422,8 @@
         dec = new H264Decoder();
     else if (format.name == cricket::kVp8CodecName)
         return VP8Decoder::Create();
+    else if (format.name == cricket::kVp9CodecName)
+        return VP9Decoder::Create();
     else {
         GST_ERROR("Could not create decoder for %s", format.name.c_str());
 
@@ -403,7 +433,9 @@
     return std::unique_ptr<webrtc::VideoDecoder>(dec);
 }
 
-GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory()
+GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2)
+    : m_isSupportingVP9Profile0(isSupportingVP9Profile0)
+    , m_isSupportingVP9Profile2(isSupportingVP9Profile2)
 {
     ensureGStreamerInitialized();
 
@@ -417,6 +449,7 @@
     std::vector<webrtc::SdpVideoFormat> formats;
 
     VP8Decoder().AddDecoderIfSupported(formats);
+    VP9Decoder(m_isSupportingVP9Profile0, m_isSupportingVP9Profile2).AddDecoderIfSupported(formats);
     H264Decoder().AddDecoderIfSupported(formats);
 
     return formats;

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h (276490 => 276491)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h	2021-04-23 09:23:04 UTC (rev 276491)
@@ -24,8 +24,7 @@
 
 #include "LibWebRTCMacros.h"
 #include "api/video_codecs/video_decoder_factory.h"
-#include <gst/gst.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/Forward.h>
 
 namespace WebCore {
 
@@ -32,12 +31,14 @@
 class GStreamerVideoDecoderFactory : public webrtc::VideoDecoderFactory {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    GStreamerVideoDecoderFactory();
-    static bool newSource(String trackId, GstElement *source);
+    GStreamerVideoDecoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2);
 
 private:
     std::unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(const webrtc::SdpVideoFormat&) final;
     std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const final;
+
+    bool m_isSupportingVP9Profile0;
+    bool m_isSupportingVP9Profile2;
 };
 }
 

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp (276490 => 276491)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp	2021-04-23 09:23:04 UTC (rev 276491)
@@ -35,7 +35,7 @@
 #define KBIT_TO_BIT 1024
 
 static GstStaticPadTemplate sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-raw(ANY)"));
-static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-h264;video/x-vp8"));
+static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-h264"));
 
 using SetBitrateFunc = Function<void(GObject* encoder, const char* propertyName, int bitrate)>;
 using SetupFunc = Function<void(WebKitWebrtcVideoEncoder*)>;
@@ -51,7 +51,7 @@
     const char* keyframeIntervalPropertyName;
 };
 
-enum EncoderId { None, X264, OpenH264, OmxH264, Vp8 };
+enum EncoderId { None, X264, OpenH264, OmxH264 };
 
 class Encoders {
 public:

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp (276490 => 276491)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp	2021-04-23 09:23:04 UTC (rev 276491)
@@ -28,12 +28,13 @@
 #include "GStreamerVideoFrameLibWebRTC.h"
 #include "LibWebRTCWebKitMacros.h"
 #include "webrtc/common_video/h264/h264_common.h"
+#include "webrtc/media/base/vp9_profile.h"
 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
 #include "webrtc/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h"
+#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
 #include "webrtc/modules/video_coding/utility/simulcast_utility.h"
-
 #include <gst/app/gstappsink.h>
 #include <gst/app/gstappsrc.h>
 
@@ -107,7 +108,7 @@
         SetRestrictionCaps(WTFMove(caps));
 
         if (m_encoder)
-            g_object_set(m_encoder, "bitrate", parameters.bitrate.get_sum_bps(), nullptr);
+            g_object_set(m_encoder.get(), "bitrate", parameters.bitrate.get_sum_bps(), nullptr);
     }
 
     GstElement* pipeline()
@@ -119,8 +120,7 @@
     {
         static Atomic<uint32_t> elementId;
         auto name = makeString(Name(), "-enc-", factoryName, "-", elementId.exchangeAdd(1));
-        auto elem = gst_element_factory_make(factoryName, name.utf8().data());
-
+        auto* elem = gst_element_factory_make(factoryName, name.utf8().data());
         return elem;
     }
 
@@ -131,7 +131,6 @@
 
         if (webrtc::SimulcastUtility::NumberOfSimulcastStreams(*codecSettings) > 1) {
             GST_ERROR("Simulcast not supported.");
-
             return WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED;
         }
 
@@ -138,33 +137,31 @@
         m_pipeline = makeElement("pipeline");
 
         connectSimpleBusMessageCallback(m_pipeline.get());
-        auto encoder = createEncoder();
-        ASSERT(encoder);
-        m_encoder = encoder.get();
+        m_encoder = createEncoder();
+        ASSERT(m_encoder);
 
-        g_object_set(m_encoder, "keyframe-interval", KeyframeInterval(codecSettings), nullptr);
+        g_object_set(m_encoder.get(), "keyframe-interval", KeyframeInterval(codecSettings), nullptr);
 
         m_src = makeElement("appsrc");
-        g_object_set(m_src, "is-live", true, "format", GST_FORMAT_TIME, nullptr);
+        g_object_set(m_src.get(), "is-live", true, "format", GST_FORMAT_TIME, nullptr);
 
-        auto videoconvert = makeElement("videoconvert");
-        auto videoscale = makeElement("videoscale");
+        auto* videoconvert = makeElement("videoconvert");
+        auto* videoscale = makeElement("videoscale");
         m_sink = makeElement("appsink");
-        g_object_set(m_sink, "sync", FALSE, nullptr);
+        g_object_set(m_sink.get(), "sync", FALSE, nullptr);
 
         m_capsFilter = makeElement("capsfilter");
         if (m_restrictionCaps)
-            g_object_set(m_capsFilter, "caps", m_restrictionCaps.get(), nullptr);
+            g_object_set(m_capsFilter.get(), "caps", m_restrictionCaps.get(), nullptr);
 
-        gst_bin_add_many(GST_BIN(m_pipeline.get()), m_src, videoconvert, videoscale, m_capsFilter, encoder.leakRef(), m_sink, nullptr);
-        if (!gst_element_link_many(m_src, videoconvert, videoscale, m_capsFilter, m_encoder, m_sink, nullptr)) {
-            GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_VERBOSE, "webkit-webrtc-encoder.error");
-
+        gst_bin_add_many(GST_BIN_CAST(m_pipeline.get()), m_src.get(), videoconvert, videoscale, m_capsFilter.get(), m_encoder.get(), m_sink.get(), nullptr);
+        if (!gst_element_link_many(m_src.get(), videoconvert, videoscale, m_capsFilter.get(), m_encoder.get(), m_sink.get(), nullptr)) {
+            GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN_CAST(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_VERBOSE, "webkit-webrtc-encoder.error");
             ASSERT_NOT_REACHED();
         }
 
         gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING);
-
+        GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN_CAST(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_VERBOSE, "webkit-webrtc-encoder");
         return WEBRTC_VIDEO_CODEC_OK;
     }
 
@@ -236,13 +233,13 @@
 
         if (!GST_CLOCK_TIME_IS_VALID(m_firstFramePts)) {
             m_firstFramePts = GST_BUFFER_PTS(buffer);
-            auto pad = adoptGRef(gst_element_get_static_pad(m_src, "src"));
+            auto pad = adoptGRef(gst_element_get_static_pad(m_src.get(), "src"));
             gst_pad_set_offset(pad.get(), -m_firstFramePts);
         }
 
         for (auto frame_type : *frameTypes) {
             if (frame_type == webrtc::VideoFrameType::kVideoFrameKey) {
-                auto pad = adoptGRef(gst_element_get_static_pad(m_src, "src"));
+                auto pad = adoptGRef(gst_element_get_static_pad(m_src.get(), "src"));
                 auto forceKeyUnit = gst_video_event_new_downstream_force_key_unit(GST_CLOCK_TIME_NONE,
                     GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE, FALSE, 1);
                 GST_INFO_OBJECT(m_pipeline.get(), "Requesting KEYFRAME!");
@@ -254,11 +251,11 @@
             }
         }
 
-        res = returnFromFlowReturn(gst_app_src_push_sample(GST_APP_SRC(m_src), sample.get()));
+        res = returnFromFlowReturn(gst_app_src_push_sample(GST_APP_SRC(m_src.get()), sample.get()));
         if (res != WEBRTC_VIDEO_CODEC_OK)
             return res;
 
-        auto encodedSample = adoptGRef(gst_app_sink_try_pull_sample(GST_APP_SINK(m_sink), 5 * GST_SECOND));
+        auto encodedSample = adoptGRef(gst_app_sink_try_pull_sample(GST_APP_SINK(m_sink.get()), 5 * GST_SECOND));
         if (!encodedSample) {
             GST_ERROR("Didn't get any encodedSample");
             return WEBRTC_VIDEO_CODEC_ERROR;
@@ -293,15 +290,13 @@
 
     GRefPtr<GstElement> createEncoder(void)
     {
+        GRefPtr<GstElement> webrtcencoder = gst_element_factory_make("webrtcvideoencoder", NULL);
+        g_object_set(webrtcencoder.get(), "format", adoptGRef(gst_caps_from_string(Caps())).get(), NULL);
+
         GRefPtr<GstElement> encoder = nullptr;
-        GstElement* webrtcencoder = GST_ELEMENT(g_object_ref_sink(gst_element_factory_make("webrtcvideoencoder", NULL)));
-
-        g_object_set(webrtcencoder, "format", adoptGRef(gst_caps_from_string(Caps())).get(), NULL);
-        g_object_get(webrtcencoder, "encoder", &encoder.outPtr(), NULL);
-
+        g_object_get(webrtcencoder.get(), "encoder", &encoder.outPtr(), NULL);
         if (!encoder) {
             GST_INFO("No encoder found for %s", Caps());
-
             return nullptr;
         }
 
@@ -334,7 +329,7 @@
     void SetRestrictionCaps(GRefPtr<GstCaps> caps)
     {
         if (m_restrictionCaps)
-            g_object_set(m_capsFilter, "caps", m_restrictionCaps.get(), nullptr);
+            g_object_set(m_capsFilter.get(), "caps", m_restrictionCaps.get(), nullptr);
 
         m_restrictionCaps = caps;
     }
@@ -341,9 +336,9 @@
 
 private:
     GRefPtr<GstElement> m_pipeline;
-    GstElement* m_src;
-    GstElement* m_encoder;
-    GstElement* m_capsFilter;
+    GRefPtr<GstElement> m_src;
+    GRefPtr<GstElement> m_encoder;
+    GRefPtr<GstElement> m_capsFilter;
 
     webrtc::EncodedImageCallback* m_imageReadyCb;
     GstClockTime m_firstFramePts;
@@ -351,7 +346,7 @@
     webrtc::EncodedImage m_encodedFrame;
 
     Lock m_bufferMapLock;
-    GstElement* m_sink;
+    GRefPtr<GstElement> m_sink;
 };
 
 class GStreamerH264Encoder : public GStreamerVideoEncoder {
@@ -393,42 +388,17 @@
     webrtc::H264PacketizationMode packetizationMode;
 };
 
-class GStreamerVP8Encoder : public GStreamerVideoEncoder {
-public:
-    GStreamerVP8Encoder() { }
-    GStreamerVP8Encoder(const webrtc::SdpVideoFormat&) { }
-    const gchar* Caps() final { return "video/x-vp8"; }
-    const gchar* Name() final { return cricket::kVp8CodecName; }
-    webrtc::VideoCodecType CodecType() final { return webrtc::kVideoCodecVP8; }
-
-    int KeyframeInterval(const webrtc::VideoCodec* codecSettings) final
-    {
-        return codecSettings->VP8().keyFrameInterval;
+std::unique_ptr<webrtc::VideoEncoder> GStreamerVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format)
+{
+    // FIXME: vpxenc doesn't support simulcast nor SVC. vp9enc supports only profile 0. These
+    // shortcomings trigger webrtc/vp9.html and webrtc/simulcast-h264.html timeouts and most likely
+    // bad UX in WPE/GTK browsers. So for now we prefer to use LibWebRTC's VPx encoders.
+    if (format.name == cricket::kVp9CodecName) {
+        GST_INFO("Using VP9 Encoder from LibWebRTC.");
+        return webrtc::VP9Encoder::Create(cricket::VideoCodec(format));
     }
 
-    void PopulateCodecSpecific(webrtc::CodecSpecificInfo* codecSpecificInfos, const GstBuffer* buffer) final
-    {
-        codecSpecificInfos->codecType = webrtc::kVideoCodecVP8;
-        webrtc::CodecSpecificInfoVP8* vp8Info = &(codecSpecificInfos->codecSpecific.VP8);
-        vp8Info->temporalIdx = 0;
-
-        vp8Info->keyIdx = webrtc::kNoKeyIdx;
-        vp8Info->nonReference = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
-    }
-};
-
-std::unique_ptr<webrtc::VideoEncoder> GStreamerVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format)
-{
     if (format.name == cricket::kVp8CodecName) {
-        GRefPtr<GstElement> webrtcencoder = adoptGRef(GST_ELEMENT(g_object_ref_sink(gst_element_factory_make("webrtcvideoencoder", NULL))));
-        GRefPtr<GstElement> encoder = nullptr;
-
-        g_object_set(webrtcencoder.get(), "format", adoptGRef(gst_caps_from_string("video/x-vp8")).get(), NULL);
-        g_object_get(webrtcencoder.get(), "encoder", &encoder.outPtr(), NULL);
-
-        if (encoder)
-            return makeUnique<GStreamerVP8Encoder>(format);
-
         GST_INFO("Using VP8 Encoder from LibWebRTC.");
         return makeUniqueWithoutFastMallocCheck<webrtc::LibvpxVp8Encoder>(webrtc::LibvpxInterface::CreateEncoder(), webrtc::VP8Encoder::Settings());
     }
@@ -446,7 +416,9 @@
     return nullptr;
 }
 
-GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory()
+GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2)
+    : m_isSupportingVP9Profile0(isSupportingVP9Profile0)
+    , m_isSupportingVP9Profile2(isSupportingVP9Profile2)
 {
     ensureGStreamerInitialized();
 
@@ -464,6 +436,10 @@
     std::vector<webrtc::SdpVideoFormat> supportedCodecs;
 
     supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp8CodecName));
+    if (m_isSupportingVP9Profile0)
+        supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, {{"profile-id", "0"}}));
+    if (m_isSupportingVP9Profile2)
+        supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, {{"profile-id", "2"}}));
 
     // If OpenH264 is present, prefer it over the GStreamer encoders (x264enc, usually).
 #if WEBKIT_LIBWEBRTC_OPENH264_ENCODER

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h (276490 => 276491)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h	2021-04-23 09:23:04 UTC (rev 276491)
@@ -23,7 +23,6 @@
 #if USE(LIBWEBRTC) && USE(GSTREAMER)
 #include "LibWebRTCMacros.h"
 #include "api/video_codecs/video_encoder_factory.h"
-#include <gst/gst.h>
 
 namespace WebCore {
 
@@ -30,7 +29,7 @@
 class GStreamerVideoEncoderFactory final : public webrtc::VideoEncoderFactory {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    GStreamerVideoEncoderFactory();
+    GStreamerVideoEncoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2);
 
 private:
     std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
@@ -37,10 +36,13 @@
     std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(const webrtc::SdpVideoFormat&) final;
     CodecInfo QueryVideoEncoder(const webrtc::SdpVideoFormat&) const override
     {
-        GST_FIXME("Detect whether the decoder is HW accelerated");
+        // FIXME: Detect whether the decoder is HW accelerated.
 
         return { false };
     }
+
+    bool m_isSupportingVP9Profile0;
+    bool m_isSupportingVP9Profile2;
 };
 }
 

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp (276490 => 276491)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp	2021-04-23 07:16:49 UTC (rev 276490)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp	2021-04-23 09:23:04 UTC (rev 276491)
@@ -28,6 +28,7 @@
 
 #if USE(LIBWEBRTC) && USE(GSTREAMER)
 
+#include "RuntimeEnabledFeatures.h"
 #include <wtf/UniqueRef.h>
 
 namespace WebCore {
@@ -44,12 +45,12 @@
 
 std::unique_ptr<webrtc::VideoDecoderFactory> LibWebRTCProviderGStreamer::createDecoderFactory()
 {
-    return makeUnique<GStreamerVideoDecoderFactory>();
+    return makeUnique<GStreamerVideoDecoderFactory>(isSupportingVP9Profile0(), isSupportingVP9Profile2());
 }
 
 std::unique_ptr<webrtc::VideoEncoderFactory> LibWebRTCProviderGStreamer::createEncoderFactory()
 {
-    return makeUnique<GStreamerVideoEncoderFactory>();
+    return makeUnique<GStreamerVideoEncoderFactory>(isSupportingVP9Profile0(), isSupportingVP9Profile2());
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to