[rygel] core: Fix DLNA bitrates using presets



commit 2bb5ad338a14785cc00b761e117b57dc829c613a
Author: Jens Georg <mail jensge org>
Date:   Fri Apr 27 23:59:35 2012 +0200

    core: Fix DLNA bitrates using presets
    
    Also cunningly work around bgo#672439 by not providing a preset for
    mpeg2enc.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675234

 common.am                             |    3 +++
 configure.ac                          |    2 +-
 data/Makefile.am                      |   20 ++++++++++++++------
 data/presets/GstLameMP3Enc.prs        |    7 +++++++
 data/presets/GstMP4Mux.prs            |    7 +++++++
 data/presets/GstTwoLame.prs           |    6 ++++++
 data/presets/GstX264Enc.prs           |    7 +++++++
 data/presets/ffenc_aac.prs            |    9 +++++++++
 data/presets/ffenc_mp2.prs            |    6 ++++++
 data/presets/ffenc_mpeg2video.prs     |    6 ++++++
 data/presets/ffenc_wmav1.prs          |    6 ++++++
 data/presets/ffenc_wmv1.prs           |    6 ++++++
 src/rygel/rygel-aac-transcoder.vala   |    1 +
 src/rygel/rygel-audio-transcoder.vala |    4 ++--
 src/rygel/rygel-avc-transcoder.vala   |    1 +
 src/rygel/rygel-build-config.vapi     |    3 +++
 src/rygel/rygel-main.vala             |    5 +++++
 src/rygel/rygel-transcoder.vala       |    4 ++++
 src/rygel/rygel-video-transcoder.vala |    2 +-
 19 files changed, 95 insertions(+), 10 deletions(-)
---
diff --git a/common.am b/common.am
index cbbcffd..880307f 100644
--- a/common.am
+++ b/common.am
@@ -4,12 +4,14 @@ sysconfigdir = $(shareddir)
 desktopdir = $(shareddir)
 plugindir = $(abs_top_builddir)/src/plugins
 icondir = $(shareddir)/icons/32x32
+presetdir = $(shareddir)/presets
 else
 shareddir = $(datadir)/rygel
 sysconfigdir = $(sysconfdir)
 desktopdir = $(datadir)/applications
 plugindir = $(libdir)/rygel-1.0
 icondir = $(datadir)/icons/hicolor/32x32/apps
+presetdir = $(shareddir)/presets
 endif
 
 smallicondir = $(shareddir)/icons/48x48
@@ -30,6 +32,7 @@ AM_CFLAGS = \
 	-I$(rygeldir) \
 	-DDATA_DIR='"$(shareddir)"' -DSYS_CONFIG_DIR='"$(sysconfigdir)"'\
 	-DPLUGIN_DIR='"$(plugindir)"' -DDESKTOP_DIR='"$(desktopdir)"'\
+	-DPRESET_DIR='"$(presetdir)"'\
 	-include config.h
 
 RYGEL_COMMON_LIBS = \
diff --git a/configure.ac b/configure.ac
index 3cc5e82..797c5e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,7 +35,7 @@ GUPNP_REQUIRED=0.17.1
 GUPNP_AV_REQUIRED=0.9.0
 GUPNP_DLNA_REQUIRED=0.5.0
 GUPNP_VALA_REQUIRED=0.10.2
-GSTREAMER_REQUIRED=0.10.35
+GSTREAMER_REQUIRED=0.10.36
 GSTPBU_REQUIRED=0.10.35
 GIO_REQUIRED=2.26
 GEE_REQUIRED=0.5.2
diff --git a/data/Makefile.am b/data/Makefile.am
index f8b3e89..244fa06 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,9 +1,9 @@
+include ../common.am
+
 SUBDIRS = xml icons
 
 sysconf_DATA = rygel.conf
 
-shareddir = $(datadir)/rygel
-
 if BUILD_UI
 dist_shared_DATA = rygel-preferences.ui
 endif
@@ -18,16 +18,24 @@ $(dbusservice_DATA): $(dbusservice_in_files) Makefile
 	@sed -e "s|\ bindir\@|$(bindir)|" $< > $@
 
 # Rule to create the .desktop files
-desktopdir = $(datadir)/applications
 desktop_in_files = rygel.desktop.in rygel-preferences.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
+preset_DATA = $(srcdir)/presets/ffenc_aac.prs \
+	$(srcdir)/presets/ffenc_mp2.prs \
+	$(srcdir)/presets/ffenc_mpeg2video.prs \
+	$(srcdir)/presets/ffenc_wmav1.prs \
+	$(srcdir)/presets/ffenc_wmv1.prs \
+	$(srcdir)/presets/GstLameMP3Enc.prs \
+	$(srcdir)/presets/GstMP4Mux.prs \
+	$(srcdir)/presets/GstTwoLame.prs \
+	$(srcdir)/presets/GstX264Enc.prs
+
 CLEANFILES = $(dbusservice_DATA) $(desktop_DATA)
 EXTRA_DIST = $(dbusservice_in_files) \
 	     $(desktop_in_files) \
 	     $(sysconf_DATA) \
