From: Jaeyun Jung Date: Thu, 2 Jan 2025 06:37:41 +0000 (+0900) Subject: [Custom] feature for custom connection X-Git-Tag: accepted/tizen/unified/20250108.103324~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0d3b3105003db5321da1e095a386910db257da6;p=platform%2Fupstream%2Fnnstreamer-edge.git [Custom] feature for custom connection Add new definition to support custom connection (default on). Signed-off-by: Jaeyun Jung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 03ad053..5fa339f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/jni/nnstreamer-edge.mk b/jni/nnstreamer-edge.mk index c5439a1..116c11e 100644 --- a/jni/nnstreamer-edge.mk +++ b/jni/nnstreamer-edge.mk @@ -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 \ diff --git a/packaging/nnstreamer-edge.spec b/packaging/nnstreamer-edge.spec index b7ef8f5..be30254 100644 --- a/packaging/nnstreamer-edge.spec +++ b/packaging/nnstreamer-edge.spec @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b61e1a..f17e728 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() diff --git a/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.h b/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.h index 250481b..a21301d 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.h +++ b/src/libnnstreamer-edge/nnstreamer-edge-custom-impl.h @@ -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 } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 218e8e6..9bd0226 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)