[rygel] core: Add hacks for XBMC
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Add hacks for XBMC
- Date: Sun, 11 Dec 2011 18:12:57 +0000 (UTC)
commit a63fe4c57fc24a791089f168df55d0fbff42b7d7
Author: Jens Georg <mail jensge org>
Date: Thu Nov 24 10:14:42 2011 +0100
core: Add hacks for XBMC
XBMC fails to recognize DLNA mime-types as AAC for AAC files.
src/rygel/Makefile.am | 1 +
src/rygel/rygel-client-hacks.vala | 12 +++++++-
src/rygel/rygel-http-get.vala | 2 +
src/rygel/rygel-xbmc-hacks.vala | 53 +++++++++++++++++++++++++++++++++++++
tests/rygel-http-get-test.vala | 3 ++
5 files changed, 69 insertions(+), 2 deletions(-)
---
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 <jensg openismus com>
+ *
+ * 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 {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]