summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Röjfors <richard.rojfors@gmail.com>2014-09-28 13:27:51 +0200
committerJens Georg <mail@jensge.org>2014-11-09 15:23:45 +0100
commit55570f32b618dd670cbe4776b607e52ebb73d0e2 (patch)
tree3f719eb0301604337fedfce2ccfbac13756f7477
parentd4d6305d6b665646b7653379a3d6b7d5e3a42dfd (diff)
downloadrygel-55570f32b618dd670cbe4776b607e52ebb73d0e2.tar.gz
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
-rw-r--r--data/xml/AVTransport2.xml.in20
-rw-r--r--src/librygel-renderer/rygel-av-transport.vala23
-rw-r--r--src/librygel-renderer/rygel-default-player-controller.vala4
-rw-r--r--src/librygel-renderer/rygel-player-controller.vala2
4 files changed, 49 insertions, 0 deletions
diff --git a/data/xml/AVTransport2.xml.in b/data/xml/AVTransport2.xml.in
index 56f7b529..05f4981a 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 2036dd67..4d0c4e1f 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 056436e7..02a29941 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 491b2bdc..8b7044a9 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;", "<");