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;
24 content_retip_if_fail(image);
26 g_free(_image->media_id);
27 g_free(_image->date_taken);
28 g_free(_image->exposure_time);
29 g_free(_image->model);
32 return MEDIA_CONTENT_ERROR_NONE;
35 int image_meta_clone(image_meta_h *dst, image_meta_h src)
37 image_meta_s *_src = (image_meta_s*)src;
39 content_retip_if_fail(dst);
40 content_retip_if_fail(src);
42 image_meta_s *_dst = g_new0(image_meta_s, 1);
44 _dst->media_id = g_strdup(_src->media_id);
45 _dst->date_taken = g_strdup(_src->date_taken);
46 _dst->exposure_time = g_strdup(_src->exposure_time);
47 _dst->model = g_strdup(_src->model);
48 _dst->fnumber = _src->fnumber;
49 _dst->iso = _src->iso;
50 _dst->width = _src->width;
51 _dst->height = _src->height;
52 _dst->orientation = _src->orientation;
54 *dst = (image_meta_h)_dst;
56 return MEDIA_CONTENT_ERROR_NONE;
59 int image_meta_get_media_id(image_meta_h image, char **media_id)
61 image_meta_s *_image = (image_meta_s*)image;
63 content_retip_if_fail(image);
64 content_retip_if_fail(media_id);
66 *media_id = g_strdup(_image->media_id);
68 return MEDIA_CONTENT_ERROR_NONE;
71 int image_meta_get_width(image_meta_h image, int *width)
73 image_meta_s *_image = (image_meta_s*)image;
75 content_retip_if_fail(image);
76 content_retip_if_fail(width);
78 *width = _image->width;
80 return MEDIA_CONTENT_ERROR_NONE;
82 int image_meta_get_height(image_meta_h image, int *height)
84 image_meta_s *_image = (image_meta_s*)image;
86 content_retip_if_fail(image);
87 content_retip_if_fail(height);
89 *height = _image->height;
91 return MEDIA_CONTENT_ERROR_NONE;
94 int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
96 image_meta_s *_image = (image_meta_s*)image;
98 content_retip_if_fail(image);
99 content_retip_if_fail(orientation);
101 *orientation = _image->orientation;
103 return MEDIA_CONTENT_ERROR_NONE;
106 int image_meta_get_date_taken(image_meta_h image, char **date_taken)
108 image_meta_s *_image = (image_meta_s*)image;
110 content_retip_if_fail(image);
111 content_retip_if_fail(date_taken);
113 *date_taken = g_strdup(_image->date_taken);
115 return MEDIA_CONTENT_ERROR_NONE;
118 int image_meta_get_exposure_time(image_meta_h image, char **exposure_time)
120 image_meta_s *_image = (image_meta_s*)image;
122 content_retip_if_fail(image);
123 content_retip_if_fail(exposure_time);
125 *exposure_time = g_strdup(_image->exposure_time);
127 return MEDIA_CONTENT_ERROR_NONE;
130 int image_meta_get_fnumber(image_meta_h image, double *fnumber)
132 image_meta_s *_image = (image_meta_s*)image;
134 content_retip_if_fail(image);
135 content_retip_if_fail(fnumber);
137 *fnumber = _image->fnumber;
139 return MEDIA_CONTENT_ERROR_NONE;
142 int image_meta_get_iso(image_meta_h image, int *iso)
144 image_meta_s *_image = (image_meta_s*)image;
146 content_retip_if_fail(image);
147 content_retip_if_fail(iso);
151 return MEDIA_CONTENT_ERROR_NONE;
154 int image_meta_get_model(image_meta_h image, char **model)
156 image_meta_s *_image = (image_meta_s*)image;
158 content_retip_if_fail(image);
159 content_retip_if_fail(model);
161 *model = g_strdup(_image->model);
163 return MEDIA_CONTENT_ERROR_NONE;
166 int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
168 content_warn("DEPRECATION WARNING: image_meta_set_orientation() is deprecated and will be removed from next release.");
169 image_meta_s *_image = (image_meta_s*)image;
171 content_retip_if_fail(image);
172 content_retvm_if(orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE || orientation > MEDIA_CONTENT_ORIENTATION_ROT_270, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid orientation");
174 _image->orientation = orientation;
176 return MEDIA_CONTENT_ERROR_NONE;
179 int image_meta_update_to_db(image_meta_h image)
181 int ret = MEDIA_CONTENT_ERROR_NONE;
182 content_warn("DEPRECATION WARNING: image_meta_update_to_db() is deprecated and will be removed from next release.");
183 image_meta_s *_image = (image_meta_s*)image;
186 content_retip_if_fail(image);
187 content_retip_if_fail(STRING_VALID(_image->media_id));
189 #ifdef _USE_TVPD_MODE
190 char *storage_id = NULL;
191 ret = _media_db_get_storage_id_by_media_id(_image->media_id, &storage_id);
192 content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
193 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, storage_id, _image->orientation, _image->media_id);
196 sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id);
198 ret = _content_query_sql(sql);
199 SQLITE3_SAFE_FREE(sql);