1 /*
2  * Copyright (C) 2010, 2011 Igalia S.L.
3  *
4  * Contact: Iago Toral Quiroga <itoral@igalia.com>
5  *
6  * Authors: Juan A. Suarez Romero <jasuarez@igalia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #if !defined (_GRILO_H_INSIDE_) && !defined (GRILO_COMPILATION)
26 #error "Only <grilo.h> can be included directly."
27 #endif
28 
29 #ifndef _GRL_MEDIA_H_
30 #define _GRL_MEDIA_H_
31 
32 #include <grl-data.h>
33 #include <grl-definitions.h>
34 
35 G_BEGIN_DECLS
36 
37 #define GRL_TYPE_MEDIA                          \
38   (grl_media_get_type())
39 
40 #define GRL_MEDIA(obj)                          \
41   (G_TYPE_CHECK_INSTANCE_CAST ((obj),           \
42                                GRL_TYPE_MEDIA,  \
43                                GrlMedia))
44 
45 #define GRL_MEDIA_CLASS(klass)                  \
46   (G_TYPE_CHECK_CLASS_CAST ((klass),            \
47                             GRL_TYPE_MEDIA,     \
48                             GrlMediaClass))
49 
50 #define GRL_IS_MEDIA(obj)                       \
51   (G_TYPE_CHECK_INSTANCE_TYPE ((obj),           \
52                                GRL_TYPE_MEDIA))
53 
54 #define GRL_IS_MEDIA_CLASS(klass)               \
55   (G_TYPE_CHECK_CLASS_TYPE ((klass),            \
56                             GRL_TYPE_MEDIA))
57 
58 #define GRL_MEDIA_GET_CLASS(obj)                \
59   (G_TYPE_INSTANCE_GET_CLASS ((obj),            \
60                               GRL_TYPE_MEDIA,   \
61                               GrlMediaClass))
62 
63 /**
64  * GrlMediaSerializeType:
65  * @GRL_MEDIA_SERIALIZE_BASIC: Basic mode
66  * @GRL_MEDIA_SERIALIZE_PARTIAL: Partial mode
67  * @GRL_MEDIA_SERIALIZE_FULL: Full mode
68  *
69  * GrlMedia serialize type
70  *
71  * Since: 0.2.3
72  */
73 typedef enum {
74   GRL_MEDIA_SERIALIZE_BASIC,
75   GRL_MEDIA_SERIALIZE_PARTIAL,
76   GRL_MEDIA_SERIALIZE_FULL
77 } GrlMediaSerializeType;
78 
79 
80 typedef struct _GrlMedia        GrlMedia;
81 typedef struct _GrlMediaPrivate GrlMediaPrivate;
82 typedef struct _GrlMediaClass   GrlMediaClass;
83 
84 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlMedia, g_object_unref)
85 
86 struct _GrlMedia
87 {
88   GrlData parent;
89 
90   /*< private >*/
91   GrlMediaPrivate *priv;
92   gpointer _grl_reserved[GRL_PADDING_SMALL];
93 };
94 
95 /**
96  * GrlMediaClass:
97  * @parent_class: the parent class structure
98  *
99  * Grilo Media Class
100  */
101 struct _GrlMediaClass
102 {
103   GrlDataClass parent_class;
104 
105   /*< private >*/
106   gpointer _grl_reserved[GRL_PADDING];
107 };
108 
109 void grl_media_set_id (GrlMedia *media, const gchar *id);
110 
111 void grl_media_set_url (GrlMedia *media, const gchar *url);
112 
113 void grl_media_set_author (GrlMedia *media, const gchar *author);
114 
115 void grl_media_set_title (GrlMedia *media, const gchar *title);
116 
117 void grl_media_set_description (GrlMedia *media, const gchar *description);
118 
119 void grl_media_set_source (GrlMedia *media, const gchar *source);
120 
121 void grl_media_set_thumbnail (GrlMedia *media, const gchar *thumbnail);
122 
123 void grl_media_set_thumbnail_binary (GrlMedia *media, const guint8 *thumbnail, gsize size);
124 
125 void grl_media_set_site (GrlMedia *media, const gchar *site);
126 
127 void grl_media_set_duration (GrlMedia *media, gint duration);
128 
129 void grl_media_set_publication_date (GrlMedia *media, const GDateTime *date);
130 
131 void grl_media_set_region (GrlMedia *media,
132                            const gchar *region);
133 
134 void grl_media_set_region_data (GrlMedia *media,
135                                 const gchar *region,
136                                 const GDateTime *publication_date,
137                                 const gchar *certificate);
138 
139 void grl_media_add_region_data (GrlMedia *media,
140                                 const gchar *region,
141                                 const GDateTime *publication_date,
142                                 const gchar *certificate);
143 
144 void grl_media_set_creation_date (GrlMedia *media,
145                                   const GDateTime *creation_date);
146 
147 void grl_media_set_modification_date (GrlMedia *media,
148                                       const GDateTime *modification_date);
149 
150 void grl_media_set_mime (GrlMedia *media, const gchar *mime);
151 
152 void grl_media_set_play_count (GrlMedia *media, gint play_count);
153 
154 void grl_media_set_last_played (GrlMedia *media, const GDateTime *last_played);
155 
156 void grl_media_set_last_position (GrlMedia *media, gint last_position);
157 
158 void grl_media_set_external_player (GrlMedia *media, const gchar *player);
159 
160 void grl_media_set_external_url (GrlMedia *media, const gchar *url);
161 
162 void grl_media_set_studio (GrlMedia *media, const gchar *studio);
163 
164 void grl_media_set_certificate (GrlMedia *media, const gchar *certificate);
165 
166 void grl_media_set_license (GrlMedia *media, const gchar *license);
167 
168 void grl_media_set_rating (GrlMedia *media, gfloat rating, gfloat max);
169 
170 void grl_media_set_url_data (GrlMedia *media, const gchar *url, const gchar *mime, gint bitrate, gfloat framerate, gint width, gint height);
171 
172 void grl_media_set_favourite (GrlMedia *media, gboolean favourite);
173 
174 void grl_media_set_keyword (GrlMedia *media, const gchar *keyword);
175 
176 void grl_media_set_size (GrlMedia *media, gint64 size);
177 
178 void grl_media_set_track_number (GrlMedia *media, gint track_number);
179 
180 void grl_media_set_bitrate (GrlMedia *media, gint bitrate);
181 
182 void grl_media_set_mb_track_id (GrlMedia *media, const gchar *mb_track_id);
183 
184 void grl_media_set_mb_recording_id (GrlMedia *media, const gchar *mb_recording_id);
185 
186 void grl_media_set_mb_artist_id (GrlMedia *media, const gchar *mb_artist_id);
187 
188 G_DEPRECATED
189 void grl_media_set_mb_album_id (GrlMedia *media, const gchar *mb_album_id);
190 
191 void grl_media_set_mb_release_id (GrlMedia *media, const gchar *mb_release_id);
192 
193 void grl_media_set_mb_release_group_id (GrlMedia *media, const gchar *mb_release_group_id);
194 
195 void grl_media_set_lyrics (GrlMedia *media, const gchar *lyrics);
196 
197 void grl_media_set_genre (GrlMedia *media, const gchar *genre);
198 
199 void grl_media_set_album (GrlMedia *media, const gchar *album);
200 
201 void grl_media_set_album_artist (GrlMedia *media, const gchar *album_artist);
202 
203 void grl_media_set_album_disc_number (GrlMedia *media, gint disc_number);
204 
205 void grl_media_set_artist (GrlMedia *media, const gchar *artist);
206 
207 void grl_media_set_composer (GrlMedia *media, const gchar *composer);
208 
209 void grl_media_set_width (GrlMedia *media, gint width);
210 
211 void grl_media_set_height (GrlMedia *media, gint height);
212 
213 void grl_media_set_framerate (GrlMedia *media, gfloat framerate);
214 
215 void grl_media_set_season (GrlMedia *media, gint season);
216 
217 void grl_media_set_episode (GrlMedia *media, gint episode);
218 
219 void grl_media_set_episode_title (GrlMedia *media, const gchar *episode_title);
220 
221 void grl_media_set_show (GrlMedia *media, const gchar *show);
222 
223 void grl_media_set_performer (GrlMedia *media, const gchar *performer);
224 
225 void grl_media_set_producer (GrlMedia *media, const gchar *producer);
226 
227 void grl_media_set_director (GrlMedia *media, const gchar *director);
228 
229 void grl_media_set_original_title (GrlMedia *media, const gchar *original_title);
230 
231 void grl_media_set_camera_model (GrlMedia *media, const gchar *camera_model);
232 
233 void grl_media_set_flash_used (GrlMedia *media, const gchar *flash_used);
234 
235 void grl_media_set_exposure_time (GrlMedia *media, gfloat exposure_time);
236 
237 void grl_media_set_iso_speed (GrlMedia *media, gfloat iso_speed);
238 
239 void grl_media_set_orientation (GrlMedia *media, gint orientation);
240 
241 void grl_media_set_childcount (GrlMedia *media, gint childcount);
242 
243 void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime, gint bitrate, gfloat framerate, gint width, gint height);
244 
245 void grl_media_add_author (GrlMedia *media, const gchar *author);
246 
247 void grl_media_add_thumbnail (GrlMedia *media, const gchar *thumbnail);
248 
249 void grl_media_add_thumbnail_binary (GrlMedia *media, const guint8 *thumbnail, gsize size);
250 
251 void grl_media_add_external_player (GrlMedia *media, const gchar *player);
252 
253 void grl_media_add_external_url (GrlMedia *media, const gchar *url);
254 
255 void grl_media_add_keyword (GrlMedia *media, const gchar *keyword);
256 
257 void grl_media_add_artist (GrlMedia *media, const gchar *artist);
258 
259 void grl_media_add_genre (GrlMedia *media, const gchar *genre);
260 
261 void grl_media_add_lyrics (GrlMedia *media, const gchar *lyrics);
262 
263 void grl_media_add_mb_artist_id (GrlMedia *media, const gchar *mb_artist_id);
264 
265 void grl_media_add_performer (GrlMedia *media, const gchar *performer);
266 
267 void grl_media_add_producer (GrlMedia *media, const gchar *producer);
268 
269 void grl_media_add_director (GrlMedia *media, const gchar *director);
270 
271 const gchar *grl_media_get_id (GrlMedia *media);
272 
273 const gchar *grl_media_get_url (GrlMedia *media);
274 
275 const gchar *grl_media_get_url_data (GrlMedia *media, gchar **mime, gint *bitrate, gfloat *framerate, gint *width, gint *height);
276 
277 const gchar *grl_media_get_url_data_nth (GrlMedia *media, guint index, gchar **mime, gint *bitrate, gfloat *framerate, gint *width, gint *height);
278 
279 const gchar *grl_media_get_author (GrlMedia *media);
280 
281 const gchar *grl_media_get_author_nth (GrlMedia *media, guint index);
282 
283 const gchar *grl_media_get_title (GrlMedia *media);
284 
285 const gchar *grl_media_get_description (GrlMedia *media);
286 
287 const gchar *grl_media_get_source (GrlMedia *media);
288 
289 const gchar *grl_media_get_thumbnail (GrlMedia *media);
290 
291 const gchar *grl_media_get_thumbnail_nth (GrlMedia *media, guint index);
292 
293 const guint8 *grl_media_get_thumbnail_binary (GrlMedia *media, gsize *size);
294 
295 const guint8 *grl_media_get_thumbnail_binary_nth (GrlMedia *media, gsize *size, guint index);
296 
297 const gchar *grl_media_get_site (GrlMedia *media);
298 
299 gint grl_media_get_duration (GrlMedia *media);
300 
301 GDateTime *grl_media_get_publication_date (GrlMedia *media);
302 
303 const gchar *grl_media_get_region (GrlMedia *media);
304 
305 const gchar *grl_media_get_region_data(GrlMedia *media,
306                                        const GDateTime **publication_date,
307                                        const gchar **certificate);
308 
309 const gchar *grl_media_get_region_data_nth(GrlMedia *media,
310                                            guint index,
311                                            const GDateTime **publication_date,
312                                            const gchar **certificate);
313 
314 GDateTime *grl_media_get_creation_date (GrlMedia *media);
315 
316 GDateTime *grl_media_get_modification_date (GrlMedia *media);
317 
318 const gchar *grl_media_get_mime (GrlMedia *media);
319 
320 gfloat grl_media_get_rating (GrlMedia *media);
321 
322 gint grl_media_get_play_count (GrlMedia *media);
323 
324 gint grl_media_get_last_position (GrlMedia *media);
325 
326 GDateTime *grl_media_get_last_played (GrlMedia *media);
327 
328 const gchar *grl_media_get_player (GrlMedia *media);
329 
330 const gchar *grl_media_get_player_nth (GrlMedia *media, guint index);
331 
332 const gchar *grl_media_get_external_url (GrlMedia *media);
333 
334 const gchar *grl_media_get_external_url_nth (GrlMedia *media, guint index);
335 
336 const gchar *grl_media_get_studio (GrlMedia *media);
337 
338 const gchar *grl_media_get_certificate (GrlMedia *media);
339 
340 const gchar *grl_media_get_license (GrlMedia *media);
341 
342 gfloat grl_media_get_start_time (GrlMedia *media);
343 
344 gboolean grl_media_get_favourite (GrlMedia *media);
345 
346 const gchar *grl_media_get_keyword (GrlMedia *media);
347 
348 const gchar * grl_media_get_keyword_nth (GrlMedia *media, guint index);
349 
350 gint64 grl_media_get_size (GrlMedia *media);
351 
352 gint grl_media_get_track_number (GrlMedia *media);
353 
354 gint grl_media_get_bitrate (GrlMedia *media);
355 
356 G_DEPRECATED
357 const gchar *grl_media_get_mb_album_id (GrlMedia *media);
358 
359 const gchar *grl_media_get_mb_artist_id (GrlMedia *media);
360 
361 const gchar *grl_media_get_mb_artist_id_nth (GrlMedia *media, guint index);
362 
363 const gchar *grl_media_get_mb_recording_id (GrlMedia *media);
364 
365 const gchar *grl_media_get_mb_track_id (GrlMedia *media);
366 
367 const gchar *grl_media_get_mb_release_id (GrlMedia *media);
368 
369 const gchar *grl_media_get_mb_release_group_id (GrlMedia *media);
370 
371 const gchar *grl_media_get_lyrics (GrlMedia *media);
372 
373 const gchar *grl_media_get_lyrics_nth (GrlMedia *media, guint index);
374 
375 const gchar *grl_media_get_genre (GrlMedia *media);
376 
377 const gchar *grl_media_get_genre_nth (GrlMedia *media, guint index);
378 
379 const gchar *grl_media_get_album (GrlMedia *media);
380 
381 const gchar *grl_media_get_album_artist (GrlMedia *media);
382 
383 gint grl_media_get_album_disc_number (GrlMedia *media);
384 
385 const gchar *grl_media_get_artist (GrlMedia *media);
386 
387 const gchar *grl_media_get_artist_nth (GrlMedia *media, guint index);
388 
389 const gchar *grl_media_get_composer (GrlMedia *media);
390 
391 const gchar *grl_media_get_composer_nth (GrlMedia *media, guint index);
392 
393 GrlMediaType grl_media_get_media_type (GrlMedia *media);
394 
395 gint grl_media_get_width (GrlMedia *media);
396 
397 gint grl_media_get_height (GrlMedia *media);
398 
399 gfloat grl_media_get_framerate (GrlMedia *media);
400 
401 gint grl_media_get_season (GrlMedia *media);
402 
403 gint grl_media_get_episode (GrlMedia *media);
404 
405 const gchar *grl_media_get_episode_title (GrlMedia *media);
406 
407 const gchar *grl_media_get_show (GrlMedia *media);
408 
409 const gchar *grl_media_get_performer (GrlMedia *media);
410 
411 const gchar *grl_media_get_performer_nth (GrlMedia *media, guint index);
412 
413 const gchar *grl_media_get_producer (GrlMedia *media);
414 
415 const gchar *grl_media_get_producer_nth (GrlMedia *media, guint index);
416 
417 const gchar *grl_media_get_director (GrlMedia *media);
418 
419 const gchar *grl_media_get_director_nth (GrlMedia *media, guint index);
420 
421 const gchar *grl_media_get_original_title (GrlMedia *media);
422 
423 const gchar *grl_media_get_camera_model (GrlMedia *media);
424 
425 const gchar *grl_media_get_flash_used (GrlMedia *media);
426 
427 gfloat grl_media_get_exposure_time (GrlMedia *media);
428 
429 gfloat grl_media_get_iso_speed (GrlMedia *media);
430 
431 gint grl_media_get_orientation (GrlMedia *media);
432 
433 gint grl_media_get_childcount (GrlMedia *media);
434 
435 GType grl_media_get_type (void) G_GNUC_CONST;
436 
437 GrlMedia *grl_media_new (void);
438 
439 GrlMedia *grl_media_audio_new (void);
440 
441 GrlMedia *grl_media_video_new (void);
442 
443 GrlMedia *grl_media_image_new (void);
444 
445 GrlMedia *grl_media_container_new (void);
446 
447 gboolean
448 grl_media_is_audio (GrlMedia *media);
449 
450 gboolean
451 grl_media_is_video (GrlMedia *media);
452 
453 gboolean
454 grl_media_is_image (GrlMedia *media);
455 
456 gboolean
457 grl_media_is_container (GrlMedia *media);
458 
459 gchar *grl_media_serialize (GrlMedia *media);
460 
461 gchar *grl_media_serialize_extended (GrlMedia *media,
462                                      GrlMediaSerializeType serial_type,
463                                      ...);
464 
465 GrlMedia *grl_media_unserialize (const gchar *serial);
466 
467 G_END_DECLS
468 
469 #endif /* _GRL_MEDIA_H_ */
470