rygel r720 - trunk/src/rygel



Author: zeeshanak
Date: Sat Mar 21 13:56:55 2009
New Revision: 720
URL: http://svn.gnome.org/viewvc/rygel?rev=720&view=rev

Log:
Generalize gst element creation in base transcoder.

Modified:
   trunk/src/rygel/rygel-mp2ts-transcoder.vala
   trunk/src/rygel/rygel-mp3-transcoder.vala
   trunk/src/rygel/rygel-transcoder.vala

Modified: trunk/src/rygel/rygel-mp2ts-transcoder.vala
==============================================================================
--- trunk/src/rygel/rygel-mp2ts-transcoder.vala	(original)
+++ trunk/src/rygel/rygel-mp2ts-transcoder.vala	Sat Mar 21 13:56:55 2009
@@ -41,26 +41,13 @@
     private dynamic Element muxer;
 
     public MP2TSTranscoder (Element src) throws Error {
-        Element decodebin = ElementFactory.make (DECODEBIN, DECODEBIN);
-        if (decodebin == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    DECODEBIN);
-        }
-
+        Element decodebin = Transcoder.create_element (DECODEBIN, DECODEBIN);
         this.audio_enc = MP3Transcoder.create_encoder (MP3Profile.LAYER2,
                                                        null,
                                                        AUDIO_ENC_SINK);
-
         this.video_enc = MP2TSTranscoder.create_encoder (null,
                                                          VIDEO_ENC_SINK);
-
-        this.muxer = ElementFactory.make (MUXER, MUXER);
-        if (muxer == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    MUXER);
-        }
+        this.muxer = Transcoder.create_element (MUXER, MUXER);
 
         this.add_many (src, decodebin, this.muxer);
         src.link (decodebin);
@@ -109,27 +96,10 @@
     internal static Element create_encoder (string? src_pad_name,
                                             string? sink_pad_name)
                                             throws Error {
-        var videorate = ElementFactory.make (VIDEO_RATE, VIDEO_RATE);
-        if (videorate == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    VIDEO_RATE);
-        }
-
-        var convert = ElementFactory.make (COLORSPACE_CONVERT,
-                COLORSPACE_CONVERT);
-        if (convert == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    COLORSPACE_CONVERT);
-        }
-
-        var encoder = ElementFactory.make (VIDEO_ENCODER, VIDEO_ENCODER);
-        if (encoder == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    VIDEO_ENCODER);
-        }
+        var videorate = Transcoder.create_element (VIDEO_RATE, VIDEO_RATE);
+        var convert = Transcoder.create_element (COLORSPACE_CONVERT,
+                                                 COLORSPACE_CONVERT);
+        var encoder = Transcoder.create_element (VIDEO_ENCODER, VIDEO_ENCODER);
 
         var bin = new Bin ("video-encoder-bin");
         bin.add_many (videorate, convert, encoder);

Modified: trunk/src/rygel/rygel-mp3-transcoder.vala
==============================================================================
--- trunk/src/rygel/rygel-mp3-transcoder.vala	(original)
+++ trunk/src/rygel/rygel-mp3-transcoder.vala	Sat Mar 21 13:56:55 2009
@@ -47,12 +47,7 @@
     public MP3Transcoder (Element src, MP3Profile layer) throws Error {
         this.layer = layer;
 
-        Element decodebin = ElementFactory.make (DECODEBIN, DECODEBIN);
-        if (decodebin == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                "Required element '%s' missing",
-                                DECODEBIN);
-        }
+        Element decodebin = Transcoder.create_element (DECODEBIN, DECODEBIN);
 
         this.audio_enc = MP3Transcoder.create_encoder (this.layer,
                                                        AUDIO_SRC_PAD,
@@ -89,34 +84,15 @@
                                             string?    src_pad_name,
                                             string?    sink_pad_name)
                                             throws Error {
-        var convert = ElementFactory.make (AUDIO_CONVERT, AUDIO_CONVERT);
-        if (convert == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    AUDIO_CONVERT);
-        }
-
-        Element resample = ElementFactory.make (AUDIO_RESAMPLE, AUDIO_RESAMPLE);
-        if (resample == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    AUDIO_RESAMPLE);
-        }
-
-        dynamic Element encoder = ElementFactory.make (AUDIO_ENCODER[layer],
+        dynamic Element convert = Transcoder.create_element (AUDIO_CONVERT,
+                                                             AUDIO_CONVERT);
+        dynamic Element resample = Transcoder.create_element (AUDIO_RESAMPLE,
+                                                              AUDIO_RESAMPLE);
+        dynamic Element encoder = Transcoder.create_element (
+                                                       AUDIO_ENCODER[layer],
                                                        AUDIO_ENCODER[layer]);
-        if (encoder == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    AUDIO_ENCODER[layer]);
-        }
-
-        Element parser = ElementFactory.make (AUDIO_PARSER, AUDIO_PARSER);
-        if (parser == null) {
-            throw new LiveResponseError.MISSING_PLUGIN (
-                                    "Required element '%s' missing",
-                                    AUDIO_PARSER);
-        }
+        dynamic Element parser = Transcoder.create_element (AUDIO_PARSER,
+                                                            AUDIO_PARSER);
 
         if (layer == MP3Profile.LAYER3) {
             // Best quality

Modified: trunk/src/rygel/rygel-transcoder.vala
==============================================================================
--- trunk/src/rygel/rygel-transcoder.vala	(original)
+++ trunk/src/rygel/rygel-transcoder.vala	Sat Mar 21 13:56:55 2009
@@ -32,6 +32,19 @@
         return !intersection.is_empty ();
     }
 
+    protected static Element create_element (string factoryname,
+                                             string? name)
+                                             throws Error {
+        Element element = ElementFactory.make (factoryname, name);
+        if (element == null) {
+            throw new LiveResponseError.MISSING_PLUGIN (
+                                "Required element factory '%s' missing",
+                                factoryname);
+        }
+
+        return element;
+    }
+
     protected void post_error (Error error) {
         Message msg = new Message.error (this, error, error.message);
         this.post_message (msg);



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