Platinum UPnP SDK  1.0.5.13
PltMediaServer.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - AV Media Server Device
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
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.
13 |
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
21 |
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.
26 |
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
32 |
33 ****************************************************************/
34 
39 #ifndef _PLT_MEDIA_SERVER_H_
40 #define _PLT_MEDIA_SERVER_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltDeviceHost.h"
47 #include "PltMediaItem.h"
48 
49 /*----------------------------------------------------------------------
50 | constants
51 +---------------------------------------------------------------------*/
52 #define MAX_PATH_LENGTH 1024
53 
54 /*----------------------------------------------------------------------
55 | PLT_MediaServerDelegate
56 +---------------------------------------------------------------------*/
63 {
64 public:
66  virtual ~PLT_MediaServerDelegate() {}
67 
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 ProcessFileRequest(NPT_HttpRequest& /*request*/,
91  const NPT_HttpRequestContext& /*context*/,
92  NPT_HttpResponse& /*response*/) = 0;
93 };
94 
95 /*----------------------------------------------------------------------
96 | PLT_MediaServer
97 +---------------------------------------------------------------------*/
103 {
104 public:
105  /* BrowseFlags */
106  enum BrowseFlags {
107  BROWSEMETADATA,
108  BROWSEDIRECTCHILDREN
109  };
110 
111  // class methods
112  static NPT_Result ParseBrowseFlag(const char* str, BrowseFlags& flag);
113  static NPT_Result ParseSort(const NPT_String& sort, NPT_List<NPT_String>& list);
114 
115  // constructor
116  PLT_MediaServer(const char* friendly_name,
117  bool show_ip = false,
118  const char* uuid = NULL,
119  NPT_UInt16 port = 0,
120  bool port_rebind = false);
121 
122  // methods
123  virtual void SetDelegate(PLT_MediaServerDelegate* delegate) { m_Delegate = delegate; }
124  PLT_MediaServerDelegate* GetDelegate() { return m_Delegate; }
125  virtual void UpdateSystemUpdateID(NPT_UInt32 update);
126  virtual void UpdateContainerUpdateID(const char* id, NPT_UInt32 update);
127 
128 protected:
129  virtual ~PLT_MediaServer();
130 
131  // PLT_DeviceHost methods
132  virtual NPT_Result SetupServices();
133  virtual NPT_Result OnAction(PLT_ActionReference& action,
134  const PLT_HttpRequestContext& context);
135  virtual NPT_Result ProcessHttpGetRequest(NPT_HttpRequest& request,
136  const NPT_HttpRequestContext& context,
137  NPT_HttpResponse& response);
138 
139  // ConnectionManager
140  virtual NPT_Result OnGetCurrentConnectionIDs(PLT_ActionReference& action,
141  const PLT_HttpRequestContext& context);
142  virtual NPT_Result OnGetProtocolInfo(PLT_ActionReference& action,
143  const PLT_HttpRequestContext& context);
144  virtual NPT_Result OnGetCurrentConnectionInfo(PLT_ActionReference& action,
145  const PLT_HttpRequestContext& context);
146 
147  // ContentDirectory
148  virtual NPT_Result OnGetSortCapabilities(PLT_ActionReference& action,
149  const PLT_HttpRequestContext& context);
150  virtual NPT_Result OnGetSearchCapabilities(PLT_ActionReference& action,
151  const PLT_HttpRequestContext& context);
152  virtual NPT_Result OnGetSystemUpdateID(PLT_ActionReference& action,
153  const PLT_HttpRequestContext& context);
154  virtual NPT_Result OnBrowse(PLT_ActionReference& action,
155  const PLT_HttpRequestContext& context);
156  virtual NPT_Result OnSearch(PLT_ActionReference& action,
157  const PLT_HttpRequestContext& context);
158 
159  // overridable methods
160  virtual NPT_Result OnBrowseMetadata(PLT_ActionReference& action,
161  const char* object_id,
162  const char* filter,
163  NPT_UInt32 starting_index,
164  NPT_UInt32 requested_count,
165  const char* sort_criteria,
166  const PLT_HttpRequestContext& context);
167  virtual NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action,
168  const char* object_id,
169  const char* filter,
170  NPT_UInt32 starting_index,
171  NPT_UInt32 requested_count,
172  const char* sort_criteria,
173  const PLT_HttpRequestContext& context);
174  virtual NPT_Result OnSearchContainer(PLT_ActionReference& action,
175  const char* container_id,
176  const char* search_criteria,
177  const char* filter,
178  NPT_UInt32 starting_index,
179  NPT_UInt32 requested_count,
180  const char* sort_criteria,
181  const PLT_HttpRequestContext& context);
182 
183 private:
184  PLT_MediaServerDelegate* m_Delegate;
185 };
186 
187 #endif /* _PLT_MEDIA_SERVER_H_ */
The PLT_MediaServerDelegate class is an interface for delegating the handling of the required UPnP AV...
Definition: PltMediaServer.h:62
The PLT_MediaServer class implements the base class for a UPnP AV Media Server device.
Definition: PltMediaServer.h:102
UPnP AV Media Object reprensentation.
virtual NPT_Result ProcessHttpGetRequest(NPT_HttpRequest &request, const NPT_HttpRequestContext &context, NPT_HttpResponse &response)
This method is called when a "GET" request for a resource other than the device description, SCPD, or icons has been received.
UPnP Device Host.
Definition: PltDeviceHost.h:69
virtual NPT_Result SetupServices()
Required method for setting up UPnP services of device host (and any embedded).
UPnP Device.
virtual NPT_Result OnAction(PLT_ActionReference &action, const PLT_HttpRequestContext &context)
This mehod is called when an action performed by a control point has been received and needs to be an...
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:115