-	     $(pixmaps_DATA)
-
+	     $(pixmaps_DATA) \
+	     $(presets_DATA)
 
-MAINTAINERCLEANFILES = Makefile.in
diff --git a/data/presets/GstLameMP3Enc.prs b/data/presets/GstLameMP3Enc.prs
new file mode 100644
index 0000000..15d0b5d
--- /dev/null
+++ b/data/presets/GstLameMP3Enc.prs
@@ -0,0 +1,7 @@
+[_presets_]
+version=0.10
+element-name=GstLameMP3Enc
+
+[Rygel DLNA preset]
+target=1
+bitrate=256
diff --git a/data/presets/GstMP4Mux.prs b/data/presets/GstMP4Mux.prs
new file mode 100644
index 0000000..8c54280
--- /dev/null
+++ b/data/presets/GstMP4Mux.prs
@@ -0,0 +1,7 @@
+[_presets_]
+version=0.10
+element-name=GstMP4Mux
+
+[Rygel DLNA preset]
+streamable=true
+faststart=true
diff --git a/data/presets/GstTwoLame.prs b/data/presets/GstTwoLame.prs
new file mode 100644
index 0000000..afe8399
--- /dev/null
+++ b/data/presets/GstTwoLame.prs
@@ -0,0 +1,6 @@
+[_presets_]
+version=0.10
+element-name=GstTwoLame
+
+[Rygel DLNA preset]
+bitrate=256
diff --git a/data/presets/GstX264Enc.prs b/data/presets/GstX264Enc.prs
new file mode 100644
index 0000000..5b2383c
--- /dev/null
+++ b/data/presets/GstX264Enc.prs
@@ -0,0 +1,7 @@
+[_presets_]
+version=0.10
+element-name=GstX264Enc
+
+[Rygel AVC_MP4_BL_CIF15_AAC_520]
+preset=1
+bitrate=1200
diff --git a/data/presets/ffenc_aac.prs b/data/presets/ffenc_aac.prs
new file mode 100644
index 0000000..1afed86
--- /dev/null
+++ b/data/presets/ffenc_aac.prs
@@ -0,0 +1,9 @@
+[_presets_]
+version=0.10
+element-name=ffenc_aac
+
+[Rygel DLNA preset]
+bitrate=64000
+
+[Rygel AAC_ISO_320 preset]
+bitrate=256000
diff --git a/data/presets/ffenc_mp2.prs b/data/presets/ffenc_mp2.prs
new file mode 100644
index 0000000..588af1b
--- /dev/null
+++ b/data/presets/ffenc_mp2.prs
@@ -0,0 +1,6 @@
+[_presets_]
+version=0.10
+element-name=ffenc_mp2
+
+[Rygel DLNA preset]
+bitrate=256000
diff --git a/data/presets/ffenc_mpeg2video.prs b/data/presets/ffenc_mpeg2video.prs
new file mode 100644
index 0000000..e0c415a
--- /dev/null
+++ b/data/presets/ffenc_mpeg2video.prs
@@ -0,0 +1,6 @@
+[_presets_]
+version=0.10
+element-name=ffenc_mpeg2video
+
+[Rygel DLNA preset]
+bitrate=3000000
diff --git a/data/presets/ffenc_wmav1.prs b/data/presets/ffenc_wmav1.prs
new file mode 100644
index 0000000..c28a00e
--- /dev/null
+++ b/data/presets/ffenc_wmav1.prs
@@ -0,0 +1,6 @@
+[_presets_]
+version=0.10
+element-name=ffenc_wmav1
+
+[Rygel DLNA preset]
+bitrate=64000
diff --git a/data/presets/ffenc_wmv1.prs b/data/presets/ffenc_wmv1.prs
new file mode 100644
index 0000000..6434df4
--- /dev/null
+++ b/data/presets/ffenc_wmv1.prs
@@ -0,0 +1,6 @@
+[_presets_]
+version=0.10
+element-name=ffenc_wmv1
+
+[Rygel DLNA preset]
+bitrate=1200000
diff --git a/src/rygel/rygel-aac-transcoder.vala b/src/rygel/rygel-aac-transcoder.vala
index 71f74fa..19e672a 100644
--- a/src/rygel/rygel-aac-transcoder.vala
+++ b/src/rygel/rygel-aac-transcoder.vala
@@ -34,5 +34,6 @@ internal class Rygel.AACTranscoder : Rygel.AudioTranscoder {
 
     public AACTranscoder () {
         base ("audio/3gpp", "AAC_ISO_320", BITRATE, CONTAINER, CODEC, "3gp");
+        this.preset = "Rygel AAC_ISO_320 preset";
     }
 }
