1 From 4a35702414b4c3be06d24b5b5c5da86c3f058078 Mon Sep 17 00:00:00 2001
2 From: montellese <montellese@xbmc.org>
3 Date: Sat, 8 Feb 2014 11:46:11 +0100
4 Subject: [PATCH 06/11] platinum: implement GetSearchCapabilities in media
8 .../Source/Devices/MediaServer/PltMediaBrowser.cpp | 58 ++++++++++++++++++++++
9 .../Source/Devices/MediaServer/PltMediaBrowser.h | 14 ++++++
10 .../Devices/MediaServer/PltSyncMediaBrowser.cpp | 55 ++++++++++++++++++++
11 .../Devices/MediaServer/PltSyncMediaBrowser.h | 15 ++++++
12 4 files changed, 142 insertions(+)
14 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.cpp
15 index 266397d..46b6f41 100644
16 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.cpp
17 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.cpp
18 @@ -305,6 +305,33 @@ PLT_MediaBrowser::Browse(PLT_DeviceDataReference& device,
21 /*----------------------------------------------------------------------
22 +| PLT_MediaBrowser::GetSearchCapabilities
23 ++---------------------------------------------------------------------*/
25 +PLT_MediaBrowser::GetSearchCapabilities(PLT_DeviceDataReference& device,
28 + // verify device still in our list
29 + PLT_DeviceDataReference device_data;
30 + NPT_CHECK_WARNING(FindServer(device->GetUUID(), device_data));
33 + PLT_ActionReference action;
34 + NPT_CHECK_SEVERE(m_CtrlPoint->CreateAction(
36 + "urn:schemas-upnp-org:service:ContentDirectory:1",
37 + "GetSearchCapabilities",
40 + // invoke the action
41 + if (NPT_FAILED(m_CtrlPoint->InvokeAction(action, userdata))) {
42 + return NPT_ERROR_INVALID_PARAMETERS;
48 +/*----------------------------------------------------------------------
49 | PLT_MediaBrowser::OnActionResponse
50 +---------------------------------------------------------------------*/
52 @@ -322,6 +349,8 @@ PLT_MediaBrowser::OnActionResponse(NPT_Result res,
53 return OnBrowseResponse(res, device, action, userdata);
54 } else if (actionName.Compare("Search", true) == 0) {
55 return OnSearchResponse(res, device, action, userdata);
56 + } else if (actionName.Compare("GetSearchCapabilities", true) == 0) {
57 + return OnGetSearchCapabilitiesResponse(res, device, action, userdata);
61 @@ -436,6 +465,35 @@ bad_action:
64 /*----------------------------------------------------------------------
65 +| PLT_MediaBrowser::OnGetSearchCapabilitiesResponse
66 ++---------------------------------------------------------------------*/
68 +PLT_MediaBrowser::OnGetSearchCapabilitiesResponse(NPT_Result res,
69 + PLT_DeviceDataReference& device,
70 + PLT_ActionReference& action,
75 + if (!m_Delegate) return NPT_SUCCESS;
77 + if (NPT_FAILED(res) || action->GetErrorCode() != 0) {
81 + if (NPT_FAILED(action->GetArgumentValue("SearchCaps", value))) {
85 + m_Delegate->OnGetSearchCapabilitiesResult(NPT_SUCCESS, device, value, userdata);
89 + m_Delegate->OnGetSearchCapabilitiesResult(NPT_FAILURE, device, value, userdata);
93 +/*----------------------------------------------------------------------
94 | PLT_MediaBrowser::OnEventNotify
95 +---------------------------------------------------------------------*/
97 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.h
98 index 2ee032b..023630d 100644
99 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.h
100 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaBrowser.h
101 @@ -91,6 +91,12 @@ public:
102 PLT_DeviceDataReference& /*device*/,
103 PLT_BrowseInfo* /*info*/,
104 void* /*userdata*/) {}
106 + virtual void OnGetSearchCapabilitiesResult(
107 + NPT_Result /*res*/,
108 + PLT_DeviceDataReference& /*device*/,
109 + NPT_String /*searchCapabilities*/,
110 + void* /*userdata*/) {}
113 /*----------------------------------------------------------------------
114 @@ -124,6 +130,9 @@ public:
115 const char* filter = "dc:date,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:originalTrackNumber,upnp:album,upnp:artist,upnp:author", // explicitely specify res otherwise WMP won't return a URL!
116 void* userdata = NULL);
118 + virtual NPT_Result GetSearchCapabilities(PLT_DeviceDataReference& device,
119 + void* userdata = NULL);
122 virtual const NPT_Lock<PLT_DeviceDataReferenceList>& GetMediaServers() { return m_MediaServers; }
123 virtual NPT_Result FindServer(const char* uuid, PLT_DeviceDataReference& device);
124 @@ -146,6 +155,11 @@ protected:
125 PLT_DeviceDataReference& device,
126 PLT_ActionReference& action,
129 + virtual NPT_Result OnGetSearchCapabilitiesResponse(NPT_Result res,
130 + PLT_DeviceDataReference& device,
131 + PLT_ActionReference& action,
135 PLT_CtrlPointReference m_CtrlPoint;
136 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp
137 index 96e4121..8ae9f72 100644
138 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp
139 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.cpp
140 @@ -169,6 +169,28 @@ PLT_SyncMediaBrowser::OnSearchResult(NPT_Result res,
143 /*----------------------------------------------------------------------
144 +| PLT_SyncMediaBrowser::OnGetSearchCapabilitiesResult
145 ++---------------------------------------------------------------------*/
147 +PLT_SyncMediaBrowser::OnGetSearchCapabilitiesResult(NPT_Result res,
148 + PLT_DeviceDataReference& device,
149 + NPT_String searchCapabilities,
152 + NPT_COMPILER_UNUSED(device);
154 + if (!userdata) return;
156 + PLT_CapabilitiesDataReference* data = (PLT_CapabilitiesDataReference*) userdata;
157 + (*data)->res = res;
158 + if (NPT_SUCCEEDED(res)) {
159 + (*data)->capabilities = searchCapabilities;
161 + (*data)->shared_var.SetValue(1);
165 +/*----------------------------------------------------------------------
166 | PLT_SyncMediaBrowser::OnMSStateVariablesChanged
167 +---------------------------------------------------------------------*/
169 @@ -280,6 +302,39 @@ PLT_SyncMediaBrowser::SearchSync(PLT_BrowseDataReference& browse_data,
172 /*----------------------------------------------------------------------
173 +| PLT_SyncMediaBrowser::GetSearchCapabilitiesSync
174 ++---------------------------------------------------------------------*/
176 +PLT_SyncMediaBrowser::GetSearchCapabilitiesSync(PLT_DeviceDataReference& device,
177 + NPT_String& searchCapabilities)
181 + PLT_CapabilitiesDataReference capabilities_data(new PLT_CapabilitiesData(), true);
182 + capabilities_data->shared_var.SetValue(0);
184 + // send of the GetSearchCapabilities packet. Note that this will
185 + // not block. There is a call to WaitForResponse in order
186 + // to block until the response comes back.
187 + res = PLT_MediaBrowser::GetSearchCapabilities(device,
188 + new PLT_CapabilitiesDataReference(capabilities_data));
189 + NPT_CHECK_SEVERE(res);
191 + res = WaitForResponse(capabilities_data->shared_var);
192 + NPT_CHECK_LABEL_WARNING(res, done);
194 + if (NPT_FAILED(capabilities_data->res)) {
195 + res = capabilities_data->res;
196 + NPT_CHECK_LABEL_WARNING(res, done);
199 + searchCapabilities = capabilities_data->capabilities;
205 +/*----------------------------------------------------------------------
206 | PLT_SyncMediaBrowser::BrowseSync
207 +---------------------------------------------------------------------*/
209 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h
210 index 5ef9f37..7054b72 100644
211 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h
212 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h
213 @@ -61,6 +61,14 @@ typedef struct PLT_BrowseData {
215 typedef NPT_Reference<PLT_BrowseData> PLT_BrowseDataReference;
217 +typedef struct PLT_CapabilitiesData {
218 + NPT_SharedVariable shared_var;
220 + NPT_String capabilities;
221 +} PLT_CapabilitiesData;
223 +typedef NPT_Reference<PLT_CapabilitiesData> PLT_CapabilitiesDataReference;
225 // explicitely specify res otherwise WMP won't return a URL!
226 #define PLT_DEFAULT_FILTER "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution,upnp:episodeCount,upnp:episodeSeason,xbmc:dateadded,xbmc:rating,xbmc:votes,xbmc:artwork"
228 @@ -103,6 +111,10 @@ public:
229 PLT_DeviceDataReference& device,
230 PLT_BrowseInfo* info,
232 + virtual void OnGetSearchCapabilitiesResult(NPT_Result res,
233 + PLT_DeviceDataReference& device,
234 + NPT_String searchCapabilities,
238 void SetContainerListener(PLT_MediaContainerChangesListener* listener) {
239 @@ -122,6 +134,9 @@ public:
241 NPT_Cardinal max_results = 0); // 0 means all
243 + NPT_Result GetSearchCapabilitiesSync(PLT_DeviceDataReference& device,
244 + NPT_String& searchCapabilities);
246 const NPT_Lock<PLT_DeviceMap>& GetMediaServersMap() const { return m_MediaServers; }
247 bool IsCached(const char* uuid, const char* object_id);