Switch to unified view

a/libupnpp/control/mediarenderer.cxx b/libupnpp/control/mediarenderer.cxx
...
...
21
#include <functional>
21
#include <functional>
22
using namespace std;
22
using namespace std;
23
using namespace std::placeholders;
23
using namespace std::placeholders;
24
24
25
#include "libupnpp/discovery.hxx"
25
#include "libupnpp/discovery.hxx"
26
#include "libupnpp/log.hxx"
26
#include "libupnpp/control/mediarenderer.hxx"
27
#include "libupnpp/control/mediarenderer.hxx"
27
#include "libupnpp/control/renderingcontrol.hxx"
28
#include "libupnpp/control/renderingcontrol.hxx"
28
29
29
namespace UPnPClient {
30
namespace UPnPClient {
30
31
...
...
38
    const string::size_type sz(DType.size()-2);
39
    const string::size_type sz(DType.size()-2);
39
    return !DType.compare(0, sz, st, 0, sz);
40
    return !DType.compare(0, sz, st, 0, sz);
40
}
41
}
41
42
42
static bool MDAccum(unordered_map<string, UPnPDeviceDesc>* out,
43
static bool MDAccum(unordered_map<string, UPnPDeviceDesc>* out,
44
                    const string& friendlyName,
43
                    const UPnPDeviceDesc& device, 
45
                    const UPnPDeviceDesc& device, 
44
                    const UPnPServiceDesc& service)
46
                    const UPnPServiceDesc& service)
45
{
47
{
48
    LOGDEB("MDAccum: friendlyname: " << friendlyName << 
49
           " dev friendlyName " << device.friendlyName << endl);
46
    if (RenderingControl::isRDCService(service.serviceType)) {
50
    if (RenderingControl::isRDCService(service.serviceType) &&
51
        (friendlyName.empty() ? true : 
52
         !friendlyName.compare(device.friendlyName))) {
53
        LOGDEB("MDAccum setting " << device.UDN << endl);
47
        (*out)[device.UDN] = device;
54
        (*out)[device.UDN] = device;
48
    }
55
    }
49
    return true;
56
    return true;
50
}
57
}
51
58
52
bool MediaRenderer::getDeviceDescs(vector<UPnPDeviceDesc>& devices)
59
bool MediaRenderer::getDeviceDescs(vector<UPnPDeviceDesc>& devices, 
60
                                   const string& friendlyName)
53
{
61
{
54
    unordered_map<string, UPnPDeviceDesc> mydevs;
62
    unordered_map<string, UPnPDeviceDesc> mydevs;
55
63
56
    UPnPDeviceDirectory::Visitor visitor = bind(MDAccum, &mydevs, _1, _2);
64
    UPnPDeviceDirectory::Visitor visitor = bind(MDAccum, &mydevs, friendlyName,
65
                                                _1, _2);
57
    UPnPDeviceDirectory::getTheDir()->traverse(visitor);
66
    UPnPDeviceDirectory::getTheDir()->traverse(visitor);
58
    for (auto& entry : mydevs)
67
    for (auto& entry : mydevs)
59
        devices.push_back(entry.second);
68
        devices.push_back(entry.second);
60
    return !devices.empty();
69
    return !devices.empty();
61
}
70
}