Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

Functions to manage the addon and get basic information about it
These are e.g. GetCapabilities to know supported groups at this addon or the others to get information about the source of the PVR stream. More...

Functions

 kodi::addon::CInstancePVRClient::CInstancePVRClient ()
 PVR client class constructor.
 
 kodi::addon::CInstancePVRClient::CInstancePVRClient (const IInstanceInfo &instance)
 PVR client class constructor used to support multiple instance types.
 
 kodi::addon::CInstancePVRClient::~CInstancePVRClient () override=default
 Destructor.
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetCapabilities (kodi::addon::PVRCapabilities &capabilities)=0
 Get the list of features that this add-on provides.
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetBackendName (std::string &name)=0
 Get the name reported by the backend that will be displayed in the UI.
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetBackendVersion (std::string &version)=0
 Get the version string reported by the backend that will be displayed in the UI.
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetBackendHostname (std::string &hostname)
 Get the hostname of the pvr backend server.
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetConnectionString (std::string &connection)
 To get the connection string reported by the backend that will be displayed in the UI.
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetDriveSpace (uint64_t &total, uint64_t &used)
 Get the disk space reported by the backend (if supported).
 
virtual PVR_ERROR kodi::addon::CInstancePVRClient::CallSettingsMenuHook (const kodi::addon::PVRMenuhook &menuhook)
 Call one of the settings related menu hooks (if supported).
 
void kodi::addon::CInstancePVRClient::AddMenuHook (const kodi::addon::PVRMenuhook &hook)
 Callback to Kodi Function\nAdd or replace a menu hook for the context menu for this add-on
 
void kodi::addon::CInstancePVRClient::ConnectionStateChange (const std::string &connectionString, PVR_CONNECTION_STATE newState, const std::string &message)
 Callback to Kodi Function
Notify a state change for a PVR backend connection.
 
std::string kodi::addon::CInstancePVRClient::UserPath () const
 Callback to Kodi Function
Get user data path of the PVR addon.
 
std::string kodi::addon::CInstancePVRClient::ClientPath () const
 Callback to Kodi Function
Get main client path of the PVR addon.
 

Detailed Description

Functions to manage the addon and get basic information about it
These are e.g. GetCapabilities to know supported groups at this addon or the others to get information about the source of the PVR stream.

The with "Valid implementation required." declared functions are mandatory, all others are an option.


Basic parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Function Documentation

◆ AddMenuHook()

void kodi::addon::CInstancePVRClient::AddMenuHook ( const kodi::addon::PVRMenuhook & hook)
inline

Callback to Kodi Function\nAdd or replace a menu hook for the context menu for this add-on

This is a callback function, called from addon to give Kodi his context menu's.

Parameters
[in]menuhookThe with class PVRMenuhook defined hook to add
Remarks
Only called from addon itself

The following table contains values that can be set with class PVRMenuhook :

Name Type Set call Get call Usage
This hook's identifier unsigned int SetHookId GetHookId required to set
Localized string Identifier unsigned int SetLocalizedStringId GetLocalizedStringId required to set
Category of menu hook PVR_MENUHOOK_CAT SetCategory GetCategory required to set

Here's an example of the use of it:

...
{
hook.SetHookId(1);
hook.SetLocalizedStringId(30000);
AddMenuHook(hook);
}
{
hook.SetHookId(2);
hook.SetLocalizedStringId(30001);
AddMenuHook(hook);
}
...
Definition MenuHook.h:46
void AddMenuHook(const kodi::addon::PVRMenuhook &hook)
Callback to Kodi Function\nAdd or replace a menu hook for the context menu for this add-on
Definition addon-instance/pvr.h:742
@ PVR_MENUHOOK_CHANNEL
1 : For channels.
Definition pvr_menu_hook.h:37
@ PVR_MENUHOOK_SETTING
6 : For settings.
Definition pvr_menu_hook.h:52
void SetHookId(unsigned int hookId)
required This hook's identifier.
Definition MenuHook.h:97
void SetLocalizedStringId(unsigned int localizedStringId)
required The id of the label for this hook in kodi::GetLocalizedString().
Definition MenuHook.h:104
void SetCategory(PVR_MENUHOOK_CAT category)
required Category of menu hook.
Definition MenuHook.h:114

