xbmc
VideoThumbLoader.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "FileItem.h"
12 #include "ThumbLoader.h"
13 #include "utils/JobManager.h"
14 
15 #include <map>
16 #include <vector>
17 
18 class CStreamDetails;
19 class CVideoDatabase;
20 class EmbeddedArt;
21 
22 using ArtMap = std::map<std::string, std::string>;
23 using ArtCache = std::map<std::pair<MediaType, int>, ArtMap>;
24 
33 class CThumbExtractor : public CJob
34 {
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;
38 
42  bool DoWork() override;
43 
44  const char* GetType() const override
45  {
46  return kJobTypeMediaFlags;
47  }
48 
49  bool operator==(const CJob* job) const override;
50 
51  std::string m_target;
52  std::string m_listpath;
53  CFileItem m_item;
54  bool m_thumb;
55  int64_t m_pos;
57 };
58 
60 {
61 public:
63  ~CVideoThumbLoader() override;
64 
65  void OnLoaderStart() override;
66  void OnLoaderFinish() override;
67 
68  bool LoadItem(CFileItem* pItem) override;
69  bool LoadItemCached(CFileItem* pItem) override;
70  bool LoadItemLookup(CFileItem* pItem) override;
71 
78  virtual bool FillThumb(CFileItem &item);
79 
86  static std::string GetLocalArt(const CFileItem &item, const std::string &type, bool checkFolder = false);
87 
93  static std::vector<std::string> GetArtTypes(const std::string &type);
94 
95  static bool IsValidArtType(const std::string& potentialArtType);
96 
97  static bool IsArtTypeInWhitelist(const std::string& artType, const std::vector<std::string>& whitelist, bool exact);
98 
103  static std::string GetEmbeddedThumbURL(const CFileItem &item);
104 
109  bool FillLibraryArt(CFileItem &item) override;
110 
118  void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
119 
120  static bool GetEmbeddedThumb(const std::string& path,
121  const std::string& type,
122  EmbeddedArt& art);
123 
124 protected:
125  CVideoDatabase *m_videoDatabase;
126  ArtCache m_artCache;
127 
132  void DetectAndAddMissingItemData(CFileItem &item);
133 
134  const ArtMap& GetArtFromCache(const std::string &mediaType, const int id);
135 };
std::string m_target
thumbpath
Definition: VideoThumbLoader.h:51
Definition: EmbeddedArt.h:38
Base class for jobs that are executed asynchronously.
Definition: Job.h:109
Definition: VideoThumbLoader.h:59
Definition: VideoDatabase.h:393
Definition: StreamDetails.h:92
bool m_thumb
extract thumb?
Definition: VideoThumbLoader.h:54
int64_t m_pos
position to extract thumb from
Definition: VideoThumbLoader.h:55
bool m_fillStreamDetails
fill in stream details?
Definition: VideoThumbLoader.h:56
bool DoWork() override
Work function that extracts thumb.
Definition: VideoThumbLoader.cpp:78
Definition: LibInputPointer.h:13
const char * GetType() const override
Function that returns the type of job.
Definition: VideoThumbLoader.h:44
std::string m_listpath
path used in fileitem list
Definition: VideoThumbLoader.h:52
Thumb extractor job class.
Definition: VideoThumbLoader.h:33
Represents a file on a share.
Definition: FileItem.h:102
Definition: ThumbLoader.h:17
Job Queue class to handle a queue of unique jobs to be processed sequentially.
Definition: JobManager.h:63