#29 [WIP] Allow to dlopen openh264
Opened a year ago by jgrulich. Modified 6 months ago
rpms/ jgrulich/chromium h264-dlopen  into  rawhide

@@ -0,0 +1,328 @@ 

+ From a19fe8c2f6b9cdda194ca8d51c025389067a068a Mon Sep 17 00:00:00 2001

+ From: Jan Grulich <grulja@gmail.com>

+ Date: Tue, 7 Feb 2023 14:05:29 +0100

+ Subject: Allow to dlopen openh264

+ 

+ 

+ diff --git a/media/BUILD.gn b/media/BUILD.gn

+ index 3da738354446b..e75b92f2d3254 100644

+ --- a/media/BUILD.gn

+ +++ b/media/BUILD.gn

+ @@ -91,6 +91,9 @@ config("media_config") {

+    if (use_cras) {

+      defines += [ "USE_CRAS" ]

+    }

+ +  if (media_use_openh264 && media_dlopen_openh264) {

+ +    defines += [ "DLOPEN_OPENH264" ]

+ +  }

+  }

+ 

+  # Internal grouping of the configs necessary to support sub-folders having their

+ diff --git a/media/media_options.gni b/media/media_options.gni

+ index 6418ab92fd648..0d7b009076a06 100644

+ --- a/media/media_options.gni

+ +++ b/media/media_options.gni

+ @@ -56,6 +56,10 @@ declare_args() {

+      media_use_openh264 = false

+    }

+ 

+ +  # Allow to use OpenH264 on systems where OpenH264 cannot be installed by

+ +  # default due to licensing, but can be installed later from other sources.

+ +  media_dlopen_openh264 = false

+ +

+    # Override to dynamically link the cras (ChromeOS audio) library.

+    use_cras = is_chromeos_device

+ 

+ diff --git a/media/video/BUILD.gn b/media/video/BUILD.gn

+ index fc45b5c1c4ee8..ec0c13eba3e08 100644

+ --- a/media/video/BUILD.gn

+ +++ b/media/video/BUILD.gn

+ @@ -3,6 +3,18 @@

+  # found in the LICENSE file.

+ 

+  import("//media/media_options.gni")

+ +import("//tools/generate_stubs/rules.gni")

+ +

+ +if (media_use_openh264 && media_dlopen_openh264) {

+ +  # When OpenH264 is not directly linked, use stubs to allow for dlopening of

+ +  # the binary.

+ +  generate_stubs("openh264_stubs") {

+ +    extra_header = "openh264_stub_header.fragment"

+ +    output_name = "openh264_stubs"

+ +    sigs = [ "openh264.sigs" ]

+ +    deps = [ "//base" ]

+ +  }

+ +}

+ 

+  source_set("video") {

+    # Do not expand the visibility here without double-checking with OWNERS, this

+ @@ -102,7 +114,12 @@ source_set("video") {

+        "openh264_video_encoder.cc",

+        "openh264_video_encoder.h",

+      ]

+ -    deps += [ "//third_party/openh264:encoder" ]

+ +

+ +    if (media_dlopen_openh264) {

+ +      deps += [ ":openh264_stubs" ]

+ +    } else {

+ +      deps += [ "//third_party/openh264:encoder" ]

+ +    }

+    }

+  }

+ 

+ diff --git a/media/video/openh264.sigs b/media/video/openh264.sigs

+ new file mode 100644

+ index 0000000000000..82f6b43619644

+ --- /dev/null

+ +++ b/media/video/openh264.sigs

+ @@ -0,0 +1,9 @@

+ +// Copyright 2023 The Chromium Authors. All rights reserved.

+ +// Use of this source code is governed by a BSD-style license that can be

+ +// found in the LICENSE file.

+ +

+ +//------------------------------------------------

+ +// Functions from OpenH264.

+ +//------------------------------------------------

+ +int WelsCreateSVCEncoder(ISVCEncoder **ppEncoder);

+ +void WelsDestroySVCEncoder(ISVCEncoder *pEncoder);

+ diff --git a/media/video/openh264_stub_header.fragment b/media/video/openh264_stub_header.fragment

+ new file mode 100644

