[rygel] core: Utility function to create source for URI



commit 6b392c20ba2f718d679449e6dc41fbc83c4a0c23
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Apr 4 22:22:24 2011 +0300

    core: Utility function to create source for URI

 src/rygel/rygel-gst-utils.vala  |   19 +++++++++++++++++++
 src/rygel/rygel-media-item.vala |   16 +---------------
 2 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/src/rygel/rygel-gst-utils.vala b/src/rygel/rygel-gst-utils.vala
index b7927f8..45521a8 100644
--- a/src/rygel/rygel-gst-utils.vala
+++ b/src/rygel/rygel-gst-utils.vala
@@ -67,6 +67,25 @@ internal abstract class Rygel.GstUtils {
         return "%llu:%.2llu:%.2llu".printf (hours, minutes, seconds);
     }
 
+    public static Element? create_source_for_uri (string uri) {
+        dynamic Element src = Element.make_from_uri (URIType.SRC, uri, null);
+        if (src != null) {
+            if (src.get_class ().find_property ("blocksize") != null) {
+                // The default is usually 4KiB which is not really big enough
+                // for most cases so we set this to 65KiB.
+                src.blocksize = (long) 65536;
+            }
+
+            if (src.get_class ().find_property ("tcp-timeout") != null) {
+                // For rtspsrc since some RTSP sources takes a while to start
+                // transmitting
+                src.tcp_timeout = (int64) 60000000;
+            }
+        }
+
+        return src;
+    }
+
     public static dynamic Element? get_rtp_depayloader (Caps caps) {
         if (!need_rtp_depayloader (caps)) {
             return null;
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 33f6210..d286362 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -102,21 +102,7 @@ public abstract class Rygel.MediaItem : MediaObject {
         dynamic Element src = null;
 
         if (this.uris.size != 0) {
-            src = Element.make_from_uri (URIType.SRC, this.uris.get (0), null);
-        }
-
-        if (src != null) {
-            if (src.get_class ().find_property ("blocksize") != null) {
-                // The default is usually 4KiB which is not really big enough
-                // for most cases so we set this to 65KiB.
-                src.blocksize = (long) 65536;
-            }
-
-            if (src.get_class ().find_property ("tcp-timeout") != null) {
-                // For rtspsrc since some RTSP sources takes a while to start
-                // transmitting
-                src.tcp_timeout = (int64) 60000000;
-            }
+            src = GstUtils.create_source_for_uri (this.uris.get (0));
         }
 
         return src;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]