1 /*****************************************************************
3 | Platinum - AV Media Browser (Media Server Control Point)
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
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 ****************************************************************/
36 UPnP AV Media Controller implementation.
39 #ifndef _PLT_MEDIA_BROWSER_H_
40 #define _PLT_MEDIA_BROWSER_H_
42 /*----------------------------------------------------------------------
44 +---------------------------------------------------------------------*/
45 #include "PltCtrlPoint.h"
46 #include "PltMediaItem.h"
48 /*----------------------------------------------------------------------
50 +---------------------------------------------------------------------*/
52 The PLT_BrowseInfo struct is used to marshall Browse or Search action
53 response results across different threads of execution.
57 PLT_MediaObjectListReference items
;
64 /*----------------------------------------------------------------------
65 | PLT_MediaBrowserDelegate
66 +---------------------------------------------------------------------*/
68 The PLT_MediaBrowserDelegate class is an interface for receiving PLT_MediaBrowser
69 events or action responses.
71 class PLT_MediaBrowserDelegate
74 virtual ~PLT_MediaBrowserDelegate() {}
76 virtual bool OnMSAdded(PLT_DeviceDataReference
& /* device */) { return true; }
77 virtual void OnMSRemoved(PLT_DeviceDataReference
& /* device */) {}
78 virtual void OnMSStateVariablesChanged(
79 PLT_Service
* /*service*/,
80 NPT_List
<PLT_StateVariable
*>* /*vars*/) {}
83 virtual void OnBrowseResult(
85 PLT_DeviceDataReference
& /*device*/,
86 PLT_BrowseInfo
* /*info*/,
87 void* /*userdata*/) {}
89 virtual void OnSearchResult(
91 PLT_DeviceDataReference
& /*device*/,
92 PLT_BrowseInfo
* /*info*/,
93 void* /*userdata*/) {}
95 virtual void OnGetSearchCapabilitiesResult(
97 PLT_DeviceDataReference
& /*device*/,
98 NPT_String
/*searchCapabilities*/,
99 void* /*userdata*/) {}
101 virtual void OnGetSortCapabilitiesResult(
103 PLT_DeviceDataReference
& /*device*/,
104 NPT_String
/*sortCapabilities*/,
105 void* /*userdata*/) {}
108 /*----------------------------------------------------------------------
110 +---------------------------------------------------------------------*/
112 The PLT_MediaBrowser class implements a UPnP AV Media Server control point.
114 class PLT_MediaBrowser
: public PLT_CtrlPointListener
117 PLT_MediaBrowser(PLT_CtrlPointReference
& ctrl_point
,
118 PLT_MediaBrowserDelegate
* delegate
= NULL
);
119 ~PLT_MediaBrowser() override
;
121 // ContentDirectory service
122 virtual NPT_Result
Browse(PLT_DeviceDataReference
& device
,
123 const char* object_id
,
124 NPT_UInt32 start_index
,
125 NPT_UInt32 count
= 30, // DLNA recommendations
126 bool browse_metadata
= false,
127 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!
128 const char* sort_criteria
= "",
129 void* userdata
= NULL
);
131 virtual NPT_Result
Search(PLT_DeviceDataReference
& device
,
132 const char* container_id
,
133 const char* search_criteria
,
134 NPT_UInt32 start_index
,
135 NPT_UInt32 count
= 30, // DLNA recommendations
136 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!
137 void* userdata
= NULL
);
139 virtual NPT_Result
GetSearchCapabilities(PLT_DeviceDataReference
& device
,
140 void* userdata
= NULL
);
142 virtual NPT_Result
GetSortCapabilities(PLT_DeviceDataReference
& device
,
143 void* userdata
= NULL
);
146 virtual const NPT_Lock
<PLT_DeviceDataReferenceList
>& GetMediaServers() { return m_MediaServers
; }
147 virtual NPT_Result
FindServer(const char* uuid
, PLT_DeviceDataReference
& device
);
148 virtual void SetDelegate(PLT_MediaBrowserDelegate
* delegate
) { m_Delegate
= delegate
; }
151 // PLT_CtrlPointListener methods
152 NPT_Result
OnDeviceAdded(PLT_DeviceDataReference
& device
) override
;
153 NPT_Result
OnDeviceRemoved(PLT_DeviceDataReference
& device
) override
;
154 NPT_Result
OnActionResponse(NPT_Result res
, PLT_ActionReference
& action
, void* userdata
) override
;
155 NPT_Result
OnEventNotify(PLT_Service
* service
, NPT_List
<PLT_StateVariable
*>* vars
) override
;
157 // ContentDirectory service responses
158 virtual NPT_Result
OnBrowseResponse(NPT_Result res
,
159 PLT_DeviceDataReference
& device
,
160 PLT_ActionReference
& action
,
163 virtual NPT_Result
OnSearchResponse(NPT_Result res
,
164 PLT_DeviceDataReference
& device
,
165 PLT_ActionReference
& action
,
168 virtual NPT_Result
OnGetSearchCapabilitiesResponse(NPT_Result res
,
169 PLT_DeviceDataReference
& device
,
170 PLT_ActionReference
& action
,
173 virtual NPT_Result
OnGetSortCapabilitiesResponse(NPT_Result res
,
174 PLT_DeviceDataReference
& device
,
175 PLT_ActionReference
& action
,
179 PLT_CtrlPointReference m_CtrlPoint
;
180 PLT_MediaBrowserDelegate
* m_Delegate
;
181 NPT_Lock
<PLT_DeviceDataReferenceList
> m_MediaServers
;
184 #endif /* _PLT_MEDIA_BROWSER_H_ */