[rygel/wip/downgrade-renderer] wip: Downgrade renderer
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/downgrade-renderer] wip: Downgrade renderer
- Date: Wed, 23 Jan 2013 22:39:29 +0000 (UTC)
commit 9b8aeac26d71b26cf74123d4fdce155da09a10a0
Author: Jens Georg <jensg openismus com>
Date: Wed Jan 23 23:39:05 2013 +0100
wip: Downgrade renderer
src/librygel-renderer/filelist.am | 3 +-
src/librygel-renderer/rygel-av-transport.vala | 2 +
.../rygel-media-renderer-plugin.vala | 8 ++
src/librygel-renderer/rygel-v1-hacks.vala | 123 ++++++++++++++++++++
4 files changed, 135 insertions(+), 1 deletions(-)
---
diff --git a/src/librygel-renderer/filelist.am b/src/librygel-renderer/filelist.am
index 3f5cb08..74a20e4 100644
--- a/src/librygel-renderer/filelist.am
+++ b/src/librygel-renderer/filelist.am
@@ -10,4 +10,5 @@ LIBRYGEL_RENDERER_NONVAPI_SOURCE_FILES = \
rygel-sink-connection-manager.vala \
rygel-time-utils.vala \
rygel-changelog.vala \
- rygel-volume.vala
+ rygel-volume.vala \
+ rygel-v1-hacks.vala
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index 215e65b..ccdd681 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -30,6 +30,8 @@ internal class Rygel.AVTransport : Service {
public const string UPNP_ID = "urn:upnp-org:serviceId:AVTransport";
public const string UPNP_TYPE =
"urn:schemas-upnp-org:service:AVTransport:2";
+ public const string UPNP_TYPE_V1 =
+ "urn:schemas-upnp-org:service:AVTransport:1";
public const string DESCRIPTION_PATH = "xml/AVTransport2.xml";
public const string LAST_CHANGE_NS =
"urn:schemas-upnp-org:metadata-1-0/AVT/";
diff --git a/src/librygel-renderer/rygel-media-renderer-plugin.vala b/src/librygel-renderer/rygel-media-renderer-plugin.vala
index aa93852..7f50a8b 100644
--- a/src/librygel-renderer/rygel-media-renderer-plugin.vala
+++ b/src/librygel-renderer/rygel-media-renderer-plugin.vala
@@ -92,6 +92,14 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
return this.controller;
}
+ public override void apply_hacks (RootDevice device,
+ string description_path)
+ throws Error {
+ var v1_hacks = new V1Hacks2 ();
+ v1_hacks.apply_on_device (device, description_path);
+ }
+
+
public string get_protocol_info () {
var player = this.get_player ();
if (player == null) {
diff --git a/src/librygel-renderer/rygel-v1-hacks.vala b/src/librygel-renderer/rygel-v1-hacks.vala
new file mode 100644
index 0000000..bfd614e
--- /dev/null
+++ b/src/librygel-renderer/rygel-v1-hacks.vala
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation.
+ * Copyright (C) 2012 Jens Georg.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ * 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 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;
+
+/**
+ * Various devices that need a downgrade to MediaServer:1 and
+ * ContentDirectory:1 because they ignore that higher versions are
+ * required to be backwards-compatible.
+ */
+internal class Rygel.V1Hacks2 : Object {
+ private const string[] AGENTS = { "Allegro-Software-WebClient",
+ "SEC HHP",
+ "SEC_HHP",
+ "Mediabolic-IMHTTP/1.",
+ "TwoPlayer",
+ "Reciva",
+ "FDSSDP" };
+
+ private const string DMR = "urn:schemas-upnp-org:device:MediaRenderer";
+ private const string DMR_V1 = DMR + ":1";
+ private const string MATCHING_PATTERN = ".*%s.*";
+
+ private static string agent_pattern;
+
+ public string description_path;
+
+ private Regex agent_regex;
+
+ /**
+ * Read the user-agent snippets from the config file and generate the
+ * regular expression string for matching.
+ *
+ * Returns: A regular expression pattern matching any of the configured
+ * user-agents.
+ */
+ private static string generate_agent_pattern () {
+ if (likely (agent_pattern != null)) {
+ return agent_pattern;
+ }
+
+ var config = MetaConfig.get_default ();
+ var raw_agents = AGENTS;
+ try {
+ raw_agents = config.get_string_list ("general",
+ "force-downgrade-for").
+ to_array ();
+ } catch (Error error) {}
+
+ var agents = new string[0];
+ foreach (var agent in raw_agents) {
+ agents += MATCHING_PATTERN.printf
+ (Regex.escape_string (agent));
+ }
+
+ if (agents.length > 0) {
+ agent_pattern = string.joinv ("|", agents);
+ } else {
+ agent_pattern = "";
+ }
+
+ debug ("V1 downgrade will be applied for devices matching %s",
+ agent_pattern);
+
+ return agent_pattern;
+ }
+
+ public V1Hacks2 () {
+ try {
+ this.agent_regex = new Regex (generate_agent_pattern ());
+ } catch (Error error) { assert_not_reached (); }
+ }
+
+ public void apply_on_device (RootDevice device,
+ string? template_path) throws Error {
+ if (!device.get_device_type ().has_prefix (DMR)) {
+ message ("=> not DMR");
+ return;
+ }
+
+ if (template_path == null) {
+ message ("=> no template");
+ return;
+ }
+
+ var description_file = new DescriptionFile (template_path);
+ description_file.set_device_type (DMR_V1);
+ description_file.modify_service_type (AVTransport.UPNP_TYPE,
+ AVTransport.UPNP_TYPE_V1);
+
+ this.description_path = template_path.replace (".xml", "-v1.xml");
+ description_file.save (this.description_path);
+
+ var server_path = "/" + device.get_relative_location ();
+ if (this.agent_regex.get_pattern () != "") {
+ device.context.host_path_for_agent (this.description_path,
+ server_path,
+ this.agent_regex);
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]