test: create the pipeline in a more simple way
authorThijs Vermeir <thijsvermeir@gmail.com>
Tue, 18 Aug 2009 03:04:30 +0000 (05:04 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 3 Sep 2009 15:41:29 +0000 (18:41 +0300)
src/plugins/test/rygel-test-audio-item.vala
src/plugins/test/rygel-test-video-item.vala

index 7f3a19f..27d6ecb 100644 (file)
@@ -43,31 +43,12 @@ public class Rygel.TestAudioItem : Rygel.TestItem {
     }
 
     public override Element? create_stream_source () {
-        Bin bin = new Bin (this.title);
-
-        dynamic Element src = ElementFactory.make ("audiotestsrc", null);
-        Element encoder = ElementFactory.make ("wavenc", null);
-
-        if (src == null || encoder == null) {
-            warning ("Required plugin missing");
-
-            return null;
+        try {
+          return Gst.parse_bin_from_description ("audiotestsrc is-live=1 ! wavenc", true);
+        } catch (Error err) {
+          warning ("Required plugin missing (%s)", err.message);
+          return null;
         }
-
-        // Tell the source to behave like a live source
-        src.is_live = true;
-
-        // Add elements to our source bin
-        bin.add_many (src, encoder);
-        // Link them
-        src.link (encoder);
-
-        // Now add the encoder's src pad to the bin
-        Pad pad = encoder.get_static_pad ("src");
-        var ghost = new GhostPad (bin.name + "." + pad.name, pad);
-        bin.add_pad (ghost);
-
-        return bin;
     }
 }
 
index 21ff907..d2b3f46 100644 (file)
@@ -43,32 +43,12 @@ public class Rygel.TestVideoItem : Rygel.TestItem {
     }
 
     public override Element? create_stream_source () {
-        Bin bin = new Bin (this.title);
-
-        dynamic Element src = ElementFactory.make ("videotestsrc", null);
-        Element encoder = ElementFactory.make ("ffenc_mpeg2video", null);
-        Element muxer = ElementFactory.make ("mpegtsmux", null);
-
-        if (src == null || muxer == null || encoder == null) {
-            warning ("Required plugin missing");
-
-            return null;
+        try {
+          return Gst.parse_bin_from_description ("videotestsrc is-live=1 ! ffenc_mpeg2video ! mpegtsmux", true);
+        } catch (Error err) {
+          warning ("Required plugin missing (%s)", err.message);
+          return null;
         }
-
-        // Tell the source to behave like a live source
-        src.is_live = true;
-
-        // Add elements to our source bin
-        bin.add_many (src, encoder, muxer);
-        // Link them
-        src.link_many (encoder, muxer);
-
-        // Now add the encoder's src pad to the bin
-        Pad pad = muxer.get_static_pad ("src");
-        var ghost = new GhostPad (bin.name + "." + pad.name, pad);
-        bin.add_pad (ghost);
-
-        return bin;
     }
 }