Here another way:

◆ CallSettingsMenuHook()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::CallSettingsMenuHook ( const kodi::addon::PVRMenuhook & menuhook)
inlinevirtual

Call one of the settings related menu hooks (if supported).

Supported menu hook instances have to be added in constructor(), by calling AddMenuHook() on the callback.

Parameters
[in]menuhookThe hook to call.
Returns
PVR_ERROR_NO_ERROR if the hook was called successfully.

The following table contains values that can be set with class PVRMenuhook :

Name Type Set call Get call Usage
This hook's identifier unsigned int SetHookId GetHookId required to set
Localized string Identifier unsigned int SetLocalizedStringId GetLocalizedStringId required to set
Category of menu hook PVR_MENUHOOK_CAT SetCategory GetCategory required to set

Example:

PVR_ERROR CMyPVRClient::CallSettingsMenuHook(const kodi::addon::PVRMenuhook& menuhook)
{
if (menuhook.GetHookId() == 2)
kodi::QueueNotification(QUEUE_INFO, "", kodi::GetLocalizedString(menuhook.GetLocalizedStringId()));
}
@ QUEUE_INFO
Show info notification message.
Definition kodi-dev-kit/include/kodi/c-api/General.h:45
PVR_ERROR
Definition pvr_general.h:36
@ PVR_ERROR_NO_ERROR
0 : No error occurred.
Definition pvr_general.h:38
unsigned int GetHookId() const
To get with SetHookId() changed values.
Definition MenuHook.h:100
unsigned int GetLocalizedStringId() const
To get with SetLocalizedStringId() changed values.
Definition MenuHook.h:110
void ATTR_DLL_LOCAL QueueNotification(QueueMsg type, const std::string &header, const std::string &message, const std::string &imageFile="", unsigned int displayTime=5000, bool withSound=true, unsigned int messageTime=1000)
Queue a notification in the GUI.
Definition kodi-dev-kit/include/kodi/General.h:260

◆ CInstancePVRClient() [1/2]

kodi::addon::CInstancePVRClient::CInstancePVRClient ( )
inline

PVR client class constructor.

Used by an add-on that only supports only PVR and only in one instance.


Here's example about the use of this:

...
class ATTR_DLL_LOCAL CPVRExample
{
public:
CPVRExample()
{
}
~CPVRExample() override;
{
}
...
};
ADDONCREATOR(CPVRExample)
#define ATTR_DLL_LOCAL
Definition addon_base.h:86
Definition kodi-dev-kit/include/kodi/AddonBase.h:775
Definition addon-instance/pvr.h:404
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:2047

◆ CInstancePVRClient() [2/2]

kodi::addon::CInstancePVRClient::CInstancePVRClient ( const IInstanceInfo & instance)
inlineexplicit

PVR client class constructor used to support multiple instance types.

Parameters
[in]instanceThe instance value given to kodi::addon::CAddonBase::CreateInstance(...).

Here's example about the use of this:

