From 30f658a348dcdf7567dc30af5bebe73996f16d45 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 18 Sep 2018 16:39:49 +0900 Subject: [PATCH] Reinforce code for coverage Change-Id: Ia914a53405a3a463b79ac6db68911b3ce8a67642 Signed-off-by: Minje Ahn --- packaging/capi-content-media-content.spec | 2 +- src/media_audio.c | 203 +++----- src/media_image.c | 132 ++--- src/media_info.c | 809 +++++++++++------------------- src/media_video.c | 206 +++----- 5 files changed, 510 insertions(+), 842 deletions(-) diff --git a/packaging/capi-content-media-content.spec b/packaging/capi-content-media-content.spec index d482003..7c27245 100755 --- a/packaging/capi-content-media-content.spec +++ b/packaging/capi-content-media-content.spec @@ -1,6 +1,6 @@ Name: capi-content-media-content Summary: A Media content library in Tizen Native API -Version: 0.3.34 +Version: 0.3.35 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_audio.c b/src/media_audio.c index ebe7062..ed9d842 100755 --- a/src/media_audio.c +++ b/src/media_audio.c @@ -17,158 +17,107 @@ #include +#define media_content_retv_free_audio_if(expr, val, p_str) do { \ + if (expr) { \ + LOGE(FONT_COLOR_RED"Memory allocation failure"FONT_COLOR_RESET); \ + audio_meta_destroy(p_str); \ + return (val); \ + } \ + } while (0) int audio_meta_destroy(audio_meta_h audio) { - int ret = MEDIA_CONTENT_ERROR_NONE; audio_meta_s *_audio = (audio_meta_s*)audio; + media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Audio handle is null"); + + SAFE_FREE(_audio->media_id); + SAFE_FREE(_audio->title); + SAFE_FREE(_audio->album); + SAFE_FREE(_audio->artist); + SAFE_FREE(_audio->album_artist); + SAFE_FREE(_audio->genre); + SAFE_FREE(_audio->composer); + SAFE_FREE(_audio->year); + SAFE_FREE(_audio->recorded_date); + SAFE_FREE(_audio->copyright); + SAFE_FREE(_audio->track_num); + SAFE_FREE(_audio); - if (_audio) { - SAFE_FREE(_audio->media_id); - SAFE_FREE(_audio->title); - SAFE_FREE(_audio->album); - SAFE_FREE(_audio->artist); - SAFE_FREE(_audio->album_artist); - SAFE_FREE(_audio->genre); - SAFE_FREE(_audio->composer); - SAFE_FREE(_audio->year); - SAFE_FREE(_audio->recorded_date); - SAFE_FREE(_audio->copyright); - SAFE_FREE(_audio->track_num); - SAFE_FREE(_audio); - - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } - - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int audio_meta_clone(audio_meta_h *dst, audio_meta_h src) { - int ret = MEDIA_CONTENT_ERROR_NONE; audio_meta_s *_src = (audio_meta_s*)src; + media_content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null"); - if (_src != NULL) { - audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s)); - media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - - if (_src->media_id != NULL) { - _dst->media_id = g_strdup(_src->media_id); - if (_dst->media_id == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s)); + media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - if (_src->title != NULL) { - _dst->title = g_strdup(_src->title); - if (_dst->title == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->media_id != NULL) { + _dst->media_id = g_strdup(_src->media_id); + media_content_retv_free_audio_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->album != NULL) { - _dst->album = g_strdup(_src->album); - if (_dst->album == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->title != NULL) { + _dst->title = g_strdup(_src->title); + media_content_retv_free_audio_if(_dst->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->artist != NULL) { - _dst->artist = g_strdup(_src->artist); - if (_dst->artist == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->album != NULL) { + _dst->album = g_strdup(_src->album); + media_content_retv_free_audio_if(_dst->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->album_artist != NULL) { - _dst->album_artist = g_strdup(_src->album_artist); - if (_dst->album_artist == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->artist != NULL) { + _dst->artist = g_strdup(_src->artist); + media_content_retv_free_audio_if(_dst->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->genre != NULL) { - _dst->genre = g_strdup(_src->genre); - if (_dst->genre == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->album_artist != NULL) { + _dst->album_artist = g_strdup(_src->album_artist); + media_content_retv_free_audio_if(_dst->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->composer != NULL) { - _dst->composer = g_strdup(_src->composer); - if (_dst->composer == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->genre != NULL) { + _dst->genre = g_strdup(_src->genre); + media_content_retv_free_audio_if(_dst->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->year != NULL) { - _dst->year = g_strdup(_src->year); - if (_dst->year == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->composer != NULL) { + _dst->composer = g_strdup(_src->composer); + media_content_retv_free_audio_if(_dst->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->recorded_date != NULL) { - _dst->recorded_date = g_strdup(_src->recorded_date); - if (_dst->recorded_date == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->year != NULL) { + _dst->year = g_strdup(_src->year); + media_content_retv_free_audio_if(_dst->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->copyright != NULL) { - _dst->copyright = g_strdup(_src->copyright); - if (_dst->copyright == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->recorded_date != NULL) { + _dst->recorded_date = g_strdup(_src->recorded_date); + media_content_retv_free_audio_if(_dst->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - if (_src->track_num != NULL) { - _dst->track_num = g_strdup(_src->track_num); - if (_dst->track_num == NULL) { - audio_meta_destroy((audio_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->copyright != NULL) { + _dst->copyright = g_strdup(_src->copyright); + media_content_retv_free_audio_if(_dst->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - _dst->bitrate = _src->bitrate; - _dst->bitpersample = _src->bitpersample; - _dst->samplerate = _src->samplerate; - _dst->channel = _src->channel; - _dst->duration = _src->duration; + if (_src->track_num != NULL) { + _dst->track_num = g_strdup(_src->track_num); + media_content_retv_free_audio_if(_dst->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst); + } - *dst = (audio_meta_h)_dst; + _dst->bitrate = _src->bitrate; + _dst->bitpersample = _src->bitpersample; + _dst->samplerate = _src->samplerate; + _dst->channel = _src->channel; + _dst->duration = _src->duration; - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + *dst = (audio_meta_h)_dst; - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int audio_meta_get_media_id(audio_meta_h audio, char **media_id) diff --git a/src/media_image.c b/src/media_image.c index f22f5e3..6c4468b 100755 --- a/src/media_image.c +++ b/src/media_image.c @@ -17,108 +17,78 @@ #include +#define media_content_retv_free_image_if(expr, val, p_str) do { \ + if (expr) { \ + LOGE(FONT_COLOR_RED"Memory allocation failure"FONT_COLOR_RESET); \ + image_meta_destroy(p_str); \ + return (val); \ + } \ + } while (0) + int image_meta_destroy(image_meta_h image) { - int ret = MEDIA_CONTENT_ERROR_NONE; image_meta_s *_image = (image_meta_s*)image; + media_content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Image handle is null"); - if (_image) { - SAFE_FREE(_image->media_id); - SAFE_FREE(_image->date_taken); - SAFE_FREE(_image->title); - SAFE_FREE(_image->burst_id); - SAFE_FREE(_image->exposure_time); - SAFE_FREE(_image->model); - SAFE_FREE(_image); - - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + SAFE_FREE(_image->media_id); + SAFE_FREE(_image->date_taken); + SAFE_FREE(_image->title); + SAFE_FREE(_image->burst_id); + SAFE_FREE(_image->exposure_time); + SAFE_FREE(_image->model); + SAFE_FREE(_image); - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int image_meta_clone(image_meta_h *dst, image_meta_h src) { - int ret = MEDIA_CONTENT_ERROR_NONE; image_meta_s *_src = (image_meta_s*)src; + media_content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null"); - if (_src != NULL) { - image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s)); - media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - - if (STRING_VALID(_src->media_id)) { - _dst->media_id = strdup(_src->media_id); - if (_dst->media_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - image_meta_destroy((image_meta_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s)); + media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - if (STRING_VALID(_src->date_taken)) { - _dst->date_taken = strdup(_src->date_taken); - if (_dst->date_taken == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - image_meta_destroy((image_meta_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->media_id)) { + _dst->media_id = strdup(_src->media_id); + media_content_retv_free_image_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst); + } - if (STRING_VALID(_src->title)) { - _dst->title = strdup(_src->title); - if (_dst->title == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - image_meta_destroy((image_meta_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->date_taken)) { + _dst->date_taken = strdup(_src->date_taken); + media_content_retv_free_image_if(_dst->date_taken == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst); + } - if (STRING_VALID(_src->burst_id)) { - _dst->burst_id = strdup(_src->burst_id); - if (_dst->burst_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - image_meta_destroy((image_meta_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->title)) { + _dst->title = strdup(_src->title); + media_content_retv_free_image_if(_dst->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst); + } - if (STRING_VALID(_src->exposure_time)) { - _dst->exposure_time = strdup(_src->exposure_time); - if (_dst->exposure_time == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - image_meta_destroy((image_meta_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->burst_id)) { + _dst->burst_id = strdup(_src->burst_id); + media_content_retv_free_image_if(_dst->burst_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst); + } - if (STRING_VALID(_src->model)) { - _dst->model = strdup(_src->model); - if (_dst->model == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - image_meta_destroy((image_meta_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->exposure_time)) { + _dst->exposure_time = strdup(_src->exposure_time); + media_content_retv_free_image_if(_dst->exposure_time == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst); + } - _dst->fnumber = _src->fnumber; - _dst->iso = _src->iso; - _dst->width = _src->width; - _dst->height = _src->height; - _dst->orientation = _src->orientation; + if (STRING_VALID(_src->model)) { + _dst->model = strdup(_src->model); + media_content_retv_free_image_if(_dst->model == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst); + } - *dst = (image_meta_h)_dst; + _dst->fnumber = _src->fnumber; + _dst->iso = _src->iso; + _dst->width = _src->width; + _dst->height = _src->height; + _dst->orientation = _src->orientation; - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + *dst = (image_meta_h)_dst; - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int image_meta_get_media_id(image_meta_h image, char **media_id) diff --git a/src/media_info.c b/src/media_info.c index e1fb158..00dd2d0 100755 --- a/src/media_info.c +++ b/src/media_info.c @@ -22,6 +22,15 @@ #include +#define media_content_retv_free_info_if(expr, val, p_str) do { \ + if (expr) { \ + LOGE(FONT_COLOR_RED"Memory allocation failure"FONT_COLOR_RESET); \ + media_info_destroy(p_str); \ + return (val); \ + } \ + } while (0) + + static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data); static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data); static void __media_info_face_completed_cb(int error, const int face_count, void *user_data); @@ -890,556 +899,346 @@ int media_info_delete_batch_from_db(filter_h filter) int media_info_destroy(media_info_h media) { - int ret = MEDIA_CONTENT_ERROR_NONE; media_info_s *_media = (media_info_s*)media; - - if (_media) { - SAFE_FREE(_media->media_id); - SAFE_FREE(_media->file_path); - SAFE_FREE(_media->display_name); - SAFE_FREE(_media->mime_type); - SAFE_FREE(_media->thumbnail_path); - SAFE_FREE(_media->description); - SAFE_FREE(_media->author); - SAFE_FREE(_media->provider); - SAFE_FREE(_media->content_name); - SAFE_FREE(_media->category); - SAFE_FREE(_media->location_tag); - SAFE_FREE(_media->age_rating); - SAFE_FREE(_media->keyword); - SAFE_FREE(_media->title); + media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Handle is null"); + + SAFE_FREE(_media->media_id); + SAFE_FREE(_media->file_path); + SAFE_FREE(_media->display_name); + SAFE_FREE(_media->mime_type); + SAFE_FREE(_media->thumbnail_path); + SAFE_FREE(_media->description); + SAFE_FREE(_media->author); + SAFE_FREE(_media->provider); + SAFE_FREE(_media->content_name); + SAFE_FREE(_media->category); + SAFE_FREE(_media->location_tag); + SAFE_FREE(_media->age_rating); + SAFE_FREE(_media->keyword); + SAFE_FREE(_media->title); #ifdef _USE_TVPD_MODE - SAFE_FREE(_media->modified_month); + SAFE_FREE(_media->modified_month); #endif - SAFE_FREE(_media->weather); - SAFE_FREE(_media->storage_uuid); + SAFE_FREE(_media->weather); + SAFE_FREE(_media->storage_uuid); #ifdef _USE_SENIOR_MODE - SAFE_FREE(_media->contact); - SAFE_FREE(_media->app_data); + SAFE_FREE(_media->contact); + SAFE_FREE(_media->app_data); #endif - if (_media->image_meta) { - SAFE_FREE(_media->image_meta->media_id); - SAFE_FREE(_media->image_meta->date_taken); - SAFE_FREE(_media->image_meta->burst_id); - SAFE_FREE(_media->image_meta->exposure_time); - SAFE_FREE(_media->image_meta->model); - SAFE_FREE(_media->image_meta->title); - - SAFE_FREE(_media->image_meta); - } + if (_media->image_meta) { + SAFE_FREE(_media->image_meta->media_id); + SAFE_FREE(_media->image_meta->date_taken); + SAFE_FREE(_media->image_meta->burst_id); + SAFE_FREE(_media->image_meta->exposure_time); + SAFE_FREE(_media->image_meta->model); + SAFE_FREE(_media->image_meta->title); + + SAFE_FREE(_media->image_meta); + } + + if (_media->video_meta) { + SAFE_FREE(_media->video_meta->media_id); + SAFE_FREE(_media->video_meta->title); + SAFE_FREE(_media->video_meta->album); + SAFE_FREE(_media->video_meta->artist); + SAFE_FREE(_media->video_meta->album_artist); + SAFE_FREE(_media->video_meta->genre); + SAFE_FREE(_media->video_meta->composer); + SAFE_FREE(_media->video_meta->year); + SAFE_FREE(_media->video_meta->recorded_date); + SAFE_FREE(_media->video_meta->copyright); + SAFE_FREE(_media->video_meta->track_num); - if (_media->video_meta) { - SAFE_FREE(_media->video_meta->media_id); - SAFE_FREE(_media->video_meta->title); - SAFE_FREE(_media->video_meta->album); - SAFE_FREE(_media->video_meta->artist); - SAFE_FREE(_media->video_meta->album_artist); - SAFE_FREE(_media->video_meta->genre); - SAFE_FREE(_media->video_meta->composer); - SAFE_FREE(_media->video_meta->year); - SAFE_FREE(_media->video_meta->recorded_date); - SAFE_FREE(_media->video_meta->copyright); - SAFE_FREE(_media->video_meta->track_num); - - SAFE_FREE(_media->video_meta); - } - - if (_media->audio_meta) { - SAFE_FREE(_media->audio_meta->media_id); - SAFE_FREE(_media->audio_meta->title); - SAFE_FREE(_media->audio_meta->album); - SAFE_FREE(_media->audio_meta->artist); - SAFE_FREE(_media->audio_meta->album_artist); - SAFE_FREE(_media->audio_meta->genre); - SAFE_FREE(_media->audio_meta->composer); - SAFE_FREE(_media->audio_meta->year); - SAFE_FREE(_media->audio_meta->recorded_date); - SAFE_FREE(_media->audio_meta->copyright); - SAFE_FREE(_media->audio_meta->track_num); - - SAFE_FREE(_media->audio_meta); - } + SAFE_FREE(_media->video_meta); + } - SAFE_FREE(_media); + if (_media->audio_meta) { + SAFE_FREE(_media->audio_meta->media_id); + SAFE_FREE(_media->audio_meta->title); + SAFE_FREE(_media->audio_meta->album); + SAFE_FREE(_media->audio_meta->artist); + SAFE_FREE(_media->audio_meta->album_artist); + SAFE_FREE(_media->audio_meta->genre); + SAFE_FREE(_media->audio_meta->composer); + SAFE_FREE(_media->audio_meta->year); + SAFE_FREE(_media->audio_meta->recorded_date); + SAFE_FREE(_media->audio_meta->copyright); + SAFE_FREE(_media->audio_meta->track_num); - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + SAFE_FREE(_media->audio_meta); } - return ret; + SAFE_FREE(_media); + + return MEDIA_CONTENT_ERROR_NONE; } int media_info_clone(media_info_h *dst, media_info_h src) { - int ret = MEDIA_CONTENT_ERROR_NONE; media_info_s *_src = (media_info_s*)src; + media_content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null"); - if (_src != NULL) { - media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s)); - media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s)); + media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - if (_src->media_id) { - _dst->media_id = g_strdup(_src->media_id); - if (_dst->media_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->file_path) { - _dst->file_path = g_strdup(_src->file_path); - if (_dst->file_path == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->display_name != NULL) { - _dst->display_name = g_strdup(_src->display_name); - if (_dst->display_name == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->mime_type) { - _dst->mime_type = g_strdup(_src->mime_type); - if (_dst->mime_type == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->thumbnail_path != NULL) { - _dst->thumbnail_path = g_strdup(_src->thumbnail_path); - if (_dst->thumbnail_path == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->description != NULL) { - _dst->description = g_strdup(_src->description); - if (_dst->description == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->media_id) { + _dst->media_id = g_strdup(_src->media_id); + media_content_retv_free_info_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->file_path) { + _dst->file_path = g_strdup(_src->file_path); + media_content_retv_free_info_if(_dst->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->display_name != NULL) { + _dst->display_name = g_strdup(_src->display_name); + media_content_retv_free_info_if(_dst->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->mime_type) { + _dst->mime_type = g_strdup(_src->mime_type); + media_content_retv_free_info_if(_dst->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->thumbnail_path != NULL) { + _dst->thumbnail_path = g_strdup(_src->thumbnail_path); + media_content_retv_free_info_if(_dst->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->description != NULL) { + _dst->description = g_strdup(_src->description); + media_content_retv_free_info_if(_dst->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (_src->weather != NULL) { - _dst->weather = g_strdup(_src->weather); - if (_dst->weather == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->weather != NULL) { + _dst->weather = g_strdup(_src->weather); + media_content_retv_free_info_if(_dst->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (_src->title != NULL) { - _dst->title = g_strdup(_src->title); - if (_dst->title == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->author != NULL) { - _dst->author = g_strdup(_src->author); - if (_dst->author == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->provider != NULL) { - _dst->provider = g_strdup(_src->provider); - if (_dst->provider == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->content_name != NULL) { - _dst->content_name = g_strdup(_src->content_name); - if (_dst->content_name == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->category != NULL) { - _dst->category = g_strdup(_src->category); - if (_dst->category == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->location_tag != NULL) { - _dst->location_tag = g_strdup(_src->location_tag); - if (_dst->location_tag == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->age_rating != NULL) { - _dst->age_rating = g_strdup(_src->age_rating); - if (_dst->age_rating == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->keyword != NULL) { - _dst->keyword = g_strdup(_src->keyword); - if (_dst->keyword == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->title != NULL) { + _dst->title = g_strdup(_src->title); + media_content_retv_free_info_if(_dst->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->author != NULL) { + _dst->author = g_strdup(_src->author); + media_content_retv_free_info_if(_dst->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->provider != NULL) { + _dst->provider = g_strdup(_src->provider); + media_content_retv_free_info_if(_dst->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->content_name != NULL) { + _dst->content_name = g_strdup(_src->content_name); + media_content_retv_free_info_if(_dst->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->category != NULL) { + _dst->category = g_strdup(_src->category); + media_content_retv_free_info_if(_dst->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->location_tag != NULL) { + _dst->location_tag = g_strdup(_src->location_tag); + media_content_retv_free_info_if(_dst->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->age_rating != NULL) { + _dst->age_rating = g_strdup(_src->age_rating); + media_content_retv_free_info_if(_dst->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->keyword != NULL) { + _dst->keyword = g_strdup(_src->keyword); + media_content_retv_free_info_if(_dst->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (_src->storage_uuid != NULL) { - _dst->storage_uuid = g_strdup(_src->storage_uuid); - if (_dst->storage_uuid == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->storage_uuid != NULL) { + _dst->storage_uuid = g_strdup(_src->storage_uuid); + media_content_retv_free_info_if(_dst->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } #ifdef _USE_TVPD_MODE - if (STRING_VALID(_src->modified_month)) { - _dst->modified_month = strdup(_src->modified_month); - if (_dst->modified_month == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->modified_month)) { + _dst->modified_month = strdup(_src->modified_month); + media_content_retv_free_info_if(_dst->modified_month == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } #endif #ifdef _USE_SENIOR_MODE - if (STRING_VALID(_src->contact)) { - _dst->contact = strdup(_src->contact); - if (_dst->contact == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->contact)) { + _dst->contact = strdup(_src->contact); + media_content_retv_free_info_if(_dst->contact == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (STRING_VALID(_src->app_data)) { - _dst->app_data = strdup(_src->app_data); - if (_dst->app_data == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (STRING_VALID(_src->app_data)) { + _dst->app_data = strdup(_src->app_data); + media_content_retv_free_info_if(_dst->app_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } #endif - _dst->media_type = _src->media_type; - _dst->size = _src->size; - _dst->added_time = _src->added_time; - _dst->modified_time = _src->modified_time; - _dst->timeline = _src->timeline; - _dst->longitude = _src->longitude; - _dst->latitude = _src->latitude; - _dst->altitude = _src->altitude; - _dst->rating = _src->rating; - _dst->favourite = _src->favourite; - _dst->is_drm = _src->is_drm; - _dst->storage_type = _src->storage_type; - _dst->played_count = _src->played_count; - _dst->played_time = _src->played_time; - _dst->played_position = _src->played_position; - _dst->sync_status = _src->sync_status; - _dst->request_id = _src->request_id; - _dst->face_request_id = _src->face_request_id; - _dst->is_360 = _src->is_360; + _dst->media_type = _src->media_type; + _dst->size = _src->size; + _dst->added_time = _src->added_time; + _dst->modified_time = _src->modified_time; + _dst->timeline = _src->timeline; + _dst->longitude = _src->longitude; + _dst->latitude = _src->latitude; + _dst->altitude = _src->altitude; + _dst->rating = _src->rating; + _dst->favourite = _src->favourite; + _dst->is_drm = _src->is_drm; + _dst->storage_type = _src->storage_type; + _dst->played_count = _src->played_count; + _dst->played_time = _src->played_time; + _dst->played_position = _src->played_position; + _dst->sync_status = _src->sync_status; + _dst->request_id = _src->request_id; + _dst->face_request_id = _src->face_request_id; + _dst->is_360 = _src->is_360; #ifdef _USE_TVPD_MODE - _dst->stitched_info = _src->stitched_info; - _dst->extract_flag = _src->extract_flag; + _dst->stitched_info = _src->stitched_info; + _dst->extract_flag = _src->extract_flag; #endif - if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) { - _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s)); - if (_dst->image_meta == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - - if (_src->image_meta->media_id != NULL) { - _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id); - if (_dst->image_meta->media_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) { + _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s)); + media_content_retv_free_info_if(_dst->image_meta == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); - if (_src->image_meta->date_taken != NULL) { - _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken); - if (_dst->image_meta->date_taken == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->image_meta->media_id != NULL) { + _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id); + media_content_retv_free_info_if(_dst->image_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (_src->image_meta->burst_id != NULL) { - _dst->image_meta->burst_id = g_strdup(_src->image_meta->burst_id); - if (_dst->image_meta->burst_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->image_meta->date_taken != NULL) { + _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken); + media_content_retv_free_info_if(_dst->image_meta->date_taken == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (_src->image_meta->exposure_time != NULL) { - _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time); - if (_dst->image_meta->exposure_time == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->image_meta->burst_id != NULL) { + _dst->image_meta->burst_id = g_strdup(_src->image_meta->burst_id); + media_content_retv_free_info_if(_dst->image_meta->burst_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - if (_src->image_meta->model != NULL) { - _dst->image_meta->model = g_strdup(_src->image_meta->model); - if (_dst->image_meta->model == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->image_meta->exposure_time != NULL) { + _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time); + media_content_retv_free_info_if(_dst->image_meta->exposure_time == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - _dst->image_meta->fnumber = _src->image_meta->fnumber; - _dst->image_meta->iso = _src->image_meta->iso; - _dst->image_meta->width = _src->image_meta->width; - _dst->image_meta->height = _src->image_meta->height; - _dst->image_meta->orientation = _src->image_meta->orientation; + if (_src->image_meta->model != NULL) { + _dst->image_meta->model = g_strdup(_src->image_meta->model); + media_content_retv_free_info_if(_dst->image_meta->model == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) { - _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s)); - if (_dst->video_meta == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } + _dst->image_meta->fnumber = _src->image_meta->fnumber; + _dst->image_meta->iso = _src->image_meta->iso; + _dst->image_meta->width = _src->image_meta->width; + _dst->image_meta->height = _src->image_meta->height; + _dst->image_meta->orientation = _src->image_meta->orientation; - if (_src->video_meta->media_id != NULL) { - _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id); - if (_dst->video_meta->media_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->title != NULL) { - _dst->video_meta->title = g_strdup(_src->video_meta->title); - if (_dst->video_meta->title == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->album != NULL) { - _dst->video_meta->album = g_strdup(_src->video_meta->album); - if (_dst->video_meta->album == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->artist != NULL) { - _dst->video_meta->artist = g_strdup(_src->video_meta->artist); - if (_dst->video_meta->artist == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->album_artist != NULL) { - _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist); - if (_dst->video_meta->album_artist == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->genre != NULL) { - _dst->video_meta->genre = g_strdup(_src->video_meta->genre); - if (_dst->video_meta->genre == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->composer != NULL) { - _dst->video_meta->composer = g_strdup(_src->video_meta->composer); - if (_dst->video_meta->composer == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->year != NULL) { - _dst->video_meta->year = g_strdup(_src->video_meta->year); - if (_dst->video_meta->year == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->recorded_date != NULL) { - _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date); - if (_dst->video_meta->recorded_date == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->copyright != NULL) { - _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright); - if (_dst->video_meta->copyright == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->video_meta->track_num != NULL) { - _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num); - if (_dst->video_meta->track_num == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) { + _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s)); + media_content_retv_free_info_if(_dst->video_meta == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); - _dst->video_meta->width = _src->video_meta->width; - _dst->video_meta->height = _src->video_meta->height; - _dst->video_meta->duration = _src->video_meta->duration; - _dst->video_meta->bitrate = _src->video_meta->bitrate; - _dst->video_meta->rotation = _src->video_meta->rotation; + if (_src->video_meta->media_id != NULL) { + _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id); + media_content_retv_free_info_if(_dst->video_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->title != NULL) { + _dst->video_meta->title = g_strdup(_src->video_meta->title); + media_content_retv_free_info_if(_dst->video_meta->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->album != NULL) { + _dst->video_meta->album = g_strdup(_src->video_meta->album); + media_content_retv_free_info_if(_dst->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->artist != NULL) { + _dst->video_meta->artist = g_strdup(_src->video_meta->artist); + media_content_retv_free_info_if(_dst->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->album_artist != NULL) { + _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist); + media_content_retv_free_info_if(_dst->video_meta->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->genre != NULL) { + _dst->video_meta->genre = g_strdup(_src->video_meta->genre); + media_content_retv_free_info_if(_dst->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->composer != NULL) { + _dst->video_meta->composer = g_strdup(_src->video_meta->composer); + media_content_retv_free_info_if(_dst->video_meta->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->year != NULL) { + _dst->video_meta->year = g_strdup(_src->video_meta->year); + media_content_retv_free_info_if(_dst->video_meta->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->recorded_date != NULL) { + _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date); + media_content_retv_free_info_if(_dst->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->copyright != NULL) { + _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright); + media_content_retv_free_info_if(_dst->video_meta->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->video_meta->track_num != NULL) { + _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num); + media_content_retv_free_info_if(_dst->video_meta->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } - } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) { - _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s)); - if (_dst->audio_meta == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } + _dst->video_meta->width = _src->video_meta->width; + _dst->video_meta->height = _src->video_meta->height; + _dst->video_meta->duration = _src->video_meta->duration; + _dst->video_meta->bitrate = _src->video_meta->bitrate; + _dst->video_meta->rotation = _src->video_meta->rotation; - if (_src->audio_meta->media_id != NULL) { - _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id); - if (_dst->audio_meta->media_id == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->title != NULL) { - _dst->audio_meta->title = g_strdup(_src->audio_meta->title); - if (_dst->audio_meta->title == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->album != NULL) { - _dst->audio_meta->album = g_strdup(_src->audio_meta->album); - if (_dst->audio_meta->album == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->artist != NULL) { - _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist); - if (_dst->audio_meta->artist == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->album_artist != NULL) { - _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist); - if (_dst->audio_meta->album_artist == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->genre != NULL) { - _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre); - if (_dst->audio_meta->genre == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->composer != NULL) { - _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer); - if (_dst->audio_meta->composer == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->year != NULL) { - _dst->audio_meta->year = g_strdup(_src->audio_meta->year); - if (_dst->audio_meta->year == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->recorded_date != NULL) { - _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date); - if (_dst->audio_meta->recorded_date == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->copyright != NULL) { - _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright); - if (_dst->audio_meta->copyright == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - if (_src->audio_meta->track_num != NULL) { - _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num); - if (_dst->audio_meta->track_num == NULL) { - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - media_info_destroy((media_info_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) { + _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s)); + media_content_retv_free_info_if(_dst->audio_meta == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); - _dst->audio_meta->channel = _src->audio_meta->channel; - _dst->audio_meta->samplerate = _src->audio_meta->samplerate; - _dst->audio_meta->duration = _src->audio_meta->duration; - _dst->audio_meta->bitrate = _src->audio_meta->bitrate; - _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample; + if (_src->audio_meta->media_id != NULL) { + _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id); + media_content_retv_free_info_if(_dst->audio_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->title != NULL) { + _dst->audio_meta->title = g_strdup(_src->audio_meta->title); + media_content_retv_free_info_if(_dst->audio_meta->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->album != NULL) { + _dst->audio_meta->album = g_strdup(_src->audio_meta->album); + media_content_retv_free_info_if(_dst->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->artist != NULL) { + _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist); + media_content_retv_free_info_if(_dst->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->album_artist != NULL) { + _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist); + media_content_retv_free_info_if(_dst->audio_meta->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->genre != NULL) { + _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre); + media_content_retv_free_info_if(_dst->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->composer != NULL) { + _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer); + media_content_retv_free_info_if(_dst->audio_meta->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->year != NULL) { + _dst->audio_meta->year = g_strdup(_src->audio_meta->year); + media_content_retv_free_info_if(_dst->audio_meta->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->recorded_date != NULL) { + _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date); + media_content_retv_free_info_if(_dst->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->copyright != NULL) { + _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright); + media_content_retv_free_info_if(_dst->audio_meta->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); + } + if (_src->audio_meta->track_num != NULL) { + _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num); + media_content_retv_free_info_if(_dst->audio_meta->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst); } - *dst = (media_info_h)_dst; - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + _dst->audio_meta->channel = _src->audio_meta->channel; + _dst->audio_meta->samplerate = _src->audio_meta->samplerate; + _dst->audio_meta->duration = _src->audio_meta->duration; + _dst->audio_meta->bitrate = _src->audio_meta->bitrate; + _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample; } + *dst = (media_info_h)_dst; - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int media_info_get_media_count_from_db(filter_h filter, int *media_count) diff --git a/src/media_video.c b/src/media_video.c index 4771df5..da79e57 100755 --- a/src/media_video.c +++ b/src/media_video.c @@ -17,158 +17,108 @@ #include +#define media_content_retv_free_video_if(expr, val, p_str) do { \ + if (expr) { \ + LOGE(FONT_COLOR_RED"Memory allocation failure"FONT_COLOR_RESET); \ + video_meta_destroy(p_str); \ + return (val); \ + } \ + } while (0) + int video_meta_destroy(video_meta_h video) { - int ret = MEDIA_CONTENT_ERROR_NONE; video_meta_s *_video = (video_meta_s*)video; + media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Video handle is null"); + + SAFE_FREE(_video->media_id); + SAFE_FREE(_video->title); + SAFE_FREE(_video->album); + SAFE_FREE(_video->artist); + SAFE_FREE(_video->album_artist); + SAFE_FREE(_video->genre); + SAFE_FREE(_video->composer); + SAFE_FREE(_video->year); + SAFE_FREE(_video->recorded_date); + SAFE_FREE(_video->copyright); + SAFE_FREE(_video->track_num); + SAFE_FREE(_video); - if (_video) { - SAFE_FREE(_video->media_id); - SAFE_FREE(_video->title); - SAFE_FREE(_video->album); - SAFE_FREE(_video->artist); - SAFE_FREE(_video->album_artist); - SAFE_FREE(_video->genre); - SAFE_FREE(_video->composer); - SAFE_FREE(_video->year); - SAFE_FREE(_video->recorded_date); - SAFE_FREE(_video->copyright); - SAFE_FREE(_video->track_num); - SAFE_FREE(_video); - - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } - - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int video_meta_clone(video_meta_h *dst, video_meta_h src) { - int ret = MEDIA_CONTENT_ERROR_NONE; video_meta_s *_src = (video_meta_s*)src; + media_content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null"); - if (_src != NULL) { - video_meta_s *_dst = (video_meta_s*)calloc(1, sizeof(video_meta_s)); - media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - - if (_src->media_id != NULL) { - _dst->media_id = g_strdup(_src->media_id); - if (_dst->media_id == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + video_meta_s *_dst = (video_meta_s*)calloc(1, sizeof(video_meta_s)); + media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - if (_src->title != NULL) { - _dst->title = g_strdup(_src->title); - if (_dst->title == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->media_id != NULL) { + _dst->media_id = g_strdup(_src->media_id); + media_content_retv_free_video_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->album != NULL) { - _dst->album = g_strdup(_src->album); - if (_dst->album == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->title != NULL) { + _dst->title = g_strdup(_src->title); + media_content_retv_free_video_if(_dst->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->artist != NULL) { - _dst->artist = g_strdup(_src->artist); - if (_dst->artist == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->album != NULL) { + _dst->album = g_strdup(_src->album); + media_content_retv_free_video_if(_dst->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->album_artist != NULL) { - _dst->album_artist = g_strdup(_src->album_artist); - if (_dst->album_artist == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->artist != NULL) { + _dst->artist = g_strdup(_src->artist); + media_content_retv_free_video_if(_dst->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->genre != NULL) { - _dst->genre = g_strdup(_src->genre); - if (_dst->genre == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->album_artist != NULL) { + _dst->album_artist = g_strdup(_src->album_artist); + media_content_retv_free_video_if(_dst->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->composer != NULL) { - _dst->composer = g_strdup(_src->composer); - if (_dst->composer == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->genre != NULL) { + _dst->genre = g_strdup(_src->genre); + media_content_retv_free_video_if(_dst->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->year != NULL) { - _dst->year = g_strdup(_src->year); - if (_dst->year == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->composer != NULL) { + _dst->composer = g_strdup(_src->composer); + media_content_retv_free_video_if(_dst->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->recorded_date != NULL) { - _dst->recorded_date = g_strdup(_src->recorded_date); - if (_dst->recorded_date == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->year != NULL) { + _dst->year = g_strdup(_src->year); + media_content_retv_free_video_if(_dst->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->copyright != NULL) { - _dst->copyright = g_strdup(_src->copyright); - if (_dst->copyright == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->recorded_date != NULL) { + _dst->recorded_date = g_strdup(_src->recorded_date); + media_content_retv_free_video_if(_dst->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - if (_src->track_num != NULL) { - _dst->track_num = g_strdup(_src->track_num); - if (_dst->track_num == NULL) { - video_meta_destroy((video_meta_h)_dst); - media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + if (_src->copyright != NULL) { + _dst->copyright = g_strdup(_src->copyright); + media_content_retv_free_video_if(_dst->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - _dst->bitrate = _src->bitrate; - _dst->duration = _src->duration; - _dst->width = _src->width; - _dst->height = _src->height; - _dst->rotation = _src->rotation; + if (_src->track_num != NULL) { + _dst->track_num = g_strdup(_src->track_num); + media_content_retv_free_video_if(_dst->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst); + } - *dst = (video_meta_h)_dst; + _dst->bitrate = _src->bitrate; + _dst->duration = _src->duration; + _dst->width = _src->width; + _dst->height = _src->height; + _dst->rotation = _src->rotation; - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + *dst = (video_meta_h)_dst; - return ret; + return MEDIA_CONTENT_ERROR_NONE; } int video_meta_get_media_id(video_meta_h video, char **media_id) @@ -481,7 +431,7 @@ int video_meta_get_rotation(video_meta_h video, int *rotation) int video_meta_update_to_db(video_meta_h video) { - media_content_warn("DEPRECATION WARNING: video_meta_update_to_db() is deprecated and will be removed from next release."); + media_content_warn("DEPRECATION WARNING: video_meta_update_to_db() is deprecated and will be removed from next release."); video_meta_s *_video = (video_meta_s*)video; if (_video == NULL) { -- 2.7.4