[Multi-valued V2 (grilo) 12/12] core: Add convenience API in GrlMediaFoo



Add some utilities in GrlMedia clases to handle multi-valued elements in those
keys that could make sense, as well as to handle correlated keys without
needing to create or handle GrlProperties.

Of course, user can still use GrlProperty and GrlData API to get most flexibility.

Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>
---
 src/data/grl-media-audio.c |  192 ++++++++++++++++++++++++++++++++++++++++
 src/data/grl-media-audio.h |   20 ++++
 src/data/grl-media-image.c |   57 ++++++++++++
 src/data/grl-media-image.h |   23 +++++
 src/data/grl-media-video.c |  134 ++++++++++++++++++++++++++++
 src/data/grl-media-video.h |   27 ++++++
 src/data/grl-media.c       |  209 ++++++++++++++++++++++++++++++++++++++++++++
 src/data/grl-media.h       |   28 ++++++
 8 files changed, 690 insertions(+), 0 deletions(-)

diff --git a/src/data/grl-media-audio.c b/src/data/grl-media-audio.c
index fcdd219..c42cb81 100644
--- a/src/data/grl-media-audio.c
+++ b/src/data/grl-media-audio.c
@@ -163,6 +163,93 @@ grl_media_audio_set_bitrate (GrlMediaAudio *data, gint bitrate)
 }
 
 /**
+ * grl_media_audio_set_url_data:
+ * @data: the media instance
+ * @url: the audio's url
+ * @mime: the @url mime-type
+ * @bitrate: the @url bitrate, or -1 to ignore
+ *
+ * Set the url of the audio, as well as its mime-type and bitrate.
+ **/
+void
+grl_media_audio_set_url_data (GrlMediaAudio *data,
+                              const gchar *url,
+                              const gchar *mime,
+                              gint bitrate)
+{
+  GrlProperty *prop = grl_property_new_for_key (GRL_METADATA_KEY_URL);
+  grl_property_set_string (prop, GRL_METADATA_KEY_URL, url);
+  grl_property_set_string (prop, GRL_METADATA_KEY_MIME, mime);
+  if (bitrate >= 0) {
+    grl_property_set_int (prop, GRL_METADATA_KEY_BITRATE, bitrate);
+  }
+  grl_data_set_property (GRL_DATA (data), prop, 0);
+}
+
+/**
+ * grl_media_audio_add_artist:
+ * @data: the media instance
+ * @artist: an audio's artist
+ *
+ * Adds a new artist to @data.
+ **/
+void
+grl_media_audio_add_artist (GrlMediaAudio *data, const gchar *artist)
+{
+  grl_data_add_string (GRL_DATA (data), GRL_METADATA_KEY_ARTIST, artist);
+}
+
+/**
+ * grl_media_audio_add_genre:
+ * @data: the media instance
+ * @genre: an audio's genre
+ *
+ * Adds a new genre to @data.
+ **/
+void
+grl_media_audio_add_genre (GrlMediaAudio *data, const gchar *genre)
+{
+  grl_data_add_string (GRL_DATA (data), GRL_METADATA_KEY_GENRE, genre);
+}
+
+/**
+ * grl_media_audio_add_lyrics:
+ * @data: the media instance
+ * @lyrics: an audio's lyrics
+ *
+ * Adds a new lyrics to @data.
+ **/
+void
+grl_media_audio_add_lyrics (GrlMediaAudio *data, const gchar *lyrics)
+{
+  grl_data_add_string (GRL_DATA (data), GRL_METADATA_KEY_LYRICS, lyrics);
+}
+
+/**
+ * grl_media_audio_add_url_data:
+ * @data: the media instance
+ * @url: an audio's url
+ * @mime: the @url mime-type
+ * @bitrate: the @url bitrate, or -1 to ignore
+ *
+ * Adds a new url to @data, as well as its mime-type and bitrate.
+ **/
+void
+grl_media_audio_add_url_data (GrlMediaAudio *data,
+                              const gchar *url,
+                              const gchar *mime,
+                              gint bitrate)
+{
+  GrlProperty *prop = grl_property_new_for_key (GRL_METADATA_KEY_URL);
+  grl_property_set_string (prop, GRL_METADATA_KEY_URL, url);
+  grl_property_set_string (prop, GRL_METADATA_KEY_MIME, mime);
+  if (bitrate >= 0) {
+    grl_property_set_int (prop, GRL_METADATA_KEY_BITRATE, bitrate);
+  }
+  grl_data_add_property (GRL_DATA (data), prop);
+}
+
+/**
  * grl_media_audio_get_artist:
  * @data: the media instance
  *
@@ -177,6 +264,25 @@ grl_media_audio_get_artist (GrlMediaAudio *data)
 }
 
 /**
+ * grl_media_audio_get_artist_nth:
+ * @data: the media instance
+ *
+ * Returns: the n-th artist of the audio
+ */
+const gchar *
+grl_media_audio_get_artist_nth (GrlMediaAudio *data, guint index)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_ARTIST, index);
+
+  if (!prop) {
+    return NULL;
+  } else {
+    return grl_property_get_string (prop, GRL_METADATA_KEY_ARTIST);
+  }
+}
+
+/**
  * grl_media_audio_get_album:
  * @data: the media instance
  *
@@ -205,6 +311,25 @@ grl_media_audio_get_genre (GrlMediaAudio *data)
 }
 
 /**
+ * grl_media_audio_get_genre_nth:
+ * @data: the media instance
+ *
+ * Returns: the n-th genre of the audio
+ */
+const gchar *
+grl_media_audio_get_genre_nth (GrlMediaAudio *data, guint index)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_GENRE, index);
+
+  if (!prop) {
+    return NULL;
+  } else {
+    return grl_property_get_string (prop, GRL_METADATA_KEY_GENRE);
+  }
+}
+
+/**
  * grl_media_audio_get_lyrics:
  * @data: the media instance
  *
@@ -219,6 +344,25 @@ grl_media_audio_get_lyrics (GrlMediaAudio *data)
 }
 
 /**
+ * grl_media_audio_get_lyrics_nth:
+ * @data: the media instance
+ *
+ * Returns: the n-th lyrics of the audio
+ */
+const gchar *
+grl_media_audio_get_lyrics_nth (GrlMediaAudio *data, guint index)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_LYRICS, index);
+
+  if (!prop) {
+    return NULL;
+  } else {
+    return grl_property_get_string (prop, GRL_METADATA_KEY_LYRICS);
+  }
+}
+
+/**
  * grl_media_audio_get_bitrate:
  * @data: the media instance
  *
@@ -231,3 +375,51 @@ grl_media_audio_get_bitrate (GrlMediaAudio *data)
 {
   return grl_data_get_int (GRL_DATA (data), GRL_METADATA_KEY_BITRATE);
 }
+
+/**
+ * grl_media_audio_get_url_data:
+ * @data: the media instance
+ * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore
+ * @bitrate: (out): the url bitrate, or %NULL to ignore
+ *
+ * Returns: the url of the audio, as well as its mime-type and bitrate.
+ */
+const gchar *
+grl_media_audio_get_url_data (GrlMediaAudio *data,
+                              gchar **mime,
+                              gint *bitrate)
+{
+  return grl_media_audio_get_url_data_nth (data, 0, mime, bitrate);
+}
+
+/**
+ * grl_media_audio_get_url_data_nth:
+ * @data: the media instance
+ * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore
+ * @bitrate: (out): the url bitrate, or %NULL to ignore
+ *
+ * Returns: the n-th url of the audio, as well as its mime-type and bitrate.
+ */
+const gchar *
+grl_media_audio_get_url_data_nth (GrlMediaAudio *data,
+                                  guint index,
+                                  gchar **mime,
+                                  gint *bitrate)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_URL, index);
+
+  if (!prop) {
+    return NULL;
+  }
+
+  if (mime) {
+    *mime = (gchar *) grl_property_get_string (prop, GRL_METADATA_KEY_MIME);
+  }
+
+  if (bitrate) {
+    *bitrate = grl_property_get_int (prop, GRL_METADATA_KEY_BITRATE);
+  }
+
+  return grl_property_get_string (prop, GRL_METADATA_KEY_URL);
+}
diff --git a/src/data/grl-media-audio.h b/src/data/grl-media-audio.h
index d9ee343..f1c0b9d 100644
--- a/src/data/grl-media-audio.h
+++ b/src/data/grl-media-audio.h
@@ -95,16 +95,36 @@ void grl_media_audio_set_lyrics (GrlMediaAudio *data, const gchar *lyrics);
 
 void grl_media_audio_set_bitrate (GrlMediaAudio *data, gint bitrate);
 
