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>
21 int image_meta_destroy(image_meta_h image)
23 int ret = MEDIA_CONTENT_ERROR_NONE;
24 image_meta_s *_image = (image_meta_s*)image;
28 SAFE_FREE(_image->media_id);
29 SAFE_FREE(_image->date_taken);
30 SAFE_FREE(_image->title);
31 SAFE_FREE(_image->weather);
32 SAFE_FREE(_image->burst_id);
33 SAFE_FREE(_image->exposure_time);
34 SAFE_FREE(_image->model);
37 ret = MEDIA_CONTENT_ERROR_NONE;
41 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
42 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
48 int image_meta_clone(image_meta_h *dst, image_meta_h src)
50 int ret = MEDIA_CONTENT_ERROR_NONE;
51 image_meta_s *_src = (image_meta_s*)src;
55 image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s));
56 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
58 if(STRING_VALID(_src->media_id))
60 _dst->media_id = strdup(_src->media_id);
61 if(_dst->media_id == NULL)
63 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
64 image_meta_destroy((image_meta_h)_dst);
65 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
69 if(STRING_VALID(_src->date_taken))
71 _dst->date_taken = strdup(_src->date_taken);
72 if(_dst->date_taken == NULL)
74 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
75 image_meta_destroy((image_meta_h)_dst);
76 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
80 if(STRING_VALID(_src->title))
82 _dst->title = strdup(_src->title);
83 if(_dst->title == NULL)
85 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
86 image_meta_destroy((image_meta_h)_dst);
87 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
91 if(STRING_VALID(_src->weather))
93 _dst->weather = strdup(_src->weather);
94 if(_dst->weather == NULL)
96 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
97 image_meta_destroy((image_meta_h)_dst);
98 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
102 if(STRING_VALID(_src->burst_id))
104 _dst->burst_id = strdup(_src->burst_id);
105 if(_dst->burst_id == NULL)
107 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
108 image_meta_destroy((image_meta_h)_dst);
109 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
113 if(STRING_VALID(_src->exposure_time))
115 _dst->exposure_time = strdup(_src->exposure_time);
116 if(_dst->exposure_time == NULL)
118 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
119 image_meta_destroy((image_meta_h)_dst);
120 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
124 if(STRING_VALID(_src->model))
126 _dst->model = strdup(_src->model);
127 if(_dst->model == NULL)
129 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
130 image_meta_destroy((image_meta_h)_dst);
131 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
135 _dst->fnumber = _src->fnumber;
136 _dst->iso = _src->iso;
137 _dst->width = _src->width;
138 _dst->height = _src->height;
139 _dst->orientation = _src->orientation;
141 *dst = (image_meta_h)_dst;
143 ret = MEDIA_CONTENT_ERROR_NONE;
147 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
148 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
154 int image_meta_get_media_id(image_meta_h image, char **media_id)
156 int ret = MEDIA_CONTENT_ERROR_NONE;
157 image_meta_s *_image = (image_meta_s*)image;
159 if(_image && media_id)
161 if(STRING_VALID(_image->media_id))
163 char *new_string = strdup(_image->media_id);
164 media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
166 *media_id = new_string;
172 ret = MEDIA_CONTENT_ERROR_NONE;
177 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
178 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
185 int image_meta_get_width(image_meta_h image, int *width)
187 int ret = MEDIA_CONTENT_ERROR_NONE;
188 image_meta_s *_image = (image_meta_s*)image;
192 *width = _image->width;
193 ret = MEDIA_CONTENT_ERROR_NONE;
197 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
198 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
203 int image_meta_get_height(image_meta_h image, int *height)
205 int ret = MEDIA_CONTENT_ERROR_NONE;
206 image_meta_s *_image = (image_meta_s*)image;
210 *height = _image->height;
211 ret = MEDIA_CONTENT_ERROR_NONE;
215 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
216 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
222 int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
224 int ret = MEDIA_CONTENT_ERROR_NONE;
225 image_meta_s *_image = (image_meta_s*)image;
227 if(_image && orientation)
229 *orientation = _image->orientation;
230 ret = MEDIA_CONTENT_ERROR_NONE;
234 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
235 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
241 int image_meta_get_date_taken(image_meta_h image, char **date_taken)
243 int ret = MEDIA_CONTENT_ERROR_NONE;
244 image_meta_s *_image = (image_meta_s*)image;
246 if(_image && date_taken)
248 if(STRING_VALID(_image->date_taken))
250 char *new_string = strdup(_image->date_taken);
251 media_content_retvm_if(new_string == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
253 *date_taken = new_string;
260 ret = MEDIA_CONTENT_ERROR_NONE;
264 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
265 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
271 int image_meta_get_burst_id(image_meta_h image, char **burst_id)
273 int ret = MEDIA_CONTENT_ERROR_NONE;
274 image_meta_s *_image = (image_meta_s*)image;
276 if(_image && burst_id)
278 if(STRING_VALID(_image->burst_id))
280 *burst_id = strdup(_image->burst_id);
281 media_content_retvm_if(*burst_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
287 ret = MEDIA_CONTENT_ERROR_NONE;
291 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
292 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
298 int image_meta_get_exposure_time(image_meta_h image, char **exposure_time)
300 int ret = MEDIA_CONTENT_ERROR_NONE;
301 image_meta_s *_image = (image_meta_s*)image;
303 if(_image && exposure_time)
305 if(STRING_VALID(_image->exposure_time))
307 *exposure_time = strdup(_image->exposure_time);
308 media_content_retvm_if(*exposure_time == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
312 *exposure_time = NULL;
314 ret = MEDIA_CONTENT_ERROR_NONE;
318 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
319 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
325 int image_meta_get_fnumber(image_meta_h image, double *fnumber)
327 int ret = MEDIA_CONTENT_ERROR_NONE;
328 image_meta_s *_image = (image_meta_s*)image;
330 if(_image && fnumber)
332 *fnumber = _image->fnumber;
333 ret = MEDIA_CONTENT_ERROR_NONE;
337 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
338 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
344 int image_meta_get_iso(image_meta_h image, int *iso)
346 int ret = MEDIA_CONTENT_ERROR_NONE;
347 image_meta_s *_image = (image_meta_s*)image;
352 ret = MEDIA_CONTENT_ERROR_NONE;
356 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
357 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
363 int image_meta_get_model(image_meta_h image, char **model)
365 int ret = MEDIA_CONTENT_ERROR_NONE;
366 image_meta_s *_image = (image_meta_s*)image;
370 if(STRING_VALID(_image->model))
372 *model = strdup(_image->model);
373 media_content_retvm_if(*model == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
379 ret = MEDIA_CONTENT_ERROR_NONE;
383 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
384 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
390 int image_meta_is_burst_shot(image_meta_h image, bool *is_burst_shot)
392 int ret = MEDIA_CONTENT_ERROR_NONE;
393 image_meta_s *_image = (image_meta_s*)image;
395 if(_image && is_burst_shot)
397 if(STRING_VALID(_image->burst_id))
398 *is_burst_shot = true;
400 *is_burst_shot = false;
402 ret = MEDIA_CONTENT_ERROR_NONE;
406 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
407 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
413 int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
415 int ret = MEDIA_CONTENT_ERROR_NONE;
416 image_meta_s *_image = (image_meta_s*)image;
420 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
421 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
424 if((orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE) || (orientation > MEDIA_CONTENT_ORIENTATION_ROT_270))
426 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
427 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
430 _image->orientation = orientation;
435 int image_meta_update_to_db(image_meta_h image)
437 int ret = MEDIA_CONTENT_ERROR_NONE;
438 image_meta_s *_image = (image_meta_s*)image;
441 if(_image != NULL && STRING_VALID(_image->media_id))
443 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
444 memset(storage_id, 0x00, sizeof(storage_id));
446 ret = _media_db_get_storage_id_by_media_id(_image->media_id, storage_id);
447 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
449 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, storage_id, _image->orientation, _image->weather, _image->media_id);
450 ret = _content_query_sql(sql);
455 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
456 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;