2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <media_info.h>
18 #include <media_info_private.h>
19 #include <media_util_private.h>
20 #include <system_info.h>
22 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
23 static int __media_info_insert_batch(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data);
24 static int __media_info_check_file_validity(const char *path);
26 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
28 int ret = MEDIA_CONTENT_ERROR_NONE;
29 media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
33 ret = _content_error_capi(result->result);
35 if (_cb_data->insert_completed_cb) {
36 content_debug("User callback is being called now");
37 _cb_data->insert_completed_cb(ret, _cb_data->user_data);
40 if (STRING_VALID(_cb_data->insert_list_path)) {
41 if (unlink(_cb_data->insert_list_path) < 0)
42 content_stderror("failed to delete");
43 g_free(_cb_data->insert_list_path);
50 static bool __media_info_isFaceRecognition_feature_supported(void)
52 bool isFaceRecognitionSupported = false;
54 const int nRetVal = system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
56 if (nRetVal != SYSTEM_INFO_ERROR_NONE) {
57 content_debug("SYSTEM_INFO_ERROR: vision.face_recognition [%d]", nRetVal);
61 return isFaceRecognitionSupported;
64 static int __media_info_insert_batch(const char **path_array,
65 unsigned int array_length,
66 media_insert_completed_cb completed_cb,
69 int ret = MEDIA_CONTENT_ERROR_NONE;
71 char list_path[BATCH_REQUEST_FILE_LEN] = {0, };
75 for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
76 snprintf(list_path, BATCH_REQUEST_FILE_LEN, "/tmp/request-%ld-%d", media_content_gettid(), idx);
78 if (g_file_test(list_path, G_FILE_TEST_EXISTS)) {
79 memset(list_path, 0x00, BATCH_REQUEST_FILE_LEN);
82 content_sec_debug("The request file list path : %s", list_path);
87 content_retvm_if(idx == BATCH_REQUEST_MAX, MEDIA_CONTENT_ERROR_DB_BUSY, "Too many request");
89 fp = fopen(list_path, "w");
91 content_stderror("failed to open file");
92 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
95 for (idx = 0; idx < array_length; idx++) {
96 if (!STRING_VALID(path_array[idx])) {
97 content_error("path[%d] is invalid string", idx);
101 ret = __media_info_check_file_validity(path_array[idx]);
102 if (ret != MEDIA_CONTENT_ERROR_NONE)
105 if (!_media_util_check_support_media_type(path_array[idx])) {
106 content_error("Not supported type: index[%d]", idx);
107 ret = MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
111 size = strlen(path_array[idx]);
112 if (fwrite(path_array[idx], 1, size, fp) != size) {
113 content_stderror("failed to write");
114 ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
118 if (fwrite("\n", 1, 1, fp) != 1) {
119 content_stderror("failed to write");
120 ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
127 media_insert_cb_s *_cb_data = g_new0(media_insert_cb_s, 1);
129 _cb_data->insert_completed_cb = completed_cb;
130 _cb_data->user_data = user_data;
131 _cb_data->insert_list_path = g_strdup(list_path);
133 ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, _content_get_uid());
134 if (ret != MEDIA_CONTENT_ERROR_NONE) {
135 content_error("media_files_register failed : %d", ret);
136 if (unlink(list_path) < 0)
137 content_stderror("failed to delete");
139 return _content_error_capi(ret);
142 return MEDIA_CONTENT_ERROR_NONE;
145 if (unlink(list_path) < 0)
146 content_stderror("failed to delete");
151 static int __media_info_check_file_validity(const char *path)
153 g_autofree gchar *folder_path = NULL;
154 int ret = MEDIA_CONTENT_ERROR_NONE;
156 content_retip_if_fail(path);
157 content_retvm_if(_media_util_is_ignorable_file(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
159 ret = _media_util_check_file_exist(path);
160 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "invalid path");
162 folder_path = g_path_get_dirname(path);
163 if (_media_util_is_ignorable_dir(folder_path))
164 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
166 return MEDIA_CONTENT_ERROR_NONE;
169 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media)
171 media_info_s *_media = (media_info_s*)media;
176 _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
177 _media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
178 _media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
179 _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
180 _media->mime_type = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
181 _media->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
182 _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
183 _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
184 _media->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
185 _media->description = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
186 _media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
187 _media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
188 _media->is_drm = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_DRM);
189 _media->longitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LONGITUDE);
190 _media->latitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LATITUDE);
191 _media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
192 _media->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
193 _media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
194 _media->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID));
195 _media->is_360 = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_360);
196 #ifdef _USE_TVPD_MODE
197 _media->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
198 _media->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
199 _media->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
200 _media->stitched_info = (int)sqlite3_column_int(stmt, MEDIA_INFO_STITCHED_INFO);
203 if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
204 _media->image_meta = g_new0(image_meta_s, 1);
206 _media->image_meta->media_id = g_strdup(_media->media_id);
207 _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
208 _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
209 _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
210 _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
211 _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
212 _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
213 _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
214 _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
216 } else if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
217 _media->video_meta = g_new0(video_meta_s, 1);
219 _media->video_meta->media_id = g_strdup(_media->media_id);
220 _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
221 _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
222 _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
223 _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
224 _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
225 _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
226 _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
227 _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
228 _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
229 _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
230 _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
231 _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
232 _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
233 _media->video_meta->rotation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
235 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
236 _media->audio_meta = g_new0(audio_meta_s, 1);
238 _media->audio_meta->media_id = g_strdup(_media->media_id);
239 _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
240 _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
241 _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
242 _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
243 _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
244 _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
245 _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
246 _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
247 _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
248 _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
249 _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
250 _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
251 _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
252 _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
253 } else if (_media->media_type == MEDIA_CONTENT_TYPE_BOOK) {
254 _media->book_meta = g_new0(book_meta_s, 1);
256 _media->book_meta->subject = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
257 _media->book_meta->author = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
258 _media->book_meta->date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
259 _media->book_meta->publisher = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
263 int _media_info_get_media_info_from_db(const char *path, media_info_h media)
265 int ret = MEDIA_CONTENT_ERROR_NONE;
266 sqlite3_stmt *stmt = NULL;
267 char *select_query = NULL;
268 media_info_s *_media = (media_info_s*)media;
270 content_retip_if_fail(path);
271 content_retip_if_fail(media);
273 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
275 ret = _content_get_result(select_query, &stmt);
276 sqlite3_free(select_query);
277 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
279 if (sqlite3_step(stmt) == SQLITE_ROW) {
280 _media_info_item_get_detail(stmt, (media_info_h)_media);
282 content_sec_error("No media : path[%s]", path);
283 ret = MEDIA_CONTENT_ERROR_DB_FAILED;
286 sqlite3_finalize(stmt);
291 int media_info_insert_to_db(const char *path, media_info_h *info)
293 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
294 int ret = MEDIA_CONTENT_ERROR_NONE;
295 int modified_time = 0;
297 content_retip_if_fail(STRING_VALID(path));
298 content_retip_if_fail(info);
300 content_sec_debug("path [%s]", path);
302 ret = __media_info_check_file_validity(path);
303 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
305 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
306 if (ret != MS_MEDIA_ERR_NONE) {
307 content_error("media_svc_get_storage_id failed : %d", ret);
308 return _content_error_capi(ret);
311 /* Get modified time for check exists */
312 ret = media_svc_get_modified_time(_content_get_db_handle(), path, &modified_time);
313 if (ret == MS_MEDIA_ERR_NONE) {
314 /* Refresh if need */
315 if (modified_time != _media_util_get_file_time(path)) {
316 ret = media_svc_refresh_item(_content_get_db_handle(), false, path, _content_get_uid());
317 if (ret != MS_MEDIA_ERR_NONE) {
318 content_error("media_svc_refresh_item failed : %d", ret);
319 return _content_error_capi(ret);
322 } else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
323 content_retvm_if(!_media_util_check_support_media_type(path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
325 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, path, _content_get_uid());
326 if (ret != MS_MEDIA_ERR_NONE) {
327 if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
328 content_info("This item is already inserted. This may be normal operation because other process already did this");
329 ret = MEDIA_CONTENT_ERROR_NONE;
331 content_error("media_svc_insert_item_immediately failed : %d", ret);
334 return _content_error_capi(ret);
337 content_error("media_svc_get_modified_time failed : %d", ret);
338 return _content_error_capi(ret);
341 media_info_s *_media = g_new0(media_info_s, 1);
342 ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
344 *info = (media_info_h)_media;
349 int media_info_insert_batch_to_db(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data)
351 content_retip_if_fail(path_array);
352 content_retip_if_fail(array_length > 0);
353 content_retip_if_fail(completed_cb);
355 return __media_info_insert_batch(path_array, array_length, completed_cb, user_data);
358 #ifdef _USE_TVPD_MODE
359 int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
361 int ret = MEDIA_CONTENT_ERROR_NONE;
363 content_retip_if_fail(STRING_VALID(path));
364 content_retip_if_fail(media);
366 media_info_s *_media = g_new0(media_info_s, 1);
368 ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
369 *media = (media_info_h)_media;
374 static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
376 int ret = MEDIA_CONTENT_ERROR_NONE;
377 sqlite3_stmt *stmt = NULL;
378 char *select_query = NULL;
380 content_retip_if_fail(STRING_VALID(media_id));
382 select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
384 ret = _content_get_result(select_query, &stmt);
385 sqlite3_free(select_query);
386 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
388 if (sqlite3_step(stmt) == SQLITE_ROW) {
389 *path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
391 content_error("There's no media with this ID : %s", media_id);
393 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
396 sqlite3_finalize(stmt);
401 int media_info_delete_from_db(const char *media_id)
403 int ret = MEDIA_CONTENT_ERROR_NONE;
406 content_retip_if_fail(STRING_VALID(media_id));
408 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
409 if (ret != MEDIA_CONTENT_ERROR_NONE) {
410 content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
415 ret = media_svc_delete_item_by_path(_content_get_db_handle(), path, _content_get_uid());
418 return _content_error_capi(ret);
422 int media_info_destroy(media_info_h media)
424 media_info_s *_media = (media_info_s*)media;
426 content_retip_if_fail(media);
428 g_free(_media->media_id);
429 g_free(_media->file_path);
430 g_free(_media->display_name);
431 g_free(_media->mime_type);
432 g_free(_media->thumbnail_path);
433 g_free(_media->description);
434 g_free(_media->title);
435 g_free(_media->storage_uuid);
437 if (_media->image_meta) {
438 g_free(_media->image_meta->media_id);
439 g_free(_media->image_meta->date_taken);
440 g_free(_media->image_meta->exposure_time);
441 g_free(_media->image_meta->model);
443 g_free(_media->image_meta);
446 if (_media->video_meta) {
447 g_free(_media->video_meta->media_id);
448 g_free(_media->video_meta->album);
449 g_free(_media->video_meta->artist);
450 g_free(_media->video_meta->album_artist);
451 g_free(_media->video_meta->genre);
452 g_free(_media->video_meta->composer);
453 g_free(_media->video_meta->year);
454 g_free(_media->video_meta->recorded_date);
455 g_free(_media->video_meta->copyright);
456 g_free(_media->video_meta->track_num);
458 g_free(_media->video_meta);
461 if (_media->audio_meta) {
462 g_free(_media->audio_meta->media_id);
463 g_free(_media->audio_meta->album);
464 g_free(_media->audio_meta->artist);
465 g_free(_media->audio_meta->album_artist);
466 g_free(_media->audio_meta->genre);
467 g_free(_media->audio_meta->composer);
468 g_free(_media->audio_meta->year);
469 g_free(_media->audio_meta->recorded_date);
470 g_free(_media->audio_meta->copyright);
471 g_free(_media->audio_meta->track_num);
473 g_free(_media->audio_meta);
476 if (_media->book_meta) {
477 g_free(_media->book_meta->media_id);
478 g_free(_media->book_meta->author);
479 g_free(_media->book_meta->date);
480 g_free(_media->book_meta->publisher);
481 g_free(_media->book_meta->subject);
483 g_free(_media->book_meta);
488 return MEDIA_CONTENT_ERROR_NONE;
491 int media_info_clone(media_info_h *dst, media_info_h src)
493 media_info_s *_src = (media_info_s*)src;
495 content_retip_if_fail(dst);
496 content_retip_if_fail(src);
498 media_info_s *_dst = g_new0(media_info_s, 1);
500 _dst->media_id = g_strdup(_src->media_id);
501 _dst->file_path = g_strdup(_src->file_path);
502 _dst->display_name = g_strdup(_src->display_name);
503 _dst->mime_type = g_strdup(_src->mime_type);
504 _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
505 _dst->description = g_strdup(_src->description);
506 _dst->title = g_strdup(_src->title);
507 _dst->storage_uuid = g_strdup(_src->storage_uuid);
508 _dst->media_type = _src->media_type;
509 _dst->size = _src->size;
510 _dst->added_time = _src->added_time;
511 _dst->modified_time = _src->modified_time;
512 _dst->timeline = _src->timeline;
513 _dst->longitude = _src->longitude;
514 _dst->latitude = _src->latitude;
515 _dst->altitude = _src->altitude;
516 _dst->rating = _src->rating;
517 _dst->favourite = _src->favourite;
518 _dst->is_drm = _src->is_drm;
519 _dst->face_request_id = _src->face_request_id;
520 _dst->is_360 = _src->is_360;
521 #ifdef _USE_TVPD_MODE
522 _dst->played_count = _src->played_count;
523 _dst->played_time = _src->played_time;
524 _dst->played_position = _src->played_position;
525 _dst->stitched_info = _src->stitched_info;
526 _dst->extract_flag = _src->extract_flag;
529 if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
530 _dst->image_meta = g_new0(image_meta_s, 1);
532 _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
533 _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
534 _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
535 _dst->image_meta->model = g_strdup(_src->image_meta->model);
536 _dst->image_meta->fnumber = _src->image_meta->fnumber;
537 _dst->image_meta->iso = _src->image_meta->iso;
538 _dst->image_meta->width = _src->image_meta->width;
539 _dst->image_meta->height = _src->image_meta->height;
540 _dst->image_meta->orientation = _src->image_meta->orientation;
542 } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
543 _dst->video_meta = g_new0(video_meta_s, 1);
545 _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
546 _dst->video_meta->album = g_strdup(_src->video_meta->album);
547 _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
548 _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
549 _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
550 _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
551 _dst->video_meta->year = g_strdup(_src->video_meta->year);
552 _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
553 _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
554 _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
555 _dst->video_meta->width = _src->video_meta->width;
556 _dst->video_meta->height = _src->video_meta->height;
557 _dst->video_meta->duration = _src->video_meta->duration;
558 _dst->video_meta->bitrate = _src->video_meta->bitrate;
559 _dst->video_meta->rotation = _src->video_meta->rotation;
561 } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
562 _dst->audio_meta = g_new0(audio_meta_s, 1);
564 _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
565 _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
566 _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
567 _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
568 _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
569 _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
570 _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
571 _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
572 _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
573 _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
574 _dst->audio_meta->channel = _src->audio_meta->channel;
575 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
576 _dst->audio_meta->duration = _src->audio_meta->duration;
577 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
578 _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
579 } else if (_src->media_type == MEDIA_CONTENT_TYPE_BOOK && _src->book_meta) {
580 _dst->book_meta = g_new0(book_meta_s, 1);
582 _dst->book_meta->media_id = g_strdup(_src->book_meta->media_id);
583 _dst->book_meta->author = g_strdup(_src->book_meta->author);
584 _dst->book_meta->date = g_strdup(_src->book_meta->date);
585 _dst->book_meta->publisher = g_strdup(_src->book_meta->publisher);
586 _dst->book_meta->subject = g_strdup(_src->book_meta->subject);
589 *dst = (media_info_h)_dst;
591 return MEDIA_CONTENT_ERROR_NONE;
594 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
596 content_retip_if_fail(media_count);
598 return _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
601 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
603 content_retip_if_fail(callback);
605 return _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
608 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
610 content_warn("DEPRECATION WARNING: media_info_get_tag_count_from_db() is deprecated and will be removed from next release.");
611 content_retip_if_fail(STRING_VALID(media_id));
612 content_retip_if_fail(tag_count);
614 return _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
617 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
619 content_warn("DEPRECATION WARNING: media_info_foreach_tag_from_db() is deprecated and will be removed from next release.");
620 content_retip_if_fail(STRING_VALID(media_id));
621 content_retip_if_fail(callback);
623 return _media_db_get_tag(media_id, filter, callback, user_data);
626 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
628 content_warn("DEPRECATION WARNING: media_info_get_bookmark_count_from_db() is deprecated and will be removed from next release.");
629 content_retip_if_fail(STRING_VALID(media_id));
630 content_retip_if_fail(bookmark_count);
632 return _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
635 int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
637 content_warn("DEPRECATION WARNING: media_info_foreach_bookmark_from_db() is deprecated and will be removed from next release.");
638 content_retip_if_fail(STRING_VALID(media_id));
639 content_retip_if_fail(callback);
641 return _media_db_get_bookmark(media_id, filter, callback, user_data);
644 int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
646 content_warn("DEPRECATION WARNING: media_info_get_face_count_from_db() is deprecated and will be removed from next release.");
647 content_retip_if_fail(STRING_VALID(media_id));
648 content_retip_if_fail(face_count);
650 return _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
653 int media_info_foreach_face_from_db(const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
655 content_warn("DEPRECATION WARNING: media_info_foreach_face_from_db() is deprecated and will be removed from next release.");
656 content_retip_if_fail(STRING_VALID(media_id));
657 content_retip_if_fail(callback);
659 return _media_db_get_face(media_id, filter, callback, user_data);
662 int media_info_get_image(media_info_h media, image_meta_h *image)
664 int ret = MEDIA_CONTENT_ERROR_NONE;
666 media_info_s *_media = (media_info_s*)media;
668 content_retip_if_fail(media);
669 content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE);
670 content_retip_if_fail(_media->image_meta);
671 content_retip_if_fail(image);
673 image_meta_s *_image = g_new0(image_meta_s, 1);
675 _image->media_id = g_strdup(_media->media_id);
676 _image->width = _media->image_meta->width;
677 _image->height = _media->image_meta->height;
678 _image->orientation = _media->image_meta->orientation;
679 _image->fnumber = _media->image_meta->fnumber;
680 _image->iso = _media->image_meta->iso;
681 _image->date_taken = g_strdup(_media->image_meta->date_taken);
682 _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
683 _image->model = g_strdup(_media->image_meta->model);
685 *image = (image_meta_h)_image;
690 int media_info_get_video(media_info_h media, video_meta_h *video)
692 content_warn("DEPRECATION WARNING: media_info_get_video() is deprecated and will be removed from next release.");
693 int ret = MEDIA_CONTENT_ERROR_NONE;
695 media_info_s *_media = (media_info_s*)media;
697 content_retip_if_fail(media);
698 content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO);
699 content_retip_if_fail(_media->video_meta);
700 content_retip_if_fail(video);
702 video_meta_s *_video = g_new0(video_meta_s, 1);
704 _video->media_id = g_strdup(_media->media_id);
705 _video->album = g_strdup(_media->video_meta->album);
706 _video->artist = g_strdup(_media->video_meta->artist);
707 _video->album_artist = g_strdup(_media->video_meta->album_artist);
708 _video->genre = g_strdup(_media->video_meta->genre);
709 _video->composer = g_strdup(_media->video_meta->composer);
710 _video->year = g_strdup(_media->video_meta->year);
711 _video->recorded_date = g_strdup(_media->video_meta->recorded_date);
712 _video->copyright = g_strdup(_media->video_meta->copyright);
713 _video->track_num = g_strdup(_media->video_meta->track_num);
715 _video->width = _media->video_meta->width;
716 _video->height = _media->video_meta->height;
717 _video->duration = _media->video_meta->duration;
718 _video->bitrate = _media->video_meta->bitrate;
719 _video->rotation = _media->video_meta->rotation;
721 *video = (video_meta_h)_video;
726 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
728 int ret = MEDIA_CONTENT_ERROR_NONE;
730 media_info_s *_media = (media_info_s*)media;
732 content_retip_if_fail(media);
733 content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_MUSIC);
734 content_retip_if_fail(_media->audio_meta);
735 content_retip_if_fail(audio);
737 audio_meta_s *_audio = g_new0(audio_meta_s, 1);
739 _audio->media_id = g_strdup(_media->media_id);
740 _audio->album = g_strdup(_media->audio_meta->album);
741 _audio->artist = g_strdup(_media->audio_meta->artist);
742 _audio->album_artist = g_strdup(_media->audio_meta->album_artist);
743 _audio->genre = g_strdup(_media->audio_meta->genre);
744 _audio->composer = g_strdup(_media->audio_meta->composer);
745 _audio->year = g_strdup(_media->audio_meta->year);
746 _audio->recorded_date = g_strdup(_media->audio_meta->recorded_date);
747 _audio->copyright = g_strdup(_media->audio_meta->copyright);
748 _audio->track_num = g_strdup(_media->audio_meta->track_num);
750 _audio->duration = _media->audio_meta->duration;
751 _audio->bitrate = _media->audio_meta->bitrate;
752 _audio->bitpersample = _media->audio_meta->bitpersample;
753 _audio->samplerate = _media->audio_meta->samplerate;
754 _audio->channel = _media->audio_meta->channel;
756 *audio = (audio_meta_h)_audio;
761 int media_info_get_book(media_info_h media, book_meta_h *book)
763 int ret = MEDIA_CONTENT_ERROR_NONE;
765 media_info_s *_media = (media_info_s*)media;
767 content_retip_if_fail(media);
768 content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_BOOK);
769 content_retip_if_fail(book);
771 book_meta_s *_book = g_new0(book_meta_s, 1);
773 _book->media_id = g_strdup(_media->media_id);
774 _book->author = g_strdup(_media->book_meta->author);
775 _book->publisher = g_strdup(_media->book_meta->publisher);
776 _book->date = g_strdup(_media->book_meta->date);
777 _book->subject = g_strdup(_media->book_meta->subject);
779 *book = (book_meta_h)_book;
784 int media_info_get_media_id(media_info_h media, char **media_id)
786 media_info_s *_media = (media_info_s*)media;
788 content_retip_if_fail(media);
789 content_retip_if_fail(media_id);
791 *media_id = g_strdup(_media->media_id);
793 return MEDIA_CONTENT_ERROR_NONE;
796 int media_info_get_file_path(media_info_h media, char **path)
798 media_info_s *_media = (media_info_s*)media;
800 content_retip_if_fail(media);
801 content_retip_if_fail(path);
803 *path = g_strdup(_media->file_path);
805 return MEDIA_CONTENT_ERROR_NONE;
808 int media_info_get_display_name(media_info_h media, char **name)
810 media_info_s *_media = (media_info_s*)media;
812 content_retip_if_fail(media);
813 content_retip_if_fail(name);
815 *name = g_strdup(_media->display_name);
817 return MEDIA_CONTENT_ERROR_NONE;
820 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
822 media_info_s *_media = (media_info_s*)media;
824 content_retip_if_fail(media);
825 content_retip_if_fail(type);
827 *type = _media->media_type;
829 return MEDIA_CONTENT_ERROR_NONE;
832 int media_info_get_mime_type(media_info_h media, char **mime_type)
834 media_info_s *_media = (media_info_s*)media;
836 content_retip_if_fail(media);
837 content_retip_if_fail(mime_type);
839 *mime_type = g_strdup(_media->mime_type);
841 return MEDIA_CONTENT_ERROR_NONE;
844 int media_info_get_size(media_info_h media, unsigned long long *size)
846 media_info_s *_media = (media_info_s*)media;
848 content_retip_if_fail(media);
849 content_retip_if_fail(size);
851 *size = _media->size;
853 return MEDIA_CONTENT_ERROR_NONE;
856 int media_info_get_added_time(media_info_h media, time_t *added_time)
858 media_info_s *_media = (media_info_s*)media;
860 content_retip_if_fail(media);
861 content_retip_if_fail(added_time);
863 *added_time = _media->added_time;
865 return MEDIA_CONTENT_ERROR_NONE;
868 int media_info_get_modified_time(media_info_h media, time_t* time)
870 media_info_s *_media = (media_info_s*)media;
872 content_retip_if_fail(media);
873 content_retip_if_fail(time);
875 *time = _media->modified_time;
877 return MEDIA_CONTENT_ERROR_NONE;
880 int media_info_get_timeline(media_info_h media, time_t* time)
882 content_warn("DEPRECATION WARNING: media_info_get_timeline() is deprecated and will be removed from next release.");
883 media_info_s *_media = (media_info_s*)media;
885 content_retip_if_fail(media);
886 content_retip_if_fail(time);
888 *time = _media->timeline;
890 return MEDIA_CONTENT_ERROR_NONE;
893 int media_info_get_thumbnail_path(media_info_h media, char **path)
895 media_info_s *_media = (media_info_s*)media;
897 content_retip_if_fail(media);
898 content_retip_if_fail(path);
900 *path = g_strdup(_media->thumbnail_path);
902 return MEDIA_CONTENT_ERROR_NONE;
905 int media_info_get_title(media_info_h media, char **title)
907 media_info_s *_media = (media_info_s*)media;
909 content_retip_if_fail(media);
910 content_retip_if_fail(title);
912 *title = g_strdup(_media->title);
914 return MEDIA_CONTENT_ERROR_NONE;
917 int media_info_get_description(media_info_h media, char **description)
919 content_warn("DEPRECATION WARNING: media_info_get_description() is deprecated and will be removed from next release.");
920 media_info_s *_media = (media_info_s*)media;
922 content_retip_if_fail(media);
923 content_retip_if_fail(description);
925 *description = g_strdup(_media->description);
927 return MEDIA_CONTENT_ERROR_NONE;
930 int media_info_get_longitude(media_info_h media, double* longitude)
932 content_warn("DEPRECATION WARNING: media_info_get_longitude() is deprecated and will be removed from next release.");
933 media_info_s *_media = (media_info_s*)media;
935 content_retip_if_fail(media);
936 content_retip_if_fail(longitude);
938 *longitude = _media->longitude;
940 return MEDIA_CONTENT_ERROR_NONE;
942 int media_info_get_latitude(media_info_h media, double* latitude)
944 content_warn("DEPRECATION WARNING: media_info_get_latitude() is deprecated and will be removed from next release.");
945 media_info_s *_media = (media_info_s*)media;
947 content_retip_if_fail(media);
948 content_retip_if_fail(latitude);
950 *latitude = _media->latitude;
952 return MEDIA_CONTENT_ERROR_NONE;
955 int media_info_get_altitude(media_info_h media, double *altitude)
957 content_warn("DEPRECATION WARNING: media_info_get_altitude() is deprecated and will be removed from next release.");
958 media_info_s *_media = (media_info_s*)media;
960 content_retip_if_fail(media);
961 content_retip_if_fail(altitude);
963 *altitude = _media->altitude;
965 return MEDIA_CONTENT_ERROR_NONE;
968 int media_info_get_rating(media_info_h media, int *rating)
970 content_warn("DEPRECATION WARNING: media_info_get_rating() is deprecated and will be removed from next release.");
971 media_info_s *_media = (media_info_s*)media;
973 content_retip_if_fail(media);
974 content_retip_if_fail(rating);
976 *rating = _media->rating;
978 return MEDIA_CONTENT_ERROR_NONE;
981 int media_info_get_favorite(media_info_h media, bool* favorite)
983 content_warn("DEPRECATION WARNING: media_info_get_favorite() is deprecated and will be removed from next release.");
984 media_info_s *_media = (media_info_s*)media;
986 content_retip_if_fail(media);
987 content_retip_if_fail(favorite);
989 *favorite = _media->favourite;
991 return MEDIA_CONTENT_ERROR_NONE;
994 int media_info_is_drm(media_info_h media, bool *is_drm)
996 content_warn("DEPRECATION WARNING: media_info_is_drm() is deprecated and will be removed from next release.");
997 media_info_s *_media = (media_info_s*)media;
999 content_retip_if_fail(media);
1000 content_retip_if_fail(is_drm);
1002 *is_drm = _media->is_drm;
1004 return MEDIA_CONTENT_ERROR_NONE;
1007 int media_info_is_360_content(media_info_h media, bool *is_360)
1009 content_warn("DEPRECATION WARNING: media_info_is_360_content() is deprecated and will be removed from next release.");
1010 media_info_s *_media = (media_info_s*)media;
1012 content_retip_if_fail(media);
1013 content_retip_if_fail(is_360);
1015 *is_360 = _media->is_360;
1017 return MEDIA_CONTENT_ERROR_NONE;
1020 #ifdef _USE_TVPD_MODE
1021 int media_info_get_played_count(media_info_h media, int *played_count)
1023 media_info_s *_media = (media_info_s*)media;
1025 content_retip_if_fail(media);
1026 content_retip_if_fail(played_count);
1028 *played_count = _media->played_count;
1030 return MEDIA_CONTENT_ERROR_NONE;
1033 int media_info_set_played_count(media_info_h media, int played_count)
1035 media_info_s *_media = (media_info_s*)media;
1037 content_retip_if_fail(media);
1039 _media->played_count = played_count;
1041 return MEDIA_CONTENT_ERROR_NONE;
1044 int media_info_set_played_position(media_info_h media, int played_position)
1046 media_info_s *_media = (media_info_s*)media;
1048 content_retip_if_fail(media);
1049 content_retip_if_fail(played_position >= 0);
1051 _media->played_position = played_position;
1053 return MEDIA_CONTENT_ERROR_NONE;
1056 int media_info_get_played_position(media_info_h media, int *played_position)
1058 media_info_s *_media = (media_info_s*)media;
1060 content_retip_if_fail(media);
1061 content_retip_if_fail(played_position);
1063 *played_position = _media->played_position;
1065 return MEDIA_CONTENT_ERROR_NONE;
1068 int media_info_set_played_time(media_info_h media)
1070 time_t current_time;
1072 media_info_s *_media = (media_info_s*)media;
1074 content_retip_if_fail(media);
1076 time(¤t_time);
1077 _media->played_time = current_time;
1079 return MEDIA_CONTENT_ERROR_NONE;
1082 int media_info_get_played_time(media_info_h media, time_t* played_time)
1084 media_info_s *_media = (media_info_s*)media;
1086 content_retip_if_fail(media);
1087 content_retip_if_fail(played_time);
1089 *played_time = _media->played_time;
1091 return MEDIA_CONTENT_ERROR_NONE;
1094 int media_info_get_extract_flag(media_info_h media, int *extract_flag)
1096 media_info_s *_media = (media_info_s *)media;
1098 content_retip_if_fail(media);
1099 content_retip_if_fail(extract_flag);
1101 *extract_flag = _media->extract_flag;
1103 return MEDIA_CONTENT_ERROR_NONE;
1106 int media_info_get_stitched_state(media_info_h media, int *stitched_info)
1108 media_info_s *_media = (media_info_s*)media;
1110 content_retip_if_fail(media);
1111 content_retip_if_fail(stitched_info);
1113 *stitched_info = (_media->stitched_info & 0xFFFF0000) >> 16;
1115 return MEDIA_CONTENT_ERROR_NONE;
1119 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
1121 int ret = MEDIA_CONTENT_ERROR_NONE;
1122 char select_query[DEFAULT_QUERY_SIZE] = {0, };
1123 sqlite3_stmt *stmt = NULL;
1125 content_retip_if_fail(STRING_VALID(media_id));
1126 content_retip_if_fail(media);
1128 snprintf(select_query, DEFAULT_QUERY_SIZE, SELECT_MEDIA_FROM_MEDIA, media_id);
1130 ret = _content_get_result(select_query, &stmt);
1131 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1133 media_info_s *_media = NULL;
1135 if (sqlite3_step(stmt) == SQLITE_ROW) {
1136 _media = g_new0(media_info_s, 1);
1138 _media_info_item_get_detail(stmt, (media_info_h)_media);
1140 *media = (media_info_h)_media;
1142 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1145 sqlite3_finalize(stmt);
1150 int media_info_get_media_from_db_by_path(const char *path, media_info_h *media)
1152 int ret = MEDIA_CONTENT_ERROR_NONE;
1153 media_info_s *_media = NULL;
1155 content_retip_if_fail(STRING_VALID(path));
1156 content_retip_if_fail(media);
1157 ret = _media_util_check_file_exist(path);
1158 content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "_media_util_check_file_exist failed : %d", ret);
1160 _media = g_new0(media_info_s, 1);
1161 ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
1162 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1167 *media = (media_info_h)_media;
1172 int media_info_set_favorite(media_info_h media, bool favorite)
1174 content_warn("DEPRECATION WARNING: media_info_set_favorite() is deprecated and will be removed from next release.");
1175 media_info_s *_media = (media_info_s*)media;
1177 content_retip_if_fail(media);
1179 if (favorite == TRUE)
1180 time(&_media->favourite);
1182 _media->favourite = 0;
1184 return MEDIA_CONTENT_ERROR_NONE;
1187 int media_info_update_to_db(media_info_h media)
1189 content_warn("DEPRECATION WARNING: media_info_update_to_db() is deprecated and will be removed from next release.");
1190 int ret = MEDIA_CONTENT_ERROR_NONE;
1191 media_info_s *_media = (media_info_s*)media;
1194 content_retip_if_fail(media);
1195 content_retip_if_fail(STRING_VALID(_media->media_id));
1197 #ifdef _USE_TVPD_MODE
1198 sql = sqlite3_mprintf("UPDATE %q SET played_count=%d, last_played_time=%d, last_played_position=%d, media_favourite=%d WHERE media_id=%Q", DB_TABLE_MEDIA, _media->played_count, _media->played_time, _media->played_position, _media->favourite, _media->media_id);
1200 sql = sqlite3_mprintf("UPDATE %q SET media_favourite=%d WHERE media_id=%Q", DB_TABLE_MEDIA, _media->favourite, _media->media_id);
1202 ret = _content_query_sql(sql);
1205 if (ret == MEDIA_CONTENT_ERROR_NONE) {
1206 /* Send notification for this update */
1207 content_debug("Update is successful. Send notification for this");
1208 if (_media->file_path && _media->mime_type)
1209 media_svc_publish_update_noti(_media->file_path, _media->media_type, _media->media_id, _media->mime_type);
1211 content_error("Can't Send Noti : path or mime type is NULL");
1217 int media_info_move_to_db(media_info_h media, const char* dst_path)
1219 int ret = MEDIA_CONTENT_ERROR_NONE;
1220 char repl_path[MAX_PATH_LEN] = {0, };
1221 media_info_s *_info = NULL;
1223 content_retip_if_fail(media);
1224 content_retip_if_fail(STRING_VALID(dst_path));
1226 media_info_s *_media = (media_info_s*)media;
1228 /* If dst_path is folder, append file_name */
1229 g_strlcpy(repl_path, dst_path, MAX_PATH_LEN);
1231 if (g_file_test(repl_path, G_FILE_TEST_IS_DIR)) {
1232 if (repl_path[strlen(repl_path) - 1] != '/')
1233 g_strlcat(repl_path, "/", MAX_PATH_LEN);
1235 g_strlcat(repl_path, _media->display_name, MAX_PATH_LEN);
1238 /* If the two paths are the same, do nothing */
1239 content_retvm_if(g_strcmp0(repl_path, _media->file_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path");
1241 ret = __media_info_check_file_validity(repl_path);
1242 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1244 ret = media_svc_move_item(_content_get_db_handle(), _media->file_path, repl_path, _media->media_id, _media->media_type, _media->mime_type, _content_get_uid());
1245 ret = _content_error_capi(ret);
1246 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1248 /* Update media_info handle */
1249 _info = g_new0(media_info_s, 1);
1250 ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_info);
1251 g_free(_media->display_name);
1252 _media->display_name = g_strdup(_info->display_name);
1253 g_free(_media->file_path);
1254 _media->file_path = g_strdup(_info->file_path);
1255 g_free(_media->storage_uuid);
1256 _media->storage_uuid = g_strdup(_info->storage_uuid);
1257 g_free(_media->thumbnail_path);
1258 _media->thumbnail_path = NULL;
1260 media_info_destroy((media_info_h)_info);
1265 int media_info_generate_thumbnail(media_info_h media)
1267 int ret = MEDIA_CONTENT_ERROR_NONE;
1268 char *thumb_path = NULL;
1269 media_info_s *_media = (media_info_s*)media;
1271 content_retip_if_fail(media);
1272 content_retip_if_fail(STRING_VALID(_media->media_id));
1273 content_retip_if_fail(STRING_VALID(_media->file_path));
1275 /* Already exists */
1276 if (STRING_VALID(_media->thumbnail_path))
1277 return MEDIA_CONTENT_ERROR_NONE;
1279 ret = media_svc_create_thumbnail(_media->file_path, _media->media_type, _content_get_uid(), &thumb_path);
1280 ret = _content_error_capi(ret);
1281 if (ret == MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT) {
1286 /* thumb_path is not NULL except #MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT */
1287 _media->thumbnail_path = g_strdup(thumb_path);
1293 int media_info_start_face_detection(media_info_h media, media_face_detection_completed_cb callback, void *user_data)
1295 content_warn("DEPRECATION WARNING: media_info_start_face_detection() is deprecated and will be removed from next release.");
1296 media_info_s *_media = (media_info_s*)media;
1298 if (!__media_info_isFaceRecognition_feature_supported()) {
1299 content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
1300 return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
1303 content_retip_if_fail(media);
1304 content_retip_if_fail(STRING_VALID(_media->media_id));
1305 content_retip_if_fail(STRING_VALID(_media->file_path));
1306 content_retip_if_fail(callback);
1308 if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
1309 content_error("Unsupported mime type");
1310 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1313 return MEDIA_CONTENT_ERROR_NONE;
1316 int media_info_cancel_face_detection(media_info_h media)
1318 content_warn("DEPRECATION WARNING: media_info_cancel_face_detection() is deprecated and will be removed from next release.");
1319 media_info_s *_media = (media_info_s*)media;
1321 if (!__media_info_isFaceRecognition_feature_supported()) {
1322 content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
1323 return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
1326 content_retip_if_fail(media);
1327 content_retip_if_fail(STRING_VALID(_media->media_id));
1328 content_retip_if_fail(_media->face_request_id > 0);
1330 return MEDIA_CONTENT_ERROR_NONE;