+ index 0000000000000..937dffc847b01

+ --- /dev/null

+ +++ b/media/video/openh264_stub_header.fragment

+ @@ -0,0 +1,8 @@

+ +// The extra include header needed in the generated stub file for defining

+ +// various OpenH264 types.

+ +

+ +extern "C" {

+ +

+ +#include "third_party/openh264/src/codec/api/wels/codec_api.h"

+ +

+ +}

+ diff --git a/media/video/openh264_video_encoder.cc b/media/video/openh264_video_encoder.cc

+ index 27d6ca96524b1..c2ff441563fa6 100644

+ --- a/media/video/openh264_video_encoder.cc

+ +++ b/media/video/openh264_video_encoder.cc

+ @@ -7,6 +7,7 @@

+  #include <algorithm>

+  #include <limits>

+ 

+ +#include "base/files/file_path.h"

+  #include "base/logging.h"

+  #include "base/numerics/safe_conversions.h"

+  #include "base/system/sys_info.h"

+ @@ -17,10 +18,23 @@

+  #include "media/base/video_util.h"

+  #include "media/video/video_encoder_info.h"

+ 

+ +#if defined(DLOPEN_OPENH264)

+ +#include "media/video/openh264_stubs.h"

+ +#endif  // defined(DLOPEN_OPENH264)

+ +

