Introduce platform-api-wrapper module for solving abi namespace issues 77/317277/17
authorGajendra N <gajendra.n@samsung.com>
Fri, 6 Sep 2024 10:31:56 +0000 (16:01 +0530)
committerGajendra N <gajendra.n@samsung.com>
Fri, 13 Sep 2024 05:20:54 +0000 (10:50 +0530)
ABI namespace string differs between libraries : GCC libstdc++ and Chromium libc++,
resulting in linker errors [1] during usage of STL classes like std::vector, std::string etc.

[1] ld.lld: error: undefined symbol: eme::IEME::enumerateMediaKeySystems(
                std::__Cr::vector<char const*, std::__Cr::allocator<char const*>>*)

This commit introduces a wrapper layer to overcome the abi compatibility issues.

Change-Id: I8457fe67f313ea44e8c66b326fcfc3af06f4363f
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
19 files changed:
packaging/chromium-efl.spec
tizen_src/build/BUILD.gn
tizen_src/build/common.sh
tizen_src/build/config/BUILD.gn
tizen_src/build/config/tizen_features.gni
tizen_src/build/gbs.conf.in
tizen_src/build/local_repository/chromium-efl-platform-api-wrapper-1.0.0-1.armv7l.rpm [new file with mode: 0644]
tizen_src/chromium_impl/media/filters/ieme_drm_bridge.cc
tizen_src/chromium_impl/media/filters/ieme_drm_bridge.h
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_integration/renderer/key_systems_tizen.cc
tizen_src/platform_api_wrapper/CMakeLists.txt [new file with mode: 0644]
tizen_src/platform_api_wrapper/README [new file with mode: 0644]
tizen_src/platform_api_wrapper/build.sh [new file with mode: 0755]
tizen_src/platform_api_wrapper/chromium-efl-platform-api-wrapper.pc [new file with mode: 0644]
tizen_src/platform_api_wrapper/gbs.conf [new file with mode: 0644]
tizen_src/platform_api_wrapper/packaging/chromium-efl-platform-api-wrapper.spec [new file with mode: 0644]
tizen_src/platform_api_wrapper/platform_api_wrapper.cc [new file with mode: 0644]
tizen_src/platform_api_wrapper/platform_api_wrapper.h [new file with mode: 0644]

index 5ea6f0489ba47976470c81dc1e67f72569c60acf..29e5721451cea14d2ce9c9507d7fe5a390ab1043 100644 (file)
@@ -205,6 +205,7 @@ BuildRequires: pkgconfig(tv-resource-manager)
 BuildRequires: pkgconfig(tv-resource-information)
 BuildRequires: pkgconfig(vd-win-util)
 BuildRequires: pkgconfig(WebProduct)
+BuildRequires: pkgconfig(chromium-efl-platform-api-wrapper)
 %if %{tizen_version} >= 60
 BuildRequires: pkgconfig(resource-center-api)
 %endif
