Skip to content

Commit

Permalink
Exported nnstreamer C++ symbols to fix onnxruntime build
Browse files Browse the repository at this point in the history
  • Loading branch information
ep-tpstevens committed Nov 1, 2024
1 parent febbaf2 commit 608fbda
Show file tree
Hide file tree
Showing 24 changed files with 193 additions and 184 deletions.
20 changes: 10 additions & 10 deletions ext/nnstreamer/extra/nnstreamer_python3_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,31 @@ extern "C" {
#define PyEval_InitThreads_IfGood() do { PyEval_InitThreads(); } while (0)
#endif

NNS_API_EXPORT tensor_type getTensorType (NPY_TYPES npyType);
NNS_API_EXPORT NPY_TYPES getNumpyType (tensor_type tType);
NNS_API_EXPORT int loadScript (PyObject **core_obj, const gchar *module_name, const gchar *class_name);
NNS_API_EXPORT int openPythonLib (void **handle);
NNS_API_EXPORT int addToSysPath (const gchar *path);
NNS_API_EXPORT int parseTensorsInfo (PyObject *result, GstTensorsInfo *info);
NNS_API_EXPORT PyObject * PyTensorShape_New (PyObject * shape_cls, const GstTensorInfo *info);
NNS_API tensor_type getTensorType (NPY_TYPES npyType);
NNS_API NPY_TYPES getNumpyType (tensor_type tType);
NNS_API int loadScript (PyObject **core_obj, const gchar *module_name, const gchar *class_name);
NNS_API int openPythonLib (void **handle);
NNS_API int addToSysPath (const gchar *path);
NNS_API int parseTensorsInfo (PyObject *result, GstTensorsInfo *info);
NNS_API PyObject * PyTensorShape_New (PyObject * shape_cls, const GstTensorInfo *info);

/**
* @brief Py_Initialize common wrapper for Python subplugins
* @note This prevents a python-using subplugin finalizing another subplugin's python interpreter by sharing the reference counter.
*/
NNS_API_EXPORT void nnstreamer_python_init_refcnt ();
NNS_API void nnstreamer_python_init_refcnt ();

/**
* @brief Py_Finalize common wrapper for Python subplugins
* @note This prevents a python-using subplugin finalizing another subplugin's python interpreter by sharing the reference counter.
*/
NNS_API_EXPORT void nnstreamer_python_fini_refcnt ();
NNS_API void nnstreamer_python_fini_refcnt ();

/**
* @brief Check Py_Init status for python eval functions.
* @return 0 if it's ready. negative error value if it's not ready.
*/
NNS_API_EXPORT int nnstreamer_python_status_check ();
NNS_API int nnstreamer_python_status_check ();

#ifdef __cplusplus
} /* extern "C" */
Expand Down
8 changes: 4 additions & 4 deletions ext/nnstreamer/tensor_decoder/tensordecutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ typedef struct {
guint max_word_length; /**< The max size of labels */
} imglabel_t;

NNS_API_EXPORT void
NNS_API void
loadImageLabels (const char * label_path, imglabel_t *l);

NNS_API_EXPORT void
NNS_API void
initSingleLineSprite (singleLineSprite_t v, rasters_t r, uint32_t pv);

NNS_API_EXPORT void _free_labels (imglabel_t *data);
NNS_API void _free_labels (imglabel_t *data);

NNS_API_EXPORT void setFramerateFromConfig (GstCaps *caps, const GstTensorsConfig * config);
NNS_API void setFramerateFromConfig (GstCaps *caps, const GstTensorsConfig * config);

#ifdef __cplusplus
}
Expand Down
6 changes: 4 additions & 2 deletions ext/nnstreamer/tensor_filter/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,15 @@ if onnxruntime_support_is_available
filter_sub_onnxruntime_sources,
dependencies: nnstreamer_filter_onnxruntime_deps,
install: true,
install_dir: filter_subplugin_install_dir
install_dir: filter_subplugin_install_dir,
cpp_args: '-DNNS_API_IMPORTS=1'
)

static_library('nnstreamer_filter_onnxruntime',
filter_sub_onnxruntime_sources,
dependencies: nnstreamer_filter_onnxruntime_deps,
install: true,
install_dir: nnstreamer_libdir
install_dir: nnstreamer_libdir,
cpp_args: '-DNNS_API_IMPORTS=1'
)
endif
4 changes: 2 additions & 2 deletions gst/nnstreamer/elements/gsttensor_sparseutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ G_BEGIN_DECLS
* @param[in] mem gst-memory of sparse tensor data
* @return pointer of GstMemory with dense tensor data or NULL on error. Caller should handle this newly allocated memory.
*/
NNS_API_EXPORT GstMemory *
NNS_API GstMemory *
gst_tensor_sparse_to_dense (GstTensorMetaInfo * meta, GstMemory * mem);

