2 * Copyright (C) 2005-2012 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 #include "BackgroundInfoLoader.h"
24 #include "utils/JobManager.h"
27 #define kJobTypeMediaFlags "mediaflags"
30 class IStreamDetailsObserver;
36 \brief Thumb extractor job class
38 Used by the CVideoThumbLoader to perform asynchronous generation of thumbs
40 \sa CVideoThumbLoader and CJob
42 class CThumbExtractor : public CJob
45 CThumbExtractor(const CFileItem& item, const CStdString& listpath, bool thumb, const CStdString& strTarget="");
46 virtual ~CThumbExtractor();
49 \brief Work function that extracts thumb.
51 virtual bool DoWork();
53 virtual const char* GetType() const
55 return kJobTypeMediaFlags;
58 virtual bool operator==(const CJob* job) const;
60 CStdString m_path; ///< path of video to extract thumb from
61 CStdString m_target; ///< thumbpath
62 CStdString m_listpath; ///< path used in fileitem list
64 bool m_thumb; ///< extract thumb?
67 class CThumbLoader : public CBackgroundInfoLoader
70 CThumbLoader(int nThreads=-1);
71 virtual ~CThumbLoader();
73 virtual void Initialize() { };
75 /*! \brief helper function to fill the art for a library item
76 \param item a CFileItem
77 \return true if we fill art, false otherwise
79 virtual bool FillLibraryArt(CFileItem &item) { return false; }
81 /*! \brief Checks whether the given item has an image listed in the texture database
82 \param item CFileItem to check
83 \param type the type of image to retrieve
84 \return the image associated with this item
86 static CStdString GetCachedImage(const CFileItem &item, const CStdString &type);
88 /*! \brief Associate an image with the given item in the texture database
89 \param item CFileItem to associate the image with
90 \param type the type of image
91 \param image the URL of the image
93 static void SetCachedImage(const CFileItem &item, const CStdString &type, const CStdString &image);
96 class CVideoThumbLoader : public CThumbLoader, public CJobQueue
100 virtual ~CVideoThumbLoader();
102 virtual void Initialize();
103 virtual bool LoadItem(CFileItem* pItem);
104 void SetStreamDetailsObserver(IStreamDetailsObserver *pObs) { m_pStreamDetailsObs = pObs; }
106 /*! \brief Fill the thumb of a video item
107 First uses a cached thumb from a previous run, then checks for a local thumb
108 and caches it for the next run
109 \param item the CFileItem object to fill
110 \return true if we fill the thumb, false otherwise
112 static bool FillThumb(CFileItem &item);
114 /*! \brief helper function to retrieve a thumb URL for embedded video thumbs
115 \param item a video CFileItem.
116 \return a URL for the embedded thumb.
118 static CStdString GetEmbeddedThumbURL(const CFileItem &item);
120 /*! \brief helper function to fill the art for a video library item
121 \param item a video CFileItem
122 \return true if we fill art, false otherwise
124 virtual bool FillLibraryArt(CFileItem &item);
127 \brief Callback from CThumbExtractor on completion of a generated image
129 Performs the callbacks and updates the GUI.
131 \sa CImageLoader, IJobCallback
133 virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
136 virtual void OnLoaderStart();
137 virtual void OnLoaderFinish();
139 IStreamDetailsObserver *m_pStreamDetailsObs;
140 CVideoDatabase *m_database;
143 class CProgramThumbLoader : public CThumbLoader
146 CProgramThumbLoader();
147 virtual ~CProgramThumbLoader();
148 virtual bool LoadItem(CFileItem* pItem);
150 /*! \brief Fill the thumb of a programs item
151 First uses a cached thumb from a previous run, then checks for a local thumb
152 and caches it for the next run
153 \param item the CFileItem object to fill
154 \return true if we fill the thumb, false otherwise
157 static bool FillThumb(CFileItem &item);
159 /*! \brief Get a local thumb for a programs item
160 Shortcuts are checked, then we check for a file or folder thumb
161 \param item the CFileItem object to check
162 \return the local thumb (if it exists)
165 static CStdString GetLocalThumb(const CFileItem &item);
173 class CMusicThumbLoader : public CThumbLoader
177 virtual ~CMusicThumbLoader();
179 virtual void Initialize();
180 virtual bool LoadItem(CFileItem* pItem);
182 /*! \brief helper function to fill the art for a video library item
183 \param item a video CFileItem
184 \return true if we fill art, false otherwise
186 virtual bool FillLibraryArt(CFileItem &item);
188 /*! \brief Fill the thumb of a music file/folder item
189 First uses a cached thumb from a previous run, then checks for a local thumb
190 and caches it for the next run
191 \param item the CFileItem object to fill
192 \return true if we fill the thumb, false otherwise
194 static bool FillThumb(CFileItem &item);
196 static bool GetEmbeddedThumb(const std::string &path, MUSIC_INFO::EmbeddedArt &art);
199 virtual void OnLoaderStart();
200 virtual void OnLoaderFinish();
202 CMusicDatabase *m_database;