|
a/libupnpp/device.cxx |
|
b/libupnpp/device.cxx |
|
... |
|
... |
170 |
struct Upnp_Action_Request *act = (struct Upnp_Action_Request *)evp;
|
170 |
struct Upnp_Action_Request *act = (struct Upnp_Action_Request *)evp;
|
171 |
LOGDEB("UPNP_CONTROL_ACTION_REQUEST: " << act->ActionName <<
|
171 |
LOGDEB("UPNP_CONTROL_ACTION_REQUEST: " << act->ActionName <<
|
172 |
". Params: " << ixmlPrintDocument(act->ActionRequest) << endl);
|
172 |
". Params: " << ixmlPrintDocument(act->ActionRequest) << endl);
|
173 |
|
173 |
|
174 |
unordered_map<string, UpnpService*>::const_iterator servit =
|
174 |
unordered_map<string, UpnpService*>::const_iterator servit =
|
175 |
m_services.find(act->ServiceID);
|
175 |
m_servicemap.find(act->ServiceID);
|
176 |
if (servit == m_services.end()) {
|
176 |
if (servit == m_servicemap.end()) {
|
177 |
LOGERR("Bad serviceID" << endl);
|
177 |
LOGERR("Bad serviceID" << endl);
|
178 |
return UPNP_E_INVALID_PARAM;
|
178 |
return UPNP_E_INVALID_PARAM;
|
179 |
}
|
179 |
}
|
180 |
const string& servicetype = servit->second->getServiceType();
|
180 |
const string& servicetype = servit->second->getServiceType();
|
181 |
|
181 |
|
|
... |
|
... |
226 |
struct Upnp_Subscription_Request *act =
|
226 |
struct Upnp_Subscription_Request *act =
|
227 |
(struct Upnp_Subscription_Request*)evp;
|
227 |
(struct Upnp_Subscription_Request*)evp;
|
228 |
LOGDEB("UPNP_EVENT_SUBSCRIPTION_REQUEST: " << act->ServiceId << endl);
|
228 |
LOGDEB("UPNP_EVENT_SUBSCRIPTION_REQUEST: " << act->ServiceId << endl);
|
229 |
|
229 |
|
230 |
unordered_map<string, UpnpService*>::const_iterator servit =
|
230 |
unordered_map<string, UpnpService*>::const_iterator servit =
|
231 |
m_services.find(act->ServiceId);
|
231 |
m_servicemap.find(act->ServiceId);
|
232 |
if (servit == m_services.end()) {
|
232 |
if (servit == m_servicemap.end()) {
|
233 |
LOGERR("Bad serviceID" << endl);
|
233 |
LOGERR("Bad serviceID" << endl);
|
234 |
return UPNP_E_INVALID_PARAM;
|
234 |
return UPNP_E_INVALID_PARAM;
|
235 |
}
|
235 |
}
|
236 |
|
236 |
|
237 |
vector<string> names, values, qvalues;
|
237 |
vector<string> names, values, qvalues;
|
|
... |
|
... |
261 |
return UPNP_E_INVALID_PARAM;
|
261 |
return UPNP_E_INVALID_PARAM;
|
262 |
}
|
262 |
}
|
263 |
|
263 |
|
264 |
void UpnpDevice::addService(UpnpService *serv, const std::string& serviceId)
|
264 |
void UpnpDevice::addService(UpnpService *serv, const std::string& serviceId)
|
265 |
{
|
265 |
{
|
266 |
m_services[serviceId] = serv;
|
266 |
m_servicemap[serviceId] = serv;
|
|
|
267 |
m_serviceids.push_back(serviceId);
|
267 |
}
|
268 |
}
|
268 |
|
269 |
|
269 |
void UpnpDevice::addActionMapping(const std::string& actName, soapfun fun)
|
270 |
void UpnpDevice::addActionMapping(const std::string& actName, soapfun fun)
|
270 |
{
|
271 |
{
|
271 |
// LOGDEB("UpnpDevice::addActionMapping:" << actName << endl);
|
272 |
// LOGDEB("UpnpDevice::addActionMapping:" << actName << endl);
|
|
... |
|
... |
327 |
// only if changed data exists. Every 3 S we generate an artificial
|
328 |
// only if changed data exists. Every 3 S we generate an artificial
|
328 |
// event with all the current state.
|
329 |
// event with all the current state.
|
329 |
void UpnpDevice::eventloop()
|
330 |
void UpnpDevice::eventloop()
|
330 |
{
|
331 |
{
|
331 |
int count = 0;
|
332 |
int count = 0;
|
332 |
const int loopwait_ms = 1000; // Polling mpd every 1 S
|
333 |
const int loopwait_ms = 1000; // Polling the services every 1 S
|
333 |
const int nloopstofull = 10; // Full state every 10 S
|
334 |
const int nloopstofull = 10; // Full state every 10 S
|
334 |
struct timespec wkuptime, earlytime;
|
335 |
struct timespec wkuptime, earlytime;
|
335 |
bool didearly = false;
|
336 |
bool didearly = false;
|
336 |
|
337 |
|
337 |
for (;;) {
|
338 |
for (;;) {
|
|
... |
|
... |
376 |
|
377 |
|
377 |
count++;
|
378 |
count++;
|
378 |
bool all = count && ((count % nloopstofull) == 0);
|
379 |
bool all = count && ((count % nloopstofull) == 0);
|
379 |
//LOGDEB("UpnpDevice::eventloop count "<<count<<" all "<<all<<endl);
|
380 |
//LOGDEB("UpnpDevice::eventloop count "<<count<<" all "<<all<<endl);
|
380 |
|
381 |
|
381 |
for (unordered_map<string, UpnpService*>::const_iterator it =
|
382 |
for (vector<string>::const_iterator it =
|
382 |
m_services.begin(); it != m_services.end(); it++) {
|
383 |
m_serviceids.begin(); it != m_serviceids.end(); it++) {
|
383 |
vector<string> names, values;
|
384 |
vector<string> names, values;
|
|
|
385 |
UpnpService* serv = m_servicemap[*it];
|
384 |
if (!it->second->getEventData(all, names, values) ||
|
386 |
if (!serv->getEventData(all, names, values) || names.empty()) {
|
385 |
names.empty()) {
|
|
|
386 |
continue;
|
387 |
continue;
|
387 |
}
|
388 |
}
|
388 |
notifyEvent(it->first, names, values);
|
389 |
notifyEvent(*it, names, values);
|
389 |
}
|
390 |
}
|
390 |
}
|
391 |
}
|
391 |
}
|
392 |
}
|
392 |
|
393 |
|
393 |
void UpnpDevice::loopWakeup()
|
394 |
void UpnpDevice::loopWakeup()
|