[rygel] core: Push creation of gst source to MediaItem
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: Push creation of gst source to MediaItem
- Date: Wed, 26 Aug 2009 14:02:17 +0000 (UTC)
commit c412f9c4a08d54beefe5a34767ef58a6321b5e32
Author: James Henstridge <james jamesh id au>
Date: Mon Aug 3 18:16:31 2009 +0800
core: Push creation of gst source to MediaItem
Previously MediaItem.create_stream_source was only called for items that
did not provide any URIs. If a URI was available, then HTTPRequest
would create an element directly from it. Now HTTPRequest always calls
create_stream_source and the default implementation knows how to create
an element from a URI.
src/rygel/rygel-http-request.vala | 32 ++++++++------------------------
src/rygel/rygel-media-item.vala | 17 ++++++++++++++++-
2 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala
index 2793a01..5f4de08 100644
--- a/src/rygel/rygel-http-request.vala
+++ b/src/rygel/rygel-http-request.vala
@@ -144,16 +144,10 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
return;
}
- // Just use the first URI available
- string uri = null;
- if (this.item.uris.size != 0) {
- uri = this.item.uris.get (0);
- }
-
if (this.item.size > 0 && this.transcoder == null) {
- this.handle_interactive_item (uri);
+ this.handle_interactive_item ();
} else {
- this.handle_streaming_item (uri);
+ this.handle_streaming_item ();
}
}
@@ -187,26 +181,16 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
}
}
- private void handle_streaming_item (string? uri) {
- dynamic Element src = null;
+ private void handle_streaming_item () {
+ 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
- src = this.item.create_stream_source ();
- }
+ src = this.item.create_stream_source ();
if (src == null) {
this.handle_error (new HTTPRequestError.NOT_FOUND ("Not Found"));
return;
}
- // For rtspsrc since some RTSP sources takes a while to start
- // transmitting
- src.tcp_timeout = (int64) 60000000;
-
try {
if (this.transcoder != null) {
src = this.transcoder.create_source (this.item, src);
@@ -220,8 +204,8 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
}
}
- private void handle_interactive_item (string? uri) {
- if (uri == null) {
+ private void handle_interactive_item () {
+ if (this.item.uris.size == 0) {
var error = new HTTPRequestError.NOT_FOUND (
"Requested item '%s' didn't provide a URI\n",
this.item.id);
@@ -229,7 +213,7 @@ internal class Rygel.HTTPRequest : GLib.Object, Rygel.StateMachine {
return;
}
- this.serve_uri (uri, this.item.size);
+ this.serve_uri (this.item.uris.get (0), this.item.size);
}
private void on_item_found (GLib.Object source_object,
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index e7fca70..75ee87b 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -75,7 +75,22 @@ public class Rygel.MediaItem : MediaObject {
// Live media items need to provide a nice working implementation of this
// method if they can/do no provide a valid URI
public virtual Gst.Element? create_stream_source () {
- return null;
+ dynamic Gst.Element src = null;
+
+ if (this.uris.size != 0) {
+ src = Gst.Element.make_from_uri (
+ Gst.URIType.SRC, this.uris.get(0),null);
+ }
+ if (src != null) {
+ weak ObjectClass cls = (ObjectClass) src.get_type().class_peek();
+
+ // For rtspsrc since some RTSP sources takes a while to start
+ // transmitting
+ if (cls.find_property ("tcp-timeout") != null) {
+ src.tcp_timeout = (int64) 60000000;
+ }
+ }
+ return src;
}
internal int compare_transcoders (void *a, void *b) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]