From: Jaeyun Date: Wed, 2 Oct 2019 08:06:49 +0000 (+0900) Subject: [Api/Tizen] Tizen internal API to construct pipeline X-Git-Tag: accepted/tizen/unified/20191008.101521^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc068203b017c7b2256e14676d749653aa7e1f26;p=platform%2Fupstream%2Fnnstreamer.git [Api/Tizen] Tizen internal API to construct pipeline Add Tizen internal API without checking the permission. Signed-off-by: Jaeyun Jung --- diff --git a/api/capi/include/nnstreamer-capi-private.h b/api/capi/include/nnstreamer-capi-private.h index afa8c09..95cd2b8 100644 --- a/api/capi/include/nnstreamer-capi-private.h +++ b/api/capi/include/nnstreamer-capi-private.h @@ -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 index 0000000..3e341ca --- /dev/null +++ b/api/capi/include/nnstreamer-tizen-internal.h @@ -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 + * @bug No known bugs except for NYI items + */ + +#ifndef __TIZEN_MACHINELEARNING_NNSTREAMER_INTERNAL_H__ +#define __TIZEN_MACHINELEARNING_NNSTREAMER_INTERNAL_H__ + +#include + +#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__ */ diff --git a/api/capi/meson.build b/api/capi/meson.build index 275730f..1adf3cc 100644 --- a/api/capi/meson.build +++ b/api/capi/meson.build @@ -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, diff --git a/api/capi/src/nnstreamer-capi-pipeline.c b/api/capi/src/nnstreamer-capi-pipeline.c index 25a4236..6d04987 100644 --- a/api/capi/src/nnstreamer-capi-pipeline.c +++ b/api/capi/src/nnstreamer-capi-pipeline.c @@ -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) */ diff --git a/packaging/nnstreamer.spec b/packaging/nnstreamer.spec index ce35674..3563c53 100644 --- a/packaging/nnstreamer.spec +++ b/packaging/nnstreamer.spec @@ -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 diff --git a/tests/tizen_capi/unittest_tizen_capi.cpp b/tests/tizen_capi/unittest_tizen_capi.cpp index 86f5e0b..cb57c2f 100644 --- a/tests/tizen_capi/unittest_tizen_capi.cpp +++ b/tests/tizen_capi/unittest_tizen_capi.cpp @@ -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__ */ /**