1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
/*****************************************************************
|
| Platinum - Synchronous Media Browser
|
| Copyright (c) 2004-2010, Plutinosoft, LLC.
| All rights reserved.
| http://www.plutinosoft.com
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of the GNU General Public License
| as published by the Free Software Foundation; either version 2
| of the License, or (at your option) any later version.
|
| OEMs, ISVs, VARs and other distributors that combine and
| distribute commercially licensed software with Platinum software
| and do not wish to distribute the source code for the commercially
| licensed software under version 2, or (at your option) any later
| version, of the GNU General Public License (the "GPL") must enter
| into a commercial license agreement with Plutinosoft, LLC.
| licensing@plutinosoft.com
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; see the file LICENSE.txt. If not, write to
| the Free Software Foundation, Inc.,
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
| http://www.gnu.org/licenses/gpl-2.0.html
|
****************************************************************/
/** @file
UPnP AV Media Controller synchronous implementation.
*/
#ifndef _PLT_SYNC_MEDIA_BROWSER_
#define _PLT_SYNC_MEDIA_BROWSER_
/*----------------------------------------------------------------------
| includes
+---------------------------------------------------------------------*/
#include "Neptune.h"
#include "PltCtrlPoint.h"
#include "PltMediaBrowser.h"
#include "PltMediaCache.h"
/*----------------------------------------------------------------------
| types
+---------------------------------------------------------------------*/
typedef NPT_Map<NPT_String, PLT_DeviceDataReference> PLT_DeviceMap;
typedef NPT_Map<NPT_String, PLT_DeviceDataReference>::Entry PLT_DeviceMapEntry;
typedef struct PLT_BrowseData {
NPT_SharedVariable shared_var;
NPT_Result res;
PLT_BrowseInfo info;
} PLT_BrowseData;
typedef NPT_Reference<PLT_BrowseData> PLT_BrowseDataReference;
typedef struct PLT_CapabilitiesData {
NPT_SharedVariable shared_var;
NPT_Result res;
NPT_String capabilities;
} PLT_CapabilitiesData;
typedef NPT_Reference<PLT_CapabilitiesData> PLT_CapabilitiesDataReference;
// explicitely specify res otherwise WMP won't return a URL!
#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:lastPlayerState,xbmc:dateadded,xbmc:rating,xbmc:votes,xbmc:artwork,xbmc:uniqueidentifier,xbmc:country,xbmc:userrating"
/*----------------------------------------------------------------------
| PLT_MediaContainerListener
+---------------------------------------------------------------------*/
class PLT_MediaContainerChangesListener
{
public:
virtual ~PLT_MediaContainerChangesListener() {}
virtual void OnContainerChanged(PLT_DeviceDataReference& device,
const char* item_id,
const char* update_id) = 0;
};
/*----------------------------------------------------------------------
| PLT_SyncMediaBrowser
+---------------------------------------------------------------------*/
class PLT_SyncMediaBrowser : public PLT_MediaBrowser,
public PLT_MediaBrowserDelegate
{
public:
PLT_SyncMediaBrowser(PLT_CtrlPointReference& ctrlPoint,
bool use_cache = false,
PLT_MediaContainerChangesListener* listener = NULL);
~PLT_SyncMediaBrowser() override;
// PLT_MediaBrowser methods
NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device) override;
NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device) override;
// PLT_MediaBrowserDelegate methods
void OnMSStateVariablesChanged(PLT_Service* service,
NPT_List<PLT_StateVariable*>* vars) override;
void OnBrowseResult(NPT_Result res,
PLT_DeviceDataReference& device,
PLT_BrowseInfo* info,
void* userdata) override;
void OnSearchResult(NPT_Result res,
PLT_DeviceDataReference& device,
PLT_BrowseInfo* info,
void* userdata) override;
void OnGetSearchCapabilitiesResult(NPT_Result res,
PLT_DeviceDataReference& device,
NPT_String searchCapabilities,
void* userdata) override;
void OnGetSortCapabilitiesResult(NPT_Result res,
PLT_DeviceDataReference& device,
NPT_String sortCapabilities,
void* userdata) override;
// methods
void SetContainerListener(PLT_MediaContainerChangesListener* listener) {
m_ContainerListener = listener;
}
NPT_Result BrowseSync(PLT_DeviceDataReference& device,
const char* id,
PLT_MediaObjectListReference& list,
bool metadata = false,
NPT_Int32 start = 0,
NPT_Cardinal max_results = 0); // 0 means all
NPT_Result SearchSync(PLT_DeviceDataReference& device,
const char* container_id,
const char* search_criteria,
PLT_MediaObjectListReference& list,
NPT_Int32 start = 0,
NPT_Cardinal max_results = 0); // 0 means all
NPT_Result GetSearchCapabilitiesSync(PLT_DeviceDataReference& device,
NPT_String& searchCapabilities);
NPT_Result GetSortCapabilitiesSync(PLT_DeviceDataReference& device,
NPT_String& sortCapabilities);
const NPT_Lock<PLT_DeviceMap>& GetMediaServersMap() const { return m_MediaServers; }
bool IsCached(const char* uuid, const char* object_id);
protected:
NPT_Result BrowseSync(PLT_BrowseDataReference& browse_data,
PLT_DeviceDataReference& device,
const char* object_id,
NPT_Int32 index,
NPT_Int32 count,
bool browse_metadata = false,
const char* filter = PLT_DEFAULT_FILTER,
const char* sort = "");
NPT_Result SearchSync(PLT_BrowseDataReference& browse_data,
PLT_DeviceDataReference& device,
const char* container_id,
const char* search_criteria,
NPT_Int32 index,
NPT_Int32 count,
const char* filter = PLT_DEFAULT_FILTER); // explicitely specify res otherwise WMP won't return a URL!
private:
NPT_Result Find(const char* ip, PLT_DeviceDataReference& device);
NPT_Result WaitForResponse(NPT_SharedVariable& shared_var);
private:
NPT_Lock<PLT_DeviceMap> m_MediaServers;
PLT_MediaContainerChangesListener* m_ContainerListener;
bool m_UseCache;
PLT_MediaCache<PLT_MediaObjectListReference,NPT_String> m_Cache;
};
/*----------------------------------------------------------------------
| PLT_DeviceMapFinderByIp
+---------------------------------------------------------------------*/
class PLT_DeviceMapFinderByIp
{
public:
// methods
PLT_DeviceMapFinderByIp(const char* ip) : m_IP(ip) {}
bool operator()(const PLT_DeviceMapEntry* const& entry) const {
const PLT_DeviceDataReference& device = entry->GetValue();
return (device->GetURLBase().GetHost() == m_IP);
}
private:
// members
NPT_String m_IP;
};
/*----------------------------------------------------------------------
| PLT_DeviceFinderByUUID
+---------------------------------------------------------------------*/
class PLT_DeviceMapFinderByUUID
{
public:
// methods
PLT_DeviceMapFinderByUUID(const char* uuid) : m_UUID(uuid) {}
bool operator()(const PLT_DeviceMapEntry* const& entry) const {
PLT_DeviceDataReference device = entry->GetValue();
return device->GetUUID() == m_UUID;
}
private:
// members
NPT_String m_UUID;
};
#endif /* _PLT_SYNC_MEDIA_BROWSER_ */
|