Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- #211

Closed
wants to merge 1 commit into from
Closed

- #211

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions src/libnnstreamer-edge/nnstreamer-edge-mcf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* SPDX-License-Identifier: Apache-2.0 */
/**
* Copyright (C) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
*
* @file nnstreamer-edge-mcf.h
* @date 02 July 2024
* @brief Common library to support communication among devices using MCF.
* @see https://github.com/nnstreamer/nnstreamer-edge
* @author Gichan Jang <gichan2.jang@samsung.com>
* @bug No known bugs except for NYI items
*/

#ifndef __NNSTREAMER_EDGE_MCF_H__
#define __NNSTREAMER_EDGE_MCF_H__

#include "nnstreamer-edge.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef void *nns_edge_mcf_h;

#if defined(ENABLE_MCF)
#include <mcf.h>

/**
* @brief Create MCF handle.
*/
int nns_edge_mcf_create (nns_edge_mcf_h *handle);

/**
* @brief Connect to MCF.
* @note This is internal function for MCF.
*/
int nns_edge_mcf_connect (nns_edge_mcf_h handle, const char *id, const char *topic, const char *host, const int port);

/**
* @brief Release the MCF handle.
* @note This is internal function for MCF.
*/
int nns_edge_mcf_close (nns_edge_mcf_h handle);

/**
* @brief Start the MCF handle.
*/
int nns_edge_mcf_start (nns_edge_mcf_h handle);

/**
* @brief Publish raw data.
* @note This is internal function for MCF.
*/
int nns_edge_mcf_publish (nns_edge_mcf_h handle, const void *data, const int length);

/**
* @brief Set event callback for new message.
*/
int nns_edge_mcf_set_event_callback (nns_edge_mcf_h handle, nns_edge_event_cb cb, void *user_data);

/**
* @brief Check whether mcf handle exists or not.
*/
int nns_edge_mcf_is_connected (nns_edge_mcf_h handle);

/**
* @brief Internal util function to send edge-data.
*/
int nns_edge_mcf_send_data (nns_edge_mcf_h handle, nns_edge_data_h data_h);

/**
* @brief Internal util function to set MCF option.
*/
int nns_edge_mcf_set_option (nns_edge_mcf_h handle, const char *key, const char *value);

/**
* @brief Internal util function to get MCF option.
*/
const char *nns_edge_mcf_get_option (nns_edge_mcf_h handle, const char *key);

#else
#define nns_edge_mcf_create(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_publish(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_start(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_set_event_callback(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_is_connected(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_send_data(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_set_option(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_mcf_get_option(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#endif /* ENABLE_MCF */

#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __NNSTREAMER_EDGE_MCF_H__ */
8 changes: 8 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ TARGET_INCLUDE_DIRECTORIES(unittest_nnstreamer-edge-mqtt PRIVATE ${EDGE_REQUIRE_
TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge-mqtt ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME})
INSTALL (TARGETS unittest_nnstreamer-edge-mqtt DESTINATION ${BIN_INSTALL_DIR})
ENDIF()

# MCF test
IF(MCF_SUPPORT)
ADD_EXECUTABLE(unittest_nnstreamer-edge-mcf unittest_nnstreamer-edge-mcf.cc)
TARGET_INCLUDE_DIRECTORIES(unittest_nnstreamer-edge-mcf PRIVATE ${EDGE_REQUIRE_PKGS_INCLUDE_DIRS} ${INCLUDE_DIR} ${NNS_EDGE_SRC_DIR})
TARGET_LINK_LIBRARIES(unittest_nnstreamer-edge-mcf ${TEST_REQUIRE_PKGS_LDFLAGS} ${NNS_EDGE_LIB_NAME})
INSTALL (TARGETS unittest_nnstreamer-edge-mcf DESTINATION ${BIN_INSTALL_DIR})
ENDIF()
45 changes: 45 additions & 0 deletions tests/unittest_nnstreamer-edge-mcf.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @file unittest_nnstreamer-edge-mcf.cc
* @date 02 July 2024
* @brief Unittest for nnstreamer-edge MCF support.
* @see https://github.com/nnstreamer/nnstreamer-edge
* @author Gichan Jang <gichan2.jang@samsung.com>
* @bug No known bugs
*/

#include <gtest/gtest.h>
#include "nnstreamer-edge.h"
#include "nnstreamer-edge-mcf.h"
#include "nnstreamer-edge-log.h"
#include "nnstreamer-edge-util.h"

/**
* @brief Connect to local host, multiple clients.
*/
TEST(edgeMCF, createHandle)
{
GTEST_SKIP();
}

/**
* @brief Main gtest
*/
int
main (int argc, char **argv)
{
int result = -1;

try {
testing::InitGoogleTest (&argc, argv);
} catch (...) {
nns_edge_loge ("Caught exception, failed to init google test.");
}

try {
result = RUN_ALL_TESTS ();
} catch (...) {
nns_edge_loge ("Caught exception, failed to run the unittest.");
}

return result;
}
Loading