[grilo] core: merge GrlMediaVideo into GrlMedia



commit 11c7c84667749a9d6f942744d5eab287e3c73197
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Tue Dec 15 17:35:11 2015 +0100

    core: merge GrlMediaVideo into GrlMedia
    
    Get rid of GrlMediaVideo and use instead GrlMedia.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755551

 bindings/vala/grilo-0.3.vapi |   77 ++---
 src/Makefile.am              |    2 -
 src/data/grl-media-video.c   |  750 ------------------------------------------
 src/data/grl-media-video.h   |  191 -----------
 src/data/grl-media.c         |  584 +++++++++++++++++++++++++++++++-
 src/data/grl-media.h         |   69 ++++-
 src/grilo.c                  |    1 -
 src/grilo.h                  |    1 -
 tools/grilo-test-ui/main.c   |    4 +-
 9 files changed, 668 insertions(+), 1011 deletions(-)
---
diff --git a/bindings/vala/grilo-0.3.vapi b/bindings/vala/grilo-0.3.vapi
index 2b1939d..73e5712 100644
--- a/bindings/vala/grilo-0.3.vapi
+++ b/bindings/vala/grilo-0.3.vapi
@@ -104,16 +104,19 @@ namespace Grl {
                public Media ();
                public void add_artist (string artist);
                public void add_author (string author);
+               public void add_director (string director);
                public void add_external_player (string player);
                public void add_external_url (string url);
                public void add_genre (string genre);
                public void add_keyword (string keyword);
                public void add_lyrics (string lyrics);
                public void add_mb_artist_id (string mb_artist_id);
+               public void add_performer (string performer);
+               public void add_producer (string producer);
                public void add_region_data (string region, GLib.DateTime publication_date, string 
certificate);
                public void add_thumbnail (string thumbnail);
                public void add_thumbnail_binary (uint8 thumbnail, size_t size);
-               public void add_url_data (string url, string mime, int bitrate);
+               public void add_url_data (string url, string mime, int bitrate, float framerate, int width, 
int height);
                [CCode (cname = "grl_media_audio_new", has_construct_function = false)]
                public Media.audio_new ();
                public unowned string get_album ();
@@ -125,12 +128,18 @@ namespace Grl {
                public unowned string get_certificate ();
                public unowned GLib.DateTime get_creation_date ();
                public unowned string get_description ();
+               public unowned string get_director ();
+               public unowned string get_director_nth (uint index);
                public int get_duration ();
+               public int get_episode ();
+               public unowned string get_episode_title ();
                public unowned string get_external_url ();
                public unowned string get_external_url_nth (uint index);
                public bool get_favourite ();
+               public float get_framerate ();
                public unowned string get_genre ();
                public unowned string get_genre_nth (uint index);
+               public int get_height ();
                public unowned string get_id ();
                public unowned string get_keyword ();
                public unowned string get_keyword_nth (uint index);
@@ -147,14 +156,21 @@ namespace Grl {
                public Grl.MediaType get_media_type ();
                public unowned string get_mime ();
                public unowned GLib.DateTime get_modification_date ();
+               public unowned string get_original_title ();
+               public unowned string get_performer ();
+               public unowned string get_performer_nth (uint index);
                public int get_play_count ();
                public unowned string get_player ();
                public unowned string get_player_nth (uint index);
+               public unowned string get_producer ();
+               public unowned string get_producer_nth (uint index);
                public unowned GLib.DateTime get_publication_date ();
                public float get_rating ();
                public unowned string get_region ();
                public unowned string get_region_data (out unowned GLib.DateTime publication_date, out 
unowned string certificate);
                public unowned string get_region_data_nth (uint index, out unowned GLib.DateTime 
publication_date, out unowned string certificate);
+               public int get_season ();
+               public unowned string get_show ();
                public unowned string get_site ();
                public int64 get_size ();
                public unowned string get_source ();
@@ -167,9 +183,11 @@ namespace Grl {
                public unowned string get_title ();
                public int get_track_number ();
                public unowned string get_url ();
-               public unowned string get_url_data (out unowned string mime, out int bitrate);
-               public unowned string get_url_data_nth (uint index, out unowned string mime, out int bitrate);
+               public unowned string get_url_data (out unowned string mime, out int bitrate, float 
framerate, int width, int height);
+               public unowned string get_url_data_nth (uint index, out unowned string mime, out int bitrate, 
float framerate, int width, int height);
+               public int get_width ();
                public bool is_audio ();
+               public bool is_video ();
                public string serialize ();
                public void set_album (string album);
                public void set_artist (string artist);
@@ -178,11 +196,16 @@ namespace Grl {
                public void set_certificate (string certificate);
                public void set_creation_date (GLib.DateTime creation_date);
                public void set_description (string description);
+               public void set_director (string director);
                public void set_duration (int duration);
+               public void set_episode (int episode);
+               public void set_episode_title (string episode_title);
                public void set_external_player (string player);
                public void set_external_url (string url);
                public void set_favourite (bool favourite);
+               public void set_framerate (float framerate);
                public void set_genre (string genre);
+               public void set_height (int height);
                public void set_id (string id);
                public void set_keyword (string keyword);
                public void set_last_played (GLib.DateTime last_played);
@@ -195,11 +218,16 @@ namespace Grl {
                public void set_mb_track_id (string mb_track_id);
                public void set_mime (string mime);
                public void set_modification_date (GLib.DateTime modification_date);
+               public void set_original_title (string original_title);
+               public void set_performer (string performer);
                public void set_play_count (int play_count);
+               public void set_producer (string producer);
                public void set_publication_date (GLib.DateTime date);
                public void set_rating (float rating, float max);
                public void set_region (string region);
                public void set_region_data (string region, GLib.DateTime publication_date, string 
certificate);
+               public void set_season (int season);
+               public void set_show (string show);
                public void set_site (string site);
                public void set_size (int64 size);
                public void set_source (string source);
@@ -209,8 +237,11 @@ namespace Grl {
                public void set_title (string title);
                public void set_track_number (int track_number);
                public void set_url (string url);
-               public void set_url_data (string url, string mime, int bitrate);
+               public void set_url_data (string url, string mime, int bitrate, float framerate, int width, 
int height);
+               public void set_width (int width);
                public static Grl.Media unserialize (string serial);
+               [CCode (cname = "grl_media_video_new", has_construct_function = false)]
+               public Media.video_new ();
                [NoAccessorMethod]
                public Grl.MediaType media_type { get; set construct; }
        }
@@ -245,44 +276,6 @@ namespace Grl {
                public void set_url_data (string url, string mime, int width, int height);
                public void set_width (int width);
        }
-       [CCode (cheader_filename = "grilo.h", type_id = "grl_media_video_get_type ()")]
-       public class MediaVideo : Grl.Media {
-               [CCode (has_construct_function = false, type = "GrlMedia*")]
-               public MediaVideo ();
-               public void add_director (string director);
-               public void add_performer (string performer);
-               public void add_producer (string producer);
-               public void add_url_data (string url, string mime, float framerate, int width, int height);
-               public unowned string get_director ();
-               public unowned string get_director_nth (uint index);
-               public int get_episode ();
-               public unowned string get_episode_title ();
-               public float get_framerate ();
-               public int get_height ();
-               public unowned string get_original_title ();
-               public unowned string get_performer ();
-               public unowned string get_performer_nth (uint index);
-               public unowned string get_producer ();
-               public unowned string get_producer_nth (uint index);
-               public int get_season ();
-               public unowned string get_show ();
-               public unowned string get_url_data (out unowned string mime, float framerate, int width, int 
height);
-               public unowned string get_url_data_nth (uint index, out unowned string mime, float framerate, 
int width, int height);
-               public int get_width ();
-               public void set_director (string director);
-               public void set_episode (int episode);
-               public void set_episode_title (string episode_title);
-               public void set_framerate (float framerate);
-               public void set_height (int height);
-               public void set_original_title (string original_title);
-               public void set_performer (string performer);
-               public void set_producer (string producer);
-               public void set_season (int season);
-               public void set_show (string show);
-               public void set_size (int width, int height);
-               public void set_url_data (string url, string mime, float framerate, int width, int height);
-               public void set_width (int width);
-       }
        [CCode (cheader_filename = "grilo.h", type_id = "grl_operation_options_get_type ()")]
        public class OperationOptions : GLib.Object {
                [CCode (has_construct_function = false)]
diff --git a/src/Makefile.am b/src/Makefile.am
index 9c6b792..1495827 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,7 +72,6 @@ data_c_sources =              \
        data/grl-data.c         \
        data/grl-related-keys.c \
        data/grl-media.c        \
-       data/grl-media-video.c  \
         data/grl-media-image.c \
        data/grl-media-box.c    \
        data/grl-config.c
@@ -104,7 +103,6 @@ data_h_headers =            \
        data/grl-related-keys.h \
        data/grl-media.h        \
        data/grl-media-box.h    \
-       data/grl-media-video.h  \
        data/grl-media-image.h  \
        data/grl-config.h
 
diff --git a/src/data/grl-media.c b/src/data/grl-media.c
index 51dfc85..782cffb 100644
--- a/src/data/grl-media.c
+++ b/src/data/grl-media.c
@@ -175,6 +175,24 @@ grl_media_audio_new (void)
                        NULL);
 }
 
+/**
+ * grl_media_video_new:
+ *
+ * Creates a new media video object.
+ *
+ * Returns: a newly-allocated media video.
+ *
+ * Since: 0.1.4
+ */
+GrlMedia *
+grl_media_video_new (void)
+{
+  return g_object_new (GRL_TYPE_MEDIA,
+                       "media-type", GRL_MEDIA_TYPE_VIDEO,
+                       NULL);
+}
+
+
 gboolean
 grl_media_is_audio (GrlMedia *media)
 {
@@ -183,6 +201,14 @@ grl_media_is_audio (GrlMedia *media)
   return (media->priv->media_type == GRL_MEDIA_TYPE_AUDIO);
 }
 
+gboolean
+grl_media_is_video (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), FALSE);
+
+  return (media->priv->media_type == GRL_MEDIA_TYPE_VIDEO);
+}
+
 /**
  * grl_media_set_rating:
  * @media: a media
@@ -213,14 +239,20 @@ grl_media_set_rating (GrlMedia *media, gfloat rating, gfloat max)
  * @url: the media's URL
  * @mime: the @url mime type
  * @bitrate: the @url bitrate, or -1 to ignore
+ * @framerate: media framerate, or -1 to ignore
+ * @width: media width, or -1 to ignore
+ * @height: media height, or -1 to ignore
  *
- * Set the media's URL and its mime-type and bitrate.
+ * Sets all the keys related with the URL of a media resource in one go.
  **/
 void
 grl_media_set_url_data (GrlMedia *media,
                         const gchar *url,
                         const gchar *mime,
-                        gint bitrate)
+                        gint bitrate,
+                        gfloat framerate,
+                        gint width,
+                        gint height)
 {
   GrlRelatedKeys *relkeys;
 
@@ -232,6 +264,15 @@ grl_media_set_url_data (GrlMedia *media,
   if (bitrate >= 0) {
     grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_BITRATE, bitrate);
   }
+  if (framerate >= 0) {
+    grl_related_keys_set_float (relkeys, GRL_METADATA_KEY_FRAMERATE, framerate);
+  }
+  if (width >= 0) {
+    grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_WIDTH, width);
+  }
+  if (height >= 0) {
+    grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_HEIGHT, height);
+  }
   grl_data_set_related_keys (GRL_DATA (media), relkeys, 0);
 }
 
