2018-03-31, 18:13
Hello everyone,
Those of you who use Kodi as UPnP client know how frustrating it is that you have to restart Kodi every time the content of your DLNA/UPnP server changes.
I googled this forum and all other places in search for an answer to this issue.
Some users suggested that Kodi expects DLNA/UPnp server to send a notification when content on the server side changes. So, initially I was blaming my DLNA server (I use miniDLNA) for not sending notifications to Kodi. Well, after some modifications I made to miniDLNA, it sends notifications about changed content to all subscribers properly. Still, Kodi didn't update UPnP directory content after notification.
Digging this issue further, I was able to prove that Kodi, after initial query of a specific directory content of UPnP source, was never querying that directory again, even after notification from DLNA server about content change.
So, my next step was to find what is Kodi doing upon receiving notification messages from DLNA server. Kodi does subscribe for notifications for two services, ContentDirectory and ConnectionManager, but the handler for these notifications is not looking for content change message. I believe Kodi doesn't expect directory content notifications, it only looks for changes in parameters like audio volume level, I didn't go into details because it was not related to filesystem notifications.
Thus, the only way to force Kodi to see changes on the DLNA server is to disable its internal directory cache for UPnP sources. This way Kodi would re-read each directory every time you navigate/browse into it. Western Digital LiveTV box does it like this and I never had issues of not being able to see content of DLNA server after content change without restarting UPnP client.
Sorry for very long explanation of why and how I came up with this patch, but maybe some users would be interested.
Here is the patch:
With this patch, to update the content of the modified directory, all you have to do is to re-read this directory: go one directory level up and then come back, or go into any subdirectory and then step back.
If parent of your current directory is renamed or moved, then you have to re-start browsing from the root directory.
This patch is made for Kodi v17.3-r1 (Krypton), on a Gentoo Linux. I guess it would be easy to adapt it for other versions of Kodi too.
Ideally, UPnP directory caching should be controlled (enabled/disabled) from user interface, but that would take for me a lot of time to implement as I am not a Kodi developer.
Here is the quick list of the threads on this forum regarding this issue:
Well, thanks for reading this if you've got this far.
Alex.
Those of you who use Kodi as UPnP client know how frustrating it is that you have to restart Kodi every time the content of your DLNA/UPnP server changes.
I googled this forum and all other places in search for an answer to this issue.
Some users suggested that Kodi expects DLNA/UPnp server to send a notification when content on the server side changes. So, initially I was blaming my DLNA server (I use miniDLNA) for not sending notifications to Kodi. Well, after some modifications I made to miniDLNA, it sends notifications about changed content to all subscribers properly. Still, Kodi didn't update UPnP directory content after notification.
Digging this issue further, I was able to prove that Kodi, after initial query of a specific directory content of UPnP source, was never querying that directory again, even after notification from DLNA server about content change.
So, my next step was to find what is Kodi doing upon receiving notification messages from DLNA server. Kodi does subscribe for notifications for two services, ContentDirectory and ConnectionManager, but the handler for these notifications is not looking for content change message. I believe Kodi doesn't expect directory content notifications, it only looks for changes in parameters like audio volume level, I didn't go into details because it was not related to filesystem notifications.
Thus, the only way to force Kodi to see changes on the DLNA server is to disable its internal directory cache for UPnP sources. This way Kodi would re-read each directory every time you navigate/browse into it. Western Digital LiveTV box does it like this and I never had issues of not being able to see content of DLNA server after content change without restarting UPnP client.
Sorry for very long explanation of why and how I came up with this patch, but maybe some users would be interested.
Here is the patch:
Quote:diff --git a/xbmc/filesystem/UPnPDirectory.h b/xbmc/filesystem/UPnPDirectory.hSorry, I cannot guide you though steps how to use this patch or how to re-compile Kodi.
index adaf4df..b469172 100644
--- a/xbmc/filesystem/UPnPDirectory.h
+++ b/xbmc/filesystem/UPnPDirectory.h
@@ -40,6 +40,7 @@ public:
// IDirectory methods
virtual bool GetDirectory(const CURL& url, CFileItemList &items);
virtual bool AllowAll() const { return true; }
+ virtual DIR_CACHE_TYPE GetCacheType(const CURL& url) const { return DIR_CACHE_NEVER; };
// class methods
static const char* GetFriendlyName(const CURL& url);
diff --git a/xbmc/network/upnp/UPnP.cpp b/xbmc/network/upnp/UPnP.cpp
index 2370ee6..1ee6005 100644
--- a/xbmc/network/upnp/UPnP.cpp
+++ b/xbmc/network/upnp/UPnP.cpp
@@ -177,7 +177,7 @@ class CMediaBrowser : public PLT_SyncMediaBrowser,
{
public:
CMediaBrowser(PLT_CtrlPointReference& ctrlPoint)
- : PLT_SyncMediaBrowser(ctrlPoint, true)
+ : PLT_SyncMediaBrowser(ctrlPoint, false)
{
SetContainerListener(this);
}
With this patch, to update the content of the modified directory, all you have to do is to re-read this directory: go one directory level up and then come back, or go into any subdirectory and then step back.
If parent of your current directory is renamed or moved, then you have to re-start browsing from the root directory.
This patch is made for Kodi v17.3-r1 (Krypton), on a Gentoo Linux. I guess it would be easy to adapt it for other versions of Kodi too.
Ideally, UPnP directory caching should be controlled (enabled/disabled) from user interface, but that would take for me a lot of time to implement as I am not a Kodi developer.
Here is the quick list of the threads on this forum regarding this issue:
- DLNA refresh for files ain't working
- Does XBMC cache upnp:// directory listings
- XBMC UPNP
- refresh upnp file listing and easy volume control
Well, thanks for reading this if you've got this far.
Alex.