Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / patches / 0009-platinum-add-support-for-upnp-lastPlaybackPosition-u.patch
blob4a8efb1ccbdb7c03df1da165e63e9b3bb2c26746
1 From 5f4aa26956ebc15e774186955e49cc7c77896f0e Mon Sep 17 00:00:00 2001
2 From: Alasdair Campbell <alcoheca@gmail.com>
3 Date: Mon, 30 Jul 2012 13:02:34 +0100
4 Subject: [PATCH 09/24] platinum: add support for upnp:lastPlaybackPosition,
5 upnp:lastPlaybackTime and upnp:playbackCount
7 ---
8 .../Source/Devices/MediaServer/PltMediaItem.cpp | 43 ++++++++++++++++++++++
9 .../Source/Devices/MediaServer/PltMediaItem.h | 3 ++
10 2 files changed, 46 insertions(+)
12 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp
13 index 62e0ba9..3ec7696 100644
14 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp
15 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.cpp
16 @@ -183,6 +183,9 @@ PLT_MediaObject::Reset()
17 m_ExtraInfo.artist_discography_uri = "";
19 m_MiscInfo.original_track_number = 0;
20 + m_MiscInfo.last_position = 0;
21 + m_MiscInfo.last_time = "";
22 + m_MiscInfo.play_count = -1;
23 m_MiscInfo.dvdregioncode = 0;
24 m_MiscInfo.toc = "";
25 m_MiscInfo.user_annotation = "";
26 @@ -316,6 +319,27 @@ PLT_MediaObject::ToDidl(NPT_UInt32 mask, NPT_String& didl)
27 didl += "</upnp:originalTrackNumber>";
30 + // last playback position
31 + if (m_MiscInfo.last_position > 0) {
32 + didl += "<upnp:lastPlaybackPosition>";
33 + didl += NPT_String::FromInteger(m_MiscInfo.last_position);
34 + didl += "</upnp:lastPlaybackPosition>";
35 + }
37 + // last playback datetime
38 + if (!m_MiscInfo.last_time.IsEmpty()) {
39 + didl += "<upnp:lastPlaybackTime>";
40 + PLT_Didl::AppendXmlEscape(didl, m_MiscInfo.last_time);
41 + didl += "</upnp:lastPlaybackTime>";
42 + }
44 + // playcount
45 + if (m_MiscInfo.play_count > -1) {
46 + didl += "<upnp:playbackCount>";
47 + didl += NPT_String::FromInteger(m_MiscInfo.play_count);
48 + didl += "</upnp:playbackCount>";
49 + }
51 // program title
52 if (mask & PLT_FILTER_MASK_PROGRAMTITLE && !m_Recorded.program_title.IsEmpty()) {
53 didl += "<upnp:programTitle>";
54 @@ -510,6 +534,25 @@ PLT_MediaObject::FromDidl(NPT_XmlElementNode* entry)
55 if (NPT_FAILED(str.ToInteger(value))) value = 0;
56 m_MiscInfo.original_track_number = value;
58 + PLT_XmlHelper::GetChildText(entry, "lastPlaybackPosition", str, didl_namespace_upnp);
59 + if (NPT_FAILED(str.ToInteger(value))) value = 0;
60 + m_MiscInfo.last_position = value;
62 + PLT_XmlHelper::GetChildText(entry, "lastPlaybackTime", m_MiscInfo.last_time, didl_namespace_dc, 256);
63 + NPT_String parsed_last_time;
64 + for (int format=0; format<=NPT_DateTime::FORMAT_RFC_1036; format++) {
65 + NPT_DateTime date;
66 + if (NPT_SUCCEEDED(date.FromString(m_MiscInfo.last_time, (NPT_DateTime::Format)format))) {
67 + parsed_last_time = date.ToString((NPT_DateTime::Format)format);
68 + break;
69 + }
70 + }
71 + m_MiscInfo.last_time = parsed_last_time;
73 + PLT_XmlHelper::GetChildText(entry, "playbackCount", str, didl_namespace_upnp);
74 + if (NPT_FAILED(str.ToInteger(value))) value = -1;
75 + m_MiscInfo.play_count = value;
77 children.Clear();
78 PLT_XmlHelper::GetChildren(entry, children, "res");
79 for (NPT_Cardinal i=0; i<children.GetItemCount(); i++) {
80 diff --git a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h
81 index 81f3dc8..cc3bdf9 100644
82 --- a/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h
83 +++ b/lib/libUPnP/Platinum/Source/Devices/MediaServer/PltMediaItem.h
84 @@ -130,6 +130,9 @@ typedef struct {
85 NPT_UInt32 original_track_number;
86 NPT_String toc;
87 NPT_String user_annotation; //TODO: can be multiple
88 + NPT_UInt32 last_position;
89 + NPT_String last_time;
90 + NPT_Int32 play_count;
91 } PLT_MiscInfo;
93 typedef struct {
94 --
95 1.7.11.msysgit.0