1 From f4eef1767e642fd3b46ce18a4daf619903b74d46 Mon Sep 17 00:00:00 2001
2 From: montellese <montellese@xbmc.org>
3 Date: Tue, 31 Dec 2013 14:06:55 +0100
4 Subject: [PATCH 03/11] platinum: add support for upnp:episodeCount and
5 upnp:episodeSeason from ContentDirectory v4
8 .../Source/Devices/MediaServer/PltDidl.cpp | 6 +++++-
9 .../Platinum/Source/Devices/MediaServer/PltDidl.h | 6 ++++++
10 .../Source/Devices/MediaServer/PltMediaItem.cpp | 22 ++++++++++++++++++++++
11 .../Source/Devices/MediaServer/PltMediaItem.h | 2 ++
12 .../Devices/MediaServer/PltSyncMediaBrowser.h | 2 +-
13 5 files changed, 36 insertions(+), 2 deletions(-)
15 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp
16 index 3d8c9fd..0758ad5 100644
17 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp
18 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.cpp
19 @@ -156,7 +156,11 @@ PLT_Didl::ConvertFilterToMask(const NPT_String& filter)
20 mask |= PLT_FILTER_MASK_RES | PLT_FILTER_MASK_RES_NRAUDIOCHANNELS;
21 } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_RES_SAMPLEFREQUENCY, len, true) == 0) {
22 mask |= PLT_FILTER_MASK_RES | PLT_FILTER_MASK_RES_SAMPLEFREQUENCY;
24 + } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_EPISODE_COUNT, len, true) == 0) {
25 + mask |= PLT_FILTER_MASK_EPISODE_COUNT;
26 + } else if (NPT_String::CompareN(s+i, PLT_FILTER_FIELD_EPISODE_SEASON, len, true) == 0) {
27 + mask |= PLT_FILTER_MASK_EPISODE_SEASON;
32 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h
33 index ae67b43..2271162 100644
34 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h
35 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltDidl.h
38 #define PLT_FILTER_MASK_PUBLISHER NPT_UINT64_C(0x0000000800000000)
40 +#define PLT_FILTER_MASK_EPISODE_COUNT NPT_UINT64_C(0x0000001000000000)
41 +#define PLT_FILTER_MASK_EPISODE_SEASON NPT_UINT64_C(0x0000002000000000)
43 #define PLT_FILTER_FIELD_TITLE "dc:title"
44 #define PLT_FILTER_FIELD_CREATOR "dc:creator"
45 #define PLT_FILTER_FIELD_DATE "dc:date"
47 #define PLT_FILTER_FIELD_RES_NRAUDIOCHANNELS "res@nrAudioChannels"
48 #define PLT_FILTER_FIELD_RES_SAMPLEFREQUENCY "res@sampleFrequency"
50 +#define PLT_FILTER_FIELD_EPISODE_COUNT "upnp:episodeCount"
51 +#define PLT_FILTER_FIELD_EPISODE_SEASON "upnp:episodeSeason"
53 extern const char* didl_header;
54 extern const char* didl_footer;
55 extern const char* didl_namespace_dc;
56 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp
57 index bd55cb5..a8855cc 100644
58 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp
59 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp
60 @@ -195,6 +195,8 @@ PLT_MediaObject::Reset()
61 m_Recorded.program_title = "";
62 m_Recorded.series_title = "";
63 m_Recorded.episode_number = 0;
64 + m_Recorded.episode_count = 0;
65 + m_Recorded.episode_season = 0;
69 @@ -389,6 +391,20 @@ PLT_MediaObject::ToDidl(NPT_UInt64 mask, NPT_String& didl)
70 didl += "</upnp:episodeNumber>";
74 + if ((mask & PLT_FILTER_MASK_EPISODE_COUNT) && m_Recorded.episode_count > 0) {
75 + didl += "<upnp:episodeCount>";
76 + didl += NPT_String::FromInteger(m_Recorded.episode_count);
77 + didl += "</upnp:episodeCount>";
81 + if ((mask & PLT_FILTER_MASK_EPISODE_SEASON)) {
82 + didl += "<upnp:episodeSeason>";
83 + didl += NPT_String::FromInteger(m_Recorded.episode_season);
84 + didl += "</upnp:episodeSeason>";
87 if ((mask & PLT_FILTER_MASK_TOC) && !m_MiscInfo.toc.IsEmpty()) {
89 PLT_Didl::AppendXmlEscape(didl, m_MiscInfo.toc);
90 @@ -547,6 +563,12 @@ PLT_MediaObject::FromDidl(NPT_XmlElementNode* entry)
92 if (NPT_FAILED(str.ToInteger(value))) value = 0;
93 m_Recorded.episode_number = value;
94 + PLT_XmlHelper::GetChildText(entry, "episodeCount", str, didl_namespace_upnp);
95 + if (NPT_FAILED(str.ToInteger(value))) value = 0;
96 + m_Recorded.episode_count = value;
97 + PLT_XmlHelper::GetChildText(entry, "episodeSeason", str, didl_namespace_upnp);
98 + if (NPT_FAILED(str.ToInteger(value))) value = -1;
99 + m_Recorded.episode_season = value;
102 PLT_XmlHelper::GetChildren(entry, children, "genre", didl_namespace_upnp);
103 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h
104 index 9df90d5..34a69b7 100644
105 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h
106 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h
107 @@ -147,6 +147,8 @@ typedef struct {
108 NPT_String program_title;
109 NPT_String series_title;
110 NPT_UInt32 episode_number;
111 + NPT_UInt32 episode_count;
112 + NPT_UInt32 episode_season;
115 /*----------------------------------------------------------------------
116 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h
117 index c6fc3be..3c14dff 100644
118 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h
119 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltSyncMediaBrowser.h
120 @@ -118,7 +118,7 @@ protected:
123 bool browse_metadata = false,
124 - const char* filter = "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution", // explicitely specify res otherwise WMP won't return a URL!
125 + const char* filter = "dc:date,dc:description,upnp:longDescription,upnp:genre,res,res@duration,res@size,upnp:albumArtURI,upnp:rating,upnp:lastPlaybackPosition,upnp:lastPlaybackTime,upnp:playbackCount,upnp:originalTrackNumber,upnp:episodeNumber,upnp:programTitle,upnp:seriesTitle,upnp:album,upnp:artist,upnp:author,upnp:director,dc:publisher,searchable,childCount,dc:title,dc:creator,upnp:actor,res@resolution,upnp:episodeCount,upnp:episodeSeason", // explicitely specify res otherwise WMP won't return a URL!
126 const char* sort = "");
128 NPT_Result Find(const char* ip, PLT_DeviceDataReference& device);