3 * Copyright (C) 2012-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
23 #include "ThumbLoader.h"
24 #include "utils/JobManager.h"
32 \brief Thumb extractor job class
34 Used by the CVideoThumbLoader to perform asynchronous generation of thumbs
36 \sa CVideoThumbLoader and CJob
38 class CThumbExtractor : public CJob
41 CThumbExtractor(const CFileItem& item, const CStdString& listpath, bool thumb, const CStdString& strTarget="");
42 virtual ~CThumbExtractor();
45 \brief Work function that extracts thumb.
47 virtual bool DoWork();
49 virtual const char* GetType() const
51 return kJobTypeMediaFlags;
54 virtual bool operator==(const CJob* job) const;
56 CStdString m_target; ///< thumbpath
57 CStdString m_listpath; ///< path used in fileitem list
59 bool m_thumb; ///< extract thumb?
62 class CVideoThumbLoader : public CThumbLoader, public CJobQueue
66 virtual ~CVideoThumbLoader();
68 virtual void OnLoaderStart();
69 virtual void OnLoaderFinish();
71 virtual bool LoadItem(CFileItem* pItem);
72 virtual bool LoadItemCached(CFileItem* pItem);
73 virtual bool LoadItemLookup(CFileItem* pItem);
75 /*! \brief Fill the thumb of a video item
76 First uses a cached thumb from a previous run, then checks for a local thumb
77 and caches it for the next run
78 \param item the CFileItem object to fill
79 \return true if we fill the thumb, false otherwise
81 virtual bool FillThumb(CFileItem &item);
83 /*! \brief Find a particular art type for a given item, optionally checking at the folder level
84 \param item the CFileItem to search.
85 \param type the type of art to look for.
86 \param checkFolder whether to also check the folder level for files. Defaults to false.
87 \return the art file (if found), else empty.
89 static std::string GetLocalArt(const CFileItem &item, const std::string &type, bool checkFolder = false);
91 /*! \brief return the available art types for a given media type
92 \param type the type of media.
93 \return a vector of art types.
96 static std::vector<std::string> GetArtTypes(const std::string &type);
98 /*! \brief helper function to retrieve a thumb URL for embedded video thumbs
99 \param item a video CFileItem.
100 \return a URL for the embedded thumb.
102 static CStdString GetEmbeddedThumbURL(const CFileItem &item);
104 /*! \brief helper function to fill the art for a video library item
105 \param item a video CFileItem
106 \return true if we fill art, false otherwise
108 virtual bool FillLibraryArt(CFileItem &item);
111 \brief Callback from CThumbExtractor on completion of a generated image
113 Performs the callbacks and updates the GUI.
115 \sa CImageLoader, IJobCallback
117 virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
119 /*! \brief set the artwork map for an item
120 In addition, sets the standard fallbacks.
121 \param item the item on which to set art.
122 \param artwork the artwork map.
124 static void SetArt(CFileItem &item, const std::map<std::string, std::string> &artwork);
127 CVideoDatabase *m_videoDatabase;
128 typedef std::map<int, std::map<std::string, std::string> > ArtCache;
131 /*! \brief Tries to detect missing data/info from a file and adds those
132 \param item The CFileItem to process
135 void DetectAndAddMissingItemData(CFileItem &item);