rygel r425 - trunk/src/rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r425 - trunk/src/rygel
- Date: Tue, 13 Jan 2009 14:32:41 +0000 (UTC)
Author: zeeshanak
Date: Tue Jan 13 14:32:41 2009
New Revision: 425
URL: http://svn.gnome.org/viewvc/rygel?rev=425&view=rev
Log:
GstStream now inherits from Stream.
As a consequence, Streamer just uses GstStream only.
Modified:
trunk/src/rygel/rygel-gst-stream.vala
trunk/src/rygel/rygel-stream.vala
trunk/src/rygel/rygel-streamer.vala
Modified: trunk/src/rygel/rygel-gst-stream.vala
==============================================================================
--- trunk/src/rygel/rygel-gst-stream.vala (original)
+++ trunk/src/rygel/rygel-gst-stream.vala Tue Jan 13 14:32:41 2009
@@ -34,38 +34,39 @@
LINK
}
-public class Rygel.GstStream : Pipeline {
+public class Rygel.GstStream : Rygel.Stream {
private const string SINK_NAME = "fakesink";
- public Stream stream;
+ private Pipeline pipeline;
private AsyncQueue<Buffer> buffers;
private Event seek_event;
- public GstStream (Stream stream,
+ public GstStream (Soup.Server server,
+ Soup.Message msg,
string name,
Element src,
Event? seek_event) throws Error {
- this.stream = stream;
- this.name = name;
+ base (server, msg, seek_event != null);
+
this.seek_event = seek_event;
this.buffers = new AsyncQueue<Buffer> ();
- this.stream.accept (seek != null);
- this.prepare_pipeline (src);
+ this.prepare_pipeline (name, src);
}
public void start () {
// Go to PAUSED first
- this.set_state (State.PAUSED);
+ this.pipeline.set_state (State.PAUSED);
}
public void stop () {
- this.set_state (State.NULL);
+ this.pipeline.set_state (State.NULL);
}
- private void prepare_pipeline (Element src) throws Error {
+ private void prepare_pipeline (string name,
+ Element src) throws Error {
dynamic Element sink = ElementFactory.make ("fakesink", SINK_NAME);
if (sink == null) {
@@ -76,7 +77,10 @@
sink.signal_handoffs = true;
sink.handoff += this.on_new_buffer;
- this.add_many (src, sink);
+ this.pipeline = new Pipeline (name);
+ assert (this.pipeline != null);
+
+ this.pipeline.add_many (src, sink);
if (src.numpads == 0) {
// Seems source uses dynamic pads, link when pad available
@@ -91,7 +95,7 @@
}
// Bus handler
- var bus = this.get_bus ();
+ var bus = this.pipeline.get_bus ();
bus.add_watch (bus_handler);
}
@@ -99,12 +103,12 @@
Pad src_pad) {
var caps = src_pad.get_caps ();
- var sink = this.get_by_name (SINK_NAME);
+ var sink = this.pipeline.get_by_name (SINK_NAME);
Pad sink_pad;
dynamic Element depay = this.get_rtp_depayloader (caps);
if (depay != null) {
- this.add (depay);
+ this.pipeline.add (depay);
if (!depay.link (sink)) {
critical ("Failed to link %s to %s",
depay.name,
@@ -120,7 +124,7 @@
critical ("Failed to link pad %s to %s",
src_pad.name,
sink_pad.name);
- this.stream.end ();
+ this.end ();
}
if (depay != null) {
@@ -198,7 +202,7 @@
var buffer = this.buffers.pop ();
if (buffer != null) {
- this.stream.push_data (buffer.data, buffer.size);
+ this.push_data (buffer.data, buffer.size);
}
return false;
@@ -217,12 +221,12 @@
if (new_state == State.PAUSED) {
if (this.seek_event != null) {
// Time to shove-in the pending seek event
- this.send_event (this.seek_event);
+ this.pipeline.send_event (this.seek_event);
this.seek_event = null;
}
// Now we can proceed to start streaming
- this.set_state (State.PLAYING);
+ this.pipeline.set_state (State.PLAYING);
}
} else {
GLib.Error err;
@@ -230,17 +234,21 @@
if (message.type == MessageType.ERROR) {
message.parse_error (out err, out err_msg);
- critical ("Error from pipeline %s:%s", this.name, err_msg);
+ critical ("Error from pipeline %s:%s",
+ this.pipeline.name,
+ err_msg);
ret = false;
} else if (message.type == MessageType.WARNING) {
message.parse_warning (out err, out err_msg);
- warning ("Warning from pipeline %s:%s", this.name, err_msg);
+ warning ("Warning from pipeline %s:%s",
+ this.pipeline.name,
+ err_msg);
}
}
if (!ret) {
- this.stream.end ();
+ this.end ();
}
return ret;
Modified: trunk/src/rygel/rygel-stream.vala
==============================================================================
--- trunk/src/rygel/rygel-stream.vala (original)
+++ trunk/src/rygel/rygel-stream.vala Tue Jan 13 14:32:41 2009
@@ -25,15 +25,23 @@
public class Rygel.Stream : GLib.Object {
public Soup.Server server { get; private set; }
- private Soup.Message msg;
+ protected Soup.Message msg;
public signal void eos ();
- public Stream (Soup.Server server, Soup.Message msg) {
+ public Stream (Soup.Server server,
+ Soup.Message msg,
+ bool partial) {
this.server = server;
this.msg = msg;
this.msg.response_headers.set_encoding (Soup.Encoding.CHUNKED);
+ if (partial) {
+ this.msg.set_status (Soup.KnownStatusCode.PARTIAL_CONTENT);
+ } else {
+ this.msg.set_status (Soup.KnownStatusCode.OK);
+ }
+ this.msg.response_body.set_accumulate (false);
this.server.request_aborted += on_request_aborted;
}
@@ -46,20 +54,6 @@
this.eos ();
}
- public void accept (bool partial) {
- if (partial) {
- this.msg.set_status (Soup.KnownStatusCode.PARTIAL_CONTENT);
- } else {
- this.msg.set_status (Soup.KnownStatusCode.OK);
- }
-
- this.msg.response_body.set_accumulate (false);
- }
-
- public void reject () {
- this.msg.set_status (Soup.KnownStatusCode.NOT_FOUND);
- }
-
public void set_mime_type (string mime_type) {
this.msg.response_headers.append ("Content-Type", mime_type);
}
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:41 2009
@@ -25,7 +25,6 @@
* version 2 of the License, or (at your option) any later version.
*/
-using Gee;
using Gst;
using GUPnP;
@@ -39,7 +38,7 @@
private string server_path_root;
private GUPnP.Context context;
- private HashMap<Stream,GstStream> streams;
+ private List<GstStream> streams;
public signal void need_stream_source (MediaItem item,
out Element src);
@@ -48,7 +47,7 @@
public Streamer (GUPnP.Context context, string name) {
this.context = context;
- this.streams = new HashMap<Stream,GstStream> ();
+ this.streams = new List<GstStream> ();
this.server_path_root = SERVER_PATH_PREFIX + "/" + name;
@@ -69,28 +68,25 @@
return create_uri_for_path (query);
}
- public void stream_from_gst_source (Element# src,
- Stream stream,
- Event? seek_event) throws Error {
- GstStream gst_stream = new GstStream (stream,
- "RygelGstStream",
- src,
- seek_event);
+ public void stream_from_gst_source (Element# src,
+ Soup.Message msg,
+ Event? seek_event) throws Error {
+ GstStream stream = new GstStream (this.context.server,
+ msg,
+ "RygelGstStream",
+ src,
+ seek_event);
- gst_stream.start ();
+ stream.start ();
stream.eos += on_eos;
- this.streams.set (stream, gst_stream);
+ this.streams.append (stream);
}
- private void on_eos (Stream stream) {
- GstStream gst_stream = this.streams.get (stream);
- if (gst_stream == null)
- return;
-
- gst_stream.stop ();
+ private void on_eos (GstStream stream) {
+ stream.stop ();
- /* Remove the associated Gst stream. */
+ /* Remove the stream from our list. */
this.streams.remove (stream);
}
@@ -222,8 +218,6 @@
// transmitting
src.tcp_timeout = (int64) 60000000;
- // create a stream for it
- var stream = new Stream (this.context.server, msg);
try {
// Create the seek event if needed
Event seek_event = null;
@@ -238,8 +232,8 @@
length);
}
- // Then attach the gst source to stream we are good to go
- this.stream_from_gst_source (src, stream, seek_event);
+ // Then start the gst stream
+ this.stream_from_gst_source (src, msg, seek_event);
} catch (Error error) {
critical ("Error in attempting to start streaming %s: %s",
uri,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]