From: Zeeshan Ali (Khattak) Date: Sun, 16 Oct 2011 22:47:03 +0000 (+0300) Subject: core: Add hacks for Panasonic TV X-Git-Tag: RYGEL_0_13_0~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cbe4a36a01bfd0c600a51905b135d1c4d7b25bf;p=profile%2Fivi%2Frygel.git core: Add hacks for Panasonic TV Currently its just about lieing to the device that png's thumbnails are jpegs. https://bugzilla.gnome.org/show_bug.cgi?id=661336 --- diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am index 2ae265e..0308b71 100644 --- a/src/rygel/Makefile.am +++ b/src/rygel/Makefile.am @@ -85,6 +85,7 @@ VAPI_SOURCE_FILES = \ rygel-search.vala \ rygel-client-hacks.vala \ rygel-xbox-hacks.vala \ + rygel-panasonic-hacks.vala \ rygel-import-resource.vala \ rygel-item-creator.vala \ rygel-item-destroyer.vala \ diff --git a/src/rygel/rygel-client-hacks.vala b/src/rygel/rygel-client-hacks.vala index ae7c725..baf7380 100644 --- a/src/rygel/rygel-client-hacks.vala +++ b/src/rygel/rygel-client-hacks.vala @@ -37,12 +37,20 @@ internal abstract class Rygel.ClientHacks : GLib.Object { public static ClientHacks create_for_action (ServiceAction action) throws ClientHacksError { - return new XBoxHacks.for_action (action); + try { + return new XBoxHacks.for_action (action); + } catch {} + + return new PanasonicHacks.for_action (action); } public static ClientHacks create_for_headers (MessageHeaders headers) throws ClientHacksError { - return new XBoxHacks.for_headers (headers); + try { + return new XBoxHacks.for_headers (headers); + } catch {} + + return new PanasonicHacks.for_headers (headers); } protected ClientHacks (string agent_pattern, MessageHeaders? headers = null) diff --git a/src/rygel/rygel-panasonic-hacks.vala b/src/rygel/rygel-panasonic-hacks.vala new file mode 100644 index 0000000..5a3a56f --- /dev/null +++ b/src/rygel/rygel-panasonic-hacks.vala @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. + * + * Author: Zeeshan Ali (Khattak) + * + * 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 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 program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +using Soup; +using GUPnP; + +internal class Rygel.PanasonicHacks : ClientHacks { + private static string AGENT = ".*Panasonic MIL DLNA CP.*"; + + 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 PanasonicHacks () throws ClientHacksError, RegexError { + base (AGENT); + } + + public PanasonicHacks.for_action (ServiceAction action) + throws ClientHacksError { + unowned MessageHeaders headers = action.get_message ().request_headers; + this.for_headers (headers); + } + + public PanasonicHacks.for_headers (MessageHeaders headers) + throws ClientHacksError { + base (AGENT, headers); + } + + public override void apply (MediaItem item) { + if (!(item is VisualItem)) { + return; + } + + 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 (); + } + } + } +}