/**
Expand All @@ -36,7 +36,7 @@ gst_tensor_sparse_to_dense (GstTensorMetaInfo * meta, GstMemory * mem);
* @param[in] mem gst-memory of dense tensor data
* @return pointer of GstMemory with sparse tensor data or NULL on error. Caller should handle this newly allocated memory.
*/
NNS_API_EXPORT GstMemory *
NNS_API GstMemory *
gst_tensor_sparse_from_dense (GstTensorMetaInfo * meta, GstMemory * mem);

G_END_DECLS
Expand Down
10 changes: 8 additions & 2 deletions gst/nnstreamer/include/nnstreamer_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
# define _NNS_IMPORT
#endif

#define NNS_API_EXPORT _NNS_EXPORT extern
#define NNS_API_IMPORT _NNS_IMPORT extern
// TODO: this is backwards and should be inverted
// Did this to avoid having to track down all the libraries that produce headers with NNS_API
// for the purposes of the prototype
#ifdef NNS_API_IMPORTS
#define NNS_API _NNS_IMPORT
#else
#define NNS_API _NNS_EXPORT
#endif

#endif
3 changes: 2 additions & 1 deletion gst/nnstreamer/include/nnstreamer_cppplugin_api_filter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#ifdef __cplusplus

#include <assert.h>
#include <nnstreamer_api.h>
#include <nnstreamer_plugin_api_filter.h>
#include <stdexcept>
#include <stdint.h>
Expand Down Expand Up @@ -65,7 +66,7 @@ namespace nnstreamer
*
* We support tensor_filter_subplugin V1 only. (NNStreamer 1.5.1 or higher)
**/
class tensor_filter_subplugin
class NNS_API tensor_filter_subplugin
{
private: /** Derived classes should NEVER access these */
const uint64_t sanity; /**< Checks if dlopened obejct is really tensor_filter_subplugin */
Expand Down
28 changes: 14 additions & 14 deletions gst/nnstreamer/include/nnstreamer_plugin_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ G_BEGIN_DECLS
* @param structure structure to be interpreted
* @return TRUE if mimetype is tensor stream
*/
NNS_API_EXPORT gboolean
NNS_API gboolean
gst_structure_is_tensor_stream (const GstStructure * structure);

/**
* @brief Get media type from structure
* @param structure structure to be interpreted
* @return corresponding media type (returns _NNS_MEDIA_INVALID for unsupported type)
*/
NNS_API_EXPORT media_type
NNS_API media_type
gst_structure_get_media_type (const GstStructure * structure);

/**
Expand All @@ -46,7 +46,7 @@ gst_structure_get_media_type (const GstStructure * structure);
* @param structure structure to be interpreted
* @return TRUE if no error
*/
NNS_API_EXPORT gboolean
NNS_API gboolean
gst_tensors_config_from_structure (GstTensorsConfig *config,
const GstStructure *structure);

Expand All @@ -57,7 +57,7 @@ gst_tensors_config_from_structure (GstTensorsConfig *config,
* @param is_fixed flag to be updated when peer caps is fixed (not mandatory, do nothing when the param is null)
* @return TRUE if successfully configured from peer
*/
NNS_API_EXPORT gboolean
NNS_API gboolean
gst_tensors_config_from_peer (GstPad * pad, GstTensorsConfig * config,
gboolean * is_fixed);

Expand All @@ -66,22 +66,22 @@ gst_tensors_config_from_peer (GstPad * pad, GstTensorsConfig * config,
* @param config tensors config info
* @return caps for given config
*/
NNS_API_EXPORT GstCaps *
NNS_API GstCaps *
gst_tensor_caps_from_config (const GstTensorsConfig * config);

/**
* @brief Get caps from tensors config (for other/tensors)
* @param config tensors config info
* @return caps for given config
*/
NNS_API_EXPORT GstCaps *
NNS_API GstCaps *
gst_tensors_caps_from_config (const GstTensorsConfig * config);

/**
* @brief set alignment that default allocator would align to
* @param alignment bytes of alignment
*/
NNS_API_EXPORT void
NNS_API void
gst_tensor_alloc_init (gsize alignment);

/**
Expand All @@ -90,7 +90,7 @@ gst_tensor_alloc_init (gsize alignment);
* @param[in] mem pointer to GstMemory to be parsed
* @return TRUE if successfully set the meta
*/
NNS_API_EXPORT gboolean
NNS_API gboolean
gst_tensor_meta_info_parse_memory (GstTensorMetaInfo * meta, GstMemory * mem);

/**
Expand All @@ -99,15 +99,15 @@ gst_tensor_meta_info_parse_memory (GstTensorMetaInfo * meta, GstMemory * mem);
* @param[in] mem pointer to GstMemory
* @return Newly allocated GstMemory (Caller should free returned memory using gst_memory_unref())
*/
NNS_API_EXPORT GstMemory *
NNS_API GstMemory *
gst_tensor_meta_info_append_header (GstTensorMetaInfo * meta, GstMemory * mem);

/**
* @brief Update caps dimension for negotiation
* @param caps caps to compare and update
* @param filter caps to compare
*/
NNS_API_EXPORT void
NNS_API void
gst_tensor_caps_update_dimension (GstCaps *caps, GstCaps *filter);

/**
Expand All @@ -116,7 +116,7 @@ gst_tensor_caps_update_dimension (GstCaps *caps, GstCaps *filter);
* @param caps2 a GstCaps to intersect
* @return TRUE if intersection would be not empty.
*/
NNS_API_EXPORT gboolean
NNS_API gboolean
gst_tensor_caps_can_intersect (GstCaps *caps1, GstCaps *caps2);

/**
Expand All @@ -125,7 +125,7 @@ gst_tensor_caps_can_intersect (GstCaps *caps1, GstCaps *caps2);
* @param[in] index Index of GstMemory to be returned.
* @return GstMemory if found, otherwise NULL (Caller should free returned memory using gst_memory_unref()).
*/
NNS_API_EXPORT GstMemory *
NNS_API GstMemory *
gst_tensor_buffer_get_nth_memory (GstBuffer * buffer, const guint index);

/**
Expand All @@ -135,13 +135,13 @@ gst_tensor_buffer_get_nth_memory (GstBuffer * buffer, const guint index);
* @param[in] info GstTensorInfo of given @a memory.
* @return TRUE if successfully appended, otherwise FALSE.
*/
NNS_API_EXPORT gboolean
NNS_API gboolean
gst_tensor_buffer_append_memory (GstBuffer * buffer, GstMemory * memory, const GstTensorInfo * info);

/**
* @brief Get the number of tensors in the buffer.
*/
NNS_API_EXPORT guint
NNS_API guint
gst_tensor_buffer_get_count (GstBuffer * buffer);

G_END_DECLS
Expand Down
8 changes: 4 additions & 4 deletions gst/nnstreamer/include/nnstreamer_plugin_api_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,26 @@ typedef struct _NNStreamerExternalConverter
* @return NNStreamerExternalConverter if subplugin is found.
* NULL if not found or the sub-plugin object has an error.
*/
NNS_API_EXPORT const NNStreamerExternalConverter *
NNS_API const NNStreamerExternalConverter *
nnstreamer_converter_find (const char *name);

/**
* @brief Converter's sub-plugin should call this function to register itself.
* @param[in] ex Converter sub-plugin to be registered.
* @return TRUE if registered. FALSE is failed or duplicated.
*/
NNS_API_EXPORT int registerExternalConverter (NNStreamerExternalConverter * ex);
NNS_API int registerExternalConverter (NNStreamerExternalConverter * ex);

/**
* @brief Converter's sub-plugin may call this to unregister itself.
* @param[in] prefix The name of converter sub-plugin.
*/
NNS_API_EXPORT void unregisterExternalConverter (const char *prefix);
NNS_API void unregisterExternalConverter (const char *prefix);

/**
* @brief set custom property description for tensor converter sub-plugin
*/
NNS_API_EXPORT void
NNS_API void
nnstreamer_converter_set_custom_property_desc (const char *name, const char *prop, ...);

#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions gst/nnstreamer/include/nnstreamer_plugin_api_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,28 @@ typedef struct _GstTensorDecoderDef
* @param[in] decoder Decoder sub-plugin to be registered.
* @return TRUE if registered. FALSE is failed or duplicated.
*/
NNS_API_EXPORT int
NNS_API int
nnstreamer_decoder_probe (GstTensorDecoderDef * decoder);

/**
* @brief Decoder's sub-plugin may call this to unregister itself.
* @param[in] name The name of decoder sub-plugin.
*/
NNS_API_EXPORT void
NNS_API void
nnstreamer_decoder_exit (const char *name);

/**
* @brief Find decoder sub-plugin with the name.
* @param[in] name The name of decoder sub-plugin.
* @return NULL if not found or the sub-plugin object has an error.
*/
NNS_API_EXPORT const GstTensorDecoderDef *
NNS_API const GstTensorDecoderDef *
nnstreamer_decoder_find (const char *name);

/**
* @brief set custom property description for tensor decoder sub-plugin
*/
NNS_API_EXPORT void
NNS_API void
nnstreamer_decoder_set_custom_property_desc (const char *name, const char *prop, ...);

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 608fbda

Please sign in to comment.