[Api/Tizen] Tizen internal API to construct pipeline accepted/tizen/unified/20191008.101521 submit/tizen/20191008.053234
authorJaeyun <jy1210.jung@samsung.com>
Wed, 2 Oct 2019 08:06:49 +0000 (17:06 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 8 Oct 2019 04:58:34 +0000 (13:58 +0900)
Add Tizen internal API without checking the permission.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
api/capi/include/nnstreamer-capi-private.h
api/capi/include/nnstreamer-tizen-internal.h [new file with mode: 0644]
api/capi/meson.build
api/capi/src/nnstreamer-capi-pipeline.c
packaging/nnstreamer.spec
tests/tizen_capi/unittest_tizen_capi.cpp

index afa8c09..95cd2b8 100644 (file)
@@ -32,6 +32,8 @@
 
 /* Tizen ML feature */
 #if defined (__TIZEN__)
+#include "nnstreamer-tizen-internal.h"
+
 #define check_feature_state() \
   do { \
     int feature_ret = ml_tizen_get_feature_enabled (); \
diff --git a/api/capi/include/nnstreamer-tizen-internal.h b/api/capi/include/nnstreamer-tizen-internal.h
new file mode 100644 (file)
index 0000000..3e341ca
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ */
+
+/**
+ * @file       nnstreamer-tizen-internal.h
+ * @date       02 October 2019
+ * @brief      NNStreamer/Pipeline(main) C-API Header for Tizen Internal API. This header should be used only in Tizen.
+ * @author     Jaeyun Jung <jy1210.jung@samsung.com>
+ * @bug                No known bugs except for NYI items
+ */
+
+#ifndef __TIZEN_MACHINELEARNING_NNSTREAMER_INTERNAL_H__
+#define __TIZEN_MACHINELEARNING_NNSTREAMER_INTERNAL_H__
+
+#include <nnstreamer.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @brief Constructs the pipeline (GStreamer + NNStreamer).
+ * @details This function is to construct the pipeline without checking the permission in platform internally. See ml_pipeline_construct() for the details.
+ * @since_tizen 5.5
+ */
+int ml_pipeline_construct_internal (const char *pipeline_description, ml_pipeline_state_cb cb, void *user_data, ml_pipeline_h *pipe);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __TIZEN_MACHINELEARNING_NNSTREAMER_INTERNAL_H__ */
index 275730f..1adf3cc 100644 (file)
@@ -34,11 +34,19 @@ endif
 capi_devel_main = []
 capi_devel_main += join_paths(meson.current_source_dir(), 'include', 'nnstreamer.h')
 capi_devel_main += join_paths(meson.current_source_dir(), 'include', 'nnstreamer-single.h')
+if get_option('enable-tizen')
+  # header for Tizen internal API
+  capi_devel_main += join_paths(meson.current_source_dir(), 'include', 'nnstreamer-tizen-internal.h')
+endif
 
-tizen_deps = []
+# Dependencies
+capi_deps = [
+  nnstreamer_dep, glib_dep, gst_dep, gst_app_dep
+]
 
 if (get_option('enable-tizen'))
   message('CAPI is in Tizen mode')
+
   tizen_deps = [
     dependency('mm-resource-manager'),
     dependency('mm-camcorder'),
@@ -47,11 +55,9 @@ if (get_option('enable-tizen'))
     dependency('capi-system-info'),
     dependency('dlog')
   ]
-endif
 
-capi_deps = [
-  nnstreamer_dep, glib_dep, gst_dep, gst_app_dep, tizen_deps
-]
+  capi_deps += tizen_deps
+endif
 
 shared_library ('capi-nnstreamer',
   capi_main,
index 25a4236..6d04987 100644 (file)
@@ -565,6 +565,19 @@ ml_pipeline_construct (const char *pipeline_description,
   return construct_pipeline_internal (pipeline_description, cb, user_data, pipe, FALSE);
 }
 
+#if defined (__TIZEN__)
+/**
+ * @brief Construct the pipeline (Tizen internal, see nnstreamer-tizen-internal.h)
+ */
+int
+ml_pipeline_construct_internal (const char *pipeline_description,
+    ml_pipeline_state_cb cb, void *user_data, ml_pipeline_h * pipe)
+{
+  /* Tizen internal pipeline construction */
+  return construct_pipeline_internal (pipeline_description, cb, user_data, pipe, TRUE);
+}
+#endif /* __TIZEN__ */
+
 /**
  * @brief Destroy the pipeline (more info in nnstreamer.h)
  */
index ce35674..3563c53 100644 (file)
@@ -195,6 +195,13 @@ Group:             Multimedia/Framework
 Requires:      capi-nnstreamer-single-new = %{version}-%{release}
 %description -n capi-nnstreamer-single-new-devel
 Developmental kit for Tizen Native new single-shot NNStreamer API.
+
+%package -n nnstreamer-tizen-internal-capi-devel
+Summary:       Tizen internal API to construct the pipeline
+Group:         Multimedia/Framework
+Requires:      capi-nnstreamer-devel = %{version}-%{release}
+%description -n nnstreamer-tizen-internal-capi-devel
+Tizen internal API to construct the pipeline without the permissions.
 %endif
 
 # Define build options
@@ -408,6 +415,9 @@ cp -r result %{buildroot}%{_datadir}/nnstreamer/unittest/
 %{_includedir}/nnstreamer/nnstreamer-single.h
 %{_libdir}/pkgconfig/capi-nnstreamer-single-new.pc
 %{_libdir}/libcapi-nnstreamer-single-new.a
+
+%files -n nnstreamer-tizen-internal-capi-devel
+%{_includedir}/nnstreamer/nnstreamer-tizen-internal.h
 %endif
 
 %changelog
index 86f5e0b..cb57c2f 100644 (file)
@@ -63,6 +63,46 @@ TEST (nnstreamer_capi_construct_destruct, tizen_cam_fail_02_n)
 
   g_free (pipeline);
 }
+
+/**
+ * @brief Test NNStreamer pipeline construct with Tizen internal API.
+ */
+TEST (nnstreamer_capi_construct_destruct, tizen_internal_01_p)
+{
+  ml_pipeline_h handle;
+  gchar *pipeline;
+  int status;
+
+  pipeline = g_strdup_printf ("videotestsrc ! videoconvert ! videoscale ! video/x-raw,format=RGB,width=320,height=240 ! tensor_converter ! tensor_sink");
+
+  status = ml_pipeline_construct_internal (pipeline, NULL, NULL, &handle);
+  EXPECT_EQ (status, ML_ERROR_NONE);
+
+  status = ml_pipeline_destroy (handle);
+  EXPECT_EQ (status, ML_ERROR_NONE);
+
+  g_free (pipeline);
+}
+
+/**
+ * @brief Test NNStreamer pipeline construct with Tizen internal API.
+ */
+TEST (nnstreamer_capi_construct_destruct, tizen_internal_02_p)
+{
+  ml_pipeline_h handle;
+  gchar *pipeline;
+  int status;
+
+  pipeline = g_strdup_printf ("audiotestsrc ! audioconvert ! audio/x-raw,format=S16LE,rate=16000 ! tensor_converter ! tensor_sink");
+
+  status = ml_pipeline_construct_internal (pipeline, NULL, NULL, &handle);
+  EXPECT_EQ (status, ML_ERROR_NONE);
+
+  status = ml_pipeline_destroy (handle);
+  EXPECT_EQ (status, ML_ERROR_NONE);
+
+  g_free (pipeline);
+}
 #endif /* __TIZEN__ */
 
 /**