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.
11 #include "threads/CriticalSection.h"
25 class CPVRRecordingUid
;
26 class CPVRRecordingsPath
;
32 virtual ~CPVRRecordings();
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
);
42 * @brief unload all recordings.
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
);
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
);
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;
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
);
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
);
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;
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();
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;