[rygel] renderer: Implement SetPlayMode



commit 55570f32b618dd670cbe4776b607e52ebb73d0e2
Author: Richard Röjfors <richard rojfors gmail com>
Date:   Sun Sep 28 13:27:51 2014 +0200

    renderer: Implement SetPlayMode
    
    Add an implementation of SetPlayMode, a method is added on the
    player controller interface to validate if the new play mode is
    valid or not. If it is the play_mode property of the controller
    gets the new mode assigned.
    
    Signed-off-by: Richard Röjfors <richard rojfors gmail com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737522

 data/xml/AVTransport2.xml.in                       |   20 +++++++++++++++++
 src/librygel-renderer/rygel-av-transport.vala      |   23 ++++++++++++++++++++
 .../rygel-default-player-controller.vala           |    4 +++
 src/librygel-renderer/rygel-player-controller.vala |    2 +
 4 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/data/xml/AVTransport2.xml.in b/data/xml/AVTransport2.xml.in
index 56f7b52..05f4981 100644
--- a/data/xml/AVTransport2.xml.in
+++ b/data/xml/AVTransport2.xml.in
@@ -415,6 +415,26 @@
             </argument>
          </argumentList>
       </action>
+
+      <action>
+          <name>SetPlayMode</name>
+          <argumentList>
+              <argument>
+                  <name>InstanceID</name>
+                  <direction>in</direction>
+                  <relatedStateVariable>
+                      A_ARG_TYPE_InstanceID
+                  </relatedStateVariable>
+              </argument>
+              <argument>
+                  <name>NewPlayMode</name>
+                  <direction>in</direction>
+                  <relatedStateVariable>
+                      CurrentPlayMode
+                  </relatedStateVariable>
+              </argument>
+          </argumentList>
+      </action>
    </actionList>
 
    <serviceStateTable>
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index 2036dd6..4d0c4e1 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -113,6 +113,7 @@ internal class Rygel.AVTransport : Service {
         action_invoked["Previous"].connect (this.previous_cb);
         action_invoked["X_DLNA_GetBytePositionInfo"].connect
                                         (this.x_dlna_get_byte_position_info_cb);
+        action_invoked["SetPlayMode"].connect (this.set_play_mode_cb);
 
         this.controller.notify["playback-state"].connect (this.notify_state_cb);
         this.controller.notify["n-tracks"].connect (this.notify_n_tracks_cb);
@@ -624,6 +625,28 @@ internal class Rygel.AVTransport : Service {
         action.return ();
     }
 
+    private void set_play_mode_cb (Service       service,
+                                   ServiceAction action) {
+        if (!this.check_instance_id (action)) {
+            return;
+        }
+
+        string play_mode;
+
+        action.get ("NewPlayMode",
+                        typeof (string),
+                        out play_mode);
+
+        if (!this.controller.is_play_mode_valid(play_mode)) {
+            action.return_error (712, _("Play mode not supported"));
+            return;
+        }
+
+        this.controller.play_mode = play_mode;
+
+        action.return ();
+    }
+
     private void notify_state_cb (Object controller, ParamSpec p) {
         var state = this.controller.playback_state;
         this.changelog.log ("TransportState", state);
diff --git a/src/librygel-renderer/rygel-default-player-controller.vala 
b/src/librygel-renderer/rygel-default-player-controller.vala
index 056436e..02a2994 100644
--- a/src/librygel-renderer/rygel-default-player-controller.vala
+++ b/src/librygel-renderer/rygel-default-player-controller.vala
@@ -358,6 +358,10 @@ internal class Rygel.DefaultPlayerController : Rygel.PlayerController, Object {
         }
     }
 
+    public bool is_play_mode_valid (string play_mode) {
+        return play_mode == "NORMAL";
+    }
+
     private void notify_uri_cb (Object player, ParamSpec p) {
         notify_property ("track-uri");
     }
diff --git a/src/librygel-renderer/rygel-player-controller.vala 
b/src/librygel-renderer/rygel-player-controller.vala
index 491b2bd..8b7044a 100644
--- a/src/librygel-renderer/rygel-player-controller.vala
+++ b/src/librygel-renderer/rygel-player-controller.vala
@@ -84,6 +84,8 @@ public interface Rygel.PlayerController : GLib.Object {
                                        string metadata,
                                        MediaCollection collection);
 
+    public abstract bool is_play_mode_valid (string play_mode);
+
     protected string unescape (string input) {
         var result = input.replace ("&quot;", "\"");
         result = result.replace ("&lt;", "<");


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