@@ -241,14 +282,21 @@ grl_media_set_url_data (GrlMedia *media,
  * @url: a media's URL
  * @mime: th @url mime type
  * @bitrate: the @url bitrate, or -1 to ignore
+ * @framerate: media framerate, or -1 to ignore
+ * @width: media width, or -1 to ignore
+ * @height: media height, or -1 to ignore
  *
- * Adds a new media's URL with its mime-type and bitrate.
+ * Sets all the keys related with the URL of a media resource and adds it to
+ * @media (useful for resources with more than one URL).
  **/
 void
 grl_media_add_url_data (GrlMedia *media,
                         const gchar *url,
                         const gchar *mime,
-                        gint bitrate)
+                        gint bitrate,
+                        gfloat framerate,
+                        gint width,
+                        gint height)
 {
   GrlRelatedKeys *relkeys;
 
@@ -260,6 +308,15 @@ grl_media_add_url_data (GrlMedia *media,
   if (bitrate >= 0) {
     grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_BITRATE, bitrate);
   }
+  if (framerate >= 0) {
+    grl_related_keys_set_float (relkeys, GRL_METADATA_KEY_FRAMERATE, framerate);
+  }
+  if (width >= 0) {
+    grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_WIDTH, width);
+  }
+  if (height >= 0) {
+    grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_HEIGHT, height);
+  }
   grl_data_add_related_keys (GRL_DATA (media), relkeys);
 }
 
