[rygel/rygel-0-28] server: Fix thumbnails on Samsung TVs



commit ca3aace1ccd6bee1984271fda1c487cc21218720
Author: Jens Georg <mail jensge org>
Date:   Sat Jan 23 18:50:01 2016 +0100

    server: Fix thumbnails on Samsung TVs
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721312

 src/librygel-server/rygel-samsung-tv-hacks.vala |   38 +++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/librygel-server/rygel-samsung-tv-hacks.vala b/src/librygel-server/rygel-samsung-tv-hacks.vala
index a2fbd67..dd2bac7 100644
--- a/src/librygel-server/rygel-samsung-tv-hacks.vala
+++ b/src/librygel-server/rygel-samsung-tv-hacks.vala
@@ -24,6 +24,18 @@ using GUPnP;
 internal class Rygel.SamsungTVHacks : ClientHacks {
     private const string AGENT = ".*SEC_HHP.*|.*SEC HHP.*";
 
+    private static Regex mime_regex;
+    private static Regex dlna_regex;
+
+    static construct {
+        try {
+            mime_regex = new Regex ("png");
+            dlna_regex = new Regex ("PNG");
+        } catch (RegexError error) {
+            assert_not_reached ();
+        }
+    }
+
     public SamsungTVHacks (Message? message = null) throws ClientHacksError {
         base (AGENT, message);
     }
@@ -44,6 +56,32 @@ internal class Rygel.SamsungTVHacks : ClientHacks {
                 resource.mime_type = "video/mp4";
             }
         }
+
+        if (!(object is MediaFileItem)) {
+            return;
+        }
+
+        var item = object as MediaFileItem;
+
+        if (!(item is VisualItem)) {
+            return;
+        }
+
+        // Samsung TVs only accept thumbnails with DLNA profile and mime
+        // type JPEG. This is correct from a DLNA pov, but we usually only
+        // supply PNG. When fooled into accepting it, they're rendered fine,
+        // however.
+        // TODO: Unifiy with Panasonic hack!
+        foreach (var thumbnail in (item as VisualItem).thumbnails) {
+            try {
+                thumbnail.mime_type = mime_regex.replace_literal
+                                        (thumbnail.mime_type, -1, 0, "jpeg");
+                thumbnail.dlna_profile = dlna_regex.replace_literal
+                                        (thumbnail.dlna_profile, -1, 0, "JPEG");
+            } catch (RegexError error) {
+                assert_not_reached ();
+            }
+        }
     }
 
     public override bool force_seek () {


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