libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
renderingcontrol.hxx
1 /* Copyright (C) 2006-2016 J.F.Dockes
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301 USA
17  */
18 #ifndef _RENDERINGCONTROL_HXX_INCLUDED_
19 #define _RENDERINGCONTROL_HXX_INCLUDED_
20 
21 #include "libupnpp/config.h"
22 
23 #include <string>
24 
25 #include "service.hxx"
26 
27 
28 namespace UPnPClient {
29 
30 class RenderingControl;
31 class UPnPDeviceDesc;
32 class UPnPServiceDesc;
33 
34 typedef std::shared_ptr<RenderingControl> RDCH;
35 
40 class RenderingControl : public Service {
41 public:
42 
44  RenderingControl(const UPnPDeviceDesc& device,
45  const UPnPServiceDesc& service);
46 
47  RenderingControl() {}
48  virtual ~RenderingControl() {}
49 
51  static bool isRDCService(const std::string& st);
52  virtual bool serviceTypeMatch(const std::string& tp);
53 
55  int setVolume(int volume, const std::string& channel = "Master");
56  int getVolume(const std::string& channel = "Master");
57  int setMute(bool mute, const std::string& channel = "Master");
58  bool getMute(const std::string& channel = "Master");
59 
60 protected:
61  virtual bool serviceInit(const UPnPDeviceDesc& device,
62  const UPnPServiceDesc& service);
63 
64  /* My service type string */
65  static const std::string SType;
66 
67  /* Volume settings params */
68  int m_volmin{0};
69  int m_volmax{100};
70  int m_volstep{1};
71 
72 private:
73  void evtCallback(const std::unordered_map<std::string, std::string>&);
74  void registerCallback();
76  void setVolParams(int min, int max, int step);
77  int devVolTo0100(int);
78 };
79 
80 } // namespace UPnPClient
81 
82 #endif /* _RENDERINGCONTROL_HXX_INCLUDED_ */
Definition: service.hxx:73
static bool isRDCService(const std::string &st)
Test service type from discovery message.
Definition: renderingcontrol.cxx:47
int setVolume(int volume, const std::string &channel="Master")
Definition: renderingcontrol.cxx:149
virtual bool serviceTypeMatch(const std::string &tp)
Perform a comparison to the service type string for this specific service.
Definition: renderingcontrol.cxx:53
Data holder for a UPnP service, parsed from the device XML description.
Definition: description.hxx:46
RenderingControl Service client class.
Definition: renderingcontrol.hxx:40
Data holder for a UPnP device, parsed from the XML description obtained during discovery.
Definition: description.hxx:142
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition: avlastchg.cxx:28
virtual bool serviceInit(const UPnPDeviceDesc &device, const UPnPServiceDesc &service)
Service-specific part of initialization.
Definition: renderingcontrol.cxx:66