[rygel-grilo] Handle "Size" property as int64



commit 53d2cfef5bb53d23301b363326629ce4279c160d
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed Sep 8 00:27:51 2010 +0200

    Handle "Size" property as int64
    
    It covers a change done in MediaServer2 specification.

 lib/media-server2-client.c        |    6 ++--
 lib/media-server2-client.h        |    2 +-
 lib/media-server2-introspection.h |    2 +-
 lib/media-server2-server-table.c  |   17 +++++++++++-
 lib/media-server2-server.c        |   51 ++++++++++++++++++++++++++++--------
 lib/media-server2-server.h        |    2 +-
 6 files changed, 60 insertions(+), 20 deletions(-)
---
diff --git a/lib/media-server2-client.c b/lib/media-server2-client.c
index 1d8a7ed..cadee24 100644
--- a/lib/media-server2-client.c
+++ b/lib/media-server2-client.c
@@ -1578,7 +1578,7 @@ ms2_client_get_genre (GHashTable *properties)
  *
  * Returns: property value or -1 if it is not available
  **/
-gint
+gint64
 ms2_client_get_size (GHashTable *properties)
 {
   GValue *val;
@@ -1586,11 +1586,11 @@ ms2_client_get_size (GHashTable *properties)
   g_return_val_if_fail (properties, -1);
 
   val = g_hash_table_lookup (properties, MS2_PROP_SIZE);
-  if (!val || !G_VALUE_HOLDS_INT (val)) {
+  if (!val || !G_VALUE_HOLDS_INT64 (val)) {
     return -1;
   }
 
-  return g_value_get_int (val);
+  return g_value_get_int64 (val);
 }
 
 /**
diff --git a/lib/media-server2-client.h b/lib/media-server2-client.h
index d77ce12..ecaf2cd 100644
--- a/lib/media-server2-client.h
+++ b/lib/media-server2-client.h
@@ -207,7 +207,7 @@ const gchar *ms2_client_get_album_art (GHashTable *properties);
 
 const gchar *ms2_client_get_genre (GHashTable *properties);
 
-gint  ms2_client_get_size (GHashTable *properties);
+gint64  ms2_client_get_size (GHashTable *properties);
 
 gint  ms2_client_get_duration (GHashTable *properties);
 
diff --git a/lib/media-server2-introspection.h b/lib/media-server2-introspection.h
index 0119b92..e3a3ed4 100644
--- a/lib/media-server2-introspection.h
+++ b/lib/media-server2-introspection.h
@@ -43,7 +43,7 @@
   "  <interface name=\"org.gnome.UPnP.MediaItem2\">"                    \
   "    <property name=\"URLs\"           type=\"as\" access=\"read\"/>" \
   "    <property name=\"MIMEType\"       type=\"s\"  access=\"read\"/>" \
-  "    <property name=\"Size\"           type=\"i\"  access=\"read\"/>" \
+  "    <property name=\"Size\"           type=\"x\"  access=\"read\"/>" \
   "    <property name=\"Artist\"         type=\"s\"  access=\"read\"/>" \
   "    <property name=\"Album\"          type=\"s\"  access=\"read\"/>" \
   "    <property name=\"Date\"           type=\"s\"  access=\"read\"/>" \
diff --git a/lib/media-server2-server-table.c b/lib/media-server2-server-table.c
index feffa4a..33d83f4 100644
--- a/lib/media-server2-server-table.c
+++ b/lib/media-server2-server-table.c
@@ -66,6 +66,19 @@ int_to_value (gint number)
   return val;
 }
 
+/* Puts an int64 in a gvalue */
+static GValue *
+int64_to_value (gint64 number)
+{
+  GValue *val = NULL;
+
+  val = g_new0 (GValue, 1);
+  g_value_init (val, G_TYPE_INT64);
+  g_value_set_int64 (val, number);
+
+  return val;
+}
+
 /* Puts an uint in a gvalue */
 static GValue *
 uint_to_value (guint number)
@@ -494,13 +507,13 @@ ms2_server_set_genre (MS2Server *server,
 void
 ms2_server_set_size (MS2Server *server,
                      GHashTable *properties,
-                     gint size)
+                     gint64 size)
 {
   g_return_if_fail (properties);
 
   g_hash_table_insert (properties,
                        MS2_PROP_SIZE,
-                       int_to_value (size));
+                       int64_to_value (size));
 }
 
 /**
diff --git a/lib/media-server2-server.c b/lib/media-server2-server.c
index 8e235af..027d677 100644
--- a/lib/media-server2-server.c
+++ b/lib/media-server2-server.c
@@ -174,6 +174,19 @@ int_to_value (gint number)
   return val;
 }
 
+/* Puts an int64 in a gvalue */
+static GValue *
+int64_to_value (gint64 number)
+{
+  GValue *val = NULL;
+
+  val = g_new0 (GValue, 1);
+  g_value_init (val, G_TYPE_INT64);
+  g_value_set_int64 (val, number);
+
+  return val;
+}
+
 /* Puts an uint in a gvalue */
 static GValue *
 uint_to_value (guint number)