diff --git a/src/rygel/rygel-audio-transcoder.vala b/src/rygel/rygel-audio-transcoder.vala
index eead824..8ff88a4 100644
--- a/src/rygel/rygel-audio-transcoder.vala
+++ b/src/rygel/rygel-audio-transcoder.vala
@@ -97,7 +97,7 @@ internal class Rygel.AudioTranscoder : Rygel.Transcoder {
 
     protected override EncodingProfile get_encoding_profile () {
         var enc_audio_profile = new EncodingAudioProfile (audio_codec_format,
-                                                          null,
+                                                          this.preset,
                                                           null,
                                                           1);
         enc_audio_profile.set_name ("audio");
@@ -106,7 +106,7 @@ internal class Rygel.AudioTranscoder : Rygel.Transcoder {
             var enc_container_profile = new EncodingContainerProfile ("container",
                                                                       null,
                                                                       container_format,
-                                                                      null);
+                                                                      this.preset);
             enc_container_profile.add_profile (enc_audio_profile);
 
             return enc_container_profile;
diff --git a/src/rygel/rygel-avc-transcoder.vala b/src/rygel/rygel-avc-transcoder.vala
index cb4dbe8..d1a4e61 100644
--- a/src/rygel/rygel-avc-transcoder.vala
+++ b/src/rygel/rygel-avc-transcoder.vala
@@ -47,6 +47,7 @@ internal class Rygel.AVCTranscoder : Rygel.VideoTranscoder {
               VIDEO_CAPS,
               "mp4",
               RESTRICTIONS);
+        this.preset = "Rygel AVC_MP4_BL_CIF15_AAC_520 preset";
     }
 
     public override DIDLLiteResource? add_resource (DIDLLiteItem     didl_item,
diff --git a/src/rygel/rygel-build-config.vapi b/src/rygel/rygel-build-config.vapi
index 9b331a0..bbf0ceb 100644
--- a/src/rygel/rygel-build-config.vapi
+++ b/src/rygel/rygel-build-config.vapi
@@ -57,4 +57,7 @@ public class Rygel.BuildConfig {
 
     [CCode (cname = "LOCALEDIR")]
     public static const string LOCALEDIR;
+
+    [CCode (cname = "PRESET_DIR")]
+    public static const string PRESET_DIR;
 }
diff --git a/src/rygel/rygel-main.vala b/src/rygel/rygel-main.vala
index 6217f19..0b7cd47 100644
--- a/src/rygel/rygel-main.vala
+++ b/src/rygel/rygel-main.vala
@@ -25,6 +25,9 @@ using Gee;
 using GUPnP;
 using Posix;
 
+[CCode (cname="gst_preset_set_app_dir")]
+extern bool gst_preset_set_app_dir (string app_dir);
+
 public class Rygel.Main : Object {
     private static int PLUGIN_TIMEOUT = 5;
 
@@ -59,6 +62,8 @@ public class Rygel.Main : Object {
         Unix.signal_add (SIGHUP, () => { this.restart (); return true; });
         Unix.signal_add (SIGINT, () => { this.exit (0); return false; });
         Unix.signal_add (SIGTERM, () => { this.exit (0); return false; });
+
+        gst_preset_set_app_dir (BuildConfig.PRESET_DIR);
     }
 
     public void exit (int exit_code) {
diff --git a/src/rygel/rygel-transcoder.vala b/src/rygel/rygel-transcoder.vala
index 63a71b2..2071bfb 100644
--- a/src/rygel/rygel-transcoder.vala
+++ b/src/rygel/rygel-transcoder.vala
@@ -32,9 +32,13 @@ internal abstract class Rygel.Transcoder : GLib.Object {
     public string mime_type { get; protected set; }
     public string dlna_profile { get; protected set; }
     public string extension { get; protected set; }
+    public string preset { get;
+                           protected set;
+                           default =  DEFAULT_ENCODING_PRESET; }
 
     private const string DECODE_BIN = "decodebin2";
     private const string ENCODE_BIN = "encodebin";
+    private const string DEFAULT_ENCODING_PRESET = "Rygel DLNA preset";
 
     dynamic Element decoder;
     dynamic Element encoder;
diff --git a/src/rygel/rygel-video-transcoder.vala b/src/rygel/rygel-video-transcoder.vala
index 15f1928..f01da21 100644
--- a/src/rygel/rygel-video-transcoder.vala
+++ b/src/rygel/rygel-video-transcoder.vala
@@ -95,7 +95,7 @@ internal class Rygel.VideoTranscoder : Rygel.AudioTranscoder {
 
         var enc_video_profile = new EncodingVideoProfile
                                         (this.video_codec_format,
-                                         null,
+                                         this.preset,
                                          this.video_restrictions,
                                          1);
         enc_video_profile.set_name ("video");



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