@@ -438,6 +495,57 @@ grl_media_add_mb_artist_id (GrlMedia *media,
 }
 
 /**
+ * grl_media_add_performer:
+ * @media: a #GrlMedia
+ * @performer: an actor performing in the movie
+ *
+ * Adds the actor performing in the movie.
+ */
+void
+grl_media_add_performer (GrlMedia *media,
+                         const gchar *performer)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_add_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_PERFORMER,
+                       performer);
+}
+
+/**
+ * grl_media_add_producer:
+ * @media: a #GrlMedia
+ * @producer: producer of the movie
+ *
+ * Adds the producer of the media.
+ */
+void
+grl_media_add_producer (GrlMedia *media,
+                        const gchar *producer)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_add_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_PRODUCER,
+                       producer);
+}
+
+/**
+ * grl_media_add_director:
+ * @media: a #GrlMedia
+ * @director: director of the movie
+ *
+ * Adds the director of the media
+ */
+void
+grl_media_add_director (GrlMedia *media,
+                        const gchar *director)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_add_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_DIRECTOR,
+                       director);
+}
+
+/**
  * grl_media_serialize:
  * @media: a #GrlMedia
  *
@@ -1540,6 +1648,187 @@ grl_media_set_artist (GrlMedia *media, const gchar *artist)
 }
 
 /**
+ * grl_media_set_width:
+ * @media: the media instance
+ * @width: the video's width
+ *
+ * Set the width of the media
+ */
+void
+grl_media_set_width (GrlMedia *media, gint width)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_int (GRL_DATA (media),
+                    GRL_METADATA_KEY_WIDTH,
+                    width);
+}
+
+/**
+ * grl_media_set_height:
+ * @media: the media instance
+ * @height: the video's height
+ *
+ * Set the height of the media
+ */
+void
+grl_media_set_height (GrlMedia *media, gint height)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_int (GRL_DATA (media),
+                    GRL_METADATA_KEY_HEIGHT,
+                    height);
+}
+
+/**
+ * grl_media_set_framerate:
+ * @media: the media instance
+ * @framerate: the video's framerate
+ *
+ * Set the framerate of the media
+ */
+void
+grl_media_set_framerate (GrlMedia *media, gfloat framerate)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_float (GRL_DATA (media),
+                      GRL_METADATA_KEY_FRAMERATE,
+                      framerate);
+}
+
+/**
+ * grl_media_set_season:
+ * @media: the media instance
+ * @season: the video's season
+ *
+ * Sets the season number of the media
+ */
+void
+grl_media_set_season (GrlMedia *media, gint season)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_int (GRL_DATA (media),
+                    GRL_METADATA_KEY_SEASON,
+                    season);
+}
+
+/**
+ * grl_media_set_episode:
+ * @media: the media instance
+ * @episode: the video's episode
+ *
+ * Sets the episode number of the media
+ */
+void
+grl_media_set_episode (GrlMedia *media, gint episode)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_int (GRL_DATA (media),
+                    GRL_METADATA_KEY_EPISODE,
+                    episode);
+}
+
+/**
+ * grl_media_set_episode_title:
+ * @media: the media instance
+ * @episode_title: the title of the episode
+ *
+ * Sets the title of an media
+ */
+void
+grl_media_set_episode_title (GrlMedia *media,
+                             const gchar *episode_title)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_EPISODE_TITLE,
+                       episode_title);
+}
+
+/**
+ * grl_media_set_show:
+ * @media: the media instance
+ * @show: the video's show name
+ *
+ * Sets the show title of the media
+ */
+void
+grl_media_set_show (GrlMedia *media, const gchar *show)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_SHOW,
+                       show);
+}
+
+/**
+ * grl_media_set_performer:
+ * @media: a #GrlMedia
+ * @performer: an actor performing in the movie
+ *
+ * Sets the actor performing in the movie.
+ */
+void
+grl_media_set_performer (GrlMedia *media,
+                         const gchar *performer)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_PERFORMER,
+                       performer);
+}
+
+/**
+ * grl_media_set_producer:
+ * @media: a #GrlMedia
+ * @producer: producer of the movie
+ *
+ * Sets the producer of the media.
+ */
+void
+grl_media_set_producer (GrlMedia *media, const gchar *producer)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_PRODUCER,
+                       producer);
+}
+
+/**
+ * grl_media_set_director:
+ * @media: a #GrlMedia
+ * @director: director of the movie
+ *
+ * Sets the director of the media.
+ */
+void
+grl_media_set_director (GrlMedia *media,
+                        const gchar *director)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_DIRECTOR,
+                       director);
+}
+
+/**
+ * grl_media_set_original_title:
+ * @media: a #GrlMedia
+ * @original_title: original, untranslated title of the movie
+ *
+ * Sets the original, untranslated title of the media.
+ */
+void
+grl_media_set_original_title (GrlMedia *media,
+                              const gchar *original_title)
+{
+  g_return_if_fail (GRL_IS_MEDIA (media));
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_ORIGINAL_TITLE,
+                       original_title);
+}
+
+/**
  * grl_media_get_id:
  * @media: the media object
  *
@@ -1576,19 +1865,30 @@ grl_media_get_url (GrlMedia *media)
  * @media: the media object
  * @mime: (out) (transfer none): the mime-type, or %NULL to ignore.
  * @bitrate: (out): the url bitrate, 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 media's URL and its mime-type.
- *
- * Since: 0.1.10
+ * Returns: the media's URL and its related properties.
  */
 const gchar *
 grl_media_get_url_data (GrlMedia *media,
                         gchar **mime,
-                        gint *bitrate)
+                        gint *bitrate,
+                        gfloat *framerate,
+                        gint *width,
+                        gint *height)
+
 {
   g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
 
-  return grl_media_get_url_data_nth (media, 0, mime, bitrate);
+  return grl_media_get_url_data_nth (media,
+                                     0,
+                                     mime,
+                                     bitrate,
+                                     framerate,
+                                     width,
+                                     height);
 }
 
 /**
@@ -1597,16 +1897,20 @@ grl_media_get_url_data (GrlMedia *media,
  * @index: element to retrieve
  * @mime: (out) (transfer none): the mime-type, or %NULL to ignore.
  * @bitrate: (out): the url bitrate, or %NULL to ignore
- *
- * Returns: the n-th media's URL and its mime-type.
- *
- * Since: 0.1.10
+ * @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 media's URL and its related properties.
  */
 const gchar *
 grl_media_get_url_data_nth (GrlMedia *media,
                             guint index,
                             gchar **mime,
-                            gint *bitrate)
+                            gint *bitrate,
+                            gfloat *framerate,
+                            gint *width,
+                            gint *height)
 {
   GrlRelatedKeys *relkeys;
 
@@ -1619,14 +1923,25 @@ grl_media_get_url_data_nth (GrlMedia *media,
   }
 
   if (mime) {
-    *mime = (gchar *) grl_related_keys_get_string (relkeys,
-                                                   GRL_METADATA_KEY_MIME);
+    *mime = (gchar *) grl_related_keys_get_string (relkeys, GRL_METADATA_KEY_MIME);
   }
 
   if (bitrate) {
     *bitrate = grl_related_keys_get_int (relkeys, GRL_METADATA_KEY_BITRATE);
   }
 
+  if (framerate) {
+    *framerate = grl_related_keys_get_float (relkeys, GRL_METADATA_KEY_FRAMERATE);
+  }
+
+  if (width) {
+    *width = grl_related_keys_get_int (relkeys, GRL_METADATA_KEY_WIDTH);
+  }
+
+  if (height) {
+    *height = grl_related_keys_get_int (relkeys, GRL_METADATA_KEY_HEIGHT);
+  }
+
   return grl_related_keys_get_string (relkeys, GRL_METADATA_KEY_URL);
 }
 
