From: Jens Georg Date: Thu, 24 Nov 2011 09:14:42 +0000 (+0100) Subject: core: Add hacks for XBMC X-Git-Tag: RYGEL_0_13_1~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a63fe4c57fc24a791089f168df55d0fbff42b7d7;p=profile%2Fivi%2Frygel.git core: Add hacks for XBMC XBMC fails to recognize DLNA mime-types as AAC for AAC files. --- diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am index 2518aa3..aa66c82 100644 --- a/src/rygel/Makefile.am +++ b/src/rygel/Makefile.am @@ -86,6 +86,7 @@ VAPI_SOURCE_FILES = \ rygel-client-hacks.vala \ rygel-xbox-hacks.vala \ rygel-panasonic-hacks.vala \ + rygel-xbmc-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 de74a70..e3944a5 100644 --- a/src/rygel/rygel-client-hacks.vala +++ b/src/rygel/rygel-client-hacks.vala @@ -41,7 +41,11 @@ internal abstract class Rygel.ClientHacks : GLib.Object { return new XBoxHacks.for_action (action); } catch {} - return new PanasonicHacks.for_action (action); + try { + return new PanasonicHacks.for_action (action); + } catch {} + + return new XBMCHacks.for_action (action); } public static ClientHacks create_for_headers (MessageHeaders headers) @@ -50,7 +54,11 @@ internal abstract class Rygel.ClientHacks : GLib.Object { return new XBoxHacks.for_headers (headers); } catch {} - return new PanasonicHacks.for_headers (headers); + try { + return new PanasonicHacks.for_headers (headers); + } catch {}; + + return new XBMCHacks.for_headers (headers); } protected ClientHacks (string agent_pattern, MessageHeaders? headers = null) diff --git a/src/rygel/rygel-http-get.vala b/src/rygel/rygel-http-get.vala index 1427195..97fa2a2 100644 --- a/src/rygel/rygel-http-get.vala +++ b/src/rygel/rygel-http-get.vala @@ -100,6 +100,8 @@ internal class Rygel.HTTPGet : HTTPRequest { this.thumbnail = visual_item.thumbnails.get (0); return; + } else { + hack.apply (this.item); } } catch (ClientHacksError error) {} diff --git a/src/rygel/rygel-xbmc-hacks.vala b/src/rygel/rygel-xbmc-hacks.vala new file mode 100644 index 0000000..44d9ad7 --- /dev/null +++ b/src/rygel/rygel-xbmc-hacks.vala @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 Nokia Corporation. + * + * Author: Jens Georg + * + * 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.XBMCHacks : ClientHacks { + // FIXME: Limit to known broken versions once this is fixed in XBMC as + // promised by developers. + private const string AGENT = ".*Platinum/.*|.*XBMC/.*"; + + public XBMCHacks () throws ClientHacksError, RegexError { + base (AGENT); + } + + public XBMCHacks.for_action (ServiceAction action) + throws ClientHacksError { + unowned MessageHeaders headers = action.get_message ().request_headers; + this.for_headers (headers); + } + + public XBMCHacks.for_headers (MessageHeaders headers) + throws ClientHacksError { + base (AGENT, headers); + } + + public override void apply (MediaItem item) { + if (item.mime_type == "audio/mp4" || + item.mime_type == "audio/3gpp" || + item.mime_type == "audio/vnd.dlna.adts") { + item.mime_type = "audio/aac"; + } + } +} diff --git a/tests/rygel-http-get-test.vala b/tests/rygel-http-get-test.vala index 0ce03cc..40ce123 100644 --- a/tests/rygel-http-get-test.vala +++ b/tests/rygel-http-get-test.vala @@ -41,6 +41,9 @@ public class Rygel.ClientHacks { public bool is_album_art_request (Message message) { return false; } + + public void apply (MediaItem item) { + } } public class Rygel.HTTPGetTest : GLib.Object {