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_image.h>
19 #include <media_content.h>
20 #include <media_info_private.h>
21 #include <media-svc.h>
24 int image_meta_destroy(image_meta_h image)
26 int ret = MEDIA_CONTENT_ERROR_NONE;
27 image_meta_s *_image = (image_meta_s*)image;
29 media_content_debug_func();
33 SAFE_FREE(_image->media_id);
34 SAFE_FREE(_image->date_taken);
35 SAFE_FREE(_image->burst_id);
38 ret = MEDIA_CONTENT_ERROR_NONE;
42 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
43 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
49 int image_meta_clone(image_meta_h *dst, image_meta_h src)
51 int ret = MEDIA_CONTENT_ERROR_NONE;
52 image_meta_s *_src = (image_meta_s*)src;
54 media_content_debug_func();
58 image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s));
61 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
62 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
65 if(STRING_VALID(_src->media_id))
67 _dst->media_id = strdup(_src->media_id);
68 if(_dst->media_id == NULL)
70 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
71 image_meta_destroy((image_meta_h)_dst);
72 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
76 if(STRING_VALID(_src->date_taken))
78 _dst->date_taken = strdup(_src->date_taken);
79 if(_dst->date_taken == NULL)
81 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
82 image_meta_destroy((image_meta_h)_dst);
83 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
87 if(STRING_VALID(_src->burst_id))
89 _dst->burst_id = strdup(_src->burst_id);
90 if(_dst->burst_id == NULL)
92 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
93 image_meta_destroy((image_meta_h)_dst);
94 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
98 _dst->width = _src->width;
99 _dst->height = _src->height;
100 _dst->orientation = _src->orientation;
102 *dst = (image_meta_h)_dst;
104 ret = MEDIA_CONTENT_ERROR_NONE;
108 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
109 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
115 int image_meta_get_media_id(image_meta_h image, char **media_id)
117 int ret = MEDIA_CONTENT_ERROR_NONE;
118 image_meta_s *_image = (image_meta_s*)image;
120 if(_image && media_id)
122 if(STRING_VALID(_image->media_id))
124 char *new_string = strdup(_image->media_id);
125 if(NULL == new_string)
127 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
128 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
130 *media_id = new_string;
136 ret = MEDIA_CONTENT_ERROR_NONE;
141 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
142 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
149 int image_meta_get_width(image_meta_h image, int *width)
151 int ret = MEDIA_CONTENT_ERROR_NONE;
152 image_meta_s *_image = (image_meta_s*)image;
156 *width = _image->width;
157 ret = MEDIA_CONTENT_ERROR_NONE;
161 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
162 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
167 int image_meta_get_height(image_meta_h image, int *height)
169 int ret = MEDIA_CONTENT_ERROR_NONE;
170 image_meta_s *_image = (image_meta_s*)image;
174 *height = _image->height;
175 ret = MEDIA_CONTENT_ERROR_NONE;
179 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
180 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
186 int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
188 int ret = MEDIA_CONTENT_ERROR_NONE;
189 image_meta_s *_image = (image_meta_s*)image;
191 if(_image && orientation)
193 *orientation = _image->orientation;
194 ret = MEDIA_CONTENT_ERROR_NONE;
198 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
199 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
205 int image_meta_get_date_taken(image_meta_h image, char **date_taken)
207 int ret = MEDIA_CONTENT_ERROR_NONE;
208 image_meta_s *_image = (image_meta_s*)image;
210 if(_image && date_taken)
212 if(STRING_VALID(_image->date_taken))
214 char *new_string = strdup(_image->date_taken);
215 if(NULL == new_string)
217 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
218 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
220 *date_taken = new_string;
227 ret = MEDIA_CONTENT_ERROR_NONE;
231 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
232 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
238 int image_meta_get_burst_id(image_meta_h image, char **burst_id)
240 int ret = MEDIA_CONTENT_ERROR_NONE;
241 image_meta_s *_image = (image_meta_s*)image;
243 if(_image && burst_id)
245 if(STRING_VALID(_image->burst_id))
247 *burst_id = strdup(_image->burst_id);
248 if(*burst_id == NULL)
250 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
251 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
258 ret = MEDIA_CONTENT_ERROR_NONE;
262 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
263 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
269 int image_meta_is_burst_shot(image_meta_h image, bool *is_burst_shot)
271 int ret = MEDIA_CONTENT_ERROR_NONE;
272 image_meta_s *_image = (image_meta_s*)image;
274 if(_image && is_burst_shot)
276 if(STRING_VALID(_image->burst_id))
277 *is_burst_shot = true;
279 *is_burst_shot = false;
281 ret = MEDIA_CONTENT_ERROR_NONE;
285 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
286 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
291 int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
293 int ret = MEDIA_CONTENT_ERROR_NONE;
294 image_meta_s *_image = (image_meta_s*)image;
298 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
299 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
302 if((orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE) || (orientation > MEDIA_CONTENT_ORIENTATION_ROT_270))
304 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
305 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
308 _image->orientation = orientation;
313 int image_meta_update_to_db(image_meta_h image)
315 int ret = MEDIA_CONTENT_ERROR_NONE;
316 image_meta_s *_image = (image_meta_s*)image;
319 if(_image != NULL && STRING_VALID(_image->media_id))
321 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id);
322 ret = _content_query_sql(sql);
327 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
328 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;