Debian Codegraph @

xbmc/pvr/recordings/PVRRecording.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
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 "XBDateTime.h"
12 #include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_providers.h"
13 #include "pvr/PVRCachedImage.h"
14 #include "threads/CriticalSection.h"
15 #include "threads/SystemClock.h"
16 #include "video/Bookmark.h"
17 #include "video/VideoInfoTag.h"
18
19 #include <memory>
20 #include <string>
21 #include <vector>
22
23 class CVideoDatabase;
24
25 struct PVR_EDL_ENTRY;
26 struct PVR_RECORDING;
27
28 namespace PVR
29 {
30 class CPVRChannel;
31 class CPVRClient;
32 class CPVRProvider;
33 class CPVRTimerInfoTag;
34
35 /*!
36 * @brief Representation of a CPVRRecording unique ID.
37 */
38 class CPVRRecordingUid final
39 {
40 public:
41 int m_iClientId; /*!< ID of the backend */
42 std::string m_strRecordingId; /*!< unique ID of the recording on the client */
43
44 CPVRRecordingUid(int iClientId, const std::string& strRecordingId);
45
46 bool operator>(const CPVRRecordingUid& right) const;
47 bool operator<(const CPVRRecordingUid& right) const;
48 bool operator==(const CPVRRecordingUid& right) const;
49 bool operator!=(const CPVRRecordingUid& right) const;
50 };
51
52 class CPVRRecording final : public CVideoInfoTag
53 {
54 public:
55 static const std::string IMAGE_OWNER_PATTERN;
56
57 CPVRRecording();
58 CPVRRecording(const PVR_RECORDING& recording, unsigned int iClientId);
59
60 bool operator==(const CPVRRecording& right) const;
61 bool operator!=(const CPVRRecording& right) const;
62
63 /*!
64 * @brief Copy over data to the given PVR_RECORDING instance.
65 * @param recording The recording instance to fill.
66 */
67 void FillAddonData(PVR_RECORDING& recording) const;
68
69 void Serialize(CVariant& value) const override;
70
71 // ISortable implementation
72 void ToSortable(SortItem& sortable, Field field) const override;
73
74 /*!
75 * @brief Reset this tag to it's initial state.
76 */
77 void Reset();
78
79 /*!
80 * @brief Delete this recording on the client (if supported).
81 * @return True if it was deleted successfully, false otherwise.
82 */
83 bool Delete();
84
85 /*!
86 * @brief Undelete this recording on the client (if supported).
87 * @return True if it was undeleted successfully, false otherwise.
88 */
89 bool Undelete();
90
91 /*!
92 * @brief Rename this recording on the client (if supported).
93 * @param strNewName The new name.
94 * @return True if it was renamed successfully, false otherwise.
95 */
96 bool Rename(const std::string& strNewName);
97
98 /*!
99 * @brief Set this recording's play count. The value will be transferred to the backend if it supports server-side play counts.
100 * @param count play count.
101 * @return True if play count was set successfully, false otherwise.
102 */
103 bool SetPlayCount(int count) override;
104
105 /*!
106 * @brief Increment this recording's play count. The value will be transferred to the backend if it supports server-side play counts.
107 * @return True if play count was increased successfully, false otherwise.
108 */
109 bool IncrementPlayCount() override;
110
111 /*!
112 * @brief Set this recording's play count without transferring the value to the backend, even if it supports server-side play counts.
113 * @param count play count.
114 * @return True if play count was set successfully, false otherwise.
115 */
116 bool SetLocalPlayCount(int count) { return CVideoInfoTag::SetPlayCount(count); }
117
118 /*!
119 * @brief Get this recording's local play count. The value will not be obtained from the backend, even if it supports server-side play counts.
120 * @return the play count.
121 */
122 int GetLocalPlayCount() const { return CVideoInfoTag::GetPlayCount(); }
123
124 /*!
125 * @brief Set this recording's resume point. The value will be transferred to the backend if it supports server-side resume points.
126 * @param resumePoint resume point.
127 * @return True if resume point was set successfully, false otherwise.
128 */
129 bool SetResumePoint(const CBookmark& resumePoint) override;
130
131 /*!
132 * @brief Set this recording's resume point. The value will be transferred to the backend if it supports server-side resume points.
133 * @param timeInSeconds the time of the resume point
134 * @param totalTimeInSeconds the total time of the video
135 * @param playerState the player state
136 * @return True if resume point was set successfully, false otherwise.
137 */
138 bool SetResumePoint(double timeInSeconds,
139 double totalTimeInSeconds,
140 const std::string& playerState = "") override;
141
142 /*!
143 * @brief Get this recording's resume point. The value will be obtained from the backend if it supports server-side resume points.
144 * @return the resume point.
145 */
146 CBookmark GetResumePoint() const override;
147
148 /*!
149 * @brief Update this recording's size. The value will be obtained from the backend if it supports server-side size retrieval.
150 * @return true if the the updated value is different, false otherwise.
151 */
152 bool UpdateRecordingSize();
153
154 /*!
155 * @brief Get this recording's local resume point. The value will not be obtained from the backend even if it supports server-side resume points.
156 * @return the resume point.
157 */
158 CBookmark GetLocalResumePoint() const { return CVideoInfoTag::GetResumePoint(); }
159
160 /*!
161 * @brief Retrieve the edit decision list (EDL) of a recording on the backend.
162 * @return The edit decision list (empty on error)
163 */
164 std::vector<PVR_EDL_ENTRY> GetEdl() const;
165
166 /*!
167 * @brief Get the resume point and play count from the database if the
168 * client doesn't handle it itself.
169 * @param db The database to read the data from.
170 * @param client The client this recording belongs to.
171 */
172 void UpdateMetadata(CVideoDatabase& db, const CPVRClient& client);
173
174 /*!
175 * @brief Update this tag with the contents of the given tag.
176 * @param tag The new tag info.
177 * @param client The client this recording belongs to.
178 */
179 void Update(const CPVRRecording& tag, const CPVRClient& client);
180
181 /*!
182 * @brief Retrieve the recording start as UTC time
183 * @return the recording start time
184 */
185 const CDateTime& RecordingTimeAsUTC() const { return m_recordingTime; }
186
187 /*!
188 * @brief Retrieve the recording start as local time
189 * @return the recording start time
190 */
191 const CDateTime& RecordingTimeAsLocalTime() const;
192
193 /*!
194 * @brief Retrieve the recording end as UTC time
195 * @return the recording end time
196 */
197 CDateTime EndTimeAsUTC() const;
198
199 /*!
200 * @brief Retrieve the recording end as local time
201 * @return the recording end time
202 */
203 CDateTime EndTimeAsLocalTime() const;
204
205 /*!
206 * @brief Check whether this recording has an expiration time
207 * @return True if the recording has an expiration time, false otherwise
208 */
209 bool HasExpirationTime() const { return m_iLifetime > 0; }
210
211 /*!
212 * @brief Retrieve the recording expiration time as local time
213 * @return the recording expiration time
214 */
215 CDateTime ExpirationTimeAsLocalTime() const;
216
217 /*!
218 * @brief Check whether this recording will immediately expire if the given lifetime value would be set
219 * @param iLifetime The lifetime value to check
220 * @return True if the recording would immediately expire, false otherwiese
221 */
222 bool WillBeExpiredWithNewLifetime(int iLifetime) const;
223
224 /*!
225 * @brief Retrieve the recording title from the URL path
226 * @param url the URL for the recording
227 * @return Title of the recording
228 */
229 static std::string GetTitleFromURL(const std::string& url);
230
231 /*!
232 * @brief If deleted but can be undeleted it is true
233 */
234 bool IsDeleted() const { return m_bIsDeleted; }
235
236 /*!
237 * @brief Check whether this is a tv or radio recording
238 * @return true if this is a radio recording, false if this is a tv recording
239 */
240 bool IsRadio() const { return m_bRadio; }
241
242 /*!
243 * @return Broadcast id of the EPG event associated with this recording or EPG_TAG_INVALID_UID
244 */
245 unsigned int BroadcastUid() const { return m_iEpgEventId; }
246
247 /*!
248 * @return Get the channel on which this recording is/was running
249 * @note Only works if the recording has a channel uid provided by the add-on
250 */
251 std::shared_ptr<CPVRChannel> Channel() const;
252
253 /*!
254 * @brief Get the uid of the channel on which this recording is/was running
255 * @return the uid of the channel or PVR_CHANNEL_INVALID_UID
256 */
257 int ChannelUid() const;
258
259 /*!
260 * @brief the identifier of the client that serves this recording
261 * @return the client identifier
262 */
263 int ClientID() const;
264
265 /*!
266 * @brief Get the recording ID as upplied by the client
267 * @return the recording identifier
268 */
269 std::string ClientRecordingID() const { return m_strRecordingId; }
270
271 /*!
272 * @brief Get the recording ID as upplied by the client
273 * @return the recording identifier
274 */
275 unsigned int RecordingID() const { return m_iRecordingId; }
276
277 /*!
278 * @brief Set the recording ID
279 * @param recordingId The new identifier
280 */
281 void SetRecordingID(unsigned int recordingId) { m_iRecordingId = recordingId; }
282
283 /*!
284 * @brief Get the directory for this recording
285 * @return the directory
286 */
287 std::string Directory() const { return m_strDirectory; }
288
289 /*!
290 * @brief Get the priority for this recording
291 * @return the priority
292 */
293 int Priority() const { return m_iPriority; }
294
295 /*!
296 * @brief Get the lifetime for this recording
297 * @return the lifetime
298 */
299 int LifeTime() const { return m_iLifetime; }
300
301 /*!
302 * @brief Set the lifetime for this recording
303 * @param lifeTime The lifetime
304 */
305 void SetLifeTime(int lifeTime) { m_iLifetime = lifeTime; }
306
307 /*!
308 * @brief Get the channel name for this recording
309 * @return the channel name
310 */
311 std::string ChannelName() const { return m_strChannelName; }
312
313 /*!
314 * @brief Return the icon path as given by the client.
315 * @return The path.
316 */
317 const std::string& ClientIconPath() const { return m_iconPath.GetClientImage(); }
318
319 /*!
320 * @brief Return the thumbnail path as given by the client.
321 * @return The path.
322 */
323 const std::string& ClientThumbnailPath() const { return m_thumbnailPath.GetClientImage(); }
324
325 /*!
326 * @brief Return the fanart path as given by the client.
327 * @return The path.
328 */
329 const std::string& ClientFanartPath() const { return m_fanartPath.GetClientImage(); }
330
331 /*!
332 * @brief Return the icon path used by Kodi.
333 * @return The path.
334 */
335 const std::string& IconPath() const { return m_iconPath.GetLocalImage(); }
336
337 /*!
338 * @brief Return the thumnail path used by Kodi.
339 * @return The path.
340 */
341 const std::string& ThumbnailPath() const { return m_thumbnailPath.GetLocalImage(); }
342
343 /*!
344 * @brief Return the fanart path used by Kodi.
345 * @return The path.
346 */
347 const std::string& FanartPath() const { return m_fanartPath.GetLocalImage(); }
348
349 /*!
350 * @brief Retrieve the recording Episode Name
351 * @note Returns an empty string if no Episode Name was provided by the PVR client
352 */
353 std::string EpisodeName() const { return m_strShowTitle; }
354
355 /*!
356 * @brief check whether this recording is currently in progress
357 * @return true if the recording is in progress, false otherwise
358 */
359 bool IsInProgress() const;
360
361 /*!
362 * @brief return the timer for an in-progress recording, if any
363 * @return the timer if the recording is in progress, nullptr otherwise
364 */
365 std::shared_ptr<CPVRTimerInfoTag> GetRecordingTimer() const;
366
367 /*!
368 * @brief set the genre for this recording.
369 * @param iGenreType The genre type ID. If set to EPG_GENRE_USE_STRING, set genre to the value provided with strGenre. Otherwise, compile the genre string from the values given by iGenreType and iGenreSubType
370 * @param iGenreSubType The genre subtype ID
371 * @param strGenre The genre
372 */
373 void SetGenre(int iGenreType, int iGenreSubType, const std::string& strGenre);
374
375 /*!
376 * @brief Get the genre type ID of this recording.
377 * @return The genre type ID.
378 */
379 int GenreType() const { return m_iGenreType; }
380
381 /*!
382 * @brief Get the genre subtype ID of this recording.
383 * @return The genre subtype ID.
384 */
385 int GenreSubType() const { return m_iGenreSubType; }
386
387 /*!
388 * @brief Get the genre as human readable string.
389 * @return The genre.
390 */
391 const std::vector<std::string> Genre() const { return m_genre; }
392
393 /*!
394 * @brief Get the genre(s) of this recording as formatted string.
395 * @return The genres label.
396 */
397 const std::string GetGenresLabel() const;
398
399 /*!
400 * @brief Get the first air date of this recording.
401 * @return The first air date.
402 */
403 CDateTime FirstAired() const;
404
405 /*!
406 * @brief Get the premiere year of this recording.
407 * @return The premiere year
408 */
409 int GetYear() const override;
410
411 /*!
412 * @brief Set the premiere year of this recording.
413 * @param year The premiere year
414 */
415 void SetYear(int year) override;
416
417 /*!
418 * @brief Check if the premiere year of this recording is valid
419 * @return True if the recording has as valid premiere date, false otherwise
420 */
421 bool HasYear() const override;
422
423 /*!
424 * @brief Check whether this recording will be flagged as new.
425 * @return True if this recording will be flagged as new, false otherwise
426 */
427 bool IsNew() const;
428
429 /*!
430 * @brief Check whether this recording will be flagged as a premiere.
431 * @return True if this recording will be flagged as a premiere, false otherwise
432 */
433 bool IsPremiere() const;
434
435 /*!
436 * @brief Check whether this recording will be flagged as a finale.
437 * @return True if this recording will be flagged as a finale, false otherwise
438 */
439 bool IsFinale() const;
440
441 /*!
442 * @brief Check whether this recording will be flagged as live.
443 * @return True if this recording will be flagged as live, false otherwise
444 */
445 bool IsLive() const;
446
447 /*!
448 * @brief Return the flags (PVR_RECORDING_FLAG_*) of this recording as a bitfield.
449 * @return the flags.
450 */
451 unsigned int Flags() const { return m_iFlags; }
452
453 /*!
454 * @brief Return the size of this recording in bytes.
455 * @return the size in bytes.
456 */
457 int64_t GetSizeInBytes() const;
458
459 /*!
460 * @brief Mark a recording as dirty/clean.
461 * @param bDirty true to mark as dirty, false to mark as clean.
462 */
463 void SetDirty(bool bDirty) { m_bDirty = bDirty; }
464
465 /*!
466 * @brief Return whether the recording is marked dirty.
467 * @return true if dirty, false otherwise.
468 */
469 bool IsDirty() const { return m_bDirty; }
470
471 /*!
472 * @brief Get the uid of the provider on the client which this recording is from
473 * @return the client uid of the provider or PVR_PROVIDER_INVALID_UID
474 */
475 int ClientProviderUniqueId() const;
476
477 /*!
478 * @brief Get the client provider name for this recording
479 * @return m_strProviderName The name for this recording provider
480 */
481 std::string ProviderName() const;
482
483 /*!
484 * @brief Get the default provider of this recording. The default
485 * provider represents the PVR add-on itself.
486 * @return The default provider of this recording
487 */
488 std::shared_ptr<CPVRProvider> GetDefaultProvider() const;
489
490 /*!
491 * @brief Whether or not this recording has a provider set by the client.
492 * @return True if a provider was set by the client, false otherwise.
493 */
494 bool HasClientProvider() const;
495
496 /*!
497 * @brief Get the provider of this recording. This may be the default provider or a
498 * custom provider set by the client. If @ref "HasClientProvider()" returns true
499 * the provider will be custom from the client, otherwise the default provider.
500 * @return The provider of this recording
501 */
502 std::shared_ptr<CPVRProvider> GetProvider() const;
503
504 private:
505 CPVRRecording(const CPVRRecording& tag) = delete;
506 CPVRRecording& operator=(const CPVRRecording& other) = delete;
507
508 void UpdatePath();
509
510 int m_iClientId; /*!< ID of the backend */
511 std::string m_strRecordingId; /*!< unique ID of the recording on the client */
512 std::string m_strChannelName; /*!< name of the channel this was recorded from */
513 int m_iPriority; /*!< priority of this recording */
514 int m_iLifetime; /*!< lifetime of this recording */
515 std::string m_strDirectory; /*!< directory of this recording on the client */
516 unsigned int m_iRecordingId; /*!< id that won't change while xbmc is running */
517
518 CPVRCachedImage m_iconPath; /*!< icon path */
519 CPVRCachedImage m_thumbnailPath; /*!< thumbnail path */
520 CPVRCachedImage m_fanartPath; /*!< fanart path */
521 CDateTime m_recordingTime; /*!< start time of the recording */
522 bool m_bGotMetaData;
523 bool m_bIsDeleted; /*!< set if entry is a deleted recording which can be undelete */
524 mutable bool m_bInProgress; /*!< set if recording might be in progress */
525 unsigned int m_iEpgEventId; /*!< epg broadcast id associated with this recording */
526 int m_iChannelUid; /*!< channel uid associated with this recording */
527 bool m_bRadio; /*!< radio or tv recording */
528 int m_iGenreType = 0; /*!< genre type */
529 int m_iGenreSubType = 0; /*!< genre subtype */
530 mutable XbmcThreads::EndTime<> m_resumePointRefetchTimeout;
531 unsigned int m_iFlags = 0; /*!< the flags applicable to this recording */
532 mutable XbmcThreads::EndTime<> m_recordingSizeRefetchTimeout;
533 int64_t m_sizeInBytes = 0; /*!< the size of the recording in bytes */
534 bool m_bDirty = false;
535 std::string m_strProviderName; /*!< name of the provider this recording is from */
536 int m_iClientProviderUniqueId =
537 PVR_PROVIDER_INVALID_UID; /*!< provider uid associated with this recording on the client */
538
539 mutable CCriticalSection m_critSection;
540 };
541 } // namespace PVR