MP2TSTranscoder supports both HD and SD.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Sat, 28 Mar 2009 00:44:46 +0000 (00:44 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Sat, 28 Mar 2009 00:44:46 +0000 (00:44 +0000)
svn path=/trunk/; revision=749

src/rygel/rygel-mp2ts-transcoder.vala
src/rygel/rygel-transcode-manager.vala

index 372726b..537b16b 100644 (file)
@@ -25,19 +25,29 @@ using Gst;
 using GUPnP;
 using Gee;
 
+internal enum Rygel.MP2TSProfile {
+    SD = 0,
+    HD
+}
+
 internal class Rygel.MP2TSTranscoder : Rygel.Transcoder {
     // HD
-    private const int WIDTH = 1920;
-    private const int HEIGHT = 1080;
+    private const int[] WIDTH = {640, 1920};
+    private const int[] HEIGHT = {480, 1080};
+    private const string[] PROFILES = {"MPEG_TS_SD_NA", "MPEG_TS_HD_NA"};
+
+    private MP2TSProfile profile;
+
+    public MP2TSTranscoder (MP2TSProfile profile) {
+        base ("video/mpeg", PROFILES[profile]);
 
-    public MP2TSTranscoder () {
-        base ("video/mpeg", "MPEG_TS_HD_NA");
+        this.profile = profile;
     }
 
     public override Element create_source (Element src) throws Error {
         return new MP2TSTranscoderBin (src,
-                                       MP2TSTranscoder.WIDTH,
-                                       MP2TSTranscoder.HEIGHT);
+                                       MP2TSTranscoder.WIDTH[this.profile],
+                                       MP2TSTranscoder.HEIGHT[this.profile]);
     }
 
     public override void add_resources (ArrayList<DIDLLiteResource?> resources,
@@ -50,9 +60,9 @@ internal class Rygel.MP2TSTranscoder : Rygel.Transcoder {
 
         var res = manager.create_resource (item,
                                            this.mime_type,
-                                           this.dlna_profile);
-        res.width = WIDTH;
-        res.height = HEIGHT;
+                                           PROFILES[this.profile]);
+        res.width = WIDTH[profile];
+        res.height = HEIGHT[profile];
 
         resources.add (res);
     }
index aa40b0f..e712a85 100644 (file)
@@ -29,12 +29,14 @@ using Gst;
 internal abstract class Rygel.TranscodeManager : GLib.Object {
     private Transcoder l16_transcoder;
     private Transcoder mp3_transcoder;
-    private Transcoder mp2ts_transcoder;
+    private Transcoder mp2ts_hd_transcoder;
+    private Transcoder mp2ts_sd_transcoder;
 
     internal TranscodeManager () {
         l16_transcoder = new L16Transcoder ();
         mp3_transcoder = new MP3Transcoder (MP3Layer.THREE);
-        mp2ts_transcoder = new MP2TSTranscoder();
+        mp2ts_sd_transcoder = new MP2TSTranscoder(MP2TSProfile.SD);
+        mp2ts_hd_transcoder = new MP2TSTranscoder(MP2TSProfile.HD);
     }
 
     internal abstract string create_uri_for_item
@@ -52,7 +54,8 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
             this.l16_transcoder.add_resources (resources, item, this);
             this.mp3_transcoder.add_resources (resources, item, this);
         } else {
-            this.mp2ts_transcoder.add_resources (resources, item, this);
+            this.mp2ts_sd_transcoder.add_resources (resources, item, this);
+            this.mp2ts_hd_transcoder.add_resources (resources, item, this);
         }
     }
 
@@ -61,8 +64,10 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
             return this.mp3_transcoder;
         } else if (this.l16_transcoder.can_handle (target)) {
             return this.l16_transcoder;
-        } else if (this.mp2ts_transcoder.can_handle (target)) {
-            return this.mp2ts_transcoder;
+        } else if (this.mp2ts_sd_transcoder.can_handle (target)) {
+            return this.mp2ts_sd_transcoder;
+        } else if (this.mp2ts_hd_transcoder.can_handle (target)) {
+            return this.mp2ts_hd_transcoder;
         } else {
             throw new HTTPRequestError.NOT_FOUND (
                             "No transcoder available for target format '%s'",