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_info_private.h>
20 int image_meta_destroy(image_meta_h image)
22 image_meta_s *_image = (image_meta_s*)image;
23 content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Image handle is null");
25 SAFE_FREE(_image->media_id);
26 SAFE_FREE(_image->date_taken);
27 SAFE_FREE(_image->exposure_time);
28 SAFE_FREE(_image->model);
31 return MEDIA_CONTENT_ERROR_NONE;
34 int image_meta_clone(image_meta_h *dst, image_meta_h src)
36 image_meta_s *_src = (image_meta_s*)src;
37 content_retvm_if(!_src, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
39 image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s));
40 content_retvm_if(!_dst, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
42 _dst->media_id = g_strdup(_src->media_id);
43 _dst->date_taken = g_strdup(_src->date_taken);
44 _dst->exposure_time = g_strdup(_src->exposure_time);
45 _dst->model = g_strdup(_src->model);
46 _dst->fnumber = _src->fnumber;
47 _dst->iso = _src->iso;
48 _dst->width = _src->width;
49 _dst->height = _src->height;
50 _dst->orientation = _src->orientation;
52 *dst = (image_meta_h)_dst;
54 return MEDIA_CONTENT_ERROR_NONE;
57 int image_meta_get_media_id(image_meta_h image, char **media_id)
59 image_meta_s *_image = (image_meta_s*)image;
60 content_retvm_if(!_image || !media_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
62 *media_id = g_strdup(_image->media_id);
64 return MEDIA_CONTENT_ERROR_NONE;
67 int image_meta_get_width(image_meta_h image, int *width)
69 image_meta_s *_image = (image_meta_s*)image;
70 content_retvm_if(!_image || !width, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
72 *width = _image->width;
74 return MEDIA_CONTENT_ERROR_NONE;
76 int image_meta_get_height(image_meta_h image, int *height)
78 image_meta_s *_image = (image_meta_s*)image;
79 content_retvm_if(!_image || !height, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
81 *height = _image->height;
83 return MEDIA_CONTENT_ERROR_NONE;
86 int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
88 image_meta_s *_image = (image_meta_s*)image;
89 content_retvm_if(!_image || !orientation, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
91 *orientation = _image->orientation;
93 return MEDIA_CONTENT_ERROR_NONE;
96 int image_meta_get_date_taken(image_meta_h image, char **date_taken)
98 image_meta_s *_image = (image_meta_s*)image;
99 content_retvm_if(!_image || !date_taken, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
101 *date_taken = g_strdup(_image->date_taken);
103 return MEDIA_CONTENT_ERROR_NONE;
106 int image_meta_get_exposure_time(image_meta_h image, char **exposure_time)
108 image_meta_s *_image = (image_meta_s*)image;
109 content_retvm_if(!_image || !exposure_time, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
111 *exposure_time = g_strdup(_image->exposure_time);
113 return MEDIA_CONTENT_ERROR_NONE;
116 int image_meta_get_fnumber(image_meta_h image, double *fnumber)
118 image_meta_s *_image = (image_meta_s*)image;
119 content_retvm_if(!_image || !fnumber, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
121 *fnumber = _image->fnumber;
123 return MEDIA_CONTENT_ERROR_NONE;
126 int image_meta_get_iso(image_meta_h image, int *iso)
128 image_meta_s *_image = (image_meta_s*)image;
129 content_retvm_if(!_image || !iso, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
133 return MEDIA_CONTENT_ERROR_NONE;
136 int image_meta_get_model(image_meta_h image, char **model)
138 image_meta_s *_image = (image_meta_s*)image;
139 content_retvm_if(!_image || !model, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
141 *model = g_strdup(_image->model);
143 return MEDIA_CONTENT_ERROR_NONE;
146 int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
148 content_warn("DEPRECATION WARNING: image_meta_set_orientation() is deprecated and will be removed from next release.");
149 image_meta_s *_image = (image_meta_s*)image;
150 content_retvm_if(!_image, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
151 content_retvm_if(orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE || orientation > MEDIA_CONTENT_ORIENTATION_ROT_270, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid orientation");
153 _image->orientation = orientation;
155 return MEDIA_CONTENT_ERROR_NONE;
158 int image_meta_update_to_db(image_meta_h image)
160 int ret = MEDIA_CONTENT_ERROR_NONE;
161 content_warn("DEPRECATION WARNING: image_meta_update_to_db() is deprecated and will be removed from next release.");
162 image_meta_s *_image = (image_meta_s*)image;
165 content_retvm_if(!_image || !STRING_VALID(_image->media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
167 #ifdef _USE_TVPD_MODE
168 char *storage_id = NULL;
169 ret = _media_db_get_storage_id_by_media_id(_image->media_id, &storage_id);
170 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
171 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, storage_id, _image->orientation, _image->media_id);
172 SAFE_FREE(storage_id);
174 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id);
176 ret = _content_query_sql(sql);
177 SQLITE3_SAFE_FREE(sql);