Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Platinum / Source / Core / PltProtocolInfo.h
blobd86ef0c38db0da9184ffeb6196de69be22a48208
1 /*****************************************************************
3 | Platinum - AV Media Protocol Info
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
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 ****************************************************************/
35 /** @file
36 UPnP AV Media Object Protocol Info.
39 #ifndef _PLT_PROTOCOL_INFO_H_
40 #define _PLT_PROTOCOL_INFO_H_
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltHttp.h"
48 /*----------------------------------------------------------------------
49 | forward declarations
50 +---------------------------------------------------------------------*/
51 class PLT_HttpRequestContext;
53 /*----------------------------------------------------------------------
54 | typedefs
55 +---------------------------------------------------------------------*/
56 typedef struct PLT_HttpFileRequestHandler_DefaultDlnaExtMapEntry {
57 const char* mime_type;
58 const char* dlna_ext;
59 } PLT_HttpFileRequestHandler_DefaultDlnaExtMapEntry ;
61 /*----------------------------------------------------------------------
62 | PLT_ProtocolInfo
63 +---------------------------------------------------------------------*/
64 /**
65 The PLT_ProtocolInfo class holds information about the protocol info of a
66 given UPnP Media Item resource.
68 class PLT_ProtocolInfo
70 public:
71 class FieldEntry {
72 public:
73 FieldEntry(const char* key, const char* value) :
74 m_Key(key), m_Value(value) {}
75 NPT_String m_Key;
76 NPT_String m_Value;
79 // class methods
80 static NPT_String GetMimeTypeFromProtocolInfo(const char* protocol_info);
82 static const char* GetDlnaExtension(const char* mime_type,
83 const PLT_HttpRequestContext* context = NULL);
84 static const char* GetDlnaExtension(const char* mime_type,
85 PLT_DeviceSignature signature = PLT_DEVICE_UNKNOWN);
87 static PLT_ProtocolInfo GetProtocolInfo(const char* filename,
88 bool with_dlna_extension = true,
89 const PLT_HttpRequestContext* context = NULL);
90 static PLT_ProtocolInfo GetProtocolInfo(const char* filename,
91 bool with_dlna_extension = true,
92 PLT_DeviceSignature signature = PLT_DEVICE_UNKNOWN);
94 static PLT_ProtocolInfo GetProtocolInfoFromMimeType(const char* mime_type,
95 bool with_dlna_extension = true,
96 const PLT_HttpRequestContext* context = NULL);
97 static PLT_ProtocolInfo GetProtocolInfoFromMimeType(const char* mime_type,
98 bool with_dlna_extension = true,
99 PLT_DeviceSignature signature = PLT_DEVICE_UNKNOWN);
101 // methods
102 PLT_ProtocolInfo();
103 //PLT_ProtocolInfo(NPT_String protocol_info);
104 PLT_ProtocolInfo(const char* protocol_info);
105 PLT_ProtocolInfo(const char* protocol,
106 const char* mask,
107 const char* content_type,
108 const char* extra);
109 const NPT_String& GetProtocol() const { return m_Protocol; }
110 const NPT_String& GetMask() const { return m_Mask; }
111 const NPT_String& GetContentType() const { return m_ContentType; }
112 const NPT_String& GetExtra() const { return m_Extra; }
114 const NPT_String& GetDLNA_PN() const { return m_DLNA_PN; }
116 bool IsValid() { return m_Valid; }
118 NPT_String ToString() const;
120 bool Match(const PLT_ProtocolInfo& other) const;
122 private:
123 typedef enum {
124 PLT_PROTINFO_PARSER_STATE_START,
125 PLT_PROTINFO_PARSER_STATE_PN,
126 PLT_PROTINFO_PARSER_STATE_OP,
127 PLT_PROTINFO_PARSER_STATE_PS,
128 PLT_PROTINFO_PARSER_STATE_CI,
129 PLT_PROTINFO_PARSER_STATE_FLAGS,
130 PLT_PROTINFO_PARSER_STATE_MAXSP,
131 PLT_PROTINFO_PARSER_STATE_OTHER
132 } PLT_ProtocolInfoParserState;
134 NPT_Result SetProtocolInfo(const char* protocol_info);
135 NPT_Result ValidateField(const char* val,
136 const char* valid_chars,
137 NPT_Cardinal num_chars = 0); // 0 means variable number of chars
138 NPT_Result ParseExtra(NPT_List<FieldEntry>& entries);
139 NPT_Result ValidateExtra();
141 private:
142 NPT_String m_Protocol;
143 NPT_String m_Mask;
144 NPT_String m_ContentType;
145 NPT_String m_Extra;
147 NPT_String m_DLNA_PN; // DLNA.ORG_PN Parameter (pn-param)
148 NPT_String m_DLNA_OP; // Operations Parameter (op-param)
149 NPT_String m_DLNA_PS; // Server-Side PlaySpeeds Parameter (ps-param)
150 NPT_String m_DLNA_CI; // Conversion Indicator Flag (ci-param)
151 NPT_String m_DLNA_FLAGS; // Flags Parameter (flags-param)
152 NPT_String m_DLNA_MAXSP; // Maximum RTSP Speed Header value (maxsp-param)
153 NPT_List<FieldEntry> m_DLNA_OTHER; // Vendor-defined 4th field Parameters (other-param)
155 bool m_Valid;
158 #endif /* _PLT_PROTOCOL_INFO_H_ */