@@ -2335,7 +2650,7 @@ grl_media_get_size (GrlMedia *media)
 gint
 grl_media_get_track_number (GrlMedia *media)
 {
-  g_return_val_if_fail (GRL_IS_MEDIA (media), -1);
+  g_return_val_if_fail (GRL_IS_MEDIA (media), 0);
   return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_TRACK_NUMBER);
 }
 
@@ -2348,7 +2663,7 @@ grl_media_get_track_number (GrlMedia *media)
 gint
 grl_media_get_bitrate (GrlMedia *media)
 {
-  g_return_val_if_fail (GRL_IS_MEDIA (media), -1);
+  g_return_val_if_fail (GRL_IS_MEDIA (media), 0);
   return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_BITRATE);
 }
 
@@ -2566,3 +2881,236 @@ grl_media_get_media_type (GrlMedia *media)
 
   return media->priv->media_type;
 }
+
+/**
+ * grl_media_get_width:
+ * @media: the media instance
+ *
+ * Returns: the width of the media
+ */
+gint
+grl_media_get_width (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_MEDIA (media), 0);
+  return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_WIDTH);
+}
+
+/**
+ * grl_media_get_height:
+ * @media: the media instance
+ *
+ * Returns: the height of the media
+ */
+gint
+grl_media_get_height (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_MEDIA (media), 0);
+  return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_HEIGHT);
+}
+
+/**
+ * grl_media_get_framerate:
+ * @media: the media instance
+ *
+ * Returns: the framerate of the media
+ */
+gfloat
+grl_media_get_framerate (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_MEDIA (media), 0);
+  return grl_data_get_float (GRL_DATA (media), GRL_METADATA_KEY_FRAMERATE);
+}
+
+/**
+ * grl_media_get_season:
+ * @media: the media instance
+ *
+ * Returns: the season number of the media
+ */
+gint
+grl_media_get_season (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_MEDIA (media), 0);
+  return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_SEASON);
+}
+
+/**
+ * grl_media_get_episode:
+ * @media: the media instance
+ *
+ * Returns: the episode number of the media
+ */
+gint
+grl_media_get_episode (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_MEDIA (media), 0);
+  return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_EPISODE);
+}
+
+/**
+ * grl_media_get_episode_title:
+ * @media: the media instance
+ *
+ * Returns: the title of the episode
+ */
+const gchar *
+grl_media_get_episode_title (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+
+  return grl_data_get_string (GRL_DATA (media), GRL_METADATA_KEY_EPISODE_TITLE);
+}
+
+/**
+ * grl_media_get_show:
+ * @media: the media instance
+ *
+ * Returns: the show title of the media
+ */
+const gchar *
+grl_media_get_show (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+
+  return grl_data_get_string (GRL_DATA (media), GRL_METADATA_KEY_SHOW);
+}
+
+/**
+ * grl_media_get_performer:
+ * @media: a #GrlMedia
+ *
+ * Returns: (transfer none): the actor performing in the movie (owned by @media).
+ */
+const gchar *
+grl_media_get_performer (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+  return grl_data_get_string (GRL_DATA (media),
+                              GRL_METADATA_KEY_PERFORMER);
+}
+
+/**
+ * grl_media_get_performer_nth:
+ * @media: a #GrlMedia
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the actor performing in the movie (owned by @medi).
+ */
+const gchar *
+grl_media_get_performer_nth (GrlMedia *media,
+                             guint index)
+{
+  GrlRelatedKeys *relkeys;
+
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+
+  relkeys =
+    grl_data_get_related_keys (GRL_DATA (media),
+                               GRL_METADATA_KEY_PERFORMER,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_PERFORMER);
+}
+
+/**
+ * grl_media_get_producer:
+ * @media: a #GrlMedia
+ *
+ * Returns: (transfer none): the producer of the movie (owned by @media).
+ */
+const gchar *
+grl_media_get_producer (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+  return grl_data_get_string (GRL_DATA (media),
+                              GRL_METADATA_KEY_PRODUCER);
+}
+
+/**
+ * grl_media_get_producer_nth:
+ * @media: a #GrlMedia
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the producer of the movie (owned by @media).
+ */
+const gchar *
+grl_media_get_producer_nth (GrlMedia *media,
+                            guint index)
+{
+  GrlRelatedKeys *relkeys;
+
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+
+  relkeys =
+    grl_data_get_related_keys (GRL_DATA (media),
+                               GRL_METADATA_KEY_PRODUCER,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_PRODUCER);
+}
+
+/**
+ * grl_media_get_director:
+ * @media: a #GrlMedia
+ *
+ * Returns: (transfer none): the director of the movie (owned by @media).
+ */
+const gchar *
+grl_media_get_director (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+  return grl_data_get_string (GRL_DATA (media),
+                              GRL_METADATA_KEY_DIRECTOR);
+}
+
+/**
+ * grl_media_get_director_nth:
+ * @media: a #GrlMedia
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the director of the movie (owned by @media).
+ */
+const gchar *
+grl_media_get_director_nth (GrlMedia *media,
+                            guint index)
+{
+  GrlRelatedKeys *relkeys;
+
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+
+  relkeys =
+    grl_data_get_related_keys (GRL_DATA (media),
+                               GRL_METADATA_KEY_DIRECTOR,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_DIRECTOR);
+}
+
+/**
+ * grl_media_get_original_title:
+ * @media: a #GrlMedia
+ *
+ * Returns: (transfer none): the original, untranslated title of the movie (owned by @media).
+ */
+const gchar *
+grl_media_get_original_title (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), NULL);
+  return grl_data_get_string (GRL_DATA (media),
+                              GRL_METADATA_KEY_ORIGINAL_TITLE);
+}
diff --git a/src/data/grl-media.h b/src/data/grl-media.h
index af1d311..87609e4 100644
--- a/src/data/grl-media.h
+++ b/src/data/grl-media.h
@@ -165,7 +165,7 @@ void grl_media_set_license (GrlMedia *media, 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, gint bitrate);
+void grl_media_set_url_data (GrlMedia *media, const gchar *url, const gchar *mime, gint bitrate, gfloat 
framerate, gint width, gint height);
 
 void grl_media_set_favourite (GrlMedia *media, gboolean favourite);
 
