kodi
PVRRecordings.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 "threads/CriticalSection.h"
12 
13 #include <map>
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 class CVideoDatabase;
19 
20 namespace PVR
21 {
22 class CPVRClient;
23 class CPVREpgInfoTag;
24 class CPVRRecording;
25 class CPVRRecordingUid;
26 class CPVRRecordingsPath;
27 
29 {
30 public:
32  virtual ~CPVRRecordings();
33 
39  bool Update(const std::vector<std::shared_ptr<CPVRClient>>& clients);
40 
44  void Unload();
45 
51  bool UpdateFromClients(const std::vector<std::shared_ptr<CPVRClient>>& clients);
52 
58  void UpdateFromClient(const std::shared_ptr<CPVRRecording>& tag, const CPVRClient& client);
59 
63  void UpdateInProgressSize();
64 
65  int GetNumTVRecordings() const;
66  bool HasDeletedTVRecordings() const;
67  int GetNumRadioRecordings() const;
68  bool HasDeletedRadioRecordings() const;
69 
76  bool MarkWatched(const std::shared_ptr<CPVRRecording>& recording, bool bWatched);
77 
83  bool ResetResumePoint(const std::shared_ptr<CPVRRecording>& recording);
84 
89  std::vector<std::shared_ptr<CPVRRecording>> GetAll() const;
90 
91  std::shared_ptr<CPVRRecording> GetByPath(const std::string& path) const;
92  std::shared_ptr<CPVRRecording> GetById(int iClientId, const std::string& strRecordingId) const;
93  std::shared_ptr<CPVRRecording> GetById(unsigned int iId) const;
94 
100  std::shared_ptr<CPVRRecording> GetRecordingForEpgTag(
101  const std::shared_ptr<const CPVREpgInfoTag>& epgTag) const;
102 
107  int CleanupCachedImages();
108 
109 private:
114  CVideoDatabase& GetVideoDatabase();
115 
122  bool SetRecordingsPlayCount(const std::shared_ptr<CPVRRecording>& recording, int count);
123 
129  bool IncrementRecordingsPlayCount(const std::shared_ptr<CPVRRecording>& recording);
130 
134  static const int INCREMENT_PLAY_COUNT = -1;
135 
142  bool ChangeRecordingsPlayCount(const std::shared_ptr<CPVRRecording>& recording, int count);
143 
144  mutable CCriticalSection m_critSection;
145  bool m_bIsUpdating = false;
146  std::map<CPVRRecordingUid, std::shared_ptr<CPVRRecording>> m_recordings;
147  unsigned int m_iLastId = 0;
148  std::unique_ptr<CVideoDatabase> m_database;
149  bool m_bDeletedTVRecordings = false;
150  bool m_bDeletedRadioRecordings = false;
151  unsigned int m_iTVRecordings = 0;
152  unsigned int m_iRadioRecordings = 0;
153 };
154 } // namespace PVR
Definition: PVRRecordings.h:28
int CleanupCachedImages()
Erase stale texture db entries and image files.
Definition: PVRRecordings.cpp:342
Definition: ContextMenuManager.h:24
bool ResetResumePoint(const std::shared_ptr< CPVRRecording > &recording)
Reset a recording&#39;s resume point, if any.
Definition: PVRRecordings.cpp:306
bool MarkWatched(const std::shared_ptr< CPVRRecording > &recording, bool bWatched)
Set a recording&#39;s watched state.
Definition: PVRRecordings.cpp:298
Definition: VideoDatabase.h:419
void UpdateFromClient(const std::shared_ptr< CPVRRecording > &tag, const CPVRClient &client)
client has delivered a new/updated recording.
Definition: PVRRecordings.cpp:190
std::shared_ptr< CPVRRecording > GetRecordingForEpgTag(const std::shared_ptr< const CPVREpgInfoTag > &epgTag) const
Get the recording for the given epg tag, if any.
Definition: PVRRecordings.cpp:221
bool UpdateFromClients(const std::vector< std::shared_ptr< CPVRClient >> &clients)
Update data with recordings from the given clients, sync with local data.
Definition: PVRRecordings.cpp:40
void UpdateInProgressSize()
refresh the size of any in progress recordings from the clients.
Definition: PVRRecordings.cpp:86
void Unload()
unload all recordings.
Definition: PVRRecordings.cpp:76
bool Update(const std::vector< std::shared_ptr< CPVRClient >> &clients)
Update all recordings from the given PVR clients.
Definition: PVRRecordings.cpp:71
std::vector< std::shared_ptr< CPVRRecording > > GetAll() const
Get a list of all recordings.
Definition: PVRRecordings.cpp:133
Definition: PVRClient.h:52