@@ -239,24 +252,30 @@ properties_lookup_with_default (GHashTable *properties,
   GValue *propvalue;
   const gchar *intern_property;
   static gchar **int_type_properties = NULL;
+  static gchar **int64_type_properties = NULL;
   static gchar **uint_type_properties = NULL;
   static gchar **bool_type_properties = NULL;
   static gchar **gptrarray_type_properties = NULL;
 
   /* Initialize data */
   if (!int_type_properties) {
-    int_type_properties = g_new (gchar *, 11);
-    int_type_properties[0] = (gchar *) g_intern_static_string (MS2_PROP_SIZE);
-    int_type_properties[1] = (gchar *) g_intern_static_string (MS2_PROP_DURATION);
-    int_type_properties[2] = (gchar *) g_intern_static_string (MS2_PROP_BITRATE);
-    int_type_properties[3] = (gchar *) g_intern_static_string (MS2_PROP_SAMPLE_RATE);
-    int_type_properties[4] = (gchar *) g_intern_static_string (MS2_PROP_BITS_PER_SAMPLE);
-    int_type_properties[5] = (gchar *) g_intern_static_string (MS2_PROP_WIDTH);
-    int_type_properties[6] = (gchar *) g_intern_static_string (MS2_PROP_HEIGHT);
-    int_type_properties[7] = (gchar *) g_intern_static_string (MS2_PROP_COLOR_DEPTH);
-    int_type_properties[8] = (gchar *) g_intern_static_string (MS2_PROP_PIXEL_WIDTH);
-    int_type_properties[9] = (gchar *) g_intern_static_string (MS2_PROP_PIXEL_HEIGHT);
-    int_type_properties[10] = NULL;
+    int_type_properties = g_new (gchar *, 10);
+    int_type_properties[0] = (gchar *) g_intern_static_string (MS2_PROP_DURATION);
+    int_type_properties[1] = (gchar *) g_intern_static_string (MS2_PROP_BITRATE);
+    int_type_properties[2] = (gchar *) g_intern_static_string (MS2_PROP_SAMPLE_RATE);
+    int_type_properties[3] = (gchar *) g_intern_static_string (MS2_PROP_BITS_PER_SAMPLE);
+    int_type_properties[4] = (gchar *) g_intern_static_string (MS2_PROP_WIDTH);
+    int_type_properties[5] = (gchar *) g_intern_static_string (MS2_PROP_HEIGHT);
+    int_type_properties[6] = (gchar *) g_intern_static_string (MS2_PROP_COLOR_DEPTH);
+    int_type_properties[7] = (gchar *) g_intern_static_string (MS2_PROP_PIXEL_WIDTH);
+    int_type_properties[8] = (gchar *) g_intern_static_string (MS2_PROP_PIXEL_HEIGHT);
+    int_type_properties[9] = NULL;
+  }
+
+  if (!int64_type_properties) {
+    int64_type_properties = g_new (gchar *, 2);
+    int64_type_properties[0] = (gchar *) g_intern_static_string (MS2_PROP_SIZE);
+    int64_type_properties[1] = NULL;
   }
 
   if (!uint_type_properties) {
@@ -298,6 +317,8 @@ properties_lookup_with_default (GHashTable *properties,
   intern_property = g_intern_string (property);
   if (lookup_in_strv (int_type_properties, intern_property)) {
     ret_value = int_to_value (MS2_UNKNOWN_INT);
+  } else if (lookup_in_strv (int64_type_properties, intern_property)) {
+    ret_value = int64_to_value (MS2_UNKNOWN_INT);
   } else if (lookup_in_strv (uint_type_properties, intern_property)) {
     ret_value = uint_to_value (MS2_UNKNOWN_UINT);
   } else if (lookup_in_strv (bool_type_properties, intern_property)) {
@@ -532,6 +553,7 @@ add_variant (DBusMessage *m,
   const gchar *str_value;
   gboolean bool_value;
   gint int_value;
+  gint int64_value;
   guint uint_value;
 
   if (!iter) {
@@ -557,6 +579,11 @@ add_variant (DBusMessage *m,
     dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "i", &sub);
     dbus_message_iter_append_basic (&sub, DBUS_TYPE_INT32, &int_value);
     dbus_message_iter_close_container (iter, &sub);
+  } else if (G_VALUE_HOLDS_INT64 (v)) {
+    int64_value = g_value_get_int64 (v);
+    dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "i", &sub);
+    dbus_message_iter_append_basic (&sub, DBUS_TYPE_INT64, &int64_value);
+    dbus_message_iter_close_container (iter, &sub);
   } else if (G_VALUE_HOLDS_UINT (v)) {
     uint_value = g_value_get_uint (v);
     dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "u", &sub);
diff --git a/lib/media-server2-server.h b/lib/media-server2-server.h
index 619fe1f..b5f530e 100644
--- a/lib/media-server2-server.h
+++ b/lib/media-server2-server.h
@@ -178,7 +178,7 @@ void ms2_server_set_album_art (MS2Server *server,
 
 void ms2_server_set_size (MS2Server *server,
                           GHashTable *properties,
-                          gint size);
+                          gint64 size);
 
 void ms2_server_set_duration (MS2Server *server,
                               GHashTable *properties,



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