|
a/src/renderctl.cxx |
|
b/src/renderctl.cxx |
|
... |
|
... |
27 |
#include <unordered_map> // for unordered_map, etc
|
27 |
#include <unordered_map> // for unordered_map, etc
|
28 |
#include <utility> // for pair
|
28 |
#include <utility> // for pair
|
29 |
#include <vector> // for vector
|
29 |
#include <vector> // for vector
|
30 |
|
30 |
|
31 |
#include "libupnpp/log.hxx" // for LOGDEB
|
31 |
#include "libupnpp/log.hxx" // for LOGDEB
|
32 |
#include "libupnpp/soaphelp.hxx" // for SoapArgs, SoapData, i2s, etc
|
32 |
#include "libupnpp/soaphelp.hxx" // for SoapIncoming, SoapOutgoing, i2s, etc
|
33 |
|
33 |
|
34 |
#include "mpdcli.hxx" // for MPDCli, MpdStatus
|
34 |
#include "mpdcli.hxx" // for MPDCli, MpdStatus
|
35 |
#include "upmpd.hxx" // for UpMpd
|
35 |
#include "upmpd.hxx" // for UpMpd
|
36 |
#include "upmpdutils.hxx" // for dbvaluetopercent, mapget, etc
|
36 |
#include "upmpdutils.hxx" // for dbvaluetopercent, mapget, etc
|
37 |
|
37 |
|
|
... |
|
... |
156 |
// in the service description must be included, in the same order as
|
156 |
// in the service description must be included, in the same order as
|
157 |
// specified in the service description (SCPD) available from the
|
157 |
// specified in the service description (SCPD) available from the
|
158 |
// device.
|
158 |
// device.
|
159 |
|
159 |
|
160 |
#if 0
|
160 |
#if 0
|
161 |
int UpMpdRenderCtl::getVolumeDBRange(const SoapArgs& sc, SoapData& data)
|
161 |
int UpMpdRenderCtl::getVolumeDBRange(const SoapIncoming& sc, SoapOutgoing& data)
|
162 |
{
|
162 |
{
|
163 |
map<string, string>::const_iterator it;
|
163 |
string channel;
|
164 |
|
164 |
|
165 |
it = sc.args.find("Channel");
|
165 |
if (!sc.get("Channel", &channel) || channel.compare("Master")) {
|
166 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
|
|
167 |
return UPNP_E_INVALID_PARAM;
|
166 |
return UPNP_E_INVALID_PARAM;
|
168 |
}
|
167 |
}
|
169 |
data.addarg("MinValue", "-10240");
|
168 |
data.addarg("MinValue", "-10240");
|
170 |
data.addarg("MaxValue", "0");
|
169 |
data.addarg("MaxValue", "0");
|
171 |
|
170 |
|
|
... |
|
... |
207 |
// Restore pre-mute
|
206 |
// Restore pre-mute
|
208 |
m_dev->m_mpdcli->setVolume(1, true);
|
207 |
m_dev->m_mpdcli->setVolume(1, true);
|
209 |
}
|
208 |
}
|
210 |
}
|
209 |
}
|
211 |
|
210 |
|
212 |
int UpMpdRenderCtl::setMute(const SoapArgs& sc, SoapData& data)
|
211 |
int UpMpdRenderCtl::setMute(const SoapIncoming& sc, SoapOutgoing& data)
|
213 |
{
|
212 |
{
|
214 |
map<string, string>::const_iterator it;
|
213 |
string channel;
|
215 |
|
214 |
if (!sc.get("Channel", &channel) || channel.compare("Master")) {
|
216 |
it = sc.args.find("Channel");
|
|
|
217 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
|
|
218 |
return UPNP_E_INVALID_PARAM;
|
215 |
return UPNP_E_INVALID_PARAM;
|
219 |
}
|
216 |
}
|
220 |
|
217 |
string desired;
|
221 |
it = sc.args.find("DesiredMute");
|
218 |
if (!sc.get("DesiredMute", &desired)) {
|
222 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
223 |
return UPNP_E_INVALID_PARAM;
|
219 |
return UPNP_E_INVALID_PARAM;
|
224 |
}
|
220 |
}
|
225 |
if (it->second[0] == 'F' || it->second[0] == '0') {
|
221 |
if (desired[0] == 'F' || desired[0] == '0') {
|
226 |
setmute_i(false);
|
222 |
setmute_i(false);
|
227 |
} else if (it->second[0] == 'T' || it->second[0] == '1') {
|
223 |
} else if (desired[0] == 'T' || desired[0] == '1') {
|
228 |
setmute_i(true);
|
224 |
setmute_i(true);
|
229 |
} else {
|
225 |
} else {
|
230 |
return UPNP_E_INVALID_PARAM;
|
226 |
return UPNP_E_INVALID_PARAM;
|
231 |
}
|
227 |
}
|
232 |
m_dev->loopWakeup();
|
228 |
m_dev->loopWakeup();
|
233 |
return UPNP_E_SUCCESS;
|
229 |
return UPNP_E_SUCCESS;
|
234 |
}
|
230 |
}
|
235 |
|
231 |
|
236 |
int UpMpdRenderCtl::getMute(const SoapArgs& sc, SoapData& data)
|
232 |
int UpMpdRenderCtl::getMute(const SoapIncoming& sc, SoapOutgoing& data)
|
237 |
{
|
233 |
{
|
238 |
map<string, string>::const_iterator it;
|
234 |
string channel;
|
239 |
|
235 |
if (!sc.get("Channel", &channel) || channel.compare("Master")) {
|
240 |
it = sc.args.find("Channel");
|
|
|
241 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
|
|
242 |
return UPNP_E_INVALID_PARAM;
|
236 |
return UPNP_E_INVALID_PARAM;
|
243 |
}
|
237 |
}
|
|
|
238 |
|
244 |
int volume = m_dev->m_mpdcli->getVolume();
|
239 |
int volume = m_dev->m_mpdcli->getVolume();
|
245 |
data.addarg("CurrentMute", volume == 0 ? "1" : "0");
|
240 |
data.addarg("CurrentMute", volume == 0 ? "1" : "0");
|
246 |
return UPNP_E_SUCCESS;
|
241 |
return UPNP_E_SUCCESS;
|
247 |
}
|
242 |
}
|
248 |
|
243 |
|
249 |
int UpMpdRenderCtl::setVolume(const SoapArgs& sc, SoapData& data, bool isDb)
|
244 |
int UpMpdRenderCtl::setVolume(const SoapIncoming& sc, SoapOutgoing& data, bool isDb)
|
250 |
{
|
245 |
{
|
251 |
map<string, string>::const_iterator it;
|
246 |
string channel;
|
252 |
|
247 |
if (!sc.get("Channel", &channel) || channel.compare("Master")) {
|
253 |
it = sc.args.find("Channel");
|
|
|
254 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
|
|
255 |
return UPNP_E_INVALID_PARAM;
|
248 |
return UPNP_E_INVALID_PARAM;
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
string desired;
|
256 |
}
|
252 |
|
257 |
|
253 |
if (!sc.get("DesiredVolume", &desired)) {
|
258 |
it = sc.args.find("DesiredVolume");
|
|
|
259 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
260 |
return UPNP_E_INVALID_PARAM;
|
254 |
return UPNP_E_INVALID_PARAM;
|
261 |
}
|
255 |
}
|
262 |
int volume = atoi(it->second.c_str());
|
256 |
int volume = atoi(desired.c_str());
|
263 |
if (isDb) {
|
257 |
if (isDb) {
|
264 |
volume = dbvaluetopercent(volume);
|
258 |
volume = dbvaluetopercent(volume);
|
265 |
}
|
259 |
}
|
266 |
if (volume < 0 || volume > 100) {
|
260 |
if (volume < 0 || volume > 100) {
|
267 |
return UPNP_E_INVALID_PARAM;
|
261 |
return UPNP_E_INVALID_PARAM;
|
|
... |
|
... |
271 |
|
265 |
|
272 |
m_dev->loopWakeup();
|
266 |
m_dev->loopWakeup();
|
273 |
return UPNP_E_SUCCESS;
|
267 |
return UPNP_E_SUCCESS;
|
274 |
}
|
268 |
}
|
275 |
|
269 |
|
276 |
int UpMpdRenderCtl::getVolume(const SoapArgs& sc, SoapData& data, bool isDb)
|
270 |
int UpMpdRenderCtl::getVolume(const SoapIncoming& sc, SoapOutgoing& data, bool isDb)
|
277 |
{
|
271 |
{
|
278 |
// LOGDEB("UpMpdRenderCtl::getVolume" << endl);
|
272 |
// LOGDEB("UpMpdRenderCtl::getVolume" << endl);
|
279 |
map<string, string>::const_iterator it;
|
273 |
string channel;
|
280 |
|
274 |
if (!sc.get("Channel", &channel) || channel.compare("Master")) {
|
281 |
it = sc.args.find("Channel");
|
|
|
282 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
|
|
283 |
return UPNP_E_INVALID_PARAM;
|
275 |
return UPNP_E_INVALID_PARAM;
|
284 |
}
|
276 |
}
|
285 |
|
277 |
|
286 |
int volume = getvolume_i();
|
278 |
int volume = getvolume_i();
|
287 |
if (isDb) {
|
279 |
if (isDb) {
|
288 |
volume = percentodbvalue(volume);
|
280 |
volume = percentodbvalue(volume);
|
289 |
}
|
281 |
}
|
290 |
data.addarg("CurrentVolume", SoapHelp::i2s(volume));
|
282 |
data.addarg("CurrentVolume", SoapHelp::i2s(volume));
|
291 |
return UPNP_E_SUCCESS;
|
283 |
return UPNP_E_SUCCESS;
|
292 |
}
|
284 |
}
|
293 |
|
285 |
|
294 |
int UpMpdRenderCtl::listPresets(const SoapArgs& sc, SoapData& data)
|
286 |
int UpMpdRenderCtl::listPresets(const SoapIncoming& sc, SoapOutgoing& data)
|
295 |
{
|
287 |
{
|
296 |
// The 2nd arg is a comma-separated list of preset names
|
288 |
// The 2nd arg is a comma-separated list of preset names
|
297 |
data.addarg("CurrentPresetNameList", "FactoryDefaults");
|
289 |
data.addarg("CurrentPresetNameList", "FactoryDefaults");
|
298 |
return UPNP_E_SUCCESS;
|
290 |
return UPNP_E_SUCCESS;
|
299 |
}
|
291 |
}
|
300 |
|
292 |
|
301 |
int UpMpdRenderCtl::selectPreset(const SoapArgs& sc, SoapData& data)
|
293 |
int UpMpdRenderCtl::selectPreset(const SoapIncoming& sc, SoapOutgoing& data)
|
302 |
{
|
294 |
{
|
303 |
map<string, string>::const_iterator it;
|
295 |
string presetnm;
|
304 |
|
|
|
305 |
it = sc.args.find("PresetName");
|
|
|
306 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
307 |
return UPNP_E_INVALID_PARAM;
|
|
|
308 |
}
|
296 |
|
|
|
297 |
if (!sc.get("PresetName", &presetnm)) {
|
|
|
298 |
return UPNP_E_INVALID_PARAM;
|
|
|
299 |
}
|
309 |
if (it->second.compare("FactoryDefaults")) {
|
300 |
if (presetnm.compare("FactoryDefaults")) {
|
310 |
return UPNP_E_INVALID_PARAM;
|
301 |
return UPNP_E_INVALID_PARAM;
|
311 |
}
|
302 |
}
|
312 |
|
303 |
|
313 |
// Well there is only the volume actually...
|
304 |
// Well there is only the volume actually...
|
314 |
int volume = 50;
|
305 |
int volume = 50;
|