From 7ae856e2e05041022b87abaa076901d8dce7bed6 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Sun, 1 Aug 2010 01:50:23 +0300 Subject: [PATCH] core,gst-renderer: Core provides base RenderingControl Core should provide base abstract class for RenderingControl implementations. --- .../gst-renderer/rygel-gst-renderer-plugin.vala | 6 +- .../rygel-gst-renderer-rendering-control.vala | 223 +-------------------- src/rygel/Makefile.am | 1 + 3 files changed, 8 insertions(+), 222 deletions(-) diff --git a/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala b/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala index 973d500..c1eddba 100644 --- a/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala +++ b/src/plugins/gst-renderer/rygel-gst-renderer-plugin.vala @@ -45,9 +45,9 @@ public void module_init (PluginLoader loader) { typeof (GstRenderer.AVTransport)); plugin.add_resource (resource); - resource = new ResourceInfo (GstRenderer.RenderingControl.UPNP_ID, - GstRenderer.RenderingControl.UPNP_TYPE, - GstRenderer.RenderingControl.DESCRIPTION_PATH, + resource = new ResourceInfo (RenderingControl.UPNP_ID, + RenderingControl.UPNP_TYPE, + RenderingControl.DESCRIPTION_PATH, typeof (GstRenderer.RenderingControl)); plugin.add_resource (resource); diff --git a/src/plugins/gst-renderer/rygel-gst-renderer-rendering-control.vala b/src/plugins/gst-renderer/rygel-gst-renderer-rendering-control.vala index 4bafe18..3ce93b4 100644 --- a/src/plugins/gst-renderer/rygel-gst-renderer-rendering-control.vala +++ b/src/plugins/gst-renderer/rygel-gst-renderer-rendering-control.vala @@ -1,8 +1,6 @@ /* - * Copyright (C) 2008 OpenedHand Ltd. - * Copyright (C) 2009 Nokia Corporation. + * Copyright (C) 2010 Nokia Corporation. * - * Author: Jorn Baayen * Zeeshan Ali (Khattak) * * @@ -20,221 +18,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -using GUPnP; -using Rygel; - -public class Rygel.GstRenderer.RenderingControl : Service { - public const string UPNP_ID = "urn:upnp-org:serviceId:RenderingControl"; - public const string UPNP_TYPE = - "urn:schemas-upnp-org:service:RenderingControl:2"; - public const string DESCRIPTION_PATH = "xml/RenderingControl2.xml"; - public const string LAST_CHANGE_NS = - "urn:schemas-upnp-org:metadata-1-0/RCS/"; - - private bool _mute = false; - public bool mute { - get { - return this._mute; - } - - set { - this._mute = value; - - if (this._mute) { - this.player.volume = 0; - } else { - this.player.volume = Volume.from_percentage (this.volume); - } - - this.changelog.log_with_channel ("Mute", - this.mute ? "1" : "0", - "Master"); - } - } - - private uint _volume = 0; - public uint volume { - get { - return this._volume; - } - - set { - this._volume = value; - - if (!this.mute) { - this.player.volume = Volume.from_percentage (this.volume); - } - - this.changelog.log_with_channel ("Volume", - this.volume.to_string (), - "Master"); - } - } - - private string preset_name_list = ""; - - private ChangeLog changelog; - private Player player; - - public override void constructed () { - this.changelog = new ChangeLog (this, LAST_CHANGE_NS); - this.player = Player.get_default (); - - query_variable["LastChange"].connect (this.query_last_change_cb); - - action_invoked["ListPresets"].connect (this.list_presets_cb); - action_invoked["SelectPreset"].connect (this.select_preset_cb); - action_invoked["GetMute"].connect (this.get_mute_cb); - action_invoked["SetMute"].connect (this.set_mute_cb); - action_invoked["GetVolume"].connect (this.get_volume_cb); - action_invoked["SetVolume"].connect (this.set_volume_cb); - - this._volume = Volume.to_percentage (this.player.volume); - } - - private void query_last_change_cb (Service service, - string variable, - ref GLib.Value value) { - // Send current state - var log = new ChangeLog (null, LAST_CHANGE_NS); - - log.log_with_channel ("Mute", this.mute ? "1" : "0", "Master"); - log.log_with_channel ("Volume", this.volume.to_string (), "Master"); - - value.init (typeof (string)); - value.set_string (log.finish ()); - } - - // Error out if InstanceID is not 0 - private bool check_instance_id (ServiceAction action) { - uint instance_id; - - action.get ("InstanceID", typeof (uint), out instance_id); - if (instance_id != 0) { - action.return_error (702, _("Invalid InstanceID")); - - return false; - } - - return true; - } - - private void list_presets_cb (Service service, - owned ServiceAction action) { - if (!this.check_instance_id (action)) { - return; - } - - action.set ("CurrentPresetNameList", - typeof (string), - this.preset_name_list); - - action.return (); - } - - private void select_preset_cb (Service service, - owned ServiceAction action) { - if (!this.check_instance_id (action)) { - return; - } - - string preset_name; - - action.get ("PresetName", typeof (string), out preset_name); - if (preset_name != "") { - action.return_error (701, _("Invalid Name")); - - return; - } - - action.return (); - } - - // Error out if 'Channel' is not 'Master' - private bool check_channel (ServiceAction action) { - string channel; - - action.get ("Channel", typeof (string), out channel); - if (channel != "Master") { - action.return_error (501, _("Action Failed")); - - return false; - } - - return true; - } - - private void get_mute_cb (Service service, - owned ServiceAction action) { - if (!this.check_instance_id (action)) { - return; - } - - if (!check_channel (action)) { - return; - } - - action.set ("CurrentMute", typeof (bool), this.mute); - - action.return (); - } - - private void set_mute_cb (Service service, - owned ServiceAction action) { - if (!this.check_instance_id (action)) { - return; - } - - if (!check_channel (action)) { - return; - } - - bool mute; - - action.get ("DesiredMute", typeof (bool), out mute); - - this.mute = mute; - - action.return (); - } - - private void get_volume_cb (Service service, - owned ServiceAction action) { - if (!this.check_instance_id (action)) { - return; - } - - if (!check_channel (action)) { - return; - } - - action.set ("CurrentVolume", typeof (uint), this.volume); - - action.return (); - } - - private void set_volume_cb (Service service, - owned ServiceAction action) { - if (!this.check_instance_id (action)) { - return; - } - - if (!check_channel (action)) { - return; - } - - uint volume; - - action.get ("DesiredVolume", typeof (uint), out volume); - if (volume > 100) { - action.return_error (501, _("Action Failed")); - - return; - } - - this.volume = volume; - - action.return (); +public class Rygel.GstRenderer.RenderingControl : Rygel.RenderingControl { + public override Rygel.Player? create_player () { + return GstRenderer.Player.get_default (); } } diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am index c47f88c..ddaa44c 100644 --- a/src/rygel/Makefile.am +++ b/src/rygel/Makefile.am @@ -53,6 +53,7 @@ VAPI_SOURCE_FILES = rygel-configuration.vala \ rygel-connection-manager.vala \ rygel-source-connection-manager.vala \ rygel-av-transport.vala \ + rygel-rendering-control.vala \ rygel-transcode-manager.vala \ rygel-http-server.vala \ rygel-state-machine.vala \ -- 2.7.4