[0.6.243] Remove libmm-utility dependency 91/245191/9
authorEunhye Choi <eunhae1.choi@samsung.com>
Mon, 5 Oct 2020 07:45:17 +0000 (16:45 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Tue, 6 Oct 2020 06:05:26 +0000 (15:05 +0900)
- remove libmm-utility dependency for headless

Change-Id: I17e4b36aec0784187049b4e7469759c7c63158ec

configure.ac
packaging/libmm-player.spec
src/Makefile.am
src/include/mm_player_priv.h
src/mm_player_capture.c
src/mm_player_priv.c
unittest/Makefile.am

index c80bf5b..3b591e2 100644 (file)
@@ -55,6 +55,10 @@ PKG_CHECK_MODULES(GLIB, glib-2.0)
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
+PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
+AC_SUBST(GMODULE_CFLAGS)
+AC_SUBST(GMODULE_LIBS)
+
 PKG_CHECK_MODULES(GST, gstreamer-1.0 >= 1.2.0)
 AC_SUBST(GST_CFLAGS)
 AC_SUBST(GST_LIBS)
@@ -79,14 +83,9 @@ PKG_CHECK_MODULES(TZPLATFORM_CONFIG, libtzplatform-config)
 AC_SUBST(TZPLATFORM_CONFIG_CFLAGS)
 AC_SUBST(TZPLATFORM_CONFIG_LIBS)
 
-# for testsuite
+# refer header
 PKG_CHECK_MODULES(MMUTIL_COMMON, mmutil-common)
 AC_SUBST(MMUTIL_COMMON_CFLAGS)
-AC_SUBST(MMUTIL_COMMON_LIBS)
-
-PKG_CHECK_MODULES(MMUTIL, mmutil-imgp)
-AC_SUBST(MMUTIL_CFLAGS)
-AC_SUBST(MMUTIL_LIBS)
 
 PKG_CHECK_MODULES(INIPARSER, iniparser)
 AC_SUBST(INIPARSER_CFLAGS)
index 3a70d7d..4768650 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.242
+Version:    0.6.243
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
@@ -10,6 +10,8 @@ Source1001:     libmm-player.manifest
 Requires(post):  /sbin/ldconfig
 Requires(postun):  /sbin/ldconfig
 BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gmodule-2.0)
 BuildRequires:  pkgconfig(mm-common)
 BuildRequires:  pkgconfig(mm-sound)
 BuildRequires:  pkgconfig(gstreamer-1.0)
@@ -17,7 +19,6 @@ BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
 BuildRequires:  pkgconfig(gstreamer-video-1.0)
 BuildRequires:  pkgconfig(gstreamer-app-1.0)
 BuildRequires:  pkgconfig(mmutil-common)
-BuildRequires:  pkgconfig(mmutil-imgp)
 BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(icu-i18n)
 BuildRequires:  pkgconfig(capi-media-tool)
@@ -48,6 +49,8 @@ cp %{SOURCE1001} .
 
 %build
 export CFLAGS+=" -Wall -DTIZEN_DEBUG -D_FILE_OFFSET_BITS=64 -DSYSCONFDIR=\\\"%{_sysconfdir}\\\" -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" "
+export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\""
+
 %if %{with x}
 export CFLAGS+=" -DHAVE_X11"
 %endif
index c5ff218..68e3633 100644 (file)
@@ -20,8 +20,7 @@ libmmfplayer_la_SOURCES = mm_player.c \
 
 libmmfplayer_la_CFLAGS =  -I$(srcdir)/include \
                        $(MMCOMMON_CFLAGS) \
-                       $(MMUTIL_COMMON_CFLAGS) \
-                       $(MMUTIL_CFLAGS) \
+                       $(MMUTIL_COMMON_CFLAGS) \
                        $(GST_CFLAGS) \
                        $(GST_VIDEO_CFLAGS) \
                        $(GST_APP_CFLAGS) \
@@ -51,9 +50,7 @@ noinst_HEADERS = include/mm_player_utils.h \
                 include/mm_player_360.h
 
 libmmfplayer_la_LIBADD = $(GST_LIBS) \
-               $(MMCOMMON_LIBS) \
-               $(MMUTIL_COMMON_LIBS) \
-               $(MMUTIL_LIBS) \
+               $(MMCOMMON_LIBS) \
                $(GST_INTERFACE_LIBS) \
                $(GST_VIDEO_LIBS) \
                $(GST_APP_LIBS) \
