core: Utility function to create source for URI
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 4 Apr 2011 19:22:24 +0000 (22:22 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 7 Apr 2011 23:11:27 +0000 (02:11 +0300)
src/rygel/rygel-gst-utils.vala
src/rygel/rygel-media-item.vala

index b7927f8..45521a8 100644 (file)
@@ -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;
index 33f6210..d286362 100644 (file)
@@ -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;