Changeset 275275 in webkit


Ignore:
Timestamp:
Mar 31, 2021 4:11:17 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

[WebRTC][GStreamer] Build and use the openh264 based encoder if present on the system
https://bugs.webkit.org/show_bug.cgi?id=202538

Patch by Thibault Saunier <tsaunier@igalia.com> and Philippe Normand <pnormand@igalia.com> on 2021-03-31
Reviewed by Xabier Rodriguez-Calvar and Adrian Perez de Castro.

Source/ThirdParty/libwebrtc:

In WPE/GTK we would like to have the libwebrtc openh264 encoder enabled if libopenh264 is
present on the host (eg not vendored).

  • CMakeLists.txt:
  • Source/webrtc/modules/video_coding/codecs/h264/h264.cc:
  • Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc:
  • Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h:

Source/WebCore:

Enable the openh264 encoder if it is available, it would be preferred over existing
GStreamer H.264 encoders in such case.

  • platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:

(WebCore::GStreamerVideoEncoder::AddCodecIfSupported):
(WebCore::GStreamerVideoEncoderFactory::CreateVideoEncoder):

Location:
trunk/Source
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/CMakeLists.txt

    r270477 r275275  
    2828if (USE_LIBWEBRTC)
    2929    add_subdirectory(ThirdParty/libwebrtc)
     30    include_directories(${CMAKE_CURRENT_BINARY_DIR}/ThirdParty/libwebrtc)
    3031endif ()
    3132
  • trunk/Source/ThirdParty/libwebrtc/CMakeLists.txt

    r272413 r275275  
    14181418endif()
    14191419
     1420
     1421find_package(Openh264)
     1422if (NOT Openh264_FOUND)
     1423    message(WARNING "openh264 is not found, not building support.")
     1424    set(WEBKIT_LIBWEBRTC_OPENH264_ENCODER 0)
     1425else()
     1426    list(APPEND webrtc_SOURCES
     1427        Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
     1428    )
     1429    set(WEBKIT_LIBWEBRTC_OPENH264_ENCODER 1)
     1430endif ()
     1431configure_file(LibWebRTCWebKitMacros.h.in LibWebRTCWebKitMacros.h @ONLY)
     1432
    14201433add_library(webrtc STATIC ${webrtc_SOURCES})
    14211434
     
    14641477  WEBRTC_OPUS_VARIABLE_COMPLEXITY=0
    14651478  WEBRTC_USE_BUILTIN_OPUS=1
     1479  WEBRTC_USE_H264=1
    14661480  WEBRTC_POSIX
    14671481  WEBRTC_USE_BUILTIN_ISAC_FIX=1
     
    15171531target_link_libraries(webrtc ${LIBOPUS_LIBRARY})
    15181532
     1533target_link_libraries(webrtc ${Openh264_LIBRARY})
     1534
    15191535# libsrtp package compilation
    15201536set(libsrtp_SOURCES
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r275082 r275275  
     12021-03-31  Thibault Saunier  <tsaunier@igalia.com> and Philippe Normand  <pnormand@igalia.com>
     2
     3        [WebRTC][GStreamer] Build and use the openh264 based encoder if present on the system
     4        https://bugs.webkit.org/show_bug.cgi?id=202538
     5
     6        Reviewed by Xabier Rodriguez-Calvar and Adrian Perez de Castro.
     7
     8        In WPE/GTK we would like to have the libwebrtc openh264 encoder enabled if libopenh264 is
     9        present on the host (eg not vendored).
     10
     11        * CMakeLists.txt:
     12        * Source/webrtc/modules/video_coding/codecs/h264/h264.cc:
     13        * Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc:
     14        * Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h:
     15
    1162021-03-26  Jessie Berlin  <jberlin@webkit.org>
    217
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/h264/h264.cc

    r269642 r275275  
    2020
    2121#if defined(WEBRTC_USE_H264)
     22#if !defined(WEBRTC_WEBKIT_BUILD)
    2223#include "modules/video_coding/codecs/h264/h264_decoder_impl.h"
     24#endif
    2325#include "modules/video_coding/codecs/h264/h264_encoder_impl.h"
    2426#endif
     
    104106std::unique_ptr<H264Decoder> H264Decoder::Create() {
    105107  RTC_DCHECK(H264Decoder::IsSupported());
    106 #if defined(WEBRTC_USE_H264)
     108#if defined(WEBRTC_USE_H264) && !defined(WEBRTC_WEBKIT_BUILD)
    107109  RTC_CHECK(g_rtc_use_h264);
    108110  RTC_LOG(LS_INFO) << "Creating H264DecoderImpl.";
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

    r269642 r275275  
    3030#include "third_party/libyuv/include/libyuv/convert.h"
    3131#include "third_party/libyuv/include/libyuv/scale.h"
     32
     33#ifdef WEBRTC_WEBKIT_BUILD
     34#include "wels/codec_api.h"
     35#include "wels/codec_app_def.h"
     36#include "wels/codec_def.h"
     37#include "wels/codec_ver.h"
     38#else
    3239#include "third_party/openh264/src/codec/api/svc/codec_api.h"
    3340#include "third_party/openh264/src/codec/api/svc/codec_app_def.h"
    3441#include "third_party/openh264/src/codec/api/svc/codec_def.h"
    3542#include "third_party/openh264/src/codec/api/svc/codec_ver.h"
     43#endif
    3644
    3745namespace webrtc {
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h

    r269642 r275275  
    3030#include "modules/video_coding/codecs/h264/include/h264.h"
    3131#include "modules/video_coding/utility/quality_scaler.h"
     32
     33#ifdef WEBRTC_WEBKIT_BUILD
     34#include "wels/codec_app_def.h"
     35#else
    3236#include "third_party/openh264/src/codec/api/svc/codec_app_def.h"
     37#endif
    3338
    3439class ISVCEncoder;
  • trunk/Source/WebCore/ChangeLog

    r275273 r275275  
     12021-03-31  Thibault Saunier  <tsaunier@igalia.com> and Philippe Normand  <pnormand@igalia.com>
     2
     3        [WebRTC][GStreamer] Build and use the openh264 based encoder if present on the system
     4        https://bugs.webkit.org/show_bug.cgi?id=202538
     5
     6        Reviewed by Xabier Rodriguez-Calvar and Adrian Perez de Castro.
     7
     8        Enable the openh264 encoder if it is available, it would be preferred over existing
     9        GStreamer H.264 encoders in such case.
     10
     11        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
     12        (WebCore::GStreamerVideoEncoder::AddCodecIfSupported):
     13        (WebCore::GStreamerVideoEncoderFactory::CreateVideoEncoder):
     14
    1152021-03-30  Antoine Quint  <graouts@webkit.org>
    216
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoCommon.cpp

    r270190 r275275  
    4040}
    4141
    42 std::vector<webrtc::SdpVideoFormat> gstreamerSupportedH264Codecs()
     42std::vector<webrtc::SdpVideoFormat> supportedH264Formats()
    4343{
    4444    // @TODO Create from encoder src pad caps template
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoCommon.h

    r270190 r275275  
    2929namespace WebCore {
    3030
    31 std::vector<webrtc::SdpVideoFormat> gstreamerSupportedH264Codecs();
     31std::vector<webrtc::SdpVideoFormat> supportedH264Formats();
    3232
    3333} // namespace WebCore
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp

    r274479 r275275  
    363363    std::vector<webrtc::SdpVideoFormat> ConfigureSupportedDecoder() final
    364364    {
    365         return gstreamerSupportedH264Codecs();
     365        return supportedH264Formats();
    366366    }
    367367};
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp

    r274149 r275275  
    2727#include "GStreamerVideoEncoder.h"
    2828#include "GStreamerVideoFrameLibWebRTC.h"
     29#include "LibWebRTCWebKitMacros.h"
    2930#include "webrtc/common_video/h264/h264_common.h"
    3031#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
     
    375376    std::vector<webrtc::SdpVideoFormat> ConfigureSupportedCodec() final
    376377    {
    377         return gstreamerSupportedH264Codecs();
     378        return supportedH264Formats();
    378379    }
    379380
     
    433434    }
    434435
    435     if (format.name == cricket::kH264CodecName)
     436    if (format.name == cricket::kH264CodecName) {
     437#if WEBKIT_LIBWEBRTC_OPENH264_ENCODER
     438        GST_INFO("Using OpenH264 libwebrtc encoder.");
     439        return webrtc::H264Encoder::Create(cricket::VideoCodec(format));
     440#else
     441        GST_INFO("Using H264 GStreamer encoder.");
    436442        return makeUnique<GStreamerH264Encoder>(format);
     443#endif
     444    }
    437445
    438446    return nullptr;
     
    457465
    458466    supportedCodecs.push_back(webrtc::SdpVideoFormat(cricket::kVp8CodecName));
     467
     468    // If OpenH264 is present, prefer it over the GStreamer encoders (x264enc, usually).
     469#if WEBKIT_LIBWEBRTC_OPENH264_ENCODER
     470    auto formats = supportedH264Formats();
     471    supportedCodecs.insert(supportedCodecs.end(), formats.begin(), formats.end());
     472#else
    459473    GStreamerH264Encoder().AddCodecIfSupported(supportedCodecs);
     474#endif
    460475
    461476    return supportedCodecs;
  • trunk/Source/cmake/GStreamerChecks.cmake

    r271399 r275275  
    5555if (ENABLE_MEDIA_STREAM AND ENABLE_WEB_RTC)
    5656    SET_AND_EXPOSE_TO_BUILD(USE_LIBWEBRTC TRUE)
    57     SET_AND_EXPOSE_TO_BUILD(WEBRTC_WEBKIT_BUILD TRUE)
    5857else ()
    5958    SET_AND_EXPOSE_TO_BUILD(USE_LIBWEBRTC FALSE)
    60     SET_AND_EXPOSE_TO_BUILD(WEBRTC_WEBKIT_BUILD FALSE)
    6159endif ()
Note: See TracChangeset for help on using the changeset viewer.