[rygel] core: Add transcoder for AVC_MP4_BL_CIF15_AAC_520



commit cef3f193a6e21356e5a977bc673fcc8adfbe9298
Author: Luis de Bethencourt <luis debethencourt collabora com>
Date:   Mon Jul 11 18:54:54 2011 +0200

    core: Add transcoder for AVC_MP4_BL_CIF15_AAC_520

 src/rygel/Makefile.am                  |    1 +
 src/rygel/rygel-avc-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 f902470..b3d3d83 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -97,6 +97,7 @@ VAPI_SOURCE_FILES = \
 	rygel-l16-transcoder.vala \
 	rygel-wmv-transcoder.vala \
 	rygel-aac-transcoder.vala \
+	rygel-avc-transcoder.vala \
 	rygel-gst-utils.vala \
 	rygel-media-receiver-registrar.vala \
 	rygel-log-handler.vala \
diff --git a/src/rygel/rygel-avc-transcoder.vala b/src/rygel/rygel-avc-transcoder.vala
new file mode 100644
index 0000000..b4c2120
--- /dev/null
+++ b/src/rygel/rygel-avc-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;
+
+internal class Rygel.AVCTranscoder : Rygel.Transcoder {
+    private const int BITRATE = 1200000;
+    private const int VIDEO_BITRATE = 1200;
+    private const int AUDIO_BITRATE = 64;
+
+    public AVCTranscoder () {
+        base ("video/mp4", "AVC_MP4_BL_CIF15_AAC_520", VideoItem.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;
+        }
+
+        var video_item = item as VideoItem;
+
+        resource.width = video_item.width;
+        resource.height = video_item.height;
+        resource.bitrate = (VIDEO_BITRATE + AUDIO_BITRATE) * 1000 / 8;
+
+        return resource;
+    }
+
+    public override uint get_distance (MediaItem item) {
+        if (!(item is VideoItem)) {
+            return uint.MAX;
+        }
+
+        var video_item = item as VideoItem;
+        var distance = uint.MIN;
+
+        if (video_item.bitrate > 0) {
+            distance += (video_item.bitrate - BITRATE).abs ();
+        }
+
+        return distance;
+    }
+
+    protected override EncodingProfile get_encoding_profile () {
+        var container_format = Caps.from_string ("video/quicktime,variant=iso");
+
+        var video_format = Caps.from_string ("video/x-h264,stream-format=avc");
+        var audio_format = Caps.from_string ("audio/mpeg,mpegversion=4");
+
+        var enc_container_profile = new EncodingContainerProfile("container",
+                                                                 null,
+                                                                 container_format,
+                                                                 null);
+        var enc_video_profile = new EncodingVideoProfile (video_format,
+                                                          null,
+                                                          null,
+                                                          1);
+        var enc_audio_profile = new EncodingAudioProfile (audio_format,
+                                                          null,
+                                                          null,
+                                                          1);
+
+        // FIXME: We should use the preset to set bitrate
+        enc_container_profile.add_profile (enc_video_profile);
+        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 62548a7..162ef7a 100644
--- a/src/rygel/rygel-transcode-manager.vala
+++ b/src/rygel/rygel-transcode-manager.vala
@@ -52,6 +52,7 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
         var mp2ts_transcoder = true;
         var wmv_transcoder = true;
         var aac_transcoder = true;
+        var avc_transcoder = true;
 
         try {
             transcoding = config.get_transcoding ();
@@ -85,6 +86,10 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
             if (aac_transcoder) {
                 transcoders.add (new AACTranscoder ());
             }
+
+            if (avc_transcoder) {
+                transcoders.add (new AVCTranscoder ());
+            }
         }
     }
 



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