[rygel] core: Add transcoder for AAC_ISO_320 format



commit 9b94f08619f4d01fab019eb3c9a7d7b73a04ed26
Author: Luis de Bethencourt <luis debethencourt collabora com>
Date:   Mon Jul 11 18:43:08 2011 +0200

    core: Add transcoder for AAC_ISO_320 format

 src/rygel/Makefile.am                  |    1 +
 src/rygel/rygel-aac-transcoder.vala    |   92 ++++++++++++++++++++++++++++++++
 src/rygel/rygel-transcode-manager.vala |    5 ++
 3 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am
index a79a3bc..f902470 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -96,6 +96,7 @@ VAPI_SOURCE_FILES = \
 	rygel-mp3-transcoder.vala \
 	rygel-l16-transcoder.vala \
 	rygel-wmv-transcoder.vala \
+	rygel-aac-transcoder.vala \
 	rygel-gst-utils.vala \
 	rygel-media-receiver-registrar.vala \
 	rygel-log-handler.vala \
diff --git a/src/rygel/rygel-aac-transcoder.vala b/src/rygel/rygel-aac-transcoder.vala
new file mode 100644
index 0000000..5dfd878
--- /dev/null
+++ b/src/rygel/rygel-aac-transcoder.vala
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation.
+ *
+ * Author: Luis de Bethencourt <luis debethencourt collabora com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+using Gst;
+using GUPnP;
+using Gee;
+
+internal enum Rygel.AACProfile {
+    SD = 0,
+    HD
+}
+
+/**
+ * Transcoder for aac stream containing mpeg 4 audio.
+ */
+internal class Rygel.AACTranscoder : Rygel.Transcoder {
+    private const int BITRATE = 256;
+
+    public AACTranscoder () {
+        base ("audio/3gpp", "AAC_ISO_320", AudioItem.UPNP_CLASS);
+    }
+
+    public override DIDLLiteResource? add_resource (DIDLLiteItem     didl_item,
+                                                    MediaItem        item,
+                                                    TranscodeManager manager)
+                                                    throws Error {
+        var resource = base.add_resource (didl_item, item, manager);
+        if (resource == null) {
+            return null;
+        }
+
+        resource.bitrate = (BITRATE * 1000) / 8;
+
+        return resource;
+    }
+
+    public override uint get_distance (MediaItem item) {
+        if (!(item is AudioItem) || item is VideoItem) {
+            return uint.MAX;
+        }
+
+        var audio_item = item as AudioItem;
+        var distance = uint.MIN;
+
+        if (audio_item.bitrate > 0) {
+            distance += (audio_item.bitrate - BITRATE).abs ();
+        }
+
+        return distance;
+    }
+
+    protected override EncodingProfile get_encoding_profile () {
+        var container_format = Caps.from_string ("application/x-3gp,profile=basic");
+        var audio_format = Caps.from_string ("audio/mpeg," +
+                                             "mpegversion=4," +
+                                             "framed=true," +
+                                             "stream-format=raw," +
+                                       /*    "level=2," + */
+                                             "profile=lc," +
+                                             "codec_data=1208,rate=44100,channels=1");
+        var enc_container_profile = new EncodingContainerProfile ("container",
+                                                                  null,
+                                                                  container_format,
+                                                                  null);
+        var enc_audio_profile = new EncodingAudioProfile (audio_format,
+                                                          null,
+                                                          null,
+                                                          1);
+
+        enc_container_profile.add_profile (enc_audio_profile);
+
+        return enc_container_profile;
+    }
+}
diff --git a/src/rygel/rygel-transcode-manager.vala b/src/rygel/rygel-transcode-manager.vala
index 8a3c17f..62548a7 100644
--- a/src/rygel/rygel-transcode-manager.vala
+++ b/src/rygel/rygel-transcode-manager.vala
@@ -51,6 +51,7 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
         var mp3_transcoder = true;
         var mp2ts_transcoder = true;
         var wmv_transcoder = true;
+        var aac_transcoder = true;
 
         try {
             transcoding = config.get_transcoding ();
@@ -80,6 +81,10 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
             if (wmv_transcoder) {
                 transcoders.add (new WMVTranscoder ());
             }
+
+            if (aac_transcoder) {
+                transcoders.add (new AACTranscoder ());
+            }
         }
     }
 



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