@@ -193,7 +193,29 @@ void grl_media_set_album (GrlMedia *media, const gchar *album);
 
 void grl_media_set_artist (GrlMedia *media, const gchar *artist);
 
-void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime, gint bitrate);
+void grl_media_set_width (GrlMedia *media, gint width);
+
+void grl_media_set_height (GrlMedia *media, gint height);
+
+void grl_media_set_framerate (GrlMedia *media, gfloat framerate);
+
+void grl_media_set_season (GrlMedia *media, gint season);
+
+void grl_media_set_episode (GrlMedia *media, gint episode);
+
+void grl_media_set_episode_title (GrlMedia *media, const gchar *episode_title);
+
+void grl_media_set_show (GrlMedia *media, const gchar *show);
+
+void grl_media_set_performer (GrlMedia *media, const gchar *performer);
+
+void grl_media_set_producer (GrlMedia *media, const gchar *producer);
+
+void grl_media_set_director (GrlMedia *media, const gchar *director);
+
+void grl_media_set_original_title (GrlMedia *media, const gchar *original_title);
+
+void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime, gint bitrate, gfloat 
framerate, gint width, gint height);
 
 void grl_media_add_author (GrlMedia *media, const gchar *author);
 
@@ -215,13 +237,19 @@ void grl_media_add_lyrics (GrlMedia *media, const gchar *lyrics);
 
 void grl_media_add_mb_artist_id (GrlMedia *media, const gchar *mb_artist_id);
 
