[Filter:*] Migrate subplugins to ext
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 29 Jan 2019 09:33:47 +0000 (18:33 +0900)
committerwooksong <wook16.song@samsung.com>
Fri, 8 Feb 2019 07:05:16 +0000 (17:05 +1000)
Filter subplugins that have external dependencies are
fully detached from Filter:main now.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
14 files changed:
debian/nnstreamer-dev.install
debian/nnstreamer.install
ext/nnstreamer/tensor_filter/meson.build [new file with mode: 0644]
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow.c [moved from gst/nnstreamer/tensor_filter/tensor_filter_tensorflow.c with 100% similarity]
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc [moved from gst/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc with 100% similarity]
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h [moved from gst/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h with 100% similarity]
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c [moved from gst/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c with 100% similarity]
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc [moved from gst/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc with 100% similarity]
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h [moved from gst/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h with 100% similarity]
gst/nnstreamer/nnstreamer_subplugin.c
gst/nnstreamer/nnstreamer_subplugin.h
gst/nnstreamer/tensor_filter/meson.build
meson.build
packaging/nnstreamer.spec

index a1d0db6..d27b4ab 100644 (file)
@@ -1,5 +1,5 @@
 /usr/include/nnstreamer/*.h
 /usr/lib/*/pkgconfig/*.pc
 /usr/lib/*/libnnstreamer.a
-/usr/lib/*/libtensor_filter*.a
+/usr/lib/*/libnnstreamer_filter*.a
 /usr/lib/*/libnnstreamer_plugin_api.a
index dc12a8c..2b52fbd 100644 (file)
@@ -1,4 +1,4 @@
-/usr/lib/*/libtensor_filter_*.so
+/usr/lib/nnstreamer/filters/libnnstreamer_filter_*.so
 /usr/lib/*/gstreamer-1.0/*.so
 /usr/lib/*/libnnstreamer_plugin_api.so
 /etc/nnstreamer.ini
diff --git a/ext/nnstreamer/tensor_filter/meson.build b/ext/nnstreamer/tensor_filter/meson.build
new file mode 100644 (file)
index 0000000..616251b
--- /dev/null
@@ -0,0 +1,52 @@
+
+if have_tensorflow
+  tensor_filter_tfcore_lib_shared = shared_library('nnstreamer_filter_tensorflow',
+      [
+        'tensor_filter_tensorflow_core.cc',
+        'tensor_filter_tensorflow.c'
+      ],
+    cpp_args: ['-Wno-sign-compare'],
+    dependencies: [tf_dep, protobuf_dep, nnstreamer_dep],
+    include_directories: nnstreamer_inc,
+    install: true,
+    install_dir: join_paths(subplugin_install_prefix, 'filters')
+  )
+
+  tensor_filter_tfcore_lib_static = static_library('nnstreamer_filter_tensorflow',
+      [
+        'tensor_filter_tensorflow_core.cc',
+        'tensor_filter_tensorflow.c'
+      ],
+    cpp_args: ['-Wno-sign-compare'],
+    dependencies: [tf_dep, protobuf_dep, nnstreamer_dep],
+    include_directories: nnstreamer_inc,
+    install: true,
+    install_dir: nnstreamer_libdir
+  )
+endif
+
+if have_tensorflow_lite
+  tensor_filter_tflitecore_lib_shared = shared_library('nnstreamer_filter_tensorflow-lite',
+      [
+        'tensor_filter_tensorflow_lite_core.cc',
+        'tensor_filter_tensorflow_lite.c'
+      ],
+    cpp_args: ['-Wno-sign-compare'],
+    dependencies: [tflite_dep, nnstreamer_dep],
+    include_directories: nnstreamer_inc,
+    install: true,
+    install_dir: join_paths(subplugin_install_prefix, 'filters')
+  )
+
+  tensor_filter_tflitecore_lib_static = static_library('nnstreamer_filter_tensorflow-lite',
+      [
+        'tensor_filter_tensorflow_lite_core.cc',
+        'tensor_filter_tensorflow_lite.c'
+      ],
+    cpp_args: ['-Wno-sign-compare'],
+    dependencies: [tflite_dep, nnstreamer_dep],
+    include_directories: nnstreamer_inc,
+    install: true,
+    install_dir: nnstreamer_libdir
+  )
+endif
index f1943e6..a3e1abe 100644 (file)
@@ -65,13 +65,19 @@ _heldsp_destroy (gpointer _data)
  * @brief API to notify subplugin-manager that this subplugin is handled already.
  */
 void
-hold_register_subplugin (subpluginType type, const char *name, void *data)
+hold_register_subplugin (subpluginType type, const char *name, const void *data)
 {
+  holdplugins *ptr;
+
   if (held_subplugins[type] == NULL)
     held_subplugins[type] =
         g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
         _heldsp_destroy);
