MythTV  master
metadatafactory.h
Go to the documentation of this file.
1 #ifndef METADATAFACTORY_H_
2 #define METADATAFACTORY_H_
3 
4 #include <utility>
5 
6 // Needed to perform a lookup
7 #include "metadatacommon.h"
9 #include "metadatadownload.h"
10 
11 // Needed to perform scans
12 #include "videoscan.h"
13 
14 // Symbol visibility
15 #include "mythmetaexp.h"
16 
17 class VideoMetadata;
18 class RecordingRule;
19 
21 {
22  public:
24  : QEvent(kEventType), m_results(res) {}
25  ~MetadataFactoryMultiResult() override;
26 
28 
29  static const Type kEventType;
30 };
31 
33 {
34  public:
36  : QEvent(kEventType), m_result(res)
37  {
38  if (m_result)
39  {
40  m_result->IncrRef();
41  }
42  }
43  ~MetadataFactorySingleResult() override;
44 
45  MetadataLookup *m_result {nullptr};
46 
47  static const Type kEventType;
48 };
49 
50 class META_PUBLIC MetadataFactoryNoResult : public QEvent
51 {
52  public:
54  : QEvent(kEventType), m_result(res)
55  {
56  if (m_result)
57  {
58  m_result->IncrRef();
59  }
60  }
61  ~MetadataFactoryNoResult() override;
62 
63  MetadataLookup *m_result {nullptr};
64 
65  static const Type kEventType;
66 };
67 
69 {
70  public:
71  MetadataFactoryVideoChanges(QList<int> adds, QList<int> movs,
72  QList<int>dels) : QEvent(kEventType),
73  m_additions(std::move(adds)),
74  m_moved(std::move(movs)),
75  m_deleted(std::move(dels)) {}
76  ~MetadataFactoryVideoChanges() override;
77 
78  QList<int> m_additions; // newly added intids
79  QList<int> m_moved; // intids moved to new filename
80  QList<int> m_deleted; // orphaned/deleted intids
81 
82  static const Type kEventType;
83 };
84 
85 class META_PUBLIC MetadataFactory : public QObject
86 {
87 
88  public:
89 
90  explicit MetadataFactory(QObject *parent);
91  ~MetadataFactory() override;
92 
93  void Lookup(ProgramInfo *pginfo, bool automatic = true,
94  bool getimages = true, bool allowgeneric = false);
95  void Lookup(VideoMetadata *metadata, bool automatic = true,
96  bool getimages = true, bool allowgeneric = false);
97  void Lookup(RecordingRule *recrule, bool automatic = true,
98  bool getimages = true, bool allowgeneric = false);
99  void Lookup(MetadataLookup *lookup);
100 
101  MetadataLookupList SynchronousLookup(const QString& title,
102  const QString& subtitle,
103  const QString& inetref,
104  int season,
105  int episode,
106  const QString& grabber,
107  bool allowgeneric = false);
108  MetadataLookupList SynchronousLookup(MetadataLookup *lookup);
109 
110  void VideoScan();
111  void VideoScan(const QStringList& hosts);
112 
113  bool IsRunning() { return m_lookupthread->isRunning() ||
114  m_imagedownload->isRunning() ||
115  m_videoscanner->isRunning(); };
116 
117  static bool VideoGrabbersFunctional();
118 
119  private:
120 
121  void customEvent(QEvent *levent) override; // QObject
122 
123  void OnMultiResult(const MetadataLookupList& list);
124  void OnSingleResult(MetadataLookup *lookup);
125  void OnNoResult(MetadataLookup *lookup);
126  void OnImageResult(MetadataLookup *lookup);
127 
128  void OnVideoResult(MetadataLookup *lookup);
129 
130  MetadataDownload *m_lookupthread {nullptr};
131  MetadataImageDownload *m_imagedownload {nullptr};
132 
133  VideoScannerThread *m_videoscanner {nullptr};
134  VideoMetadataListManager *m_mlm {nullptr};
135  bool m_scanning {false};
136 
137  // Variables used in synchronous mode
139  bool m_sync {false};
140 };
141 
146 META_PUBLIC LookupType GuessLookupType(const QString& inetref);
147 
148 #endif
VideoMetadata
Definition: videometadata.h:24
MetadataImageDownload
Definition: metadataimagedownload.h:87
VideoMetadataListManager
Definition: videometadatalistmanager.h:10
MetadataFactoryMultiResult::MetadataFactoryMultiResult
MetadataFactoryMultiResult(const MetadataLookupList &res)
Definition: metadatafactory.h:23
GuessLookupType
META_PUBLIC LookupType GuessLookupType(ProgramInfo *pginfo)
Definition: metadatafactory.cpp:645
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:28
MetadataDownload
Definition: metadatadownload.h:35
MetadataFactoryMultiResult::m_results
MetadataLookupList m_results
Definition: metadatafactory.h:27
mythmetaexp.h
MetadataFactoryVideoChanges::kEventType
static const Type kEventType
Definition: metadatafactory.h:82
MetadataFactoryNoResult
Definition: metadatafactory.h:50
MetadataLookup
Definition: metadatacommon.h:87
MetadataFactoryNoResult::kEventType
static const Type kEventType
Definition: metadatafactory.h:65
videoscan.h
VideoScannerThread
Definition: videoscan.h:60
metadatadownload.h
metadataimagedownload.h
RefCountedList< MetadataLookup >
MetadataFactoryVideoChanges
Definition: metadatafactory.h:68
MetadataFactoryVideoChanges::MetadataFactoryVideoChanges
MetadataFactoryVideoChanges(QList< int > adds, QList< int > movs, QList< int >dels)
Definition: metadatafactory.h:71
MetadataFactoryVideoChanges::m_moved
QList< int > m_moved
Definition: metadatafactory.h:79
MetadataFactory::IsRunning
bool IsRunning()
Definition: metadatafactory.h:113
MetadataFactoryMultiResult::kEventType
static const Type kEventType
Definition: metadatafactory.h:29
MetadataFactoryMultiResult
Definition: metadatafactory.h:20
MetadataFactory
Definition: metadatafactory.h:85
MetadataFactory::m_returnList
MetadataLookupList m_returnList
Definition: metadatafactory.h:138
MetadataFactorySingleResult
Definition: metadatafactory.h:32
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:67
MetadataFactorySingleResult::kEventType
static const Type kEventType
Definition: metadatafactory.h:47
LookupType
LookupType
Definition: metadatacommon.h:50
MetadataFactorySingleResult::MetadataFactorySingleResult
MetadataFactorySingleResult(MetadataLookup *res)
Definition: metadatafactory.h:35
MetadataFactoryVideoChanges::m_deleted
QList< int > m_deleted
Definition: metadatafactory.h:80
MetadataFactoryVideoChanges::m_additions
QList< int > m_additions
Definition: metadatafactory.h:78
MetadataFactoryNoResult::MetadataFactoryNoResult
MetadataFactoryNoResult(MetadataLookup *res)
Definition: metadatafactory.h:53
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
metadatacommon.h