[rygel] core,playbin: React to external URI changes



commit 5a9db5056a35acf24f081834980c4c7cec64cc84
Author: Jens Georg <mail jensge org>
Date:   Thu Jun 14 10:58:02 2012 +0200

    core,playbin: React to external URI changes
    
    Once on GStreamer 1.0, use "current-uri" property. See
    https://bugzilla.gnome.org/show_bug.cgi?id=676665

 src/plugins/playbin/rygel-playbin-player.vala |   21 ++++++++++++++++++++-
 src/rygel/rygel-av-transport.vala             |   11 ++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/playbin/rygel-playbin-player.vala b/src/plugins/playbin/rygel-playbin-player.vala
index 60919af..a8f1f32 100644
--- a/src/plugins/playbin/rygel-playbin-player.vala
+++ b/src/plugins/playbin/rygel-playbin-player.vala
@@ -120,6 +120,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
 
     private string transfer_mode = null;
 
+    private bool uri_update_hint = false;
     private string? _uri = null;
     public string? uri {
         owned get {
@@ -133,11 +134,15 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
             if (value != "") {
                 switch (this._playback_state) {
                     case "NO_MEDIA_PRESENT":
+                        this.playbin.set_state (State.READY);
                         this._playback_state = "STOPPED";
                         this.notify_property ("playback-state");
                         break;
                     case "STOPPED":
+                        this.playbin.set_state (State.READY);
+                        break;
                     case "PAUSED_PLAYBACK":
+                        this.playbin.set_state (State.PAUSED);
                         break;
                     case "PLAYING":
                         this.playbin.set_state (State.PLAYING);
@@ -247,7 +252,8 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
         this.playbin.auto_flush_bus = false;
         assert (this.playbin != null);
 
-        playbin.source_setup.connect (this.on_source_setup);
+        this.playbin.source_setup.connect (this.on_source_setup);
+        this.playbin.notify["uri"].connect (this.on_uri_notify);
 
         // Bus handler
         var bus = this.playbin.get_bus ();
@@ -303,6 +309,15 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
                                              out pending);
                 if (old_state == State.READY && new_state == State.PAUSED) {
                     this.notify_property ("duration");
+                    if (this.uri_update_hint) {
+                        this.uri_update_hint = false;
+                        string uri = this.playbin.uri;
+                        if (this._uri != uri) {
+                            // uri changed externally
+                            this._uri = this.playbin.uri;
+                            this.notify_property("uri");
+                        }
+                    }
                 }
 
                 debug ("%d %d %d", old_state, new_state, pending);
@@ -363,4 +378,8 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
             source.extra_headers = structure;
         }
     }
+
+    private void on_uri_notify (ParamSpec pspec) {
+        this.uri_update_hint = true;
+    }
 }
diff --git a/src/rygel/rygel-av-transport.vala b/src/rygel/rygel-av-transport.vala
index dac83f5..6d929e2 100644
--- a/src/rygel/rygel-av-transport.vala
+++ b/src/rygel/rygel-av-transport.vala
@@ -1,10 +1,12 @@
 /*
  * Copyright (C) 2008 OpenedHand Ltd.
  * Copyright (C) 2009,2010 Nokia Corporation.
+ * Copyright (C) 2012 Openismus GmbH.
  *
  * Author: Jorn Baayen <jorn openedhand com>
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  *                               <zeeshan ali nokia com>
+ *         Jens Georg <jensg openismus com>
  *
  * 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
@@ -89,9 +91,6 @@ internal class Rygel.AVTransport : Service {
 
         set {
             this.player.uri = value;
-
-            this.changelog.log ("CurrentTrackURI", this.uri);
-            this.changelog.log ("AVTransportURI", this.uri);
         }
     }
 
@@ -162,6 +161,7 @@ internal class Rygel.AVTransport : Service {
 
         this.player.notify["playback-state"].connect (this.notify_state_cb);
         this.player.notify["duration"].connect (this.notify_duration_cb);
+        this.player.notify["uri"].connect (this.notify_uri_cb);
 
         this.session = new SessionAsync ();
     }
@@ -556,4 +556,9 @@ internal class Rygel.AVTransport : Service {
         this.changelog.log ("CurrentMediaDuration",
                             this.player.duration_as_str);
     }
+
+    private void notify_uri_cb (Object player, ParamSpec p) {
+        this.changelog.log ("CurrentTrackURI", this.uri);
+        this.changelog.log ("AVTransportURI", this.uri);
+    }
 }



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