xbmc
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 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;
95 
96  virtual NPT_Result ProcessFileRequest(NPT_HttpRequest& /*request*/,
97  const NPT_HttpRequestContext& /*context*/,
98  NPT_HttpResponse& /*response*/) = 0;
99 };
100 
101 /*----------------------------------------------------------------------
102 | PLT_MediaServer
103 +---------------------------------------------------------------------*/
109 {
110 public:
111  /* BrowseFlags */
112  enum BrowseFlags {
113  BROWSEMETADATA,
114  BROWSEDIRECTCHILDREN
115  };
116 
117  // class methods
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);
121 
122  // constructor
123  PLT_MediaServer(const char* friendly_name,
124  bool show_ip = false,
125  const char* uuid = NULL,
126  NPT_UInt16 port = 0,
127  bool port_rebind = false);
128 
129  // methods
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);
134 
135 protected:
136  ~PLT_MediaServer() override;
137 
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;
145 
146  // ConnectionManager
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);
153 
154  // ContentDirectory
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);
167 
168  // overridable methods
169  virtual NPT_Result OnBrowseMetadata(PLT_ActionReference& action,
170  const char* object_id,
171  const char* filter,
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,
178  const char* filter,
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,
186  const char* filter,
187  NPT_UInt32 starting_index,
188  NPT_UInt32 requested_count,
189  const char* sort_criteria,
190  const PLT_HttpRequestContext& context);
191 
192 private:
193  PLT_MediaServerDelegate* m_Delegate;
194 };
195 
196 #endif /* _PLT_MEDIA_SERVER_H_ */
Definition: NptHttp.h:566
The PLT_MediaServerDelegate class is an interface for delegating the handling of the required UPnP AV...
Definition: PltMediaServer.h:62
Definition: NptHttp.h:315
Definition: NptHttp.h:282
The PLT_MediaServer class implements the base class for a UPnP AV Media Server device.
Definition: PltMediaServer.h:108
UPnP AV Media Object reprensentation.
UPnP Device Host.
Definition: PltDeviceHost.h:69
UPnP Device.
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
Definition: NptStrings.h:57