summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhj kim <backto.kim@samsung.com>2015-06-05 04:09:04 (GMT)
committerhj kim <backto.kim@samsung.com>2015-06-05 04:09:04 (GMT)
commit999b9402a56d7c9738d6d632eff2f90004bbfbaf (patch)
tree31416fd3ece796751014dab252673fc71b278240
parentc896230ef091a244204b17bc9ab0ffa974ce2031 (diff)
downloadlibmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.zip
libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.tar.gz
libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.tar.bz2
This reverts commit c896230ef091a244204b17bc9ab0ffa974ce2031. Change-Id: I94ec0a56f7c3d84ad76645b91310494b96d41932
-rw-r--r--CMakeLists.txt3
-rwxr-xr-xinclude/media-thumb-error.h63
-rwxr-xr-xinclude/media-thumb-types.h3
-rwxr-xr-xinclude/media-thumbnail-private.h2
-rwxr-xr-xinclude/media-thumbnail.h1
-rw-r--r--md5/media-thumb-hash.c7
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/thumb-server-internal.c28
-rwxr-xr-xserver/thumb-server.c9
-rw-r--r--src/codec/IfegDecodeAGIF.c6
-rw-r--r--src/codec/img-codec-osal.c2
-rw-r--r--src/codec/img-codec-parser.c117
-rw-r--r--src/include/codec/img-codec.h1
-rwxr-xr-xsrc/include/ipc/media-thumb-ipc.h1
-rwxr-xr-xsrc/include/media-thumb-internal.h4
-rwxr-xr-xsrc/include/util/media-thumb-db.h1
-rwxr-xr-xsrc/include/util/media-thumb-debug.h1
-rwxr-xr-xsrc/include/util/media-thumb-util.h1
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c96
-rwxr-xr-xsrc/media-thumb-internal.c204
-rwxr-xr-xsrc/media-thumbnail.c108
-rwxr-xr-xsrc/util/media-thumb-db.c139
-rwxr-xr-xsrc/util/media-thumb-util.c16
23 files changed, 489 insertions, 326 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75edff3..cc114a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ SET(VERSION "${VERSION_MAJOR}.0.0")
SET(MEDIATHUMB-LIB "media-thumbnail")
SET(MEDIAHASH-LIB "media-hash")
-SET(SRCS
+SET(SRCS
src/media-thumbnail.c
src/media-thumb-internal.c
src/util/media-thumb-debug.c
@@ -98,6 +98,7 @@ INSTALL(TARGETS test-thumb DESTINATION ${BINDIR})
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})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumb-error.h DESTINATION include/${MEDIATHUMB-LIB})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-thumb-types.h DESTINATION include/${MEDIATHUMB-LIB})
#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/thumbsvr DESTINATION /etc/init.d)
diff --git a/include/media-thumb-error.h b/include/media-thumb-error.h
new file mode 100755
index 0000000..3ec6cbe
--- /dev/null
+++ b/include/media-thumb-error.h
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ */
+
+
+
+#ifndef _MEDIA_THUMB_ERROR_H_
+#define _MEDIA_THUMB_ERROR_H_
+
+/**
+ @addtogroup THUMB_GENERATE
+ @{
+ * @file media-thumb-error.h
+ * @brief This file defines error codes for thumbnail generation.
+
+ */
+
+/**
+ @defgroup THUMB_GENERAE_ERROR error code
+ @{
+
+ @par
+ error code
+ */
+
+
+#define MEDIA_THUMB_ERROR_NONE 0 /* No Error */
+#define MEDIA_THUMB_ERROR_INVALID_PARAMETER -1 /* invalid parameter(s) */
+#define MEDIA_THUMB_ERROR_TOO_BIG -2 /* Original is too big to make thumb */
+#define MEDIA_THUMB_ERROR_MM_UTIL -3 /* Error in mm-util lib */
+#define MEDIA_THUMB_ERROR_UNSUPPORTED -4 /* Unsupported type */
+#define MEDIA_THUMB_ERROR_NETWORK -5 /* Error in socket */
+#define MEDIA_THUMB_ERROR_DB -6 /* Timeout */
+#define MEDIA_THUMB_ERROR_TIMEOUT -7 /* Timeout */
+#define MEDIA_THUMB_ERROR_HASHCODE -8 /* Failed to generate hash code */
+#define MEDIA_THUMB_ERROR_DUPLICATED_REQUEST -9 /* Duplicated request of same path */
+
+/**
+ @}
+*/
+
+/**
+ @}
+*/
+
+#endif /*_MEDIA_THUMB_ERROR_H_*/
diff --git a/include/media-thumb-types.h b/include/media-thumb-types.h
index 56e36ea..3387a6c 100755
--- a/include/media-thumb-types.h
+++ b/include/media-thumb-types.h
@@ -18,7 +18,8 @@
* limitations under the License.
*
*/
-#include "media-util.h"
+
+
#ifndef _MEDIA_THUMB_TYPES_H_
#define _MEDIA_THUMB_TYPES_H_
diff --git a/include/media-thumbnail-private.h b/include/media-thumbnail-private.h
index a7d1daf..e606141 100755
--- a/include/media-thumbnail-private.h
+++ b/include/media-thumbnail-private.h
@@ -23,6 +23,8 @@
#ifndef _MEDIA_THUMBNAIL_PRIVATE_H_
#define _MEDIA_THUMBNAIL_PRIVATE_H_
+#include "media-thumb-error.h"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/media-thumbnail.h b/include/media-thumbnail.h
index f3b6148..1101258 100755
--- a/include/media-thumbnail.h
+++ b/include/media-thumbnail.h
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include "media-thumb-types.h"
+#include "media-thumb-error.h"
#ifdef __cplusplus
extern "C" {
diff --git a/md5/media-thumb-hash.c b/md5/media-thumb-hash.c
index 6081681..bd8df13 100644
--- a/md5/media-thumb-hash.c
+++ b/md5/media-thumb-hash.c
@@ -29,7 +29,6 @@
#include "media-thumbnail-private.h"
#include <string.h>
#include <alloca.h>
-#include <media-util-err.h>
static const char ACCEPTABLE_URI_CHARS[96] = {
@@ -116,18 +115,18 @@ int thumbnail_generate_hash_code(const char *origin_path, char *hash_code, int m
char *hash = NULL;
if (max_length < ((2 * MD5_HASHBYTES) + 1)) {
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
hash = _media_thumb_generate_hash_name(origin_path);
if (hash == NULL) {
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_HASHCODE;
}
strncpy(hash_code, hash, max_length);
hash_code[strlen(hash_code)] ='\0';
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 4886069..be63478 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -9,7 +9,6 @@ Source1001: %{name}.manifest
Source1002: %{name}-devel.manifest
Source1003: media-thumbnail-server.manifest
-Requires: media-server
BuildRequires: cmake
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(dlog)
@@ -23,6 +22,7 @@ BuildRequires: pkgconfig(mmutil-jpeg)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(gdk-pixbuf-2.0)
+Requires: media-server
%description
Media thumbnail service library for multimedia applications.
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index bd08d61..1553604 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -151,10 +151,10 @@ void _thumb_daemon_stop_job()
int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = _media_thumb_process(req_msg, res_msg, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
if (req_msg->msg_type == THUMB_REQUEST_SAVE_FILE) {
thumb_err("_media_thumb_process is failed: %d", err);
res_msg->status = THUMB_FAIL;
@@ -171,7 +171,7 @@ int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
int _thumb_daemon_all_extract(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
int count = 0;
char query_string[MAX_PATH_SIZE + 1] = { 0, };
char path[MAX_PATH_SIZE + 1] = { 0, };
@@ -179,15 +179,15 @@ int _thumb_daemon_all_extract(uid_t uid)
sqlite3_stmt *sqlite_stmt = NULL;
err = _media_thumb_db_connect(uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_db_connect failed: %d", err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
sqlite_db_handle = _media_thumb_db_get_handle();
if (sqlite_db_handle == NULL) {
thumb_err("sqlite handle is NULL");
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_DB;
}
if (_thumb_daemon_mmc_status() == VCONFKEY_SYSMAN_MMC_MOUNTED) {
@@ -195,20 +195,20 @@ int _thumb_daemon_all_extract(uid_t uid)
} else {
snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA);
}
-
+
thumb_warn("Query: %s", query_string);
err = sqlite3_prepare_v2(sqlite_db_handle, query_string, strlen(query_string), &sqlite_stmt, NULL);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(sqlite_db_handle));
+ thumb_err("prepare error [%s]\n", sqlite3_errmsg(sqlite_db_handle));
_media_thumb_db_disconnect();
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_DB;
}
while(1) {
err = sqlite3_step(sqlite_stmt);
if (err != SQLITE_ROW) {
- thumb_dbg("end of row [%s]", sqlite3_errmsg(sqlite_db_handle));
+ thumb_dbg("end of row [%s]\n", sqlite3_errmsg(sqlite_db_handle));
break;
}
@@ -232,17 +232,17 @@ int _thumb_daemon_all_extract(uid_t uid)
sqlite3_finalize(sqlite_stmt);
_media_thumb_db_disconnect();
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int _thumb_daemon_process_queue_jobs(gpointer data)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
char *path = NULL;
uid_t uid = NULL;
if (g_cur_idx < g_idx) {
- thumb_warn("There are %d jobs in the queue", g_idx - g_cur_idx);
+ thumb_dbg("There are %d jobs in the queue", g_idx - g_cur_idx);
thumb_dbg("Current idx : [%d]", g_cur_idx);
uid = arr_uid[g_cur_idx];
path = arr_path[g_cur_idx++];
@@ -261,7 +261,7 @@ int _thumb_daemon_process_queue_jobs(gpointer data)
if (res_msg.status == THUMB_SUCCESS) {
err = _media_thumb_db_connect(uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
return TRUE;
}
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 4248f24..ca5fd48 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -24,6 +24,7 @@
#include "media-thumb-ipc.h"
#include "media-thumb-util.h"
#include "thumb-server-internal.h"
+
#include <pthread.h>
#include <heynoti.h>
#include <vconf.h>
@@ -91,12 +92,12 @@ int main()
/* Create and bind new UDP socket */
if (!_thumb_server_prepare_socket(&sockfd)) {
- thumb_err("Failed to create socket");
+ thumb_err("Failed to create socket\n");
return -1;
}
g_thumb_server_mainloop = g_main_loop_new(context, FALSE);
-
+
/* Create new channel to watch udp socket */
channel = g_io_channel_unix_new(sockfd);
source = g_io_create_watch(channel, G_IO_IN);
@@ -116,13 +117,15 @@ int main()
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_run(g_thumb_server_mainloop);
-
+
thumb_dbg("Thumbnail server is shutting down...");
+
g_io_channel_shutdown(channel, FALSE, NULL);
g_io_channel_unref(channel);
_thumb_daemon_finish_jobs();
diff --git a/src/codec/IfegDecodeAGIF.c b/src/codec/IfegDecodeAGIF.c
index e1e5a11..dad124b 100644
--- a/src/codec/IfegDecodeAGIF.c
+++ b/src/codec/IfegDecodeAGIF.c
@@ -47,7 +47,7 @@ AGifFrameInfo *FastImgCreateAGIFFrameData(unsigned int width, unsigned int heigh
int inputPos = 0;
int inputPos_temp = 0;
- AGifFrameInfo *pFrameData;
+ AGifFrameInfo *pFrameData;
if (0 == (pFrameData = IfegMemAlloc(sizeof(AGifFrameInfo)))) {
return 0;
}
@@ -126,7 +126,7 @@ AGifFrameInfo *FastImgCreateAGIFFrameData(unsigned int width, unsigned int heigh
backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3);
}
- /* graphic extension block */
+ /* graphic extension block */
if (pEncodedData[14+header_temp] == 0xF9 || pEncodedData[14+19+header_temp] == 0xF9) {
if (transparent == 1 && backcolor_index == transIndex) {
@@ -690,7 +690,7 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl
if (pFrameData->nLoopCount == -1) {
break;
} else if (pFrameData->bLoop || (pFrameData->nRepeatCount <= pFrameData->nLoopCount) || (pFrameData->nLoopCount == 0)) {
- /* Background Color */
+ /* Background Color */
pImage16 = (unsigned short *)pFrameData->pPrevImg;
for (i = 0; i < expected_width * expected_height; i++) {
diff --git a/src/codec/img-codec-osal.c b/src/codec/img-codec-osal.c
index 47062bc..46eb130 100644
--- a/src/codec/img-codec-osal.c
+++ b/src/codec/img-codec-osal.c
@@ -24,7 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
+
//#include <drm-service.h>
#include <drm_client.h>
diff --git a/src/codec/img-codec-parser.c b/src/codec/img-codec-parser.c
index dd04455..26027b9 100644
--- a/src/codec/img-codec-parser.c
+++ b/src/codec/img-codec-parser.c
@@ -28,7 +28,6 @@
#include <sys/time.h>
#endif
-#include <media-util-err.h>
#include "media-thumb-debug.h"
#include "img-codec-common.h"
#include "img-codec-parser.h"
@@ -424,7 +423,7 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
unsigned char tmp;
if (DrmReadFile(hFile, EncodedDataBuffer, 32, &fileread) ==
- FALSE) {
+ FALSE) {
thumb_err("DrmReadFile was failed");
return IMG_CODEC_NONE;
}
@@ -446,7 +445,7 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
tmp = *(EncodedDataBuffer + 20);
/* If image is interlaced then multiple should be 2 */
if (tmp) {
- thumb_dbg("Interlaced PNG Image.");
+ thumb_dbg("Interlaced PNG Image.\n");
}
thumb_dbg("IMG_CODEC_PNG\n");
return IMG_CODEC_PNG;
@@ -470,22 +469,23 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
}
if (pWidth) {
*pWidth =
- EncodedDataBuffer[18] | (EncodedDataBuffer[19] << 8)
- | (EncodedDataBuffer[20] << 16) |
- (EncodedDataBuffer[21] << 24);
+ EncodedDataBuffer[18] | (EncodedDataBuffer[19] << 8)
+ | (EncodedDataBuffer[20] << 16) |
+ (EncodedDataBuffer[21] << 24);
}
if (pHeight) {
*pHeight =
- EncodedDataBuffer[22] | (EncodedDataBuffer[23] << 8)
- | (EncodedDataBuffer[24] << 16) |
- (EncodedDataBuffer[25] << 24);
+ EncodedDataBuffer[22] | (EncodedDataBuffer[23] << 8)
+ | (EncodedDataBuffer[24] << 16) |
+ (EncodedDataBuffer[25] << 24);
}
thumb_dbg("IMG_CODEC_BMP");
return IMG_CODEC_BMP;
}
/*********************** GIF *************************/
- else if (AcMemcmp(EncodedDataBuffer, gIfegGIFHeader, GIF_HEADER_LENGTH) == 0) {
+ else if (AcMemcmp(EncodedDataBuffer, gIfegGIFHeader, GIF_HEADER_LENGTH)
+ == 0) {
unsigned int tablelength = 0;
unsigned int imagecount = 0;
int finished = 0;
@@ -498,7 +498,8 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
return IMG_CODEC_UNKNOWN_TYPE;
}
- if (DrmReadFile(hFile, &EncodedDataBuffer[8], 5, &fileread) == FALSE) {
+ if (DrmReadFile(hFile, &EncodedDataBuffer[8], 5, &fileread) ==
+ FALSE) {
thumb_err("DrmReadFile was failed");
return IMG_CODEC_NONE;
@@ -509,10 +510,10 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
}
if (EncodedDataBuffer[0] != 'G' || EncodedDataBuffer[1] != 'I'
- || EncodedDataBuffer[2] != 'F' || EncodedDataBuffer[3] < '0'
- || EncodedDataBuffer[3] > '9' || EncodedDataBuffer[4] < '0'
- || EncodedDataBuffer[4] > '9' || EncodedDataBuffer[5] < 'A'
- || EncodedDataBuffer[5] > 'z') {
+ || EncodedDataBuffer[2] != 'F' || EncodedDataBuffer[3] < '0'
+ || EncodedDataBuffer[3] > '9' || EncodedDataBuffer[4] < '0'
+ || EncodedDataBuffer[4] > '9' || EncodedDataBuffer[5] < 'A'
+ || EncodedDataBuffer[5] > 'z') {
thumb_warn("IMG_CODEC_UNKNOWN_TYPE in GIF");
return IMG_CODEC_UNKNOWN_TYPE;
}
@@ -526,14 +527,17 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
EncodedDataBuffer[8] | (EncodedDataBuffer[9] << 8);
}
- thumb_dbg("Logical width : %d, Height : %d", *pWidth, *pHeight);
+ thumb_dbg("Logical width : %d, Height : %d", *pWidth,
+ *pHeight);
if ((EncodedDataBuffer[10] & 0x80) != 0) { /* Global color table */
temp = (EncodedDataBuffer[10] & 0x7) + 1;
tablelength = (1 << temp) * 3;
- if ((tablelength * sizeof(char)) > sizeof(EncodedDataBuffer)) {
- thumb_warn("_ImgGetInfoStreaming :table length is more than buffer length");
+ if ((tablelength * sizeof(char)) >
+ sizeof(EncodedDataBuffer)) {
+ thumb_warn
+ ("_ImgGetInfoStreaming :table length is more than buffer length");
return IMG_CODEC_UNKNOWN_TYPE;
}
@@ -542,7 +546,9 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
return IMG_CODEC_UNKNOWN_TYPE;
}
/* coverity[ -tainted_data_argument : EncodedDataBuffer ] */
- if (DrmReadFile(hFile, EncodedDataBuffer, tablelength, &fileread) == FALSE) {
+ if (DrmReadFile
+ (hFile, EncodedDataBuffer, tablelength,
+ &fileread) == FALSE) {
thumb_err("DrmReadFile was failed");
return IMG_CODEC_NONE;
@@ -582,11 +588,14 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
return IMG_CODEC_UNKNOWN_TYPE;
}
- switch (EncodedDataBuffer[ifegstreamctrl.buffpos++]) {
+ switch (EncodedDataBuffer
+ [ifegstreamctrl.buffpos++]) {
case 0xf9: /* Graphic control extension block */
- if (_CheckBuffer(&ifegstreamctrl, 6) == 0) {
- thumb_warn("_CheckBuffer was failed");
+ if (_CheckBuffer(&ifegstreamctrl, 6) ==
+ 0) {
+ thumb_warn
+ ("_CheckBuffer was failed");
return IMG_CODEC_UNKNOWN_TYPE;
}
@@ -600,20 +609,28 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
case 0x01: /* Plain Text block */
case 0xfe: /* Comment Extension block */
case 0xff: /* Appliation Extension block */
- if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
- thumb_warn("_CheckBuffer was failed");
+ if (_CheckBuffer(&ifegstreamctrl, 1) ==
+ 0) {
+ thumb_warn
+ ("_CheckBuffer was failed");
return IMG_CODEC_UNKNOWN_TYPE;
}
- if (ifegstreamctrl.buffpos > sizeof(EncodedDataBuffer)) {
- thumb_warn("buffer position exceeds buffer max length ");
+ if (ifegstreamctrl.buffpos >
+ sizeof(EncodedDataBuffer)) {
+ thumb_warn
+ ("buffer position exceeds buffer max length ");
return IMG_CODEC_UNKNOWN_TYPE;
}
while ((ifegstreamctrl.buffpos < sizeof(EncodedDataBuffer)) && ((length = EncodedDataBuffer[ifegstreamctrl.buffpos++]) > 0)) { /* get the data length */
- if (_CheckBuffer(&ifegstreamctrl, length) == 0) {
- thumb_warn("_CheckBuffer was failed");
- return IMG_CODEC_UNKNOWN_TYPE;
+ if (_CheckBuffer
+ (&ifegstreamctrl,
+ length) == 0) {
+ thumb_warn
+ ("_CheckBuffer was failed");
+ return
+ IMG_CODEC_UNKNOWN_TYPE;
}
/* Check integer overflow */
@@ -622,7 +639,8 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
return IMG_CODEC_UNKNOWN_TYPE;
}
- ifegstreamctrl.buffpos += (length);
+ ifegstreamctrl.buffpos +=
+ (length);
/* File End Check */
}
break;
@@ -703,38 +721,51 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
return IMG_CODEC_UNKNOWN_TYPE;
}
- temp = EncodedDataBuffer[ifegstreamctrl.buffpos++];
+ temp =
+ EncodedDataBuffer[ifegstreamctrl.buffpos++];
if (temp < 2 || 9 < temp) {
return IMG_CODEC_UNKNOWN_TYPE;
}
do {
- if (_CheckBuffer(&ifegstreamctrl, 1) == 0) {
- thumb_warn("_CheckBuffer was failed");
+ if (_CheckBuffer(&ifegstreamctrl, 1) ==
+ 0) {
+ thumb_warn
+ ("_CheckBuffer was failed");
return IMG_CODEC_UNKNOWN_TYPE;
}
- length =EncodedDataBuffer[ifegstreamctrl.buffpos++];
+ length =
+ EncodedDataBuffer[ifegstreamctrl.
+ buffpos++];
if ((length + ifegstreamctrl.buffpos) > ifegstreamctrl.buffend) {
length =
- length +
- ifegstreamctrl.buffpos -
- ifegstreamctrl.buffend;
- if (DrmSeekFile(ifegstreamctrl.fd, SEEK_CUR, length) == FALSE) {
+ length +
+ ifegstreamctrl.buffpos -
+ ifegstreamctrl.buffend;
+ if (DrmSeekFile
+ (ifegstreamctrl.fd,
+ SEEK_CUR,
+ length) == FALSE) {
if (imagecount) {
if (pNumberOfFrames)
*pNumberOfFrames
= 2;
- thumb_dbg("IMG_CODEC_AGIF");
- return IMG_CODEC_AGIF;
+ thumb_dbg
+ ("IMG_CODEC_AGIF");
+ return
+ IMG_CODEC_AGIF;
}
- return IMG_CODEC_UNKNOWN_TYPE;
+ return
+ IMG_CODEC_UNKNOWN_TYPE;
}
- ifegstreamctrl.filepos += length;
+ ifegstreamctrl.filepos +=
+ length;
ifegstreamctrl.buffpos = 0;
ifegstreamctrl.buffend = 0;
} else {
- ifegstreamctrl.buffpos +=length;
+ ifegstreamctrl.buffpos +=
+ length;
}
/* File End Check */
diff --git a/src/include/codec/img-codec.h b/src/include/codec/img-codec.h
index 708c5ce..07f3a6b 100644
--- a/src/include/codec/img-codec.h
+++ b/src/include/codec/img-codec.h
@@ -26,6 +26,7 @@
#include "img-codec-parser.h"
#include "img-codec-agif.h"
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h
index b4ad38e..1819af4 100755
--- a/src/include/ipc/media-thumb-ipc.h
+++ b/src/include/ipc/media-thumb-ipc.h
@@ -20,6 +20,7 @@
*/
+#include "media-thumb-error.h"
#include "media-thumb-debug.h"
#include "media-thumb-types.h"
#include "media-thumb-internal.h"
diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h
index addbc7b..84556fc 100755
--- a/src/include/media-thumb-internal.h
+++ b/src/include/media-thumb-internal.h
@@ -19,9 +19,9 @@
*
*/
-#include <stdbool.h>
-#include <media-util-err.h>
+
#include "media-thumbnail.h"
+#include "media-thumb-error.h"
#include "media-thumb-types.h"
#include "media-thumb-debug.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index 3dc5495..b29920a 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -21,6 +21,7 @@
#include <sqlite3.h>
#include <media-util.h>
+#include "media-thumb-error.h"
#include "media-thumb-types.h"
#include "media-thumb-debug.h"
diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h
index 2bc7380..65ca53f 100755
--- a/src/include/util/media-thumb-debug.h
+++ b/src/include/util/media-thumb-debug.h
@@ -28,7 +28,6 @@
#include <unistd.h>
#include <asm/unistd.h>
-#include <errno.h>
#ifdef LOG_TAG
#undef LOG_TAG
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
index 7eee7d8..41409d2 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -19,6 +19,7 @@
*
*/
+#include "media-thumb-error.h"
#include "media-thumb-types.h"
#include "media-thumb-debug.h"
#include "media-util.h"
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 2f56457..e9d7c0c 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -23,7 +23,6 @@
#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>
@@ -47,7 +46,7 @@ _media_thumb_create_socket(int sock_type, int *sock)
if ((sock_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
thumb_err("socket failed: %s", strerror(errno));
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
if (sock_type == CLIENT_SOCKET) {
@@ -61,7 +60,7 @@ _media_thumb_create_socket(int sock_type, int *sock)
if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
thumb_err("setsockopt failed: %s", strerror(errno));
close(sock_fd);
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
} else if (sock_type == SERVER_SOCKET) {
@@ -70,13 +69,13 @@ _media_thumb_create_socket(int sock_type, int *sock)
if (setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &n_reuse, sizeof(n_reuse)) == -1) {
thumb_err("setsockopt failed: %s", strerror(errno));
close(sock_fd);
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
}
*sock = sock_fd;
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
@@ -87,7 +86,7 @@ _media_thumb_create_udp_socket(int *sock)
if ((sock_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
thumb_err("socket failed: %s", strerror(errno));
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
#ifdef _USE_MEDIA_UTIL_
@@ -99,22 +98,22 @@ _media_thumb_create_udp_socket(int *sock)
if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
thumb_err("setsockopt failed: %s", strerror(errno));
close(sock_fd);
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
*sock = sock_fd;
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int _media_thumb_get_error()
{
if (errno == EWOULDBLOCK) {
thumb_err("Timeout. Can't try any more");
- return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
+ return MEDIA_THUMB_ERROR_TIMEOUT;
} else {
thumb_err("recvfrom failed : %s", strerror(errno));
- return MS_MEDIA_ERR_SOCKET_RECEIVE;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
}
@@ -158,14 +157,14 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
}
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int __media_thumb_check_req_queue(const char *path)
{
int req_len = 0, i;
- if (g_request_queue == NULL) return MS_MEDIA_ERR_NONE;
+ if (g_request_queue == NULL) return MEDIA_THUMB_ERROR_NONE;
req_len = g_queue_get_length(g_request_queue);
// thumb_dbg("Queue length : %d", req_len);
@@ -182,14 +181,14 @@ int __media_thumb_check_req_queue(const char *path)
if (strncmp(path, req->path, strlen(path)) == 0) {
//thumb_dbg("Same Request - %s", path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
break;
}
}
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
@@ -235,7 +234,7 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
//thumb_dbg("destination path : %s", msg->dst_path);
SAFE_FREE(buf);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
#ifdef _USE_UDS_SOCKET_
@@ -267,7 +266,7 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
if (msg->origin_path_size <= 0 || msg->origin_path_size > MAX_PATH_SIZE) {
SAFE_FREE(buf);
thumb_err("msg->origin_path_size is invalid %d", msg->origin_path_size );
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
strncpy(msg->org_path, (char*)buf + header_size, msg->origin_path_size);
@@ -276,7 +275,7 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
if (msg->dest_path_size <= 0 || msg->dest_path_size > MAX_PATH_SIZE) {
SAFE_FREE(buf);
thumb_err("msg->origin_path_size is invalid %d", msg->dest_path_size );
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
strncpy(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, msg->dest_path_size);
@@ -285,14 +284,14 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
SAFE_FREE(buf);
*from_size = from_addr_size;
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
_media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
{
if (req_msg == NULL || buf == NULL) {
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
int org_path_len = 0;
@@ -314,7 +313,7 @@ _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
*buf_size = size;
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
int
@@ -331,7 +330,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
#endif
int recv_str_len = 0;
- int err = MS_MEDIA_ERR_NONE;
+ int err;
int pid;
@@ -344,13 +343,13 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
#endif
thumb_err("ms_ipc_create_client_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
#else
/* Creaete a TCP socket */
if (_media_thumb_create_socket(CLIENT_SOCKET, &sock) < 0) {
thumb_err("_media_thumb_create_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
#endif
@@ -380,7 +379,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
thumb_err("connect error : %s", strerror(errno));
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
thumbMsg req_msg;
@@ -411,7 +410,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
close(sock);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
unsigned char *buf = NULL;
@@ -425,7 +424,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
thumb_err("sendto failed: %d\n", errno);
SAFE_FREE(buf);
close(sock);
- return MS_MEDIA_ERR_SOCKET_SEND;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
thumb_dbg("Sending msg to thumbnail daemon is successful");
@@ -445,12 +444,12 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
if (recv_str_len > max_length) {
thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
if (recv_msg.status == THUMB_FAIL) {
thumb_err("Failed to make thumbnail");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
if (msg_type != THUMB_REQUEST_SAVE_FILE) {
@@ -460,7 +459,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
thumb_info->origin_width = recv_msg.origin_width;
thumb_info->origin_height = recv_msg.origin_height;
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
static int _mkdir(const char *dir, mode_t mode) {
@@ -537,7 +536,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
if (req_msg == NULL || res_msg == NULL) {
thumb_err("Invalid msg!");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
int msg_type = req_msg->msg_type;
@@ -552,22 +551,22 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
max_length = sizeof(res_msg->dst_path);
err = _media_thumb_db_connect(uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return MEDIA_THUMB_ERROR_DB;
}
if (msg_type == THUMB_REQUEST_DB_INSERT) {
err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &origin_w, &origin_h);
- if (err == MS_MEDIA_ERR_NONE) {
+ if (err == 0) {
res_msg->origin_width = origin_w;
res_msg->origin_height = origin_h;
_media_thumb_db_disconnect();
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
} else {
if (strlen(thumb_path) == 0) {
err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
_media_thumb_db_disconnect();
@@ -600,7 +599,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
}
err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &gdkdata, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_thumbnail_get_data failed - %d\n", err);
if ( gdkdata != NULL ){
g_object_unref(gdkdata);
@@ -670,14 +669,14 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
/* DB update if needed */
if (need_update_db == 1) {
err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_update_db failed : %d", err);
}
}
_media_thumb_db_disconnect();
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
@@ -686,7 +685,7 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
int header_size = 0;
int recv_str_len = 0;
int sock = 0;
- int err = MS_MEDIA_ERR_NONE;
+ int err = MEDIA_THUMB_ERROR_NONE;
memset((void *)&recv_msg, 0, sizeof(thumbMsg));
sock = g_io_channel_unix_get_fd(src);
@@ -711,7 +710,7 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
if (recv_msg.status == THUMB_FAIL) {
thumb_err("Failed to make thumbnail");
- err = MS_MEDIA_ERR_INTERNAL;
+ err = MEDIA_THUMB_ERROR_UNSUPPORTED;
goto callback;
}
@@ -743,7 +742,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
int pid;
if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
- return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
+ return MEDIA_THUMB_ERROR_DUPLICATED_REQUEST;
}
#ifdef _USE_MEDIA_UTIL_
@@ -755,13 +754,13 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
#endif
thumb_err("ms_ipc_create_client_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
#else
/* Creaete a TCP socket */
if (_media_thumb_create_socket(CLIENT_SOCKET, &sock) < 0) {
thumb_err("_media_thumb_create_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
#endif
@@ -796,7 +795,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
thumb_err("connect error : %s", strerror(errno));
g_io_channel_shutdown(channel, TRUE, NULL);
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
if (msg_type != THUMB_REQUEST_CANCEL_MEDIA) {
@@ -829,7 +828,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
g_io_channel_shutdown(channel, TRUE, NULL);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
unsigned char *buf = NULL;
@@ -843,7 +842,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
SAFE_FREE(buf);
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);
- return MS_MEDIA_ERR_SOCKET_SEND;
+ return MEDIA_THUMB_ERROR_NETWORK;
}
SAFE_FREE(buf);
@@ -868,7 +867,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
thumb_req = calloc(1, sizeof(thumbReq));
if (thumb_req == NULL) {
thumb_err("Failed to create request element");
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
thumb_req->channel = channel;
@@ -880,5 +879,6 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
}
#endif
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
+
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index b8890f7..e6b3f12 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -111,7 +111,7 @@ int _media_thumb_get_proper_thumb_size(media_thumb_type thumb_type,
thumb_dbg("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value,
@@ -122,7 +122,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
ExifTag tag;
if (ed == NULL) {
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
ifd = ifdtype;
@@ -136,7 +136,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
if (value == NULL) {
thumb_dbg("value is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
@@ -147,7 +147,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
/* Get the contents of the tag in human-readable form */
if (buf == NULL) {
thumb_dbg("buf is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
exif_entry_get_value(entry, buf, max_size);
buf[strlen(buf)] = '\0';
@@ -159,10 +159,11 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
}
}
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
-int _media_thumb_get_thumb_from_exif(ExifData *ed,
+int
+_media_thumb_get_thumb_from_exif(ExifData *ed,
const char *file_full_path,
int orientation,
int required_width,
@@ -199,15 +200,16 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
thumb_dbg("There's jpeg thumb in this image");
} else {
thumb_dbg("There's NO jpeg thumb in this image");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
} else {
thumb_dbg("entry is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
/* Get width and height of thumbnail */
tag = EXIF_TAG_IMAGE_WIDTH;
+
entry = exif_content_get_entry(ed->ifd[ifd], tag);
if (entry) {
@@ -219,7 +221,9 @@ int _media_thumb_get_thumb_from_exif(ExifData *ed,
}
tag = EXIF_TAG_IMAGE_LENGTH;
+
entry = exif_content_get_entry(ed->ifd[ifd], tag);
+
if (entry) {
/* Get the contents of the tag in human-readable form */
ExifShort value = exif_get_short(entry->data, byte_order);
@@ -454,10 +458,11 @@ int _media_thumb_resize_data(unsigned char *src_data,
int thumb_width = dst_width;
int thumb_height = dst_height;
unsigned int buf_size = 0;
-
- if (mm_util_get_image_size(src_format, thumb_width, thumb_height, &buf_size) < 0) {
+
+ if (mm_util_get_image_size(src_format, thumb_width,
+ thumb_height, &buf_size) < 0) {
thumb_err("Failed to get buffer size");
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
thumb_dbg("mm_util_get_image_size : %d", buf_size);
@@ -472,7 +477,7 @@ int _media_thumb_resize_data(unsigned char *src_data,
SAFE_FREE(dst);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
thumb_info->size = buf_size;
@@ -483,7 +488,7 @@ int _media_thumb_resize_data(unsigned char *src_data,
SAFE_FREE(dst);
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
int _media_thumb_get_wh_with_gdk(const char *origin_path, int *width, int *height)
@@ -496,14 +501,14 @@ int _media_thumb_get_wh_with_gdk(const char *origin_path, int *width, int *heigh
if (error) {
thumb_err ("Error loading image file %s",origin_path);
g_error_free (error);
- return MS_MEDIA_ERR_INTERNAL;
+ return -1;
}
/* Get w/h of original image */
*width = gdk_pixbuf_get_width(pixbuf);
*height = gdk_pixbuf_get_height(pixbuf);
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
int _media_thumb_decode_with_gdk(const char *origin_path,
@@ -517,7 +522,7 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
if (error) {
thumb_err ("Error loading image file %s",origin_path);
g_error_free (error);
- return MS_MEDIA_ERR_INTERNAL;
+ return -1;
}
/* Get w/h of original image */
@@ -541,7 +546,7 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
rotated_orig_h = height;
}
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
media_thumb_type thumb_type;
if (thumb_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
@@ -553,7 +558,7 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
err = _media_thumb_get_proper_thumb_size(thumb_type,
rotated_orig_w, rotated_orig_h,
&thumb_width, &thumb_height);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
g_object_unref(pixbuf);
return err;
@@ -569,7 +574,7 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
g_object_unref(pixbuf);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
thumb_info->size = buf_size;
@@ -579,37 +584,38 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
thumb_info->gdkdata = gdk_pixbuf_copy(pixbuf);
g_object_unref(pixbuf);
- return MS_MEDIA_ERR_NONE;
+ return 0;
}
mm_util_img_format _media_thumb_get_format(media_thumb_format src_format)
{
switch(src_format) {
- case MEDIA_THUMB_BGRA:
+ case MEDIA_THUMB_BGRA:
return MM_UTIL_IMG_FMT_BGRA8888;
- case MEDIA_THUMB_RGB888:
+ case MEDIA_THUMB_RGB888:
return MM_UTIL_IMG_FMT_RGB888;
default:
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
}
int _media_thumb_convert_data(media_thumb_info *thumb_info,
- int thumb_width,
+ int thumb_width,
int thumb_height,
mm_util_img_format src_format,
mm_util_img_format dst_format)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
unsigned int buf_size = 0;
unsigned char *src_data = thumb_info->data;
unsigned char *dst_data = NULL;
thumb_dbg("src format:%d, dst format:%d", src_format, dst_format);
- if (mm_util_get_image_size(dst_format, thumb_width, thumb_height, &buf_size) < 0) {
+ if (mm_util_get_image_size(dst_format, thumb_width,
+ thumb_height, &buf_size) < 0) {
thumb_err("Failed to get buffer size");
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
thumb_dbg("mm_util_get_image_size : %d", buf_size);
@@ -635,11 +641,11 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info,
src_format,
dst_data,
dst_format);
-
+
if (err < 0) {
thumb_err("Failed to change from rgb888 to argb8888 %d", err);
SAFE_FREE(dst_data);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
}
@@ -649,18 +655,18 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info,
thumb_dbg("_media_thumb_convert_data success");
- return err;
+ return 0;
}
int _media_thumb_convert_format(media_thumb_info *thumb_info,
media_thumb_format src_format,
media_thumb_format dst_format)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
if (src_format == dst_format) {
//thumb_dbg("src_format == dst_format");
- return err;
+ return 0;
}
mm_util_img_format src_mm_format;
@@ -671,21 +677,21 @@ int _media_thumb_convert_format(media_thumb_info *thumb_info,
if (src_mm_format == -1 || dst_mm_format == -1) {
thumb_err("Format is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_UNSUPPORTED;
}
- err = _media_thumb_convert_data(thumb_info,
- thumb_info->width,
+ err = _media_thumb_convert_data(thumb_info,
+ thumb_info->width,
thumb_info->height,
- src_mm_format,
+ src_mm_format,
dst_mm_format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_thumb_convert_format failed : %d", err);
return err;
}
- return err;
+ return 0;
}
int _media_thumb_agif(const char *origin_path,
@@ -695,7 +701,7 @@ int _media_thumb_agif(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
unsigned int *thumb = NULL;
media_thumb_type thumb_type;
@@ -703,7 +709,7 @@ int _media_thumb_agif(const char *origin_path,
if (!thumb) {
thumb_err("Frame data is NULL!!");
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_UNSUPPORTED;
}
if (thumb_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
@@ -715,13 +721,13 @@ int _media_thumb_agif(const char *origin_path,
err = _media_thumb_get_proper_thumb_size(thumb_type,
thumb_info->origin_width, thumb_info->origin_height,
&thumb_width, &thumb_height);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
SAFE_FREE(thumb);
return err;
}
- err = _media_thumb_resize_data((unsigned char *)thumb,
+ err = _media_thumb_resize_data((unsigned char *)thumb,
image_info->width,
image_info->height,
MM_UTIL_IMG_FMT_RGB888,
@@ -729,7 +735,7 @@ int _media_thumb_agif(const char *origin_path,
thumb_width,
thumb_height);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_resize_data failed: %d", err);
SAFE_FREE(thumb);
return err;
@@ -738,13 +744,13 @@ int _media_thumb_agif(const char *origin_path,
SAFE_FREE(thumb);
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return err;
+ return 0;
}
int _media_thumb_png(const char *origin_path,
@@ -753,22 +759,22 @@ int _media_thumb_png(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
-
- if (err != MS_MEDIA_ERR_NONE) {
+
+ if (err < 0) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return err;
+ return 0;
}
int _media_thumb_bmp(const char *origin_path,
@@ -777,22 +783,22 @@ int _media_thumb_bmp(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return err;
+ return 0;
}
int _media_thumb_wbmp(const char *origin_path,
@@ -801,46 +807,46 @@ int _media_thumb_wbmp(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return err;
+ return 0;
}
-int _media_thumb_gif(const char *origin_path,
+int _media_thumb_gif(const char *origin_path,
int thumb_width,
int thumb_height,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return err;
+ return 0;
}
int _media_thumb_jpeg(const char *origin_path,
@@ -850,7 +856,7 @@ int _media_thumb_jpeg(const char *origin_path,
media_thumb_info *thumb_info,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
ExifData *ed = NULL;
int thumb_done = 0;
int orientation = NORMAL;
@@ -862,14 +868,14 @@ int _media_thumb_jpeg(const char *origin_path,
/* First, Get orientation from exif */
err = _media_thumb_get_exif_info(ed, NULL, 0, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_warn("_media_thumb_get_exif_info failed");
}
/* Second, Get thumb from exif */
err = _media_thumb_get_thumb_from_exif(ed, origin_path, orientation, thumb_width, thumb_height, thumb_info, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_dbg("_media_thumb_get_thumb_from_exif failed");
} else {
thumb_done = 1;
@@ -883,7 +889,7 @@ int _media_thumb_jpeg(const char *origin_path,
MM_UTIL_IMG_FMT_RGB888,
dst_format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_data failed : %d", err);
exif_data_unref(ed);
return err;
@@ -897,20 +903,20 @@ int _media_thumb_jpeg(const char *origin_path,
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, orientation);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
}
- return err;
+ return 0;
}
int
@@ -920,7 +926,7 @@ _media_thumb_image(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
int image_type = 0;
int origin_w = 0;
int origin_h = 0;
@@ -936,7 +942,7 @@ _media_thumb_image(const char *origin_path,
if ((image_type != IMG_CODEC_JPEG) &&
(origin_w * origin_h > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
thumb_warn("This original image is too big");
- return MS_MEDIA_ERR_THUMB_TOO_BIG;
+ return MEDIA_THUMB_ERROR_UNSUPPORTED;
}
if (image_type == IMG_CODEC_AGIF) {
@@ -952,7 +958,7 @@ _media_thumb_image(const char *origin_path,
} else {
char file_ext[10];
err = _media_thumb_get_file_ext(origin_path, file_ext, sizeof(file_ext));
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_warn("_media_thumb_get_file_ext failed");
} else {
if (strcasecmp(file_ext, "wbmp") == 0) {
@@ -961,14 +967,14 @@ _media_thumb_image(const char *origin_path,
int wbmp_height = 0;
err = _media_thumb_get_wh_with_gdk(origin_path, &wbmp_width, &wbmp_height);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_get_wh_with_gdk in WBMP : %d", err);
return err;
}
if (wbmp_width * wbmp_height > THUMB_MAX_ALLOWED_MEM_FOR_THUMB) {
thumb_warn("This original image is too big");
- return MS_MEDIA_ERR_THUMB_TOO_BIG;
+ return MEDIA_THUMB_ERROR_UNSUPPORTED;
}
thumb_info->origin_width = wbmp_width;
@@ -981,21 +987,22 @@ _media_thumb_image(const char *origin_path,
}
thumb_warn("Unsupported image type");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_UNSUPPORTED;
}
return err;
}
-int _media_thumb_video(const char *origin_path,
+int
+_media_thumb_video(const char *origin_path,
int thumb_width,
int thumb_height,
media_thumb_format format,
media_thumb_info *thumb_info,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
-
+ int err = -1;
+
MMHandleType content = (MMHandleType) NULL;
void *frame = NULL;
int video_track_num = 0;
@@ -1009,7 +1016,7 @@ int _media_thumb_video(const char *origin_path,
drm_bool_type_e drm_type;
ret = (drm_is_drm_file(origin_path, &drm_type) == 1);
- if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret < 0) {
thumb_err("drm_is_drm_file falied : %d", ret);
drm_type = DRM_FALSE;
}
@@ -1017,17 +1024,21 @@ int _media_thumb_video(const char *origin_path,
is_drm = drm_type;
err = mm_file_create_content_attrs(&content, origin_path);
- if (err != MM_ERROR_NONE) {
+ if (err < 0) {
thumb_err("mm_file_create_content_attrs fails : %d", err);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
- err = mm_file_get_attrs(content, &err_msg, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &video_track_num, NULL);
- if (err != MM_ERROR_NONE) {
+ err =
+ mm_file_get_attrs(content, &err_msg,
+ MM_FILE_CONTENT_VIDEO_TRACK_COUNT,
+ &video_track_num, NULL);
+
+ if (err != 0) {
thumb_err("mm_file_get_attrs fails : %s", err_msg);
SAFE_FREE(err_msg);
mm_file_destroy_content_attrs(content);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
/* MMF api handle both normal and DRM video */
@@ -1041,11 +1052,11 @@ int _media_thumb_video(const char *origin_path,
MM_FILE_CONTENT_VIDEO_THUMBNAIL, &frame, /* raw image is RGB888 format */
&size, NULL);
- if (err != MM_ERROR_NONE) {
+ if (err != 0) {
thumb_err("mm_file_get_attrs fails : %s", err_msg);
SAFE_FREE(err_msg);
mm_file_destroy_content_attrs(content);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
thumb_dbg("video width: %d", width);
@@ -1056,7 +1067,7 @@ int _media_thumb_video(const char *origin_path,
if (frame == NULL || width == 0 || height == 0) {
thumb_err("Failed to get frame data");
mm_file_destroy_content_attrs(content);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_MM_UTIL;
}
media_thumb_type thumb_type;
@@ -1080,7 +1091,7 @@ int _media_thumb_video(const char *origin_path,
thumb_width,
thumb_height);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_resize_data failed - %d", err);
SAFE_FREE(thumb_info->data);
mm_file_destroy_content_attrs(content);
@@ -1146,8 +1157,8 @@ int _media_thumb_video(const char *origin_path,
}
err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, r_w, r_h, &r_size);
- if (err != MM_ERROR_NONE) {
- thumb_err("mm_util_get_image_size failed : %d", err);
+ if (err < 0) {
+ thumb_dbg("mm_util_get_image_size failed : %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
@@ -1156,10 +1167,10 @@ int _media_thumb_video(const char *origin_path,
rotated = (unsigned char *)malloc(r_size);
err = mm_util_rotate_image(thumb_info->data, thumb_info->width, thumb_info->height,
MM_UTIL_IMG_FMT_RGB888,
- rotated, &r_w, &r_h,
+ rotated, &r_w, &r_h,
rot_type);
- if (err != MM_ERROR_NONE) {
+ if (err < 0) {
thumb_err("mm_util_rotate_image failed : %d", err);
SAFE_FREE(thumb_info->data);
SAFE_FREE(rotated);
@@ -1169,6 +1180,7 @@ int _media_thumb_video(const char *origin_path,
}
SAFE_FREE(thumb_info->data);
+
thumb_info->data = rotated;
thumb_info->size = r_size;
thumb_info->width = r_w;
@@ -1176,7 +1188,7 @@ int _media_thumb_video(const char *origin_path,
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
@@ -1190,9 +1202,9 @@ int _media_thumb_video(const char *origin_path,
frame = NULL;
mm_file_destroy_content_attrs(content);
- return MS_MEDIA_ERR_INTERNAL;
+ return MEDIA_THUMB_ERROR_UNSUPPORTED;
}
- return err;
+ return 0;
}
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index dca2285..c52c42a 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -30,24 +30,24 @@
int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
//int need_update_db = 0;
media_thumb_info thumb_info;
if (origin_path == NULL || thumb_path == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_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 MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
if (max_length <= 0) {
thumb_err("Length is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
int store_type = -1;
@@ -55,28 +55,51 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) {
thumb_err("origin path(%s) is invalid", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ 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(origin_path, thumb_path, max_length, &need_update_db);
+ 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, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
+ //_media_thumb_db_disconnect();
return err;
}
+/*
+ // Need to update DB once generating thumb is done
+ if (need_update_db) {
+ err = _media_thumb_update_db(origin_path, thumb_path, thumb_info.origin_width, thumb_info.origin_height);
+ if (err < 0) {
+ thumb_err("_media_thumb_update_db failed : %d", err);
+ }
+ }
- return MS_MEDIA_ERR_NONE;
+ _media_thumb_db_disconnect();
+*/
+ return MEDIA_THUMB_ERROR_NONE;
}
int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thumb_type, const char *thumb_path, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
if (origin_path == NULL || thumb_path == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
media_thumb_info thumb_info;
@@ -87,39 +110,39 @@ int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thu
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_SAVE_FILE, thumb_type, origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MS_MEDIA_ERR_NONE;
+ 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, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
//int need_update_db = 0;
media_thumb_info thumb_info;
if (origin_path == NULL || thumb_path == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
if (origin_width == NULL || origin_height == NULL) {
thumb_err("Invalid parameter ( width or height )");
- return MS_MEDIA_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 MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
if (max_length <= 0) {
thumb_err("Length is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
int store_type = -1;
@@ -127,14 +150,26 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat
if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) {
thumb_err("origin path(%s) is invalid", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ 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, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
//_media_thumb_db_disconnect();
return err;
@@ -143,12 +178,13 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat
*origin_width = thumb_info.origin_width;
*origin_height = thumb_info.origin_height;
- return MS_MEDIA_ERR_NONE;
+ //_media_thumb_db_disconnect();
+ return MEDIA_THUMB_ERROR_NONE;
}
int thumbnail_request_extract_all_thumbs(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
media_thumb_info thumb_info;
media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
@@ -157,27 +193,27 @@ int thumbnail_request_extract_all_thumbs(uid_t uid)
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_ALL_MEDIA, thumb_type, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
if (origin_path == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_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 MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
int store_type = -1;
@@ -185,7 +221,7 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi
if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) {
thumb_err("origin path(%s) is invalid", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_err("Path : %s", origin_path);
@@ -196,13 +232,13 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, userData, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
SAFE_FREE(userData);
return err;
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int _media_thumbnail_cancel_cb(int error_code, char* path, void* data)
@@ -210,32 +246,32 @@ int _media_thumbnail_cancel_cb(int error_code, char* path, void* data)
thumb_dbg("Error code : %d", error_code);
if (path) thumb_dbg("Cancel : %s", path);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int thumbnail_request_cancel_media(const char *origin_path, uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
if (origin_path == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, thumb_type, origin_path, NULL, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int thumbnail_request_cancel_all(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
media_thumb_info thumb_info;
media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
@@ -244,10 +280,10 @@ int thumbnail_request_cancel_all(uid_t uid)
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL, thumb_type, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
return 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 664cc47..1ee9aa5 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -21,7 +21,6 @@
#include "media-thumb-db.h"
#include "media-thumb-util.h"
-#include "media-thumb-debug.h"
#include <glib.h>
#include <string.h>
@@ -51,14 +50,14 @@ sqlite3 *_media_thumb_db_get_handle()
int
_media_thumb_sqlite_connect(sqlite3 **handle)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = db_util_open(MEDIA_DATABASE_NAME, handle,
DB_UTIL_REGISTER_HOOK_METHOD);
if (SQLITE_OK != err) {
*handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
/*Register busy handler*/
@@ -71,30 +70,30 @@ _media_thumb_sqlite_connect(sqlite3 **handle)
}
*handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
} else {
*handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
_media_thumb_sqlite_disconnect(sqlite3 *handle)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
if (handle != NULL) {
err = db_util_close(handle);
if (SQLITE_OK != err) {
handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
@@ -106,7 +105,7 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
int err = -1;
@@ -125,21 +124,21 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
- return MS_MEDIA_ERR_DB_INTERNAL;
+ 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]", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_DB_NO_RECORD;
+ return -1;
}
*type = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
@@ -186,10 +185,11 @@ int _media_thumb_get_wh_from_db(sqlite3 *handle,
*height = sqlite3_column_int(stmt, 1);
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
+int
+_media_thumb_get_thumb_path_from_db(sqlite3 *handle,
const char *origin_path,
char *thumb_path,
int max_length)
@@ -217,13 +217,13 @@ int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
+ 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]", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
return -1;
}
@@ -235,23 +235,24 @@ int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
+int
+_media_thumb_update_thumb_path_to_db(sqlite3 *handle,
const char *origin_path,
char *thumb_path,
uid_t uid)
{
thumb_dbg("");
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
char *path_string = NULL;
char *thumbpath_string = NULL;
char *query_string = NULL;
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
path_string = sqlite3_mprintf("%s", origin_path);
@@ -275,7 +276,7 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
err_msg = NULL;
}
- return MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ return -1;
}
if (err_msg)
@@ -289,7 +290,7 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
#endif
thumb_dbg("Query success");
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
@@ -299,13 +300,14 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
int height,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ thumb_dbg("");
+ int err = -1;
char *path_string = NULL;
char *query_string = NULL;
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
path_string = sqlite3_mprintf("%s", origin_path);
@@ -327,31 +329,33 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
err_msg = NULL;
}
- return MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ return -1;
}
if (err_msg)
sqlite3_free(err_msg);
#else
err = media_db_request_update_db(query_string, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
#endif
thumb_dbg("Query success");
- return err;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
+int
+_media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
const char *origin_path,
char *thumb_path,
int width,
int height,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ thumb_dbg("");
+ int err = -1;
char *path_string = NULL;
char *query_string = NULL;
@@ -364,22 +368,23 @@ int _media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
query_string = sqlite3_mprintf(UPDATE_THUMB_WH_BY_PATH, thumb_path, width, height, path_string);
err = media_db_request_update_db(query_string, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
thumb_dbg("Query success");
- return err;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_db_connect(uid_t uid)
+int
+_media_thumb_db_connect(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
/*
err = media_svc_connect(&mb_svc_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_svc_connect failed: %d", err);
mb_svc_handle = NULL;
return err;
@@ -387,31 +392,31 @@ int _media_thumb_db_connect(uid_t uid)
*/
#ifndef _USE_MEDIA_UTIL_
err = _media_thumb_sqlite_connect(&db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_sqlite_connect failed: %d", err);
db_handle = NULL;
return err;
}
#else
err = media_db_connect(&db_handle,uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_connect failed: %d", err);
db_handle = NULL;
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return MEDIA_THUMB_ERROR_DB;
}
#endif
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
_media_thumb_db_disconnect()
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
/*
err = media_svc_disconnect(mb_svc_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_svc_disconnect failed: %d", err);
}
@@ -419,17 +424,17 @@ _media_thumb_db_disconnect()
*/
#ifndef _USE_MEDIA_UTIL_
err = _media_thumb_sqlite_disconnect(db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_sqlite_disconnect failed: %d", err);
db_handle = NULL;
return err;
}
#else
err = media_db_disconnect(db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_disconnect failed: %d", err);
db_handle = NULL;
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return MEDIA_THUMB_ERROR_DB;
}
#endif
@@ -437,11 +442,13 @@ _media_thumb_db_disconnect()
return err;
}
-int _media_thumb_get_thumb_from_db(const char *origin_path,
+int
+_media_thumb_get_thumb_from_db(const char *origin_path,
char *thumb_path,
int max_length,
int *need_update_db)
{
+ thumb_dbg("");
int err = -1;
//err = minfo_get_thumb_path(mb_svc_handle, origin_path, thumb_path, max_length);
@@ -468,16 +475,18 @@ int _media_thumb_get_thumb_from_db(const char *origin_path,
thumb_dbg("This thumb path already exist");
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_get_thumb_from_db_with_size(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);
@@ -515,32 +524,34 @@ int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
}
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_update_db(const char *origin_path,
+int
+_media_thumb_update_db(const char *origin_path,
char *thumb_path,
int width,
int height,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ thumb_dbg("");
+ int err = -1;
#if 0
Mitem *item = NULL;
err = minfo_get_item(mb_svc_handle, origin_path, &item);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("minfo_get_item (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
err = minfo_update_media_thumb(mb_svc_handle, item->uuid, thumb_path);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("minfo_update_media_thumb (ID:%s, %s) failed: %d",
item->uuid, thumb_path, err);
minfo_destroy_mtype_item(item);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
if (item->type == MINFO_ITEM_IMAGE) {
@@ -548,10 +559,10 @@ int _media_thumb_update_db(const char *origin_path,
MINFO_IMAGE_META_WIDTH, width,
MINFO_IMAGE_META_HEIGHT, height, -1);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("minfo_update_image_meta_info_int failed: %d", err);
minfo_destroy_mtype_item(item);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
}
@@ -562,21 +573,21 @@ int _media_thumb_update_db(const char *origin_path,
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 err;
+ return MEDIA_THUMB_ERROR_DB;
}
#if 0
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 err;
+ return MEDIA_THUMB_ERROR_DB;
}
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) {
thumb_err("_media_thumb_update_wh_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
}
#else
@@ -584,19 +595,19 @@ int _media_thumb_update_db(const char *origin_path,
err = _media_thumb_update_thumb_path_wh_to_db(db_handle, origin_path, thumb_path, width, height,uid);
if (err < 0) {
thumb_err("_media_thumb_update_wh_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
} else {
err = _media_thumb_update_thumb_path_to_db(db_handle, origin_path, thumb_path, uid);
if (err < 0) {
thumb_err("_media_thumb_update_thumb_path_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
}
#endif
thumb_dbg("_media_thumb_update_db success");
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 2f0fef0..8421146 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -83,7 +83,7 @@ _media_thumb_get_file_type(const char *file_full_path)
char mimetype[255];
if (file_full_path == NULL)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
ret = drm_is_drm_file(file_full_path, &drm_type);
if (ret < 0) {
@@ -382,30 +382,30 @@ int _thumbnail_get_data(const char *origin_path,
if (origin_path == NULL || size == NULL
|| width == NULL || height == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) {
thumb_err("parameter format is invalid");
- return MS_MEDIA_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) does not exist", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_width = _media_thumb_get_width(thumb_type);
if (thumb_width < 0) {
thumb_err("media_thumb_type is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_height = _media_thumb_get_height(thumb_type);
if (thumb_height < 0) {
thumb_err("media_thumb_type is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_dbg("Origin path : %s", origin_path);
@@ -440,5 +440,5 @@ int _thumbnail_get_data(const char *origin_path,
thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x",
*size, *width, *height, *data);
- return MS_MEDIA_ERR_NONE;
-} \ No newline at end of file
+ return MEDIA_THUMB_ERROR_NONE;
+}