Skip to content

Commit

Permalink
[Custom] feature for custom connection
Browse files Browse the repository at this point in the history
Add new definition to support custom connection (default on).

Signed-off-by: Jaeyun Jung <[email protected]>
  • Loading branch information
jaeyun-jung committed Jan 3, 2025
1 parent 3ea46c6 commit 2271d76
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion jni/nnstreamer-edge.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
19 changes: 16 additions & 3 deletions packaging/nnstreamer-edge.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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} .
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# 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
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-internal.c
${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()
Expand Down Expand Up @@ -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()
13 changes: 13 additions & 0 deletions src/libnnstreamer-edge/nnstreamer-edge-custom-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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)
Expand Down

0 comments on commit 2271d76

Please sign in to comment.