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-register.h>
24 #include <media-util-err.h>
27 static int __media_info_get_media_info_from_db(char *path, media_info_h media);
28 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
30 static int __media_info_get_media_info_from_db(char *path, media_info_h media)
32 int ret = MEDIA_CONTENT_ERROR_NONE;
33 sqlite3_stmt *stmt = NULL;
34 char *select_query = NULL;
35 media_info_s *_media = (media_info_s*)media;
39 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
40 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
43 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
45 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
46 sqlite3_free(select_query);
47 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
49 if(sqlite3_step(stmt) == SQLITE_ROW)
51 _media_info_item_get_detail(stmt, (media_info_h)_media);
52 media_content_debug("New Media ID: %s", _media->media_id);
54 media_content_debug("There's no media!!");
57 while(sqlite3_step(stmt) == SQLITE_ROW)
59 _media_info_item_get_detail(stmt, (media_info_h)_media);
60 media_content_debug("New Media ID: %s", _media->media_id);
63 SQLITE3_FINALIZE(stmt);
68 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
70 int error_value = MEDIA_CONTENT_ERROR_NONE;
72 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
73 media_info_s *media = NULL;
77 media = _thumb_cb->handle;
78 if((media != NULL) && STRING_VALID(path))
80 SAFE_FREE(media->thumbnail_path);
81 media->thumbnail_path = strdup(path);
84 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
85 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
86 _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
94 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
96 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
97 // 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"
99 media_info_s *_media = (media_info_s*)media;
101 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
102 _media->media_id = strdup((const char *)sqlite3_column_text(stmt, 0));
104 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
105 _media->file_path = strdup((const char *)sqlite3_column_text(stmt, 1));
107 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
108 _media->display_name = strdup((const char *)sqlite3_column_text(stmt, 2));
110 _media->media_type = (int)sqlite3_column_int(stmt, 3);
112 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4)))
113 _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, 4));
115 _media->size = (unsigned long long)sqlite3_column_int64(stmt, 5);
117 _media->added_time = (int)sqlite3_column_int(stmt, 6);
119 _media->modified_time = (int)sqlite3_column_int(stmt, 7);
121 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8)))
122 _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, 8));
124 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9)))
125 _media->description = strdup((const char *)sqlite3_column_text(stmt, 9));
127 _media->rating = (int)sqlite3_column_int(stmt,10);
129 _media->favourite = (int)sqlite3_column_int(stmt, 11);
131 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 12)))
132 _media->author = strdup((const char *)sqlite3_column_text(stmt, 12));
134 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 13)))
135 _media->provider = strdup((const char *)sqlite3_column_text(stmt, 13));
137 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 14)))
138 _media->content_name = strdup((const char *)sqlite3_column_text(stmt, 14));
140 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 15)))
141 _media->category = strdup((const char *)sqlite3_column_text(stmt, 15));
143 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 16)))
144 _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, 16));
146 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 17)))
147 _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, 17));
149 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 18)))
150 _media->keyword = strdup((const char *)sqlite3_column_text(stmt, 18));
152 _media->is_drm = (int)sqlite3_column_int(stmt, 19);
154 _media->storage_type = (int)sqlite3_column_int(stmt, 20);
156 _media->longitude = (double)sqlite3_column_double(stmt, 21);
157 _media->latitude = (double)sqlite3_column_double(stmt, 22);
158 _media->altitude = (double)sqlite3_column_double(stmt, 23);
160 if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
161 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
162 if(_media->image_meta) {
163 if(STRING_VALID(_media->media_id))
164 _media->image_meta->media_id = strdup(_media->media_id);
166 _media->image_meta->width = sqlite3_column_int(stmt, 24);
167 _media->image_meta->height = sqlite3_column_int(stmt, 25);
169 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 26)))
170 _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, 26));
172 _media->image_meta->orientation = sqlite3_column_int(stmt, 27);
175 } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
176 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
177 if(_media->video_meta) {
178 if(STRING_VALID(_media->media_id))
179 _media->video_meta->media_id = strdup(_media->media_id);
181 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
182 _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
184 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
185 _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
187 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
188 _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
190 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
191 _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
193 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
194 _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
196 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
197 _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
199 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
200 _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
202 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
203 _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
205 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
206 _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
208 _media->video_meta->bitrate = sqlite3_column_int(stmt, 37);
209 _media->video_meta->duration = sqlite3_column_int(stmt, 38);
210 _media->video_meta->played_count = sqlite3_column_int(stmt, 39);
211 _media->video_meta->played_time = sqlite3_column_int(stmt, 40);
212 _media->video_meta->played_position = sqlite3_column_int(stmt, 41);
213 _media->video_meta->width = sqlite3_column_int(stmt, 24);
214 _media->video_meta->height = sqlite3_column_int(stmt, 25);
218 else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
219 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
220 if(_media->audio_meta) {
221 if(STRING_VALID(_media->media_id))
222 _media->audio_meta->media_id = strdup(_media->media_id);
224 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
225 _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
227 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
228 _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
230 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
231 _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
233 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
234 _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
236 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
237 _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
239 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
240 _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
242 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
243 _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
245 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
246 _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
248 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
249 _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
251 _media->audio_meta->bitrate = sqlite3_column_int(stmt, 37);
252 _media->audio_meta->duration = sqlite3_column_int(stmt, 38);
253 _media->audio_meta->played_count = sqlite3_column_int(stmt, 39);
254 _media->audio_meta->played_time = sqlite3_column_int(stmt, 40);
255 _media->audio_meta->played_position = sqlite3_column_int(stmt, 41);
256 _media->audio_meta->samplerate = sqlite3_column_int(stmt, 42);
257 _media->audio_meta->channel = sqlite3_column_int(stmt, 43);
263 int media_info_insert_to_db (const char *path, media_info_h *info)
265 int ret = MEDIA_CONTENT_ERROR_NONE;
267 if(!STRING_VALID(path))
269 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
270 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
275 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
276 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
279 media_content_debug("Register: %s", path);
280 ret = media_file_register(path);
281 if(ret != MS_MEDIA_ERR_NONE)
283 media_content_error("media_file_register failed");
284 return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
287 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
290 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
291 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
294 _media->file_path = strdup(path);
295 if(_media->file_path == NULL)
297 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
299 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
302 ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
304 *info = (media_info_h)_media;
309 int media_info_delete_from_db(const char *media_id)
311 int ret = MEDIA_CONTENT_ERROR_NONE;
313 char *query_string = NULL;
315 if(!STRING_VALID(media_id))
317 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
318 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
321 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id);
323 ret = _content_query_sql(query_string);
325 sqlite3_free(query_string);
330 int media_info_destroy(media_info_h media)
332 int ret = MEDIA_CONTENT_ERROR_NONE;
333 media_info_s *_media = (media_info_s*)media;
337 SAFE_FREE(_media->media_id);
338 SAFE_FREE(_media->file_path);
339 SAFE_FREE(_media->display_name);
340 SAFE_FREE(_media->mime_type);
341 SAFE_FREE(_media->thumbnail_path);
342 SAFE_FREE(_media->description);
343 SAFE_FREE(_media->author);
344 SAFE_FREE(_media->provider);
345 SAFE_FREE(_media->content_name);
346 SAFE_FREE(_media->category);
347 SAFE_FREE(_media->location_tag);
348 SAFE_FREE(_media->age_rating);
349 SAFE_FREE(_media->keyword);
351 if(_media->image_meta) {
352 SAFE_FREE(_media->image_meta->media_id);
353 SAFE_FREE(_media->image_meta->date_taken);
355 SAFE_FREE(_media->image_meta);
356 } else if(_media->video_meta) {
357 SAFE_FREE(_media->video_meta->media_id);
358 SAFE_FREE(_media->video_meta->title);
359 SAFE_FREE(_media->video_meta->album);
360 SAFE_FREE(_media->video_meta->artist);
361 SAFE_FREE(_media->video_meta->genre);
362 SAFE_FREE(_media->video_meta->composer);
363 SAFE_FREE(_media->video_meta->year);
364 SAFE_FREE(_media->video_meta->recorded_date);
365 SAFE_FREE(_media->video_meta->copyright);
366 SAFE_FREE(_media->video_meta->track_num);
368 SAFE_FREE(_media->video_meta);
369 } else if(_media->audio_meta) {
370 SAFE_FREE(_media->audio_meta->media_id);
371 SAFE_FREE(_media->audio_meta->title);
372 SAFE_FREE(_media->audio_meta->album);
373 SAFE_FREE(_media->audio_meta->artist);
374 SAFE_FREE(_media->audio_meta->genre);
375 SAFE_FREE(_media->audio_meta->composer);
376 SAFE_FREE(_media->audio_meta->year);
377 SAFE_FREE(_media->audio_meta->recorded_date);
378 SAFE_FREE(_media->audio_meta->copyright);
379 SAFE_FREE(_media->audio_meta->track_num);
381 SAFE_FREE(_media->audio_meta);
386 ret = MEDIA_CONTENT_ERROR_NONE;
390 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
391 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
397 int media_info_clone(media_info_h *dst, media_info_h src)
399 int ret = MEDIA_CONTENT_ERROR_NONE;
400 media_info_s *_src = (media_info_s*)src;
405 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
409 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
410 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
413 if(STRING_VALID(_src->media_id))
415 _dst->media_id = strdup(_src->media_id);
416 if(_dst->media_id == NULL)
418 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
419 media_info_destroy((media_info_h)_dst);
420 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
423 if(STRING_VALID(_src->file_path))
425 _dst->file_path = strdup(_src->file_path);
426 if(_dst->file_path == NULL)
428 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
429 media_info_destroy((media_info_h)_dst);
430 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
433 if(STRING_VALID(_src->display_name))
435 _dst->display_name = strdup(_src->display_name);
436 if(_dst->display_name == NULL)
438 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
439 media_info_destroy((media_info_h)_dst);
440 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
443 if(STRING_VALID(_src->mime_type))
445 _dst->mime_type = strdup(_src->mime_type);
446 if(_dst->mime_type == NULL)
448 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
449 media_info_destroy((media_info_h)_dst);
450 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
453 if(STRING_VALID(_src->thumbnail_path))
455 _dst->thumbnail_path = strdup(_src->thumbnail_path);
456 if(_dst->thumbnail_path == NULL)
458 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
459 media_info_destroy((media_info_h)_dst);
460 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
463 if(STRING_VALID(_src->description))
465 _dst->description = strdup(_src->description);
466 if(_dst->description == NULL)
468 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
469 media_info_destroy((media_info_h)_dst);
470 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
473 if(STRING_VALID(_src->author))
475 _dst->author = strdup(_src->author);
476 if(_dst->author == NULL)
478 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
479 media_info_destroy((media_info_h)_dst);
480 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
483 if(STRING_VALID(_src->provider))
485 _dst->provider = strdup(_src->provider);
486 if(_dst->provider == NULL)
488 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
489 media_info_destroy((media_info_h)_dst);
490 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
493 if(STRING_VALID(_src->content_name))
495 _dst->content_name = strdup(_src->content_name);
496 if(_dst->content_name == NULL)
498 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
499 media_info_destroy((media_info_h)_dst);
500 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
503 if(STRING_VALID(_src->category))
505 _dst->category = strdup(_src->category);
506 if(_dst->category == NULL)
508 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
509 media_info_destroy((media_info_h)_dst);
510 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
513 if(STRING_VALID(_src->location_tag))
515 _dst->location_tag = strdup(_src->location_tag);
516 if(_dst->location_tag == NULL)
518 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
519 media_info_destroy((media_info_h)_dst);
520 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
523 if(STRING_VALID(_src->age_rating))
525 _dst->age_rating = strdup(_src->age_rating);
526 if(_dst->age_rating == NULL)
528 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
529 media_info_destroy((media_info_h)_dst);
530 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
533 if(STRING_VALID(_src->keyword))
535 _dst->keyword = strdup(_src->keyword);
536 if(_dst->keyword == NULL)
538 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
539 media_info_destroy((media_info_h)_dst);
540 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
544 _dst->media_type = _src->media_type;
545 _dst->size = _src->size;
546 _dst->added_time = _src->added_time;
547 _dst->modified_time = _src->modified_time;
548 _dst->longitude = _src->longitude;
549 _dst->latitude = _src->latitude;
550 _dst->altitude = _src->altitude;
551 _dst->rating = _src->rating;
552 _dst->favourite = _src->favourite;
553 _dst->is_drm = _src->is_drm;
555 if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
556 _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
557 if(_dst->image_meta == NULL)
559 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
560 media_info_destroy((media_info_h)_dst);
561 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
564 if(STRING_VALID(_src->image_meta->media_id))
566 _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
567 if(_dst->image_meta->media_id == NULL)
569 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
570 media_info_destroy((media_info_h)_dst);
571 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
574 if(STRING_VALID(_src->image_meta->date_taken))
576 _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
577 if(_dst->image_meta->date_taken == NULL)
579 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
580 media_info_destroy((media_info_h)_dst);
581 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
585 _dst->image_meta->width = _src->image_meta->width;
586 _dst->image_meta->height = _src->image_meta->height;
587 _dst->image_meta->orientation = _src->image_meta->orientation;
589 } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
590 _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
591 if(_dst->video_meta == NULL)
593 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
594 media_info_destroy((media_info_h)_dst);
595 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
598 if(STRING_VALID(_src->video_meta->media_id))
600 _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
601 if(_dst->video_meta->media_id == NULL)
603 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
604 media_info_destroy((media_info_h)_dst);
605 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
608 if(STRING_VALID(_src->video_meta->title))
610 _dst->video_meta->title = strdup(_src->video_meta->title);
611 if(_dst->video_meta->title == NULL)
613 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
614 media_info_destroy((media_info_h)_dst);
615 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
618 if(STRING_VALID(_src->video_meta->album))
620 _dst->video_meta->album = strdup(_src->video_meta->album);
621 if(_dst->video_meta->album == NULL)
623 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
624 media_info_destroy((media_info_h)_dst);
625 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
628 if(STRING_VALID(_src->video_meta->artist))
630 _dst->video_meta->artist = strdup(_src->video_meta->artist);
631 if(_dst->video_meta->artist == NULL)
633 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
634 media_info_destroy((media_info_h)_dst);
635 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
638 if(STRING_VALID(_src->video_meta->genre))
640 _dst->video_meta->genre = strdup(_src->video_meta->genre);
641 if(_dst->video_meta->genre == NULL)
643 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
644 media_info_destroy((media_info_h)_dst);
645 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
648 if(STRING_VALID(_src->video_meta->composer))
650 _dst->video_meta->composer = strdup(_src->video_meta->composer);
651 if(_dst->video_meta->composer == NULL)
653 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
654 media_info_destroy((media_info_h)_dst);
655 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
658 if(STRING_VALID(_src->video_meta->year))
660 _dst->video_meta->year = strdup(_src->video_meta->year);
661 if(_dst->video_meta->year == NULL)
663 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
664 media_info_destroy((media_info_h)_dst);
665 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
668 if(STRING_VALID(_src->video_meta->recorded_date))
670 _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
671 if(_dst->video_meta->recorded_date == NULL)
673 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
674 media_info_destroy((media_info_h)_dst);
675 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
678 if(STRING_VALID(_src->video_meta->copyright))
680 _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
681 if(_dst->video_meta->copyright == NULL)
683 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
684 media_info_destroy((media_info_h)_dst);
685 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
688 if(STRING_VALID(_src->video_meta->track_num))
690 _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
691 if(_dst->video_meta->year == NULL)
693 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
694 media_info_destroy((media_info_h)_dst);
695 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
699 _dst->video_meta->width = _src->video_meta->width;
700 _dst->video_meta->height = _src->video_meta->height;
701 _dst->video_meta->duration = _src->video_meta->duration;
702 _dst->video_meta->bitrate = _src->video_meta->bitrate;
703 _dst->video_meta->played_count = _src->video_meta->played_count;
704 _dst->video_meta->played_time = _src->video_meta->played_time;
705 _dst->video_meta->played_position = _src->video_meta->played_position;
707 } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
708 _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
709 if(_dst->audio_meta == NULL)
711 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
712 media_info_destroy((media_info_h)_dst);
713 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
716 if(STRING_VALID(_src->audio_meta->media_id))
718 _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
719 if(_dst->audio_meta->media_id == NULL)
721 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
722 media_info_destroy((media_info_h)_dst);
723 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
726 if(STRING_VALID(_src->audio_meta->title))
728 _dst->audio_meta->title = strdup(_src->audio_meta->title);
729 if(_dst->audio_meta->title == NULL)
731 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
732 media_info_destroy((media_info_h)_dst);
733 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
736 if(STRING_VALID(_src->audio_meta->album))
738 _dst->audio_meta->album = strdup(_src->audio_meta->album);
739 if(_dst->audio_meta->album == NULL)
741 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
742 media_info_destroy((media_info_h)_dst);
743 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
746 if(STRING_VALID(_src->audio_meta->artist))
748 _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
749 if(_dst->audio_meta->artist == NULL)
751 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
752 media_info_destroy((media_info_h)_dst);
753 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
756 if(STRING_VALID(_src->audio_meta->genre))
758 _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
759 if(_dst->audio_meta->genre == NULL)
761 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
762 media_info_destroy((media_info_h)_dst);
763 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
766 if(STRING_VALID(_src->audio_meta->composer))
768 _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
769 if(_dst->audio_meta->composer == NULL)
771 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
772 media_info_destroy((media_info_h)_dst);
773 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
776 if(STRING_VALID(_src->audio_meta->year))
778 _dst->audio_meta->year = strdup(_src->audio_meta->year);
779 if(_dst->audio_meta->year == NULL)
781 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
782 media_info_destroy((media_info_h)_dst);
783 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
786 if(STRING_VALID(_src->audio_meta->recorded_date))
788 _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
789 if(_dst->audio_meta->recorded_date == NULL)
791 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
792 media_info_destroy((media_info_h)_dst);
793 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
796 if(STRING_VALID(_src->audio_meta->copyright))
798 _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
799 if(_dst->audio_meta->copyright == NULL)
801 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
802 media_info_destroy((media_info_h)_dst);
803 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
806 if(STRING_VALID(_src->audio_meta->track_num))
808 _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
809 if(_dst->audio_meta->year == NULL)
811 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
812 media_info_destroy((media_info_h)_dst);
813 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
817 _dst->audio_meta->channel = _src->audio_meta->channel;
818 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
819 _dst->audio_meta->duration = _src->audio_meta->duration;
820 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
821 _dst->audio_meta->played_count = _src->audio_meta->played_count;
822 _dst->audio_meta->played_time = _src->audio_meta->played_time;
823 _dst->audio_meta->played_position = _src->audio_meta->played_position;
826 *dst = (media_info_h)_dst;
828 ret = MEDIA_CONTENT_ERROR_NONE;
832 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
833 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
839 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
841 int ret = MEDIA_CONTENT_ERROR_NONE;
843 media_content_debug_func();
845 if(media_count == NULL)
847 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
848 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
853 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
858 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
860 int ret = MEDIA_CONTENT_ERROR_NONE;
862 media_content_debug_func();
866 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
867 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
870 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
875 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
877 int ret = MEDIA_CONTENT_ERROR_NONE;
879 media_content_debug_func();
881 if(STRING_VALID(media_id) && tag_count)
883 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
887 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
888 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
894 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
896 int ret = MEDIA_CONTENT_ERROR_NONE;
898 media_content_debug_func();
900 if((callback != NULL) && STRING_VALID(media_id))
902 ret = _media_db_get_tag(media_id, filter, callback, user_data);
906 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
907 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
913 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
915 int ret = MEDIA_CONTENT_ERROR_NONE;
917 media_content_debug_func();
919 if(STRING_VALID(media_id) && bookmark_count)
921 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
925 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
926 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
932 int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
934 int ret = MEDIA_CONTENT_ERROR_NONE;
936 media_content_debug_func();
938 if((callback != NULL) && STRING_VALID(media_id))
940 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
944 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
945 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
951 int media_info_get_image(media_info_h media, image_meta_h *image)
953 int ret = MEDIA_CONTENT_ERROR_NONE;
955 media_info_s *_media = (media_info_s*)media;
956 media_content_debug_func();
960 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
961 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
964 if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
966 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
967 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
970 if(_media->image_meta == NULL)
972 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
973 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
976 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
980 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
981 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
984 if(STRING_VALID(_media->media_id)) {
985 _image->media_id = strdup(_media->media_id);
988 _image->width = _media->image_meta->width;
989 _image->height = _media->image_meta->height;
990 _image->orientation = _media->image_meta->orientation;
992 if(STRING_VALID(_media->image_meta->date_taken)) {
993 _image->date_taken = strdup(_media->image_meta->date_taken);
996 *image = (image_meta_h)_image;
1001 int media_info_get_video(media_info_h media, video_meta_h *video)
1003 int ret = MEDIA_CONTENT_ERROR_NONE;
1005 media_info_s *_media = (media_info_s*)media;
1006 media_content_debug_func();
1010 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1011 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1014 if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
1016 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1017 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1020 if(_media->video_meta == NULL)
1022 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1023 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1026 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1030 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1031 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1034 if(STRING_VALID(_media->media_id)) {
1035 _video->media_id = strdup(_media->media_id);
1038 if(STRING_VALID(_media->video_meta->title)) {
1039 _video->title = strdup(_media->video_meta->title);
1041 if(STRING_VALID(_media->video_meta->album)) {
1042 _video->album = strdup(_media->video_meta->album);
1044 if(STRING_VALID(_media->video_meta->artist)) {
1045 _video->artist = strdup(_media->video_meta->artist);
1047 if(STRING_VALID(_media->video_meta->genre)) {
1048 _video->genre = strdup(_media->video_meta->genre);
1050 if(STRING_VALID(_media->video_meta->composer)) {
1051 _video->composer = strdup(_media->video_meta->composer);
1053 if(STRING_VALID(_media->video_meta->year)) {
1054 _video->year = strdup(_media->video_meta->year);
1056 if(STRING_VALID(_media->video_meta->recorded_date)) {
1057 _video->recorded_date = strdup(_media->video_meta->recorded_date);
1059 if(STRING_VALID(_media->video_meta->copyright)) {
1060 _video->copyright = strdup(_media->video_meta->copyright);
1062 if(STRING_VALID(_media->video_meta->track_num)) {
1063 _video->track_num = strdup(_media->video_meta->track_num);
1066 _video->width = _media->video_meta->width;
1067 _video->height = _media->video_meta->height;
1068 _video->duration = _media->video_meta->duration;
1069 _video->bitrate = _media->video_meta->bitrate;
1070 _video->played_count = _media->video_meta->played_count;
1071 _video->played_time = _media->video_meta->played_time;
1072 _video->played_position = _media->video_meta->played_position;
1074 *video = (video_meta_h)_video;
1079 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1081 int ret = MEDIA_CONTENT_ERROR_NONE;
1083 media_info_s *_media = (media_info_s*)media;
1084 media_content_debug_func();
1088 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1089 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1092 if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
1094 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1095 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1098 if(_media->audio_meta == NULL)
1100 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1101 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1104 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1108 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1109 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1112 if(STRING_VALID(_media->media_id)) {
1113 _audio->media_id = strdup(_media->media_id);
1116 if(STRING_VALID(_media->audio_meta->title)) {
1117 _audio->title = strdup(_media->audio_meta->title);
1119 if(STRING_VALID(_media->audio_meta->album)) {
1120 _audio->album = strdup(_media->audio_meta->album);
1122 if(STRING_VALID(_media->audio_meta->artist)) {
1123 _audio->artist = strdup(_media->audio_meta->artist);
1125 if(STRING_VALID(_media->audio_meta->genre)) {
1126 _audio->genre = strdup(_media->audio_meta->genre);
1128 if(STRING_VALID(_media->audio_meta->composer)) {
1129 _audio->composer = strdup(_media->audio_meta->composer);
1131 if(STRING_VALID(_media->audio_meta->year)) {
1132 _audio->year = strdup(_media->audio_meta->year);
1134 if(STRING_VALID(_media->audio_meta->recorded_date)) {
1135 _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
1137 if(STRING_VALID(_media->audio_meta->copyright)) {
1138 _audio->copyright = strdup(_media->audio_meta->copyright);
1140 if(STRING_VALID(_media->audio_meta->track_num)) {
1141 _audio->track_num = strdup(_media->audio_meta->track_num);
1144 _audio->duration = _media->audio_meta->duration;
1145 _audio->bitrate = _media->audio_meta->bitrate;
1146 _audio->samplerate = _media->audio_meta->samplerate;
1147 _audio->channel = _media->audio_meta->channel;
1148 _audio->played_time = _media->audio_meta->played_time;
1149 _audio->played_count = _media->audio_meta->played_count;
1150 _audio->played_position = _media->audio_meta->played_position;
1152 *audio = (audio_meta_h)_audio;
1157 int media_info_get_media_id(media_info_h media, char **media_id)
1159 int ret = MEDIA_CONTENT_ERROR_NONE;
1160 media_info_s *_media = (media_info_s*)media;
1162 if(_media && media_id)
1164 if(STRING_VALID(_media->media_id))
1166 *media_id = strdup(_media->media_id);
1167 if(*media_id == NULL)
1169 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1170 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1177 ret = MEDIA_CONTENT_ERROR_NONE;
1181 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1182 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1188 int media_info_get_file_path(media_info_h media, char **path)
1190 int ret = MEDIA_CONTENT_ERROR_NONE;
1191 media_info_s *_media = (media_info_s*)media;
1195 if(STRING_VALID(_media->file_path))
1197 *path = strdup(_media->file_path);
1200 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1201 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1208 ret = MEDIA_CONTENT_ERROR_NONE;
1213 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1214 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1220 int media_info_get_display_name(media_info_h media, char **name)
1222 int ret = MEDIA_CONTENT_ERROR_NONE;
1223 media_info_s *_media = (media_info_s*)media;
1226 if(STRING_VALID(_media->display_name))
1228 *name = strdup(_media->display_name);
1231 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1232 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1239 ret = MEDIA_CONTENT_ERROR_NONE;
1244 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1245 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1251 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1253 int ret = MEDIA_CONTENT_ERROR_NONE;
1254 media_info_s *_media = (media_info_s*)media;
1257 *type = _media->media_type;
1258 ret = MEDIA_CONTENT_ERROR_NONE;
1262 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1263 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1269 int media_info_get_mime_type(media_info_h media, char **mime_type)
1271 int ret = MEDIA_CONTENT_ERROR_NONE;
1272 media_info_s *_media = (media_info_s*)media;
1274 if(_media && mime_type)
1276 if(STRING_VALID(_media->mime_type))
1278 *mime_type = strdup(_media->mime_type);
1279 if(*mime_type == NULL)
1281 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1282 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1289 ret = MEDIA_CONTENT_ERROR_NONE;
1293 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1294 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1300 int media_info_get_size(media_info_h media, unsigned long long *size)
1302 int ret = MEDIA_CONTENT_ERROR_NONE;
1303 media_info_s *_media = (media_info_s*)media;
1307 *size = _media->size;
1308 ret = MEDIA_CONTENT_ERROR_NONE;
1312 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1313 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1319 int media_info_get_added_time(media_info_h media, time_t *added_time)
1321 int ret = MEDIA_CONTENT_ERROR_NONE;
1322 media_info_s *_media = (media_info_s*)media;
1323 if(_media && added_time)
1325 *added_time = _media->added_time;
1326 ret = MEDIA_CONTENT_ERROR_NONE;
1330 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1331 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1337 int media_info_get_modified_time(media_info_h media, time_t* time)
1339 int ret = MEDIA_CONTENT_ERROR_NONE;
1340 media_info_s *_media = (media_info_s*)media;
1343 *time = _media->modified_time;
1344 ret = MEDIA_CONTENT_ERROR_NONE;
1348 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1349 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1355 int media_info_get_thumbnail_path(media_info_h media, char **path)
1357 int ret = MEDIA_CONTENT_ERROR_NONE;
1358 media_info_s *_media = (media_info_s*)media;
1361 if(STRING_VALID(_media->thumbnail_path))
1363 *path = strdup(_media->thumbnail_path);
1366 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1367 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1374 ret = MEDIA_CONTENT_ERROR_NONE;
1379 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1380 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1386 int media_info_get_description(media_info_h media, char **description)
1388 int ret = MEDIA_CONTENT_ERROR_NONE;
1389 media_info_s *_media = (media_info_s*)media;
1391 if(_media && description)
1393 if(STRING_VALID(_media->description))
1395 *description = strdup(_media->description);
1396 if(*description == NULL)
1398 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1399 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1404 *description = NULL;
1406 ret = MEDIA_CONTENT_ERROR_NONE;
1410 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1411 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1417 int media_info_get_longitude(media_info_h media, double* longitude)
1419 int ret = MEDIA_CONTENT_ERROR_NONE;
1420 media_info_s *_media = (media_info_s*)media;
1422 if(_media && longitude)
1424 *longitude = _media->longitude;
1425 ret = MEDIA_CONTENT_ERROR_NONE;
1429 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1430 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1435 int media_info_get_latitude(media_info_h media, double* latitude)
1437 int ret = MEDIA_CONTENT_ERROR_NONE;
1438 media_info_s *_media = (media_info_s*)media;
1440 if(_media && latitude)
1442 *latitude = _media->latitude;
1443 ret = MEDIA_CONTENT_ERROR_NONE;
1447 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1448 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1454 int media_info_get_altitude(media_info_h media, double *altitude)
1456 int ret = MEDIA_CONTENT_ERROR_NONE;
1457 media_info_s *_media = (media_info_s*)media;
1459 if(_media && altitude)
1461 *altitude = _media->altitude;
1462 ret = MEDIA_CONTENT_ERROR_NONE;
1466 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1467 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1473 int media_info_get_rating(media_info_h media, int *rating)
1475 int ret = MEDIA_CONTENT_ERROR_NONE;
1476 media_info_s *_media = (media_info_s*)media;
1478 if(_media && rating)
1480 *rating = _media->rating;
1481 ret = MEDIA_CONTENT_ERROR_NONE;
1485 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1486 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1492 int media_info_get_favorite(media_info_h media, bool* favorite)
1494 int ret = MEDIA_CONTENT_ERROR_NONE;
1495 media_info_s *_media = (media_info_s*)media;
1497 if(_media && favorite)
1500 *favorite = _media->favourite;
1501 ret = MEDIA_CONTENT_ERROR_NONE;
1505 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1506 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1512 int media_info_get_author(media_info_h media, char **author)
1514 int ret = MEDIA_CONTENT_ERROR_NONE;
1515 media_info_s *_media = (media_info_s*)media;
1517 if(_media && author)
1519 if(STRING_VALID(_media->author))
1521 *author = strdup(_media->author);
1524 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1525 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1532 ret = MEDIA_CONTENT_ERROR_NONE;
1536 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1537 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1543 int media_info_get_provider(media_info_h media, char **provider)
1545 int ret = MEDIA_CONTENT_ERROR_NONE;
1546 media_info_s *_media = (media_info_s*)media;
1548 if(_media && provider)
1550 if(STRING_VALID(_media->provider))
1552 *provider = strdup(_media->provider);
1553 if(*provider == NULL)
1555 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1556 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1563 ret = MEDIA_CONTENT_ERROR_NONE;
1567 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1568 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1574 int media_info_get_content_name(media_info_h media, char **content_name)
1576 int ret = MEDIA_CONTENT_ERROR_NONE;
1577 media_info_s *_media = (media_info_s*)media;
1579 if(_media && content_name)
1581 if(STRING_VALID(_media->content_name))
1583 *content_name = strdup(_media->content_name);
1584 if(*content_name == NULL)
1586 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1587 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1592 *content_name = NULL;
1594 ret = MEDIA_CONTENT_ERROR_NONE;
1598 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1599 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1605 int media_info_get_category(media_info_h media, char **category)
1607 int ret = MEDIA_CONTENT_ERROR_NONE;
1608 media_info_s *_media = (media_info_s*)media;
1610 if(_media && category)
1612 if(STRING_VALID(_media->category))
1614 *category = strdup(_media->category);
1615 if(*category == NULL)
1617 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1618 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1625 ret = MEDIA_CONTENT_ERROR_NONE;
1629 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1630 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1636 int media_info_get_location_tag(media_info_h media, char **location_tag)
1638 int ret = MEDIA_CONTENT_ERROR_NONE;
1639 media_info_s *_media = (media_info_s*)media;
1641 if(_media && location_tag)
1643 if(STRING_VALID(_media->location_tag))
1645 *location_tag = strdup(_media->location_tag);
1646 if(*location_tag == NULL)
1648 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1649 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1654 *location_tag = NULL;
1656 ret = MEDIA_CONTENT_ERROR_NONE;
1660 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1661 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1667 int media_info_get_age_rating(media_info_h media, char **age_rating)
1669 int ret = MEDIA_CONTENT_ERROR_NONE;
1670 media_info_s *_media = (media_info_s*)media;
1672 if(_media && age_rating)
1674 if(STRING_VALID(_media->age_rating))
1676 *age_rating = strdup(_media->age_rating);
1677 if(*age_rating == NULL)
1679 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1680 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1687 ret = MEDIA_CONTENT_ERROR_NONE;
1691 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1692 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1698 int media_info_get_keyword(media_info_h media, char **keyword)
1700 int ret = MEDIA_CONTENT_ERROR_NONE;
1701 media_info_s *_media = (media_info_s*)media;
1703 if(_media && keyword)
1705 if(STRING_VALID(_media->keyword))
1707 *keyword = strdup(_media->keyword);
1708 if(*keyword == NULL)
1710 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1711 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1718 ret = MEDIA_CONTENT_ERROR_NONE;
1722 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1723 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1729 int media_info_is_drm(media_info_h media, bool *is_drm)
1731 int ret = MEDIA_CONTENT_ERROR_NONE;
1732 media_info_s *_media = (media_info_s*)media;
1736 *is_drm = _media->is_drm;
1737 ret = MEDIA_CONTENT_ERROR_NONE;
1741 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1742 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1748 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
1750 int ret = MEDIA_CONTENT_ERROR_NONE;
1751 media_info_s *_media = (media_info_s*)media;
1753 if(_media && storage_type)
1755 *storage_type = _media->storage_type;
1756 ret = MEDIA_CONTENT_ERROR_NONE;
1760 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1761 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1767 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
1769 int ret = MEDIA_CONTENT_ERROR_NONE;
1770 char select_query[DEFAULT_QUERY_SIZE];
1771 sqlite3_stmt *stmt = NULL;
1773 if(!STRING_VALID(media_id) || (media == NULL))
1775 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1776 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1779 memset(select_query, 0x00, sizeof(select_query));
1781 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
1782 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
1783 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1785 while(sqlite3_step(stmt) == SQLITE_ROW)
1787 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
1791 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1792 SQLITE3_FINALIZE(stmt);
1793 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1796 _media_info_item_get_detail(stmt, (media_info_h)_media);
1798 *media = (media_info_h)_media;
1801 SQLITE3_FINALIZE(stmt);
1806 int media_info_set_display_name(media_info_h media, const char *display_name)
1808 int ret = MEDIA_CONTENT_ERROR_NONE;
1809 media_info_s *_media = (media_info_s*)media;
1811 if(_media != NULL && STRING_VALID(display_name))
1813 SAFE_FREE(_media->display_name);
1815 _media->display_name = strdup(display_name);
1816 if(_media->display_name == NULL)
1818 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1819 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1824 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1825 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1831 int media_info_set_description(media_info_h media, const char *description)
1833 int ret = MEDIA_CONTENT_ERROR_NONE;
1834 media_info_s *_media = (media_info_s*)media;
1838 SAFE_FREE(_media->description);
1840 if(STRING_VALID(description))
1842 _media->description = strdup(description);
1844 if(_media->description == NULL)
1846 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1847 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1852 _media->description = NULL;
1857 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1858 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1864 int media_info_set_longitude(media_info_h media, double longitude)
1866 int ret = MEDIA_CONTENT_ERROR_NONE;
1867 media_info_s *_media = (media_info_s*)media;
1871 _media->longitude = longitude;
1875 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1876 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1882 int media_info_set_latitude(media_info_h media, double latitude)
1884 int ret = MEDIA_CONTENT_ERROR_NONE;
1885 media_info_s *_media = (media_info_s*)media;
1889 _media->latitude = latitude;
1893 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1894 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1900 int media_info_set_altitude(media_info_h media, double altitude)
1902 int ret = MEDIA_CONTENT_ERROR_NONE;
1903 media_info_s *_media = (media_info_s*)media;
1907 _media->altitude = altitude;
1911 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1912 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1918 int media_info_set_rating(media_info_h media, int rating)
1920 int ret = MEDIA_CONTENT_ERROR_NONE;
1921 media_info_s *_media = (media_info_s*)media;
1925 _media->rating = rating;
1929 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1930 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1936 int media_info_set_added_time(media_info_h media, time_t added_time)
1938 int ret = MEDIA_CONTENT_ERROR_NONE;
1940 media_info_s *_media = (media_info_s*)media;
1942 if((_media != NULL) && (added_time >= 0))
1944 _media->added_time = added_time;
1948 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1949 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1955 int media_info_set_favorite(media_info_h media, bool favorite)
1957 int ret = MEDIA_CONTENT_ERROR_NONE;
1958 media_info_s *_media = (media_info_s*)media;
1962 _media->favourite = favorite;
1966 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1967 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1973 int media_info_set_author(media_info_h media, const char *author)
1975 int ret = MEDIA_CONTENT_ERROR_NONE;
1976 media_info_s *_media = (media_info_s*)media;
1980 if(STRING_VALID(author))
1982 _media->author = strdup(author);
1983 if(_media->author == NULL)
1985 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1986 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1991 _media->author = NULL;
1996 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1997 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2003 int media_info_set_provider(media_info_h media, const char *provider)
2005 int ret = MEDIA_CONTENT_ERROR_NONE;
2006 media_info_s *_media = (media_info_s*)media;
2010 SAFE_FREE(_media->provider);
2012 if(STRING_VALID(provider))
2014 _media->provider = strdup(provider);
2015 if(_media->provider == NULL)
2017 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2018 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2023 _media->provider = NULL;
2028 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2029 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2035 int media_info_set_content_name(media_info_h media, const char *content_name)
2037 int ret = MEDIA_CONTENT_ERROR_NONE;
2038 media_info_s *_media = (media_info_s*)media;
2042 SAFE_FREE(_media->content_name);
2044 if(STRING_VALID(content_name))
2046 _media->content_name = strdup(content_name);
2047 if(_media->content_name == NULL)
2049 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2050 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2055 _media->content_name = NULL;
2060 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2061 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2067 int media_info_set_category(media_info_h media, const char *category)
2069 int ret = MEDIA_CONTENT_ERROR_NONE;
2070 media_info_s *_media = (media_info_s*)media;
2074 SAFE_FREE(_media->category);
2076 if(STRING_VALID(category))
2078 _media->category = strdup(category);
2079 if(_media->category == NULL)
2081 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2082 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2087 _media->category = NULL;
2092 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2093 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2099 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2101 int ret = MEDIA_CONTENT_ERROR_NONE;
2102 media_info_s *_media = (media_info_s*)media;
2106 SAFE_FREE(_media->location_tag);
2108 if(STRING_VALID(location_tag))
2110 _media->location_tag = strdup(location_tag);
2111 if(_media->location_tag == NULL)
2113 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2114 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2119 _media->location_tag = NULL;
2124 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2125 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2131 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2133 int ret = MEDIA_CONTENT_ERROR_NONE;
2134 media_info_s *_media = (media_info_s*)media;
2138 SAFE_FREE(_media->age_rating);
2140 if(STRING_VALID(age_rating))
2142 _media->age_rating = strdup(age_rating);
2143 if(_media->age_rating == NULL)
2145 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2146 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2151 _media->age_rating = NULL;
2156 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2157 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2163 int media_info_set_keyword(media_info_h media, const char *keyword)
2165 int ret = MEDIA_CONTENT_ERROR_NONE;
2166 media_info_s *_media = (media_info_s*)media;
2170 SAFE_FREE(_media->keyword);
2172 if(STRING_VALID(keyword))
2174 _media->keyword = strdup(keyword);
2175 if(_media->keyword == NULL)
2177 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2178 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2183 _media->keyword = NULL;
2188 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2189 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2195 int media_info_update_to_db(media_info_h media)
2197 int ret = MEDIA_CONTENT_ERROR_NONE;
2199 media_info_s *_media = (media_info_s*)media;
2200 char *set_sql = NULL;
2201 char sql[MAX_QUERY_SIZE];
2202 memset(sql, '\0', sizeof(sql));
2204 if(_media != NULL && STRING_VALID(_media->media_id))
2206 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2207 rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q",
2208 _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite,
2209 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword);
2211 len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
2212 sqlite3_free(set_sql);
2216 media_content_error("snprintf failed");
2217 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2220 ret = _content_query_sql(sql);
2224 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2225 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2231 int media_info_refresh_metadata_to_db(const char *media_id)
2233 int ret = MEDIA_CONTENT_ERROR_NONE;
2235 char *file_path = NULL;
2236 media_content_type_e media_type = 0;
2237 media_content_storage_e storage_type = 0;
2239 if(!STRING_VALID(media_id))
2241 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2242 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2245 ret = media_info_get_media_from_db(media_id, &media);
2246 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2248 ret = media_info_get_media_type(media, &media_type);
2249 if(ret != MEDIA_CONTENT_ERROR_NONE)
2251 media_info_destroy(media);
2255 ret = media_info_get_storage_type(media, &storage_type);
2256 if(ret != MEDIA_CONTENT_ERROR_NONE)
2258 media_info_destroy(media);
2262 ret = media_info_get_file_path(media, &file_path);
2263 if(ret != MEDIA_CONTENT_ERROR_NONE)
2265 media_info_destroy(media);
2269 ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, media_type);
2271 SAFE_FREE(file_path);
2272 media_info_destroy(media);
2277 int media_info_move_to_db(media_info_h media, const char* dst_path)
2279 int ret = MEDIA_CONTENT_ERROR_NONE;
2281 int src_storage_type = 0;
2282 int dst_storage_type = 0;
2284 if(media == NULL || !STRING_VALID(dst_path))
2286 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2287 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2290 media_info_s *_media = (media_info_s*)media;
2292 ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2293 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2294 ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2295 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2297 ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path);
2298 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2301 int media_info_move_media_to_db(media_info_h media, const char* dst_path)
2303 int ret = MEDIA_CONTENT_ERROR_NONE;
2305 int src_storage_type = 0;
2306 int dst_storage_type = 0;
2308 if(media == NULL || !STRING_VALID(dst_path))
2310 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2311 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2314 media_info_s *_media = (media_info_s*)media;
2316 ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2317 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2318 ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2319 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2321 ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path);
2322 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2325 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2327 int ret = MEDIA_CONTENT_ERROR_NONE;
2328 media_info_s *_media = (media_info_s*)media;
2330 if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2332 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2333 _thumb_cb->handle = _media;
2334 _thumb_cb->user_data = user_data;
2335 _thumb_cb->thumbnail_completed_cb = callback;
2337 ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb);
2338 _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2342 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2343 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;