[platform-api-wrapper] Remove c++ header dependancy from wrapper.h 00/318100/4
authorGajendra N <gajendra.n@samsung.com>
Tue, 24 Sep 2024 12:04:44 +0000 (17:34 +0530)
committerGajendra N <gajendra.n@samsung.com>
Wed, 25 Sep 2024 04:17:43 +0000 (09:47 +0530)
Wrapper header gets compiled with clang-libc++ during chromium build
and hence its better to avoid usage of std c++ headers.

Change-Id: I1d2cee5cbaf6df3abcc6718302f5239df2d757d5
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
tizen_src/chromium_impl/media/filters/ieme_drm_bridge.cc
tizen_src/ewk/efl_integration/renderer/key_systems_tizen.cc
tizen_src/platform_api_wrapper/build.sh
tizen_src/platform_api_wrapper/platform_api_wrapper.cc
tizen_src/platform_api_wrapper/platform_api_wrapper.h

index de9f6ff71f2a32c804ea44e2d9404149fbea4cfe..2628d4597d36bb1ded462cda8f5e334a8aed907a 100644 (file)
@@ -181,11 +181,10 @@ std::vector<uint8_t> CreateBinaryDataFromString(const std::string& data) {
 bool IEMEDrmBridge::IsKeySystemSupported(const std::string& key_system) {
   CHECK(!key_system.empty());
 #if defined(PLATFORM_API_WRAPPER)
-  return platform_api_wrapper::isKeySystemSupported(key_system.c_str()) ==
-         eme::kSupported;
+  return static_cast<eme::Status>(platform_api_wrapper::isKeySystemSupported(
+             key_system.c_str())) == eme::kSupported;
 #else
-  return platform_api_wrapper::isKeySystemSupported(key_system) ==
-         eme::kSupported;
+  return eme::IEME::isKeySystemSupported(key_system) == eme::kSupported;
 #endif
 }
 
index debb721ff1a18d7a598936bf550aae0df118b0a7..6084bda91175ac504708fbf3330073955090d228 100644 (file)
@@ -19,7 +19,7 @@ void TizenAddKeySystems(
     std::vector<std::unique_ptr<media::KeySystemInfo>>* key_systems_info) {
   eme::supportedCDMList supportedKeySystems;
 #if defined(PLATFORM_API_WRAPPER)
-  platform_api_wrapper::vector_wrapper<const char*> supportedKeySystemsCharList;
+  platform_api_wrapper::StringVector supportedKeySystemsCharList;
   platform_api_wrapper::enumerateMediaKeySystems(&supportedKeySystemsCharList);
   for (int i = 0; i < supportedKeySystemsCharList.size(); i++) {
     supportedKeySystems.push_back(supportedKeySystemsCharList[i]);
index 1aa66b69a66ff1ea1e7e260edb266271d1d5d6d6..852e8ce49e939d6bf88f8c7a96587de0c54fb9f9 100755 (executable)
@@ -1,7 +1,12 @@
 # Script for building platform-api-wrapper library with cmake.
 
 cd ./tizen_src/platform_api_wrapper
-rm -r build *.so
+if [ -d "build" ]; then
+  rm -r build
+fi
+if [ -f "*.so" ]; then
+  rm *.so
+fi
 mkdir build && cd build
 cmake ../ -DTIZEN_PROFILE=$1
 make && make install
index 5461296ba7580980a7ce7dbf1a4f22e0106f37eb..f40368c592e8a69ec663fbd23703de4fa5994795 100644 (file)
@@ -1,11 +1,46 @@
 #include "platform_api_wrapper.h"
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+#include <emeCDM/IEME.h>
+#endif
+
+#include <string>
+#include <vector>
+
 namespace platform_api_wrapper {
 
+class StringVectorImpl {
+ public:
+  StringVectorImpl() {}
+  ~StringVectorImpl() { list_.clear(); }
+  void push_back(std::string data) { list_.push_back(data); }
+  std::string& operator[](size_t index) { return list_[index]; }
+  size_t size() { return list_.size(); }
+
+ private:
+  std::vector<std::string> list_;
+};
+
+StringVector::StringVector() {
+  impl_ = new StringVectorImpl;
+}
+StringVector::~StringVector() {
+  delete impl_;
+}
+void StringVector::push_back(const char* data) {
+  impl_->push_back(std::string(data));
+}
+const char* StringVector::operator[](size_t index) {
+  return (*impl_)[index].c_str();
+}
+size_t StringVector::size() {
+  return impl_->size();
+}
+
 #if defined(OS_TIZEN_TV_PRODUCT)
 // eme::IEME wrapper impl
 
-void enumerateMediaKeySystems(vector_wrapper<const char*>* list) {
+void enumerateMediaKeySystems(StringVector* list) {
   eme::supportedCDMList supportedKeySystems;
   eme::IEME::enumerateMediaKeySystems(&supportedKeySystems);
   for (auto& it : supportedKeySystems) {
@@ -19,8 +54,8 @@ eme::IEME* createIEME(eme::IEventListener* listener,
   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));
+unsigned isKeySystemSupported(const char* key_system) {
+  return (unsigned)eme::IEME::isKeySystemSupported(std::string(key_system));
 }
 #endif
 
index ee6c14a46e531b1657a3ade6f1a524266ac27304..a12eb2ce902d7b6e69e2b694e9d4d815dc7e9ec9 100644 (file)
@@ -1,39 +1,40 @@
 #ifndef PLATFORM_API_WRAPPER_H_
 #define PLATFORM_API_WRAPPER_H_
 
-#if defined(OS_TIZEN_TV_PRODUCT)
-#include <emeCDM/IEME.h>
-#endif
+#include <cstddef>
 
-#include <vector>
+namespace eme {
+class IEME;
+class IEventListener;
+}  // namespace eme
 
 namespace platform_api_wrapper {
 
 // Wrapper impl for std::vector
+class StringVectorImpl;
 
-template <typename T>
-class vector_wrapper {
+class StringVector {
  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(); }
+  StringVector();
+  ~StringVector();
+  void push_back(const char* data);
+  const char* operator[](size_t index);
+  size_t size();
 
  private:
-  std::vector<T> list_;
+  StringVectorImpl* impl_ = nullptr;
 };
 
 #if defined(OS_TIZEN_TV_PRODUCT)
 // Wrapper APIs for <emeCDM/IEME.h>
 
-void enumerateMediaKeySystems(vector_wrapper<const char*>* list);
+void enumerateMediaKeySystems(StringVector* list);
 
 eme::IEME* createIEME(eme::IEventListener* listener,
                       const char* key_system,
                       bool privacy_mode);
 
-eme::Status isKeySystemSupported(const char* key_system);
+unsigned isKeySystemSupported(const char* key_system);
 #endif
 
 }  // namespace platform_api_wrapper