[rygel] core: add timestamp to MediaObject



commit 1c2c3a008fac0c0c4fbaa48454e8e85dd964500c
Author: Jens Georg <mail jensge org>
Date:   Sun Jun 28 03:46:17 2009 +0200

    core: add timestamp to MediaObject

 src/rygel/rygel-media-db.vala           |   18 +++++++++++-------
 src/rygel/rygel-media-object.vala       |    1 +
 src/rygel/rygel-metadata-extractor.vala |   11 ++++++++++-
 3 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/src/rygel/rygel-media-db.vala b/src/rygel/rygel-media-db.vala
index 750e7ec..4208e03 100644
--- a/src/rygel/rygel-media-db.vala
+++ b/src/rygel/rygel-media-db.vala
@@ -121,11 +121,11 @@ public class Rygel.MediaDB : Object {
          "WHERE object_fk = ?";
 
     private const string INSERT_OBJECT_STRING =
-    "INSERT INTO Object (upnp_id, title, type_fk, parent) " +
-        "VALUES (?,?,?,?)";
+    "INSERT INTO Object (upnp_id, title, type_fk, parent, timestamp) " +
+        "VALUES (?,?,?,?,?)";
 
     private const string UPDATE_OBJECT_STRING =
-    "UPDATE Object SET title = ? WHERE upnp_id = ?";
+    "UPDATE Object SET title = ?, timestamp = ? WHERE upnp_id = ?";
 
     private const string INSERT_URI_STRING =
     "INSERT INTO Uri (object_fk, uri) VALUES (?,?)";
@@ -161,7 +161,7 @@ public class Rygel.MediaDB : Object {
             "Meta_Data.date, Meta_Data.bitrate, Meta_Data.sample_freq, " +
             "Meta_Data.bits_per_sample, Meta_Data.channels, " +
             "Meta_Data.track, Meta_Data.color_depth, Meta_Data.duration, " +
-            "upnp_id, Object.parent " +
+            "upnp_id, Object.parent, Object.timestamp " +
     "FROM Object LEFT OUTER JOIN Meta_Data " +
         "ON Object.upnp_id = Meta_Data.object_fk " +
     "WHERE Object.parent = ? " +
@@ -376,7 +376,8 @@ public class Rygel.MediaDB : Object {
                                 null);
         if (rc == Sqlite.OK) {
             statement.bind_text (1, obj.title);
-            statement.bind_text (2, obj.id);
+            statement.bind_int64 (2, (int64) obj.timestamp);
+            statement.bind_text (3, obj.id);
             rc = statement.step ();
             if (rc != Sqlite.DONE && rc != Sqlite.OK) {
                 throw new MediaDBError.SQLITE_ERROR (db.errmsg ());
@@ -462,6 +463,8 @@ public class Rygel.MediaDB : Object {
             } else {
                 statement.bind_text (4, item.parent.id);
             }
+
+            statement.bind_int64 (5, (int64) item.timestamp);
             rc = statement.step ();
             if (rc != Sqlite.OK && rc != Sqlite.DONE) {
                 throw new MediaDBError.SQLITE_ERROR (db.errmsg ());
@@ -586,6 +589,7 @@ public class Rygel.MediaDB : Object {
         }
 
         if (obj != null) {
+            obj.timestamp = statement.column_int64 (18);
             add_uris (obj);
         }
         return obj;
@@ -692,8 +696,8 @@ public class Rygel.MediaDB : Object {
                                 null);
         if (rc == Sqlite.OK) {
             statement.bind_text (1, object_id);
-            statement.bind_int64 (2, (int64)offset);
-            statement.bind_int64 (3, (int64)max_count);
+            statement.bind_int64 (2, (int64) offset);
+            statement.bind_int64 (3, (int64) max_count);
             while ((rc = statement.step ()) == Sqlite.ROW) {
                 var child_id = statement.column_text (17);
                 var parent = get_object (statement.column_text (18));
diff --git a/src/rygel/rygel-media-object.vala b/src/rygel/rygel-media-object.vala
index d6b1b9b..ace77e9 100644
--- a/src/rygel/rygel-media-object.vala
+++ b/src/rygel/rygel-media-object.vala
@@ -29,6 +29,7 @@ using Gee;
 public abstract class Rygel.MediaObject : GLib.Object {
     public string id;
     public string title;
+    public uint64 timestamp;
     public Gee.ArrayList<string> uris;
 
     // You can keep both a unowned and owned ref to parent of this MediaObject.
diff --git a/src/rygel/rygel-metadata-extractor.vala b/src/rygel/rygel-metadata-extractor.vala
index fa7dd4d..a6095f8 100644
--- a/src/rygel/rygel-metadata-extractor.vala
+++ b/src/rygel/rygel-metadata-extractor.vala
@@ -48,6 +48,7 @@ public class Rygel.MetadataExtractor: GLib.Object {
     public const string TAG_RYGEL_WIDTH = "rygel-width";
     public const string TAG_RYGEL_HEIGHT = "rygel-height";
     public const string TAG_RYGEL_DEPTH = "rygel-depth";
+    public const string TAG_RYGEL_MTIME = "rygel-mtime";
 
     /* TODO: Use tagbin instead once it's ready */
     private dynamic Gst.Element playbin;
@@ -83,6 +84,7 @@ public class Rygel.MetadataExtractor: GLib.Object {
         this.register_custom_tag (TAG_RYGEL_WIDTH, typeof (int));
         this.register_custom_tag (TAG_RYGEL_HEIGHT, typeof (int));
         this.register_custom_tag (TAG_RYGEL_DEPTH, typeof (int));
+        this.register_custom_tag (TAG_RYGEL_MTIME, typeof (uint64));
 
         // setup fake sinks
         this.playbin = ElementFactory.make ("playbin", null);
@@ -191,7 +193,8 @@ public class Rygel.MetadataExtractor: GLib.Object {
         try {
             file_info = file.query_info (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE
                                          + "," +
-                                         FILE_ATTRIBUTE_STANDARD_SIZE,
+                                         FILE_ATTRIBUTE_STANDARD_SIZE + "," +
+                                         FILE_ATTRIBUTE_TIME_MODIFIED,
                                          FileQueryInfoFlags.NONE,
                                          null);
         } catch (Error error) {
@@ -217,6 +220,12 @@ public class Rygel.MetadataExtractor: GLib.Object {
         this.tag_list.add (TagMergeMode.REPLACE,
                            TAG_RYGEL_SIZE,
                            size);
+
+        var mtime = file_info.get_attribute_uint64(
+                                                FILE_ATTRIBUTE_TIME_MODIFIED);
+        this.tag_list.add (TagMergeMode.REPLACE,
+                           TAG_RYGEL_MTIME,
+                           mtime);
     }
 
     private void extract_duration () {



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