[rygel] core: Move some code from LiveResponse to GstUtils



commit c7c7e2f66c365bf83745686003d6dee0c587748d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 27 15:55:45 2009 +0200

    core: Move some code from LiveResponse to GstUtils

 src/rygel/rygel-gst-utils.vala     |   60 +++++++++++++++++++++++++++++++++++
 src/rygel/rygel-live-response.vala |   61 +-----------------------------------
 2 files changed, 61 insertions(+), 60 deletions(-)
---
diff --git a/src/rygel/rygel-gst-utils.vala b/src/rygel/rygel-gst-utils.vala
index 4a18c77..e649e3b 100644
--- a/src/rygel/rygel-gst-utils.vala
+++ b/src/rygel/rygel-gst-utils.vala
@@ -41,4 +41,64 @@ internal abstract class Rygel.GstUtils {
         Message msg = new Message.error (dest, error, error.message);
         dest.post_message (msg);
     }
+
+    public static dynamic Element? get_rtp_depayloader (Caps caps) {
+        if (!need_rtp_depayloader (caps)) {
+            return null;
+        }
+
+        unowned Registry registry = Registry.get_default ();
+        var features = registry.feature_filter (rtp_depay_filter, false);
+
+        return get_best_depay (features, caps);
+    }
+
+    private static bool need_rtp_depayloader (Caps caps) {
+        var structure = caps.get_structure (0);
+        return structure.get_name () == "application/x-rtp";
+    }
+
+    private static dynamic Element? get_best_depay (
+                                        GLib.List<PluginFeature> features,
+                                        Caps                     caps) {
+        var relevant_factories = new GLib.List<ElementFactory> ();
+
+        // First construct a list of relevant factories
+        foreach (PluginFeature feature in features) {
+            var factory = (ElementFactory) feature;
+            if (factory.can_sink_caps (caps)) {
+               relevant_factories.append (factory);
+            }
+        }
+
+        if (relevant_factories.length () == 0) {
+            // No relevant factory available, hence no depayloader
+            return null;
+        }
+
+        // Then sort the list through their ranks
+        relevant_factories.sort (compare_factories);
+
+        // create an element of the top ranking factory and return it
+        var factory = relevant_factories.data;
+
+        return ElementFactory.make (factory.get_name (), null);
+    }
+
+    private static bool rtp_depay_filter (PluginFeature feature) {
+        if (!feature.get_type ().is_a (typeof (ElementFactory))) {
+            return false;
+        }
+
+        var factory = (ElementFactory) feature;
+
+        return factory.get_klass ().contains ("Depayloader");
+    }
+
+    private static int compare_factories (void *a, void *b) {
+        ElementFactory factory_a = (ElementFactory) a;
+        ElementFactory factory_b = (ElementFactory) b;
+
+        return (int) (factory_b.get_rank () - factory_a.get_rank ());
+    }
 }
diff --git a/src/rygel/rygel-live-response.vala b/src/rygel/rygel-live-response.vala
index 8713dc8..9608e08 100644
--- a/src/rygel/rygel-live-response.vala
+++ b/src/rygel/rygel-live-response.vala
@@ -128,7 +128,7 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
         var sink = this.pipeline.get_by_name (SINK_NAME);
         Pad sink_pad;
 
-        dynamic Element depay = this.get_rtp_depayloader (caps);
+        dynamic Element depay = GstUtils.get_rtp_depayloader (caps);
         if (depay != null) {
             this.pipeline.add (depay);
             if (!depay.link (sink)) {
@@ -157,65 +157,6 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
         }
     }
 
-    private bool need_rtp_depayloader (Caps caps) {
-        var structure = caps.get_structure (0);
-        return structure.get_name () == "application/x-rtp";
-    }
-
-    private dynamic Element? get_rtp_depayloader (Caps caps) {
-        if (!need_rtp_depayloader (caps)) {
-            return null;
-        }
-
-        unowned Registry registry = Registry.get_default ();
-        var features = registry.feature_filter (this.rtp_depay_filter, false);
-
-        return get_best_depay (features, caps);
-    }
-
-    private dynamic Element? get_best_depay (GLib.List<PluginFeature> features,
-                                             Caps                     caps) {
-        var relevant_factories = new GLib.List<ElementFactory> ();
-
-        // First construct a list of relevant factories
-        foreach (PluginFeature feature in features) {
-            var factory = (ElementFactory) feature;
-            if (factory.can_sink_caps (caps)) {
-               relevant_factories.append (factory);
-            }
-        }
-
-        if (relevant_factories.length () == 0) {
-            // No relevant factory available, hence no depayloader
-            return null;
-        }
-
-        // Then sort the list through their ranks
-        relevant_factories.sort (this.compare_factories);
-
-        // create an element of the top ranking factory and return it
-        var factory = relevant_factories.data;
-
-        return ElementFactory.make (factory.get_name (), null);
-    }
-
-    private bool rtp_depay_filter (PluginFeature feature) {
-        if (!feature.get_type ().is_a (typeof (ElementFactory))) {
-            return false;
-        }
-
-        var factory = (ElementFactory) feature;
-
-        return factory.get_klass ().contains ("Depayloader");
-    }
-
-    private static int compare_factories (void *a, void *b) {
-        ElementFactory factory_a = (ElementFactory) a;
-        ElementFactory factory_b = (ElementFactory) b;
-
-        return (int) (factory_b.get_rank () - factory_a.get_rank ());
-    }
-
     private void on_new_buffer (Element sink,
                                 Buffer  buffer,
                                 Pad     pad) {



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