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.
18 #include <media_content.h>
19 #include <media-thumbnail.h>
20 #include <media_info_private.h>
21 #include <media_util_private.h>
22 #include <media-svc.h>
23 #include <media-util.h>
25 static int __media_info_get_media_info_from_db(char *path, media_info_h media);
26 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
27 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
28 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data);
29 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data);
31 static int __media_info_get_media_info_from_db(char *path, media_info_h media)
33 int ret = MEDIA_CONTENT_ERROR_NONE;
34 sqlite3_stmt *stmt = NULL;
35 char *select_query = NULL;
36 media_info_s *_media = (media_info_s*)media;
40 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
41 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
44 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
46 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
47 sqlite3_free(select_query);
48 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
50 if(sqlite3_step(stmt) == SQLITE_ROW)
52 _media_info_item_get_detail(stmt, (media_info_h)_media);
53 media_content_debug("New Media ID: %s", _media->media_id);
55 media_content_debug("There's no media!!");
58 while(sqlite3_step(stmt) == SQLITE_ROW)
60 _media_info_item_get_detail(stmt, (media_info_h)_media);
61 media_content_debug("New Media ID: %s", _media->media_id);
64 SQLITE3_FINALIZE(stmt);
69 static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
71 int ret = MEDIA_CONTENT_ERROR_NONE;
72 sqlite3_stmt *stmt = NULL;
73 char *select_query = NULL;
75 if(!STRING_VALID(media_id))
77 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
78 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
81 select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
83 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
84 sqlite3_free(select_query);
85 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
87 if(sqlite3_step(stmt) == SQLITE_ROW)
89 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
90 *path = strdup((const char *)sqlite3_column_text(stmt, 0));
92 media_content_debug("There's no media with this ID : %s", media_id);
94 ret = MEDIA_CONTENT_ERROR_DB_FAILED;
97 SQLITE3_FINALIZE(stmt);
102 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
104 int ret = MEDIA_CONTENT_ERROR_NONE;
105 media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
107 if (_cb_data && _cb_data->insert_completed_cb) {
109 ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
112 _cb_data->insert_completed_cb(ret, _cb_data->user_data);
114 if (STRING_VALID(_cb_data->insert_list_path)) {
115 if (unlink(_cb_data->insert_list_path) < 0) {
116 media_content_error("failed to delete : %s", strerror(errno));
118 SAFE_FREE(_cb_data->insert_list_path);
127 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
129 int error_value = MEDIA_CONTENT_ERROR_NONE;
131 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
132 media_info_s *media = NULL;
134 if(_thumb_cb != NULL)
136 media = _thumb_cb->handle;
137 if((media != NULL) && STRING_VALID(path))
139 SAFE_FREE(media->thumbnail_path);
140 media->thumbnail_path = strdup(path);
143 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
144 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
145 if (_thumb_cb->thumbnail_completed_cb)
146 _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
149 SAFE_FREE(_thumb_cb);
154 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
156 char *thumb_path = NULL;
157 media_content_type_e media_type = 0;
161 media_content_debug("NO Item \n");
165 media_info_get_media_type(media, &media_type);
166 media_content_debug("media_type : [%d] \n", media_type);
168 media_info_get_thumbnail_path(media, &thumb_path);
169 if (STRING_VALID(thumb_path)) {
170 if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0) {
171 media_content_debug("Deleting thumbnail : [%s] \n", thumb_path);
172 if (unlink(thumb_path) < 0) {
173 media_content_error("failed to delete : %s", strerror(errno));
177 SAFE_FREE(thumb_path);
183 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
185 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
186 // rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel"
188 media_info_s *_media = (media_info_s*)media;
190 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
191 _media->media_id = strdup((const char *)sqlite3_column_text(stmt, 0));
193 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
194 _media->file_path = strdup((const char *)sqlite3_column_text(stmt, 1));
196 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
197 _media->display_name = strdup((const char *)sqlite3_column_text(stmt, 2));
199 _media->media_type = (int)sqlite3_column_int(stmt, 3);
201 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4)))
202 _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, 4));
204 _media->size = (unsigned long long)sqlite3_column_int64(stmt, 5);
206 _media->added_time = (int)sqlite3_column_int(stmt, 6);
208 _media->modified_time = (int)sqlite3_column_int(stmt, 7);
210 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8)))
211 _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, 8));
213 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9)))
214 _media->description = strdup((const char *)sqlite3_column_text(stmt, 9));
216 _media->rating = (int)sqlite3_column_int(stmt,10);
218 _media->favourite = (int)sqlite3_column_int(stmt, 11);
220 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 12)))
221 _media->author = strdup((const char *)sqlite3_column_text(stmt, 12));
223 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 13)))
224 _media->provider = strdup((const char *)sqlite3_column_text(stmt, 13));
226 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 14)))
227 _media->content_name = strdup((const char *)sqlite3_column_text(stmt, 14));
229 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 15)))
230 _media->category = strdup((const char *)sqlite3_column_text(stmt, 15));
232 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 16)))
233 _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, 16));
235 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 17)))
236 _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, 17));
238 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 18)))
239 _media->keyword = strdup((const char *)sqlite3_column_text(stmt, 18));
241 _media->is_drm = (int)sqlite3_column_int(stmt, 19);
243 _media->storage_type = (int)sqlite3_column_int(stmt, 20);
245 _media->longitude = (double)sqlite3_column_double(stmt, 21);
246 _media->latitude = (double)sqlite3_column_double(stmt, 22);
247 _media->altitude = (double)sqlite3_column_double(stmt, 23);
249 if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
250 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
251 if(_media->image_meta) {
252 if(STRING_VALID(_media->media_id))
253 _media->image_meta->media_id = strdup(_media->media_id);
255 _media->image_meta->width = sqlite3_column_int(stmt, 24);
256 _media->image_meta->height = sqlite3_column_int(stmt, 25);
258 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 26)))
259 _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, 26));
261 _media->image_meta->orientation = sqlite3_column_int(stmt, 27);
263 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 44)))
264 _media->image_meta->burst_id = strdup((const char *)sqlite3_column_text(stmt, 44));
267 } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
268 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
269 if(_media->video_meta) {
270 if(STRING_VALID(_media->media_id))
271 _media->video_meta->media_id = strdup(_media->media_id);
273 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
274 _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
276 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
277 _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
279 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
280 _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
282 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
283 _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
285 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
286 _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
288 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
289 _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
291 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
292 _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
294 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
295 _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
297 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
298 _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
300 _media->video_meta->bitrate = sqlite3_column_int(stmt, 37);
301 _media->video_meta->duration = sqlite3_column_int(stmt, 38);
302 _media->video_meta->played_count = sqlite3_column_int(stmt, 39);
303 _media->video_meta->played_time = sqlite3_column_int(stmt, 40);
304 _media->video_meta->played_position = sqlite3_column_int(stmt, 41);
305 _media->video_meta->width = sqlite3_column_int(stmt, 24);
306 _media->video_meta->height = sqlite3_column_int(stmt, 25);
310 else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
311 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
312 if(_media->audio_meta) {
313 if(STRING_VALID(_media->media_id))
314 _media->audio_meta->media_id = strdup(_media->media_id);
316 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
317 _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
319 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
320 _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
322 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
323 _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
325 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
326 _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
328 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
329 _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
331 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
332 _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
334 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
335 _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
337 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
338 _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
340 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
341 _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
343 _media->audio_meta->bitrate = sqlite3_column_int(stmt, 37);
344 _media->audio_meta->duration = sqlite3_column_int(stmt, 38);
345 _media->audio_meta->played_count = sqlite3_column_int(stmt, 39);
346 _media->audio_meta->played_time = sqlite3_column_int(stmt, 40);
347 _media->audio_meta->played_position = sqlite3_column_int(stmt, 41);
348 _media->audio_meta->samplerate = sqlite3_column_int(stmt, 42);
349 _media->audio_meta->channel = sqlite3_column_int(stmt, 43);
355 int media_info_insert_to_db (const char *path, media_info_h *info)
357 int ret = MEDIA_CONTENT_ERROR_NONE;
359 if(!STRING_VALID(path))
361 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
362 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
367 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
368 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
372 media_content_debug("Register: %s", path);
373 ret = media_file_register(path);
374 if(ret != MS_MEDIA_ERR_NONE)
376 media_content_error("media_file_register failed");
377 return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
381 ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), path);
382 if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
383 media_content_debug("media_svc_check_item_exist_by_path : no record : %s", path);
385 media_svc_media_type_e media_type;
386 media_svc_storage_type_e storage_type;
387 char mime_type[255] = {0, };
389 ret = media_svc_get_storage_type(path, &storage_type);
391 media_content_error("media_svc_get_storage_type failed : %d (%s)", ret, path);
392 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
395 ret = media_svc_get_mime_type(path, mime_type);
397 media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
398 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
401 ret = media_svc_get_media_type(path, mime_type, &media_type);
403 media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
404 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
407 media_content_debug("media_svc_insert_item_immediately: %s", path);
408 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_type, path, mime_type, media_type);
411 media_content_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
412 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
414 } else if (ret != MEDIA_INFO_ERROR_NONE) {
415 media_content_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, path);
416 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
420 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
423 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
424 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
427 _media->file_path = strdup(path);
428 if(_media->file_path == NULL)
430 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
432 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
435 ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
437 *info = (media_info_h)_media;
441 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
442 unsigned int array_length,
443 media_insert_completed_cb completed_cb,
446 int ret = MEDIA_CONTENT_ERROR_NONE;
448 char list_path[255] = {0,};
452 for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
453 snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
455 if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
456 memset(list_path, 0x00, sizeof(list_path));
459 media_content_debug("The request file list path : %s", list_path);
464 if (idx == BATCH_REQUEST_MAX) {
465 media_content_error("Too many batch request for one thread");
466 return MEDIA_CONTENT_ERROR_DB_BUSY;
469 fp = fopen(list_path, "w");
471 media_content_error("failed to open file : %s [%s]", list_path, strerror(errno));
472 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
475 for (idx = 0; idx < array_length; idx++) {
476 if (STRING_VALID(path_array[idx])) {
477 int size = strlen(path_array[idx]);
479 nwrites = fwrite(path_array[idx], 1, size, fp);
480 if (nwrites != size) {
481 media_content_error("failed to write thumbnail : %s", strerror(errno));
483 if (unlink(list_path) < 0) {
484 media_content_error("failed to delete : %s", strerror(errno));
486 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
489 nwrites = fwrite("\n", 1, 1, fp);
491 media_content_error("failed to write thumbnail : %s", strerror(errno));
493 if (unlink(list_path) < 0) {
494 media_content_error("failed to delete : %s", strerror(errno));
496 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
499 media_content_error("path[%d] is invalid string", idx);
505 media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
506 _cb_data->insert_completed_cb = completed_cb;
507 _cb_data->user_data = user_data;
508 _cb_data->insert_list_path = strdup(list_path);
510 if(insert_type == MEDIA_BATCH_INSERT_NORMAL)
511 ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data);
512 else if(insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
513 ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data);
515 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
517 if (ret != MEDIA_CONTENT_ERROR_NONE) {
518 media_content_error("media_files_register failed : %d", ret);
519 if (unlink(list_path) < 0) {
520 media_content_error("failed to delete : %s", strerror(errno));
522 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
528 int media_info_insert_batch_to_db(
529 const char **path_array,
530 unsigned int array_length,
531 media_insert_completed_cb completed_cb,
534 if (path_array == NULL)
536 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
537 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
540 if (array_length <= 0)
542 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
543 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
546 return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
549 int media_info_insert_burst_shot_to_db(const char **path_array, unsigned int array_length, media_insert_burst_shot_completed_cb callback, void *user_data)
551 if (path_array == NULL)
553 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
554 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
557 if (array_length <= 0)
559 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
560 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
563 return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
566 int media_info_delete_from_db(const char *media_id)
568 int ret = MEDIA_CONTENT_ERROR_NONE;
570 if(!STRING_VALID(media_id))
572 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
573 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
577 char *query_string = NULL;
578 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id);
580 ret = _content_query_sql(query_string);
582 sqlite3_free(query_string);
588 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
589 if (ret < MEDIA_CONTENT_ERROR_NONE) {
590 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
595 ret = media_svc_delete_item_by_path(_content_get_db_handle(), path);
598 return _content_error_capi(ret,MEDIA_CONTENT_TYPE);
602 int media_info_delete_batch_from_db(filter_h filter)
604 int ret = MEDIA_CONTENT_ERROR_NONE;
606 char *query_string = NULL;
607 filter_s *_filter = NULL;
609 char *condition_query = NULL;
613 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
614 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
617 /* Delete thumbnail of each item */
618 ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, NULL, MEDIA_GROUP_NONE);
620 _filter = (filter_s*)filter;
621 attr = _content_get_attirbute_handle();
623 if(_filter->condition)
625 ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
626 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
629 if(STRING_VALID(condition_query))
631 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, condition_query);
635 SAFE_FREE(condition_query);
636 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
639 ret = _content_query_sql(query_string);
640 if (ret == MEDIA_CONTENT_ERROR_NONE) {
641 /* Send notification for this
642 In this case, send noti for internal storage and external storage
644 media_content_debug("Batch deletion is successfull. Send notification for this");
645 media_db_update_send(getpid(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_CONTENT_PATH_PHONE, NULL, -1, NULL);
646 media_db_update_send(getpid(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_CONTENT_PATH_MMC, NULL, -1, NULL);
649 SAFE_FREE(condition_query);
650 sqlite3_free(query_string);
655 int media_info_destroy(media_info_h media)
657 int ret = MEDIA_CONTENT_ERROR_NONE;
658 media_info_s *_media = (media_info_s*)media;
662 SAFE_FREE(_media->media_id);
663 SAFE_FREE(_media->file_path);
664 SAFE_FREE(_media->display_name);
665 SAFE_FREE(_media->mime_type);
666 SAFE_FREE(_media->thumbnail_path);
667 SAFE_FREE(_media->description);
668 SAFE_FREE(_media->author);
669 SAFE_FREE(_media->provider);
670 SAFE_FREE(_media->content_name);
671 SAFE_FREE(_media->category);
672 SAFE_FREE(_media->location_tag);
673 SAFE_FREE(_media->age_rating);
674 SAFE_FREE(_media->keyword);
676 if(_media->image_meta) {
677 SAFE_FREE(_media->image_meta->media_id);
678 SAFE_FREE(_media->image_meta->date_taken);
679 SAFE_FREE(_media->image_meta->burst_id);
681 SAFE_FREE(_media->image_meta);
682 } else if(_media->video_meta) {
683 SAFE_FREE(_media->video_meta->media_id);
684 SAFE_FREE(_media->video_meta->title);
685 SAFE_FREE(_media->video_meta->album);
686 SAFE_FREE(_media->video_meta->artist);
687 SAFE_FREE(_media->video_meta->genre);
688 SAFE_FREE(_media->video_meta->composer);
689 SAFE_FREE(_media->video_meta->year);
690 SAFE_FREE(_media->video_meta->recorded_date);
691 SAFE_FREE(_media->video_meta->copyright);
692 SAFE_FREE(_media->video_meta->track_num);
694 SAFE_FREE(_media->video_meta);
695 } else if(_media->audio_meta) {
696 SAFE_FREE(_media->audio_meta->media_id);
697 SAFE_FREE(_media->audio_meta->title);
698 SAFE_FREE(_media->audio_meta->album);
699 SAFE_FREE(_media->audio_meta->artist);
700 SAFE_FREE(_media->audio_meta->genre);
701 SAFE_FREE(_media->audio_meta->composer);
702 SAFE_FREE(_media->audio_meta->year);
703 SAFE_FREE(_media->audio_meta->recorded_date);
704 SAFE_FREE(_media->audio_meta->copyright);
705 SAFE_FREE(_media->audio_meta->track_num);
707 SAFE_FREE(_media->audio_meta);
712 ret = MEDIA_CONTENT_ERROR_NONE;
716 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
717 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
723 int media_info_clone(media_info_h *dst, media_info_h src)
725 int ret = MEDIA_CONTENT_ERROR_NONE;
726 media_info_s *_src = (media_info_s*)src;
731 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
735 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
736 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
739 if(STRING_VALID(_src->media_id))
741 _dst->media_id = strdup(_src->media_id);
742 if(_dst->media_id == NULL)
744 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
745 media_info_destroy((media_info_h)_dst);
746 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
749 if(STRING_VALID(_src->file_path))
751 _dst->file_path = strdup(_src->file_path);
752 if(_dst->file_path == NULL)
754 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
755 media_info_destroy((media_info_h)_dst);
756 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
759 if(STRING_VALID(_src->display_name))
761 _dst->display_name = strdup(_src->display_name);
762 if(_dst->display_name == NULL)
764 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
765 media_info_destroy((media_info_h)_dst);
766 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
769 if(STRING_VALID(_src->mime_type))
771 _dst->mime_type = strdup(_src->mime_type);
772 if(_dst->mime_type == NULL)
774 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
775 media_info_destroy((media_info_h)_dst);
776 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
779 if(STRING_VALID(_src->thumbnail_path))
781 _dst->thumbnail_path = strdup(_src->thumbnail_path);
782 if(_dst->thumbnail_path == NULL)
784 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
785 media_info_destroy((media_info_h)_dst);
786 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
789 if(STRING_VALID(_src->description))
791 _dst->description = strdup(_src->description);
792 if(_dst->description == NULL)
794 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
795 media_info_destroy((media_info_h)_dst);
796 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
799 if(STRING_VALID(_src->author))
801 _dst->author = strdup(_src->author);
802 if(_dst->author == NULL)
804 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
805 media_info_destroy((media_info_h)_dst);
806 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
809 if(STRING_VALID(_src->provider))
811 _dst->provider = strdup(_src->provider);
812 if(_dst->provider == NULL)
814 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
815 media_info_destroy((media_info_h)_dst);
816 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
819 if(STRING_VALID(_src->content_name))
821 _dst->content_name = strdup(_src->content_name);
822 if(_dst->content_name == NULL)
824 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
825 media_info_destroy((media_info_h)_dst);
826 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
829 if(STRING_VALID(_src->category))
831 _dst->category = strdup(_src->category);
832 if(_dst->category == NULL)
834 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
835 media_info_destroy((media_info_h)_dst);
836 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
839 if(STRING_VALID(_src->location_tag))
841 _dst->location_tag = strdup(_src->location_tag);
842 if(_dst->location_tag == NULL)
844 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
845 media_info_destroy((media_info_h)_dst);
846 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
849 if(STRING_VALID(_src->age_rating))
851 _dst->age_rating = strdup(_src->age_rating);
852 if(_dst->age_rating == NULL)
854 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
855 media_info_destroy((media_info_h)_dst);
856 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
859 if(STRING_VALID(_src->keyword))
861 _dst->keyword = strdup(_src->keyword);
862 if(_dst->keyword == NULL)
864 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
865 media_info_destroy((media_info_h)_dst);
866 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
870 _dst->media_type = _src->media_type;
871 _dst->size = _src->size;
872 _dst->added_time = _src->added_time;
873 _dst->modified_time = _src->modified_time;
874 _dst->longitude = _src->longitude;
875 _dst->latitude = _src->latitude;
876 _dst->altitude = _src->altitude;
877 _dst->rating = _src->rating;
878 _dst->favourite = _src->favourite;
879 _dst->is_drm = _src->is_drm;
880 _dst->storage_type = _src->storage_type;
882 if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
883 _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
884 if(_dst->image_meta == NULL)
886 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
887 media_info_destroy((media_info_h)_dst);
888 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
891 if(STRING_VALID(_src->image_meta->media_id))
893 _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
894 if(_dst->image_meta->media_id == NULL)
896 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
897 media_info_destroy((media_info_h)_dst);
898 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
902 if(STRING_VALID(_src->image_meta->date_taken))
904 _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
905 if(_dst->image_meta->date_taken == NULL)
907 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
908 media_info_destroy((media_info_h)_dst);
909 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
913 if(STRING_VALID(_src->image_meta->burst_id))
915 _dst->image_meta->burst_id = strdup(_src->image_meta->burst_id);
916 if(_dst->image_meta->burst_id == NULL)
918 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
919 media_info_destroy((media_info_h)_dst);
920 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
923 _dst->image_meta->width = _src->image_meta->width;
924 _dst->image_meta->height = _src->image_meta->height;
925 _dst->image_meta->orientation = _src->image_meta->orientation;
927 } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
928 _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
929 if(_dst->video_meta == NULL)
931 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
932 media_info_destroy((media_info_h)_dst);
933 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
936 if(STRING_VALID(_src->video_meta->media_id))
938 _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
939 if(_dst->video_meta->media_id == NULL)
941 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
942 media_info_destroy((media_info_h)_dst);
943 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
946 if(STRING_VALID(_src->video_meta->title))
948 _dst->video_meta->title = strdup(_src->video_meta->title);
949 if(_dst->video_meta->title == NULL)
951 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
952 media_info_destroy((media_info_h)_dst);
953 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
956 if(STRING_VALID(_src->video_meta->album))
958 _dst->video_meta->album = strdup(_src->video_meta->album);
959 if(_dst->video_meta->album == NULL)
961 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
962 media_info_destroy((media_info_h)_dst);
963 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
966 if(STRING_VALID(_src->video_meta->artist))
968 _dst->video_meta->artist = strdup(_src->video_meta->artist);
969 if(_dst->video_meta->artist == NULL)
971 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
972 media_info_destroy((media_info_h)_dst);
973 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
976 if(STRING_VALID(_src->video_meta->genre))
978 _dst->video_meta->genre = strdup(_src->video_meta->genre);
979 if(_dst->video_meta->genre == NULL)
981 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
982 media_info_destroy((media_info_h)_dst);
983 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
986 if(STRING_VALID(_src->video_meta->composer))
988 _dst->video_meta->composer = strdup(_src->video_meta->composer);
989 if(_dst->video_meta->composer == NULL)
991 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
992 media_info_destroy((media_info_h)_dst);
993 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
996 if(STRING_VALID(_src->video_meta->year))
998 _dst->video_meta->year = strdup(_src->video_meta->year);
999 if(_dst->video_meta->year == NULL)
1001 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1002 media_info_destroy((media_info_h)_dst);
1003 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1006 if(STRING_VALID(_src->video_meta->recorded_date))
1008 _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
1009 if(_dst->video_meta->recorded_date == NULL)
1011 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1012 media_info_destroy((media_info_h)_dst);
1013 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1016 if(STRING_VALID(_src->video_meta->copyright))
1018 _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
1019 if(_dst->video_meta->copyright == NULL)
1021 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1022 media_info_destroy((media_info_h)_dst);
1023 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1026 if(STRING_VALID(_src->video_meta->track_num))
1028 _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
1029 if(_dst->video_meta->track_num == NULL)
1031 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1032 media_info_destroy((media_info_h)_dst);
1033 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1037 _dst->video_meta->width = _src->video_meta->width;
1038 _dst->video_meta->height = _src->video_meta->height;
1039 _dst->video_meta->duration = _src->video_meta->duration;
1040 _dst->video_meta->bitrate = _src->video_meta->bitrate;
1041 _dst->video_meta->played_count = _src->video_meta->played_count;
1042 _dst->video_meta->played_time = _src->video_meta->played_time;
1043 _dst->video_meta->played_position = _src->video_meta->played_position;
1045 } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
1046 _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
1047 if(_dst->audio_meta == NULL)
1049 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1050 media_info_destroy((media_info_h)_dst);
1051 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1054 if(STRING_VALID(_src->audio_meta->media_id))
1056 _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
1057 if(_dst->audio_meta->media_id == NULL)
1059 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1060 media_info_destroy((media_info_h)_dst);
1061 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1064 if(STRING_VALID(_src->audio_meta->title))
1066 _dst->audio_meta->title = strdup(_src->audio_meta->title);
1067 if(_dst->audio_meta->title == NULL)
1069 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1070 media_info_destroy((media_info_h)_dst);
1071 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1074 if(STRING_VALID(_src->audio_meta->album))
1076 _dst->audio_meta->album = strdup(_src->audio_meta->album);
1077 if(_dst->audio_meta->album == NULL)
1079 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1080 media_info_destroy((media_info_h)_dst);
1081 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1084 if(STRING_VALID(_src->audio_meta->artist))
1086 _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
1087 if(_dst->audio_meta->artist == NULL)
1089 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1090 media_info_destroy((media_info_h)_dst);
1091 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1094 if(STRING_VALID(_src->audio_meta->genre))
1096 _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
1097 if(_dst->audio_meta->genre == NULL)
1099 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1100 media_info_destroy((media_info_h)_dst);
1101 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1104 if(STRING_VALID(_src->audio_meta->composer))
1106 _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
1107 if(_dst->audio_meta->composer == NULL)
1109 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1110 media_info_destroy((media_info_h)_dst);
1111 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1114 if(STRING_VALID(_src->audio_meta->year))
1116 _dst->audio_meta->year = strdup(_src->audio_meta->year);
1117 if(_dst->audio_meta->year == NULL)
1119 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1120 media_info_destroy((media_info_h)_dst);
1121 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1124 if(STRING_VALID(_src->audio_meta->recorded_date))
1126 _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
1127 if(_dst->audio_meta->recorded_date == NULL)
1129 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1130 media_info_destroy((media_info_h)_dst);
1131 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1134 if(STRING_VALID(_src->audio_meta->copyright))
1136 _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
1137 if(_dst->audio_meta->copyright == NULL)
1139 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1140 media_info_destroy((media_info_h)_dst);
1141 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1144 if(STRING_VALID(_src->audio_meta->track_num))
1146 _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
1147 if(_dst->audio_meta->track_num == NULL)
1149 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1150 media_info_destroy((media_info_h)_dst);
1151 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1155 _dst->audio_meta->channel = _src->audio_meta->channel;
1156 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
1157 _dst->audio_meta->duration = _src->audio_meta->duration;
1158 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
1159 _dst->audio_meta->played_count = _src->audio_meta->played_count;
1160 _dst->audio_meta->played_time = _src->audio_meta->played_time;
1161 _dst->audio_meta->played_position = _src->audio_meta->played_position;
1164 *dst = (media_info_h)_dst;
1166 ret = MEDIA_CONTENT_ERROR_NONE;
1170 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1171 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1177 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1179 int ret = MEDIA_CONTENT_ERROR_NONE;
1181 media_content_debug_func();
1183 if(media_count == NULL)
1185 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1186 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1191 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1196 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1198 int ret = MEDIA_CONTENT_ERROR_NONE;
1200 media_content_debug_func();
1202 if(callback == NULL)
1204 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1205 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1208 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1213 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1215 int ret = MEDIA_CONTENT_ERROR_NONE;
1217 media_content_debug_func();
1219 if(STRING_VALID(media_id) && tag_count)
1221 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1225 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1226 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1232 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1234 int ret = MEDIA_CONTENT_ERROR_NONE;
1236 media_content_debug_func();
1238 if((callback != NULL) && STRING_VALID(media_id))
1240 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1244 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1245 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1251 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1253 int ret = MEDIA_CONTENT_ERROR_NONE;
1255 media_content_debug_func();
1257 if(STRING_VALID(media_id) && bookmark_count)
1259 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1263 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1264 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1270 int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1272 int ret = MEDIA_CONTENT_ERROR_NONE;
1274 media_content_debug_func();
1276 if((callback != NULL) && STRING_VALID(media_id))
1278 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1282 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1283 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1289 int media_info_get_image(media_info_h media, image_meta_h *image)
1291 int ret = MEDIA_CONTENT_ERROR_NONE;
1293 media_info_s *_media = (media_info_s*)media;
1294 media_content_debug_func();
1298 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1299 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1302 if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
1304 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1305 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1308 if(_media->image_meta == NULL)
1310 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1311 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1314 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1318 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1319 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1322 if(STRING_VALID(_media->media_id)) {
1323 _image->media_id = strdup(_media->media_id);
1326 _image->width = _media->image_meta->width;
1327 _image->height = _media->image_meta->height;
1328 _image->orientation = _media->image_meta->orientation;
1330 if(STRING_VALID(_media->image_meta->date_taken)) {
1331 _image->date_taken = strdup(_media->image_meta->date_taken);
1334 if(STRING_VALID(_media->image_meta->burst_id)) {
1335 _image->burst_id = strdup(_media->image_meta->burst_id);
1338 *image = (image_meta_h)_image;
1343 int media_info_get_video(media_info_h media, video_meta_h *video)
1345 int ret = MEDIA_CONTENT_ERROR_NONE;
1347 media_info_s *_media = (media_info_s*)media;
1348 media_content_debug_func();
1352 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1353 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1356 if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
1358 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1359 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1362 if(_media->video_meta == NULL)
1364 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1365 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1368 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1372 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1373 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1376 if(STRING_VALID(_media->media_id)) {
1377 _video->media_id = strdup(_media->media_id);
1380 if(STRING_VALID(_media->video_meta->title)) {
1381 _video->title = strdup(_media->video_meta->title);
1383 if(STRING_VALID(_media->video_meta->album)) {
1384 _video->album = strdup(_media->video_meta->album);
1386 if(STRING_VALID(_media->video_meta->artist)) {
1387 _video->artist = strdup(_media->video_meta->artist);
1389 if(STRING_VALID(_media->video_meta->genre)) {
1390 _video->genre = strdup(_media->video_meta->genre);
1392 if(STRING_VALID(_media->video_meta->composer)) {
1393 _video->composer = strdup(_media->video_meta->composer);
1395 if(STRING_VALID(_media->video_meta->year)) {
1396 _video->year = strdup(_media->video_meta->year);
1398 if(STRING_VALID(_media->video_meta->recorded_date)) {
1399 _video->recorded_date = strdup(_media->video_meta->recorded_date);
1401 if(STRING_VALID(_media->video_meta->copyright)) {
1402 _video->copyright = strdup(_media->video_meta->copyright);
1404 if(STRING_VALID(_media->video_meta->track_num)) {
1405 _video->track_num = strdup(_media->video_meta->track_num);
1408 _video->width = _media->video_meta->width;
1409 _video->height = _media->video_meta->height;
1410 _video->duration = _media->video_meta->duration;
1411 _video->bitrate = _media->video_meta->bitrate;
1412 _video->played_count = _media->video_meta->played_count;
1413 _video->played_time = _media->video_meta->played_time;
1414 _video->played_position = _media->video_meta->played_position;
1416 *video = (video_meta_h)_video;
1421 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1423 int ret = MEDIA_CONTENT_ERROR_NONE;
1425 media_info_s *_media = (media_info_s*)media;
1426 media_content_debug_func();
1430 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1431 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1434 if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
1436 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1437 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1440 if(_media->audio_meta == NULL)
1442 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1443 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1446 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1450 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1451 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1454 if(STRING_VALID(_media->media_id)) {
1455 _audio->media_id = strdup(_media->media_id);
1458 if(STRING_VALID(_media->audio_meta->title)) {
1459 _audio->title = strdup(_media->audio_meta->title);
1461 if(STRING_VALID(_media->audio_meta->album)) {
1462 _audio->album = strdup(_media->audio_meta->album);
1464 if(STRING_VALID(_media->audio_meta->artist)) {
1465 _audio->artist = strdup(_media->audio_meta->artist);
1467 if(STRING_VALID(_media->audio_meta->genre)) {
1468 _audio->genre = strdup(_media->audio_meta->genre);
1470 if(STRING_VALID(_media->audio_meta->composer)) {
1471 _audio->composer = strdup(_media->audio_meta->composer);
1473 if(STRING_VALID(_media->audio_meta->year)) {
1474 _audio->year = strdup(_media->audio_meta->year);
1476 if(STRING_VALID(_media->audio_meta->recorded_date)) {
1477 _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
1479 if(STRING_VALID(_media->audio_meta->copyright)) {
1480 _audio->copyright = strdup(_media->audio_meta->copyright);
1482 if(STRING_VALID(_media->audio_meta->track_num)) {
1483 _audio->track_num = strdup(_media->audio_meta->track_num);
1486 _audio->duration = _media->audio_meta->duration;
1487 _audio->bitrate = _media->audio_meta->bitrate;
1488 _audio->samplerate = _media->audio_meta->samplerate;
1489 _audio->channel = _media->audio_meta->channel;
1490 _audio->played_time = _media->audio_meta->played_time;
1491 _audio->played_count = _media->audio_meta->played_count;
1492 _audio->played_position = _media->audio_meta->played_position;
1494 *audio = (audio_meta_h)_audio;
1499 int media_info_get_media_id(media_info_h media, char **media_id)
1501 int ret = MEDIA_CONTENT_ERROR_NONE;
1502 media_info_s *_media = (media_info_s*)media;
1504 if(_media && media_id)
1506 if(STRING_VALID(_media->media_id))
1508 *media_id = strdup(_media->media_id);
1509 if(*media_id == NULL)
1511 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1512 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1519 ret = MEDIA_CONTENT_ERROR_NONE;
1523 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1524 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1530 int media_info_get_file_path(media_info_h media, char **path)
1532 int ret = MEDIA_CONTENT_ERROR_NONE;
1533 media_info_s *_media = (media_info_s*)media;
1537 if(STRING_VALID(_media->file_path))
1539 *path = strdup(_media->file_path);
1542 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1543 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1550 ret = MEDIA_CONTENT_ERROR_NONE;
1555 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1556 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1562 int media_info_get_display_name(media_info_h media, char **name)
1564 int ret = MEDIA_CONTENT_ERROR_NONE;
1565 media_info_s *_media = (media_info_s*)media;
1568 if(STRING_VALID(_media->display_name))
1570 *name = strdup(_media->display_name);
1573 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1574 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1581 ret = MEDIA_CONTENT_ERROR_NONE;
1586 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1587 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1593 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1595 int ret = MEDIA_CONTENT_ERROR_NONE;
1596 media_info_s *_media = (media_info_s*)media;
1599 *type = _media->media_type;
1600 ret = MEDIA_CONTENT_ERROR_NONE;
1604 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1605 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1611 int media_info_get_mime_type(media_info_h media, char **mime_type)
1613 int ret = MEDIA_CONTENT_ERROR_NONE;
1614 media_info_s *_media = (media_info_s*)media;
1616 if(_media && mime_type)
1618 if(STRING_VALID(_media->mime_type))
1620 *mime_type = strdup(_media->mime_type);
1621 if(*mime_type == NULL)
1623 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1624 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1631 ret = MEDIA_CONTENT_ERROR_NONE;
1635 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1636 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1642 int media_info_get_size(media_info_h media, unsigned long long *size)
1644 int ret = MEDIA_CONTENT_ERROR_NONE;
1645 media_info_s *_media = (media_info_s*)media;
1649 *size = _media->size;
1650 ret = MEDIA_CONTENT_ERROR_NONE;
1654 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1655 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1661 int media_info_get_added_time(media_info_h media, time_t *added_time)
1663 int ret = MEDIA_CONTENT_ERROR_NONE;
1664 media_info_s *_media = (media_info_s*)media;
1665 if(_media && added_time)
1667 *added_time = _media->added_time;
1668 ret = MEDIA_CONTENT_ERROR_NONE;
1672 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1673 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1679 int media_info_get_modified_time(media_info_h media, time_t* time)
1681 int ret = MEDIA_CONTENT_ERROR_NONE;
1682 media_info_s *_media = (media_info_s*)media;
1685 *time = _media->modified_time;
1686 ret = MEDIA_CONTENT_ERROR_NONE;
1690 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1691 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1697 int media_info_get_thumbnail_path(media_info_h media, char **path)
1699 int ret = MEDIA_CONTENT_ERROR_NONE;
1700 media_info_s *_media = (media_info_s*)media;
1703 if(STRING_VALID(_media->thumbnail_path))
1705 *path = strdup(_media->thumbnail_path);
1708 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1709 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1716 ret = MEDIA_CONTENT_ERROR_NONE;
1721 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1722 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1728 int media_info_get_description(media_info_h media, char **description)
1730 int ret = MEDIA_CONTENT_ERROR_NONE;
1731 media_info_s *_media = (media_info_s*)media;
1733 if(_media && description)
1735 if(STRING_VALID(_media->description))
1737 *description = strdup(_media->description);
1738 if(*description == NULL)
1740 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1741 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1746 *description = NULL;
1748 ret = MEDIA_CONTENT_ERROR_NONE;
1752 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1753 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1759 int media_info_get_longitude(media_info_h media, double* longitude)
1761 int ret = MEDIA_CONTENT_ERROR_NONE;
1762 media_info_s *_media = (media_info_s*)media;
1764 if(_media && longitude)
1766 *longitude = _media->longitude;
1767 ret = MEDIA_CONTENT_ERROR_NONE;
1771 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1772 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1777 int media_info_get_latitude(media_info_h media, double* latitude)
1779 int ret = MEDIA_CONTENT_ERROR_NONE;
1780 media_info_s *_media = (media_info_s*)media;
1782 if(_media && latitude)
1784 *latitude = _media->latitude;
1785 ret = MEDIA_CONTENT_ERROR_NONE;
1789 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1790 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1796 int media_info_get_altitude(media_info_h media, double *altitude)
1798 int ret = MEDIA_CONTENT_ERROR_NONE;
1799 media_info_s *_media = (media_info_s*)media;
1801 if(_media && altitude)
1803 *altitude = _media->altitude;
1804 ret = MEDIA_CONTENT_ERROR_NONE;
1808 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1809 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1815 int media_info_get_rating(media_info_h media, int *rating)
1817 int ret = MEDIA_CONTENT_ERROR_NONE;
1818 media_info_s *_media = (media_info_s*)media;
1820 if(_media && rating)
1822 *rating = _media->rating;
1823 ret = MEDIA_CONTENT_ERROR_NONE;
1827 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1828 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1834 int media_info_get_favorite(media_info_h media, bool* favorite)
1836 int ret = MEDIA_CONTENT_ERROR_NONE;
1837 media_info_s *_media = (media_info_s*)media;
1839 if(_media && favorite)
1842 *favorite = _media->favourite;
1843 ret = MEDIA_CONTENT_ERROR_NONE;
1847 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1848 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1854 int media_info_get_author(media_info_h media, char **author)
1856 int ret = MEDIA_CONTENT_ERROR_NONE;
1857 media_info_s *_media = (media_info_s*)media;
1859 if(_media && author)
1861 if(STRING_VALID(_media->author))
1863 *author = strdup(_media->author);
1866 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1867 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1874 ret = MEDIA_CONTENT_ERROR_NONE;
1878 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1879 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1885 int media_info_get_provider(media_info_h media, char **provider)
1887 int ret = MEDIA_CONTENT_ERROR_NONE;
1888 media_info_s *_media = (media_info_s*)media;
1890 if(_media && provider)
1892 if(STRING_VALID(_media->provider))
1894 *provider = strdup(_media->provider);
1895 if(*provider == NULL)
1897 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1898 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1905 ret = MEDIA_CONTENT_ERROR_NONE;
1909 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1910 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1916 int media_info_get_content_name(media_info_h media, char **content_name)
1918 int ret = MEDIA_CONTENT_ERROR_NONE;
1919 media_info_s *_media = (media_info_s*)media;
1921 if(_media && content_name)
1923 if(STRING_VALID(_media->content_name))
1925 *content_name = strdup(_media->content_name);
1926 if(*content_name == NULL)
1928 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1929 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1934 *content_name = NULL;
1936 ret = MEDIA_CONTENT_ERROR_NONE;
1940 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1941 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1947 int media_info_get_category(media_info_h media, char **category)
1949 int ret = MEDIA_CONTENT_ERROR_NONE;
1950 media_info_s *_media = (media_info_s*)media;
1952 if(_media && category)
1954 if(STRING_VALID(_media->category))
1956 *category = strdup(_media->category);
1957 if(*category == NULL)
1959 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1960 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1967 ret = MEDIA_CONTENT_ERROR_NONE;
1971 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1972 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1978 int media_info_get_location_tag(media_info_h media, char **location_tag)
1980 int ret = MEDIA_CONTENT_ERROR_NONE;
1981 media_info_s *_media = (media_info_s*)media;
1983 if(_media && location_tag)
1985 if(STRING_VALID(_media->location_tag))
1987 *location_tag = strdup(_media->location_tag);
1988 if(*location_tag == NULL)
1990 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1991 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1996 *location_tag = NULL;
1998 ret = MEDIA_CONTENT_ERROR_NONE;
2002 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2003 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2009 int media_info_get_age_rating(media_info_h media, char **age_rating)
2011 int ret = MEDIA_CONTENT_ERROR_NONE;
2012 media_info_s *_media = (media_info_s*)media;
2014 if(_media && age_rating)
2016 if(STRING_VALID(_media->age_rating))
2018 *age_rating = strdup(_media->age_rating);
2019 if(*age_rating == NULL)
2021 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2022 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2029 ret = MEDIA_CONTENT_ERROR_NONE;
2033 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2034 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2040 int media_info_get_keyword(media_info_h media, char **keyword)
2042 int ret = MEDIA_CONTENT_ERROR_NONE;
2043 media_info_s *_media = (media_info_s*)media;
2045 if(_media && keyword)
2047 if(STRING_VALID(_media->keyword))
2049 *keyword = strdup(_media->keyword);
2050 if(*keyword == NULL)
2052 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2053 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2060 ret = MEDIA_CONTENT_ERROR_NONE;
2064 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2065 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2071 int media_info_is_drm(media_info_h media, bool *is_drm)
2073 int ret = MEDIA_CONTENT_ERROR_NONE;
2074 media_info_s *_media = (media_info_s*)media;
2078 *is_drm = _media->is_drm;
2079 ret = MEDIA_CONTENT_ERROR_NONE;
2083 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2084 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2090 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
2092 int ret = MEDIA_CONTENT_ERROR_NONE;
2093 media_info_s *_media = (media_info_s*)media;
2095 if(_media && storage_type)
2097 *storage_type = _media->storage_type;
2098 ret = MEDIA_CONTENT_ERROR_NONE;
2102 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2103 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2109 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
2111 int ret = MEDIA_CONTENT_ERROR_NONE;
2112 char select_query[DEFAULT_QUERY_SIZE];
2113 sqlite3_stmt *stmt = NULL;
2115 if(!STRING_VALID(media_id) || (media == NULL))
2117 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2118 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2121 memset(select_query, 0x00, sizeof(select_query));
2123 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
2124 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
2125 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2127 while(sqlite3_step(stmt) == SQLITE_ROW)
2129 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
2133 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2134 SQLITE3_FINALIZE(stmt);
2135 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2138 _media_info_item_get_detail(stmt, (media_info_h)_media);
2140 *media = (media_info_h)_media;
2143 SQLITE3_FINALIZE(stmt);
2148 int media_info_set_display_name(media_info_h media, const char *display_name)
2150 int ret = MEDIA_CONTENT_ERROR_NONE;
2151 media_info_s *_media = (media_info_s*)media;
2153 if(_media != NULL && STRING_VALID(display_name))
2155 SAFE_FREE(_media->display_name);
2157 _media->display_name = strdup(display_name);
2158 if(_media->display_name == NULL)
2160 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2161 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2166 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2167 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2173 int media_info_set_description(media_info_h media, const char *description)
2175 int ret = MEDIA_CONTENT_ERROR_NONE;
2176 media_info_s *_media = (media_info_s*)media;
2180 SAFE_FREE(_media->description);
2182 if(STRING_VALID(description))
2184 _media->description = strdup(description);
2186 if(_media->description == NULL)
2188 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2189 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2194 _media->description = NULL;
2199 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2200 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2206 int media_info_set_longitude(media_info_h media, double longitude)
2208 int ret = MEDIA_CONTENT_ERROR_NONE;
2209 media_info_s *_media = (media_info_s*)media;
2213 _media->longitude = longitude;
2217 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2218 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2224 int media_info_set_latitude(media_info_h media, double latitude)
2226 int ret = MEDIA_CONTENT_ERROR_NONE;
2227 media_info_s *_media = (media_info_s*)media;
2231 _media->latitude = latitude;
2235 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2236 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2242 int media_info_set_altitude(media_info_h media, double altitude)
2244 int ret = MEDIA_CONTENT_ERROR_NONE;
2245 media_info_s *_media = (media_info_s*)media;
2249 _media->altitude = altitude;
2253 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2254 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2260 int media_info_set_rating(media_info_h media, int rating)
2262 int ret = MEDIA_CONTENT_ERROR_NONE;
2263 media_info_s *_media = (media_info_s*)media;
2267 _media->rating = rating;
2271 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2272 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2278 int media_info_set_added_time(media_info_h media, time_t added_time)
2280 int ret = MEDIA_CONTENT_ERROR_NONE;
2282 media_info_s *_media = (media_info_s*)media;
2284 if((_media != NULL) && (added_time >= 0))
2286 _media->added_time = added_time;
2290 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2291 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2297 int media_info_set_favorite(media_info_h media, bool favorite)
2299 int ret = MEDIA_CONTENT_ERROR_NONE;
2300 media_info_s *_media = (media_info_s*)media;
2304 _media->favourite = favorite;
2308 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2309 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2315 int media_info_set_author(media_info_h media, const char *author)
2317 int ret = MEDIA_CONTENT_ERROR_NONE;
2318 media_info_s *_media = (media_info_s*)media;
2322 if(STRING_VALID(author))
2324 _media->author = strdup(author);
2325 if(_media->author == NULL)
2327 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2328 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2333 _media->author = NULL;
2338 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2339 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2345 int media_info_set_provider(media_info_h media, const char *provider)
2347 int ret = MEDIA_CONTENT_ERROR_NONE;
2348 media_info_s *_media = (media_info_s*)media;
2352 SAFE_FREE(_media->provider);
2354 if(STRING_VALID(provider))
2356 _media->provider = strdup(provider);
2357 if(_media->provider == NULL)
2359 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2360 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2365 _media->provider = NULL;
2370 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2371 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2377 int media_info_set_content_name(media_info_h media, const char *content_name)
2379 int ret = MEDIA_CONTENT_ERROR_NONE;
2380 media_info_s *_media = (media_info_s*)media;
2384 SAFE_FREE(_media->content_name);
2386 if(STRING_VALID(content_name))
2388 _media->content_name = strdup(content_name);
2389 if(_media->content_name == NULL)
2391 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2392 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2397 _media->content_name = NULL;
2402 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2403 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2409 int media_info_set_category(media_info_h media, const char *category)
2411 int ret = MEDIA_CONTENT_ERROR_NONE;
2412 media_info_s *_media = (media_info_s*)media;
2416 SAFE_FREE(_media->category);
2418 if(STRING_VALID(category))
2420 _media->category = strdup(category);
2421 if(_media->category == NULL)
2423 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2424 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2429 _media->category = NULL;
2434 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2435 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2441 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2443 int ret = MEDIA_CONTENT_ERROR_NONE;
2444 media_info_s *_media = (media_info_s*)media;
2448 SAFE_FREE(_media->location_tag);
2450 if(STRING_VALID(location_tag))
2452 _media->location_tag = strdup(location_tag);
2453 if(_media->location_tag == NULL)
2455 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2456 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2461 _media->location_tag = NULL;
2466 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2467 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2473 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2475 int ret = MEDIA_CONTENT_ERROR_NONE;
2476 media_info_s *_media = (media_info_s*)media;
2480 SAFE_FREE(_media->age_rating);
2482 if(STRING_VALID(age_rating))
2484 _media->age_rating = strdup(age_rating);
2485 if(_media->age_rating == NULL)
2487 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2488 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2493 _media->age_rating = NULL;
2498 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2499 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2505 int media_info_set_keyword(media_info_h media, const char *keyword)
2507 int ret = MEDIA_CONTENT_ERROR_NONE;
2508 media_info_s *_media = (media_info_s*)media;
2512 SAFE_FREE(_media->keyword);
2514 if(STRING_VALID(keyword))
2516 _media->keyword = strdup(keyword);
2517 if(_media->keyword == NULL)
2519 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2520 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2525 _media->keyword = NULL;
2530 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2531 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2537 int media_info_update_to_db(media_info_h media)
2539 int ret = MEDIA_CONTENT_ERROR_NONE;
2541 media_info_s *_media = (media_info_s*)media;
2542 char *set_sql = NULL;
2543 char sql[MAX_QUERY_SIZE];
2544 memset(sql, '\0', sizeof(sql));
2546 if(_media != NULL && STRING_VALID(_media->media_id))
2548 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2549 /* This code will be removed when sqlite3_mprintf works clearly */
2550 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2551 sqlite3_free(test_sql);
2553 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2554 rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q",
2555 _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite,
2556 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword);
2558 len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
2559 sqlite3_free(set_sql);
2563 media_content_error("snprintf failed");
2564 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2567 ret = _content_query_sql(sql);
2568 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2569 /* Send notification for this update */
2570 media_content_debug("Update is successfull. Send notification for this");
2571 if (_media->file_path && _media->mime_type) {
2572 media_db_update_send(getpid(), MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_id, _media->media_type, _media->mime_type);
2574 media_content_error("Can't media_db_update_send : path or mime type is NULL");
2580 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2581 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2587 int media_info_refresh_metadata_to_db(const char *media_id)
2589 int ret = MEDIA_CONTENT_ERROR_NONE;
2590 media_info_h media = NULL;
2591 char *file_path = NULL;
2592 media_content_type_e media_type = 0;
2593 media_content_storage_e storage_type = 0;
2595 if(!STRING_VALID(media_id))
2597 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2598 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2601 ret = media_info_get_media_from_db(media_id, &media);
2602 if(ret != MEDIA_CONTENT_ERROR_NONE)
2604 media_info_destroy(media);
2608 ret = media_info_get_media_type(media, &media_type);
2609 if(ret != MEDIA_CONTENT_ERROR_NONE)
2611 media_info_destroy(media);
2615 ret = media_info_get_storage_type(media, &storage_type);
2616 if(ret != MEDIA_CONTENT_ERROR_NONE)
2618 media_info_destroy(media);
2622 ret = media_info_get_file_path(media, &file_path);
2623 if(ret != MEDIA_CONTENT_ERROR_NONE)
2625 media_info_destroy(media);
2629 ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, media_type);
2631 SAFE_FREE(file_path);
2632 media_info_destroy(media);
2637 int media_info_move_to_db(media_info_h media, const char* dst_path)
2639 int ret = MEDIA_CONTENT_ERROR_NONE;
2641 int src_storage_type = 0;
2642 int dst_storage_type = 0;
2644 if(media == NULL || !STRING_VALID(dst_path))
2646 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2647 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2650 media_info_s *_media = (media_info_s*)media;
2652 ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2653 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2654 ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2655 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2657 ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path);
2658 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2661 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2663 int ret = MEDIA_CONTENT_ERROR_NONE;
2664 media_info_s *_media = (media_info_s*)media;
2666 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2668 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2669 _thumb_cb->handle = _media;
2670 _thumb_cb->user_data = user_data;
2671 _thumb_cb->thumbnail_completed_cb = callback;
2673 ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb);
2674 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2678 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2679 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2685 int media_info_cancel_thumbnail(media_info_h media)
2687 int ret = MEDIA_CONTENT_ERROR_NONE;
2688 media_info_s *_media = (media_info_s*)media;
2690 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2692 ret = thumbnail_request_cancel_media(_media->file_path);
2693 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2697 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2698 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;