[Android] Add NO_AUDIO for video only case
authorjijoong.moon <jijoong.moon@samsung.com>
Mon, 4 Mar 2019 08:30:49 +0000 (17:30 +0900)
committerGeunsik Lim <leemgs@users.noreply.github.com>
Mon, 11 Mar 2019 05:45:15 +0000 (14:45 +0900)
There are the cases which has no needs for audio support. In order to
reduce shared library size, NO_AUDIO build Option is added.

**Changes proposed in this PR:**
- Addded NO_AUDIO option for build.
- Modify Android-app.mk and Android-nnstreamer.mk

**Self evaluation:**
1. Build test:  [X]Passed [ ]Failed [ ]Skipped
2. Run test:  [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
gst/nnstreamer/nnstreamer_plugin_api.h
gst/nnstreamer/no_audio_define.h [new file with mode: 0644]
gst/nnstreamer/tensor_aggregator/tensor_aggregator.h
gst/nnstreamer/tensor_common.c
gst/nnstreamer/tensor_common.h
gst/nnstreamer/tensor_converter/tensor_converter.h
jni/Android-app.mk
jni/Android-nnstreamer.mk
meson.build
meson_options.txt

index ff07c5f..d8d8bce 100644 (file)
@@ -29,7 +29,6 @@
 #include <glib.h>
 #include <gst/gst.h>
 #include <gst/video/video-format.h>
-#include <gst/audio/audio-format.h>
 #include <tensor_typedef.h>
 
 G_BEGIN_DECLS
diff --git a/gst/nnstreamer/no_audio_define.h b/gst/nnstreamer/no_audio_define.h
new file mode 100644 (file)
index 0000000..ee3e956
--- /dev/null
@@ -0,0 +1,90 @@
+/**
+ * NNStreamer Common API Header for Plug-Ins
+ * Copyright (C) 2019 Jijoong Moon <jijoong.moon@samsung.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ */
+/**
+ * @file  no_audio_define.h
+ * @date  07 Mar 2019
+ * @brief Define collection of audio variables and functions for no audio support
+ * @see https://github.com/nnsuite/nnstreamer
+ * @author  Jijoong Moon <jijoong.moon@samsung.com>
+ * @bug No known bugs except for NYI items
+ *
+ */
+#ifndef __NO_AUDIO_DEFINE_H__
+#define __NO_AUDIO_DEFINE_H__
+
+/**
+ * @brief Macro for gst_tensor_config_from_audio_info
+ */
+#define gst_tensor_config_from_audio_info(...) do { \
+    GST_ERROR ("\n This binary does not support audio type. Please build NNStreamer with disable-audio-support : false\n"); \
+    return FALSE; \
+  } while(0)
+
+/**
+ * @brief Macro for gst_audio_format_from_string
+ */
+#define gst_audio_format_from_string(...) GST_AUDIO_FORMAT_UNKNOWN
+
+/**
+ * @brief Macro for gst_audio_format_to_string
+ */
+#define gst_audio_format_to_string(...) "Unknown"
+
+/**
+ * @brief Macro for gst_audio_info_init
+ */
+#define gst_audio_info_init(...) do { \
+    GST_ERROR ("\n This binary does not support audio type. Please build NNStreamer with disable-audio-support : false\n"); \
+  } while(0)
+
+/**
+ * @brief Macro for gst_audio_info_from_caps
+ */
+#define gst_audio_info_from_caps(...) FALSE
+
+/**
+ * @brief Macro for GstAudioInfo structure
+ */
+#define GstAudioInfo gsize
+
+/**
+ * @brief Macro for GST_AUDIO_INFO_BPF
+ */
+#define GST_AUDIO_INFO_BPF(...) 1
+
+/**
+ * @brief GstAudioFormat ( There are more variables in audio-format.h )
+ */
+typedef enum _GstAudioFormat
+{
+  GST_AUDIO_FORMAT_UNKNOWN,
+  GST_AUDIO_FORMAT_S8,
+  GST_AUDIO_FORMAT_U8,
+  GST_AUDIO_FORMAT_S16,
+  GST_AUDIO_FORMAT_U16,
+  GST_AUDIO_FORMAT_S32,
+  GST_AUDIO_FORMAT_U32,
+  GST_AUDIO_FORMAT_F32,
+  GST_AUDIO_FORMAT_F64
+} GstAudioFormat;
+
+/**
+ * @brief Macro for GST_AUDIO_CAPS_MAKE
+ */
+#define GST_AUDIO_CAPS_MAKE(format) \
+      "audio/x-raw, " \
+          "format = (string) " format
+#endif
index f250422..17ad58c 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gst/gst.h>
 #include <tensor_common.h>
