[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / video / VideoThumbLoader.h
blob3c2d9f045339b625b928ccd1d242633864f0ab85
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "FileItem.h"
12 #include "ThumbLoader.h"
13 #include "utils/JobManager.h"
15 #include <map>
16 #include <vector>
18 class CStreamDetails;
19 class CVideoDatabase;
20 class EmbeddedArt;
22 using ArtMap = std::map<std::string, std::string>;
23 using ArtCache = std::map<std::pair<MediaType, int>, ArtMap>;
25 /*!
26 \ingroup thumbs,jobs
27 \brief Thumb extractor job class
29 Used by the CVideoThumbLoader to perform asynchronous generation of thumbs
31 \sa CVideoThumbLoader and CJob
33 class CThumbExtractor : public CJob
35 public:
36 CThumbExtractor(const CFileItem& item, const std::string& listpath, bool thumb, const std::string& strTarget="", int64_t pos = -1, bool fillStreamDetails = true);
37 ~CThumbExtractor() override;
39 /*!
40 \brief Work function that extracts thumb.
42 bool DoWork() override;
44 const char* GetType() const override
46 return kJobTypeMediaFlags;
49 bool operator==(const CJob* job) const override;
51 std::string m_target; ///< thumbpath
52 std::string m_listpath; ///< path used in fileitem list
53 CFileItem m_item;
54 bool m_thumb; ///< extract thumb?
55 int64_t m_pos; ///< position to extract thumb from
56 bool m_fillStreamDetails; ///< fill in stream details?
59 class CVideoThumbLoader : public CThumbLoader, public CJobQueue
61 public:
62 CVideoThumbLoader();
63 ~CVideoThumbLoader() override;
65 void OnLoaderStart() override;
66 void OnLoaderFinish() override;
68 bool LoadItem(CFileItem* pItem) override;
69 bool LoadItemCached(CFileItem* pItem) override;
70 bool LoadItemLookup(CFileItem* pItem) override;
72 /*! \brief Fill the thumb of a video item
73 First uses a cached thumb from a previous run, then checks for a local thumb
74 and caches it for the next run
75 \param item the CFileItem object to fill
76 \return true if we fill the thumb, false otherwise
78 virtual bool FillThumb(CFileItem &item);
80 /*! \brief Find a particular art type for a given item, optionally checking at the folder level
81 \param item the CFileItem to search.
82 \param type the type of art to look for.
83 \param checkFolder whether to also check the folder level for files. Defaults to false.
84 \return the art file (if found), else empty.
86 static std::string GetLocalArt(const CFileItem &item, const std::string &type, bool checkFolder = false);
88 /*! \brief return the available art types for a given media type
89 \param type the type of media.
90 \return a vector of art types.
91 \sa GetLocalArt
93 static std::vector<std::string> GetArtTypes(const std::string &type);
95 static bool IsValidArtType(const std::string& potentialArtType);
97 static bool IsArtTypeInWhitelist(const std::string& artType, const std::vector<std::string>& whitelist, bool exact);
99 /*! \brief helper function to retrieve a thumb URL for embedded video thumbs
100 \param item a video CFileItem.
101 \return a URL for the embedded thumb.
103 static std::string GetEmbeddedThumbURL(const CFileItem &item);
105 /*! \brief helper function to fill the art for a video library item
106 \param item a video CFileItem
107 \return true if we fill art, false otherwise
109 bool FillLibraryArt(CFileItem &item) override;
112 \brief Callback from CThumbExtractor on completion of a generated image
114 Performs the callbacks and updates the GUI.
116 \sa CImageLoader, IJobCallback
118 void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
120 static bool GetEmbeddedThumb(const std::string& path,
121 const std::string& type,
122 EmbeddedArt& art);
124 protected:
125 CVideoDatabase *m_videoDatabase;
126 ArtCache m_artCache;
128 /*! \brief Tries to detect missing data/info from a file and adds those
129 \param item The CFileItem to process
130 \return void
132 void DetectAndAddMissingItemData(CFileItem &item);
134 const ArtMap& GetArtFromCache(const std::string &mediaType, const int id);