summaryrefslogtreecommitdiff
path: root/pictureCache.h
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2015-04-04 15:10:52 +0200
committerchriszero <zerov83@gmail.com>2015-04-04 15:10:52 +0200
commit21ee9e67ff7029c099c9fd772d3dc3e23c955199 (patch)
tree254ecef54be3682aea55ff747f3d2912e5732faf /pictureCache.h
parentb3a59b06a977129bd773ff46f4fd66e0057fb9cd (diff)
downloadvdr-plugin-plex-21ee9e67ff7029c099c9fd772d3dc3e23c955199.tar.gz
vdr-plugin-plex-21ee9e67ff7029c099c9fd772d3dc3e23c955199.tar.bz2
more skindesigner support
Diffstat (limited to 'pictureCache.h')
-rw-r--r--pictureCache.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/pictureCache.h b/pictureCache.h
new file mode 100644
index 0000000..e63d44b
--- /dev/null
+++ b/pictureCache.h
@@ -0,0 +1,67 @@
+#ifndef CPICTURECACHE_H
+#define CPICTURECACHE_H
+
+#include <memory>
+#include <iostream>
+#include <fstream>
+#include <deque>
+#include <string>
+
+#include <vdr/thread.h>
+#include <vdr/plugin.h>
+
+#include "viewGridNavigator.h"
+
+enum ImageResolution {
+ SD384,
+ SD480,
+ HD720,
+ HD1080
+};
+
+class cPictureCache : public cThread
+{
+private:
+ struct CacheInfo {
+ CacheInfo(std::string Uri, int Width, int Height, std::function<void(cGridElement*)> OnCached, cGridElement* Calle) {
+ uri = Uri;
+ width = Width;
+ height = Height;
+ onCached = OnCached;
+ calle = Calle;
+ };
+ std::string uri;
+ int width;
+ int height;
+ std::function<void(cGridElement*)> onCached;
+ cGridElement* calle;
+ };
+ cPictureCache();
+ std::deque<CacheInfo> m_qImagesToLoad;
+
+
+ std::string FileName(std::string uri, int width);
+
+ std::shared_ptr<std::istream> DownloadFile(std::string uri);
+ void SaveFileToDisk(std::shared_ptr<std::istream> file, std::string fileName);
+ std::string TranscodeUri(std::string uri, int width, int height);
+
+ std::string m_cacheDir;
+
+protected:
+ virtual void Action();
+
+public:
+ static cPictureCache& GetInstance() {
+ static cPictureCache instance;
+ return instance;
+ }
+ void Stop();
+
+ bool Cached(std::string uri, int width);
+ std::string GetPath(std::string uri, int width, int height, bool& cached, std::function<void(cGridElement*)> OnCached = NULL, cGridElement* calle = NULL);
+ void Remove(cGridElement* element);
+ void Remove(std::string uri);
+};
+
+#endif // CPICTURECACHE_H