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 g_free(_image->media_id);
26 g_free(_image->date_taken);
27 g_free(_image->exposure_time);
28 g_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;
38 content_retip_if_fail(dst);
39 content_retip_if_fail(src);
41 image_meta_s *_dst = g_new0(image_meta_s, 1);
43 _dst->media_id = g_strdup(_src->media_id);
44 _dst->date_taken = g_strdup(_src->date_taken);
45 _dst->exposure_time = g_strdup(_src->exposure_time);
46 _dst->model = g_strdup(_src->model);
47 _dst->fnumber = _src->fnumber;
48 _dst->iso = _src->iso;
49 _dst->width = _src->width;
50 _dst->height = _src->height;
51 _dst->orientation = _src->orientation;
53 *dst = (image_meta_h)_dst;
55 return MEDIA_CONTENT_ERROR_NONE;
58 int image_meta_get_media_id(image_meta_h image, char **media_id)
60 image_meta_s *_image = (image_meta_s*)image;
62 content_retip_if_fail(image);
63 content_retip_if_fail(media_id);
65 *media_id = g_strdup(_image->media_id);
67 return MEDIA_CONTENT_ERROR_NONE;
70 int image_meta_get_width(image_meta_h image, int *width)
72 image_meta_s *_image = (image_meta_s*)image;
73 content_retvm_if(!_image || !width, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
75 *width = _image->width;
77 return MEDIA_CONTENT_ERROR_NONE;
79 int image_meta_get_height(image_meta_h image, int *height)
81 image_meta_s *_image = (image_meta_s*)image;
82 content_retvm_if(!_image || !height, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
84 *height = _image->height;
86 return MEDIA_CONTENT_ERROR_NONE;
89 int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
91 image_meta_s *_image = (image_meta_s*)image;
92 content_retvm_if(!_image || !orientation, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
94 *orientation = _image->orientation;
96 return MEDIA_CONTENT_ERROR_NONE;
99 int image_meta_get_date_taken(image_meta_h image, char **date_taken)
101 image_meta_s *_image = (image_meta_s*)image;
103 content_retip_if_fail(image);
104 content_retip_if_fail(date_taken);
106 *date_taken = g_strdup(_image->date_taken);
108 return MEDIA_CONTENT_ERROR_NONE;
111 int image_meta_get_exposure_time(image_meta_h image, char **exposure_time)
113 image_meta_s *_image = (image_meta_s*)image;
115 content_retip_if_fail(image);
116 content_retip_if_fail(exposure_time);
118 *exposure_time = g_strdup(_image->exposure_time);
120 return MEDIA_CONTENT_ERROR_NONE;
123 int image_meta_get_fnumber(image_meta_h image, double *fnumber)
125 image_meta_s *_image = (image_meta_s*)image;
126 content_retvm_if(!_image || !fnumber, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
128 *fnumber = _image->fnumber;
130 return MEDIA_CONTENT_ERROR_NONE;
133 int image_meta_get_iso(image_meta_h image, int *iso)
135 image_meta_s *_image = (image_meta_s*)image;
136 content_retvm_if(!_image || !iso, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
140 return MEDIA_CONTENT_ERROR_NONE;
143 int image_meta_get_model(image_meta_h image, char **model)
145 image_meta_s *_image = (image_meta_s*)image;
147 content_retip_if_fail(image);
148 content_retip_if_fail(model);
150 *model = g_strdup(_image->model);
152 return MEDIA_CONTENT_ERROR_NONE;
155 int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
157 content_warn("DEPRECATION WARNING: image_meta_set_orientation() is deprecated and will be removed from next release.");
158 image_meta_s *_image = (image_meta_s*)image;
159 content_retvm_if(!_image, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
160 content_retvm_if(orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE || orientation > MEDIA_CONTENT_ORIENTATION_ROT_270, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid orientation");
162 _image->orientation = orientation;
164 return MEDIA_CONTENT_ERROR_NONE;
167 int image_meta_update_to_db(image_meta_h image)
169 int ret = MEDIA_CONTENT_ERROR_NONE;
170 content_warn("DEPRECATION WARNING: image_meta_update_to_db() is deprecated and will be removed from next release.");
171 image_meta_s *_image = (image_meta_s*)image;
174 content_retvm_if(!_image || !STRING_VALID(_image->media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
176 #ifdef _USE_TVPD_MODE
177 char *storage_id = NULL;
178 ret = _media_db_get_storage_id_by_media_id(_image->media_id, &storage_id);
179 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
180 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, storage_id, _image->orientation, _image->media_id);
183 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id);
185 ret = _content_query_sql(sql);
186 SQLITE3_SAFE_FREE(sql);