media-export: Convenience function for object ids
authorJens Georg <mail@jensge.org>
Fri, 23 Jul 2010 20:45:37 +0000 (23:45 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 24 Jul 2010 00:28:17 +0000 (03:28 +0300)
src/plugins/media-export/rygel-media-export-item.vala

index 41d7d69..ea270ae 100644 (file)
@@ -28,13 +28,16 @@ using Gst;
  * Represents MediaExport item.
  */
 public class Rygel.MediaExport.Item : Rygel.MediaItem {
+    public static string get_id (File file) {
+        return Checksum.compute_for_string (ChecksumType.MD5,
+                                            file.get_uri ());
+    }
+
     public Item.simple (MediaContainer parent,
                         File           file,
                         string         mime,
                         uint64         size,
                         uint64         mtime) {
-        string id = Checksum.compute_for_string (ChecksumType.MD5,
-                                                 file.get_uri ());
         var title = file.get_basename ();
         string upnp_class;
 
@@ -46,7 +49,7 @@ public class Rygel.MediaExport.Item : Rygel.MediaItem {
             upnp_class = MediaItem.AUDIO_CLASS;
         }
 
-        base (id, parent, title, upnp_class);
+        base (get_id (file), parent, title, upnp_class);
         this.mime_type = mime;
         this.size = (long) size;
         this.modified = mtime;
@@ -59,8 +62,7 @@ public class Rygel.MediaExport.Item : Rygel.MediaItem {
                                           string                mime,
                                           uint64                size,
                                           uint64                mtime) {
-        string id = Checksum.compute_for_string (ChecksumType.MD5,
-                                                 file.get_uri ());
+        string id = get_id (file);
         unowned StreamAudioInformation audio_info = null;
         unowned StreamVideoInformation video_info = null;