kodi
StreamHandler.h
1 /*****************************************************************
2 |
3 | Platinum - Stream Handler
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 
35 #ifndef _PLT_STREAM_HANDLER_H_
36 #define _PLT_STREAM_HANDLER_H_
37 
38 /*----------------------------------------------------------------------
39 | includes
40 +---------------------------------------------------------------------*/
41 #include "Neptune.h"
42 
43 /*----------------------------------------------------------------------
44 | forward declarations
45 +---------------------------------------------------------------------*/
46 class CMediaCrawler;
47 
48 /*----------------------------------------------------------------------
49 | CStreamHandler
50 +---------------------------------------------------------------------*/
52 {
53 public:
54  CStreamHandler(CMediaCrawler* crawler) : m_MediaCrawler(crawler) {}
55  virtual ~CStreamHandler() {}
56 
57  // overridables
58  virtual bool HandleResource(const char* prot_info, const char* url) = 0;
59  virtual NPT_Result ModifyResource(NPT_XmlElementNode* resource, NPT_SocketInfo* info = NULL) = 0;
60  virtual NPT_Result ProcessFileRequest(NPT_HttpRequest& request, NPT_HttpResponse*& response) = 0;
61 
62 protected:
63  CMediaCrawler* m_MediaCrawler;
64 };
65 
66 /*----------------------------------------------------------------------
67 | CStreamHandlerFinder
68 +---------------------------------------------------------------------*/
70 {
71 public:
72  // methods
73  CStreamHandlerFinder(const char* prot_info, const char* url) : m_ProtInfo(prot_info), m_Url(url) {}
74  bool operator()(CStreamHandler* const & handler) const {
75  return handler->HandleResource(m_ProtInfo, m_Url);
76  }
77 
78 private:
79  // members
80  NPT_String m_ProtInfo;
81  NPT_String m_Url;
82 };
83 
84 /*----------------------------------------------------------------------
85 | CPassThroughStreamHandler
86 +---------------------------------------------------------------------*/
88 {
89 public:
91  virtual ~CPassThroughStreamHandler() {}
92 
93  // overridables
94  virtual bool HandleResource(const char* /*prot_info*/, const char* /*url*/) {
95  return true;
96  }
97 
98  virtual NPT_Result ModifyResource(NPT_XmlElementNode* resource,
99  NPT_SocketInfo* info = NULL) {
100  NPT_COMPILER_UNUSED(resource);
101  NPT_COMPILER_UNUSED(info);
102  return NPT_SUCCESS;
103  }
104 
105  virtual NPT_Result ProcessFileRequest(NPT_HttpRequest& request,
106  NPT_HttpResponse*& response) {
107  NPT_HttpClient client;
108  return client.SendRequest(request, response);
109  }
110 
111 };
112 
113 #endif /* _PLT_STREAM_HANDLER_H_ */
Definition: MediaCrawler.h:49
Definition: NptXml.h:172
Definition: NptHttp.h:315
Definition: NptHttp.h:282
Definition: NptSockets.h:115
Definition: StreamHandler.h:69
Definition: StreamHandler.h:51
Definition: NptHttp.h:386
Definition: NptStrings.h:57
Definition: StreamHandler.h:87