1 /*****************************************************************
3 | Platinum - DIDL handling
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 ****************************************************************/
42 /*----------------------------------------------------------------------
44 +---------------------------------------------------------------------*/
46 #include "PltMediaItem.h"
48 /*----------------------------------------------------------------------
50 +---------------------------------------------------------------------*/
51 #define PLT_FILTER_MASK_ALL NPT_UINT64_C(0xFFFFFFFFFFFFFFFF)
53 #define PLT_FILTER_MASK_CREATOR NPT_UINT64_C(0x0000000000000001)
54 #define PLT_FILTER_MASK_ARTIST NPT_UINT64_C(0x0000000000000002)
55 #define PLT_FILTER_MASK_ALBUM NPT_UINT64_C(0x0000000000000004)
56 #define PLT_FILTER_MASK_GENRE NPT_UINT64_C(0x0000000000000008)
57 #define PLT_FILTER_MASK_ALBUMARTURI NPT_UINT64_C(0x0000000000000010)
58 #define PLT_FILTER_MASK_DESCRIPTION NPT_UINT64_C(0x0000000000000020)
59 #define PLT_FILTER_MASK_SEARCHABLE NPT_UINT64_C(0x0000000000000040)
60 #define PLT_FILTER_MASK_CHILDCOUNT NPT_UINT64_C(0x0000000000000080)
61 #define PLT_FILTER_MASK_ORIGINALTRACK NPT_UINT64_C(0x0000000000000100)
62 #define PLT_FILTER_MASK_ACTOR NPT_UINT64_C(0x0000000000000200)
63 #define PLT_FILTER_MASK_AUTHOR NPT_UINT64_C(0x0000000000000400)
64 #define PLT_FILTER_MASK_DIRECTOR NPT_UINT64_C(0x0000000000000800)
65 #define PLT_FILTER_MASK_DATE NPT_UINT64_C(0x0000000000001000)
66 #define PLT_FILTER_MASK_PROGRAMTITLE NPT_UINT64_C(0x0000000000002000)
67 #define PLT_FILTER_MASK_SERIESTITLE NPT_UINT64_C(0x0000000000004000)
68 #define PLT_FILTER_MASK_EPISODE NPT_UINT64_C(0x0000000000008000)
69 #define PLT_FILTER_MASK_TITLE NPT_UINT64_C(0x0000000000010000)
71 #define PLT_FILTER_MASK_RES NPT_UINT64_C(0x0000000000020000)
72 #define PLT_FILTER_MASK_RES_DURATION NPT_UINT64_C(0x0000000000040000)
73 #define PLT_FILTER_MASK_RES_SIZE NPT_UINT64_C(0x0000000000080000)
74 #define PLT_FILTER_MASK_RES_PROTECTION NPT_UINT64_C(0x0000000000100000)
75 #define PLT_FILTER_MASK_RES_RESOLUTION NPT_UINT64_C(0x0000000000200000)
76 #define PLT_FILTER_MASK_RES_BITRATE NPT_UINT64_C(0x0000000000400000)
77 #define PLT_FILTER_MASK_RES_BITSPERSAMPLE NPT_UINT64_C(0x0000000000800000)
78 #define PLT_FILTER_MASK_RES_NRAUDIOCHANNELS NPT_UINT64_C(0x0000000001000000)
79 #define PLT_FILTER_MASK_RES_SAMPLEFREQUENCY NPT_UINT64_C(0x0000000002000000)
81 #define PLT_FILTER_MASK_LONGDESCRIPTION NPT_UINT64_C(0x0000000004000000)
82 #define PLT_FILTER_MASK_ICON NPT_UINT64_C(0x0000000008000000)
83 #define PLT_FILTER_MASK_RATING NPT_UINT64_C(0x0000000010000000)
85 #define PLT_FILTER_MASK_TOC NPT_UINT64_C(0x0000000020000000)
86 #define PLT_FILTER_MASK_SEARCHCLASS NPT_UINT64_C(0x0000000040000000)
87 #define PLT_FILTER_MASK_REFID NPT_UINT64_C(0x0000000080000000)
89 #define PLT_FILTER_MASK_LASTPOSITION NPT_UINT64_C(0x0000000100000000)
90 #define PLT_FILTER_MASK_LASTPLAYBACK NPT_UINT64_C(0x0000000200000000)
91 #define PLT_FILTER_MASK_PLAYCOUNT NPT_UINT64_C(0x0000000400000000)
93 #define PLT_FILTER_MASK_PUBLISHER NPT_UINT64_C(0x0000000800000000)
95 #define PLT_FILTER_MASK_EPISODE_COUNT NPT_UINT64_C(0x0000001000000000)
96 #define PLT_FILTER_MASK_EPISODE_SEASON NPT_UINT64_C(0x0000002000000000)
98 #define PLT_FILTER_MASK_XBMC_DATEADDED NPT_UINT64_C(0x0000100000000000)
99 #define PLT_FILTER_MASK_XBMC_RATING NPT_UINT64_C(0x0000200000000000)
100 #define PLT_FILTER_MASK_XBMC_VOTES NPT_UINT64_C(0x0000400000000000)
101 #define PLT_FILTER_MASK_XBMC_ARTWORK NPT_UINT64_C(0x0000800000000000)
102 #define PLT_FILTER_MASK_XBMC_UNIQUE_IDENTIFIER NPT_UINT64_C(0x0001000000000000)
103 #define PLT_FILTER_MASK_XBMC_COUNTRY NPT_UINT64_C(0x0002000000000000)
104 #define PLT_FILTER_MASK_XBMC_USERRATING NPT_UINT64_C(0x0004000000000000)
105 #define PLT_FILTER_MASK_XBMC_LASTPLAYERSTATE NPT_UINT64_C(0x0008000000000000)
107 #define PLT_FILTER_FIELD_TITLE "dc:title"
108 #define PLT_FILTER_FIELD_CREATOR "dc:creator"
109 #define PLT_FILTER_FIELD_DATE "dc:date"
110 #define PLT_FILTER_FIELD_ARTIST "upnp:artist"
111 #define PLT_FILTER_FIELD_ACTOR "upnp:actor"
112 #define PLT_FILTER_FIELD_AUTHOR "upnp:author"
113 #define PLT_FILTER_FIELD_DIRECTOR "upnp:director"
114 #define PLT_FILTER_FIELD_ALBUM "upnp:album"
115 #define PLT_FILTER_FIELD_GENRE "upnp:genre"
116 #define PLT_FILTER_FIELD_ALBUMARTURI "upnp:albumArtURI"
117 #define PLT_FILTER_FIELD_ALBUMARTURI_DLNAPROFILEID "upnp:albumArtURI@dlna:profileID"
118 #define PLT_FILTER_FIELD_DESCRIPTION "dc:description"
119 #define PLT_FILTER_FIELD_LONGDESCRIPTION "upnp:longDescription"
120 #define PLT_FILTER_FIELD_ICON "upnp:icon"
121 #define PLT_FILTER_FIELD_RATING "upnp:rating"
122 #define PLT_FILTER_FIELD_ORIGINALTRACK "upnp:originalTrackNumber"
123 #define PLT_FILTER_FIELD_PROGRAMTITLE "upnp:programTitle"
124 #define PLT_FILTER_FIELD_SERIESTITLE "upnp:seriesTitle"
125 #define PLT_FILTER_FIELD_EPISODE "upnp:episodeNumber"
126 #define PLT_FILTER_FIELD_LASTPOSITION "upnp:lastPlaybackPosition"
127 #define PLT_FILTER_FIELD_LASTPLAYBACK "upnp:lastPlaybackTime"
128 #define PLT_FILTER_FIELD_PLAYCOUNT "upnp:playbackCount"
129 #define PLT_FILTER_FIELD_SEARCHCLASS "upnp:searchClass"
130 #define PLT_FILTER_FIELD_SEARCHABLE "@searchable"
131 #define PLT_FILTER_FIELD_CHILDCOUNT "@childcount"
132 #define PLT_FILTER_FIELD_CONTAINER_CHILDCOUNT "container@childCount"
133 #define PLT_FILTER_FIELD_CONTAINER_SEARCHABLE "container@searchable"
134 #define PLT_FILTER_FIELD_REFID "@refID"
135 #define PLT_FILTER_FIELD_PUBLISHER "dc:publisher"
137 #define PLT_FILTER_FIELD_RES "res"
138 #define PLT_FILTER_FIELD_RES_DURATION "res@duration"
139 #define PLT_FILTER_FIELD_RES_DURATION_SHORT "@duration"
140 #define PLT_FILTER_FIELD_RES_SIZE "res@size"
141 #define PLT_FILTER_FIELD_RES_PROTECTION "res@protection"
142 #define PLT_FILTER_FIELD_RES_RESOLUTION "res@resolution"
143 #define PLT_FILTER_FIELD_RES_BITRATE "res@bitrate"
144 #define PLT_FILTER_FIELD_RES_BITSPERSAMPLE "res@bitsPerSample"
145 #define PLT_FILTER_FIELD_RES_NRAUDIOCHANNELS "res@nrAudioChannels"
146 #define PLT_FILTER_FIELD_RES_SAMPLEFREQUENCY "res@sampleFrequency"
148 #define PLT_FILTER_FIELD_EPISODE_COUNT "upnp:episodeCount"
149 #define PLT_FILTER_FIELD_EPISODE_SEASON "upnp:episodeSeason"
151 #define PLT_FILTER_FIELD_XBMC_LASTPLAYERSTATE "xbmc:lastPlayerState"
152 #define PLT_FILTER_FIELD_XBMC_DATEADDED "xbmc:dateadded"
153 #define PLT_FILTER_FIELD_XBMC_RATING "xbmc:rating"
154 #define PLT_FILTER_FIELD_XBMC_VOTES "xbmc:votes"
155 #define PLT_FILTER_FIELD_XBMC_ARTWORK "xbmc:artwork"
156 #define PLT_FILTER_FIELD_XBMC_UNIQUE_IDENTIFIER "xbmc:uniqueidentifier"
157 #define PLT_FILTER_FIELD_XBMC_COUNTRY "xbmc:country"
158 #define PLT_FILTER_FIELD_XBMC_USERRATING "xbmc:userrating"
160 extern const char* didl_header
;
161 extern const char* didl_footer
;
162 extern const char* didl_namespace_dc
;
163 extern const char* didl_namespace_upnp
;
164 extern const char* didl_namespace_dlna
;
165 extern const char* didl_namespace_xbmc
;
167 /*----------------------------------------------------------------------
169 +---------------------------------------------------------------------*/
172 The PLT_Didl class provides a mechanism to (de)serialize a PLT_MediaObject or
173 list of PLT_MediaObject (PLT_MediaObjectList).
178 static NPT_Result
ToDidl(PLT_MediaObject
& object
,
179 const NPT_String
& filter
,
181 static NPT_Result
FromDidl(const char* didl
,
182 PLT_MediaObjectListReference
& objects
);
183 static void AppendXmlEscape(NPT_String
& out
, const char* in
);
184 static void AppendXmlUnEscape(NPT_String
& out
, const char* in
);
185 static NPT_Result
ParseTimeStamp(const NPT_String
& timestamp
, NPT_UInt32
& seconds
);
186 static NPT_String
FormatTimeStamp(NPT_UInt32 seconds
);
187 static NPT_Result
ParseTimeStamp(const NPT_String
& in
, NPT_TimeStamp
& timestamp
) {
189 NPT_Result res
= ParseTimeStamp(in
, seconds
);
190 timestamp
= NPT_TimeStamp((double)seconds
);
194 static NPT_UInt64
ConvertFilterToMask(const NPT_String
& filter
);
197 #endif /* _PLT_DIDL_H_ */