diff options
author | Hyunjun Ko <zzoon.ko@samsung.com> | 2012-08-21 17:59:20 +0900 |
---|---|---|
committer | Hyunjun Ko <zzoon.ko@samsung.com> | 2012-08-21 17:59:20 +0900 |
commit | 933fd44374830be92e08801629bd7eb00e8e1b71 (patch) | |
tree | b561e00c8ff48055ee15e701572a8298f025f6e1 | |
parent | 69a56c3e83fe93a7b4286623e28d0059a9cbbe05 (diff) | |
download | libmedia-thumbnail-933fd44374830be92e08801629bd7eb00e8e1b71.tar.gz libmedia-thumbnail-933fd44374830be92e08801629bd7eb00e8e1b71.tar.bz2 libmedia-thumbnail-933fd44374830be92e08801629bd7eb00e8e1b71.zip |
Tizen 2.0 beta
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rwxr-xr-x | debian/changelog | 338 | ||||
-rwxr-xr-x | debian/control | 4 | ||||
-rwxr-xr-x | include/media-thumbnail.h | 52 | ||||
-rw-r--r-- | packaging/libmedia-thumbnail.spec | 36 | ||||
-rwxr-xr-x | server/include/thumb-server-internal.h | 9 | ||||
-rwxr-xr-x | server/thumb-server-internal.c | 246 | ||||
-rwxr-xr-x | server/thumb-server.c | 130 | ||||
-rw-r--r-- | src/codec/img-codec-osal.c | 36 | ||||
-rwxr-xr-x | src/include/ipc/media-thumb-ipc.h | 6 | ||||
-rwxr-xr-x | src/include/media-thumb-internal.h | 6 | ||||
-rwxr-xr-x | src/include/util/media-thumb-db.h | 19 | ||||
-rwxr-xr-x | src/include/util/media-thumb-util.h | 10 | ||||
-rwxr-xr-x | src/ipc/media-thumb-ipc.c | 122 | ||||
-rwxr-xr-x | src/media-thumb-internal.c | 32 | ||||
-rwxr-xr-x | src/media-thumbnail.c | 103 | ||||
-rwxr-xr-x | src/util/media-thumb-db.c | 157 | ||||
-rwxr-xr-x | src/util/media-thumb-util.c | 59 |
18 files changed, 1013 insertions, 358 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cd592e..e0363c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ SET(PACKAGE ${PROJECT_NAME}) SET(PKGNAME "com.${VENDOR}.${PACKAGE}") SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(BINDIR "${PREFIX}/bin") +SET(LOCALBINDIR "${PREFIX}/local/bin") SET(DATADIR "${PREFIX}/share") SET(EXEC_PREFIX "\${prefix}") SET(LIBDIR "\${prefix}/lib") @@ -44,7 +45,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED -glib-2.0 gthread-2.0 dlog mm-fileinfo drm-service aul +glib-2.0 gthread-2.0 dlog mm-fileinfo drm-client aul libexif ecore-evas evas mmutil-imgp mmutil-jpeg heynoti) @@ -68,6 +69,7 @@ ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"") ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") #ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_") +ADD_DEFINITIONS("-D_USE_NEW_MEDIA_DB_") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both") CONFIGURE_FILE(media-thumbnail.pc.in media-thumbnail.pc @ONLY) @@ -92,7 +94,7 @@ INSTALL(TARGETS media-thumbnail-server DESTINATION ${BINDIR}) ADD_EXECUTABLE(test-thumb ${TEST-THUMB}) TARGET_LINK_LIBRARIES(test-thumb ${pkgs_LDFLAGS} ${MEDIATHUMB-LIB} ) -INSTALL(TARGETS test-thumb DESTINATION ${BINDIR}) +INSTALL(TARGETS test-thumb DESTINATION ${LOCALBINDIR}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumbnail.h DESTINATION include/${MEDIATHUMB-LIB}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumbnail-private.h DESTINATION include/${MEDIATHUMB-LIB}) diff --git a/debian/changelog b/debian/changelog index c2ac9c8..aba5c9e 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,49 +1,331 @@ -libmedia-thumbnail (0.2.0-5) unstable; urgency=low +libmedia-thumbnail (0.1.42) unstable; urgency=low - * Push for tizen 1.0 release - * Git : pkgs/l/libmedia-thumbnail - * Tag : libmedia-thumbnail_0.2.0-5 + * Change the way to call ecore_evas_init + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.42 - -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 19 Mar 2012 18:30:00 +0900 + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 2 Aug 2012 18:00:00 +0900 -libmedia-thumbnail (0.2.0-4) unstable; urgency=low +libmedia-thumbnail (0.1.41) unstable; urgency=low + + * Fix the issue about fds opened over maximum + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.41 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 1 Aug 2012 18:00:00 +0900 + +libmedia-thumbnail (0.1.40) unstable; urgency=low + + * Add the api for client to get width and height + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.40 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 31 Jul 2012 18:00:00 +0900 + +libmedia-thumbnail (0.1.39) unstable; urgency=low + + * Use new media DB + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.39 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 25 Jul 2012 18:00:00 +0900 + +libmedia-thumbnail (0.1.38) unstable; urgency=low + + * Add to code to handle heynoti power-off + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.38 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 13 Jul 2012 15:00:00 +0900 + +libmedia-thumbnail (0.1.35) unstable; urgency=low + + * Change DRM apis + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.35 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 22 May 2012 15:00:00 +0900 + +libmedia-thumbnail (0.1.34) unstable; urgency=low + + * Change the structure of the thumb server to use gmainloop + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.34 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 13 Apr 2012 15:00:00 +0900 + +libmedia-thumbnail (0.1.33) unstable; urgency=low + + * Fix a bug of the api thumbnail_request_save_to_file + * Modify rpm packaging file + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.33 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 28 Mar 2012 14:00:00 +0900 + +libmedia-thumbnail (0.1.32) unstable; urgency=low + + * Fix a bug when getting size of RGB888 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.32 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 9 Mar 2012 18:00:00 +0900 + +libmedia-thumbnail (0.1.31) unstable; urgency=low + + * Add new api thumbnail_request_extract_all_thumbs + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.31 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 29 Feb 2012 18:00:00 +0900 + +libmedia-thumbnail (0.1.30) unstable; urgency=low + + * Making db handle static + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.30 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 16 Feb 2012 14:00:00 +0900 + +libmedia-thumbnail (0.1.29) unstable; urgency=low - * Change thumbnail policy - Large: 320x240, Small: 160x120 - * Remove libmedia-service dependancy * Change of DB schema in media.db - * Git : pkgs/l/libmedia-thumbnail - * Tag : libmedia-thumbnail_0.2.0-4 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.29 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 31 Jan 2012 17:00:00 +0900 + +libmedia-thumbnail (0.1.28) unstable; urgency=low + + * Remove libmedia-service dependancy + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.28 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 25 Jan 2012 17:00:00 +0900 + +libmedia-thumbnail (0.1.27) unstable; urgency=low + + * Change according to change of libmedia-service + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.27 - -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 10 Feb 2012 18:30:00 +0900 + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 18 Jan 2012 17:00:00 +0900 + +libmedia-thumbnail (0.1.26) unstable; urgency=low + + * Change thumbnail policy - Large: 320x240, Small: 160x120 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.26 -libmedia-thumbnail (0.2.0-3) unstable; urgency=low + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 6 Jan 2012 19:00:00 +0900 + +libmedia-thumbnail (0.1.25) unstable; urgency=low + + * Put COPYING file to md5 directory + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.25 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 3 Jan 2012 19:00:00 +0900 + +libmedia-thumbnail (0.1.24) unstable; urgency=low * Separates md5 codes to another shared object - * Git : pkgs/l/libmedia-thumbnail - * Tag : libmedia-thumbnail_0.2.0-3 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.24 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 3 Jan 2012 18:00:00 +0900 + +libmedia-thumbnail (0.1.23) unstable; urgency=low + + * Packaging + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.23 - -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 3 Jan 2012 18:30:00 +0900 + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 28 Dec 2011 18:00:00 +0900 -libmedia-thumbnail (0.2.0-2) unstable; urgency=low +libmedia-thumbnail (0.1.22) unstable; urgency=low + * Arrange MD5 algorithm opensource * Remove timeout in select for battery - * Git : pkgs/l/libmedia-thumbnail - * Tag : libmedia-thumbnail_0.2.0-2 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.22 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 28 Dec 2011 17:00:00 +0900 + +libmedia-thumbnail (0.1.21) unstable; urgency=low + + * Change the pkg name from libmedia-info to libmedia-service + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.21 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 8 Dec 2011 15:00:00 +0900 + +libmedia-thumbnail (0.1.20) unstable; urgency=low + + * Code cleanup for opening + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.20 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 5 Dec 2011 15:00:00 +0900 + +libmedia-thumbnail (0.1.19) unstable; urgency=low + + * Add a parameter thumbnail type to the api thumbnail_request_save_to_file + * Close the api thumbnail_get_data temporarily + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.19 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 5 Dec 2011 15:00:00 +0900 + +libmedia-thumbnail (0.1.18) unstable; urgency=low + + * Modify boilerplate + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.18 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 2 Dec 2011 15:00:00 +0900 + +libmedia-thumbnail (0.1.17) unstable; urgency=low + + * Change the name from thumb-daemon to media-thumbnail-server + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.17 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 1 Dec 2011 18:00:00 +0900 + +libmedia-thumbnail (0.1.16) unstable; urgency=low + + * Adjust to use thread in thumb-daemon + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.16 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 30 Nov 2011 18:00:00 +0900 + +libmedia-thumbnail (0.1.15) unstable; urgency=low + + * Add script to start network + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.15 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 15 Nov 2011 16:00:00 +0900 + +libmedia-thumbnail (0.1.14) unstable; urgency=low + + * Change timeout from 5 to 10 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.14 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 14 Nov 2011 16:00:00 +0900 + +libmedia-thumbnail (0.1.13) unstable; urgency=low + + * change sequence of booting script + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.13 + + -- Yong Yeon Kim <yy9875.kim@samsung.com> Sat, 12 Nov 2011 11:05:48 +0900 + +libmedia-thumbnail (0.1.12) unstable; urgency=low + + * change sequence of booting script + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.12 + + -- Yong Yeon Kim <yy9875.kim@samsung.com> Thu, 10 Nov 2011 15:18:57 +0900 + +libmedia-thumbnail (0.1.11) unstable; urgency=low + + * Fix prevent defects + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.11 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 7 Nov 2011 18:00:00 +0900 + +libmedia-thumbnail (0.1.10) unstable; urgency=low + + * Changes according to the change in libmedia-info lib + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.10 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 2 Nov 2011 16:00:00 +0900 + +libmedia-thumbnail (0.1.9) unstable; urgency=low + + * Modify boilerplate + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.9 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 21 Oct 2011 15:00:00 +0900 + +libmedia-thumbnail (0.1.8) unstable; urgency=low + + * New api thumbnail_request_save_to_file + * fsync call when writing thumb to file system + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.8 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 18 Oct 2011 15:00:00 +0900 + +libmedia-thumbnail (0.1.7) unstable; urgency=low + + * Add UTCs + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.7 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 13 Oct 2011 14:00:00 +0900 + +libmedia-thumbnail (0.1.6) unstable; urgency=low + + * Fix a crash caused by wrong frame data + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.6 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 13 Oct 2011 12:00:00 +0900 + +libmedia-thumbnail (0.1.5) unstable; urgency=low + + * Fix a build break + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.5 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 12 Oct 2011 13:00:00 +0900 + +libmedia-thumbnail (0.1.4) unstable; urgency=low + + * Add shell script to invoke thumb-daemon + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.4 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 12 Oct 2011 12:00:00 +0900 + +libmedia-thumbnail (0.1.3) unstable; urgency=low + + * Enable hibernation callbacks + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.3 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 12 Oct 2011 12:00:00 +0900 + +libmedia-thumbnail (0.1.2) unstable; urgency=low + + * Modify packaging file + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.2 - -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 22 Dec 2011 16:00:00 +0900 + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 10 Oct 2011 18:00:00 +0900 -libmedia-thumbnail (0.2.0-1) unstable; urgency=low +libmedia-thumbnail (0.1.1) unstable; urgency=low - * Change the symbolic link path of start script - * Git : pkgs/l/libmedia-thumbnail - * Tag : libmedia-thumbnail_0.2.0-1 + * Stabilize. + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.1 - -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 20 Dec 2011 18:00:00 +0900 + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 10 Oct 2011 17:00:00 +0900 -libmedia-thumbnail (0.2.0-0) unstable; urgency=low +libmedia-thumbnail (0.1.0) unstable; urgency=low * Initial Release. - * Git : pkgs/l/libmedia-thumbnail - * Tag : libmedia-thumbnail_0.2.0-0 + * Git : 165.213.180.234:slp/pkgs/l/libmedia-thumbnail + * Tag : libmedia-thumbnail_0.1.0 - -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 7 Dec 2011 15:50:00 +0900 + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 4 Oct 2011 15:50:00 +0900 diff --git a/debian/control b/debian/control index 3a94b71..67f5085 100755 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 5), libglib2.0-dev, dlog-dev, libmm-fileinfo-dev, libmm-utility-dev, - drm-service-dev, + drm-client-dev, libexif-dev, libheynoti-dev, libevas-dev, @@ -37,7 +37,7 @@ Description: Media thumbnail service library for multimedia applications. Package: libmedia-thumbnail-dev Section: libdevel Architecture: any -Depends: libmedia-thumbnail (= ${Source-Version}), libmm-fileinfo-dev, libmm-utility-dev, libglib2.0-dev, dlog-dev, drm-service-dev, libevas-dev, libecore-dev, libexif-dev, libaul-1-dev +Depends: libmedia-thumbnail (= ${Source-Version}), libmm-fileinfo-dev, libmm-utility-dev, libglib2.0-dev, dlog-dev, drm-client-dev, libevas-dev, libecore-dev, libexif-dev, libaul-1-dev Description: Media thumbnail service library for multimedia applications. (development) Package: libmedia-thumbnail-dbg diff --git a/include/media-thumbnail.h b/include/media-thumbnail.h index 2d77601..76de9e8 100755 --- a/include/media-thumbnail.h +++ b/include/media-thumbnail.h @@ -49,6 +49,13 @@ extern "C" { /** + * Callback function, which is used to call thumbnail_request_from_db_async + */ + +typedef int (*ThumbFunc) (int error_code, char* path, void* data); + + +/** * thumbnail_request_from_db: * This function connects to the media database and find thumbnail path of the passed original image. * If found, the thumbnail path will be returned, or starts to generate thumbnail @@ -88,6 +95,51 @@ void gen_thumbs() int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length); /** + * thumbnail_request_from_db_async: + * This function connects to the media database and find thumbnail path of the passed original image. + * If found, the thumbnail path will be returned through callback, which is registered by user. + * + * @return This function returns zero(MEDIA_THUMB_ERROR_NONE) on success, or negative value with error code. + * Please refer 'media-thumb-error.h' to know the exact meaning of the error. + * @param[in] origin_path The path of the original image + * @param[in] func The callback, which is registered by user + * @param[in] user_data User data, which is used by user in callback + * @see None. + * @pre None. + * @post None. + * @remark The database name is "/opt/dbspace/.media.db". + * @par example + * @code + +#include <media-thumbnail.h> + +int _thumb_cb(int error_code, char *path, void *user_data) +{ + printf("Error code : %d\n", error_code); + printf("Thumb path : %s\n", path); +} + +void gen_thumbs() +{ + int ret = MEDIA_THUMB_ERROR_NONE; + const char *origin_path = "/opt/media/test.jpg"; + char thumb_path[255]; + + ret = thumbnail_request_from_db_async(origin_path, _thumb_cb, NULL); + + if (ret < 0) + { + printf( "thumbnail_request_from_db_async fails. error code->%d", ret); + } + + return; +} + + * @endcode + */ +int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data); + +/** * thumbnail_request_save_to_file: * This function generates thumbnail of the original path and save it to the file system as jpeg format with the passed thumbnail path. * This function doesn't care about media DB. diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec index 7407641..1187fc5 100644 --- a/packaging/libmedia-thumbnail.spec +++ b/packaging/libmedia-thumbnail.spec @@ -1,16 +1,17 @@ +#sbs-git:slp/pkgs/l/libmedia-thumbnail libmedia-thumbnail 0.1.32 a6b6cb2f372f6a8cca44ef50813ad0300d34a9de Name: libmedia-thumbnail Summary: Media thumbnail service library for multimedia applications. -Version: 0.2.0 -Release: 1 -Group: System/Libraries -License: Apache-2.0 +Version: 0.1.42 +Release: 0 +Group: utils +License: Apache Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(mm-fileinfo) BuildRequires: pkgconfig(mmutil-imgp) BuildRequires: pkgconfig(mmutil-jpeg) -BuildRequires: pkgconfig(drm-service) +BuildRequires: pkgconfig(drm-client) BuildRequires: pkgconfig(libexif) BuildRequires: pkgconfig(heynoti) BuildRequires: pkgconfig(evas) @@ -23,7 +24,7 @@ Description: Media thumbnail service library for multimedia applications. %package devel -License: Apache-2.0 +License: Apache Summary: Media thumbnail service library for multimedia applications. (development) Requires: %{name} = %{version}-%{release} Group: Development/Libraries @@ -32,7 +33,7 @@ Group: Development/Libraries Description: Media thumbnail service library for multimedia applications. (development) %package -n media-thumbnail-server -License: Apache-2.0 +License: Apache Summary: Thumbnail generator. Requires: %{name} = %{version}-%{release} Group: Development/Libraries @@ -61,24 +62,23 @@ ln -s %{_sysconfdir}/init.d/thumbsvr %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S47th %files +%defattr(-,root,root,-) %{_libdir}/libmedia-thumbnail.so %{_libdir}/libmedia-thumbnail.so.* %{_libdir}/libmedia-hash.so -%{_libdir}/libmedia-hash.so.* - +%{_libdir}/libmedia-hash.so.1 +%{_libdir}/libmedia-hash.so.1.0.0 %files devel +%defattr(-,root,root,-) %{_libdir}/pkgconfig/media-thumbnail.pc -%{_includedir}/media-thumbnail/media-thumb-types.h -%{_includedir}/media-thumbnail/media-thumb-error.h -%{_includedir}/media-thumbnail/media-thumbnail.h -%{_includedir}/media-thumbnail/media-thumbnail-private.h - +%{_includedir}/media-thumbnail/*.h %files -n media-thumbnail-server +%defattr(-,root,root,-) %{_bindir}/media-thumbnail-server -%attr(755,root,root) %{_sysconfdir}/init.d/thumbsvr -%attr(755,root,root) %{_sysconfdir}/rc.d/rc3.d/S47thumbsvr -%attr(755,root,root) %{_sysconfdir}/rc.d/rc5.d/S47thumbsvr -%exclude %{_bindir}/test-thumb +/usr/local/bin/test-thumb +%attr(755,-,-) %{_sysconfdir}/init.d/thumbsvr +%{_sysconfdir}/rc.d/rc3.d/S47thumbsvr +%{_sysconfdir}/rc.d/rc5.d/S47thumbsvr diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h index 2d061c8..cbf8644 100755 --- a/server/include/thumb-server-internal.h +++ b/server/include/thumb-server-internal.h @@ -39,8 +39,17 @@ typedef enum { TIMEOUT_MODE = 1 } _server_mode_e; +#if 0 int _thumb_daemon_get_sockfd(); gboolean _thumb_daemon_udp_thread(void *data); +#endif + +gboolean _thumb_daemon_start_jobs(gpointer data); +void _thumb_daemon_finish_jobs(); +gboolean _thumb_server_prepare_socket(int *sock_fd); +gboolean _thumb_server_read_socket(GIOChannel *src, + GIOCondition condition, + gpointer data); #endif /*_THUMB_DAEMON_INTERNAL_H_*/ diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c index bf455db..7a425d0 100755 --- a/server/thumb-server-internal.c +++ b/server/thumb-server-internal.c @@ -25,6 +25,7 @@ #include <dirent.h> #include <stdio.h> #include <string.h> +#include <Ecore_Evas.h> #ifdef LOG_TAG @@ -33,124 +34,33 @@ #define LOG_TAG "Thumb-Server" -static __thread int sock; static __thread char **arr_path; static __thread int g_idx = 0; static __thread int g_cur_idx = 0; -static __thread _server_mode_e g_server_mode = BLOCK_MODE; -static __thread int g_media_svr_pid = 0; -int _thumb_daemon_get_sockfd() +gboolean _thumb_daemon_start_jobs(gpointer data) { - return sock; -} - -int _thumb_daemon_compare_pid_with_mediaserver_fast(int pid) -{ - int find_pid = -1; - - char path[128]; - char buff[128]; - snprintf(path, sizeof(path), "/proc/%d/status", g_media_svr_pid); - - FILE *fp = NULL; - fp = fopen(path, "rt"); - if (fp) { - fgets(buff, sizeof(buff), fp); - fclose(fp); - - if (strstr(buff, "media-server")) { - find_pid = g_media_svr_pid; - thumb_dbg(" find_pid : %d", find_pid); - } else { - g_media_svr_pid = 0; - return GETPID_FAIL; - } - } else { - thumb_err("Can't read file [%s]", path); - g_media_svr_pid = 0; - return GETPID_FAIL; - } + thumb_dbg(""); + /* Initialize ecore-evas to use evas library */ + ecore_evas_init(); - if (find_pid == pid) { - thumb_dbg("This is a request from media-server"); - return MEDIA_SERVER_PID; - } else { - thumb_dbg("This is a request from other apps"); - return OTHERS_PID; - } -} - -int _thumb_daemon_compare_pid_with_mediaserver(int pid) -{ - DIR *pdir; - struct dirent pinfo; - struct dirent *result = NULL; - - pdir = opendir("/proc"); - if (pdir == NULL) { - thumb_err("err: NO_DIR"); - return GETPID_FAIL; - } - - while (!readdir_r(pdir, &pinfo, &result)) { - if (result == NULL) - break; - - if (pinfo.d_type != 4 || pinfo.d_name[0] == '.' - || pinfo.d_name[0] > 57) - continue; - - FILE *fp; - char buff[128]; - char path[128]; - - snprintf(path, sizeof(path), "/proc/%s/status", pinfo.d_name); - - fp = fopen(path, "rt"); - if (fp) { - fgets(buff, sizeof(buff), fp); - fclose(fp); - - if (strstr(buff, "media-server")) { - thumb_dbg("pinfo->d_name : %s", pinfo.d_name); - g_media_svr_pid = atoi(pinfo.d_name); - thumb_dbg("Media Server PID : %d", g_media_svr_pid); - } - } - } - - closedir(pdir); - - if (g_media_svr_pid == pid) { - thumb_dbg("This is a request from media-server"); - return MEDIA_SERVER_PID; - } else { - thumb_dbg("This is a request from other apps"); - return OTHERS_PID; - } + return FALSE; } -int _thumb_daemon_recv_by_select(int fd, gboolean is_timeout) +void _thumb_daemon_finish_jobs() { - fd_set fds; - int ret = -1; - - FD_ZERO(&fds); - FD_SET(fd, &fds); + sqlite3 *sqlite_db_handle = _media_thumb_db_get_handle(); - if (is_timeout) { - struct timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - - ret = select(fd + 1, &fds, 0, 0, &timeout); - } else { - ret = select(fd + 1, &fds, 0, 0, NULL); + if (sqlite_db_handle != NULL) { + _media_thumb_db_disconnect(); + thumb_dbg("sqlite3 handle is alive. So disconnect to sqlite3"); } - return ret; + /* Shutdown ecore-evas */ + ecore_evas_shutdown(); + + return; } int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg) @@ -230,7 +140,7 @@ int _thumb_daemon_all_extract() return MEDIA_THUMB_ERROR_NONE; } -int _thumb_daemon_process_queue_jobs() +int _thumb_daemon_process_queue_jobs(gpointer data) { int err = -1; char *path = NULL; @@ -254,7 +164,7 @@ int _thumb_daemon_process_queue_jobs() err = _media_thumb_db_connect(); if (err < 0) { thumb_err("_media_thumb_mb_svc_connect failed: %d", err); - return MEDIA_THUMB_ERROR_DB; + return TRUE; } /* Need to update DB once generating thumb is done */ @@ -271,31 +181,78 @@ int _thumb_daemon_process_queue_jobs() free(path); path = NULL; - g_server_mode = TIMEOUT_MODE; } else { g_cur_idx = 0; g_idx = 0; - g_server_mode = BLOCK_MODE; thumb_warn("Deleting array"); free(arr_path); + + return FALSE; } - return MEDIA_THUMB_ERROR_NONE; + return TRUE; } -gboolean _thumb_daemon_udp_thread(void *data) +gboolean _thumb_server_read_socket(GIOChannel *src, + GIOCondition condition, + gpointer data) { - int err = -1; - gboolean is_timeout = FALSE; - - struct sockaddr_in serv_addr; struct sockaddr_in client_addr; - unsigned short serv_port; unsigned int client_addr_len; thumbMsg recv_msg; thumbMsg res_msg; int recv_msg_size; + int sock = -1; + + sock = g_io_channel_unix_get_fd(src); + if (sock < 0) { + thumb_err("sock fd is invalid!"); + return TRUE; + } + + /* Socket is readable */ + client_addr_len = sizeof(client_addr); + if ((recv_msg_size = recvfrom(sock, &recv_msg, sizeof(recv_msg), 0, (struct sockaddr *)&client_addr, &client_addr_len)) < 0) { + thumb_err("recvfrom failed\n"); + return TRUE; + } + + thumb_dbg("Received [%d] %s(%d) from PID(%d) \n", recv_msg.msg_type, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid); + + if (recv_msg.msg_type == THUMB_REQUEST_ALL_MEDIA) { + thumb_dbg("All thumbnails are being extracted now"); + _thumb_daemon_all_extract(); + g_idle_add(_thumb_daemon_process_queue_jobs, NULL); + } else { + long start = thumb_get_debug_time(); + + _thumb_daemon_process_job(&recv_msg, &res_msg); + + long end = thumb_get_debug_time(); + thumb_dbg("Time : %f (%s)\n", ((double)(end - start) / (double)CLOCKS_PER_SEC), recv_msg.org_path); + } + + if (sendto(sock, &res_msg, sizeof(res_msg), 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != sizeof(res_msg)) { + thumb_err("sendto failed\n"); + } else { + thumb_dbg("Sent %s(%d) \n", res_msg.dst_path, strlen(res_msg.dst_path)); + } + + memset((void *)&recv_msg, 0, sizeof(recv_msg)); + memset((void *)&res_msg, 0, sizeof(res_msg)); + + return TRUE; +} + +gboolean _thumb_server_prepare_socket(int *sock_fd) +{ + int sock; + struct sockaddr_in serv_addr; + unsigned short serv_port; + + thumbMsg recv_msg; + thumbMsg res_msg; char thumb_path[MAX_PATH_SIZE + 1]; memset((void *)&recv_msg, 0, sizeof(recv_msg)); @@ -322,62 +279,7 @@ gboolean _thumb_daemon_udp_thread(void *data) thumb_dbg("bind success"); - while(1) { - if (g_server_mode == TIMEOUT_MODE) { - thumb_dbg("Wait for other app's request for 10 msec"); - is_timeout = TRUE; - } else { - is_timeout = FALSE; - } - - err = _thumb_daemon_recv_by_select(sock, is_timeout); - - if (err == 0) { - /* timeout in select() */ - err = _thumb_daemon_process_queue_jobs(); - continue; - - } else if (err == -1) { - /* error in select() */ - thumb_err("ERROR in select()"); - continue; - - } else { - /* Socket is readable */ - client_addr_len = sizeof(client_addr); - if ((recv_msg_size = recvfrom(sock, &recv_msg, sizeof(recv_msg), 0, (struct sockaddr *)&client_addr, &client_addr_len)) < 0) { - thumb_err("recvfrom failed\n"); - continue; - } - - thumb_dbg("Received [%d] %s(%d) from PID(%d) \n", recv_msg.msg_type, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid); - - if (recv_msg.msg_type == THUMB_REQUEST_ALL_MEDIA) { - thumb_dbg("All thumbnails are being extracted now"); - _thumb_daemon_all_extract(); - - g_server_mode = TIMEOUT_MODE; - } else { - long start = thumb_get_debug_time(); - - _thumb_daemon_process_job(&recv_msg, &res_msg); - - long end = thumb_get_debug_time(); - thumb_dbg("Time : %f (%s)\n", ((double)(end - start) / (double)CLOCKS_PER_SEC), recv_msg.org_path); - } - - if (sendto(sock, &res_msg, sizeof(res_msg), 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != sizeof(res_msg)) { - thumb_err("sendto failed\n"); - } else { - thumb_dbg("Sent %s(%d) \n", res_msg.dst_path, strlen(res_msg.dst_path)); - } - - memset((void *)&recv_msg, 0, sizeof(recv_msg)); - memset((void *)&res_msg, 0, sizeof(res_msg)); - } - } - - close(sock); + *sock_fd = sock; return TRUE; } diff --git a/server/thumb-server.c b/server/thumb-server.c index f94d32a..dc72fee 100755 --- a/server/thumb-server.c +++ b/server/thumb-server.c @@ -27,107 +27,89 @@ #include <pthread.h> #include <heynoti.h> +//#include <signal.h> +//#include <glib-unix.h> #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "Thumb-Server" +#define POWEROFF_NOTI_NAME "power_off_start" /*poeroff noti from system-server*/ -#ifdef USE_HIB -#undef USE_HIB -#endif -#ifdef USE_HIB -int hib_fd = 0; +GMainLoop *g_thumb_server_mainloop = NULL; -void _hibernation_leave_callback(void *data) +static void _media_thumb_signal_handler(void *user_data) { - thumb_dbg("hibernation leave callback\n"); - - GMainLoop *mainloop = NULL; - GThread *udp_thr = NULL; - - if (!g_thread_supported()) { - g_thread_init(NULL); - } - - udp_thr = g_thread_create((GThreadFunc)_thumb_daemon_udp_thread, NULL, FALSE, NULL); - mainloop = g_main_loop_new(NULL, FALSE); + thumb_dbg("Singal Hander for HEYNOTI \"power_off_start\""); - thumb_dbg("*****************************************"); - thumb_dbg("*** Server of thumbnail is running ***"); - thumb_dbg("*****************************************"); + if (g_thumb_server_mainloop) + g_main_loop_quit(g_thumb_server_mainloop); + else + exit(1); - g_main_loop_run(mainloop); - - g_main_loop_unref(mainloop); - - exit(0); + return; } -void _hibernation_enter_callback(void *data) + +int main() { - thumb_dbg("hibernation enter callback\n"); + int sockfd = -1; - int sock = _thumb_daemon_get_sockfd(); - if (sock != 0) { - close(sock); - } + GSource *source = NULL; + GIOChannel *channel = NULL; + GMainContext *context = NULL; - if (hib_fd != 0) { - heynoti_close(hib_fd); - hib_fd = 0; - } -} + /*heynoti for power off*/ + int err = 0; + int heynoti_id = heynoti_init(); -void _hibernation_initialize(void) -{ - hib_fd = heynoti_init(); - heynoti_subscribe(hib_fd, "HIBERNATION_ENTER", - _hibernation_enter_callback, (void *)hib_fd); - heynoti_subscribe(hib_fd, "HIBERNATION_LEAVE", - _hibernation_leave_callback, (void *)hib_fd); - heynoti_attach_handler(hib_fd); + heynoti_subscribe(heynoti_id, POWEROFF_NOTI_NAME, _media_thumb_signal_handler, NULL); - return; -} + err = heynoti_attach_handler(heynoti_id); + if (err < 0) + thumb_err("heynoti_attach_handler failed: %d", err); -void _hibernation_fianalize(void) -{ - heynoti_close(hib_fd); -} -#endif + /* Create and bind new UDP socket */ + if (!_thumb_server_prepare_socket(&sockfd)) { + thumb_err("Failed to create socket\n"); + return -1; + } -int main() -{ -#ifdef USE_HIB - _hibernation_initialize(); -#endif + g_thumb_server_mainloop = g_main_loop_new(context, FALSE); + context = g_main_loop_get_context(g_thumb_server_mainloop); - GMainLoop *mainloop = NULL; - GThread *udp_thr = NULL; - - if (!g_thread_supported()) { - g_thread_init(NULL); - } - - udp_thr = g_thread_create((GThreadFunc)_thumb_daemon_udp_thread, NULL, FALSE, NULL); + /* Create new channel to watch udp socket */ + channel = g_io_channel_unix_new(sockfd); + source = g_io_create_watch(channel, G_IO_IN); - mainloop = g_main_loop_new(NULL, FALSE); + /* Set callback to be called when socket is readable */ + g_source_set_callback(source, (GSourceFunc)_thumb_server_read_socket, NULL, NULL); + g_source_attach(source, context); - thumb_dbg("*****************************************"); - thumb_dbg("*** Server of thumbnail is running ***"); - thumb_dbg("*****************************************"); + GSource *source_evas_init = NULL; + source_evas_init = g_idle_source_new (); + g_source_set_callback (source_evas_init, _thumb_daemon_start_jobs, NULL, NULL); + g_source_attach (source_evas_init, context); - g_main_loop_run(mainloop); +/* Would be used when glib 2.32 is installed + GSource *sig_handler_src = NULL; + sig_handler_src = g_unix_signal_source_new (SIGTERM); + g_source_set_callback(sig_handler_src, (GSourceFunc)_media_thumb_signal_handler, NULL, NULL); + g_source_attach(sig_handler_src, context); +*/ + thumb_dbg("************************************"); + thumb_dbg("*** Thumbnail server is running ***"); + thumb_dbg("************************************"); - g_main_loop_unref(mainloop); + g_main_loop_run(g_thumb_server_mainloop); -#ifdef USE_HIB - _hibernation_fianalize(); -#endif + thumb_dbg("Thumbnail server is shutting down..."); + g_io_channel_shutdown(channel, FALSE, NULL); + g_io_channel_unref(channel); + _thumb_daemon_finish_jobs(); + g_main_loop_unref(g_thumb_server_mainloop); return 0; } - diff --git a/src/codec/img-codec-osal.c b/src/codec/img-codec-osal.c index c39d57c..8f10910 100644 --- a/src/codec/img-codec-osal.c +++ b/src/codec/img-codec-osal.c @@ -19,12 +19,14 @@ * */ +#include "media-thumb-debug.h" #include "img-codec-osal.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <drm-service.h> +//#include <drm-service.h> +#include <drm_client.h> void *IfegMemAlloc(unsigned int size) { @@ -59,12 +61,20 @@ int IfegMemcmp(const void *pMem1, const void *pMem2, size_t length) return memcmp(pMem1, pMem2, length); } -DRM_FILE_HANDLE hDrmFile = NULL; static BOOL _is_real_drm = FALSE; HFile DrmOpenFile(const char *szPathName) { - if (drm_svc_is_drm_file(szPathName) == DRM_TRUE) { + int ret = 0; + drm_bool_type_e drm_type; + + ret = drm_is_drm_file(szPathName, &drm_type); + if (ret < 0) { + thumb_err("drm_is_drm_file falied : %d", ret); + drm_type = DRM_FALSE; + } + + if (drm_type == DRM_TRUE) { _is_real_drm = TRUE; } else { _is_real_drm = FALSE; @@ -75,19 +85,13 @@ HFile DrmOpenFile(const char *szPathName) if (fp == NULL) { return (HFile) INVALID_HOBJ; + thumb_err("file open error: %s", szPathName); } return fp; } else { - int ret = - drm_svc_open_file(szPathName, DRM_PERMISSION_DISPLAY, - &hDrmFile); - - if (ret != DRM_RESULT_SUCCESS) { - return (HFile) INVALID_HOBJ; - } - return hDrmFile; + return (HFile) INVALID_HOBJ; } } @@ -99,9 +103,7 @@ BOOL DrmReadFile(HFile hFile, void *pBuffer, ULONG bufLen, ULONG * pReadLen) readCnt = fread(pBuffer, sizeof(char), bufLen, hFile); *pReadLen = (ULONG) readCnt; } else { - drm_svc_read_file((DRM_FILE_HANDLE) hFile, pBuffer, bufLen, - &readCnt); - *pReadLen = (ULONG) readCnt; + return FALSE; } return TRUE; } @@ -111,7 +113,7 @@ long DrmTellFile(HFile hFile) if (!_is_real_drm) { return ftell(hFile); } else { - return drm_svc_tell_file((DRM_FILE_HANDLE) hFile); + return -1; } } @@ -124,7 +126,7 @@ BOOL DrmSeekFile(HFile hFile, long position, long offset) if (!_is_real_drm) { fseek(hFile, offset, position); } else { - drm_svc_seek_file((DRM_FILE_HANDLE) hFile, offset, position); + return FALSE; } return TRUE; @@ -152,7 +154,7 @@ BOOL DrmCloseFile(HFile hFile) if (!_is_real_drm) { fclose(hFile); } else { - drm_svc_close_file((DRM_FILE_HANDLE) hFile); + return FALSE; } return TRUE; diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h index 81f9116..7c9f6b0 100755 --- a/src/include/ipc/media-thumb-ipc.h +++ b/src/include/ipc/media-thumb-ipc.h @@ -77,6 +77,12 @@ _media_thumb_request(int msg_type, media_thumb_info *thumb_info); int +_media_thumb_request_async(int msg_type, + media_thumb_type thumb_type, + const char *origin_path, + thumbUserData *userData); + +int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg); #endif /*_MEDIA_THUMB_IPC_H_*/ diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h index ac19f66..05dc459 100755 --- a/src/include/media-thumb-internal.h +++ b/src/include/media-thumb-internal.h @@ -20,6 +20,7 @@ */ +#include "media-thumbnail.h" #include "media-thumb-error.h" #include "media-thumb-types.h" #include "media-thumb-debug.h" @@ -57,6 +58,11 @@ enum Exif_Orientation { ROT_270 =8 }; +typedef struct { + ThumbFunc func; + void *user_data; +} thumbUserData; + int _media_thumb_image(const char *origin_path, int thumb_width, diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h index bf89e94..8d44aa4 100755 --- a/src/include/util/media-thumb-db.h +++ b/src/include/util/media-thumb-db.h @@ -29,11 +29,22 @@ #define MEDIA_DATABASE_NAME "/opt/dbspace/.media.db" +#ifndef _USE_NEW_MEDIA_DB_ #define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from visual_media where thumbnail_path='' and valid=1;" #define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM visual_media WHERE path='%q';" +#define SELECT_TYPE_BY_PATH "SELECT content_type FROM visual_media WHERE path='%q';" #define UPDATE_THUMB_BY_PATH "UPDATE visual_media SET thumbnail_path = '%q' WHERE path='%q';" #define UPDATE_WH_BY_PATH "UPDATE image_meta SET width=%d,height=%d WHERE visual_uuid=(SELECT visual_uuid FROM visual_media WHERE path='%q');" +#else +#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from media where thumbnail_path is null and validity=1;" +#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM media WHERE path='%q';" +#define SELECT_TYPE_BY_PATH "SELECT media_type FROM media WHERE path='%q';" +#define SELECT_WH_BY_PATH "SELECT width, height FROM media WHERE path='%q';" +#define UPDATE_THUMB_BY_PATH "UPDATE media SET thumbnail_path = '%q' WHERE path='%q';" +#define UPDATE_WH_BY_PATH "UPDATE media SET width=%d,height=%d WHERE path='%q';" +#endif + sqlite3 *_media_thumb_db_get_handle(); int @@ -49,6 +60,14 @@ _media_thumb_get_thumb_from_db(const char *origin_path, int *need_update_db); int +_media_thumb_get_thumb_from_db_with_size(const char *origin_path, + char *thumb_path, + int max_length, + int *need_update_db, + int *width, + int *height); + +int _media_thumb_update_db(const char *origin_path, char *thumb_path, int width, diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h index 7185100..8b455b5 100755 --- a/src/include/util/media-thumb-util.h +++ b/src/include/util/media-thumb-util.h @@ -28,9 +28,15 @@ #define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} -#define THUMB_NONE_TYPE 0x00000001 /* Image */ +#ifndef _USE_NEW_MEDIA_DB_ +#define THUMB_NONE_TYPE 0x00000000 /* None */ #define THUMB_IMAGE_TYPE 0x00000001 /* Image */ -#define THUMB_VIDEO_TYPE 0x00000002 /* Image */ +#define THUMB_VIDEO_TYPE 0x00000002 /* Video */ +#else +#define THUMB_NONE_TYPE -1 /* None */ +#define THUMB_IMAGE_TYPE 0 /* Image */ +#define THUMB_VIDEO_TYPE 1 /* Video */ +#endif #define THUMB_PATH_PHONE "/opt/media" /**< File path prefix of files stored in phone */ #define THUMB_PATH_MMC "/opt/storage/sdcard" /**< File path prefix of files stored in mmc card */ diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c index ad45153..2504480 100755 --- a/src/ipc/media-thumb-ipc.c +++ b/src/ipc/media-thumb-ipc.c @@ -63,8 +63,6 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig struct timeval tv_timeout = { TIMEOUT_SEC, 0 }; - serv_ip = "127.0.0.1"; - if (send_str_len > MAX_PATH_SIZE) { thumb_err("original path's length exceeds %d(max packet size)", MAX_PATH_SIZE); return MEDIA_THUMB_ERROR_INVALID_PARAMETER; @@ -209,7 +207,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg) thumb_path[strlen(thumb_path)] = '\0'; } else if (msg_type == THUMB_REQUEST_SAVE_FILE) { - strncpy(thumb_path, req_msg->dst_path, sizeof(thumb_path)); + strncpy(thumb_path, req_msg->dst_path, max_length); } thumb_dbg("Thumb path : %s", thumb_path); @@ -273,4 +271,122 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg) return 0; } +gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data) +{ + thumb_err("_media_thumb_write_socket is called"); + + thumbMsg recv_msg; + int recv_msg_len; + int recv_str_len; + int sock = 0; + int err = MEDIA_THUMB_ERROR_NONE; + unsigned int from_size; + + struct sockaddr_in from_addr; + + memset((void *)&recv_msg, 0, sizeof(thumbMsg)); + sock = g_io_channel_unix_get_fd(src); + + /* recv a response */ + from_size = sizeof(from_addr); + + if ((recv_msg_len = recvfrom(sock, &recv_msg, sizeof(recv_msg), 0, (struct sockaddr *)&from_addr, &from_size)) < 0) { + + if (errno == EWOULDBLOCK) { + thumb_warn("Timeout. Can't try any more"); + g_io_channel_shutdown(src, TRUE, NULL); + err = MEDIA_THUMB_ERROR_TIMEOUT; + goto callback; + } else { + thumb_err("recvfrom failed"); + g_tries = 0; + g_io_channel_shutdown(src, TRUE, NULL); + err = MEDIA_THUMB_ERROR_NETWORK; + goto callback; + } + } else { + thumb_dbg("recvfrom done"); + } + + recv_msg.org_path[MAX_PATH_SIZE - 1] = '\0'; + recv_str_len = strlen(recv_msg.dst_path); + thumb_dbg("recv %s(%d) from thumb daemon is successful", recv_msg.dst_path, recv_str_len); + + g_io_channel_shutdown(src, TRUE, NULL); + + if (recv_msg.status == THUMB_FAIL) { + thumb_err("Failed to make thumbnail"); + err = MEDIA_THUMB_ERROR_UNSUPPORTED; + goto callback; + } + +callback: + if (data) { + thumbUserData* cb = (thumbUserData*)data; + cb->func(err, recv_msg.dst_path, cb->user_data); + free(cb); + cb = NULL; + } + + return FALSE; +} + +int +_media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData) +{ + int sock; + const char *serv_ip = "127.0.0.1"; + struct sockaddr_in serv_addr; + + int send_str_len = strlen(origin_path); + int pid; + + thumbMsg req_msg; + memset((void *)&req_msg, 0, sizeof(thumbMsg)); + + req_msg.msg_type = msg_type; + req_msg.thumb_type = thumb_type; + strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path)); + req_msg.org_path[strlen(req_msg.org_path)] = '\0'; + + struct timeval tv_timeout = { 0, 100 }; + + if (send_str_len > MAX_PATH_SIZE) { + thumb_err("original path's length exceeds %d(max packet size)", MAX_PATH_SIZE); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + pid = getpid(); + req_msg.pid = pid; + + /* Creaete a datagram/UDP socket */ + if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + thumb_err("socket failed: %d\n", errno); + return MEDIA_THUMB_ERROR_NETWORK; + } + + if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) { + thumb_err("setsockopt failed: %d\n", errno); + return MEDIA_THUMB_ERROR_NETWORK; + } + + GIOChannel *channel = NULL; + channel = g_io_channel_unix_new(sock); + g_io_add_watch(channel, G_IO_IN, _media_thumb_write_socket, userData ); + + memset(&serv_addr, 0, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = inet_addr(serv_ip); + serv_addr.sin_port = htons(THUMB_DAEMON_PORT); + + if (sendto(sock, &req_msg, sizeof(req_msg), 0, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != sizeof(req_msg)) { + thumb_err("sendto failed: %d\n", errno); + g_io_channel_shutdown(channel, TRUE, NULL); + return MEDIA_THUMB_ERROR_NETWORK; + } + + thumb_dbg("Sending msg to thumbnail daemon is successful"); + + return 0; +} diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c index 1f62014..ee7e199 100755 --- a/src/media-thumb-internal.c +++ b/src/media-thumb-internal.c @@ -36,7 +36,8 @@ #include <fcntl.h> #include <unistd.h> -#include <drm-service.h> +//#include <drm-service.h> +#include <drm_client.h> #include <mm_file.h> #include <mm_util_imgp.h> #include <mm_util_jpeg.h> @@ -523,8 +524,6 @@ int _media_thumb_resize_data(unsigned char *src_data, int _media_thumb_get_wh_with_evas(const char *origin_path, int *width, int *height) { /* using evas to get w/h */ - ecore_evas_init(); - Ecore_Evas *ee = ecore_evas_buffer_new(0, 0); if (!ee) { @@ -556,7 +555,6 @@ int _media_thumb_get_wh_with_evas(const char *origin_path, int *width, int *heig thumb_dbg("Width:%d, Height:%d", *width, *height); ecore_evas_free(ee); - ecore_evas_shutdown(); return 0; } @@ -565,15 +563,12 @@ int _media_thumb_decode_with_evas(const char *origin_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info, int need_scale) { - ecore_evas_init(); - Ecore_Evas *resize_img_ee; resize_img_ee = ecore_evas_buffer_new(thumb_width, thumb_height); if (!resize_img_ee) { thumb_err("Failed to create a new ecore evas buffer\n"); - ecore_evas_shutdown(); return -1; } @@ -581,16 +576,13 @@ int _media_thumb_decode_with_evas(const char *origin_path, if (!resize_img_e) { thumb_err("Failed to ecore_evas_get\n"); ecore_evas_free(resize_img_ee); - ecore_evas_shutdown(); return -1; } Evas_Object *source_img = evas_object_image_add(resize_img_e); if (!source_img) { - thumb_dbg - ("evas_object_image_add failed\n"); + thumb_err("evas_object_image_add failed\n"); ecore_evas_free(resize_img_ee); - ecore_evas_shutdown(); return -1; } @@ -626,7 +618,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, if (err < 0) { thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err); ecore_evas_free(resize_img_ee); - ecore_evas_shutdown(); return err; } @@ -649,7 +640,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, if (!target_ee) { thumb_err("Failed to create a ecore evas\n"); ecore_evas_free(resize_img_ee); - ecore_evas_shutdown(); return -1; } @@ -658,7 +648,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, thumb_err("Failed to ecore_evas_get\n"); ecore_evas_free(resize_img_ee); ecore_evas_free(target_ee); - ecore_evas_shutdown(); return -1; } @@ -688,7 +677,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, ecore_evas_free(resize_img_ee); ecore_evas_free(target_ee); - ecore_evas_shutdown(); return MEDIA_THUMB_ERROR_MM_UTIL; } @@ -703,7 +691,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, ecore_evas_free(target_ee); ecore_evas_free(resize_img_ee); - ecore_evas_shutdown(); return 0; } @@ -1135,8 +1122,16 @@ _media_thumb_video(const char *origin_path, int size = 0; int width = 0; int height = 0; + int ret = 0; + drm_bool_type_e drm_type; - is_drm = (drm_svc_is_drm_file(origin_path) == 1); + ret = (drm_is_drm_file(origin_path, &drm_type) == 1); + if (ret < 0) { + thumb_err("drm_is_drm_file falied : %d", ret); + drm_type = DRM_FALSE; + } + + is_drm = drm_type; err = mm_file_create_content_attrs(&content, origin_path); if (err < 0) { @@ -1185,6 +1180,9 @@ _media_thumb_video(const char *origin_path, return MEDIA_THUMB_ERROR_MM_UTIL; } + thumb_info->origin_width = width; + thumb_info->origin_height = height; + if (width > thumb_width || height > thumb_height) { err = _media_thumb_resize_data(frame, width, diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c index 0796bec..1030279 100755 --- a/src/media-thumbnail.c +++ b/src/media-thumbnail.c @@ -116,6 +116,71 @@ int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thu return MEDIA_THUMB_ERROR_NONE; } +int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height) +{ + int err = -1; + int need_update_db = 0; + int width, height = 0; + media_thumb_info thumb_info; + + if (origin_path == NULL || thumb_path == NULL) { + thumb_err("Invalid parameter"); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + if (origin_width == NULL || origin_height == NULL) { + thumb_err("Invalid parameter ( width or height )"); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + if (!g_file_test + (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + thumb_err("Original path(%s) doesn't exist.", origin_path); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + if (max_length <= 0) { + thumb_err("Length is invalid"); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + int store_type = -1; + store_type = _media_thumb_get_store_type_by_path(origin_path); + + if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) { + thumb_err("origin path(%s) is invalid", origin_path); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + thumb_err("Path : %s", origin_path); + + err = _media_thumb_db_connect(); + if (err < 0) { + thumb_err("_media_thumb_mb_svc_connect failed: %d", err); + return MEDIA_THUMB_ERROR_DB; + } + + err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &width, &height); + if (err == 0) { + _media_thumb_db_disconnect(); + return MEDIA_THUMB_ERROR_NONE; + } + + /* Request for thumb file to the daemon "Thumbnail generator" */ + err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info); + if (err < 0) { + thumb_err("_media_thumb_request failed : %d", err); + _media_thumb_db_disconnect(); + return err; + } + + *origin_width = thumb_info.origin_width; + *origin_height = thumb_info.origin_height; + + _media_thumb_db_disconnect(); + return MEDIA_THUMB_ERROR_NONE; +} + int thumbnail_request_extract_all_thumbs(void) { int err = -1; @@ -135,3 +200,41 @@ int thumbnail_request_extract_all_thumbs(void) return MEDIA_THUMB_ERROR_NONE; } +int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data) +{ + int err = -1; + + if (origin_path == NULL) { + thumb_err("Invalid parameter"); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + if (!g_file_test + (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + thumb_err("Original path(%s) doesn't exist.", origin_path); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData)); + userData->func = (ThumbFunc)func; + userData->user_data = user_data; + + int store_type = -1; + store_type = _media_thumb_get_store_type_by_path(origin_path); + + if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) { + thumb_err("origin path(%s) is invalid", origin_path); + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; + } + + thumb_err("Path : %s", origin_path); + + /* Request for thumb file to the daemon "Thumbnail generator" */ + err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, userData); + if (err < 0) { + thumb_err("_media_thumb_request failed : %d", err); + return err; + } + + return MEDIA_THUMB_ERROR_NONE; +} diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c index a379eed..ae84b72 100755 --- a/src/util/media-thumb-db.c +++ b/src/util/media-thumb-db.c @@ -84,6 +84,98 @@ _media_thumb_sqlite_disconnect(sqlite3 *handle) } int +_media_thumb_get_type_from_db(sqlite3 *handle, + const char *origin_path, + int *type) +{ + thumb_dbg("Origin path : %s", origin_path); + + if (handle == NULL) { + thumb_err("DB handle is NULL"); + return -1; + } + + int err = -1; + char *path_string = NULL; + char *query_string = NULL; + sqlite3_stmt *stmt = NULL; + + path_string = sqlite3_mprintf("%s", origin_path); + query_string = sqlite3_mprintf(SELECT_TYPE_BY_PATH, path_string); + + thumb_dbg("Query: %s", query_string); + + err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL); + + sqlite3_free(query_string); + sqlite3_free(path_string); + + if (SQLITE_OK != err) { + thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle)); + return -1; + } + + err = sqlite3_step(stmt); + if (err != SQLITE_ROW) { + thumb_err("end of row [%s]\n", sqlite3_errmsg(handle)); + sqlite3_finalize(stmt); + return -1; + } + + *type = sqlite3_column_int(stmt, 0); + sqlite3_finalize(stmt); + + return MEDIA_THUMB_ERROR_NONE; +} + + +int _media_thumb_get_wh_from_db(sqlite3 *handle, + const char *origin_path, + int *width, + int *height) +{ + thumb_dbg("Origin path : %s", origin_path); + + if (handle == NULL) { + thumb_err("DB handle is NULL"); + return -1; + } + + int err = -1; + char *path_string = NULL; + char *query_string = NULL; + sqlite3_stmt *stmt = NULL; + + path_string = sqlite3_mprintf("%s", origin_path); + query_string = sqlite3_mprintf(SELECT_WH_BY_PATH, path_string); + + thumb_dbg("Query: %s", query_string); + + err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL); + + sqlite3_free(query_string); + sqlite3_free(path_string); + + if (SQLITE_OK != err) { + thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle)); + return -1; + } + + err = sqlite3_step(stmt); + if (err != SQLITE_ROW) { + thumb_err("end of row [%s]\n", sqlite3_errmsg(handle)); + sqlite3_finalize(stmt); + return -1; + } + + *width = sqlite3_column_int(stmt, 0); + *height = sqlite3_column_int(stmt, 1); + sqlite3_finalize(stmt); + + return MEDIA_THUMB_ERROR_NONE; +} + +int _media_thumb_get_thumb_path_from_db(sqlite3 *handle, const char *origin_path, char *thumb_path, @@ -123,7 +215,11 @@ _media_thumb_get_thumb_path_from_db(sqlite3 *handle, return -1; } - strncpy(thumb_path, (const char *)sqlite3_column_text(stmt, 0), max_length); + if (sqlite3_column_text(stmt, 0)) + strncpy(thumb_path, (const char *)sqlite3_column_text(stmt, 0), max_length); + else + thumb_path[0] = '\0'; + sqlite3_finalize(stmt); return MEDIA_THUMB_ERROR_NONE; @@ -304,6 +400,55 @@ _media_thumb_get_thumb_from_db(const char *origin_path, } int +_media_thumb_get_thumb_from_db_with_size(const char *origin_path, + char *thumb_path, + int max_length, + int *need_update_db, + int *width, + int *height) +{ + thumb_dbg(""); + int err = -1; + + //err = minfo_get_thumb_path(mb_svc_handle, origin_path, thumb_path, max_length); + err = _media_thumb_get_thumb_path_from_db(db_handle, origin_path, thumb_path, max_length); + if (err < 0) { + thumb_warn("Original path doesn't exist in DB"); + return -1; + } + + if (strlen(thumb_path) == 0) { + thumb_warn("thumb path doesn't exist in DB"); + *need_update_db = 1; + return -1; + } + + thumb_dbg("Thumb path in DB is %s", thumb_path); + + if (!g_file_test(thumb_path, + G_FILE_TEST_EXISTS)) { + thumb_warn("thumb path doesn't exist in file system"); + *need_update_db = 1; + return -1; + } else { + thumb_dbg("This thumb path already exist"); + int orig_w = 0; + int orig_h = 0; + + err = _media_thumb_get_wh_from_db(db_handle, origin_path, &orig_w, &orig_h); + if (err < 0) { + thumb_err("_media_thumb_get_wh_from_db failed : %d", err); + } else { + thumb_err("_media_thumb_get_wh_from_db Success ( w:%d, h:%d )", orig_w, orig_h); + *width = orig_w; + *height = orig_h; + } + } + + return MEDIA_THUMB_ERROR_NONE; +} + +int _media_thumb_update_db(const char *origin_path, char *thumb_path, int width, @@ -344,15 +489,19 @@ _media_thumb_update_db(const char *origin_path, err = minfo_destroy_mtype_item(item); #endif + int media_type = THUMB_NONE_TYPE; + err = _media_thumb_get_type_from_db(db_handle, origin_path, &media_type); + if (err < 0) { + thumb_err("_media_thumb_get_type_from_db (%s) failed: %d", origin_path, err); + return MEDIA_THUMB_ERROR_DB; + } + err = _media_thumb_update_thumb_path_to_db(db_handle, origin_path, thumb_path); if (err < 0) { thumb_err("_media_thumb_update_thumb_path_to_db (%s) failed: %d", origin_path, err); return MEDIA_THUMB_ERROR_DB; } - int media_type = THUMB_NONE_TYPE; - media_type = _media_thumb_get_file_type(origin_path); - if (media_type == THUMB_IMAGE_TYPE && width > 0 && height > 0) { err = _media_thumb_update_wh_to_db(db_handle, origin_path, width, height); if (err < 0) { diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c index f224c17..88473ac 100755 --- a/src/util/media-thumb-util.c +++ b/src/util/media-thumb-util.c @@ -25,7 +25,7 @@ #include <glib.h> #include <aul.h> #include <string.h> -#include <drm-service.h> +#include <drm_client.h> #include <Evas.h> #include <Ecore_Evas.h> @@ -75,27 +75,43 @@ int _media_thumb_get_file_type(const char *file_full_path) { int ret = 0; + drm_bool_type_e drm_type; + drm_file_type_e drm_file_type; char mimetype[255]; if (file_full_path == NULL) return MEDIA_THUMB_ERROR_INVALID_PARAMETER; - if (drm_svc_is_drm_file(file_full_path) == DRM_TRUE) { - DRM_FILE_TYPE drm_type = DRM_FILE_TYPE_NONE; - drm_type = drm_svc_get_drm_type(file_full_path); - if (drm_type == DRM_FILE_TYPE_NONE) { + ret = drm_is_drm_file(file_full_path, &drm_type); + if (ret < 0) { + thumb_err("drm_is_drm_file falied : %d", ret); + drm_type = DRM_FALSE; + } + + if (drm_type == DRM_TRUE) { + thumb_dbg("DRM file : %s", file_full_path); + + ret = drm_get_file_type(file_full_path, &drm_file_type); + if (ret < 0) { + thumb_err("drm_get_file_type falied : %d", ret); return THUMB_NONE_TYPE; - } - else { - drm_content_info_t contentInfo = { 0 }; + } + + if (drm_file_type == DRM_TYPE_UNDEFINED) { + return THUMB_NONE_TYPE; + } else { + drm_content_info_s contentInfo; + memset(&contentInfo, 0x00, sizeof(drm_content_info_s)); - ret = drm_svc_get_content_info(file_full_path, &contentInfo); - if (ret != DRM_RESULT_SUCCESS) { - thumb_err("drm_svc_get_content_info() fails. "); + ret = drm_get_content_info(file_full_path, &contentInfo); + if (ret != DRM_RETURN_SUCCESS) { + thumb_err("drm_get_content_info() fails. : %d", ret); return THUMB_NONE_TYPE; } + thumb_dbg("DRM mime type: %s", contentInfo.mime_type); - strncpy(mimetype, contentInfo.contentType, sizeof(mimetype)); + strncpy(mimetype, contentInfo.mime_type, sizeof(mimetype) - 1); + mimetype[sizeof(mimetype) - 1] = '\0'; } } else { /* get content type and mime type from file. */ @@ -216,20 +232,27 @@ int _media_thumb_save_to_file_with_evas(unsigned char *data, int w, int h, char *thumb_path) -{ - ecore_evas_init(); - +{ Ecore_Evas *ee = ecore_evas_buffer_new(w, h); + if (ee == NULL) { + thumb_err("Failed to create a new ecore evas buffer\n"); + return -1; + } + Evas *evas = ecore_evas_get(ee); + if (evas == NULL) { + thumb_err("Failed to ecore_evas_get\n"); + ecore_evas_free(ee); + return -1; + } Evas_Object *img = NULL; img = evas_object_image_add(evas); if (img == NULL) { - thumb_dbg("image object is NULL\n"); + thumb_err("image object is NULL\n"); ecore_evas_free(ee); - ecore_evas_shutdown(); return -1; } @@ -244,13 +267,11 @@ int _media_thumb_save_to_file_with_evas(unsigned char *data, (img, thumb_path, NULL, "quality=100 compress=1")) { thumb_dbg("evas_object_image_save success\n"); ecore_evas_free(ee); - ecore_evas_shutdown(); return 0; } else { thumb_dbg("evas_object_image_save failed\n"); ecore_evas_free(ee); - ecore_evas_shutdown(); return -1; } } |