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 int ret_view = MEDIA_CONTENT_ERROR_NONE;
35 sqlite3_stmt *stmt = NULL;
36 char *select_query = NULL;
37 media_info_s *_media = (media_info_s*)media;
41 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
42 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
45 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
47 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
48 sqlite3_free(select_query);
49 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
51 if(sqlite3_step(stmt) == SQLITE_ROW)
53 _media_info_item_get_detail(stmt, (media_info_h)_media);
54 media_content_debug("New Media ID: %s", _media->media_id);
56 media_content_debug("There's no media!!");
59 while(sqlite3_step(stmt) == SQLITE_ROW)
61 _media_info_item_get_detail(stmt, (media_info_h)_media);
62 media_content_debug("New Media ID: %s", _media->media_id);
65 SQLITE3_FINALIZE(stmt);
70 static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
72 int ret = MEDIA_CONTENT_ERROR_NONE;
73 int ret_view = MEDIA_CONTENT_ERROR_NONE;
74 sqlite3_stmt *stmt = NULL;
75 char *select_query = NULL;
77 if(!STRING_VALID(media_id))
79 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
80 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
83 select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
85 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
86 sqlite3_free(select_query);
87 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
89 if(sqlite3_step(stmt) == SQLITE_ROW)
91 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
92 *path = strdup((const char *)sqlite3_column_text(stmt, 0));
94 media_content_debug("There's no media with this ID : %s", media_id);
96 ret = MEDIA_CONTENT_ERROR_DB_FAILED;
99 SQLITE3_FINALIZE(stmt);
103 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
105 int ret = MEDIA_CONTENT_ERROR_NONE;
106 media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
110 ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
113 if (_cb_data->insert_completed_cb)
114 _cb_data->insert_completed_cb(ret, _cb_data->user_data);
116 if (STRING_VALID(_cb_data->insert_list_path)) {
117 if (unlink(_cb_data->insert_list_path) < 0) {
118 media_content_error("failed to delete : %s", strerror(errno));
120 SAFE_FREE(_cb_data->insert_list_path);
129 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
131 int error_value = MEDIA_CONTENT_ERROR_NONE;
133 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
134 media_info_s *media = NULL;
136 if(_thumb_cb != NULL)
138 media = _thumb_cb->handle;
139 if((media != NULL) && STRING_VALID(path))
141 SAFE_FREE(media->thumbnail_path);
142 media->thumbnail_path = strdup(path);
145 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
146 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
147 if (_thumb_cb->thumbnail_completed_cb)
148 _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
151 SAFE_FREE(_thumb_cb);
156 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
158 char *thumb_path = NULL;
159 media_content_type_e media_type = 0;
163 media_content_debug("NO Item \n");
167 media_info_get_media_type(media, &media_type);
168 media_content_debug("media_type : [%d] \n", media_type);
170 media_info_get_thumbnail_path(media, &thumb_path);
171 if (STRING_VALID(thumb_path)) {
172 if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0) {
173 media_content_debug("Deleting thumbnail : [%s] \n", thumb_path);
174 if (unlink(thumb_path) < 0) {
175 media_content_error("failed to delete : %s", strerror(errno));
179 SAFE_FREE(thumb_path);
189 MEDIA_INFO_FILE_NAME,
191 MEDIA_INFO_MIME_TYPE,
193 MEDIA_INFO_ADDED_TIME,
194 MEDIA_INFO_MODIFIED_TIME,
195 MEDIA_INFO_THUMBNAIL_PATH,
196 MEDIA_INFO_DESCRIPTION,
197 MEDIA_INFO_RATING, //10
198 MEDIA_INFO_FAVOURITE,
201 MEDIA_INFO_CONTENT_NAME,
203 MEDIA_INFO_LOCATION_TAG,
204 MEDIA_INFO_AGE_RATING,
207 MEDIA_INFO_STORAGE_TYPE, //20
208 MEDIA_INFO_LONGITUDE,
213 MEDIA_INFO_DATETAKEN,
214 MEDIA_INFO_ORIENTATION,
217 MEDIA_INFO_ARTIST, //30
218 MEDIA_INFO_ALBUM_ARTIST,
222 MEDIA_INFO_RECORDED_DATE,
223 MEDIA_INFO_COPYRIGHT,
224 MEDIA_INFO_TRACK_NUM,
226 MEDIA_INFO_BITPERSAMPLE,
228 MEDIA_INFO_PLAYED_COUNT, //40
229 MEDIA_INFO_LAST_PLAYED_TIME,
230 MEDIA_INFO_LAST_PLAYED_POSITION,
231 MEDIA_INFO_SAMPLERATE,
236 MEDIA_INFO_SYNC_STATUS,
239 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
241 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
242 // 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"
244 media_info_s *_media = (media_info_s*)media;
246 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID)))
247 _media->media_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
249 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH)))
250 _media->file_path = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
252 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME)))
253 _media->display_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
255 _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
257 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE)))
258 _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
260 _media->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
262 _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
264 _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
266 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH)))
267 _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
269 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION)))
270 _media->description = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
272 _media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
274 _media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
276 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR)))
277 _media->author = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR));
279 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER)))
280 _media->provider = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER));
282 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME)))
283 _media->content_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME));
285 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY)))
286 _media->category = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY));
288 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG)))
289 _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG));
291 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING)))
292 _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING));
294 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD)))
295 _media->keyword = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD));
297 _media->is_drm = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_DRM);
299 _media->storage_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_STORAGE_TYPE);
301 _media->longitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LONGITUDE);
302 _media->latitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LATITUDE);
303 _media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
305 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
306 _media->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
308 _media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
310 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER)))
311 _media->weather = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
313 _media->sync_status = (int)sqlite3_column_int(stmt, MEDIA_INFO_SYNC_STATUS);
316 if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
317 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
318 if(_media->image_meta) {
319 if(STRING_VALID(_media->media_id))
320 _media->image_meta->media_id = strdup(_media->media_id);
322 _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
323 _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
325 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN)))
326 _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
328 _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
330 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
331 _media->image_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
333 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID)))
334 _media->image_meta->burst_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
336 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER)))
337 _media->image_meta->weather = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
340 } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
341 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
342 if(_media->video_meta) {
343 if(STRING_VALID(_media->media_id))
344 _media->video_meta->media_id = strdup(_media->media_id);
346 _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
347 _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
349 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
350 _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
352 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM)))
353 _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
355 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST)))
356 _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
358 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST)))
359 _media->video_meta->album_artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
361 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)))
362 _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
364 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)))
365 _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
367 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR)))
368 _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
370 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)))
371 _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
373 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)))
374 _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
376 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM)))
377 _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
379 _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
380 _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
381 _media->video_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
382 _media->video_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
383 _media->video_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
387 else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
388 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
389 if(_media->audio_meta) {
390 if(STRING_VALID(_media->media_id))
391 _media->audio_meta->media_id = strdup(_media->media_id);
393 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
394 _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
396 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM)))
397 _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
399 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST)))
400 _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
402 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST)))
403 _media->audio_meta->album_artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
405 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)))
406 _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
408 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)))
409 _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
411 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR)))
412 _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
414 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)))
415 _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
417 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)))
418 _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
420 if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM)))
421 _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
423 _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
424 _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
425 _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
426 _media->audio_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
427 _media->audio_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
428 _media->audio_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
429 _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
430 _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
436 int media_info_insert_to_db (const char *path, media_info_h *info)
438 int ret = MEDIA_CONTENT_ERROR_NONE;
440 if(!STRING_VALID(path))
442 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
443 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
448 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
449 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
453 media_content_debug("Register: %s", path);
454 ret = media_file_register(path);
455 if(ret != MS_MEDIA_ERR_NONE)
457 media_content_error("media_file_register failed");
458 return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
462 char *_path = strdup(path);
464 media_content_error("strdup failed : %s", path);
465 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
468 ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), _path);
469 if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
470 media_content_debug("media_svc_check_item_exist_by_path : no record : %s", _path);
472 media_svc_storage_type_e storage_type;
474 ret = media_svc_get_storage_type(_path, &storage_type);
476 media_content_error("media_svc_get_storage_type failed : %d (%s)", ret, _path);
478 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
481 media_content_debug("media_svc_insert_item_immediately: %s", _path);
482 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_type, _path, tzplatform_getuid(TZ_USER_NAME));
485 media_content_error("media_svc_insert_item_immediately failed : %d (%s)", ret, _path);
487 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
489 } else if (ret != MEDIA_INFO_ERROR_NONE) {
490 media_content_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, _path);
492 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
496 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
499 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
501 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
504 _media->file_path = _path;
505 if(_media->file_path == NULL)
507 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
509 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
512 ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
514 *info = (media_info_h)_media;
518 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
519 unsigned int array_length,
520 media_insert_completed_cb completed_cb,
523 int ret = MEDIA_CONTENT_ERROR_NONE;
525 char list_path[255] = {0,};
529 for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
530 snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
532 if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
533 memset(list_path, 0x00, sizeof(list_path));
536 media_content_debug("The request file list path : %s", list_path);
541 if (idx == BATCH_REQUEST_MAX) {
542 media_content_error("Too many batch request for one thread");
543 return MEDIA_CONTENT_ERROR_DB_BUSY;
546 fp = fopen(list_path, "w");
548 media_content_error("failed to open file : %s [%s]", list_path, strerror(errno));
549 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
552 for (idx = 0; idx < array_length; idx++) {
553 if (STRING_VALID(path_array[idx])) {
554 int size = strlen(path_array[idx]);
556 nwrites = fwrite(path_array[idx], 1, size, fp);
557 if (nwrites != size) {
558 media_content_error("failed to write thumbnail : %s", strerror(errno));
560 if (unlink(list_path) < 0) {
561 media_content_error("failed to delete : %s", strerror(errno));
563 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
566 nwrites = fwrite("\n", 1, 1, fp);
568 media_content_error("failed to write thumbnail : %s", strerror(errno));
570 if (unlink(list_path) < 0) {
571 media_content_error("failed to delete : %s", strerror(errno));
573 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
576 media_content_error("path[%d] is invalid string", idx);
582 media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
583 _cb_data->insert_completed_cb = completed_cb;
584 _cb_data->user_data = user_data;
585 _cb_data->insert_list_path = strdup(list_path);
587 if(insert_type == MEDIA_BATCH_INSERT_NORMAL)
588 ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
589 else if(insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
590 ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
592 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
594 if (ret != MEDIA_CONTENT_ERROR_NONE) {
595 media_content_error("media_files_register failed : %d", ret);
596 if (unlink(list_path) < 0) {
597 media_content_error("failed to delete : %s", strerror(errno));
599 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
605 int media_info_insert_batch_to_db(
606 const char **path_array,
607 unsigned int array_length,
608 media_insert_completed_cb completed_cb,
611 if (path_array == NULL)
613 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
614 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
617 if (array_length <= 0)
619 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
620 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
623 return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
626 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)
628 if (path_array == NULL)
630 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
631 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
634 if (array_length <= 0)
636 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
637 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
640 return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
643 int media_info_delete_from_db(const char *media_id)
645 int ret = MEDIA_CONTENT_ERROR_NONE;
647 if(!STRING_VALID(media_id))
649 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
650 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
654 char *query_string = NULL;
655 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id);
657 ret = _content_query_sql(query_string);
659 sqlite3_free(query_string);
665 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
666 if (ret < MEDIA_CONTENT_ERROR_NONE) {
667 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
672 ret = media_svc_delete_item_by_path(_content_get_db_handle(), path, tzplatform_getuid(TZ_USER_NAME));
675 return _content_error_capi(ret,MEDIA_CONTENT_TYPE);
679 int media_info_delete_batch_from_db(filter_h filter)
681 int ret = MEDIA_CONTENT_ERROR_NONE;
683 char *query_string = NULL;
684 filter_s *_filter = NULL;
686 char *condition_query = NULL;
690 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
691 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
694 /* Delete thumbnail of each item */
695 ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, NULL, MEDIA_GROUP_NONE);
697 _filter = (filter_s*)filter;
698 attr = _content_get_attirbute_handle();
700 if(_filter->condition)
702 ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
703 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
706 if(STRING_VALID(condition_query))
708 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, condition_query);
712 SAFE_FREE(condition_query);
713 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
716 ret = _content_query_sql(query_string);
717 if (ret == MEDIA_CONTENT_ERROR_NONE) {
718 /* Send notification for this
719 In this case, send noti for internal storage and external storage
721 media_content_debug("Batch deletion is successfull. Send notification for this");
722 media_db_update_send(getpid(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_CONTENT_PATH_PHONE, NULL, -1, NULL);
723 media_db_update_send(getpid(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_CONTENT_PATH_MMC, NULL, -1, NULL);
726 SAFE_FREE(condition_query);
727 sqlite3_free(query_string);
732 int media_info_destroy(media_info_h media)
734 int ret = MEDIA_CONTENT_ERROR_NONE;
735 media_info_s *_media = (media_info_s*)media;
739 SAFE_FREE(_media->media_id);
740 SAFE_FREE(_media->file_path);
741 SAFE_FREE(_media->display_name);
742 SAFE_FREE(_media->mime_type);
743 SAFE_FREE(_media->thumbnail_path);
744 SAFE_FREE(_media->description);
745 SAFE_FREE(_media->author);
746 SAFE_FREE(_media->provider);
747 SAFE_FREE(_media->content_name);
748 SAFE_FREE(_media->category);
749 SAFE_FREE(_media->location_tag);
750 SAFE_FREE(_media->age_rating);
751 SAFE_FREE(_media->keyword);
752 SAFE_FREE(_media->title);
753 SAFE_FREE(_media->weather);
755 if(_media->image_meta) {
756 SAFE_FREE(_media->image_meta->media_id);
757 SAFE_FREE(_media->image_meta->date_taken);
758 SAFE_FREE(_media->image_meta->burst_id);
759 SAFE_FREE(_media->image_meta->title);
760 SAFE_FREE(_media->image_meta->weather);
762 SAFE_FREE(_media->image_meta);
763 } else if(_media->video_meta) {
764 SAFE_FREE(_media->video_meta->media_id);
765 SAFE_FREE(_media->video_meta->title);
766 SAFE_FREE(_media->video_meta->album);
767 SAFE_FREE(_media->video_meta->artist);
768 SAFE_FREE(_media->video_meta->album_artist);
769 SAFE_FREE(_media->video_meta->genre);
770 SAFE_FREE(_media->video_meta->composer);
771 SAFE_FREE(_media->video_meta->year);
772 SAFE_FREE(_media->video_meta->recorded_date);
773 SAFE_FREE(_media->video_meta->copyright);
774 SAFE_FREE(_media->video_meta->track_num);
776 SAFE_FREE(_media->video_meta);
777 } else if(_media->audio_meta) {
778 SAFE_FREE(_media->audio_meta->media_id);
779 SAFE_FREE(_media->audio_meta->title);
780 SAFE_FREE(_media->audio_meta->album);
781 SAFE_FREE(_media->audio_meta->artist);
782 SAFE_FREE(_media->audio_meta->album_artist);
783 SAFE_FREE(_media->audio_meta->genre);
784 SAFE_FREE(_media->audio_meta->composer);
785 SAFE_FREE(_media->audio_meta->year);
786 SAFE_FREE(_media->audio_meta->recorded_date);
787 SAFE_FREE(_media->audio_meta->copyright);
788 SAFE_FREE(_media->audio_meta->track_num);
790 SAFE_FREE(_media->audio_meta);
795 ret = MEDIA_CONTENT_ERROR_NONE;
799 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
800 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
806 int media_info_clone(media_info_h *dst, media_info_h src)
808 int ret = MEDIA_CONTENT_ERROR_NONE;
809 media_info_s *_src = (media_info_s*)src;
814 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
818 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
819 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
822 if(STRING_VALID(_src->media_id))
824 _dst->media_id = strdup(_src->media_id);
825 if(_dst->media_id == NULL)
827 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
828 media_info_destroy((media_info_h)_dst);
829 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
832 if(STRING_VALID(_src->file_path))
834 _dst->file_path = strdup(_src->file_path);
835 if(_dst->file_path == NULL)
837 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
838 media_info_destroy((media_info_h)_dst);
839 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
842 if(STRING_VALID(_src->display_name))
844 _dst->display_name = strdup(_src->display_name);
845 if(_dst->display_name == NULL)
847 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
848 media_info_destroy((media_info_h)_dst);
849 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
852 if(STRING_VALID(_src->mime_type))
854 _dst->mime_type = strdup(_src->mime_type);
855 if(_dst->mime_type == NULL)
857 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
858 media_info_destroy((media_info_h)_dst);
859 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
862 if(STRING_VALID(_src->thumbnail_path))
864 _dst->thumbnail_path = strdup(_src->thumbnail_path);
865 if(_dst->thumbnail_path == NULL)
867 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
868 media_info_destroy((media_info_h)_dst);
869 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
872 if(STRING_VALID(_src->description))
874 _dst->description = strdup(_src->description);
875 if(_dst->description == NULL)
877 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
878 media_info_destroy((media_info_h)_dst);
879 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
883 if(STRING_VALID(_src->weather))
885 _dst->weather = strdup(_src->weather);
886 if(_dst->weather == NULL)
888 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
889 media_info_destroy((media_info_h)_dst);
890 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
894 if(STRING_VALID(_src->title))
896 _dst->title = strdup(_src->title);
897 if(_dst->title == NULL)
899 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
900 media_info_destroy((media_info_h)_dst);
901 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
904 if(STRING_VALID(_src->author))
906 _dst->author = strdup(_src->author);
907 if(_dst->author == NULL)
909 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
910 media_info_destroy((media_info_h)_dst);
911 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
914 if(STRING_VALID(_src->provider))
916 _dst->provider = strdup(_src->provider);
917 if(_dst->provider == NULL)
919 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
920 media_info_destroy((media_info_h)_dst);
921 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
924 if(STRING_VALID(_src->content_name))
926 _dst->content_name = strdup(_src->content_name);
927 if(_dst->content_name == NULL)
929 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
930 media_info_destroy((media_info_h)_dst);
931 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
934 if(STRING_VALID(_src->category))
936 _dst->category = strdup(_src->category);
937 if(_dst->category == NULL)
939 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
940 media_info_destroy((media_info_h)_dst);
941 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
944 if(STRING_VALID(_src->location_tag))
946 _dst->location_tag = strdup(_src->location_tag);
947 if(_dst->location_tag == NULL)
949 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
950 media_info_destroy((media_info_h)_dst);
951 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
954 if(STRING_VALID(_src->age_rating))
956 _dst->age_rating = strdup(_src->age_rating);
957 if(_dst->age_rating == NULL)
959 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
960 media_info_destroy((media_info_h)_dst);
961 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
964 if(STRING_VALID(_src->keyword))
966 _dst->keyword = strdup(_src->keyword);
967 if(_dst->keyword == NULL)
969 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
970 media_info_destroy((media_info_h)_dst);
971 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
975 _dst->media_type = _src->media_type;
976 _dst->size = _src->size;
977 _dst->added_time = _src->added_time;
978 _dst->modified_time = _src->modified_time;
979 _dst->timeline = _src->timeline;
980 _dst->longitude = _src->longitude;
981 _dst->latitude = _src->latitude;
982 _dst->altitude = _src->altitude;
983 _dst->rating = _src->rating;
984 _dst->favourite = _src->favourite;
985 _dst->is_drm = _src->is_drm;
986 _dst->storage_type = _src->storage_type;
987 _dst->sync_status = _src->sync_status;
989 if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
990 _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
991 if(_dst->image_meta == NULL)
993 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
994 media_info_destroy((media_info_h)_dst);
995 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
998 if(STRING_VALID(_src->image_meta->media_id))
1000 _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
1001 if(_dst->image_meta->media_id == NULL)
1003 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1004 media_info_destroy((media_info_h)_dst);
1005 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1009 if(STRING_VALID(_src->image_meta->date_taken))
1011 _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
1012 if(_dst->image_meta->date_taken == NULL)
1014 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1015 media_info_destroy((media_info_h)_dst);
1016 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1020 if(STRING_VALID(_src->image_meta->burst_id))
1022 _dst->image_meta->burst_id = strdup(_src->image_meta->burst_id);
1023 if(_dst->image_meta->burst_id == NULL)
1025 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1026 media_info_destroy((media_info_h)_dst);
1027 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1031 if(STRING_VALID(_src->image_meta->weather))
1033 _dst->image_meta->weather = strdup(_src->image_meta->weather);
1034 if(_dst->image_meta->weather == NULL)
1036 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1037 media_info_destroy((media_info_h)_dst);
1038 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1042 _dst->image_meta->width = _src->image_meta->width;
1043 _dst->image_meta->height = _src->image_meta->height;
1044 _dst->image_meta->orientation = _src->image_meta->orientation;
1046 } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
1047 _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
1048 if(_dst->video_meta == NULL)
1050 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1051 media_info_destroy((media_info_h)_dst);
1052 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1055 if(STRING_VALID(_src->video_meta->media_id))
1057 _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
1058 if(_dst->video_meta->media_id == NULL)
1060 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1061 media_info_destroy((media_info_h)_dst);
1062 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1065 if(STRING_VALID(_src->video_meta->title))
1067 _dst->video_meta->title = strdup(_src->video_meta->title);
1068 if(_dst->video_meta->title == NULL)
1070 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1071 media_info_destroy((media_info_h)_dst);
1072 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1075 if(STRING_VALID(_src->video_meta->album))
1077 _dst->video_meta->album = strdup(_src->video_meta->album);
1078 if(_dst->video_meta->album == NULL)
1080 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1081 media_info_destroy((media_info_h)_dst);
1082 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1085 if(STRING_VALID(_src->video_meta->artist))
1087 _dst->video_meta->artist = strdup(_src->video_meta->artist);
1088 if(_dst->video_meta->artist == NULL)
1090 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1091 media_info_destroy((media_info_h)_dst);
1092 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1095 if(STRING_VALID(_src->video_meta->genre))
1097 _dst->video_meta->genre = strdup(_src->video_meta->genre);
1098 if(_dst->video_meta->genre == NULL)
1100 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1101 media_info_destroy((media_info_h)_dst);
1102 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1105 if(STRING_VALID(_src->video_meta->composer))
1107 _dst->video_meta->composer = strdup(_src->video_meta->composer);
1108 if(_dst->video_meta->composer == NULL)
1110 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1111 media_info_destroy((media_info_h)_dst);
1112 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1115 if(STRING_VALID(_src->video_meta->year))
1117 _dst->video_meta->year = strdup(_src->video_meta->year);
1118 if(_dst->video_meta->year == NULL)
1120 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1121 media_info_destroy((media_info_h)_dst);
1122 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1125 if(STRING_VALID(_src->video_meta->recorded_date))
1127 _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
1128 if(_dst->video_meta->recorded_date == NULL)
1130 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1131 media_info_destroy((media_info_h)_dst);
1132 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1135 if(STRING_VALID(_src->video_meta->copyright))
1137 _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
1138 if(_dst->video_meta->copyright == NULL)
1140 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1141 media_info_destroy((media_info_h)_dst);
1142 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1145 if(STRING_VALID(_src->video_meta->track_num))
1147 _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
1148 if(_dst->video_meta->track_num == NULL)
1150 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1151 media_info_destroy((media_info_h)_dst);
1152 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1156 _dst->video_meta->width = _src->video_meta->width;
1157 _dst->video_meta->height = _src->video_meta->height;
1158 _dst->video_meta->duration = _src->video_meta->duration;
1159 _dst->video_meta->bitrate = _src->video_meta->bitrate;
1160 _dst->video_meta->played_count = _src->video_meta->played_count;
1161 _dst->video_meta->played_time = _src->video_meta->played_time;
1162 _dst->video_meta->played_position = _src->video_meta->played_position;
1164 } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
1165 _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
1166 if(_dst->audio_meta == NULL)
1168 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1169 media_info_destroy((media_info_h)_dst);
1170 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1173 if(STRING_VALID(_src->audio_meta->media_id))
1175 _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
1176 if(_dst->audio_meta->media_id == NULL)
1178 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1179 media_info_destroy((media_info_h)_dst);
1180 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1183 if(STRING_VALID(_src->audio_meta->title))
1185 _dst->audio_meta->title = strdup(_src->audio_meta->title);
1186 if(_dst->audio_meta->title == NULL)
1188 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1189 media_info_destroy((media_info_h)_dst);
1190 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1193 if(STRING_VALID(_src->audio_meta->album))
1195 _dst->audio_meta->album = strdup(_src->audio_meta->album);
1196 if(_dst->audio_meta->album == NULL)
1198 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1199 media_info_destroy((media_info_h)_dst);
1200 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1203 if(STRING_VALID(_src->audio_meta->artist))
1205 _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
1206 if(_dst->audio_meta->artist == NULL)
1208 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1209 media_info_destroy((media_info_h)_dst);
1210 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1213 if(STRING_VALID(_src->audio_meta->genre))
1215 _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
1216 if(_dst->audio_meta->genre == NULL)
1218 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1219 media_info_destroy((media_info_h)_dst);
1220 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1223 if(STRING_VALID(_src->audio_meta->composer))
1225 _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
1226 if(_dst->audio_meta->composer == NULL)
1228 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1229 media_info_destroy((media_info_h)_dst);
1230 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1233 if(STRING_VALID(_src->audio_meta->year))
1235 _dst->audio_meta->year = strdup(_src->audio_meta->year);
1236 if(_dst->audio_meta->year == NULL)
1238 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1239 media_info_destroy((media_info_h)_dst);
1240 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1243 if(STRING_VALID(_src->audio_meta->recorded_date))
1245 _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
1246 if(_dst->audio_meta->recorded_date == NULL)
1248 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1249 media_info_destroy((media_info_h)_dst);
1250 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1253 if(STRING_VALID(_src->audio_meta->copyright))
1255 _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
1256 if(_dst->audio_meta->copyright == NULL)
1258 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1259 media_info_destroy((media_info_h)_dst);
1260 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1263 if(STRING_VALID(_src->audio_meta->track_num))
1265 _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
1266 if(_dst->audio_meta->track_num == NULL)
1268 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1269 media_info_destroy((media_info_h)_dst);
1270 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1274 _dst->audio_meta->channel = _src->audio_meta->channel;
1275 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
1276 _dst->audio_meta->duration = _src->audio_meta->duration;
1277 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
1278 _dst->audio_meta->played_count = _src->audio_meta->played_count;
1279 _dst->audio_meta->played_time = _src->audio_meta->played_time;
1280 _dst->audio_meta->played_position = _src->audio_meta->played_position;
1283 *dst = (media_info_h)_dst;
1285 ret = MEDIA_CONTENT_ERROR_NONE;
1289 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1290 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1296 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1298 int ret = MEDIA_CONTENT_ERROR_NONE;
1300 media_content_debug_func();
1302 if(media_count == NULL)
1304 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1305 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1310 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1315 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1317 int ret = MEDIA_CONTENT_ERROR_NONE;
1319 media_content_debug_func();
1321 if(callback == NULL)
1323 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1324 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1327 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1332 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1334 int ret = MEDIA_CONTENT_ERROR_NONE;
1336 media_content_debug_func();
1338 if(STRING_VALID(media_id) && tag_count)
1340 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1344 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1345 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1351 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1353 int ret = MEDIA_CONTENT_ERROR_NONE;
1355 media_content_debug_func();
1357 if((callback != NULL) && STRING_VALID(media_id))
1359 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1363 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1364 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1370 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1372 int ret = MEDIA_CONTENT_ERROR_NONE;
1374 media_content_debug_func();
1376 if(STRING_VALID(media_id) && bookmark_count)
1378 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1382 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1383 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1389 int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1391 int ret = MEDIA_CONTENT_ERROR_NONE;
1393 media_content_debug_func();
1395 if((callback != NULL) && STRING_VALID(media_id))
1397 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1401 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1402 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1408 int media_info_get_image(media_info_h media, image_meta_h *image)
1410 int ret = MEDIA_CONTENT_ERROR_NONE;
1412 media_info_s *_media = (media_info_s*)media;
1416 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1417 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1420 if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
1422 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1423 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1426 if(_media->image_meta == NULL)
1428 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1429 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1432 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1436 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1437 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1440 if(STRING_VALID(_media->media_id)) {
1441 _image->media_id = strdup(_media->media_id);
1444 _image->width = _media->image_meta->width;
1445 _image->height = _media->image_meta->height;
1446 _image->orientation = _media->image_meta->orientation;
1448 if(STRING_VALID(_media->image_meta->date_taken)) {
1449 _image->date_taken = strdup(_media->image_meta->date_taken);
1452 if(STRING_VALID(_media->image_meta->title)) {
1453 _image->title = strdup(_media->image_meta->title);
1456 if(STRING_VALID(_media->image_meta->burst_id)) {
1457 _image->burst_id = strdup(_media->image_meta->burst_id);
1460 if(STRING_VALID(_media->image_meta->weather)) {
1461 _image->weather = strdup(_media->image_meta->weather);
1464 *image = (image_meta_h)_image;
1469 int media_info_get_video(media_info_h media, video_meta_h *video)
1471 int ret = MEDIA_CONTENT_ERROR_NONE;
1473 media_info_s *_media = (media_info_s*)media;
1477 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1478 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1481 if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
1483 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1484 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1487 if(_media->video_meta == NULL)
1489 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1490 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1493 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1497 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1498 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1501 if(STRING_VALID(_media->media_id)) {
1502 _video->media_id = strdup(_media->media_id);
1505 if(STRING_VALID(_media->video_meta->title)) {
1506 _video->title = strdup(_media->video_meta->title);
1508 if(STRING_VALID(_media->video_meta->album)) {
1509 _video->album = strdup(_media->video_meta->album);
1511 if(STRING_VALID(_media->video_meta->artist)) {
1512 _video->artist = strdup(_media->video_meta->artist);
1514 if(STRING_VALID(_media->video_meta->genre)) {
1515 _video->genre = strdup(_media->video_meta->genre);
1517 if(STRING_VALID(_media->video_meta->composer)) {
1518 _video->composer = strdup(_media->video_meta->composer);
1520 if(STRING_VALID(_media->video_meta->year)) {
1521 _video->year = strdup(_media->video_meta->year);
1523 if(STRING_VALID(_media->video_meta->recorded_date)) {
1524 _video->recorded_date = strdup(_media->video_meta->recorded_date);
1526 if(STRING_VALID(_media->video_meta->copyright)) {
1527 _video->copyright = strdup(_media->video_meta->copyright);
1529 if(STRING_VALID(_media->video_meta->track_num)) {
1530 _video->track_num = strdup(_media->video_meta->track_num);
1533 _video->width = _media->video_meta->width;
1534 _video->height = _media->video_meta->height;
1535 _video->duration = _media->video_meta->duration;
1536 _video->bitrate = _media->video_meta->bitrate;
1537 _video->played_count = _media->video_meta->played_count;
1538 _video->played_time = _media->video_meta->played_time;
1539 _video->played_position = _media->video_meta->played_position;
1541 *video = (video_meta_h)_video;
1546 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1548 int ret = MEDIA_CONTENT_ERROR_NONE;
1550 media_info_s *_media = (media_info_s*)media;
1554 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1555 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1558 if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
1560 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1561 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1564 if(_media->audio_meta == NULL)
1566 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1567 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1570 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1574 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1575 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1578 if(STRING_VALID(_media->media_id)) {
1579 _audio->media_id = strdup(_media->media_id);
1582 if(STRING_VALID(_media->audio_meta->title)) {
1583 _audio->title = strdup(_media->audio_meta->title);
1585 if(STRING_VALID(_media->audio_meta->album)) {
1586 _audio->album = strdup(_media->audio_meta->album);
1588 if(STRING_VALID(_media->audio_meta->artist)) {
1589 _audio->artist = strdup(_media->audio_meta->artist);
1591 if(STRING_VALID(_media->audio_meta->genre)) {
1592 _audio->genre = strdup(_media->audio_meta->genre);
1594 if(STRING_VALID(_media->audio_meta->composer)) {
1595 _audio->composer = strdup(_media->audio_meta->composer);
1597 if(STRING_VALID(_media->audio_meta->year)) {
1598 _audio->year = strdup(_media->audio_meta->year);
1600 if(STRING_VALID(_media->audio_meta->recorded_date)) {
1601 _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
1603 if(STRING_VALID(_media->audio_meta->copyright)) {
1604 _audio->copyright = strdup(_media->audio_meta->copyright);
1606 if(STRING_VALID(_media->audio_meta->track_num)) {
1607 _audio->track_num = strdup(_media->audio_meta->track_num);
1610 _audio->duration = _media->audio_meta->duration;
1611 _audio->bitrate = _media->audio_meta->bitrate;
1612 _audio->samplerate = _media->audio_meta->samplerate;
1613 _audio->channel = _media->audio_meta->channel;
1614 _audio->played_time = _media->audio_meta->played_time;
1615 _audio->played_count = _media->audio_meta->played_count;
1616 _audio->played_position = _media->audio_meta->played_position;
1618 *audio = (audio_meta_h)_audio;
1623 int media_info_get_media_id(media_info_h media, char **media_id)
1625 int ret = MEDIA_CONTENT_ERROR_NONE;
1626 media_info_s *_media = (media_info_s*)media;
1628 if(_media && media_id)
1630 if(STRING_VALID(_media->media_id))
1632 *media_id = strdup(_media->media_id);
1633 if(*media_id == NULL)
1635 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1636 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1643 ret = MEDIA_CONTENT_ERROR_NONE;
1647 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1648 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1654 int media_info_get_file_path(media_info_h media, char **path)
1656 int ret = MEDIA_CONTENT_ERROR_NONE;
1657 media_info_s *_media = (media_info_s*)media;
1661 if(STRING_VALID(_media->file_path))
1663 *path = strdup(_media->file_path);
1666 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1667 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1674 ret = MEDIA_CONTENT_ERROR_NONE;
1679 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1680 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1686 int media_info_get_display_name(media_info_h media, char **name)
1688 int ret = MEDIA_CONTENT_ERROR_NONE;
1689 media_info_s *_media = (media_info_s*)media;
1692 if(STRING_VALID(_media->display_name))
1694 *name = strdup(_media->display_name);
1697 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1698 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1705 ret = MEDIA_CONTENT_ERROR_NONE;
1710 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1711 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1717 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1719 int ret = MEDIA_CONTENT_ERROR_NONE;
1720 media_info_s *_media = (media_info_s*)media;
1723 *type = _media->media_type;
1724 ret = MEDIA_CONTENT_ERROR_NONE;
1728 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1729 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1735 int media_info_get_mime_type(media_info_h media, char **mime_type)
1737 int ret = MEDIA_CONTENT_ERROR_NONE;
1738 media_info_s *_media = (media_info_s*)media;
1740 if(_media && mime_type)
1742 if(STRING_VALID(_media->mime_type))
1744 *mime_type = strdup(_media->mime_type);
1745 if(*mime_type == NULL)
1747 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1748 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1755 ret = MEDIA_CONTENT_ERROR_NONE;
1759 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1760 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1766 int media_info_get_size(media_info_h media, unsigned long long *size)
1768 int ret = MEDIA_CONTENT_ERROR_NONE;
1769 media_info_s *_media = (media_info_s*)media;
1773 *size = _media->size;
1774 ret = MEDIA_CONTENT_ERROR_NONE;
1778 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1779 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1785 int media_info_get_added_time(media_info_h media, time_t *added_time)
1787 int ret = MEDIA_CONTENT_ERROR_NONE;
1788 media_info_s *_media = (media_info_s*)media;
1789 if(_media && added_time)
1791 *added_time = _media->added_time;
1792 ret = MEDIA_CONTENT_ERROR_NONE;
1796 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1797 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1803 int media_info_get_modified_time(media_info_h media, time_t* time)
1805 int ret = MEDIA_CONTENT_ERROR_NONE;
1806 media_info_s *_media = (media_info_s*)media;
1809 *time = _media->modified_time;
1810 ret = MEDIA_CONTENT_ERROR_NONE;
1814 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1815 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1821 int media_info_get_timeline(media_info_h media, time_t* time)
1823 int ret = MEDIA_CONTENT_ERROR_NONE;
1824 media_info_s *_media = (media_info_s*)media;
1827 *time = _media->timeline;
1828 ret = MEDIA_CONTENT_ERROR_NONE;
1832 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1833 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1839 int media_info_get_thumbnail_path(media_info_h media, char **path)
1841 int ret = MEDIA_CONTENT_ERROR_NONE;
1842 media_info_s *_media = (media_info_s*)media;
1845 if(STRING_VALID(_media->thumbnail_path))
1847 *path = strdup(_media->thumbnail_path);
1850 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1851 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1858 ret = MEDIA_CONTENT_ERROR_NONE;
1863 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1864 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1870 int media_info_get_title(media_info_h media, char **title)
1872 int ret = MEDIA_CONTENT_ERROR_NONE;
1873 media_info_s *_media = (media_info_s*)media;
1877 if(STRING_VALID(_media->title))
1879 *title = strdup(_media->title);
1882 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1883 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1890 ret = MEDIA_CONTENT_ERROR_NONE;
1894 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1895 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1901 int media_info_get_description(media_info_h media, char **description)
1903 int ret = MEDIA_CONTENT_ERROR_NONE;
1904 media_info_s *_media = (media_info_s*)media;
1906 if(_media && description)
1908 if(STRING_VALID(_media->description))
1910 *description = strdup(_media->description);
1911 if(*description == NULL)
1913 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1914 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1919 *description = NULL;
1921 ret = MEDIA_CONTENT_ERROR_NONE;
1925 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1926 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1932 int media_info_get_longitude(media_info_h media, double* longitude)
1934 int ret = MEDIA_CONTENT_ERROR_NONE;
1935 media_info_s *_media = (media_info_s*)media;
1937 if(_media && longitude)
1939 *longitude = _media->longitude;
1940 ret = MEDIA_CONTENT_ERROR_NONE;
1944 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1945 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1950 int media_info_get_latitude(media_info_h media, double* latitude)
1952 int ret = MEDIA_CONTENT_ERROR_NONE;
1953 media_info_s *_media = (media_info_s*)media;
1955 if(_media && latitude)
1957 *latitude = _media->latitude;
1958 ret = MEDIA_CONTENT_ERROR_NONE;
1962 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1963 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1969 int media_info_get_altitude(media_info_h media, double *altitude)
1971 int ret = MEDIA_CONTENT_ERROR_NONE;
1972 media_info_s *_media = (media_info_s*)media;
1974 if(_media && altitude)
1976 *altitude = _media->altitude;
1977 ret = MEDIA_CONTENT_ERROR_NONE;
1981 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1982 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1988 int media_info_get_weather(media_info_h media, char **weather)
1990 int ret = MEDIA_CONTENT_ERROR_NONE;
1991 media_info_s *_media = (media_info_s*)media;
1993 if(_media && weather)
1995 if(STRING_VALID(_media->weather))
1997 *weather = strdup(_media->weather);
1998 if(*weather == NULL)
2000 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2001 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2008 ret = MEDIA_CONTENT_ERROR_NONE;
2012 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2013 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2019 int media_info_get_rating(media_info_h media, int *rating)
2021 int ret = MEDIA_CONTENT_ERROR_NONE;
2022 media_info_s *_media = (media_info_s*)media;
2024 if(_media && rating)
2026 *rating = _media->rating;
2027 ret = MEDIA_CONTENT_ERROR_NONE;
2031 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2032 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2038 int media_info_get_favorite(media_info_h media, bool* favorite)
2040 int ret = MEDIA_CONTENT_ERROR_NONE;
2041 media_info_s *_media = (media_info_s*)media;
2043 if(_media && favorite)
2046 *favorite = _media->favourite;
2047 ret = MEDIA_CONTENT_ERROR_NONE;
2051 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2052 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2058 int media_info_get_author(media_info_h media, char **author)
2060 int ret = MEDIA_CONTENT_ERROR_NONE;
2061 media_info_s *_media = (media_info_s*)media;
2063 if(_media && author)
2065 if(STRING_VALID(_media->author))
2067 *author = strdup(_media->author);
2070 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2071 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2078 ret = MEDIA_CONTENT_ERROR_NONE;
2082 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2083 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2089 int media_info_get_provider(media_info_h media, char **provider)
2091 int ret = MEDIA_CONTENT_ERROR_NONE;
2092 media_info_s *_media = (media_info_s*)media;
2094 if(_media && provider)
2096 if(STRING_VALID(_media->provider))
2098 *provider = strdup(_media->provider);
2099 if(*provider == NULL)
2101 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2102 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2109 ret = MEDIA_CONTENT_ERROR_NONE;
2113 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2114 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2120 int media_info_get_content_name(media_info_h media, char **content_name)
2122 int ret = MEDIA_CONTENT_ERROR_NONE;
2123 media_info_s *_media = (media_info_s*)media;
2125 if(_media && content_name)
2127 if(STRING_VALID(_media->content_name))
2129 *content_name = strdup(_media->content_name);
2130 if(*content_name == NULL)
2132 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2133 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2138 *content_name = NULL;
2140 ret = MEDIA_CONTENT_ERROR_NONE;
2144 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2145 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2151 int media_info_get_category(media_info_h media, char **category)
2153 int ret = MEDIA_CONTENT_ERROR_NONE;
2154 media_info_s *_media = (media_info_s*)media;
2156 if(_media && category)
2158 if(STRING_VALID(_media->category))
2160 *category = strdup(_media->category);
2161 if(*category == NULL)
2163 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2164 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2171 ret = MEDIA_CONTENT_ERROR_NONE;
2175 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2176 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2182 int media_info_get_location_tag(media_info_h media, char **location_tag)
2184 int ret = MEDIA_CONTENT_ERROR_NONE;
2185 media_info_s *_media = (media_info_s*)media;
2187 if(_media && location_tag)
2189 if(STRING_VALID(_media->location_tag))
2191 *location_tag = strdup(_media->location_tag);
2192 if(*location_tag == NULL)
2194 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2195 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2200 *location_tag = NULL;
2202 ret = MEDIA_CONTENT_ERROR_NONE;
2206 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2207 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2213 int media_info_get_age_rating(media_info_h media, char **age_rating)
2215 int ret = MEDIA_CONTENT_ERROR_NONE;
2216 media_info_s *_media = (media_info_s*)media;
2218 if(_media && age_rating)
2220 if(STRING_VALID(_media->age_rating))
2222 *age_rating = strdup(_media->age_rating);
2223 if(*age_rating == NULL)
2225 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2226 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2233 ret = MEDIA_CONTENT_ERROR_NONE;
2237 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2238 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2244 int media_info_get_keyword(media_info_h media, char **keyword)
2246 int ret = MEDIA_CONTENT_ERROR_NONE;
2247 media_info_s *_media = (media_info_s*)media;
2249 if(_media && keyword)
2251 if(STRING_VALID(_media->keyword))
2253 *keyword = strdup(_media->keyword);
2254 if(*keyword == NULL)
2256 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2257 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2264 ret = MEDIA_CONTENT_ERROR_NONE;
2268 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2269 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2275 int media_info_is_drm(media_info_h media, bool *is_drm)
2277 int ret = MEDIA_CONTENT_ERROR_NONE;
2278 media_info_s *_media = (media_info_s*)media;
2282 *is_drm = _media->is_drm;
2283 ret = MEDIA_CONTENT_ERROR_NONE;
2287 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2288 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2294 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
2296 int ret = MEDIA_CONTENT_ERROR_NONE;
2297 media_info_s *_media = (media_info_s*)media;
2299 if(_media && storage_type)
2301 *storage_type = _media->storage_type;
2302 ret = MEDIA_CONTENT_ERROR_NONE;
2306 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2307 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2313 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
2315 int ret = MEDIA_CONTENT_ERROR_NONE;
2316 int ret_view = MEDIA_CONTENT_ERROR_NONE;
2317 char select_query[DEFAULT_QUERY_SIZE];
2318 sqlite3_stmt *stmt = NULL;
2320 if(!STRING_VALID(media_id) || (media == NULL))
2322 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2323 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2326 memset(select_query, 0x00, sizeof(select_query));
2328 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
2329 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
2330 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2332 while(sqlite3_step(stmt) == SQLITE_ROW)
2334 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
2338 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2339 SQLITE3_FINALIZE(stmt);
2340 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2343 _media_info_item_get_detail(stmt, (media_info_h)_media);
2345 *media = (media_info_h)_media;
2348 SQLITE3_FINALIZE(stmt);
2352 int media_info_set_display_name(media_info_h media, const char *display_name)
2354 int ret = MEDIA_CONTENT_ERROR_NONE;
2355 media_info_s *_media = (media_info_s*)media;
2357 if(_media != NULL && STRING_VALID(display_name))
2359 SAFE_FREE(_media->display_name);
2361 _media->display_name = strdup(display_name);
2362 if(_media->display_name == NULL)
2364 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2365 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
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_description(media_info_h media, const char *description)
2379 int ret = MEDIA_CONTENT_ERROR_NONE;
2380 media_info_s *_media = (media_info_s*)media;
2384 SAFE_FREE(_media->description);
2386 if(STRING_VALID(description))
2388 _media->description = strdup(description);
2390 if(_media->description == NULL)
2392 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2393 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2398 _media->description = NULL;
2403 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2404 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2410 int media_info_set_longitude(media_info_h media, double longitude)
2412 int ret = MEDIA_CONTENT_ERROR_NONE;
2413 media_info_s *_media = (media_info_s*)media;
2417 _media->longitude = longitude;
2421 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2422 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2428 int media_info_set_latitude(media_info_h media, double latitude)
2430 int ret = MEDIA_CONTENT_ERROR_NONE;
2431 media_info_s *_media = (media_info_s*)media;
2435 _media->latitude = latitude;
2439 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2440 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2446 int media_info_set_altitude(media_info_h media, double altitude)
2448 int ret = MEDIA_CONTENT_ERROR_NONE;
2449 media_info_s *_media = (media_info_s*)media;
2453 _media->altitude = altitude;
2457 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2458 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2464 int media_info_set_weather(media_info_h media, const char *weather)
2466 int ret = MEDIA_CONTENT_ERROR_NONE;
2467 media_info_s *_media = (media_info_s*)media;
2471 SAFE_FREE(_media->weather);
2473 if(STRING_VALID(weather))
2475 _media->weather = strdup(weather);
2477 if(_media->weather == NULL)
2479 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2480 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2485 _media->weather = NULL;
2490 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2491 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2497 int media_info_set_rating(media_info_h media, int rating)
2499 int ret = MEDIA_CONTENT_ERROR_NONE;
2500 media_info_s *_media = (media_info_s*)media;
2504 _media->rating = rating;
2508 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2509 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2515 int media_info_set_added_time(media_info_h media, time_t added_time)
2517 int ret = MEDIA_CONTENT_ERROR_NONE;
2519 media_info_s *_media = (media_info_s*)media;
2521 if((_media != NULL) && (added_time >= 0))
2523 _media->added_time = added_time;
2527 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2528 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2534 int media_info_set_favorite(media_info_h media, bool favorite)
2536 int ret = MEDIA_CONTENT_ERROR_NONE;
2537 media_info_s *_media = (media_info_s*)media;
2541 _media->favourite = favorite;
2545 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2546 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2552 int media_info_set_author(media_info_h media, const char *author)
2554 int ret = MEDIA_CONTENT_ERROR_NONE;
2555 media_info_s *_media = (media_info_s*)media;
2559 if(STRING_VALID(author))
2561 _media->author = strdup(author);
2562 if(_media->author == NULL)
2564 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2565 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2570 _media->author = NULL;
2575 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2576 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2582 int media_info_set_provider(media_info_h media, const char *provider)
2584 int ret = MEDIA_CONTENT_ERROR_NONE;
2585 media_info_s *_media = (media_info_s*)media;
2589 SAFE_FREE(_media->provider);
2591 if(STRING_VALID(provider))
2593 _media->provider = strdup(provider);
2594 if(_media->provider == NULL)
2596 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2597 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2602 _media->provider = NULL;
2607 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2608 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2614 int media_info_set_content_name(media_info_h media, const char *content_name)
2616 int ret = MEDIA_CONTENT_ERROR_NONE;
2617 media_info_s *_media = (media_info_s*)media;
2621 SAFE_FREE(_media->content_name);
2623 if(STRING_VALID(content_name))
2625 _media->content_name = strdup(content_name);
2626 if(_media->content_name == NULL)
2628 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2629 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2634 _media->content_name = NULL;
2639 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2640 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2646 int media_info_set_category(media_info_h media, const char *category)
2648 int ret = MEDIA_CONTENT_ERROR_NONE;
2649 media_info_s *_media = (media_info_s*)media;
2653 SAFE_FREE(_media->category);
2655 if(STRING_VALID(category))
2657 _media->category = strdup(category);
2658 if(_media->category == NULL)
2660 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2661 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2666 _media->category = NULL;
2671 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2672 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2678 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2680 int ret = MEDIA_CONTENT_ERROR_NONE;
2681 media_info_s *_media = (media_info_s*)media;
2685 SAFE_FREE(_media->location_tag);
2687 if(STRING_VALID(location_tag))
2689 _media->location_tag = strdup(location_tag);
2690 if(_media->location_tag == NULL)
2692 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2693 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2698 _media->location_tag = NULL;
2703 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2704 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2710 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2712 int ret = MEDIA_CONTENT_ERROR_NONE;
2713 media_info_s *_media = (media_info_s*)media;
2717 SAFE_FREE(_media->age_rating);
2719 if(STRING_VALID(age_rating))
2721 _media->age_rating = strdup(age_rating);
2722 if(_media->age_rating == NULL)
2724 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2725 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2730 _media->age_rating = NULL;
2735 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2736 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2742 int media_info_set_keyword(media_info_h media, const char *keyword)
2744 int ret = MEDIA_CONTENT_ERROR_NONE;
2745 media_info_s *_media = (media_info_s*)media;
2749 SAFE_FREE(_media->keyword);
2751 if(STRING_VALID(keyword))
2753 _media->keyword = strdup(keyword);
2754 if(_media->keyword == NULL)
2756 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2757 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2762 _media->keyword = NULL;
2767 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2768 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2774 int media_info_update_to_db(media_info_h media)
2776 int ret = MEDIA_CONTENT_ERROR_NONE;
2778 media_info_s *_media = (media_info_s*)media;
2779 char *set_sql = NULL;
2780 char sql[MAX_QUERY_SIZE];
2781 memset(sql, '\0', sizeof(sql));
2783 if(_media != NULL && STRING_VALID(_media->media_id))
2785 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2786 /* This code will be removed when sqlite3_mprintf works clearly */
2787 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2788 sqlite3_free(test_sql);
2790 /*Update Pinyin If Support Pinyin*/
2791 char *file_name_pinyin = NULL;
2792 char *description_pinyin = NULL;
2793 char *author_pinyin = NULL;
2794 char *provider_pinyin = NULL;
2795 char *content_name_pinyin = NULL;
2796 char *category_pinyin = NULL;
2797 char *location_tag_pinyin = NULL;
2798 char *age_rating_pinyin = NULL;
2799 char *keyword_pinyin = NULL;
2800 bool pinyin_support = FALSE;
2802 /*Update Pinyin If Support Pinyin*/
2803 media_svc_check_pinyin_support(&pinyin_support);
2806 if(STRING_VALID(_media->display_name))
2807 media_svc_get_pinyin(_content_get_db_handle(), _media->display_name, &file_name_pinyin);
2808 if(STRING_VALID(_media->description))
2809 media_svc_get_pinyin(_content_get_db_handle(), _media->description, &description_pinyin);
2810 if(STRING_VALID(_media->author))
2811 media_svc_get_pinyin(_content_get_db_handle(), _media->author, &author_pinyin);
2812 if(STRING_VALID(_media->provider))
2813 media_svc_get_pinyin(_content_get_db_handle(), _media->provider, &provider_pinyin);
2814 if(STRING_VALID(_media->content_name))
2815 media_svc_get_pinyin(_content_get_db_handle(), _media->content_name, &content_name_pinyin);
2816 if(STRING_VALID(_media->category))
2817 media_svc_get_pinyin(_content_get_db_handle(), _media->category, &category_pinyin);
2818 if(STRING_VALID(_media->location_tag))
2819 media_svc_get_pinyin(_content_get_db_handle(), _media->location_tag, &location_tag_pinyin);
2820 if(STRING_VALID(_media->age_rating))
2821 media_svc_get_pinyin(_content_get_db_handle(), _media->age_rating, &age_rating_pinyin);
2822 if(STRING_VALID(_media->keyword))
2823 media_svc_get_pinyin(_content_get_db_handle(), _media->keyword, &keyword_pinyin);
2826 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2827 rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q, weather=%Q, sync_status=%d, \
2828 file_name_pinyin=%Q, description_pinyin=%Q, author_pinyin=%Q, provider_pinyin=%Q, content_name_pinyin=%Q, category_pinyin=%Q, location_tag_pinyin=%Q, age_rating_pinyin=%Q, keyword_pinyin=%Q",
2829 _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite,
2830 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2831 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin);
2833 len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
2834 sqlite3_free(set_sql);
2836 SAFE_FREE(description_pinyin);
2837 SAFE_FREE(author_pinyin);
2838 SAFE_FREE(provider_pinyin);
2839 SAFE_FREE(content_name_pinyin);
2840 SAFE_FREE(category_pinyin);
2841 SAFE_FREE(location_tag_pinyin);
2842 SAFE_FREE(age_rating_pinyin);
2843 SAFE_FREE(keyword_pinyin);
2848 media_content_error("snprintf failed");
2849 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2853 ret = _content_query_sql(sql);
2854 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2855 /* Send notification for this update */
2856 media_content_debug("Update is successfull. Send notification for this");
2857 if (_media->file_path && _media->mime_type) {
2858 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);
2860 media_content_error("Can't media_db_update_send : path or mime type is NULL");
2866 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2867 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2873 int media_info_refresh_metadata_to_db(const char *media_id)
2875 int ret = MEDIA_CONTENT_ERROR_NONE;
2876 media_info_h media = NULL;
2877 char *file_path = NULL;
2878 media_content_storage_e storage_type = 0;
2880 if(!STRING_VALID(media_id))
2882 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2883 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2886 ret = media_info_get_media_from_db(media_id, &media);
2887 if(ret != MEDIA_CONTENT_ERROR_NONE)
2889 media_info_destroy(media);
2893 ret = media_info_get_storage_type(media, &storage_type);
2894 if(ret != MEDIA_CONTENT_ERROR_NONE)
2896 media_info_destroy(media);
2900 ret = media_info_get_file_path(media, &file_path);
2901 if(ret != MEDIA_CONTENT_ERROR_NONE)
2903 media_info_destroy(media);
2907 ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
2909 SAFE_FREE(file_path);
2910 media_info_destroy(media);
2915 int media_info_move_to_db(media_info_h media, const char* dst_path)
2917 int ret = MEDIA_CONTENT_ERROR_NONE;
2919 int src_storage_type = 0;
2920 int dst_storage_type = 0;
2922 if(media == NULL || !STRING_VALID(dst_path))
2924 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2925 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2928 media_info_s *_media = (media_info_s*)media;
2930 ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2931 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2932 ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2933 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2935 ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path, tzplatform_getuid(TZ_USER_NAME));
2936 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2939 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2941 int ret = MEDIA_CONTENT_ERROR_NONE;
2942 media_info_s *_media = (media_info_s*)media;
2944 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2946 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2947 _thumb_cb->handle = _media;
2948 _thumb_cb->user_data = user_data;
2949 _thumb_cb->thumbnail_completed_cb = callback;
2951 ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
2952 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2956 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2957 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2963 int media_info_cancel_thumbnail(media_info_h media)
2965 int ret = MEDIA_CONTENT_ERROR_NONE;
2966 media_info_s *_media = (media_info_s*)media;
2968 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2970 ret = thumbnail_request_cancel_media(_media->file_path, tzplatform_getuid(TZ_USER_NAME));
2971 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2975 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2976 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;