+void grl_media_add_performer (GrlMedia *media, const gchar *performer);
+
+void grl_media_add_producer (GrlMedia *media, const gchar *producer);
+
+void grl_media_add_director (GrlMedia *media, const gchar *director);
+
 const gchar *grl_media_get_id (GrlMedia *media);
 
 const gchar *grl_media_get_url (GrlMedia *media);
 
-const gchar *grl_media_get_url_data (GrlMedia *media, gchar **mime, gint *bitrate);
+const gchar *grl_media_get_url_data (GrlMedia *media, gchar **mime, gint *bitrate, gfloat *framerate, gint 
*width, gint *height);
 
-const gchar *grl_media_get_url_data_nth (GrlMedia *media, guint index, gchar **mime, gint *bitrate);
+const gchar *grl_media_get_url_data_nth (GrlMedia *media, guint index, gchar **mime, gint *bitrate, gfloat 
*framerate, gint *width, gint *height);
 
 const gchar *grl_media_get_author (GrlMedia *media);
 
@@ -326,15 +354,48 @@ const gchar *grl_media_get_artist_nth (GrlMedia *media, guint index);
 
 GrlMediaType grl_media_get_media_type (GrlMedia *media);
 
+gint grl_media_get_width (GrlMedia *media);
+
+gint grl_media_get_height (GrlMedia *media);
+
+gfloat grl_media_get_framerate (GrlMedia *media);
+
+gint grl_media_get_season (GrlMedia *media);
+
+gint grl_media_get_episode (GrlMedia *media);
+
+const gchar *grl_media_get_episode_title (GrlMedia *media);
+
+const gchar *grl_media_get_show (GrlMedia *media);
+
+const gchar *grl_media_get_performer (GrlMedia *media);
+
+const gchar *grl_media_get_performer_nth (GrlMedia *media, guint index);
+
+const gchar *grl_media_get_producer (GrlMedia *media);
+
+const gchar *grl_media_get_producer_nth (GrlMedia *media, guint index);
+
+const gchar *grl_media_get_director (GrlMedia *media);
+
+const gchar *grl_media_get_director_nth (GrlMedia *media, guint index);
+
+const gchar *grl_media_get_original_title (GrlMedia *media);
+
 GType grl_media_get_type (void) G_GNUC_CONST;
 
 GrlMedia *grl_media_new (void);
 
 GrlMedia *grl_media_audio_new (void);
 
