[rygel] media-export: Add Fast image extractor



commit 45d49c14ee1df6018fedc382ad96e2c1e8d33e8f
Author: Jens Georg <mail jensge org>
Date:   Sun May 15 09:57:19 2016 +0200

    media-export: Add Fast image extractor
    
    Uses GdkPixbuf readers for fast meta-data extracting and does manual
    DLNA profile guessing.
    
    Signed-off-by: Jens Georg <mail jensge org>

 configure.ac                                       |    3 +-
 src/plugins/media-export/Makefile.am               |    2 +
 .../media-export/rygel-media-export-extractor.vala |    5 ++
 .../rygel-media-export-image-extractor.vala        |   67 ++++++++++++++++++++
 4 files changed, 76 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 35e77a7..50812e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -264,7 +264,8 @@ AS_IF([test "x$with_media_engine" = "xgstreamer"],
                                libsoup-2.4 >= $LIBSOUP_REQUIRED
                                sqlite3 >= $LIBSQLITE3_REQUIRED
                                libxml-2.0 >= $LIBXML_REQUIRED
-                               libmediaart-2.0 >= $MEDIAART_REQUIRED])
+                               libmediaart-2.0 >= $MEDIAART_REQUIRED
+                               gdk-pixbuf-2.0])
             RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg gupnp-dlna-2.0 
--pkg gupnp-dlna-gst-2.0 --pkg gstreamer-tag-1.0 --pkg gstreamer-app-1.0 --pkg gstreamer-pbutils-1.0 --pkg 
sqlite3 --pkg libmediaart-2.0"
             AC_SUBST([RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_VALAFLAGS])
           ])
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index c681797..3724eda 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -12,6 +12,7 @@ mx_extract_SOURCES = \
        rygel-media-export-extract.vala \
        rygel-media-export-dvd-parser.vala \
        rygel-media-export-playlist-extractor.vala \
+       rygel-media-export-image-extractor.vala \
        rygel-media-export-extractor.vala \
        rygel-media-export-generic-extractor.vala
 
@@ -19,6 +20,7 @@ mx_extract_VALAFLAGS = \
        --enable-experimental \
        --pkg posix \
        --pkg gio-unix-2.0 \
+       --pkg gdk-pixbuf-2.0 \
        $(RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_VALAFLAGS) \
        $(RYGEL_COMMON_VALAFLAGS)
 
diff --git a/src/plugins/media-export/rygel-media-export-extractor.vala 
b/src/plugins/media-export/rygel-media-export-extractor.vala
index 3f1fc83..97dfed1 100644
--- a/src/plugins/media-export/rygel-media-export-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-extractor.vala
@@ -72,6 +72,11 @@ public class Rygel.MediaExport.Extractor : Object {
             return new PlaylistExtractor (file);
         }
 
+        if (content_type == "image/jpeg" ||
+            content_type == "image/png") {
+            return new ImageExtractor (file);
+        }
+
         return new GenericExtractor (file);
     }
 
diff --git a/src/plugins/media-export/rygel-media-export-image-extractor.vala 
b/src/plugins/media-export/rygel-media-export-image-extractor.vala
new file mode 100644
index 0000000..7652266
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-image-extractor.vala
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Jens Georg <mail jensge org>
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using Gdk;
+
+internal class Rygel.MediaExport.ImageExtractor : Extractor {
+    public ImageExtractor (File file) {
+        GLib.Object (file : file);
+    }
+
+    public override async void run () throws Error {
+        int width;
+        int height;
+
+        var format = yield Pixbuf.get_file_info_async (file.get_path (),
+                                                       null,
+                                                       out width,
+                                                       out height);
+
+        var mime = format.get_mime_types ()[0];
+        // TODO: Use enhanced EXIF information?
+        this.serialized_info.insert ("UPnPClass", "s", UPNP_CLASS_PHOTO);
+        this.serialized_info.insert ("MimeType", "s", mime);
+
+        this.serialized_info.insert ("VideoWidth", "i", width);
+        this.serialized_info.insert ("VideoHeight", "i", height);
+
+        if (mime == "image/png") {
+            if (width <= 4096 && height <= 4096) {
+                this.serialized_info.insert ("DLNAProfile", "s", "PNG_LRG");
+            } else {
+                var profile = "PNG_RES_%d_%d".printf (width, height);
+                this.serialized_info.insert ("DLNAProfile", "s", profile);
+            }
+        } else {
+            if (width <= 640 && height <= 480) {
+                this.serialized_info.insert ("DLNAProfile", "s", "JPG_SM");
+            } else if (width <= 1024 && height <= 768) {
+                this.serialized_info.insert ("DLNAProfile", "s", "JPG_MED");
+            } else if (width <= 4096 && height <= 4096) {
+                this.serialized_info.insert ("DLNAProfile", "s", "JPEG_LRG");
+            } else {
+                var profile = "JPEG_RES_%d_%d".printf (width, height);
+                this.serialized_info.insert ("DLNAProfile", "s", profile);
+            }
+        }
+    }
+}


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