[grilo] core: Add metadata key for size



commit 09d9b0a88286a5bf29414187ebcf636474d83c75
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Mon Mar 3 00:03:14 2014 +0000

    core: Add metadata key for size
    
    Add GRL_METADATA_KEY_SIZE, and proper functions, that get/set the size in media
    size in bytes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=629002

 doc/grilo/grilo-sections.txt |    2 ++
 src/data/grl-media.c         |   28 ++++++++++++++++++++++++++++
 src/data/grl-media.h         |    4 ++++
 src/grl-metadata-key.c       |   13 +++++++++++++
 src/grl-metadata-key.h       |    1 +
 5 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/doc/grilo/grilo-sections.txt b/doc/grilo/grilo-sections.txt
index 55edc41..8bef646 100644
--- a/doc/grilo/grilo-sections.txt
+++ b/doc/grilo/grilo-sections.txt
@@ -380,6 +380,7 @@ grl_media_get_title
 grl_media_get_url
 grl_media_get_url_data
 grl_media_get_url_data_nth
+grl_media_get_size
 grl_media_serialize
 grl_media_serialize_extended
 grl_media_set_author
@@ -410,6 +411,7 @@ grl_media_set_thumbnail_binary
 grl_media_set_title
 grl_media_set_url
 grl_media_set_url_data
+grl_media_set_size
 grl_media_unserialize
 <SUBSECTION Standard>
 GRL_IS_MEDIA
diff --git a/src/data/grl-media.c b/src/data/grl-media.c
index 1ad2f58..1e5ffee 100644
--- a/src/data/grl-media.c
+++ b/src/data/grl-media.c
@@ -1120,6 +1120,21 @@ grl_media_set_keyword (GrlMedia *media,
 }
 
 /**
+ * grl_media_set_size:
+ * @media: the media
+ * @size: the size in bytes
+ *
+ * Set the size of the media
+ */
+void
+grl_media_set_size (GrlMedia *media, gint size)
+{
+  grl_data_set_int (GRL_DATA (media),
+                    GRL_METADATA_KEY_SIZE,
+                    size);
+}
+
+/**
  * grl_media_get_id:
  * @media: the media object
  *
@@ -1789,3 +1804,16 @@ grl_media_get_keyword_nth (GrlMedia *media,
   return grl_related_keys_get_string (relkeys,
                                       GRL_METADATA_KEY_KEYWORD);
 }
+
+/**
+ * grl_media_get_size:
+ * @media: the media object
+ *
+ * Returns: the media's size, in bytes or -1 if unknown.
+ */
+gint
+grl_media_get_size (GrlMedia *media)
+{
+  g_return_val_if_fail (GRL_IS_MEDIA (media), -1);
+  return grl_data_get_int (GRL_DATA (media), GRL_METADATA_KEY_SIZE);
+}
diff --git a/src/data/grl-media.h b/src/data/grl-media.h
index ea7b82d..1043229 100644
--- a/src/data/grl-media.h
+++ b/src/data/grl-media.h
@@ -185,6 +185,8 @@ void grl_media_set_favourite (GrlMedia *media, gboolean favourite);
 
 void grl_media_set_keyword (GrlMedia *media, const gchar *keyword);
 
+void grl_media_set_size (GrlMedia *media, gint size);
+
 void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime);
 
 void grl_media_add_author (GrlMedia *media, const gchar *author);
@@ -278,6 +280,8 @@ const gchar *grl_media_get_keyword (GrlMedia *media);
 
 const gchar * grl_media_get_keyword_nth (GrlMedia *media, guint index);
 
+gint grl_media_get_size (GrlMedia *media);
+
 GType grl_media_get_type (void) G_GNUC_CONST;
 
 GrlMedia *grl_media_new (void);
diff --git a/src/grl-metadata-key.c b/src/grl-metadata-key.c
index ec5b73f..5f9a39f 100644
--- a/src/grl-metadata-key.c
+++ b/src/grl-metadata-key.c
@@ -511,6 +511,16 @@ grl_metadata_key_setup_system_keys (GrlRegistry *registry)
                                              GRL_METADATA_KEY_ORIGINAL_TITLE,
                                              NULL);
 
+  grl_registry_register_metadata_key_system (registry,
+                                             g_param_spec_int ("size",
+                                                               "Size",
+                                                               "Size in bytes",
+                                                               -1, G_MAXINT,
+                                                               -1,
+                                                               G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+                                             GRL_METADATA_KEY_SIZE,
+                                             NULL);
+
   /* Create the relations */
   grl_registry_register_metadata_key_relation (registry,
                                                GRL_METADATA_KEY_URL,
@@ -531,6 +541,9 @@ grl_metadata_key_setup_system_keys (GrlRegistry *registry)
                                                GRL_METADATA_KEY_URL,
                                                GRL_METADATA_KEY_START_TIME);
   grl_registry_register_metadata_key_relation (registry,
+                                               GRL_METADATA_KEY_URL,
+                                               GRL_METADATA_KEY_SIZE);
+  grl_registry_register_metadata_key_relation (registry,
                                                GRL_METADATA_KEY_REGION,
                                                GRL_METADATA_KEY_PUBLICATION_DATE);
   grl_registry_register_metadata_key_relation (registry,
diff --git a/src/grl-metadata-key.h b/src/grl-metadata-key.h
index f525054..c20d752 100644
--- a/src/grl-metadata-key.h
+++ b/src/grl-metadata-key.h
@@ -96,6 +96,7 @@ typedef guint32 GrlKeyID;
 #define GRL_METADATA_KEY_PRODUCER             47
 #define GRL_METADATA_KEY_DIRECTOR             48
 #define GRL_METADATA_KEY_ORIGINAL_TITLE       49
+#define GRL_METADATA_KEY_SIZE                 50
 
 G_BEGIN_DECLS
 


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