rygel r418 - in trunk/src: plugins/test rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r418 - in trunk/src: plugins/test rygel
- Date: Tue, 13 Jan 2009 14:32:13 +0000 (UTC)
Author: zeeshanak
Date: Tue Jan 13 14:32:12 2009
New Revision: 418
URL: http://svn.gnome.org/viewvc/rygel?rev=418&view=rev
Log:
New low-level Streamer API.
Instead of emitting a signal for availability of a new stream, signal for
need of a gst source element if no URI is provided by the requested item.
This only works for streaming media.
Modified:
trunk/src/plugins/test/rygel-test-audio-item.vala
trunk/src/plugins/test/rygel-test-content-dir.vala
trunk/src/plugins/test/rygel-test-item.vala
trunk/src/plugins/test/rygel-test-video-item.vala
trunk/src/rygel/rygel-streamer.vala
Modified: trunk/src/plugins/test/rygel-test-audio-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-audio-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-audio-item.vala Tue Jan 13 14:32:12 2009
@@ -33,7 +33,6 @@
* Represents Test audio item.
*/
public class Rygel.TestAudioItem : Rygel.TestItem {
- const string TEST_PATH = "/test.wav";
const string TEST_MIMETYPE = "audio/x-wav";
public TestAudioItem (string id,
@@ -45,11 +44,10 @@
title,
TEST_MIMETYPE,
MediaItem.AUDIO_CLASS,
- streamer,
- TEST_PATH);
+ streamer);
}
- protected override Element create_gst_source () throws Error {
+ public override Element create_gst_source () throws Error {
Bin bin = new Bin (this.title);
dynamic Element src = ElementFactory.make ("audiotestsrc", null);
Modified: trunk/src/plugins/test/rygel-test-content-dir.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-content-dir.vala (original)
+++ trunk/src/plugins/test/rygel-test-content-dir.vala Tue Jan 13 14:32:12 2009
@@ -26,7 +26,7 @@
using Rygel;
using GUPnP;
-using DBus;
+using Gst;
/**
* Implementation of ContentDirectory service, meant for testing purposes only.
@@ -34,22 +34,27 @@
public class Rygel.TestContentDir : ContentDirectory {
private List<MediaItem> items;
+ private Streamer streamer;
+
/* Pubic methods */
public override void constructed () {
// Chain-up to base first
base.constructed ();
- Streamer streamer = new Streamer (context, "RygelTest");
+ this.streamer = new Streamer (context, "RygelTest");
+
+ this.streamer.item_requested += this.on_item_requested;
+ this.streamer.need_stream_source += this.on_need_stream_source;
this.items = new List<MediaItem> ();
this.items.append (new TestAudioItem ("sinewave",
this.root_container.id,
"Sine Wave",
- streamer));
+ this.streamer));
this.items.append (new TestVideoItem ("smtpe",
this.root_container.id,
"SMTPE",
- streamer));
+ this.streamer));
// Now we know how many top-level items we have
this.root_container.child_count = this.items.length ();
@@ -90,5 +95,25 @@
return item;
}
+
+ private void on_item_requested (Streamer streamer,
+ string item_id,
+ out MediaItem item) {
+ item = this.find_item_by_id (item_id);
+ }
+
+ private void on_need_stream_source (Streamer streamer,
+ MediaItem item,
+ out Element src) {
+ try {
+ src = ((TestItem) item).create_gst_source ();
+ } catch (Error error) {
+ critical ("Error creating Gst source element for item %s: %s",
+ item.id,
+ error.message);
+
+ return;
+ }
+ }
}
Modified: trunk/src/plugins/test/rygel-test-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-item.vala Tue Jan 13 14:32:12 2009
@@ -34,51 +34,18 @@
public abstract class Rygel.TestItem : Rygel.MediaItem {
const string TEST_AUTHOR = "Zeeshan Ali (Khattak)";
- public string path;
-
public TestItem (string id,
string parent_id,
string title,
string mime,
string upnp_class,
- Streamer streamer,
- string path) {
+ Streamer streamer) {
base (id, parent_id, title, upnp_class, streamer);
this.res.mime_type = mime;
this.author = TEST_AUTHOR;
- this.path= path;
-
- this.res.uri = streamer.create_uri_for_path (path);
-
- streamer.stream_available += this.on_stream_available;
- }
-
- private void on_stream_available (Streamer streamer,
- Stream stream,
- string path) {
- if (path != this.path) {
- /* Not our path and therefore not interesting. */
- return;
- }
-
- // FIXME: This should be done by GstStream
- stream.set_mime_type (this.res.mime_type);
-
- try {
- Element src = this.create_gst_source ();
- // Ask streamer to handle the stream for us but use our source in
- // the pipeline.
- streamer.stream_from_gst_source (src, stream, null);
- } catch (Error error) {
- critical ("Error in attempting to start streaming %s: %s",
- path,
- error.message);
-
- return;
- }
}
- protected abstract Element create_gst_source () throws Error;
+ public abstract Element create_gst_source () throws Error;
}
Modified: trunk/src/plugins/test/rygel-test-video-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-video-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-video-item.vala Tue Jan 13 14:32:12 2009
@@ -33,7 +33,6 @@
* Represents Test video item.
*/
public class Rygel.TestVideoItem : Rygel.TestItem {
- const string TEST_PATH = "/test.mpeg";
const string TEST_MIMETYPE = "video/mpeg";
public TestVideoItem (string id,
@@ -45,11 +44,10 @@
title,
TEST_MIMETYPE,
MediaItem.VIDEO_CLASS,
- streamer,
- TEST_PATH);
+ streamer);
}
- protected override Element create_gst_source () throws Error {
+ public override Element create_gst_source () throws Error {
Bin bin = new Bin (this.title);
dynamic Element src = ElementFactory.make ("videotestsrc", null);
Modified: trunk/src/rygel/rygel-streamer.vala
==============================================================================
--- trunk/src/rygel/rygel-streamer.vala (original)
+++ trunk/src/rygel/rygel-streamer.vala Tue Jan 13 14:32:12 2009
@@ -41,8 +41,8 @@
private GUPnP.Context context;
private HashMap<Stream,GstStream> streams;
- public signal void stream_available (Rygel.Stream stream,
- string path);
+ public signal void need_stream_source (MediaItem item,
+ out Element src);
public signal void item_requested (string item_id,
out MediaItem item);
@@ -55,7 +55,7 @@
context.server.add_handler (this.server_path_root, server_handler);
}
- public string create_uri_for_path (string path) {
+ private string create_uri_for_path (string path) {
return "http://%s:%u%s%s".printf (this.context.host_ip,
this.context.port,
this.server_path_root,
@@ -113,11 +113,12 @@
item_id = query.lookup ("itemid");
}
- if (item_id != null) {
- this.handle_item_request (msg, item_id);
- } else {
- this.handle_path_request (msg, server_path);
+ if (item_id == null) {
+ msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
+ return;
}
+
+ this.handle_item_request (msg, item_id);
}
private void handle_item_request (Soup.Message msg,
@@ -132,12 +133,6 @@
return;
}
- if (item.res.uri == null) {
- warning ("Requested item '%s' didn't provide a URI\n", item_id);
- msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
- return;
- }
-
size_t offset = 0;
size_t length = item.res.size;
bool got_range;
@@ -172,26 +167,6 @@
}
}
- private void handle_path_request (Soup.Message msg,
- string path) {
- string[] path_tokens = path.split (this.server_path_root, 2);
- if (path_tokens[0] == null || path_tokens[1] == null) {
- msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
- return;
- }
-
- string stream_path = path_tokens[1];
- var stream = new Stream (this.context.server, msg);
-
- this.stream_available (stream, stream_path);
-
- if (!stream.accepted ()) {
- /* No body accepted the stream. */
- stream.reject ();
- return;
- }
- }
-
private void add_item_headers (Soup.Message msg,
MediaItem item,
bool partial_content,
@@ -227,11 +202,19 @@
size_t offset,
size_t length) {
string uri = item.res.uri;
+ dynamic Element src = null;
+
+ if (uri != null) {
+ // URI provided, try to create source element from it
+ src = Element.make_from_uri (URIType.SRC, uri, null);
+ } else {
+ // No URI provided, ask for source element directly
+ this.need_stream_source (item, out src);
+ }
- // Create to Gst source that can handle the URI
- dynamic Element src = Element.make_from_uri (URIType.SRC, uri, null);
if (src == null) {
- warning ("Failed to create source element for URI: %s\n", uri);
+ warning ("Failed to create source element for item: %s\n",
+ item.id);
msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
return;
}
@@ -272,6 +255,12 @@
size_t length) {
string uri = item.res.uri;
+ if (uri == null) {
+ warning ("Requested item '%s' didn't provide a URI\n", item.id);
+ msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
+ return;
+ }
+
File file = File.new_for_uri (uri);
string contents;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]