xbmc
PltFileMediaServer.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - File Media Server
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_FILE_MEDIA_SERVER_H_
40 #define _PLT_FILE_MEDIA_SERVER_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltMediaServer.h"
47 #include "PltMediaCache.h"
48 
49 /*----------------------------------------------------------------------
50 | PLT_FileMediaServerDelegate
51 +---------------------------------------------------------------------*/
58 {
59 public:
60  // class methods
61  static NPT_String BuildSafeResourceUri(const NPT_HttpUrl& base_uri,
62  const char* host,
63  const char* file_path);
64  // constructor & destructor
65  PLT_FileMediaServerDelegate(const char* url_root, const char* file_root, bool use_cache = false);
66  ~PLT_FileMediaServerDelegate() override;
67 
68 protected:
69  // PLT_MediaServerDelegate methods
70  NPT_Result OnBrowseMetadata(PLT_ActionReference& action,
71  const char* object_id,
72  const char* filter,
73  NPT_UInt32 starting_index,
74  NPT_UInt32 requested_count,
75  const char* sort_criteria,
76  const PLT_HttpRequestContext& context) override;
77  NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action,
78  const char* object_id,
79  const char* filter,
80  NPT_UInt32 starting_index,
81  NPT_UInt32 requested_count,
82  const char* sort_criteria,
83  const PLT_HttpRequestContext& context) override;
84  NPT_Result OnSearchContainer(PLT_ActionReference& action,
85  const char* object_id,
86  const char* search_criteria,
87  const char* filter,
88  NPT_UInt32 starting_index,
89  NPT_UInt32 requested_count,
90  const char* sort_criteria,
91  const PLT_HttpRequestContext& context) override;
92  NPT_Result ProcessFileRequest(NPT_HttpRequest& request,
93  const NPT_HttpRequestContext& context,
94  NPT_HttpResponse& response) override;
95 
96  // overridable methods
97  virtual NPT_Result ExtractResourcePath(const NPT_HttpUrl& url, NPT_String& file_path);
98  virtual NPT_String BuildResourceUri(const NPT_HttpUrl& base_uri, const char* host, const char* file_path);
99  virtual NPT_Result ServeFile(const NPT_HttpRequest& request,
100  const NPT_HttpRequestContext& context,
101  NPT_HttpResponse& response,
102  const NPT_String& file_path);
103  virtual NPT_Result GetFilePath(const char* object_id, NPT_String& filepath);
104  virtual bool ProcessFile(const NPT_String&, const char* filter = NULL) { NPT_COMPILER_UNUSED(filter); return true;}
105  virtual PLT_MediaObject* BuildFromFilePath(const NPT_String& filepath,
106  const PLT_HttpRequestContext& context,
107  bool with_count = true,
108  bool keep_extension_in_title = false,
109  bool allip = false);
110 
111 protected:
112  friend class PLT_MediaItem;
113 
114  NPT_String m_UrlRoot;
115  NPT_String m_FileRoot;
116  bool m_FilterUnknownOut;
117  bool m_UseCache;
118 
120 };
121 
122 /*----------------------------------------------------------------------
123 | PLT_FileMediaServer
124 +---------------------------------------------------------------------*/
132 {
133 public: // constructor
134  PLT_FileMediaServer(const char* file_root,
135  const char* friendly_name,
136  bool show_ip = false,
137  const char* uuid = NULL,
138  NPT_UInt16 port = 0,
139  bool port_rebind = false) :
140  PLT_MediaServer(friendly_name,
141  show_ip,
142  uuid,
143  port,
144  port_rebind),
145  PLT_FileMediaServerDelegate("/", file_root) {SetDelegate(this);}
146 
147 protected:
148  ~PLT_FileMediaServer() override {}
149 };
150 
151 #endif /* _PLT_FILE_MEDIA_SERVER_H_ */
Definition: NptHttp.h:566
The PLT_MediaItem class represents a first-level class derived directly from PLT_MediaObject.
Definition: PltMediaItem.h:282
The PLT_MediaServerDelegate class is an interface for delegating the handling of the required UPnP AV...
Definition: PltMediaServer.h:62
UPnP AV Media Server.
Definition: NptHttp.h:315
Definition: NptHttp.h:126
Definition: NptHttp.h:282
The PLT_MediaCache template provides a way to hold references to object in memory.
Definition: PltMediaCache.h:55
File Media Server Delegate.
Definition: PltFileMediaServer.h:57
The PLT_MediaServer class implements the base class for a UPnP AV Media Server device.
Definition: PltMediaServer.h:108
Simple Object Caching utility.
Definition: NptTime.h:50
File Media Server.
Definition: PltFileMediaServer.h:130
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
The PLT_MediaObject class is any data entity that can be returned by a ContentDirectory Service from ...
Definition: PltMediaItem.h:217
Definition: NptStrings.h:57