* ContentDirectory:1 because they ignore that higher versions are
* required to be backwards-compatible.
*/
-internal class Rygel.V1Hacks : ClientHacks {
+public class Rygel.V1Hacks : Object {
private const string[] AGENTS = { "Allegro-Software-WebClient",
"SEC HHP",
"SEC_HHP",
"Reciva",
"FDSSDP" };
- private const string DMS = "urn:schemas-upnp-org:device:MediaServer";
- private const string DMS_V1 = DMS + ":1";
+ private string _device_type;
+ public string device_type {
+ construct set {
+ this._device_type = value;
+ this.device_type_v1 = value + ":1";
+ }
+ get { return this._device_type; }
+ }
+ private string device_type_v1;
+
+ public string service_type { construct; get; }
+ public string service_type_v1 { construct; get; }
+
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.
* user-agents.
*/
private static string generate_agent_pattern () {
- if (likely (agent_pattern != null)) {
+ if (agent_pattern != null) {
return agent_pattern;
}
return agent_pattern;
}
- public V1Hacks () throws ClientHacksError {
- base (generate_agent_pattern (), null);
+ public V1Hacks (string device_type,
+ string service_type,
+ string service_type_v1) {
+ Object (device_type : device_type,
+ service_type : service_type,
+ service_type_v1 : service_type_v1);
+ }
+
+ public override void constructed () {
+ base.constructed ();
+
+ 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 (DMS)) {
+ if (!device.get_device_type ().has_prefix (device_type)) {
return;
}
}
var description_file = new DescriptionFile (template_path);
- description_file.set_device_type (DMS_V1);
- description_file.modify_service_type (ContentDirectory.UPNP_TYPE,
- ContentDirectory.UPNP_TYPE_V1);
+ description_file.set_device_type (device_type_v1);
+ description_file.modify_service_type (service_type, service_type_v1);
this.description_path = template_path.replace (".xml", "-v1.xml");
description_file.save (this.description_path);
private static const string MEDIA_RENDERER_DESC_PATH =
BuildConfig.DATA_DIR +
"/xml/MediaRenderer2.xml";
+ private static const string DMR = "urn:schemas-upnp-org:device:MediaRenderer";
private string sink_protocol_info;
private PlayerController controller;
return this.controller;
}
+ public override void apply_hacks (RootDevice device,
+ string description_path)
+ throws Error {
+ var v1_hacks = new V1Hacks (DMR,
+ AVTransport.UPNP_TYPE,
+ AVTransport.UPNP_TYPE_V1);
+ v1_hacks.apply_on_device (device, description_path);
+ }
+
+
public string get_protocol_info () {
var player = this.get_player ();
if (player == null) {
* in-process via the librygel-server API.
*/
public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
+ private static const string DMS = "urn:schemas-upnp-org:device:MediaServer";
private static const string MEDIA_SERVER_DESC_PATH =
BuildConfig.DATA_DIR + "/xml/MediaServer3.xml";
string description_path)
throws Error {
// Apply V1 downgrades
- var v1_hacks = new V1Hacks ();
+ var v1_hacks = new V1Hacks (DMS,
+ ContentDirectory.UPNP_TYPE,
+ ContentDirectory.UPNP_TYPE_V1);
v1_hacks.apply_on_device (device, description_path);
// Apply XBox hacks on top of that