rygel r113 - in trunk: . src



Author: zeeshanak
Date: Tue Oct 28 21:00:39 2008
New Revision: 113
URL: http://svn.gnome.org/viewvc/rygel?rev=113&view=rev

Log:
Extract the mime-type using GIO.

Modified:
   trunk/ChangeLog
   trunk/src/gupnp-metadata-extractor.vala

Modified: trunk/src/gupnp-metadata-extractor.vala
==============================================================================
--- trunk/src/gupnp-metadata-extractor.vala	(original)
+++ trunk/src/gupnp-metadata-extractor.vala	Tue Oct 28 21:00:39 2008
@@ -54,6 +54,7 @@
             this.playbin.uri = value;
 
             if (this.playbin.uri != null) {
+                extract_mime ();
                 /* Start the extaction when we get a new URI */
                 this.playbin.set_state (State.PAUSED);
             }
@@ -93,6 +94,34 @@
         }
     }
 
+    private void extract_mime () {
+        File file = File.new_for_uri (this.uri);
+
+        weak FileInfo file_info;
+
+        try {
+            file_info = file.query_info (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+                                         FileQueryInfoFlags.NONE,
+                                         null);
+        } catch (Error error) {
+            critical ("Failed to query content type for '%s'\n", this.uri);
+
+            return;
+        }
+
+        weak string content_type = file_info.get_content_type ();
+        weak string mime = g_content_type_get_mime_type (content_type);
+        if (mime != null) {
+            GLib.Value value;
+
+            value.init (typeof (string));
+            value.set_string (mime);
+
+            /* signal the availability of new tag */
+            this.metadata_available (this.playbin.uri, "mime-type", ref value);
+        }
+    }
+
     private void tag_cb (Gst.Bus     bus,
                          Gst.Message message) {
         TagList tag_list;



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