+void grl_media_audio_set_url_data (GrlMediaAudio *data, const gchar *url, const gchar *mime, gint bitrate);
+
+void grl_media_audio_add_artist (GrlMediaAudio *data, const gchar *artist);
+
+void grl_media_audio_add_genre (GrlMediaAudio *data, const gchar *genre);
+
+void grl_media_audio_add_lyrics (GrlMediaAudio *data, const gchar *lyrics);
+
+void grl_media_audio_add_url_data (GrlMediaAudio *data, const gchar *url, const gchar *mime, gint bitrate);
+
 const gchar *grl_media_audio_get_artist (GrlMediaAudio *data);
 
+const gchar *grl_media_audio_get_artist_nth (GrlMediaAudio *data, guint index);
+
 const gchar *grl_media_audio_get_album (GrlMediaAudio *data);
 
 const gchar *grl_media_audio_get_genre (GrlMediaAudio *data);
 
+const gchar *grl_media_audio_get_genre_nth (GrlMediaAudio *data, guint index);
+
 const gchar *grl_media_audio_get_lyrics (GrlMediaAudio *data);
 
+const gchar *grl_media_audio_get_lyrics_nth (GrlMediaAudio *data, guint index);
+
 gint grl_media_audio_get_bitrate (GrlMediaAudio *data);
 