@@ -753,6 +754,7 @@ install -m 0644 third_party/electron_node/src/*.h "%{buildroot}"%{_includedir}/n
   %else
     install -m 0644 "%{OUTPUT_FOLDER}"/libchromium-ewk.so  "%{buildroot}"%{CHROMIUM_LIB_DIR}/lib/
   %endif
+  install -m 0644 "%{_libdir}"/libchromium-efl-platform-api-wrapper.so "%{buildroot}"%{CHROMIUM_LIB_DIR}/lib/
 %endif
 
 install -m 0644 "%{OUTPUT_FOLDER}"/resources/*.edj "%{buildroot}"%{CHROMIUM_LIB_DIR}/res/themes/
@@ -1132,6 +1134,7 @@ rm -rf %{CHROMIUM_TPK_DIR}/%{_tpk_file_name}.tpk
   %else
     %{CHROMIUM_LIB_DIR}/lib/libchromium-ewk.so
   %endif
+  %{CHROMIUM_LIB_DIR}/lib/libchromium-efl-platform-api-wrapper.so
   %{CHROMIUM_LIB_DIR}/res/images/*.png
 %endif
 
index fde5305d1b81469e260b1746482525aef6e5b345..361bd55ef996d2ef19cc71d11e923cd69d47ecd3 100644 (file)
@@ -880,6 +880,13 @@ tizen_pkg_config("autoinput") {
   }
 }
 
+tizen_pkg_config("chromium-efl-platform-api-wrapper") {
+  packages = []
+  if (tizen_product_tv) {
+    packages = [ "chromium-efl-platform-api-wrapper" ]
+  }
+}
+
 if (enable_wrt_js) {
   tizen_pkg_config("appcore-agent") {
     packages = [ "appcore-agent" ]
index 34f2dea0f68357f0b795ff12f78a6f5ab819a7e9..23a3e77076021be8313acf9f17bfd85424fca627 100755 (executable)
@@ -18,6 +18,7 @@ if [ "$DEFAULT_TIZEN_VERSION" != "${LATEST_TIZEN_VERSION}" ]; then
 fi
 sed -e "s/@PUBLIC_REPO_VERSION@/$PUBLIC_REPO_VERSION/g" \
     -e "s/@TIZEN_VERSION@/$DEFAULT_TIZEN_VERSION/g" \
+    -e "s#@RPM_LOCAL_PATH_PREFIX@#$PWD#g" \
     tizen_src/build/gbs.conf.in > tizen_src/build/gbs.conf
 
 function getSystemDeps() {
index 36fd9395e45c35223db336f0ca491e4e76aeb5d4..0ffa71d8778c01036f3a570f877dd375c9bad365 100644 (file)
@@ -20,6 +20,9 @@ config("tizen_feature_flags") {
   if (ewk_bringup) {
     defines += [ "EWK_BRINGUP" ]
   }
+  if (platform_api_wrapper) {
+    defines += [ "PLATFORM_API_WRAPPER" ]
+  }
   if (tizen_autofill) {
     defines += [ "TIZEN_AUTOFILL" ]
   }
index 5001f3471d39979662ff28f7b0908cbad6f2c39b..3f79d549bb7d581b813fb0c8ee681ae00c17d61d 100644 (file)
@@ -117,6 +117,7 @@ werror = false
 use_gstreamer_fft = false
 
 ewk_bringup = true
+platform_api_wrapper = true
 wayland_bringup = use_wayland
 
 compile_suid_client = true
index f6788ab687f181fde941e87b0cfc0016dff89686..576e0d5a245ffcb86ea0d1987373cdb3da9c155b 100755 (executable)
@@ -129,7 +129,7 @@ url = https://168.219.243.64/api
 #
 [profile.tztv_9.0_arm-pontusm]
 obs = obs.tizen_product_tv
-repos = repo.tv_product_9.0_pontusm, repo.tv_product_9.0_base
+repos = repo.tv_product_9.0_pontusm, repo.tv_product_9.0_base, repo.tv_product_9.0_pontusm_local
 buildroot = ~/GBS-ROOT-TZTV_9.0_ARM-PONTUSM
 
 [repo.tv_product_9.0_base]
@@ -138,6 +138,9 @@ url = http://repos.vd.sec.samsung.net/base/tizen-9.0-base/standard/latest/repos/
 [repo.tv_product_9.0_pontusm]
 url = http://repos.vd.sec.samsung.net/products/tv/official/2025/ONEMAIN/PontusM/latest/repos/product/armv7l/packages/
 
+[repo.tv_product_9.0_pontusm_local]
+url = @RPM_LOCAL_PATH_PREFIX@/tizen_src/build/local_repository/
+
 ###############################################
 #
 # Tizen v8.0 for product tv (PontusM armv7l)
diff --git a/tizen_src/build/local_repository/chromium-efl-platform-api-wrapper-1.0.0-1.armv7l.rpm b/tizen_src/build/local_repository/chromium-efl-platform-api-wrapper-1.0.0-1.armv7l.rpm
new file mode 100644 (file)
index 0000000..8ca850e
Binary files /dev/null and b/tizen_src/build/local_repository/chromium-efl-platform-api-wrapper-1.0.0-1.armv7l.rpm differ
index 1bb4deca391027a08a7cf7455b2fb156f263ae7f..eb4cf73e3e4a408ff5227ae940fa62e5a3841b50 100644 (file)
@@ -5,6 +5,7 @@
 #include "media/filters/ieme_drm_bridge.h"
 
 #include <drmdecrypt_api.h>
+#include <platform-api-wrapper/platform_api_wrapper.h>
 #include <algorithm>
 #include <limits>
 
@@ -179,10 +180,13 @@ std::vector<uint8_t> CreateBinaryDataFromString(const std::string& data) {
 // static
 bool IEMEDrmBridge::IsKeySystemSupported(const std::string& key_system) {
   CHECK(!key_system.empty());
-#if !defined(EWK_BRINGUP)  // FIXME: m126 bringup
-  return eme::IEME::isKeySystemSupported(key_system) == eme::kSupported;
+#if defined(PLATFORM_API_WRAPPER)
+  return platform_api_wrapper::isKeySystemSupported(key_system.c_str()) ==
+         eme::kSupported;
+#else
+  return platform_api_wrapper::isKeySystemSupported(key_system) ==
+         eme::kSupported;
 #endif
-  return false;
 }
 
 IEMEDrmBridge::IEMEDrmBridge(
@@ -208,8 +212,11 @@ IEMEDrmBridge::IEMEDrmBridge(
       switches::kSingleProcess);
   LOG(INFO) << "single process mode:" << std::boolalpha << single_process_mode_;
   // TODO(mdebski): what is privacy_mode?
-#if !defined(EWK_BRINGUP)  // FIXME: m126 bringup
-  cdm_.reset(eme::IEME::create(this, key_system_, false));
+#if defined(PLATFORM_API_WRAPPER)
+  cdm_.reset(
+      platform_api_wrapper::createIEME(this, key_system_.c_str(), false));
+#else
+  cdm_.reset(platform_api_wrapper::createIEME(this, key_system_, false));
 #endif
   CHECK(cdm_.get());
 }
index bcc9c76e2c8d0f8c378e9ec50705f659e6c7aac8..419a519c8795ce1289e2e017224b807c011c8635 100644 (file)
@@ -129,6 +129,11 @@ class MEDIA_EXPORT IEMEDrmBridge : public ContentDecryptionModule,
                  const std::string& message) override;
   void onKeyStatusesChange(const std::string& ieme_session_id) override;
   void onRemoveComplete(const std::string& ieme_session_id) override;
+  void onHostNetwork(const std::string& session_id,
+                     eme::MessageType message_type,
+                     const std::string& inMessage,
+                     const std::string& inMsgURL,
+                     std::string& outMessage) override {}
 
  private:
   IEMEDrmBridge(const std::string& key_system,
index 510bc849f5f7a6dc6d2bb3b9ad8ac1a6196e0ea2..4dce0cefd949a60746c0225e1e9565907dfdc848 100644 (file)
@@ -78,6 +78,7 @@ shared_library("chromium-ewk") {
   if (tizen_product_tv) {
     configs += [ "//tizen_src/build:WebProduct" ]
     configs += [ "//tizen_src/build:drmdecrypt" ]
+    configs += [ "//tizen_src/build:chromium-efl-platform-api-wrapper" ]
   }
   deps = [
     "//base/:base_static",
@@ -205,7 +206,7 @@ shared_library("chromium-ewk") {
 
   if (is_clang) {
     libs = [ "atomic" ]
-    ldflags += [ "-Wl,-rpath=/usr/local/lib/" ]
+    ldflags += [ "-Wl,-rpath=\$ORIGIN/:/usr/local/lib/" ]
   }
 
   if (enable_wrt_js) {
index f99fb046f18e8f7d805acc70e881a5461d36468a..4e4aded7202a938abef6c195184d86ea94023d69 100644 (file)
@@ -5,6 +5,7 @@
 #include "renderer/key_systems_tizen.h"
 
 #include <emeCDM/IEME.h>
+#include <platform-api-wrapper/platform_api_wrapper.h>
 #include <algorithm>
 
 #include "base/logging.h"
@@ -17,9 +18,16 @@ void TizenAddKeySystems(
     const std::vector<std::string>& key_system_whitelist,
     std::vector<std::unique_ptr<media::KeySystemInfo>>* key_systems_info) {
   eme::supportedCDMList supportedKeySystems;
-#if !defined(EWK_BRINGUP)  // FIXME: m126 bringup
+#if defined(PLATFORM_API_WRAPPER)
+  platform_api_wrapper::vector_wrapper<const char*> supportedKeySystemsCharList;
+  platform_api_wrapper::enumerateMediaKeySystems(&supportedKeySystemsCharList);
+  for (int i = 0; i < supportedKeySystemsCharList.size(); i++) {
+    supportedKeySystems.push_back(supportedKeySystemsCharList[i]);
+  }
+#else
   eme::IEME::enumerateMediaKeySystems(&supportedKeySystems);
 #endif
+
   for (const auto& keySystem : supportedKeySystems) {
     if (!key_system_whitelist.empty() &&
         std::find(key_system_whitelist.begin(), key_system_whitelist.end(),
diff --git a/tizen_src/platform_api_wrapper/CMakeLists.txt b/tizen_src/platform_api_wrapper/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5707e1f
--- /dev/null
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.10)
+project(chromium-efl-platform-api-wrapper)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_COMPILER gcc)
+
+set(CMAKE_CXX_FLAGS "-Wno-error -Wno-unused-variable -Wno-unused-function -Wno-shadow -fPIC -Wno-attributes")
+set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS})
+set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS})
+
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(PACKAGE_DEPS REQUIRED drmdecrypt)
+
+add_library(chromium-efl-platform-api-wrapper
+            platform_api_wrapper.cc
+           )
+
+target_link_libraries(chromium-efl-platform-api-wrapper ${PACKAGE_DEPS_LIBRARIES})
+target_link_libraries(chromium-efl-platform-api-wrapper stdc++)
+
+target_include_directories(chromium-efl-platform-api-wrapper PUBLIC ${PACKAGE_DEPS_INCLUDE_DIRS})
diff --git a/tizen_src/platform_api_wrapper/README b/tizen_src/platform_api_wrapper/README
new file mode 100644 (file)
index 0000000..30cc0bd
--- /dev/null
@@ -0,0 +1,2 @@
+This directory has to be built in a separate git codebase,
+and the built rpm has to be copied to tizen_src/build/local_repository/
diff --git a/tizen_src/platform_api_wrapper/build.sh b/tizen_src/platform_api_wrapper/build.sh
new file mode 100755 (executable)
index 0000000..aacdf48
--- /dev/null
@@ -0,0 +1 @@
+gbs -c ./gbs.conf build -P profile.tztv_9.0_arm-pontusm -A armv7l --include-all $1
diff --git a/tizen_src/platform_api_wrapper/chromium-efl-platform-api-wrapper.pc b/tizen_src/platform_api_wrapper/chromium-efl-platform-api-wrapper.pc
new file mode 100644 (file)
index 0000000..2acc12e
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: chromium-efl-platform-api-wrapper
+Description: Chromium-Efl Platform Api Wrapper
+Requires: drmdecrypt
+Version: 1.0.0
+
+Libs: -L${libdir} -lchromium-efl-platform-api-wrapper
+Cflags: -I${includedir}/platform-api-wrapper
diff --git a/tizen_src/platform_api_wrapper/gbs.conf b/tizen_src/platform_api_wrapper/gbs.conf
new file mode 100644 (file)
index 0000000..7ab66a0
--- /dev/null
@@ -0,0 +1,21 @@
+###############################################
+#
+# Tizen product tv
+#
+[obs.tizen_product_tv]
+url = https://168.219.243.64/api
+
+###############################################
+#
+# Tizen v9.0 for product tv (PontusM armv7l)
+#
+[profile.tztv_9.0_arm-pontusm]
+obs = obs.tizen_product_tv
+repos = repo.tv_product_9.0_pontusm, repo.tv_product_9.0_base
+buildroot = ~/GBS-ROOT-PLATFORM-API-WRAPPER
+
+[repo.tv_product_9.0_base]
+url = http://repos.vd.sec.samsung.net/base/tizen-9.0-base/standard/latest/repos/base/armv7l/packages/
+
+[repo.tv_product_9.0_pontusm]
+url = http://repos.vd.sec.samsung.net/products/tv/official/2025/ONEMAIN/PontusM/latest/repos/product/armv7l/packages/
diff --git a/tizen_src/platform_api_wrapper/packaging/chromium-efl-platform-api-wrapper.spec b/tizen_src/platform_api_wrapper/packaging/chromium-efl-platform-api-wrapper.spec
new file mode 100644 (file)
index 0000000..a0cc775
--- /dev/null
@@ -0,0 +1,46 @@
+%define _unpackaged_files_terminate_build 0
+
+Name:           chromium-efl-platform-api-wrapper
+Summary:        Chromium-Efl Plaform Api Wrapper
+Version:        1.0.0
+Release:        1
+Group:          Application
+License:        Apache-2.0 and BSD-3-Clause
+Source0:        %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(drmdecrypt)
+
+%description
+Plaform Api Wrapper
+
+%prep
+%setup -q
+
+%build
+export CXX=/usr/bin/g++
+export CC=/usr/bin/gcc
+export CXXFLAGS="$(echo $CFLAGS | sed 's/-Wl,--as-needed//g')"
+export CXXFLAGS="$(echo $CFLAGS | sed 's/-Wshadow//g')"
+
+%cmake .
+make %{?_smp_mflags}
+
+%install
+
+install -d %{buildroot}/usr/lib/
+install -d %{buildroot}/usr/lib/pkgconfig/
+install -d %{buildroot}/usr/include/platform-api-wrapper/
+
+install -m 0644 ./libchromium-efl-platform-api-wrapper.so   %{buildroot}/usr/lib/libchromium-efl-platform-api-wrapper.so
+install -m 0644 ./chromium-efl-platform-api-wrapper.pc      %{buildroot}/usr/lib/pkgconfig/chromium-efl-platform-api-wrapper.pc
+install -m 0644 ./platform_api_wrapper.h                    %{buildroot}/usr/include/platform-api-wrapper/platform_api_wrapper.h
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+/usr/lib/libchromium-efl-platform-api-wrapper.so
+/usr/lib/pkgconfig/chromium-efl-platform-api-wrapper.pc
+/usr/include/platform-api-wrapper/platform_api_wrapper.h
diff --git a/tizen_src/platform_api_wrapper/platform_api_wrapper.cc b/tizen_src/platform_api_wrapper/platform_api_wrapper.cc
new file mode 100644 (file)
index 0000000..2f2847b
--- /dev/null
@@ -0,0 +1,25 @@
+#include "platform_api_wrapper.h"
+
+namespace platform_api_wrapper {
+
+// eme::IEME wrapper impl
+
+void enumerateMediaKeySystems(vector_wrapper<const char*>* list) {
+  eme::supportedCDMList supportedKeySystems;
+  eme::IEME::enumerateMediaKeySystems(&supportedKeySystems);
+  for (auto& it : supportedKeySystems) {
+    list->push_back(it.c_str());
+  }
+}
+
+eme::IEME* createIEME(eme::IEventListener* listener,
+                      const char* key_system,
+                      bool privacy_mode) {
+  return eme::IEME::create(listener, std::string(key_system), privacy_mode);
+}
+
+eme::Status isKeySystemSupported(const char* key_system) {
+  return eme::IEME::isKeySystemSupported(std::string(key_system));
+}
+
+}  // namespace platform_api_wrapper
diff --git a/tizen_src/platform_api_wrapper/platform_api_wrapper.h b/tizen_src/platform_api_wrapper/platform_api_wrapper.h
new file mode 100644 (file)
index 0000000..6cff344
--- /dev/null
@@ -0,0 +1,30 @@
+#include <emeCDM/IEME.h>
+
+namespace platform_api_wrapper {
+
+// Wrapper impl for std::vector
+
+template <typename T>
+class vector_wrapper {
+ public:
+  vector_wrapper() {}
+  ~vector_wrapper() { list_.clear(); }
+  void push_back(T data) { list_.push_back(data); }
+  T& operator[](int index) { return list_[index]; }
+  size_t size() { return list_.size(); }
+
+ private:
+  std::vector<T> list_;
+};
+
+// Wrapper APIs for <emeCDM/IEME.h>
+
+void enumerateMediaKeySystems(vector_wrapper<const char*>* list);
+
+eme::IEME* createIEME(eme::IEventListener* listener,
+                      const char* key_system,
+                      bool privacy_mode);
+
+eme::Status isKeySystemSupported(const char* key_system);
+
+}  // namespace platform_api_wrapper