[rygel] server: Hide engine-specific uris
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] server: Hide engine-specific uris
- Date: Sat, 6 Feb 2016 11:12:28 +0000 (UTC)
commit 47e15dc9f3c37fc1e463508470107e12d58beede
Author: Jens Georg <mail jensge org>
Date: Sat Feb 6 11:47:48 2016 +0100
server: Hide engine-specific uris
For example, the GStreamer engine uses gst-launch:// and dvd:// pseud-uris
that confuse some clients such as Kodi.
Signed-off-by: Jens Georg <mail jensge org>
src/librygel-server/rygel-media-engine.vala | 9 +++++++++
src/librygel-server/rygel-media-object.vala | 11 +++++++++--
.../gstreamer/rygel-gst-media-engine.vala | 8 ++++++++
3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/librygel-server/rygel-media-engine.vala b/src/librygel-server/rygel-media-engine.vala
index 79fde43..067a8a2 100644
--- a/src/librygel-server/rygel-media-engine.vala
+++ b/src/librygel-server/rygel-media-engine.vala
@@ -136,4 +136,13 @@ public abstract class Rygel.MediaEngine : GLib.Object {
* @return A #DataSource representing the uri
*/
public abstract DataSource? create_data_source_for_uri (string uri) throws Error;
+
+ /**
+ * Get a list of URI schemes that are internal to the engine.
+ *
+ * @return A list of strings considered protocol schemees
+ */
+ public virtual List<string> get_internal_protocol_schemes () {
+ return new List<string> ();
+ }
}
diff --git a/src/librygel-server/rygel-media-object.vala b/src/librygel-server/rygel-media-object.vala
index 51e3621..6a9e17b 100644
--- a/src/librygel-server/rygel-media-object.vala
+++ b/src/librygel-server/rygel-media-object.vala
@@ -274,7 +274,8 @@ public abstract class Rygel.MediaObject : GLib.Object {
} else {
try {
var protocol = this.get_protocol_for_uri (res.uri);
- if (protocol != "internal" || http_server.is_local ()) {
+ if (protocol != null &&
+ (protocol != "internal" || http_server.is_local ())) {
// Exclude internal resources when request is non-local
var didl_resource = didl_object.add_resource ();
res.serialize (didl_resource, replacements);
@@ -502,12 +503,18 @@ public abstract class Rygel.MediaObject : GLib.Object {
return "";
}
- internal string get_protocol_for_uri (string uri) throws Error {
+ internal string? get_protocol_for_uri (string uri) throws Error {
var scheme = Uri.parse_scheme (uri);
if (scheme == null) {
throw new MediaItemError.BAD_URI (_("Bad URI: %s"), uri);
}
+ var engine = MediaEngine.get_default ();
+ var schemes = engine.get_internal_protocol_schemes ();
+ if (schemes.find_custom (scheme, strcmp) != null) {
+ return null;
+ }
+
if (scheme == "http") {
return "http-get";
} else if (scheme == "file") {
diff --git a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
index a5e6b83..d3a4fd3 100644
--- a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
+++ b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
@@ -250,6 +250,14 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
public DataSource create_data_source_from_element (Element element) {
return new GstDataSource.from_element (element);
}
+
+ public override GLib.List<string> get_internal_protocol_schemes () {
+ var list = new GLib.List<string> ();
+ list.prepend ("dvd");
+ list.prepend ("gst-launch");
+
+ return list;
+ }
}
public static Rygel.MediaEngine module_get_instance () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]