-  g_hash_table_insert (held_subplugins[type], g_strdup (name), data);
+
+  ptr = g_new (holdplugins, 1);
+  ptr->name = g_strdup (name);
+  ptr->data = data;
+  g_hash_table_insert (held_subplugins[type], g_strdup (name), ptr);
 }
 
 /**
@@ -80,9 +86,15 @@ hold_register_subplugin (subpluginType type, const char *name, void *data)
 static const void *
 check_held_subplugin (subpluginType type, const char *name)
 {
+  holdplugins *ptr;
+
   if (held_subplugins[type] == NULL)
     return NULL;
-  return g_hash_table_lookup (held_subplugins[type], name);
+  ptr = g_hash_table_lookup (held_subplugins[type], name);
+
+  if (ptr)
+    return ptr->data;
+  return NULL;
 }
 
 /** @brief Private function for g_hash_table data destructor, GDestroyNotify */
index 0ee8e72..e82825f 100644 (file)
@@ -90,6 +90,7 @@ unregister_subplugin (subpluginType type, const char *name);
 /**
  * @brief Call this at subplugin probe to avoid duplicated registration
  */
-extern void hold_register_subplugin (subpluginType type, const char *name, void *data);
+extern void
+hold_register_subplugin (subpluginType type, const char *name, const void *data);
 
 #endif /* __GST_NNSTREAMER_SUBPLUGIN_H__ */
index 5e3a8cd..03ee8d7 100644 (file)
@@ -3,66 +3,6 @@ tensor_filter_sources = [
   'tensor_filter_custom.c'
 ]
 
-if have_tensorflow
-  tensor_filter_sources += ['tensor_filter_tensorflow.c']
-
-  tensor_filter_tfcore_lib_shared = shared_library('tensor_filter_tensorflow',
-    ['tensor_filter_tensorflow_core.cc'],
-    cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tf_dep, protobuf_dep, glib_dep, gst_dep],
-    include_directories: nnstreamer_inc,
-    install: true,
-    install_dir: subplugins_install_dir
-  )
-
-  tensor_filter_tfcore_lib_static = static_library('tensor_filter_tensorflow',
-    ['tensor_filter_tensorflow_core.cc'],
-    cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tf_dep, protobuf_dep, glib_dep, gst_dep],
-    include_directories: nnstreamer_inc,
-    install: true,
-    install_dir: subplugins_install_dir
-  )
-
-  tensor_filter_tfcore_lib = tensor_filter_tfcore_lib_shared
-  if get_option('default_library') == 'static'
-    tensor_filter_tfcore_lib = tensor_filter_tfcore_lib_static
-  endif
-
-  tensor_filter_tfcore_dep = declare_dependency(link_with: tensor_filter_tfcore_lib)
-  nnstreamer_extra_deps += tensor_filter_tfcore_dep
-endif
-
-if have_tensorflow_lite
-  tensor_filter_sources += ['tensor_filter_tensorflow_lite.c']
-
-  tensor_filter_tflitecore_lib_shared = shared_library('tensor_filter_tensorflow-lite',
-    ['tensor_filter_tensorflow_lite_core.cc'],
-    cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tflite_dep, thread_dep, libdl_dep, glib_dep, gst_dep],
-    include_directories: nnstreamer_inc,
-    install: true,
-    install_dir: subplugins_install_dir
-  )
-
-  tensor_filter_tflitecore_lib_static = static_library('tensor_filter_tensorflow-lite',
-    ['tensor_filter_tensorflow_lite_core.cc'],
-    cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tflite_dep, thread_dep, libdl_dep, glib_dep, gst_dep],
-    include_directories: nnstreamer_inc,
-    install: true,
-    install_dir: subplugins_install_dir
-  )
-
-  tensor_filter_tflitecore_lib = tensor_filter_tflitecore_lib_shared
-  if get_option('default_library') == 'static'
-    tensor_filter_tflitecore_lib = tensor_filter_tflitecore_lib_static
-  endif
-
-  tensor_filter_tflitecore_dep = declare_dependency(link_with: tensor_filter_tflitecore_lib)
-  nnstreamer_extra_deps += tensor_filter_tflitecore_dep
-endif
-
 foreach s : tensor_filter_sources
   nnstreamer_sources += join_paths(meson.current_source_dir(), s)
 endforeach
index ace3779..1123e8a 100644 (file)
@@ -106,6 +106,9 @@ endif
 # Build nnstreamer (common, plugins)
 subdir('gst')
 
+# Build ext subplugins (filter-subplugins)
+subdir('ext/nnstreamer/tensor_filter')
+
 # Build nnstreamer examples
 if get_option('enable-test') or get_option('install-example')
   subdir('nnstreamer_example')
index b799131..e06a239 100644 (file)
@@ -110,6 +110,7 @@ ninja -C build %{?_smp_mflags}
     ./tests/unittest_sink --gst-plugin-path=.
     ./tests/unittest_plugins --gst-plugin-path=.
     popd
+    export NNSTREAMER_FILTERS=$(pwd)/build/ext/nnstreamer/tensor_filter
     pushd tests
     ssat -n
     popd
@@ -160,7 +161,7 @@ cp -r result %{buildroot}%{_datadir}/nnstreamer/unittest/
 %manifest nnstreamer.manifest
 %defattr(-,root,root,-)
 %license LICENSE
-%{_libdir}/libtensor_filter_*.so
+%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_*.so
 %{gstlibdir}/*.so
 %{_libdir}/libnnstreamer_plugin_api.so
 %{_sysconfdir}/nnstreamer.ini