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