[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / pvr / recordings / PVRRecordings.h
blob7184b6c3e8e7b3e0839df6acb22550ff37ac4a3d
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 "threads/CriticalSection.h"
13 #include <map>
14 #include <memory>
15 #include <string>
16 #include <vector>
18 class CVideoDatabase;
20 namespace PVR
22 class CPVRClient;
23 class CPVREpgInfoTag;
24 class CPVRRecording;
25 class CPVRRecordingUid;
26 class CPVRRecordingsPath;
28 class CPVRRecordings
30 public:
31 CPVRRecordings();
32 virtual ~CPVRRecordings();
34 /*!
35 * @brief Update all recordings from the given PVR clients.
36 * @param clients The PVR clients data should be loaded for. Leave empty for all clients.
37 * @return True on success, false otherwise.
39 bool Update(const std::vector<std::shared_ptr<CPVRClient>>& clients);
41 /*!
42 * @brief unload all recordings.
44 void Unload();
46 /*!
47 * @brief Update data with recordings from the given clients, sync with local data.
48 * @param clients The clients to fetch data from. Leave empty to fetch data from all created clients.
49 * @return True on success, false otherwise.
51 bool UpdateFromClients(const std::vector<std::shared_ptr<CPVRClient>>& clients);
53 /*!
54 * @brief client has delivered a new/updated recording.
55 * @param tag The recording
56 * @param client The client the recording belongs to.
58 void UpdateFromClient(const std::shared_ptr<CPVRRecording>& tag, const CPVRClient& client);
60 /*!
61 * @brief refresh the size of any in progress recordings from the clients.
63 void UpdateInProgressSize();
65 int GetNumTVRecordings() const;
66 bool HasDeletedTVRecordings() const;
67 int GetNumRadioRecordings() const;
68 bool HasDeletedRadioRecordings() const;
70 /*!
71 * @brief Set a recording's watched state
72 * @param recording The recording
73 * @param bWatched True to set watched, false to set unwatched state
74 * @return True on success, false otherwise
76 bool MarkWatched(const std::shared_ptr<CPVRRecording>& recording, bool bWatched);
78 /*!
79 * @brief Reset a recording's resume point, if any
80 * @param recording The recording
81 * @return True on success, false otherwise
83 bool ResetResumePoint(const std::shared_ptr<CPVRRecording>& recording);
85 /*!
86 * @brief Get a list of all recordings
87 * @return the list of all recordings
89 std::vector<std::shared_ptr<CPVRRecording>> GetAll() const;
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;
95 /*!
96 * @brief Get the recording for the given epg tag, if any.
97 * @param epgTag The epg tag.
98 * @return The requested recording, or an empty recordingptr if none was found.
100 std::shared_ptr<CPVRRecording> GetRecordingForEpgTag(
101 const std::shared_ptr<const CPVREpgInfoTag>& epgTag) const;
104 * @brief Erase stale texture db entries and image files.
105 * @return number of cleaned up images.
107 int CleanupCachedImages();
109 private:
111 * @brief Get/Open the video database.
112 * @return A reference to the video database.
114 CVideoDatabase& GetVideoDatabase();
117 * @brief Set a recording's play count
118 * @param recording The recording
119 * @param count The new play count
120 * @return True on success, false otherwise
122 bool SetRecordingsPlayCount(const std::shared_ptr<CPVRRecording>& recording, int count);
125 * @brief Increment a recording's play count
126 * @param recording The recording
127 * @return True on success, false otherwise
129 bool IncrementRecordingsPlayCount(const std::shared_ptr<CPVRRecording>& recording);
132 * @brief special value for parameter count of method ChangeRecordingsPlayCount
134 static const int INCREMENT_PLAY_COUNT = -1;
137 * @brief change the play count of the given recording
138 * @param recording The recording
139 * @param count The new play count or INCREMENT_PLAY_COUNT to denote that the current play count is to be incremented by one
140 * @return true if the play count was changed successfully
142 bool ChangeRecordingsPlayCount(const std::shared_ptr<CPVRRecording>& recording, int count);
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;
154 } // namespace PVR