class CMyPVRClient : public ::kodi::addon::CInstancePVRClient
{
public:
CMyPVRClient(const kodi::addon::IInstanceInfo& instance)
{
...
}
...
};
ADDON_STATUS CMyAddon::CreateInstance(const kodi::addon::IInstanceInfo& instance,
{
kodi::Log(ADDON_LOG_INFO, "Creating my PVR client instance");
hdl = new CMyPVRClient(instance);
}
void * KODI_ADDON_INSTANCE_HDL
Definition addon_base.h:121
KODI_ADDON_HDL * hdl
Definition addon_base.h:344
Definition kodi-dev-kit/include/kodi/AddonBase.h:498
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition addon_base.h:187
ADDON_STATUS
Definition addon_base.h:138
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:140
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition kodi-dev-kit/include/kodi/AddonBase.h:1938
Definition addon_base.h:268

◆ ClientPath()

std::string kodi::addon::CInstancePVRClient::ClientPath ( ) const
inline

Callback to Kodi Function
Get main client path of the PVR addon.

Returns
Path of addon client
Remarks
Only called from addon itself.
Note
Alternatively, kodi::GetBaseUserPath() can be used for this.

◆ ConnectionStateChange()

void kodi::addon::CInstancePVRClient::ConnectionStateChange ( const std::string & connectionString,
PVR_CONNECTION_STATE newState,
const std::string & message )
inline

Callback to Kodi Function
Notify a state change for a PVR backend connection.

Parameters
[in]connectionStringThe connection string reported by the backend that can be displayed in the UI.
[in]newStateThe by PVR_CONNECTION_STATE defined new state.
[in]messageA localized addon-defined string representing the new state, that can be displayed in the UI or empty if the Kodi-defined default string for the new state shall be displayed.
Remarks
Only called from addon itself

Here's an example of the use of it:

#include <kodi/General.h> /* for kodi::GetLocalizedString(...) *&zwj;/
...
ConnectionStateChange("PVR demo connection lost", PVR_CONNECTION_STATE_DISCONNECTED, kodi::GetLocalizedString(30005, "Lost connection to Server"););
...

◆ GetBackendHostname()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetBackendHostname ( std::string & hostname)
inlinevirtual

Get the hostname of the pvr backend server.

Parameters
[out]hostnameHostname as ip address or alias. If backend does not utilize a server, return empty string.
Returns
PVR_ERROR_NO_ERROR if successfully done

◆ GetBackendName()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetBackendName ( std::string & name)
pure virtual

Get the name reported by the backend that will be displayed in the UI.

Parameters
[out]nameThe name reported by the backend that will be displayed in the UI.
Returns
PVR_ERROR_NO_ERROR if successfully done

Example:

PVR_ERROR CMyPVRClient::GetBackendName(std::string& name)
{
name = "My special PVR client";
}
enum const char * name
Definition addon_base.h:203

Note
Valid implementation required.

◆ GetBackendVersion()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetBackendVersion ( std::string & version)
pure virtual

Get the version string reported by the backend that will be displayed in the UI.

Parameters
[out]versionThe version string reported by the backend that will be displayed in the UI.
Returns
PVR_ERROR_NO_ERROR if successfully done

Example:

PVR_ERROR CMyPVRClient::GetBackendVersion(std::string& version)
{
version = "1.0.0";
}

Note
Valid implementation required.

◆ GetCapabilities()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetCapabilities ( kodi::addon::PVRCapabilities & capabilities)
pure virtual

Get the list of features that this add-on provides.

Called by Kodi to query the add-on's capabilities. Used to check which options should be presented in the UI, which methods to call, etc. All capabilities that the add-on supports should be set to true.

Parameters
capabilitiesThe with class PVRCapabilities defined add-on's capabilities.
Returns
PVR_ERROR_NO_ERROR if the properties were fetched successfully.

@ingroup cpp_kodi_addon_pvr_Defs_PVRCapabilities

The following table contains values that can be set with class PVRCapabilities :

Name Type Set call Get call
Supports EPG boolean SetSupportsEPG GetSupportsEPG
Supports EPG EDL boolean SetSupportsEPGEdl GetSupportsEPGEdl
Supports TV boolean SetSupportsTV GetSupportsTV
Supports radio boolean SetSupportsRadio GetSupportsRadio
Supports recordings boolean SetSupportsRecordings GetSupportsRecordings
Supports recordings undelete boolean SetSupportsRecordingsUndelete SetSupportsRecordingsUndelete
Supports timers boolean SetSupportsTimers GetSupportsTimers
Supports providers boolean SetSupportsProviders GetSupportsProviders
Supports channel groups boolean SetSupportsChannelGroups GetSupportsChannelGroups
Supports channel scan boolean SetSupportsChannelScan GetSupportsChannelScan
Supports channel settings boolean SetSupportsChannelSettings GetSupportsChannelSettings
Handles input stream boolean SetHandlesInputStream GetHandlesInputStream
Handles demuxing boolean SetHandlesDemuxing GetHandlesDemuxing
Supports recording play count boolean SetSupportsRecordingPlayCount GetSupportsRecordingPlayCount
Supports last played position boolean SetSupportsLastPlayedPosition GetSupportsLastPlayedPosition
Supports recording EDL boolean SetSupportsRecordingEdl GetSupportsRecordingEdl
Supports recordings rename boolean SetSupportsRecordingsRename GetSupportsRecordingsRename
Supports recordings lifetime change boolean SetSupportsRecordingsLifetimeChange GetSupportsRecordingsLifetimeChange
Supports descramble info boolean SetSupportsDescrambleInfo GetSupportsDescrambleInfo
Supports async EPG transfer boolean SetSupportsAsyncEPGTransfer GetSupportsAsyncEPGTransfer
Supports recording size boolean SetSupportsRecordingSize GetSupportsRecordingSize
Supports recordings delete boolean SetSupportsRecordingsDelete SetSupportsRecordingsDelete
Supports multiple recorded streams boolean SetSupportsMultipleRecordedStreams GetSupportsMultipleRecordedStreams
Recordings lifetime values PVRTypeIntValue SetRecordingsLifetimeValues GetRecordingsLifetimeValues
Warning
This class can not be used outside of kodi::addon::CInstancePVRClient::GetCapabilities()

Example:

PVR_ERROR CMyPVRClient::GetCapabilities(kodi::addon::PVRCapabilities& capabilities)
{
capabilities.SetSupportsTV(true);
capabilities.SetSupportsEPG(true);
}
Definition kodi-dev-kit/include/kodi/addon-instance/pvr/General.h:1077
void SetSupportsEPG(bool supportsEPG)
Set true if the add-on provides EPG information.
Definition kodi-dev-kit/include/kodi/addon-instance/pvr/General.h:1125
void SetSupportsTV(bool supportsTV)
Set true if this add-on provides TV channels.
Definition kodi-dev-kit/include/kodi/addon-instance/pvr/General.h:1138

Note
Valid implementation required.

◆ GetConnectionString()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetConnectionString ( std::string & connection)
inlinevirtual

To get the connection string reported by the backend that will be displayed in the UI.

Parameters
[out]connectionThe connection string reported by the backend that will be displayed in the UI.
Returns
PVR_ERROR_NO_ERROR if successfully done

◆ GetDriveSpace()

virtual PVR_ERROR kodi::addon::CInstancePVRClient::GetDriveSpace ( uint64_t & total,
uint64_t & used )
inlinevirtual

Get the disk space reported by the backend (if supported).

Parameters
[in]totalThe total disk space in KiB.
[in]usedThe used disk space in KiB.
Returns
PVR_ERROR_NO_ERROR if the drive space has been fetched successfully.

Example:

PVR_ERROR CMyPVRClient::GetDriveSpace(uint64_t& total, uint64_t& used)
{
total = 100 * 1024 * 1024; // To set complete size of drive in KiB (100GB)
used = 12232424; // To set the used amount
}

◆ UserPath()

std::string kodi::addon::CInstancePVRClient::UserPath ( ) const
inline

Callback to Kodi Function
Get user data path of the PVR addon.

Returns
Path of current Kodi user
Remarks
Only called from addon itself
Note
Alternatively, kodi::GetAddonPath() can be used for this.

◆ ~CInstancePVRClient()

kodi::addon::CInstancePVRClient::~CInstancePVRClient ( )
overridedefault

Destructor.