core: Re-mux only if transcoding is not needed
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 8 May 2010 18:37:04 +0000 (21:37 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 8 May 2010 18:37:04 +0000 (21:37 +0300)
MPEG2TS and WMV transcoders now bypass encoders if the stream is already
encoded in the needed codec. However, this also implies skipping the raw
audio and video tansformations and that in turn implies we are not exactly
being honest about the advertized DLNA profile name of the remuxed stream.
In most cases that shouldn't be a problem and this change should only make
users happy (hopefully).

src/rygel/rygel-mp2ts-transcoder-bin.vala
src/rygel/rygel-wmv-transcoder-bin.vala

index dc6059f..e4e4706 100644 (file)
@@ -42,7 +42,8 @@ internal class Rygel.MP2TSTranscoderBin : Gst.Bin {
                                Element         src,
                                MP2TSTranscoder transcoder)
                                throws Error {
-        Element decodebin = GstUtils.create_element (DECODEBIN, DECODEBIN);
+        dynamic Element decodebin = GstUtils.create_element (DECODEBIN,
+                                                             DECODEBIN);
         var mp3_transcoder = new MP3Transcoder (MP3Layer.TWO);
         this.audio_enc = mp3_transcoder.create_encoder (item,
                                                         null,
@@ -62,6 +63,19 @@ internal class Rygel.MP2TSTranscoderBin : Gst.Bin {
         this.add_pad (ghost);
 
         decodebin.pad_added += this.decodebin_pad_added;
+        decodebin.autoplug_continue += this.autoplug_continue;
+    }
+
+    private bool autoplug_continue (Element decodebin,
+                                    Pad     new_pad,
+                                    Caps    caps) {
+        var muxer_pad = this.muxer.get_compatible_pad (new_pad, null);
+
+        if (muxer_pad == null) {
+            return true;
+        } else {
+            return new_pad.link (muxer_pad) != PadLinkReturn.OK;
+        }
     }
 
     private void decodebin_pad_added (Element decodebin, Pad new_pad) {
index 435d924..1ee5efe 100644 (file)
@@ -40,7 +40,8 @@ internal class Rygel.WMVTranscoderBin : Gst.Bin {
                              Element       src,
                              WMVTranscoder transcoder)
                              throws Error {
-        Element decodebin = GstUtils.create_element (DECODEBIN, DECODEBIN);
+        dynamic Element decodebin = GstUtils.create_element (DECODEBIN,
+                                                             DECODEBIN);
         var wma_transcoder = new WMATranscoder ();
         this.audio_enc = wma_transcoder.create_encoder (item,
                                                         null,
@@ -60,6 +61,19 @@ internal class Rygel.WMVTranscoderBin : Gst.Bin {
         this.add_pad (ghost);
 
         decodebin.pad_added += this.decodebin_pad_added;
+        decodebin.autoplug_continue += this.autoplug_continue;
+    }
+
+    private bool autoplug_continue (Element decodebin,
+                                    Pad     new_pad,
+                                    Caps    caps) {
+        var muxer_pad = this.muxer.get_compatible_pad (new_pad, null);
+
+        if (muxer_pad == null) {
+            return true;
+        } else {
+            return new_pad.link (muxer_pad) != PadLinkReturn.OK;
+        }
     }
 
     private void decodebin_pad_added (Element decodebin, Pad new_pad) {