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->bitpersample = _src->audio_meta->bitpersample;
1279 _dst->audio_meta->played_count = _src->audio_meta->played_count;
1280 _dst->audio_meta->played_time = _src->audio_meta->played_time;
1281 _dst->audio_meta->played_position = _src->audio_meta->played_position;
1284 *dst = (media_info_h)_dst;
1286 ret = MEDIA_CONTENT_ERROR_NONE;
1290 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1291 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1297 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1299 int ret = MEDIA_CONTENT_ERROR_NONE;
1301 media_content_debug_func();
1303 if(media_count == NULL)
1305 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1306 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1311 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1316 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1318 int ret = MEDIA_CONTENT_ERROR_NONE;
1320 media_content_debug_func();
1322 if(callback == NULL)
1324 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1325 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1328 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1333 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1335 int ret = MEDIA_CONTENT_ERROR_NONE;
1337 media_content_debug_func();
1339 if(STRING_VALID(media_id) && tag_count)
1341 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1345 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1346 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1352 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1354 int ret = MEDIA_CONTENT_ERROR_NONE;
1356 media_content_debug_func();
1358 if((callback != NULL) && STRING_VALID(media_id))
1360 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1364 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1365 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1371 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1373 int ret = MEDIA_CONTENT_ERROR_NONE;
1375 media_content_debug_func();
1377 if(STRING_VALID(media_id) && bookmark_count)
1379 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1383 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1384 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1390 int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1392 int ret = MEDIA_CONTENT_ERROR_NONE;
1394 media_content_debug_func();
1396 if((callback != NULL) && STRING_VALID(media_id))
1398 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1402 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1403 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1409 int media_info_get_image(media_info_h media, image_meta_h *image)
1411 int ret = MEDIA_CONTENT_ERROR_NONE;
1413 media_info_s *_media = (media_info_s*)media;
1417 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1418 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1421 if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
1423 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1424 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1427 if(_media->image_meta == NULL)
1429 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1430 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1433 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1437 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1438 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1441 if(STRING_VALID(_media->media_id)) {
1442 _image->media_id = strdup(_media->media_id);
1445 _image->width = _media->image_meta->width;
1446 _image->height = _media->image_meta->height;
1447 _image->orientation = _media->image_meta->orientation;
1449 if(STRING_VALID(_media->image_meta->date_taken)) {
1450 _image->date_taken = strdup(_media->image_meta->date_taken);
1453 if(STRING_VALID(_media->image_meta->title)) {
1454 _image->title = strdup(_media->image_meta->title);
1457 if(STRING_VALID(_media->image_meta->burst_id)) {
1458 _image->burst_id = strdup(_media->image_meta->burst_id);
1461 if(STRING_VALID(_media->image_meta->weather)) {
1462 _image->weather = strdup(_media->image_meta->weather);
1465 *image = (image_meta_h)_image;
1470 int media_info_get_video(media_info_h media, video_meta_h *video)
1472 int ret = MEDIA_CONTENT_ERROR_NONE;
1474 media_info_s *_media = (media_info_s*)media;
1478 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1479 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1482 if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
1484 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1485 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1488 if(_media->video_meta == NULL)
1490 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1491 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1494 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1498 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1499 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1502 if(STRING_VALID(_media->media_id)) {
1503 _video->media_id = strdup(_media->media_id);
1506 if(STRING_VALID(_media->video_meta->title)) {
1507 _video->title = strdup(_media->video_meta->title);
1509 if(STRING_VALID(_media->video_meta->album)) {
1510 _video->album = strdup(_media->video_meta->album);
1512 if(STRING_VALID(_media->video_meta->artist)) {
1513 _video->artist = strdup(_media->video_meta->artist);
1515 if(STRING_VALID(_media->video_meta->genre)) {
1516 _video->genre = strdup(_media->video_meta->genre);
1518 if(STRING_VALID(_media->video_meta->composer)) {
1519 _video->composer = strdup(_media->video_meta->composer);
1521 if(STRING_VALID(_media->video_meta->year)) {
1522 _video->year = strdup(_media->video_meta->year);
1524 if(STRING_VALID(_media->video_meta->recorded_date)) {
1525 _video->recorded_date = strdup(_media->video_meta->recorded_date);
1527 if(STRING_VALID(_media->video_meta->copyright)) {
1528 _video->copyright = strdup(_media->video_meta->copyright);
1530 if(STRING_VALID(_media->video_meta->track_num)) {
1531 _video->track_num = strdup(_media->video_meta->track_num);
1534 _video->width = _media->video_meta->width;
1535 _video->height = _media->video_meta->height;
1536 _video->duration = _media->video_meta->duration;
1537 _video->bitrate = _media->video_meta->bitrate;
1538 _video->played_count = _media->video_meta->played_count;
1539 _video->played_time = _media->video_meta->played_time;
1540 _video->played_position = _media->video_meta->played_position;
1542 *video = (video_meta_h)_video;
1547 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1549 int ret = MEDIA_CONTENT_ERROR_NONE;
1551 media_info_s *_media = (media_info_s*)media;
1555 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1556 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1559 if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
1561 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1562 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1565 if(_media->audio_meta == NULL)
1567 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1568 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1571 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1575 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1576 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1579 if(STRING_VALID(_media->media_id)) {
1580 _audio->media_id = strdup(_media->media_id);
1583 if(STRING_VALID(_media->audio_meta->title)) {
1584 _audio->title = strdup(_media->audio_meta->title);
1586 if(STRING_VALID(_media->audio_meta->album)) {
1587 _audio->album = strdup(_media->audio_meta->album);
1589 if(STRING_VALID(_media->audio_meta->artist)) {
1590 _audio->artist = strdup(_media->audio_meta->artist);
1592 if(STRING_VALID(_media->audio_meta->genre)) {
1593 _audio->genre = strdup(_media->audio_meta->genre);
1595 if(STRING_VALID(_media->audio_meta->composer)) {
1596 _audio->composer = strdup(_media->audio_meta->composer);
1598 if(STRING_VALID(_media->audio_meta->year)) {
1599 _audio->year = strdup(_media->audio_meta->year);
1601 if(STRING_VALID(_media->audio_meta->recorded_date)) {
1602 _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
1604 if(STRING_VALID(_media->audio_meta->copyright)) {
1605 _audio->copyright = strdup(_media->audio_meta->copyright);
1607 if(STRING_VALID(_media->audio_meta->track_num)) {
1608 _audio->track_num = strdup(_media->audio_meta->track_num);
1611 _audio->duration = _media->audio_meta->duration;
1612 _audio->bitrate = _media->audio_meta->bitrate;
1613 _audio->bitpersample = _media->audio_meta->bitpersample;
1614 _audio->samplerate = _media->audio_meta->samplerate;
1615 _audio->channel = _media->audio_meta->channel;
1616 _audio->played_time = _media->audio_meta->played_time;
1617 _audio->played_count = _media->audio_meta->played_count;
1618 _audio->played_position = _media->audio_meta->played_position;
1620 *audio = (audio_meta_h)_audio;
1625 int media_info_get_media_id(media_info_h media, char **media_id)
1627 int ret = MEDIA_CONTENT_ERROR_NONE;
1628 media_info_s *_media = (media_info_s*)media;
1630 if(_media && media_id)
1632 if(STRING_VALID(_media->media_id))
1634 *media_id = strdup(_media->media_id);
1635 if(*media_id == NULL)
1637 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1638 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1645 ret = MEDIA_CONTENT_ERROR_NONE;
1649 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1650 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1656 int media_info_get_file_path(media_info_h media, char **path)
1658 int ret = MEDIA_CONTENT_ERROR_NONE;
1659 media_info_s *_media = (media_info_s*)media;
1663 if(STRING_VALID(_media->file_path))
1665 *path = strdup(_media->file_path);
1668 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1669 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1676 ret = MEDIA_CONTENT_ERROR_NONE;
1681 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1682 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1688 int media_info_get_display_name(media_info_h media, char **name)
1690 int ret = MEDIA_CONTENT_ERROR_NONE;
1691 media_info_s *_media = (media_info_s*)media;
1694 if(STRING_VALID(_media->display_name))
1696 *name = strdup(_media->display_name);
1699 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1700 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1707 ret = MEDIA_CONTENT_ERROR_NONE;
1712 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1713 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1719 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1721 int ret = MEDIA_CONTENT_ERROR_NONE;
1722 media_info_s *_media = (media_info_s*)media;
1725 *type = _media->media_type;
1726 ret = MEDIA_CONTENT_ERROR_NONE;
1730 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1731 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1737 int media_info_get_mime_type(media_info_h media, char **mime_type)
1739 int ret = MEDIA_CONTENT_ERROR_NONE;
1740 media_info_s *_media = (media_info_s*)media;
1742 if(_media && mime_type)
1744 if(STRING_VALID(_media->mime_type))
1746 *mime_type = strdup(_media->mime_type);
1747 if(*mime_type == NULL)
1749 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1750 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1757 ret = MEDIA_CONTENT_ERROR_NONE;
1761 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1762 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1768 int media_info_get_size(media_info_h media, unsigned long long *size)
1770 int ret = MEDIA_CONTENT_ERROR_NONE;
1771 media_info_s *_media = (media_info_s*)media;
1775 *size = _media->size;
1776 ret = MEDIA_CONTENT_ERROR_NONE;
1780 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1781 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1787 int media_info_get_added_time(media_info_h media, time_t *added_time)
1789 int ret = MEDIA_CONTENT_ERROR_NONE;
1790 media_info_s *_media = (media_info_s*)media;
1791 if(_media && added_time)
1793 *added_time = _media->added_time;
1794 ret = MEDIA_CONTENT_ERROR_NONE;
1798 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1799 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1805 int media_info_get_modified_time(media_info_h media, time_t* time)
1807 int ret = MEDIA_CONTENT_ERROR_NONE;
1808 media_info_s *_media = (media_info_s*)media;
1811 *time = _media->modified_time;
1812 ret = MEDIA_CONTENT_ERROR_NONE;
1816 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1817 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1823 int media_info_get_timeline(media_info_h media, time_t* time)
1825 int ret = MEDIA_CONTENT_ERROR_NONE;
1826 media_info_s *_media = (media_info_s*)media;
1829 *time = _media->timeline;
1830 ret = MEDIA_CONTENT_ERROR_NONE;
1834 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1835 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1841 int media_info_get_thumbnail_path(media_info_h media, char **path)
1843 int ret = MEDIA_CONTENT_ERROR_NONE;
1844 media_info_s *_media = (media_info_s*)media;
1847 if(STRING_VALID(_media->thumbnail_path))
1849 *path = strdup(_media->thumbnail_path);
1852 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1853 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1860 ret = MEDIA_CONTENT_ERROR_NONE;
1865 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1866 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1872 int media_info_get_title(media_info_h media, char **title)
1874 int ret = MEDIA_CONTENT_ERROR_NONE;
1875 media_info_s *_media = (media_info_s*)media;
1879 if(STRING_VALID(_media->title))
1881 *title = strdup(_media->title);
1884 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1885 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1892 ret = MEDIA_CONTENT_ERROR_NONE;
1896 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1897 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1903 int media_info_get_description(media_info_h media, char **description)
1905 int ret = MEDIA_CONTENT_ERROR_NONE;
1906 media_info_s *_media = (media_info_s*)media;
1908 if(_media && description)
1910 if(STRING_VALID(_media->description))
1912 *description = strdup(_media->description);
1913 if(*description == NULL)
1915 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1916 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1921 *description = NULL;
1923 ret = MEDIA_CONTENT_ERROR_NONE;
1927 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1928 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1934 int media_info_get_longitude(media_info_h media, double* longitude)
1936 int ret = MEDIA_CONTENT_ERROR_NONE;
1937 media_info_s *_media = (media_info_s*)media;
1939 if(_media && longitude)
1941 *longitude = _media->longitude;
1942 ret = MEDIA_CONTENT_ERROR_NONE;
1946 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1947 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1952 int media_info_get_latitude(media_info_h media, double* latitude)
1954 int ret = MEDIA_CONTENT_ERROR_NONE;
1955 media_info_s *_media = (media_info_s*)media;
1957 if(_media && latitude)
1959 *latitude = _media->latitude;
1960 ret = MEDIA_CONTENT_ERROR_NONE;
1964 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1965 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1971 int media_info_get_altitude(media_info_h media, double *altitude)
1973 int ret = MEDIA_CONTENT_ERROR_NONE;
1974 media_info_s *_media = (media_info_s*)media;
1976 if(_media && altitude)
1978 *altitude = _media->altitude;
1979 ret = MEDIA_CONTENT_ERROR_NONE;
1983 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1984 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1990 int media_info_get_weather(media_info_h media, char **weather)
1992 int ret = MEDIA_CONTENT_ERROR_NONE;
1993 media_info_s *_media = (media_info_s*)media;
1995 if(_media && weather)
1997 if(STRING_VALID(_media->weather))
1999 *weather = strdup(_media->weather);
2000 if(*weather == NULL)
2002 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2003 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2010 ret = MEDIA_CONTENT_ERROR_NONE;
2014 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2015 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2021 int media_info_get_rating(media_info_h media, int *rating)
2023 int ret = MEDIA_CONTENT_ERROR_NONE;
2024 media_info_s *_media = (media_info_s*)media;
2026 if(_media && rating)
2028 *rating = _media->rating;
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_favorite(media_info_h media, bool* favorite)
2042 int ret = MEDIA_CONTENT_ERROR_NONE;
2043 media_info_s *_media = (media_info_s*)media;
2045 if(_media && favorite)
2048 *favorite = _media->favourite;
2049 ret = MEDIA_CONTENT_ERROR_NONE;
2053 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2054 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2060 int media_info_get_author(media_info_h media, char **author)
2062 int ret = MEDIA_CONTENT_ERROR_NONE;
2063 media_info_s *_media = (media_info_s*)media;
2065 if(_media && author)
2067 if(STRING_VALID(_media->author))
2069 *author = strdup(_media->author);
2072 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2073 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2080 ret = MEDIA_CONTENT_ERROR_NONE;
2084 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2085 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2091 int media_info_get_provider(media_info_h media, char **provider)
2093 int ret = MEDIA_CONTENT_ERROR_NONE;
2094 media_info_s *_media = (media_info_s*)media;
2096 if(_media && provider)
2098 if(STRING_VALID(_media->provider))
2100 *provider = strdup(_media->provider);
2101 if(*provider == NULL)
2103 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2104 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2111 ret = MEDIA_CONTENT_ERROR_NONE;
2115 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2116 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2122 int media_info_get_content_name(media_info_h media, char **content_name)
2124 int ret = MEDIA_CONTENT_ERROR_NONE;
2125 media_info_s *_media = (media_info_s*)media;
2127 if(_media && content_name)
2129 if(STRING_VALID(_media->content_name))
2131 *content_name = strdup(_media->content_name);
2132 if(*content_name == NULL)
2134 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2135 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2140 *content_name = NULL;
2142 ret = MEDIA_CONTENT_ERROR_NONE;
2146 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2147 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2153 int media_info_get_category(media_info_h media, char **category)
2155 int ret = MEDIA_CONTENT_ERROR_NONE;
2156 media_info_s *_media = (media_info_s*)media;
2158 if(_media && category)
2160 if(STRING_VALID(_media->category))
2162 *category = strdup(_media->category);
2163 if(*category == NULL)
2165 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2166 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2173 ret = MEDIA_CONTENT_ERROR_NONE;
2177 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2178 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2184 int media_info_get_location_tag(media_info_h media, char **location_tag)
2186 int ret = MEDIA_CONTENT_ERROR_NONE;
2187 media_info_s *_media = (media_info_s*)media;
2189 if(_media && location_tag)
2191 if(STRING_VALID(_media->location_tag))
2193 *location_tag = strdup(_media->location_tag);
2194 if(*location_tag == NULL)
2196 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2197 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2202 *location_tag = NULL;
2204 ret = MEDIA_CONTENT_ERROR_NONE;
2208 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2209 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2215 int media_info_get_age_rating(media_info_h media, char **age_rating)
2217 int ret = MEDIA_CONTENT_ERROR_NONE;
2218 media_info_s *_media = (media_info_s*)media;
2220 if(_media && age_rating)
2222 if(STRING_VALID(_media->age_rating))
2224 *age_rating = strdup(_media->age_rating);
2225 if(*age_rating == NULL)
2227 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2228 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2235 ret = MEDIA_CONTENT_ERROR_NONE;
2239 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2240 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2246 int media_info_get_keyword(media_info_h media, char **keyword)
2248 int ret = MEDIA_CONTENT_ERROR_NONE;
2249 media_info_s *_media = (media_info_s*)media;
2251 if(_media && keyword)
2253 if(STRING_VALID(_media->keyword))
2255 *keyword = strdup(_media->keyword);
2256 if(*keyword == NULL)
2258 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2259 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2266 ret = MEDIA_CONTENT_ERROR_NONE;
2270 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2271 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2277 int media_info_is_drm(media_info_h media, bool *is_drm)
2279 int ret = MEDIA_CONTENT_ERROR_NONE;
2280 media_info_s *_media = (media_info_s*)media;
2284 *is_drm = _media->is_drm;
2285 ret = MEDIA_CONTENT_ERROR_NONE;
2289 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2290 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2296 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
2298 int ret = MEDIA_CONTENT_ERROR_NONE;
2299 media_info_s *_media = (media_info_s*)media;
2301 if(_media && storage_type)
2303 *storage_type = _media->storage_type;
2304 ret = MEDIA_CONTENT_ERROR_NONE;
2308 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2309 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2315 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
2317 int ret = MEDIA_CONTENT_ERROR_NONE;
2318 int ret_view = MEDIA_CONTENT_ERROR_NONE;
2319 char select_query[DEFAULT_QUERY_SIZE];
2320 sqlite3_stmt *stmt = NULL;
2322 if(!STRING_VALID(media_id) || (media == NULL))
2324 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2325 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2328 memset(select_query, 0x00, sizeof(select_query));
2330 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
2331 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
2332 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2334 while(sqlite3_step(stmt) == SQLITE_ROW)
2336 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
2340 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2341 SQLITE3_FINALIZE(stmt);
2342 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2345 _media_info_item_get_detail(stmt, (media_info_h)_media);
2347 *media = (media_info_h)_media;
2350 SQLITE3_FINALIZE(stmt);
2354 int media_info_set_display_name(media_info_h media, const char *display_name)
2356 int ret = MEDIA_CONTENT_ERROR_NONE;
2357 media_info_s *_media = (media_info_s*)media;
2359 if(_media != NULL && STRING_VALID(display_name))
2361 SAFE_FREE(_media->display_name);
2363 _media->display_name = strdup(display_name);
2364 if(_media->display_name == NULL)
2366 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2367 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2372 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2373 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2379 int media_info_set_description(media_info_h media, const char *description)
2381 int ret = MEDIA_CONTENT_ERROR_NONE;
2382 media_info_s *_media = (media_info_s*)media;
2386 SAFE_FREE(_media->description);
2388 if(STRING_VALID(description))
2390 _media->description = strdup(description);
2392 if(_media->description == NULL)
2394 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2395 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2400 _media->description = NULL;
2405 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2406 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2412 int media_info_set_longitude(media_info_h media, double longitude)
2414 int ret = MEDIA_CONTENT_ERROR_NONE;
2415 media_info_s *_media = (media_info_s*)media;
2419 _media->longitude = longitude;
2423 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2424 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2430 int media_info_set_latitude(media_info_h media, double latitude)
2432 int ret = MEDIA_CONTENT_ERROR_NONE;
2433 media_info_s *_media = (media_info_s*)media;
2437 _media->latitude = latitude;
2441 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2442 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2448 int media_info_set_altitude(media_info_h media, double altitude)
2450 int ret = MEDIA_CONTENT_ERROR_NONE;
2451 media_info_s *_media = (media_info_s*)media;
2455 _media->altitude = altitude;
2459 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2460 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2466 int media_info_set_weather(media_info_h media, const char *weather)
2468 int ret = MEDIA_CONTENT_ERROR_NONE;
2469 media_info_s *_media = (media_info_s*)media;
2473 SAFE_FREE(_media->weather);
2475 if(STRING_VALID(weather))
2477 _media->weather = strdup(weather);
2479 if(_media->weather == NULL)
2481 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2482 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2487 _media->weather = NULL;
2492 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2493 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2499 int media_info_set_rating(media_info_h media, int rating)
2501 int ret = MEDIA_CONTENT_ERROR_NONE;
2502 media_info_s *_media = (media_info_s*)media;
2506 _media->rating = rating;
2510 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2511 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2517 int media_info_set_added_time(media_info_h media, time_t added_time)
2519 int ret = MEDIA_CONTENT_ERROR_NONE;
2521 media_info_s *_media = (media_info_s*)media;
2523 if((_media != NULL) && (added_time >= 0))
2525 _media->added_time = added_time;
2529 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2530 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2536 int media_info_set_favorite(media_info_h media, bool favorite)
2538 int ret = MEDIA_CONTENT_ERROR_NONE;
2539 media_info_s *_media = (media_info_s*)media;
2543 _media->favourite = favorite;
2547 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2548 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2554 int media_info_set_author(media_info_h media, const char *author)
2556 int ret = MEDIA_CONTENT_ERROR_NONE;
2557 media_info_s *_media = (media_info_s*)media;
2561 if(STRING_VALID(author))
2563 _media->author = strdup(author);
2564 if(_media->author == NULL)
2566 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2567 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2572 _media->author = NULL;
2577 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2578 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2584 int media_info_set_provider(media_info_h media, const char *provider)
2586 int ret = MEDIA_CONTENT_ERROR_NONE;
2587 media_info_s *_media = (media_info_s*)media;
2591 SAFE_FREE(_media->provider);
2593 if(STRING_VALID(provider))
2595 _media->provider = strdup(provider);
2596 if(_media->provider == NULL)
2598 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2599 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2604 _media->provider = NULL;
2609 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2610 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2616 int media_info_set_content_name(media_info_h media, const char *content_name)
2618 int ret = MEDIA_CONTENT_ERROR_NONE;
2619 media_info_s *_media = (media_info_s*)media;
2623 SAFE_FREE(_media->content_name);
2625 if(STRING_VALID(content_name))
2627 _media->content_name = strdup(content_name);
2628 if(_media->content_name == NULL)
2630 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2631 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2636 _media->content_name = NULL;
2641 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2642 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2648 int media_info_set_category(media_info_h media, const char *category)
2650 int ret = MEDIA_CONTENT_ERROR_NONE;
2651 media_info_s *_media = (media_info_s*)media;
2655 SAFE_FREE(_media->category);
2657 if(STRING_VALID(category))
2659 _media->category = strdup(category);
2660 if(_media->category == NULL)
2662 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2663 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2668 _media->category = NULL;
2673 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2674 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2680 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2682 int ret = MEDIA_CONTENT_ERROR_NONE;
2683 media_info_s *_media = (media_info_s*)media;
2687 SAFE_FREE(_media->location_tag);
2689 if(STRING_VALID(location_tag))
2691 _media->location_tag = strdup(location_tag);
2692 if(_media->location_tag == NULL)
2694 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2695 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2700 _media->location_tag = NULL;
2705 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2706 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2712 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2714 int ret = MEDIA_CONTENT_ERROR_NONE;
2715 media_info_s *_media = (media_info_s*)media;
2719 SAFE_FREE(_media->age_rating);
2721 if(STRING_VALID(age_rating))
2723 _media->age_rating = strdup(age_rating);
2724 if(_media->age_rating == NULL)
2726 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2727 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2732 _media->age_rating = NULL;
2737 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2738 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2744 int media_info_set_keyword(media_info_h media, const char *keyword)
2746 int ret = MEDIA_CONTENT_ERROR_NONE;
2747 media_info_s *_media = (media_info_s*)media;
2751 SAFE_FREE(_media->keyword);
2753 if(STRING_VALID(keyword))
2755 _media->keyword = strdup(keyword);
2756 if(_media->keyword == NULL)
2758 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2759 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2764 _media->keyword = NULL;
2769 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2770 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2776 int media_info_update_to_db(media_info_h media)
2778 int ret = MEDIA_CONTENT_ERROR_NONE;
2780 media_info_s *_media = (media_info_s*)media;
2781 char *set_sql = NULL;
2782 char sql[MAX_QUERY_SIZE];
2783 memset(sql, '\0', sizeof(sql));
2785 if(_media != NULL && STRING_VALID(_media->media_id))
2787 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2788 /* This code will be removed when sqlite3_mprintf works clearly */
2789 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2790 sqlite3_free(test_sql);
2792 /*Update Pinyin If Support Pinyin*/
2793 char *file_name_pinyin = NULL;
2794 char *description_pinyin = NULL;
2795 char *author_pinyin = NULL;
2796 char *provider_pinyin = NULL;
2797 char *content_name_pinyin = NULL;
2798 char *category_pinyin = NULL;
2799 char *location_tag_pinyin = NULL;
2800 char *age_rating_pinyin = NULL;
2801 char *keyword_pinyin = NULL;
2802 bool pinyin_support = FALSE;
2804 /*Update Pinyin If Support Pinyin*/
2805 media_svc_check_pinyin_support(&pinyin_support);
2808 if(STRING_VALID(_media->display_name))
2809 media_svc_get_pinyin(_content_get_db_handle(), _media->display_name, &file_name_pinyin);
2810 if(STRING_VALID(_media->description))
2811 media_svc_get_pinyin(_content_get_db_handle(), _media->description, &description_pinyin);
2812 if(STRING_VALID(_media->author))
2813 media_svc_get_pinyin(_content_get_db_handle(), _media->author, &author_pinyin);
2814 if(STRING_VALID(_media->provider))
2815 media_svc_get_pinyin(_content_get_db_handle(), _media->provider, &provider_pinyin);
2816 if(STRING_VALID(_media->content_name))
2817 media_svc_get_pinyin(_content_get_db_handle(), _media->content_name, &content_name_pinyin);
2818 if(STRING_VALID(_media->category))
2819 media_svc_get_pinyin(_content_get_db_handle(), _media->category, &category_pinyin);
2820 if(STRING_VALID(_media->location_tag))
2821 media_svc_get_pinyin(_content_get_db_handle(), _media->location_tag, &location_tag_pinyin);
2822 if(STRING_VALID(_media->age_rating))
2823 media_svc_get_pinyin(_content_get_db_handle(), _media->age_rating, &age_rating_pinyin);
2824 if(STRING_VALID(_media->keyword))
2825 media_svc_get_pinyin(_content_get_db_handle(), _media->keyword, &keyword_pinyin);
2828 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2829 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, \
2830 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",
2831 _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite,
2832 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2833 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin);
2835 len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
2836 sqlite3_free(set_sql);
2838 SAFE_FREE(description_pinyin);
2839 SAFE_FREE(author_pinyin);
2840 SAFE_FREE(provider_pinyin);
2841 SAFE_FREE(content_name_pinyin);
2842 SAFE_FREE(category_pinyin);
2843 SAFE_FREE(location_tag_pinyin);
2844 SAFE_FREE(age_rating_pinyin);
2845 SAFE_FREE(keyword_pinyin);
2850 media_content_error("snprintf failed");
2851 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2855 ret = _content_query_sql(sql);
2856 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2857 /* Send notification for this update */
2858 media_content_debug("Update is successfull. Send notification for this");
2859 if (_media->file_path && _media->mime_type) {
2860 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);
2862 media_content_error("Can't media_db_update_send : path or mime type is NULL");
2868 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2869 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2875 int media_info_refresh_metadata_to_db(const char *media_id)
2877 int ret = MEDIA_CONTENT_ERROR_NONE;
2878 media_info_h media = NULL;
2879 char *file_path = NULL;
2880 media_content_storage_e storage_type = 0;
2882 if(!STRING_VALID(media_id))
2884 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2885 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2888 ret = media_info_get_media_from_db(media_id, &media);
2889 if(ret != MEDIA_CONTENT_ERROR_NONE)
2891 media_info_destroy(media);
2895 ret = media_info_get_storage_type(media, &storage_type);
2896 if(ret != MEDIA_CONTENT_ERROR_NONE)
2898 media_info_destroy(media);
2902 ret = media_info_get_file_path(media, &file_path);
2903 if(ret != MEDIA_CONTENT_ERROR_NONE)
2905 media_info_destroy(media);
2909 ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
2911 SAFE_FREE(file_path);
2912 media_info_destroy(media);
2917 int media_info_move_to_db(media_info_h media, const char* dst_path)
2919 int ret = MEDIA_CONTENT_ERROR_NONE;
2921 int src_storage_type = 0;
2922 int dst_storage_type = 0;
2924 if(media == NULL || !STRING_VALID(dst_path))
2926 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2927 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2930 media_info_s *_media = (media_info_s*)media;
2932 ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2933 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2934 ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2935 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2937 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));
2938 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2941 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2943 int ret = MEDIA_CONTENT_ERROR_NONE;
2944 media_info_s *_media = (media_info_s*)media;
2946 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2948 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2949 _thumb_cb->handle = _media;
2950 _thumb_cb->user_data = user_data;
2951 _thumb_cb->thumbnail_completed_cb = callback;
2953 ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
2954 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2958 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2959 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2965 int media_info_cancel_thumbnail(media_info_h media)
2967 int ret = MEDIA_CONTENT_ERROR_NONE;
2968 media_info_s *_media = (media_info_s*)media;
2970 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2972 ret = thumbnail_request_cancel_media(_media->file_path, tzplatform_getuid(TZ_USER_NAME));
2973 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2977 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2978 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;