webrtc_restriction: Add function to check feature 96/252496/3
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 28 Jan 2021 09:09:10 +0000 (18:09 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 2 Feb 2021 06:46:42 +0000 (15:46 +0900)
RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED macro is also added in
webrtc_private.h.

[Version] 0.1.97
[Issue Type] Feature

Change-Id: I6b154da971830d2392fe691370fe88ec88afddfc
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
CMakeLists.txt
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_restriction.c

index c1f7afa6f9d8b5c2f8829a33741ce49053d73a54..0e4e0c091429ee9d3ac9d3849068a94bfa1141af 100644 (file)
@@ -13,7 +13,7 @@ INCLUDE_DIRECTORIES(${INC_DIR})
 
 SET(dependents "dlog glib-2.0 gstreamer-1.0 gstreamer-webrtc-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 \
                 json-glib-1.0 iniparser mm-common mm-display-interface capi-media-tool libtbm libwebsockets \
-                cynara-client libsmack libsoup-2.4")
+                cynara-client libsmack capi-system-info libsoup-2.4")
 IF(TIZEN_FEATURE_RESOURCE_MANAGER)
 SET(dependents "${dependents} mm-resource-manager")
 ADD_DEFINITIONS("-DTIZEN_FEATURE_RES_MGR")
index 73edd2e7b4023176e45142480cde6ffe2abae2cf..098fe607549c1bede2be95e83415e3c16455ccfd 100644 (file)
@@ -128,6 +128,13 @@ do { \
                return ret; \
 } while (0)
 
+#define RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(x_feature) \
+do { \
+       int ret = _check_feature(x_feature); \
+       if (ret != WEBRTC_ERROR_NONE) \
+               return ret; \
+} while (0)
+
 #define SAFE_FREE(src)    { if (src) { free(src); src = NULL; } }
 #define SAFE_STR(str)     (str) ? str : "null"
 
@@ -466,6 +473,7 @@ int _start_websocket(webrtc_websocket_s *ws, int timeout_ms);
 int _stop_websocket(webrtc_websocket_s *ws);
 
 int _check_privilege(const char *privilege);
+int _check_feature(const char *feature);
 
 #ifdef __cplusplus
 }
index 3468e17227a55dc17c1830449b97ecbfb00eb7b8..10fd28218028060eb6003a86e43f2f75b5908db5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.96
+Version:    0.1.97
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -27,6 +27,7 @@ BuildRequires:  pkgconfig(libtbm)
 BuildRequires:  pkgconfig(libwebsockets)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(libsmack)
+BuildRequires:  pkgconfig(capi-system-info)
 %if "%{tizen_profile_name}" != "tv"
 BuildRequires:  pkgconfig(mm-resource-manager)
 %endif
index fad54ed1e78bd0e77c7b19e525a6d1dfb52d9a28..a37f6203f666955567e8c206f655b3baaeff8812 100644 (file)
@@ -18,6 +18,7 @@
 #include "webrtc_private.h"
 #include <cynara-client.h>
 #include <sys/smack.h>
+#include <system_info.h>
 
 int _check_privilege(const char *privilege)
 {
@@ -49,3 +50,24 @@ exit:
        cynara_finish(cynara_h);
        return ret;
 }
+
+int _check_feature(const char *feature)
+{
+       bool supported;
+
+       RET_VAL_IF(feature == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "feature is NULL");
+
+       if (system_info_get_platform_bool(feature, &supported) != SYSTEM_INFO_ERROR_NONE) {
+               LOG_ERROR("failed to system_info_get_platform_bool(), feature[%s]", feature);
+               return WEBRTC_ERROR_INVALID_OPERATION;
+       }
+
+       if (!supported) {
+               LOG_ERROR("feature[%s] is not supported", feature);
+               return WEBRTC_ERROR_NOT_SUPPORTED;
+       }
+
+       LOG_INFO("feature[%s] is supported", feature);
+
+       return WEBRTC_ERROR_NONE;
+}