[rygel/wip/didl-s: 24/35] renderer: Switch to next playlist item



commit 1211c6a0ea4d6fbc41ff26ca214ca83fe04cbbd6
Author: Jens Georg <jensg openismus com>
Date:   Tue Nov 20 16:22:30 2012 +0100

    renderer: Switch to next playlist item
    
    Add "EOS" state where the player can signalize that it has reached the end of
    the current track.
    
    If the item is an image use the upnp:lifetime setting or default timeout for
    an image inside the playlist handler.

 .../rygel-playbin-player.vala                      |    6 ++++-
 src/librygel-renderer/rygel-av-transport.vala      |   20 +++++++++++++++-
 src/librygel-renderer/rygel-playlist-handler.vala  |   24 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/src/librygel-renderer-gst/rygel-playbin-player.vala b/src/librygel-renderer-gst/rygel-playbin-player.vala
index cca07ba..9a6ad26 100644
--- a/src/librygel-renderer-gst/rygel-playbin-player.vala
+++ b/src/librygel-renderer-gst/rygel-playbin-player.vala
@@ -132,6 +132,9 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
                         this._playback_state = value;
                     }
                 break;
+                case "EOS":
+                    this._playback_state = value;
+                break;
                 default:
                 break;
             }
@@ -163,6 +166,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
                         this.is_live = this.playbin.set_state (State.PAUSED)
                                         == StateChangeReturn.NO_PREROLL;
                         break;
+                    case "EOS":
                     case "PLAYING":
                         // This needs a check if GStreamer and DLNA agree on
                         // the "liveness" of the source (s0/sn increase in
@@ -397,7 +401,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
         case MessageType.EOS:
             if (!this.is_rendering_image ()) {
                 debug ("EOS");
-                this.playback_state = "STOPPED";
+                this.playback_state = "EOS";
             } else {
                 debug ("Content is image, ignoring EOS");
             }
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index 917062c..06029b5 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -652,7 +652,25 @@ internal class Rygel.AVTransport : Service {
     }
 
     private void notify_state_cb (Object player, ParamSpec p) {
-        this.changelog.log ("TransportState", this.player.playback_state);
+        var state = this.player.playback_state;
+        if (state == "EOS") {
+            if (this.playlist_handler == null) {
+                // Just move to stop
+                Idle.add (() => {
+                    this.player.playback_state = "STOPPED";
+
+                    return false;
+                });
+
+                return;
+            } else {
+                debug ("=> Setting next playlist item");
+                // Get next playlist item
+                this.playlist_handler.next ();
+            }
+        } else {
+            this.changelog.log ("TransportState", state);
+        }
     }
 
     private void notify_duration_cb (Object player, ParamSpec p) {
diff --git a/src/librygel-renderer/rygel-playlist-handler.vala b/src/librygel-renderer/rygel-playlist-handler.vala
index 23dedcb..7f57463 100644
--- a/src/librygel-renderer/rygel-playlist-handler.vala
+++ b/src/librygel-renderer/rygel-playlist-handler.vala
@@ -8,6 +8,7 @@ internal class Rygel.PlaylistHandler : GLib.Object {
     public uint current_track { construct set; get; default = 1; }
 
     private List<DIDLLiteItem> items;
+    private uint timeout_id;
 
     public PlaylistHandler (MediaCollection collection,
                             AVTransport     transport) {
@@ -51,5 +52,28 @@ internal class Rygel.PlaylistHandler : GLib.Object {
         this.transport.track = this.current_track;
         this.transport.track_uri = res.get_uri ();
         debug ("Trying to set track uri to %s", res.get_uri ());
+
+        // For images, we handle the timeout here. Either the item carries a
+        // dlna:lifetime tag, then we use that or we use a default timeout of
+        // 5 minutes.
+        if (item.upnp_class.has_prefix ("object.item.image")) {
+            var timeout = item.lifetime;
+            if (timeout < 0) {
+                timeout = DEFAULT_IMAGE_TIMEOUT;
+            }
+
+            debug ("Item is image, setup timer: %ld", timeout);
+
+            if (this.timeout_id != 0) {
+                Source.remove (this.timeout_id);
+            }
+
+            this.timeout_id = Timeout.add_seconds ((uint) timeout, () => {
+                this.timeout_id = 0;
+                this.next ();
+
+                return false;
+            });
+        }
     }
 }



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