diff options
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | data/rygel.conf | 9 | ||||
-rw-r--r-- | doc/man/rygel.conf.xml | 11 | ||||
-rw-r--r-- | src/rygel/rygel-v1-hacks.vala | 46 |
4 files changed, 62 insertions, 7 deletions
@@ -64,9 +64,6 @@ * Start rygel as part of user session. * Remove relavent code from UI code. - * XBox hacks: - * Config for device hacks user-agent. - * Transcoding: * Make use of encodebin when it's ready (update README/wiki afterwards). * Use h264 instead of mpeg2 video? diff --git a/data/rygel.conf b/data/rygel.conf index 25e852a7..0c8c63a8 100644 --- a/data/rygel.conf +++ b/data/rygel.conf @@ -68,6 +68,15 @@ allow-upload=true # Allow deletion of media folders and files? allow-deletion=true +# Semicolon-separated list of device user-agents (or parts thereof) that need +# a downgrade in the UPnP device versions +# WARNING /!\: Only change this setting when told to do so or when you know +# what you're doing. If you find that adding your device makes it +# working with Rygel, please file a bug at +# https://bugzilla.gnome.org/enter_bug.cgi?product=Rygel&component=IOP +# so we can include it in future releases. +#force-downgrade-for=Allegro-Software-WebClient;SEC_HHP_Galaxy S/1.0 + # Plugin specific sections # # Some options are generic and some are specific to each plugin. diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml index 61d74eea..b306529b 100644 --- a/doc/man/rygel.conf.xml +++ b/doc/man/rygel.conf.xml @@ -263,6 +263,17 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ <para>If <option>allow-upload</option> is <userinput>true</userinput>, use this folder to store uploaded pictures. It defaults to <userinput>@PICTURES@</userinput> which expands to the default directory for picture files (usually <filename><envar>$HOME</envar>/Pictures</filename>).</para> </listitem> </varlistentry> + <varlistentry> + <term> + <option>force-downgrade-for</option> + </term> + <listitem> + <para>Semicolon-separated list of device user-agents (or parts thereof) which need a forced downgrade to <userinput>MediaServer:1</userinput> and/or <userinput>ContentDirectory:1</userinput>.</para> + <para><warning> + <para>Only use this parameter if you know what your're doing or are being told to do so; overriding the default value might cause incompatibilites. If you find that adding your device here enables its usage with Rygel, please <ulink url="https://bugzilla.gnome.org/enter_bug.cgi?product=Rygel&component=IOP">file an IOP bug</ulink> so we can include it into the default configuration.</para> + </warning></para> + </listitem> + </varlistentry> </variablelist> <para>Sections for plugins are denoted with <option>[PluginName]</option> and can contain options specific to a plugin (see below) as well these common options: diff --git a/src/rygel/rygel-v1-hacks.vala b/src/rygel/rygel-v1-hacks.vala index d8c9d464..68d67f66 100644 --- a/src/rygel/rygel-v1-hacks.vala +++ b/src/rygel/rygel-v1-hacks.vala @@ -26,15 +26,53 @@ using GUPnP; /** * Various devices that need a downgrade to MediaServer:1 and * ContentDirectory:1 because they ignore that higher versions are - * backwards-compatible. + * required to be backwards-compatible. */ internal class Rygel.V1Hacks : ClientHacks { - private const string AGENT = ".*Allegro-Software-WebClient.*|.*SEC_HHP_Galaxy S/1\\.0.*"; + private const string DEFAULT_AGENT = ".*Allegro-Software-WebClient.*|" + + ".*SEC_HHP_Galaxy S/1\\.0.*"; private const string DMS = "urn:schemas-upnp-org:device:MediaServer"; private const string DMS_V1 = DMS + ":1"; + private const string MATCHING_PATTERN = ".*%s.*"; + + private static string agent_pattern; + + /** + * 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 (); + agent_pattern = DEFAULT_AGENT; + try { + var raw_agents = config.get_string_list ("general", + "force-downgrade-for"); + 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); + } + } catch (Error error) {} + + debug ("V1 downgrade will be applied for devices matching %s", + agent_pattern); + + return agent_pattern; + } public V1Hacks () throws ClientHacksError, RegexError { - base (AGENT); + base (generate_agent_pattern ()); } public V1Hacks.for_action (ServiceAction action) @@ -45,7 +83,7 @@ internal class Rygel.V1Hacks : ClientHacks { public V1Hacks.for_headers (MessageHeaders headers) throws ClientHacksError { - base (AGENT, headers); + base (generate_agent_pattern (), headers); } public void apply_on_device (RootDevice device, |