Repository navigation
Expand file tree
/
Copy pathThumbLoader.h
More file actions
143 lines (120 loc) · 4.03 KB
/
Copy pathThumbLoader.h
File metadata and controls
143 lines (120 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#ifndef THUMBLOADER_H
#define THUMBLOADER_H
#include "BackgroundInfoLoader.h"
#include "utils/JobManager.h"
#include "FileItem.h"
class CStreamDetails;
class IStreamDetailsObserver;
/*!
\ingroup thumbs,jobs
\brief Thumb extractor job class
Used by the CVideoThumbLoader to perform asynchronous generation of thumbs
\sa CVideoThumbLoader and CJob
*/
class CThumbExtractor : public CJob
{
public:
CThumbExtractor(const CFileItem& item, const CStdString& listpath, bool thumb, const CStdString& strTarget="");
virtual ~CThumbExtractor();
/*!
\brief Work function that extracts thumb.
*/
virtual bool DoWork();
virtual const char* GetType() const
{
return "mediaflags";
}
virtual bool operator==(const CJob* job) const;
CStdString m_path; ///< path of video to extract thumb from
CStdString m_target; ///< thumbpath
CStdString m_listpath; ///< path used in fileitem list
CFileItem m_item;
bool m_thumb; ///< extract thumb?
};
class CThumbLoader : public CBackgroundInfoLoader
{
public:
CThumbLoader(int nThreads=-1);
virtual ~CThumbLoader();
bool LoadRemoteThumb(CFileItem *pItem);
/*! \brief Checks whether the given item has a thumb that needs caching, and if so caches it.
\param item CFileItem to check for a cachable thumb.
\return true if we successfully cache a thumb, false otherwise.
\sa GetCachedThumb
*/
static bool CheckAndCacheThumb(CFileItem &item);
/*! \brief Checks whether the given item has a thumb listed in the texture database
\param item CFileItem to check for a thumb
\return the thumb associated with this item
\sa CheckAndCacheThumb
*/
static CStdString GetCachedThumb(const CFileItem &item);
};
class CVideoThumbLoader : public CThumbLoader, public CJobQueue
{
public:
CVideoThumbLoader();
virtual ~CVideoThumbLoader();
virtual bool LoadItem(CFileItem* pItem);
void SetStreamDetailsObserver(IStreamDetailsObserver *pObs) { m_pStreamDetailsObs = pObs; }
/*!
\brief Callback from CThumbExtractor on completion of a generated image
Performs the callbacks and updates the GUI.
\sa CImageLoader, IJobCallback
*/
virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
protected:
virtual void OnLoaderStart() ;
virtual void OnLoaderFinish() ;
IStreamDetailsObserver *m_pStreamDetailsObs;
};
class CProgramThumbLoader : public CThumbLoader
{
public:
CProgramThumbLoader();
virtual ~CProgramThumbLoader();
virtual bool LoadItem(CFileItem* pItem);
/*! \brief Fill the thumb of a programs item
First uses a cached thumb from a previous run, then checks for a local thumb
and caches it for the next run
\param item the CFileItem object to fill
\return true if we fill the thumb, false otherwise
\sa GetLocalThumb
*/
static bool FillThumb(CFileItem &item);
/*! \brief Get a local thumb for a programs item
Shortcuts are checked, then we check for a file or folder thumb
\param item the CFileItem object to check
\return the local thumb (if it exists)
\sa FillThumb
*/
static CStdString GetLocalThumb(const CFileItem &item);
};
class CMusicThumbLoader : public CThumbLoader
{
public:
CMusicThumbLoader();
virtual ~CMusicThumbLoader();
virtual bool LoadItem(CFileItem* pItem);
};
#endif