diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/media-export/Makefile.am | 2 | ||||
-rw-r--r-- | src/plugins/media-export/rygel-media-export-extractor.vala | 5 | ||||
-rw-r--r-- | src/plugins/media-export/rygel-media-export-image-extractor.vala | 67 |
3 files changed, 74 insertions, 0 deletions
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am index c6817979..3724edac 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 3f1fc834..97dfed1f 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 00000000..7652266b --- /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); + } + } + } +} |