1 /*****************************************************************
3 | Platinum - AV Media Server Device
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 ****************************************************************/
39 #ifndef _PLT_MEDIA_SERVER_H_
40 #define _PLT_MEDIA_SERVER_H_
42 /*----------------------------------------------------------------------
44 +---------------------------------------------------------------------*/
46 #include "PltDeviceHost.h"
47 #include "PltMediaItem.h"
49 /*----------------------------------------------------------------------
51 +---------------------------------------------------------------------*/
52 #define MAX_PATH_LENGTH 1024
54 /*----------------------------------------------------------------------
55 | PLT_MediaServerDelegate
56 +---------------------------------------------------------------------*/
58 The PLT_MediaServerDelegate class is an interface for delegating the handling
59 of the required UPnP AV ContentDirectory service actions. It also handles
60 resource HTTP requests (downloading).
62 class PLT_MediaServerDelegate
65 PLT_MediaServerDelegate() {}
66 virtual ~PLT_MediaServerDelegate() {}
68 virtual NPT_Result
OnBrowseMetadata(PLT_ActionReference
& /*action*/,
69 const char* /*object_id*/,
70 const char* /*filter*/,
71 NPT_UInt32
/*starting_index*/,
72 NPT_UInt32
/*requested_count*/,
73 const char* /*sort_criteria*/,
74 const PLT_HttpRequestContext
& /*context*/) = 0;
75 virtual NPT_Result
OnBrowseDirectChildren(PLT_ActionReference
& /*action*/,
76 const char* /*object_id*/,
77 const char* /*filter*/,
78 NPT_UInt32
/*starting_index*/,
79 NPT_UInt32
/*requested_count*/,
80 const char* /*sort_criteria*/,
81 const PLT_HttpRequestContext
& /*context*/) = 0;
82 virtual NPT_Result
OnSearchContainer(PLT_ActionReference
& /*action*/,
83 const char* /*container_id*/,
84 const char* /*search_criteria*/,
85 const char* /*filter*/,
86 NPT_UInt32
/*starting_index*/,
87 NPT_UInt32
/*requested_count*/,
88 const char* /*sort_criteria*/,
89 const PLT_HttpRequestContext
& /*context*/) = 0;
90 virtual NPT_Result
OnUpdateObject(PLT_ActionReference
& /*action*/,
91 const char* /*object_id*/,
92 NPT_Map
<NPT_String
,NPT_String
>& /*current_vals*/,
93 NPT_Map
<NPT_String
,NPT_String
>& /*new_vals*/,
94 const PLT_HttpRequestContext
& /*context*/) = 0;
96 virtual NPT_Result
ProcessFileRequest(NPT_HttpRequest
& /*request*/,
97 const NPT_HttpRequestContext
& /*context*/,
98 NPT_HttpResponse
& /*response*/) = 0;
101 /*----------------------------------------------------------------------
103 +---------------------------------------------------------------------*/
105 The PLT_MediaServer class implements the base class for a UPnP AV
108 class PLT_MediaServer
: public PLT_DeviceHost
118 static NPT_Result
ParseBrowseFlag(const char* str
, BrowseFlags
& flag
);
119 static NPT_Result
ParseSort(const NPT_String
& sort
, NPT_List
<NPT_String
>& list
);
120 static NPT_Result
ParseTagList(const NPT_String
& updates
, NPT_Map
<NPT_String
,NPT_String
>& tags
);
123 PLT_MediaServer(const char* friendly_name
,
124 bool show_ip
= false,
125 const char* uuid
= NULL
,
127 bool port_rebind
= false);
130 virtual void SetDelegate(PLT_MediaServerDelegate
* delegate
) { m_Delegate
= delegate
; }
131 PLT_MediaServerDelegate
* GetDelegate() { return m_Delegate
; }
132 virtual void UpdateSystemUpdateID(NPT_UInt32 update
);
133 virtual void UpdateContainerUpdateID(const char* id
, NPT_UInt32 update
);
136 ~PLT_MediaServer() override
;
138 // PLT_DeviceHost methods
139 NPT_Result
SetupServices() override
;
140 NPT_Result
OnAction(PLT_ActionReference
& action
,
141 const PLT_HttpRequestContext
& context
) override
;
142 NPT_Result
ProcessHttpGetRequest(NPT_HttpRequest
& request
,
143 const NPT_HttpRequestContext
& context
,
144 NPT_HttpResponse
& response
) override
;
147 virtual NPT_Result
OnGetCurrentConnectionIDs(PLT_ActionReference
& action
,
148 const PLT_HttpRequestContext
& context
);
149 virtual NPT_Result
OnGetProtocolInfo(PLT_ActionReference
& action
,
150 const PLT_HttpRequestContext
& context
);
151 virtual NPT_Result
OnGetCurrentConnectionInfo(PLT_ActionReference
& action
,
152 const PLT_HttpRequestContext
& context
);
155 virtual NPT_Result
OnGetSortCapabilities(PLT_ActionReference
& action
,
156 const PLT_HttpRequestContext
& context
);
157 virtual NPT_Result
OnGetSearchCapabilities(PLT_ActionReference
& action
,
158 const PLT_HttpRequestContext
& context
);
159 virtual NPT_Result
OnGetSystemUpdateID(PLT_ActionReference
& action
,
160 const PLT_HttpRequestContext
& context
);
161 virtual NPT_Result
OnBrowse(PLT_ActionReference
& action
,
162 const PLT_HttpRequestContext
& context
);
163 virtual NPT_Result
OnSearch(PLT_ActionReference
& action
,
164 const PLT_HttpRequestContext
& context
);
165 virtual NPT_Result
OnUpdate(PLT_ActionReference
& action
,
166 const PLT_HttpRequestContext
& context
);
168 // overridable methods
169 virtual NPT_Result
OnBrowseMetadata(PLT_ActionReference
& action
,
170 const char* object_id
,
172 NPT_UInt32 starting_index
,
173 NPT_UInt32 requested_count
,
174 const char* sort_criteria
,
175 const PLT_HttpRequestContext
& context
);
176 virtual NPT_Result
OnBrowseDirectChildren(PLT_ActionReference
& action
,
177 const char* object_id
,
179 NPT_UInt32 starting_index
,
180 NPT_UInt32 requested_count
,
181 const char* sort_criteria
,
182 const PLT_HttpRequestContext
& context
);
183 virtual NPT_Result
OnSearchContainer(PLT_ActionReference
& action
,
184 const char* container_id
,
185 const char* search_criteria
,
187 NPT_UInt32 starting_index
,
188 NPT_UInt32 requested_count
,
189 const char* sort_criteria
,
190 const PLT_HttpRequestContext
& context
);
193 PLT_MediaServerDelegate
* m_Delegate
;
196 #endif /* _PLT_MEDIA_SERVER_H_ */