[rygel] test: create the pipeline in a more simple way



commit 887875ee7dbffa3c9aa40e3c9ffcdcfd70e7fc5b
Author: Thijs Vermeir <thijsvermeir gmail com>
Date:   Tue Aug 18 05:04:30 2009 +0200

    test: create the pipeline in a more simple way

 src/plugins/test/rygel-test-audio-item.vala |   29 ++++---------------------
 src/plugins/test/rygel-test-video-item.vala |   30 ++++----------------------
 2 files changed, 10 insertions(+), 49 deletions(-)
---
diff --git a/src/plugins/test/rygel-test-audio-item.vala b/src/plugins/test/rygel-test-audio-item.vala
index 7f3a19f..27d6ecb 100644
--- a/src/plugins/test/rygel-test-audio-item.vala
+++ b/src/plugins/test/rygel-test-audio-item.vala
@@ -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;
     }
 }
 
diff --git a/src/plugins/test/rygel-test-video-item.vala b/src/plugins/test/rygel-test-video-item.vala
index 21ff907..d2b3f46 100644
--- a/src/plugins/test/rygel-test-video-item.vala
+++ b/src/plugins/test/rygel-test-video-item.vala
@@ -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;
     }
 }
 



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