From d0ac58768f9544ee85dd54fc351c7438ec8ec351 Mon Sep 17 00:00:00 2001 From: Fredrik Zetterlund Date: Sat, 30 Aug 2014 19:49:54 +0200 Subject: [PATCH] Fix to return proper BrowseMetaData for Root-folder (Fixes DLNA for PS3) --- MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs | 8 ++++++-- MediaBrowser.Dlna/Didl/DidlBuilder.cs | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs index 6d5ed9eb8..563f9c59a 100644 --- a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs +++ b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs @@ -190,6 +190,8 @@ namespace MediaBrowser.Dlna.ContentDirectory if (string.Equals(flag, "BrowseMetadata")) { + + var folder = item as Folder; if (folder == null) @@ -198,10 +200,12 @@ namespace MediaBrowser.Dlna.ContentDirectory } else { + + var childrenResult = (await GetChildrenSorted(folder, user, sortCriteria, start, requested).ConfigureAwait(false)); totalCount = childrenResult.TotalRecordCount; - result.DocumentElement.AppendChild(_didlBuilder.GetFolderElement(result, folder, totalCount, filter)); + result.DocumentElement.AppendChild(_didlBuilder.GetFolderElement(result, folder, totalCount, filter, id)); } provided++; } @@ -237,7 +241,7 @@ namespace MediaBrowser.Dlna.ContentDirectory { new KeyValuePair("Result", resXML), new KeyValuePair("NumberReturned", provided.ToString(_usCulture)), - new KeyValuePair("TotalMatches", totalCount.ToString(_usCulture)), + new KeyValuePair("TotalMatches", id == "0" ? "1" :totalCount.ToString(_usCulture)), new KeyValuePair("UpdateID", _systemUpdateId.ToString(_usCulture)) }; } diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.cs index 69fec1e44..7f9428da5 100644 --- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs +++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs @@ -362,7 +362,7 @@ namespace MediaBrowser.Dlna.Didl container.AppendChild(res); } - public XmlElement GetFolderElement(XmlDocument doc, Folder folder, int childCount, Filter filter) + public XmlElement GetFolderElement(XmlDocument doc, Folder folder, int childCount, Filter filter, string requestedId = null) { var container = doc.CreateElement(string.Empty, "container", NS_DIDL); container.SetAttribute("restricted", "0"); @@ -380,6 +380,12 @@ namespace MediaBrowser.Dlna.Didl container.SetAttribute("parentID", parent.Id.ToString("N")); } + if (requestedId == "0") + { + container.SetAttribute("id","0"); + container.SetAttribute("parentID", "-1"); + } + AddCommonFields(folder, container, filter); AddCover(folder, container);