[Custom] feature for custom connection
authorJaeyun Jung <jy1210.jung@samsung.com>
Thu, 2 Jan 2025 06:37:41 +0000 (15:37 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 3 Jan 2025 11:58:05 +0000 (20:58 +0900)
Add new definition to support custom connection (default on).

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
CMakeLists.txt
jni/nnstreamer-edge.mk
packaging/nnstreamer-edge.spec
src/CMakeLists.txt
src/libnnstreamer-edge/nnstreamer-edge-custom-impl.h
tests/CMakeLists.txt

index 03ad053c550b2cb6c70a56e46cb14be0c32970aa..5fa339f1382d3666e2c035a23b947bbb58a9b59c 100644 (file)
@@ -8,6 +8,7 @@ OPTION(ENABLE_DEBUG     "Enable Debug" OFF)
 OPTION(ENABLE_TIZEN     "Enable Tizen build" OFF)
 
 # Default features. You may change the features according to your needs.
+OPTION(ENABLE_CUSTOM_CONNECTION "Enable custom connection" ON)
 OPTION(MQTT_SUPPORT     "Enable MQTT" OFF)
 
 IF (NOT DEFINED VERSION)
@@ -62,6 +63,11 @@ IF(NOT ${REQUIRE_PKGS} STREQUAL "")
     ADD_DEFINITIONS(${EDGE_REQUIRE_PKGS_CFLAGS})
 ENDIF()
 
+# Support custom connection
+IF(ENABLE_CUSTOM_CONNECTION)
+    SET(NNS_EDGE_FLAGS "${NNS_EDGE_FLAGS} -DENABLE_CUSTOM_CONNECTION=1")
+ENDIF()
+
 # MQTT Library
 IF(MQTT_SUPPORT)
     FIND_LIBRARY(MOSQUITTO_LIB NAMES mosquitto)
index c5439a15c9c457093ea4e60c6d8f666a2b21bece..116c11ed13da5dcbf530b09f2ea36712a5a13ad7 100644 (file)
@@ -10,7 +10,6 @@ NNSTREAMER_EDGE_INCLUDES := \
 
 # nnstreamer-edge sources
 NNSTREAMER_EDGE_SRCS := \
-    $(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.c \
     $(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-data.c \
     $(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-event.c \
     $(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-internal.c \
index b7ef8f5df9ee7e8e06a61c5e9c53958474e298cd..be30254ffe107ea0cf34f31395ddbc2c19f49a2f 100644 (file)
@@ -2,6 +2,7 @@
 
 # Default features for Tizen releases
 %define     mqtt_support 1
+%define     custom_connection_support 1
 
 # Define features for TV releases
 %if "%{?profile}" == "tv"
@@ -87,6 +88,12 @@ HTML pages of lcov results of nnstreamer-edge generated during rpm build
 %define enable_mqtt -DMQTT_SUPPORT=OFF
 %endif
 
+%if 0%{?custom_connection_support}
+%define enable_custom_connection -DENABLE_CUSTOM_CONNECTION=ON
+%else
+%define enable_custom_connection -DENABLE_CUSTOM_CONNECTION=OFF
+%endif
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -113,7 +120,7 @@ pushd build
 %cmake .. \
     -DCMAKE_INSTALL_PREFIX=%{_prefix} \
     -DVERSION=%{version} \
-    %{enable_tizen} %{enable_unittest} %{enable_mqtt}
+    %{enable_tizen} %{enable_unittest} %{enable_mqtt} %{enable_custom_connection}
 
 make %{?jobs:-j%jobs}
 popd
@@ -135,7 +142,10 @@ popd
 
 %if 0%{?unit_test}
 LD_LIBRARY_PATH=./src bash %{test_script} ./tests/unittest_nnstreamer-edge
+
+%if 0%{?custom_connection_support}
 LD_LIBRARY_PATH=./src:./tests bash %{test_script} ./tests/unittest_nnstreamer-edge-custom
+%endif
 
 %if 0%{?mqtt_support}
 LD_LIBRARY_PATH=./src bash %{test_script} ./tests/unittest_nnstreamer-edge-mqtt
@@ -181,19 +191,22 @@ rm -rf %{buildroot}
 
 %files devel
 %{_includedir}/nnstreamer/nnstreamer-edge.h
-%{_includedir}/nnstreamer/nnstreamer-edge-custom.h
 %{_includedir}/nnstreamer/nnstreamer-edge-data.h
 %{_includedir}/nnstreamer/nnstreamer-edge-event.h
 %{_libdir}/pkgconfig/nnstreamer-edge.pc
+%if 0%{?custom_connection_support}
+%{_includedir}/nnstreamer/nnstreamer-edge-custom.h
+%endif
 
 %if 0%{?unit_test}
 %files unittest
 %manifest nnstreamer-edge.manifest
 %defattr(-,root,root,-)
 %{_bindir}/unittest_nnstreamer-edge
+%if 0%{?custom_connection_support}
 %{_bindir}/unittest_nnstreamer-edge-custom
 %{_libdir}/libnnstreamer-edge-custom-test.so*
-
+%endif
 %if 0%{?mqtt_support}
 %{_bindir}/unittest_nnstreamer-edge-mqtt
 %endif
index 3b61e1a7d586161e5529ebb38a9a81f9cc2bede2..f17e728c5b3edebe087d747ba145ab85d00efd53 100644 (file)
@@ -1,6 +1,5 @@
 # NNStreamer-Edge library
 SET(NNS_EDGE_SRCS
-    ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-custom-impl.c
     ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-metadata.c
     ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-data.c
     ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-event.c
@@ -8,6 +7,11 @@ SET(NNS_EDGE_SRCS
     ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-util.c
     ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-queue.c
 )
+
+IF(ENABLE_CUSTOM_CONNECTION)
+    SET(NNS_EDGE_SRCS ${NNS_EDGE_SRCS} ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-custom-impl.c)
+ENDIF()
+
 IF (NOT ENABLE_TIZEN)
     SET(NNS_EDGE_SRCS ${NNS_EDGE_SRCS} ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-log.c)
 ENDIF()
@@ -35,6 +39,8 @@ ENDIF()
 
 INSTALL (TARGETS ${NNS_EDGE_LIB_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
 INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge.h DESTINATION ${INCLUDE_INSTALL_DIR})
-INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-custom.h DESTINATION ${INCLUDE_INSTALL_DIR})
 INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-data.h DESTINATION ${INCLUDE_INSTALL_DIR})
 INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-event.h DESTINATION ${INCLUDE_INSTALL_DIR})
+IF(ENABLE_CUSTOM_CONNECTION)
+    INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-custom.h DESTINATION ${INCLUDE_INSTALL_DIR})
+ENDIF()
index 250481b5fb78d2eeddc104bec68fb4aee1c41939..a21301dfc00ee6d0f52e63c225c5dd2f51a612dc 100644 (file)
@@ -29,6 +29,7 @@ typedef struct
   void *priv;
 } custom_connection_s;
 
+#if defined(ENABLE_CUSTOM_CONNECTION)
 /**
  * @brief Internal function to load custom connection from library.
  */
@@ -78,6 +79,18 @@ int nns_edge_custom_set_info (custom_connection_s *custom, const char *key, cons
  * @brief Internal function to get information from custom connection.
  */
 int nns_edge_custom_get_info (custom_connection_s *custom, const char *key, char **value);
+#else
+#define nns_edge_custom_load(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_release(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_start(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_stop(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_set_event_callback(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_is_connected(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_send_data(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_set_info(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_custom_get_info(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#endif /* ENABLE_CUSTOM_CONNECTION */
 
 #ifdef __cplusplus
 }
index 218e8e69cb54b395e4ecd9b75b12bd6291060902..9bd022664979318bcd060e8868b1b410a76bdbba 100644 (file)
@@ -5,6 +5,7 @@ TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge ${TEST_REQUIRE_PKGS_LDFLAGS} ${NN
 INSTALL (TARGETS unittest_nnstreamer-edge DESTINATION ${BIN_INSTALL_DIR})
 
 # Custom connection lib for unit test
+IF(ENABLE_CUSTOM_CONNECTION)
 SET(NNS_EDGE_CUSTOM_TEST_LIB_NAME nnstreamer-edge-custom-test)
 SET(NNS_EDGE_CUSTOM_SRCS ${NNS_EDGE_SRCS} nnstreamer-edge-custom-test.c)
 ADD_LIBRARY(${NNS_EDGE_CUSTOM_TEST_LIB_NAME} SHARED ${NNS_EDGE_CUSTOM_SRCS})
@@ -16,6 +17,7 @@ ADD_EXECUTABLE(unittest_nnstreamer-edge-custom unittest_nnstreamer-edge-custom.c
 TARGET_INCLUDE_DIRECTORIES(unittest_nnstreamer-edge-custom PRIVATE ${EDGE_REQUIRE_PKGS_INCLUDE_DIRS} ${INCLUDE_DIR} ${NNS_EDGE_SRC_DIR})
 TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge-custom ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME} ${NNS_EDGE_CUSTOM_TEST_LIB_NAME})
 INSTALL (TARGETS unittest_nnstreamer-edge-custom DESTINATION ${BIN_INSTALL_DIR})
+ENDIF()
 
 # MQTT test
 IF(MQTT_SUPPORT)