+  namespace media {

+ 

+  namespace {

+ 

+ +#if defined(DLOPEN_OPENH264)

+ +using media_video::InitializeStubs;

+ +using media_video::kModuleOpenh264;

+ +using media_video::StubPathMap;

+ +

+ +static const base::FilePath::CharType kOpenH264Lib[] = FILE_PATH_LITERAL("libopenh264.so.7");

+ +#endif // defined(DLOPEN_OPENH264)

+ +

+ +

+  void SetUpOpenH264Params(const VideoEncoder::Options& options,

+                           const VideoColorSpace& itu_cs,

+                           SEncParamExt* params) {

+ @@ -147,6 +161,18 @@ void OpenH264VideoEncoder::Initialize(VideoCodecProfile profile,

+      return;

+    }

+ 

+ +#if defined(DLOPEN_OPENH264)

+ +  StubPathMap paths;

+ +  paths[kModuleOpenh264].push_back(kOpenH264Lib);

+ +

+ +  if (!InitializeStubs(paths)) {

+ +    std::move(done_cb).Run(

+ +        EncoderStatus(EncoderStatus::Codes::kEncoderInitializationError,

+ +                      "Failed on loading the openh264 library and symbols,"));

+ +    return;

+ +  }

+ +#endif // defined(DLOPEN_OPENH264)

+ +

+    ISVCEncoder* raw_codec = nullptr;

+    if (WelsCreateSVCEncoder(&raw_codec) != 0) {

+      std::move(done_cb).Run(

+ diff --git a/sandbox/policy/linux/bpf_gpu_policy_linux.cc b/sandbox/policy/linux/bpf_gpu_policy_linux.cc

+ index 35ccbb7a7f82b..dd6b990d2e10c 100644

+ --- a/sandbox/policy/linux/bpf_gpu_policy_linux.cc

+ +++ b/sandbox/policy/linux/bpf_gpu_policy_linux.cc

+ @@ -41,6 +41,7 @@ GpuProcessPolicy::~GpuProcessPolicy() {}

+ 

+  // Main policy for x86_64/i386. Extended by CrosArmGpuProcessPolicy.

+  ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {

+ +  VLOG(1) << "GpuProcessPolicy::EvaluateSyscall";

+    // Many GPU drivers need to dlopen additional libraries (see the file

+    // permissions in gpu_sandbox_hook_linux.cc that end in .so).

+    if (SyscallSets::IsDlopen(sysno)) {

+ diff --git a/third_party/blink/renderer/modules/mediarecorder/BUILD.gn b/third_party/blink/renderer/modules/mediarecorder/BUILD.gn

+ index cf6de49bef6b2..61e8879d6b97f 100644

+ --- a/third_party/blink/renderer/modules/mediarecorder/BUILD.gn

+ +++ b/third_party/blink/renderer/modules/mediarecorder/BUILD.gn

+ @@ -5,12 +5,23 @@

+  import("//build/buildflag_header.gni")

+  import("//third_party/blink/renderer/modules/modules.gni")

+  import("//third_party/webrtc/webrtc.gni")

+ +import("//tools/generate_stubs/rules.gni")

+ 

+  buildflag_header("buildflags") {

+    header = "buildflags.h"

+    flags = [ "RTC_USE_H264=$rtc_use_h264" ]

+  }

+ 

+ +if (rtc_use_h264 && rtc_dlopen_openh264) {

+ +  # When OpenH264 is not directly linked, use stubs to allow for dlopening of

+ +  # the binary.

+ +  generate_stubs("openh264_stubs") {

+ +    extra_header = "openh264_stub_header.fragment"

+ +    output_name = "openh264_stubs"

+ +    sigs = [ "openh264.sigs" ]

+ +  }

+ +}

+ +

+  blink_modules_sources("mediarecorder") {

+    sources = [

+      "audio_track_encoder.cc",

+ @@ -56,6 +67,11 @@ blink_modules_sources("mediarecorder") {

+        "h264_encoder.h",

+      ]

+ 

+ -    deps += [ "//third_party/openh264:encoder" ]

+ +    if (rtc_dlopen_openh264) {

+ +      defines = [ "BLINK_DLOPEN_OPENH264" ]

+ +      deps += [ ":openh264_stubs" ]

+ +    } else {

+ +      deps += [ "//third_party/openh264:encoder" ]

+ +    }

+    }

+  }

+ diff --git a/third_party/blink/renderer/modules/mediarecorder/h264_encoder.cc b/third_party/blink/renderer/modules/mediarecorder/h264_encoder.cc

+ index 0aac5f9eba327..3ec1b4c8c4e49 100644

+ --- a/third_party/blink/renderer/modules/mediarecorder/h264_encoder.cc

+ +++ b/third_party/blink/renderer/modules/mediarecorder/h264_encoder.cc

+ @@ -23,9 +23,21 @@

+  #include "third_party/openh264/src/codec/api/wels/codec_def.h"

+  #include "ui/gfx/geometry/size.h"

+ 

+ +#if defined(BLINK_DLOPEN_OPENH264)

+ +#include "third_party/blink/renderer/modules/mediarecorder/openh264_stubs.h"

+ +#endif  // defined(BLINK_DLOPEN_OPENH264)

+ +

+  namespace blink {

+  namespace {

+ 

+ +#if defined(BLINK_DLOPEN_OPENH264)

+ +using third_party_blink_renderer_modules_mediarecorder::InitializeStubs;

+ +using third_party_blink_renderer_modules_mediarecorder::kModuleOpenh264;

+ +using third_party_blink_renderer_modules_mediarecorder::StubPathMap;

+ +

+ +static constexpr char kOpenH264Lib[] = "libopenh264.so.7";

+ +#endif

+ +

+  absl::optional<EProfileIdc> ToOpenH264Profile(

+      media::VideoCodecProfile profile) {

+    static const HashMap<media::VideoCodecProfile, EProfileIdc>

+ @@ -86,6 +98,13 @@ H264Encoder::H264Encoder(

+      : Encoder(on_encoded_video_cb, bits_per_second),

+        codec_profile_(codec_profile) {

+    DCHECK_EQ(codec_profile_.codec_id, VideoTrackRecorder::CodecId::kH264);

+ +

+ +#if defined(BLINK_DLOPEN_OPENH264)

+ +  StubPathMap paths;

+ +  paths[kModuleOpenh264].push_back(kOpenH264Lib);

+ +

+ +  openh264_dlopened_ = InitializeStubs(paths);

+ +#endif

+  }

+ 

+  // Needs to be defined here to combat a Windows linking issue.

+ @@ -167,6 +186,14 @@ void H264Encoder::EncodeFrame(scoped_refptr<media::VideoFrame> frame,

+ 

+  bool H264Encoder::ConfigureEncoder(const gfx::Size& size) {

+    TRACE_EVENT0("media", "H264Encoder::ConfigureEncoder");

+ +

+ +#if defined(BLINK_DLOPEN_OPENH264)

+ +  if (!openh264_dlopened_) {

+ +    NOTREACHED() << "Failed to dlopen openh264";

+ +    return false;

+ +  }

+ +#endif

+ +

+    ISVCEncoder* temp_encoder = nullptr;

+    if (WelsCreateSVCEncoder(&temp_encoder) != 0) {

+      NOTREACHED() << "Failed to create OpenH264 encoder";

+ diff --git a/third_party/blink/renderer/modules/mediarecorder/h264_encoder.h b/third_party/blink/renderer/modules/mediarecorder/h264_encoder.h

+ index 1d9d7bc5a3a3d..77494d2044ef4 100644

+ --- a/third_party/blink/renderer/modules/mediarecorder/h264_encoder.h

+ +++ b/third_party/blink/renderer/modules/mediarecorder/h264_encoder.h

+ @@ -55,6 +55,8 @@ class MODULES_EXPORT H264Encoder final : public VideoTrackRecorder::Encoder {

+    gfx::Size configured_size_;

+    ScopedISVCEncoderPtr openh264_encoder_;

+ 

+ +  bool openh264_dlopened_ = false;

+ +

+    // The |VideoFrame::timestamp()| of the first received frame.

+    base::TimeTicks first_frame_timestamp_;

+    base::WeakPtrFactory<H264Encoder> weak_factory_{this};

+ diff --git a/third_party/blink/renderer/modules/mediarecorder/openh264.sigs b/third_party/blink/renderer/modules/mediarecorder/openh264.sigs

+ new file mode 100644

+ index 0000000000000..4924f8e9a17de

+ --- /dev/null

+ +++ b/third_party/blink/renderer/modules/mediarecorder/openh264.sigs

+ @@ -0,0 +1,14 @@

+ +// Copyright 2022 The WebRTC project authors. All rights reserved.

+ +// Use of this source code is governed by a BSD-style license that can be

+ +// found in the LICENSE file.

+ +

+ +//------------------------------------------------

+ +// Functions from OpenH264.

+ +//------------------------------------------------

+ +int WelsCreateSVCEncoder(ISVCEncoder **ppEncoder);

+ +void WelsDestroySVCEncoder(ISVCEncoder *pEncoder);

+ +int WelsGetDecoderCapability(SDecoderCapability *pDecCapability);

+ +long WelsCreateDecoder(ISVCDecoder **ppDecoder);

+ +void WelsDestroyDecoder(ISVCDecoder *pDecoder);

+ +OpenH264Version WelsGetCodecVersion(void);

+ +void WelsGetCodecVersionEx(OpenH264Version *pVersion);

+ diff --git a/third_party/blink/renderer/modules/mediarecorder/openh264_stub_header.fragment b/third_party/blink/renderer/modules/mediarecorder/openh264_stub_header.fragment

+ new file mode 100644

+ index 0000000000000..9bc0a7cbee038

+ --- /dev/null

+ +++ b/third_party/blink/renderer/modules/mediarecorder/openh264_stub_header.fragment

+ @@ -0,0 +1,11 @@

+ +// The extra include header needed in the generated stub file for defining

+ +// various OpenH264 types.

+ +

+ +extern "C" {

+ +

+ +#include "third_party/openh264/src/codec/api/wels/codec_api.h"

+ +#include "third_party/openh264/src/codec/api/wels/codec_app_def.h"

+ +#include "third_party/openh264/src/codec/api/wels/codec_def.h"

+ +#include "third_party/openh264/src/codec/api/wels/codec_ver.h"

+ +

+ +}

+ diff --git a/third_party/blink/renderer/modules/webcodecs/BUILD.gn b/third_party/blink/renderer/modules/webcodecs/BUILD.gn

+ index 70f30624ddcc5..659161b295747 100644

+ --- a/third_party/blink/renderer/modules/webcodecs/BUILD.gn

+ +++ b/third_party/blink/renderer/modules/webcodecs/BUILD.gn

+ @@ -109,9 +109,6 @@ blink_modules_sources("webcodecs") {

+    if (media_use_libvpx) {

+      deps += [ "//third_party/libvpx" ]

+    }

+ -  if (media_use_openh264) {

+ -    deps += [ "//third_party/openh264:encoder" ]

+ -  }

+    if (is_fuchsia) {

+      deps += [ "//media/fuchsia/video" ]

+    }

@@ -0,0 +1,191 @@ 

+ From 4c84adf2f52d64c32f7d86eca9d8f4988e990292 Mon Sep 17 00:00:00 2001

+ From: Jan Grulich <jgrulich@redhat.com>

+ Date: Mon, 23 Jan 2023 09:30:48 +0100

+ Subject: [WebRTC] Video encoding: allow to dlopen h264

+ 

+ 

+ diff --git a/third_party/webrtc/modules/video_coding/BUILD.gn b/third_party/webrtc/modules/video_coding/BUILD.gn

+ index 77f2daf3e..b1b4945b9 100644

+ --- a/third_party/webrtc/modules/video_coding/BUILD.gn

+ +++ b/third_party/webrtc/modules/video_coding/BUILD.gn

+ @@ -7,6 +7,7 @@

+  # be found in the AUTHORS file in the root of the source tree.

+ 

+  import("//third_party/libaom/options.gni")

+ +import("//tools/generate_stubs/rules.gni")

+  import("../../webrtc.gni")

+ 

+  rtc_library("encoded_frame") {

+ @@ -499,6 +500,21 @@ rtc_library("video_coding_utility") {

+    ]

+  }

+ 

+ +if (rtc_use_h264 && rtc_dlopen_openh264) {

+ +  # When OpenH264 is not directly linked, use stubs to allow for dlopening of

+ +  # the binary.

+ +  generate_stubs("openh264_stubs") {

+ +    configs = [ "../../:common_config" ]

+ +    deps = [ "../../rtc_base" ]

+ +    extra_header = "codecs/h264/openh264_stub_header.fragment"

+ +    logging_function = "RTC_LOG(LS_VERBOSE)"

+ +    logging_include = "rtc_base/logging.h"

+ +    output_name = "codecs/h264/openh264_stubs"

+ +    path_from_source = "modules/video_coding/codecs/h264"

+ +    sigs = [ "codecs/h264/openh264.sigs" ]

+ +  }

+ +}

+ +

+  rtc_library("webrtc_h264") {

+    visibility = [ "*" ]

+    sources = [

+ @@ -542,11 +558,18 @@ rtc_library("webrtc_h264") {

+    ]

+ 

+    if (rtc_use_h264) {

+ -    deps += [

+ -      "//third_party/ffmpeg",

+ -      "//third_party/openh264:buildflags",

+ -      "//third_party/openh264:encoder",

+ -    ]

+ +    deps += [ "//third_party/ffmpeg" ]

+ +

+ +    if (rtc_dlopen_openh264) {

+ +      defines = [ "WEBRTC_DLOPEN_OPENH264" ]

+ +      deps += [ ":openh264_stubs" ]

+ +    } else {

+ +      deps += [

+ +        "//third_party/openh264:buildflags",

+ +        "//third_party/openh264:encoder",

+ +      ]

+ +    }

+ +

+      if (!build_with_mozilla) {

+        deps += [ "../../media:rtc_media_base" ]

+      }

+ diff --git a/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

+ index 5029dc9..e5b878e 100644

+ --- a/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

+ +++ b/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

+ @@ -31,24 +31,27 @@

+  #include "system_wrappers/include/metrics.h"

+  #include "third_party/libyuv/include/libyuv/convert.h"

+  #include "third_party/libyuv/include/libyuv/scale.h"

+ -// TODO(crbug.com/1218384): Remove after new openh264 is rolled.

+ -#include "third_party/openh264/buildflags.h"

+ -#if BUILDFLAG(OPENH264_API_WELS)

+  #include "third_party/openh264/src/codec/api/wels/codec_api.h"

+  #include "third_party/openh264/src/codec/api/wels/codec_app_def.h"

+  #include "third_party/openh264/src/codec/api/wels/codec_def.h"

+  #include "third_party/openh264/src/codec/api/wels/codec_ver.h"

+ -#else

+ -#include "third_party/openh264/src/codec/api/svc/codec_api.h"

+ -#include "third_party/openh264/src/codec/api/svc/codec_app_def.h"

+ -#include "third_party/openh264/src/codec/api/svc/codec_def.h"

+ -#include "third_party/openh264/src/codec/api/svc/codec_ver.h"

+ -#endif

+ +

+ +#if defined(WEBRTC_DLOPEN_OPENH264)

+ +#include "modules/video_coding/codecs/h264/openh264_stubs.h"

+ +#endif  // defined(WEBRTC_DLOPEN_OPENH264)

+ 

+  namespace webrtc {

+ 

+  namespace {

+ 

+ +#if defined(WEBRTC_DLOPEN_OPENH264)

+ +using modules_video_coding_codecs_h264::InitializeStubs;

+ +using modules_video_coding_codecs_h264::kModuleOpenh264;

+ +using modules_video_coding_codecs_h264::StubPathMap;

+ +

+ +static constexpr char kOpenH264Lib[] = "libopenh264.so.7";

+ +#endif

+ +

+  const bool kOpenH264EncoderDetailedLogging = false;

+ 

+  // QP scaling thresholds.

+ @@ -176,6 +179,15 @@ H264EncoderImpl::~H264EncoderImpl() {

+ 

+  int32_t H264EncoderImpl::InitEncode(const VideoCodec* inst,

+                                      const VideoEncoder::Settings& settings) {

+ +#if defined(WEBRTC_DLOPEN_OPENH264)

+ +  StubPathMap paths;

+ +  paths[kModuleOpenh264].push_back(kOpenH264Lib);

+ +

+ +  static bool result = InitializeStubs(paths);

+ +  if (!result)

+ +    return WEBRTC_VIDEO_CODEC_UNINITIALIZED;

+ +#endif

+ +

+    ReportInit();

+    if (!inst || inst->codecType != kVideoCodecH264) {

+      ReportError();

+ diff --git a/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h b/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h

+ index c1d8191..bf70c89 100644

+ --- a/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h

+ +++ b/third_party/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h

+ @@ -30,13 +30,7 @@

+  #include "modules/video_coding/codecs/h264/include/h264.h"

+  #include "modules/video_coding/svc/scalable_video_controller.h"

+  #include "modules/video_coding/utility/quality_scaler.h"

+ -// TODO(crbug.com/1218384): Remove after new openh264 is rolled.

+ -#include "third_party/openh264/buildflags.h"

+ -#if BUILDFLAG(OPENH264_API_WELS)

+  #include "third_party/openh264/src/codec/api/wels/codec_app_def.h"

+ -#else

+ -#include "third_party/openh264/src/codec/api/svc/codec_app_def.h"

+ -#endif

+ 

+  class ISVCEncoder;

+ 

+ diff --git a/third_party/webrtc/modules/video_coding/codecs/h264/openh264.sigs b/third_party/webrtc/modules/video_coding/codecs/h264/openh264.sigs

+ new file mode 100644

+ index 000000000..4924f8e9a

+ --- /dev/null

+ +++ b/third_party/webrtc/modules/video_coding/codecs/h264/openh264.sigs

+ @@ -0,0 +1,14 @@

+ +// Copyright 2022 The WebRTC project authors. All rights reserved.

+ +// Use of this source code is governed by a BSD-style license that can be

+ +// found in the LICENSE file.

+ +

+ +//------------------------------------------------

+ +// Functions from OpenH264.

+ +//------------------------------------------------

+ +int WelsCreateSVCEncoder(ISVCEncoder **ppEncoder);

+ +void WelsDestroySVCEncoder(ISVCEncoder *pEncoder);

+ +int WelsGetDecoderCapability(SDecoderCapability *pDecCapability);

+ +long WelsCreateDecoder(ISVCDecoder **ppDecoder);

+ +void WelsDestroyDecoder(ISVCDecoder *pDecoder);

+ +OpenH264Version WelsGetCodecVersion(void);

+ +void WelsGetCodecVersionEx(OpenH264Version *pVersion);

+ diff --git a/third_party/webrtc/modules/video_coding/codecs/h264/openh264_stub_header.fragment b/third_party/webrtc/modules/video_coding/codecs/h264/openh264_stub_header.fragment

+ new file mode 100644

+ index 000000000..9bc0a7cbe

+ --- /dev/null

+ +++ b/third_party/webrtc/modules/video_coding/codecs/h264/openh264_stub_header.fragment

+ @@ -0,0 +1,11 @@

+ +// The extra include header needed in the generated stub file for defining

+ +// various OpenH264 types.

+ +

+ +extern "C" {

+ +

+ +#include "third_party/openh264/src/codec/api/wels/codec_api.h"

+ +#include "third_party/openh264/src/codec/api/wels/codec_app_def.h"

+ +#include "third_party/openh264/src/codec/api/wels/codec_def.h"

+ +#include "third_party/openh264/src/codec/api/wels/codec_ver.h"

+ +

+ +}

+ diff --git a/third_party/webrtc/webrtc.gni b/third_party/webrtc/webrtc.gni

+ index a5da76c6f..6da346fd4 100644

+ --- a/third_party/webrtc/webrtc.gni

+ +++ b/third_party/webrtc/webrtc.gni

+ @@ -177,6 +177,10 @@ declare_args() {

+    rtc_use_h264 =

+        proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)

+  

+ +  # Allow to use OpenH264 on systems where OpenH264 cannot be installed by

+ +  # default due to licensing, but can be installed later from other sources.

+ +  rtc_dlopen_openh264 = false

+ +

+    # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.

+    rtc_use_absl_mutex = false

+  

file modified
+14 -3
@@ -229,7 +229,7 @@ 

  

  Name:	chromium%{chromium_channel}

  Version: 110.0.5481.61

- Release: 1%{?dist}

+ Release: 2%{?dist}

  Summary: A WebKit (Blink) powered web browser that Google doesn't want you to use

  Url: http://www.chromium.org/Home

  License: BSD and LGPLv2+ and ASL 2.0 and IJG and MIT and GPLv2+ and ISC and OpenSSL and (MPLv1.1 or GPLv2 or LGPLv2)
@@ -374,6 +374,10 @@ 

  Patch144: chromium-111-v8-std-layout1.patch

  Patch145: chromium-111-v8-std-layout2.patch

  

+ # allow to dlopen openh264

+ Patch150: chromium-111-webrtc-dlopen-h264.patch

+ Patch151: chromium-111-media-dlopen-h264.patch

+ 

  # VAAPI

  # Upstream turned VAAPI on in Linux in 86

  Patch202: chromium-104.0.5112.101-enable-hardware-accelerated-mjpeg.patch
@@ -1040,6 +1044,8 @@ 

  %endif

    

  %patch122 -p1 -b .gcc13

+ %patch150 -p1 -b .webrtc-dlopen-h264.patch

+ %patch151 -p1 -b .media-dlopen-h264.patch

  

  # Feature specific patches

  %if %{use_vaapi}
@@ -1301,8 +1307,10 @@ 

  %else

  CHROMIUM_BROWSER_GN_DEFINES+=' ffmpeg_branding="Chromium" proprietary_codecs=false is_component_ffmpeg=false enable_ffmpeg_video_decoders=false media_use_ffmpeg=true'

  %endif

- CHROMIUM_BROWSER_GN_DEFINES+=' media_use_openh264=false'

- CHROMIUM_BROWSER_GN_DEFINES+=' rtc_use_h264=false'

+ CHROMIUM_BROWSER_GN_DEFINES+=' media_use_openh264=true

+ CHROMIUM_BROWSER_GN_DEFINES+=' media_dlopen_openh264=true

+ CHROMIUM_BROWSER_GN_DEFINES+=' rtc_use_h264=true'

+ CHROMIUM_BROWSER_GN_DEFINES+=' rtc_dlopen_openh264=true'

  CHROMIUM_BROWSER_GN_DEFINES+=' use_kerberos=true'

  

  %if 0%{?rhel} == 8
@@ -1806,6 +1814,9 @@ 

  %{chromium_path}/chromedriver

  

  %changelog

+ * Mon Jan 23 2023 Jan Grulich <jgrulich@redhat.com> - 110.0.5481.61-2

+ - Allow to dlopen openh264

+ 

  * Sat Feb 04 2023 Than Ngo <than@redhat.com> - 110.0.5481.61-1

  - update to 110.0.5481.61

  

no initial comment

rebased onto 6662a21

a year ago

rebased onto fb9cda3

a year ago

It's nice that you made the patch for it. To compile it, you need the openh264-devel package, which unfortunately we can't have as a build request.

Chromium already uses the ffmpeg system, which also supports opening openh264.

For the above reasons, we unfortunately cannot include your patches.

It's nice that you made the patch for it. To compile it, you need the openh264-devel package, which unfortunately we can't have as a build request.

Chromium already uses the ffmpeg system, which also supports opening openh264.

For the above reasons, we unfortunately cannot include your patches.

This patch allows to dlopen openh264 when it is installed and actually build openh264 code in Chromium (WebRTC) without needing openh264-devel package, it's just on runtime instead of build time. It's also for the part of the code where ffmpeg is not used.

rebased onto d3e8017

a year ago

rebased onto 61a0a1d

a year ago

rebased onto 868c60c

a year ago

Hmm, currently Chromium in rawhide fails with:
FAILED: gen/third_party/devtools-frontend/src/extension-api/ExtensionAPI.d.ts gen/third_party/devtools-frontend/src/extension-api/extension-api-tsconfig.json /usr/bin/python3 ../../third_party/node/node.py ../../third_party/devtools-frontend/src/scripts/build/ninja/copy-files.js ../../third_party/devtools-frontend/src/extension-api gen/third_party/devtools-frontend/src/extension-api ExtensionAPI.d.ts,extension-api-tsconfig.json Traceback (most recent call last): File "/builddir/build/BUILD/chromium-109.0.5414.74/out/Headless/../../third_party/node/node.py", line 39, in <module> RunNode(sys.argv[1:]) File "/builddir/build/BUILD/chromium-109.0.5414.74/out/Headless/../../third_party/node/node.py", line 25, in RunNode process = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/subprocess.py", line 1024, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib64/python3.11/subprocess.py", line 1901, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)

it looks like you are not using the latest. Following commits were missing in your test build

commit 1057f0a0a2b5361d19d4134cfde82bfa701619d6 (HEAD -> rawhide, origin/rawhide, origin/HEAD)
Author: Than Ngo <than@redhat.com>
Date:   Mon Jan 23 15:50:01 2023 +0100

    fix nodejs issue

commit 2e0aa4d4c9123213f2c495909762b5764d4ce19b
Author: Than Ngo <than@redhat.com>
Date:   Mon Jan 23 12:58:13 2023 +0100

    disable bootstrap on fedora and epel >=8, use system gn

Please rebase and try again.
Thanks!

rebased onto 5849c2d

a year ago

rebased onto 4ed6f8b

a year ago

@ngompa looks it builds now, I installed it, but I'm unsure how to verify it works as expected. Any idea?

rebased onto 2bbc1b1

a year ago

Can we get another rebase of this? Currently fails on top of master. Tried to rebase myself but im getting a failure that looks like its caused by openh264_stubs.h not generating:

gen/third_party/webrtc/modules/video_coding/codecs/h264/openh264_stubs.cc:3:10: fatal error: 'modules/video_coding/codecs/h264/openh264_stubs.h' file not found

include "modules/video_coding/codecs/h264/openh264_stubs.h"

     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated.

-edit- managed to get my rebased patch to build. I mistakenly removed rtc_base dependency as it was removed during a refactor as a dependency:

https://bugs.chromium.org/p/webrtc/issues/detail?id=9838

But then upon further inspection I realized it specifically needs rtc_base:logging. Once I corrected the dependency to that instead of removing it the rest of the rebase entries were minor and it did build as expected.

Unfortunately it did not resolve the issue I was trying to test it for:

https://bugzilla.redhat.com/show_bug.cgi?id=2249271

Rebased patches as of version 119 are here:
https://gist.github.com/GloriousEggroll/be69950e6d0c8cacae789ac160f9eda1