summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminje.ahn <minje.ahn@samsung.com>2022-08-30 10:59:39 +0900
committerminje.ahn <minje.ahn@samsung.com>2022-08-30 11:11:55 +0900
commit3109ba893189415b037a751f78eddc619474ce7b (patch)
treeac7ff51fc12178b26902ee5260a99b2b67c28a78
parentfc35eda8c93d85d14405494bbf244888898ef856 (diff)
downloadlibmedia-thumbnail-3109ba893189415b037a751f78eddc619474ce7b.tar.gz
libmedia-thumbnail-3109ba893189415b037a751f78eddc619474ce7b.tar.bz2
libmedia-thumbnail-3109ba893189415b037a751f78eddc619474ce7b.zip
Remove thumbnail-server
The functions below have been deprecated since 5.0: - media_info_create_thumbnail() - media_info_cancel_thumbnail() According to the internal code modification of the above APIs, unused code is removed. Change-Id: Id2d83f9d3b183ce2a2d82a8ea9e88fc29cd4181d Signed-off-by: minje.ahn <minje.ahn@samsung.com>
-rw-r--r--CMakeLists.txt17
-rw-r--r--NOTICE4
-rwxr-xr-xinclude/media-thumbnail-debug.h (renamed from src/include/util/media-thumb-debug.h)7
-rwxr-xr-xinclude/media-thumbnail.h8
-rwxr-xr-xmd5/md5.c252
-rwxr-xr-xmd5/md5.h38
-rwxr-xr-xmd5/media-thumb-hash.c107
-rwxr-xr-xmedia-thumbnail.pc.in2
-rw-r--r--packaging/libmedia-thumbnail.spec24
-rw-r--r--packaging/media-thumbnail-server.manifest5
-rwxr-xr-xserver/CMakeLists.txt19
-rwxr-xr-xserver/include/thumb-server-internal.h33
-rwxr-xr-xserver/thumb-server-internal.c251
-rwxr-xr-xserver/thumb-server.c71
-rwxr-xr-xsrc/include/ipc/media-thumb-ipc.h41
-rwxr-xr-xsrc/include/media-thumb-internal.h36
-rwxr-xr-xsrc/include/util/media-thumb-db.h39
-rwxr-xr-xsrc/include/util/media-thumb-util.h45
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c286
-rwxr-xr-xsrc/media-thumb-internal.c70
-rwxr-xr-xsrc/media-thumbnail.c52
-rwxr-xr-xsrc/util/media-thumb-db.c92
-rwxr-xr-xsrc/util/media-thumb-util.c110
-rwxr-xr-xunittest/libmedia_thumbnail_unittest.cpp22
24 files changed, 27 insertions, 1604 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3313844..c74eb53 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,15 +4,8 @@ SET(VERSION_MAJOR 1)
SET(VERSION "${VERSION_MAJOR}.0.0")
SET(MEDIATHUMB-LIB "media-thumbnail")
-SET(MEDIAHASH-LIB "media-hash")
SET(SRCS
src/media-thumbnail.c
- src/util/media-thumb-util.c
- src/ipc/media-thumb-ipc.c
- )
-SET(HASH_SRCS
- md5/md5.c
- md5/media-thumb-hash.c
)
SET(VENDOR "samsung")
@@ -31,10 +24,10 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/ipc ${CMAKE_SOURCE_DIR}/server/include ${CMAKE_SOURCE_DIR}/md5)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE(FindPkgConfig)
- pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 mm-fileinfo aul libmedia-utils libtzplatform-config mmutil-common mmutil-magick)
+ pkg_check_modules(pkgs REQUIRED glib-2.0 dlog mm-fileinfo aul libmedia-utils libtzplatform-config mmutil-common mmutil-magick)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -63,18 +56,12 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/media-thumbnail.pc DESTINATION ${LIB_I
LINK_DIRECTORIES(${LIB_INSTALL_DIR})
-ADD_LIBRARY(${MEDIAHASH-LIB} SHARED ${HASH_SRCS})
-SET_TARGET_PROPERTIES(${MEDIAHASH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${MEDIAHASH-LIB} PROPERTIES VERSION ${VERSION})
ADD_LIBRARY(${MEDIATHUMB-LIB} SHARED ${SRCS})
TARGET_LINK_LIBRARIES(${MEDIATHUMB-LIB} ${pkgs_LDFLAGS} ${MEDIAHASH-LIB})
SET_TARGET_PROPERTIES(${MEDIATHUMB-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${MEDIATHUMB-LIB} PROPERTIES VERSION ${VERSION})
INSTALL(TARGETS ${MEDIATHUMB-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
-INSTALL(TARGETS ${MEDIAHASH-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
-
-ADD_SUBDIRECTORY(server)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumbnail.h DESTINATION include/${MEDIATHUMB-LIB})
IF(BUILD_GTESTS)
diff --git a/NOTICE b/NOTICE
index 35369be..ccdad52 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,7 +1,3 @@
Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
Except as noted, this software is licensed under Apache License, Version 2.
Please, see the LICENSE file for Apache License terms and conditions.
-
-Some parts of libmedia-thumbnail are licensed under the Public domain
- - md5/md5.c
- - md5/md5.h
diff --git a/src/include/util/media-thumb-debug.h b/include/media-thumbnail-debug.h
index 2aa517f..e7cd9e0 100755
--- a/src/include/util/media-thumb-debug.h
+++ b/include/media-thumbnail-debug.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef _MEDIA_THUMB_DEBUG_H_
-#define _MEDIA_THUMB_DEBUG_H_
+#ifndef _MEDIA_THUMBNAIL_DEBUG_H_
+#define _MEDIA_THUMBNAIL_DEBUG_H_
#include <stdio.h>
#include <stdlib.h>
@@ -98,5 +98,4 @@
} \
} while (0)
-#endif /*_MEDIA_THUMB_DEBUG_H_*/
-
+#endif /*_MEDIA_THUMBNAIL_DEBUG_H_*/
diff --git a/include/media-thumbnail.h b/include/media-thumbnail.h
index 77511c6..3e6dc84 100755
--- a/include/media-thumbnail.h
+++ b/include/media-thumbnail.h
@@ -31,13 +31,7 @@
extern "C" {
#endif
-#define CONTENT_THUMB_DEFAULT_WIDTH 320
-#define CONTENT_THUMB_DEFAULT_HEIGHT 240
-
-typedef int (*ThumbFunc) (int error_code, char* path, void* data);
-
-int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_path, ThumbFunc func, void *user_data, uid_t uid);
-int thumbnail_request_cancel_media(unsigned int request_id);
+#define THUMB_STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? true : false)
int create_video_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path, bool auto_rotate);
int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height, bool auto_rotate, bool is_server_request);
diff --git a/md5/md5.c b/md5/md5.c
deleted file mode 100755
index c223cfe..0000000
--- a/md5/md5.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h> /* for memcpy() */
-#include "md5.h"
-
-#if (__BYTE_ORDER == 1234)
-#define byteReverse(buf, len) /* Nothing */
-#else
-void byteReverse(unsigned char *buf, unsigned longs);
-
-/*
- * Note: this code is harmless on little-endian machines.
- */
-void byteReverse(unsigned char *buf, unsigned longs)
-{
- uint32_t t;
- do {
- t = (uint32_t) ((unsigned)buf[3] << 8 | buf[2]) << 16 |
- ((unsigned)buf[1] << 8 | buf[0]);
- *(uint32_t *) buf = t;
- buf += 4;
- } while (--longs);
-}
-#endif
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-void media_thumb_MD5Init(MD5_CTX *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-void media_thumb_MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
-{
- uint32_t t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) {
- ctx->bits[1]++; /* Carry from low to high */
- }
-
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- unsigned char *p = (unsigned char *)ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
- }
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memcpy(ctx->in, buf, len);
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-void media_thumb_MD5Final(unsigned char digest[16], MD5_CTX *ctx)
-{
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- memcpy(((uint32_t *) ctx->in)+14, ctx->bits, sizeof(uint32_t)*2);
-
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- byteReverse((unsigned char *)ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset((char *)ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
-}
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
-#define F2(x, y, z) (F1((z), (x), (y)))
-#define F3(x, y, z) ((x) ^ (y) ^ (z))
-#define F4(x, y, z) ((y) ^ ((x) | ~(z)))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
-(w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x)
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-void MD5Transform(uint32_t buf[4], uint32_t const in[16])
-{
- register uint32_t a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
diff --git a/md5/md5.h b/md5/md5.h
deleted file mode 100755
index 72c9994..0000000
--- a/md5/md5.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-
-#ifndef _MD5_H_
-#define _MD5_H_
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#define MD5_HASHBYTES 16
-
-typedef struct MD5Context {
- uint32_t buf[4];
- uint32_t bits[2];
- unsigned char in[64];
-} MD5_CTX;
-
-extern void media_thumb_MD5Init(MD5_CTX *context);
-extern void media_thumb_MD5Update(MD5_CTX *context, unsigned char const *buf, unsigned len);
-extern void media_thumb_MD5Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context);
-extern void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
-
-#endif
diff --git a/md5/media-thumb-hash.c b/md5/media-thumb-hash.c
deleted file mode 100755
index b0a94f7..0000000
--- a/md5/media-thumb-hash.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "md5.h"
-#include <string.h>
-#include <alloca.h>
-#include <media-util-err.h>
-
-
-static const char ACCEPTABLE_URI_CHARS[96] = {
- /* ! " # $ % & ' ( ) * + , - . / */
- 0x00, 0x3F, 0x20, 0x20, 0x28, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x2A,
- 0x28, 0x3F, 0x3F, 0x1C,
- /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20,
- 0x20, 0x2C, 0x20, 0x20,
- /* @ A B C D E F G H I J K L M N O */
- 0x38, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x3F, 0x3F, 0x3F, 0x3F,
- /* P Q R S T U V W X Y Z [ \ ] ^ _ */
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
- 0x20, 0x20, 0x20, 0x3F,
- /* ` a b c d e f g h i j k l m n o */
- 0x20, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x3F, 0x3F, 0x3F, 0x3F,
- /* p q r s t u v w x y z { | } ~ DEL */
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
- 0x20, 0x20, 0x3F, 0x20
-};
-
-char *_media_thumb_generate_hash_name(const char *file)
-{
- int n;
- MD5_CTX ctx;
- static char md5out[(2 * MD5_HASHBYTES) + 1];
- unsigned char hash[MD5_HASHBYTES];
- static const char hex[] = "0123456789abcdef";
-
- char *uri;
- char *t;
- const unsigned char *c;
- int length;
-
- if (!file) {
- return NULL;
- }
-
- length = 3 * strlen(file) + 9;
-
- memset(md5out, 0, sizeof(md5out));
-
-#define _check_uri_char(c) \
-((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
-
- uri = alloca(length);
- if (uri == NULL) {
- return NULL;
- }
-
- strncpy(uri, "file://", length);
- uri[length - 1] = '\0';
- t = uri + sizeof("file://") - 1;
-
- for (c = (const unsigned char *)file; *c != '\0'; c++) {
- if (!_check_uri_char(*c)) {
- *t++ = '%';
- *t++ = hex[*c >> 4];
- *t++ = hex[*c & 15];
- } else {
- *t++ = *c;
- }
- }
- *t = '\0';
-#undef _check_uri_char
-
- memset(&ctx, 0x00, sizeof(MD5_CTX));
-
- media_thumb_MD5Init(&ctx);
- media_thumb_MD5Update(&ctx, (unsigned char const *)uri, (unsigned)strlen(uri));
- media_thumb_MD5Final(hash, &ctx);
-
- for (n = 0; n < MD5_HASHBYTES; n++) {
- md5out[2 * n] = hex[hash[n] >> 4];
- md5out[2 * n + 1] = hex[hash[n] & 0x0f];
- }
- md5out[2 * n] = '\0';
-
- return md5out;
-}
diff --git a/media-thumbnail.pc.in b/media-thumbnail.pc.in
index 2ba5b97..d9e8954 100755
--- a/media-thumbnail.pc.in
+++ b/media-thumbnail.pc.in
@@ -9,5 +9,5 @@ Name: @PROJECT_NAME@
Description: Samsung Linux platform @PROJECT_NAME@ library
Version: @VERSION@
Requires:
-Libs: -L${libdir} -lmedia-thumbnail -lmedia-hash
+Libs: -L${libdir} -lmedia-thumbnail
Cflags: -I${includedir}/media-thumbnail
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index bdfed4c..92c04a3 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -1,22 +1,19 @@
Name: libmedia-thumbnail
Summary: Media thumbnail service library for multimedia applications
-Version: 0.3.5
+Version: 0.4.0
Release: 0
Group: Multimedia/Libraries
-License: Apache-2.0 and PD
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Source1001: %{name}.manifest
Source1002: %{name}-devel.manifest
-Source1003: media-thumbnail-server.manifest
-Requires: media-server
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(mm-fileinfo)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(libmedia-utils)
BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(mmutil-common)
BuildRequires: pkgconfig(mmutil-magick)
%if 0%{?gtests:1}
@@ -35,18 +32,9 @@ Group: Multimedia/Development
%description devel
Description: Media thumbnail service library for multimedia applications (development)
-%package -n media-thumbnail-server
-Summary: Thumbnail generator
-Requires: %{name} = %{version}-%{release}
-Group: Multimedia/Service
-
-%description -n media-thumbnail-server
-Description: Media Thumbnail Server
-
-
%prep
%setup -q
-cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} .
+cp %{SOURCE1001} %{SOURCE1002} .
%build
@@ -75,9 +63,3 @@ make %{?_smp_mflags}
%{_libdir}/*.so
%{_libdir}/pkgconfig/media-thumbnail.pc
%{_includedir}/media-thumbnail/*.h
-
-%files -n media-thumbnail-server
-%manifest media-thumbnail-server.manifest
-%defattr(-,root,root,-)
-%{_bindir}/media-thumbnail-server
-%license LICENSE.APLv2.0
diff --git a/packaging/media-thumbnail-server.manifest b/packaging/media-thumbnail-server.manifest
deleted file mode 100644
index c00c25b..0000000
--- a/packaging/media-thumbnail-server.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
deleted file mode 100755
index e0fbb06..0000000
--- a/server/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-SET(THUMB-SERVER
- ../src/util/media-thumb-db.c
- ../src/media-thumb-internal.c
- thumb-server.c
- thumb-server-internal.c)
-
-INCLUDE(FindPkgConfig)
- pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo aul libmedia-utils libtzplatform-config)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -pie")
-
-ADD_EXECUTABLE(media-thumbnail-server ${THUMB-SERVER})
-TARGET_LINK_LIBRARIES(media-thumbnail-server ${pkgs_LDFLAGS} ${MEDIATHUMB-LIB} )
-INSTALL(TARGETS media-thumbnail-server DESTINATION ${BINDIR})
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
deleted file mode 100755
index 5d862c9..0000000
--- a/server/include/thumb-server-internal.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * media-thumbnail-server
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <glib.h>
-#include "media-thumb-ipc.h"
-#include "media-thumb-db.h"
-
-#ifndef _THUMB_DAEMON_INTERNAL_H_
-#define _THUMB_DAEMON_INTERNAL_H_
-
-gboolean _thumb_daemon_start_jobs(gpointer data);
-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
deleted file mode 100755
index b536ed1..0000000
--- a/server/thumb-server-internal.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * media-thumbnail-server
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "thumb-server-internal.h"
-#include "media-thumb-util.h"
-#include "media-thumb-debug.h"
-#include "media-thumbnail.h"
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <tzplatform_config.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "MEDIA_THUMBNAIL_SERVER"
-#define THUMB_COMM_SOCK_PATH tzplatform_mkpath(TZ_SYS_RUN, "media-server/media_ipc_thumbcomm.socket")
-#define THUMB_EMPTY_STR ""
-
-static int __thumbnail_get_data(const char *origin_path, char *thumb_path)
-{
- int err = MS_MEDIA_ERR_NONE;
- int file_type = THUMB_NONE_TYPE;
-
- thumb_retvm_if(!origin_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Original path is null");
- thumb_retvm_if(!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR), MS_MEDIA_ERR_INVALID_PARAMETER, "Original path(%s) does not exist", origin_path);
- thumb_dbg_slog("Origin path : %s", origin_path);
-
- file_type = _media_thumb_get_file_type(origin_path);
-
- if (file_type == THUMB_IMAGE_TYPE) {
- err = create_image_thumbnail_to_file(origin_path, CONTENT_THUMB_DEFAULT_WIDTH, CONTENT_THUMB_DEFAULT_HEIGHT, thumb_path, true);
- } else if (file_type == THUMB_VIDEO_TYPE) {
- err = create_video_thumbnail_to_file(origin_path, CONTENT_THUMB_DEFAULT_WIDTH, CONTENT_THUMB_DEFAULT_HEIGHT, thumb_path, true);
- } else {
- thumb_err("invalid file type");
- return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
- }
-
- thumb_dbg("Thumb data is generated successfully");
-
- return err;
-}
-
-static int __media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- thumb_retvm_if(!req_msg || !res_msg, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid msg");
-
- memset(res_msg->dst_path, 0, MAX_FILEPATH_LEN);
- res_msg->status = MS_MEDIA_ERR_NONE;
-
- if (!g_file_test(req_msg->org_path, G_FILE_TEST_IS_REGULAR)) {
- thumb_err("origin_path does not exist in file system.");
- res_msg->status = MS_MEDIA_ERR_FILE_NOT_EXIST;
- return MS_MEDIA_ERR_FILE_NOT_EXIST;
- }
-
- err = _media_thumb_get_thumb_from_db(req_msg->org_path, res_msg->dst_path, MAX_FILEPATH_LEN, req_msg->uid);
- thumb_retvm_if(err == MS_MEDIA_ERR_NONE, err, "Already exists");
- if (strlen(res_msg->dst_path) == 0) {
- err = _media_thumb_get_hash_name(req_msg->org_path, res_msg->dst_path, MAX_FILEPATH_LEN, req_msg->uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_get_hash_name failed - %d", err);
- SAFE_STRLCPY(res_msg->dst_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
- res_msg->status = err;
- return err;
- }
- }
-
- thumb_dbg_slog("Thumb path : %s", res_msg->dst_path);
-
- err = __thumbnail_get_data(req_msg->org_path, res_msg->dst_path);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_thumbnail_get_data failed - %d", err);
- SAFE_STRLCPY(res_msg->dst_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
- res_msg->status = err;
-
- goto DB_UPDATE;
- }
-
- res_msg->msg_type = THUMB_RESPONSE;
-
-DB_UPDATE:
- err = _media_thumb_update_db(req_msg->org_path, res_msg->dst_path, req_msg->uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_update_db failed : %d", err);
- res_msg->status = err;
- }
-
- return err;
-}
-
-static int __thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
-{
- thumb_retv_if(req_msg->msg_type != THUMB_REQUEST_DB_INSERT, MS_MEDIA_ERR_NONE);
- return __media_thumb_process(req_msg, res_msg);
-}
-
-static void __thumb_server_send_deny_message(int sockfd)
-{
- thumbMsg msg = {0};
-
- msg.msg_type = THUMB_RESPONSE;
- msg.status = MS_MEDIA_ERR_PERMISSION_DENIED;
-
- if (send(sockfd, &msg, sizeof(msg), 0) < 0)
- thumb_stderror("send failed");
-}
-
-gboolean _thumb_daemon_start_jobs(gpointer data)
-{
- int client_sock;
- struct sockaddr_un serv_addr;
- ms_thumb_server_msg send_msg;
-
- if (ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &client_sock) < 0) {
- thumb_err("ms_ipc_create_server_socket failed");
- return G_SOURCE_REMOVE;
- }
-
- memset(&serv_addr, 0, sizeof(serv_addr));
-
- serv_addr.sun_family = AF_UNIX;
- SAFE_STRLCPY(serv_addr.sun_path, THUMB_COMM_SOCK_PATH, sizeof(serv_addr.sun_path));
-
- /* Connecting to the thumbnail server */
- if (connect(client_sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- thumb_stderror("connect");
- goto ERROR;
- }
-
- send_msg.msg_type = MS_MSG_THUMB_SERVER_READY;
-
- if (send(client_sock, &send_msg, sizeof(ms_thumb_server_msg), 0) < 0) {
- thumb_stderror("send failed");
- goto ERROR;
- }
-
- thumb_dbg("Sending msg to thumbnail agent[%d] is successful", send_msg.msg_type);
-ERROR:
- close(client_sock);
-
- return G_SOURCE_REMOVE;
-}
-
-gboolean _thumb_server_read_socket(GIOChannel *channel, GIOCondition condition, gpointer data)
-{
- struct sockaddr_un client_addr;
- unsigned int client_addr_len;
- thumbMsg recv_msg;
- thumbMsg res_msg;
- ms_peer_credentials credentials;
- GMainLoop *thumb_server = (GMainLoop *)data;
-
- int sock = -1;
- int client_sock = -1;
-
- memset((void *)&recv_msg, 0, sizeof(recv_msg));
- memset((void *)&res_msg, 0, sizeof(res_msg));
- memset((void *)&credentials, 0, sizeof(credentials));
-
- sock = g_io_channel_unix_get_fd(channel);
- thumb_retvm_if(sock < 0, G_SOURCE_CONTINUE, "sock fd is invalid!");
-
- client_addr_len = sizeof(client_addr);
-
- if ((client_sock = accept(sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
- thumb_stderror("accept failed");
- return G_SOURCE_CONTINUE;
- }
-
- if (ms_cynara_receive_untrusted_message_thumb(client_sock, &recv_msg, &credentials) != MS_MEDIA_ERR_NONE) {
- thumb_err("ms_cynara_receive_untrusted_message_thumb failed");
- goto ERROR;
- }
-
- if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
- thumb_warn("Shutting down...");
- g_main_loop_quit(thumb_server);
- close(client_sock);
-
- return G_SOURCE_REMOVE;
- }
-
- if (ms_cynara_check(&credentials, MEDIA_STORAGE_PRIVILEGE) != MS_MEDIA_ERR_NONE) {
- thumb_err("Cynara denied access to process request");
- __thumb_server_send_deny_message(client_sock);
- goto ERROR;
- }
-
- SAFE_FREE(credentials.smack);
- SAFE_FREE(credentials.uid);
-
- thumb_warn_slog("Received [%d] %.*s(%zu) from PID(%d)", recv_msg.msg_type, MAX_FILEPATH_LEN, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid);
-
- __thumb_daemon_process_job(&recv_msg, &res_msg);
- if (res_msg.msg_type == 0)
- res_msg.msg_type = recv_msg.msg_type;
- res_msg.request_id = recv_msg.request_id;
- SAFE_STRLCPY(res_msg.org_path, recv_msg.org_path, sizeof(res_msg.org_path));
-
- if (send(client_sock, &res_msg, sizeof(res_msg), 0) < 0)
- thumb_stderror("send failed");
-
-ERROR:
- close(client_sock);
-
- return G_SOURCE_CONTINUE;
-}
-
-gboolean _thumb_server_prepare_socket(int *sock_fd)
-{
- int sock;
-
- if (ms_ipc_create_server_socket(MS_THUMB_DAEMON_PORT, &sock) < 0) {
- thumb_err("ms_ipc_create_server_socket failed");
- return FALSE;
- }
-
- if (ms_cynara_enable_credentials_passing(sock) != MS_MEDIA_ERR_NONE) {
- thumb_err("ms_cynara_enable_credentials_passing failed");
- close(sock);
- return FALSE;
- }
-
- *sock_fd = sock;
-
- return TRUE;
-}
diff --git a/server/thumb-server.c b/server/thumb-server.c
deleted file mode 100755
index 750f782..0000000
--- a/server/thumb-server.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * media-thumbnail-server
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "media-thumbnail.h"
-#include "media-thumb-debug.h"
-#include "media-thumb-ipc.h"
-#include "media-thumb-util.h"
-#include "thumb-server-internal.h"
-#include <pthread.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "MEDIA_THUMBNAIL_SERVER"
-
-static GMainLoop *g_thumb_server_mainloop;
-
-int main(void)
-{
- int sockfd = -1;
- GIOChannel *channel = NULL;
-
- if (ms_cynara_initialize() != MS_MEDIA_ERR_NONE) {
- thumb_err("Cynara initialization failed");
- return -1;
- }
-
- /* Create and bind new tcp socket */
- if (!_thumb_server_prepare_socket(&sockfd)) {
- thumb_err("Failed to create socket");
- return -1;
- }
-
- g_thumb_server_mainloop = g_main_loop_new(NULL, FALSE);
-
- /* Create new channel to watch tcp socket */
- channel = g_io_channel_unix_new(sockfd);
- g_io_add_watch(channel, G_IO_IN, _thumb_server_read_socket, g_thumb_server_mainloop);
- g_io_channel_unref(channel);
-
- g_idle_add(_thumb_daemon_start_jobs, NULL);
-
- thumb_info("Thumbnail server is running");
- g_main_loop_run(g_thumb_server_mainloop);
-
- thumb_info("Thumbnail server is shutting down");
- close(sockfd);
- g_main_loop_unref(g_thumb_server_mainloop);
- ms_cynara_finish();
-
- return 0;
-}
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h
deleted file mode 100755
index 58d58fc..0000000
--- a/src/include/ipc/media-thumb-ipc.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#include <sys/un.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/types.h>
-
-#include "media-thumb-internal.h"
-#include "media-util-ipc.h"
-#include "media-server-ipc.h"
-
-#ifndef _MEDIA_THUMB_IPC_H_
-#define _MEDIA_THUMB_IPC_H_
-
-int _media_thumb_request_async(int msg_type, unsigned int request_id, const char *origin_path, thumbUserData *userData, uid_t uid);
-
-#endif /*_MEDIA_THUMB_IPC_H_*/
diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h
deleted file mode 100755
index 175dd12..0000000
--- a/src/include/media-thumb-internal.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <media-util-err.h>
-#include "media-thumbnail.h"
-#include "media-thumb-util.h"
-
-#ifndef _MEDIA_THUMB_INTERNAL_H_
-#define _MEDIA_THUMB_INTERNAL_H_
-
-typedef struct {
- ThumbFunc func;
- void *user_data;
-} thumbUserData;
-
-int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
-
-#endif /*_MEDIA_THUMB_INTERNAL_H_*/
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
deleted file mode 100755
index 27c21ed..0000000
--- a/src/include/util/media-thumb-db.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sqlite3.h>
-#include <media-util.h>
-
-#ifndef _MEDIA_THUMB_DB_H_
-#define _MEDIA_THUMB_DB_H_
-
-#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
-#define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); }
-#define SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
-
-#define SELECT_THUMB_BY_PATH "SELECT media_thumbnail_path FROM media WHERE media_path='%q' AND media_thumbnail_path IS NOT NULL;"
-#define UPDATE_THUMB_BY_PATH "UPDATE media SET media_thumbnail_path = '%q' WHERE media_path='%q';"
-
-int _media_thumb_get_thumb_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid);
-int _media_thumb_update_db(const char *origin_path, char *thumb_path, uid_t uid);
-
-#endif /*_MEDIA_THUMB_DB_H_*/
-
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
deleted file mode 100755
index 59a85f7..0000000
--- a/src/include/util/media-thumb-util.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef _MEDIA_THUMB_UTIL_H_
-#define _MEDIA_THUMB_UTIL_H_
-
-#define SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
-#define STRING_VALID(str) \
- ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
-#define THUMB_MALLOC(src, size) { if (size <= 0) {src = NULL; } \
- else { src = malloc(size); if (src) memset(src, 0x0, size); } }
-#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
-
-#define THUMB_NONE_TYPE -1 /* None */
-#define THUMB_IMAGE_TYPE 0 /* Image */
-#define THUMB_VIDEO_TYPE 1 /* Video */
-
-int _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
-int _media_thumb_get_file_type(const char *file_full_path);
-
-char* _media_thumb_generate_hash_name(const char *file);
-
-#endif /*_MEDIA_THUMB_UTIL_H_*/
-
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
deleted file mode 100755
index 4975b3c..0000000
--- a/src/ipc/media-thumb-ipc.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "media-thumbnail.h"
-#include "media-thumb-ipc.h"
-#include "media-thumb-util.h"
-#include "media-thumb-db.h"
-#include "media-thumb-debug.h"
-#include <glib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <grp.h>
-#include <pwd.h>
-
-#define THUMB_IPC_PATH tzplatform_mkpath(TZ_SYS_RUN, "media-server/media_ipc_thumbcreator.socket")
-
-static GQueue *g_manage_queue = NULL;
-
-
-typedef struct {
- GIOChannel *channel;
- int msg_type;
- unsigned int request_id;
- bool isCanceled;
- bool isRequested;
- int source_id;
- uid_t uid;
- char *path;
- thumbUserData *userData;
-} thumbReq;
-
-static int __media_thumb_send_request(void);
-
-static int __media_thumb_cancel(unsigned int request_id)
-{
- int len = 0, i;
- thumbReq *req = NULL;
-
- thumb_retv_if(!g_manage_queue, MS_MEDIA_ERR_NONE);
-
- len = g_queue_get_length(g_manage_queue);
-
- for (i = 0; i < len; i++) {
- req = (thumbReq *)g_queue_peek_nth(g_manage_queue, i);
- if (!req)
- continue;
-
- if (req->request_id == request_id) {
- if (req->isRequested) {
- req->isCanceled = true;
- } else {
- g_queue_pop_nth(g_manage_queue, i);
-
- SAFE_FREE(req->path);
- SAFE_FREE(req->userData);
- SAFE_FREE(req);
- }
-
- return MS_MEDIA_ERR_NONE;
- }
- }
-
- return MS_MEDIA_ERR_INTERNAL;
-}
-
-static bool __media_thumb_is_canceled(void)
-{
- thumbReq *req = (thumbReq *)g_queue_peek_head(g_manage_queue);
-
- if (!req)
- return true;
-
- return req->isCanceled;
-}
-
-static int __media_thumb_recv_msg(int sock, thumbMsg *msg)
-{
- if (!msg)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- if (recv(sock, msg, sizeof(thumbMsg), 0) < 0) {
- thumb_stderror("recv failed");
- return MS_MEDIA_ERR_IPC;
- }
-
- thumb_retvm_if(strlen(msg->org_path) == 0 || strlen(msg->org_path) >= MAX_FILEPATH_LEN, MS_MEDIA_ERR_IPC, "Invalid org_path");
- thumb_retvm_if(strlen(msg->dst_path) >= MAX_FILEPATH_LEN, MS_MEDIA_ERR_IPC, "Invalid dst_path");
-
- return MS_MEDIA_ERR_NONE;
-}
-
-static void __media_thumb_pop(void)
-{
- int len = 0;
- int sock = 0;
- thumbReq *req = NULL;
- GSource *source_id = NULL;
-
- if (!g_manage_queue)
- return;
-
- req = (thumbReq *)g_queue_pop_head(g_manage_queue);
- if (req) {
- source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id);
- sock = g_io_channel_unix_get_fd(req->channel);
-
- g_io_channel_shutdown(req->channel, TRUE, NULL);
- g_io_channel_unref(req->channel);
- close(sock);
- if (source_id)
- g_source_destroy(source_id);
-
- SAFE_FREE(req->path);
- SAFE_FREE(req->userData);
- SAFE_FREE(req);
- }
-
- /* Check manage queue */
- len = g_queue_get_length(g_manage_queue);
- if (len > 0)
- __media_thumb_send_request();
-}
-
-static gboolean __media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
-{
- thumbMsg recv_msg;
- int sock = 0;
- int err = MS_MEDIA_ERR_NONE;
- thumbUserData *userdata = NULL;
-
- memset((void *)&recv_msg, 0, sizeof(thumbMsg));
- sock = g_io_channel_unix_get_fd(src);
-
- if ((err = __media_thumb_recv_msg(sock, &recv_msg)) < 0) {
- thumb_err("_media_thumb_recv_msg failed ");
- goto NEXT;
- }
-
- if (recv_msg.status != MS_MEDIA_ERR_NONE) {
- err = recv_msg.status;
- thumb_err("Failed to make thumbnail (%d)", err);
- }
-
- if (__media_thumb_is_canceled() || !data)
- goto NEXT;
-
- userdata = (thumbUserData*)data;
- if (userdata->func)
- userdata->func(err, recv_msg.dst_path, userdata->user_data);
-
- thumb_dbg("Done");
-NEXT:
- __media_thumb_pop();
-
- return G_SOURCE_REMOVE;
-}
-
-static int __media_thumb_send_request(void)
-{
- int err = MS_MEDIA_ERR_NONE;
- int sock = -1;
- struct sockaddr_un serv_addr;
- thumbReq *req_manager = NULL;
- int pid;
-
- err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "ms_ipc_create_client_socket failed");
-
- memset(&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sun_family = AF_UNIX;
- SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
-
- GIOChannel *channel = NULL;
- channel = g_io_channel_unix_new(sock);
- int source_id = -1;
-
- /* Connecting to the thumbnail server */
- if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- thumb_stderror("connect");
- if (errno == EACCES)
- err = MS_MEDIA_ERR_PERMISSION_DENIED;
- else
- err = MS_MEDIA_ERR_IPC;
-
- g_io_channel_shutdown(channel, TRUE, NULL);
- g_io_channel_unref(channel);
- close(sock);
-
- return err;
- }
-
- req_manager = (thumbReq *)g_queue_peek_head(g_manage_queue);
- if (!req_manager) {
- thumb_err("queue peek fail");
- g_io_channel_shutdown(channel, TRUE, NULL);
- g_io_channel_unref(channel);
- close(sock);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- GSource *source = NULL;
- source = g_io_create_watch(channel, G_IO_IN);
- g_source_set_callback(source, (GSourceFunc)__media_thumb_write_socket, req_manager->userData, NULL);
- source_id = g_source_attach(source, g_main_context_get_thread_default());
-
- thumbMsg req_msg;
- memset((void *)&req_msg, 0, sizeof(thumbMsg));
-
- pid = getpid();
- req_msg.pid = pid;
- req_msg.msg_type = req_manager->msg_type;
- req_msg.request_id = 0;
- req_msg.uid = req_manager->uid;
- SAFE_STRLCPY(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
- req_msg.dst_path[0] = '\0';
-
- if (send(sock, &req_msg, sizeof(req_msg), 0) < 0) {
- thumb_err("send failed: %d", errno);
- g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
- g_io_channel_shutdown(channel, TRUE, NULL);
- g_io_channel_unref(channel);
- close(sock);
- return MS_MEDIA_ERR_IPC;
- }
-
- thumb_dbg("Sending msg to thumbnail daemon is successful");
-
- if (req_manager->msg_type == THUMB_REQUEST_DB_INSERT) {
- req_manager->channel = channel;
- req_manager->source_id = source_id;
- req_manager->isRequested = true;
- }
-
- return err;
-}
-
-int _media_thumb_request_async(int msg_type, unsigned int request_id, const char *origin_path, thumbUserData *userData, uid_t uid)
-{
- int err = MS_MEDIA_ERR_NONE;
- int len = 0;
-
- if (msg_type == THUMB_REQUEST_CANCEL_MEDIA)
- return __media_thumb_cancel(request_id);
-
- if (g_manage_queue == NULL)
- g_manage_queue = g_queue_new();
-
- thumbReq *thumb_req = NULL;
- THUMB_MALLOC(thumb_req, sizeof(thumbReq));
- thumb_retvm_if(thumb_req == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Failed to create request element");
-
- thumb_req->msg_type = msg_type;
- thumb_req->path = g_strdup(origin_path);
- thumb_req->userData = userData;
- thumb_req->isCanceled = false;
- thumb_req->isRequested = false;
- thumb_req->request_id = request_id;
- thumb_req->uid = uid;
-
- len = g_queue_get_length(g_manage_queue);
- g_queue_push_tail(g_manage_queue, (gpointer)thumb_req);
-
- if (len == 0)
- err = __media_thumb_send_request();
-
- return err;
-} \ No newline at end of file
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
deleted file mode 100755
index bf9fd63..0000000
--- a/src/media-thumb-internal.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <media-util.h>
-#include "media-thumb-debug.h"
-#include "media-thumb-internal.h"
-
-int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid)
-{
- char *hash_name = NULL;
- char file_ext[255] = { 0 };
- char *get_path = NULL;
- int ret_len = 0;
- ms_user_storage_type_e storage_type = -1;
- int ret = MS_MEDIA_ERR_NONE;
-
- if (file_full_path == NULL || thumb_hash_path == NULL || max_thumb_path <= 0) {
- thumb_err("file_full_path==NULL || thumb_hash_path == NULL || max_thumb_path <= 0");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- _media_thumb_get_file_ext(file_full_path, file_ext, sizeof(file_ext));
-
- ret = ms_user_get_storage_type(uid, file_full_path, &storage_type);
- if ((ret != MS_MEDIA_ERR_NONE) || ((storage_type != MS_USER_STORAGE_INTERNAL) && (storage_type != MS_USER_STORAGE_EXTERNAL))) {
- thumb_err_slog("origin path(%s) is invalid. err : [%d] storage_type [%d]", file_full_path, ret, storage_type);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- hash_name = _media_thumb_generate_hash_name(file_full_path);
- if (hash_name == NULL) {
- thumb_err("_media_thumb_generate_hash_name fail");
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- ret = ms_user_get_root_thumb_store_path(uid, &get_path);
- if (get_path != NULL) {
- if (strcasecmp(file_ext, "PNG") == 0)
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.png", get_path, file_ext, hash_name);
- else
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
-
- }
- SAFE_FREE(get_path);
-
- if ((ret_len < 0) || (ret_len > (int)max_thumb_path)) {
- thumb_err("invalid hash path ret_len[%d]", ret_len);
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index 4425764..2b7e850 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -24,58 +24,12 @@
#include <mm_util_magick.h>
#include <media-util.h>
#include "media-thumbnail.h"
-#include "media-thumb-debug.h"
-#include "media-thumb-util.h"
-#include "media-thumb-internal.h"
-#include "media-thumb-ipc.h"
+#include "media-thumbnail-debug.h"
/* The maximum of resolution to be able to get thumbnail is 3000 x 3000, except for only jpeg */
#define THUMB_MAX_ALLOWED_MEM_FOR_THUMB 9000000
#define THUMB_MAX_ALLOWED_RESOLUTION 2000
-int thumbnail_request_from_db_async(unsigned int request_id, const char *origin_path, ThumbFunc func, void *user_data, uid_t uid)
-{
- int err = MS_MEDIA_ERR_NONE;
- ms_user_storage_type_e store_type = MS_USER_STORAGE_INTERNAL;
-
- thumb_retvm_if(!origin_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid parameter");
- thumb_retvm_if(!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR), MS_MEDIA_ERR_INVALID_PARAMETER, "No file [%s]", origin_path);
-
- err = ms_user_get_storage_type(uid, origin_path, &store_type);
- if ((err != MS_MEDIA_ERR_NONE) || ((store_type != MS_USER_STORAGE_INTERNAL) && (store_type != MS_USER_STORAGE_EXTERNAL))) {
- thumb_err_slog("origin path(%s) is invalid. err : [%d] store_type [%d]", origin_path, err, store_type);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- thumb_dbg_slog("Path : %s", origin_path);
-
- thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData));
- thumb_retvm_if(!userData, MS_MEDIA_ERR_OUT_OF_MEMORY, "Allocation failed");
-
- userData->func = (ThumbFunc)func;
- userData->user_data = user_data;
-
- /* Request for thumb file to the daemon "Thumbnail generator" */
- err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, request_id, origin_path, userData, uid);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_request failed : %d", err);
- SAFE_FREE(userData);
- return err;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int thumbnail_request_cancel_media(unsigned int request_id)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, request_id, NULL, NULL, 0);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_request_async failed : %d", err);
-
- return err;
-}
-
static void __get_rotation_and_cdis(const char *path, mm_util_rotate_type_e *rot_type, int *cdis_value)
{
int err = MS_MEDIA_ERR_NONE;
@@ -322,7 +276,7 @@ static int __check_thumb_path_validity(const char *path)
char *dir_name = NULL;
int ret = MS_MEDIA_ERR_NONE;
- thumb_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+ thumb_retvm_if(!THUMB_STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
dir_name = g_path_get_dirname(path);
@@ -336,7 +290,7 @@ static int __check_thumb_path_validity(const char *path)
}
}
- SAFE_FREE(dir_name);
+ g_free(dir_name);
return ret;
}
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
deleted file mode 100755
index 972fdc2..0000000
--- a/src/util/media-thumb-db.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "media-thumb-db.h"
-#include "media-thumb-util.h"
-#include "media-thumb-debug.h"
-
-#include <glib.h>
-#include <string.h>
-#include <unistd.h>
-
-int _media_thumb_get_thumb_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid)
-{
- int err = MS_MEDIA_ERR_NONE;
- char *query_string = NULL;
- sqlite3_stmt *stmt = NULL;
- sqlite3 *db_handle = NULL;
-
- thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
-
- query_string = sqlite3_mprintf(SELECT_THUMB_BY_PATH, origin_path);
- thumb_retvm_if(!STRING_VALID(query_string), MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
- thumb_dbg_slog("Query: %s", query_string);
-
- err = media_db_connect(&db_handle, uid, FALSE);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("media_db_connect failed: %d", err);
- db_handle = NULL;
- SQLITE3_SAFE_FREE(query_string);
- return err;
- }
-
- err = sqlite3_prepare_v2(db_handle, query_string, strlen(query_string), &stmt, NULL);
- SQLITE3_SAFE_FREE(query_string);
- if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(db_handle));
- media_db_disconnect(db_handle);
-
- return MS_MEDIA_ERR_DB_INTERNAL;
- }
-
- if (sqlite3_step(stmt) == SQLITE_ROW) {
- SAFE_STRLCPY(thumb_path, (const char *)sqlite3_column_text(stmt, 0), max_length);
- } else {
- thumb_err("end of row [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_FINALIZE(stmt);
- media_db_disconnect(db_handle);
-
- return MS_MEDIA_ERR_DB_INTERNAL;
- }
-
- SQLITE3_FINALIZE(stmt);
- media_db_disconnect(db_handle);
-
- thumb_retvm_if(!g_file_test(thumb_path, G_FILE_TEST_EXISTS), MS_MEDIA_ERR_INTERNAL, "thumb path doesn't exist in file system");
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int _media_thumb_update_db(const char *origin_path, char *thumb_path, uid_t uid)
-{
- int err = MS_MEDIA_ERR_NONE;
- char *query_string = NULL;
-
- thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
-
- query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumb_path, origin_path);
- thumb_retvm_if(!STRING_VALID(query_string), MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
-
- err = media_db_request_update_db(query_string, uid);
- SQLITE3_SAFE_FREE(query_string);
-
- return err;
-} \ No newline at end of file
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
deleted file mode 100755
index cc03075..0000000
--- a/src/util/media-thumb-util.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * libmedia-thumbnail
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "media-thumb-util.h"
-#include "media-thumb-internal.h"
-#include "media-thumb-debug.h"
-
-#include <glib.h>
-#include <aul.h>
-#include <string.h>
-
-int _media_thumb_get_file_type(const char *file_full_path)
-{
- int ret = 0;
- char mimetype[255] = {0,};
- const char *unsupported_type = "image/tiff";
- const char *supported_type = "application/vnd.ms-asf";
-
- if (file_full_path == NULL)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- /* get content type and mime type from file. */
- ret = aul_get_mime_from_file(file_full_path, mimetype, sizeof(mimetype));
- if (ret < 0) {
- thumb_warn
- ("aul_get_mime_from_file fail.. Now trying to get type by extension");
-
- char ext[255] = { 0 };
- ret = _media_thumb_get_file_ext(file_full_path, ext, sizeof(ext));
- if (ret < 0) {
- thumb_err("_media_thumb_get_file_ext failed");
- return THUMB_NONE_TYPE;
- }
-
- if (strcasecmp(ext, "JPG") == 0 ||
- strcasecmp(ext, "JPEG") == 0 ||
- strcasecmp(ext, "PNG") == 0 ||
- strcasecmp(ext, "GIF") == 0 ||
- strcasecmp(ext, "AGIF") == 0 ||
- strcasecmp(ext, "XWD") == 0 ||
- strcasecmp(ext, "BMP") == 0 ||
- strcasecmp(ext, "WBMP") == 0) {
- return THUMB_IMAGE_TYPE;
- } else if (strcasecmp(ext, "AVI") == 0 ||
- strcasecmp(ext, "MPEG") == 0 ||
- strcasecmp(ext, "MP4") == 0 ||
- strcasecmp(ext, "DCF") == 0 ||
- strcasecmp(ext, "WMV") == 0 ||
- strcasecmp(ext, "3GPP") == 0 ||
- strcasecmp(ext, "3GP") == 0) {
- return THUMB_VIDEO_TYPE;
- } else {
- return THUMB_NONE_TYPE;
- }
- }
-
- thumb_dbg("mime type : %s", mimetype);
-
- /* categorize from mimetype */
- if (strstr(mimetype, "image") != NULL) {
- if (!strcmp(mimetype, unsupported_type)) {
- thumb_warn("This is unsupport file type");
- return THUMB_NONE_TYPE;
- }
- return THUMB_IMAGE_TYPE;
- } else if (strstr(mimetype, "video") != NULL) {
- return THUMB_VIDEO_TYPE;
- } else if (strstr(mimetype, supported_type) != NULL) {
- return THUMB_VIDEO_TYPE;
- }
-
- return THUMB_NONE_TYPE;
-}
-
-int _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len)
-{
- int i = 0;
-
- for (i = (int)strlen(file_path); i >= 0; i--) {
- if ((file_path[i] == '.') && (i < (int)strlen(file_path))) {
- strncpy(file_ext, &file_path[i + 1], max_len);
- return 0;
- }
-
- /* meet the dir. no ext */
- if (file_path[i] == '/') {
- return -1;
- }
- }
-
- return -1;
-}
diff --git a/unittest/libmedia_thumbnail_unittest.cpp b/unittest/libmedia_thumbnail_unittest.cpp
index 5e5077c..6f7f83a 100755
--- a/unittest/libmedia_thumbnail_unittest.cpp
+++ b/unittest/libmedia_thumbnail_unittest.cpp
@@ -40,23 +40,29 @@ class libmedia_thumbnail_Test : public ::testing::Test {
}
};
-TEST(libmedia_thumbnail_Test, thumbnail_request_from_db_async_n)
+TEST(libmedia_thumbnail_Test, create_image_thumbnail_to_buffer_n)
{
int ret = MS_MEDIA_ERR_NONE;
+ unsigned char *buffer = NULL;
+ size_t size = 0;
+ unsigned int w, h;
- ret = thumbnail_request_from_db_async(0, NULL, NULL, NULL, 5001);
- EXPECT_EQ(ret, MS_MEDIA_ERR_INVALID_PARAMETER);
-
- ret = thumbnail_request_from_db_async(0, GTEST_IMAGE_FILE_PATH, NULL, NULL, 5001);
+ ret = create_image_thumbnail_to_buffer(NULL, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, &buffer, &size, &w, &h);
EXPECT_EQ(ret, MS_MEDIA_ERR_INVALID_PARAMETER);
}
-TEST(libmedia_thumbnail_Test, thumbnail_request_cancel_media_n)
+TEST(libmedia_thumbnail_Test, create_image_thumbnail_to_buffer_p)
{
int ret = MS_MEDIA_ERR_NONE;
+ unsigned char *buffer = NULL;
+ size_t size = 0;
+ unsigned int w, h;
+
+ ret = create_image_thumbnail_to_buffer(GTEST_IMAGE_FILE_PATH, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, &buffer, &size, &w, &h);
+ EXPECT_EQ(ret, MS_MEDIA_ERR_NONE);
- ret = thumbnail_request_cancel_media(0);
- EXPECT_EQ(ret, MS_MEDIA_ERR_INTERNAL);
+ if (buffer)
+ free(buffer);
}
int main(int argc, char **argv)