+const gchar *grl_media_audio_get_url_data (GrlMediaAudio *data, gchar **mime, gint *bitrate);
+
+const gchar *grl_media_audio_get_url_data_nth (GrlMediaAudio *data, guint index, gchar **mime, gint *bitrate);
+
 GType grl_media_audio_get_type (void) G_GNUC_CONST;
 
 GrlMedia *grl_media_audio_new (void);
diff --git a/src/data/grl-media-image.c b/src/data/grl-media-image.c
index 2049474..bf4c9d9 100644
--- a/src/data/grl-media-image.c
+++ b/src/data/grl-media-image.c
@@ -162,3 +162,60 @@ grl_media_image_get_height (GrlMediaImage *data)
 {
   return grl_data_get_int (GRL_DATA (data), GRL_METADATA_KEY_HEIGHT);
 }
+
+/**
+ * grl_media_image_get_url_data:
+ * @data: the image instance
+ * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore
+ * @width: the width, or %NULL to ignore
+ * @height: the height, or %NULL to ignore
+ *
+ * Returns: the url of image, as well as its mime-type, width and height.
+ **/
+const gchar *
+grl_media_image_get_url_data (GrlMediaImage *image,
+                              gchar **mime,
+                              gint *width,
+                              gint *height)
+{
+  return grl_media_image_get_url_data_nth (image, 0, mime, width, height);
+}
+
+/**
+ * grl_media_image_get_url_data_nth:
+ * @data: the image instance
+ * @index: element to retrieve
+ * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore
+ * @width: the width, or %NULL to ignore
+ * @height: the height, or %NULL to ignore
+ *
+ * Returns: the n-th url of image, as well as its mime-type, width and height.
+ **/
+const gchar *
+grl_media_image_get_url_data_nth (GrlMediaImage *image,
+                                  guint index,
+                                  gchar **mime,
+                                  gint *width,
+                                  gint *height)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (image), GRL_METADATA_KEY_URL, index);
+
+  if (!prop) {
+    return NULL;
+  }
+
+  if (mime) {
+    *mime = (gchar *) grl_property_get_string (prop, GRL_METADATA_KEY_MIME);
+  }
+
+  if (width) {
+    *width = grl_property_get_int (prop, GRL_METADATA_KEY_WIDTH);
+  }
+
+  if (height) {
+    *height = grl_property_get_int (prop, GRL_METADATA_KEY_HEIGHT);
+  }
+
+  return grl_property_get_string (prop, GRL_METADATA_KEY_URL);
+}
diff --git a/src/data/grl-media-image.h b/src/data/grl-media-image.h
index 2dd4269..21bbd19 100644
--- a/src/data/grl-media-image.h
+++ b/src/data/grl-media-image.h
@@ -99,6 +99,29 @@ void grl_media_image_set_size (GrlMediaImage *image,
                                gint width,
                                gint height);
 
