Remove out of memory related code by using glib APIs
[platform/core/api/media-content.git] / src / media_video.c
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 #include <media_info_private.h>
19
20 int video_meta_destroy(video_meta_h video)
21 {
22         video_meta_s *_video = (video_meta_s*)video;
23         content_retvm_if(!_video, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Video handle is null");
24
25         g_free(_video->media_id);
26         g_free(_video->album);
27         g_free(_video->artist);
28         g_free(_video->album_artist);
29         g_free(_video->genre);
30         g_free(_video->composer);
31         g_free(_video->year);
32         g_free(_video->recorded_date);
33         g_free(_video->copyright);
34         g_free(_video->track_num);
35         g_free(_video);
36
37         return MEDIA_CONTENT_ERROR_NONE;
38 }
39
40 int video_meta_clone(video_meta_h *dst, video_meta_h src)
41 {
42         video_meta_s *_src = (video_meta_s*)src;
43
44         content_retip_if_fail(dst);
45         content_retip_if_fail(src);
46
47         video_meta_s *_dst = g_new(video_meta_s, 1);
48
49         _dst->media_id = g_strdup(_src->media_id);
50         _dst->album = g_strdup(_src->album);
51         _dst->artist = g_strdup(_src->artist);
52         _dst->album_artist = g_strdup(_src->album_artist);
53         _dst->genre = g_strdup(_src->genre);
54         _dst->composer = g_strdup(_src->composer);
55         _dst->year = g_strdup(_src->year);
56         _dst->recorded_date = g_strdup(_src->recorded_date);
57         _dst->copyright = g_strdup(_src->copyright);
58         _dst->track_num = g_strdup(_src->track_num);
59         _dst->bitrate = _src->bitrate;
60         _dst->duration = _src->duration;
61         _dst->width = _src->width;
62         _dst->height = _src->height;
63         _dst->rotation = _src->rotation;
64
65         *dst = (video_meta_h)_dst;
66
67         return MEDIA_CONTENT_ERROR_NONE;
68 }
69
70 int video_meta_get_media_id(video_meta_h video, char **media_id)
71 {
72         video_meta_s *_video = (video_meta_s*)video;
73
74         content_retip_if_fail(video);
75         content_retip_if_fail(media_id);
76
77         *media_id = g_strdup(_video->media_id);
78
79         return MEDIA_CONTENT_ERROR_NONE;
80 }
81
82 int video_meta_get_album(video_meta_h video, char **album)
83 {
84         video_meta_s *_video = (video_meta_s*)video;
85
86         content_retip_if_fail(video);
87         content_retip_if_fail(album);
88
89         *album = g_strdup(_video->album);
90
91         return MEDIA_CONTENT_ERROR_NONE;
92 }
93
94 int video_meta_get_artist(video_meta_h video, char **artist)
95 {
96         video_meta_s *_video = (video_meta_s*)video;
97
98         content_retip_if_fail(video);
99         content_retip_if_fail(artist);
100
101         *artist = g_strdup(_video->artist);
102
103         return MEDIA_CONTENT_ERROR_NONE;
104 }
105
106 int video_meta_get_album_artist(video_meta_h video, char **album_artist)
107 {
108         video_meta_s *_video = (video_meta_s*)video;
109
110         content_retip_if_fail(video);
111         content_retip_if_fail(album_artist);
112
113         *album_artist = g_strdup(_video->album_artist);
114
115         return MEDIA_CONTENT_ERROR_NONE;
116 }
117
118 int video_meta_get_genre(video_meta_h video, char **genre)
119 {
120         video_meta_s *_video = (video_meta_s*)video;
121
122         content_retip_if_fail(video);
123         content_retip_if_fail(genre);
124
125         *genre = g_strdup(_video->genre);
126
127         return MEDIA_CONTENT_ERROR_NONE;
128 }
129
130 int video_meta_get_composer(video_meta_h video, char **composer)
131 {
132         video_meta_s *_video = (video_meta_s*)video;
133
134         content_retip_if_fail(video);
135         content_retip_if_fail(composer);
136
137         *composer = g_strdup(_video->composer);
138
139         return MEDIA_CONTENT_ERROR_NONE;
140 }
141
142 int video_meta_get_year(video_meta_h video, char **year)
143 {
144         video_meta_s *_video = (video_meta_s*)video;
145
146         content_retip_if_fail(video);
147         content_retip_if_fail(year);
148
149         *year = g_strdup(_video->year);
150
151         return MEDIA_CONTENT_ERROR_NONE;
152 }
153
154 int video_meta_get_recorded_date(video_meta_h video, char **recorded_date)
155 {
156         video_meta_s *_video = (video_meta_s*)video;
157
158         content_retip_if_fail(video);
159         content_retip_if_fail(recorded_date);
160
161         *recorded_date = g_strdup(_video->recorded_date);
162
163         return MEDIA_CONTENT_ERROR_NONE;
164 }
165
166 int video_meta_get_copyright(video_meta_h video, char **copyright)
167 {
168         video_meta_s *_video = (video_meta_s*)video;
169
170         content_retip_if_fail(video);
171         content_retip_if_fail(copyright);
172
173         *copyright = g_strdup(_video->copyright);
174
175         return MEDIA_CONTENT_ERROR_NONE;
176 }
177
178 int video_meta_get_track_num(video_meta_h video, char **track_num)
179 {
180         video_meta_s *_video = (video_meta_s*)video;
181
182         content_retip_if_fail(video);
183         content_retip_if_fail(track_num);
184
185         *track_num = g_strdup(_video->track_num);
186
187         return MEDIA_CONTENT_ERROR_NONE;
188 }
189
190 int video_meta_get_bit_rate(video_meta_h video, int *bit_rate)
191 {
192         video_meta_s *_video = (video_meta_s*)video;
193         content_retvm_if(!_video || !bit_rate, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
194
195         *bit_rate = _video->bitrate;
196
197         return MEDIA_CONTENT_ERROR_NONE;
198 }
199
200 int video_meta_get_duration(video_meta_h video, int *duration)
201 {
202         video_meta_s *_video = (video_meta_s*)video;
203         content_retvm_if(!_video || !duration, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
204
205         *duration = _video->duration;
206
207         return MEDIA_CONTENT_ERROR_NONE;
208 }
209
210 int video_meta_get_width(video_meta_h video, int *width)
211 {
212         video_meta_s *_video = (video_meta_s*)video;
213         content_retvm_if(!_video || !width, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
214
215         *width = _video->width;
216
217         return MEDIA_CONTENT_ERROR_NONE;
218 }
219
220 int video_meta_get_height(video_meta_h video, int *height)
221 {
222         video_meta_s *_video = (video_meta_s*)video;
223         content_retvm_if(!_video || !height, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
224
225         *height = _video->height;
226
227         return MEDIA_CONTENT_ERROR_NONE;
228 }
229
230 int video_meta_get_rotation(video_meta_h video, int *rotation)
231 {
232         video_meta_s *_video = (video_meta_s*)video;
233         content_retvm_if(!_video || !rotation, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
234
235         *rotation = _video->rotation;
236
237         return MEDIA_CONTENT_ERROR_NONE;
238 }