[Playerutil] Removed dependency to EWK by using XWALK Extension 61/263761/1
authorPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Thu, 9 Sep 2021 12:18:16 +0000 (14:18 +0200)
committerPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Thu, 9 Sep 2021 12:45:53 +0000 (14:45 +0200)
Related native change:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/249379/

Change-Id: Ie1088d64b84b9f2087be20531e6852d62f754f21

src/playerutil/playerutil.gyp
src/playerutil/playerutil_api.js
src/playerutil/playerutil_instance.cc
src/playerutil/playerutil_instance.h
src/playerutil/playerutil_utils.cc [deleted file]
src/playerutil/playerutil_utils.h [deleted file]

index e1fe9e8..72ef970 100644 (file)
         'playerutil_extension.h',
         'playerutil_instance.cc',
         'playerutil_instance.h',
-        'playerutil_utils.cc',
-        'playerutil_utils.h',
       ],
       'includes': [
         '../common/pkg-config.gypi',
       ],
-      'conditions': [
-        ['tizen == 1', {
-          'variables': {
-            'packages': [
-              'chromium-efl',
-              'eina',
-              'evas'
-            ]
-          },
-        }],
-      ],
     },
   ],
 }
index c9bc4ce..1fb87c5 100644 (file)
@@ -25,15 +25,42 @@ var LatencyMode = {
     HIGH: 'HIGH'
 };
 
+function toLatencyModeName(codeString) {
+    var code = parseInt(codeString);
+    switch (code) {
+    case 0:
+        return LatencyMode.LOW;
+    case 1:
+        return LatencyMode.MID;
+    case 2:
+        return LatencyMode.HIGH;
+    default:
+        throw new WebAPIException(WebAPIException.ABORT_ERR, 'Unknown latency');
+    }
+}
+
+function toLatencyModeCode(string) {
+    switch (string) {
+    case LatencyMode.LOW:
+        return String(0);
+    case LatencyMode.MID:
+        return String(1);
+    case LatencyMode.HIGH:
+        return String(2);
+    default:
+        throw new WebAPIException(WebAPIException.ABORT_ERR, 'Unknown latency');
+    }
+}
+
 function PlayerUtil() {}
 
 PlayerUtil.prototype.getLatencyMode = function() {
-    var result = native.callSync('PlayerUtilGetLatencyMode', {});
+    var ret = native.sendRuntimeSyncMessage('tizen://getAudioLatencyMode');
 
-    if (native.isSuccess(result)) {
-        return native.getResultObject(result);
+    if (ret === 'error') {
+        throw new WebAPIException(WebAPIException.ABORT_ERR, 'Abort Error');
     } else {
-        throw native.getErrorObject(result);
+        return toLatencyModeName(ret);
     }
 };
 
@@ -46,13 +73,13 @@ PlayerUtil.prototype.setLatencyMode = function() {
         }
     ]);
 
-    var callArgs = {};
-    callArgs.latencyMode = args.latencyMode;
-
-    var result = native.callSync('PlayerUtilSetLatencyMode', callArgs);
+    var ret = native.sendRuntimeSyncMessage(
+        'tizen://setAudioLatencyMode',
+        toLatencyModeCode(args.latencyMode)
+    );
 
-    if (native.isFailure(result)) {
-        throw native.getErrorObject(result);
+    if (ret === 'error') {
+        throw new WebAPIException(WebAPIException.ABORT_ERR, 'Abort Error');
     }
 };
 
index 955df6a..37e6b21 100644 (file)
  */
 
 #include "playerutil/playerutil_instance.h"
-
-#include <ewk_context.h>
-#include <thread>
-
 #include "common/logger.h"
