⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276491 in webkit


Ignore:
Timestamp:
Apr 23, 2021, 2:23:04 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Philippe Normand <pnormand@igalia.com> 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.
Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276489 r276491  
     12021-04-23  Philippe Normand  <pnormand@igalia.com>
     2
     3        [LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
     4        https://bugs.webkit.org/show_bug.cgi?id=222795
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Update GLIB baselines for webrtc tests.
     9
     10        * platform/glib/TestExpectations:
     11        * platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-onnegotiationneeded-expected.txt: Added.
     12        * platform/glib/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https-expected.txt: Added.
     13        * platform/glib/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver-setCodecPreferences-expected.txt: Added.
     14
    1152021-04-22  Diego Pino Garcia  <dpino@igalia.com>
    216
  • trunk/LayoutTests/platform/glib/TestExpectations

    r276489 r276491  
    11211121webkit.org/b/212809 [ Release ] webrtc/datachannel/gather-candidates-networkprocess-crash.html [ Timeout Pass ]
    11221122
    1123 webkit.org/b/213780 webrtc/vp9.html [ Failure ]
    1124 
    11251123webkit.org/b/215005 webkit.org/b/218787 webrtc/h264-baseline.html [ Crash Timeout ]
    11261124# h264-high.html is marked as slow in the root expectation
     
    11391137webkit.org/b/216763 webrtc/captureCanvas-webrtc-software-h264-high.html [ Crash Failure ]
    11401138
    1141 webkit.org/b/218221 webrtc/vp9-profile2.html [ Failure ]
     1139webkit.org/b/218221 webrtc/vp9-profile2.html [ Timeout Failure ]
    11421140
    11431141# Release timing out.
     
    20282026webkit.org/b/186100 fast/hidpi/filters-turbulence.html [ ImageOnlyFailure ]
    20292027webkit.org/b/187044 webanimations/opacity-animation-yields-compositing-span.html [ Failure ]
    2030 webkit.org/b/187064 webrtc/audio-peer-connection-g722.html
    2031 webkit.org/b/187064 webrtc/captureCanvas-webrtc.html
     2028
     2029webkit.org/b/187064 webrtc/libwebrtc/descriptionGetters.html
    20322030webkit.org/b/187064 webrtc/datachannel/mdns-ice-candidates.html
    2033 webkit.org/b/187064 webrtc/libwebrtc/descriptionGetters.html
    2034 webkit.org/b/187064 webrtc/peer-connection-track-end.html
    20352031webkit.org/b/187064 webrtc/video-addTrack.html
    2036 webkit.org/b/187064 webrtc/video-addTransceiver.html
    20372032webkit.org/b/187064 webrtc/video-disabled-black.html
    2038 webkit.org/b/187064 webrtc/video.html
    2039 webkit.org/b/187064 webrtc/video-mute.html
    20402033webkit.org/b/187064 webrtc/video-remote-mute.html
    20412034webkit.org/b/187064 webrtc/video-replace-muted-track.html
    2042 webkit.org/b/187064 webrtc/video-replace-track.html
    20432035webkit.org/b/187064 webrtc/video-rotation.html
    2044 webkit.org/b/187064 webrtc/video-unmute.html
    20452036webkit.org/b/187064 webrtc/video-with-data-channel.html
     2037webkit.org/b/187064 webrtc/video-replace-track.html [ Failure Pass ]
     2038webkit.org/b/187064 imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-getStats.https.html [ Failure Pass ]
     2039
    20462040webkit.org/b/187271 fast/text/emoji-with-joiner.html [ Failure ]
    20472041webkit.org/b/189343 imported/w3c/web-platform-tests/xhr/sync-no-timeout.any.worker.html [ Failure ]
  • trunk/Source/ThirdParty/libwebrtc/CMakeLists.txt

    r276019 r276491  
    539539    Source/webrtc/common_video/h264/sps_parser.cc
    540540    Source/webrtc/common_video/h264/sps_vui_rewriter.cc
     541    Source/webrtc/common_video/h265/h265_common.cc
     542    Source/webrtc/common_video/h265/h265_pps_parser.cc
     543    Source/webrtc/common_video/h265/h265_sps_parser.cc
     544    Source/webrtc/common_video/h265/h265_vps_parser.cc
    541545    Source/webrtc/common_video/incoming_video_stream.cc
    542546    Source/webrtc/common_video/libyuv/webrtc_libyuv.cc
     
    10431047    Source/webrtc/modules/video_coding/codecs/vp9/svc_config.cc
    10441048    Source/webrtc/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
     1049    Source/webrtc/modules/video_coding/codecs/vp9/vp9.cc
     1050    Source/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc
    10451051    Source/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
    1046     Source/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc
    10471052    Source/webrtc/modules/video_coding/codec_timer.cc
    10481053    Source/webrtc/modules/video_coding/decoder_database.cc
     
    10581063    Source/webrtc/modules/video_coding/h264_sprop_parameter_sets.cc
    10591064    Source/webrtc/modules/video_coding/h264_sps_pps_tracker.cc
     1065    Source/webrtc/modules/video_coding/h265_vps_sps_pps_tracker.cc
    10601066    Source/webrtc/modules/video_coding/histogram.cc
    10611067    Source/webrtc/modules/video_coding/include/video_codec_interface.cc
     
    16091615
    16101616target_compile_definitions(webrtc PRIVATE
    1611   OPENSSL_NO_ASM
    16121617  DYNAMIC_ANNOTATIONS_ENABLED=1
    16131618  EXPAT_RELATIVE_PATH
     1619  HAVE_CONFIG_H
    16141620  HAVE_LRINT
    16151621  HAVE_LRINTF
    16161622  HAVE_NETINET_IN_H
    16171623  HAVE_SCTP
     1624  HAVE_STDINT_H
     1625  HAVE_STDLIB_H
     1626  HAVE_UINT64_T
    16181627  HAVE_WEBRTC_VIDEO
    16191628  HAVE_WEBRTC_VOICE
    16201629  JSON_USE_EXCEPTION=0
    16211630  NON_WINDOWS_DEFINE
     1631  NO_MAIN_THREAD_WRAPPING
     1632  OPENSSL_NO_ASM
    16221633  OPUS_BUILD
    16231634  OPUS_EXPORT=
     1635  RTC_ENABLE_VP9
    16241636  VAR_ARRAYS
    16251637  WEBRTC_APM_DEBUG_DUMP=0
     
    16401652  WEBRTC_USE_BUILTIN_ISAC_FLOAT=0
    16411653  WTF_USE_DYNAMIC_ANNOTATIONS=1
    1642   RTC_DISABLE_VP9
    16431654  _GNU_SOURCE
    16441655)
     
    16461657if (APPLE)
    16471658    target_compile_definitions(webrtc PRIVATE
    1648         RTC_ENABLE_VP9
    16491659        WEBRTC_ARCH_LITTLE_ENDIAN
    16501660        WEBRTC_MAC
     
    16521662else ()
    16531663    target_compile_definitions(webrtc PRIVATE
    1654         DISABLE_H265
    16551664        SCTP_PROCESS_LEVEL_LOCKS
    16561665        SCTP_SIMPLE_ALLOCATOR
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r276362 r276491  
     12021-04-23  Philippe Normand  <pnormand@igalia.com>
     2
     3        [LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
     4        https://bugs.webkit.org/show_bug.cgi?id=222795
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        * CMakeLists.txt: Enable NO_MAIN_THREAD_WRAPPING as in the XCode build and harmonize options
     9        between Apple and non-Apple ports.
     10        * Source/webrtc/common_video/h265/h265_pps_parser.h:
     11
    1122021-04-21  Kimmo Kinnunen  <kkinnunen@apple.com>
    213
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/common_video/h265/h265_pps_parser.h

    r259452 r276491  
    1313
    1414#include "absl/types/optional.h"
     15
     16#ifdef HAVE_STDINT_H
     17#include <stdint.h>
     18#endif
    1519
    1620namespace rtc {
  • trunk/Source/WebCore/ChangeLog

    r276488 r276491  
     12021-04-23  Philippe Normand  <pnormand@igalia.com>
     2
     3        [LibWebRTC][WPE][GTK] Enable vp9 and NO_MAIN_THREAD_WRAPPING
     4        https://bugs.webkit.org/show_bug.cgi?id=222795
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Add VP9 encoding and decoding support in the WPE/GTK LibWebRTC backend. The underlying
     9        encoding support is based on LibWebRTC's internal VP9 support. The GStreamer VPx encoders
     10        lack simulcast and high profile support, so can't really be used anyway. The
     11        GStreamerVP8Encoder was removed for this reason as well.
     12
     13        * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp:
     14        (WebCore::VP9Decoder::VP9Decoder):
     15        (WebCore::VP9Decoder::Create):
     16        (WebCore::GStreamerVideoDecoderFactory::CreateVideoDecoder):
     17        (WebCore::GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory):
     18        (WebCore::GStreamerVideoDecoderFactory::GetSupportedFormats const):
     19        * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h:
     20        * platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:
     21        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
     22        (WebCore::GStreamerVideoEncoder::makeElement):
     23        (WebCore::GStreamerVideoEncoder::createEncoder):
     24        (WebCore::GStreamerVideoEncoder::SetRestrictionCaps):
     25        (WebCore::GStreamerVideoEncoderFactory::CreateVideoEncoder):
     26        (WebCore::GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory):
     27        (WebCore::GStreamerVideoEncoderFactory::GetSupportedFormats const):
     28        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h:
     29        * platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp:
     30        (WebCore::LibWebRTCProviderGStreamer::createDecoderFactory):
     31        (WebCore::LibWebRTCProviderGStreamer::createEncoderFactory):
     32
    1332021-04-22  Tyler Wilcock  <twilco.o@protonmail.com>
    234
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp

    r276019 r276491  
    387387};
    388388
     389class VP9Decoder : public GStreamerVideoDecoder {
     390public:
     391    VP9Decoder(bool isSupportingVP9Profile0 = true, bool isSupportingVP9Profile2 = true)
     392        : m_isSupportingVP9Profile0(isSupportingVP9Profile0)
     393        , m_isSupportingVP9Profile2(isSupportingVP9Profile2) { };
     394
     395    const gchar* Caps() final { return "video/x-vp9"; }
     396    const gchar* Name() final { return cricket::kVp9CodecName; }
     397    webrtc::VideoCodecType CodecType() final { return webrtc::kVideoCodecVP9; }
     398    static std::unique_ptr<webrtc::VideoDecoder> Create()
     399    {
     400        return std::unique_ptr<webrtc::VideoDecoder>(new VP9Decoder());
     401    }
     402
     403    std::vector<webrtc::SdpVideoFormat> ConfigureSupportedDecoder() final
     404    {
     405        std::vector<webrtc::SdpVideoFormat> formats;
     406        if (m_isSupportingVP9Profile0)
     407            formats.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, { { "profile-id", "0" } }));
     408        if (m_isSupportingVP9Profile2)
     409            formats.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, { { "profile-id", "2" } }));
     410        return formats;
     411    }
     412private:
     413    bool m_isSupportingVP9Profile0;
     414    bool m_isSupportingVP9Profile2;
     415};
     416
    389417std::unique_ptr<webrtc::VideoDecoder> GStreamerVideoDecoderFactory::CreateVideoDecoder(const webrtc::SdpVideoFormat& format)
    390418{
     
    395423    else if (format.name == cricket::kVp8CodecName)
    396424        return VP8Decoder::Create();
     425    else if (format.name == cricket::kVp9CodecName)
     426        return VP9Decoder::Create();
    397427    else {
    398428        GST_ERROR("Could not create decoder for %s", format.name.c_str());
     
    404434}
    405435
    406 GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory()
     436GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2)
     437    : m_isSupportingVP9Profile0(isSupportingVP9Profile0)
     438    , m_isSupportingVP9Profile2(isSupportingVP9Profile2)
    407439{
    408440    ensureGStreamerInitialized();
     
    418450
    419451    VP8Decoder().AddDecoderIfSupported(formats);
     452    VP9Decoder(m_isSupportingVP9Profile0, m_isSupportingVP9Profile2).AddDecoderIfSupported(formats);
    420453    H264Decoder().AddDecoderIfSupported(formats);
    421454
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h

    r248762 r276491  
    2525#include "LibWebRTCMacros.h"
    2626#include "api/video_codecs/video_decoder_factory.h"
    27 #include <gst/gst.h>
    28 #include <wtf/text/WTFString.h>
     27#include <wtf/Forward.h>
    2928
    3029namespace WebCore {
     
    3332    WTF_MAKE_FAST_ALLOCATED;
    3433public:
    35     GStreamerVideoDecoderFactory();
    36     static bool newSource(String trackId, GstElement *source);
     34    GStreamerVideoDecoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2);
    3735
    3836private:
    3937    std::unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(const webrtc::SdpVideoFormat&) final;
    4038    std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const final;
     39
     40    bool m_isSupportingVP9Profile0;
     41    bool m_isSupportingVP9Profile2;
    4142};
    4243}
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp

    r274149 r276491  
    3636
    3737static GstStaticPadTemplate sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-raw(ANY)"));
    38 static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-h264;video/x-vp8"));
     38static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS("video/x-h264"));
    3939
    4040using SetBitrateFunc = Function<void(GObject* encoder, const char* propertyName, int bitrate)>;
     
    5252};
    5353
    54 enum EncoderId { None, X264, OpenH264, OmxH264, Vp8 };
     54enum EncoderId { None, X264, OpenH264, OmxH264 };
    5555
    5656class Encoders {
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp

    r276019 r276491  
    2929#include "LibWebRTCWebKitMacros.h"
    3030#include "webrtc/common_video/h264/h264_common.h"
     31#include "webrtc/media/base/vp9_profile.h"
    3132#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
    3233#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
    3334#include "webrtc/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h"
     35#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
    3436#include "webrtc/modules/video_coding/include/video_codec_interface.h"
    3537#include "webrtc/modules/video_coding/utility/simulcast_utility.h"
    36 
    3738#include <gst/app/gstappsink.h>
    3839#include <gst/app/gstappsrc.h>
     
    108109
    109110        if (m_encoder)
    110             g_object_set(m_encoder, "bitrate", parameters.bitrate.get_sum_bps(), nullptr);
     111            g_object_set(m_encoder.get(), "bitrate", parameters.bitrate.get_sum_bps(), nullptr);
    111112    }
    112113
     
    120121        static Atomic<uint32_t> elementId;
    121122        auto name = makeString(Name(), "-enc-", factoryName, "-", elementId.exchangeAdd(1));
    122         auto elem = gst_element_factory_make(factoryName, name.utf8().data());
    123 
     123        auto* elem = gst_element_factory_make(factoryName, name.utf8().data());
    124124        return elem;
    125125    }
     
    132132        if (webrtc::SimulcastUtility::NumberOfSimulcastStreams(*codecSettings) > 1) {
    133133            GST_ERROR("Simulcast not supported.");
    134 
    135134            return WEBRTC_VIDEO_CODEC_ERR_SIMULCAST_PARAMETERS_NOT_SUPPORTED;
    136135        }
     
    139138
    140139        connectSimpleBusMessageCallback(m_pipeline.get());
    141         auto encoder = createEncoder();
    142         ASSERT(encoder);
    143         m_encoder = encoder.get();
    144 
    145         g_object_set(m_encoder, "keyframe-interval", KeyframeInterval(codecSettings), nullptr);
     140        m_encoder = createEncoder();
     141        ASSERT(m_encoder);
     142
     143        g_object_set(m_encoder.get(), "keyframe-interval", KeyframeInterval(codecSettings), nullptr);
    146144
    147145        m_src = makeElement("appsrc");
    148         g_object_set(m_src, "is-live", true, "format", GST_FORMAT_TIME, nullptr);
    149 
    150         auto videoconvert = makeElement("videoconvert");
    151         auto videoscale = makeElement("videoscale");
     146        g_object_set(m_src.get(), "is-live", true, "format", GST_FORMAT_TIME, nullptr);
     147
     148        auto* videoconvert = makeElement("videoconvert");
     149        auto* videoscale = makeElement("videoscale");
    152150        m_sink = makeElement("appsink");
    153         g_object_set(m_sink, "sync", FALSE, nullptr);
     151        g_object_set(m_sink.get(), "sync", FALSE, nullptr);
    154152
    155153        m_capsFilter = makeElement("capsfilter");
    156154        if (m_restrictionCaps)
    157             g_object_set(m_capsFilter, "caps", m_restrictionCaps.get(), nullptr);
    158 
    159         gst_bin_add_many(GST_BIN(m_pipeline.get()), m_src, videoconvert, videoscale, m_capsFilter, encoder.leakRef(), m_sink, nullptr);
    160         if (!gst_element_link_many(m_src, videoconvert, videoscale, m_capsFilter, m_encoder, m_sink, nullptr)) {
    161             GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_VERBOSE, "webkit-webrtc-encoder.error");
    162 
     155            g_object_set(m_capsFilter.get(), "caps", m_restrictionCaps.get(), nullptr);
     156
     157        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);
     158        if (!gst_element_link_many(m_src.get(), videoconvert, videoscale, m_capsFilter.get(), m_encoder.get(), m_sink.get(), nullptr)) {
     159            GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN_CAST(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_VERBOSE, "webkit-webrtc-encoder.error");
    163160            ASSERT_NOT_REACHED();
    164161        }
    165162
    166163        gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING);
    167 
     164        GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN_CAST(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_VERBOSE, "webkit-webrtc-encoder");
    168165        return WEBRTC_VIDEO_CODEC_OK;
    169166    }
     
    237234        if (!GST_CLOCK_TIME_IS_VALID(m_firstFramePts)) {
    238235            m_firstFramePts = GST_BUFFER_PTS(buffer);
    239             auto pad = adoptGRef(gst_element_get_static_pad(m_src, "src"));
     236            auto pad = adoptGRef(gst_element_get_static_pad(m_src.get(), "src"));
    240237            gst_pad_set_offset(pad.get(), -m_firstFramePts);
    241238        }
     
    243240        for (auto frame_type : *frameTypes) {
    244241            if (frame_type == webrtc::VideoFrameType::kVideoFrameKey) {
    245                 auto pad = adoptGRef(gst_element_get_static_pad(m_src, "src"));
     242                auto pad = adoptGRef(gst_element_get_static_pad(m_src.get(), "src"));
    246243                auto forceKeyUnit = gst_video_event_new_downstream_force_key_unit(GST_CLOCK_TIME_NONE,
    247244                    GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE, FALSE, 1);
     
    255252        }
    256253
    257         res = returnFromFlowReturn(gst_app_src_push_sample(GST_APP_SRC(m_src), sample.get()));
     254        res = returnFromFlowReturn(gst_app_src_push_sample(GST_APP_SRC(m_src.get()), sample.get()));
    258255        if (res != WEBRTC_VIDEO_CODEC_OK)
    259256            return res;
    260257
    261         auto encodedSample = adoptGRef(gst_app_sink_try_pull_sample(GST_APP_SINK(m_sink), 5 * GST_SECOND));
     258        auto encodedSample = adoptGRef(gst_app_sink_try_pull_sample(GST_APP_SINK(m_sink.get()), 5 * GST_SECOND));
    262259        if (!encodedSample) {
    263260            GST_ERROR("Didn't get any encodedSample");
     
    294291    GRefPtr<GstElement> createEncoder(void)
    295292    {
     293        GRefPtr<GstElement> webrtcencoder = gst_element_factory_make("webrtcvideoencoder", NULL);
     294        g_object_set(webrtcencoder.get(), "format", adoptGRef(gst_caps_from_string(Caps())).get(), NULL);
     295
    296296        GRefPtr<GstElement> encoder = nullptr;
    297         GstElement* webrtcencoder = GST_ELEMENT(g_object_ref_sink(gst_element_factory_make("webrtcvideoencoder", NULL)));
    298 
    299         g_object_set(webrtcencoder, "format", adoptGRef(gst_caps_from_string(Caps())).get(), NULL);
    300         g_object_get(webrtcencoder, "encoder", &encoder.outPtr(), NULL);
    301 
     297        g_object_get(webrtcencoder.get(), "encoder", &encoder.outPtr(), NULL);
    302298        if (!encoder) {
    303299            GST_INFO("No encoder found for %s", Caps());
    304 
    305300            return nullptr;
    306301        }
     
    335330    {
    336331        if (m_restrictionCaps)
    337             g_object_set(m_capsFilter, "caps", m_restrictionCaps.get(), nullptr);
     332            g_object_set(m_capsFilter.get(), "caps", m_restrictionCaps.get(), nullptr);
    338333
    339334        m_restrictionCaps = caps;
     
    342337private:
    343338    GRefPtr<GstElement> m_pipeline;
    344     GstElement* m_src;
    345     GstElement* m_encoder;
    346     GstElement* m_capsFilter;
     339    GRefPtr<GstElement> m_src;
     340    GRefPtr<GstElement> m_encoder;
     341    GRefPtr<GstElement> m_capsFilter;
    347342
    348343    webrtc::EncodedImageCallback* m_imageReadyCb;
     
    352347
    353348    Lock m_bufferMapLock;
    354     GstElement* m_sink;
     349    GRefPtr<GstElement> m_sink;
    355350};
    356351
     
    394389};
    395390
    396 class GStreamerVP8Encoder : public GStreamerVideoEncoder {
    397 public:
    398     GStreamerVP8Encoder() { }
    399     GStreamerVP8Encoder(const webrtc::SdpVideoFormat&) { }
    400     const gchar* Caps() final { return "video/x-vp8"; }
    401     const gchar* Name() final { return cricket::kVp8CodecName; }
    402     webrtc::VideoCodecType CodecType() final { return webrtc::kVideoCodecVP8; }
    403 
    404     int KeyframeInterval(const webrtc::VideoCodec* codecSettings) final
    405     {
    406         return codecSettings->VP8().keyFrameInterval;
    407     }
    408 
    409     void PopulateCodecSpecific(webrtc::CodecSpecificInfo* codecSpecificInfos, const GstBuffer* buffer) final
    410     {
    411         codecSpecificInfos->codecType = webrtc::kVideoCodecVP8;
    412         webrtc::CodecSpecificInfoVP8* vp8Info = &(codecSpecificInfos->codecSpecific.VP8);
    413         vp8Info->temporalIdx = 0;
    414 
    415         vp8Info->keyIdx = webrtc::kNoKeyIdx;
    416         vp8Info->nonReference = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
    417     }
    418 };
    419 
    420391std::unique_ptr<webrtc::VideoEncoder> GStreamerVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format)
    421392{
     393    // FIXME: vpxenc doesn't support simulcast nor SVC. vp9enc supports only profile 0. These
     394    // shortcomings trigger webrtc/vp9.html and webrtc/simulcast-h264.html timeouts and most likely
     395    // bad UX in WPE/GTK browsers. So for now we prefer to use LibWebRTC's VPx encoders.
     396    if (format.name == cricket::kVp9CodecName) {
     397        GST_INFO("Using VP9 Encoder from LibWebRTC.");
     398        return webrtc::VP9Encoder::Create(cricket::VideoCodec(format));
     399    }
     400
    422401    if (format.name == cricket::kVp8CodecName) {
    423         GRefPtr<GstElement> webrtcencoder = adoptGRef(GST_ELEMENT(g_object_ref_sink(gst_element_factory_make("webrtcvideoencoder", NULL))));
    424         GRefPtr<GstElement> encoder = nullptr;
    425 
    426         g_object_set(webrtcencoder.get(), "format", adoptGRef(gst_caps_from_string("video/x-vp8")).get(), NULL);
    427         g_object_get(webrtcencoder.get(), "encoder", &encoder.outPtr(), NULL);
    428 
    429         if (encoder)
    430             return makeUnique<GStreamerVP8Encoder>(format);
    431 
    432402        GST_INFO("Using VP8 Encoder from LibWebRTC.");
    433403        return makeUniqueWithoutFastMallocCheck<webrtc::LibvpxVp8Encoder>(webrtc::LibvpxInterface::CreateEncoder(), webrtc::VP8Encoder::Settings());
     
    447417}
    448418
    449 GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory()
     419GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2)
     420    : m_isSupportingVP9Profile0(isSupportingVP9Profile0)
     421    , m_isSupportingVP9Profile2(isSupportingVP9Profile2)
    450422{
    451423    ensureGStreamerInitialized();
     
    465437
    466438    supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp8CodecName));
     439    if (m_isSupportingVP9Profile0)
     440        supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, {{"profile-id", "0"}}));
     441    if (m_isSupportingVP9Profile2)
     442        supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp9CodecName, {{"profile-id", "2"}}));
    467443
    468444    // If OpenH264 is present, prefer it over the GStreamer encoders (x264enc, usually).
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h

    r270190 r276491  
    2424#include "LibWebRTCMacros.h"
    2525#include "api/video_codecs/video_encoder_factory.h"
    26 #include <gst/gst.h>
    2726
    2827namespace WebCore {
     
    3130    WTF_MAKE_FAST_ALLOCATED;
    3231public:
    33     GStreamerVideoEncoderFactory();
     32    GStreamerVideoEncoderFactory(bool isSupportingVP9Profile0, bool isSupportingVP9Profile2);
    3433
    3534private:
     
    3837    CodecInfo QueryVideoEncoder(const webrtc::SdpVideoFormat&) const override
    3938    {
    40         GST_FIXME("Detect whether the decoder is HW accelerated");
     39        // FIXME: Detect whether the decoder is HW accelerated.
    4140
    4241        return { false };
    4342    }
     43
     44    bool m_isSupportingVP9Profile0;
     45    bool m_isSupportingVP9Profile2;
    4446};
    4547}
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp

    r248846 r276491  
    2929#if USE(LIBWEBRTC) && USE(GSTREAMER)
    3030
     31#include "RuntimeEnabledFeatures.h"
    3132#include <wtf/UniqueRef.h>
    3233
     
    4546std::unique_ptr<webrtc::VideoDecoderFactory> LibWebRTCProviderGStreamer::createDecoderFactory()
    4647{
    47     return makeUnique<GStreamerVideoDecoderFactory>();
     48    return makeUnique<GStreamerVideoDecoderFactory>(isSupportingVP9Profile0(), isSupportingVP9Profile2());
    4849}
    4950
    5051std::unique_ptr<webrtc::VideoEncoderFactory> LibWebRTCProviderGStreamer::createEncoderFactory()
    5152{
    52     return makeUnique<GStreamerVideoEncoderFactory>();
     53    return makeUnique<GStreamerVideoEncoderFactory>(isSupportingVP9Profile0(), isSupportingVP9Profile2());
    5354}
    5455
Note: See TracChangeset for help on using the changeset viewer.