CStdString CTextureCache::GetCachedImage(const CStdString &image, CTextureDetails &details, bool trackUsage)
{
- CStdString url = UnwrapImageURL(image);
+ CStdString url = CTextureUtils::UnwrapImageURL(image);
if (IsCachedImage(url))
return url;
return "";
}
-CStdString CTextureCache::GetWrappedImageURL(const CStdString &image, const CStdString &type, const CStdString &options)
-{
- if (StringUtils::StartsWith(image, "image://"))
- return image; // already wrapped
-
- CURL url;
- url.SetProtocol("image");
- url.SetUserName(type);
- url.SetHostName(image);
- if (!options.IsEmpty())
- {
- url.SetFileName("transform");
- url.SetOptions("?" + options);
- }
- return url.Get();
-}
-
-CStdString CTextureCache::GetWrappedThumbURL(const CStdString &image)
-{
- return GetWrappedImageURL(image, "", "size=thumb");
-}
-
-CStdString CTextureCache::UnwrapImageURL(const CStdString &image)
-{
- if (StringUtils::StartsWith(image, "image://"))
- {
- CURL url(image);
- if (url.GetUserName().IsEmpty() && url.GetOptions().IsEmpty())
- return url.GetHostName();
- }
- return image;
-}
-
bool CTextureCache::CanCacheImageURL(const CURL &url)
{
return (url.GetUserName().empty() || url.GetUserName() == "music");
return; // image is already cached and doesn't need to be checked further
// needs (re)caching
- AddJob(new CTextureCacheJob(UnwrapImageURL(url), details.hash));
+ AddJob(new CTextureCacheJob(CTextureUtils::UnwrapImageURL(url), details.hash));
}
bool CTextureCache::CacheImage(const CStdString &image, CTextureDetails &details)
CStdString CTextureCache::CacheImage(const CStdString &image, CBaseTexture **texture, CTextureDetails *details)
{
- CStdString url = UnwrapImageURL(image);
+ CStdString url = CTextureUtils::UnwrapImageURL(image);
CSingleLock lock(m_processingSection);
if (m_processing.find(url) == m_processing.end())
{
*/
static CStdString GetCachedPath(const CStdString &file);
- /*! \brief retrieve a wrapped URL for a image file
- \param image name of the file
- \param type signifies a special type of image (eg embedded video thumb, picture folder thumb)
- \param options which options we need (eg size=thumb)
- \return full wrapped URL of the image file
- */
- static CStdString GetWrappedImageURL(const CStdString &image, const CStdString &type = "", const CStdString &options = "");
- static CStdString GetWrappedThumbURL(const CStdString &image);
-
- /*! \brief Unwrap an image://<url_encoded_path> style URL
- Such urls are used for art over the webserver or other users of the VFS
- \param image url of the image
- \return the unwrapped URL, or the original URL if unwrapping is inappropriate.
- */
- static CStdString UnwrapImageURL(const CStdString &image);
-
/*! \brief check whether an image:// URL may be cached
\param url the URL to the image
\return true if the given URL may be cached, false otherwise
fieldList.push_back(fields[i].string);
}
+CStdString CTextureUtils::GetWrappedImageURL(const CStdString &image, const CStdString &type, const CStdString &options)
+{
+ if (StringUtils::StartsWith(image, "image://"))
+ return image; // already wrapped
+
+ CURL url;
+ url.SetProtocol("image");
+ url.SetUserName(type);
+ url.SetHostName(image);
+ if (!options.IsEmpty())
+ {
+ url.SetFileName("transform");
+ url.SetOptions("?" + options);
+ }
+ return url.Get();
+}
+
+CStdString CTextureUtils::GetWrappedThumbURL(const CStdString &image)
+{
+ return GetWrappedImageURL(image, "", "size=thumb");
+}
+
+CStdString CTextureUtils::UnwrapImageURL(const CStdString &image)
+{
+ if (StringUtils::StartsWith(image, "image://"))
+ {
+ CURL url(image);
+ if (url.GetUserName().IsEmpty() && url.GetOptions().IsEmpty())
+ return url.GetHostName();
+ }
+ return image;
+}
+
CTextureDatabase::CTextureDatabase()
{
}
virtual FIELD_TYPE GetFieldType(int field) const;
};
+class CTextureUtils
+{
+public:
+ /*! \brief retrieve a wrapped URL for a image file
+ \param image name of the file
+ \param type signifies a special type of image (eg embedded video thumb, picture folder thumb)
+ \param options which options we need (eg size=thumb)
+ \return full wrapped URL of the image file
+ */
+ static CStdString GetWrappedImageURL(const CStdString &image, const CStdString &type = "", const CStdString &options = "");
+ static CStdString GetWrappedThumbURL(const CStdString &image);
+
+ /*! \brief Unwrap an image://<url_encoded_path> style URL
+ Such urls are used for art over the webserver or other users of the VFS
+ \param image url of the image
+ \return the unwrapped URL, or the original URL if unwrapping is inappropriate.
+ */
+ static CStdString UnwrapImageURL(const CStdString &image);
+};
+
class CTextureDatabase : public CDatabase, public IDatabaseQueryRuleFactory
{
public:
bool needsRecaching;
CStdString image = CTextureCache::Get().CheckCachedImage(url, false, needsRecaching);
if (!image.empty() || CFile::Exists(url))
- object[field] = CTextureCache::Get().GetWrappedImageURL(url);
+ object[field] = CTextureUtils::GetWrappedImageURL(url);
else
object[field] = "";
}
#include "video/VideoDatabase.h"
#include "filesystem/Directory.h"
#include "filesystem/File.h"
-#include "TextureCache.h"
+#include "TextureDatabase.h"
#include "video/VideoThumbLoader.h"
#include "music/MusicThumbLoader.h"
#include "Util.h"
for (CGUIListItem::ArtMap::const_iterator artIt = artMap.begin(); artIt != artMap.end(); ++artIt)
{
if (!artIt->second.empty())
- artObj[artIt->first] = CTextureCache::GetWrappedImageURL(artIt->second);
+ artObj[artIt->first] = CTextureUtils::GetWrappedImageURL(artIt->second);
}
result["art"] = artObj;
fetchedArt = true;
}
else if (item->HasPictureInfoTag() && !item->HasArt("thumb"))
- item->SetArt("thumb", CTextureCache::GetWrappedThumbURL(item->GetPath()));
+ item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(item->GetPath()));
if (item->HasArt("thumb"))
- result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetArt("thumb"));
+ result["thumbnail"] = CTextureUtils::GetWrappedImageURL(item->GetArt("thumb"));
else
result["thumbnail"] = "";
}
if (item->HasArt("fanart"))
- result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetArt("fanart"));
+ result["fanart"] = CTextureUtils::GetWrappedImageURL(item->GetArt("fanart"));
else
result["fanart"] = "";
#include "VideoLibrary.h"
#include "ApplicationMessenger.h"
-#include "TextureCache.h"
+#include "TextureDatabase.h"
#include "Util.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
for (CVariant::const_iterator_map artIt = art.begin_map(); artIt != art.end_map(); artIt++)
{
if (!artIt->second.asString().empty())
- artwork[artIt->first] = CTextureCache::UnwrapImageURL(artIt->second.asString());
+ artwork[artIt->first] = CTextureUtils::UnwrapImageURL(artIt->second.asString());
}
}
}
#include "MusicThumbLoader.h"
#include "FileItem.h"
-#include "TextureCache.h"
+#include "TextureDatabase.h"
#include "music/tags/MusicInfoTag.h"
#include "music/tags/MusicInfoTagLoaderFactory.h"
#include "music/infoscanner/MusicInfoScanner.h"
if (!FillThumb(*pItem, false)) // Check for user thumbs but ignore folder thumbs
{
// No user thumb, use embedded art
- CStdString thumb = CTextureCache::GetWrappedImageURL(pItem->GetPath(), "music");
+ CStdString thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "music");
pItem->SetArt("thumb", thumb);
}
}
strItemPath.Format("fanart://Remote%i",i);
CFileItemPtr item(new CFileItem(strItemPath, false));
CStdString thumb = m_artist.fanart.GetPreviewURL(i);
- item->SetArt("thumb", CTextureCache::GetWrappedThumbURL(thumb));
+ item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb));
item->SetIconImage("DefaultPicture.png");
item->SetLabel(g_localizeStrings.Get(20441));
result.clear();
if (flip && !result.empty())
- result = CTextureCache::GetWrappedImageURL(result, "", "flipped");
+ result = CTextureUtils::GetWrappedImageURL(result, "", "flipped");
// update thumb in the database
CMusicDatabase db;
if (!art->strThumb.empty())
albumArt = art->strThumb;
else
- albumArt = CTextureCache::GetWrappedImageURL(art->strFileName, "music");
+ albumArt = CTextureUtils::GetWrappedImageURL(art->strFileName, "music");
}
if (!albumArt.empty())
for (VECSONGS::iterator k = album.songs.begin(); k != album.songs.end(); ++k)
{
if (k->strThumb.empty() && !k->embeddedArt.empty())
- k->strThumb = CTextureCache::GetWrappedImageURL(k->strFileName, "music");
+ k->strThumb = CTextureUtils::GetWrappedImageURL(k->strFileName, "music");
}
}
}
#include "video/VideoInfoTag.h"
#include "music/MusicDatabase.h"
#include "music/tags/MusicInfoTag.h"
-#include "TextureCache.h"
+#include "TextureDatabase.h"
#include "ThumbLoader.h"
#include "utils/URIUtils.h"
art.uri = upnp_server->BuildSafeResourceUri(
rooturi,
(*ips.GetFirstItem()).ToString(),
- CTextureCache::GetWrappedImageURL(thumb).c_str());
+ CTextureUtils::GetWrappedImageURL(thumb).c_str());
// Set DLNA profileID by extension, defaulting to JPEG.
if (URIUtils::HasExtension(thumb, ".png")) {
fanart = item.GetArt("fanart");
if (upnp_server && !fanart.empty())
- upnp_server->AddSafeResourceUri(object, rooturi, ips, CTextureCache::GetWrappedImageURL(fanart), "xbmc.org:*:fanart:*");
+ upnp_server->AddSafeResourceUri(object, rooturi, ips, CTextureUtils::GetWrappedImageURL(fanart), "xbmc.org:*:fanart:*");
return object;
#include "pictures/PictureInfoTag.h"
#include "interfaces/AnnouncementManager.h"
#include "settings/Settings.h"
-#include "TextureCache.h"
+#include "TextureDatabase.h"
#include "ThumbLoader.h"
#include "URL.h"
#include "utils/URIUtils.h"
else
thumb = g_infoManager.GetImage(VIDEOPLAYER_COVER, -1);
- thumb = CTextureCache::GetWrappedImageURL(thumb);
+ thumb = CTextureUtils::GetWrappedImageURL(thumb);
NPT_String ip;
if (g_application.getNetwork().GetFirstConnectedInterface()) {
CStdString thumb;
if (pItem->IsPicture() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList())
{ // load the thumb from the image file
- thumb = pItem->HasArt("thumb") ? pItem->GetArt("thumb") : CTextureCache::GetWrappedThumbURL(pItem->GetPath());
+ thumb = pItem->HasArt("thumb") ? pItem->GetArt("thumb") : CTextureUtils::GetWrappedThumbURL(pItem->GetPath());
}
else if (pItem->IsVideo() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList())
{ // video
if (items.Size() < 4 || pItem->IsCBR() || pItem->IsCBZ())
{ // less than 4 items, so just grab the first thumb
items.Sort(SortByLabel, SortOrderAscending);
- CStdString thumb = CTextureCache::GetWrappedThumbURL(items[0]->GetPath());
+ CStdString thumb = CTextureUtils::GetWrappedThumbURL(items[0]->GetPath());
db.SetTextureForPath(pItem->GetPath(), "thumb", thumb);
CTextureCache::Get().BackgroundCacheImage(thumb);
pItem->SetArt("thumb", thumb);
vector<string> files;
for (int thumb = 0; thumb < 4; thumb++)
files.push_back(items[thumb]->GetPath());
- CStdString thumb = CTextureCache::GetWrappedImageURL(pItem->GetPath(), "picturefolder");
+ CStdString thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(), "picturefolder");
CStdString relativeCacheFile = CTextureCache::GetCacheFile(thumb) + ".png";
if (CPicture::CreateTiledThumb(files, CTextureCache::GetCachedPath(relativeCacheFile)))
{
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/Variant.h"
-#include "TextureCache.h"
+#include "TextureDatabase.h"
#include "filesystem/File.h"
#include <sstream>
actor["role"] = m_cast[i].strRole;
actor["order"] = m_cast[i].order;
if (!m_cast[i].thumb.IsEmpty())
- actor["thumbnail"] = CTextureCache::GetWrappedImageURL(m_cast[i].thumb);
+ actor["thumbnail"] = CTextureUtils::GetWrappedImageURL(m_cast[i].thumb);
value["cast"].push_back(actor);
}
value["set"] = m_strSet;
if (URIUtils::IsStack(path))
path = CStackDirectory::GetFirstStackedFile(path);
- return CTextureCache::GetWrappedImageURL(path, "video");
+ return CTextureUtils::GetWrappedImageURL(path, "video");
}
void CVideoThumbLoader::OnJobComplete(unsigned int jobID, bool success, CJob* job)
strItemPath.Format("fanart://Remote%i",i);
CFileItemPtr item(new CFileItem(strItemPath, false));
CStdString thumb = m_movieItem->GetVideoInfoTag()->m_fanart.GetPreviewURL(i);
- item->SetArt("thumb", CTextureCache::GetWrappedThumbURL(thumb));
+ item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb));
item->SetIconImage("DefaultPicture.png");
item->SetLabel(g_localizeStrings.Get(20441));
// set the fanart image
if (flip && !result.IsEmpty())
- result = CTextureCache::GetWrappedImageURL(result, "", "flipped");
+ result = CTextureUtils::GetWrappedImageURL(result, "", "flipped");
CVideoDatabase db;
if (db.Open())
{
if (result.Equals("fanart://None") || !CFile::Exists(result))
result.clear();
if (!result.IsEmpty() && flip)
- result = CTextureCache::GetWrappedImageURL(result, "", "flipped");
+ result = CTextureUtils::GetWrappedImageURL(result, "", "flipped");
// update the db
CVideoDatabase db;