+const gchar *grl_media_image_get_url_data (GrlMediaImage *image,
+                                           gchar **mime,
+                                           gint *width,
+                                           gint *height);
+
+const gchar *grl_media_image_get_url_data_nth (GrlMediaImage *image,
+                                               guint index,
+                                               gchar **mime,
+                                               gint *width,
+                                               gint *height);
+
+void grl_media_image_set_url_data (GrlMediaImage *image,
+                                   const gchar *url,
+                                   const gchar *mime,
+                                   gint width,
+                                   gint height);
+
+void grl_media_image_add_url_data (GrlMediaImage *image,
+                                   const gchar *url,
+                                   const gchar *mime,
+                                   gint width,
+                                   gint height);
+
 G_END_DECLS
 
 #endif /* _GRL_MEDIA_IMAGE_H_ */
diff --git a/src/data/grl-media-video.c b/src/data/grl-media-video.c
index b957dad..f7f7093 100644
--- a/src/data/grl-media-video.c
+++ b/src/data/grl-media-video.c
@@ -193,3 +193,137 @@ grl_media_video_get_framerate (GrlMediaVideo *data)
 {
   return grl_data_get_float (GRL_DATA (data), GRL_METADATA_KEY_FRAMERATE);
 }
+
+/**
+ * grl_media_video_set_url_data:
+ * @video: the media instance
+ * @url: the video's url
+ * @mime: video mime-type
+ * @framerate: video framerate, or -1 to ignore
+ * @width: video width, or -1 to ignore
+ * @height: video height, or -1 to ignore
+ *
+ * Sets the video url, as well as its mime type, framerate, width and height.
+ **/
+void
+grl_media_video_set_url_data (GrlMediaVideo *video,
+                              const gchar *url,
+                              const gchar *mime,
+                              gfloat framerate,
+                              gint width,
+                              gint height)
+{
+  GrlProperty *prop = grl_property_new_for_key (GRL_METADATA_KEY_URL);
+  grl_property_set_string (prop, GRL_METADATA_KEY_URL, url);
+  grl_property_set_string (prop, GRL_METADATA_KEY_MIME, mime);
+  if (framerate >= 0) {
+    grl_property_set_float (prop, GRL_METADATA_KEY_FRAMERATE, framerate);
+  }
+  if (width >= 0) {
+    grl_property_set_int (prop, GRL_METADATA_KEY_WIDTH, width);
+  }
+  if (height >= 0) {
+    grl_property_set_int (prop, GRL_METADATA_KEY_HEIGHT, height);
+  }
+  grl_data_set_property (GRL_DATA (video), prop, 0);
+}
+
+/**
+ * grl_media_video_add_url_data:
+ * @video: the media instance
+ * @url: a video's url
+ * @mime: video mime-type
+ * @framerate: video framerate, or -1 to ignore
+ * @width: video width, or -1 to ignore
+ * @height: video height, or -1 to ignore
+ *
+ * Sets a new video url, as well as its mime type, framerate, width and height.
+ **/
+void
+grl_media_video_add_url_data (GrlMediaVideo *video,
+                              const gchar *url,
+                              const gchar *mime,
+                              gfloat framerate,
+                              gint width,
+                              gint height)
+{
+  GrlProperty *prop = grl_property_new_for_key (GRL_METADATA_KEY_URL);
+  grl_property_set_string (prop, GRL_METADATA_KEY_URL, url);
+  grl_property_set_string (prop, GRL_METADATA_KEY_MIME, mime);
+  if (framerate >= 0) {
+    grl_property_set_float (prop, GRL_METADATA_KEY_FRAMERATE, framerate);
+  }
+  if (width >= 0) {
+    grl_property_set_int (prop, GRL_METADATA_KEY_WIDTH, width);
+  }
+  if (height >= 0) {
+    grl_property_set_int (prop, GRL_METADATA_KEY_HEIGHT, height);
+  }
+  grl_data_add_property (GRL_DATA (video), prop);
+}
+
+/**
+ * grl_media_video_get_url_data:
+ * @video: the media instance
+ * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore
+ * @framerate: the url framerate, or %NULL to ignore
+ * @width: the url width, or %NULL to ignore
+ * @height: the url height, or %NULL to ignore
+ *
+ * Returns: the video's url, as well as its mime-type, framerate, width and height.
+ **/
+const gchar *
+grl_media_video_get_url_data (GrlMediaVideo *video,
+                              gchar **mime,
+                              gfloat *framerate,
+                              gint *width,
+                              gint *height)
+{
+  return grl_media_video_get_url_data_nth (video, 0, mime, framerate, width, height);
+}
+
+/**
+ * grl_media_video_get_url_data_nth:
+ * @video: the media instance
+ * @index: element to retrieve
+ * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore
+ * @framerate: the url framerate, or %NULL to ignore
+ * @width: the url width, or %NULL to ignore
+ * @height: the url height, or %NULL to ignore
+ *
+ * Returns: the n-th video's url, as well as its mime-type, framerate, width and
+ * height.
+ **/
+const gchar *
+grl_media_video_get_url_data_nth (GrlMediaVideo *video,
+                                  guint index,
+                                  gchar **mime,
+                                  gfloat *framerate,
+                                  gint *width,
+                                  gint *height)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (video), GRL_METADATA_KEY_URL, index);
+
+  if (!prop) {
+    return NULL;
+  }
+
+  if (mime) {
+    *mime = (gchar *) grl_property_get_string (prop, GRL_METADATA_KEY_MIME);
+  }
+
+  if (framerate) {
+    *framerate = grl_property_get_float (prop, GRL_METADATA_KEY_FRAMERATE);
+  }
+
+  if (width) {
+    *width = grl_property_get_int (prop, GRL_METADATA_KEY_WIDTH);
+  }
+
+  if (height) {
+    *height = grl_property_get_int (prop, GRL_METADATA_KEY_HEIGHT);
+  }
+
+  return grl_property_get_string (prop, GRL_METADATA_KEY_URL);
+}
diff --git a/src/data/grl-media-video.h b/src/data/grl-media-video.h
index 9f28db6..87897a3 100644
--- a/src/data/grl-media-video.h
+++ b/src/data/grl-media-video.h
@@ -105,6 +105,33 @@ void grl_media_video_set_size (GrlMediaVideo *video,
                                gint width,
                                gint height);
 
