[rygel] all: Align MediaEngine API
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] all: Align MediaEngine API
- Date: Tue, 17 Feb 2015 00:06:41 +0000 (UTC)
commit 6799ac6a4b0fc3d3d21eb4ca4de2b567c65e4136
Author: Jens Georg <mail jensge org>
Date: Mon Feb 16 22:10:03 2015 +0100
all: Align MediaEngine API
Aign API with Cablelab's changes.
Signed-off-by: Jens Georg <mail jensge org>
.../rygel-http-subtitle-handler.vala | 2 +-
.../rygel-http-thumbnail-handler.vala | 2 +-
src/librygel-server/rygel-media-engine.vala | 87 ++++++++++----------
src/librygel-server/rygel-media-file-item.vala | 20 -----
.../gstreamer/rygel-gst-data-source.vala | 1 -
.../gstreamer/rygel-gst-media-engine.vala | 37 ++++----
.../simple/rygel-simple-data-source.vala | 3 +-
.../simple/rygel-simple-media-engine.vala | 34 ++++----
.../gst-launch/rygel-gst-launch-audio-item.vala | 3 +-
src/plugins/gst-launch/rygel-gst-launch-item.vala | 9 ++-
.../gst-launch/rygel-gst-launch-video-item.vala | 3 +-
11 files changed, 96 insertions(+), 105 deletions(-)
---
diff --git a/src/librygel-server/rygel-http-subtitle-handler.vala
b/src/librygel-server/rygel-http-subtitle-handler.vala
index cb27d73..ff18fe4 100644
--- a/src/librygel-server/rygel-http-subtitle-handler.vala
+++ b/src/librygel-server/rygel-http-subtitle-handler.vala
@@ -81,7 +81,7 @@ internal class Rygel.HTTPSubtitleHandler : Rygel.HTTPGetHandler {
DataSource src;
try {
var engine = MediaEngine.get_default ();
- src = engine.create_data_source (this.subtitle.uri);
+ src = engine.create_data_source_for_uri (this.subtitle.uri);
return new HTTPResponse (request, this, src);
} catch (Error err) {
diff --git a/src/librygel-server/rygel-http-thumbnail-handler.vala
b/src/librygel-server/rygel-http-thumbnail-handler.vala
index cc23e71..449cb0b 100644
--- a/src/librygel-server/rygel-http-thumbnail-handler.vala
+++ b/src/librygel-server/rygel-http-thumbnail-handler.vala
@@ -82,7 +82,7 @@ internal class Rygel.HTTPThumbnailHandler : Rygel.HTTPGetHandler {
DataSource src;
try {
var engine = MediaEngine.get_default ();
- src = engine.create_data_source (this.thumbnail.uri);
+ src = engine.create_data_source_for_uri (this.thumbnail.uri);
return new HTTPResponse (request, this, src);
} catch (Error err) {
diff --git a/src/librygel-server/rygel-media-engine.vala b/src/librygel-server/rygel-media-engine.vala
index e152f26..d6f2bee 100644
--- a/src/librygel-server/rygel-media-engine.vala
+++ b/src/librygel-server/rygel-media-engine.vala
@@ -1,7 +1,9 @@
/*
* Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2013 Cable Television Laboratories, Inc.
*
* Author: Jens Georg <jensg openismus com>
+ * Craig Pratt <craig ecaspia com>
*
* This file is part of Rygel.
*
@@ -26,10 +28,13 @@ public errordomain Rygel.MediaEngineError {
/**
* This is the base class for media engines that contain knowledge about
- * the streaming and (optionally) the transcoding and seeking capabilites
- * of the media library in use. Derived classes also instantiate any
- * transcoding objects supported by the media engine and specify the list
- * of media formats the engine is capable of playing.
+ * the streaming and transformational capabilites of the media library in use.
+ *
+ * Media engines express what representations of a MediaObject they can
+ * produce by returning MediaResource objects which will, in turn, be
+ * used to express to endpoints representations can be streamed from
+ * the MediaServer. These representations may include transformations,
+ * time-scaled representations, and/or encrypted representations.
*
* See, for instance, Rygel's built-in "gstreamer" and "simple" media engines,
* or the external rygel-gst-0-10-media-engine module.
@@ -42,18 +47,6 @@ public errordomain Rygel.MediaEngineError {
* Media engines should also derive their own #RygelDataSource,
* returning an instance of it from create_data_source().
*
- * If this media engine supports transcoding then it will typically
- * implement a set of transcoding classes, typically with one
- * base class and a number of sub-classes - one for each transcoding
- * format you want to support. These should be returned by the
- * get_transcoders() virtual function. The base transcoder class could
- * provide a generic way to create a #RygelDataSource capable of
- * providing Rygel with a transcoded version of a file using the
- * underlying media framework. The sub-classes could contain the
- * various media-framework-specific parameters required to
- * transcode to a given format and implement a heuristic that
- * can be used to order an item's transcoded resources.
- *
* See the
* <link linkend="implementing-media-engines">Implementing Media Engines</link> section.
*/
@@ -84,55 +77,63 @@ public abstract class Rygel.MediaEngine : GLib.Object {
}
/**
- * Get a list of the DLNA profiles that are supported by this media
- * engine when calling rygel_media_engine_create_data_source().
- *
- * Other DLNA profiles may be supported as transcoding targets -
+ * Get a list of the DLNA profiles that the media engine can stream.
*
* This information is needed to implement DLNA's
* ConnectionManager.GetProtocolInfo call and to determine whether Rygel
* can accept an uploaded file.
*
* @return A list of #RygelDLNAProfile<!-- -->s
- * @see rygel_media_engine_get_transcoders().
*/
public abstract unowned List<DLNAProfile> get_dlna_profiles ();
/**
* Retrieve engine-provided resources for the given MediaObject
*
- * The MediaResources returned may include formats/profiles that do not
- * match the source content byte-for-byte (e.g. transcodes, encrypted
- * formats, etc). The MediaEngine must return a MediaResource for the raw
- * MediaObject content if it can support streaming the content directly.
+ * The MediaResources returned may include formats/profiles that do not match the
+ * source content byte-for-byte (e.g. transcodes, encrypted formats, etc). The
+ * MediaEngine must return a MediaResource for the raw MediaObject content if it
+ * can support streaming the content directly.
*
- * The order of MediaResources in the returned List should be from
- * most-preferred to least-preferred and each must have a unique
- * alphanumeric "name" field.
+ * The order of MediaResources in the returned List should be from most-preferred to
+ * least-preferred and each must have a unique alphanumeric "name" field.
*
- * Note: The engine should set all delivery-related flags assuming all
- * delivery forms are supported (e.g. the protocol fields and delivery
- * flags of the ProtocolInfo). And the resource uri should be set to the
- * empty string for http-delivered resources. The effective delivery
- * options and uri will be established by the HTTP server.
+ * Note: The engine should set all delivery-related flags assuming all delivery forms are
+ * supported (e.g. the protocol fields and delivery flags of the ProtocolInfo). And the
+ * resource uri should be set to the empty string for http-delivered resources. The
+ * effective delivery options and uri will be established by the HTTP server.
*
* @return A list of #MediaResources<!-- -->s or null if no representations
* are provided by the engine for the item.
*/
public abstract async Gee.List<MediaResource> ? get_resources_for_item (MediaObject item);
- public virtual DataSource? create_data_source_for_resource
- (MediaObject item,
- MediaResource resource)
- throws Error {
- return this.create_data_source (resource.uri);
- }
+ /**
+ * Signaled when one or more #MediaResources<!-- -->s associated with a MediaObject changes.
+ * #get_resources_for_item should be called in response to this signal to retrieve the
+ * updated list of MediaResources for the associated MediaObject.
+ *
+ * @param media_object_uri is the uri associated with a MediaObject.=
+ */
+ public signal void resource_changed (string media_object_uri);
+
+ /**
+ * Get a #DataSource for given #MediaResource representation of the #MediaObject.
+ *
+ * @param item The #MediaObject to create the #DataSource for
+ * @param resource The specific resource to create the #DataSource for
+ *
+ * @return A #DataSource representing the given item resource
+ */
+ public abstract DataSource? create_data_source_for_resource (MediaObject item,
+ MediaResource resource)
+ throws Error;
/**
- * Get a data source for the URI.
+ * Get a #DataSource for the URI.
*
- * @param uri to create the data source for.
- * @return A data source representing the uri
+ * @param uri to create the #DataSource for.
+ * @return A #DataSource representing the uri
*/
- public abstract DataSource? create_data_source (string uri);
+ public abstract DataSource? create_data_source_for_uri (string uri) throws Error;
}
diff --git a/src/librygel-server/rygel-media-file-item.vala b/src/librygel-server/rygel-media-file-item.vala
index eca2393..763e502 100644
--- a/src/librygel-server/rygel-media-file-item.vala
+++ b/src/librygel-server/rygel-media-file-item.vala
@@ -123,26 +123,6 @@ public abstract class Rygel.MediaFileItem : MediaItem {
}
}
- // Live media items need to provide a nice working implementation of this
- // method if they can/do not provide a valid URI
- public virtual DataSource? create_stream_source (string? host_ip = null) {
- if (this.get_uris ().is_empty) {
- return null;
- }
-
- string translated_uri = this.get_primary_uri ();
- if (host_ip != null) {
- try {
- translated_uri = MediaFileItem.address_regex.replace_literal
- (translated_uri, -1, 0, host_ip);
- } catch (Error error) {
- assert_not_reached ();
- }
- }
-
- return MediaEngine.get_default ().create_data_source (translated_uri);
- }
-
public override DataSource? create_stream_source_for_resource
(HTTPRequest request,
MediaResource resource)
diff --git a/src/media-engines/gstreamer/rygel-gst-data-source.vala
b/src/media-engines/gstreamer/rygel-gst-data-source.vala
index fb08a4f..d08f9ec 100644
--- a/src/media-engines/gstreamer/rygel-gst-data-source.vala
+++ b/src/media-engines/gstreamer/rygel-gst-data-source.vala
@@ -71,7 +71,6 @@ internal class Rygel.GstDataSource : Rygel.DataSource, GLib.Object {
(_("Playspeed not supported"));
}
-
if (seek_request == null) {
debug("No seek requested - sending entire binary");
} else if (seek_request is HTTPByteSeekRequest) {
diff --git a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
index 6f96f8f..211d131 100644
--- a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
+++ b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
@@ -116,18 +116,6 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
return this.dlna_profiles;
}
- public override DataSource? create_data_source (string uri) {
- try {
- return new GstDataSource (uri, null);
- } catch (Error error) {
- warning (_("Failed to create GStreamer data source for %s: %s"),
- uri,
- error.message);
-
- return null;
- }
- }
-
public override async Gee.List<MediaResource> ? get_resources_for_item (MediaObject object) {
if (! (object is MediaFileItem)) {
warning ("Can only process file-based MediaObjects (MediaFileItems)");
@@ -179,20 +167,20 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
if (res != null)
resources.add (res);
}
+
// Put the primary resource as most-preferred (front of the list)
resources.add (primary_res);
return resources;
}
- public override DataSource? create_data_source_for_resource
- (MediaObject object,
- MediaResource resource) throws Error {
- if (!(object is MediaFileItem)) {
- warning ("Can only process file-based MediaObjects (MediaFileItem)");
+ public override DataSource? create_data_source_for_resource ( MediaObject object,
+ MediaResource resource)
+ throws Error {
+ if (! (object is MediaFileItem)) {
+ warning ("Can only process file-based MediaObjects (MediaFileItems)");
return null;
}
-
var item = object as MediaFileItem;
// For MediaFileItems, the primary URI refers directly to the content
@@ -215,6 +203,19 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
return ds;
}
+ public override DataSource? create_data_source_for_uri (string source_uri) {
+ try {
+ debug("creating data source for %s", source_uri);
+ DataSource ds = new GstDataSource (source_uri, null);
+ return ds;
+ } catch (Error error) {
+ warning (_("Failed to create GStreamer data source for %s: %s"),
+ source_uri,
+ error.message);
+
+ return null;
+ }
+ }
public DataSource create_data_source_from_element (Element element) {
return new GstDataSource.from_element (element);
diff --git a/src/media-engines/simple/rygel-simple-data-source.vala
b/src/media-engines/simple/rygel-simple-data-source.vala
index 1ed0577..1a36c58 100644
--- a/src/media-engines/simple/rygel-simple-data-source.vala
+++ b/src/media-engines/simple/rygel-simple-data-source.vala
@@ -53,7 +53,7 @@ internal class Rygel.SimpleDataSource : DataSource, Object {
public Gee.List<HTTPResponseElement> ? preroll (HTTPSeekRequest? seek_request,
PlaySpeedRequest? playspeed_request)
throws Error {
- var response_list = new Gee.ArrayList<HTTPResponseElement> ();
+ var response_list = new Gee.ArrayList<HTTPResponseElement> ();
if (seek_request != null) {
if (!(seek_request is HTTPByteSeekRequest)) {
@@ -81,6 +81,7 @@ internal class Rygel.SimpleDataSource : DataSource, Object {
return response_list;
}
+
public void start () throws Error {
debug ("Starting data source for uri %s", this.uri);
diff --git a/src/media-engines/simple/rygel-simple-media-engine.vala
b/src/media-engines/simple/rygel-simple-media-engine.vala
index 4580432..422ec16 100644
--- a/src/media-engines/simple/rygel-simple-media-engine.vala
+++ b/src/media-engines/simple/rygel-simple-media-engine.vala
@@ -1,7 +1,9 @@
/*
* Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2013 Cable Television Laboratories, Inc.
*
* Author: Jens Georg <jensg openismus com>
+ * Craig Pratt <craig ecaspia com>
*
* This file is part of Rygel.
*
@@ -26,7 +28,7 @@ using GUPnP;
* The simple media engine does not use GStreamer or any other
* multimedia framework. Therefore its capabilities are limited.
*
- * It does not support transcoding - get_transcoders() returns null.
+ * It does not support transcoding - get_resources() returns null.
* Also, its RygelSimpleDataSource does not support time-base seeking.
*/
internal class Rygel.SimpleMediaEngine : MediaEngine {
@@ -34,12 +36,12 @@ internal class Rygel.SimpleMediaEngine : MediaEngine {
public SimpleMediaEngine () { }
- public override unowned List<DLNAProfile> get_dlna_profiles () {
+ public override unowned List<DLNAProfile> get_dlna_profiles() {
return this.profiles;
}
- public override async Gee.List<MediaResource>? get_resources_for_item (MediaObject
- object) {
+ public override async Gee.List<MediaResource> ? get_resources_for_item
+ (MediaObject object) {
if (! (object is MediaFileItem)) {
warning ("Can only process file-based MediaObjects (MediaFileItems)");
return null;
@@ -74,24 +76,26 @@ internal class Rygel.SimpleMediaEngine : MediaEngine {
resources.add (primary_res);
return resources;
- }
+ }
- public override DataSource? create_data_source_for_resource
- (MediaObject object,
- MediaResource res) throws Error {
- if (!(object is MediaFileItem)) {
- warning ("Can only process file-based MediaObjects (MediaFileItem)");
+ public override DataSource? create_data_source_for_resource (MediaObject object,
+ MediaResource resource)
+ throws Error {
+ if (! (object is MediaFileItem)) {
+ warning ("Can only process file-based MediaObjects (MediaFileItems)");
return null;
- }
+ }
- string source_uri = object.get_primary_uri ();
- return new SimpleDataSource (source_uri);
+ // For MediaFileItems, the primary URI referrs to the local content file
+ string source_uri = object.get_primary_uri ();
+ return new SimpleDataSource (source_uri);
}
- public override DataSource? create_data_source (string uri) {
+
+ public override DataSource? create_data_source_for_uri (string uri) {
if (!uri.has_prefix ("file://")) {
return null;
}
-
+ debug ("creating data source for %s", uri);
return new SimpleDataSource (uri);
}
}
diff --git a/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
b/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
index ed696f8..9d24e21 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
@@ -42,7 +42,8 @@ public class Rygel.GstLaunch.AudioItem : Rygel.AudioItem, Item {
this.launch_line = launch_line;
}
- public override DataSource? create_stream_source (string? host_ip) {
+ public override DataSource? create_stream_source_for_resource (HTTPRequest request,
+ MediaResource resource) {
return this.create_source ();
}
}
diff --git a/src/plugins/gst-launch/rygel-gst-launch-item.vala
b/src/plugins/gst-launch/rygel-gst-launch-item.vala
index 965ef92..8b57de1 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-item.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-item.vala
@@ -26,13 +26,16 @@
/**
* Item that serves data from a gst-launch commandline.
*/
-public interface Rygel.GstLaunch.Item : Rygel.MediaItem {
+public interface Rygel.GstLaunch.Item : Rygel.MediaFileItem {
public abstract string launch_line { get; protected set; }
protected DataSource? create_source () {
var engine = MediaEngine.get_default ();
-
- return engine.create_data_source ("gst-launch://" + this.launch_line);
+ try {
+ return engine.create_data_source_for_uri ("gst-launch://" + this.launch_line);
+ } catch (Error error) {
+ return null;
+ }
}
}
diff --git a/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
b/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
index be29c61..90c4554 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
@@ -42,7 +42,8 @@ public class Rygel.GstLaunch.VideoItem : Rygel.VideoItem, Item {
this.launch_line = launch_line;
}
- public override DataSource? create_stream_source (string? host_ip) {
+ public override DataSource? create_stream_source_for_resource (HTTPRequest request,
+ MediaResource resource) {
return this.create_source ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]