index f939b7e..881b9d1 100644 (file)
@@ -29,6 +29,7 @@
 |                                                                                                                                                                              |
 ========================================================================================== */
 #include <glib.h>
+#include <gmodule.h>
 #include <gst/gst.h>
 #include <mm_attrs.h>
 #include <math.h>
@@ -535,6 +536,19 @@ typedef struct {
 } mmplayer_spherical_metadata_t;
 
 typedef struct {
+       GModule *img_module;
+       GModule *imgp_module;
+       int  (*create)(unsigned int, unsigned int,
+                       int, const unsigned char *, size_t, void **);
+       void (*destroy)(void *);
+       int  (*get)(void *, unsigned int *, unsigned int *,
+                       int *, unsigned char **, size_t *);
+       void (*debug)(void *, const char *);
+       int  (*rotate)(void *, int, void **);
+       int  (*convert)(void *, int, void **);
+} mm_img_util_interface_t;
+
+typedef struct {
        /* STATE */
        int state;                                      // player current state
        int prev_state;                         // player previous state
@@ -566,6 +580,7 @@ typedef struct {
        mmplayer_video_capture_t capture;
        mmplayer_video_color_space_e video_cs;
        MMVideoBuffer captured;
+       mm_img_util_interface_t *img_util;
 
        /* gst bus msg thread, create during realize */
        GThread *bus_msg_thread;
index 0297b6e..b9e5c69 100644 (file)
 #include "mm_player_capture.h"
 #include "mm_player_priv.h"
 
-#include <mm_util_image.h>
-#include <mm_util_imgp.h>
+#include <mm_util_type.h>
 #include <gst/video/video-info.h>
 
 //#define      CAPTURE_OUTPUT_DUMP     1
-/*---------------------------------------------------------------------------
-|    LOCAL VARIABLE DEFINITIONS for internal                                                           |
----------------------------------------------------------------------------*/
+#define MM_IMG_UITL_LIBRARY_PATH PATH_LIBDIR"/libmmutil_common.so"
+#define MM_IMGP_UITL_LIBRARY_PATH PATH_LIBDIR"/libmmutil_imgp.so"
+
+#define IMG_UTIL_INTERFACE(_player) (((mmplayer_t *)_player)->img_util)
 
 /*---------------------------------------------------------------------------
 |    LOCAL FUNCTION PROTOTYPES:                                                                                                |
@@ -47,7 +47,6 @@ static int  __mmplayer_get_video_frame_from_buffer(mmplayer_t *player, GstPad *p
 static gpointer __mmplayer_capture_thread(gpointer data);
 static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height, int left, int top, int right, int bottom);
 static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos);
-static int __mm_player_convert_colorspace(mmplayer_t *player, unsigned char *src_data, size_t src_size, mm_util_color_format_e src_fmt, unsigned int src_w, unsigned int src_h, mm_util_color_format_e dst_fmt);
 static int __mm_player_convert_NV12_tiled(mmplayer_t *player);
 static int __mm_player_convert_NV12(mmplayer_t *player);
 static int __mm_player_convert_I420(mmplayer_t *player);
@@ -61,11 +60,118 @@ static void capture_output_dump(mmplayer_t *player);
 |  FUNCTION DEFINITIONS                                                                                                                                                |
 |                                                                                                                                                                                      |
 ========================================================================================== */
+
+static int __mmplayer_init_img_util_interface(mmplayer_t *player)
+{
+       int ret = MM_ERROR_NONE;
+       gboolean sym_ret = FALSE;
+       GModule *img_module = NULL;
+       GModule *imgp_module = NULL;
+       mm_img_util_interface_t *img_util = NULL;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       if ((access(MM_IMG_UITL_LIBRARY_PATH, F_OK) != 0) ||
+               (access(MM_IMGP_UITL_LIBRARY_PATH, F_OK) != 0)){
+               LOGE("there is no img util library");
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
+       /* allocate new handle */
+       img_util = (mm_img_util_interface_t *)g_try_malloc0(sizeof(mm_img_util_interface_t));
+       if (!img_util) {
+               LOGE("failed to alloc memory for image util interface");
+               ret = MM_ERROR_OUT_OF_MEMORY;
+               goto _INIT_FAILED;
+       }
+
+       img_module = g_module_open(MM_IMG_UITL_LIBRARY_PATH, G_MODULE_BIND_LAZY);
+       if (!img_module) {
+               LOGE("failed to open img common module");
+               goto _INIT_FAILED;
+       }
+
+       imgp_module = g_module_open(MM_IMGP_UITL_LIBRARY_PATH, G_MODULE_BIND_LAZY);
+       if (!imgp_module) {
+               LOGE("failed to open imgp module");
+               goto _INIT_FAILED;
+       }
+
+       /* find symbols */
+       sym_ret = g_module_symbol(img_module, "mm_image_create_image", (gpointer *)&img_util->create);
+       sym_ret &= g_module_symbol(img_module, "mm_image_destroy_image", (gpointer *)&img_util->destroy);
+       sym_ret &= g_module_symbol(img_module, "mm_image_get_image", (gpointer *)&img_util->get);
+       sym_ret &= g_module_symbol(img_module, "mm_image_debug_image", (gpointer *)&img_util->debug);
+       sym_ret &= g_module_symbol(imgp_module, "mm_util_rotate_image", (gpointer *)&img_util->rotate);
+       sym_ret &= g_module_symbol(imgp_module, "mm_util_convert_colorspace", (gpointer *)&img_util->convert);
+
+       if (sym_ret == FALSE || !img_util->create || !img_util->rotate) {
+               LOGE("failed to find symbol %d %p %p", sym_ret, img_util->create, img_util->rotate);
+               ret = MM_ERROR_PLAYER_INTERNAL;
+               goto _INIT_FAILED;
+       }
+
+       img_util->img_module = img_module;
+       img_util->imgp_module = imgp_module;
+       player->img_util = img_util;
+
+       LOGD("image util interface handle %p", img_util);
+       return MM_ERROR_NONE;
+
+_INIT_FAILED:
+       /* release allocated resources */
+       if (img_module) {
+               g_module_close(img_module);
+               img_module = NULL;
+       }
+       if (imgp_module) {
+               g_module_close(imgp_module);
+               imgp_module = NULL;
+       }
+
+       MMPLAYER_FREEIF(img_util);
+       return ret;
+}
+
+static int __mmplayer_deinit_img_util_interface(mmplayer_t *player)
+{
+       int ret = MM_ERROR_NONE;
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       if (IMG_UTIL_INTERFACE(player)->img_module) {
+               LOGD("close img common module %p", IMG_UTIL_INTERFACE(player)->img_module);
+               if (!g_module_close(IMG_UTIL_INTERFACE(player)->img_module)) {
+                       LOGE("failed to close module");
+                       ret = MM_ERROR_PLAYER_INTERNAL;
+               }
+       }
+
+       if (IMG_UTIL_INTERFACE(player)->imgp_module) {
+               LOGD("close imgp module %p", IMG_UTIL_INTERFACE(player)->imgp_module);
+               if (!g_module_close(IMG_UTIL_INTERFACE(player)->imgp_module)) {
+                       LOGE("failed to close module");
+                       ret = MM_ERROR_PLAYER_INTERNAL;
+               }
+       }
+
+       MMPLAYER_FREEIF(IMG_UTIL_INTERFACE(player));
+       MMPLAYER_FLEAVE();
+       return ret;
+}
+
 int
 _mmplayer_initialize_video_capture(mmplayer_t *player)
 {
        int ret = MM_ERROR_NONE;
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       if (__mmplayer_init_img_util_interface(player) != MM_ERROR_NONE) {
+               LOGE("failed to initialize img util interface");
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
        /* create capture mutex */
        g_mutex_init(&player->capture_thread_mutex);
 
@@ -96,6 +202,13 @@ int
 _mmplayer_release_video_capture(mmplayer_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       if (!IMG_UTIL_INTERFACE(player)) {
+               LOGW("there is no allocated resource");
+               return MM_ERROR_NONE;
+       }
+
+       __mmplayer_deinit_img_util_interface(player);
+
        /* release capture thread */
        MMPLAYER_CAPTURE_THREAD_LOCK(player);
        player->capture_thread_exit = TRUE;
@@ -119,9 +232,13 @@ _mmplayer_do_video_capture(MMHandleType hplayer)
        GstPad *pad = NULL;
 
        MMPLAYER_FENTER();
-
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
+       if (!IMG_UTIL_INTERFACE(player)) {
+               LOGW("video capture is not supported");
+               return MM_ERROR_NONE;
+       }
+
        /* capturing or not */
        if (player->video_capture_cb_probe_id || player->capture.data
                        || player->captured.data[0] || player->captured.data[1]) {
@@ -212,23 +329,23 @@ __mmplayer_handle_orientation(mmplayer_t *player, int orientation, int format)
 
        LOGD("source buffer for rotation = %p and rotation = %d", src_buffer, rot_enum);
 
-       ret = mm_image_create_image(player->captured.width[0], player->captured.height[0], format, src_buffer, (size_t)player->capture.size, &src_image);
+       ret = IMG_UTIL_INTERFACE(player)->create(player->captured.width[0], player->captured.height[0], format, src_buffer, (size_t)player->capture.size, &src_image);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to create image");
                return ret;
        }
 
-       ret = mm_util_rotate_image(src_image, rot_enum, &dst_image);
-       mm_image_destroy_image(src_image);
+       ret = IMG_UTIL_INTERFACE(player)->rotate(src_image, rot_enum, &dst_image);
+       IMG_UTIL_INTERFACE(player)->destroy(src_image);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to rotate image");
                return ret;
        }
 
-       mm_image_debug_image(dst_image, NULL);
+       IMG_UTIL_INTERFACE(player)->debug(dst_image, NULL);
 
-       ret = mm_image_get_image(dst_image, &player->capture.width, &player->capture.height, NULL, &player->capture.data, &dst_size);
-       mm_image_destroy_image(dst_image);
+       ret = IMG_UTIL_INTERFACE(player)->get(dst_image, &player->capture.width, &player->capture.height, NULL, &player->capture.data, &dst_size);
+       IMG_UTIL_INTERFACE(player)->destroy(dst_image);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to get image");
                return ret;
@@ -475,29 +592,28 @@ __mm_player_convert_colorspace(mmplayer_t *player, unsigned char *src_data, size
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_INTERNAL);
        SECURE_LOGD("src size info. width: %d, height: %d", src_w, src_h);
 
-       ret = mm_image_create_image(src_w, src_h, src_fmt, src_data, src_size, &src_image);
+       ret = IMG_UTIL_INTERFACE(player)->create(src_w, src_h, src_fmt, src_data, src_size, &src_image);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to create image for capture, %d", ret);
                return MM_ERROR_PLAYER_INTERNAL;
        }
 
-       ret = mm_util_convert_colorspace(src_image, dst_fmt, &dst_image);
-       mm_image_destroy_image(src_image);
+       ret = IMG_UTIL_INTERFACE(player)->convert(src_image, dst_fmt, &dst_image);
+       IMG_UTIL_INTERFACE(player)->destroy(src_image);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to convert for capture, %d", ret);
                return MM_ERROR_PLAYER_INTERNAL;
        }
-       mm_image_debug_image(dst_image, NULL);
+       IMG_UTIL_INTERFACE(player)->debug(dst_image, NULL);
 
-       ret = mm_image_get_image(dst_image, NULL, NULL, NULL, &player->capture.data, &size);
-       mm_image_destroy_image(dst_image);
+       ret = IMG_UTIL_INTERFACE(player)->get(dst_image, NULL, NULL, NULL, &player->capture.data, &size);
+       IMG_UTIL_INTERFACE(player)->destroy(dst_image);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to get image for capture, %d", ret);
                return MM_ERROR_PLAYER_INTERNAL;
        }
 
        player->capture.size = (int)size;
-
        return MM_ERROR_NONE;
 }
 
index ec122c6..080e630 100644 (file)
@@ -4719,8 +4719,8 @@ _mmplayer_create_player(MMHandleType handle)
 
        ret = _mmplayer_initialize_video_capture(player);
        if (ret != MM_ERROR_NONE) {
-               LOGE("failed to initialize video capture");
-               goto ERROR;
+               LOGW("video capture is not supported");
+               /* do not handle as error for headless profile */
        }
 
        /* initialize resource manager */
index f7aad95..8423b6b 100644 (file)
@@ -8,7 +8,6 @@ gtest_libmm_player_SOURCES  = unittest.cpp \
 gtest_libmm_player_CXXFLAGS =  -I$(top_srcdir)/src/include \
                        -I$(top_srcdir)/unittest/include \
                        $(MMCOMMON_CFLAGS) \
-                       $(MMUTIL_CFLAGS) \
                        $(GST_CFLAGS) \
                        $(GST_VIDEO_CFLAGS) \
                        $(GST_APP_CFLAGS) \
@@ -32,7 +31,6 @@ gtest_libmm_player_DEPENDENCIES = $(top_srcdir)/src/.libs/libmmfplayer.la
 gtest_libmm_player_LDADD = \
                        $(GST_LIBS) \
                        $(MMCOMMON_LIBS) \
-                       $(MMUTIL_LIBS) \
                        $(GST_INTERFACE_LIBS) \
                        $(GST_VIDEO_LIBS) \
                        $(GST_APP_LIBS) \