+GrlMedia *grl_media_video_new (void);
+
 gboolean
 grl_media_is_audio (GrlMedia *media);
 
+gboolean
+grl_media_is_video (GrlMedia *media);
+
 gchar *grl_media_serialize (GrlMedia *media);
 
 gchar *grl_media_serialize_extended (GrlMedia *media,
diff --git a/src/grilo.c b/src/grilo.c
index de2684d..e5a3db8 100644
--- a/src/grilo.c
+++ b/src/grilo.c
@@ -110,7 +110,6 @@ post_parse_hook_cb (GOptionContext  *context,
 
   /* Register GrlMedia in glib typesystem */
   g_type_class_ref (GRL_TYPE_MEDIA_BOX);
-  g_type_class_ref (GRL_TYPE_MEDIA_VIDEO);
   g_type_class_ref (GRL_TYPE_MEDIA_IMAGE);
 
   /* Set default plugin directories */
diff --git a/src/grilo.h b/src/grilo.h
index 9f93287..fc48869 100644
--- a/src/grilo.h
+++ b/src/grilo.h
@@ -34,7 +34,6 @@
 #include <grl-metadata-key.h>
 #include <grl-data.h>
 #include <grl-media.h>
-#include <grl-media-video.h>
 #include <grl-media-image.h>
 #include <grl-media-box.h>
 #include <grl-config.h>
diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index 4b82ca4..ff93aef 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -343,7 +343,7 @@ get_icon_for_media (GrlMedia *media)
 {
   if (GRL_IS_MEDIA_BOX (media)) {
     return g_themed_icon_new ("folder");
-  } else if (GRL_IS_MEDIA_VIDEO (media)) {
+  } else if (grl_media_is_video (media)) {
     return g_themed_icon_new ("gnome-mime-video");
   } else if (grl_media_is_audio (media)) {
     return g_themed_icon_new ("gnome-mime-audio");
@@ -617,7 +617,7 @@ resolve_cb (GrlSource *source,
 
     /* Set/unset show button */
     if ((grl_media_is_audio (media) ||
-         GRL_IS_MEDIA_VIDEO (media) ||
+         grl_media_is_video (media) ||
          GRL_IS_MEDIA_IMAGE (media)) &&
         (ui_state->last_url = grl_media_get_url (media))) {
       gtk_widget_set_sensitive (view->show_btn, TRUE);


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