summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhj kim <backto.kim@samsung.com>2015-06-04 22:58:36 -0700
committerhj kim <backto.kim@samsung.com>2015-06-04 22:58:36 -0700
commit147bd126e27935c2f61283e0b9b247b713744127 (patch)
tree97e54161e040dbc59c0945184ed3a0abc1f3cc02
parent999b9402a56d7c9738d6d632eff2f90004bbfbaf (diff)
downloadlibmedia-thumbnail-147bd126e27935c2f61283e0b9b247b713744127.tar.gz
libmedia-thumbnail-147bd126e27935c2f61283e0b9b247b713744127.tar.bz2
libmedia-thumbnail-147bd126e27935c2f61283e0b9b247b713744127.zip
This reverts commit 999b9402a56d7c9738d6d632eff2f90004bbfbaf. Change-Id: Ieadecdcb087ad27b7c60a1ed448db329df2b38c1
-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, 326 insertions, 489 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc114a7..75edff3 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,7 +98,6 @@ 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
deleted file mode 100755
index 3ec6cbe..0000000
--- a/include/media-thumb-error.h
+++ /dev/null
@@ -1,63 +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.
- *
- */
-
-
-
-#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 3387a6c..56e36ea 100755
--- a/include/media-thumb-types.h
+++ b/include/media-thumb-types.h
@@ -18,8 +18,7 @@
* 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 e606141..a7d1daf 100755
--- a/include/media-thumbnail-private.h
+++ b/include/media-thumbnail-private.h
@@ -23,8 +23,6 @@
#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 1101258..f3b6148 100755
--- a/include/media-thumbnail.h
+++ b/include/media-thumbnail.h
@@ -26,7 +26,6 @@
#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 bd8df13..6081681 100644
--- a/md5/media-thumb-hash.c
+++ b/md5/media-thumb-hash.c
@@ -29,6 +29,7 @@
#include "media-thumbnail-private.h"
#include <string.h>
#include <alloca.h>
+#include <media-util-err.h>
static const char ACCEPTABLE_URI_CHARS[96] = {
@@ -115,18 +116,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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
hash = _media_thumb_generate_hash_name(origin_path);
if (hash == NULL) {
- return MEDIA_THUMB_ERROR_HASHCODE;
+ return MS_MEDIA_ERR_INTERNAL;
}
strncpy(hash_code, hash, max_length);
hash_code[strlen(hash_code)] ='\0';
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index be63478..4886069 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -9,6 +9,7 @@ Source1001: %{name}.manifest
Source1002: %{name}-devel.manifest
Source1003: media-thumbnail-server.manifest
+Requires: media-server
BuildRequires: cmake
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(dlog)
@@ -22,7 +23,6 @@ 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 1553604..bd08d61 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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_process(req_msg, res_msg, uid);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_db_connect failed: %d", err);
- return MEDIA_THUMB_ERROR_DB;
+ return err;
}
sqlite_db_handle = _media_thumb_db_get_handle();
if (sqlite_db_handle == NULL) {
thumb_err("sqlite handle is NULL");
- return MEDIA_THUMB_ERROR_DB;
+ return MS_MEDIA_ERR_INTERNAL;
}
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]\n", sqlite3_errmsg(sqlite_db_handle));
+ thumb_err("prepare error [%s]", sqlite3_errmsg(sqlite_db_handle));
_media_thumb_db_disconnect();
- return MEDIA_THUMB_ERROR_DB;
+ return MS_MEDIA_ERR_INTERNAL;
}
while(1) {
err = sqlite3_step(sqlite_stmt);
if (err != SQLITE_ROW) {
- thumb_dbg("end of row [%s]\n", sqlite3_errmsg(sqlite_db_handle));
+ thumb_dbg("end of row [%s]", 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 MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _thumb_daemon_process_queue_jobs(gpointer data)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
char *path = NULL;
uid_t uid = NULL;
if (g_cur_idx < g_idx) {
- thumb_dbg("There are %d jobs in the queue", g_idx - g_cur_idx);
+ thumb_warn("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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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 ca5fd48..4248f24 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -24,7 +24,6 @@
#include "media-thumb-ipc.h"
#include "media-thumb-util.h"
#include "thumb-server-internal.h"
-
#include <pthread.h>
#include <heynoti.h>
#include <vconf.h>
@@ -92,12 +91,12 @@ int main()
/* Create and bind new UDP socket */
if (!_thumb_server_prepare_socket(&sockfd)) {
- thumb_err("Failed to create socket\n");
+ thumb_err("Failed to create socket");
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);
@@ -117,15 +116,13 @@ 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...");
+ 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 dad124b..e1e5a11 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 46eb130..47062bc 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 26027b9..dd04455 100644
--- a/src/codec/img-codec-parser.c
+++ b/src/codec/img-codec-parser.c
@@ -28,6 +28,7 @@
#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"
@@ -423,7 +424,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;
}
@@ -445,7 +446,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.\n");
+ thumb_dbg("Interlaced PNG Image.");
}
thumb_dbg("IMG_CODEC_PNG\n");
return IMG_CODEC_PNG;
@@ -469,23 +470,22 @@ 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,8 +498,7 @@ 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;
@@ -510,10 +509,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;
}
@@ -527,17 +526,14 @@ 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;
}
@@ -546,9 +542,7 @@ 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;
@@ -588,14 +582,11 @@ 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;
}
@@ -609,28 +600,20 @@ 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 */
@@ -639,8 +622,7 @@ ImgCodecType _ImgGetInfoStreaming(HFile hFile, unsigned long fileSize,
return IMG_CODEC_UNKNOWN_TYPE;
}
- ifegstreamctrl.buffpos +=
- (length);
+ ifegstreamctrl.buffpos += (length);
/* File End Check */
}
break;
@@ -721,51 +703,38 @@ 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 07f3a6b..708c5ce 100644
--- a/src/include/codec/img-codec.h
+++ b/src/include/codec/img-codec.h
@@ -26,7 +26,6 @@
#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 1819af4..b4ad38e 100755
--- a/src/include/ipc/media-thumb-ipc.h
+++ b/src/include/ipc/media-thumb-ipc.h
@@ -20,7 +20,6 @@
*/
-#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 84556fc..addbc7b 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 b29920a..3dc5495 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -21,7 +21,6 @@
#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 65ca53f..2bc7380 100755
--- a/src/include/util/media-thumb-debug.h
+++ b/src/include/util/media-thumb-debug.h
@@ -28,6 +28,7 @@
#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 41409d2..7eee7d8 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -19,7 +19,6 @@
*
*/
-#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 e9d7c0c..2f56457 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -23,6 +23,7 @@
#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>
@@ -46,7 +47,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
if (sock_type == CLIENT_SOCKET) {
@@ -60,7 +61,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
} else if (sock_type == SERVER_SOCKET) {
@@ -69,13 +70,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
}
*sock = sock_fd;
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
@@ -86,7 +87,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
#ifdef _USE_MEDIA_UTIL_
@@ -98,22 +99,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
*sock = sock_fd;
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_thumb_get_error()
{
if (errno == EWOULDBLOCK) {
thumb_err("Timeout. Can't try any more");
- return MEDIA_THUMB_ERROR_TIMEOUT;
+ return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
} else {
thumb_err("recvfrom failed : %s", strerror(errno));
- return MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_RECEIVE;
}
}
@@ -157,14 +158,14 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
}
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int __media_thumb_check_req_queue(const char *path)
{
int req_len = 0, i;
- if (g_request_queue == NULL) return MEDIA_THUMB_ERROR_NONE;
+ if (g_request_queue == NULL) return MS_MEDIA_ERR_NONE;
req_len = g_queue_get_length(g_request_queue);
// thumb_dbg("Queue length : %d", req_len);
@@ -181,14 +182,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 -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
break;
}
}
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int
@@ -234,7 +235,7 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
//thumb_dbg("destination path : %s", msg->dst_path);
SAFE_FREE(buf);
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
#ifdef _USE_UDS_SOCKET_
@@ -266,7 +267,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
strncpy(msg->org_path, (char*)buf + header_size, msg->origin_path_size);
@@ -275,7 +276,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
strncpy(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, msg->dest_path_size);
@@ -284,14 +285,14 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
SAFE_FREE(buf);
*from_size = from_addr_size;
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int
_media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
{
if (req_msg == NULL || buf == NULL) {
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
int org_path_len = 0;
@@ -313,7 +314,7 @@ _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
*buf_size = size;
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
int
@@ -330,7 +331,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
#endif
int recv_str_len = 0;
- int err;
+ int err = MS_MEDIA_ERR_NONE;
int pid;
@@ -343,13 +344,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
#else
/* Creaete a TCP socket */
if (_media_thumb_create_socket(CLIENT_SOCKET, &sock) < 0) {
thumb_err("_media_thumb_create_socket failed");
- return MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
#endif
@@ -379,7 +380,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
thumbMsg req_msg;
@@ -410,7 +411,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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
unsigned char *buf = NULL;
@@ -424,7 +425,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_SEND;
}
thumb_dbg("Sending msg to thumbnail daemon is successful");
@@ -444,12 +445,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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (recv_msg.status == THUMB_FAIL) {
thumb_err("Failed to make thumbnail");
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (msg_type != THUMB_REQUEST_SAVE_FILE) {
@@ -459,7 +460,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 0;
+ return MS_MEDIA_ERR_NONE;
}
static int _mkdir(const char *dir, mode_t mode) {
@@ -536,7 +537,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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
int msg_type = req_msg->msg_type;
@@ -551,22 +552,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
- return MEDIA_THUMB_ERROR_DB;
+ return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
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 == 0) {
+ if (err == MS_MEDIA_ERR_NONE) {
res_msg->origin_width = origin_w;
res_msg->origin_height = origin_h;
_media_thumb_db_disconnect();
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
} else {
if (strlen(thumb_path) == 0) {
err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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();
@@ -599,7 +600,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_thumbnail_get_data failed - %d\n", err);
if ( gdkdata != NULL ){
g_object_unref(gdkdata);
@@ -669,14 +670,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_update_db failed : %d", err);
}
}
_media_thumb_db_disconnect();
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
@@ -685,7 +686,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 = MEDIA_THUMB_ERROR_NONE;
+ int err = MS_MEDIA_ERR_NONE;
memset((void *)&recv_msg, 0, sizeof(thumbMsg));
sock = g_io_channel_unix_get_fd(src);
@@ -710,7 +711,7 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
if (recv_msg.status == THUMB_FAIL) {
thumb_err("Failed to make thumbnail");
- err = MEDIA_THUMB_ERROR_UNSUPPORTED;
+ err = MS_MEDIA_ERR_INTERNAL;
goto callback;
}
@@ -742,7 +743,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 MEDIA_THUMB_ERROR_DUPLICATED_REQUEST;
+ return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
}
#ifdef _USE_MEDIA_UTIL_
@@ -754,13 +755,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
#else
/* Creaete a TCP socket */
if (_media_thumb_create_socket(CLIENT_SOCKET, &sock) < 0) {
thumb_err("_media_thumb_create_socket failed");
- return MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
#endif
@@ -795,7 +796,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_CONN;
}
if (msg_type != THUMB_REQUEST_CANCEL_MEDIA) {
@@ -828,7 +829,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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
unsigned char *buf = NULL;
@@ -842,7 +843,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 MEDIA_THUMB_ERROR_NETWORK;
+ return MS_MEDIA_ERR_SOCKET_SEND;
}
SAFE_FREE(buf);
@@ -867,7 +868,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 0;
+ return MS_MEDIA_ERR_NONE;
}
thumb_req->channel = channel;
@@ -879,6 +880,5 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
}
#endif
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
-
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index e6b3f12..b8890f7 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 0;
+ return MS_MEDIA_ERR_NONE;
}
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 -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
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 -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
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 -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
exif_entry_get_value(entry, buf, max_size);
buf[strlen(buf)] = '\0';
@@ -159,11 +159,10 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
}
}
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
-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,
@@ -200,16 +199,15 @@ _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 -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
} else {
thumb_dbg("entry is NULL");
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/* Get width and height of thumbnail */
tag = EXIF_TAG_IMAGE_WIDTH;
-
entry = exif_content_get_entry(ed->ifd[ifd], tag);
if (entry) {
@@ -221,9 +219,7 @@ _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);
@@ -458,11 +454,10 @@ 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 MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
thumb_dbg("mm_util_get_image_size : %d", buf_size);
@@ -477,7 +472,7 @@ int _media_thumb_resize_data(unsigned char *src_data,
SAFE_FREE(dst);
- return MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
thumb_info->size = buf_size;
@@ -488,7 +483,7 @@ int _media_thumb_resize_data(unsigned char *src_data,
SAFE_FREE(dst);
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
int _media_thumb_get_wh_with_gdk(const char *origin_path, int *width, int *height)
@@ -501,14 +496,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 -1;
+ return MS_MEDIA_ERR_INTERNAL;
}
/* Get w/h of original image */
*width = gdk_pixbuf_get_width(pixbuf);
*height = gdk_pixbuf_get_height(pixbuf);
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
int _media_thumb_decode_with_gdk(const char *origin_path,
@@ -522,7 +517,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 -1;
+ return MS_MEDIA_ERR_INTERNAL;
}
/* Get w/h of original image */
@@ -546,7 +541,7 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
rotated_orig_h = height;
}
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
media_thumb_type thumb_type;
if (thumb_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
@@ -558,7 +553,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
g_object_unref(pixbuf);
return err;
@@ -574,7 +569,7 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
g_object_unref(pixbuf);
- return MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
thumb_info->size = buf_size;
@@ -584,38 +579,37 @@ int _media_thumb_decode_with_gdk(const char *origin_path,
thumb_info->gdkdata = gdk_pixbuf_copy(pixbuf);
g_object_unref(pixbuf);
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
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 -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
}
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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
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 MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
thumb_dbg("mm_util_get_image_size : %d", buf_size);
@@ -641,11 +635,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 MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
}
@@ -655,18 +649,18 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info,
thumb_dbg("_media_thumb_convert_data success");
- return 0;
+ return err;
}
int _media_thumb_convert_format(media_thumb_info *thumb_info,
media_thumb_format src_format,
media_thumb_format dst_format)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
if (src_format == dst_format) {
//thumb_dbg("src_format == dst_format");
- return 0;
+ return err;
}
mm_util_img_format src_mm_format;
@@ -677,21 +671,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 MEDIA_THUMB_ERROR_UNSUPPORTED;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- 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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_thumb_convert_format failed : %d", err);
return err;
}
- return 0;
+ return err;
}
int _media_thumb_agif(const char *origin_path,
@@ -701,7 +695,7 @@ int _media_thumb_agif(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
unsigned int *thumb = NULL;
media_thumb_type thumb_type;
@@ -709,7 +703,7 @@ int _media_thumb_agif(const char *origin_path,
if (!thumb) {
thumb_err("Frame data is NULL!!");
- return MEDIA_THUMB_ERROR_UNSUPPORTED;
+ return MS_MEDIA_ERR_INTERNAL;
}
if (thumb_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
@@ -721,13 +715,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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,
@@ -735,7 +729,7 @@ int _media_thumb_agif(const char *origin_path,
thumb_width,
thumb_height);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_resize_data failed: %d", err);
SAFE_FREE(thumb);
return err;
@@ -744,13 +738,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return 0;
+ return err;
}
int _media_thumb_png(const char *origin_path,
@@ -759,22 +753,22 @@ int _media_thumb_png(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
-
- if (err < 0) {
+
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return 0;
+ return err;
}
int _media_thumb_bmp(const char *origin_path,
@@ -783,22 +777,22 @@ int _media_thumb_bmp(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return 0;
+ return err;
}
int _media_thumb_wbmp(const char *origin_path,
@@ -807,46 +801,46 @@ int _media_thumb_wbmp(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return 0;
+ return err;
}
-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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
- return 0;
+ return err;
}
int _media_thumb_jpeg(const char *origin_path,
@@ -856,7 +850,7 @@ int _media_thumb_jpeg(const char *origin_path,
media_thumb_info *thumb_info,
uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
ExifData *ed = NULL;
int thumb_done = 0;
int orientation = NORMAL;
@@ -868,14 +862,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_dbg("_media_thumb_get_thumb_from_exif failed");
} else {
thumb_done = 1;
@@ -889,7 +883,7 @@ int _media_thumb_jpeg(const char *origin_path,
MM_UTIL_IMG_FMT_RGB888,
dst_format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_data failed : %d", err);
exif_data_unref(ed);
return err;
@@ -903,20 +897,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("decode_with_gdk failed : %d", err);
return err;
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
}
- return 0;
+ return err;
}
int
@@ -926,7 +920,7 @@ _media_thumb_image(const char *origin_path,
media_thumb_format format,
media_thumb_info *thumb_info, uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
int image_type = 0;
int origin_w = 0;
int origin_h = 0;
@@ -942,7 +936,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 MEDIA_THUMB_ERROR_UNSUPPORTED;
+ return MS_MEDIA_ERR_THUMB_TOO_BIG;
}
if (image_type == IMG_CODEC_AGIF) {
@@ -958,7 +952,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_warn("_media_thumb_get_file_ext failed");
} else {
if (strcasecmp(file_ext, "wbmp") == 0) {
@@ -967,14 +961,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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 MEDIA_THUMB_ERROR_UNSUPPORTED;
+ return MS_MEDIA_ERR_THUMB_TOO_BIG;
}
thumb_info->origin_width = wbmp_width;
@@ -987,22 +981,21 @@ _media_thumb_image(const char *origin_path,
}
thumb_warn("Unsupported image type");
- return MEDIA_THUMB_ERROR_UNSUPPORTED;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
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 = -1;
-
+ int err = MS_MEDIA_ERR_NONE;
+
MMHandleType content = (MMHandleType) NULL;
void *frame = NULL;
int video_track_num = 0;
@@ -1016,7 +1009,7 @@ _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 < 0) {
+ if (ret != MS_MEDIA_ERR_NONE) {
thumb_err("drm_is_drm_file falied : %d", ret);
drm_type = DRM_FALSE;
}
@@ -1024,21 +1017,17 @@ _media_thumb_video(const char *origin_path,
is_drm = drm_type;
err = mm_file_create_content_attrs(&content, origin_path);
- if (err < 0) {
+ if (err != MM_ERROR_NONE) {
thumb_err("mm_file_create_content_attrs fails : %d", err);
- return MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
- err =
- mm_file_get_attrs(content, &err_msg,
- MM_FILE_CONTENT_VIDEO_TRACK_COUNT,
- &video_track_num, NULL);
-
- if (err != 0) {
+ err = mm_file_get_attrs(content, &err_msg, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &video_track_num, NULL);
+ if (err != MM_ERROR_NONE) {
thumb_err("mm_file_get_attrs fails : %s", err_msg);
SAFE_FREE(err_msg);
mm_file_destroy_content_attrs(content);
- return MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
/* MMF api handle both normal and DRM video */
@@ -1052,11 +1041,11 @@ _media_thumb_video(const char *origin_path,
MM_FILE_CONTENT_VIDEO_THUMBNAIL, &frame, /* raw image is RGB888 format */
&size, NULL);
- if (err != 0) {
+ if (err != MM_ERROR_NONE) {
thumb_err("mm_file_get_attrs fails : %s", err_msg);
SAFE_FREE(err_msg);
mm_file_destroy_content_attrs(content);
- return MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
thumb_dbg("video width: %d", width);
@@ -1067,7 +1056,7 @@ _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 MEDIA_THUMB_ERROR_MM_UTIL;
+ return MS_MEDIA_ERR_INTERNAL;
}
media_thumb_type thumb_type;
@@ -1091,7 +1080,7 @@ _media_thumb_video(const char *origin_path,
thumb_width,
thumb_height);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_resize_data failed - %d", err);
SAFE_FREE(thumb_info->data);
mm_file_destroy_content_attrs(content);
@@ -1157,8 +1146,8 @@ _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 < 0) {
- thumb_dbg("mm_util_get_image_size failed : %d", err);
+ if (err != MM_ERROR_NONE) {
+ thumb_err("mm_util_get_image_size failed : %d", err);
SAFE_FREE(thumb_info->data);
return err;
}
@@ -1167,10 +1156,10 @@ _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 < 0) {
+ if (err != MM_ERROR_NONE) {
thumb_err("mm_util_rotate_image failed : %d", err);
SAFE_FREE(thumb_info->data);
SAFE_FREE(rotated);
@@ -1180,7 +1169,6 @@ _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;
@@ -1188,7 +1176,7 @@ _media_thumb_video(const char *origin_path,
}
err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_convert_format falied: %d", err);
SAFE_FREE(thumb_info->data);
return err;
@@ -1202,9 +1190,9 @@ _media_thumb_video(const char *origin_path,
frame = NULL;
mm_file_destroy_content_attrs(content);
- return MEDIA_THUMB_ERROR_UNSUPPORTED;
+ return MS_MEDIA_ERR_INTERNAL;
}
- return 0;
+ return err;
}
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index c52c42a..dca2285 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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
//int need_update_db = 0;
media_thumb_info thumb_info;
if (origin_path == NULL || thumb_path == NULL) {
thumb_err("Invalid parameter");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (!g_file_test
(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("Original path(%s) doesn't exist.", origin_path);
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (max_length <= 0) {
thumb_err("Length is invalid");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
int store_type = -1;
@@ -55,51 +55,28 @@ 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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
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);
- }
- }
- _media_thumb_db_disconnect();
-*/
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
if (origin_path == NULL || thumb_path == NULL) {
thumb_err("Invalid parameter");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
media_thumb_info thumb_info;
@@ -110,39 +87,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
//int need_update_db = 0;
media_thumb_info thumb_info;
if (origin_path == NULL || thumb_path == NULL) {
thumb_err("Invalid parameter");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (origin_width == NULL || origin_height == NULL) {
thumb_err("Invalid parameter ( width or height )");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (!g_file_test
(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("Original path(%s) doesn't exist.", origin_path);
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (max_length <= 0) {
thumb_err("Length is invalid");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
int store_type = -1;
@@ -150,26 +127,14 @@ 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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
//_media_thumb_db_disconnect();
return err;
@@ -178,13 +143,12 @@ 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;
- //_media_thumb_db_disconnect();
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int thumbnail_request_extract_all_thumbs(uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
media_thumb_info thumb_info;
media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
@@ -193,27 +157,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data, uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
if (origin_path == NULL) {
thumb_err("Invalid parameter");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (!g_file_test
(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("Original path(%s) doesn't exist.", origin_path);
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
int store_type = -1;
@@ -221,7 +185,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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
thumb_err("Path : %s", origin_path);
@@ -232,13 +196,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
SAFE_FREE(userData);
return err;
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_thumbnail_cancel_cb(int error_code, char* path, void* data)
@@ -246,32 +210,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 MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int thumbnail_request_cancel_media(const char *origin_path, uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
if (origin_path == NULL) {
thumb_err("Invalid parameter");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, thumb_type, origin_path, NULL, uid);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int thumbnail_request_cancel_all(uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
media_thumb_info thumb_info;
media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
@@ -280,10 +244,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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return MEDIA_THUMB_ERROR_NONE;
+ return err;
}
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index 1ee9aa5..664cc47 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -21,6 +21,7 @@
#include "media-thumb-db.h"
#include "media-thumb-util.h"
+#include "media-thumb-debug.h"
#include <glib.h>
#include <string.h>
@@ -50,14 +51,14 @@ sqlite3 *_media_thumb_db_get_handle()
int
_media_thumb_sqlite_connect(sqlite3 **handle)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
err = db_util_open(MEDIA_DATABASE_NAME, handle,
DB_UTIL_REGISTER_HOOK_METHOD);
if (SQLITE_OK != err) {
*handle = NULL;
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/*Register busy handler*/
@@ -70,30 +71,30 @@ _media_thumb_sqlite_connect(sqlite3 **handle)
}
*handle = NULL;
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
} else {
*handle = NULL;
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int
_media_thumb_sqlite_disconnect(sqlite3 *handle)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
if (handle != NULL) {
err = db_util_close(handle);
if (SQLITE_OK != err) {
handle = NULL;
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int
@@ -105,7 +106,7 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
int err = -1;
@@ -124,21 +125,21 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle));
- return -1;
+ thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
err = sqlite3_step(stmt);
if (err != SQLITE_ROW) {
- thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
- return -1;
+ return MS_MEDIA_ERR_DB_NO_RECORD;
}
*type = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
@@ -185,11 +186,10 @@ int _media_thumb_get_wh_from_db(sqlite3 *handle,
*height = sqlite3_column_int(stmt, 1);
sqlite3_finalize(stmt);
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_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 @@ _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle));
+ thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
return -1;
}
err = sqlite3_step(stmt);
if (err != SQLITE_ROW) {
- thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
return -1;
}
@@ -235,24 +235,23 @@ _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
sqlite3_finalize(stmt);
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_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 = -1;
+ int err = MS_MEDIA_ERR_NONE;
char *path_string = NULL;
char *thumbpath_string = NULL;
char *query_string = NULL;
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
path_string = sqlite3_mprintf("%s", origin_path);
@@ -276,7 +275,7 @@ _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
err_msg = NULL;
}
- return -1;
+ return MS_MEDIA_ERR_DB_UPDATE_FAIL;
}
if (err_msg)
@@ -290,7 +289,7 @@ _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
#endif
thumb_dbg("Query success");
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int
@@ -300,14 +299,13 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
int height,
uid_t uid)
{
- thumb_dbg("");
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
char *path_string = NULL;
char *query_string = NULL;
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return -1;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
path_string = sqlite3_mprintf("%s", origin_path);
@@ -329,33 +327,31 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
err_msg = NULL;
}
- return -1;
+ return MS_MEDIA_ERR_DB_UPDATE_FAIL;
}
if (err_msg)
sqlite3_free(err_msg);
#else
err = media_db_request_update_db(query_string, uid);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
#endif
thumb_dbg("Query success");
- return MEDIA_THUMB_ERROR_NONE;
+ return err;
}
-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)
{
- thumb_dbg("");
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
char *path_string = NULL;
char *query_string = NULL;
@@ -368,23 +364,22 @@ _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 < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
thumb_dbg("Query success");
- return MEDIA_THUMB_ERROR_NONE;
+ return err;
}
-int
-_media_thumb_db_connect(uid_t uid)
+int _media_thumb_db_connect(uid_t uid)
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
/*
err = media_svc_connect(&mb_svc_handle);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_svc_connect failed: %d", err);
mb_svc_handle = NULL;
return err;
@@ -392,31 +387,31 @@ _media_thumb_db_connect(uid_t uid)
*/
#ifndef _USE_MEDIA_UTIL_
err = _media_thumb_sqlite_connect(&db_handle);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_sqlite_connect failed: %d", err);
db_handle = NULL;
return err;
}
#else
err = media_db_connect(&db_handle,uid);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_connect failed: %d", err);
db_handle = NULL;
- return MEDIA_THUMB_ERROR_DB;
+ return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
#endif
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int
_media_thumb_db_disconnect()
{
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
/*
err = media_svc_disconnect(mb_svc_handle);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_svc_disconnect failed: %d", err);
}
@@ -424,17 +419,17 @@ _media_thumb_db_disconnect()
*/
#ifndef _USE_MEDIA_UTIL_
err = _media_thumb_sqlite_disconnect(db_handle);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_sqlite_disconnect failed: %d", err);
db_handle = NULL;
return err;
}
#else
err = media_db_disconnect(db_handle);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("media_db_disconnect failed: %d", err);
db_handle = NULL;
- return MEDIA_THUMB_ERROR_DB;
+ return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
#endif
@@ -442,13 +437,11 @@ _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);
@@ -475,18 +468,16 @@ _media_thumb_get_thumb_from_db(const char *origin_path,
thumb_dbg("This thumb path already exist");
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_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);
@@ -524,34 +515,32 @@ _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
}
}
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_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)
{
- thumb_dbg("");
- int err = -1;
+ int err = MS_MEDIA_ERR_NONE;
#if 0
Mitem *item = NULL;
err = minfo_get_item(mb_svc_handle, origin_path, &item);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("minfo_get_item (%s) failed: %d", origin_path, err);
- return MEDIA_THUMB_ERROR_DB;
+ return err;
}
err = minfo_update_media_thumb(mb_svc_handle, item->uuid, thumb_path);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("minfo_update_media_thumb (ID:%s, %s) failed: %d",
item->uuid, thumb_path, err);
minfo_destroy_mtype_item(item);
- return MEDIA_THUMB_ERROR_DB;
+ return err;
}
if (item->type == MINFO_ITEM_IMAGE) {
@@ -559,10 +548,10 @@ _media_thumb_update_db(const char *origin_path,
MINFO_IMAGE_META_WIDTH, width,
MINFO_IMAGE_META_HEIGHT, height, -1);
- if (err < 0) {
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("minfo_update_image_meta_info_int failed: %d", err);
minfo_destroy_mtype_item(item);
- return MEDIA_THUMB_ERROR_DB;
+ return err;
}
}
@@ -573,21 +562,21 @@ _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 MEDIA_THUMB_ERROR_DB;
+ return err;
}
#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 MEDIA_THUMB_ERROR_DB;
+ return err;
}
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 MEDIA_THUMB_ERROR_DB;
+ return err;
}
}
#else
@@ -595,19 +584,19 @@ _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 MEDIA_THUMB_ERROR_DB;
+ return err;
}
} 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 MEDIA_THUMB_ERROR_DB;
+ return err;
}
}
#endif
thumb_dbg("_media_thumb_update_db success");
- return MEDIA_THUMB_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 8421146..2f0fef0 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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) {
thumb_err("parameter format is invalid");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_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 MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
thumb_width = _media_thumb_get_width(thumb_type);
if (thumb_width < 0) {
thumb_err("media_thumb_type is invalid");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
thumb_height = _media_thumb_get_height(thumb_type);
if (thumb_height < 0) {
thumb_err("media_thumb_type is invalid");
- return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_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 MEDIA_THUMB_ERROR_NONE;
-}
+ return MS_MEDIA_ERR_NONE;
+} \ No newline at end of file