Kodi Development  19.0
for Binary and Script based Add-Ons
General.h
1 /*
2  * Copyright (C) 2005-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 "../../AddonBase.h"
12 #include "../../c-api/addon-instance/pvr/pvr_general.h"
13 
14 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15 // "C++" Definitions group 1 - General PVR
16 #ifdef __cplusplus
17 
18 namespace kodi
19 {
20 namespace addon
21 {
22 
23 //==============================================================================
34 class PVRTypeIntValue : public CStructHdl<PVRTypeIntValue, PVR_ATTRIBUTE_INT_VALUE>
35 {
36  friend class CInstancePVRClient;
37 
38 public:
40  PVRTypeIntValue(const PVRTypeIntValue& data) : CStructHdl(data) {}
43 
56 
60  PVRTypeIntValue() = default;
61 
66  PVRTypeIntValue(int value, const std::string& description)
67  {
68  SetValue(value);
69  SetDescription(description);
70  }
71 
73  void SetValue(int value) { m_cStructure->iValue = value; }
74 
76  int GetValue() const { return m_cStructure->iValue; }
77 
79  void SetDescription(const std::string& description)
80  {
81  strncpy(m_cStructure->strDescription, description.c_str(),
82  sizeof(m_cStructure->strDescription) - 1);
83  }
84 
86  std::string GetDescription() const { return m_cStructure->strDescription; }
88 
89 private:
90  PVRTypeIntValue(const PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {}
91  PVRTypeIntValue(PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {}
92 };
94 //------------------------------------------------------------------------------
95 
96 //==============================================================================
116 {
117  friend class CInstancePVRClient;
118 
119 public:
121  explicit PVRCapabilities() = delete;
124 
158 
160  void SetSupportsEPG(bool supportsEPG) { m_capabilities->bSupportsEPG = supportsEPG; }
161 
163  bool GetSupportsEPG() const { return m_capabilities->bSupportsEPG; }
164 
167  void SetSupportsEPGEdl(bool supportsEPGEdl) { m_capabilities->bSupportsEPGEdl = supportsEPGEdl; }
168 
170  bool GetSupportsEPGEdl() const { return m_capabilities->bSupportsEPGEdl; }
171 
173  void SetSupportsTV(bool supportsTV) { m_capabilities->bSupportsTV = supportsTV; }
174 
176  bool GetSupportsTV() const { return m_capabilities->bSupportsTV; }
177 
179  void SetSupportsRadio(bool supportsRadio) { m_capabilities->bSupportsRadio = supportsRadio; }
180 
182  bool GetSupportsRadio() const { return m_capabilities->bSupportsRadio; }
183 
186  void SetSupportsRecordings(bool supportsRecordings)
187  {
188  m_capabilities->bSupportsRecordings = supportsRecordings;
189  }
190 
192  bool GetSupportsRecordings() const { return m_capabilities->bSupportsRecordings; }
193 
196  void SetSupportsRecordingsUndelete(bool supportsRecordingsUndelete)
197  {
198  m_capabilities->bSupportsRecordingsUndelete = supportsRecordingsUndelete;
199  }
200 
202  bool GetSupportsRecordingsUndelete() const { return m_capabilities->bSupportsRecordingsUndelete; }
203 
206  void SetSupportsTimers(bool supportsTimers) { m_capabilities->bSupportsTimers = supportsTimers; }
207 
209  bool GetSupportsTimers() const { return m_capabilities->bSupportsTimers; }
210 
217  void SetSupportsChannelGroups(bool supportsChannelGroups)
218  {
219  m_capabilities->bSupportsChannelGroups = supportsChannelGroups;
220  }
221 
223  bool GetSupportsChannelGroups() const { return m_capabilities->bSupportsChannelGroups; }
224 
230  void SetSupportsChannelScan(bool supportsChannelScan)
231  {
232  m_capabilities->bSupportsChannelScan = supportsChannelScan;
233  }
234 
236  bool GetSupportsChannelScan() const { return m_capabilities->bSupportsChannelScan; }
237 
245  void SetSupportsChannelSettings(bool supportsChannelSettings)
246  {
247  m_capabilities->bSupportsChannelSettings = supportsChannelSettings;
248  }
249 
251  bool GetSupportsChannelSettings() const { return m_capabilities->bSupportsChannelSettings; }
252 
255  void SetHandlesInputStream(bool handlesInputStream)
256  {
257  m_capabilities->bHandlesInputStream = handlesInputStream;
258  }
259 
261  bool GetHandlesInputStream() const { return m_capabilities->bHandlesInputStream; }
262 
264  void SetHandlesDemuxing(bool handlesDemuxing)
265  {
266  m_capabilities->bHandlesDemuxing = handlesDemuxing;
267  }
268 
270  bool GetHandlesDemuxing() const { return m_capabilities->bHandlesDemuxing; }
271 
273  void SetSupportsRecordingPlayCount(bool supportsRecordingPlayCount)
274  {
275  m_capabilities->bSupportsRecordingPlayCount = supportsRecordingPlayCount;
276  }
277 
279  bool GetSupportsRecordingPlayCount() const { return m_capabilities->bSupportsRecordingPlayCount; }
280 
283  void SetSupportsLastPlayedPosition(bool supportsLastPlayedPosition)
284  {
285  m_capabilities->bSupportsLastPlayedPosition = supportsLastPlayedPosition;
286  }
287 
289  bool GetSupportsLastPlayedPosition() const { return m_capabilities->bSupportsLastPlayedPosition; }
290 
293  void SetSupportsRecordingEdl(bool supportsRecordingEdl)
294  {
295  m_capabilities->bSupportsRecordingEdl = supportsRecordingEdl;
296  }
297 
299  bool GetSupportsRecordingEdl() const { return m_capabilities->bSupportsRecordingEdl; }
300 
302  void SetSupportsRecordingsRename(bool supportsRecordingsRename)
303  {
304  m_capabilities->bSupportsRecordingsRename = supportsRecordingsRename;
305  }
306 
308  bool GetSupportsRecordingsRename() const { return m_capabilities->bSupportsRecordingsRename; }
309 
312  void SetSupportsRecordingsLifetimeChange(bool supportsRecordingsLifetimeChange)
313  {
314  m_capabilities->bSupportsRecordingsLifetimeChange = supportsRecordingsLifetimeChange;
315  }
316 
320  {
321  return m_capabilities->bSupportsRecordingsLifetimeChange;
322  }
323 
326  void SetSupportsDescrambleInfo(bool supportsDescrambleInfo)
327  {
328  m_capabilities->bSupportsDescrambleInfo = supportsDescrambleInfo;
329  }
330 
332  bool GetSupportsDescrambleInfo() const { return m_capabilities->bSupportsDescrambleInfo; }
333 
337  void SetSupportsAsyncEPGTransfer(bool supportsAsyncEPGTransfer)
338  {
339  m_capabilities->bSupportsAsyncEPGTransfer = supportsAsyncEPGTransfer;
340  }
341 
343  bool GetSupportsAsyncEPGTransfer() const { return m_capabilities->bSupportsAsyncEPGTransfer; }
344 
346  void SetSupportsRecordingSize(bool supportsRecordingSize)
347  {
348  m_capabilities->bSupportsRecordingSize = supportsRecordingSize;
349  }
350 
352  bool GetSupportsRecordingSize() const { return m_capabilities->bSupportsRecordingSize; }
353 
361  const std::vector<PVRTypeIntValue>& recordingsLifetimeValues)
362  {
363  m_capabilities->iRecordingsLifetimesSize = 0;
364  for (unsigned int i = 0; i < recordingsLifetimeValues.size() &&
365  i < sizeof(m_capabilities->recordingsLifetimeValues);
366  ++i)
367  {
368  m_capabilities->recordingsLifetimeValues[i].iValue =
369  recordingsLifetimeValues[i].GetCStructure()->iValue;
370  strncpy(m_capabilities->recordingsLifetimeValues[i].strDescription,
371  recordingsLifetimeValues[i].GetCStructure()->strDescription,
372  sizeof(m_capabilities->recordingsLifetimeValues[i].strDescription) - 1);
373  ++m_capabilities->iRecordingsLifetimesSize;
374  }
375  }
376 
378  std::vector<PVRTypeIntValue> GetRecordingsLifetimeValues() const
379  {
380  std::vector<PVRTypeIntValue> recordingsLifetimeValues;
381  for (unsigned int i = 0; i < m_capabilities->iRecordingsLifetimesSize; ++i)
382  recordingsLifetimeValues.emplace_back(
383  m_capabilities->recordingsLifetimeValues[i].iValue,
384  m_capabilities->recordingsLifetimeValues[i].strDescription);
385  return recordingsLifetimeValues;
386  }
388 
389 private:
390  PVRCapabilities(PVR_ADDON_CAPABILITIES* capabilities) : m_capabilities(capabilities) {}
391 
392  PVR_ADDON_CAPABILITIES* m_capabilities;
393 };
395 //------------------------------------------------------------------------------
396 
397 //==============================================================================
444 class PVRStreamProperty : public CStructHdl<PVRStreamProperty, PVR_NAMED_VALUE>
445 {
446  friend class CInstancePVRClient;
447 
448 public:
450  PVRStreamProperty(const PVRStreamProperty& data) : CStructHdl(data) {}
453 
466 
470  PVRStreamProperty() = default;
471 
476  PVRStreamProperty(const std::string& name, const std::string& value)
477  {
478  SetName(name);
479  SetValue(value);
480  }
481 
483  void SetName(const std::string& name)
484  {
485  strncpy(m_cStructure->strName, name.c_str(), sizeof(m_cStructure->strName) - 1);
486  }
487 
489  std::string GetName() const { return m_cStructure->strName; }
490 
492  void SetValue(const std::string& value)
493  {
494  strncpy(m_cStructure->strValue, value.c_str(), sizeof(m_cStructure->strValue) - 1);
495  }
496 
498  std::string GetValue() const { return m_cStructure->strValue; }
500 
501 private:
502  PVRStreamProperty(const PVR_NAMED_VALUE* data) : CStructHdl(data) {}
503  PVRStreamProperty(PVR_NAMED_VALUE* data) : CStructHdl(data) {}
504 };
506 //------------------------------------------------------------------------------
507 
508 } /* namespace addon */
509 } /* namespace kodi */
510 
511 #endif /* __cplusplus */
kodi::addon::PVRStreamProperty::PVRStreamProperty
PVRStreamProperty()=default
Default class constructor.
kodi::addon::PVRCapabilities::SetSupportsChannelSettings
void SetSupportsChannelSettings(bool supportsChannelSettings)
Set true if this add-on supports channel edit.
Definition: General.h:245
kodi::addon::PVRCapabilities::GetSupportsLastPlayedPosition
bool GetSupportsLastPlayedPosition() const
To get with SetSupportsLastPlayedPosition changed values.
Definition: General.h:289
kodi::addon::PVRCapabilities::GetSupportsRecordingsRename
bool GetSupportsRecordingsRename() const
To get with SetSupportsRecordingsRename changed values.
Definition: General.h:308
kodi::addon::PVRCapabilities::GetSupportsAsyncEPGTransfer
bool GetSupportsAsyncEPGTransfer() const
To get with SetSupportsAsyncEPGTransfer changed values.
Definition: General.h:343
kodi::addon::PVRCapabilities::SetSupportsChannelScan
void SetSupportsChannelScan(bool supportsChannelScan)
Set true if this add-on support scanning for new channels on the backend.
Definition: General.h:230
kodi::addon::PVRTypeIntValue::GetValue
int GetValue() const
To get with the identification value.
Definition: General.h:76
kodi::addon::PVRCapabilities::GetSupportsEPGEdl
bool GetSupportsEPGEdl() const
To get with SetSupportsEPGEdl changed values.
Definition: General.h:170
kodi::addon::PVRCapabilities::SetSupportsEPG
void SetSupportsEPG(bool supportsEPG)
Set true if the add-on provides EPG information.
Definition: General.h:160
kodi::addon::PVRStreamProperty::PVRStreamProperty
PVRStreamProperty(const std::string &name, const std::string &value)
Class constructor with integrated value set.
Definition: General.h:476
kodi::addon::PVRStreamProperty::GetValue
std::string GetValue() const
To get with the used property value.
Definition: General.h:498
kodi::addon::PVRTypeIntValue::SetValue
void SetValue(int value)
To set with the identification value.
Definition: General.h:73
kodi::addon::PVRCapabilities::GetSupportsRecordingPlayCount
bool GetSupportsRecordingPlayCount() const
To get with SetSupportsRecordingPlayCount changed values.
Definition: General.h:279
kodi::addon::PVRCapabilities::SetSupportsRecordingPlayCount
void SetSupportsRecordingPlayCount(bool supportsRecordingPlayCount)
Set true if the backend supports play count for recordings.
Definition: General.h:273
kodi::addon::PVRCapabilities::SetSupportsChannelGroups
void SetSupportsChannelGroups(bool supportsChannelGroups)
Set true if this add-on supports channel groups.
Definition: General.h:217
kodi::addon::PVRCapabilities::SetSupportsDescrambleInfo
void SetSupportsDescrambleInfo(bool supportsDescrambleInfo)
Set true if the backend supports descramble information for playing channels.
Definition: General.h:326
kodi::addon::PVRCapabilities::GetSupportsChannelGroups
bool GetSupportsChannelGroups() const
To get with SetSupportsChannelGroups changed values.
Definition: General.h:223
kodi::addon::PVRCapabilities::SetHandlesInputStream
void SetHandlesInputStream(bool handlesInputStream)
Set true if this add-on provides an input stream. false if Kodi handles the stream.
Definition: General.h:255
kodi::addon::PVRTypeIntValue::PVRTypeIntValue
PVRTypeIntValue()=default
Default class constructor.
kodi::addon::PVRCapabilities::GetSupportsDescrambleInfo
bool GetSupportsDescrambleInfo() const
To get with SetSupportsDescrambleInfo changed values.
Definition: General.h:332
kodi::addon::PVRCapabilities::GetSupportsTimers
bool GetSupportsTimers() const
To get with SetSupportsTimers changed values.
Definition: General.h:209
kodi::addon::PVRCapabilities::SetSupportsAsyncEPGTransfer
void SetSupportsAsyncEPGTransfer(bool supportsAsyncEPGTransfer)
Set true if this addon-on supports asynchronous transfer of epg events to Kodi using the callback fun...
Definition: General.h:337
kodi::addon::PVRCapabilities::GetSupportsRadio
bool GetSupportsRadio() const
To get with SetSupportsRadio changed values.
Definition: General.h:182
kodi::addon::PVRCapabilities::GetSupportsRecordingEdl
bool GetSupportsRecordingEdl() const
To get with SetSupportsRecordingEdl changed values.
Definition: General.h:299
kodi::addon::PVRCapabilities
Definition: General.h:116
kodi::addon::PVRCapabilities::SetRecordingsLifetimeValues
void SetRecordingsLifetimeValues(const std::vector< PVRTypeIntValue > &recordingsLifetimeValues)
optional Set array containing the possible values for PVRRecording::SetLifetime().
Definition: General.h:360
kodi::addon::PVRCapabilities::SetSupportsTV
void SetSupportsTV(bool supportsTV)
Set true if this add-on provides TV channels.
Definition: General.h:173
kodi::addon::PVRCapabilities::SetSupportsRecordingEdl
void SetSupportsRecordingEdl(bool supportsRecordingEdl)
Set true if the backend supports retrieving an edit decision list for recordings.
Definition: General.h:293
PVR_NAMED_VALUE
"C" Representation of a named value.
Definition: pvr_defines.h:57
kodi::addon::PVRCapabilities::SetSupportsRecordingSize
void SetSupportsRecordingSize(bool supportsRecordingSize)
Set true if this addon-on supports retrieving size of recordings.
Definition: General.h:346
kodi::addon::PVRCapabilities::SetSupportsRadio
void SetSupportsRadio(bool supportsRadio)
Set true if this add-on provides TV channels.
Definition: General.h:179
kodi::addon::PVRCapabilities::GetSupportsChannelSettings
bool GetSupportsChannelSettings() const
To get with SetSupportsChannelSettings changed values.
Definition: General.h:251
PVR_ATTRIBUTE_INT_VALUE
"C" Representation of a general attribute integer value.
Definition: pvr_defines.h:48
kodi::addon::PVRCapabilities::GetSupportsChannelScan
bool GetSupportsChannelScan() const
To get with SetSupportsChannelScan changed values.
Definition: General.h:236
kodi::addon::PVRCapabilities::GetSupportsRecordingsLifetimeChange
bool GetSupportsRecordingsLifetimeChange() const
To get with SetSupportsRecordingsLifetimeChange changed values.
Definition: General.h:319
kodi::addon::PVRStreamProperty::SetValue
void SetValue(const std::string &value)
To set with the used property value.
Definition: General.h:492
kodi::addon::PVRStreamProperty::GetName
std::string GetName() const
To get with the identification name.
Definition: General.h:489
kodi::addon::PVRTypeIntValue::PVRTypeIntValue
PVRTypeIntValue(int value, const std::string &description)
Class constructor with integrated value set.
Definition: General.h:66
kodi::addon::PVRCapabilities::SetSupportsRecordings
void SetSupportsRecordings(bool supportsRecordings)
true if this add-on supports playback of recordings stored on the backend.
Definition: General.h:186
kodi::addon::PVRCapabilities::SetSupportsRecordingsUndelete
void SetSupportsRecordingsUndelete(bool supportsRecordingsUndelete)
Set true if this add-on supports undelete of recordings stored on the backend.
Definition: General.h:196
kodi::addon::PVRCapabilities::SetSupportsLastPlayedPosition
void SetSupportsLastPlayedPosition(bool supportsLastPlayedPosition)
Set true if the backend supports store/retrieve of last played position for recordings.
Definition: General.h:283
kodi::addon::PVRCapabilities::GetHandlesInputStream
bool GetHandlesInputStream() const
To get with SetHandlesInputStream changed values.
Definition: General.h:261
kodi::addon::PVRCapabilities::SetSupportsRecordingsRename
void SetSupportsRecordingsRename(bool supportsRecordingsRename)
Set true if the backend supports renaming recordings.
Definition: General.h:302
kodi::addon::PVRCapabilities::SetSupportsTimers
void SetSupportsTimers(bool supportsTimers)
Set true if this add-on supports the creation and editing of timers.
Definition: General.h:206
kodi::addon::PVRCapabilities::GetSupportsRecordingSize
bool GetSupportsRecordingSize() const
To get with SetSupportsRecordingSize changed values.
Definition: General.h:352
PVR_ADDON_CAPABILITIES
"C" PVR add-on capabilities.
Definition: pvr_general.h:265
kodi::addon::PVRCapabilities::GetSupportsEPG
bool GetSupportsEPG() const
To get with SetSupportsEPG changed values.
Definition: General.h:163
kodi::addon::PVRCapabilities::SetSupportsEPGEdl
void SetSupportsEPGEdl(bool supportsEPGEdl)
Set true if the backend supports retrieving an edit decision list for an EPG tag.
Definition: General.h:167
kodi::addon::CInstancePVRClient
Definition: PVR.h:385
kodi::addon::PVRStreamProperty
Definition: General.h:445
kodi::addon::PVRCapabilities::GetSupportsRecordingsUndelete
bool GetSupportsRecordingsUndelete() const
To get with SetSupportsRecordings changed values.
Definition: General.h:202
kodi::addon::PVRCapabilities::SetSupportsRecordingsLifetimeChange
void SetSupportsRecordingsLifetimeChange(bool supportsRecordingsLifetimeChange)
Set true if the backend supports changing lifetime for recordings.
Definition: General.h:312
kodi::addon::PVRTypeIntValue
Definition: General.h:35
kodi::addon::PVRCapabilities::GetRecordingsLifetimeValues
std::vector< PVRTypeIntValue > GetRecordingsLifetimeValues() const
To get with SetRecordingsLifetimeValues changed values.
Definition: General.h:378
kodi::addon::PVRCapabilities::SetHandlesDemuxing
void SetHandlesDemuxing(bool handlesDemuxing)
Set true if this add-on demultiplexes packets.
Definition: General.h:264
kodi::addon::PVRTypeIntValue::GetDescription
std::string GetDescription() const
To get with the description text of the value.
Definition: General.h:86
kodi::addon::CStructHdl
Definition: AddonBase.h:249
kodi::addon::PVRStreamProperty::SetName
void SetName(const std::string &name)
To set with the identification name.
Definition: General.h:483
kodi::addon::PVRCapabilities::GetSupportsTV
bool GetSupportsTV() const
To get with SetSupportsTV changed values.
Definition: General.h:176
kodi::addon::PVRTypeIntValue::SetDescription
void SetDescription(const std::string &description)
To set with the description text of the value.
Definition: General.h:79
kodi::addon::PVRCapabilities::GetHandlesDemuxing
bool GetHandlesDemuxing() const
To get with SetHandlesDemuxing changed values.
Definition: General.h:270
kodi::addon::PVRCapabilities::GetSupportsRecordings
bool GetSupportsRecordings() const
To get with SetSupportsRecordings changed values.
Definition: General.h:192