1 /*****************************************************************
3 | Platinum - AV Media Protocol Info
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
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 ****************************************************************/
36 UPnP AV Media Object Protocol Info.
39 #ifndef _PLT_PROTOCOL_INFO_H_
40 #define _PLT_PROTOCOL_INFO_H_
42 /*----------------------------------------------------------------------
44 +---------------------------------------------------------------------*/
48 /*----------------------------------------------------------------------
49 | forward declarations
50 +---------------------------------------------------------------------*/
51 class PLT_HttpRequestContext
;
53 /*----------------------------------------------------------------------
55 +---------------------------------------------------------------------*/
56 typedef struct PLT_HttpFileRequestHandler_DefaultDlnaExtMapEntry
{
57 const char* mime_type
;
59 } PLT_HttpFileRequestHandler_DefaultDlnaExtMapEntry
;
61 /*----------------------------------------------------------------------
63 +---------------------------------------------------------------------*/
65 The PLT_ProtocolInfo class holds information about the protocol info of a
66 given UPnP Media Item resource.
68 class PLT_ProtocolInfo
73 FieldEntry(const char* key
, const char* value
) :
74 m_Key(key
), m_Value(value
) {}
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
);
103 //PLT_ProtocolInfo(NPT_String protocol_info);
104 PLT_ProtocolInfo(const char* protocol_info
);
105 PLT_ProtocolInfo(const char* protocol
,
107 const char* content_type
,
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;
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();
142 NPT_String m_Protocol
;
144 NPT_String m_ContentType
;
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)
158 #endif /* _PLT_PROTOCOL_INFO_H_ */