-#include "common/scope_exit.h"
-#include "common/tools.h"
-
-#include "playerutil/playerutil_utils.h"
 
 namespace extension {
 namespace playerutil {
@@ -33,49 +25,11 @@ PlayerUtilInstance::PlayerUtilInstance() {
 
   using std::placeholders::_1;
   using std::placeholders::_2;
-
-#define REGISTER_METHOD(M) RegisterSyncHandler(#M, std::bind(&PlayerUtilInstance::M, this, _1))
-  REGISTER_METHOD(PlayerUtilGetLatencyMode);
-  REGISTER_METHOD(PlayerUtilSetLatencyMode);
-#undef REGISTER_METHOD
 }
 
 PlayerUtilInstance::~PlayerUtilInstance() {
   ScopeLogger();
 }
 
-common::TizenResult PlayerUtilInstance::PlayerUtilGetLatencyMode(const picojson::object& args) {
-  ScopeLogger();
-
-  Ewk_Context* context = ewk_context_default_get();
-
-  Ewk_Audio_Latency_Mode latency_mode = ewk_context_audio_latency_mode_get(context);
-
-  if (EWK_AUDIO_LATENCY_MODE_ERROR == latency_mode) {
-    LogAndReturnTizenError(common::AbortError(), ("ewk_context_audio_latency_mode_get() failed"));
-  }
-
-  return common::TizenSuccess{picojson::value{PlayerUtilUtils::FromLatencyMode(latency_mode)}};
-}
-
-common::TizenResult PlayerUtilInstance::PlayerUtilSetLatencyMode(const picojson::object& args) {
-  ScopeLogger();
-
-  CHECK_EXIST(args, kLatencyMode);
-  auto latency_it = args.find(kLatencyMode)->second;
-  if (latency_it.is<std::string>()) {
-    Ewk_Audio_Latency_Mode latency_mode =
-        PlayerUtilUtils::ToLatencyMode(latency_it.get<std::string>());
-    Ewk_Context* context = ewk_context_default_get();
-
-    auto ret = ewk_context_audio_latency_mode_set(context, latency_mode);
-    if (EINA_TRUE != ret) {
-      LogAndReturnTizenError(common::AbortError(), ("ewk_context_audio_latency_mode_set() failed"));
-    }
-  }
-
-  return common::TizenSuccess();
-}
-
 }  // namespace playerutil
 }  // namespace extension
index 2fd69a0..5b4c755 100644 (file)
@@ -26,10 +26,6 @@ class PlayerUtilInstance : public common::TizenInstance {
  public:
   PlayerUtilInstance();
   virtual ~PlayerUtilInstance();
-
- private:
-  common::TizenResult PlayerUtilGetLatencyMode(const picojson::object& args);
-  common::TizenResult PlayerUtilSetLatencyMode(const picojson::object& args);
 };
 
 }  // namespace playerutil
diff --git a/src/playerutil/playerutil_utils.cc b/src/playerutil/playerutil_utils.cc
deleted file mode 100644 (file)
index dd6739c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include "playerutil_utils.h"
-
-#include "common/logger.h"
-
-namespace extension {
-namespace playerutil {
-
-namespace {
-#define PLAYER_UTIL_LATENCY_MODE_E       \
-  X(EWK_AUDIO_LATENCY_MODE_HIGH, "HIGH") \
-  X(EWK_AUDIO_LATENCY_MODE_MID, "MID")   \
-  X(EWK_AUDIO_LATENCY_MODE_LOW, "LOW")   \
-  XD(EWK_AUDIO_LATENCY_MODE_LOW, "unknown")
-
-}  // namespace
-
-const std::string kLatencyMode = "latencyMode";
-
-#define X(v, s) \
-  case v:       \
-    return s;
-#define XD(v, s)                                               \
-  default:                                                     \
-    LoggerE("Unknown value: %d, returning default: %s", e, s); \
-    return s;
-
-std::string PlayerUtilUtils::FromLatencyMode(Ewk_Audio_Latency_Mode e) {
-  ScopeLogger();
-
-  switch (e) { PLAYER_UTIL_LATENCY_MODE_E }
-}
-
-#undef X
-#undef XD
-
-#define X(v, s) \
-  if (e == s) return v;
-#define XD(v, s)                                                     \
-  LoggerE("Unknown value: %s, returning default: %d", e.c_str(), v); \
-  return v;
-
-Ewk_Audio_Latency_Mode PlayerUtilUtils::ToLatencyMode(const std::string& e) {
-  ScopeLogger();
-
-  PLAYER_UTIL_LATENCY_MODE_E
-}
-#undef X
-#undef XD
-
-}  // namespace playerutil
-}  // namespace extension
diff --git a/src/playerutil/playerutil_utils.h b/src/playerutil/playerutil_utils.h
deleted file mode 100644 (file)
index 612a1d3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef WEBAPI_PLUGINS_PLAYER_UTIL_UTILS_H__
-#define WEBAPI_PLUGINS_PLAYER_UTIL_UTILS_H__
-
-#include <string>
-
-#include <EWebKit.h>
-#include <EWebKit_internal.h>
-
-#include "common/tizen_instance.h"
-#include "common/tizen_result.h"
-
-namespace extension {
-namespace playerutil {
-
-#define CHECK_EXIST(args, name)                                                    \
-  if (args.end() == args.find(name)) {                                             \
-    return common::TypeMismatchError(std::string(name) + " is required argument"); \
-  }
-
-extern const std::string kLatencyMode;
-
-class PlayerUtilUtils {
- public:
-  static std::string FromLatencyMode(Ewk_Audio_Latency_Mode e);
-  static Ewk_Audio_Latency_Mode ToLatencyMode(const std::string& e);
-};
-
-}  // namespace playerutil
-}  // namespace extension
-
-#endif  // WEBAPI_PLUGINS_PLAYER_UTIL_UTILS_H__