+void grl_media_video_set_url_data (GrlMediaVideo *video,
+                                   const gchar *url,
+                                   const gchar *mime,
+                                   gfloat framerate,
+                                   gint width,
+                                   gint height);
+
+void grl_media_video_add_url_data (GrlMediaVideo *video,
+                                   const gchar *url,
+                                   const gchar *mime,
+                                   gfloat framerate,
+                                   gint width,
+                                   gint height);
+
+const gchar *grl_media_video_get_url_data (GrlMediaVideo *video,
+                                           gchar **mime,
+                                           gfloat *framerate,
+                                           gint *width,
+                                           gint *height);
+
+const gchar *grl_media_video_get_url_data_nth (GrlMediaVideo *video,
+                                               guint index,
+                                               gchar **mime,
+                                               gfloat *framerate,
+                                               gint *width,
+                                               gint *height);
+
 G_END_DECLS
 
 #endif /* _GRL_MEDIA_VIDEO_H_ */
diff --git a/src/data/grl-media.c b/src/data/grl-media.c
index d37bed3..bb8a696 100644
--- a/src/data/grl-media.c
+++ b/src/data/grl-media.c
@@ -112,6 +112,115 @@ grl_media_set_rating (GrlMedia *media, gfloat rating, gfloat max)
 }
 
 /**
+ * grl_media_set_url_data:
+ * @media: a #GrlMedia
+ * @url: the media's URL
+ * @mime: the @url mime type
+ *
+ * Set the media's URL and its mime-type.
+ **/
+void
+grl_media_set_url_data (GrlMedia *media, const gchar *url, const gchar *mime)
+{
+  GrlProperty *prop = grl_property_new_for_key (GRL_METADATA_KEY_URL);
+  grl_property_set_string (prop, GRL_METADATA_KEY_URL, url);
+  grl_property_set_string (prop, GRL_METADATA_KEY_MIME, mime);
+  grl_data_set_property (GRL_DATA (media), prop, 0);
+}
+
+/**
+ * grl_media_add_url_data:
+ * @media: a #GrlMedia
+ * @url: a media's URL
+ * @mime: th @url mime type
+ *
+ * Adds a new media's URL with its mime-type.
+ **/
+void
+grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime)
+{
+  GrlProperty *prop = grl_property_new_for_key (GRL_METADATA_KEY_URL);
+  grl_property_set_string (prop, GRL_METADATA_KEY_URL, url);
+  grl_property_set_string (prop, GRL_METADATA_KEY_MIME, mime);
+  grl_data_add_property (GRL_DATA (media), prop);
+}
+
+/**
+ * grl_media_add_author:
+ * @media: a #GrlMedia
+ * @author: an author for @media
+ *
+ * Adds a new author to @media.
+ **/
+void
+grl_media_add_author (GrlMedia *media, const gchar *author)
+{
+  grl_data_add_string (GRL_DATA (media), GRL_METADATA_KEY_AUTHOR, author);
+}
+
+/**
+ * grl_media_add_thumbnail:
+ * @media: a #GrlMedia
+ * @thumbnail: a thumbnail for @media
+ *
+ * Adds a new thumbnail to @media.
+ **/
+void
+grl_media_add_thumbnail (GrlMedia *media, const gchar *thumbnail)
+{
+  grl_data_add_string (GRL_DATA (media), GRL_METADATA_KEY_THUMBNAIL, thumbnail);
+}
+
+/**
+ * grl_media_add_thumbnail_binary:
+ * @media: a #GrlMedia
+ * @thumbnail: a buffer containing the thumbnail for @media
+ * @size: size of buffer
+ *
+ * Adds a new thumbnail to @media.
+ **/
+void
+grl_media_add_thumbnail_binary (GrlMedia *media,
+                                const guint8 *thumbnail,
+                                gsize size)
+{
+  grl_data_add_binary (GRL_DATA (media),
+                       GRL_METADATA_KEY_THUMBNAIL_BINARY,
+                       thumbnail,
+                       size);
+}
+
+/**
+ * grl_media_add_external_player:
+ * @media: a #GrlMedia
+ * @player: an external player for @media
+ *
+ * Adds a new external player to @media.
+ **/
+void
+grl_media_add_external_player (GrlMedia *media, const gchar *player)
+{
+  grl_data_add_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_EXTERNAL_PLAYER,
+                       player);
+}
+
+/**
+ * grl_media_add_external_url:
+ * @media: a #GrlMedia
+ * @url: an external url for @media
+ *
+ * Adds a new external url to @media.
+ **/
+void
+grl_media_add_external_url (GrlMedia *media, const gchar *url)
+{
+  grl_data_add_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_EXTERNAL_URL,
+                       url);
+}
+
+/**
  * grl_media_serialize:
  * @media: a #GrlMedia
  *
@@ -742,6 +851,44 @@ grl_media_get_url (GrlMedia *data)
 }
 
 /**
+ * grl_media_get_url_data:
+ * @media: the media object
+ * @mime: (out) (transfer none): the mime-type, or %NULL to ignore.
+ *
+ * Returns: the media's URL and its mime-type.
+ */
+const gchar *
+grl_media_get_url_data (GrlMedia *media, gchar **mime)
+{
+  return grl_media_get_url_data_nth (media, 0, mime);
+}
+
+/**
+ * grl_media_get_url_data_nth:
+ * @data: the media object
+ * @index: element to retrieve
+ * @mime: (out) (transfer none): the mime-type, or %NULL to ignore.
+ *
+ * Returns: the n-th media's URL and its mime-type.
+ */
+const gchar *
+grl_media_get_url_data_nth (GrlMedia *data, guint index, gchar **mime)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_URL, index);
+
+  if (!prop) {
+    return NULL;
+  }
+
+  if (mime) {
+    *mime = (gchar *) grl_property_get_string (prop, GRL_METADATA_KEY_MIME);
+  }
+
+  return grl_property_get_string (prop, GRL_METADATA_KEY_URL);
+}
+
+/**
  * grl_media_get_author:
  * @data: the media object
  *
@@ -756,6 +903,26 @@ grl_media_get_author (GrlMedia *data)
 }
 
 /**
+ * grl_media_get_author_nth:
+ * @data: the media object
+ * @index: element to retrieve
+ *
+ * Returns: the n-th media's author.
+ */
+const gchar *
+grl_media_get_author_nth (GrlMedia *data, guint index)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_AUTHOR, index);
+
+  if (!prop) {
+    return NULL;
+  } else {
+    return grl_property_get_string (prop, GRL_METADATA_KEY_AUTHOR);
+  }
+}
+
+/**
  * grl_media_get_title:
  * @data: the media object
  *
@@ -812,6 +979,26 @@ grl_media_get_thumbnail (GrlMedia *data)
 }
 
 /**
+ * grl_media_get_thumbnail_nth:
+ * @data: the media object
+ * @index: element to retrieve
+ *
+ * Returns: the n-th media's thumbnail.
+ */
+const gchar *
+grl_media_get_thumbnail_nth (GrlMedia *data, guint index)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_THUMBNAIL, index);
+
+  if (!prop) {
+    return NULL;
+  } else {
+    return grl_property_get_string (prop, GRL_METADATA_KEY_THUMBNAIL);
+  }
+}
+
+/**
  * grl_media_get_thumbnail_binary:
  * @data: the media object
  * @size: pointer to storing the thumbnail buffer size
@@ -829,6 +1016,28 @@ grl_media_get_thumbnail_binary (GrlMedia *data, gsize *size)
 }
 
 /**
+ * grl_media_get_thumbnail_binary_nth:
+ * @data: the media object
+ * @size: pointer to store the thumbnail buffer size
+ * @index: element to retrieve
+ *
+ * Returns: the n-th media's thumbnail binary and sets size to the thumbnail
+ * buffer size.
+ */
+const guint8 *
+grl_media_get_thumbnail_binary_nth (GrlMedia *data, gsize *size, guint index)
+{
+  GrlProperty *prop =
+    grl_data_get_property (GRL_DATA (data), GRL_METADATA_KEY_THUMBNAIL, index);
+
+  if (!prop) {
+    return NULL;
+  } else {
+    return grl_property_get_binary (prop, GRL_METADATA_KEY_THUMBNAIL, size);
+  }
+}
+
+/**
  * grl_media_get_site:
  * @data: the media object
  *
diff --git a/src/data/grl-media.h b/src/data/grl-media.h
index 31c2928..65eed67 100644
--- a/src/data/grl-media.h
+++ b/src/data/grl-media.h
@@ -141,12 +141,32 @@ void grl_media_set_license (GrlMedia *data, const gchar *license);
 
 void grl_media_set_rating (GrlMedia *media, gfloat rating, gfloat max);
 
+void grl_media_set_url_data (GrlMedia *media, const gchar *url, const gchar *mime);
+
+void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime);
+
+void grl_media_add_author (GrlMedia *media, const gchar *author);
+
+void grl_media_add_thumbnail (GrlMedia *media, const gchar *thumbnail);
+
+void grl_media_add_thumbnail_binary (GrlMedia *media, const guint8 *thumbnail, gsize size);
+
+void grl_media_add_external_player (GrlMedia *media, const gchar *player);
+
+void grl_media_add_external_url (GrlMedia *media, const gchar *url);
+
 const gchar *grl_media_get_id (GrlMedia *data);
 
 const gchar *grl_media_get_url (GrlMedia *data);
 
+const gchar *grl_media_get_url_data (GrlMedia *media, gchar **mime);
+
+const gchar *grl_media_get_url_data_nth (GrlMedia *media, guint index, gchar **mime);
+
 const gchar *grl_media_get_author (GrlMedia *data);
 
+const gchar *grl_media_get_author_nth (GrlMedia *data, guint index);
+
 const gchar *grl_media_get_title (GrlMedia *data);
 
 const gchar *grl_media_get_description (GrlMedia *data);
@@ -155,8 +175,12 @@ const gchar *grl_media_get_source (GrlMedia *data);
 
 const gchar *grl_media_get_thumbnail (GrlMedia *data);
 
+const gchar *grl_media_get_thumbnail_nth (GrlMedia *media, guint index);
+
 const guint8 *grl_media_get_thumbnail_binary (GrlMedia *data, gsize *size);
 
+const guint8 *grl_media_get_thumbnail_binary_nth (GrlMedia *media, gsize *size, guint index);
+
 const gchar *grl_media_get_site (GrlMedia *data);
 
 gint grl_media_get_duration (GrlMedia *data);
@@ -175,8 +199,12 @@ const gchar *grl_media_get_last_played (GrlMedia *data);
 
 const gchar *grl_media_get_player (GrlMedia *data);
 
+const gchar *grl_media_get_player_nth (GrlMedia *data, guint index);
+
 const gchar *grl_media_get_external_url (GrlMedia *data);
 
+const gchar *grl_media_get_external_url_nth (GrlMedia *media, guint index);
+
 const gchar *grl_media_get_studio (GrlMedia *data);
 
 const gchar *grl_media_get_certificate (GrlMedia *data);
-- 
1.7.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]