+#include <gst/base/gstadapter.h>
 
 G_BEGIN_DECLS
 
index ebcb096..e9bb5c3 100644 (file)
@@ -693,8 +693,10 @@ gst_tensor_config_from_video_info (GstTensorConfig * config,
  * @note Change dimention if tensor contains N frames.
  * @return TRUE if supported type
  */
-static gboolean
-gst_tensor_config_from_audio_info (GstTensorConfig * config,
+
+__attribute__ ((unused))
+     static gboolean
+         _gst_tensor_config_from_audio_info (GstTensorConfig * config,
     const GstStructure * structure)
 {
   /**
index 4a6782e..29715d2 100644 (file)
 #define nns_memset memset
 #endif
 
+#ifdef NO_AUDIO
+#include <no_audio_define.h>
+#else
+#include <gst/audio/audio-info.h>
+#include <gst/audio/audio-format.h>
+#define gst_tensor_config_from_audio_info(...) _gst_tensor_config_from_audio_info(__VA_ARGS__)
+#endif
+
 G_BEGIN_DECLS
 
 /**
index 28a65e3..7bc25c2 100644 (file)
@@ -36,7 +36,6 @@
 
 #include <gst/gst.h>
 #include <gst/video/video-info.h>
-#include <gst/audio/audio-info.h>
 #include <tensor_common.h>
 
 G_BEGIN_DECLS
index 6f1721d..ba07966 100644 (file)
@@ -19,6 +19,7 @@ LOCAL_PATH := $(call my-dir)
 NNSTREAMER_VERSION := 0.1.1
 CUSTOM_LINKER64    := -fPIE -pie -Wl,-dynamic-linker,/data/nnstreamer/libandroid/linker64
 
+NO_AUDIO := false
 
 # Do not specify "TARGET_ARCH_ABI" in this file. If you want to append additional architecture,
 # Please append an architecture name behind "APP_ABI" in Application.mk file.
@@ -55,30 +56,42 @@ define shared_lib_gst
 endef
 
 # Describe shared libraries that are needed to run this application.
-so_names_common := gstreamer-1.0 gstbase-1.0 gstaudio-1.0 gstvideo-1.0 glib-2.0 \
+so_names_common := gstreamer-1.0 gstbase-1.0 gstvideo-1.0 glib-2.0 \
                    gobject-2.0 intl z bz2 orc-0.4 gmodule-2.0 ffi gsttag-1.0 iconv \
-                   gstapp-1.0 png16 gstbadaudio-1.0 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \
+                   gstapp-1.0 png16 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \
                    pangoft2-1.0 pango-1.0 gthread-2.0 cairo pixman-1 fontconfig expat freetype \
                    gstbadvideo-1.0 gstcontroller-1.0 jpeg graphene-1.0 gstpbutils-1.0 gstgl-1.0 \
                    gstallocators-1.0 gstbadallocators-1.0 harfbuzz
+
+ifeq ($(NO_AUDIO), false)
+so_names_common += gstaudio-1.0 gstbadaudio-1.0
+endif
+
 $(foreach item,$(so_names_common),$(eval $(call shared_lib_common,$(item))))
 
-so_names_gst := gstcoreelements gstcoretracers gstadder gstapp gstaudioconvert \
-                gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc gstgio \
+so_names_gst := gstcoreelements gstcoretracers gstadder gstapp \
                 gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate \
                 gstvideoscale gstvideotestsrc gstvolume gstautodetect gstvideofilter gstopengl \
                 gstopensles gstcompositor gstpng gstmultifile nnstreamer
-$(foreach item,$(so_names_gst),$(eval $(call shared_lib_gst,$(item))))
 
+ifeq ($(NO_AUDIO), false)
+so_names_gst += gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc
+endif
 
-BUILDING_BLOCK_LIST := gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \
-gstapp gstaudioconvert gstaudiomixer gstaudioresample gstaudiorate gstaudioresample gstaudiotestsrc gstgio \
+$(foreach item,$(so_names_gst),$(eval $(call shared_lib_gst,$(item))))
+
+BUILDING_BLOCK_LIST := z gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \
+gstapp gstgio \
 gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate gstvideoscale gstvideotestsrc \
 gstvolume gstautodetect gstvideofilter gstopengl gstopensles gmodule-2.0 gstcompositor ffi iconv png multifile \
-gstbase-1.0 gstaudio-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badaudio badbase-1.0 gio-2.0 pangocairo  pango gthread \
+gstbase-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badbase-1.0 gio-2.0 pangocairo  pango gthread \
 cairo pixman fontconfig expat gstbadvideo gstcontroller jpeg graphene gstpbutils gstgl gstallocators gstbadallocators \
 harfbuzz bz2 nnstreamer
 
+ifeq ($(NO_AUDIO), false)
+BUILDING_BLOCK_LIST += gstaudio-1.0 gstbadaudio-1.0 gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc
+endif
+
 # In case of Android ARM 64bit environment, the default path of linker is "/data/nnstreamer/".
 # We use the "tests/nnstreamer_repo_dynamicity/tensor_repo_dynamic_test.c" file as a test application.
 # This application is dependent on 'multifilesrc' and 'png' element that are provided by Gstreamer.
index 0581b20..716b4b9 100644 (file)
@@ -28,6 +28,7 @@ LOCAL_PATH := $(call my-dir)
 #
 
 NNSTREAMER_VERSION := 0.1.2
+NO_AUDIO := false
 
 # Do not specify "TARGET_ARCH_ABI" in this file. If you want to append additional architecture,
 # Please append an architecture name behind "APP_ABI" in Application.mk file.
@@ -64,22 +65,44 @@ define shared_lib_gst
 endef
 
 # Describe shared libraries that are needed to run this application.
-so_names_common := gstreamer-1.0 gstbase-1.0 gstaudio-1.0 gstvideo-1.0 glib-2.0 \
+
+so_names_common := gstreamer-1.0 gstbase-1.0 gstvideo-1.0 glib-2.0 \
                    gobject-2.0 intl z bz2 orc-0.4 gmodule-2.0 ffi gsttag-1.0 iconv \
-                   gstapp-1.0 png16 gstbadaudio-1.0 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \
+                   gstapp-1.0 png16 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \
                    pangoft2-1.0 pango-1.0 gthread-2.0 cairo pixman-1 fontconfig expat freetype \
                    gstbadvideo-1.0 gstcontroller-1.0 jpeg graphene-1.0 gstpbutils-1.0 gstgl-1.0 \
-                   gstbadallocators-1.0 harfbuzz
+                   gstallocators-1.0 gstbadallocators-1.0 harfbuzz
+
+ifeq ($(NO_AUDIO), false)
+so_names_common += gstaudio-1.0 gstbadaudio-1.0
+endif
+
 $(foreach item,$(so_names_common),$(eval $(call shared_lib_common,$(item))))
 
-so_names_gst := gstcoreelements gstcoretracers gstadder gstapp gstaudioconvert \
-                gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc gstgio \
+so_names_gst := gstcoreelements gstcoretracers gstadder gstapp \
                 gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate \
                 gstvideoscale gstvideotestsrc gstvolume gstautodetect gstvideofilter gstopengl \
                 gstopensles gstcompositor gstpng gstmultifile
+
+ifeq ($(NO_AUDIO), false)
+so_names_gst += gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc
+endif
+
 $(foreach item,$(so_names_gst),$(eval $(call shared_lib_gst,$(item))))
 
 
+BUILDING_BLOCK_LIST := gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \
+gstapp \
+gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate gstvideoscale gstvideotestsrc \
+gstvolume gstautodetect gstvideofilter gstopengl gstopensles gmodule-2.0 gstcompositor ffi iconv png multifile \
+gstbase-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badbase-1.0 pangocairo  pango gthread \
+cairo pixman fontconfig expat gstbadvideo gstcontroller jpeg graphene gstpbutils gstgl gstallocators gstbadallocators \
+harfbuzz bz2
+
+ifeq ($(NO_AUDIO), false)
+BUILDING_BLOCK_LIST += gstaudio-1.0 gstbadaudio-1.0 gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc
+endif
+
 include $(CLEAR_VARS)
 
 # Please keep the pthread and openmp library for checking a compatibility
@@ -88,6 +111,11 @@ LOCAL_CFLAGS        += -O0 -DVERSION=\"$(NNSTREAMER_VERSION)\"
 LOCAL_CXXFLAGS      += -std=c++11
 LOCAL_CFLAGS        += -pthread -fopenmp
 
+ifeq ($(NO_AUDIO), true)
+LOCAL_CFLAGS += -DNO_AUDIO
+LOCAL_CXXFLAGS += -DNO_AUDIO
+endif
+
 LOCAL_LDFLAGS       += -fuse-ld=bfd
 LOCAL_MODULE_TAGS   := optional
 
@@ -129,12 +157,12 @@ LOCAL_C_INCLUDES := $(NNSTREAMER_GST_HOME)/ \
        $(NNSTREAMER_GST_HOME)/tensor_transform/
 
 BUILDING_BLOCK_LIST := gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \
-gstapp gstaudioconvert gstaudiomixer gstaudioresample gstaudiorate gstaudioresample gstaudiotestsrc gstgio \
+gstapp gstaudioconvert gstaudiomixer gstaudioresample gstaudiorate gstaudioresample gstaudiotestsrc \
 gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate gstvideoscale gstvideotestsrc \
 gstvolume gstautodetect gstvideofilter gstopengl gstopensles gmodule-2.0 gstcompositor ffi iconv png multifile \
-gstbase-1.0 gstaudio-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badaudio badbase-1.0 gio-2.0 pangocairo  pango gthread \
+gstbase-1.0 gstaudio-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badaudio badbase-1.0 pangocairo  pango gthread \
  cairo pixman fontconfig expat gstbadvideo gstcontroller jpeg graphene gstpbutils gstgl gstbadallocators \
-gstallocators harfbuzz bz2
+gstallocators harfbuzz bz2 z
 
 LOCAL_C_INCLUDES += $(GSTREAMER_ROOT)/include/gstreamer-1.0 \
      $(GSTREAMER_ROOT)/include/glib-2.0 \
index fab7f99..b3831b1 100644 (file)
@@ -75,6 +75,15 @@ else
   add_project_arguments('-DDISABLE_ORC=1', language: ['c', 'cpp'])
 endif
 
+# NO Audio support
+disable_audio = false
+
+if get_option('disable-audio-support')
+   disable_audio = true
+   add_project_arguments('-DNO_AUDIO=1', language: ['c', 'cpp'])
+   message('Disable Audio Type Support')
+endif
+
 # Tensorflow
 have_tensorflow = false
 
index 3bb31f7..23f8d33 100644 (file)
@@ -2,3 +2,4 @@ option('enable-test', type: 'boolean', value: true)
 option('enable-tensorflow-lite', type: 'boolean', value: true)
 option('enable-tensorflow', type: 'boolean', value: true)
 option('install-example', type: 'boolean', value: false)
+option('disable-audio-support', type: 'boolean', value: false)