#include <media_info_private.h>
-#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)
{
video_meta_s *_video = (video_meta_s*)video;
- media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Video handle is null");
+ media_content_retvm_if(!_video, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Video handle is null");
SAFE_FREE(_video->media_id);
SAFE_FREE(_video->album);
int video_meta_clone(video_meta_h *dst, video_meta_h src)
{
video_meta_s *_src = (video_meta_s*)src;
- media_content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
+ media_content_retvm_if(!_src, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is 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);
- 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);
- media_content_retv_free_video_if(_dst->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (video_meta_h)_dst);
- }
-
- 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->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->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->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->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->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->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);
- }
-
- 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);
- }
-
+ media_content_retvm_if(!_dst, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ _dst->media_id = g_strdup(_src->media_id);
+ _dst->album = g_strdup(_src->album);
+ _dst->artist = g_strdup(_src->artist);
+ _dst->album_artist = g_strdup(_src->album_artist);
+ _dst->genre = g_strdup(_src->genre);
+ _dst->composer = g_strdup(_src->composer);
+ _dst->year = g_strdup(_src->year);
+ _dst->recorded_date = g_strdup(_src->recorded_date);
+ _dst->copyright = g_strdup(_src->copyright);
+ _dst->track_num = g_strdup(_src->track_num);
_dst->bitrate = _src->bitrate;
_dst->duration = _src->duration;
_dst->width = _src->width;
int video_meta_get_media_id(video_meta_h video, char **media_id)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->media_id != NULL) {
- char *new_string = strdup(_video->media_id);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *media_id = new_string;
- } else {
- *media_id = NULL;
- }
- 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;
+ media_content_retvm_if(!_video || !media_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *media_id = g_strdup(_video->media_id);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_album(video_meta_h video, char **album)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->album != NULL) {
- char *new_string = strdup(_video->album);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *album = new_string;
- } else {
- *album = NULL;
- }
- 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;
+ media_content_retvm_if(!_video || !album, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *album = g_strdup(_video->album);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_artist(video_meta_h video, char **artist)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->artist != NULL) {
- char *new_string = strdup(_video->artist);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *artist = new_string;
- } else {
- *artist = NULL;
- }
- 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;
+ media_content_retvm_if(!_video || !artist, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *artist = g_strdup(_video->artist);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_album_artist(video_meta_h video, char **album_artist)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->album_artist != NULL) {
- char *new_string = strdup(_video->album_artist);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *album_artist = new_string;
- } else {
- *album_artist = NULL;
- }
- 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;
+ media_content_retvm_if(!_video || !album_artist, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *album_artist = g_strdup(_video->album_artist);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_genre(video_meta_h video, char **genre)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->genre != NULL) {
- char *new_string = strdup(_video->genre);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *genre = new_string;
- } else {
- *genre = NULL;
- }
-
- 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;
+ media_content_retvm_if(!_video || !genre, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *genre = g_strdup(_video->genre);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_composer(video_meta_h video, char **composer)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->composer != NULL) {
- char *new_string = strdup(_video->composer);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *composer = new_string;
- } else {
- *composer = NULL;
- }
-
- 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;
+ media_content_retvm_if(!_video || !composer, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *composer = g_strdup(_video->composer);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_year(video_meta_h video, char **year)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->year != NULL) {
- char *new_string = strdup(_video->year);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *year = new_string;
- } else {
- *year = NULL;
- }
-
- 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;
+ media_content_retvm_if(!_video || !year, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *year = g_strdup(_video->year);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_recorded_date(video_meta_h video, char **recorded_date)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->recorded_date != NULL) {
- char *new_string = strdup(_video->recorded_date);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *recorded_date = new_string;
- } else {
- *recorded_date = NULL;
- }
-
- 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;
+ media_content_retvm_if(!_video || !recorded_date, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *recorded_date = g_strdup(_video->recorded_date);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_copyright(video_meta_h video, char **copyright)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->copyright != NULL) {
- char *new_string = strdup(_video->copyright);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *copyright = new_string;
- } else {
- *copyright = NULL;
- }
-
- 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;
+ media_content_retvm_if(!_video || !copyright, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *copyright = g_strdup(_video->copyright);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_track_num(video_meta_h video, char **track_num)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video) {
- if (_video->track_num != NULL) {
- char *new_string = strdup(_video->track_num);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- *track_num = new_string;
- } else {
- *track_num = NULL;
- }
-
- 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;
+ media_content_retvm_if(!_video || !track_num, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *track_num = g_strdup(_video->track_num);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_bit_rate(video_meta_h video, int *bit_rate)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
+ media_content_retvm_if(!_video || !bit_rate, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_video && bit_rate) {
- *bit_rate = _video->bitrate;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *bit_rate = _video->bitrate;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_duration(video_meta_h video, int *duration)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
+ media_content_retvm_if(!_video || !duration, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_video && duration) {
- *duration = _video->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;
- }
+ *duration = _video->duration;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_width(video_meta_h video, int *width)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
+ media_content_retvm_if(!_video || !width, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_video && width) {
- *width = _video->width;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *width = _video->width;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_height(video_meta_h video, int *height)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video && height) {
- *height = _video->height;
- 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;
+ media_content_retvm_if(!_video || !height, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *height = _video->height;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int video_meta_get_rotation(video_meta_h video, int *rotation)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
video_meta_s *_video = (video_meta_s*)video;
- if (_video && rotation) {
- *rotation = _video->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;
- }
-
- return ret;
+ media_content_retvm_if(!_video || !rotation, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ *rotation = _video->rotation;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}