[rygel/wip/didl-s: 28/35] renderer: Get image timeout from config



commit 0dbf522e72f9e6071f4905a4b4e4a266183713a8
Author: Jens Georg <jensg openismus com>
Date:   Tue Nov 20 17:09:54 2012 +0100

    renderer: Get image timeout from config

 data/rygel.conf                                   |    7 +++++
 src/librygel-renderer/rygel-playlist-handler.vala |   31 +++++++++++++++++++--
 2 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/data/rygel.conf b/data/rygel.conf
index 848b25c..78db632 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -85,6 +85,13 @@ allow-deletion=true
 # List of active transcoders. To disable one, remove from list.
 transcoders=mp3;lpcm;mp2ts;wmv;aac;avc
 
+# Options that apply to the renderer framework in general
+[Renderer]
+
+# Default showtime in seconds to use for images in playlists if dlna:lifetime
+# is not set. DLNA wants something between 5 and 15 seconds.
+image-timeout = 15
+
 [Tracker]
 enabled=true
 share-pictures=true
diff --git a/src/librygel-renderer/rygel-playlist-handler.vala b/src/librygel-renderer/rygel-playlist-handler.vala
index 7f57463..274956e 100644
--- a/src/librygel-renderer/rygel-playlist-handler.vala
+++ b/src/librygel-renderer/rygel-playlist-handler.vala
@@ -1,14 +1,18 @@
 using GUPnP;
 
 internal class Rygel.PlaylistHandler : GLib.Object {
-    //private const int DEFAULT_IMAGE_TIMEOUT = 300;
-    private const int DEFAULT_IMAGE_TIMEOUT = 30;
+    private const int DEFAULT_IMAGE_TIMEOUT = 15;
+    private const string CONFIG_SECTION = "Renderer";
+    private const string TIMEOUT_KEY = "image-timeout";
+
     public MediaCollection collection { construct; private get; }
     public unowned AVTransport transport { construct; private get; }
     public uint current_track { construct set; get; default = 1; }
 
     private List<DIDLLiteItem> items;
     private uint timeout_id;
+    private uint default_image_timeout;
+    private Configuration config;
 
     public PlaylistHandler (MediaCollection collection,
                             AVTransport     transport) {
@@ -16,7 +20,11 @@ internal class Rygel.PlaylistHandler : GLib.Object {
     }
 
     public override void constructed () {
-        debug ("Playlist handler constructed");
+        this.config = MetaConfig.get_default ();
+        this.config.setting_changed.connect (this.on_setting_changed);
+        this.default_image_timeout = DEFAULT_IMAGE_TIMEOUT;
+        this.on_setting_changed (CONFIG_SECTION, TIMEOUT_KEY);
+
         this.items = this.collection.get_items ();
         this.transport.n_tracks = items.length ();
         this.set_track ();
@@ -76,4 +84,21 @@ internal class Rygel.PlaylistHandler : GLib.Object {
             });
         }
     }
+
+    private void on_setting_changed (string section, string key) {
+        if (section != CONFIG_SECTION && key != TIMEOUT_KEY) {
+            return;
+        }
+
+        try {
+            this.default_image_timeout = config.get_int (CONFIG_SECTION,
+                                                         TIMEOUT_KEY,
+                                                         0,
+                                                         int.MAX);
+        } catch (Error error) {
+            this.default_image_timeout = DEFAULT_IMAGE_TIMEOUT;
+        }
+
+        debug ("New image timeout: %lu", this.default_image_timeout);
+    }
 }



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