#include <media_info_private.h>
-#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)
{
image_meta_s *_image = (image_meta_s*)image;
int image_meta_clone(image_meta_h *dst, image_meta_h src)
{
image_meta_s *_src = (image_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");
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);
- media_content_retv_free_image_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (image_meta_h)_dst);
- }
-
- 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->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);
- }
-
- 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);
- }
+ media_content_retvm_if(!_dst, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ _dst->media_id = g_strdup(_src->media_id);
+ _dst->date_taken = g_strdup(_src->date_taken);
+ _dst->exposure_time = g_strdup(_src->exposure_time);
+ _dst->model = g_strdup(_src->model);
_dst->fnumber = _src->fnumber;
_dst->iso = _src->iso;
_dst->width = _src->width;
int image_meta_get_media_id(image_meta_h image, char **media_id)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !media_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && media_id) {
- if (STRING_VALID(_image->media_id)) {
- char *new_string = strdup(_image->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_id = g_strdup(_image->media_id);
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_width(image_meta_h image, int *width)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !width, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && width) {
- *width = _image->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 = _image->width;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_height(image_meta_h image, int *height)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !height, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && height) {
- *height = _image->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;
- }
+ *height = _image->height;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !orientation, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && orientation) {
- *orientation = _image->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;
- }
+ *orientation = _image->orientation;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_date_taken(image_meta_h image, char **date_taken)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !date_taken, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && date_taken) {
- if (STRING_VALID(_image->date_taken)) {
- char *new_string = strdup(_image->date_taken);
- media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ *date_taken = g_strdup(_image->date_taken);
- *date_taken = new_string;
- } else {
- *date_taken = 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;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_exposure_time(image_meta_h image, char **exposure_time)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !exposure_time, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && exposure_time) {
- if (STRING_VALID(_image->exposure_time)) {
- *exposure_time = strdup(_image->exposure_time);
- media_content_retvm_if(*exposure_time == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *exposure_time = 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;
- }
+ *exposure_time = g_strdup(_image->exposure_time);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_fnumber(image_meta_h image, double *fnumber)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !fnumber, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && fnumber) {
- *fnumber = _image->fnumber;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *fnumber = _image->fnumber;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_iso(image_meta_h image, int *iso)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !iso, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && iso) {
- *iso = _image->iso;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *iso = _image->iso;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_get_model(image_meta_h image, char **model)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
+ media_content_retvm_if(!_image || !model, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (_image && model) {
- if (STRING_VALID(_image->model)) {
- *model = strdup(_image->model);
- media_content_retvm_if(*model == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *model = 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;
- }
+ *model = g_strdup(_image->model);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_content_warn("DEPRECATION WARNING: image_meta_set_orientation() is deprecated and will be removed from next release.");
image_meta_s *_image = (image_meta_s*)image;
-
- if (_image == NULL) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if ((orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE) || (orientation > MEDIA_CONTENT_ORIENTATION_ROT_270)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ media_content_retvm_if(!_image, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ media_content_retvm_if(orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE || orientation > MEDIA_CONTENT_ORIENTATION_ROT_270, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid orientation");
_image->orientation = orientation;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int image_meta_update_to_db(image_meta_h image)
image_meta_s *_image = (image_meta_s*)image;
char *sql = NULL;
- if (_image != NULL && STRING_VALID(_image->media_id)) {
+ media_content_retvm_if(!_image || !STRING_VALID(_image->media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
#ifdef _USE_TVPD_MODE
char *storage_id = NULL;
ret = _media_db_get_storage_id_by_media_id(_image->media_id, &storage_id);
#endif
ret = _content_query_sql(sql);
SQLITE3_SAFE_FREE(sql);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
return ret;
}