diff options
Diffstat (limited to 'xbmc')
108 files changed, 24151 insertions, 11307 deletions
diff --git a/xbmc/addons/AddonBindings.cmake b/xbmc/addons/AddonBindings.cmake index 53a9801..7fb5aba 100644 --- a/xbmc/addons/AddonBindings.cmake +++ b/xbmc/addons/AddonBindings.cmake | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | # Keep this in alphabetical order | 5 | # Keep this in alphabetical order |
| 6 | set(CORE_ADDON_BINDINGS_FILES | 6 | set(CORE_ADDON_BINDINGS_FILES |
| 7 | ${CORE_SOURCE_DIR}/xbmc/cores/AudioEngine/Utils/AEChannelData.h | 7 | ${CORE_SOURCE_DIR}/xbmc/cores/AudioEngine/Utils/AEChannelData.h |
| 8 | ${CORE_SOURCE_DIR}/xbmc/filesystem/IFileTypes.h | ||
| 9 | ${CORE_SOURCE_DIR}/xbmc/input/actions/ActionIDs.h | 8 | ${CORE_SOURCE_DIR}/xbmc/input/actions/ActionIDs.h |
| 10 | ${CORE_SOURCE_DIR}/xbmc/input/XBMC_vkeys.h | 9 | ${CORE_SOURCE_DIR}/xbmc/input/XBMC_vkeys.h |
| 11 | ) | 10 | ) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h index db39f86..b0fddda 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h | |||
| @@ -8,230 +8,137 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include <stdarg.h> /* va_list, va_start, va_arg, va_end */ | 11 | #include "c-api/addon_base.h" |
| 12 | #include "versions.h" | ||
| 13 | |||
| 14 | #include <assert.h> /* assert */ | ||
| 12 | #include <cstdlib> | 15 | #include <cstdlib> |
| 13 | #include <cstring> | 16 | #include <cstring> |
| 17 | #include <ctime> | ||
| 18 | #include <memory> | ||
| 19 | #include <stdarg.h> /* va_list, va_start, va_arg, va_end */ | ||
| 14 | #include <stdexcept> | 20 | #include <stdexcept> |
| 15 | #include <string> | 21 | #include <string> |
| 16 | #include <vector> | 22 | #include <vector> |
| 17 | 23 | ||
| 18 | #ifndef TARGET_WINDOWS | 24 | namespace kodi |
| 19 | #ifndef __cdecl | ||
| 20 | #define __cdecl | ||
| 21 | #endif | ||
| 22 | #ifndef __declspec | ||
| 23 | #define __declspec(X) | ||
| 24 | #endif | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #undef ATTRIBUTE_PACKED | ||
| 28 | #undef PRAGMA_PACK_BEGIN | ||
| 29 | #undef PRAGMA_PACK_END | ||
| 30 | |||
| 31 | #if defined(__GNUC__) | ||
| 32 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 33 | #define PRAGMA_PACK 0 | ||
| 34 | #define ATTRIBUTE_HIDDEN __attribute__ ((visibility ("hidden"))) | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #if !defined(ATTRIBUTE_PACKED) | ||
| 38 | #define ATTRIBUTE_PACKED | ||
| 39 | #define PRAGMA_PACK 1 | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #if !defined(ATTRIBUTE_HIDDEN) | ||
| 43 | #define ATTRIBUTE_HIDDEN | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifdef _MSC_VER | ||
| 47 | #define ATTRIBUTE_FORCEINLINE __forceinline | ||
| 48 | #elif defined(__GNUC__) | ||
| 49 | #define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__)) | ||
| 50 | #elif defined(__CLANG__) | ||
| 51 | #if __has_attribute(__always_inline__) | ||
| 52 | #define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__)) | ||
| 53 | #else | ||
| 54 | #define ATTRIBUTE_FORCEINLINE inline | ||
| 55 | #endif | ||
| 56 | #else | ||
| 57 | #define ATTRIBUTE_FORCEINLINE inline | ||
| 58 | #endif | ||
| 59 | |||
| 60 | #include "versions.h" | ||
| 61 | |||
| 62 | namespace kodi { namespace addon { class CAddonBase; }} | ||
| 63 | namespace kodi { namespace addon { class IAddonInstance; }} | ||
| 64 | |||
| 65 | extern "C" { | ||
| 66 | |||
| 67 | //============================================================================== | ||
| 68 | /// Standard undefined pointer handle | ||
| 69 | typedef void* KODI_HANDLE; | ||
| 70 | //------------------------------------------------------------------------------ | ||
| 71 | |||
| 72 | //============================================================================== | ||
| 73 | /// | ||
| 74 | typedef enum ADDON_STATUS | ||
| 75 | { | 25 | { |
| 76 | /// | ||
| 77 | ADDON_STATUS_OK, | ||
| 78 | |||
| 79 | /// | ||
| 80 | ADDON_STATUS_LOST_CONNECTION, | ||
| 81 | |||
| 82 | /// | ||
| 83 | ADDON_STATUS_NEED_RESTART, | ||
| 84 | |||
| 85 | /// | ||
| 86 | ADDON_STATUS_NEED_SETTINGS, | ||
| 87 | 26 | ||
| 88 | /// | 27 | namespace gui |
| 89 | ADDON_STATUS_UNKNOWN, | 28 | { |
| 90 | 29 | struct IRenderHelper; | |
| 91 | /// permanent failure, like failing to resolve methods | 30 | } // namespace gui |
| 92 | ADDON_STATUS_PERMANENT_FAILURE, | ||
| 93 | |||
| 94 | /* internal used return error if function becomes not used from child on | ||
| 95 | * addon */ | ||
| 96 | ADDON_STATUS_NOT_IMPLEMENTED | ||
| 97 | } ADDON_STATUS; | ||
| 98 | //------------------------------------------------------------------------------ | ||
| 99 | 31 | ||
| 100 | //============================================================================== | 32 | //============================================================================== |
| 101 | /// @todo remove start with ADDON_* after old way on libXBMC_addon.h is removed | 33 | /// @ingroup cpp_kodi_addon_addonbase_Defs |
| 34 | /// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue class CSettingValue | ||
| 35 | /// @brief Inside addon main instance used helper class to give settings value. | ||
| 36 | /// | ||
| 37 | /// This is used on @ref addon::CAddonBase::SetSetting() to inform addon about | ||
| 38 | /// settings change by used. This becomes then used to give the related value | ||
| 39 | /// name. | ||
| 40 | /// | ||
| 41 | /// ---------------------------------------------------------------------------- | ||
| 42 | /// | ||
| 43 | /// @copydetails cpp_kodi_addon_addonbase_Defs_CSettingValue_Help | ||
| 102 | /// | 44 | /// |
| 103 | typedef enum AddonLog | 45 | /// ---------------------------------------------------------------------------- |
| 46 | /// | ||
| 47 | /// **Here is a code example how this is used:** | ||
| 48 | /// | ||
| 49 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 50 | /// #include <kodi/AddonBase.h> | ||
| 51 | /// | ||
| 52 | /// enum myEnumValue | ||
| 53 | /// { | ||
| 54 | /// valueA, | ||
| 55 | /// valueB, | ||
| 56 | /// valueC | ||
| 57 | /// }; | ||
| 58 | /// | ||
| 59 | /// std::string m_myStringValue; | ||
| 60 | /// int m_myIntegerValue; | ||
| 61 | /// bool m_myBooleanValue; | ||
| 62 | /// float m_myFloatingPointValue; | ||
| 63 | /// myEnumValue m_myEnumValue; | ||
| 64 | /// | ||
| 65 | /// | ||
| 66 | /// ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::CSettingValue& settingValue) | ||
| 67 | /// { | ||
| 68 | /// if (settingName == "my_string_value") | ||
| 69 | /// m_myStringValue = settingValue.GetString(); | ||
| 70 | /// else if (settingName == "my_integer_value") | ||
| 71 | /// m_myIntegerValue = settingValue.GetInt(); | ||
| 72 | /// else if (settingName == "my_boolean_value") | ||
| 73 | /// m_myBooleanValue = settingValue.GetBoolean(); | ||
| 74 | /// else if (settingName == "my_float_value") | ||
| 75 | /// m_myFloatingPointValue = settingValue.GetFloat(); | ||
| 76 | /// else if (settingName == "my_enum_value") | ||
| 77 | /// m_myEnumValue = settingValue.GetEnum<myEnumValue>(); | ||
| 78 | /// } | ||
| 79 | /// ~~~~~~~~~~~~~ | ||
| 80 | /// | ||
| 81 | /// @note The asked type should match the type used on settings.xml. | ||
| 82 | /// | ||
| 83 | ///@{ | ||
| 84 | class ATTRIBUTE_HIDDEN CSettingValue | ||
| 104 | { | 85 | { |
| 105 | /// | 86 | public: |
| 106 | ADDON_LOG_DEBUG = 0, | 87 | explicit CSettingValue(const void* settingValue) : m_settingValue(settingValue) {} |
| 107 | |||
| 108 | /// | ||
| 109 | ADDON_LOG_INFO = 1, | ||
| 110 | 88 | ||
| 111 | /// | 89 | bool empty() const { return (m_settingValue == nullptr) ? true : false; } |
| 112 | ADDON_LOG_NOTICE = 2, | ||
| 113 | 90 | ||
| 91 | /// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue_Help Value Help | ||
| 92 | /// @ingroup cpp_kodi_addon_addonbase_Defs_CSettingValue | ||
| 114 | /// | 93 | /// |
| 115 | ADDON_LOG_WARNING = 3, | 94 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_addonbase_Defs_CSettingValue :</b> |
| 95 | /// | Name | Type | Get call | ||
| 96 | /// |------|------|---------- | ||
| 97 | /// | **Settings value as string** | `std::string` | @ref CSettingValue::GetString "GetString" | ||
| 98 | /// | **Settings value as integer** | `int` | @ref CSettingValue::GetInt "GetInt" | ||
| 99 | /// | **Settings value as unsigned integer** | `unsigned int` | @ref CSettingValue::GetUInt "GetUInt" | ||
| 100 | /// | **Settings value as boolean** | `bool` | @ref CSettingValue::GetBoolean "GetBoolean" | ||
| 101 | /// | **Settings value as floating point** | `float` | @ref CSettingValue::GetFloat "GetFloat" | ||
| 102 | /// | **Settings value as enum** | `enum` | @ref CSettingValue::GetEnum "GetEnum" | ||
| 103 | |||
| 104 | /// @addtogroup cpp_kodi_addon_addonbase_Defs_CSettingValue | ||
| 105 | ///@{ | ||
| 106 | |||
| 107 | /// @brief To get settings value as string. | ||
| 108 | std::string GetString() const { return (const char*)m_settingValue; } | ||
| 116 | 109 | ||
| 117 | /// | 110 | /// @brief To get settings value as integer. |
| 118 | ADDON_LOG_ERROR = 4, | 111 | int GetInt() const { return *(const int*)m_settingValue; } |
| 119 | 112 | ||
| 120 | /// | 113 | /// @brief To get settings value as unsigned integer. |
| 121 | ADDON_LOG_SEVERE = 5, | 114 | unsigned int GetUInt() const { return *(const unsigned int*)m_settingValue; } |
| 122 | 115 | ||
| 123 | /// | 116 | /// @brief To get settings value as boolean. |
| 124 | ADDON_LOG_FATAL = 6 | 117 | bool GetBoolean() const { return *(const bool*)m_settingValue; } |
| 125 | } AddonLog; | ||
| 126 | //------------------------------------------------------------------------------ | ||
| 127 | 118 | ||
| 128 | /*! | 119 | /// @brief To get settings value as floating point. |
| 129 | * @brief Handle used to return data from the PVR add-on to CPVRClient | 120 | float GetFloat() const { return *(const float*)m_settingValue; } |
| 130 | */ | ||
| 131 | struct ADDON_HANDLE_STRUCT | ||
| 132 | { | ||
| 133 | void *callerAddress; /*!< address of the caller */ | ||
| 134 | void *dataAddress; /*!< address to store data in */ | ||
| 135 | int dataIdentifier; /*!< parameter to pass back when calling the callback */ | ||
| 136 | }; | ||
| 137 | typedef ADDON_HANDLE_STRUCT *ADDON_HANDLE; | ||
| 138 | 121 | ||
| 139 | /* | 122 | /// @brief To get settings value as enum. |
| 140 | * To have a on add-on and kodi itself handled string always on known size! | 123 | /// @note Inside settings.xml them stored as integer. |
| 141 | */ | 124 | template<typename enumType> |
| 142 | #define ADDON_STANDARD_STRING_LENGTH 1024 | 125 | enumType GetEnum() const |
| 143 | #define ADDON_STANDARD_STRING_LENGTH_SMALL 256 | 126 | { |
| 127 | return static_cast<enumType>(*(const int*)m_settingValue); | ||
| 128 | } | ||
| 144 | 129 | ||
| 145 | /* | 130 | ///@} |
| 146 | * Callback function tables from addon to Kodi | ||
| 147 | * Set complete from Kodi! | ||
| 148 | */ | ||
| 149 | struct AddonToKodiFuncTable_kodi; | ||
| 150 | struct AddonToKodiFuncTable_kodi_audioengine; | ||
| 151 | struct AddonToKodiFuncTable_kodi_filesystem; | ||
| 152 | struct AddonToKodiFuncTable_kodi_network; | ||
| 153 | struct AddonToKodiFuncTable_kodi_gui; | ||
| 154 | typedef struct AddonToKodiFuncTable_Addon | ||
| 155 | { | ||
| 156 | // Pointer inside Kodi, used on callback functions to give related handle | ||
| 157 | // class, for this ADDON::CAddonDll inside Kodi. | ||
| 158 | KODI_HANDLE kodiBase; | ||
| 159 | |||
| 160 | // Function addresses used for callbacks from addon to Kodi | ||
| 161 | void (*free_string)(void* kodiBase, char* str); | ||
| 162 | void (*free_string_array)(void* kodiBase, char** arr, int numElements); | ||
| 163 | char* (*get_addon_path)(void* kodiBase); | ||
| 164 | char* (*get_base_user_path)(void* kodiBase); | ||
| 165 | void (*addon_log_msg)(void* kodiBase, const int loglevel, const char *msg); | ||
| 166 | |||
| 167 | bool (*get_setting_bool)(void* kodiBase, const char* id, bool* value); | ||
| 168 | bool (*get_setting_int)(void* kodiBase, const char* id, int* value); | ||
| 169 | bool (*get_setting_float)(void* kodiBase, const char* id, float* value); | ||
| 170 | bool (*get_setting_string)(void* kodiBase, const char* id, char** value); | ||
| 171 | |||
| 172 | bool (*set_setting_bool)(void* kodiBase, const char* id, bool value); | ||
| 173 | bool (*set_setting_int)(void* kodiBase, const char* id, int value); | ||
| 174 | bool (*set_setting_float)(void* kodiBase, const char* id, float value); | ||
| 175 | bool (*set_setting_string)(void* kodiBase, const char* id, const char* value); | ||
| 176 | |||
| 177 | AddonToKodiFuncTable_kodi* kodi; | ||
| 178 | AddonToKodiFuncTable_kodi_audioengine* kodi_audioengine; | ||
| 179 | AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem; | ||
| 180 | AddonToKodiFuncTable_kodi_gui* kodi_gui; | ||
| 181 | AddonToKodiFuncTable_kodi_network *kodi_network; | ||
| 182 | |||
| 183 | void* (*get_interface)(void* kodiBase, const char *name, const char *version); | ||
| 184 | } AddonToKodiFuncTable_Addon; | ||
| 185 | 131 | ||
| 186 | /* | 132 | private: |
| 187 | * Function tables from Kodi to addon | 133 | const void* m_settingValue; |
| 188 | */ | 134 | }; |
| 189 | typedef struct KodiToAddonFuncTable_Addon | 135 | ///@} |
| 190 | { | 136 | //------------------------------------------------------------------------------ |
| 191 | void (*destroy)(); | ||
| 192 | ADDON_STATUS (*get_status)(); | ||
| 193 | ADDON_STATUS (*create_instance)(int instanceType, const char* instanceID, KODI_HANDLE instance, KODI_HANDLE* addonInstance, KODI_HANDLE parent); | ||
| 194 | void (*destroy_instance)(int instanceType, KODI_HANDLE instance); | ||
| 195 | ADDON_STATUS (*set_setting)(const char *settingName, const void *settingValue); | ||
| 196 | ADDON_STATUS(*create_instance_ex)(int instanceType, const char* instanceID, KODI_HANDLE instance, KODI_HANDLE* addonInstance, KODI_HANDLE parent, const char* version); | ||
| 197 | } KodiToAddonFuncTable_Addon; | ||
| 198 | 137 | ||
| 199 | /* | 138 | namespace addon |
| 200 | * Main structure passed from kodi to addon with basic information needed to | ||
| 201 | * create add-on. | ||
| 202 | */ | ||
| 203 | typedef struct AddonGlobalInterface | ||
| 204 | { | 139 | { |
| 205 | // String with full path where add-on is installed (without his name on end) | ||
| 206 | // Set from Kodi! | ||
| 207 | const char* libBasePath; | ||
| 208 | |||
| 209 | // Pointer of first created instance, used in case this add-on goes with single way | ||
| 210 | // Set from Kodi! | ||
| 211 | KODI_HANDLE firstKodiInstance; | ||
| 212 | |||
| 213 | // Pointer to master base class inside add-on | ||
| 214 | // Set from addon header! | ||
| 215 | kodi::addon::CAddonBase* addonBase; | ||
| 216 | |||
| 217 | // Pointer to a instance used on single way (together with this class) | ||
| 218 | // Set from addon header! | ||
| 219 | kodi::addon::IAddonInstance* globalSingleInstance; | ||
| 220 | |||
| 221 | // Callback function tables from addon to Kodi | ||
| 222 | // Set from Kodi! | ||
| 223 | AddonToKodiFuncTable_Addon* toKodi; | ||
| 224 | |||
| 225 | // Function tables from Kodi to addon | ||
| 226 | // Set from addon header! | ||
| 227 | KodiToAddonFuncTable_Addon* toAddon; | ||
| 228 | } AddonGlobalInterface; | ||
| 229 | |||
| 230 | } /* extern "C" */ | ||
| 231 | 140 | ||
| 232 | //============================================================================== | 141 | //============================================================================== |
| 233 | namespace kodi { | ||
| 234 | namespace addon { | ||
| 235 | /* | 142 | /* |
| 236 | * Internal class to control various instance types with general parts defined | 143 | * Internal class to control various instance types with general parts defined |
| 237 | * here. | 144 | * here. |
| @@ -241,66 +148,147 @@ namespace addon { | |||
| 241 | * @note This class is not need to know during add-on development thats why | 148 | * @note This class is not need to know during add-on development thats why |
| 242 | * commented with "*". | 149 | * commented with "*". |
| 243 | */ | 150 | */ |
| 244 | class IAddonInstance | 151 | class ATTRIBUTE_HIDDEN IAddonInstance |
| 245 | { | 152 | { |
| 246 | public: | 153 | public: |
| 247 | explicit IAddonInstance(ADDON_TYPE type) : m_type(type) { } | 154 | explicit IAddonInstance(ADDON_TYPE type, const std::string& version) |
| 248 | virtual ~IAddonInstance() = default; | 155 | : m_type(type), m_kodiVersion(version) |
| 249 | |||
| 250 | virtual ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) | ||
| 251 | { | 156 | { |
| 252 | return ADDON_STATUS_NOT_IMPLEMENTED; | ||
| 253 | } | 157 | } |
| 158 | virtual ~IAddonInstance() = default; | ||
| 254 | 159 | ||
| 255 | virtual ADDON_STATUS CreateInstanceEx(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance, const std::string &version) | 160 | virtual ADDON_STATUS CreateInstance(int instanceType, |
| 161 | const std::string& instanceID, | ||
| 162 | KODI_HANDLE instance, | ||
| 163 | const std::string& version, | ||
| 164 | KODI_HANDLE& addonInstance) | ||
| 256 | { | 165 | { |
| 257 | return CreateInstance(instanceType, instanceID, instance, addonInstance); | 166 | return ADDON_STATUS_NOT_IMPLEMENTED; |
| 258 | } | 167 | } |
| 259 | 168 | ||
| 260 | const ADDON_TYPE m_type; | 169 | const ADDON_TYPE m_type; |
| 170 | const std::string m_kodiVersion; | ||
| 171 | std::string m_id; | ||
| 261 | }; | 172 | }; |
| 262 | } /* namespace addon */ | ||
| 263 | } /* namespace kodi */ | ||
| 264 | //------------------------------------------------------------------------------ | ||
| 265 | 173 | ||
| 266 | //============================================================================== | 174 | /* |
| 267 | namespace kodi { | 175 | * Internally used helper class to manage processing of a "C" structure in "CPP" |
| 268 | /// | 176 | * class. |
| 269 | class CSettingValue | 177 | * |
| 178 | * At constant, the "C" structure is copied, otherwise the given pointer is | ||
| 179 | * superseded and is changeable. | ||
| 180 | * | ||
| 181 | * ----------------------------------------------------------------------------- | ||
| 182 | * | ||
| 183 | * Example: | ||
| 184 | * | ||
| 185 | * ~~~~~~~~~~~~~{.cpp} | ||
| 186 | * extern "C" typedef struct C_SAMPLE_DATA | ||
| 187 | * { | ||
| 188 | * unsigned int iUniqueId; | ||
| 189 | * } C_SAMPLE_DATA; | ||
| 190 | * | ||
| 191 | * class CPPSampleData : public CStructHdl<CPPSampleData, C_SAMPLE_DATA> | ||
| 192 | * { | ||
| 193 | * public: | ||
| 194 | * CPPSampleData() = default; | ||
| 195 | * CPPSampleData(const CPPSampleData& sample) : CStructHdl(sample) { } | ||
| 196 | * CPPSampleData(const C_SAMPLE_DATA* sample) : CStructHdl(sample) { } | ||
| 197 | * CPPSampleData(C_SAMPLE_DATA* sample) : CStructHdl(sample) { } | ||
| 198 | * | ||
| 199 | * void SetUniqueId(unsigned int uniqueId) { m_cStructure->iUniqueId = uniqueId; } | ||
| 200 | * unsigned int GetUniqueId() const { return m_cStructure->iUniqueId; } | ||
| 201 | * }; | ||
| 202 | * | ||
| 203 | * ~~~~~~~~~~~~~ | ||
| 204 | * | ||
| 205 | * It also works with the following example: | ||
| 206 | * | ||
| 207 | * ~~~~~~~~~~~~~{.cpp} | ||
| 208 | * CPPSampleData test; | ||
| 209 | * // Some work | ||
| 210 | * C_SAMPLE_DATA* data = test; | ||
| 211 | * // Give "data" to Kodi | ||
| 212 | * ~~~~~~~~~~~~~ | ||
| 213 | */ | ||
| 214 | template<class CPP_CLASS, typename C_STRUCT> | ||
| 215 | class CStructHdl | ||
| 270 | { | 216 | { |
| 271 | public: | 217 | public: |
| 272 | explicit CSettingValue(const void *settingValue) : m_settingValue(settingValue) {} | 218 | CStructHdl() : m_cStructure(new C_STRUCT()), m_owner(true) {} |
| 273 | 219 | ||
| 274 | bool empty() const { return (m_settingValue == nullptr) ? true : false; } | 220 | CStructHdl(const CPP_CLASS& cppClass) |
| 275 | std::string GetString() const { return (const char*)m_settingValue; } | 221 | : m_cStructure(new C_STRUCT(*cppClass.m_cStructure)), m_owner(true) |
| 276 | int GetInt() const { return *(const int*)m_settingValue; } | 222 | { |
| 277 | unsigned int GetUInt() const { return *(const unsigned int*)m_settingValue; } | 223 | } |
| 278 | bool GetBoolean() const { return *(const bool*)m_settingValue; } | 224 | |
| 279 | float GetFloat() const { return *(const float*)m_settingValue; } | 225 | CStructHdl(const C_STRUCT* cStructure) : m_cStructure(new C_STRUCT(*cStructure)), m_owner(true) {} |
| 226 | |||
| 227 | CStructHdl(C_STRUCT* cStructure) : m_cStructure(cStructure) { assert(cStructure); } | ||
| 228 | |||
| 229 | const CStructHdl& operator=(const CStructHdl& right) | ||
| 230 | { | ||
| 231 | assert(&right.m_cStructure); | ||
| 232 | if (m_cStructure && !m_owner) | ||
| 233 | { | ||
| 234 | memcpy(m_cStructure, right.m_cStructure, sizeof(C_STRUCT)); | ||
| 235 | } | ||
| 236 | else | ||
| 237 | { | ||
| 238 | if (m_owner) | ||
| 239 | delete m_cStructure; | ||
| 240 | m_owner = true; | ||
| 241 | m_cStructure = new C_STRUCT(*right.m_cStructure); | ||
| 242 | } | ||
| 243 | return *this; | ||
| 244 | } | ||
| 245 | |||
| 246 | const CStructHdl& operator=(const C_STRUCT& right) | ||
| 247 | { | ||
| 248 | assert(&right); | ||
| 249 | if (m_cStructure && !m_owner) | ||
| 250 | { | ||
| 251 | memcpy(m_cStructure, &right, sizeof(C_STRUCT)); | ||
| 252 | } | ||
| 253 | else | ||
| 254 | { | ||
| 255 | if (m_owner) | ||
| 256 | delete m_cStructure; | ||
| 257 | m_owner = true; | ||
| 258 | m_cStructure = new C_STRUCT(*right); | ||
| 259 | } | ||
| 260 | return *this; | ||
| 261 | } | ||
| 262 | |||
| 263 | virtual ~CStructHdl() | ||
| 264 | { | ||
| 265 | if (m_owner) | ||
| 266 | delete m_cStructure; | ||
| 267 | } | ||
| 268 | |||
| 269 | operator C_STRUCT*() { return m_cStructure; } | ||
| 270 | operator const C_STRUCT*() const { return m_cStructure; } | ||
| 271 | |||
| 272 | const C_STRUCT* GetCStructure() const { return m_cStructure; } | ||
| 273 | |||
| 274 | protected: | ||
| 275 | C_STRUCT* m_cStructure = nullptr; | ||
| 280 | 276 | ||
| 281 | private: | 277 | private: |
| 282 | const void *m_settingValue; | 278 | bool m_owner = false; |
| 283 | }; | 279 | }; |
| 284 | } /* namespace kodi */ | ||
| 285 | //------------------------------------------------------------------------------ | ||
| 286 | 280 | ||
| 287 | //============================================================================== | ||
| 288 | namespace kodi { | ||
| 289 | namespace addon { | ||
| 290 | /// Add-on main instance class. | 281 | /// Add-on main instance class. |
| 291 | class ATTRIBUTE_HIDDEN CAddonBase | 282 | class ATTRIBUTE_HIDDEN CAddonBase |
| 292 | { | 283 | { |
| 293 | public: | 284 | public: |
| 294 | CAddonBase() | 285 | CAddonBase() |
| 295 | { | 286 | { |
| 296 | CAddonBase::m_interface->toAddon->destroy = ADDONBASE_Destroy; | 287 | m_interface->toAddon->destroy = ADDONBASE_Destroy; |
| 297 | CAddonBase::m_interface->toAddon->get_status = ADDONBASE_GetStatus; | 288 | m_interface->toAddon->get_status = ADDONBASE_GetStatus; |
| 298 | CAddonBase::m_interface->toAddon->create_instance = ADDONBASE_CreateInstance; | 289 | m_interface->toAddon->create_instance = ADDONBASE_CreateInstance; |
| 299 | CAddonBase::m_interface->toAddon->destroy_instance = ADDONBASE_DestroyInstance; | 290 | m_interface->toAddon->destroy_instance = ADDONBASE_DestroyInstance; |
| 300 | CAddonBase::m_interface->toAddon->set_setting = ADDONBASE_SetSetting; | 291 | m_interface->toAddon->set_setting = ADDONBASE_SetSetting; |
| 301 | // If version is present, we know that kodi has create_instance_ex implemented | ||
| 302 | if (!CAddonBase::m_strGlobalApiVersion.empty()) | ||
| 303 | CAddonBase::m_interface->toAddon->create_instance_ex = ADDONBASE_CreateInstanceEx; | ||
| 304 | } | 292 | } |
| 305 | 293 | ||
| 306 | virtual ~CAddonBase() = default; | 294 | virtual ~CAddonBase() = default; |
| @@ -309,97 +297,301 @@ public: | |||
| 309 | 297 | ||
| 310 | virtual ADDON_STATUS GetStatus() { return ADDON_STATUS_OK; } | 298 | virtual ADDON_STATUS GetStatus() { return ADDON_STATUS_OK; } |
| 311 | 299 | ||
| 312 | virtual ADDON_STATUS SetSetting(const std::string& settingName, const CSettingValue& settingValue) { return ADDON_STATUS_UNKNOWN; } | 300 | //============================================================================ |
| 313 | 301 | /// @ingroup cpp_kodi_addon_addonbase | |
| 314 | virtual ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) | 302 | /// @brief To inform addon about changed settings values. |
| 303 | /// | ||
| 304 | /// This becomes called for every entry defined inside his settings.xml and | ||
| 305 | /// as **last** call the one where last in xml (to identify end of calls). | ||
| 306 | /// | ||
| 307 | /// -------------------------------------------------------------------------- | ||
| 308 | /// | ||
| 309 | /// @copydetails cpp_kodi_addon_addonbase_Defs_CSettingValue_Help | ||
| 310 | /// | ||
| 311 | /// | ||
| 312 | /// -------------------------------------------------------------------------- | ||
| 313 | /// | ||
| 314 | /// **Here is a code example how this is used:** | ||
| 315 | /// | ||
| 316 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 317 | /// #include <kodi/AddonBase.h> | ||
| 318 | /// | ||
| 319 | /// enum myEnumValue | ||
| 320 | /// { | ||
| 321 | /// valueA, | ||
| 322 | /// valueB, | ||
| 323 | /// valueC | ||
| 324 | /// }; | ||
| 325 | /// | ||
| 326 | /// std::string m_myStringValue; | ||
| 327 | /// int m_myIntegerValue; | ||
| 328 | /// bool m_myBooleanValue; | ||
| 329 | /// float m_myFloatingPointValue; | ||
| 330 | /// myEnumValue m_myEnumValue; | ||
| 331 | /// | ||
| 332 | /// | ||
| 333 | /// ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::CSettingValue& settingValue) | ||
| 334 | /// { | ||
| 335 | /// if (settingName == "my_string_value") | ||
| 336 | /// m_myStringValue = settingValue.GetString(); | ||
| 337 | /// else if (settingName == "my_integer_value") | ||
| 338 | /// m_myIntegerValue = settingValue.GetInt(); | ||
| 339 | /// else if (settingName == "my_boolean_value") | ||
| 340 | /// m_myBooleanValue = settingValue.GetBoolean(); | ||
| 341 | /// else if (settingName == "my_float_value") | ||
| 342 | /// m_myFloatingPointValue = settingValue.GetFloat(); | ||
| 343 | /// else if (settingName == "my_enum_value") | ||
| 344 | /// m_myEnumValue = settingValue.GetEnum<myEnumValue>(); | ||
| 345 | /// } | ||
| 346 | /// ~~~~~~~~~~~~~ | ||
| 347 | /// | ||
| 348 | /// @note The asked type should match the type used on settings.xml. | ||
| 349 | /// | ||
| 350 | virtual ADDON_STATUS SetSetting(const std::string& settingName, | ||
| 351 | const kodi::CSettingValue& settingValue) | ||
| 315 | { | 352 | { |
| 316 | /* The handling below is intended for the case of the add-on only one | ||
| 317 | * instance and this is integrated in the add-on base class. | ||
| 318 | */ | ||
| 319 | |||
| 320 | /* Check about single instance usage */ | ||
| 321 | if (CAddonBase::m_interface->firstKodiInstance == instance && // the kodi side instance pointer must be equal to first one | ||
| 322 | CAddonBase::m_interface->globalSingleInstance && // the addon side instance pointer must be set | ||
| 323 | CAddonBase::m_interface->globalSingleInstance->m_type == instanceType) // and the requested type must be equal with used add-on class | ||
| 324 | { | ||
| 325 | addonInstance = CAddonBase::m_interface->globalSingleInstance; | ||
| 326 | return ADDON_STATUS_OK; | ||
| 327 | } | ||
| 328 | |||
| 329 | return ADDON_STATUS_UNKNOWN; | 353 | return ADDON_STATUS_UNKNOWN; |
| 330 | } | 354 | } |
| 355 | //---------------------------------------------------------------------------- | ||
| 331 | 356 | ||
| 332 | virtual ADDON_STATUS CreateInstanceEx(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance, const std::string &version) | 357 | //========================================================================== |
| 358 | /// @ingroup cpp_kodi_addon_addonbase | ||
| 359 | /// @brief Instance created | ||
| 360 | /// | ||
| 361 | /// @param[in] instanceType The requested type of required instance, see \ref ADDON_TYPE. | ||
| 362 | /// @param[in] instanceID An individual identification key string given by Kodi. | ||
| 363 | /// @param[in] instance The instance handler used by Kodi must be passed to | ||
| 364 | /// the classes created here. See in the example. | ||
| 365 | /// @param[in] version The from Kodi used version of instance. This can be | ||
| 366 | /// used to allow compatibility to older versions of | ||
| 367 | /// them. Further is this given to the parent instance | ||
| 368 | /// that it can handle differences. | ||
| 369 | /// @param[out] addonInstance The pointer to instance class created in addon. | ||
| 370 | /// Needed to be able to identify them on calls. | ||
| 371 | /// @return \ref ADDON_STATUS_OK if correct, for possible errors | ||
| 372 | /// see \ref ADDON_STATUS | ||
| 373 | /// | ||
| 374 | /// | ||
| 375 | /// -------------------------------------------------------------------------- | ||
| 376 | /// | ||
| 377 | /// **Here is a code example how this is used:** | ||
| 378 | /// | ||
| 379 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 380 | /// #include <kodi/AddonBase.h> | ||
| 381 | /// | ||
| 382 | /// ... | ||
| 383 | /// | ||
| 384 | /// /* If you use only one instance in your add-on, can be instanceType and | ||
| 385 | /// * instanceID ignored */ | ||
| 386 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 387 | /// const std::string& instanceID, | ||
| 388 | /// KODI_HANDLE instance, | ||
| 389 | /// const std::string& version, | ||
| 390 | /// KODI_HANDLE& addonInstance) | ||
| 391 | /// { | ||
| 392 | /// if (instanceType == ADDON_INSTANCE_SCREENSAVER) | ||
| 393 | /// { | ||
| 394 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Screensaver"); | ||
| 395 | /// addonInstance = new CMyScreensaver(instance); | ||
| 396 | /// return ADDON_STATUS_OK; | ||
| 397 | /// } | ||
| 398 | /// else if (instanceType == ADDON_INSTANCE_VISUALIZATION) | ||
| 399 | /// { | ||
| 400 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Visualization"); | ||
| 401 | /// addonInstance = new CMyVisualization(instance); | ||
| 402 | /// return ADDON_STATUS_OK; | ||
| 403 | /// } | ||
| 404 | /// else if (...) | ||
| 405 | /// { | ||
| 406 | /// ... | ||
| 407 | /// } | ||
| 408 | /// return ADDON_STATUS_UNKNOWN; | ||
| 409 | /// } | ||
| 410 | /// | ||
| 411 | /// ... | ||
| 412 | /// | ||
| 413 | /// ~~~~~~~~~~~~~ | ||
| 414 | /// | ||
| 415 | virtual ADDON_STATUS CreateInstance(int instanceType, | ||
| 416 | const std::string& instanceID, | ||
| 417 | KODI_HANDLE instance, | ||
| 418 | const std::string& version, | ||
| 419 | KODI_HANDLE& addonInstance) | ||
| 333 | { | 420 | { |
| 334 | return CreateInstance(instanceType, instanceID, instance, addonInstance); | 421 | return ADDON_STATUS_NOT_IMPLEMENTED; |
| 335 | } | 422 | } |
| 423 | //-------------------------------------------------------------------------- | ||
| 424 | |||
| 425 | //========================================================================== | ||
| 426 | /// @ingroup cpp_kodi_addon_addonbase | ||
| 427 | /// @brief Instance destroy | ||
| 428 | /// | ||
| 429 | /// This function is optional and intended to notify addon that the instance | ||
| 430 | /// is terminating. | ||
| 431 | /// | ||
| 432 | /// @param[in] instanceType The requested type of required instance, see \ref ADDON_TYPE. | ||
| 433 | /// @param[in] instanceID An individual identification key string given by Kodi. | ||
| 434 | /// @param[in] addonInstance The pointer to instance class created in addon. | ||
| 435 | /// | ||
| 436 | /// @warning This call is only used to inform that the associated instance | ||
| 437 | /// is terminated. The deletion is carried out in the background. | ||
| 438 | /// | ||
| 439 | virtual void DestroyInstance(int instanceType, | ||
| 440 | const std::string& instanceID, | ||
| 441 | KODI_HANDLE addonInstance) | ||
| 442 | { | ||
| 443 | } | ||
| 444 | //-------------------------------------------------------------------------- | ||
| 445 | |||
| 446 | /* Background helper for GUI render systems, e.g. Screensaver or Visualization */ | ||
| 447 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 336 | 448 | ||
| 337 | /* Global variables of class */ | 449 | /* Global variables of class */ |
| 338 | static AddonGlobalInterface* m_interface; // Interface function table to hold addresses on add-on and from kodi | 450 | static AddonGlobalInterface* |
| 339 | static std::string m_strGlobalApiVersion; | 451 | m_interface; // Interface function table to hold addresses on add-on and from kodi |
| 340 | 452 | ||
| 341 | /*private:*/ /* Needed public as long the old call functions becomes used! */ | 453 | /*private:*/ /* Needed public as long the old call functions becomes used! */ |
| 342 | static inline void ADDONBASE_Destroy() | 454 | static inline void ADDONBASE_Destroy() |
| 343 | { | 455 | { |
| 344 | delete CAddonBase::m_interface->addonBase; | 456 | delete static_cast<CAddonBase*>(m_interface->addonBase); |
| 345 | CAddonBase::m_interface->addonBase = nullptr; | 457 | m_interface->addonBase = nullptr; |
| 346 | } | 458 | } |
| 347 | 459 | ||
| 348 | static inline ADDON_STATUS ADDONBASE_GetStatus() { return CAddonBase::m_interface->addonBase->GetStatus(); } | 460 | static inline ADDON_STATUS ADDONBASE_GetStatus() |
| 349 | |||
| 350 | static inline ADDON_STATUS ADDONBASE_SetSetting(const char *settingName, const void *settingValue) | ||
| 351 | { | 461 | { |
| 352 | return CAddonBase::m_interface->addonBase->SetSetting(settingName, CSettingValue(settingValue)); | 462 | return static_cast<CAddonBase*>(m_interface->addonBase)->GetStatus(); |
| 353 | } | 463 | } |
| 354 | 464 | ||
| 355 | static inline ADDON_STATUS ADDONBASE_CreateInstance(int instanceType, const char* instanceID, KODI_HANDLE instance, KODI_HANDLE* addonInstance, KODI_HANDLE parent) | 465 | static inline ADDON_STATUS ADDONBASE_SetSetting(const char* settingName, const void* settingValue) |
| 356 | { | 466 | { |
| 357 | return ADDONBASE_CreateInstanceEx(instanceType, instanceID, instance, addonInstance, parent, ""); | 467 | return static_cast<CAddonBase*>(m_interface->addonBase) |
| 468 | ->SetSetting(settingName, CSettingValue(settingValue)); | ||
| 358 | } | 469 | } |
| 359 | 470 | ||
| 360 | static inline ADDON_STATUS ADDONBASE_CreateInstanceEx(int instanceType, const char* instanceID, KODI_HANDLE instance, KODI_HANDLE* addonInstance, KODI_HANDLE parent, const char* version) | 471 | private: |
| 472 | static inline ADDON_STATUS ADDONBASE_CreateInstance(int instanceType, | ||
| 473 | const char* instanceID, | ||
| 474 | KODI_HANDLE instance, | ||
| 475 | const char* version, | ||
| 476 | KODI_HANDLE* addonInstance, | ||
| 477 | KODI_HANDLE parent) | ||
| 361 | { | 478 | { |
| 479 | CAddonBase* base = static_cast<CAddonBase*>(m_interface->addonBase); | ||
| 480 | |||
| 362 | ADDON_STATUS status = ADDON_STATUS_NOT_IMPLEMENTED; | 481 | ADDON_STATUS status = ADDON_STATUS_NOT_IMPLEMENTED; |
| 363 | if (parent != nullptr) | 482 | |
| 364 | status = static_cast<IAddonInstance*>(parent)->CreateInstanceEx(instanceType, instanceID, instance, *addonInstance, version); | 483 | /* Check about single instance usage: |
| 365 | if (status == ADDON_STATUS_NOT_IMPLEMENTED) | 484 | * 1. The kodi side instance pointer must be equal to first one |
| 366 | status = CAddonBase::m_interface->addonBase->CreateInstanceEx(instanceType, instanceID, instance, *addonInstance, version); | 485 | * 2. The addon side instance pointer must be set |
| 486 | * 3. And the requested type must be equal with used add-on class | ||
| 487 | */ | ||
| 488 | if (m_interface->firstKodiInstance == instance && m_interface->globalSingleInstance && | ||
| 489 | static_cast<IAddonInstance*>(m_interface->globalSingleInstance)->m_type == instanceType) | ||
| 490 | { | ||
| 491 | /* The handling here is intended for the case of the add-on only one | ||
| 492 | * instance and this is integrated in the add-on base class. | ||
| 493 | */ | ||
| 494 | *addonInstance = m_interface->globalSingleInstance; | ||
| 495 | status = ADDON_STATUS_OK; | ||
| 496 | } | ||
| 497 | else | ||
| 498 | { | ||
| 499 | /* Here it should use the CreateInstance instance function to allow | ||
| 500 | * creation of several on one addon. | ||
| 501 | */ | ||
| 502 | |||
| 503 | /* Check first a parent is defined about (e.g. Codec within inputstream) */ | ||
| 504 | if (parent != nullptr) | ||
| 505 | status = static_cast<IAddonInstance*>(parent)->CreateInstance( | ||
| 506 | instanceType, instanceID, instance, version, *addonInstance); | ||
| 507 | |||
| 508 | /* if no parent call the main instance creation function to get it */ | ||
| 509 | if (status == ADDON_STATUS_NOT_IMPLEMENTED) | ||
| 510 | { | ||
| 511 | status = base->CreateInstance(instanceType, instanceID, instance, version, *addonInstance); | ||
| 512 | } | ||
| 513 | } | ||
| 514 | |||
| 367 | if (*addonInstance == nullptr) | 515 | if (*addonInstance == nullptr) |
| 368 | throw std::logic_error("kodi::addon::CAddonBase CreateInstanceEx returns a empty instance pointer!"); | 516 | { |
| 517 | if (status == ADDON_STATUS_OK) | ||
| 518 | { | ||
| 519 | m_interface->toKodi->addon_log_msg(m_interface->toKodi->kodiBase, ADDON_LOG_FATAL, | ||
| 520 | "kodi::addon::CAddonBase CreateInstance returned an " | ||
| 521 | "empty instance pointer, but reported OK!"); | ||
| 522 | return ADDON_STATUS_PERMANENT_FAILURE; | ||
| 523 | } | ||
| 524 | else | ||
| 525 | { | ||
| 526 | return status; | ||
| 527 | } | ||
| 528 | } | ||
| 529 | |||
| 530 | if (static_cast<IAddonInstance*>(*addonInstance)->m_type != instanceType) | ||
| 531 | { | ||
| 532 | m_interface->toKodi->addon_log_msg( | ||
| 533 | m_interface->toKodi->kodiBase, ADDON_LOG_FATAL, | ||
| 534 | "kodi::addon::CAddonBase CreateInstance difference between given and returned"); | ||
| 535 | delete static_cast<IAddonInstance*>(*addonInstance); | ||
| 536 | *addonInstance = nullptr; | ||
| 537 | return ADDON_STATUS_PERMANENT_FAILURE; | ||
| 538 | } | ||
| 369 | 539 | ||
| 370 | if (static_cast<::kodi::addon::IAddonInstance*>(*addonInstance)->m_type != instanceType) | 540 | // Store the used ID inside instance, to have on destroy calls by addon to identify |
| 371 | throw std::logic_error("kodi::addon::CAddonBase CreateInstanceEx with difference on given and returned instance type!"); | 541 | static_cast<IAddonInstance*>(*addonInstance)->m_id = instanceID; |
| 372 | 542 | ||
| 373 | return status; | 543 | return status; |
| 374 | } | 544 | } |
| 375 | 545 | ||
| 376 | static inline void ADDONBASE_DestroyInstance(int instanceType, KODI_HANDLE instance) | 546 | static inline void ADDONBASE_DestroyInstance(int instanceType, KODI_HANDLE instance) |
| 377 | { | 547 | { |
| 378 | if (CAddonBase::m_interface->globalSingleInstance == nullptr && instance != CAddonBase::m_interface->addonBase) | 548 | CAddonBase* base = static_cast<CAddonBase*>(m_interface->addonBase); |
| 549 | |||
| 550 | if (m_interface->globalSingleInstance == nullptr && instance != base) | ||
| 379 | { | 551 | { |
| 380 | if (static_cast<::kodi::addon::IAddonInstance*>(instance)->m_type == instanceType) | 552 | base->DestroyInstance(instanceType, static_cast<IAddonInstance*>(instance)->m_id, instance); |
| 381 | delete static_cast<::kodi::addon::IAddonInstance*>(instance); | 553 | delete static_cast<IAddonInstance*>(instance); |
| 382 | else | ||
| 383 | throw std::logic_error("kodi::addon::CAddonBase DestroyInstance called with difference on given and present instance type!"); | ||
| 384 | } | 554 | } |
| 385 | } | 555 | } |
| 386 | }; | 556 | }; |
| 557 | |||
| 387 | } /* namespace addon */ | 558 | } /* namespace addon */ |
| 388 | } /* namespace kodi */ | 559 | |
| 560 | //============================================================================== | ||
| 561 | /// @ingroup cpp_kodi_addon | ||
| 562 | /// @brief To get used version inside Kodi itself about asked type. | ||
| 563 | /// | ||
| 564 | /// This thought to allow a addon a handling of newer addon versions within | ||
| 565 | /// older Kodi until the type min version not changed. | ||
| 566 | /// | ||
| 567 | /// @param[in] type The wanted type of @ref ADDON_TYPE to ask | ||
| 568 | /// @return The version string about type in MAJOR.MINOR.PATCH style. | ||
| 569 | /// | ||
| 570 | inline std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type) | ||
| 571 | { | ||
| 572 | using namespace kodi::addon; | ||
| 573 | |||
| 574 | char* str = CAddonBase::m_interface->toKodi->get_type_version( | ||
| 575 | CAddonBase::m_interface->toKodi->kodiBase, type); | ||
| 576 | std::string ret = str; | ||
| 577 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str); | ||
| 578 | return ret; | ||
| 579 | } | ||
| 389 | //------------------------------------------------------------------------------ | 580 | //------------------------------------------------------------------------------ |
| 390 | 581 | ||
| 391 | //============================================================================== | 582 | //============================================================================== |
| 392 | namespace kodi { | ||
| 393 | /// | 583 | /// |
| 394 | inline std::string GetAddonPath(const std::string& append = "") | 584 | inline std::string ATTRIBUTE_HIDDEN GetAddonPath(const std::string& append = "") |
| 395 | { | 585 | { |
| 396 | char* str = ::kodi::addon::CAddonBase::m_interface->toKodi->get_addon_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | 586 | using namespace kodi::addon; |
| 587 | |||
| 588 | char* str = | ||
| 589 | CAddonBase::m_interface->toKodi->get_addon_path(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 397 | std::string ret = str; | 590 | std::string ret = str; |
| 398 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, str); | 591 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str); |
| 399 | if (!append.empty()) | 592 | if (!append.empty()) |
| 400 | { | 593 | { |
| 401 | if (append.at(0) != '\\' && | 594 | if (append.at(0) != '\\' && append.at(0) != '/') |
| 402 | append.at(0) != '/') | ||
| 403 | #ifdef TARGET_WINDOWS | 595 | #ifdef TARGET_WINDOWS |
| 404 | ret.append("\\"); | 596 | ret.append("\\"); |
| 405 | #else | 597 | #else |
| @@ -409,21 +601,21 @@ inline std::string GetAddonPath(const std::string& append = "") | |||
| 409 | } | 601 | } |
| 410 | return ret; | 602 | return ret; |
| 411 | } | 603 | } |
| 412 | } /* namespace kodi */ | ||
| 413 | //------------------------------------------------------------------------------ | 604 | //------------------------------------------------------------------------------ |
| 414 | 605 | ||
| 415 | //============================================================================== | 606 | //============================================================================== |
| 416 | namespace kodi { | ||
| 417 | /// | 607 | /// |
| 418 | inline std::string GetBaseUserPath(const std::string& append = "") | 608 | inline std::string ATTRIBUTE_HIDDEN GetBaseUserPath(const std::string& append = "") |
| 419 | { | 609 | { |
| 420 | char* str = ::kodi::addon::CAddonBase::m_interface->toKodi->get_base_user_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | 610 | using namespace kodi::addon; |
| 611 | |||
| 612 | char* str = CAddonBase::m_interface->toKodi->get_base_user_path( | ||
| 613 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 421 | std::string ret = str; | 614 | std::string ret = str; |
| 422 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, str); | 615 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str); |
| 423 | if (!append.empty()) | 616 | if (!append.empty()) |
| 424 | { | 617 | { |
| 425 | if (append.at(0) != '\\' && | 618 | if (append.at(0) != '\\' && append.at(0) != '/') |
| 426 | append.at(0) != '/') | ||
| 427 | #ifdef TARGET_WINDOWS | 619 | #ifdef TARGET_WINDOWS |
| 428 | ret.append("\\"); | 620 | ret.append("\\"); |
| 429 | #else | 621 | #else |
| @@ -433,174 +625,574 @@ inline std::string GetBaseUserPath(const std::string& append = "") | |||
| 433 | } | 625 | } |
| 434 | return ret; | 626 | return ret; |
| 435 | } | 627 | } |
| 436 | } /* namespace kodi */ | ||
| 437 | //------------------------------------------------------------------------------ | 628 | //------------------------------------------------------------------------------ |
| 438 | 629 | ||
| 439 | //============================================================================== | 630 | //============================================================================== |
| 440 | namespace kodi { | ||
| 441 | /// | 631 | /// |
| 442 | inline std::string GetLibPath() | 632 | inline std::string ATTRIBUTE_HIDDEN GetLibPath() |
| 443 | { | 633 | { |
| 444 | return ::kodi::addon::CAddonBase::m_interface->libBasePath; | 634 | using namespace kodi::addon; |
| 635 | |||
| 636 | return CAddonBase::m_interface->libBasePath; | ||
| 445 | } | 637 | } |
| 446 | } /* namespace kodi */ | ||
| 447 | //------------------------------------------------------------------------------ | 638 | //------------------------------------------------------------------------------ |
| 448 | 639 | ||
| 449 | //============================================================================== | 640 | //============================================================================== |
| 450 | namespace kodi { | 641 | /// @ingroup cpp_kodi |
| 642 | /// @brief Add a message to Kodi's log. | ||
| 643 | /// | ||
| 644 | /// @param[in] loglevel The log level of the message. | ||
| 645 | /// @param[in] format The format of the message to pass to Kodi. | ||
| 646 | /// @param[in] ... Additional text to insert in format text | ||
| 647 | /// | ||
| 648 | /// | ||
| 649 | /// @note This method uses limited buffer (16k) for the formatted output. | ||
| 650 | /// So data, which will not fit into it, will be silently discarded. | ||
| 451 | /// | 651 | /// |
| 452 | inline void Log(const AddonLog loglevel, const char* format, ...) | 652 | /// |
| 653 | /// ---------------------------------------------------------------------------- | ||
| 654 | /// | ||
| 655 | /// **Example:** | ||
| 656 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 657 | /// #include <kodi/General.h> | ||
| 658 | /// | ||
| 659 | /// kodi::Log(ADDON_LOG_ERROR, "%s: There is an error occurred!", __func__); | ||
| 660 | /// | ||
| 661 | /// ~~~~~~~~~~~~~ | ||
| 662 | /// | ||
| 663 | inline void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char* format, ...) | ||
| 453 | { | 664 | { |
| 665 | using namespace kodi::addon; | ||
| 666 | |||
| 454 | char buffer[16384]; | 667 | char buffer[16384]; |
| 455 | va_list args; | 668 | va_list args; |
| 456 | va_start(args, format); | 669 | va_start(args, format); |
| 457 | vsprintf(buffer, format, args); | 670 | vsnprintf(buffer, sizeof(buffer), format, args); |
| 458 | va_end(args); | 671 | va_end(args); |
| 459 | ::kodi::addon::CAddonBase::m_interface->toKodi->addon_log_msg(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, loglevel, buffer); | 672 | CAddonBase::m_interface->toKodi->addon_log_msg(CAddonBase::m_interface->toKodi->kodiBase, |
| 673 | loglevel, buffer); | ||
| 460 | } | 674 | } |
| 461 | } /* namespace kodi */ | ||
| 462 | //------------------------------------------------------------------------------ | 675 | //------------------------------------------------------------------------------ |
| 463 | 676 | ||
| 464 | //============================================================================ | 677 | //############################################################################## |
| 465 | namespace kodi { | 678 | /// @ingroup cpp_kodi |
| 679 | /// @defgroup cpp_kodi_settings 1. Setting control | ||
| 680 | /// @brief **Functions to handle settings access**\n | ||
| 681 | /// This can be used to get and set the addon related values inside his | ||
| 682 | /// settings.xml. | ||
| 683 | /// | ||
| 684 | /// The settings style is given with installed part on e.g. | ||
| 685 | /// <b>`$HOME/.kodi/addons/myspecial.addon/resources/settings.xml`</b>. The | ||
| 686 | /// related edit becomes then stored inside | ||
| 687 | /// <b>`$HOME/.kodi/userdata/addon_data/myspecial.addon/settings.xml`</b>. | ||
| 688 | /// | ||
| 689 | /*!@{*/ | ||
| 690 | |||
| 691 | //============================================================================== | ||
| 692 | /// @brief Check the given setting name is set to default value. | ||
| 466 | /// | 693 | /// |
| 467 | inline bool CheckSettingString(const std::string& settingName, std::string& settingValue) | 694 | /// The setting name relate to names used in his <b>settings.xml</b> file. |
| 695 | /// | ||
| 696 | /// @param[in] settingName The name of asked setting | ||
| 697 | /// @return true if setting is the default | ||
| 698 | /// | ||
| 699 | inline bool ATTRIBUTE_HIDDEN IsSettingUsingDefault(const std::string& settingName) | ||
| 468 | { | 700 | { |
| 701 | using namespace kodi::addon; | ||
| 702 | return CAddonBase::m_interface->toKodi->is_setting_using_default( | ||
| 703 | CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str()); | ||
| 704 | } | ||
| 705 | //------------------------------------------------------------------------------ | ||
| 706 | |||
| 707 | //============================================================================== | ||
| 708 | /// @brief Check and get a string setting value. | ||
| 709 | /// | ||
| 710 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 711 | /// | ||
| 712 | /// @param[in] settingName The name of asked setting | ||
| 713 | /// @param[out] settingValue The given setting value | ||
| 714 | /// @return true if setting was successfully found and "settingValue" is set | ||
| 715 | /// | ||
| 716 | /// @note If returns false, the "settingValue" is not changed. | ||
| 717 | /// | ||
| 718 | /// | ||
| 719 | /// ---------------------------------------------------------------------------- | ||
| 720 | /// | ||
| 721 | /// **Example:** | ||
| 722 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 723 | /// #include <kodi/General.h> | ||
| 724 | /// | ||
| 725 | /// std::string value; | ||
| 726 | /// if (!kodi::CheckSettingString("my_string_value", value)) | ||
| 727 | /// value = "my_default_if_setting_not_work"; | ||
| 728 | /// ~~~~~~~~~~~~~ | ||
| 729 | /// | ||
| 730 | inline bool ATTRIBUTE_HIDDEN CheckSettingString(const std::string& settingName, | ||
| 731 | std::string& settingValue) | ||
| 732 | { | ||
| 733 | using namespace kodi::addon; | ||
| 734 | |||
| 469 | char* buffer = nullptr; | 735 | char* buffer = nullptr; |
| 470 | bool ret = ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &buffer); | 736 | bool ret = CAddonBase::m_interface->toKodi->get_setting_string( |
| 737 | CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &buffer); | ||
| 471 | if (buffer) | 738 | if (buffer) |
| 472 | { | 739 | { |
| 473 | if (ret) | 740 | if (ret) |
| 474 | settingValue = buffer; | 741 | settingValue = buffer; |
| 475 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, buffer); | 742 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, buffer); |
| 476 | } | 743 | } |
| 477 | return ret; | 744 | return ret; |
| 478 | } | 745 | } |
| 479 | } /* namespace kodi */ | 746 | //------------------------------------------------------------------------------ |
| 480 | //---------------------------------------------------------------------------- | ||
| 481 | 747 | ||
| 482 | //============================================================================ | 748 | //============================================================================== |
| 483 | namespace kodi { | 749 | /// @brief Get string setting value. |
| 750 | /// | ||
| 751 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 752 | /// | ||
| 753 | /// @param[in] settingName The name of asked setting | ||
| 754 | /// @param[in] defaultValue [opt] Default value if not found | ||
| 755 | /// @return The value of setting, empty if not found; | ||
| 756 | /// | ||
| 757 | /// | ||
| 758 | /// ---------------------------------------------------------------------------- | ||
| 759 | /// | ||
| 760 | /// **Example:** | ||
| 761 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 762 | /// #include <kodi/General.h> | ||
| 763 | /// | ||
| 764 | /// std::string value = kodi::GetSettingString("my_string_value"); | ||
| 765 | /// ~~~~~~~~~~~~~ | ||
| 484 | /// | 766 | /// |
| 485 | inline std::string GetSettingString(const std::string& settingName) | 767 | inline std::string ATTRIBUTE_HIDDEN GetSettingString(const std::string& settingName, |
| 768 | const std::string& defaultValue = "") | ||
| 486 | { | 769 | { |
| 487 | std::string settingValue; | 770 | std::string settingValue = defaultValue; |
| 488 | CheckSettingString(settingName, settingValue); | 771 | CheckSettingString(settingName, settingValue); |
| 489 | return settingValue; | 772 | return settingValue; |
| 490 | } | 773 | } |
| 491 | } /* namespace kodi */ | 774 | //------------------------------------------------------------------------------ |
| 492 | //---------------------------------------------------------------------------- | ||
| 493 | 775 | ||
| 494 | //============================================================================ | 776 | //============================================================================== |
| 495 | namespace kodi { | 777 | /// @brief Set string setting of addon. |
| 778 | /// | ||
| 779 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 780 | /// | ||
| 781 | /// @param[in] settingName The name of setting | ||
| 782 | /// @param[in] settingValue The setting value to write | ||
| 783 | /// | ||
| 496 | /// | 784 | /// |
| 497 | inline void SetSettingString(const std::string& settingName, const std::string& settingValue) | 785 | /// ---------------------------------------------------------------------------- |
| 786 | /// | ||
| 787 | /// **Example:** | ||
| 788 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 789 | /// #include <kodi/General.h> | ||
| 790 | /// | ||
| 791 | /// std::string value = "my_new_name for"; | ||
| 792 | /// kodi::SetSettingString("my_string_value", value); | ||
| 793 | /// ~~~~~~~~~~~~~ | ||
| 794 | /// | ||
| 795 | inline void ATTRIBUTE_HIDDEN SetSettingString(const std::string& settingName, | ||
| 796 | const std::string& settingValue) | ||
| 498 | { | 797 | { |
| 499 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue.c_str()); | 798 | using namespace kodi::addon; |
| 799 | |||
| 800 | CAddonBase::m_interface->toKodi->set_setting_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 801 | settingName.c_str(), settingValue.c_str()); | ||
| 500 | } | 802 | } |
| 501 | } /* namespace kodi */ | 803 | //------------------------------------------------------------------------------ |
| 502 | //---------------------------------------------------------------------------- | ||
| 503 | 804 | ||
| 504 | //============================================================================ | 805 | //============================================================================== |
| 505 | namespace kodi { | 806 | /// @brief Check and get a integer setting value. |
| 807 | /// | ||
| 808 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 809 | /// | ||
| 810 | /// @param[in] settingName The name of asked setting | ||
| 811 | /// @param[out] settingValue The given setting value | ||
| 812 | /// @return true if setting was successfully found and "settingValue" is set | ||
| 813 | /// | ||
| 814 | /// @note If returns false, the "settingValue" is not changed. | ||
| 506 | /// | 815 | /// |
| 507 | inline bool CheckSettingInt(const std::string& settingName, int& settingValue) | 816 | /// |
| 817 | /// ---------------------------------------------------------------------------- | ||
| 818 | /// | ||
| 819 | /// **Example:** | ||
| 820 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 821 | /// #include <kodi/General.h> | ||
| 822 | /// | ||
| 823 | /// int value = 0; | ||
| 824 | /// if (!kodi::CheckSettingInt("my_integer_value", value)) | ||
| 825 | /// value = 123; // My default of them | ||
| 826 | /// ~~~~~~~~~~~~~ | ||
| 827 | /// | ||
| 828 | inline bool ATTRIBUTE_HIDDEN CheckSettingInt(const std::string& settingName, int& settingValue) | ||
| 508 | { | 829 | { |
| 509 | return ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting_int(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | 830 | using namespace kodi::addon; |
| 831 | |||
| 832 | return CAddonBase::m_interface->toKodi->get_setting_int(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 833 | settingName.c_str(), &settingValue); | ||
| 510 | } | 834 | } |
| 511 | } /* namespace kodi */ | 835 | //------------------------------------------------------------------------------ |
| 512 | //---------------------------------------------------------------------------- | ||
| 513 | 836 | ||
| 514 | //============================================================================ | 837 | //============================================================================== |
| 515 | namespace kodi { | 838 | /// @brief Get integer setting value. |
| 839 | /// | ||
| 840 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 841 | /// | ||
| 842 | /// @param[in] settingName The name of asked setting | ||
| 843 | /// @param[in] defaultValue [opt] Default value if not found | ||
| 844 | /// @return The value of setting, <b>`0`</b> or defaultValue if not found | ||
| 516 | /// | 845 | /// |
| 517 | inline int GetSettingInt(const std::string& settingName) | 846 | /// |
| 847 | /// ---------------------------------------------------------------------------- | ||
| 848 | /// | ||
| 849 | /// **Example:** | ||
| 850 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 851 | /// #include <kodi/General.h> | ||
| 852 | /// | ||
| 853 | /// int value = kodi::GetSettingInt("my_integer_value"); | ||
| 854 | /// ~~~~~~~~~~~~~ | ||
| 855 | /// | ||
| 856 | inline int ATTRIBUTE_HIDDEN GetSettingInt(const std::string& settingName, int defaultValue = 0) | ||
| 518 | { | 857 | { |
| 519 | int settingValue = 0; | 858 | int settingValue = defaultValue; |
| 520 | CheckSettingInt(settingName, settingValue); | 859 | CheckSettingInt(settingName, settingValue); |
| 521 | return settingValue; | 860 | return settingValue; |
| 522 | } | 861 | } |
| 523 | } /* namespace kodi */ | 862 | //------------------------------------------------------------------------------ |
| 524 | //---------------------------------------------------------------------------- | ||
| 525 | 863 | ||
| 526 | //============================================================================ | 864 | //============================================================================== |
| 527 | namespace kodi { | 865 | /// @brief Set integer setting of addon. |
| 866 | /// | ||
| 867 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 868 | /// | ||
| 869 | /// @param[in] settingName The name of setting | ||
| 870 | /// @param[in] settingValue The setting value to write | ||
| 528 | /// | 871 | /// |
| 529 | inline void SetSettingInt(const std::string& settingName, int settingValue) | 872 | /// |
| 873 | /// ---------------------------------------------------------------------------- | ||
| 874 | /// | ||
| 875 | /// **Example:** | ||
| 876 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 877 | /// #include <kodi/General.h> | ||
| 878 | /// | ||
| 879 | /// int value = 123; | ||
| 880 | /// kodi::SetSettingInt("my_integer_value", value); | ||
| 881 | /// ~~~~~~~~~~~~~ | ||
| 882 | /// | ||
| 883 | inline void ATTRIBUTE_HIDDEN SetSettingInt(const std::string& settingName, int settingValue) | ||
| 530 | { | 884 | { |
| 531 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting_int(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue); | 885 | using namespace kodi::addon; |
| 886 | |||
| 887 | CAddonBase::m_interface->toKodi->set_setting_int(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 888 | settingName.c_str(), settingValue); | ||
| 532 | } | 889 | } |
| 533 | } /* namespace kodi */ | 890 | //------------------------------------------------------------------------------ |
| 534 | //---------------------------------------------------------------------------- | ||
| 535 | 891 | ||
| 536 | //============================================================================ | 892 | //============================================================================== |
| 537 | namespace kodi { | 893 | /// @brief Check and get a boolean setting value. |
| 894 | /// | ||
| 895 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 896 | /// | ||
| 897 | /// @param[in] settingName The name of asked setting | ||
| 898 | /// @param[out] settingValue The given setting value | ||
| 899 | /// @return true if setting was successfully found and "settingValue" is set | ||
| 900 | /// | ||
| 901 | /// @note If returns false, the "settingValue" is not changed. | ||
| 902 | /// | ||
| 903 | /// | ||
| 904 | /// ---------------------------------------------------------------------------- | ||
| 538 | /// | 905 | /// |
| 539 | inline bool CheckSettingBoolean(const std::string& settingName, bool& settingValue) | 906 | /// **Example:** |
| 907 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 908 | /// #include <kodi/General.h> | ||
| 909 | /// | ||
| 910 | /// bool value = false; | ||
| 911 | /// if (!kodi::CheckSettingBoolean("my_boolean_value", value)) | ||
| 912 | /// value = true; // My default of them | ||
| 913 | /// ~~~~~~~~~~~~~ | ||
| 914 | /// | ||
| 915 | inline bool ATTRIBUTE_HIDDEN CheckSettingBoolean(const std::string& settingName, bool& settingValue) | ||
| 540 | { | 916 | { |
| 541 | return ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting_bool(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | 917 | using namespace kodi::addon; |
| 918 | |||
| 919 | return CAddonBase::m_interface->toKodi->get_setting_bool( | ||
| 920 | CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | ||
| 542 | } | 921 | } |
| 543 | } /* namespace kodi */ | 922 | //------------------------------------------------------------------------------ |
| 544 | //---------------------------------------------------------------------------- | ||
| 545 | 923 | ||
| 546 | //============================================================================ | 924 | //============================================================================== |
| 547 | namespace kodi { | 925 | /// @brief Get boolean setting value. |
| 926 | /// | ||
| 927 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 928 | /// | ||
| 929 | /// @param[in] settingName The name of asked setting | ||
| 930 | /// @param[in] defaultValue [opt] Default value if not found | ||
| 931 | /// @return The value of setting, <b>`false`</b> or defaultValue if not found | ||
| 932 | /// | ||
| 933 | /// | ||
| 934 | /// ---------------------------------------------------------------------------- | ||
| 548 | /// | 935 | /// |
| 549 | inline bool GetSettingBoolean(const std::string& settingName) | 936 | /// **Example:** |
| 937 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 938 | /// #include <kodi/General.h> | ||
| 939 | /// | ||
| 940 | /// bool value = kodi::GetSettingBoolean("my_boolean_value"); | ||
| 941 | /// ~~~~~~~~~~~~~ | ||
| 942 | /// | ||
| 943 | inline bool ATTRIBUTE_HIDDEN GetSettingBoolean(const std::string& settingName, | ||
| 944 | bool defaultValue = false) | ||
| 550 | { | 945 | { |
| 551 | bool settingValue = false; | 946 | bool settingValue = defaultValue; |
| 552 | CheckSettingBoolean(settingName, settingValue); | 947 | CheckSettingBoolean(settingName, settingValue); |
| 553 | return settingValue; | 948 | return settingValue; |
| 554 | } | 949 | } |
| 555 | } /* namespace kodi */ | 950 | //------------------------------------------------------------------------------ |
| 556 | //---------------------------------------------------------------------------- | ||
| 557 | 951 | ||
| 558 | //============================================================================ | 952 | //============================================================================== |
| 559 | namespace kodi { | 953 | /// @brief Set boolean setting of addon. |
| 954 | /// | ||
| 955 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 956 | /// | ||
| 957 | /// @param[in] settingName The name of setting | ||
| 958 | /// @param[in] settingValue The setting value to write | ||
| 959 | /// | ||
| 960 | /// | ||
| 961 | /// ---------------------------------------------------------------------------- | ||
| 560 | /// | 962 | /// |
| 561 | inline void SetSettingBoolean(const std::string& settingName, bool settingValue) | 963 | /// **Example:** |
| 964 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 965 | /// #include <kodi/General.h> | ||
| 966 | /// | ||
| 967 | /// bool value = true; | ||
| 968 | /// kodi::SetSettingBoolean("my_boolean_value", value); | ||
| 969 | /// ~~~~~~~~~~~~~ | ||
| 970 | /// | ||
| 971 | inline void ATTRIBUTE_HIDDEN SetSettingBoolean(const std::string& settingName, bool settingValue) | ||
| 562 | { | 972 | { |
| 563 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting_bool(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue); | 973 | using namespace kodi::addon; |
| 974 | |||
| 975 | CAddonBase::m_interface->toKodi->set_setting_bool(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 976 | settingName.c_str(), settingValue); | ||
| 564 | } | 977 | } |
| 565 | } /* namespace kodi */ | 978 | //------------------------------------------------------------------------------ |
| 566 | //---------------------------------------------------------------------------- | ||
| 567 | 979 | ||
| 568 | //============================================================================ | 980 | //============================================================================== |
| 569 | namespace kodi { | 981 | /// @brief Check and get a floating point setting value. |
| 982 | /// | ||
| 983 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 984 | /// | ||
| 985 | /// @param[in] settingName The name of asked setting | ||
| 986 | /// @param[out] settingValue The given setting value | ||
| 987 | /// @return true if setting was successfully found and "settingValue" is set | ||
| 988 | /// | ||
| 989 | /// @note If returns false, the "settingValue" is not changed. | ||
| 990 | /// | ||
| 570 | /// | 991 | /// |
| 571 | inline bool CheckSettingFloat(const std::string& settingName, float& settingValue) | 992 | /// ---------------------------------------------------------------------------- |
| 993 | /// | ||
| 994 | /// **Example:** | ||
| 995 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 996 | /// #include <kodi/General.h> | ||
| 997 | /// | ||
| 998 | /// float value = 0.0f; | ||
| 999 | /// if (!kodi::CheckSettingBoolean("my_float_value", value)) | ||
| 1000 | /// value = 1.0f; // My default of them | ||
| 1001 | /// ~~~~~~~~~~~~~ | ||
| 1002 | /// | ||
| 1003 | inline bool ATTRIBUTE_HIDDEN CheckSettingFloat(const std::string& settingName, float& settingValue) | ||
| 572 | { | 1004 | { |
| 573 | return ::kodi::addon::CAddonBase::m_interface->toKodi->get_setting_float(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | 1005 | using namespace kodi::addon; |
| 1006 | |||
| 1007 | return CAddonBase::m_interface->toKodi->get_setting_float( | ||
| 1008 | CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue); | ||
| 574 | } | 1009 | } |
| 575 | } /* namespace kodi */ | 1010 | //------------------------------------------------------------------------------ |
| 576 | //---------------------------------------------------------------------------- | ||
| 577 | 1011 | ||
| 578 | //============================================================================ | 1012 | //============================================================================== |
| 579 | namespace kodi { | 1013 | /// @brief Get floating point setting value. |
| 1014 | /// | ||
| 1015 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 1016 | /// | ||
| 1017 | /// @param[in] settingName The name of asked setting | ||
| 1018 | /// @param[in] defaultValue [opt] Default value if not found | ||
| 1019 | /// @return The value of setting, <b>`0.0`</b> or defaultValue if not found | ||
| 1020 | /// | ||
| 580 | /// | 1021 | /// |
| 581 | inline float GetSettingFloat(const std::string& settingName) | 1022 | /// ---------------------------------------------------------------------------- |
| 1023 | /// | ||
| 1024 | /// **Example:** | ||
| 1025 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1026 | /// #include <kodi/General.h> | ||
| 1027 | /// | ||
| 1028 | /// float value = kodi::GetSettingFloat("my_float_value"); | ||
| 1029 | /// ~~~~~~~~~~~~~ | ||
| 1030 | /// | ||
| 1031 | inline float ATTRIBUTE_HIDDEN GetSettingFloat(const std::string& settingName, | ||
| 1032 | float defaultValue = 0.0f) | ||
| 582 | { | 1033 | { |
| 583 | float settingValue = 0.0f; | 1034 | float settingValue = defaultValue; |
| 584 | CheckSettingFloat(settingName, settingValue); | 1035 | CheckSettingFloat(settingName, settingValue); |
| 585 | return settingValue; | 1036 | return settingValue; |
| 586 | } | 1037 | } |
| 587 | } /* namespace kodi */ | 1038 | //------------------------------------------------------------------------------ |
| 588 | //---------------------------------------------------------------------------- | ||
| 589 | 1039 | ||
| 590 | //============================================================================ | 1040 | //============================================================================== |
| 591 | namespace kodi { | 1041 | /// @brief Set floating point setting of addon. |
| 1042 | /// | ||
| 1043 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 1044 | /// | ||
| 1045 | /// @param[in] settingName The name of setting | ||
| 1046 | /// @param[in] settingValue The setting value to write | ||
| 1047 | /// | ||
| 1048 | /// | ||
| 1049 | /// ---------------------------------------------------------------------------- | ||
| 592 | /// | 1050 | /// |
| 593 | inline void SetSettingFloat(const std::string& settingName, float settingValue) | 1051 | /// **Example:** |
| 1052 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1053 | /// #include <kodi/General.h> | ||
| 1054 | /// | ||
| 1055 | /// float value = 1.0f; | ||
| 1056 | /// kodi::SetSettingFloat("my_float_value", value); | ||
| 1057 | /// ~~~~~~~~~~~~~ | ||
| 1058 | /// | ||
| 1059 | inline void ATTRIBUTE_HIDDEN SetSettingFloat(const std::string& settingName, float settingValue) | ||
| 594 | { | 1060 | { |
| 595 | ::kodi::addon::CAddonBase::m_interface->toKodi->set_setting_float(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), settingValue); | 1061 | using namespace kodi::addon; |
| 1062 | |||
| 1063 | CAddonBase::m_interface->toKodi->set_setting_float(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1064 | settingName.c_str(), settingValue); | ||
| 596 | } | 1065 | } |
| 597 | } /* namespace kodi */ | 1066 | //------------------------------------------------------------------------------ |
| 598 | //---------------------------------------------------------------------------- | 1067 | |
| 1068 | //============================================================================== | ||
| 1069 | /// @brief Check and get a enum setting value. | ||
| 1070 | /// | ||
| 1071 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 1072 | /// | ||
| 1073 | /// @param[in] settingName The name of asked setting | ||
| 1074 | /// @param[out] settingValue The given setting value | ||
| 1075 | /// @return true if setting was successfully found and "settingValue" is set | ||
| 1076 | /// | ||
| 1077 | /// @remark The enums are used as integer inside settings.xml. | ||
| 1078 | /// @note If returns false, the "settingValue" is not changed. | ||
| 1079 | /// | ||
| 1080 | /// | ||
| 1081 | /// ---------------------------------------------------------------------------- | ||
| 1082 | /// | ||
| 1083 | /// **Example:** | ||
| 1084 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1085 | /// #include <kodi/General.h> | ||
| 1086 | /// | ||
| 1087 | /// enum myEnumValue | ||
| 1088 | /// { | ||
| 1089 | /// valueA, | ||
| 1090 | /// valueB, | ||
| 1091 | /// valueC | ||
| 1092 | /// }; | ||
| 1093 | /// | ||
| 1094 | /// myEnumValue value; | ||
| 1095 | /// if (!kodi::CheckSettingEnum<myEnumValue>("my_enum_value", value)) | ||
| 1096 | /// value = valueA; // My default of them | ||
| 1097 | /// ~~~~~~~~~~~~~ | ||
| 1098 | /// | ||
| 1099 | template<typename enumType> | ||
| 1100 | inline bool ATTRIBUTE_HIDDEN CheckSettingEnum(const std::string& settingName, | ||
| 1101 | enumType& settingValue) | ||
| 1102 | { | ||
| 1103 | using namespace kodi::addon; | ||
| 1104 | |||
| 1105 | int settingValueInt = static_cast<int>(settingValue); | ||
| 1106 | bool ret = CAddonBase::m_interface->toKodi->get_setting_int( | ||
| 1107 | CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValueInt); | ||
| 1108 | if (ret) | ||
| 1109 | settingValue = static_cast<enumType>(settingValueInt); | ||
| 1110 | return ret; | ||
| 1111 | } | ||
| 1112 | //------------------------------------------------------------------------------ | ||
| 1113 | |||
| 1114 | //============================================================================== | ||
| 1115 | /// @brief Get enum setting value. | ||
| 1116 | /// | ||
| 1117 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 1118 | /// | ||
| 1119 | /// @param[in] settingName The name of asked setting | ||
| 1120 | /// @param[in] defaultValue [opt] Default value if not found | ||
| 1121 | /// @return The value of setting, forced to <b>`0`</b> or defaultValue if not found | ||
| 1122 | /// | ||
| 1123 | /// @remark The enums are used as integer inside settings.xml. | ||
| 1124 | /// | ||
| 1125 | /// | ||
| 1126 | /// ---------------------------------------------------------------------------- | ||
| 1127 | /// | ||
| 1128 | /// **Example:** | ||
| 1129 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1130 | /// #include <kodi/General.h> | ||
| 1131 | /// | ||
| 1132 | /// enum myEnumValue | ||
| 1133 | /// { | ||
| 1134 | /// valueA, | ||
| 1135 | /// valueB, | ||
| 1136 | /// valueC | ||
| 1137 | /// }; | ||
| 1138 | /// | ||
| 1139 | /// myEnumValue value = kodi::GetSettingEnum<myEnumValue>("my_enum_value"); | ||
| 1140 | /// ~~~~~~~~~~~~~ | ||
| 1141 | /// | ||
| 1142 | template<typename enumType> | ||
| 1143 | inline enumType ATTRIBUTE_HIDDEN GetSettingEnum(const std::string& settingName, | ||
| 1144 | enumType defaultValue = static_cast<enumType>(0)) | ||
| 1145 | { | ||
| 1146 | enumType settingValue = defaultValue; | ||
| 1147 | CheckSettingEnum(settingName, settingValue); | ||
| 1148 | return settingValue; | ||
| 1149 | } | ||
| 1150 | //------------------------------------------------------------------------------ | ||
| 1151 | |||
| 1152 | //============================================================================== | ||
| 1153 | /// @brief Set enum setting of addon. | ||
| 1154 | /// | ||
| 1155 | /// The setting name relate to names used in his <b>settings.xml</b> file. | ||
| 1156 | /// | ||
| 1157 | /// @param[in] settingName The name of setting | ||
| 1158 | /// @param[in] settingValue The setting value to write | ||
| 1159 | /// | ||
| 1160 | /// @remark The enums are used as integer inside settings.xml. | ||
| 1161 | /// | ||
| 1162 | /// | ||
| 1163 | /// ---------------------------------------------------------------------------- | ||
| 1164 | /// | ||
| 1165 | /// **Example:** | ||
| 1166 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1167 | /// #include <kodi/General.h> | ||
| 1168 | /// | ||
| 1169 | /// enum myEnumValue | ||
| 1170 | /// { | ||
| 1171 | /// valueA, | ||
| 1172 | /// valueB, | ||
| 1173 | /// valueC | ||
| 1174 | /// }; | ||
| 1175 | /// | ||
| 1176 | /// myEnumValue value = valueA; | ||
| 1177 | /// kodi::SetSettingEnum<myEnumValue>("my_enum_value", value); | ||
| 1178 | /// ~~~~~~~~~~~~~ | ||
| 1179 | /// | ||
| 1180 | template<typename enumType> | ||
| 1181 | inline void ATTRIBUTE_HIDDEN SetSettingEnum(const std::string& settingName, enumType settingValue) | ||
| 1182 | { | ||
| 1183 | using namespace kodi::addon; | ||
| 1184 | |||
| 1185 | CAddonBase::m_interface->toKodi->set_setting_int(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1186 | settingName.c_str(), | ||
| 1187 | static_cast<int>(settingValue)); | ||
| 1188 | } | ||
| 1189 | //------------------------------------------------------------------------------ | ||
| 1190 | |||
| 1191 | /*!@}*/ | ||
| 599 | 1192 | ||
| 600 | //============================================================================ | 1193 | //============================================================================ |
| 601 | namespace kodi { | ||
| 602 | /// | 1194 | /// |
| 603 | inline std::string TranslateAddonStatus(ADDON_STATUS status) | 1195 | inline std::string ATTRIBUTE_HIDDEN TranslateAddonStatus(ADDON_STATUS status) |
| 604 | { | 1196 | { |
| 605 | switch (status) | 1197 | switch (status) |
| 606 | { | 1198 | { |
| @@ -623,13 +1215,10 @@ inline std::string TranslateAddonStatus(ADDON_STATUS status) | |||
| 623 | } | 1215 | } |
| 624 | return "Unknown"; | 1216 | return "Unknown"; |
| 625 | } | 1217 | } |
| 626 | } /* namespace kodi */ | ||
| 627 | //---------------------------------------------------------------------------- | 1218 | //---------------------------------------------------------------------------- |
| 628 | 1219 | ||
| 629 | //============================================================================== | 1220 | //============================================================================== |
| 630 | namespace kodi { | 1221 | /// @ingroup cpp_kodi |
| 631 | /// | ||
| 632 | /// \ingroup cpp_kodi | ||
| 633 | /// @brief Returns a function table to a named interface | 1222 | /// @brief Returns a function table to a named interface |
| 634 | /// | 1223 | /// |
| 635 | /// @return pointer to struct containing interface functions | 1224 | /// @return pointer to struct containing interface functions |
| @@ -646,12 +1235,16 @@ namespace kodi { | |||
| 646 | /// ... | 1235 | /// ... |
| 647 | /// ~~~~~~~~~~~~~ | 1236 | /// ~~~~~~~~~~~~~ |
| 648 | /// | 1237 | /// |
| 649 | inline void* GetInterface(const std::string &name, const std::string &version) | 1238 | inline void* GetInterface(const std::string& name, const std::string& version) |
| 650 | { | 1239 | { |
| 651 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 1240 | using namespace kodi::addon; |
| 1241 | |||
| 1242 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 652 | 1243 | ||
| 653 | return toKodi->get_interface(toKodi->kodiBase, name.c_str(), version.c_str()); | 1244 | return toKodi->get_interface(toKodi->kodiBase, name.c_str(), version.c_str()); |
| 654 | } | 1245 | } |
| 1246 | //---------------------------------------------------------------------------- | ||
| 1247 | |||
| 655 | } /* namespace kodi */ | 1248 | } /* namespace kodi */ |
| 656 | 1249 | ||
| 657 | /*! addon creation macro | 1250 | /*! addon creation macro |
| @@ -663,17 +1256,13 @@ inline void* GetInterface(const std::string &name, const std::string &version) | |||
| 663 | * Becomes really cleaned up soon :D | 1256 | * Becomes really cleaned up soon :D |
| 664 | */ | 1257 | */ |
| 665 | #define ADDONCREATOR(AddonClass) \ | 1258 | #define ADDONCREATOR(AddonClass) \ |
| 666 | extern "C" __declspec(dllexport) void get_addon(void* pAddon) {} \ | 1259 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_Create( \ |
| 667 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_Create(KODI_HANDLE addonInterface, void *unused) \ | 1260 | KODI_HANDLE addonInterface, const char* /*globalApiVersion*/, void* /*unused*/) \ |
| 668 | { \ | 1261 | { \ |
| 669 | kodi::addon::CAddonBase::m_interface = static_cast<AddonGlobalInterface*>(addonInterface); \ | 1262 | kodi::addon::CAddonBase::m_interface = static_cast<AddonGlobalInterface*>(addonInterface); \ |
| 670 | kodi::addon::CAddonBase::m_interface->addonBase = new AddonClass; \ | 1263 | kodi::addon::CAddonBase::m_interface->addonBase = new AddonClass; \ |
| 671 | return kodi::addon::CAddonBase::m_interface->addonBase->Create(); \ | 1264 | return static_cast<kodi::addon::CAddonBase*>(kodi::addon::CAddonBase::m_interface->addonBase) \ |
| 672 | } \ | 1265 | ->Create(); \ |
| 673 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_CreateEx(KODI_HANDLE addonInterface, const char* globalApiVersion, void *unused) \ | ||
| 674 | { \ | ||
| 675 | kodi::addon::CAddonBase::m_strGlobalApiVersion = globalApiVersion; \ | ||
| 676 | return ADDON_Create(addonInterface, unused); \ | ||
| 677 | } \ | 1266 | } \ |
| 678 | extern "C" __declspec(dllexport) void ADDON_Destroy() \ | 1267 | extern "C" __declspec(dllexport) void ADDON_Destroy() \ |
| 679 | { \ | 1268 | { \ |
| @@ -683,7 +1272,8 @@ inline void* GetInterface(const std::string &name, const std::string &version) | |||
| 683 | { \ | 1272 | { \ |
| 684 | return kodi::addon::CAddonBase::ADDONBASE_GetStatus(); \ | 1273 | return kodi::addon::CAddonBase::ADDONBASE_GetStatus(); \ |
| 685 | } \ | 1274 | } \ |
| 686 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue) \ | 1275 | extern "C" __declspec(dllexport) ADDON_STATUS ADDON_SetSetting(const char* settingName, \ |
| 1276 | const void* settingValue) \ | ||
| 687 | { \ | 1277 | { \ |
| 688 | return kodi::addon::CAddonBase::ADDONBASE_SetSetting(settingName, settingValue); \ | 1278 | return kodi::addon::CAddonBase::ADDONBASE_SetSetting(settingName, settingValue); \ |
| 689 | } \ | 1279 | } \ |
| @@ -695,6 +1285,4 @@ inline void* GetInterface(const std::string &name, const std::string &version) | |||
| 695 | { \ | 1285 | { \ |
| 696 | return kodi::addon::GetTypeMinVersion(type); \ | 1286 | return kodi::addon::GetTypeMinVersion(type); \ |
| 697 | } \ | 1287 | } \ |
| 698 | AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr; \ | 1288 | AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr; |
| 699 | std::string kodi::addon::CAddonBase::m_strGlobalApiVersion; | ||
| 700 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h new file mode 100644 index 0000000..0cfefac --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h | |||
| @@ -0,0 +1,618 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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/audio_engine.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace audioengine | ||
| 19 | { | ||
| 20 | |||
| 21 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 22 | // Main page text for audio engine group by Doxygen. | ||
| 23 | //{{{ | ||
| 24 | |||
| 25 | //============================================================================== | ||
| 26 | /// | ||
| 27 | /// @defgroup cpp_kodi_audioengine Interface - kodi::audioengine | ||
| 28 | /// @ingroup cpp | ||
| 29 | /// @brief **Audio engine functions**\n | ||
| 30 | /// This interface contains auxiliary functions and classes which allow an addon | ||
| 31 | /// to play their own individual audio stream in Kodi. | ||
| 32 | /// | ||
| 33 | /// Using @ref cpp_kodi_audioengine_CAEStream "kodi::audioengine::CAEStream", | ||
| 34 | /// a class can be created in this regard, about which the necessary stream data and | ||
| 35 | /// information are given to Kodi. | ||
| 36 | /// | ||
| 37 | /// Via @ref kodi::audioengine::GetCurrentSinkFormat(), the audio formats currently | ||
| 38 | /// processed in Kodi can be called up beforehand in order to adapt your own stream | ||
| 39 | /// to them. | ||
| 40 | /// | ||
| 41 | /// However, the created stream can also differ from this because Kodi changes | ||
| 42 | /// it to suit it. | ||
| 43 | /// | ||
| 44 | /// | ||
| 45 | /// ------------------------------------------------------------------------ | ||
| 46 | /// | ||
| 47 | /// **Example:** | ||
| 48 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 49 | /// | ||
| 50 | /// #include <kodi/AudioEngine.h> | ||
| 51 | /// | ||
| 52 | /// ... | ||
| 53 | /// | ||
| 54 | /// kodi::audioengine::AudioEngineFormat format; | ||
| 55 | /// if (!kodi::audioengine::GetCurrentSinkFormat(format)) | ||
| 56 | /// return false; | ||
| 57 | /// | ||
| 58 | /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP); | ||
| 59 | /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR)); | ||
| 60 | /// | ||
| 61 | /// unsigned int myUsedSampleRate = format.GetSampleRate(); | ||
| 62 | /// | ||
| 63 | /// ... | ||
| 64 | /// | ||
| 65 | /// kodi::audioengine::CAEStream* stream = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_AUTOSTART); | ||
| 66 | /// | ||
| 67 | /// ~~~~~~~~~~~~~ | ||
| 68 | /// | ||
| 69 | /// ------------------------------------------------------------------------ | ||
| 70 | /// | ||
| 71 | /// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be included | ||
| 72 | /// to enjoy it. | ||
| 73 | /// | ||
| 74 | //------------------------------------------------------------------------------ | ||
| 75 | |||
| 76 | //============================================================================== | ||
| 77 | /// | ||
| 78 | /// @defgroup cpp_kodi_audioengine_Defs Definitions, structures and enumerators | ||
| 79 | /// @ingroup cpp_kodi_audioengine | ||
| 80 | /// @brief **Library definition values**\n | ||
| 81 | /// All audio engine functions associated data structures. | ||
| 82 | /// | ||
| 83 | //------------------------------------------------------------------------------ | ||
| 84 | |||
| 85 | //}}} | ||
| 86 | |||
| 87 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 88 | // "C++" related audio engine definitions | ||
| 89 | //{{{ | ||
| 90 | |||
| 91 | //============================================================================== | ||
| 92 | /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineFormat class AudioEngineFormat | ||
| 93 | /// @ingroup cpp_kodi_audioengine_Defs | ||
| 94 | /// @brief **Audio format structure**\n | ||
| 95 | /// The audio format structure that fully defines a stream's audio | ||
| 96 | /// information. | ||
| 97 | /// | ||
| 98 | /// With the help of this format information, Kodi adjusts its processing | ||
| 99 | /// accordingly. | ||
| 100 | /// | ||
| 101 | //@{ | ||
| 102 | class ATTRIBUTE_HIDDEN AudioEngineFormat | ||
| 103 | : public addon::CStructHdl<AudioEngineFormat, AUDIO_ENGINE_FORMAT> | ||
| 104 | { | ||
| 105 | public: | ||
| 106 | /*! \cond PRIVATE */ | ||
| 107 | AudioEngineFormat() | ||
| 108 | { | ||
| 109 | m_cStructure->m_dataFormat = AUDIOENGINE_FMT_INVALID; | ||
| 110 | m_cStructure->m_sampleRate = 0; | ||
| 111 | m_cStructure->m_encodedRate = 0; | ||
| 112 | m_cStructure->m_frames = 0; | ||
| 113 | m_cStructure->m_frameSize = 0; | ||
| 114 | m_cStructure->m_channelCount = 0; | ||
| 115 | |||
| 116 | for (size_t ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch) | ||
| 117 | m_cStructure->m_channels[ch] = AUDIOENGINE_CH_NULL; | ||
| 118 | } | ||
| 119 | AudioEngineFormat(const AudioEngineFormat& channel) : CStructHdl(channel) {} | ||
| 120 | AudioEngineFormat(const AUDIO_ENGINE_FORMAT* channel) : CStructHdl(channel) {} | ||
| 121 | AudioEngineFormat(AUDIO_ENGINE_FORMAT* channel) : CStructHdl(channel) {} | ||
| 122 | /*! \endcond */ | ||
| 123 | |||
| 124 | /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineFormat_Help *Value Help* | ||
| 125 | /// @ingroup cpp_kodi_audioengine_Defs_AudioEngineFormat | ||
| 126 | /// | ||
| 127 | /// <b>The following table contains values that can be set with @ref cpp_kodi_audioengine_Defs_AudioEngineFormat :</b> | ||
| 128 | /// | Name | Type | Set call | Get call | ||
| 129 | /// |------|------|----------|---------- | ||
| 130 | /// | **Data format**, see @ref AudioEngineDataFormat for available types | enum | @ref AudioEngineFormat::SetDataFormat "SetDataFormat" | @ref AudioEngineFormat::GetDataFormat "GetDataFormat" | ||
| 131 | /// | **Sample rate** | unsigned int | @ref AudioEngineFormat::SetSampleRate "SetSampleRate" | @ref AudioEngineFormat::GetSampleRate "GetSampleRate" | ||
| 132 | /// | **Encoded rate** | unsigned int | @ref AudioEngineFormat::SetEncodedRate "SetEncodedRate" | @ref AudioEngineFormat::GetEncodedRate "GetEncodedRate" | ||
| 133 | /// | **Channel layout**, see @ref AudioEngineChannel for available types | std::vector<enum AudioEngineChannel> | @ref AudioEngineFormat::SetChannelLayout "SetChannelLayout" | @ref AudioEngineFormat::GetChannelLayout "GetChannelLayout" | ||
| 134 | /// | **Frames amount** | unsigned int | @ref AudioEngineFormat::SetFramesAmount "SetFramesAmount" | @ref AudioEngineFormat::GetFramesAmount "GetFramesAmount" | ||
| 135 | /// | **Frame size** | unsigned int | @ref AudioEngineFormat::SetFrameSize "SetFrameSize" | @ref AudioEngineFormat::GetFrameSize "GetFrameSize" | ||
| 136 | /// | ||
| 137 | /// Further is @ref AudioEngineFormat::CompareFormat "CompareFormat" included to compare this class with another. | ||
| 138 | /// | ||
| 139 | |||
| 140 | /// @addtogroup cpp_kodi_audioengine_Defs_AudioEngineFormat | ||
| 141 | /// @copydetails cpp_kodi_audioengine_Defs_AudioEngineFormat_Help | ||
| 142 | //@{ | ||
| 143 | |||
| 144 | /// @brief The stream's data format (eg, AUDIOENGINE_FMT_S16LE) | ||
| 145 | void SetDataFormat(enum AudioEngineDataFormat format) { m_cStructure->m_dataFormat = format; } | ||
| 146 | |||
| 147 | /// @brief To get with @ref SetDataFormat changed values. | ||
| 148 | enum AudioEngineDataFormat GetDataFormat() const { return m_cStructure->m_dataFormat; } | ||
| 149 | |||
| 150 | /// @brief The stream's sample rate (eg, 48000) | ||
| 151 | void SetSampleRate(unsigned int rate) { m_cStructure->m_sampleRate = rate; } | ||
| 152 | |||
| 153 | /// @brief To get with @ref SetSampleRate changed values. | ||
| 154 | unsigned int GetSampleRate() const { return m_cStructure->m_sampleRate; } | ||
| 155 | |||
| 156 | /// @brief The encoded streams sample rate if a bitstream, otherwise undefined | ||
| 157 | void SetEncodedRate(unsigned int rate) { m_cStructure->m_encodedRate = rate; } | ||
| 158 | |||
| 159 | /// @brief To get with @ref SetEncodedRate changed values. | ||
| 160 | unsigned int GetEncodedRate() const { return m_cStructure->m_encodedRate; } | ||
| 161 | |||
| 162 | /// @brief The stream's channel layout | ||
| 163 | void SetChannelLayout(const std::vector<enum AudioEngineChannel>& layout) | ||
| 164 | { | ||
| 165 | // Reset first all to empty values to AUDIOENGINE_CH_NULL, in case given list is empty | ||
| 166 | m_cStructure->m_channelCount = 0; | ||
| 167 | for (size_t ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch) | ||
| 168 | m_cStructure->m_channels[ch] = AUDIOENGINE_CH_NULL; | ||
| 169 | |||
| 170 | for (size_t ch = 0; ch < layout.size() && ch < AUDIOENGINE_CH_MAX; ++ch) | ||
| 171 | { | ||
| 172 | m_cStructure->m_channels[ch] = layout[ch]; | ||
| 173 | m_cStructure->m_channelCount++; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | /// @brief To get with @ref SetChannelLayout changed values. | ||
| 178 | std::vector<enum AudioEngineChannel> GetChannelLayout() const | ||
| 179 | { | ||
| 180 | std::vector<enum AudioEngineChannel> channels; | ||
| 181 | for (size_t ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch) | ||
| 182 | { | ||
| 183 | if (m_cStructure->m_channels[ch] == AUDIOENGINE_CH_NULL) | ||
| 184 | break; | ||
| 185 | |||
| 186 | channels.push_back(m_cStructure->m_channels[ch]); | ||
| 187 | } | ||
| 188 | return channels; | ||
| 189 | } | ||
| 190 | |||
| 191 | /// @brief The number of frames per period | ||
| 192 | void SetFramesAmount(unsigned int frames) { m_cStructure->m_frames = frames; } | ||
| 193 | |||
| 194 | /// @brief To get with @ref SetFramesAmount changed values. | ||
| 195 | unsigned int GetFramesAmount() const { return m_cStructure->m_frames; } | ||
| 196 | |||
| 197 | /// @brief The size of one frame in bytes | ||
| 198 | void SetFrameSize(unsigned int frameSize) { m_cStructure->m_frameSize = frameSize; } | ||
| 199 | |||
| 200 | /// @brief To get with @ref SetFrameSize changed values. | ||
| 201 | unsigned int GetFrameSize() const { return m_cStructure->m_frameSize; } | ||
| 202 | |||
| 203 | /// @brief Function to compare the format structure with another | ||
| 204 | bool CompareFormat(const AudioEngineFormat* fmt) | ||
| 205 | { | ||
| 206 | if (!fmt) | ||
| 207 | { | ||
| 208 | return false; | ||
| 209 | } | ||
| 210 | |||
| 211 | if (m_cStructure->m_dataFormat != fmt->m_cStructure->m_dataFormat || | ||
| 212 | m_cStructure->m_sampleRate != fmt->m_cStructure->m_sampleRate || | ||
| 213 | m_cStructure->m_encodedRate != fmt->m_cStructure->m_encodedRate || | ||
| 214 | m_cStructure->m_frames != fmt->m_cStructure->m_frames || | ||
| 215 | m_cStructure->m_frameSize != fmt->m_cStructure->m_frameSize || | ||
| 216 | m_cStructure->m_channelCount != fmt->m_cStructure->m_channelCount) | ||
| 217 | { | ||
| 218 | return false; | ||
| 219 | } | ||
| 220 | |||
| 221 | for (unsigned int ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch) | ||
| 222 | { | ||
| 223 | if (fmt->m_cStructure->m_channels[ch] != m_cStructure->m_channels[ch]) | ||
| 224 | { | ||
| 225 | return false; | ||
| 226 | } | ||
| 227 | } | ||
| 228 | |||
| 229 | return true; | ||
| 230 | } | ||
| 231 | }; | ||
| 232 | //@} | ||
| 233 | //---------------------------------------------------------------------------- | ||
| 234 | |||
| 235 | //}}} | ||
| 236 | |||
| 237 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 238 | // "C++" AudioEngine addon interface | ||
| 239 | //{{{ | ||
| 240 | |||
| 241 | //============================================================================ | ||
| 242 | /// | ||
| 243 | /// @defgroup cpp_kodi_audioengine_CAEStream class CAEStream | ||
| 244 | /// @ingroup cpp_kodi_audioengine | ||
| 245 | /// @brief **Audio Engine Stream Class**\n | ||
| 246 | /// Class that can be created by the addon in order to be able to transfer | ||
| 247 | /// audiostream data processed on the addon to Kodi and output it audibly. | ||
| 248 | /// | ||
| 249 | /// This can create individually several times and performed in different | ||
| 250 | /// processes simultaneously. | ||
| 251 | /// | ||
| 252 | /// It has the header @ref AudioEngine.h "#include <kodi/AudioEngine.h>" be | ||
| 253 | /// included to enjoy it. | ||
| 254 | /// | ||
| 255 | //---------------------------------------------------------------------------- | ||
| 256 | class ATTRIBUTE_HIDDEN CAEStream | ||
| 257 | { | ||
| 258 | public: | ||
| 259 | //========================================================================== | ||
| 260 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 261 | /// @brief Contructs new class to an Kodi IAEStream in the format specified. | ||
| 262 | /// | ||
| 263 | /// @param[in] format The data format the incoming audio will be in | ||
| 264 | /// (e.g. \ref AUDIOENGINE_FMT_S16LE) | ||
| 265 | /// @param[in] options [opt] A bit field of stream options (see: enum \ref AudioEngineStreamOptions) | ||
| 266 | /// | ||
| 267 | /// | ||
| 268 | /// ------------------------------------------------------------------------ | ||
| 269 | /// | ||
| 270 | /// @copydetails cpp_kodi_audioengine_Defs_AudioEngineFormat_Help | ||
| 271 | /// | ||
| 272 | /// ------------------------------------------------------------------------ | ||
| 273 | /// | ||
| 274 | /// **Bit options to pass (on Kodi by <c>IAE::MakeStream</c>)** | ||
| 275 | /// | ||
| 276 | /// | enum AEStreamOptions | Value: | Description: | ||
| 277 | /// |----------------------------:|:------:|:----------------------------------- | ||
| 278 | /// | AUDIO_STREAM_FORCE_RESAMPLE | 1 << 0 | Force resample even if rates match | ||
| 279 | /// | AUDIO_STREAM_PAUSED | 1 << 1 | Create the stream paused | ||
| 280 | /// | AUDIO_STREAM_AUTOSTART | 1 << 2 | Autostart the stream when enough data is buffered | ||
| 281 | /// | ||
| 282 | /// | ||
| 283 | /// ------------------------------------------------------------------------ | ||
| 284 | /// | ||
| 285 | /// **Example:** | ||
| 286 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 287 | /// | ||
| 288 | /// #include <kodi/AudioEngine.h> | ||
| 289 | /// | ||
| 290 | /// ... | ||
| 291 | /// | ||
| 292 | /// kodi::audioengine::AudioEngineFormat format; | ||
| 293 | /// | ||
| 294 | /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP); /* The stream's data format (eg, AUDIOENGINE_FMT_S16LE) */ | ||
| 295 | /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR)); /* The stream's channel layout */ | ||
| 296 | /// format.SetSampleRate(48000); /* The stream's sample rate (eg, 48000) */ | ||
| 297 | /// format.SetFrameSize(sizeof(float)*2); /* The size of one frame in bytes */ | ||
| 298 | /// format.SetFramesAmount(882); /* The number of samples in one frame */ | ||
| 299 | /// | ||
| 300 | /// kodi::audioengine::CAEStream* stream = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_AUTOSTART); | ||
| 301 | /// | ||
| 302 | /// ~~~~~~~~~~~~~ | ||
| 303 | /// | ||
| 304 | CAEStream(AudioEngineFormat& format, unsigned int options = 0) | ||
| 305 | : m_kodiBase(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase), | ||
| 306 | m_cb(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_audioengine) | ||
| 307 | { | ||
| 308 | m_StreamHandle = m_cb->make_stream(m_kodiBase, format, options); | ||
| 309 | if (m_StreamHandle == nullptr) | ||
| 310 | { | ||
| 311 | kodi::Log(ADDON_LOG_FATAL, "CAEStream: make_stream failed!"); | ||
| 312 | } | ||
| 313 | } | ||
| 314 | //-------------------------------------------------------------------------- | ||
| 315 | |||
| 316 | //========================================================================== | ||
| 317 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 318 | /// @brief Class destructor. | ||
| 319 | /// | ||
| 320 | ~CAEStream() | ||
| 321 | { | ||
| 322 | if (m_StreamHandle) | ||
| 323 | { | ||
| 324 | m_cb->free_stream(m_kodiBase, m_StreamHandle); | ||
| 325 | m_StreamHandle = nullptr; | ||
| 326 | } | ||
| 327 | } | ||
| 328 | //-------------------------------------------------------------------------- | ||
| 329 | |||
| 330 | //========================================================================== | ||
| 331 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 332 | /// @brief Returns the amount of space available in the stream. | ||
| 333 | /// | ||
| 334 | /// @return The number of bytes AddData will consume | ||
| 335 | /// | ||
| 336 | unsigned int GetSpace() { return m_cb->aestream_get_space(m_kodiBase, m_StreamHandle); } | ||
| 337 | //-------------------------------------------------------------------------- | ||
| 338 | |||
| 339 | //========================================================================== | ||
| 340 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 341 | /// @brief Add planar or interleaved PCM data to the stream. | ||
| 342 | /// | ||
| 343 | /// @param[in] data array of pointers to the planes | ||
| 344 | /// @param[in] offset to frame in frames | ||
| 345 | /// @param[in] frames number of frames | ||
| 346 | /// @param[in] pts [opt] presentation timestamp, default is 0 | ||
| 347 | /// @param[in] hasDownmix [opt] set true if downmix is present, default is false | ||
| 348 | /// @param[in] centerMixLevel [opt] level to mix left and right to center default is 1.0 | ||
| 349 | /// @return The number of frames consumed | ||
| 350 | /// | ||
| 351 | unsigned int AddData(uint8_t* const* data, | ||
| 352 | unsigned int offset, | ||
| 353 | unsigned int frames, | ||
| 354 | double pts = 0, | ||
| 355 | bool hasDownmix = false, | ||
| 356 | double centerMixLevel = 1.0) | ||
| 357 | { | ||
| 358 | return m_cb->aestream_add_data(m_kodiBase, m_StreamHandle, data, offset, frames, pts, | ||
| 359 | hasDownmix, centerMixLevel); | ||
| 360 | } | ||
| 361 | //-------------------------------------------------------------------------- | ||
| 362 | |||
| 363 | //========================================================================== | ||
| 364 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 365 | /// @brief Returns the time in seconds that it will take for the next added | ||
| 366 | /// packet to be heard from the speakers. | ||
| 367 | /// | ||
| 368 | /// @return seconds | ||
| 369 | /// | ||
| 370 | double GetDelay() { return m_cb->aestream_get_delay(m_kodiBase, m_StreamHandle); } | ||
| 371 | //-------------------------------------------------------------------------- | ||
| 372 | |||
| 373 | //========================================================================== | ||
| 374 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 375 | /// @brief Returns if the stream is buffering. | ||
| 376 | /// | ||
| 377 | /// @return True if the stream is buffering | ||
| 378 | /// | ||
| 379 | bool IsBuffering() { return m_cb->aestream_is_buffering(m_kodiBase, m_StreamHandle); } | ||
| 380 | //-------------------------------------------------------------------------- | ||
| 381 | |||
| 382 | //========================================================================== | ||
| 383 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 384 | /// @brief Returns the time in seconds of the stream's cached audio samples. | ||
| 385 | /// Engine buffers excluded. | ||
| 386 | /// | ||
| 387 | /// @return seconds | ||
| 388 | /// | ||
| 389 | double GetCacheTime() { return m_cb->aestream_get_cache_time(m_kodiBase, m_StreamHandle); } | ||
| 390 | //-------------------------------------------------------------------------- | ||
| 391 | |||
| 392 | //========================================================================== | ||
| 393 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 394 | /// @brief Returns the total time in seconds of the cache. | ||
| 395 | /// | ||
| 396 | /// @return seconds | ||
| 397 | /// | ||
| 398 | double GetCacheTotal() { return m_cb->aestream_get_cache_total(m_kodiBase, m_StreamHandle); } | ||
| 399 | //-------------------------------------------------------------------------- | ||
| 400 | |||
| 401 | //========================================================================== | ||
| 402 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 403 | /// @brief Pauses the stream playback. | ||
| 404 | /// | ||
| 405 | void Pause() { return m_cb->aestream_pause(m_kodiBase, m_StreamHandle); } | ||
| 406 | //-------------------------------------------------------------------------- | ||
| 407 | |||
| 408 | //========================================================================== | ||
| 409 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 410 | /// @brief Resumes the stream after pausing | ||
| 411 | /// | ||
| 412 | void Resume() { return m_cb->aestream_resume(m_kodiBase, m_StreamHandle); } | ||
| 413 | //-------------------------------------------------------------------------- | ||
| 414 | |||
| 415 | //========================================================================== | ||
| 416 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 417 | /// @brief Start draining the stream. | ||
| 418 | /// | ||
| 419 | /// @param[in] wait [opt] Wait until drain is finished if set to true, | ||
| 420 | /// otherwise it returns direct | ||
| 421 | /// | ||
| 422 | /// @note Once called AddData will not consume more data. | ||
| 423 | /// | ||
| 424 | void Drain(bool wait = true) { return m_cb->aestream_drain(m_kodiBase, m_StreamHandle, wait); } | ||
| 425 | //-------------------------------------------------------------------------- | ||
| 426 | |||
| 427 | //========================================================================== | ||
| 428 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 429 | /// @brief Returns true if the is stream draining. | ||
| 430 | /// | ||
| 431 | bool IsDraining() { return m_cb->aestream_is_draining(m_kodiBase, m_StreamHandle); } | ||
| 432 | //-------------------------------------------------------------------------- | ||
| 433 | |||
| 434 | //========================================================================== | ||
| 435 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 436 | /// @brief Returns true if the is stream has finished draining. | ||
| 437 | /// | ||
| 438 | bool IsDrained() { return m_cb->aestream_is_drained(m_kodiBase, m_StreamHandle); } | ||
| 439 | //-------------------------------------------------------------------------- | ||
| 440 | |||
| 441 | //========================================================================== | ||
| 442 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 443 | /// @brief Flush all buffers dropping the audio data. | ||
| 444 | /// | ||
| 445 | void Flush() { return m_cb->aestream_flush(m_kodiBase, m_StreamHandle); } | ||
| 446 | //-------------------------------------------------------------------------- | ||
| 447 | |||
| 448 | //========================================================================== | ||
| 449 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 450 | /// @brief Return the stream's current volume level. | ||
| 451 | /// | ||
| 452 | /// @return The volume level between 0.0 and 1.0 | ||
| 453 | /// | ||
| 454 | float GetVolume() { return m_cb->aestream_get_volume(m_kodiBase, m_StreamHandle); } | ||
| 455 | //-------------------------------------------------------------------------- | ||
| 456 | |||
| 457 | //========================================================================== | ||
| 458 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 459 | /// @brief Set the stream's volume level. | ||
| 460 | /// | ||
| 461 | /// @param[in] volume The new volume level between 0.0 and 1.0 | ||
| 462 | /// | ||
| 463 | void SetVolume(float volume) | ||
| 464 | { | ||
| 465 | return m_cb->aestream_set_volume(m_kodiBase, m_StreamHandle, volume); | ||
| 466 | } | ||
| 467 | //-------------------------------------------------------------------------- | ||
| 468 | |||
| 469 | //========================================================================== | ||
| 470 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 471 | /// @brief Gets the stream's volume amplification in linear units. | ||
| 472 | /// | ||
| 473 | /// @return The volume amplification factor between 1.0 and 1000.0 | ||
| 474 | /// | ||
| 475 | float GetAmplification() { return m_cb->aestream_get_amplification(m_kodiBase, m_StreamHandle); } | ||
| 476 | //-------------------------------------------------------------------------- | ||
| 477 | |||
| 478 | //========================================================================== | ||
| 479 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 480 | /// @brief Sets the stream's volume amplification in linear units. | ||
| 481 | /// | ||
| 482 | /// @param[in] amplify The volume amplification factor between 1.0 and 1000.0 | ||
| 483 | /// | ||
| 484 | void SetAmplification(float amplify) | ||
| 485 | { | ||
| 486 | return m_cb->aestream_set_amplification(m_kodiBase, m_StreamHandle, amplify); | ||
| 487 | } | ||
| 488 | //-------------------------------------------------------------------------- | ||
| 489 | |||
| 490 | //========================================================================== | ||
| 491 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 492 | /// @brief Returns the size of one audio frame in bytes (channelCount * resolution). | ||
| 493 | /// | ||
| 494 | /// @return The size in bytes of one frame | ||
| 495 | /// | ||
| 496 | unsigned int GetFrameSize() const | ||
| 497 | { | ||
| 498 | return m_cb->aestream_get_frame_size(m_kodiBase, m_StreamHandle); | ||
| 499 | } | ||
| 500 | //-------------------------------------------------------------------------- | ||
| 501 | |||
| 502 | //========================================================================== | ||
| 503 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 504 | /// @brief Returns the number of channels the stream is configured to accept. | ||
| 505 | /// | ||
| 506 | /// @return The channel count | ||
| 507 | /// | ||
| 508 | unsigned int GetChannelCount() const | ||
| 509 | { | ||
| 510 | return m_cb->aestream_get_channel_count(m_kodiBase, m_StreamHandle); | ||
| 511 | } | ||
| 512 | //-------------------------------------------------------------------------- | ||
| 513 | |||
| 514 | //========================================================================== | ||
| 515 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 516 | /// @brief Returns the stream's sample rate, if the stream is using a dynamic | ||
| 517 | /// sample rate, this value will NOT reflect any changes made by calls to | ||
| 518 | /// SetResampleRatio(). | ||
| 519 | /// | ||
| 520 | /// @return The stream's sample rate (eg, 48000) | ||
| 521 | /// | ||
| 522 | unsigned int GetSampleRate() const | ||
| 523 | { | ||
| 524 | return m_cb->aestream_get_sample_rate(m_kodiBase, m_StreamHandle); | ||
| 525 | } | ||
| 526 | //-------------------------------------------------------------------------- | ||
| 527 | |||
| 528 | //========================================================================== | ||
| 529 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 530 | /// @brief Return the data format the stream has been configured with. | ||
| 531 | /// | ||
| 532 | /// @return The stream's data format (eg, AUDIOENGINE_FMT_S16LE) | ||
| 533 | /// | ||
| 534 | AudioEngineDataFormat GetDataFormat() const | ||
| 535 | { | ||
| 536 | return m_cb->aestream_get_data_format(m_kodiBase, m_StreamHandle); | ||
| 537 | } | ||
| 538 | //-------------------------------------------------------------------------- | ||
| 539 | |||
| 540 | //========================================================================== | ||
| 541 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 542 | /// @brief Return the resample ratio. | ||
| 543 | /// | ||
| 544 | /// @note This will return an undefined value if the stream is not resampling. | ||
| 545 | /// | ||
| 546 | /// @return the current resample ratio or undefined if the stream is not resampling | ||
| 547 | /// | ||
| 548 | double GetResampleRatio() | ||
| 549 | { | ||
| 550 | return m_cb->aestream_get_resample_ratio(m_kodiBase, m_StreamHandle); | ||
| 551 | } | ||
| 552 | //-------------------------------------------------------------------------- | ||
| 553 | |||
| 554 | //========================================================================== | ||
| 555 | /// @ingroup cpp_kodi_audioengine_CAEStream | ||
| 556 | /// @brief Sets the resample ratio. | ||
| 557 | /// | ||
| 558 | /// @note This function may return false if the stream is not resampling, if | ||
| 559 | /// you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option. | ||
| 560 | /// | ||
| 561 | /// @param[in] ratio the new sample rate ratio, calculated by | ||
| 562 | /// ((double)desiredRate / (double)GetSampleRate()) | ||
| 563 | /// | ||
| 564 | void SetResampleRatio(double ratio) | ||
| 565 | { | ||
| 566 | m_cb->aestream_set_resample_ratio(m_kodiBase, m_StreamHandle, ratio); | ||
| 567 | } | ||
| 568 | //-------------------------------------------------------------------------- | ||
| 569 | |||
| 570 | private: | ||
| 571 | void* m_kodiBase; | ||
| 572 | AddonToKodiFuncTable_kodi_audioengine* m_cb; | ||
| 573 | AEStreamHandle* m_StreamHandle; | ||
| 574 | }; | ||
| 575 | //---------------------------------------------------------------------------- | ||
| 576 | |||
| 577 | //============================================================================ | ||
| 578 | /// @ingroup cpp_kodi_audioengine | ||
| 579 | /// @brief Get the current sink data format. | ||
| 580 | /// | ||
| 581 | /// @param[in] format Current sink data format. For more details see AudioEngineFormat. | ||
| 582 | /// @return Returns true on success, else false. | ||
| 583 | /// | ||
| 584 | /// | ||
| 585 | /// ------------------------------------------------------------------------ | ||
| 586 | /// | ||
| 587 | /// **Example:** | ||
| 588 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 589 | /// | ||
| 590 | /// #include <kodi/AudioEngine.h> | ||
| 591 | /// | ||
| 592 | /// ... | ||
| 593 | /// | ||
| 594 | /// kodi::audioengine::AudioEngineFormat format; | ||
| 595 | /// if (!kodi::audioengine::GetCurrentSinkFormat(format)) | ||
| 596 | /// return false; | ||
| 597 | /// | ||
| 598 | /// std::vector<AudioEngineChannel> layout = format.GetChannelLayout(); | ||
| 599 | /// | ||
| 600 | /// ... | ||
| 601 | /// return true; | ||
| 602 | /// | ||
| 603 | /// ~~~~~~~~~~~~~ | ||
| 604 | /// | ||
| 605 | inline bool ATTRIBUTE_HIDDEN GetCurrentSinkFormat(AudioEngineFormat& format) | ||
| 606 | { | ||
| 607 | using namespace kodi::addon; | ||
| 608 | return CAddonBase::m_interface->toKodi->kodi_audioengine->get_current_sink_format( | ||
| 609 | CAddonBase::m_interface->toKodi->kodiBase, format); | ||
| 610 | } | ||
| 611 | //---------------------------------------------------------------------------- | ||
| 612 | |||
| 613 | //}}} | ||
| 614 | |||
| 615 | } // namespace audioengine | ||
| 616 | } // namespace kodi | ||
| 617 | |||
| 618 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt index 2b98154..de7cb3e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt | |||
| @@ -1,22 +1,11 @@ | |||
| 1 | set(HEADERS AddonBase.h | 1 | set(HEADERS AddonBase.h |
| 2 | AudioEngine.h | ||
| 2 | Filesystem.h | 3 | Filesystem.h |
| 3 | General.h | 4 | General.h |
| 4 | Network.h | 5 | Network.h |
| 5 | StreamCodec.h | 6 | StreamCodec.h |
| 6 | StreamCrypto.h | 7 | StreamCrypto.h |
| 7 | kodi_game_dll.h | 8 | versions.h) |
| 8 | kodi_game_types.h | ||
| 9 | kodi_vfs_types.h | ||
| 10 | libKODI_game.h | ||
| 11 | libKODI_guilib.h | ||
| 12 | libXBMC_addon.h | ||
| 13 | libXBMC_pvr.h | ||
| 14 | versions.h | ||
| 15 | xbmc_addon_dll.h | ||
| 16 | xbmc_addon_types.h | ||
| 17 | xbmc_epg_types.h | ||
| 18 | xbmc_pvr_dll.h | ||
| 19 | xbmc_pvr_types.h) | ||
| 20 | 9 | ||
| 21 | if(CORE_SYSTEM_NAME STREQUAL android) | 10 | if(CORE_SYSTEM_NAME STREQUAL android) |
| 22 | list(APPEND SOURCES platform/android/System.h) | 11 | list(APPEND SOURCES platform/android/System.h) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h index 3df6cec..2054ce6 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Filesystem.h | |||
| @@ -9,1627 +9,2313 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "AddonBase.h" | 11 | #include "AddonBase.h" |
| 12 | #include "c-api/filesystem.h" | ||
| 12 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | #include <cstring> | ||
| 13 | #include <map> | 17 | #include <map> |
| 14 | #include <vector> | 18 | #include <vector> |
| 15 | 19 | ||
| 16 | #if !defined(_WIN32) | 20 | namespace kodi |
| 17 | #include <sys/stat.h> | 21 | { |
| 18 | #if !defined(__stat64) | 22 | namespace vfs |
| 19 | #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) | ||
| 20 | #define __stat64 stat | ||
| 21 | #else | ||
| 22 | #define __stat64 stat64 | ||
| 23 | #endif | ||
| 24 | #endif | ||
| 25 | #endif | ||
| 26 | #ifdef _WIN32 // windows | ||
| 27 | #ifndef _SSIZE_T_DEFINED | ||
| 28 | typedef intptr_t ssize_t; | ||
| 29 | #define _SSIZE_T_DEFINED | ||
| 30 | #endif // !_SSIZE_T_DEFINED | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #ifndef S_ISDIR | ||
| 34 | #define S_ISDIR(mode) ((((mode)) & 0170000) == (0040000)) | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #ifndef S_ISLNK | ||
| 38 | #define S_ISLNK(mode) ((((mode)) & 0170000) == (0120000)) | ||
| 39 | #endif | ||
| 40 | |||
| 41 | /* | ||
| 42 | * For interface between add-on and kodi. | ||
| 43 | * | ||
| 44 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 45 | * are then available for the add-on to call | ||
| 46 | * | ||
| 47 | * All function pointers there are used by the C++ interface functions below. | ||
| 48 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 49 | * | ||
| 50 | * Note: For add-on development itself this is not needed | ||
| 51 | */ | ||
| 52 | extern "C" | ||
| 53 | { | 23 | { |
| 54 | 24 | ||
| 55 | struct VFSProperty | 25 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ |
| 56 | { | 26 | // Main page text for filesystem group by Doxygen. |
| 57 | char* name; | 27 | //{{{ |
| 58 | char* val; | ||
| 59 | }; | ||
| 60 | |||
| 61 | struct VFSDirEntry | ||
| 62 | { | ||
| 63 | char* label; //!< item label | ||
| 64 | char* title; //!< item title | ||
| 65 | char* path; //!< item path | ||
| 66 | unsigned int num_props; //!< Number of properties attached to item | ||
| 67 | VFSProperty* properties; //!< Properties | ||
| 68 | time_t date_time; //!< file creation date & time | ||
| 69 | bool folder; //!< Item is a folder | ||
| 70 | uint64_t size; //!< Size of file represented by item | ||
| 71 | }; | ||
| 72 | |||
| 73 | typedef struct AddonToKodiFuncTable_kodi_filesystem | ||
| 74 | { | ||
| 75 | bool (*can_open_directory)(void* kodiBase, const char* url); | ||
| 76 | bool (*create_directory)(void* kodiBase, const char* path); | ||
| 77 | bool (*remove_directory)(void* kodiBase, const char* path); | ||
| 78 | bool (*directory_exists)(void* kodiBase, const char* path); | ||
| 79 | bool (*get_directory)(void* kodiBase, const char* path, const char* mask, VFSDirEntry** items, unsigned int* num_items); | ||
| 80 | void (*free_directory)(void* kodiBase, VFSDirEntry* items, unsigned int num_items); | ||
| 81 | |||
| 82 | bool (*file_exists)(void* kodiBase, const char *filename, bool useCache); | ||
| 83 | int (*stat_file)(void* kodiBase, const char *filename, struct __stat64* buffer); | ||
| 84 | bool (*delete_file)(void* kodiBase, const char *filename); | ||
| 85 | bool (*rename_file)(void* kodiBase, const char *filename, const char *newFileName); | ||
| 86 | bool (*copy_file)(void* kodiBase, const char *filename, const char *dest); | ||
| 87 | |||
| 88 | char* (*get_file_md5)(void* kodiBase, const char* filename); | ||
| 89 | char* (*get_cache_thumb_name)(void* kodiBase, const char* filename); | ||
| 90 | char* (*make_legal_filename)(void* kodiBase, const char* filename); | ||
| 91 | char* (*make_legal_path)(void* kodiBase, const char* path); | ||
| 92 | char* (*translate_special_protocol)(void* kodiBase, const char *strSource); | ||
| 93 | |||
| 94 | void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags); | ||
| 95 | void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite); | ||
| 96 | ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size); | ||
| 97 | bool (*read_file_string)(void* kodiBase, void* file, char *szLine, int iLineLength); | ||
| 98 | ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size); | ||
| 99 | void (*flush_file)(void* kodiBase, void* file); | ||
| 100 | int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence); | ||
| 101 | int (*truncate_file)(void* kodiBase, void* file, int64_t size); | ||
| 102 | int64_t (*get_file_position)(void* kodiBase, void* file); | ||
| 103 | int64_t (*get_file_length)(void* kodiBase, void* file); | ||
| 104 | double (*get_file_download_speed)(void* kodiBase, void* file); | ||
| 105 | void (*close_file)(void* kodiBase, void* file); | ||
| 106 | int (*get_file_chunk_size)(void* kodiBase, void* file); | ||
| 107 | char** (*get_property_values)(void* kodiBase, void* file, int type, const char *name, int *numValues); | ||
| 108 | |||
| 109 | void* (*curl_create)(void* kodiBase, const char* url); | ||
| 110 | bool (*curl_add_option)(void* kodiBase, void* file, int type, const char* name, const char* value); | ||
| 111 | bool (*curl_open)(void* kodiBase, void* file, unsigned int flags); | ||
| 112 | } AddonToKodiFuncTable_kodi_filesystem; | ||
| 113 | |||
| 114 | } /* extern "C" */ | ||
| 115 | 28 | ||
| 116 | //============================================================================== | 29 | //============================================================================== |
| 117 | /// | 30 | /// |
| 118 | /// \defgroup cpp_kodi_vfs Interface - kodi::vfs | 31 | /// @defgroup cpp_kodi_vfs Interface - kodi::vfs |
| 119 | /// \ingroup cpp | 32 | /// @ingroup cpp |
| 120 | /// @brief **Virtual filesystem functions** | 33 | /// @brief **Virtual filesystem functions**\n |
| 34 | /// Offers classes and functions for access to the Virtual File Server (VFS) | ||
| 35 | /// which you can use to manipulate files and folders. | ||
| 121 | /// | 36 | /// |
| 37 | /// This system allow the use of ["Special Protocol"](https://kodi.wiki/view/Special_protocol) | ||
| 38 | /// where is Kodi's solution to platform dependent directories. Common directory | ||
| 39 | /// names are assigned a <b>`special://[name]`</b> path which is passed around | ||
| 40 | /// inside Kodi and then translated to the platform specific path before the | ||
| 41 | /// operating system sees it. This helps keep most of the platform mess | ||
| 42 | /// centralized in the code.\n | ||
| 43 | /// To become a correct path back can be @ref TranslateSpecialProtocol() used. | ||
| 122 | /// | 44 | /// |
| 123 | /// It has the header \ref Filesystem.h "#include <kodi/Filesystem.h>" be | 45 | /// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be |
| 124 | /// included to enjoy it. | 46 | /// included to enjoy it. |
| 125 | /// | 47 | /// |
| 126 | //------------------------------------------------------------------------------ | 48 | //------------------------------------------------------------------------------ |
| 127 | 49 | ||
| 128 | //============================================================================== | 50 | //============================================================================== |
| 129 | /// \defgroup cpp_kodi_vfs_Defs Definitions, structures and enumerators | 51 | /// @defgroup cpp_kodi_vfs_Defs Definitions, structures and enumerators |
| 130 | /// \ingroup cpp_kodi_vfs | 52 | /// @ingroup cpp_kodi_vfs |
| 131 | /// @brief **Virtual file Server definition values** | 53 | /// @brief **Virtual file Server definition values**\n |
| 54 | /// All to VFS system functions associated data structures. | ||
| 55 | /// | ||
| 132 | //------------------------------------------------------------------------------ | 56 | //------------------------------------------------------------------------------ |
| 133 | 57 | ||
| 134 | //============================================================================== | 58 | //============================================================================== |
| 59 | /// @defgroup cpp_kodi_vfs_Directory 1. Directory functions | ||
| 60 | /// @ingroup cpp_kodi_vfs | ||
| 61 | /// @brief **Globally available directories related functions**\n | ||
| 62 | /// Used to perform typical operations with it. | ||
| 135 | /// | 63 | /// |
| 136 | /// @ingroup cpp_kodi_vfs_Defs | 64 | //------------------------------------------------------------------------------ |
| 137 | /// Flags to define way how file becomes opened with kodi::vfs::CFile::OpenFile() | 65 | |
| 66 | //============================================================================== | ||
| 67 | /// @defgroup cpp_kodi_vfs_File 2. File functions | ||
| 68 | /// @ingroup cpp_kodi_vfs | ||
| 69 | /// @brief **Globally available file related functions**\n | ||
| 70 | /// Used to perform typical operations with it. | ||
| 138 | /// | 71 | /// |
| 139 | /// The values can be used together, e.g. <b>`file.Open("myfile", READ_TRUNCATED | READ_CHUNKED);`</b> | 72 | //------------------------------------------------------------------------------ |
| 73 | |||
| 74 | //============================================================================== | ||
| 75 | /// @defgroup cpp_kodi_vfs_General 3. General functions | ||
| 76 | /// @ingroup cpp_kodi_vfs | ||
| 77 | /// @brief **Other globally available functions**\n | ||
| 78 | /// Used to perform typical operations with it. | ||
| 140 | /// | 79 | /// |
| 141 | typedef enum OpenFileFlags | 80 | //------------------------------------------------------------------------------ |
| 81 | |||
| 82 | //}}} | ||
| 83 | |||
| 84 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 85 | // "C++" related filesystem definitions | ||
| 86 | //{{{ | ||
| 87 | |||
| 88 | //============================================================================== | ||
| 89 | /// @defgroup cpp_kodi_vfs_Defs_FileStatus class FileStatus | ||
| 90 | /// @ingroup cpp_kodi_vfs_Defs | ||
| 91 | /// @brief **File information status**\n | ||
| 92 | /// Used on kodi::vfs::StatFile() to get detailed information about a file. | ||
| 93 | /// | ||
| 94 | //@{ | ||
| 95 | class ATTRIBUTE_HIDDEN FileStatus : public kodi::addon::CStructHdl<FileStatus, STAT_STRUCTURE> | ||
| 142 | { | 96 | { |
| 143 | /// indicate that caller can handle truncated reads, where function returns | 97 | public: |
| 144 | /// before entire buffer has been filled | 98 | /*! \cond PRIVATE */ |
| 145 | READ_TRUNCATED = 0x01, | 99 | FileStatus() { memset(m_cStructure, 0, sizeof(STAT_STRUCTURE)); } |
| 100 | FileStatus(const FileStatus& channel) : CStructHdl(channel) {} | ||
| 101 | FileStatus(const STAT_STRUCTURE* channel) : CStructHdl(channel) {} | ||
| 102 | FileStatus(STAT_STRUCTURE* channel) : CStructHdl(channel) {} | ||
| 103 | /*! \endcond */ | ||
| 104 | |||
| 105 | /// @defgroup cpp_kodi_vfs_Defs_FileStatus_Help *Value Help* | ||
| 106 | /// @ingroup cpp_kodi_vfs_Defs_FileStatus | ||
| 107 | /// ---------------------------------------------------------------------------- | ||
| 108 | /// | ||
| 109 | /// <b>The following table contains values that can be set with @ref cpp_kodi_vfs_Defs_FileStatus :</b> | ||
| 110 | /// | Name | Type | Set call | Get call | ||
| 111 | /// |------|------|----------|---------- | ||
| 112 | /// | **ID of device containing file** | `uint32_t` | @ref FileStatus::SetDeviceId "SetDeviceId" | @ref FileStatus::GetDeviceId "GetDeviceId" | ||
| 113 | /// | **Total size, in bytes** | `uint64_t` | @ref FileStatus::SetSize "SetSize" | @ref FileStatus::GetSize "GetSize" | ||
| 114 | /// | **Time of last access** | `time_t` | @ref FileStatus::SetAccessTime "SetAccessTime" | @ref FileStatus::GetAccessTime "GetAccessTime" | ||
| 115 | /// | **Time of last modification** | `time_t` | @ref FileStatus::SetModificationTime "SetModificationTime" | @ref FileStatus::GetModificationTime "GetModificationTime" | ||
| 116 | /// | **Time of last status change** | `time_t` | @ref FileStatus::SetStatusTime "SetStatusTime" | @ref FileStatus::GetStatusTime "GetStatusTime" | ||
| 117 | /// | **Stat url is a directory** | `bool` | @ref FileStatus::SetIsDirectory "SetIsDirectory" | @ref FileStatus::GetIsDirectory "GetIsDirectory" | ||
| 118 | /// | **Stat url as a symbolic link** | `bool` | @ref FileStatus::SetIsSymLink "SetIsSymLink" | @ref FileStatus::GetIsSymLink "GetIsSymLink" | ||
| 119 | /// | ||
| 120 | |||
| 121 | /// @addtogroup cpp_kodi_vfs_Defs_FileStatus | ||
| 122 | /// @copydetails cpp_kodi_vfs_Defs_FileStatus_Help | ||
| 123 | //@{ | ||
| 146 | 124 | ||
| 147 | /// indicate that that caller support read in the minimum defined chunk size, | 125 | /// @brief Set ID of device containing file. |
| 148 | /// this disables internal cache then | 126 | void SetDeviceId(uint32_t deviceId) { m_cStructure->deviceId = deviceId; } |
| 149 | READ_CHUNKED = 0x02, | ||
| 150 | 127 | ||
| 151 | /// use cache to access this file | 128 | /// @brief Get ID of device containing file. |
| 152 | READ_CACHED = 0x04, | 129 | uint32_t GetDeviceId() const { return m_cStructure->deviceId; } |
| 153 | 130 | ||
| 154 | /// open without caching. regardless to file type | 131 | /// @brief Set total size, in bytes. |
| 155 | READ_NO_CACHE = 0x08, | 132 | void SetSize(uint64_t size) { m_cStructure->size = size; } |
| 133 | |||
| 134 | /// @brief Get total size, in bytes. | ||
| 135 | uint64_t GetSize() const { return m_cStructure->size; } | ||
| 136 | |||
| 137 | /// @brief Set time of last access. | ||
| 138 | void SetAccessTime(time_t accessTime) { m_cStructure->accessTime = accessTime; } | ||
| 139 | |||
| 140 | /// @brief Get time of last access. | ||
| 141 | time_t GetAccessTime() const { return m_cStructure->accessTime; } | ||
| 142 | |||
| 143 | /// @brief Set time of last modification. | ||
| 144 | void SetModificationTime(time_t modificationTime) | ||
| 145 | { | ||
| 146 | m_cStructure->modificationTime = modificationTime; | ||
| 147 | } | ||
| 156 | 148 | ||
| 157 | /// calcuate bitrate for file while reading | 149 | /// @brief Get time of last modification. |
| 158 | READ_BITRATE = 0x10, | 150 | time_t GetModificationTime() const { return m_cStructure->modificationTime; } |
| 159 | 151 | ||
| 160 | /// indicate to the caller we will seek between multiple streams in the file | 152 | /// @brief Set time of last status change. |
| 161 | /// frequently | 153 | void SetStatusTime(time_t statusTime) { m_cStructure->statusTime = statusTime; } |
| 162 | READ_MULTI_STREAM = 0x20, | ||
| 163 | 154 | ||
| 164 | /// indicate to the caller file is audio and/or video (and e.g. may grow) | 155 | /// @brief Get time of last status change. |
| 165 | READ_AUDIO_VIDEO = 0x40, | 156 | time_t GetStatusTime() const { return m_cStructure->statusTime; } |
| 166 | 157 | ||
| 167 | /// indicate that caller will do write operations before reading | 158 | /// @brief Set the stat url is a directory. |
| 168 | READ_AFTER_WRITE = 0x80, | 159 | void SetIsDirectory(bool isDirectory) { m_cStructure->isDirectory = isDirectory; } |
| 169 | 160 | ||
| 170 | /// indicate that caller want to reopen a file if its already open | 161 | /// @brief The stat url is a directory if returns true. |
| 171 | READ_REOPEN = 0x100 | 162 | bool GetIsDirectory() const { return m_cStructure->isDirectory; } |
| 172 | } OpenFileFlags; | 163 | |
| 164 | /// @brief Set stat url as a symbolic link. | ||
| 165 | void SetIsSymLink(bool isSymLink) { m_cStructure->isSymLink = isSymLink; } | ||
| 166 | |||
| 167 | /// @brief Get stat url is a symbolic link. | ||
| 168 | bool GetIsSymLink() const { return m_cStructure->isSymLink; } | ||
| 169 | |||
| 170 | //@} | ||
| 171 | }; | ||
| 172 | //@} | ||
| 173 | //------------------------------------------------------------------------------ | 173 | //------------------------------------------------------------------------------ |
| 174 | 174 | ||
| 175 | //============================================================================== | 175 | //============================================================================== |
| 176 | /// \ingroup cpp_kodi_vfs_Defs | 176 | /// @defgroup cpp_kodi_vfs_Defs_CacheStatus class CacheStatus |
| 177 | /// @brief CURL message types | 177 | /// @ingroup cpp_kodi_vfs_Defs |
| 178 | /// | 178 | /// @brief **Cache information status**\n |
| 179 | /// Used on kodi::vfs::CFile::CURLAddOption() | 179 | /// Used on kodi::vfs::CFile::IoControlGetCacheStatus() to get running cache |
| 180 | /// status of proccessed stream. | ||
| 180 | /// | 181 | /// |
| 181 | typedef enum CURLOptiontype | 182 | //@{ |
| 183 | class ATTRIBUTE_HIDDEN CacheStatus | ||
| 184 | : public kodi::addon::CStructHdl<CacheStatus, VFS_CACHE_STATUS_DATA> | ||
| 182 | { | 185 | { |
| 183 | /// Set a general option | 186 | public: |
| 184 | ADDON_CURL_OPTION_OPTION, | 187 | /*! \cond PRIVATE */ |
| 185 | 188 | CacheStatus() { memset(m_cStructure, 0, sizeof(VFS_CACHE_STATUS_DATA)); } | |
| 186 | /// Set a protocol option | 189 | CacheStatus(const CacheStatus& channel) : CStructHdl(channel) {} |
| 187 | /// | 190 | CacheStatus(const VFS_CACHE_STATUS_DATA* channel) : CStructHdl(channel) {} |
| 188 | /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible: | 191 | CacheStatus(VFS_CACHE_STATUS_DATA* channel) : CStructHdl(channel) {} |
| 189 | /// | 192 | /*! \endcond */ |
| 190 | /// | Option name | Description | 193 | |
| 191 | /// |---------------------------:|:---------------------------------------------------------- | 194 | /// @defgroup cpp_kodi_vfs_Defs_CacheStatus_Help *Value Help* |
| 192 | /// | accept-charset | Set the "accept-charset" header | 195 | /// @ingroup cpp_kodi_vfs_Defs_CacheStatus |
| 193 | /// | acceptencoding or encoding | Set the "accept-encoding" header | 196 | /// ---------------------------------------------------------------------------- |
| 194 | /// | active-remote | Set the "active-remote" header | 197 | /// |
| 195 | /// | auth | Set the authentication method. Possible values: any, anysafe, digest, ntlm | 198 | /// <b>The following table contains values that can be set with @ref cpp_kodi_vfs_Defs_CacheStatus :</b> |
| 196 | /// | connection-timeout | Set the connection timeout in seconds | 199 | /// | Name | Type | Set call | Get call |
| 197 | /// | cookie | Set the "cookie" header | 200 | /// |------|------|----------|---------- |
| 198 | /// | customrequest | Set a custom HTTP request like DELETE | 201 | /// | **Number of bytes cached** | `uint64_t` | @ref CacheStatus::SetForward "SetForward" | @ref CacheStatus::GetForward "GetForward" |
| 199 | /// | noshout | Set to true if kodi detects a stream as shoutcast by mistake. | 202 | /// | **Maximum number of bytes per second** | `unsigned int` | @ref CacheStatus::SetMaxRate "SetMaxRate" | @ref CacheStatus::GetMaxRate "GetMaxRate" |
| 200 | /// | postdata | Set the post body (value needs to be base64 encoded). (Implicitly sets the request to POST) | 203 | /// | **Average read rate from source file** | `unsigned int` | @ref CacheStatus::SetCurrentRate "SetCurrentRate" | @ref CacheStatus::GetCurrentRate "GetCurrentRate" |
| 201 | /// | referer | Set the "referer" header | 204 | /// | **Cache low speed condition detected** | `bool` | @ref CacheStatus::SetLowspeed "SetLowspeed" | @ref CacheStatus::GetLowspeed "GetLowspeed" |
| 202 | /// | user-agent | Set the "user-agent" header | 205 | /// |
| 203 | /// | seekable | Set the stream seekable. 1: enable, 0: disable | 206 | |
| 204 | /// | sslcipherlist | Set list of accepted SSL ciphers. | 207 | /// @addtogroup cpp_kodi_vfs_Defs_CacheStatus |
| 205 | /// | 208 | /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help |
| 206 | ADDON_CURL_OPTION_PROTOCOL, | 209 | //@{ |
| 207 | 210 | ||
| 208 | /// Set User and password | 211 | /// @brief Set number of bytes cached forward of current position. |
| 209 | ADDON_CURL_OPTION_CREDENTIALS, | 212 | void SetForward(uint64_t forward) { m_cStructure->forward = forward; } |
| 210 | 213 | ||
| 211 | /// Add a Header | 214 | /// @brief Get number of bytes cached forward of current position. |
| 212 | ADDON_CURL_OPTION_HEADER | 215 | uint64_t GetForward() { return m_cStructure->forward; } |
| 213 | } CURLOptiontype; | 216 | |
| 217 | /// @brief Set maximum number of bytes per second cache is allowed to fill. | ||
| 218 | void SetMaxRate(unsigned int maxrate) { m_cStructure->maxrate = maxrate; } | ||
| 219 | |||
| 220 | /// @brief Set maximum number of bytes per second cache is allowed to fill. | ||
| 221 | unsigned int GetMaxRate() { return m_cStructure->maxrate; } | ||
| 222 | |||
| 223 | /// @brief Set average read rate from source file since last position change. | ||
| 224 | void SetCurrentRate(unsigned int currate) { m_cStructure->currate = currate; } | ||
| 225 | |||
| 226 | /// @brief Get average read rate from source file since last position change. | ||
| 227 | unsigned int GetCurrentRate() { return m_cStructure->currate; } | ||
| 228 | |||
| 229 | /// @brief Set cache low speed condition detected. | ||
| 230 | void SetLowspeed(bool lowspeed) { m_cStructure->lowspeed = lowspeed; } | ||
| 231 | |||
| 232 | /// @brief Get cache low speed condition detected. | ||
| 233 | bool GetLowspeed() { return m_cStructure->lowspeed; } | ||
| 234 | |||
| 235 | //@} | ||
| 236 | }; | ||
| 237 | //@} | ||
| 214 | //------------------------------------------------------------------------------ | 238 | //------------------------------------------------------------------------------ |
| 215 | 239 | ||
| 216 | //============================================================================== | 240 | //============================================================================== |
| 217 | /// \ingroup cpp_kodi_vfs_Defs | 241 | /// @defgroup cpp_kodi_vfs_Defs_HttpHeader class HttpHeader |
| 218 | /// @brief CURL message types | 242 | /// @ingroup cpp_kodi_vfs_Defs |
| 243 | /// @brief **HTTP header information**\n | ||
| 244 | /// The class used to access HTTP header information and get his information. | ||
| 219 | /// | 245 | /// |
| 220 | /// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues() | 246 | /// Used on @ref kodi::vfs::GetHttpHeader(). |
| 221 | /// | 247 | /// |
| 222 | typedef enum FilePropertyTypes | 248 | /// ---------------------------------------------------------------------------- |
| 223 | { | ||
| 224 | /// Get protocol response line | ||
| 225 | ADDON_FILE_PROPERTY_RESPONSE_PROTOCOL, | ||
| 226 | /// Get a response header | ||
| 227 | ADDON_FILE_PROPERTY_RESPONSE_HEADER, | ||
| 228 | /// Get file content type | ||
| 229 | ADDON_FILE_PROPERTY_CONTENT_TYPE, | ||
| 230 | /// Get file content charset | ||
| 231 | ADDON_FILE_PROPERTY_CONTENT_CHARSET, | ||
| 232 | /// Get file mime type | ||
| 233 | ADDON_FILE_PROPERTY_MIME_TYPE, | ||
| 234 | /// Get file effective URL (last one if redirected) | ||
| 235 | ADDON_FILE_PROPERTY_EFFECTIVE_URL | ||
| 236 | } FilePropertyTypes; | ||
| 237 | //------------------------------------------------------------------------------ | ||
| 238 | |||
| 239 | //============================================================================ | ||
| 240 | /// | ||
| 241 | /// \ingroup cpp_kodi_vfs_Defs | ||
| 242 | /// @brief File information status | ||
| 243 | /// | 249 | /// |
| 244 | /// Used on kodi::vfs::StatFile(), all of these calls return a this stat | 250 | /// @copydetails cpp_kodi_vfs_Defs_HttpHeader_Help |
| 245 | /// structure, which contains the following fields: | ||
| 246 | /// | 251 | /// |
| 247 | struct STAT_STRUCTURE | 252 | ///@{ |
| 253 | class ATTRIBUTE_HIDDEN HttpHeader | ||
| 248 | { | 254 | { |
| 249 | /// ID of device containing file | 255 | public: |
| 250 | uint32_t deviceId; | 256 | //========================================================================== |
| 251 | /// Total size, in bytes | 257 | /// @brief Http header parser class constructor. |
| 252 | uint64_t size; | 258 | /// |
| 253 | #ifdef TARGET_WINDOWS | 259 | HttpHeader() |
| 254 | /// Time of last access | 260 | { |
| 255 | __time64_t accessTime; | 261 | using namespace ::kodi::addon; |
| 256 | /// Time of last modification | ||
| 257 | __time64_t modificationTime; | ||
| 258 | /// Time of last status change | ||
| 259 | __time64_t statusTime; | ||
| 260 | #else | ||
| 261 | /// Time of last access | ||
| 262 | timespec accessTime; | ||
| 263 | /// Time of last modification | ||
| 264 | timespec modificationTime; | ||
| 265 | /// Time of last status change | ||
| 266 | timespec statusTime; | ||
| 267 | #endif | ||
| 268 | /// The stat url is a directory | ||
| 269 | bool isDirectory; | ||
| 270 | /// The stat url is a symbolic link | ||
| 271 | bool isSymLink; | ||
| 272 | }; | ||
| 273 | //------------------------------------------------------------------------------ | ||
| 274 | 262 | ||
| 275 | namespace kodi | 263 | CAddonBase::m_interface->toKodi->kodi_filesystem->http_header_create( |
| 276 | { | 264 | CAddonBase::m_interface->toKodi->kodiBase, &m_handle); |
| 277 | namespace vfs | 265 | } |
| 278 | { | 266 | //-------------------------------------------------------------------------- |
| 279 | 267 | ||
| 280 | //============================================================================ | 268 | //========================================================================== |
| 269 | /// @brief Class destructor. | ||
| 281 | /// | 270 | /// |
| 282 | /// \defgroup cpp_kodi_vfs_CDirEntry class CDirEntry | 271 | ~HttpHeader() |
| 283 | /// \ingroup cpp_kodi_vfs | 272 | { |
| 273 | using namespace ::kodi::addon; | ||
| 274 | |||
| 275 | CAddonBase::m_interface->toKodi->kodi_filesystem->http_header_free( | ||
| 276 | CAddonBase::m_interface->toKodi->kodiBase, &m_handle); | ||
| 277 | } | ||
| 278 | //-------------------------------------------------------------------------- | ||
| 279 | |||
| 280 | /// @defgroup cpp_kodi_vfs_Defs_HttpHeader_Help *Value Help* | ||
| 281 | /// @ingroup cpp_kodi_vfs_Defs_HttpHeader | ||
| 284 | /// | 282 | /// |
| 285 | /// @brief **Virtual file server directory entry** | 283 | /// <b>The following table contains values that can be get with @ref cpp_kodi_vfs_Defs_HttpHeader :</b> |
| 284 | /// | Description | Type | Get call | ||
| 285 | /// |-------------|------|------------ | ||
| 286 | /// | **Get the value associated with this parameter of these HTTP headers** | `std::string` | @ref HttpHeader::GetValue "GetValue" | ||
| 287 | /// | **Get the values as list associated with this parameter of these HTTP headers** | `std::vector<std::string>` | @ref HttpHeader::GetValues "GetValues" | ||
| 288 | /// | **Get the full header string associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetHeader "GetHeader" | ||
| 289 | /// | **Get the mime type associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetMimeType "GetMimeType" | ||
| 290 | /// | **Get the charset associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetCharset "GetCharset" | ||
| 291 | /// | **The protocol line associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetProtoLine "GetProtoLine" | ||
| 286 | /// | 292 | /// |
| 287 | /// This class is used as an entry for files and folders in | 293 | |
| 288 | /// kodi::vfs::GetDirectory(). | 294 | /// @addtogroup cpp_kodi_vfs_Defs_HttpHeader |
| 295 | ///@{ | ||
| 296 | |||
| 297 | //========================================================================== | ||
| 298 | /// @brief Get the value associated with this parameter of these HTTP | ||
| 299 | /// headers. | ||
| 289 | /// | 300 | /// |
| 301 | /// @param[in] param The name of the parameter a value is required for | ||
| 302 | /// @return The value found | ||
| 290 | /// | 303 | /// |
| 291 | /// ------------------------------------------------------------------------ | 304 | std::string GetValue(const std::string& param) const |
| 305 | { | ||
| 306 | using namespace ::kodi::addon; | ||
| 307 | |||
| 308 | if (!m_handle.handle) | ||
| 309 | return ""; | ||
| 310 | |||
| 311 | std::string protoLine; | ||
| 312 | char* string = m_handle.get_value(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle, | ||
| 313 | param.c_str()); | ||
| 314 | if (string != nullptr) | ||
| 315 | { | ||
| 316 | protoLine = string; | ||
| 317 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 318 | string); | ||
| 319 | } | ||
| 320 | return protoLine; | ||
| 321 | } | ||
| 322 | //-------------------------------------------------------------------------- | ||
| 323 | |||
| 324 | //========================================================================== | ||
| 325 | /// @brief Get the values as list associated with this parameter of these | ||
| 326 | /// HTTP headers. | ||
| 292 | /// | 327 | /// |
| 293 | /// **Example:** | 328 | /// @param[in] param The name of the parameter values are required for |
| 294 | /// ~~~~~~~~~~~~~{.cpp} | 329 | /// @return The values found |
| 295 | /// #include <kodi/Filesystem.h> | ||
| 296 | /// | 330 | /// |
| 297 | /// ... | 331 | std::vector<std::string> GetValues(const std::string& param) const |
| 332 | { | ||
| 333 | using namespace kodi::addon; | ||
| 334 | |||
| 335 | if (!m_handle.handle) | ||
| 336 | return std::vector<std::string>(); | ||
| 337 | |||
| 338 | int numValues = 0; | ||
| 339 | char** res(m_handle.get_values(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle, | ||
| 340 | param.c_str(), &numValues)); | ||
| 341 | if (res) | ||
| 342 | { | ||
| 343 | std::vector<std::string> vecReturn; | ||
| 344 | for (int i = 0; i < numValues; ++i) | ||
| 345 | { | ||
| 346 | vecReturn.emplace_back(res[i]); | ||
| 347 | } | ||
| 348 | CAddonBase::m_interface->toKodi->free_string_array(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 349 | res, numValues); | ||
| 350 | return vecReturn; | ||
| 351 | } | ||
| 352 | return std::vector<std::string>(); | ||
| 353 | } | ||
| 354 | //-------------------------------------------------------------------------- | ||
| 355 | |||
| 356 | //========================================================================== | ||
| 357 | /// @brief Get the full header string associated with these HTTP headers. | ||
| 298 | /// | 358 | /// |
| 299 | /// std::vector<kodi::vfs::CDirEntry> items; | 359 | /// @return The header as a string |
| 300 | /// kodi::vfs::GetDirectory("special://temp", "", items); | ||
| 301 | /// | 360 | /// |
| 302 | /// fprintf(stderr, "Directory have %lu entries\n", items.size()); | 361 | std::string GetHeader() const |
| 303 | /// for (unsigned long i = 0; i < items.size(); i++) | 362 | { |
| 304 | /// { | 363 | using namespace ::kodi::addon; |
| 305 | /// char buff[20]; | 364 | |
| 306 | /// time_t now = items[i].DateTime(); | 365 | if (!m_handle.handle) |
| 307 | /// strftime(buff, 20, "%Y-%m-%d %H:%M:%S", gmtime(&now)); | 366 | return ""; |
| 308 | /// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s -- Time: %s\n", | 367 | |
| 309 | /// i+1, | 368 | std::string header; |
| 310 | /// items[i].IsFolder() ? "yes" : "no ", | 369 | char* string = m_handle.get_header(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle); |
| 311 | /// items[i].Label().c_str(), | 370 | if (string != nullptr) |
| 312 | /// items[i].Path().c_str(), | 371 | { |
| 313 | /// buff); | 372 | header = string; |
| 314 | /// } | 373 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, |
| 315 | /// ~~~~~~~~~~~~~ | 374 | string); |
| 375 | } | ||
| 376 | return header; | ||
| 377 | } | ||
| 378 | //-------------------------------------------------------------------------- | ||
| 379 | |||
| 380 | //========================================================================== | ||
| 381 | /// @brief Get the mime type associated with these HTTP headers. | ||
| 316 | /// | 382 | /// |
| 317 | /// It has the header \ref Filesystem.h "#include <kodi/Filesystem.h>" be included | 383 | /// @return The mime type |
| 318 | /// to enjoy it. | ||
| 319 | /// | 384 | /// |
| 320 | //@{ | 385 | std::string GetMimeType() const |
| 321 | class CDirEntry | 386 | { |
| 387 | using namespace ::kodi::addon; | ||
| 388 | |||
| 389 | if (!m_handle.handle) | ||
| 390 | return ""; | ||
| 391 | |||
| 392 | std::string protoLine; | ||
| 393 | char* string = | ||
| 394 | m_handle.get_mime_type(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle); | ||
| 395 | if (string != nullptr) | ||
| 396 | { | ||
| 397 | protoLine = string; | ||
| 398 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 399 | string); | ||
| 400 | } | ||
| 401 | return protoLine; | ||
| 402 | } | ||
| 403 | //-------------------------------------------------------------------------- | ||
| 404 | |||
| 405 | //========================================================================== | ||
| 406 | /// @brief Get the charset associated with these HTTP headers. | ||
| 407 | /// | ||
| 408 | /// @return The charset | ||
| 409 | /// | ||
| 410 | std::string GetCharset() const | ||
| 411 | { | ||
| 412 | using namespace ::kodi::addon; | ||
| 413 | |||
| 414 | if (!m_handle.handle) | ||
| 415 | return ""; | ||
| 416 | |||
| 417 | std::string protoLine; | ||
| 418 | char* string = m_handle.get_charset(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle); | ||
| 419 | if (string != nullptr) | ||
| 420 | { | ||
| 421 | protoLine = string; | ||
| 422 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 423 | string); | ||
| 424 | } | ||
| 425 | return protoLine; | ||
| 426 | } | ||
| 427 | //-------------------------------------------------------------------------- | ||
| 428 | |||
| 429 | //========================================================================== | ||
| 430 | /// @brief The protocol line associated with these HTTP headers. | ||
| 431 | /// | ||
| 432 | /// @return The protocol line | ||
| 433 | /// | ||
| 434 | std::string GetProtoLine() const | ||
| 322 | { | 435 | { |
| 323 | public: | 436 | using namespace ::kodi::addon; |
| 324 | //============================================================================ | 437 | |
| 325 | /// | 438 | if (!m_handle.handle) |
| 326 | /// @ingroup cpp_kodi_vfs_CDirEntry | 439 | return ""; |
| 327 | /// @brief Constructor for VFS directory entry | 440 | |
| 328 | /// | 441 | std::string protoLine; |
| 329 | /// @param[in] label [opt] Name to use for entry | 442 | char* string = |
| 330 | /// @param[in] path [opt] Used path of the entry | 443 | m_handle.get_proto_line(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle); |
| 331 | /// @param[in] folder [opt] If set entry used as folder | 444 | if (string != nullptr) |
| 332 | /// @param[in] size [opt] If used as file, his size defined there | ||
| 333 | /// | ||
| 334 | CDirEntry(const std::string& label = "", | ||
| 335 | const std::string& path = "", | ||
| 336 | bool folder = false, | ||
| 337 | int64_t size = -1) : | ||
| 338 | m_label(label), | ||
| 339 | m_path(path), | ||
| 340 | m_folder(folder), | ||
| 341 | m_size(size) | ||
| 342 | { | 445 | { |
| 446 | protoLine = string; | ||
| 447 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 448 | string); | ||
| 343 | } | 449 | } |
| 344 | //---------------------------------------------------------------------------- | 450 | return protoLine; |
| 345 | 451 | } | |
| 346 | //============================================================================ | 452 | //-------------------------------------------------------------------------- |
| 347 | // @note Not for addon development itself needed, thats why below is | 453 | |
| 348 | // disabled for doxygen! | 454 | ///@} |
| 349 | // | 455 | |
| 350 | // @ingroup cpp_kodi_vfs_CDirEntry | 456 | KODI_HTTP_HEADER m_handle; |
| 351 | // @brief Constructor to create own copy | 457 | }; |
| 352 | // | 458 | ///@} |
| 353 | // @param[in] dirEntry pointer to own class type | 459 | //---------------------------------------------------------------------------- |
| 354 | // | 460 | |
| 355 | explicit CDirEntry(const VFSDirEntry& dirEntry) : | 461 | //============================================================================== |
| 356 | m_label(dirEntry.label ? dirEntry.label : ""), | 462 | /// @defgroup cpp_kodi_vfs_CDirEntry class CDirEntry |
| 463 | /// @ingroup cpp_kodi_vfs_Defs | ||
| 464 | /// | ||
| 465 | /// @brief **Virtual file server directory entry**\n | ||
| 466 | /// This class is used as an entry for files and folders in | ||
| 467 | /// kodi::vfs::GetDirectory(). | ||
| 468 | /// | ||
| 469 | /// | ||
| 470 | /// ------------------------------------------------------------------------ | ||
| 471 | /// | ||
| 472 | /// **Example:** | ||
| 473 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 474 | /// #include <kodi/Filesystem.h> | ||
| 475 | /// | ||
| 476 | /// ... | ||
| 477 | /// | ||
| 478 | /// std::vector<kodi::vfs::CDirEntry> items; | ||
| 479 | /// kodi::vfs::GetDirectory("special://temp", "", items); | ||
| 480 | /// | ||
| 481 | /// fprintf(stderr, "Directory have %lu entries\n", items.size()); | ||
| 482 | /// for (unsigned long i = 0; i < items.size(); i++) | ||
| 483 | /// { | ||
| 484 | /// char buff[20]; | ||
| 485 | /// time_t now = items[i].DateTime(); | ||
| 486 | /// strftime(buff, 20, "%Y-%m-%d %H:%M:%S", gmtime(&now)); | ||
| 487 | /// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s -- Time: %s\n", | ||
| 488 | /// i+1, | ||
| 489 | /// items[i].IsFolder() ? "yes" : "no ", | ||
| 490 | /// items[i].Label().c_str(), | ||
| 491 | /// items[i].Path().c_str(), | ||
| 492 | /// buff); | ||
| 493 | /// } | ||
| 494 | /// ~~~~~~~~~~~~~ | ||
| 495 | /// | ||
| 496 | /// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be included | ||
| 497 | /// to enjoy it. | ||
| 498 | /// | ||
| 499 | //@{ | ||
| 500 | class ATTRIBUTE_HIDDEN CDirEntry | ||
| 501 | { | ||
| 502 | public: | ||
| 503 | //============================================================================ | ||
| 504 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 505 | /// @brief Constructor for VFS directory entry | ||
| 506 | /// | ||
| 507 | /// @param[in] label [opt] Name to use for entry | ||
| 508 | /// @param[in] path [opt] Used path of the entry | ||
| 509 | /// @param[in] folder [opt] If set entry used as folder | ||
| 510 | /// @param[in] size [opt] If used as file, his size defined there | ||
| 511 | /// @param[in] dateTime [opt] Date time of the entry | ||
| 512 | /// | ||
| 513 | CDirEntry(const std::string& label = "", | ||
| 514 | const std::string& path = "", | ||
| 515 | bool folder = false, | ||
| 516 | int64_t size = -1, | ||
| 517 | time_t dateTime = 0) | ||
| 518 | : m_label(label), m_path(path), m_folder(folder), m_size(size), m_dateTime(dateTime) | ||
| 519 | { | ||
| 520 | } | ||
| 521 | //---------------------------------------------------------------------------- | ||
| 522 | |||
| 523 | //============================================================================ | ||
| 524 | // @note Not for addon development itself needed, thats why below is | ||
| 525 | // disabled for doxygen! | ||
| 526 | // | ||
| 527 | // @ingroup cpp_kodi_vfs_CDirEntry | ||
| 528 | // @brief Constructor to create own copy | ||
| 529 | // | ||
| 530 | // @param[in] dirEntry pointer to own class type | ||
| 531 | // | ||
| 532 | explicit CDirEntry(const VFSDirEntry& dirEntry) | ||
| 533 | : m_label(dirEntry.label ? dirEntry.label : ""), | ||
| 357 | m_path(dirEntry.path ? dirEntry.path : ""), | 534 | m_path(dirEntry.path ? dirEntry.path : ""), |
| 358 | m_folder(dirEntry.folder), | 535 | m_folder(dirEntry.folder), |
| 359 | m_size(dirEntry.size), | 536 | m_size(dirEntry.size), |
| 360 | m_dateTime(dirEntry.date_time) | 537 | m_dateTime(dirEntry.date_time) |
| 361 | { | 538 | { |
| 362 | } | 539 | } |
| 363 | //---------------------------------------------------------------------------- | ||
| 364 | |||
| 365 | //============================================================================ | ||
| 366 | /// | ||
| 367 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 368 | /// @brief Get the directory entry name | ||
| 369 | /// | ||
| 370 | /// @return Name of the entry | ||
| 371 | /// | ||
| 372 | const std::string& Label(void) const { return m_label; } | ||
| 373 | //---------------------------------------------------------------------------- | ||
| 374 | |||
| 375 | //============================================================================ | ||
| 376 | /// | ||
| 377 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 378 | /// @brief Get the optional title of entry | ||
| 379 | /// | ||
| 380 | /// @return Title of the entry, if exists | ||
| 381 | /// | ||
| 382 | const std::string& Title(void) const { return m_title; } | ||
| 383 | //---------------------------------------------------------------------------- | ||
| 384 | |||
| 385 | //============================================================================ | ||
| 386 | /// | ||
| 387 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 388 | /// @brief Get the path of the entry | ||
| 389 | /// | ||
| 390 | /// @return File system path of the entry | ||
| 391 | /// | ||
| 392 | const std::string& Path(void) const { return m_path; } | ||
| 393 | //---------------------------------------------------------------------------- | ||
| 394 | |||
| 395 | //============================================================================ | ||
| 396 | /// | ||
| 397 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 398 | /// @brief Used to check entry is folder | ||
| 399 | /// | ||
| 400 | /// @return true if entry is a folder | ||
| 401 | /// | ||
| 402 | bool IsFolder(void) const { return m_folder; } | ||
| 403 | //---------------------------------------------------------------------------- | ||
| 404 | |||
| 405 | //============================================================================ | ||
| 406 | /// | ||
| 407 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 408 | /// @brief If file, the size of the file | ||
| 409 | /// | ||
| 410 | /// @return Defined file size | ||
| 411 | /// | ||
| 412 | int64_t Size(void) const { return m_size; } | ||
| 413 | //---------------------------------------------------------------------------- | ||
| 414 | |||
| 415 | //============================================================================ | ||
| 416 | /// | ||
| 417 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 418 | /// @brief Get file time and date for a new entry | ||
| 419 | /// | ||
| 420 | /// @return The with time_t defined date and time of file | ||
| 421 | /// | ||
| 422 | time_t DateTime() { return m_dateTime; } | ||
| 423 | //---------------------------------------------------------------------------- | ||
| 424 | |||
| 425 | //============================================================================ | ||
| 426 | /// | ||
| 427 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 428 | /// @brief Set the label name | ||
| 429 | /// | ||
| 430 | /// @param[in] label name of entry | ||
| 431 | /// | ||
| 432 | void SetLabel(const std::string& label) { m_label = label; } | ||
| 433 | //---------------------------------------------------------------------------- | ||
| 434 | |||
| 435 | //============================================================================ | ||
| 436 | /// | ||
| 437 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 438 | /// @brief Set the title name | ||
| 439 | /// | ||
| 440 | /// @param[in] title title name of entry | ||
| 441 | /// | ||
| 442 | void SetTitle(const std::string& title) { m_title = title; } | ||
| 443 | //---------------------------------------------------------------------------- | ||
| 444 | |||
| 445 | //============================================================================ | ||
| 446 | /// | ||
| 447 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 448 | /// @brief Set the path of the entry | ||
| 449 | /// | ||
| 450 | /// @param[in] path path of entry | ||
| 451 | /// | ||
| 452 | void SetPath(const std::string& path) { m_path = path; } | ||
| 453 | //---------------------------------------------------------------------------- | ||
| 454 | |||
| 455 | //============================================================================ | ||
| 456 | /// | ||
| 457 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 458 | /// @brief Set the entry defined as folder | ||
| 459 | /// | ||
| 460 | /// @param[in] folder If true becomes entry defined as folder | ||
| 461 | /// | ||
| 462 | void SetFolder(bool folder) { m_folder = folder; } | ||
| 463 | //---------------------------------------------------------------------------- | ||
| 464 | |||
| 465 | //============================================================================ | ||
| 466 | /// | ||
| 467 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 468 | /// @brief Set a file size for a new entry | ||
| 469 | /// | ||
| 470 | /// @param[in] size Size to set for dir entry | ||
| 471 | /// | ||
| 472 | void SetSize(int64_t size) { m_size = size; } | ||
| 473 | //---------------------------------------------------------------------------- | ||
| 474 | |||
| 475 | //============================================================================ | ||
| 476 | /// | ||
| 477 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 478 | /// @brief Set file time and date for a new entry | ||
| 479 | /// | ||
| 480 | /// @param[in] dateTime The with time_t defined date and time of file | ||
| 481 | /// | ||
| 482 | void SetDateTime(time_t dateTime) { m_dateTime = dateTime; } | ||
| 483 | //---------------------------------------------------------------------------- | ||
| 484 | |||
| 485 | //============================================================================ | ||
| 486 | /// | ||
| 487 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 488 | /// @brief Add a by string defined property entry to directory entry | ||
| 489 | /// | ||
| 490 | /// @note A property can be used to add some special information about a file | ||
| 491 | /// or directory entry, this can be used on other places to do the right work | ||
| 492 | /// of them. | ||
| 493 | /// | ||
| 494 | /// @param[in] id Identification name of property | ||
| 495 | /// @param[in] value The property value to add by given id | ||
| 496 | /// | ||
| 497 | void AddProperty(const std::string& id, const std::string& value) { m_properties[id] = value; } | ||
| 498 | //---------------------------------------------------------------------------- | ||
| 499 | |||
| 500 | //============================================================================ | ||
| 501 | /// | ||
| 502 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 503 | /// @brief Clear all present properties | ||
| 504 | /// | ||
| 505 | void ClearProperties() { m_properties.clear(); } | ||
| 506 | //---------------------------------------------------------------------------- | ||
| 507 | |||
| 508 | //============================================================================ | ||
| 509 | /// | ||
| 510 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 511 | /// @brief Get the present properties list on directory entry | ||
| 512 | /// | ||
| 513 | /// @return map with all present properties | ||
| 514 | /// | ||
| 515 | const std::map<std::string, std::string>& GetProperties() const { return m_properties; } | ||
| 516 | //---------------------------------------------------------------------------- | ||
| 517 | |||
| 518 | private: | ||
| 519 | std::string m_label; | ||
| 520 | std::string m_title; | ||
| 521 | std::string m_path; | ||
| 522 | std::map<std::string, std::string> m_properties; | ||
| 523 | bool m_folder; | ||
| 524 | int64_t m_size; | ||
| 525 | time_t m_dateTime; | ||
| 526 | }; | ||
| 527 | //@} | ||
| 528 | //---------------------------------------------------------------------------- | 540 | //---------------------------------------------------------------------------- |
| 529 | 541 | ||
| 530 | //============================================================================ | 542 | /// @defgroup cpp_kodi_vfs_CDirEntry_Help *Value Help* |
| 543 | /// @ingroup cpp_kodi_vfs_CDirEntry | ||
| 544 | /// -------------------------------------------------------------------------- | ||
| 531 | /// | 545 | /// |
| 532 | /// @ingroup cpp_kodi_vfs | 546 | /// <b>The following table contains values that can be set with @ref cpp_kodi_vfs_CDirEntry :</b> |
| 533 | /// @brief Make a directory | 547 | /// | Name | Type | Set call | Get call | Clear call | |
| 548 | /// |------|------|----------|----------|------------| | ||
| 549 | /// | **Directory entry name** | `std::string` | @ref CDirEntry::SetLabel "SetLabel" | @ref CDirEntry::Label "Label" | | | ||
| 550 | /// | **Title of entry** | `std::string` | @ref CDirEntry::SetTitle "SetTitle" | @ref CDirEntry::Title "Title" | | | ||
| 551 | /// | **Path of the entry** | `std::string` | @ref CDirEntry::SetPath "SetPath" | @ref CDirEntry::Path "Path" | | | ||
| 552 | /// | **Entry is folder** | `bool` | @ref CDirEntry::SetFolder "SetFolder" | @ref CDirEntry::IsFolder "IsFolder" | | | ||
| 553 | /// | **The size of the file** | `int64_t` | @ref CDirEntry::SetSize "SetSize" | @ref CDirEntry::Size "Size" | | | ||
| 554 | /// | **File time and date** | `time_t` | @ref CDirEntry::SetDateTime "SetDateTime" | @ref CDirEntry::DateTime "DateTime" | | | ||
| 555 | /// | **Property entries** | `std::string, std::string` | @ref CDirEntry::AddProperty "AddProperty" | @ref CDirEntry::GetProperties "GetProperties" | @ref CDirEntry::ClearProperties "ClearProperties" | ||
| 534 | /// | 556 | /// |
| 535 | /// The kodi::vfs::CreateDirectory() function shall create a | 557 | |
| 536 | /// new directory with name path. | 558 | /// @addtogroup cpp_kodi_vfs_CDirEntry |
| 537 | /// | 559 | /// @copydetails cpp_kodi_vfs_CDirEntry_Help |
| 538 | /// The newly created directory shall be an empty directory. | 560 | //@{ |
| 539 | /// | 561 | |
| 540 | /// @param[in] path Path to the directory. | 562 | //============================================================================ |
| 541 | /// @return Upon successful completion, CreateDirectory() shall return true. | 563 | /// @brief Get the directory entry name. |
| 542 | /// Otherwise false shall be returned, no directory shall be created. | ||
| 543 | /// | 564 | /// |
| 565 | /// @return Name of the entry | ||
| 544 | /// | 566 | /// |
| 545 | /// ------------------------------------------------------------------------- | 567 | const std::string& Label(void) const { return m_label; } |
| 568 | //---------------------------------------------------------------------------- | ||
| 569 | |||
| 570 | //============================================================================ | ||
| 571 | /// @brief Get the optional title of entry. | ||
| 546 | /// | 572 | /// |
| 547 | /// **Example:** | 573 | /// @return Title of the entry, if exists |
| 548 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 549 | /// #include <kodi/Filesystem.h> | ||
| 550 | /// ... | ||
| 551 | /// std::string directory = "C:\\my_dir"; | ||
| 552 | /// bool ret = kodi::vfs::CreateDirectory(directory); | ||
| 553 | /// fprintf(stderr, "Directory '%s' successfull created: %s\n", directory.c_str(), ret ? "yes" : "no"); | ||
| 554 | /// ... | ||
| 555 | /// ~~~~~~~~~~~~~ | ||
| 556 | /// | 574 | /// |
| 557 | inline bool CreateDirectory(const std::string& path) | 575 | const std::string& Title(void) const { return m_title; } |
| 558 | { | ||
| 559 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 560 | } | ||
| 561 | //---------------------------------------------------------------------------- | 576 | //---------------------------------------------------------------------------- |
| 562 | 577 | ||
| 563 | //============================================================================ | 578 | //============================================================================ |
| 579 | /// @brief Get the path of the entry. | ||
| 564 | /// | 580 | /// |
| 565 | /// @ingroup cpp_kodi_vfs | 581 | /// @return File system path of the entry |
| 566 | /// @brief Verifying the Existence of a Directory | ||
| 567 | /// | 582 | /// |
| 568 | /// The kodi::vfs::DirectoryExists() method determines whether | 583 | const std::string& Path(void) const { return m_path; } |
| 569 | /// a specified folder exists. | 584 | //---------------------------------------------------------------------------- |
| 570 | /// | 585 | |
| 571 | /// @param[in] path Path to the directory. | 586 | //============================================================================ |
| 572 | /// @return True when it exists, false otherwise. | 587 | /// @brief Used to check entry is folder. |
| 573 | /// | 588 | /// |
| 589 | /// @return true if entry is a folder | ||
| 574 | /// | 590 | /// |
| 575 | /// ------------------------------------------------------------------------- | 591 | bool IsFolder(void) const { return m_folder; } |
| 592 | //---------------------------------------------------------------------------- | ||
| 593 | |||
| 594 | //============================================================================ | ||
| 595 | /// @brief If file, the size of the file. | ||
| 576 | /// | 596 | /// |
| 577 | /// **Example:** | 597 | /// @return Defined file size |
| 578 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 579 | /// #include <kodi/Filesystem.h> | ||
| 580 | /// ... | ||
| 581 | /// std::string directory = "C:\\my_dir"; | ||
| 582 | /// bool ret = kodi::vfs::DirectoryExists(directory); | ||
| 583 | /// fprintf(stderr, "Directory '%s' present: %s\n", directory.c_str(), ret ? "yes" : "no"); | ||
| 584 | /// ... | ||
| 585 | /// ~~~~~~~~~~~~~ | ||
| 586 | /// | 598 | /// |
| 587 | inline bool DirectoryExists(const std::string& path) | 599 | int64_t Size(void) const { return m_size; } |
| 588 | { | ||
| 589 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 590 | } | ||
| 591 | //---------------------------------------------------------------------------- | 600 | //---------------------------------------------------------------------------- |
| 592 | 601 | ||
| 593 | //============================================================================ | 602 | //============================================================================ |
| 603 | /// @brief Get file time and date for a new entry. | ||
| 594 | /// | 604 | /// |
| 595 | /// @ingroup cpp_kodi_vfs | 605 | /// @return The with time_t defined date and time of file |
| 596 | /// @brief Removes a directory. | ||
| 597 | /// | 606 | /// |
| 598 | /// The kodi::vfs::RemoveDirectory() function shall remove a | 607 | time_t DateTime() { return m_dateTime; } |
| 599 | /// directory whose name is given by path. | 608 | //---------------------------------------------------------------------------- |
| 600 | /// | 609 | |
| 601 | /// @param[in] path Path to the directory. | 610 | //============================================================================ |
| 602 | /// @return Upon successful completion, the function RemoveDirectory() shall | 611 | /// @brief Set the label name. |
| 603 | /// return true. Otherwise, false shall be returned, and errno set | ||
| 604 | /// to indicate the error. If false is returned, the named directory | ||
| 605 | /// shall not be changed. | ||
| 606 | /// | 612 | /// |
| 613 | /// @param[in] label name of entry | ||
| 607 | /// | 614 | /// |
| 608 | /// ------------------------------------------------------------------------- | 615 | void SetLabel(const std::string& label) { m_label = label; } |
| 616 | //---------------------------------------------------------------------------- | ||
| 617 | |||
| 618 | //============================================================================ | ||
| 619 | /// @brief Set the title name. | ||
| 609 | /// | 620 | /// |
| 610 | /// **Example:** | 621 | /// @param[in] title title name of entry |
| 611 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 612 | /// #include <kodi/Filesystem.h> | ||
| 613 | /// ... | ||
| 614 | /// bool ret = kodi::vfs::RemoveDirectory("C:\\my_dir"); | ||
| 615 | /// ... | ||
| 616 | /// ~~~~~~~~~~~~~ | ||
| 617 | /// | 622 | /// |
| 618 | inline bool RemoveDirectory(const std::string& path) | 623 | void SetTitle(const std::string& title) { m_title = title; } |
| 619 | { | ||
| 620 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 621 | } | ||
| 622 | //---------------------------------------------------------------------------- | 624 | //---------------------------------------------------------------------------- |
| 623 | 625 | ||
| 624 | //============================================================================ | 626 | //============================================================================ |
| 627 | /// @brief Set the path of the entry. | ||
| 625 | /// | 628 | /// |
| 626 | /// @ingroup cpp_kodi_vfs | 629 | /// @param[in] path path of entry |
| 627 | /// @brief Lists a directory. | ||
| 628 | /// | 630 | /// |
| 629 | /// Return the list of files and directories which have been found in the | 631 | void SetPath(const std::string& path) { m_path = path; } |
| 630 | /// specified directory and which respect the given constraint. | 632 | //---------------------------------------------------------------------------- |
| 631 | /// | 633 | |
| 632 | /// It can handle the normal OS dependent paths and also the special virtual | 634 | //============================================================================ |
| 633 | /// filesystem from Kodi what starts with \b special://. | 635 | /// @brief Set the entry defined as folder. |
| 634 | /// | 636 | /// |
| 635 | /// @param[in] path The path in which the files and directories are located. | 637 | /// @param[in] folder If true becomes entry defined as folder |
| 636 | /// @param[in] mask Mask to filter out requested files, e.g. "*.avi|*.mpg" to | ||
| 637 | /// files with this ending. | ||
| 638 | /// @param[out] items The returned list directory entries. | ||
| 639 | /// @return True if listing was successful, false otherwise. | ||
| 640 | /// | 638 | /// |
| 639 | void SetFolder(bool folder) { m_folder = folder; } | ||
| 640 | //---------------------------------------------------------------------------- | ||
| 641 | |||
| 642 | //============================================================================ | ||
| 643 | /// @brief Set a file size for a new entry. | ||
| 641 | /// | 644 | /// |
| 642 | /// ------------------------------------------------------------------------- | 645 | /// @param[in] size Size to set for dir entry |
| 643 | /// | 646 | /// |
| 644 | /// **Example:** | 647 | void SetSize(int64_t size) { m_size = size; } |
| 645 | /// ~~~~~~~~~~~~~{.cpp} | 648 | //---------------------------------------------------------------------------- |
| 646 | /// #include <kodi/Filesystem.h> | 649 | |
| 650 | //============================================================================ | ||
| 651 | /// @brief Set file time and date for a new entry. | ||
| 647 | /// | 652 | /// |
| 648 | /// std::vector<kodi::vfs::CDirEntry> items; | 653 | /// @param[in] dateTime The with time_t defined date and time of file |
| 649 | /// kodi::vfs::GetDirectory("special://temp", "", items); | ||
| 650 | /// | 654 | /// |
| 651 | /// fprintf(stderr, "Directory have %lu entries\n", items.size()); | 655 | void SetDateTime(time_t dateTime) { m_dateTime = dateTime; } |
| 652 | /// for (unsigned long i = 0; i < items.size(); i++) | ||
| 653 | /// { | ||
| 654 | /// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s\n", | ||
| 655 | /// i+1, | ||
| 656 | /// items[i].IsFolder() ? "yes" : "no ", | ||
| 657 | /// items[i].Label().c_str(), | ||
| 658 | /// items[i].Path().c_str()); | ||
| 659 | /// } | ||
| 660 | /// ~~~~~~~~~~~~~ | ||
| 661 | inline bool GetDirectory(const std::string& path, const std::string& mask, std::vector<CDirEntry>& items) | ||
| 662 | { | ||
| 663 | VFSDirEntry* dir_list = nullptr; | ||
| 664 | unsigned int num_items = 0; | ||
| 665 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list, &num_items)) | ||
| 666 | { | ||
| 667 | if (dir_list) | ||
| 668 | { | ||
| 669 | for (unsigned int i = 0; i < num_items; ++i) | ||
| 670 | items.push_back(CDirEntry(dir_list[i])); | ||
| 671 | |||
| 672 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->free_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, dir_list, num_items); | ||
| 673 | } | ||
| 674 | |||
| 675 | return true; | ||
| 676 | } | ||
| 677 | return false; | ||
| 678 | } | ||
| 679 | //---------------------------------------------------------------------------- | 656 | //---------------------------------------------------------------------------- |
| 680 | 657 | ||
| 681 | //============================================================================ | 658 | //============================================================================ |
| 659 | /// @brief Add a by string defined property entry to directory entry. | ||
| 682 | /// | 660 | /// |
| 683 | /// @ingroup cpp_kodi_vfs | 661 | /// @note A property can be used to add some special information about a file |
| 684 | /// @brief Retrieve MD5sum of a file | 662 | /// or directory entry, this can be used on other places to do the right work |
| 663 | /// of them. | ||
| 685 | /// | 664 | /// |
| 686 | /// @param[in] path path to the file to MD5sum | 665 | /// @param[in] id Identification name of property |
| 687 | /// @return md5 sum of the file | 666 | /// @param[in] value The property value to add by given id |
| 688 | /// | 667 | /// |
| 668 | void AddProperty(const std::string& id, const std::string& value) { m_properties[id] = value; } | ||
| 669 | //---------------------------------------------------------------------------- | ||
| 670 | |||
| 671 | //============================================================================ | ||
| 672 | /// @brief Clear all present properties. | ||
| 689 | /// | 673 | /// |
| 690 | /// ------------------------------------------------------------------------- | 674 | void ClearProperties() { m_properties.clear(); } |
| 675 | //---------------------------------------------------------------------------- | ||
| 676 | |||
| 677 | //============================================================================ | ||
| 678 | /// @brief Get the present properties list on directory entry. | ||
| 691 | /// | 679 | /// |
| 692 | /// **Example:** | 680 | /// @return map with all present properties |
| 693 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 694 | /// #include <kodi/Filesystem.h> | ||
| 695 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 696 | /// ... | ||
| 697 | /// std::string md5; | ||
| 698 | /// std::string filename; | ||
| 699 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4", | ||
| 700 | /// "Test File selection to get MD5", | ||
| 701 | /// filename)) | ||
| 702 | /// { | ||
| 703 | /// md5 = kodi::vfs::GetFileMD5(filename); | ||
| 704 | /// fprintf(stderr, "MD5 of file '%s' is %s\n", md5.c_str(), filename.c_str()); | ||
| 705 | /// } | ||
| 706 | /// ~~~~~~~~~~~~~ | ||
| 707 | /// | 681 | /// |
| 708 | inline std::string GetFileMD5(const std::string& path) | 682 | const std::map<std::string, std::string>& GetProperties() const { return m_properties; } |
| 683 | //---------------------------------------------------------------------------- | ||
| 684 | |||
| 685 | //@} | ||
| 686 | |||
| 687 | private: | ||
| 688 | std::string m_label; | ||
| 689 | std::string m_title; | ||
| 690 | std::string m_path; | ||
| 691 | std::map<std::string, std::string> m_properties; | ||
| 692 | bool m_folder; | ||
| 693 | int64_t m_size; | ||
| 694 | time_t m_dateTime; | ||
| 695 | }; | ||
| 696 | //@} | ||
| 697 | //------------------------------------------------------------------------------ | ||
| 698 | |||
| 699 | //}}} | ||
| 700 | |||
| 701 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 702 | // "C++" Directory related functions | ||
| 703 | //{{{ | ||
| 704 | |||
| 705 | //============================================================================== | ||
| 706 | /// @ingroup cpp_kodi_vfs_Directory | ||
| 707 | /// @brief Make a directory. | ||
| 708 | /// | ||
| 709 | /// The kodi::vfs::CreateDirectory() function shall create a | ||
| 710 | /// new directory with name path. | ||
| 711 | /// | ||
| 712 | /// The newly created directory shall be an empty directory. | ||
| 713 | /// | ||
| 714 | /// @param[in] path Path to the directory. | ||
| 715 | /// @return Upon successful completion, CreateDirectory() shall return true. | ||
| 716 | /// Otherwise false shall be returned, no directory shall be created. | ||
| 717 | /// | ||
| 718 | /// | ||
| 719 | /// ------------------------------------------------------------------------- | ||
| 720 | /// | ||
| 721 | /// **Example:** | ||
| 722 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 723 | /// #include <kodi/Filesystem.h> | ||
| 724 | /// ... | ||
| 725 | /// std::string directory = "C:\\my_dir"; | ||
| 726 | /// bool ret = kodi::vfs::CreateDirectory(directory); | ||
| 727 | /// fprintf(stderr, "Directory '%s' successfull created: %s\n", directory.c_str(), ret ? "yes" : "no"); | ||
| 728 | /// ... | ||
| 729 | /// ~~~~~~~~~~~~~ | ||
| 730 | /// | ||
| 731 | inline bool ATTRIBUTE_HIDDEN CreateDirectory(const std::string& path) | ||
| 732 | { | ||
| 733 | using namespace kodi::addon; | ||
| 734 | |||
| 735 | return CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory( | ||
| 736 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 737 | } | ||
| 738 | //------------------------------------------------------------------------------ | ||
| 739 | |||
| 740 | //============================================================================== | ||
| 741 | /// @ingroup cpp_kodi_vfs_Directory | ||
| 742 | /// @brief Verifying the Existence of a Directory. | ||
| 743 | /// | ||
| 744 | /// The kodi::vfs::DirectoryExists() method determines whether | ||
| 745 | /// a specified folder exists. | ||
| 746 | /// | ||
| 747 | /// @param[in] path Path to the directory. | ||
| 748 | /// @return True when it exists, false otherwise. | ||
| 749 | /// | ||
| 750 | /// | ||
| 751 | /// ------------------------------------------------------------------------- | ||
| 752 | /// | ||
| 753 | /// **Example:** | ||
| 754 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 755 | /// #include <kodi/Filesystem.h> | ||
| 756 | /// ... | ||
| 757 | /// std::string directory = "C:\\my_dir"; | ||
| 758 | /// bool ret = kodi::vfs::DirectoryExists(directory); | ||
| 759 | /// fprintf(stderr, "Directory '%s' present: %s\n", directory.c_str(), ret ? "yes" : "no"); | ||
| 760 | /// ... | ||
| 761 | /// ~~~~~~~~~~~~~ | ||
| 762 | /// | ||
| 763 | inline bool ATTRIBUTE_HIDDEN DirectoryExists(const std::string& path) | ||
| 764 | { | ||
| 765 | using namespace kodi::addon; | ||
| 766 | |||
| 767 | return CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists( | ||
| 768 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 769 | } | ||
| 770 | //------------------------------------------------------------------------------ | ||
| 771 | |||
| 772 | //============================================================================== | ||
| 773 | /// @ingroup cpp_kodi_vfs_Directory | ||
| 774 | /// @brief Removes a directory. | ||
| 775 | /// | ||
| 776 | /// The kodi::vfs::RemoveDirectory() function shall remove a | ||
| 777 | /// directory whose name is given by path. | ||
| 778 | /// | ||
| 779 | /// @param[in] path Path to the directory. | ||
| 780 | /// @return Upon successful completion, the function RemoveDirectory() shall | ||
| 781 | /// return true. Otherwise, false shall be returned, and errno set | ||
| 782 | /// to indicate the error. If false is returned, the named directory | ||
| 783 | /// shall not be changed. | ||
| 784 | /// | ||
| 785 | /// | ||
| 786 | /// ------------------------------------------------------------------------- | ||
| 787 | /// | ||
| 788 | /// **Example:** | ||
| 789 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 790 | /// #include <kodi/Filesystem.h> | ||
| 791 | /// ... | ||
| 792 | /// bool ret = kodi::vfs::RemoveDirectory("C:\\my_dir"); | ||
| 793 | /// ... | ||
| 794 | /// ~~~~~~~~~~~~~ | ||
| 795 | /// | ||
| 796 | inline bool ATTRIBUTE_HIDDEN RemoveDirectory(const std::string& path) | ||
| 797 | { | ||
| 798 | using namespace kodi::addon; | ||
| 799 | |||
| 800 | return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory( | ||
| 801 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 802 | } | ||
| 803 | //------------------------------------------------------------------------------ | ||
| 804 | |||
| 805 | //============================================================================== | ||
| 806 | /// @ingroup cpp_kodi_vfs_Directory | ||
| 807 | /// @brief Lists a directory. | ||
| 808 | /// | ||
| 809 | /// Return the list of files and directories which have been found in the | ||
| 810 | /// specified directory and which respect the given constraint. | ||
| 811 | /// | ||
| 812 | /// It can handle the normal OS dependent paths and also the special virtual | ||
| 813 | /// filesystem from Kodi what starts with \b special://. | ||
| 814 | /// | ||
| 815 | /// @param[in] path The path in which the files and directories are located. | ||
| 816 | /// @param[in] mask Mask to filter out requested files, e.g. "*.avi|*.mpg" to | ||
| 817 | /// files with this ending. | ||
| 818 | /// @param[out] items The returned list directory entries. | ||
| 819 | /// @return True if listing was successful, false otherwise. | ||
| 820 | /// | ||
| 821 | /// | ||
| 822 | /// ------------------------------------------------------------------------- | ||
| 823 | /// | ||
| 824 | /// **Example:** | ||
| 825 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 826 | /// #include <kodi/Filesystem.h> | ||
| 827 | /// | ||
| 828 | /// std::vector<kodi::vfs::CDirEntry> items; | ||
| 829 | /// kodi::vfs::GetDirectory("special://temp", "", items); | ||
| 830 | /// | ||
| 831 | /// fprintf(stderr, "Directory have %lu entries\n", items.size()); | ||
| 832 | /// for (unsigned long i = 0; i < items.size(); i++) | ||
| 833 | /// { | ||
| 834 | /// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s\n", | ||
| 835 | /// i+1, | ||
| 836 | /// items[i].IsFolder() ? "yes" : "no ", | ||
| 837 | /// items[i].Label().c_str(), | ||
| 838 | /// items[i].Path().c_str()); | ||
| 839 | /// } | ||
| 840 | /// ~~~~~~~~~~~~~ | ||
| 841 | inline bool ATTRIBUTE_HIDDEN GetDirectory(const std::string& path, | ||
| 842 | const std::string& mask, | ||
| 843 | std::vector<kodi::vfs::CDirEntry>& items) | ||
| 844 | { | ||
| 845 | using namespace kodi::addon; | ||
| 846 | |||
| 847 | VFSDirEntry* dir_list = nullptr; | ||
| 848 | unsigned int num_items = 0; | ||
| 849 | if (CAddonBase::m_interface->toKodi->kodi_filesystem->get_directory( | ||
| 850 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list, | ||
| 851 | &num_items)) | ||
| 709 | { | 852 | { |
| 710 | std::string strReturn; | 853 | if (dir_list) |
| 711 | char* strMd5 = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_md5(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 712 | if (strMd5 != nullptr) | ||
| 713 | { | 854 | { |
| 714 | if (std::strlen(strMd5)) | 855 | for (unsigned int i = 0; i < num_items; ++i) |
| 715 | strReturn = strMd5; | 856 | items.emplace_back(dir_list[i]); |
| 716 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strMd5); | 857 | |
| 858 | CAddonBase::m_interface->toKodi->kodi_filesystem->free_directory( | ||
| 859 | CAddonBase::m_interface->toKodi->kodiBase, dir_list, num_items); | ||
| 717 | } | 860 | } |
| 718 | return strReturn; | 861 | |
| 862 | return true; | ||
| 719 | } | 863 | } |
| 864 | return false; | ||
| 865 | } | ||
| 866 | //------------------------------------------------------------------------------ | ||
| 867 | |||
| 868 | //}}} | ||
| 869 | |||
| 870 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 871 | // "C++" File related functions | ||
| 872 | //{{{ | ||
| 873 | |||
| 874 | //============================================================================== | ||
| 875 | /// @ingroup cpp_kodi_vfs_File | ||
| 876 | /// @brief Check if a file exists. | ||
| 877 | /// | ||
| 878 | /// @param[in] filename The filename to check. | ||
| 879 | /// @param[in] usecache Check in file cache. | ||
| 880 | /// @return true if the file exists false otherwise. | ||
| 881 | /// | ||
| 882 | /// | ||
| 883 | /// ------------------------------------------------------------------------- | ||
| 884 | /// | ||
| 885 | /// **Example:** | ||
| 886 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 887 | /// #include <kodi/Filesystem.h> | ||
| 888 | /// ... | ||
| 889 | /// bool exists = kodi::vfs::FileExists("special://temp/kodi.log"); | ||
| 890 | /// fprintf(stderr, "Log file should be always present, is it present? %s\n", exists ? "yes" : "no"); | ||
| 891 | /// ~~~~~~~~~~~~~ | ||
| 892 | /// | ||
| 893 | inline bool ATTRIBUTE_HIDDEN FileExists(const std::string& filename, bool usecache = false) | ||
| 894 | { | ||
| 895 | using namespace kodi::addon; | ||
| 896 | |||
| 897 | return CAddonBase::m_interface->toKodi->kodi_filesystem->file_exists( | ||
| 898 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache); | ||
| 899 | } | ||
| 900 | //------------------------------------------------------------------------------ | ||
| 901 | |||
| 902 | //============================================================================== | ||
| 903 | /// @ingroup cpp_kodi_vfs_File | ||
| 904 | /// @brief Get file status. | ||
| 905 | /// | ||
| 906 | /// These function return information about a file. Execute (search) | ||
| 907 | /// permission is required on all of the directories in path that | ||
| 908 | /// lead to the file. | ||
| 909 | /// | ||
| 910 | /// The call return a stat structure, which contains the on | ||
| 911 | /// @ref cpp_kodi_vfs_Defs_FileStatus defined values. | ||
| 912 | /// | ||
| 913 | /// @warning Not all of the OS file systems implement all of the time fields. | ||
| 914 | /// | ||
| 915 | /// @param[in] filename The filename to read the status from. | ||
| 916 | /// @param[out] buffer The file status is written into this buffer. | ||
| 917 | /// @return On success, trur is returned. On error, false is returned | ||
| 918 | /// | ||
| 919 | /// | ||
| 920 | /// @copydetails cpp_kodi_vfs_Defs_FileStatus_Help | ||
| 921 | /// | ||
| 922 | /// ------------------------------------------------------------------------- | ||
| 923 | /// | ||
| 924 | /// **Example:** | ||
| 925 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 926 | /// #include <kodi/Filesystem.h> | ||
| 927 | /// ... | ||
| 928 | /// kodi::vfs::FileStatus statFile; | ||
| 929 | /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", statFile); | ||
| 930 | /// fprintf(stderr, "deviceId (ID of device containing file) = %u\n" | ||
| 931 | /// "size (total size, in bytes) = %lu\n" | ||
| 932 | /// "accessTime (time of last access) = %lu\n" | ||
| 933 | /// "modificationTime (time of last modification) = %lu\n" | ||
| 934 | /// "statusTime (time of last status change) = %lu\n" | ||
| 935 | /// "isDirectory (The stat url is a directory) = %s\n" | ||
| 936 | /// "isSymLink (The stat url is a symbolic link) = %s\n" | ||
| 937 | /// "Return value = %i\n", | ||
| 938 | /// statFile.GetDeviceId(), | ||
| 939 | /// statFile.GetSize(), | ||
| 940 | /// statFile.GetAccessTime(), | ||
| 941 | /// statFile.GetModificationTime(), | ||
| 942 | /// statFile.GetStatusTime(), | ||
| 943 | /// statFile.GetIsDirectory() ? "true" : "false", | ||
| 944 | /// statFile.GetIsSymLink() ? "true" : "false", | ||
| 945 | /// ret); | ||
| 946 | /// ~~~~~~~~~~~~~ | ||
| 947 | /// | ||
| 948 | inline bool ATTRIBUTE_HIDDEN StatFile(const std::string& filename, kodi::vfs::FileStatus& buffer) | ||
| 949 | { | ||
| 950 | using namespace kodi::addon; | ||
| 951 | |||
| 952 | return CAddonBase::m_interface->toKodi->kodi_filesystem->stat_file( | ||
| 953 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), buffer); | ||
| 954 | } | ||
| 955 | //------------------------------------------------------------------------------ | ||
| 956 | |||
| 957 | //============================================================================== | ||
| 958 | /// @ingroup cpp_kodi_vfs_File | ||
| 959 | /// @brief Deletes a file. | ||
| 960 | /// | ||
| 961 | /// @param[in] filename The filename to delete. | ||
| 962 | /// @return The file was successfully deleted. | ||
| 963 | /// | ||
| 964 | /// | ||
| 965 | /// ------------------------------------------------------------------------- | ||
| 966 | /// | ||
| 967 | /// **Example:** | ||
| 968 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 969 | /// #include <kodi/Filesystem.h> | ||
| 970 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 971 | /// #include <kodi/gui/DialogOK.h> | ||
| 972 | /// ... | ||
| 973 | /// std::string filename; | ||
| 974 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "", | ||
| 975 | /// "Test File selection and delete of them!", | ||
| 976 | /// filename)) | ||
| 977 | /// { | ||
| 978 | /// bool successed = kodi::vfs::DeleteFile(filename); | ||
| 979 | /// if (!successed) | ||
| 980 | /// kodi::gui::DialogOK::ShowAndGetInput("Error", "Delete of File", filename, "failed!"); | ||
| 981 | /// else | ||
| 982 | /// kodi::gui::DialogOK::ShowAndGetInput("Information", "Delete of File", filename, "successfull done."); | ||
| 983 | /// } | ||
| 984 | /// ~~~~~~~~~~~~~ | ||
| 985 | /// | ||
| 986 | inline bool ATTRIBUTE_HIDDEN DeleteFile(const std::string& filename) | ||
| 987 | { | ||
| 988 | using namespace kodi::addon; | ||
| 989 | |||
| 990 | return CAddonBase::m_interface->toKodi->kodi_filesystem->delete_file( | ||
| 991 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | ||
| 992 | } | ||
| 993 | //------------------------------------------------------------------------------ | ||
| 994 | |||
| 995 | //============================================================================== | ||
| 996 | /// @ingroup cpp_kodi_vfs_File | ||
| 997 | /// @brief Rename a file name. | ||
| 998 | /// | ||
| 999 | /// @param[in] filename The filename to copy. | ||
| 1000 | /// @param[in] newFileName The new filename | ||
| 1001 | /// @return true if successfully renamed | ||
| 1002 | /// | ||
| 1003 | /// | ||
| 1004 | inline bool ATTRIBUTE_HIDDEN RenameFile(const std::string& filename, const std::string& newFileName) | ||
| 1005 | { | ||
| 1006 | using namespace kodi::addon; | ||
| 1007 | |||
| 1008 | return CAddonBase::m_interface->toKodi->kodi_filesystem->rename_file( | ||
| 1009 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str()); | ||
| 1010 | } | ||
| 1011 | //------------------------------------------------------------------------------ | ||
| 1012 | |||
| 1013 | //============================================================================== | ||
| 1014 | /// @ingroup cpp_kodi_vfs_File | ||
| 1015 | /// @brief Copy a file from source to destination. | ||
| 1016 | /// | ||
| 1017 | /// @param[in] filename The filename to copy. | ||
| 1018 | /// @param[in] destination The destination to copy file to | ||
| 1019 | /// @return true if successfully copied | ||
| 1020 | /// | ||
| 1021 | /// | ||
| 1022 | inline bool ATTRIBUTE_HIDDEN CopyFile(const std::string& filename, const std::string& destination) | ||
| 1023 | { | ||
| 1024 | using namespace kodi::addon; | ||
| 1025 | |||
| 1026 | return CAddonBase::m_interface->toKodi->kodi_filesystem->copy_file( | ||
| 1027 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str()); | ||
| 1028 | } | ||
| 1029 | //------------------------------------------------------------------------------ | ||
| 1030 | |||
| 1031 | //}}} | ||
| 1032 | |||
| 1033 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 1034 | // "C++" General filesystem functions | ||
| 1035 | //{{{ | ||
| 1036 | |||
| 1037 | //============================================================================== | ||
| 1038 | /// @ingroup cpp_kodi_vfs_General | ||
| 1039 | /// @brief Retrieve MD5sum of a file. | ||
| 1040 | /// | ||
| 1041 | /// @param[in] path Path to the file to MD5sum | ||
| 1042 | /// @return MD5 sum of the file | ||
| 1043 | /// | ||
| 1044 | /// | ||
| 1045 | /// ------------------------------------------------------------------------- | ||
| 1046 | /// | ||
| 1047 | /// **Example:** | ||
| 1048 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1049 | /// #include <kodi/Filesystem.h> | ||
| 1050 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 1051 | /// ... | ||
| 1052 | /// std::string md5; | ||
| 1053 | /// std::string filename; | ||
| 1054 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4", | ||
| 1055 | /// "Test File selection to get MD5", | ||
| 1056 | /// filename)) | ||
| 1057 | /// { | ||
| 1058 | /// md5 = kodi::vfs::GetFileMD5(filename); | ||
| 1059 | /// fprintf(stderr, "MD5 of file '%s' is %s\n", md5.c_str(), filename.c_str()); | ||
| 1060 | /// } | ||
| 1061 | /// ~~~~~~~~~~~~~ | ||
| 1062 | /// | ||
| 1063 | inline std::string ATTRIBUTE_HIDDEN GetFileMD5(const std::string& path) | ||
| 1064 | { | ||
| 1065 | using namespace kodi::addon; | ||
| 1066 | |||
| 1067 | std::string strReturn; | ||
| 1068 | char* strMd5 = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_md5( | ||
| 1069 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 1070 | if (strMd5 != nullptr) | ||
| 1071 | { | ||
| 1072 | if (std::strlen(strMd5)) | ||
| 1073 | strReturn = strMd5; | ||
| 1074 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMd5); | ||
| 1075 | } | ||
| 1076 | return strReturn; | ||
| 1077 | } | ||
| 1078 | //------------------------------------------------------------------------------ | ||
| 1079 | |||
| 1080 | //============================================================================== | ||
| 1081 | /// @ingroup cpp_kodi_vfs_General | ||
| 1082 | /// @brief Returns a thumb cache filename. | ||
| 1083 | /// | ||
| 1084 | /// @param[in] filename Path to file | ||
| 1085 | /// @return Cache filename | ||
| 1086 | /// | ||
| 1087 | /// | ||
| 1088 | /// ------------------------------------------------------------------------ | ||
| 1089 | /// | ||
| 1090 | /// **Example:** | ||
| 1091 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1092 | /// #include <kodi/Filesystem.h> | ||
| 1093 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 1094 | /// ... | ||
| 1095 | /// std::string thumb; | ||
| 1096 | /// std::string filename; | ||
| 1097 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4", | ||
| 1098 | /// "Test File selection to get Thumnail", | ||
| 1099 | /// filename)) | ||
| 1100 | /// { | ||
| 1101 | /// thumb = kodi::vfs::GetCacheThumbName(filename); | ||
| 1102 | /// fprintf(stderr, "Thumb name of file '%s' is %s\n", thumb.c_str(), filename.c_str()); | ||
| 1103 | /// } | ||
| 1104 | /// ~~~~~~~~~~~~~ | ||
| 1105 | /// | ||
| 1106 | inline std::string ATTRIBUTE_HIDDEN GetCacheThumbName(const std::string& filename) | ||
| 1107 | { | ||
| 1108 | using namespace kodi::addon; | ||
| 1109 | |||
| 1110 | std::string strReturn; | ||
| 1111 | char* strThumbName = CAddonBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name( | ||
| 1112 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | ||
| 1113 | if (strThumbName != nullptr) | ||
| 1114 | { | ||
| 1115 | if (std::strlen(strThumbName)) | ||
| 1116 | strReturn = strThumbName; | ||
| 1117 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1118 | strThumbName); | ||
| 1119 | } | ||
| 1120 | return strReturn; | ||
| 1121 | } | ||
| 1122 | //------------------------------------------------------------------------------ | ||
| 1123 | |||
| 1124 | //============================================================================== | ||
| 1125 | /// @ingroup cpp_kodi_vfs_General | ||
| 1126 | /// @brief Make filename valid. | ||
| 1127 | /// | ||
| 1128 | /// Function to replace not valid characters with '_'. It can be also | ||
| 1129 | /// compared with original before in a own loop until it is equal | ||
| 1130 | /// (no invalid characters). | ||
| 1131 | /// | ||
| 1132 | /// @param[in] filename Filename to check and fix | ||
| 1133 | /// @return The legal filename | ||
| 1134 | /// | ||
| 1135 | /// | ||
| 1136 | /// ------------------------------------------------------------------------ | ||
| 1137 | /// | ||
| 1138 | /// **Example:** | ||
| 1139 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1140 | /// #include <kodi/Filesystem.h> | ||
| 1141 | /// ... | ||
| 1142 | /// std::string fileName = "///\\jk???lj????.mpg"; | ||
| 1143 | /// std::string legalName = kodi::vfs::MakeLegalFileName(fileName); | ||
| 1144 | /// fprintf(stderr, "Legal name of '%s' is '%s'\n", fileName.c_str(), legalName.c_str()); | ||
| 1145 | /// | ||
| 1146 | /// /* Returns as legal: 'jk___lj____.mpg' */ | ||
| 1147 | /// ~~~~~~~~~~~~~ | ||
| 1148 | /// | ||
| 1149 | inline std::string ATTRIBUTE_HIDDEN MakeLegalFileName(const std::string& filename) | ||
| 1150 | { | ||
| 1151 | using namespace kodi::addon; | ||
| 1152 | |||
| 1153 | std::string strReturn; | ||
| 1154 | char* strLegalFileName = CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_filename( | ||
| 1155 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | ||
| 1156 | if (strLegalFileName != nullptr) | ||
| 1157 | { | ||
| 1158 | if (std::strlen(strLegalFileName)) | ||
| 1159 | strReturn = strLegalFileName; | ||
| 1160 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1161 | strLegalFileName); | ||
| 1162 | } | ||
| 1163 | return strReturn; | ||
| 1164 | } | ||
| 1165 | //------------------------------------------------------------------------------ | ||
| 1166 | |||
| 1167 | //============================================================================== | ||
| 1168 | /// @ingroup cpp_kodi_vfs_General | ||
| 1169 | /// @brief Make directory name valid. | ||
| 1170 | /// | ||
| 1171 | /// Function to replace not valid characters with '_'. It can be also | ||
| 1172 | /// compared with original before in a own loop until it is equal | ||
| 1173 | /// (no invalid characters). | ||
| 1174 | /// | ||
| 1175 | /// @param[in] path Directory name to check and fix | ||
| 1176 | /// @return The legal directory name | ||
| 1177 | /// | ||
| 1178 | /// | ||
| 1179 | /// ------------------------------------------------------------------------ | ||
| 1180 | /// | ||
| 1181 | /// **Example:** | ||
| 1182 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1183 | /// #include <kodi/Filesystem.h> | ||
| 1184 | /// ... | ||
| 1185 | /// std::string path = "///\\jk???lj????\\hgjkg"; | ||
| 1186 | /// std::string legalPath = kodi::vfs::MakeLegalPath(path); | ||
| 1187 | /// fprintf(stderr, "Legal name of '%s' is '%s'\n", path.c_str(), legalPath.c_str()); | ||
| 1188 | /// | ||
| 1189 | /// /* Returns as legal: '/jk___lj____/hgjkg' */ | ||
| 1190 | /// ~~~~~~~~~~~~~ | ||
| 1191 | /// | ||
| 1192 | inline std::string ATTRIBUTE_HIDDEN MakeLegalPath(const std::string& path) | ||
| 1193 | { | ||
| 1194 | using namespace kodi::addon; | ||
| 1195 | |||
| 1196 | std::string strReturn; | ||
| 1197 | char* strLegalPath = CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_path( | ||
| 1198 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 1199 | if (strLegalPath != nullptr) | ||
| 1200 | { | ||
| 1201 | if (std::strlen(strLegalPath)) | ||
| 1202 | strReturn = strLegalPath; | ||
| 1203 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1204 | strLegalPath); | ||
| 1205 | } | ||
| 1206 | return strReturn; | ||
| 1207 | } | ||
| 1208 | //------------------------------------------------------------------------------ | ||
| 1209 | |||
| 1210 | //============================================================================== | ||
| 1211 | /// @ingroup cpp_kodi_vfs_General | ||
| 1212 | /// @brief Returns the translated path. | ||
| 1213 | /// | ||
| 1214 | /// @param[in] source String or unicode - Path to format | ||
| 1215 | /// @return A human-readable string suitable for logging | ||
| 1216 | /// | ||
| 1217 | /// @note Only useful if you are coding for both Linux and Windows. e.g. | ||
| 1218 | /// Converts 'special://masterprofile/script_data' -> | ||
| 1219 | /// '/home/user/.kodi/UserData/script_data' on Linux. | ||
| 1220 | /// | ||
| 1221 | /// | ||
| 1222 | /// ------------------------------------------------------------------------ | ||
| 1223 | /// | ||
| 1224 | /// **Example:** | ||
| 1225 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1226 | /// #include <kodi/Filesystem.h> | ||
| 1227 | /// ... | ||
| 1228 | /// std::string path = kodi::vfs::TranslateSpecialProtocol("special://masterprofile/script_data"); | ||
| 1229 | /// fprintf(stderr, "Translated path is: %s\n", path.c_str()); | ||
| 1230 | /// ... | ||
| 1231 | /// ~~~~~~~~~~~~~ | ||
| 1232 | /// or | ||
| 1233 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1234 | /// #include <kodi/Filesystem.h> | ||
| 1235 | /// ... | ||
| 1236 | /// fprintf(stderr, "Directory 'special://temp' is '%s'\n", kodi::vfs::TranslateSpecialProtocol("special://temp").c_str()); | ||
| 1237 | /// ... | ||
| 1238 | /// ~~~~~~~~~~~~~ | ||
| 1239 | /// | ||
| 1240 | inline std::string ATTRIBUTE_HIDDEN TranslateSpecialProtocol(const std::string& source) | ||
| 1241 | { | ||
| 1242 | using namespace kodi::addon; | ||
| 1243 | |||
| 1244 | std::string strReturn; | ||
| 1245 | char* protocol = CAddonBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol( | ||
| 1246 | CAddonBase::m_interface->toKodi->kodiBase, source.c_str()); | ||
| 1247 | if (protocol != nullptr) | ||
| 1248 | { | ||
| 1249 | if (std::strlen(protocol)) | ||
| 1250 | strReturn = protocol; | ||
| 1251 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1252 | protocol); | ||
| 1253 | } | ||
| 1254 | return strReturn; | ||
| 1255 | } | ||
| 1256 | //------------------------------------------------------------------------------ | ||
| 1257 | |||
| 1258 | //============================================================================== | ||
| 1259 | /// @ingroup cpp_kodi_vfs_General | ||
| 1260 | /// @brief Retrieves information about the amount of space that is available on | ||
| 1261 | /// a disk volume. | ||
| 1262 | /// | ||
| 1263 | /// Path can be also with Kodi's special protocol. | ||
| 1264 | /// | ||
| 1265 | /// @param[in] path Path for where to check | ||
| 1266 | /// @param[out] capacity The total number of bytes in the file system | ||
| 1267 | /// @param[out] free The total number of free bytes in the file system | ||
| 1268 | /// @param[out] available The total number of free bytes available to a | ||
| 1269 | /// non-privileged process | ||
| 1270 | /// @return true if successfully done and set | ||
| 1271 | /// | ||
| 1272 | /// @warning This only works with paths belonging to OS. If <b>"special://"</b> | ||
| 1273 | /// is used, it must point to a place on your own OS. | ||
| 1274 | /// | ||
| 1275 | /// | ||
| 1276 | /// ------------------------------------------------------------------------ | ||
| 1277 | /// | ||
| 1278 | /// **Example:** | ||
| 1279 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1280 | /// #include <climits> // for ULLONG_MAX | ||
| 1281 | /// #include <kodi/Filesystem.h> | ||
| 1282 | /// ... | ||
| 1283 | /// std::string path = "special://temp"; | ||
| 1284 | /// uint64_t capacity = ULLONG_MAX; | ||
| 1285 | /// uint64_t free = ULLONG_MAX; | ||
| 1286 | /// uint64_t available = ULLONG_MAX; | ||
| 1287 | /// kodi::vfs::GetDiskSpace(path, capacity, free, available); | ||
| 1288 | /// fprintf(stderr, "Path '%s' sizes:\n", path.c_str()); | ||
| 1289 | /// fprintf(stderr, " - capacity: %lu MByte\n", capacity / 1024 / 1024); | ||
| 1290 | /// fprintf(stderr, " - free: %lu MByte\n", free / 1024 / 1024); | ||
| 1291 | /// fprintf(stderr, " - available: %lu MByte\n", available / 1024 / 1024); | ||
| 1292 | /// ~~~~~~~~~~~~~ | ||
| 1293 | /// | ||
| 1294 | inline bool ATTRIBUTE_HIDDEN GetDiskSpace(const std::string& path, | ||
| 1295 | uint64_t& capacity, | ||
| 1296 | uint64_t& free, | ||
| 1297 | uint64_t& available) | ||
| 1298 | { | ||
| 1299 | using namespace kodi::addon; | ||
| 1300 | |||
| 1301 | return CAddonBase::m_interface->toKodi->kodi_filesystem->get_disk_space( | ||
| 1302 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &capacity, &free, &available); | ||
| 1303 | } | ||
| 1304 | //------------------------------------------------------------------------------ | ||
| 1305 | |||
| 1306 | //============================================================================== | ||
| 1307 | /// @ingroup cpp_kodi_vfs_General | ||
| 1308 | /// @brief Return the file name from given complate path string. | ||
| 1309 | /// | ||
| 1310 | /// @param[in] path The complete path include file and directory | ||
| 1311 | /// @return Filename from path | ||
| 1312 | /// | ||
| 1313 | /// | ||
| 1314 | /// ------------------------------------------------------------------------ | ||
| 1315 | /// | ||
| 1316 | /// **Example:** | ||
| 1317 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1318 | /// #include <kodi/Filesystem.h> | ||
| 1319 | /// ... | ||
| 1320 | /// std::string fileName = kodi::vfs::GetFileName("special://temp/kodi.log"); | ||
| 1321 | /// fprintf(stderr, "File name is '%s'\n", fileName.c_str()); | ||
| 1322 | /// ~~~~~~~~~~~~~ | ||
| 1323 | /// | ||
| 1324 | inline std::string ATTRIBUTE_HIDDEN GetFileName(const std::string& path) | ||
| 1325 | { | ||
| 1326 | /* find the last slash */ | ||
| 1327 | const size_t slash = path.find_last_of("/\\"); | ||
| 1328 | return path.substr(slash + 1); | ||
| 1329 | } | ||
| 1330 | //------------------------------------------------------------------------------ | ||
| 1331 | |||
| 1332 | //============================================================================== | ||
| 1333 | /// @ingroup cpp_kodi_vfs_General | ||
| 1334 | /// @brief Return the directory name from given complate path string. | ||
| 1335 | /// | ||
| 1336 | /// @param[in] path The complete path include file and directory | ||
| 1337 | /// @return Directory name from path | ||
| 1338 | /// | ||
| 1339 | /// | ||
| 1340 | /// ------------------------------------------------------------------------ | ||
| 1341 | /// | ||
| 1342 | /// **Example:** | ||
| 1343 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1344 | /// #include <kodi/Filesystem.h> | ||
| 1345 | /// ... | ||
| 1346 | /// std::string dirName = kodi::vfs::GetDirectoryName("special://temp/kodi.log"); | ||
| 1347 | /// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str()); | ||
| 1348 | /// ~~~~~~~~~~~~~ | ||
| 1349 | /// | ||
| 1350 | inline std::string ATTRIBUTE_HIDDEN GetDirectoryName(const std::string& path) | ||
| 1351 | { | ||
| 1352 | // Will from a full filename return the directory the file resides in. | ||
| 1353 | // Keeps the final slash at end and possible |option=foo options. | ||
| 1354 | |||
| 1355 | size_t iPosSlash = path.find_last_of("/\\"); | ||
| 1356 | if (iPosSlash == std::string::npos) | ||
| 1357 | return ""; // No slash, so no path (ignore any options) | ||
| 1358 | |||
| 1359 | size_t iPosBar = path.rfind('|'); | ||
| 1360 | if (iPosBar == std::string::npos) | ||
| 1361 | return path.substr(0, iPosSlash + 1); // Only path | ||
| 1362 | |||
| 1363 | return path.substr(0, iPosSlash + 1) + path.substr(iPosBar); // Path + options | ||
| 1364 | } | ||
| 1365 | //------------------------------------------------------------------------------ | ||
| 1366 | |||
| 1367 | //============================================================================== | ||
| 1368 | /// @ingroup cpp_kodi_vfs_General | ||
| 1369 | /// @brief Remove the slash on given path name. | ||
| 1370 | /// | ||
| 1371 | /// @param[in,out] path The complete path | ||
| 1372 | /// | ||
| 1373 | /// | ||
| 1374 | /// ------------------------------------------------------------------------ | ||
| 1375 | /// | ||
| 1376 | /// **Example:** | ||
| 1377 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1378 | /// #include <kodi/Filesystem.h> | ||
| 1379 | /// ... | ||
| 1380 | /// std::string dirName = "special://temp/"; | ||
| 1381 | /// kodi::vfs::RemoveSlashAtEnd(dirName); | ||
| 1382 | /// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str()); | ||
| 1383 | /// ~~~~~~~~~~~~~ | ||
| 1384 | /// | ||
| 1385 | inline void ATTRIBUTE_HIDDEN RemoveSlashAtEnd(std::string& path) | ||
| 1386 | { | ||
| 1387 | if (!path.empty()) | ||
| 1388 | { | ||
| 1389 | char last = path[path.size() - 1]; | ||
| 1390 | if (last == '/' || last == '\\') | ||
| 1391 | path.erase(path.size() - 1); | ||
| 1392 | } | ||
| 1393 | } | ||
| 1394 | //------------------------------------------------------------------------------ | ||
| 1395 | |||
| 1396 | //============================================================================== | ||
| 1397 | /// @ingroup cpp_kodi_vfs_General | ||
| 1398 | /// @brief Return a size aligned to the chunk size at least as large as the | ||
| 1399 | /// chunk size. | ||
| 1400 | /// | ||
| 1401 | /// @param[in] chunk The chunk size | ||
| 1402 | /// @param[in] minimum The minimum size (or maybe the minimum number of chunks?) | ||
| 1403 | /// @return The aligned size | ||
| 1404 | /// | ||
| 1405 | inline unsigned int ATTRIBUTE_HIDDEN GetChunkSize(unsigned int chunk, unsigned int minimum) | ||
| 1406 | { | ||
| 1407 | if (chunk) | ||
| 1408 | return chunk * ((minimum + chunk - 1) / chunk); | ||
| 1409 | else | ||
| 1410 | return minimum; | ||
| 1411 | } | ||
| 1412 | //------------------------------------------------------------------------------ | ||
| 1413 | |||
| 1414 | //============================================================================== | ||
| 1415 | /// @ingroup cpp_kodi_vfs_General | ||
| 1416 | /// @brief Checks the given path contains a known internet protocol. | ||
| 1417 | /// | ||
| 1418 | /// About following protocols are the path checked: | ||
| 1419 | /// | Protocol | Return true condition | Protocol | Return true condition | ||
| 1420 | /// |----------|-----------------------|----------|----------------------- | ||
| 1421 | /// | **dav** | strictCheck = true | **rtmps** | always | ||
| 1422 | /// | **davs** | strictCheck = true | **rtmpt** | always | ||
| 1423 | /// | **ftp** | strictCheck = true | **rtmpte** | always | ||
| 1424 | /// | **ftps** | strictCheck = true | **rtp** | always | ||
| 1425 | /// | **http** | always | **rtsp** | always | ||
| 1426 | /// | **https**| always | **sdp** | always | ||
| 1427 | /// | **mms** | always | **sftp** | strictCheck = true | ||
| 1428 | /// | **mmsh** | always | **stack** | always | ||
| 1429 | /// | **mmst** | always | **tcp** | always | ||
| 1430 | /// | **rtmp** | always | **udp** | always | ||
| 1431 | /// | **rtmpe**| always | | | | ||
| 1432 | /// | ||
| 1433 | /// @param[in] path To checked path/URL | ||
| 1434 | /// @param[in] strictCheck [opt] If True the set of protocols used will be | ||
| 1435 | /// extended to include ftp, ftps, dav, davs and sftp. | ||
| 1436 | /// @return True if path is to a internet stream, false otherwise | ||
| 1437 | /// | ||
| 1438 | /// | ||
| 1439 | /// ------------------------------------------------------------------------ | ||
| 1440 | /// | ||
| 1441 | /// **Example:** | ||
| 1442 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1443 | /// #include <kodi/Filesystem.h> | ||
| 1444 | /// ... | ||
| 1445 | /// // Check should return false | ||
| 1446 | /// fprintf(stderr, "File name 1 is internet stream '%s' (should no)\n", | ||
| 1447 | /// kodi::vfs::IsInternetStream("D:/my-file.mkv") ? "yes" : "no"); | ||
| 1448 | /// | ||
| 1449 | /// // Check should return true | ||
| 1450 | /// fprintf(stderr, "File name 2 is internet stream '%s' (should yes)\n", | ||
| 1451 | /// kodi::vfs::IsInternetStream("http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4") ? "yes" : "no"); | ||
| 1452 | /// | ||
| 1453 | /// // Check should return false | ||
| 1454 | /// fprintf(stderr, "File name 1 is internet stream '%s' (should no)\n", | ||
| 1455 | /// kodi::vfs::IsInternetStream("ftp://do-somewhere.com/the-file.mkv") ? "yes" : "no", false); | ||
| 1456 | /// | ||
| 1457 | /// // Check should return true | ||
| 1458 | /// fprintf(stderr, "File name 1 is internet stream '%s' (should yes)\n", | ||
| 1459 | /// kodi::vfs::IsInternetStream("ftp://do-somewhere.com/the-file.mkv") ? "yes" : "no", true); | ||
| 1460 | /// ~~~~~~~~~~~~~ | ||
| 1461 | /// | ||
| 1462 | inline bool ATTRIBUTE_HIDDEN IsInternetStream(const std::string& path, bool strictCheck = false) | ||
| 1463 | { | ||
| 1464 | using namespace kodi::addon; | ||
| 1465 | |||
| 1466 | return CAddonBase::m_interface->toKodi->kodi_filesystem->is_internet_stream( | ||
| 1467 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), strictCheck); | ||
| 1468 | } | ||
| 1469 | //------------------------------------------------------------------------------ | ||
| 1470 | |||
| 1471 | //============================================================================== | ||
| 1472 | /// @ingroup cpp_kodi_vfs_General | ||
| 1473 | /// @brief Checks whether the specified path refers to a local network. | ||
| 1474 | /// | ||
| 1475 | /// In difference to @ref IsHostOnLAN() include this more deeper checks where | ||
| 1476 | /// also handle Kodi's special protocol and stacks. | ||
| 1477 | /// | ||
| 1478 | /// @param[in] path To checked path | ||
| 1479 | /// @return True if path is on LAN, false otherwise | ||
| 1480 | /// | ||
| 1481 | /// @note Check includes @ref IsHostOnLAN() too. | ||
| 1482 | /// | ||
| 1483 | /// | ||
| 1484 | /// ------------------------------------------------------------------------ | ||
| 1485 | /// | ||
| 1486 | /// **Example:** | ||
| 1487 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1488 | /// #include <kodi/Filesystem.h> | ||
| 1489 | /// ... | ||
| 1490 | /// // Check should return true | ||
| 1491 | /// bool lan = kodi::vfs::IsOnLAN("smb://path/to/file"); | ||
| 1492 | /// ~~~~~~~~~~~~~ | ||
| 1493 | /// | ||
| 1494 | inline bool ATTRIBUTE_HIDDEN IsOnLAN(const std::string& path) | ||
| 1495 | { | ||
| 1496 | using namespace kodi::addon; | ||
| 1497 | |||
| 1498 | return CAddonBase::m_interface->toKodi->kodi_filesystem->is_on_lan( | ||
| 1499 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 1500 | } | ||
| 1501 | //------------------------------------------------------------------------------ | ||
| 1502 | |||
| 1503 | //============================================================================== | ||
| 1504 | /// @ingroup cpp_kodi_vfs_General | ||
| 1505 | /// @brief Checks specified path for external network. | ||
| 1506 | /// | ||
| 1507 | /// @param[in] path To checked path | ||
| 1508 | /// @return True if path is remote, false otherwise | ||
| 1509 | /// | ||
| 1510 | /// @note This does not apply to the local network. | ||
| 1511 | /// | ||
| 1512 | /// | ||
| 1513 | /// ------------------------------------------------------------------------ | ||
| 1514 | /// | ||
| 1515 | /// **Example:** | ||
| 1516 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1517 | /// #include <kodi/Filesystem.h> | ||
| 1518 | /// ... | ||
| 1519 | /// // Check should return true | ||
| 1520 | /// bool remote = kodi::vfs::IsRemote("http://path/to/file"); | ||
| 1521 | /// ~~~~~~~~~~~~~ | ||
| 1522 | /// | ||
| 1523 | inline bool ATTRIBUTE_HIDDEN IsRemote(const std::string& path) | ||
| 1524 | { | ||
| 1525 | using namespace kodi::addon; | ||
| 1526 | |||
| 1527 | return CAddonBase::m_interface->toKodi->kodi_filesystem->is_remote( | ||
| 1528 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 1529 | } | ||
| 1530 | //------------------------------------------------------------------------------ | ||
| 1531 | |||
| 1532 | //============================================================================== | ||
| 1533 | /// @ingroup cpp_kodi_vfs_General | ||
| 1534 | /// @brief Checks whether the given path refers to the own system. | ||
| 1535 | /// | ||
| 1536 | /// @param[in] path To checked path | ||
| 1537 | /// @return True if path is local, false otherwise | ||
| 1538 | /// | ||
| 1539 | inline bool ATTRIBUTE_HIDDEN IsLocal(const std::string& path) | ||
| 1540 | { | ||
| 1541 | using namespace kodi::addon; | ||
| 1542 | |||
| 1543 | return CAddonBase::m_interface->toKodi->kodi_filesystem->is_local( | ||
| 1544 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 1545 | } | ||
| 1546 | //------------------------------------------------------------------------------ | ||
| 1547 | |||
| 1548 | //============================================================================== | ||
| 1549 | /// @ingroup cpp_kodi_vfs_General | ||
| 1550 | /// @brief Checks specified path is a regular URL, e.g. "someprotocol://path/to/file" | ||
| 1551 | /// | ||
| 1552 | /// @return True if file item is URL, false otherwise | ||
| 1553 | /// | ||
| 1554 | /// | ||
| 1555 | /// ------------------------------------------------------------------------ | ||
| 1556 | /// | ||
| 1557 | /// **Example:** | ||
| 1558 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1559 | /// #include <kodi/Filesystem.h> | ||
| 1560 | /// ... | ||
| 1561 | /// | ||
| 1562 | /// bool isURL; | ||
| 1563 | /// // Check should return true | ||
| 1564 | /// isURL = kodi::vfs::IsURL("someprotocol://path/to/file"); | ||
| 1565 | /// | ||
| 1566 | /// // Check should return false | ||
| 1567 | /// isURL = kodi::vfs::IsURL("/path/to/file"); | ||
| 1568 | /// ~~~~~~~~~~~~~ | ||
| 1569 | /// | ||
| 1570 | inline bool ATTRIBUTE_HIDDEN IsURL(const std::string& path) | ||
| 1571 | { | ||
| 1572 | using namespace kodi::addon; | ||
| 1573 | |||
| 1574 | return CAddonBase::m_interface->toKodi->kodi_filesystem->is_url( | ||
| 1575 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | ||
| 1576 | } | ||
| 1577 | //-------------------------------------------------------------------------- | ||
| 1578 | |||
| 1579 | //============================================================================ | ||
| 1580 | /// @ingroup cpp_kodi_vfs_General | ||
| 1581 | /// @brief To get HTTP header information. | ||
| 1582 | /// | ||
| 1583 | /// @param[in] url URL source of the data | ||
| 1584 | /// @param[out] header The @ref cpp_kodi_vfs_Defs_HttpHeader | ||
| 1585 | /// @return true if successfully done, otherwise false | ||
| 1586 | /// | ||
| 1587 | /// | ||
| 1588 | /// ------------------------------------------------------------------------ | ||
| 1589 | /// | ||
| 1590 | /// @copydetails cpp_kodi_vfs_Defs_HttpHeader_Help | ||
| 1591 | /// | ||
| 1592 | /// ------------------------------------------------------------------------ | ||
| 1593 | /// | ||
| 1594 | /// **Example:** | ||
| 1595 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1596 | /// #include <kodi/Filesystem.h> | ||
| 1597 | /// ... | ||
| 1598 | /// kodi::vfs::HttpHeader header; | ||
| 1599 | /// bool ret = kodi::vfs::GetHttpHeader(url, header); | ||
| 1600 | /// ... | ||
| 1601 | /// ~~~~~~~~~~~~~ | ||
| 1602 | /// | ||
| 1603 | inline bool ATTRIBUTE_HIDDEN GetHttpHeader(const std::string& url, HttpHeader& header) | ||
| 1604 | { | ||
| 1605 | using namespace ::kodi::addon; | ||
| 1606 | |||
| 1607 | return CAddonBase::m_interface->toKodi->kodi_filesystem->get_http_header( | ||
| 1608 | CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &header.m_handle); | ||
| 1609 | } | ||
| 1610 | //---------------------------------------------------------------------------- | ||
| 1611 | |||
| 1612 | //============================================================================ | ||
| 1613 | /// @ingroup cpp_kodi_vfs_General | ||
| 1614 | /// @brief Get file mime type. | ||
| 1615 | /// | ||
| 1616 | /// @param[in] url URL source of the data | ||
| 1617 | /// @param[out] mimeType the mime type of the URL | ||
| 1618 | /// @param[in] useragent to be used when retrieving the MimeType [opt] | ||
| 1619 | /// @return true if successfully done, otherwise false | ||
| 1620 | /// | ||
| 1621 | /// | ||
| 1622 | /// ------------------------------------------------------------------------ | ||
| 1623 | /// | ||
| 1624 | /// **Example:** | ||
| 1625 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1626 | /// #include <kodi/Filesystem.h> | ||
| 1627 | /// ... | ||
| 1628 | /// std::string mimeType;. | ||
| 1629 | /// if (kodi::vfs::GetMimeType(url, mimeType)) | ||
| 1630 | /// fprintf(stderr, "The mime type is '%s'\n", mimeType.c_str()); | ||
| 1631 | /// ... | ||
| 1632 | /// ~~~~~~~~~~~~~ | ||
| 1633 | /// | ||
| 1634 | inline bool ATTRIBUTE_HIDDEN GetMimeType(const std::string& url, | ||
| 1635 | std::string& mimeType, | ||
| 1636 | const std::string& useragent = "") | ||
| 1637 | { | ||
| 1638 | using namespace ::kodi::addon; | ||
| 1639 | |||
| 1640 | char* cMimeType = nullptr; | ||
| 1641 | bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_mime_type( | ||
| 1642 | CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cMimeType, useragent.c_str()); | ||
| 1643 | if (cMimeType != nullptr) | ||
| 1644 | { | ||
| 1645 | mimeType = cMimeType; | ||
| 1646 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1647 | cMimeType); | ||
| 1648 | } | ||
| 1649 | return ret; | ||
| 1650 | } | ||
| 1651 | //---------------------------------------------------------------------------- | ||
| 1652 | |||
| 1653 | //============================================================================ | ||
| 1654 | /// @ingroup cpp_kodi_vfs_General | ||
| 1655 | /// @brief Get file content-type. | ||
| 1656 | /// | ||
| 1657 | /// @param[in] url URL source of the data | ||
| 1658 | /// @param[out] content The returned type | ||
| 1659 | /// @param[in] useragent to be used when retrieving the MimeType [opt] | ||
| 1660 | /// @return true if successfully done, otherwise false | ||
| 1661 | /// | ||
| 1662 | /// | ||
| 1663 | /// ------------------------------------------------------------------------ | ||
| 1664 | /// | ||
| 1665 | /// **Example:** | ||
| 1666 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1667 | /// #include <kodi/Filesystem.h> | ||
| 1668 | /// ... | ||
| 1669 | /// std::string content;. | ||
| 1670 | /// if (kodi::vfs::GetContentType(url, content)) | ||
| 1671 | /// fprintf(stderr, "The content type is '%s'\n", content.c_str()); | ||
| 1672 | /// ... | ||
| 1673 | /// ~~~~~~~~~~~~~ | ||
| 1674 | /// | ||
| 1675 | inline bool ATTRIBUTE_HIDDEN GetContentType(const std::string& url, | ||
| 1676 | std::string& content, | ||
| 1677 | const std::string& useragent = "") | ||
| 1678 | { | ||
| 1679 | using namespace ::kodi::addon; | ||
| 1680 | |||
| 1681 | char* cContent = nullptr; | ||
| 1682 | bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_content_type( | ||
| 1683 | CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cContent, useragent.c_str()); | ||
| 1684 | if (cContent != nullptr) | ||
| 1685 | { | ||
| 1686 | content = cContent; | ||
| 1687 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1688 | cContent); | ||
| 1689 | } | ||
| 1690 | return ret; | ||
| 1691 | } | ||
| 1692 | //---------------------------------------------------------------------------- | ||
| 1693 | |||
| 1694 | //============================================================================ | ||
| 1695 | /// @ingroup cpp_kodi_vfs_General | ||
| 1696 | /// @brief Get cookies stored by CURL in RFC 2109 format. | ||
| 1697 | /// | ||
| 1698 | /// @param[in] url URL source of the data | ||
| 1699 | /// @param[out] cookies The text list of available cookies | ||
| 1700 | /// @return true if successfully done, otherwise false | ||
| 1701 | /// | ||
| 1702 | /// | ||
| 1703 | /// ------------------------------------------------------------------------ | ||
| 1704 | /// | ||
| 1705 | /// **Example:** | ||
| 1706 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1707 | /// #include <kodi/Filesystem.h> | ||
| 1708 | /// ... | ||
| 1709 | /// std::string url = ""; | ||
| 1710 | /// std::string cookies; | ||
| 1711 | /// bool ret = kodi::vfs::GetCookies(url, cookies); | ||
| 1712 | /// fprintf(stderr, "Cookies from URL '%s' are '%s' (return was %s)\n", | ||
| 1713 | /// url.c_str(), cookies.c_str(), ret ? "true" : "false"); | ||
| 1714 | /// ... | ||
| 1715 | /// ~~~~~~~~~~~~~ | ||
| 1716 | /// | ||
| 1717 | inline bool ATTRIBUTE_HIDDEN GetCookies(const std::string& url, std::string& cookies) | ||
| 1718 | { | ||
| 1719 | using namespace ::kodi::addon; | ||
| 1720 | |||
| 1721 | char* cCookies = nullptr; | ||
| 1722 | bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_cookies( | ||
| 1723 | CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cCookies); | ||
| 1724 | if (cCookies != nullptr) | ||
| 1725 | { | ||
| 1726 | cookies = cCookies; | ||
| 1727 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 1728 | cCookies); | ||
| 1729 | } | ||
| 1730 | return ret; | ||
| 1731 | } | ||
| 1732 | //---------------------------------------------------------------------------- | ||
| 1733 | |||
| 1734 | //}}} | ||
| 1735 | |||
| 1736 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 1737 | // "C++" CFile class | ||
| 1738 | //{{{ | ||
| 1739 | |||
| 1740 | //============================================================================== | ||
| 1741 | /// @defgroup cpp_kodi_vfs_CFile 4. class CFile | ||
| 1742 | /// @ingroup cpp_kodi_vfs | ||
| 1743 | /// | ||
| 1744 | /// @brief **Creatable class for virtual file server control**\n | ||
| 1745 | /// To perform file read/write with Kodi's filesystem parts. | ||
| 1746 | /// | ||
| 1747 | /// CFile is the class used for handling Files in Kodi. This class can be used | ||
| 1748 | /// for creating, reading, writing and modifying files. It directly provides unbuffered, binary disk input/output services | ||
| 1749 | /// | ||
| 1750 | /// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be included | ||
| 1751 | /// to enjoy it. | ||
| 1752 | /// | ||
| 1753 | /// | ||
| 1754 | /// ------------------------------------------------------------------------ | ||
| 1755 | /// | ||
| 1756 | /// **Example:** | ||
| 1757 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1758 | /// #include <kodi/Filesystem.h> | ||
| 1759 | /// | ||
| 1760 | /// ... | ||
| 1761 | /// | ||
| 1762 | /// /* Create the needed file handle class */ | ||
| 1763 | /// kodi::vfs::CFile myFile(); | ||
| 1764 | /// | ||
| 1765 | /// /* In this example we use the user path for the add-on */ | ||
| 1766 | /// std::string file = kodi::GetUserPath() + "/myFile.txt"; | ||
| 1767 | /// | ||
| 1768 | /// /* Now create and open the file or overwrite if present */ | ||
| 1769 | /// myFile.OpenFileForWrite(file, true); | ||
| 1770 | /// | ||
| 1771 | /// const char* str = "I love Kodi!"; | ||
| 1772 | /// | ||
| 1773 | /// /* write string */ | ||
| 1774 | /// myFile.Write(str, sizeof(str)); | ||
| 1775 | /// | ||
| 1776 | /// /* On this way the Close() is not needed to call, becomes done from destructor */ | ||
| 1777 | /// | ||
| 1778 | /// ~~~~~~~~~~~~~ | ||
| 1779 | /// | ||
| 1780 | //@{ | ||
| 1781 | class ATTRIBUTE_HIDDEN CFile | ||
| 1782 | { | ||
| 1783 | public: | ||
| 1784 | //============================================================================ | ||
| 1785 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1786 | /// @brief Construct a new, unopened file. | ||
| 1787 | /// | ||
| 1788 | CFile() = default; | ||
| 720 | //---------------------------------------------------------------------------- | 1789 | //---------------------------------------------------------------------------- |
| 721 | 1790 | ||
| 722 | //============================================================================ | 1791 | //============================================================================ |
| 1792 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1793 | /// @brief <b>`Close()`</b> is called from the destructor, so explicitly | ||
| 1794 | /// closing the file isn't required. | ||
| 723 | /// | 1795 | /// |
| 724 | /// @ingroup cpp_kodi_vfs | 1796 | virtual ~CFile() { Close(); } |
| 725 | /// @brief Returns a thumb cache filename | 1797 | //-------------------------------------------------------------------------- |
| 1798 | |||
| 1799 | //========================================================================== | ||
| 1800 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1801 | /// @brief Open the file with filename via Kodi's @ref cpp_kodi_vfs_CFile | ||
| 1802 | /// "CFile". Needs to be closed by calling Close() when done. | ||
| 726 | /// | 1803 | /// |
| 727 | /// @param[in] filename path to file | 1804 | /// @param[in] filename The filename to open. |
| 728 | /// @return cache filename | 1805 | /// @param[in] flags [opt] The flags to pass, see @ref OpenFileFlags |
| 1806 | /// @return True on success or false on failure | ||
| 729 | /// | 1807 | /// |
| 1808 | bool OpenFile(const std::string& filename, unsigned int flags = 0) | ||
| 1809 | { | ||
| 1810 | using namespace kodi::addon; | ||
| 1811 | |||
| 1812 | Close(); | ||
| 1813 | m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file( | ||
| 1814 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), flags); | ||
| 1815 | return m_file != nullptr; | ||
| 1816 | } | ||
| 1817 | //-------------------------------------------------------------------------- | ||
| 1818 | |||
| 1819 | //========================================================================== | ||
| 1820 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1821 | /// @brief Open the file with filename via Kodi's @ref cpp_kodi_vfs_CFile | ||
| 1822 | /// "CFile" in write mode. Needs to be closed by calling Close() when | ||
| 1823 | /// done. | ||
| 730 | /// | 1824 | /// |
| 731 | /// ------------------------------------------------------------------------ | 1825 | /// @note Related folders becomes created if not present. |
| 732 | /// | 1826 | /// |
| 733 | /// **Example:** | 1827 | /// @param[in] filename The filename to open. |
| 734 | /// ~~~~~~~~~~~~~{.cpp} | 1828 | /// @param[in] overwrite True to overwrite, false otherwise. |
| 735 | /// #include <kodi/Filesystem.h> | 1829 | /// @return True on success or false on failure |
| 736 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 737 | /// ... | ||
| 738 | /// std::string thumb; | ||
| 739 | /// std::string filename; | ||
| 740 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4", | ||
| 741 | /// "Test File selection to get Thumnail", | ||
| 742 | /// filename)) | ||
| 743 | /// { | ||
| 744 | /// thumb = kodi::vfs::GetCacheThumbName(filename); | ||
| 745 | /// fprintf(stderr, "Thumb name of file '%s' is %s\n", thumb.c_str(), filename.c_str()); | ||
| 746 | /// } | ||
| 747 | /// ~~~~~~~~~~~~~ | ||
| 748 | /// | 1830 | /// |
| 749 | inline std::string GetCacheThumbName(const std::string& filename) | 1831 | bool OpenFileForWrite(const std::string& filename, bool overwrite = false) |
| 750 | { | 1832 | { |
| 751 | std::string strReturn; | 1833 | using namespace kodi::addon; |
| 752 | char* strThumbName = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | 1834 | |
| 753 | if (strThumbName != nullptr) | 1835 | Close(); |
| 1836 | |||
| 1837 | // Try to open the file. If it fails, check if we need to create the directory first | ||
| 1838 | // This way we avoid checking if the directory exists every time | ||
| 1839 | m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write( | ||
| 1840 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite); | ||
| 1841 | if (!m_file) | ||
| 754 | { | 1842 | { |
| 755 | if (std::strlen(strThumbName)) | 1843 | std::string cacheDirectory = kodi::vfs::GetDirectoryName(filename); |
| 756 | strReturn = strThumbName; | 1844 | if (CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists( |
| 757 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strThumbName); | 1845 | CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) || |
| 1846 | CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory( | ||
| 1847 | CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str())) | ||
| 1848 | m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write( | ||
| 1849 | CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite); | ||
| 758 | } | 1850 | } |
| 759 | return strReturn; | 1851 | return m_file != nullptr; |
| 760 | } | 1852 | } |
| 761 | //---------------------------------------------------------------------------- | 1853 | //-------------------------------------------------------------------------- |
| 762 | 1854 | ||
| 763 | //============================================================================ | 1855 | //========================================================================== |
| 764 | /// | 1856 | /// @ingroup cpp_kodi_vfs_CFile |
| 765 | /// @ingroup cpp_kodi_vfs | 1857 | /// @brief Check file is opened. |
| 766 | /// @brief Make filename valid | ||
| 767 | /// | 1858 | /// |
| 768 | /// Function to replace not valid characters with '_'. It can be also | 1859 | /// @return True on open or false on closed or failure |
| 769 | /// compared with original before in a own loop until it is equal | ||
| 770 | /// (no invalid characters). | ||
| 771 | /// | 1860 | /// |
| 772 | /// @param[in] filename Filename to check and fix | 1861 | bool IsOpen() const { return m_file != nullptr; } |
| 773 | /// @return The legal filename | 1862 | //-------------------------------------------------------------------------- |
| 1863 | |||
| 1864 | //========================================================================== | ||
| 1865 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1866 | /// @brief Close an open file. | ||
| 774 | /// | 1867 | /// |
| 1868 | void Close() | ||
| 1869 | { | ||
| 1870 | using namespace kodi::addon; | ||
| 1871 | |||
| 1872 | if (!m_file) | ||
| 1873 | return; | ||
| 1874 | CAddonBase::m_interface->toKodi->kodi_filesystem->close_file( | ||
| 1875 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1876 | m_file = nullptr; | ||
| 1877 | } | ||
| 1878 | //-------------------------------------------------------------------------- | ||
| 1879 | |||
| 1880 | //========================================================================== | ||
| 1881 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1882 | /// @brief Create a Curl representation | ||
| 775 | /// | 1883 | /// |
| 776 | /// ------------------------------------------------------------------------ | 1884 | /// @param[in] url The URL of the Type. |
| 1885 | /// @return True on success or false on failure | ||
| 777 | /// | 1886 | /// |
| 778 | /// **Example:** | 1887 | bool CURLCreate(const std::string& url) |
| 779 | /// ~~~~~~~~~~~~~{.cpp} | 1888 | { |
| 780 | /// #include <kodi/Filesystem.h> | 1889 | using namespace kodi::addon; |
| 781 | /// ... | 1890 | |
| 782 | /// std::string fileName = "///\\jk???lj????.mpg"; | 1891 | m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->curl_create( |
| 783 | /// std::string legalName = kodi::vfs::MakeLegalFileName(fileName); | 1892 | CAddonBase::m_interface->toKodi->kodiBase, url.c_str()); |
| 784 | /// fprintf(stderr, "Legal name of '%s' is '%s'\n", fileName.c_str(), legalName.c_str()); | 1893 | return m_file != nullptr; |
| 1894 | } | ||
| 1895 | //-------------------------------------------------------------------------- | ||
| 1896 | |||
| 1897 | //========================================================================== | ||
| 1898 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1899 | /// @brief Add options to the curl file created with CURLCreate. | ||
| 785 | /// | 1900 | /// |
| 786 | /// /* Returns as legal: 'jk___lj____.mpg' */ | 1901 | /// @param[in] type Option type to set, see @ref CURLOptiontype |
| 787 | /// ~~~~~~~~~~~~~ | 1902 | /// @param[in] name Name of the option |
| 1903 | /// @param[in] value Value of the option | ||
| 1904 | /// @return True on success or false on failure | ||
| 788 | /// | 1905 | /// |
| 789 | inline std::string MakeLegalFileName(const std::string& filename) | 1906 | bool CURLAddOption(CURLOptiontype type, const std::string& name, const std::string& value) |
| 790 | { | 1907 | { |
| 791 | std::string strReturn; | 1908 | using namespace kodi::addon; |
| 792 | char* strLegalFileName = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_filename(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | 1909 | |
| 793 | if (strLegalFileName != nullptr) | 1910 | if (!m_file) |
| 794 | { | 1911 | { |
| 795 | if (std::strlen(strLegalFileName)) | 1912 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!"); |
| 796 | strReturn = strLegalFileName; | 1913 | return false; |
| 797 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strLegalFileName); | ||
| 798 | } | 1914 | } |
| 799 | return strReturn; | 1915 | return CAddonBase::m_interface->toKodi->kodi_filesystem->curl_add_option( |
| 1916 | CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str()); | ||
| 800 | } | 1917 | } |
| 801 | //---------------------------------------------------------------------------- | 1918 | //-------------------------------------------------------------------------- |
| 802 | 1919 | ||
| 803 | //============================================================================ | 1920 | //========================================================================== |
| 804 | /// | 1921 | /// @ingroup cpp_kodi_vfs_CFile |
| 805 | /// @ingroup cpp_kodi_vfs | 1922 | /// @brief Open the curl file created with CURLCreate. |
| 806 | /// @brief Make directory name valid | ||
| 807 | /// | ||
| 808 | /// Function to replace not valid characters with '_'. It can be also | ||
| 809 | /// compared with original before in a own loop until it is equal | ||
| 810 | /// (no invalid characters). | ||
| 811 | /// | 1923 | /// |
| 812 | /// @param[in] path Directory name to check and fix | 1924 | /// @param[in] flags [opt] The flags to pass, see @ref OpenFileFlags |
| 813 | /// @return The legal directory name | 1925 | /// @return True on success or false on failure |
| 814 | /// | 1926 | /// |
| 815 | /// | 1927 | bool CURLOpen(unsigned int flags = 0) |
| 816 | /// ------------------------------------------------------------------------ | ||
| 817 | /// | ||
| 818 | /// **Example:** | ||
| 819 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 820 | /// #include <kodi/Filesystem.h> | ||
| 821 | /// ... | ||
| 822 | /// std::string path = "///\\jk???lj????\\hgjkg"; | ||
| 823 | /// std::string legalPath = kodi::vfs::MakeLegalPath(path); | ||
| 824 | /// fprintf(stderr, "Legal name of '%s' is '%s'\n", path.c_str(), legalPath.c_str()); | ||
| 825 | /// | ||
| 826 | /// /* Returns as legal: '/jk___lj____/hgjkg' */ | ||
| 827 | /// ~~~~~~~~~~~~~ | ||
| 828 | /// | ||
| 829 | inline std::string MakeLegalPath(const std::string& path) | ||
| 830 | { | 1928 | { |
| 831 | std::string strReturn; | 1929 | using namespace kodi::addon; |
| 832 | char* strLegalPath = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, path.c_str()); | 1930 | |
| 833 | if (strLegalPath != nullptr) | 1931 | if (!m_file) |
| 834 | { | 1932 | { |
| 835 | if (std::strlen(strLegalPath)) | 1933 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!"); |
| 836 | strReturn = strLegalPath; | 1934 | return false; |
| 837 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strLegalPath); | ||
| 838 | } | 1935 | } |
| 839 | return strReturn; | 1936 | return CAddonBase::m_interface->toKodi->kodi_filesystem->curl_open( |
| 1937 | CAddonBase::m_interface->toKodi->kodiBase, m_file, flags); | ||
| 840 | } | 1938 | } |
| 841 | //---------------------------------------------------------------------------- | 1939 | //-------------------------------------------------------------------------- |
| 842 | 1940 | ||
| 843 | //============================================================================ | 1941 | //========================================================================== |
| 844 | /// | 1942 | /// @ingroup cpp_kodi_vfs_CFile |
| 845 | /// @ingroup cpp_kodi_vfs | 1943 | /// @brief Read from an open file. |
| 846 | /// @brief Returns the translated path | ||
| 847 | /// | 1944 | /// |
| 848 | /// @param[in] source string or unicode - Path to format | 1945 | /// @param[in] ptr The buffer to store the data in. |
| 849 | /// @return A human-readable string suitable for logging | 1946 | /// @param[in] size The size of the buffer. |
| 1947 | /// @return number of successfully read bytes if any bytes were read and | ||
| 1948 | /// stored in buffer, zero if no bytes are available to read (end of | ||
| 1949 | /// file was reached) or undetectable error occur, -1 in case of any | ||
| 1950 | /// explicit error | ||
| 850 | /// | 1951 | /// |
| 851 | /// @note Only useful if you are coding for both Linux and Windows. | 1952 | ssize_t Read(void* ptr, size_t size) |
| 852 | /// e.g. Converts 'special://masterprofile/script_data' -> '/home/user/.kodi/UserData/script_data' | 1953 | { |
| 853 | /// on Linux. | 1954 | using namespace kodi::addon; |
| 854 | /// | 1955 | |
| 855 | /// | 1956 | if (!m_file) |
| 856 | /// ------------------------------------------------------------------------ | 1957 | return -1; |
| 1958 | return CAddonBase::m_interface->toKodi->kodi_filesystem->read_file( | ||
| 1959 | CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size); | ||
| 1960 | } | ||
| 1961 | //-------------------------------------------------------------------------- | ||
| 1962 | |||
| 1963 | //========================================================================== | ||
| 1964 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1965 | /// @brief Read a string from an open file. | ||
| 857 | /// | 1966 | /// |
| 858 | /// **Example:** | 1967 | /// @param[out] line The buffer to store the data in. |
| 859 | /// ~~~~~~~~~~~~~{.cpp} | 1968 | /// @return True when a line was read, false otherwise. |
| 860 | /// #include <kodi/Filesystem.h> | ||
| 861 | /// ... | ||
| 862 | /// std::string path = kodi::vfs::TranslateSpecialProtocol("special://masterprofile/script_data"); | ||
| 863 | /// fprintf(stderr, "Translated path is: %s\n", path.c_str()); | ||
| 864 | /// ... | ||
| 865 | /// ~~~~~~~~~~~~~ | ||
| 866 | /// or | ||
| 867 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 868 | /// #include <kodi/Filesystem.h> | ||
| 869 | /// ... | ||
| 870 | /// fprintf(stderr, "Directory 'special://temp' is '%s'\n", kodi::vfs::TranslateSpecialProtocol("special://temp").c_str()); | ||
| 871 | /// ... | ||
| 872 | /// ~~~~~~~~~~~~~ | ||
| 873 | /// | 1969 | /// |
| 874 | inline std::string TranslateSpecialProtocol(const std::string& source) | 1970 | bool ReadLine(std::string& line) |
| 875 | { | 1971 | { |
| 876 | std::string strReturn; | 1972 | using namespace kodi::addon; |
| 877 | char* protocol = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, source.c_str()); | 1973 | |
| 878 | if (protocol != nullptr) | 1974 | line.clear(); |
| 1975 | if (!m_file) | ||
| 1976 | return false; | ||
| 1977 | // TODO: Read 1024 chars into buffer. If file position advanced that many | ||
| 1978 | // chars, we didn't hit a newline. Otherwise, if file position is 1 or 2 | ||
| 1979 | // past the number of bytes read, we read (and skipped) a newline sequence. | ||
| 1980 | char buffer[1025]; | ||
| 1981 | if (CAddonBase::m_interface->toKodi->kodi_filesystem->read_file_string( | ||
| 1982 | CAddonBase::m_interface->toKodi->kodiBase, m_file, buffer, sizeof(buffer))) | ||
| 879 | { | 1983 | { |
| 880 | if (std::strlen(protocol)) | 1984 | line = buffer; |
| 881 | strReturn = protocol; | 1985 | return !line.empty(); |
| 882 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, protocol); | ||
| 883 | } | 1986 | } |
| 884 | return strReturn; | 1987 | return false; |
| 885 | } | 1988 | } |
| 886 | //---------------------------------------------------------------------------- | 1989 | //-------------------------------------------------------------------------- |
| 887 | 1990 | ||
| 888 | //============================================================================ | 1991 | //========================================================================== |
| 889 | /// | 1992 | /// @ingroup cpp_kodi_vfs_CFile |
| 890 | /// @ingroup cpp_kodi_vfs | 1993 | /// @brief Write to a file opened in write mode. |
| 891 | /// @brief Return the file name from given complate path string | ||
| 892 | /// | ||
| 893 | /// @param[in] path The complete path include file and directory | ||
| 894 | /// @return Filename from path | ||
| 895 | /// | ||
| 896 | /// | 1994 | /// |
| 897 | /// ------------------------------------------------------------------------ | 1995 | /// @param[in] ptr Pointer to the data to write, converted to a <b>`const void*`</b>. |
| 1996 | /// @param[in] size Size of the data to write. | ||
| 1997 | /// @return number of successfully written bytes if any bytes were written, | ||
| 1998 | /// zero if no bytes were written and no detectable error occur,-1 | ||
| 1999 | /// in case of any explicit error | ||
| 898 | /// | 2000 | /// |
| 899 | /// **Example:** | 2001 | ssize_t Write(const void* ptr, size_t size) |
| 900 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 901 | /// #include <kodi/Filesystem.h> | ||
| 902 | /// ... | ||
| 903 | /// std::string fileName = kodi::vfs::GetFileName("special://temp/kodi.log"); | ||
| 904 | /// fprintf(stderr, "File name is '%s'\n", fileName.c_str()); | ||
| 905 | /// ~~~~~~~~~~~~~ | ||
| 906 | /// | ||
| 907 | inline std::string GetFileName(const std::string& path) | ||
| 908 | { | 2002 | { |
| 909 | /* find the last slash */ | 2003 | using namespace kodi::addon; |
| 910 | const size_t slash = path.find_last_of("/\\"); | 2004 | |
| 911 | return path.substr(slash+1); | 2005 | if (!m_file) |
| 2006 | return -1; | ||
| 2007 | return CAddonBase::m_interface->toKodi->kodi_filesystem->write_file( | ||
| 2008 | CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size); | ||
| 912 | } | 2009 | } |
| 913 | //---------------------------------------------------------------------------- | 2010 | //-------------------------------------------------------------------------- |
| 914 | 2011 | ||
| 915 | //============================================================================ | 2012 | //========================================================================== |
| 916 | /// | 2013 | /// @ingroup cpp_kodi_vfs_CFile |
| 917 | /// @ingroup cpp_kodi_vfs | 2014 | /// @brief Flush buffered data. |
| 918 | /// @brief Return the directory name from given complate path string | ||
| 919 | /// | ||
| 920 | /// @param[in] path The complete path include file and directory | ||
| 921 | /// @return Directory name from path | ||
| 922 | /// | 2015 | /// |
| 2016 | /// If the given stream was open for writing (or if it was open for updating | ||
| 2017 | /// and the last i/o operation was an output operation) any unwritten data | ||
| 2018 | /// in its output buffer is written to the file. | ||
| 923 | /// | 2019 | /// |
| 924 | /// ------------------------------------------------------------------------ | 2020 | /// The stream remains open after this call. |
| 925 | /// | 2021 | /// |
| 926 | /// **Example:** | 2022 | /// When a file is closed, either because of a call to close or because the |
| 927 | /// ~~~~~~~~~~~~~{.cpp} | 2023 | /// class is destructed, all the buffers associated with it are |
| 928 | /// #include <kodi/Filesystem.h> | 2024 | /// automatically flushed. |
| 929 | /// ... | ||
| 930 | /// std::string dirName = kodi::vfs::GetDirectoryName("special://temp/kodi.log"); | ||
| 931 | /// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str()); | ||
| 932 | /// ~~~~~~~~~~~~~ | ||
| 933 | /// | 2025 | /// |
| 934 | inline std::string GetDirectoryName(const std::string& path) | 2026 | void Flush() |
| 935 | { | 2027 | { |
| 936 | // Will from a full filename return the directory the file resides in. | 2028 | using namespace kodi::addon; |
| 937 | // Keeps the final slash at end and possible |option=foo options. | ||
| 938 | 2029 | ||
| 939 | size_t iPosSlash = path.find_last_of("/\\"); | 2030 | if (!m_file) |
| 940 | if (iPosSlash == std::string::npos) | 2031 | return; |
| 941 | return ""; // No slash, so no path (ignore any options) | 2032 | CAddonBase::m_interface->toKodi->kodi_filesystem->flush_file( |
| 942 | 2033 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | |
| 943 | size_t iPosBar = path.rfind('|'); | ||
| 944 | if (iPosBar == std::string::npos) | ||
| 945 | return path.substr(0, iPosSlash + 1); // Only path | ||
| 946 | |||
| 947 | return path.substr(0, iPosSlash + 1) + path.substr(iPosBar); // Path + options | ||
| 948 | } | 2034 | } |
| 949 | //---------------------------------------------------------------------------- | 2035 | //-------------------------------------------------------------------------- |
| 950 | 2036 | ||
| 951 | 2037 | //========================================================================== | |
| 952 | //============================================================================ | 2038 | /// @ingroup cpp_kodi_vfs_CFile |
| 953 | /// | 2039 | /// @brief Set the file's current position. |
| 954 | /// @ingroup cpp_kodi_vfs | ||
| 955 | /// @brief Remove the slash on given path name | ||
| 956 | /// | 2040 | /// |
| 957 | /// @param[in,out] path The complete path | 2041 | /// The whence argument is optional and defaults to SEEK_SET (0) |
| 958 | /// | 2042 | /// |
| 2043 | /// @param[in] position the position that you want to seek to | ||
| 2044 | /// @param[in] whence [optional] offset relative to You can set the value of | ||
| 2045 | /// whence to one of three things: | ||
| 2046 | /// | Value | int | Description | | ||
| 2047 | /// |:--------:|:---:|:----------------------------------------------------| | ||
| 2048 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 2049 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 2050 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 959 | /// | 2051 | /// |
| 960 | /// ------------------------------------------------------------------------ | 2052 | /// @return Returns the resulting offset location as measured in bytes from |
| 2053 | /// the beginning of the file. On error, the value -1 is returned. | ||
| 961 | /// | 2054 | /// |
| 962 | /// **Example:** | 2055 | int64_t Seek(int64_t position, int whence = SEEK_SET) |
| 963 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 964 | /// #include <kodi/Filesystem.h> | ||
| 965 | /// ... | ||
| 966 | /// std::string dirName = "special://temp/"; | ||
| 967 | /// kodi::vfs::RemoveSlashAtEnd(dirName); | ||
| 968 | /// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str()); | ||
| 969 | /// ~~~~~~~~~~~~~ | ||
| 970 | /// | ||
| 971 | inline void RemoveSlashAtEnd(std::string& path) | ||
| 972 | { | 2056 | { |
| 973 | if (!path.empty()) | 2057 | using namespace kodi::addon; |
| 974 | { | 2058 | |
| 975 | char last = path[path.size() - 1]; | 2059 | if (!m_file) |
| 976 | if (last == '/' || last == '\\') | 2060 | return -1; |
| 977 | path.erase(path.size() - 1); | 2061 | return CAddonBase::m_interface->toKodi->kodi_filesystem->seek_file( |
| 978 | } | 2062 | CAddonBase::m_interface->toKodi->kodiBase, m_file, position, whence); |
| 979 | } | 2063 | } |
| 980 | //---------------------------------------------------------------------------- | 2064 | //-------------------------------------------------------------------------- |
| 981 | 2065 | ||
| 982 | //============================================================================ | 2066 | //========================================================================== |
| 2067 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2068 | /// @brief Truncate a file to the requested size. | ||
| 983 | /// | 2069 | /// |
| 984 | /// @ingroup cpp_kodi_vfs | 2070 | /// @param[in] size The new max size. |
| 985 | /// @brief Return a size aligned to the chunk size at least as large as the chunk size. | 2071 | /// @return New size? On error, the value -1 is returned. |
| 986 | /// | 2072 | /// |
| 987 | /// @param[in] chunk The chunk size | 2073 | int Truncate(int64_t size) |
| 988 | /// @param[in] minimum The minimum size (or maybe the minimum number of chunks?) | ||
| 989 | /// @return The aligned size | ||
| 990 | /// | ||
| 991 | inline unsigned int GetChunkSize(unsigned int chunk, unsigned int minimum) | ||
| 992 | { | 2074 | { |
| 993 | if (chunk) | 2075 | using namespace kodi::addon; |
| 994 | return chunk * ((minimum + chunk - 1) / chunk); | 2076 | |
| 995 | else | 2077 | if (!m_file) |
| 996 | return minimum; | 2078 | return -1; |
| 2079 | return CAddonBase::m_interface->toKodi->kodi_filesystem->truncate_file( | ||
| 2080 | CAddonBase::m_interface->toKodi->kodiBase, m_file, size); | ||
| 997 | } | 2081 | } |
| 998 | //---------------------------------------------------------------------------- | 2082 | //-------------------------------------------------------------------------- |
| 999 | 2083 | ||
| 1000 | //============================================================================ | 2084 | //========================================================================== |
| 1001 | /// | 2085 | /// @ingroup cpp_kodi_vfs_CFile |
| 1002 | /// @ingroup cpp_kodi_vfs | 2086 | /// @brief The current offset in an open file. |
| 1003 | /// @brief Check if a file exists. | ||
| 1004 | /// | 2087 | /// |
| 1005 | /// @param[in] filename The filename to check. | 2088 | /// @return The requested offset. On error, the value -1 is returned. |
| 1006 | /// @param[in] usecache Check in file cache. | ||
| 1007 | /// @return true if the file exists false otherwise. | ||
| 1008 | /// | 2089 | /// |
| 2090 | int64_t GetPosition() const | ||
| 2091 | { | ||
| 2092 | using namespace kodi::addon; | ||
| 2093 | |||
| 2094 | if (!m_file) | ||
| 2095 | return -1; | ||
| 2096 | return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position( | ||
| 2097 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 2098 | } | ||
| 2099 | //-------------------------------------------------------------------------- | ||
| 2100 | |||
| 2101 | //========================================================================== | ||
| 2102 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2103 | /// @brief Get the file size of an open file. | ||
| 1009 | /// | 2104 | /// |
| 1010 | /// ------------------------------------------------------------------------- | 2105 | /// @return The requested size. On error, the value -1 is returned. |
| 1011 | /// | ||
| 1012 | /// **Example:** | ||
| 1013 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1014 | /// #include <kodi/Filesystem.h> | ||
| 1015 | /// ... | ||
| 1016 | /// bool exists = kodi::vfs::FileExists("special://temp/kodi.log"); | ||
| 1017 | /// fprintf(stderr, "Log file should be always present, is it present? %s\n", exists ? "yes" : "no"); | ||
| 1018 | /// ~~~~~~~~~~~~~ | ||
| 1019 | /// | 2106 | /// |
| 1020 | inline bool FileExists(const std::string& filename, bool usecache = false) | 2107 | int64_t GetLength() const |
| 1021 | { | 2108 | { |
| 1022 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->file_exists(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache); | 2109 | using namespace kodi::addon; |
| 2110 | |||
| 2111 | if (!m_file) | ||
| 2112 | return -1; | ||
| 2113 | return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length( | ||
| 2114 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1023 | } | 2115 | } |
| 1024 | //---------------------------------------------------------------------------- | 2116 | //-------------------------------------------------------------------------- |
| 1025 | 2117 | ||
| 1026 | //============================================================================ | 2118 | //========================================================================== |
| 2119 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2120 | /// @brief Checks the file access is on end position. | ||
| 2121 | /// | ||
| 2122 | /// @return If you've reached the end of the file, AtEnd() returns true. | ||
| 1027 | /// | 2123 | /// |
| 1028 | /// @ingroup cpp_kodi_vfs | 2124 | bool AtEnd() const |
| 1029 | /// @brief Get file status. | ||
| 1030 | /// | ||
| 1031 | /// These function return information about a file. Execute (search) | ||
| 1032 | /// permission is required on all of the directories in path that | ||
| 1033 | /// lead to the file. | ||
| 1034 | /// | ||
| 1035 | /// The call return a stat structure, which contains the on \ref STAT_STRUCTURE | ||
| 1036 | /// defined values. | ||
| 1037 | /// | ||
| 1038 | /// @warning Not all of the OS file systems implement all of the time fields. | ||
| 1039 | /// | ||
| 1040 | /// @param[in] filename The filename to read the status from. | ||
| 1041 | /// @param[out] buffer The file status is written into this buffer. | ||
| 1042 | /// @return On success, tru is returned. On error, fale is returned | ||
| 1043 | /// | ||
| 1044 | /// | ||
| 1045 | /// ------------------------------------------------------------------------- | ||
| 1046 | /// | ||
| 1047 | /// **Example:** | ||
| 1048 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1049 | /// #include <kodi/Filesystem.h> | ||
| 1050 | /// ... | ||
| 1051 | /// STAT_STRUCTURE statFile; | ||
| 1052 | /// int ret = kodi::vfs::StatFile("special://temp/kodi.log", statFile); | ||
| 1053 | /// fprintf(stderr, "deviceId (ID of device containing file) = %u\n" | ||
| 1054 | /// "size (total size, in bytes) = %lu\n" | ||
| 1055 | /// "accessTime (time of last access) = %lu\n" | ||
| 1056 | /// "modificationTime (time of last modification) = %lu\n" | ||
| 1057 | /// "statusTime (time of last status change) = %lu\n" | ||
| 1058 | /// "isDirectory (The stat url is a directory) = %s\n" | ||
| 1059 | /// "isSymLink (The stat url is a symbolic link) = %s\n" | ||
| 1060 | /// "Return value = %i\n", | ||
| 1061 | /// statFile.deviceId, | ||
| 1062 | /// statFile.size, | ||
| 1063 | /// statFile.accessTime, | ||
| 1064 | /// statFile.modificationTime, | ||
| 1065 | /// statFile.statusTime, | ||
| 1066 | /// statFile.isDirectory ? "true" : "false", | ||
| 1067 | /// statFile.isSymLink ? "true" : "false", | ||
| 1068 | /// ret); | ||
| 1069 | /// ~~~~~~~~~~~~~ | ||
| 1070 | /// | ||
| 1071 | inline bool StatFile(const std::string& filename, STAT_STRUCTURE& buffer) | ||
| 1072 | { | 2125 | { |
| 1073 | struct __stat64 frontendBuffer = { }; | 2126 | using namespace kodi::addon; |
| 1074 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->stat_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), &frontendBuffer)) | 2127 | |
| 1075 | { | 2128 | if (!m_file) |
| 1076 | buffer.deviceId = frontendBuffer.st_dev; | ||
| 1077 | buffer.size = frontendBuffer.st_size; | ||
| 1078 | #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) | ||
| 1079 | buffer.accessTime = frontendBuffer.st_atimespec; | ||
| 1080 | buffer.modificationTime = frontendBuffer.st_mtimespec; | ||
| 1081 | buffer.statusTime = frontendBuffer.st_ctimespec; | ||
| 1082 | #elif defined(TARGET_WINDOWS) | ||
| 1083 | buffer.accessTime = frontendBuffer.st_atime; | ||
| 1084 | buffer.modificationTime = frontendBuffer.st_mtime; | ||
| 1085 | buffer.statusTime = frontendBuffer.st_ctime; | ||
| 1086 | #elif defined(TARGET_ANDROID) | ||
| 1087 | buffer.accessTime.tv_sec = frontendBuffer.st_atime; | ||
| 1088 | buffer.accessTime.tv_nsec = frontendBuffer.st_atime_nsec; | ||
| 1089 | buffer.modificationTime.tv_sec = frontendBuffer.st_mtime; | ||
| 1090 | buffer.modificationTime.tv_nsec = frontendBuffer.st_mtime_nsec; | ||
| 1091 | buffer.statusTime.tv_sec = frontendBuffer.st_ctime; | ||
| 1092 | buffer.statusTime.tv_nsec = frontendBuffer.st_ctime_nsec; | ||
| 1093 | #else | ||
| 1094 | buffer.accessTime = frontendBuffer.st_atim; | ||
| 1095 | buffer.modificationTime = frontendBuffer.st_mtim; | ||
| 1096 | buffer.statusTime = frontendBuffer.st_ctim; | ||
| 1097 | #endif | ||
| 1098 | buffer.isDirectory = S_ISDIR(frontendBuffer.st_mode); | ||
| 1099 | buffer.isSymLink = S_ISLNK(frontendBuffer.st_mode); | ||
| 1100 | return true; | 2129 | return true; |
| 1101 | } | 2130 | int64_t length = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length( |
| 1102 | return false; | 2131 | CAddonBase::m_interface->toKodi->kodiBase, m_file); |
| 2132 | int64_t position = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position( | ||
| 2133 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 2134 | return position >= length; | ||
| 1103 | } | 2135 | } |
| 1104 | //---------------------------------------------------------------------------- | 2136 | //-------------------------------------------------------------------------- |
| 1105 | 2137 | ||
| 1106 | //============================================================================ | 2138 | //========================================================================== |
| 2139 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2140 | /// @brief Get the chunk size for an open file. | ||
| 1107 | /// | 2141 | /// |
| 1108 | /// @ingroup cpp_kodi_vfs | 2142 | /// @return The requested size. On error, the value -1 is returned. |
| 1109 | /// @brief Deletes a file. | 2143 | /// |
| 1110 | /// | 2144 | int GetChunkSize() const |
| 1111 | /// @param[in] filename The filename to delete. | ||
| 1112 | /// @return The file was successfully deleted. | ||
| 1113 | /// | ||
| 1114 | /// | ||
| 1115 | /// ------------------------------------------------------------------------- | ||
| 1116 | /// | ||
| 1117 | /// **Example:** | ||
| 1118 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1119 | /// #include <kodi/Filesystem.h> | ||
| 1120 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 1121 | /// #include <kodi/gui/DialogOK.h> | ||
| 1122 | /// ... | ||
| 1123 | /// std::string filename; | ||
| 1124 | /// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "", | ||
| 1125 | /// "Test File selection and delete of them!", | ||
| 1126 | /// filename)) | ||
| 1127 | /// { | ||
| 1128 | /// bool successed = kodi::vfs::DeleteFile(filename); | ||
| 1129 | /// if (!successed) | ||
| 1130 | /// kodi::gui::DialogOK::ShowAndGetInput("Error", "Delete of File", filename, "failed!"); | ||
| 1131 | /// else | ||
| 1132 | /// kodi::gui::DialogOK::ShowAndGetInput("Information", "Delete of File", filename, "successfull done."); | ||
| 1133 | /// } | ||
| 1134 | /// ~~~~~~~~~~~~~ | ||
| 1135 | /// | ||
| 1136 | inline bool DeleteFile(const std::string& filename) | ||
| 1137 | { | 2145 | { |
| 1138 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->delete_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str()); | 2146 | using namespace kodi::addon; |
| 2147 | |||
| 2148 | if (!m_file) | ||
| 2149 | return -1; | ||
| 2150 | return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size( | ||
| 2151 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1139 | } | 2152 | } |
| 1140 | //---------------------------------------------------------------------------- | 2153 | //-------------------------------------------------------------------------- |
| 1141 | 2154 | ||
| 1142 | //============================================================================ | 2155 | //========================================================================== |
| 1143 | /// | 2156 | /// @ingroup cpp_kodi_vfs_CFile |
| 1144 | /// @ingroup cpp_kodi_vfs | 2157 | /// @brief To check seek possible on current stream by file. |
| 1145 | /// @brief Rename a file name | ||
| 1146 | /// | ||
| 1147 | /// @param[in] filename The filename to copy. | ||
| 1148 | /// @param[in] newFileName The new filename | ||
| 1149 | /// @return true if successfully renamed | ||
| 1150 | /// | 2158 | /// |
| 2159 | /// @return true if seek possible, false if not | ||
| 1151 | /// | 2160 | /// |
| 1152 | inline bool RenameFile(const std::string& filename, const std::string& newFileName) | 2161 | bool IoControlGetSeekPossible() const |
| 1153 | { | 2162 | { |
| 1154 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->rename_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str()); | 2163 | using namespace kodi::addon; |
| 2164 | |||
| 2165 | if (!m_file) | ||
| 2166 | return false; | ||
| 2167 | return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_get_seek_possible( | ||
| 2168 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1155 | } | 2169 | } |
| 1156 | //---------------------------------------------------------------------------- | 2170 | //-------------------------------------------------------------------------- |
| 1157 | 2171 | ||
| 1158 | //============================================================================ | 2172 | //========================================================================== |
| 2173 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2174 | /// @brief To check a running stream on file for state of his cache. | ||
| 1159 | /// | 2175 | /// |
| 1160 | /// @ingroup cpp_kodi_vfs | 2176 | /// @param[in] status Information about current cache status |
| 1161 | /// @brief Copy a file from source to destination | 2177 | /// @return true if successfull done, false otherwise |
| 1162 | /// | 2178 | /// |
| 1163 | /// @param[in] filename The filename to copy. | ||
| 1164 | /// @param[in] destination The destination to copy file to | ||
| 1165 | /// @return true if successfully copied | ||
| 1166 | /// | 2179 | /// |
| 2180 | /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help | ||
| 1167 | /// | 2181 | /// |
| 1168 | inline bool CopyFile(const std::string& filename, const std::string& destination) | 2182 | bool IoControlGetCacheStatus(CacheStatus& status) const |
| 1169 | { | 2183 | { |
| 1170 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->copy_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str()); | 2184 | using namespace kodi::addon; |
| 2185 | |||
| 2186 | if (!m_file) | ||
| 2187 | return false; | ||
| 2188 | return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_get_cache_status( | ||
| 2189 | CAddonBase::m_interface->toKodi->kodiBase, m_file, status); | ||
| 1171 | } | 2190 | } |
| 1172 | //---------------------------------------------------------------------------- | 2191 | //-------------------------------------------------------------------------- |
| 1173 | 2192 | ||
| 1174 | //============================================================================ | 2193 | //========================================================================== |
| 1175 | /// | 2194 | /// @ingroup cpp_kodi_vfs_CFile |
| 1176 | /// \defgroup cpp_kodi_vfs_CFile class CFile | 2195 | /// @brief Unsigned int with speed limit for caching in bytes per second. |
| 1177 | /// \ingroup cpp_kodi_vfs | ||
| 1178 | /// | ||
| 1179 | /// @brief **Virtual file server control** | ||
| 1180 | /// | ||
| 1181 | /// CFile is the class used for handling Files in Kodi. This class can be used | ||
| 1182 | /// for creating, reading, writing and modifying files. It directly provides unbuffered, binary disk input/output services | ||
| 1183 | /// | ||
| 1184 | /// It has the header \ref Filesystem.h "#include <kodi/Filesystem.h>" be included | ||
| 1185 | /// to enjoy it. | ||
| 1186 | /// | ||
| 1187 | /// | ||
| 1188 | /// ------------------------------------------------------------------------ | ||
| 1189 | /// | 2196 | /// |
| 1190 | /// **Example:** | 2197 | /// @param[in] rate Cache rate size to use |
| 1191 | /// ~~~~~~~~~~~~~{.cpp} | 2198 | /// @return true if successfull done, false otherwise |
| 1192 | /// #include <kodi/Filesystem.h> | ||
| 1193 | /// | 2199 | /// |
| 1194 | /// ... | 2200 | bool IoControlSetCacheRate(unsigned int rate) |
| 1195 | /// | 2201 | { |
| 1196 | /// /* Create the needed file handle class */ | 2202 | using namespace kodi::addon; |
| 1197 | /// kodi::vfs::CFile myFile(); | 2203 | |
| 1198 | /// | 2204 | if (!m_file) |
| 1199 | /// /* In this example we use the user path for the add-on */ | 2205 | return false; |
| 1200 | /// std::string file = kodi::GetUserPath() + "/myFile.txt"; | 2206 | return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_set_cache_rate( |
| 1201 | /// | 2207 | CAddonBase::m_interface->toKodi->kodiBase, m_file, rate); |
| 1202 | /// /* Now create and open the file or overwrite if present */ | 2208 | } |
| 1203 | /// myFile.OpenFileForWrite(file, true); | 2209 | //-------------------------------------------------------------------------- |
| 1204 | /// | 2210 | |
| 1205 | /// const char* str = "I love Kodi!"; | 2211 | //========================================================================== |
| 2212 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2213 | /// @brief Enable/disable retry within the protocol handler (if supported). | ||
| 1206 | /// | 2214 | /// |
| 1207 | /// /* write string */ | 2215 | /// @param[in] retry To set the retry, true for use, false for not |
| 1208 | /// myFile.Write(str, sizeof(str)); | 2216 | /// @return true if successfull done, false otherwise |
| 1209 | /// | 2217 | /// |
| 1210 | /// /* On this way the Close() is not needed to call, becomes done from destructor */ | 2218 | bool IoControlSetRetry(bool retry) |
| 2219 | { | ||
| 2220 | using namespace kodi::addon; | ||
| 2221 | |||
| 2222 | if (!m_file) | ||
| 2223 | return false; | ||
| 2224 | return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_set_retry( | ||
| 2225 | CAddonBase::m_interface->toKodi->kodiBase, m_file, retry); | ||
| 2226 | } | ||
| 2227 | //-------------------------------------------------------------------------- | ||
| 2228 | |||
| 2229 | //========================================================================== | ||
| 2230 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 2231 | /// @brief Retrieve a file property. | ||
| 1211 | /// | 2232 | /// |
| 1212 | /// ~~~~~~~~~~~~~ | 2233 | /// @param[in] type The type of the file property to retrieve the value for |
| 2234 | /// @param[in] name The name of a named property value (e.g. Header) | ||
| 2235 | /// @return value of requested property, empty on failure / non-existance | ||
| 1213 | /// | 2236 | /// |
| 1214 | //@{ | 2237 | const std::string GetPropertyValue(FilePropertyTypes type, const std::string& name) const |
| 1215 | class CFile | ||
| 1216 | { | 2238 | { |
| 1217 | public: | 2239 | using namespace kodi::addon; |
| 1218 | //========================================================================== | ||
| 1219 | /// | ||
| 1220 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1221 | /// @brief Construct a new, unopened file | ||
| 1222 | /// | ||
| 1223 | CFile() = default; | ||
| 1224 | //-------------------------------------------------------------------------- | ||
| 1225 | |||
| 1226 | //========================================================================== | ||
| 1227 | /// | ||
| 1228 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1229 | /// @brief Close() is called from the destructor, so explicitly closing the | ||
| 1230 | /// file isn't required | ||
| 1231 | /// | ||
| 1232 | virtual ~CFile() { Close(); } | ||
| 1233 | //-------------------------------------------------------------------------- | ||
| 1234 | |||
| 1235 | //========================================================================== | ||
| 1236 | /// | ||
| 1237 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1238 | /// @brief Open the file with filename via Kodi's \ref cpp_kodi_vfs_CFile | ||
| 1239 | /// "CFile". Needs to be closed by calling Close() when done. | ||
| 1240 | /// | ||
| 1241 | /// @param[in] filename The filename to open. | ||
| 1242 | /// @param[in] flags [opt] The flags to pass, see \ref OpenFileFlags | ||
| 1243 | /// @return True on success or false on failure | ||
| 1244 | /// | ||
| 1245 | bool OpenFile(const std::string& filename, unsigned int flags = 0) | ||
| 1246 | { | ||
| 1247 | Close(); | ||
| 1248 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->open_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), flags); | ||
| 1249 | return m_file != nullptr; | ||
| 1250 | } | ||
| 1251 | //-------------------------------------------------------------------------- | ||
| 1252 | |||
| 1253 | //========================================================================== | ||
| 1254 | /// | ||
| 1255 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1256 | /// @brief Open the file with filename via Kodi's \ref cpp_kodi_vfs_CFile | ||
| 1257 | /// "CFile" in write mode. Needs to be closed by calling Close() when | ||
| 1258 | /// done. | ||
| 1259 | /// | ||
| 1260 | /// @note Related folders becomes created if not present. | ||
| 1261 | /// | ||
| 1262 | /// @param[in] filename The filename to open. | ||
| 1263 | /// @param[in] overwrite True to overwrite, false otherwise. | ||
| 1264 | /// @return True on success or false on failure | ||
| 1265 | /// | ||
| 1266 | bool OpenFileForWrite(const std::string& filename, bool overwrite = false) | ||
| 1267 | { | ||
| 1268 | Close(); | ||
| 1269 | 2240 | ||
| 1270 | // Try to open the file. If it fails, check if we need to create the directory first | 2241 | if (!m_file) |
| 1271 | // This way we avoid checking if the directory exists every time | ||
| 1272 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite); | ||
| 1273 | if (!m_file) | ||
| 1274 | { | ||
| 1275 | std::string cacheDirectory = kodi::vfs::GetDirectoryName(filename); | ||
| 1276 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) || | ||
| 1277 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str())) | ||
| 1278 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite); | ||
| 1279 | } | ||
| 1280 | return m_file != nullptr; | ||
| 1281 | } | ||
| 1282 | //-------------------------------------------------------------------------- | ||
| 1283 | |||
| 1284 | //========================================================================== | ||
| 1285 | /// | ||
| 1286 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1287 | /// @brief Create a Curl representation | ||
| 1288 | /// | ||
| 1289 | /// @param[in] url the URL of the Type. | ||
| 1290 | /// @return True on success or false on failure | ||
| 1291 | /// | ||
| 1292 | bool CURLCreate(const std::string& url) | ||
| 1293 | { | ||
| 1294 | m_file = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->curl_create(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, url.c_str()); | ||
| 1295 | return m_file != nullptr; | ||
| 1296 | } | ||
| 1297 | //-------------------------------------------------------------------------- | ||
| 1298 | |||
| 1299 | //========================================================================== | ||
| 1300 | /// | ||
| 1301 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1302 | /// @brief Add options to the curl file created with CURLCreate | ||
| 1303 | /// | ||
| 1304 | /// @param[in] type option type to set, see \ref CURLOptiontype | ||
| 1305 | /// @param[in] name name of the option | ||
| 1306 | /// @param[in] value value of the option | ||
| 1307 | /// @return True on success or false on failure | ||
| 1308 | /// | ||
| 1309 | bool CURLAddOption(CURLOptiontype type, const std::string& name, const std::string& value) | ||
| 1310 | { | ||
| 1311 | if (!m_file) | ||
| 1312 | { | ||
| 1313 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!"); | ||
| 1314 | return false; | ||
| 1315 | } | ||
| 1316 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->curl_add_option(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str()); | ||
| 1317 | } | ||
| 1318 | //-------------------------------------------------------------------------- | ||
| 1319 | |||
| 1320 | //========================================================================== | ||
| 1321 | /// | ||
| 1322 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1323 | /// @brief Open the curl file created with CURLCreate | ||
| 1324 | /// | ||
| 1325 | /// @param[in] flags [opt] The flags to pass, see \ref OpenFileFlags | ||
| 1326 | /// @return True on success or false on failure | ||
| 1327 | /// | ||
| 1328 | bool CURLOpen(unsigned int flags = 0) | ||
| 1329 | { | ||
| 1330 | if (!m_file) | ||
| 1331 | { | ||
| 1332 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!"); | ||
| 1333 | return false; | ||
| 1334 | } | ||
| 1335 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->curl_open(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, flags); | ||
| 1336 | } | ||
| 1337 | //-------------------------------------------------------------------------- | ||
| 1338 | |||
| 1339 | //========================================================================== | ||
| 1340 | /// | ||
| 1341 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1342 | /// @brief Read from an open file. | ||
| 1343 | /// | ||
| 1344 | /// @param[in] ptr The buffer to store the data in. | ||
| 1345 | /// @param[in] size The size of the buffer. | ||
| 1346 | /// @return number of successfully read bytes if any bytes | ||
| 1347 | /// were read and stored in buffer, zero if no bytes | ||
| 1348 | /// are available to read (end of file was reached) | ||
| 1349 | /// or undetectable error occur, -1 in case of any | ||
| 1350 | /// explicit error | ||
| 1351 | /// | ||
| 1352 | ssize_t Read(void* ptr, size_t size) | ||
| 1353 | { | ||
| 1354 | if (!m_file) | ||
| 1355 | return -1; | ||
| 1356 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->read_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size); | ||
| 1357 | } | ||
| 1358 | //-------------------------------------------------------------------------- | ||
| 1359 | |||
| 1360 | //========================================================================== | ||
| 1361 | /// | ||
| 1362 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1363 | /// @brief Read a string from an open file. | ||
| 1364 | /// | ||
| 1365 | /// @param[out] line The buffer to store the data in. | ||
| 1366 | /// @return True when a line was read, false otherwise. | ||
| 1367 | /// | ||
| 1368 | bool ReadLine(std::string &line) | ||
| 1369 | { | ||
| 1370 | line.clear(); | ||
| 1371 | if (!m_file) | ||
| 1372 | return false; | ||
| 1373 | // TODO: Read 1024 chars into buffer. If file position advanced that many | ||
| 1374 | // chars, we didn't hit a newline. Otherwise, if file position is 1 or 2 | ||
| 1375 | // past the number of bytes read, we read (and skipped) a newline sequence. | ||
| 1376 | char buffer[1025]; | ||
| 1377 | if (::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->read_file_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, buffer, sizeof(buffer))) | ||
| 1378 | { | ||
| 1379 | line = buffer; | ||
| 1380 | return !line.empty(); | ||
| 1381 | } | ||
| 1382 | return false; | ||
| 1383 | } | ||
| 1384 | //-------------------------------------------------------------------------- | ||
| 1385 | |||
| 1386 | //========================================================================== | ||
| 1387 | /// | ||
| 1388 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1389 | /// @brief Write to a file opened in write mode. | ||
| 1390 | /// | ||
| 1391 | /// @param[in] ptr Pointer to the data to write, converted to a | ||
| 1392 | /// const void*. | ||
| 1393 | /// @param[in] size Size of the data to write. | ||
| 1394 | /// @return number of successfully written bytes if any | ||
| 1395 | /// bytes were written, zero if no bytes were | ||
| 1396 | /// written and no detectable error occur,-1 in case | ||
| 1397 | /// of any explicit error | ||
| 1398 | /// | ||
| 1399 | ssize_t Write(const void* ptr, size_t size) | ||
| 1400 | { | ||
| 1401 | if (!m_file) | ||
| 1402 | return -1; | ||
| 1403 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->write_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size); | ||
| 1404 | } | ||
| 1405 | //-------------------------------------------------------------------------- | ||
| 1406 | |||
| 1407 | //========================================================================== | ||
| 1408 | /// | ||
| 1409 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1410 | /// @brief Flush buffered data. | ||
| 1411 | /// | ||
| 1412 | /// If the given stream was open for writing (or if it was open for updating | ||
| 1413 | /// and the last i/o operation was an output operation) any unwritten data | ||
| 1414 | /// in its output buffer is written to the file. | ||
| 1415 | /// | ||
| 1416 | /// The stream remains open after this call. | ||
| 1417 | /// | ||
| 1418 | /// When a file is closed, either because of a call to close or because the | ||
| 1419 | /// class is destructed, all the buffers associated with it are | ||
| 1420 | /// automatically flushed. | ||
| 1421 | /// | ||
| 1422 | void Flush() | ||
| 1423 | { | ||
| 1424 | if (!m_file) | ||
| 1425 | return; | ||
| 1426 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->flush_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1427 | } | ||
| 1428 | //-------------------------------------------------------------------------- | ||
| 1429 | |||
| 1430 | //========================================================================== | ||
| 1431 | /// | ||
| 1432 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1433 | /// @brief Set the file's current position. | ||
| 1434 | /// | ||
| 1435 | /// The whence argument is optional and defaults to SEEK_SET (0) | ||
| 1436 | /// | ||
| 1437 | /// @param[in] position the position that you want to seek to | ||
| 1438 | /// @param[in] whence [optional] offset relative to | ||
| 1439 | /// You can set the value of whence to one. | ||
| 1440 | /// of three things: | ||
| 1441 | /// | Value | int | Description | | ||
| 1442 | /// |:--------:|:---:|:----------------------------------------------------| | ||
| 1443 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 1444 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 1445 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 1446 | /// | ||
| 1447 | /// @return Returns the resulting offset location as | ||
| 1448 | /// measured in bytes from the beginning of | ||
| 1449 | /// the file. On error, the value -1 is | ||
| 1450 | /// returned. | ||
| 1451 | /// | ||
| 1452 | int64_t Seek(int64_t position, int whence = SEEK_SET) | ||
| 1453 | { | ||
| 1454 | if (!m_file) | ||
| 1455 | return -1; | ||
| 1456 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->seek_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, position, whence); | ||
| 1457 | } | ||
| 1458 | //-------------------------------------------------------------------------- | ||
| 1459 | |||
| 1460 | //========================================================================== | ||
| 1461 | /// | ||
| 1462 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1463 | /// @brief Truncate a file to the requested size. | ||
| 1464 | /// | ||
| 1465 | /// @param[in] size The new max size. | ||
| 1466 | /// @return New size? On error, the value -1 is | ||
| 1467 | /// returned. | ||
| 1468 | /// | ||
| 1469 | int Truncate(int64_t size) | ||
| 1470 | { | ||
| 1471 | if (!m_file) | ||
| 1472 | return -1; | ||
| 1473 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->truncate_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, size); | ||
| 1474 | } | ||
| 1475 | //-------------------------------------------------------------------------- | ||
| 1476 | |||
| 1477 | //========================================================================== | ||
| 1478 | /// | ||
| 1479 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1480 | /// @brief The current offset in an open file. | ||
| 1481 | /// | ||
| 1482 | /// @return The requested offset. On error, the value -1 is | ||
| 1483 | /// returned. | ||
| 1484 | /// | ||
| 1485 | int64_t GetPosition() | ||
| 1486 | { | 2242 | { |
| 1487 | if (!m_file) | 2243 | kodi::Log(ADDON_LOG_ERROR, |
| 1488 | return -1; | 2244 | "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!"); |
| 1489 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | 2245 | return ""; |
| 1490 | } | 2246 | } |
| 1491 | //-------------------------------------------------------------------------- | 2247 | std::vector<std::string> values = GetPropertyValues(type, name); |
| 1492 | 2248 | if (values.empty()) | |
| 1493 | //========================================================================== | ||
| 1494 | /// | ||
| 1495 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1496 | /// @brief Get the file size of an open file. | ||
| 1497 | /// | ||
| 1498 | /// @return The requested size. On error, the value -1 is | ||
| 1499 | /// returned. | ||
| 1500 | /// | ||
| 1501 | int64_t GetLength() | ||
| 1502 | { | 2249 | { |
| 1503 | if (!m_file) | 2250 | return ""; |
| 1504 | return -1; | ||
| 1505 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1506 | } | 2251 | } |
| 1507 | //-------------------------------------------------------------------------- | 2252 | return values[0]; |
| 1508 | 2253 | } | |
| 1509 | //========================================================================== | 2254 | //-------------------------------------------------------------------------- |
| 1510 | /// | 2255 | |
| 1511 | /// @ingroup cpp_kodi_vfs_CFile | 2256 | //========================================================================== |
| 1512 | /// @brief Checks the file access is on end position. | 2257 | /// @ingroup cpp_kodi_vfs_CFile |
| 1513 | /// | 2258 | /// @brief Retrieve file property values. |
| 1514 | /// @return If you've reached the end of the file, AtEnd() returns true. | 2259 | /// |
| 1515 | /// | 2260 | /// @param[in] type The type of the file property values to retrieve the value for |
| 1516 | bool AtEnd() | 2261 | /// @param[in] name The name of the named property (e.g. Header) |
| 1517 | { | 2262 | /// @return values of requested property, empty vector on failure / non-existance |
| 1518 | if (!m_file) | 2263 | /// |
| 1519 | return true; | 2264 | const std::vector<std::string> GetPropertyValues(FilePropertyTypes type, |
| 1520 | int64_t length = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | 2265 | const std::string& name) const |
| 1521 | int64_t position = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | 2266 | { |
| 1522 | return position >= length; | 2267 | using namespace kodi::addon; |
| 1523 | } | 2268 | |
| 1524 | //-------------------------------------------------------------------------- | 2269 | if (!m_file) |
| 1525 | |||
| 1526 | //========================================================================== | ||
| 1527 | /// | ||
| 1528 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1529 | /// @brief Close an open file. | ||
| 1530 | /// | ||
| 1531 | void Close() | ||
| 1532 | { | ||
| 1533 | if (!m_file) | ||
| 1534 | return; | ||
| 1535 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->close_file(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1536 | m_file = nullptr; | ||
| 1537 | } | ||
| 1538 | //-------------------------------------------------------------------------- | ||
| 1539 | |||
| 1540 | //========================================================================== | ||
| 1541 | /// | ||
| 1542 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1543 | /// @brief Get the chunk size for an open file. | ||
| 1544 | /// | ||
| 1545 | /// @return The requested size. On error, the value -1 is | ||
| 1546 | /// returned. | ||
| 1547 | /// | ||
| 1548 | int GetChunkSize() | ||
| 1549 | { | ||
| 1550 | if (!m_file) | ||
| 1551 | return -1; | ||
| 1552 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1553 | } | ||
| 1554 | //-------------------------------------------------------------------------- | ||
| 1555 | |||
| 1556 | //========================================================================== | ||
| 1557 | /// | ||
| 1558 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1559 | /// @brief retrieve a file property | ||
| 1560 | /// | ||
| 1561 | /// @param[in] type The type of the file property to retrieve the value for | ||
| 1562 | /// @param[in] name The name of a named property value (e.g. Header) | ||
| 1563 | /// @return value of requested property, empty on failure / non-existance | ||
| 1564 | /// | ||
| 1565 | const std::string GetPropertyValue(FilePropertyTypes type, const std::string &name) const | ||
| 1566 | { | 2270 | { |
| 1567 | if (!m_file) | 2271 | kodi::Log(ADDON_LOG_ERROR, |
| 1568 | { | 2272 | "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!"); |
| 1569 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!"); | 2273 | return std::vector<std::string>(); |
| 1570 | return ""; | ||
| 1571 | } | ||
| 1572 | std::vector<std::string> values = GetPropertyValues(type, name); | ||
| 1573 | if (values.empty()) { | ||
| 1574 | return ""; | ||
| 1575 | } | ||
| 1576 | return values[0]; | ||
| 1577 | } | 2274 | } |
| 1578 | //-------------------------------------------------------------------------- | 2275 | int numValues = 0; |
| 1579 | 2276 | char** res(CAddonBase::m_interface->toKodi->kodi_filesystem->get_property_values( | |
| 1580 | //========================================================================== | 2277 | CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues)); |
| 1581 | /// | 2278 | if (res) |
| 1582 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1583 | /// @brief retrieve file property values | ||
| 1584 | /// | ||
| 1585 | /// @param[in] type The type of the file property values to retrieve the value for | ||
| 1586 | /// @param[in] name The name of the named property (e.g. Header) | ||
| 1587 | /// @return values of requested property, empty vector on failure / non-existance | ||
| 1588 | /// | ||
| 1589 | const std::vector<std::string> GetPropertyValues(FilePropertyTypes type, const std::string &name) const | ||
| 1590 | { | 2279 | { |
| 1591 | if (!m_file) | 2280 | std::vector<std::string> vecReturn; |
| 1592 | { | 2281 | for (int i = 0; i < numValues; ++i) |
| 1593 | kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!"); | ||
| 1594 | return std::vector<std::string>(); | ||
| 1595 | } | ||
| 1596 | int numValues; | ||
| 1597 | char **res(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_property_values( | ||
| 1598 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues)); | ||
| 1599 | if (res) | ||
| 1600 | { | 2282 | { |
| 1601 | std::vector<std::string> vecReturn; | 2283 | vecReturn.emplace_back(res[i]); |
| 1602 | for (int i = 0; i < numValues; ++i) | ||
| 1603 | { | ||
| 1604 | vecReturn.emplace_back(res[i]); | ||
| 1605 | } | ||
| 1606 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string_array(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, res, numValues); | ||
| 1607 | return vecReturn; | ||
| 1608 | } | 2284 | } |
| 1609 | return std::vector<std::string>(); | 2285 | CAddonBase::m_interface->toKodi->free_string_array(CAddonBase::m_interface->toKodi->kodiBase, |
| 1610 | } | 2286 | res, numValues); |
| 1611 | //-------------------------------------------------------------------------- | 2287 | return vecReturn; |
| 1612 | |||
| 1613 | //========================================================================== | ||
| 1614 | /// | ||
| 1615 | /// @ingroup cpp_kodi_vfs_CFile | ||
| 1616 | /// @brief Get the current download speed of file if loaded from web. | ||
| 1617 | /// | ||
| 1618 | /// @return The current download speed. | ||
| 1619 | /// | ||
| 1620 | double GetFileDownloadSpeed() | ||
| 1621 | { | ||
| 1622 | if (!m_file) | ||
| 1623 | return 0.0; | ||
| 1624 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 1625 | } | 2288 | } |
| 1626 | //-------------------------------------------------------------------------- | 2289 | return std::vector<std::string>(); |
| 2290 | } | ||
| 2291 | //-------------------------------------------------------------------------- | ||
| 1627 | 2292 | ||
| 1628 | private: | 2293 | //========================================================================== |
| 1629 | void* m_file = nullptr; | 2294 | /// @ingroup cpp_kodi_vfs_CFile |
| 1630 | }; | 2295 | /// @brief Get the current download speed of file if loaded from web. |
| 1631 | //@} | 2296 | /// |
| 1632 | //---------------------------------------------------------------------------- | 2297 | /// @return The current download speed. |
| 2298 | /// | ||
| 2299 | double GetFileDownloadSpeed() const | ||
| 2300 | { | ||
| 2301 | using namespace kodi::addon; | ||
| 2302 | |||
| 2303 | if (!m_file) | ||
| 2304 | return 0.0; | ||
| 2305 | return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed( | ||
| 2306 | CAddonBase::m_interface->toKodi->kodiBase, m_file); | ||
| 2307 | } | ||
| 2308 | //-------------------------------------------------------------------------- | ||
| 2309 | |||
| 2310 | private: | ||
| 2311 | void* m_file = nullptr; | ||
| 2312 | }; | ||
| 2313 | //@} | ||
| 2314 | //------------------------------------------------------------------------------ | ||
| 2315 | |||
| 2316 | //}}} | ||
| 1633 | 2317 | ||
| 1634 | } /* namespace vfs */ | 2318 | } /* namespace vfs */ |
| 1635 | } /* namespace kodi */ | 2319 | } /* namespace kodi */ |
| 2320 | |||
| 2321 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h index 999ff6a..878eaa4 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h | |||
| @@ -9,68 +9,9 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "AddonBase.h" | 11 | #include "AddonBase.h" |
| 12 | #include "c-api/general.h" | ||
| 12 | 13 | ||
| 13 | /* | 14 | #ifdef __cplusplus |
| 14 | * For interface between add-on and kodi. | ||
| 15 | * | ||
| 16 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 17 | * are then available for the add-on to call | ||
| 18 | * | ||
| 19 | * All function pointers there are used by the C++ interface functions below. | ||
| 20 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 21 | * | ||
| 22 | * Note: For add-on development itself this is not needed | ||
| 23 | */ | ||
| 24 | typedef struct AddonToKodiFuncTable_kodi | ||
| 25 | { | ||
| 26 | char* (*get_addon_info)(void* kodiBase, const char* id); | ||
| 27 | bool (*open_settings_dialog)(void* kodiBase); | ||
| 28 | char* (*unknown_to_utf8)(void* kodiBase, const char* source, bool* ret, bool failOnBadChar); | ||
| 29 | char* (*get_localized_string)(void* kodiBase, long label_id); | ||
| 30 | char* (*get_language)(void* kodiBase, int format, bool region); | ||
| 31 | bool (*queue_notification)(void* kodiBase, int type, const char* header, const char* message, const char* imageFile, unsigned int displayTime, bool withSound, unsigned int messageTime); | ||
| 32 | void (*get_md5)(void* kodiBase, const char* text, char* md5); | ||
| 33 | char* (*get_temp_path)(void* kodiBase); | ||
| 34 | char* (*get_region)(void* kodiBase, const char* id); | ||
| 35 | void (*get_free_mem)(void* kodiBase, long* free, long* total, bool as_bytes); | ||
| 36 | int (*get_global_idle_time)(void* kodiBase); | ||
| 37 | void (*kodi_version)(void* kodiBase, char** compile_name, int* major, int* minor, char** revision, char** tag, char** tagversion); | ||
| 38 | char* (*get_current_skin_id)(void* kodiBase); | ||
| 39 | } AddonToKodiFuncTable_kodi; | ||
| 40 | |||
| 41 | //============================================================================== | ||
| 42 | /// \ingroup cpp_kodi_Defs | ||
| 43 | /// @brief For kodi::QueueNotification() used message types | ||
| 44 | /// | ||
| 45 | typedef enum QueueMsg | ||
| 46 | { | ||
| 47 | /// Show info notification message | ||
| 48 | QUEUE_INFO, | ||
| 49 | /// Show warning notification message | ||
| 50 | QUEUE_WARNING, | ||
| 51 | /// Show error notification message | ||
| 52 | QUEUE_ERROR, | ||
| 53 | /// Show with own given image and parts if set on values | ||
| 54 | QUEUE_OWN_STYLE | ||
| 55 | } QueueMsg; | ||
| 56 | //------------------------------------------------------------------------------ | ||
| 57 | |||
| 58 | //============================================================================== | ||
| 59 | /// \ingroup cpp_kodi_Defs | ||
| 60 | /// @brief Format codes to get string from them. | ||
| 61 | /// | ||
| 62 | /// Used on kodi::GetLanguage(). | ||
| 63 | /// | ||
| 64 | typedef enum LangFormats | ||
| 65 | { | ||
| 66 | /// two letter code as defined in ISO 639-1 | ||
| 67 | LANG_FMT_ISO_639_1, | ||
| 68 | /// three letter code as defined in ISO 639-2/T or ISO 639-2/B | ||
| 69 | LANG_FMT_ISO_639_2, | ||
| 70 | /// full language name in English | ||
| 71 | LANG_FMT_ENGLISH_NAME | ||
| 72 | } LangFormats; | ||
| 73 | //------------------------------------------------------------------------------ | ||
| 74 | 15 | ||
| 75 | //============================================================================== | 16 | //============================================================================== |
| 76 | /// \ingroup cpp_kodi_Defs | 17 | /// \ingroup cpp_kodi_Defs |
| @@ -93,9 +34,10 @@ typedef struct kodi_version_t | |||
| 93 | } kodi_version_t; | 34 | } kodi_version_t; |
| 94 | //------------------------------------------------------------------------------ | 35 | //------------------------------------------------------------------------------ |
| 95 | 36 | ||
| 37 | namespace kodi | ||
| 38 | { | ||
| 39 | |||
| 96 | //============================================================================== | 40 | //============================================================================== |
| 97 | namespace kodi { | ||
| 98 | /// | ||
| 99 | /// \ingroup cpp_kodi | 41 | /// \ingroup cpp_kodi |
| 100 | /// @brief Returns the value of an addon property as a string | 42 | /// @brief Returns the value of an addon property as a string |
| 101 | /// | 43 | /// |
| @@ -121,9 +63,11 @@ namespace kodi { | |||
| 121 | /// ... | 63 | /// ... |
| 122 | /// ~~~~~~~~~~~~~ | 64 | /// ~~~~~~~~~~~~~ |
| 123 | /// | 65 | /// |
| 124 | inline std::string GetAddonInfo(const std::string& id) | 66 | inline std::string ATTRIBUTE_HIDDEN GetAddonInfo(const std::string& id) |
| 125 | { | 67 | { |
| 126 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 68 | using namespace kodi::addon; |
| 69 | |||
| 70 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 127 | 71 | ||
| 128 | std::string strReturn; | 72 | std::string strReturn; |
| 129 | char* strMsg = toKodi->kodi->get_addon_info(toKodi->kodiBase, id.c_str()); | 73 | char* strMsg = toKodi->kodi->get_addon_info(toKodi->kodiBase, id.c_str()); |
| @@ -135,12 +79,9 @@ inline std::string GetAddonInfo(const std::string& id) | |||
| 135 | } | 79 | } |
| 136 | return strReturn; | 80 | return strReturn; |
| 137 | } | 81 | } |
| 138 | } /* namespace kodi */ | ||
| 139 | //------------------------------------------------------------------------------ | 82 | //------------------------------------------------------------------------------ |
| 140 | 83 | ||
| 141 | //============================================================================== | 84 | //============================================================================== |
| 142 | namespace kodi { | ||
| 143 | /// | ||
| 144 | /// \ingroup cpp_kodi | 85 | /// \ingroup cpp_kodi |
| 145 | /// @brief Opens this Add-Ons settings dialog. | 86 | /// @brief Opens this Add-Ons settings dialog. |
| 146 | /// | 87 | /// |
| @@ -157,16 +98,15 @@ namespace kodi { | |||
| 157 | /// .. | 98 | /// .. |
| 158 | /// ~~~~~~~~~~~~~ | 99 | /// ~~~~~~~~~~~~~ |
| 159 | /// | 100 | /// |
| 160 | inline bool OpenSettings() | 101 | inline bool ATTRIBUTE_HIDDEN OpenSettings() |
| 161 | { | 102 | { |
| 162 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->open_settings_dialog(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | 103 | using namespace kodi::addon; |
| 104 | return CAddonBase::m_interface->toKodi->kodi->open_settings_dialog( | ||
| 105 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 163 | } | 106 | } |
| 164 | } /* namespace kodi */ | ||
| 165 | //------------------------------------------------------------------------------ | 107 | //------------------------------------------------------------------------------ |
| 166 | 108 | ||
| 167 | //============================================================================== | 109 | //============================================================================== |
| 168 | namespace kodi { | ||
| 169 | /// | ||
| 170 | /// \ingroup cpp_kodi | 110 | /// \ingroup cpp_kodi |
| 171 | /// @brief Returns an addon's localized 'unicode string'. | 111 | /// @brief Returns an addon's localized 'unicode string'. |
| 172 | /// | 112 | /// |
| @@ -193,24 +133,25 @@ namespace kodi { | |||
| 193 | /// ... | 133 | /// ... |
| 194 | /// ~~~~~~~~~~~~~ | 134 | /// ~~~~~~~~~~~~~ |
| 195 | /// | 135 | /// |
| 196 | inline std::string GetLocalizedString(uint32_t labelId, const std::string& defaultStr = "") | 136 | inline std::string ATTRIBUTE_HIDDEN GetLocalizedString(uint32_t labelId, |
| 137 | const std::string& defaultStr = "") | ||
| 197 | { | 138 | { |
| 139 | using namespace kodi::addon; | ||
| 140 | |||
| 198 | std::string retString = defaultStr; | 141 | std::string retString = defaultStr; |
| 199 | char* strMsg = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->get_localized_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, labelId); | 142 | char* strMsg = CAddonBase::m_interface->toKodi->kodi->get_localized_string( |
| 143 | CAddonBase::m_interface->toKodi->kodiBase, labelId); | ||
| 200 | if (strMsg != nullptr) | 144 | if (strMsg != nullptr) |
| 201 | { | 145 | { |
| 202 | if (std::strlen(strMsg)) | 146 | if (std::strlen(strMsg)) |
| 203 | retString = strMsg; | 147 | retString = strMsg; |
| 204 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, strMsg); | 148 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); |
| 205 | } | 149 | } |
| 206 | return retString; | 150 | return retString; |
| 207 | } | 151 | } |
| 208 | } /* namespace kodi */ | ||
| 209 | //------------------------------------------------------------------------------ | 152 | //------------------------------------------------------------------------------ |
| 210 | 153 | ||
| 211 | //============================================================================== | 154 | //============================================================================== |
| 212 | namespace kodi { | ||
| 213 | /// | ||
| 214 | /// \ingroup cpp_kodi | 155 | /// \ingroup cpp_kodi |
| 215 | /// @brief Translate a string with an unknown encoding to UTF8. | 156 | /// @brief Translate a string with an unknown encoding to UTF8. |
| 216 | /// | 157 | /// |
| @@ -232,25 +173,27 @@ namespace kodi { | |||
| 232 | /// ... | 173 | /// ... |
| 233 | /// ~~~~~~~~~~~~~ | 174 | /// ~~~~~~~~~~~~~ |
| 234 | /// | 175 | /// |
| 235 | inline bool UnknownToUTF8(const std::string& stringSrc, std::string& utf8StringDst, bool failOnBadChar = false) | 176 | inline bool ATTRIBUTE_HIDDEN UnknownToUTF8(const std::string& stringSrc, |
| 177 | std::string& utf8StringDst, | ||
| 178 | bool failOnBadChar = false) | ||
| 236 | { | 179 | { |
| 180 | using namespace kodi::addon; | ||
| 181 | |||
| 237 | bool ret = false; | 182 | bool ret = false; |
| 238 | char* retString = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->unknown_to_utf8(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, | 183 | char* retString = CAddonBase::m_interface->toKodi->kodi->unknown_to_utf8( |
| 239 | stringSrc.c_str(), &ret, failOnBadChar); | 184 | CAddonBase::m_interface->toKodi->kodiBase, stringSrc.c_str(), &ret, failOnBadChar); |
| 240 | if (retString != nullptr) | 185 | if (retString != nullptr) |
| 241 | { | 186 | { |
| 242 | if (ret) | 187 | if (ret) |
| 243 | utf8StringDst = retString; | 188 | utf8StringDst = retString; |
| 244 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, retString); | 189 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, |
| 190 | retString); | ||
| 245 | } | 191 | } |
| 246 | return ret; | 192 | return ret; |
| 247 | } | 193 | } |
| 248 | } /* namespace kodi */ | ||
| 249 | //------------------------------------------------------------------------------ | 194 | //------------------------------------------------------------------------------ |
| 250 | 195 | ||
| 251 | //============================================================================== | 196 | //============================================================================== |
| 252 | namespace kodi { | ||
| 253 | /// | ||
| 254 | /// \ingroup cpp_kodi | 197 | /// \ingroup cpp_kodi |
| 255 | /// @brief Returns the active language as a string. | 198 | /// @brief Returns the active language as a string. |
| 256 | /// | 199 | /// |
| @@ -274,24 +217,26 @@ namespace kodi { | |||
| 274 | /// ... | 217 | /// ... |
| 275 | /// ~~~~~~~~~~~~~ | 218 | /// ~~~~~~~~~~~~~ |
| 276 | /// | 219 | /// |
| 277 | inline std::string GetLanguage(LangFormats format = LANG_FMT_ENGLISH_NAME, bool region = false) | 220 | inline std::string ATTRIBUTE_HIDDEN GetLanguage(LangFormats format = LANG_FMT_ENGLISH_NAME, |
| 221 | bool region = false) | ||
| 278 | { | 222 | { |
| 223 | using namespace kodi::addon; | ||
| 224 | |||
| 279 | std::string language; | 225 | std::string language; |
| 280 | char* retString = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->get_language(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, format, region); | 226 | char* retString = CAddonBase::m_interface->toKodi->kodi->get_language( |
| 227 | CAddonBase::m_interface->toKodi->kodiBase, format, region); | ||
| 281 | if (retString != nullptr) | 228 | if (retString != nullptr) |
| 282 | { | 229 | { |
| 283 | if (std::strlen(retString)) | 230 | if (std::strlen(retString)) |
| 284 | language = retString; | 231 | language = retString; |
| 285 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, retString); | 232 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, |
| 233 | retString); | ||
| 286 | } | 234 | } |
| 287 | return language; | 235 | return language; |
| 288 | } | 236 | } |
| 289 | } /* namespace kodi */ | ||
| 290 | //------------------------------------------------------------------------------ | 237 | //------------------------------------------------------------------------------ |
| 291 | 238 | ||
| 292 | //============================================================================== | 239 | //============================================================================== |
| 293 | namespace kodi { | ||
| 294 | /// | ||
| 295 | /// \ingroup cpp_kodi | 240 | /// \ingroup cpp_kodi |
| 296 | /// @brief Writes the C string pointed by format in the GUI. If format includes | 241 | /// @brief Writes the C string pointed by format in the GUI. If format includes |
| 297 | /// format specifiers (subsequences beginning with %), the additional arguments | 242 | /// format specifiers (subsequences beginning with %), the additional arguments |
| @@ -367,22 +312,21 @@ namespace kodi { | |||
| 367 | /// ... | 312 | /// ... |
| 368 | /// ~~~~~~~~~~~~~ | 313 | /// ~~~~~~~~~~~~~ |
| 369 | /// | 314 | /// |
| 370 | inline void QueueFormattedNotification(QueueMsg type, const char* format, ... ) | 315 | inline void ATTRIBUTE_HIDDEN QueueFormattedNotification(QueueMsg type, const char* format, ...) |
| 371 | { | 316 | { |
| 317 | using namespace kodi::addon; | ||
| 318 | |||
| 372 | va_list args; | 319 | va_list args; |
| 373 | char buffer[16384]; | 320 | char buffer[16384]; |
| 374 | va_start(args, format); | 321 | va_start(args, format); |
| 375 | vsprintf(buffer, format, args); | 322 | vsprintf(buffer, format, args); |
| 376 | va_end(args); | 323 | va_end(args); |
| 377 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->queue_notification(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, | 324 | CAddonBase::m_interface->toKodi->kodi->queue_notification( |
| 378 | type, "", buffer, "", 5000, false, 1000); | 325 | CAddonBase::m_interface->toKodi->kodiBase, type, "", buffer, "", 5000, false, 1000); |
| 379 | } | 326 | } |
| 380 | } /* namespace kodi */ | ||
| 381 | //------------------------------------------------------------------------------ | 327 | //------------------------------------------------------------------------------ |
| 382 | 328 | ||
| 383 | //============================================================================== | 329 | //============================================================================== |
| 384 | namespace kodi { | ||
| 385 | /// | ||
| 386 | /// \ingroup cpp_kodi | 330 | /// \ingroup cpp_kodi |
| 387 | /// @brief Queue a notification in the GUI. | 331 | /// @brief Queue a notification in the GUI. |
| 388 | /// | 332 | /// |
| @@ -427,21 +371,23 @@ namespace kodi { | |||
| 427 | /// ... | 371 | /// ... |
| 428 | /// ~~~~~~~~~~~~~ | 372 | /// ~~~~~~~~~~~~~ |
| 429 | /// | 373 | /// |
| 430 | inline void QueueNotification(QueueMsg type, const std::string& header, | 374 | inline void ATTRIBUTE_HIDDEN QueueNotification(QueueMsg type, |
| 431 | const std::string& message, const std::string& imageFile = "", | 375 | const std::string& header, |
| 432 | unsigned int displayTime = 5000, bool withSound = true, | 376 | const std::string& message, |
| 433 | unsigned int messageTime = 1000) | 377 | const std::string& imageFile = "", |
| 378 | unsigned int displayTime = 5000, | ||
| 379 | bool withSound = true, | ||
| 380 | unsigned int messageTime = 1000) | ||
| 434 | { | 381 | { |
| 435 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->queue_notification(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, | 382 | using namespace kodi::addon; |
| 436 | type, header.c_str(), message.c_str(), imageFile.c_str(), displayTime, | 383 | |
| 437 | withSound, messageTime); | 384 | CAddonBase::m_interface->toKodi->kodi->queue_notification( |
| 385 | CAddonBase::m_interface->toKodi->kodiBase, type, header.c_str(), message.c_str(), | ||
| 386 | imageFile.c_str(), displayTime, withSound, messageTime); | ||
| 438 | } | 387 | } |
| 439 | } /* namespace kodi */ | ||
| 440 | //------------------------------------------------------------------------------ | 388 | //------------------------------------------------------------------------------ |
| 441 | 389 | ||
| 442 | //============================================================================ | 390 | //============================================================================ |
| 443 | namespace kodi { | ||
| 444 | /// | ||
| 445 | /// \ingroup cpp_kodi | 391 | /// \ingroup cpp_kodi |
| 446 | /// @brief Get the MD5 digest of the given text | 392 | /// @brief Get the MD5 digest of the given text |
| 447 | /// | 393 | /// |
| @@ -460,20 +406,20 @@ namespace kodi { | |||
| 460 | /// ... | 406 | /// ... |
| 461 | /// ~~~~~~~~~~~~~ | 407 | /// ~~~~~~~~~~~~~ |
| 462 | /// | 408 | /// |
| 463 | inline std::string GetMD5(const std::string& text) | 409 | inline std::string ATTRIBUTE_HIDDEN GetMD5(const std::string& text) |
| 464 | { | 410 | { |
| 465 | char* md5ret = static_cast<char*>(malloc(40*sizeof(char))); // md5 size normally 32 bytes | 411 | using namespace kodi::addon; |
| 466 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->get_md5(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), md5ret); | 412 | |
| 413 | char* md5ret = static_cast<char*>(malloc(40 * sizeof(char))); // md5 size normally 32 bytes | ||
| 414 | CAddonBase::m_interface->toKodi->kodi->get_md5(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 415 | text.c_str(), md5ret); | ||
| 467 | std::string md5 = md5ret; | 416 | std::string md5 = md5ret; |
| 468 | free(md5ret); | 417 | free(md5ret); |
| 469 | return md5; | 418 | return md5; |
| 470 | } | 419 | } |
| 471 | } /* namespace kodi */ | ||
| 472 | //---------------------------------------------------------------------------- | 420 | //---------------------------------------------------------------------------- |
| 473 | 421 | ||
| 474 | //============================================================================== | 422 | //============================================================================== |
| 475 | namespace kodi { | ||
| 476 | /// | ||
| 477 | /// \ingroup cpp_kodi | 423 | /// \ingroup cpp_kodi |
| 478 | /// @brief To get a temporary path for the addon | 424 | /// @brief To get a temporary path for the addon |
| 479 | /// | 425 | /// |
| @@ -484,15 +430,17 @@ namespace kodi { | |||
| 484 | /// @param[in] append A string to append to returned temporary path | 430 | /// @param[in] append A string to append to returned temporary path |
| 485 | /// @return Individual path for the addon | 431 | /// @return Individual path for the addon |
| 486 | /// | 432 | /// |
| 487 | inline std::string GetTempAddonPath(const std::string& append = "") | 433 | inline std::string ATTRIBUTE_HIDDEN GetTempAddonPath(const std::string& append = "") |
| 488 | { | 434 | { |
| 489 | char* str = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi->get_temp_path(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | 435 | using namespace kodi::addon; |
| 436 | |||
| 437 | char* str = CAddonBase::m_interface->toKodi->kodi->get_temp_path( | ||
| 438 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 490 | std::string ret = str; | 439 | std::string ret = str; |
| 491 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, str); | 440 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str); |
| 492 | if (!append.empty()) | 441 | if (!append.empty()) |
| 493 | { | 442 | { |
| 494 | if (append.at(0) != '\\' && | 443 | if (append.at(0) != '\\' && append.at(0) != '/') |
| 495 | append.at(0) != '/') | ||
| 496 | #ifdef TARGET_WINDOWS | 444 | #ifdef TARGET_WINDOWS |
| 497 | ret.append("\\"); | 445 | ret.append("\\"); |
| 498 | #else | 446 | #else |
| @@ -502,12 +450,9 @@ inline std::string GetTempAddonPath(const std::string& append = "") | |||
| 502 | } | 450 | } |
| 503 | return ret; | 451 | return ret; |
| 504 | } | 452 | } |
| 505 | } /* namespace kodi */ | ||
| 506 | //------------------------------------------------------------------------------ | 453 | //------------------------------------------------------------------------------ |
| 507 | 454 | ||
| 508 | //============================================================================== | 455 | //============================================================================== |
| 509 | namespace kodi { | ||
| 510 | /// | ||
| 511 | /// \ingroup cpp_kodi | 456 | /// \ingroup cpp_kodi |
| 512 | /// @brief Returns your regions setting as a string for the specified id | 457 | /// @brief Returns your regions setting as a string for the specified id |
| 513 | /// | 458 | /// |
| @@ -530,9 +475,11 @@ namespace kodi { | |||
| 530 | /// ... | 475 | /// ... |
| 531 | /// ~~~~~~~~~~~~~ | 476 | /// ~~~~~~~~~~~~~ |
| 532 | /// | 477 | /// |
| 533 | inline std::string GetRegion(const std::string& id) | 478 | inline std::string ATTRIBUTE_HIDDEN GetRegion(const std::string& id) |
| 534 | { | 479 | { |
| 535 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 480 | using namespace kodi::addon; |
| 481 | |||
| 482 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 536 | 483 | ||
| 537 | std::string strReturn; | 484 | std::string strReturn; |
| 538 | char* strMsg = toKodi->kodi->get_region(toKodi->kodiBase, id.c_str()); | 485 | char* strMsg = toKodi->kodi->get_region(toKodi->kodiBase, id.c_str()); |
| @@ -544,12 +491,9 @@ inline std::string GetRegion(const std::string& id) | |||
| 544 | } | 491 | } |
| 545 | return strReturn; | 492 | return strReturn; |
| 546 | } | 493 | } |
| 547 | } /* namespace kodi */ | ||
| 548 | //------------------------------------------------------------------------------ | 494 | //------------------------------------------------------------------------------ |
| 549 | 495 | ||
| 550 | //============================================================================== | 496 | //============================================================================== |
| 551 | namespace kodi { | ||
| 552 | /// | ||
| 553 | /// \ingroup cpp_kodi | 497 | /// \ingroup cpp_kodi |
| 554 | /// @brief Returns the amount of free memory in MByte (or as bytes) as an long | 498 | /// @brief Returns the amount of free memory in MByte (or as bytes) as an long |
| 555 | /// integer | 499 | /// integer |
| @@ -572,19 +516,18 @@ namespace kodi { | |||
| 572 | /// ... | 516 | /// ... |
| 573 | /// ~~~~~~~~~~~~~ | 517 | /// ~~~~~~~~~~~~~ |
| 574 | /// | 518 | /// |
| 575 | inline void GetFreeMem(long& free, long& total, bool asBytes = false) | 519 | inline void ATTRIBUTE_HIDDEN GetFreeMem(long& free, long& total, bool asBytes = false) |
| 576 | { | 520 | { |
| 521 | using namespace kodi::addon; | ||
| 522 | |||
| 577 | free = -1; | 523 | free = -1; |
| 578 | total = -1; | 524 | total = -1; |
| 579 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 525 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; |
| 580 | toKodi->kodi->get_free_mem(toKodi->kodiBase, &free, &total, asBytes); | 526 | toKodi->kodi->get_free_mem(toKodi->kodiBase, &free, &total, asBytes); |
| 581 | } | 527 | } |
| 582 | } /* namespace kodi */ | ||
| 583 | //------------------------------------------------------------------------------ | 528 | //------------------------------------------------------------------------------ |
| 584 | 529 | ||
| 585 | //============================================================================== | 530 | //============================================================================== |
| 586 | namespace kodi { | ||
| 587 | /// | ||
| 588 | /// \ingroup cpp_kodi | 531 | /// \ingroup cpp_kodi |
| 589 | /// @brief Returns the elapsed idle time in seconds as an integer | 532 | /// @brief Returns the elapsed idle time in seconds as an integer |
| 590 | /// | 533 | /// |
| @@ -601,20 +544,18 @@ namespace kodi { | |||
| 601 | /// ... | 544 | /// ... |
| 602 | /// ~~~~~~~~~~~~~ | 545 | /// ~~~~~~~~~~~~~ |
| 603 | /// | 546 | /// |
| 604 | inline int GetGlobalIdleTime() | 547 | inline int ATTRIBUTE_HIDDEN GetGlobalIdleTime() |
| 605 | { | 548 | { |
| 606 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 549 | using namespace kodi::addon; |
| 550 | |||
| 551 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 607 | return toKodi->kodi->get_global_idle_time(toKodi->kodiBase); | 552 | return toKodi->kodi->get_global_idle_time(toKodi->kodiBase); |
| 608 | } | 553 | } |
| 609 | } /* namespace kodi */ | ||
| 610 | //------------------------------------------------------------------------------ | 554 | //------------------------------------------------------------------------------ |
| 611 | 555 | ||
| 612 | //============================================================================== | 556 | //============================================================================== |
| 613 | namespace kodi { | ||
| 614 | /// | ||
| 615 | /// \ingroup cpp_kodi | 557 | /// \ingroup cpp_kodi |
| 616 | /// @brief Get the currently used skin identification name from Kodi | 558 | /// @brief Get the currently used skin identification name from Kodi |
| 617 | ///----------------------------------------------------------------------- | ||
| 618 | /// | 559 | /// |
| 619 | /// @return The active skin id name as a string | 560 | /// @return The active skin id name as a string |
| 620 | /// | 561 | /// |
| @@ -633,9 +574,11 @@ namespace kodi { | |||
| 633 | /// .. | 574 | /// .. |
| 634 | /// ~~~~~~~~~~~~~ | 575 | /// ~~~~~~~~~~~~~ |
| 635 | /// | 576 | /// |
| 636 | inline std::string GetCurrentSkinId() | 577 | inline std::string ATTRIBUTE_HIDDEN GetCurrentSkinId() |
| 637 | { | 578 | { |
| 638 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 579 | using namespace kodi::addon; |
| 580 | |||
| 581 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 639 | 582 | ||
| 640 | std::string strReturn; | 583 | std::string strReturn; |
| 641 | char* strMsg = toKodi->kodi->get_current_skin_id(toKodi->kodiBase); | 584 | char* strMsg = toKodi->kodi->get_current_skin_id(toKodi->kodiBase); |
| @@ -647,12 +590,50 @@ inline std::string GetCurrentSkinId() | |||
| 647 | } | 590 | } |
| 648 | return strReturn; | 591 | return strReturn; |
| 649 | } | 592 | } |
| 650 | } /* namespace kodi */ | ||
| 651 | //------------------------------------------------------------------------------ | 593 | //------------------------------------------------------------------------------ |
| 652 | 594 | ||
| 653 | //============================================================================== | 595 | //============================================================================== |
| 654 | namespace kodi { | 596 | /// @brief To check another addon is available and usable inside Kodi. |
| 597 | /// | ||
| 598 | /// @param[in] id The wanted addon identification string to check | ||
| 599 | /// @param[out] version Version string of addon if **installed** inside Kodi | ||
| 600 | /// @param[out] enabled Set to true <b>`true* </b> if addon is enabled | ||
| 601 | /// @return Returns <b>`true* </b> if addon is installed | ||
| 602 | /// | ||
| 603 | /// | ||
| 604 | /// ------------------------------------------------------------------------ | ||
| 605 | /// | ||
| 606 | /// **Example:** | ||
| 607 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 608 | /// #include <kodi/General.h> | ||
| 655 | /// | 609 | /// |
| 610 | /// bool enabled = false; | ||
| 611 | /// std::string version; | ||
| 612 | /// bool ret = kodi::IsAddonAvailable("inputstream.adaptive", version, enabled); | ||
| 613 | /// fprintf(stderr, "Available inputstream.adaptive version '%s' and enabled '%s'\n", | ||
| 614 | /// ret ? version.c_str() : "not installed", enabled ? "yes" : "no"); | ||
| 615 | /// ~~~~~~~~~~~~~ | ||
| 616 | /// | ||
| 617 | inline bool ATTRIBUTE_HIDDEN IsAddonAvailable(const std::string& id, | ||
| 618 | std::string& version, | ||
| 619 | bool& enabled) | ||
| 620 | { | ||
| 621 | using namespace kodi::addon; | ||
| 622 | |||
| 623 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 624 | |||
| 625 | char* cVersion = nullptr; | ||
| 626 | bool ret = toKodi->kodi->is_addon_avilable(toKodi->kodiBase, id.c_str(), &cVersion, &enabled); | ||
| 627 | if (cVersion) | ||
| 628 | { | ||
| 629 | version = cVersion; | ||
| 630 | toKodi->free_string(toKodi->kodiBase, cVersion); | ||
| 631 | } | ||
| 632 | return ret; | ||
| 633 | } | ||
| 634 | //------------------------------------------------------------------------------ | ||
| 635 | |||
| 636 | //============================================================================== | ||
| 656 | /// \ingroup cpp_kodi | 637 | /// \ingroup cpp_kodi |
| 657 | /// @brief Get current Kodi informations and versions, returned data from the following | 638 | /// @brief Get current Kodi informations and versions, returned data from the following |
| 658 | /// <b><tt>kodi_version_t version; kodi::KodiVersion(version);</tt></b> | 639 | /// <b><tt>kodi_version_t version; kodi::KodiVersion(version);</tt></b> |
| @@ -691,23 +672,22 @@ namespace kodi { | |||
| 691 | /// ... | 672 | /// ... |
| 692 | /// ~~~~~~~~~~~~~ | 673 | /// ~~~~~~~~~~~~~ |
| 693 | /// | 674 | /// |
| 694 | inline void KodiVersion(kodi_version_t& version) | 675 | inline void ATTRIBUTE_HIDDEN KodiVersion(kodi_version_t& version) |
| 695 | { | 676 | { |
| 677 | using namespace kodi::addon; | ||
| 678 | |||
| 696 | char* compile_name = nullptr; | 679 | char* compile_name = nullptr; |
| 697 | char* revision = nullptr; | 680 | char* revision = nullptr; |
| 698 | char* tag = nullptr; | 681 | char* tag = nullptr; |
| 699 | char* tag_revision = nullptr; | 682 | char* tag_revision = nullptr; |
| 700 | 683 | ||
| 701 | AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi; | 684 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; |
| 702 | toKodi->kodi->kodi_version(toKodi->kodiBase, &compile_name, &version.major, &version.minor, &revision, &tag, &tag_revision); | 685 | toKodi->kodi->kodi_version(toKodi->kodiBase, &compile_name, &version.major, &version.minor, |
| 686 | &revision, &tag, &tag_revision); | ||
| 703 | if (compile_name != nullptr) | 687 | if (compile_name != nullptr) |
| 704 | { | 688 | { |
| 705 | version.compile_name = compile_name; | 689 | version.compile_name = compile_name; |
| 706 | toKodi->free_string | 690 | toKodi->free_string(toKodi->kodiBase, compile_name); |
| 707 | ( | ||
| 708 | toKodi->kodiBase, | ||
| 709 | compile_name | ||
| 710 | ); | ||
| 711 | } | 691 | } |
| 712 | if (revision != nullptr) | 692 | if (revision != nullptr) |
| 713 | { | 693 | { |
| @@ -725,5 +705,130 @@ inline void KodiVersion(kodi_version_t& version) | |||
| 725 | toKodi->free_string(toKodi->kodiBase, tag_revision); | 705 | toKodi->free_string(toKodi->kodiBase, tag_revision); |
| 726 | } | 706 | } |
| 727 | } | 707 | } |
| 728 | } /* namespace kodi */ | ||
| 729 | //------------------------------------------------------------------------------ | 708 | //------------------------------------------------------------------------------ |
| 709 | |||
| 710 | //============================================================================== | ||
| 711 | /// \ingroup cpp_kodi | ||
| 712 | /// @brief To get keyboard layout characters | ||
| 713 | /// | ||
| 714 | /// This is used to get the keyboard layout currently used from Kodi by the | ||
| 715 | /// there set language. | ||
| 716 | /// | ||
| 717 | /// @param[in] modifierKey the key to define the needed layout (uppercase, symbols...) | ||
| 718 | /// @param[out] layout_name name of used layout | ||
| 719 | /// @param[out] layout list of selected keyboard layout | ||
| 720 | /// @return true if request successed | ||
| 721 | /// | ||
| 722 | /// | ||
| 723 | /// ------------------------------------------------------------------------ | ||
| 724 | /// | ||
| 725 | /// **Example:** | ||
| 726 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 727 | /// #include <kodi/General.h> | ||
| 728 | /// ... | ||
| 729 | /// std::string layout_name; | ||
| 730 | /// std::vector<std::vector<std::string>> layout; | ||
| 731 | /// kodi::GetKeyboardLayout(STD_KB_MODIFIER_KEY_SHIFT | STD_KB_MODIFIER_KEY_SYMBOL, layout_name, layout); | ||
| 732 | /// fprintf(stderr, "Layout: '%s'\n", layout_name.c_str()); | ||
| 733 | /// for (unsigned int row = 0; row < STD_KB_BUTTONS_MAX_ROWS; row++) | ||
| 734 | /// { | ||
| 735 | /// for (unsigned int column = 0; column < STD_KB_BUTTONS_PER_ROW; column++) | ||
| 736 | /// { | ||
| 737 | /// fprintf(stderr, " - Row: '%02i'; Column: '%02i'; Text: '%s'\n", row, column, layout[row][column].c_str()); | ||
| 738 | /// } | ||
| 739 | /// } | ||
| 740 | /// ... | ||
| 741 | /// ~~~~~~~~~~~~~ | ||
| 742 | /// | ||
| 743 | inline bool ATTRIBUTE_HIDDEN GetKeyboardLayout(int modifierKey, | ||
| 744 | std::string& layout_name, | ||
| 745 | std::vector<std::vector<std::string>>& layout) | ||
| 746 | { | ||
| 747 | using namespace kodi::addon; | ||
| 748 | |||
| 749 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 750 | AddonKeyboardKeyTable c_layout; | ||
| 751 | char* c_layout_name = nullptr; | ||
| 752 | bool ret = | ||
| 753 | toKodi->kodi->get_keyboard_layout(toKodi->kodiBase, &c_layout_name, modifierKey, &c_layout); | ||
| 754 | if (ret) | ||
| 755 | { | ||
| 756 | if (c_layout_name) | ||
| 757 | { | ||
| 758 | layout_name = c_layout_name; | ||
| 759 | toKodi->free_string(toKodi->kodiBase, c_layout_name); | ||
| 760 | } | ||
| 761 | |||
| 762 | layout.resize(STD_KB_BUTTONS_MAX_ROWS); | ||
| 763 | for (unsigned int row = 0; row < STD_KB_BUTTONS_MAX_ROWS; row++) | ||
| 764 | { | ||
| 765 | layout[row].resize(STD_KB_BUTTONS_PER_ROW); | ||
| 766 | for (unsigned int column = 0; column < STD_KB_BUTTONS_PER_ROW; column++) | ||
| 767 | { | ||
| 768 | char* button = c_layout.keys[row][column]; | ||
| 769 | if (button) | ||
| 770 | { | ||
| 771 | layout[row][column] = button; | ||
| 772 | toKodi->free_string(toKodi->kodiBase, button); | ||
| 773 | } | ||
| 774 | } | ||
| 775 | } | ||
| 776 | } | ||
| 777 | return ret; | ||
| 778 | } | ||
| 779 | //------------------------------------------------------------------------------ | ||
| 780 | |||
| 781 | //============================================================================== | ||
| 782 | /// \ingroup cpp_kodi | ||
| 783 | /// @brief To change keyboard layout characters | ||
| 784 | /// | ||
| 785 | /// This is used to change the keyboard layout currently used from Kodi | ||
| 786 | /// | ||
| 787 | /// @param[out] layout_name new name of used layout (input string not used!) | ||
| 788 | /// @return true if request successed | ||
| 789 | /// | ||
| 790 | /// @note \ref GetKeyboardLayout must be called afterwards. | ||
| 791 | /// | ||
| 792 | /// | ||
| 793 | /// ------------------------------------------------------------------------ | ||
| 794 | /// | ||
| 795 | /// **Example:** | ||
| 796 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 797 | /// #include <kodi/General.h> | ||
| 798 | /// ... | ||
| 799 | /// std::string layout_name; | ||
| 800 | /// kodi::ChangeKeyboardLayout(layout_name); | ||
| 801 | /// | ||
| 802 | /// std::vector<std::vector<std::string>> layout; | ||
| 803 | /// kodi::GetKeyboardLayout(STD_KB_MODIFIER_KEY_SHIFT | STD_KB_MODIFIER_KEY_SYMBOL, layout_name, layout); | ||
| 804 | /// fprintf(stderr, "Layout: '%s'\n", layout_name.c_str()); | ||
| 805 | /// for (unsigned int row = 0; row < STD_KB_BUTTONS_MAX_ROWS; row++) | ||
| 806 | /// { | ||
| 807 | /// for (unsigned int column = 0; column < STD_KB_BUTTONS_PER_ROW; column++) | ||
| 808 | /// { | ||
| 809 | /// fprintf(stderr, " - Row: '%02i'; Column: '%02i'; Text: '%s'\n", row, column, layout[row][column].c_str()); | ||
| 810 | /// } | ||
| 811 | /// } | ||
| 812 | /// ... | ||
| 813 | /// ~~~~~~~~~~~~~ | ||
| 814 | /// | ||
| 815 | inline bool ATTRIBUTE_HIDDEN ChangeKeyboardLayout(std::string& layout_name) | ||
| 816 | { | ||
| 817 | using namespace kodi::addon; | ||
| 818 | |||
| 819 | AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi; | ||
| 820 | char* c_layout_name = nullptr; | ||
| 821 | bool ret = toKodi->kodi->change_keyboard_layout(toKodi->kodiBase, &c_layout_name); | ||
| 822 | if (c_layout_name) | ||
| 823 | { | ||
| 824 | layout_name = c_layout_name; | ||
| 825 | toKodi->free_string(toKodi->kodiBase, c_layout_name); | ||
| 826 | } | ||
| 827 | |||
| 828 | return ret; | ||
| 829 | } | ||
| 830 | //------------------------------------------------------------------------------ | ||
| 831 | |||
| 832 | } /* namespace kodi */ | ||
| 833 | |||
| 834 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h index 73390c4..910385f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/Network.h | |||
| @@ -9,35 +9,17 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "AddonBase.h" | 11 | #include "AddonBase.h" |
| 12 | #include "c-api/network.h" | ||
| 12 | 13 | ||
| 13 | /* | 14 | #ifdef __cplusplus |
| 14 | * For interface between add-on and kodi. | ||
| 15 | * | ||
| 16 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 17 | * are then available for the add-on to call | ||
| 18 | * | ||
| 19 | * All function pointers there are used by the C++ interface functions below. | ||
| 20 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 21 | * | ||
| 22 | * Note: For add-on development itself this is not needed | ||
| 23 | */ | ||
| 24 | typedef struct AddonToKodiFuncTable_kodi_network | ||
| 25 | { | ||
| 26 | bool (*wake_on_lan)(void* kodiBase, const char *mac); | ||
| 27 | char* (*get_ip_address)(void* kodiBase); | ||
| 28 | char* (*dns_lookup)(void* kodiBase, const char* url, bool* ret); | ||
| 29 | char* (*url_encode)(void* kodiBase, const char* url); | ||
| 30 | } AddonToKodiFuncTable_kodi_network; | ||
| 31 | 15 | ||
| 32 | //============================================================================== | 16 | //============================================================================== |
| 33 | /// | 17 | /// @defgroup cpp_kodi_network Interface - kodi::network |
| 34 | /// \defgroup cpp_kodi_network Interface - kodi::network | 18 | /// @ingroup cpp |
| 35 | /// \ingroup cpp | 19 | /// @brief **Network functions**\n |
| 36 | /// @brief **Network functions** | ||
| 37 | /// | ||
| 38 | /// The network module offers functions that allow you to control it. | 20 | /// The network module offers functions that allow you to control it. |
| 39 | /// | 21 | /// |
| 40 | /// It has the header \ref Network.h "#include <kodi/Network.h>" be included | 22 | /// It has the header @ref Network.h "#include <kodi/Network.h>" be included |
| 41 | /// to enjoy it. | 23 | /// to enjoy it. |
| 42 | /// | 24 | /// |
| 43 | //------------------------------------------------------------------------------ | 25 | //------------------------------------------------------------------------------ |
| @@ -47,130 +29,254 @@ namespace kodi | |||
| 47 | namespace network | 29 | namespace network |
| 48 | { | 30 | { |
| 49 | 31 | ||
| 50 | //============================================================================ | 32 | //============================================================================ |
| 51 | /// | 33 | /// @ingroup cpp_kodi_network |
| 52 | /// \ingroup cpp_kodi_network | 34 | /// @brief Send WakeOnLan magic packet. |
| 53 | /// @brief Send WakeOnLan magic packet. | 35 | /// |
| 54 | /// | 36 | /// @param[in] mac Network address of the host to wake. |
| 55 | /// @param[in] mac Network address of the host to wake. | 37 | /// @return True if the magic packet was successfully sent, false otherwise. |
| 56 | /// @return True if the magic packet was successfully sent, false otherwise. | 38 | /// |
| 57 | /// | 39 | inline bool ATTRIBUTE_HIDDEN WakeOnLan(const std::string& mac) |
| 58 | inline bool WakeOnLan(const std::string& mac) | 40 | { |
| 41 | using namespace ::kodi::addon; | ||
| 42 | |||
| 43 | return CAddonBase::m_interface->toKodi->kodi_network->wake_on_lan( | ||
| 44 | CAddonBase::m_interface->toKodi->kodiBase, mac.c_str()); | ||
| 45 | } | ||
| 46 | //---------------------------------------------------------------------------- | ||
| 47 | |||
| 48 | //============================================================================ | ||
| 49 | /// @ingroup cpp_kodi_network | ||
| 50 | /// @brief To the current own ip address as a string. | ||
| 51 | /// | ||
| 52 | /// @return Own system ip. | ||
| 53 | /// | ||
| 54 | /// | ||
| 55 | /// ------------------------------------------------------------------------ | ||
| 56 | /// | ||
| 57 | /// **Example:** | ||
| 58 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 59 | /// #include <kodi/Network.h> | ||
| 60 | /// ... | ||
| 61 | /// std::string ipAddress = kodi::network::GetIPAddress(); | ||
| 62 | /// fprintf(stderr, "My IP is '%s'\n", ipAddress.c_str()); | ||
| 63 | /// ... | ||
| 64 | /// ~~~~~~~~~~~~~ | ||
| 65 | /// | ||
| 66 | inline std::string ATTRIBUTE_HIDDEN GetIPAddress() | ||
| 67 | { | ||
| 68 | using namespace ::kodi::addon; | ||
| 69 | |||
| 70 | std::string ip; | ||
| 71 | char* string = CAddonBase::m_interface->toKodi->kodi_network->get_ip_address( | ||
| 72 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 73 | if (string != nullptr) | ||
| 59 | { | 74 | { |
| 60 | return ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->wake_on_lan(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, mac.c_str()); | 75 | ip = string; |
| 76 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 61 | } | 77 | } |
| 62 | //---------------------------------------------------------------------------- | 78 | return ip; |
| 63 | 79 | } | |
| 64 | //============================================================================ | 80 | //---------------------------------------------------------------------------- |
| 65 | /// | 81 | |
| 66 | /// \ingroup cpp_kodi_network | 82 | //============================================================================ |
| 67 | /// @brief To the current own ip address as a string. | 83 | /// @ingroup cpp_kodi_network |
| 68 | /// | 84 | /// @brief Return our hostname. |
| 69 | /// @return Own system ip. | 85 | /// |
| 70 | /// | 86 | /// @return String about hostname, empty in case of error |
| 71 | /// | 87 | /// |
| 72 | /// ------------------------------------------------------------------------ | 88 | /// |
| 73 | /// | 89 | /// ------------------------------------------------------------------------ |
| 74 | /// **Example:** | 90 | /// |
| 75 | /// ~~~~~~~~~~~~~{.cpp} | 91 | /// **Example:** |
| 76 | /// #include <kodi/Network.h> | 92 | /// ~~~~~~~~~~~~~{.cpp} |
| 77 | /// ... | 93 | /// #include <kodi/Network.h> |
| 78 | /// std::string ipAddress = kodi::network::GetIPAddress(); | 94 | /// ... |
| 79 | /// fprintf(stderr, "My IP is '%s'\n", ipAddress.c_str()); | 95 | /// std::string hostname = kodi::network::GetHostname(); |
| 80 | /// ... | 96 | /// fprintf(stderr, "My hostname is '%s'\n", hostname.c_str()); |
| 81 | /// ~~~~~~~~~~~~~ | 97 | /// ... |
| 82 | /// | 98 | /// ~~~~~~~~~~~~~ |
| 83 | inline std::string GetIPAddress() | 99 | /// |
| 100 | inline std::string ATTRIBUTE_HIDDEN GetHostname() | ||
| 101 | { | ||
| 102 | using namespace ::kodi::addon; | ||
| 103 | |||
| 104 | std::string ip; | ||
| 105 | char* string = CAddonBase::m_interface->toKodi->kodi_network->get_hostname( | ||
| 106 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 107 | if (string != nullptr) | ||
| 84 | { | 108 | { |
| 85 | std::string ip; | 109 | ip = string; |
| 86 | char* string = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->get_ip_address(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase); | 110 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string); |
| 87 | if (string != nullptr) | ||
| 88 | { | ||
| 89 | ip = string; | ||
| 90 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 91 | } | ||
| 92 | return ip; | ||
| 93 | } | 111 | } |
| 94 | //---------------------------------------------------------------------------- | 112 | return ip; |
| 95 | 113 | } | |
| 96 | //============================================================================ | 114 | //---------------------------------------------------------------------------- |
| 97 | /// | 115 | |
| 98 | /// \ingroup cpp_kodi_network | 116 | //============================================================================ |
| 99 | /// @brief URL encodes the given string | 117 | /// @ingroup cpp_kodi_network |
| 100 | /// | 118 | /// @brief Returns Kodi's HTTP UserAgent string. |
| 101 | /// This function converts the given input string to a URL encoded string and | 119 | /// |
| 102 | /// returns that as a new allocated string. All input characters that are | 120 | /// @return HTTP user agent |
| 103 | /// not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" | 121 | /// |
| 104 | /// version (%NN where NN is a two-digit hexadecimal number). | 122 | /// |
| 105 | /// | 123 | /// ------------------------------------------------------------------------ |
| 106 | /// @param[in] url The code of the message to get. | 124 | /// |
| 107 | /// @return Encoded URL string | 125 | /// **Example:** |
| 108 | /// | 126 | /// ~~~~~~~~~~~~~{.py} |
| 109 | /// | 127 | /// .. |
| 110 | /// ------------------------------------------------------------------------ | 128 | /// std::string agent = kodi::network::GetUserAgent() |
| 111 | /// | 129 | /// .. |
| 112 | /// **Example:** | 130 | /// ~~~~~~~~~~~~~ |
| 113 | /// ~~~~~~~~~~~~~{.cpp} | 131 | /// |
| 114 | /// #include <kodi/Network.h> | 132 | /// example output: |
| 115 | /// ... | 133 | /// Kodi/19.0-ALPHA1 (X11; Linux x86_64) Ubuntu/20.04 App_Bitness/64 Version/19.0-ALPHA1-Git:20200522-0076d136d3-dirty |
| 116 | /// std::string encodedUrl = kodi::network::URLEncode("François"); | 134 | /// |
| 117 | /// fprintf(stderr, "Encoded URL is '%s'\n", encodedUrl.c_str()); | 135 | inline std::string ATTRIBUTE_HIDDEN GetUserAgent() |
| 118 | /// ... | 136 | { |
| 119 | /// ~~~~~~~~~~~~~ | 137 | using namespace ::kodi::addon; |
| 120 | /// For example, the string: François ,would be encoded as: Fran%C3%A7ois | 138 | |
| 121 | /// | 139 | std::string agent; |
| 122 | inline std::string URLEncode(const std::string& url) | 140 | char* string = CAddonBase::m_interface->toKodi->kodi_network->get_user_agent( |
| 141 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 142 | if (string != nullptr) | ||
| 123 | { | 143 | { |
| 124 | std::string retString; | 144 | agent = string; |
| 125 | char* string = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->url_encode(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, url.c_str()); | 145 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string); |
| 126 | if (string != nullptr) | ||
| 127 | { | ||
| 128 | retString = string; | ||
| 129 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 130 | } | ||
| 131 | return retString; | ||
| 132 | } | 146 | } |
| 133 | //---------------------------------------------------------------------------- | 147 | return agent; |
| 134 | 148 | } | |
| 135 | //============================================================================ | 149 | //---------------------------------------------------------------------------- |
| 136 | /// | 150 | |
| 137 | /// \ingroup cpp_kodi_network | 151 | //============================================================================ |
| 138 | /// @brief Lookup URL in DNS cache | 152 | /// @ingroup cpp_kodi_network |
| 139 | /// | 153 | /// @brief Check given name or ip address corresponds to localhost. |
| 140 | /// This test will get DNS record for a domain. The DNS lookup is done directly | 154 | /// |
| 141 | /// against the domain's authoritative name server, so changes to DNS Records | 155 | /// @param[in] hostname Hostname to check |
| 142 | /// should show up instantly. By default, the DNS lookup tool will return an | 156 | /// @return Return true if given name or ip address corresponds to localhost |
| 143 | /// IP address if you give it a name (e.g. www.example.com) | 157 | /// |
| 144 | /// | 158 | /// |
| 145 | /// @param[in] hostName The code of the message to get. | 159 | /// ------------------------------------------------------------------------ |
| 146 | /// @param[out] ipAddress Returned address | 160 | /// |
| 147 | /// @return true if successfull | 161 | /// **Example:** |
| 148 | /// | 162 | /// ~~~~~~~~~~~~~{.cpp} |
| 149 | /// | 163 | /// #include <kodi/Network.h> |
| 150 | /// ------------------------------------------------------------------------ | 164 | /// ... |
| 151 | /// | 165 | /// if (kodi::network::IsLocalHost("127.0.0.1")) |
| 152 | /// **Example:** | 166 | /// fprintf(stderr, "Is localhost\n"); |
| 153 | /// ~~~~~~~~~~~~~{.cpp} | 167 | /// ... |
| 154 | /// #include <kodi/Network.h> | 168 | /// ~~~~~~~~~~~~~ |
| 155 | /// ... | 169 | /// |
| 156 | /// std::string ipAddress; | 170 | inline bool ATTRIBUTE_HIDDEN IsLocalHost(const std::string& hostname) |
| 157 | /// bool ret = kodi::network::DNSLookup("www.google.com", ipAddress); | 171 | { |
| 158 | /// fprintf(stderr, "DNSLookup returned for www.google.com the IP '%s', call was %s\n", ipAddress.c_str(), ret ? "ok" : "failed"); | 172 | using namespace ::kodi::addon; |
| 159 | /// ... | 173 | |
| 160 | /// ~~~~~~~~~~~~~ | 174 | return CAddonBase::m_interface->toKodi->kodi_network->is_local_host( |
| 161 | /// | 175 | CAddonBase::m_interface->toKodi->kodiBase, hostname.c_str()); |
| 162 | inline bool DNSLookup(const std::string& hostName, std::string& ipAddress) | 176 | } |
| 177 | //---------------------------------------------------------------------------- | ||
| 178 | |||
| 179 | //============================================================================== | ||
| 180 | /// @ingroup cpp_kodi_network | ||
| 181 | /// @brief Checks whether the specified path refers to a local network. | ||
| 182 | /// | ||
| 183 | /// @param[in] hostname Hostname to check | ||
| 184 | /// @param[in] offLineCheck Check if in private range, see https://en.wikipedia.org/wiki/Private_network | ||
| 185 | /// @return True if host is on a LAN, false otherwise | ||
| 186 | /// | ||
| 187 | inline bool ATTRIBUTE_HIDDEN IsHostOnLAN(const std::string& hostname, bool offLineCheck = false) | ||
| 188 | { | ||
| 189 | using namespace kodi::addon; | ||
| 190 | |||
| 191 | return CAddonBase::m_interface->toKodi->kodi_network->is_host_on_lan( | ||
| 192 | CAddonBase::m_interface->toKodi->kodiBase, hostname.c_str(), offLineCheck); | ||
| 193 | } | ||
| 194 | //------------------------------------------------------------------------------ | ||
| 195 | |||
| 196 | //============================================================================ | ||
| 197 | /// @ingroup cpp_kodi_network | ||
| 198 | /// @brief URL encodes the given string | ||
| 199 | /// | ||
| 200 | /// This function converts the given input string to a URL encoded string and | ||
| 201 | /// returns that as a new allocated string. All input characters that are | ||
| 202 | /// not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" | ||
| 203 | /// version (%NN where NN is a two-digit hexadecimal number). | ||
| 204 | /// | ||
| 205 | /// @param[in] url The code of the message to get. | ||
| 206 | /// @return Encoded URL string | ||
| 207 | /// | ||
| 208 | /// | ||
| 209 | /// ------------------------------------------------------------------------ | ||
| 210 | /// | ||
| 211 | /// **Example:** | ||
| 212 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 213 | /// #include <kodi/Network.h> | ||
| 214 | /// ... | ||
| 215 | /// std::string encodedUrl = kodi::network::URLEncode("François"); | ||
| 216 | /// fprintf(stderr, "Encoded URL is '%s'\n", encodedUrl.c_str()); | ||
| 217 | /// ... | ||
| 218 | /// ~~~~~~~~~~~~~ | ||
| 219 | /// For example, the string: François ,would be encoded as: Fran%C3%A7ois | ||
| 220 | /// | ||
| 221 | inline std::string ATTRIBUTE_HIDDEN URLEncode(const std::string& url) | ||
| 222 | { | ||
| 223 | using namespace ::kodi::addon; | ||
| 224 | |||
| 225 | std::string retString; | ||
| 226 | char* string = CAddonBase::m_interface->toKodi->kodi_network->url_encode( | ||
| 227 | CAddonBase::m_interface->toKodi->kodiBase, url.c_str()); | ||
| 228 | if (string != nullptr) | ||
| 229 | { | ||
| 230 | retString = string; | ||
| 231 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 232 | } | ||
| 233 | return retString; | ||
| 234 | } | ||
| 235 | //---------------------------------------------------------------------------- | ||
| 236 | |||
| 237 | //============================================================================ | ||
| 238 | /// @ingroup cpp_kodi_network | ||
| 239 | /// @brief Lookup URL in DNS cache | ||
| 240 | /// | ||
| 241 | /// This test will get DNS record for a domain. The DNS lookup is done directly | ||
| 242 | /// against the domain's authoritative name server, so changes to DNS Records | ||
| 243 | /// should show up instantly. By default, the DNS lookup tool will return an | ||
| 244 | /// IP address if you give it a name (e.g. www.example.com) | ||
| 245 | /// | ||
| 246 | /// @param[in] hostName The code of the message to get. | ||
| 247 | /// @param[out] ipAddress Returned address | ||
| 248 | /// @return true if successfull | ||
| 249 | /// | ||
| 250 | /// | ||
| 251 | /// ------------------------------------------------------------------------ | ||
| 252 | /// | ||
| 253 | /// **Example:** | ||
| 254 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 255 | /// #include <kodi/Network.h> | ||
| 256 | /// ... | ||
| 257 | /// std::string ipAddress; | ||
| 258 | /// bool ret = kodi::network::DNSLookup("www.google.com", ipAddress); | ||
| 259 | /// fprintf(stderr, "DNSLookup returned for www.google.com the IP '%s', call was %s\n", ipAddress.c_str(), ret ? "ok" : "failed"); | ||
| 260 | /// ... | ||
| 261 | /// ~~~~~~~~~~~~~ | ||
| 262 | /// | ||
| 263 | inline bool ATTRIBUTE_HIDDEN DNSLookup(const std::string& hostName, std::string& ipAddress) | ||
| 264 | { | ||
| 265 | using namespace ::kodi::addon; | ||
| 266 | |||
| 267 | bool ret = false; | ||
| 268 | char* string = CAddonBase::m_interface->toKodi->kodi_network->dns_lookup( | ||
| 269 | CAddonBase::m_interface->toKodi->kodiBase, hostName.c_str(), &ret); | ||
| 270 | if (string != nullptr) | ||
| 163 | { | 271 | { |
| 164 | bool ret = false; | 272 | ipAddress = string; |
| 165 | char* string = ::kodi::addon::CAddonBase::m_interface->toKodi->kodi_network->dns_lookup(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, hostName.c_str(), &ret); | 273 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string); |
| 166 | if (string != nullptr) | ||
| 167 | { | ||
| 168 | ipAddress = string; | ||
| 169 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, string); | ||
| 170 | } | ||
| 171 | return ret; | ||
| 172 | } | 274 | } |
| 173 | //---------------------------------------------------------------------------- | 275 | return ret; |
| 276 | } | ||
| 277 | //---------------------------------------------------------------------------- | ||
| 174 | 278 | ||
| 175 | } /* namespace network */ | 279 | } /* namespace network */ |
| 176 | } /* namespace kodi */ | 280 | } /* namespace kodi */ |
| 281 | |||
| 282 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCodec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCodec.h index 729cdc0..e030371 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCodec.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCodec.h | |||
| @@ -8,15 +8,119 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | enum STREAMCODEC_PROFILE | 11 | #ifdef __cplusplus |
| 12 | extern "C" | ||
| 12 | { | 13 | { |
| 13 | CodecProfileUnknown = 0, | 14 | #endif /* __cplusplus */ |
| 14 | CodecProfileNotNeeded, | 15 | |
| 15 | H264CodecProfileBaseline, | 16 | //============================================================================== |
| 16 | H264CodecProfileMain, | 17 | /// @ingroup cpp_kodi_addon_videocodec_Defs_VIDEOCODEC_INITDATA |
| 17 | H264CodecProfileExtended, | 18 | /// @brief The standard defines several sets of capabilities, which are referred |
| 18 | H264CodecProfileHigh, | 19 | /// to as profiles, targeting specific classes of applications. |
| 19 | H264CodecProfileHigh10, | 20 | //@{ |
| 20 | H264CodecProfileHigh422, | 21 | enum STREAMCODEC_PROFILE |
| 21 | H264CodecProfileHigh444Predictive | 22 | { |
| 22 | }; | 23 | /// @brief Unknown codec profile |
| 24 | CodecProfileUnknown = 0, | ||
| 25 | |||
| 26 | /// @brief If a codec profile is not required | ||
| 27 | CodecProfileNotNeeded, | ||
| 28 | |||
| 29 | /// @brief **H264** Baseline Profile (BP, 66) | ||
| 30 | /// | ||
| 31 | /// Primarily for low-cost applications that require additional data loss | ||
| 32 | /// robustness, this profile is used in some videoconferencing and mobile | ||
| 33 | /// applications. This profile includes all features that are supported | ||
| 34 | /// in the Constrained Baseline Profile, plus three additional features | ||
| 35 | /// that can be used for loss robustness (or for other purposes such as | ||
| 36 | /// low-delay multi-point video stream compositing). The importance of | ||
| 37 | /// this profile has faded somewhat since the definition of the Constrained | ||
| 38 | /// Baseline Profile in 2009. All Constrained Baseline Profile bitstreams | ||
| 39 | /// are also considered to be Baseline Profile bitstreams, as these two | ||
| 40 | /// profiles share the same profile identifier code value. | ||
| 41 | H264CodecProfileBaseline, | ||
| 42 | |||
| 43 | /// @brief **H264** Main Profile (MP, 77) | ||
| 44 | /// | ||
| 45 | /// This profile is used for standard-definition digital TV broadcasts that | ||
| 46 | /// use the MPEG-4 format as defined in the | ||
| 47 | /// [DVB standard](http://www.etsi.org/deliver/etsi_ts/101100_101199/101154/01.09.01_60/ts_101154v010901p.pdf). | ||
| 48 | /// It is not, however, used for high-definition television broadcasts, as the | ||
| 49 | /// importance of this profile faded when the High Profile was developed | ||
| 50 | /// in 2004 for that application. | ||
| 51 | H264CodecProfileMain, | ||
| 52 | |||
| 53 | /// @brief **H264** Extended Profile (XP, 88) | ||
| 54 | /// | ||
| 55 | /// Intended as the streaming video profile, this profile has relatively high | ||
| 56 | /// compression capability and some extra tricks for robustness to data losses | ||
| 57 | /// and server stream switching. | ||
| 58 | H264CodecProfileExtended, | ||
| 59 | |||
| 60 | /// @brief **H264** High Profile (HiP, 100) | ||
| 61 | /// | ||
| 62 | /// The primary profile for broadcast and disc storage applications, | ||
| 63 | /// particularly for high-definition television applications (for example, | ||
| 64 | /// this is the profile adopted by the [Blu-ray Disc](https://en.wikipedia.org/wiki/Blu-ray_Disc) | ||
| 65 | /// storage format and the [DVB](https://en.wikipedia.org/wiki/Digital_Video_Broadcasting) | ||
| 66 | /// HDTV broadcast service). | ||
| 67 | H264CodecProfileHigh, | ||
| 68 | |||
| 69 | /// @brief **H264** High 10 Profile (Hi10P, 110) | ||
| 70 | /// | ||
| 71 | /// Going beyond typical mainstream consumer product capabilities, this | ||
| 72 | /// profile builds on top of the High Profile, adding support for up to 10 | ||
| 73 | /// bits per sample of decoded picture precision. | ||
| 74 | H264CodecProfileHigh10, | ||
| 75 | |||
| 76 | /// @brief **H264** High 4:2:2 Profile (Hi422P, 122) | ||
| 77 | /// | ||
| 78 | /// Primarily targeting professional applications that use interlaced video, | ||
| 79 | /// this profile builds on top of the High 10 Profile, adding support for the | ||
| 80 | /// 4:2:2 chroma sampling format while using up to 10 bits per sample of | ||
| 81 | /// decoded picture precision. | ||
| 82 | H264CodecProfileHigh422, | ||
| 83 | |||
| 84 | /// @brief **H264** High 4:4:4 Predictive Profile (Hi444PP, 244) | ||
| 85 | /// | ||
| 86 | /// This profile builds on top of the High 4:2:2 Profile, supporting up to | ||
| 87 | /// 4:4:4 chroma sampling, up to 14 bits per sample, and additionally | ||
| 88 | /// supporting efficient lossless region coding and the coding of each | ||
| 89 | /// picture as three separate color planes. | ||
| 90 | H264CodecProfileHigh444Predictive, | ||
| 91 | |||
| 92 | /// @brief **VP9** profile 0 | ||
| 93 | /// | ||
| 94 | /// There are several variants of the VP9 format (known as "coding profiles"), | ||
| 95 | /// which successively allow more features; profile 0 is the basic variant, | ||
| 96 | /// requiring the least from a hardware implementation. | ||
| 97 | /// | ||
| 98 | /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit/sample, | ||
| 99 | /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0 | ||
| 100 | VP9CodecProfile0 = 20, | ||
| 101 | |||
| 102 | /// @brief **VP9** profile 1 | ||
| 103 | /// | ||
| 104 | /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit, | ||
| 105 | /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4 | ||
| 106 | VP9CodecProfile1, | ||
| 107 | |||
| 108 | /// @brief **VP9** profile 2 | ||
| 109 | /// | ||
| 110 | /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit, | ||
| 111 | /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0 | ||
| 112 | VP9CodecProfile2, | ||
| 113 | |||
| 114 | /// @brief **VP9** profile 3 | ||
| 115 | /// | ||
| 116 | /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit, | ||
| 117 | /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4, | ||
| 118 | /// see [VP9 Bitstream & Decoding Process Specification](https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.6-20160331-draft.pdf) | ||
| 119 | VP9CodecProfile3, | ||
| 120 | }; | ||
| 121 | //@} | ||
| 122 | //------------------------------------------------------------------------------ | ||
| 123 | |||
| 124 | #ifdef __cplusplus | ||
| 125 | } /* extern "C" */ | ||
| 126 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCrypto.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCrypto.h index dcb7896..8008aa1 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCrypto.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/StreamCrypto.h | |||
| @@ -8,19 +8,35 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | typedef struct CRYPTO_INFO | 11 | #include <inttypes.h> |
| 12 | #include <string.h> | ||
| 13 | |||
| 14 | #define STREAMCRYPTO_VERSION_LEVEL 1 | ||
| 15 | |||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 12 | { | 18 | { |
| 13 | enum CRYPTO_KEY_SYSTEM : uint8_t | 19 | #endif /* __cplusplus */ |
| 20 | |||
| 21 | typedef struct CRYPTO_INFO | ||
| 14 | { | 22 | { |
| 15 | CRYPTO_KEY_SYSTEM_NONE = 0, | 23 | enum CRYPTO_KEY_SYSTEM : uint8_t |
| 16 | CRYPTO_KEY_SYSTEM_WIDEVINE, | 24 | { |
| 17 | CRYPTO_KEY_SYSTEM_PLAYREADY, | 25 | CRYPTO_KEY_SYSTEM_NONE = 0, |
| 18 | CRYPTO_KEY_SYSTEM_COUNT | 26 | CRYPTO_KEY_SYSTEM_WIDEVINE, |
| 19 | } m_CryptoKeySystem; /*!< @brief keysystem for encrypted media, KEY_SYSTEM_NONE for unencrypted media */ | 27 | CRYPTO_KEY_SYSTEM_PLAYREADY, |
| 20 | 28 | CRYPTO_KEY_SYSTEM_WISEPLAY, | |
| 21 | static const uint8_t FLAG_SECURE_DECODER = 1; /*!< @brief is set in flags if decoding has to be done in TEE environment */ | 29 | CRYPTO_KEY_SYSTEM_COUNT |
| 22 | 30 | } m_CryptoKeySystem; /*!< @brief keysystem for encrypted media, KEY_SYSTEM_NONE for unencrypted media */ | |
| 23 | uint8_t flags; | 31 | |
| 24 | uint16_t m_CryptoSessionIdSize; /*!< @brief The size of the crypto session key id */ | 32 | static const uint8_t FLAG_SECURE_DECODER = |
| 25 | const char *m_CryptoSessionId; /*!< @brief The crypto session key id */ | 33 | 1; /*!< @brief is set in flags if decoding has to be done in TEE environment */ |
| 26 | } CRYPTO_INFO; | 34 | |
| 35 | uint8_t flags; | ||
| 36 | uint16_t m_CryptoSessionIdSize; /*!< @brief The size of the crypto session key id */ | ||
| 37 | const char* m_CryptoSessionId; /*!< @brief The crypto session key id */ | ||
| 38 | } CRYPTO_INFO; | ||
| 39 | |||
| 40 | #ifdef __cplusplus | ||
| 41 | } /* extern "C" */ | ||
| 42 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h index 7407830..25e39e2 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h | |||
| @@ -16,45 +16,51 @@ | |||
| 16 | #endif | 16 | #endif |
| 17 | #include <stdint.h> | 17 | #include <stdint.h> |
| 18 | 18 | ||
| 19 | namespace kodi { namespace addon { class CInstanceAudioDecoder; }} | 19 | namespace kodi |
| 20 | { | ||
| 21 | namespace addon | ||
| 22 | { | ||
| 23 | class CInstanceAudioDecoder; | ||
| 24 | } /* namespace addon */ | ||
| 25 | } /* namespace kodi */ | ||
| 20 | 26 | ||
| 21 | extern "C" | 27 | extern "C" |
| 22 | { | 28 | { |
| 23 | 29 | ||
| 24 | typedef struct AddonProps_AudioDecoder | 30 | typedef struct AddonProps_AudioDecoder |
| 25 | { | 31 | { |
| 26 | int dummy; | 32 | int dummy; |
| 27 | } AddonProps_AudioDecoder; | 33 | } AddonProps_AudioDecoder; |
| 28 | 34 | ||
| 29 | typedef struct AddonToKodiFuncTable_AudioDecoder | 35 | typedef struct AddonToKodiFuncTable_AudioDecoder |
| 30 | { | 36 | { |
| 31 | void* kodiInstance; | 37 | void* kodiInstance; |
| 32 | } AddonToKodiFuncTable_AudioDecoder; | 38 | } AddonToKodiFuncTable_AudioDecoder; |
| 33 | 39 | ||
| 34 | struct AddonInstance_AudioDecoder; | 40 | struct AddonInstance_AudioDecoder; |
| 35 | typedef struct KodiToAddonFuncTable_AudioDecoder | 41 | typedef struct KodiToAddonFuncTable_AudioDecoder |
| 36 | { | 42 | { |
| 37 | kodi::addon::CInstanceAudioDecoder* addonInstance; | 43 | kodi::addon::CInstanceAudioDecoder* addonInstance; |
| 38 | bool (__cdecl* init) (const AddonInstance_AudioDecoder* instance, | 44 | bool (__cdecl* init)(const AddonInstance_AudioDecoder* instance, |
| 39 | const char* file, unsigned int filecache, | 45 | const char* file, unsigned int filecache, |
| 40 | int* channels, int* samplerate, | 46 | int* channels, int* samplerate, |
| 41 | int* bitspersample, int64_t* totaltime, | 47 | int* bitspersample, int64_t* totaltime, |
| 42 | int* bitrate, AEDataFormat* format, | 48 | int* bitrate, AEDataFormat* format, |
| 43 | const AEChannel** info); | 49 | const AEChannel** info); |
| 44 | int (__cdecl* read_pcm) (const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize); | 50 | int (__cdecl* read_pcm)(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize); |
| 45 | int64_t (__cdecl* seek) (const AddonInstance_AudioDecoder* instance, int64_t time); | 51 | int64_t (__cdecl* seek)(const AddonInstance_AudioDecoder* instance, int64_t time); |
| 46 | bool (__cdecl* read_tag) (const AddonInstance_AudioDecoder* instance, | 52 | bool (__cdecl* read_tag)(const AddonInstance_AudioDecoder* instance, |
| 47 | const char* file, char* title, | 53 | const char* file, char* title, |
| 48 | char* artist, int* length); | 54 | char* artist, int* length); |
| 49 | int (__cdecl* track_count) (const AddonInstance_AudioDecoder* instance, const char* file); | 55 | int (__cdecl* track_count)(const AddonInstance_AudioDecoder* instance, const char* file); |
| 50 | } KodiToAddonFuncTable_AudioDecoder; | 56 | } KodiToAddonFuncTable_AudioDecoder; |
| 51 | 57 | ||
| 52 | typedef struct AddonInstance_AudioDecoder | 58 | typedef struct AddonInstance_AudioDecoder |
| 53 | { | 59 | { |
| 54 | AddonProps_AudioDecoder props; | 60 | AddonProps_AudioDecoder props; |
| 55 | AddonToKodiFuncTable_AudioDecoder toKodi; | 61 | AddonToKodiFuncTable_AudioDecoder toKodi; |
| 56 | KodiToAddonFuncTable_AudioDecoder toAddon; | 62 | KodiToAddonFuncTable_AudioDecoder toAddon; |
| 57 | } AddonInstance_AudioDecoder; | 63 | } AddonInstance_AudioDecoder; |
| 58 | 64 | ||
| 59 | } /* extern "C" */ | 65 | } /* extern "C" */ |
| 60 | 66 | ||
| @@ -63,167 +69,295 @@ namespace kodi | |||
| 63 | namespace addon | 69 | namespace addon |
| 64 | { | 70 | { |
| 65 | 71 | ||
| 66 | class CInstanceAudioDecoder : public IAddonInstance | 72 | //============================================================================== |
| 73 | /// | ||
| 74 | /// \addtogroup cpp_kodi_addon_audiodecoder | ||
| 75 | /// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder } | ||
| 76 | /// **Audio decoder add-on instance** | ||
| 77 | /// | ||
| 78 | /// For audio decoders as binary add-ons. This class implements a way to handle | ||
| 79 | /// special types of audio files. | ||
| 80 | /// | ||
| 81 | /// The add-on handles loading of the source file and outputting the audio stream | ||
| 82 | /// for consumption by the player. | ||
| 83 | /// | ||
| 84 | /// The addon.xml defines the capabilities of this add-on. | ||
| 85 | /// | ||
| 86 | /// @note The option to have multiple instances is possible with audio-decoder | ||
| 87 | /// add-ons. This is useful, since some playback engines are riddled by global | ||
| 88 | /// variables, making decoding of multiple streams using the same instance | ||
| 89 | /// impossible. | ||
| 90 | /// | ||
| 91 | /// | ||
| 92 | /// ---------------------------------------------------------------------------- | ||
| 93 | /// | ||
| 94 | /// **Here's an example on addon.xml:** | ||
| 95 | /// ~~~~~~~~~~~~~{.xml} | ||
| 96 | /// <extension | ||
| 97 | /// point="kodi.audiodecoder" | ||
| 98 | /// name="2sf" | ||
| 99 | /// extension=".2sf|.mini2sf" | ||
| 100 | /// tags="true" | ||
| 101 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 102 | /// ~~~~~~~~~~~~~ | ||
| 103 | /// | ||
| 104 | /// Description to audio decoder related addon.xml values: | ||
| 105 | /// | Name | Description | ||
| 106 | /// |:------------------------------|---------------------------------------- | ||
| 107 | /// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>. | ||
| 108 | /// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. | ||
| 109 | /// | <b>`name`</b> | The name of the decoder used in Kodi for display. | ||
| 110 | /// | <b>`extension`</b> | The file extensions / styles supported by this addon. | ||
| 111 | /// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, \ref CInstanceAudioDecoder::ReadTag is used and must be implemented. | ||
| 112 | /// | ||
| 113 | /// -------------------------------------------------------------------------- | ||
| 114 | /// | ||
| 115 | /// **Here is a code example how this addon is used:** | ||
| 116 | /// | ||
| 117 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 118 | /// #include <kodi/addon-instance/AudioDecoder.h> | ||
| 119 | /// | ||
| 120 | /// class CMyAudioDecoder : public ::kodi::addon::CInstanceAudioDecoder | ||
| 121 | /// { | ||
| 122 | /// public: | ||
| 123 | /// CMyAudioDecoder(KODI_HANDLE instance); | ||
| 124 | /// | ||
| 125 | /// bool Init(const std::string& filename, unsigned int filecache, | ||
| 126 | /// int& channels, int& samplerate, | ||
| 127 | /// int& bitspersample, int64_t& totaltime, | ||
| 128 | /// int& bitrate, AEDataFormat& format, | ||
| 129 | /// std::vector<AEChannel>& channellist) override; | ||
| 130 | /// int ReadPCM(uint8_t* buffer, int size, int& actualsize) override; | ||
| 131 | /// }; | ||
| 132 | /// | ||
| 133 | /// CMyAudioDecoder::CMyAudioDecoder(KODI_HANDLE instance) | ||
| 134 | /// : CInstanceAudioDecoder(instance) | ||
| 135 | /// { | ||
| 136 | /// ... | ||
| 137 | /// } | ||
| 138 | /// | ||
| 139 | /// bool CMyAudioDecoder::Init(const std::string& filename, unsigned int filecache, | ||
| 140 | /// int& channels, int& samplerate, | ||
| 141 | /// int& bitspersample, int64_t& totaltime, | ||
| 142 | /// int& bitrate, AEDataFormat& format, | ||
| 143 | /// std::vector<AEChannel>& channellist) | ||
| 144 | /// { | ||
| 145 | /// ... | ||
| 146 | /// return true; | ||
| 147 | /// } | ||
| 148 | /// | ||
| 149 | /// int CMyAudioDecoder::ReadPCM(uint8_t* buffer, int size, int& actualsize) | ||
| 150 | /// { | ||
| 151 | /// ... | ||
| 152 | /// return 0; | ||
| 153 | /// } | ||
| 154 | /// | ||
| 155 | /// | ||
| 156 | /// /*----------------------------------------------------------------------*/ | ||
| 157 | /// | ||
| 158 | /// class CMyAddon : public ::kodi::addon::CAddonBase | ||
| 159 | /// { | ||
| 160 | /// public: | ||
| 161 | /// CMyAddon() { } | ||
| 162 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 163 | /// std::string instanceID, | ||
| 164 | /// KODI_HANDLE instance, | ||
| 165 | /// KODI_HANDLE& addonInstance) override; | ||
| 166 | /// }; | ||
| 167 | /// | ||
| 168 | /// /* If you use only one instance in your add-on, can be instanceType and | ||
| 169 | /// * instanceID ignored */ | ||
| 170 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 171 | /// std::string instanceID, | ||
| 172 | /// KODI_HANDLE instance, | ||
| 173 | /// KODI_HANDLE& addonInstance) | ||
| 174 | /// { | ||
| 175 | /// if (instanceType == ADDON_INSTANCE_AUDIODECODER) | ||
| 176 | /// { | ||
| 177 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my audio decoder"); | ||
| 178 | /// addonInstance = new CMyAudioDecoder(instance); | ||
| 179 | /// return ADDON_STATUS_OK; | ||
| 180 | /// } | ||
| 181 | /// else if (...) | ||
| 182 | /// { | ||
| 183 | /// ... | ||
| 184 | /// } | ||
| 185 | /// return ADDON_STATUS_UNKNOWN; | ||
| 186 | /// } | ||
| 187 | /// | ||
| 188 | /// ADDONCREATOR(CMyAddon) | ||
| 189 | /// ~~~~~~~~~~~~~ | ||
| 190 | /// | ||
| 191 | /// The destruction of the example class `CMyAudioDecoder` is called from | ||
| 192 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 193 | /// | ||
| 194 | class ATTRIBUTE_HIDDEN CInstanceAudioDecoder : public IAddonInstance | ||
| 195 | { | ||
| 196 | public: | ||
| 197 | //========================================================================== | ||
| 198 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 199 | /// @brief Class constructor | ||
| 200 | /// | ||
| 201 | /// @param[in] instance The addon instance class handler given by Kodi | ||
| 202 | /// at \ref kodi::addon::CAddonBase::CreateInstance(...) | ||
| 203 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 204 | /// allow compatibility to older Kodi versions. | ||
| 205 | /// @note Recommended to set. | ||
| 206 | /// | ||
| 207 | explicit CInstanceAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 208 | : IAddonInstance(ADDON_INSTANCE_AUDIODECODER, | ||
| 209 | !kodiVersion.empty() ? kodiVersion | ||
| 210 | : GetKodiTypeVersion(ADDON_INSTANCE_AUDIODECODER)) | ||
| 67 | { | 211 | { |
| 68 | public: | 212 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 69 | //========================================================================== | 213 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation of multiple together with single instance way is not allowed!"); |
| 70 | /// @brief Class constructor | ||
| 71 | /// | ||
| 72 | /// @param[in] instance The from Kodi given instance given be | ||
| 73 | /// add-on CreateInstance call with instance | ||
| 74 | /// id ADDON_INSTANCE_AUDIODECODER. | ||
| 75 | explicit CInstanceAudioDecoder(KODI_HANDLE instance) | ||
| 76 | : IAddonInstance(ADDON_INSTANCE_AUDIODECODER) | ||
| 77 | { | ||
| 78 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 79 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation of multiple together with single instance way is not allowed!"); | ||
| 80 | 214 | ||
| 81 | SetAddonStruct(instance); | 215 | SetAddonStruct(instance); |
| 82 | } | 216 | } |
| 83 | //-------------------------------------------------------------------------- | 217 | //-------------------------------------------------------------------------- |
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 87 | /// @brief Initialize a decoder | ||
| 88 | /// | ||
| 89 | /// @param[in] filename The file to read | ||
| 90 | /// @param[in] filecache The file cache size | ||
| 91 | /// @param[out] channels Number of channels in output stream | ||
| 92 | /// @param[out] samplerate Samplerate of output stream | ||
| 93 | /// @param[out] bitspersample Bits per sample in output stream | ||
| 94 | /// @param[out] totaltime Total time for stream | ||
| 95 | /// @param[out] bitrate Average bitrate of input stream | ||
| 96 | /// @param[out] format Data format for output stream | ||
| 97 | /// @param[out] channellist Channel mapping for output stream | ||
| 98 | /// @return true if successfully done, otherwise | ||
| 99 | /// false | ||
| 100 | /// | ||
| 101 | virtual bool Init(const std::string& filename, unsigned int filecache, | ||
| 102 | int& channels, int& samplerate, | ||
| 103 | int& bitspersample, int64_t& totaltime, | ||
| 104 | int& bitrate, AEDataFormat& format, | ||
| 105 | std::vector<AEChannel>& channellist) = 0; | ||
| 106 | //-------------------------------------------------------------------------- | ||
| 107 | |||
| 108 | //========================================================================== | ||
| 109 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 110 | /// @brief Produce some noise | ||
| 111 | /// | ||
| 112 | /// @param[in] buffer Output buffer | ||
| 113 | /// @param[in] size Size of output buffer | ||
| 114 | /// @param[out] actualsize Actual number of bytes written to output buffer | ||
| 115 | /// @return Return with following possible values: | ||
| 116 | /// | Value | Description | | ||
| 117 | /// |:-----:|:-----------------------------| | ||
| 118 | /// | 0 | on success | ||
| 119 | /// | -1 | on end of stream | ||
| 120 | /// | 1 | on failure | ||
| 121 | /// | ||
| 122 | virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) = 0; | ||
| 123 | //-------------------------------------------------------------------------- | ||
| 124 | |||
| 125 | //========================================================================== | ||
| 126 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 127 | /// @brief Seek in output stream | ||
| 128 | /// | ||
| 129 | /// @param[in] time Time position to seek to in milliseconds | ||
| 130 | /// @return Time position seek ended up on | ||
| 131 | /// | ||
| 132 | virtual int64_t Seek(int64_t time) { return time; } | ||
| 133 | //-------------------------------------------------------------------------- | ||
| 134 | |||
| 135 | //========================================================================== | ||
| 136 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 137 | /// @brief Read tag of a file | ||
| 138 | /// | ||
| 139 | /// @param[in] file File to read tag for | ||
| 140 | /// @param[out] title Title of file | ||
| 141 | /// @param[out] artist Artist of file | ||
| 142 | /// @param[out] length Length of file | ||
| 143 | /// @return True on success, false on failure | ||
| 144 | /// | ||
| 145 | virtual bool ReadTag(const std::string& file, std::string& title, std::string& artist, int& length) { return false; } | ||
| 146 | //-------------------------------------------------------------------------- | ||
| 147 | |||
| 148 | //========================================================================== | ||
| 149 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 150 | /// @brief Get number of tracks in a file | ||
| 151 | /// | ||
| 152 | /// @param[in] file File to read tag for | ||
| 153 | /// @return Number of tracks in file | ||
| 154 | /// | ||
| 155 | virtual int TrackCount(const std::string& file) { return 1; } | ||
| 156 | //-------------------------------------------------------------------------- | ||
| 157 | |||
| 158 | private: | ||
| 159 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 160 | { | ||
| 161 | if (instance == nullptr) | ||
| 162 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 163 | 218 | ||
| 164 | m_instanceData = static_cast<AddonInstance_AudioDecoder*>(instance); | 219 | //========================================================================== |
| 220 | /// @ingroup cpp_kodi_addon_audiodecoder | ||
| 221 | /// @brief Initialize a decoder | ||
| 222 | /// | ||
| 223 | /// @param[in] filename The file to read | ||
| 224 | /// @param[in] filecache The file cache size | ||
| 225 | /// @param[out] channels Number of channels in output stream | ||
| 226 | /// @param[out] samplerate Samplerate of output stream | ||
| 227 | /// @param[out] bitspersample Bits per sample in output stream | ||
| 228 | /// @param[out] totaltime Total time for stream | ||
| 229 | /// @param[out] bitrate Average bitrate of input stream | ||
| 230 | /// @param[out] format Data format for output stream | ||
| 231 | /// @param[out] channellist Channel mapping for output stream | ||
| 232 | /// @return true if successfully done, otherwise | ||
| 233 | /// false | ||
| 234 | /// | ||
| 235 | virtual bool Init(const std::string& filename, unsigned int filecache, | ||
| 236 | int& channels, int& samplerate, | ||
| 237 | int& bitspersample, int64_t& totaltime, | ||
| 238 | int& bitrate, AEDataFormat& format, | ||
| 239 | std::vector<AEChannel>& channellist) = 0; | ||
| 240 | //-------------------------------------------------------------------------- | ||
| 165 | 241 | ||
| 166 | m_instanceData->toAddon.addonInstance = this; | 242 | //========================================================================== |
| 167 | m_instanceData->toAddon.init = ADDON_Init; | 243 | /// @ingroup cpp_kodi_addon_audiodecoder |
| 168 | m_instanceData->toAddon.read_pcm = ADDON_ReadPCM; | 244 | /// @brief Produce some noise |
| 169 | m_instanceData->toAddon.seek = ADDON_Seek; | 245 | /// |
| 170 | m_instanceData->toAddon.read_tag = ADDON_ReadTag; | 246 | /// @param[in] buffer Output buffer |
| 171 | m_instanceData->toAddon.track_count = ADDON_TrackCount; | 247 | /// @param[in] size Size of output buffer |
| 172 | } | 248 | /// @param[out] actualsize Actual number of bytes written to output buffer |
| 249 | /// @return Return with following possible values: | ||
| 250 | /// | Value | Description | | ||
| 251 | /// |:-----:|:-----------------------------| | ||
| 252 | /// | 0 | on success | ||
| 253 | /// | -1 | on end of stream | ||
| 254 | /// | 1 | on failure | ||
| 255 | /// | ||
| 256 | virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) = 0; | ||
| 257 | //-------------------------------------------------------------------------- | ||
| 173 | 258 | ||
| 174 | inline static bool ADDON_Init(const AddonInstance_AudioDecoder* instance, const char* file, unsigned int filecache, | 259 | //========================================================================== |
| 175 | int* channels, int* samplerate, | 260 | /// @ingroup cpp_kodi_addon_audiodecoder |
| 176 | int* bitspersample, int64_t* totaltime, | 261 | /// @brief Seek in output stream |
| 177 | int* bitrate, AEDataFormat* format, | 262 | /// |
| 178 | const AEChannel** info) | 263 | /// @param[in] time Time position to seek to in milliseconds |
| 179 | { | 264 | /// @return Time position seek ended up on |
| 180 | instance->toAddon.addonInstance->m_channelList.clear(); | 265 | /// |
| 181 | bool ret = instance->toAddon.addonInstance->Init(file, filecache, *channels, | 266 | virtual int64_t Seek(int64_t time) { return time; } |
| 182 | *samplerate, *bitspersample, | 267 | //-------------------------------------------------------------------------- |
| 183 | *totaltime, *bitrate, *format, | ||
| 184 | instance->toAddon.addonInstance->m_channelList); | ||
| 185 | if (!instance->toAddon.addonInstance->m_channelList.empty()) | ||
| 186 | { | ||
| 187 | if (instance->toAddon.addonInstance->m_channelList.back() != AE_CH_NULL) | ||
| 188 | instance->toAddon.addonInstance->m_channelList.push_back(AE_CH_NULL); | ||
| 189 | *info = instance->toAddon.addonInstance->m_channelList.data(); | ||
| 190 | } | ||
| 191 | else | ||
| 192 | *info = nullptr; | ||
| 193 | return ret; | ||
| 194 | } | ||
| 195 | 268 | ||
| 196 | inline static int ADDON_ReadPCM(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize) | 269 | //========================================================================== |
| 197 | { | 270 | /// @ingroup cpp_kodi_addon_audiodecoder |
| 198 | return instance->toAddon.addonInstance->ReadPCM(buffer, size, *actualsize); | 271 | /// @brief Read tag of a file |
| 199 | } | 272 | /// |
| 273 | /// @param[in] file File to read tag for | ||
| 274 | /// @param[out] title Title of file | ||
| 275 | /// @param[out] artist Artist of file | ||
| 276 | /// @param[out] length Length of file | ||
| 277 | /// @return True on success, false on failure | ||
| 278 | /// | ||
| 279 | virtual bool ReadTag(const std::string& file, std::string& title, std::string& artist, int& length) { return false; } | ||
| 280 | //-------------------------------------------------------------------------- | ||
| 200 | 281 | ||
| 201 | inline static int64_t ADDON_Seek(const AddonInstance_AudioDecoder* instance, int64_t time) | 282 | //========================================================================== |
| 202 | { | 283 | /// @ingroup cpp_kodi_addon_audiodecoder |
| 203 | return instance->toAddon.addonInstance->Seek(time); | 284 | /// @brief Get number of tracks in a file |
| 204 | } | 285 | /// |
| 286 | /// @param[in] file File to read tag for | ||
| 287 | /// @return Number of tracks in file | ||
| 288 | /// | ||
| 289 | virtual int TrackCount(const std::string& file) { return 1; } | ||
| 290 | //-------------------------------------------------------------------------- | ||
| 291 | |||
| 292 | private: | ||
| 293 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 294 | { | ||
| 295 | if (instance == nullptr) | ||
| 296 | throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 297 | |||
| 298 | m_instanceData = static_cast<AddonInstance_AudioDecoder*>(instance); | ||
| 205 | 299 | ||
| 206 | inline static bool ADDON_ReadTag(const AddonInstance_AudioDecoder* instance, const char* file, char* title, char* artist, int* length) | 300 | m_instanceData->toAddon.addonInstance = this; |
| 301 | m_instanceData->toAddon.init = ADDON_Init; | ||
| 302 | m_instanceData->toAddon.read_pcm = ADDON_ReadPCM; | ||
| 303 | m_instanceData->toAddon.seek = ADDON_Seek; | ||
| 304 | m_instanceData->toAddon.read_tag = ADDON_ReadTag; | ||
| 305 | m_instanceData->toAddon.track_count = ADDON_TrackCount; | ||
| 306 | } | ||
| 307 | |||
| 308 | inline static bool ADDON_Init(const AddonInstance_AudioDecoder* instance, const char* file, unsigned int filecache, | ||
| 309 | int* channels, int* samplerate, | ||
| 310 | int* bitspersample, int64_t* totaltime, | ||
| 311 | int* bitrate, AEDataFormat* format, | ||
| 312 | const AEChannel** info) | ||
| 313 | { | ||
| 314 | instance->toAddon.addonInstance->m_channelList.clear(); | ||
| 315 | bool ret = instance->toAddon.addonInstance->Init(file, filecache, *channels, | ||
| 316 | *samplerate, *bitspersample, | ||
| 317 | *totaltime, *bitrate, *format, | ||
| 318 | instance->toAddon.addonInstance->m_channelList); | ||
| 319 | if (!instance->toAddon.addonInstance->m_channelList.empty()) | ||
| 207 | { | 320 | { |
| 208 | std::string intTitle; | 321 | if (instance->toAddon.addonInstance->m_channelList.back() != AE_CH_NULL) |
| 209 | std::string intArtist; | 322 | instance->toAddon.addonInstance->m_channelList.push_back(AE_CH_NULL); |
| 210 | bool ret = instance->toAddon.addonInstance->ReadTag(file, intTitle, intArtist, *length); | 323 | *info = instance->toAddon.addonInstance->m_channelList.data(); |
| 211 | if (ret) | ||
| 212 | { | ||
| 213 | strncpy(title, intTitle.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1); | ||
| 214 | strncpy(artist, intArtist.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1); | ||
| 215 | } | ||
| 216 | return ret; | ||
| 217 | } | 324 | } |
| 325 | else | ||
| 326 | *info = nullptr; | ||
| 327 | return ret; | ||
| 328 | } | ||
| 218 | 329 | ||
| 219 | inline static int ADDON_TrackCount(const AddonInstance_AudioDecoder* instance, const char* file) | 330 | inline static int ADDON_ReadPCM(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize) |
| 331 | { | ||
| 332 | return instance->toAddon.addonInstance->ReadPCM(buffer, size, *actualsize); | ||
| 333 | } | ||
| 334 | |||
| 335 | inline static int64_t ADDON_Seek(const AddonInstance_AudioDecoder* instance, int64_t time) | ||
| 336 | { | ||
| 337 | return instance->toAddon.addonInstance->Seek(time); | ||
| 338 | } | ||
| 339 | |||
| 340 | inline static bool ADDON_ReadTag(const AddonInstance_AudioDecoder* instance, const char* file, char* title, char* artist, int* length) | ||
| 341 | { | ||
| 342 | std::string intTitle; | ||
| 343 | std::string intArtist; | ||
| 344 | bool ret = instance->toAddon.addonInstance->ReadTag(file, intTitle, intArtist, *length); | ||
| 345 | if (ret) | ||
| 220 | { | 346 | { |
| 221 | return instance->toAddon.addonInstance->TrackCount(file); | 347 | strncpy(title, intTitle.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1); |
| 348 | strncpy(artist, intArtist.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1); | ||
| 222 | } | 349 | } |
| 350 | return ret; | ||
| 351 | } | ||
| 352 | |||
| 353 | inline static int ADDON_TrackCount(const AddonInstance_AudioDecoder* instance, const char* file) | ||
| 354 | { | ||
| 355 | return instance->toAddon.addonInstance->TrackCount(file); | ||
| 356 | } | ||
| 223 | 357 | ||
| 224 | std::vector<AEChannel> m_channelList; | 358 | std::vector<AEChannel> m_channelList; |
| 225 | AddonInstance_AudioDecoder* m_instanceData; | 359 | AddonInstance_AudioDecoder* m_instanceData; |
| 226 | }; | 360 | }; |
| 227 | 361 | ||
| 228 | } /* namespace addon */ | 362 | } /* namespace addon */ |
| 229 | } /* namespace kodi */ | 363 | } /* namespace kodi */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h index b98884e..36257e1 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h | |||
| @@ -55,7 +55,7 @@ namespace kodi | |||
| 55 | namespace addon | 55 | namespace addon |
| 56 | { | 56 | { |
| 57 | 57 | ||
| 58 | class CInstanceAudioEncoder : public IAddonInstance | 58 | class ATTRIBUTE_HIDDEN CInstanceAudioEncoder : public IAddonInstance |
| 59 | { | 59 | { |
| 60 | public: | 60 | public: |
| 61 | //========================================================================== | 61 | //========================================================================== |
| @@ -64,8 +64,14 @@ namespace addon | |||
| 64 | /// @param[in] instance The from Kodi given instance given be | 64 | /// @param[in] instance The from Kodi given instance given be |
| 65 | /// add-on CreateInstance call with instance | 65 | /// add-on CreateInstance call with instance |
| 66 | /// id ADDON_INSTANCE_AUDIOENCODER. | 66 | /// id ADDON_INSTANCE_AUDIOENCODER. |
| 67 | explicit CInstanceAudioEncoder(KODI_HANDLE instance) | 67 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to |
| 68 | : IAddonInstance(ADDON_INSTANCE_AUDIOENCODER) | 68 | /// allow compatibility to older Kodi versions. |
| 69 | /// @note Recommended to set. | ||
| 70 | /// | ||
| 71 | explicit CInstanceAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 72 | : IAddonInstance(ADDON_INSTANCE_AUDIOENCODER, | ||
| 73 | !kodiVersion.empty() ? kodiVersion | ||
| 74 | : GetKodiTypeVersion(ADDON_INSTANCE_AUDIOENCODER)) | ||
| 69 | { | 75 | { |
| 70 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 76 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 71 | throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation of multiple together with single instance way is not allowed!"); | 77 | throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation of multiple together with single instance way is not allowed!"); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt index 44aaf05..8fa6e05 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt | |||
| @@ -1,9 +1,11 @@ | |||
| 1 | set(HEADERS AudioDecoder.h | 1 | set(HEADERS AudioDecoder.h |
| 2 | AudioEncoder.h | 2 | AudioEncoder.h |
| 3 | Game.h | ||
| 3 | ImageDecoder.h | 4 | ImageDecoder.h |
| 4 | Inputstream.h | 5 | Inputstream.h |
| 5 | Peripheral.h | 6 | Peripheral.h |
| 6 | PeripheralUtils.h | 7 | PeripheralUtils.h |
| 8 | PVR.h | ||
| 7 | Screensaver.h | 9 | Screensaver.h |
| 8 | VFS.h | 10 | VFS.h |
| 9 | VideoCodec.h | 11 | VideoCodec.h |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h new file mode 100644 index 0000000..a53f1e7 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h | |||
| @@ -0,0 +1,2360 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-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 | |||
| 13 | #ifdef BUILD_KODI_ADDON | ||
| 14 | #include "XBMC_vkeys.h" | ||
| 15 | #else | ||
| 16 | #include "input/XBMC_vkeys.h" | ||
| 17 | #endif | ||
| 18 | |||
| 19 | //============================================================================== | ||
| 20 | /// @addtogroup cpp_kodi_addon_game | ||
| 21 | /// | ||
| 22 | /// To use on Libretro and for stand-alone games or emulators that does not use | ||
| 23 | /// the Libretro API. | ||
| 24 | /// | ||
| 25 | /// Possible examples could be, Nvidia GameStream via Limelight or WINE capture | ||
| 26 | /// could possible through the Game API. | ||
| 27 | /// | ||
| 28 | |||
| 29 | namespace kodi | ||
| 30 | { | ||
| 31 | namespace addon | ||
| 32 | { | ||
| 33 | class CInstanceGame; | ||
| 34 | } | ||
| 35 | } // namespace kodi | ||
| 36 | |||
| 37 | extern "C" | ||
| 38 | { | ||
| 39 | |||
| 40 | //============================================================================== | ||
| 41 | /// \defgroup cpp_kodi_addon_game_Defs Definitions, structures and enumerators | ||
| 42 | /// \ingroup cpp_kodi_addon_game | ||
| 43 | /// @brief **Game add-on instance definition values** | ||
| 44 | //------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | //============================================================================== | ||
| 47 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 48 | /// @brief **Port ID used when topology is unknown** | ||
| 49 | #define DEFAULT_PORT_ID "1" | ||
| 50 | //------------------------------------------------------------------------------ | ||
| 51 | |||
| 52 | //============================================================================== | ||
| 53 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 54 | /// @brief **Game add-on error codes** | ||
| 55 | /// | ||
| 56 | /// Used as return values on most Game related functions. | ||
| 57 | /// | ||
| 58 | typedef enum GAME_ERROR | ||
| 59 | { | ||
| 60 | /// @brief no error occurred | ||
| 61 | GAME_ERROR_NO_ERROR, | ||
| 62 | |||
| 63 | /// @brief an unknown error occurred | ||
| 64 | GAME_ERROR_UNKNOWN, | ||
| 65 | |||
| 66 | /// @brief the method that the frontend called is not implemented | ||
| 67 | GAME_ERROR_NOT_IMPLEMENTED, | ||
| 68 | |||
| 69 | /// @brief the command was rejected by the game client | ||
| 70 | GAME_ERROR_REJECTED, | ||
| 71 | |||
| 72 | /// @brief the parameters of the method that was called are invalid for this operation | ||
| 73 | GAME_ERROR_INVALID_PARAMETERS, | ||
| 74 | |||
| 75 | /// @brief the command failed | ||
| 76 | GAME_ERROR_FAILED, | ||
| 77 | |||
| 78 | /// @brief no game is loaded | ||
| 79 | GAME_ERROR_NOT_LOADED, | ||
| 80 | |||
| 81 | /// @brief game requires restricted resources | ||
| 82 | GAME_ERROR_RESTRICTED, | ||
| 83 | } GAME_ERROR; | ||
| 84 | //------------------------------------------------------------------------------ | ||
| 85 | |||
| 86 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 87 | /// \defgroup cpp_kodi_addon_game_Defs_AudioStream 1. Audio stream | ||
| 88 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 89 | /// @brief **The for Audio stream used data system** | ||
| 90 | /// | ||
| 91 | /// Used to give Addon currently used audio stream configuration on Kodi and | ||
| 92 | /// arrays to give related data to Kodi on callbacks. | ||
| 93 | /// | ||
| 94 | //@{ | ||
| 95 | |||
| 96 | //============================================================================== | ||
| 97 | /// @brief **Stream Format** | ||
| 98 | /// | ||
| 99 | /// From Kodi requested specified audio sample format. | ||
| 100 | /// | ||
| 101 | typedef enum GAME_PCM_FORMAT | ||
| 102 | { | ||
| 103 | GAME_PCM_FORMAT_UNKNOWN, | ||
| 104 | |||
| 105 | /// @brief S16NE sample format | ||
| 106 | GAME_PCM_FORMAT_S16NE, | ||
| 107 | } GAME_PCM_FORMAT; | ||
| 108 | //------------------------------------------------------------------------------ | ||
| 109 | |||
| 110 | //============================================================================== | ||
| 111 | /// @brief **Audio channel** | ||
| 112 | /// | ||
| 113 | /// Channel identification flags. | ||
| 114 | /// | ||
| 115 | typedef enum GAME_AUDIO_CHANNEL | ||
| 116 | { | ||
| 117 | /// @brief Channel list terminator | ||
| 118 | GAME_CH_NULL, | ||
| 119 | |||
| 120 | /// @brief Channel front left | ||
| 121 | GAME_CH_FL, | ||
| 122 | |||
| 123 | /// @brief Channel front right | ||
| 124 | GAME_CH_FR, | ||
| 125 | |||
| 126 | /// @brief Channel front center | ||
| 127 | GAME_CH_FC, | ||
| 128 | |||
| 129 | /// @brief Channel Low Frequency Effects / Subwoofer | ||
| 130 | GAME_CH_LFE, | ||
| 131 | |||
| 132 | /// @brief Channel back left | ||
| 133 | GAME_CH_BL, | ||
| 134 | |||
| 135 | /// @brief Channel back right | ||
| 136 | GAME_CH_BR, | ||
| 137 | |||
| 138 | /// @brief Channel front left over center | ||
| 139 | GAME_CH_FLOC, | ||
| 140 | |||
| 141 | /// @brief Channel front right over center | ||
| 142 | GAME_CH_FROC, | ||
| 143 | |||
| 144 | /// @brief Channel back center | ||
| 145 | GAME_CH_BC, | ||
| 146 | |||
| 147 | /// @brief Channel surround/side left | ||
| 148 | GAME_CH_SL, | ||
| 149 | |||
| 150 | /// @brief Channel surround/side right | ||
| 151 | GAME_CH_SR, | ||
| 152 | |||
| 153 | /// @brief Channel top front left | ||
| 154 | GAME_CH_TFL, | ||
| 155 | |||
| 156 | /// @brief Channel top front right | ||
| 157 | GAME_CH_TFR, | ||
| 158 | |||
| 159 | /// @brief Channel top front center | ||
| 160 | GAME_CH_TFC, | ||
| 161 | |||
| 162 | /// @brief Channel top center | ||
| 163 | GAME_CH_TC, | ||
| 164 | |||
| 165 | /// @brief Channel top back left | ||
| 166 | GAME_CH_TBL, | ||
| 167 | |||
| 168 | /// @brief Channel top back right | ||
| 169 | GAME_CH_TBR, | ||
| 170 | |||
| 171 | /// @brief Channel top back center | ||
| 172 | GAME_CH_TBC, | ||
| 173 | |||
| 174 | /// @brief Channel bacl left over center | ||
| 175 | GAME_CH_BLOC, | ||
| 176 | |||
| 177 | /// @brief Channel back right over center | ||
| 178 | GAME_CH_BROC, | ||
| 179 | } GAME_AUDIO_CHANNEL; | ||
| 180 | //------------------------------------------------------------------------------ | ||
| 181 | |||
| 182 | //============================================================================== | ||
| 183 | /// @brief **Game audio stream properties** | ||
| 184 | /// | ||
| 185 | /// Used by Kodi to pass the currently required audio stream settings to the addon | ||
| 186 | /// | ||
| 187 | typedef struct game_stream_audio_properties | ||
| 188 | { | ||
| 189 | GAME_PCM_FORMAT format; | ||
| 190 | const GAME_AUDIO_CHANNEL* channel_map; | ||
| 191 | } ATTRIBUTE_PACKED game_stream_audio_properties; | ||
| 192 | //------------------------------------------------------------------------------ | ||
| 193 | |||
| 194 | //============================================================================== | ||
| 195 | /// @brief **Audio stream packet** | ||
| 196 | /// | ||
| 197 | /// This packet contains audio stream data passed to Kodi. | ||
| 198 | /// | ||
| 199 | typedef struct game_stream_audio_packet | ||
| 200 | { | ||
| 201 | /// @brief Pointer for audio stream data given to Kodi | ||
| 202 | const uint8_t *data; | ||
| 203 | |||
| 204 | /// @brief Size of data array | ||
| 205 | size_t size; | ||
| 206 | } ATTRIBUTE_PACKED game_stream_audio_packet; | ||
| 207 | //------------------------------------------------------------------------------ | ||
| 208 | |||
| 209 | //@} | ||
| 210 | |||
| 211 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 212 | /// \defgroup cpp_kodi_addon_game_Defs_VideoStream 2. Video stream | ||
| 213 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 214 | /// @brief **The for Video stream used data system** | ||
| 215 | /// | ||
| 216 | /// Used to give Addon currently used video stream configuration on Kodi and | ||
| 217 | /// arrays to give related data to Kodi on callbacks. | ||
| 218 | /// | ||
| 219 | //@{ | ||
| 220 | |||
| 221 | //============================================================================== | ||
| 222 | /// @brief **Pixel format** | ||
| 223 | /// | ||
| 224 | /// From Kodi requested specified video RGB color model format. | ||
| 225 | /// | ||
| 226 | typedef enum GAME_PIXEL_FORMAT | ||
| 227 | { | ||
| 228 | GAME_PIXEL_FORMAT_UNKNOWN, | ||
| 229 | |||
| 230 | /// @brief 0RGB8888 Format | ||
| 231 | GAME_PIXEL_FORMAT_0RGB8888, | ||
| 232 | |||
| 233 | /// @brief RGB565 Format | ||
| 234 | GAME_PIXEL_FORMAT_RGB565, | ||
| 235 | |||
| 236 | /// @brief 0RGB1555 Format | ||
| 237 | GAME_PIXEL_FORMAT_0RGB1555, | ||
| 238 | } GAME_PIXEL_FORMAT; | ||
| 239 | //------------------------------------------------------------------------------ | ||
| 240 | |||
| 241 | //============================================================================== | ||
| 242 | /// @brief **Video rotation position** | ||
| 243 | /// | ||
| 244 | /// To define position how video becomes shown. | ||
| 245 | /// | ||
| 246 | typedef enum GAME_VIDEO_ROTATION | ||
| 247 | { | ||
| 248 | /// @brief 0° and Without rotation | ||
| 249 | GAME_VIDEO_ROTATION_0, | ||
| 250 | |||
| 251 | /// @brief rotate 90° counterclockwise | ||
| 252 | GAME_VIDEO_ROTATION_90_CCW, | ||
| 253 | |||
| 254 | /// @brief rotate 180° counterclockwise | ||
| 255 | GAME_VIDEO_ROTATION_180_CCW, | ||
| 256 | |||
| 257 | /// @brief rotate 270° counterclockwise | ||
| 258 | GAME_VIDEO_ROTATION_270_CCW, | ||
| 259 | } GAME_VIDEO_ROTATION; | ||
| 260 | //------------------------------------------------------------------------------ | ||
| 261 | |||
| 262 | //============================================================================== | ||
| 263 | /// @brief **Game video stream properties** | ||
| 264 | /// | ||
| 265 | /// Used by Kodi to pass the currently required video stream settings to the addon | ||
| 266 | /// | ||
| 267 | typedef struct game_stream_video_properties | ||
| 268 | { | ||
| 269 | /// @brief The to used pixel format | ||
| 270 | GAME_PIXEL_FORMAT format; | ||
| 271 | |||
| 272 | /// @brief The nominal used width | ||
| 273 | unsigned int nominal_width; | ||
| 274 | |||
| 275 | /// @brief The nominal used height | ||
| 276 | unsigned int nominal_height; | ||
| 277 | |||
| 278 | /// @brief The maximal used width | ||
| 279 | unsigned int max_width; | ||
| 280 | |||
| 281 | /// @brief The maximal used height | ||
| 282 | unsigned int max_height; | ||
| 283 | |||
| 284 | /// @brief On video stream used aspect ration | ||
| 285 | /// | ||
| 286 | /// @note If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed | ||
| 287 | float aspect_ratio; | ||
| 288 | } ATTRIBUTE_PACKED game_stream_video_properties; | ||
| 289 | //------------------------------------------------------------------------------ | ||
| 290 | |||
| 291 | //============================================================================== | ||
| 292 | /// @brief **Video stream packet** | ||
| 293 | /// | ||
| 294 | /// This packet contains video stream data passed to Kodi. | ||
| 295 | /// | ||
| 296 | typedef struct game_stream_video_packet | ||
| 297 | { | ||
| 298 | /// @brief Video height | ||
| 299 | unsigned int width; | ||
| 300 | |||
| 301 | /// @brief Video width | ||
| 302 | unsigned int height; | ||
| 303 | |||
| 304 | /// @brief Width @ref GAME_VIDEO_ROTATION defined rotation angle. | ||
| 305 | GAME_VIDEO_ROTATION rotation; | ||
| 306 | |||
| 307 | /// @brief Pointer for video stream data given to Kodi | ||
| 308 | const uint8_t *data; | ||
| 309 | |||
| 310 | /// @brief Size of data array | ||
| 311 | size_t size; | ||
| 312 | } ATTRIBUTE_PACKED game_stream_video_packet; | ||
| 313 | //------------------------------------------------------------------------------ | ||
| 314 | |||
| 315 | //@} | ||
| 316 | |||
| 317 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 318 | /// \defgroup cpp_kodi_addon_game_Defs_HardwareFramebuffer 3. Hardware framebuffer stream | ||
| 319 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 320 | /// @brief **Hardware framebuffer stream data** | ||
| 321 | /// | ||
| 322 | //@{ | ||
| 323 | |||
| 324 | //============================================================================== | ||
| 325 | /// @brief **Hardware framebuffer type** | ||
| 326 | /// | ||
| 327 | typedef enum GAME_HW_CONTEXT_TYPE | ||
| 328 | { | ||
| 329 | /// @brief None context | ||
| 330 | GAME_HW_CONTEXT_NONE, | ||
| 331 | |||
| 332 | /// @brief OpenGL 2.x. Driver can choose to use latest compatibility context | ||
| 333 | GAME_HW_CONTEXT_OPENGL, | ||
| 334 | |||
| 335 | /// @brief OpenGL ES 2.0 | ||
| 336 | GAME_HW_CONTEXT_OPENGLES2, | ||
| 337 | |||
| 338 | /// @brief Modern desktop core GL context. Use major/minor fields to set GL version | ||
| 339 | GAME_HW_CONTEXT_OPENGL_CORE, | ||
| 340 | |||
| 341 | /// @brief OpenGL ES 3.0 | ||
| 342 | GAME_HW_CONTEXT_OPENGLES3, | ||
| 343 | |||
| 344 | /// @brief OpenGL ES 3.1+. Set major/minor fields. | ||
| 345 | GAME_HW_CONTEXT_OPENGLES_VERSION, | ||
| 346 | |||
| 347 | /// @brief Vulkan | ||
| 348 | GAME_HW_CONTEXT_VULKAN | ||
| 349 | } GAME_HW_CONTEXT_TYPE; | ||
| 350 | //------------------------------------------------------------------------------ | ||
| 351 | |||
| 352 | //============================================================================== | ||
| 353 | /// @brief **Hardware framebuffer properties** | ||
| 354 | /// | ||
| 355 | typedef struct game_stream_hw_framebuffer_properties | ||
| 356 | { | ||
| 357 | /// @brief The API to use. | ||
| 358 | /// | ||
| 359 | GAME_HW_CONTEXT_TYPE context_type; | ||
| 360 | |||
| 361 | /// @brief Set if render buffers should have depth component attached. | ||
| 362 | /// | ||
| 363 | /// @todo: Obsolete | ||
| 364 | /// | ||
| 365 | bool depth; | ||
| 366 | |||
| 367 | /// @brief Set if stencil buffers should be attached. | ||
| 368 | /// | ||
| 369 | /// If depth and stencil are true, a packed 24/8 buffer will be added. | ||
| 370 | /// Only attaching stencil is invalid and will be ignored. | ||
| 371 | /// | ||
| 372 | /// @todo: Obsolete. | ||
| 373 | /// | ||
| 374 | bool stencil; | ||
| 375 | |||
| 376 | /// @brief Use conventional bottom-left origin convention. | ||
| 377 | /// | ||
| 378 | /// If false, standard top-left origin semantics are used. | ||
| 379 | /// | ||
| 380 | /// @todo: Move to GL specific interface | ||
| 381 | /// | ||
| 382 | bool bottom_left_origin; | ||
| 383 | |||
| 384 | /// @brief Major version number for core GL context or GLES 3.1+. | ||
| 385 | unsigned int version_major; | ||
| 386 | |||
| 387 | /// @brief Minor version number for core GL context or GLES 3.1+. | ||
| 388 | unsigned int version_minor; | ||
| 389 | |||
| 390 | /// @brief If this is true, the frontend will go very far to avoid resetting context | ||
| 391 | /// in scenarios like toggling fullscreen, etc. | ||
| 392 | /// | ||
| 393 | /// @todo: Obsolete? Maybe frontend should just always assume this... | ||
| 394 | /// | ||
| 395 | /// The reset callback might still be called in extreme situations such as if | ||
| 396 | /// the context is lost beyond recovery. | ||
| 397 | /// | ||
| 398 | /// For optimal stability, set this to false, and allow context to be reset at | ||
| 399 | /// any time. | ||
| 400 | /// | ||
| 401 | bool cache_context; | ||
| 402 | |||
| 403 | /// @brief Creates a debug context. | ||
| 404 | bool debug_context; | ||
| 405 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties; | ||
| 406 | //------------------------------------------------------------------------------ | ||
| 407 | |||
| 408 | //============================================================================== | ||
| 409 | /// @brief **Hardware framebuffer buffer** | ||
| 410 | /// | ||
| 411 | typedef struct game_stream_hw_framebuffer_buffer | ||
| 412 | { | ||
| 413 | /// @brief | ||
| 414 | uintptr_t framebuffer; | ||
| 415 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer; | ||
| 416 | //------------------------------------------------------------------------------ | ||
| 417 | |||
| 418 | //============================================================================== | ||
| 419 | /// @brief **Hardware framebuffer packet** | ||
| 420 | /// | ||
| 421 | typedef struct game_stream_hw_framebuffer_packet | ||
| 422 | { | ||
| 423 | /// @brief | ||
| 424 | uintptr_t framebuffer; | ||
| 425 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet; | ||
| 426 | //------------------------------------------------------------------------------ | ||
| 427 | |||
| 428 | //============================================================================== | ||
| 429 | /// @brief **Hardware framebuffer process function address** | ||
| 430 | /// | ||
| 431 | typedef void (*game_proc_address_t)(void); | ||
| 432 | //------------------------------------------------------------------------------ | ||
| 433 | |||
| 434 | //@} | ||
| 435 | |||
| 436 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 437 | /// \defgroup cpp_kodi_addon_game_Defs_SoftwareFramebuffer 4. Software framebuffer stream | ||
| 438 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 439 | /// @brief **Software framebuffer stream data** | ||
| 440 | /// | ||
| 441 | //@{ | ||
| 442 | |||
| 443 | //============================================================================== | ||
| 444 | /// @brief **Game video stream properties** | ||
| 445 | /// | ||
| 446 | /// Used by Kodi to pass the currently required video stream settings to the addon | ||
| 447 | /// | ||
| 448 | typedef game_stream_video_properties game_stream_sw_framebuffer_properties; | ||
| 449 | //------------------------------------------------------------------------------ | ||
| 450 | |||
| 451 | //============================================================================== | ||
| 452 | /// @brief **Hardware framebuffer type** | ||
| 453 | /// | ||
| 454 | typedef struct game_stream_sw_framebuffer_buffer | ||
| 455 | { | ||
| 456 | GAME_PIXEL_FORMAT format; | ||
| 457 | uint8_t *data; | ||
| 458 | size_t size; | ||
| 459 | } ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer; | ||
| 460 | //------------------------------------------------------------------------------ | ||
| 461 | |||
| 462 | //============================================================================== | ||
| 463 | /// @brief **Video stream packet** | ||
| 464 | /// | ||
| 465 | /// This packet contains video stream data passed to Kodi. | ||
| 466 | /// | ||
| 467 | typedef game_stream_video_packet game_stream_sw_framebuffer_packet; | ||
| 468 | //------------------------------------------------------------------------------ | ||
| 469 | |||
| 470 | //@} | ||
| 471 | |||
| 472 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 473 | /// \defgroup cpp_kodi_addon_game_Defs_StreamTypes 5. Stream types | ||
| 474 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 475 | /// @brief **Stream types data** | ||
| 476 | /// | ||
| 477 | //@{ | ||
| 478 | |||
| 479 | //============================================================================== | ||
| 480 | /// @brief **Game stream types** | ||
| 481 | /// | ||
| 482 | typedef enum GAME_STREAM_TYPE | ||
| 483 | { | ||
| 484 | /// @brief Unknown | ||
| 485 | GAME_STREAM_UNKNOWN, | ||
| 486 | |||
| 487 | /// @brief Audio stream | ||
| 488 | GAME_STREAM_AUDIO, | ||
| 489 | |||
| 490 | /// @brief Video stream | ||
| 491 | GAME_STREAM_VIDEO, | ||
| 492 | |||
| 493 | /// @brief Hardware framebuffer | ||
| 494 | GAME_STREAM_HW_FRAMEBUFFER, | ||
| 495 | |||
| 496 | /// @brief Software framebuffer | ||
| 497 | GAME_STREAM_SW_FRAMEBUFFER, | ||
| 498 | } GAME_STREAM_TYPE; | ||
| 499 | //------------------------------------------------------------------------------ | ||
| 500 | |||
| 501 | //============================================================================== | ||
| 502 | /// @brief **Immutable stream metadata** | ||
| 503 | /// | ||
| 504 | /// This metadata is provided when the stream is opened. If any stream | ||
| 505 | /// properties change, a new stream must be opened. | ||
| 506 | /// | ||
| 507 | typedef struct game_stream_properties | ||
| 508 | { | ||
| 509 | /// @brief | ||
| 510 | GAME_STREAM_TYPE type; | ||
| 511 | union | ||
| 512 | { | ||
| 513 | /// @brief | ||
| 514 | game_stream_audio_properties audio; | ||
| 515 | |||
| 516 | /// @brief | ||
| 517 | game_stream_video_properties video; | ||
| 518 | |||
| 519 | /// @brief | ||
| 520 | game_stream_hw_framebuffer_properties hw_framebuffer; | ||
| 521 | |||
| 522 | /// @brief | ||
| 523 | game_stream_sw_framebuffer_properties sw_framebuffer; | ||
| 524 | }; | ||
| 525 | } ATTRIBUTE_PACKED game_stream_properties; | ||
| 526 | //------------------------------------------------------------------------------ | ||
| 527 | |||
| 528 | //============================================================================== | ||
| 529 | /// @brief **Stream buffers for hardware rendering and zero-copy support** | ||
| 530 | /// | ||
| 531 | typedef struct game_stream_buffer | ||
| 532 | { | ||
| 533 | /// @brief | ||
| 534 | GAME_STREAM_TYPE type; | ||
| 535 | union | ||
| 536 | { | ||
| 537 | /// @brief | ||
| 538 | game_stream_hw_framebuffer_buffer hw_framebuffer; | ||
| 539 | |||
| 540 | /// @brief | ||
| 541 | game_stream_sw_framebuffer_buffer sw_framebuffer; | ||
| 542 | }; | ||
| 543 | } ATTRIBUTE_PACKED game_stream_buffer; | ||
| 544 | //------------------------------------------------------------------------------ | ||
| 545 | |||
| 546 | //============================================================================== | ||
| 547 | /// @brief **Stream packet and ephemeral metadata** | ||
| 548 | /// | ||
| 549 | /// This packet contains stream data and accompanying metadata. The metadata | ||
| 550 | /// is ephemeral, meaning it only applies to the current packet and can change | ||
| 551 | /// from packet to packet in the same stream. | ||
| 552 | /// | ||
| 553 | typedef struct game_stream_packet | ||
| 554 | { | ||
| 555 | /// @brief | ||
| 556 | GAME_STREAM_TYPE type; | ||
| 557 | union | ||
| 558 | { | ||
| 559 | /// @brief | ||
| 560 | game_stream_audio_packet audio; | ||
| 561 | |||
| 562 | /// @brief | ||
| 563 | game_stream_video_packet video; | ||
| 564 | |||
| 565 | /// @brief | ||
| 566 | game_stream_hw_framebuffer_packet hw_framebuffer; | ||
| 567 | |||
| 568 | /// @brief | ||
| 569 | game_stream_sw_framebuffer_packet sw_framebuffer; | ||
| 570 | }; | ||
| 571 | } ATTRIBUTE_PACKED game_stream_packet; | ||
| 572 | //------------------------------------------------------------------------------ | ||
| 573 | |||
| 574 | //@} | ||
| 575 | |||
| 576 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 577 | /// \defgroup cpp_kodi_addon_game_Defs_GameTypes 6. Game types | ||
| 578 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 579 | /// @brief **Game types data** | ||
| 580 | /// | ||
| 581 | //@{ | ||
| 582 | |||
| 583 | //============================================================================== | ||
| 584 | /// @brief **Game reguin definition** | ||
| 585 | /// | ||
| 586 | /// Returned from game_get_region() | ||
| 587 | typedef enum GAME_REGION | ||
| 588 | { | ||
| 589 | /// @brief Game region unknown | ||
| 590 | GAME_REGION_UNKNOWN, | ||
| 591 | |||
| 592 | /// @brief Game region NTSC | ||
| 593 | GAME_REGION_NTSC, | ||
| 594 | |||
| 595 | /// @brief Game region PAL | ||
| 596 | GAME_REGION_PAL, | ||
| 597 | } GAME_REGION; | ||
| 598 | //------------------------------------------------------------------------------ | ||
| 599 | |||
| 600 | //============================================================================== | ||
| 601 | /// @brief **Special game types passed into game_load_game_special().** | ||
| 602 | /// | ||
| 603 | /// @remark Only used when multiple ROMs are required. | ||
| 604 | /// | ||
| 605 | typedef enum SPECIAL_GAME_TYPE | ||
| 606 | { | ||
| 607 | /// @brief Game Type BSX | ||
| 608 | SPECIAL_GAME_TYPE_BSX, | ||
| 609 | |||
| 610 | /// @brief Game Type BSX slotted | ||
| 611 | SPECIAL_GAME_TYPE_BSX_SLOTTED, | ||
| 612 | |||
| 613 | /// @brief Game Type sufami turbo | ||
| 614 | SPECIAL_GAME_TYPE_SUFAMI_TURBO, | ||
| 615 | |||
| 616 | /// @brief Game Type super game boy | ||
| 617 | SPECIAL_GAME_TYPE_SUPER_GAME_BOY, | ||
| 618 | } SPECIAL_GAME_TYPE; | ||
| 619 | //------------------------------------------------------------------------------ | ||
| 620 | |||
| 621 | //============================================================================== | ||
| 622 | /// @brief **Game Memory** | ||
| 623 | /// | ||
| 624 | typedef enum GAME_MEMORY | ||
| 625 | { | ||
| 626 | /// @brief Passed to game_get_memory_data/size(). If the memory type doesn't apply | ||
| 627 | /// to the implementation NULL/0 can be returned. | ||
| 628 | GAME_MEMORY_MASK = 0xff, | ||
| 629 | |||
| 630 | /// @brief Regular save ram. | ||
| 631 | /// | ||
| 632 | /// This ram is usually found on a game cartridge, backed | ||
| 633 | /// up by a battery. If save game data is too complex for a single memory | ||
| 634 | /// buffer, the SYSTEM_DIRECTORY environment callback can be used. | ||
| 635 | GAME_MEMORY_SAVE_RAM = 0, | ||
| 636 | |||
| 637 | /// @brief Some games have a built-in clock to keep track of time. | ||
| 638 | /// | ||
| 639 | /// This memory is usually just a couple of bytes to keep track of time. | ||
| 640 | GAME_MEMORY_RTC = 1, | ||
| 641 | |||
| 642 | /// @brief System ram lets a frontend peek into a game systems main RAM | ||
| 643 | GAME_MEMORY_SYSTEM_RAM = 2, | ||
| 644 | |||
| 645 | /// @brief Video ram lets a frontend peek into a game systems video RAM (VRAM) | ||
| 646 | GAME_MEMORY_VIDEO_RAM = 3, | ||
| 647 | |||
| 648 | /// @brief Special memory type | ||
| 649 | GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 650 | |||
| 651 | /// @brief Special memory type | ||
| 652 | GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 653 | |||
| 654 | /// @brief Special memory type | ||
| 655 | GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM = ((3 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 656 | |||
| 657 | /// @brief Special memory type | ||
| 658 | GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM = ((4 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 659 | |||
| 660 | /// @brief Special memory type | ||
| 661 | GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 662 | |||
| 663 | /// @brief Special memory type | ||
| 664 | GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC), | ||
| 665 | } GAME_MEMORY; | ||
| 666 | //------------------------------------------------------------------------------ | ||
| 667 | |||
| 668 | //============================================================================== | ||
| 669 | /// @brief **ID values for SIMD CPU features** | ||
| 670 | typedef enum GAME_SIMD | ||
| 671 | { | ||
| 672 | /// @brief SIMD CPU SSE | ||
| 673 | GAME_SIMD_SSE = (1 << 0), | ||
| 674 | |||
| 675 | /// @brief SIMD CPU SSE2 | ||
| 676 | GAME_SIMD_SSE2 = (1 << 1), | ||
| 677 | |||
| 678 | /// @brief SIMD CPU VMX | ||
| 679 | GAME_SIMD_VMX = (1 << 2), | ||
| 680 | |||
| 681 | /// @brief SIMD CPU VMX128 | ||
| 682 | GAME_SIMD_VMX128 = (1 << 3), | ||
| 683 | |||
| 684 | /// @brief SIMD CPU AVX | ||
| 685 | GAME_SIMD_AVX = (1 << 4), | ||
| 686 | |||
| 687 | /// @brief SIMD CPU NEON | ||
| 688 | GAME_SIMD_NEON = (1 << 5), | ||
| 689 | |||
| 690 | /// @brief SIMD CPU SSE3 | ||
| 691 | GAME_SIMD_SSE3 = (1 << 6), | ||
| 692 | |||
| 693 | /// @brief SIMD CPU SSSE3 | ||
| 694 | GAME_SIMD_SSSE3 = (1 << 7), | ||
| 695 | |||
| 696 | /// @brief SIMD CPU MMX | ||
| 697 | GAME_SIMD_MMX = (1 << 8), | ||
| 698 | |||
| 699 | /// @brief SIMD CPU MMXEXT | ||
| 700 | GAME_SIMD_MMXEXT = (1 << 9), | ||
| 701 | |||
| 702 | /// @brief SIMD CPU SSE4 | ||
| 703 | GAME_SIMD_SSE4 = (1 << 10), | ||
| 704 | |||
| 705 | /// @brief SIMD CPU SSE42 | ||
| 706 | GAME_SIMD_SSE42 = (1 << 11), | ||
| 707 | |||
| 708 | /// @brief SIMD CPU AVX2 | ||
| 709 | GAME_SIMD_AVX2 = (1 << 12), | ||
| 710 | |||
| 711 | /// @brief SIMD CPU VFPU | ||
| 712 | GAME_SIMD_VFPU = (1 << 13), | ||
| 713 | } GAME_SIMD; | ||
| 714 | //------------------------------------------------------------------------------ | ||
| 715 | |||
| 716 | //@} | ||
| 717 | |||
| 718 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 719 | /// \defgroup cpp_kodi_addon_game_Defs_InputTypes 7. Input types | ||
| 720 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 721 | /// @brief **Input types** | ||
| 722 | /// | ||
| 723 | //@{ | ||
| 724 | |||
| 725 | //============================================================================== | ||
| 726 | /// @brief | ||
| 727 | typedef enum GAME_INPUT_EVENT_SOURCE | ||
| 728 | { | ||
| 729 | /// @brief | ||
| 730 | GAME_INPUT_EVENT_DIGITAL_BUTTON, | ||
| 731 | |||
| 732 | /// @brief | ||
| 733 | GAME_INPUT_EVENT_ANALOG_BUTTON, | ||
| 734 | |||
| 735 | /// @brief | ||
| 736 | GAME_INPUT_EVENT_AXIS, | ||
| 737 | |||
| 738 | /// @brief | ||
| 739 | GAME_INPUT_EVENT_ANALOG_STICK, | ||
| 740 | |||
| 741 | /// @brief | ||
| 742 | GAME_INPUT_EVENT_ACCELEROMETER, | ||
| 743 | |||
| 744 | /// @brief | ||
| 745 | GAME_INPUT_EVENT_KEY, | ||
| 746 | |||
| 747 | /// @brief | ||
| 748 | GAME_INPUT_EVENT_RELATIVE_POINTER, | ||
| 749 | |||
| 750 | /// @brief | ||
| 751 | GAME_INPUT_EVENT_ABSOLUTE_POINTER, | ||
| 752 | |||
| 753 | /// @brief | ||
| 754 | GAME_INPUT_EVENT_MOTOR, | ||
| 755 | } GAME_INPUT_EVENT_SOURCE; | ||
| 756 | //------------------------------------------------------------------------------ | ||
| 757 | |||
| 758 | //============================================================================== | ||
| 759 | /// @brief | ||
| 760 | typedef enum GAME_KEY_MOD | ||
| 761 | { | ||
| 762 | /// @brief | ||
| 763 | GAME_KEY_MOD_NONE = 0x0000, | ||
| 764 | |||
| 765 | /// @brief | ||
| 766 | GAME_KEY_MOD_SHIFT = 0x0001, | ||
| 767 | |||
| 768 | /// @brief | ||
| 769 | GAME_KEY_MOD_CTRL = 0x0002, | ||
| 770 | |||
| 771 | /// @brief | ||
| 772 | GAME_KEY_MOD_ALT = 0x0004, | ||
| 773 | |||
| 774 | /// @brief | ||
| 775 | GAME_KEY_MOD_META = 0x0008, | ||
| 776 | |||
| 777 | /// @brief | ||
| 778 | GAME_KEY_MOD_SUPER = 0x0010, | ||
| 779 | |||
| 780 | /// @brief | ||
| 781 | GAME_KEY_MOD_NUMLOCK = 0x0100, | ||
| 782 | |||
| 783 | /// @brief | ||
| 784 | GAME_KEY_MOD_CAPSLOCK = 0x0200, | ||
| 785 | |||
| 786 | /// @brief | ||
| 787 | GAME_KEY_MOD_SCROLLOCK = 0x0400, | ||
| 788 | } GAME_KEY_MOD; | ||
| 789 | //------------------------------------------------------------------------------ | ||
| 790 | |||
| 791 | //============================================================================== | ||
| 792 | /// @brief Type of port on the virtual game console | ||
| 793 | typedef enum GAME_PORT_TYPE | ||
| 794 | { | ||
| 795 | /// @brief Game port unknown | ||
| 796 | GAME_PORT_UNKNOWN, | ||
| 797 | |||
| 798 | /// @brief Game port Keyboard | ||
| 799 | GAME_PORT_KEYBOARD, | ||
| 800 | |||
| 801 | /// @brief Game port mouse | ||
| 802 | GAME_PORT_MOUSE, | ||
| 803 | |||
| 804 | /// @brief Game port controller | ||
| 805 | GAME_PORT_CONTROLLER, | ||
| 806 | } GAME_PORT_TYPE; | ||
| 807 | //------------------------------------------------------------------------------ | ||
| 808 | |||
| 809 | /*! \cond PRIVATE */ | ||
| 810 | /*! | ||
| 811 | * @brief "C" Game add-on controller layout. | ||
| 812 | * | ||
| 813 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 814 | * | ||
| 815 | * See @ref AddonGameControllerLayout for description of values. | ||
| 816 | */ | ||
| 817 | typedef struct game_controller_layout | ||
| 818 | { | ||
| 819 | char* controller_id; | ||
| 820 | bool provides_input; // False for multitaps | ||
| 821 | char** digital_buttons; | ||
| 822 | unsigned int digital_button_count; | ||
| 823 | char** analog_buttons; | ||
| 824 | unsigned int analog_button_count; | ||
| 825 | char** analog_sticks; | ||
| 826 | unsigned int analog_stick_count; | ||
| 827 | char** accelerometers; | ||
| 828 | unsigned int accelerometer_count; | ||
| 829 | char** keys; | ||
| 830 | unsigned int key_count; | ||
| 831 | char** rel_pointers; | ||
| 832 | unsigned int rel_pointer_count; | ||
| 833 | char** abs_pointers; | ||
| 834 | unsigned int abs_pointer_count; | ||
| 835 | char** motors; | ||
| 836 | unsigned int motor_count; | ||
| 837 | } ATTRIBUTE_PACKED game_controller_layout; | ||
| 838 | /*! \endcond */ | ||
| 839 | |||
| 840 | //============================================================================== | ||
| 841 | /// @brief | ||
| 842 | struct AddonGameControllerLayout | ||
| 843 | { | ||
| 844 | /*! \cond PRIVATE */ | ||
| 845 | explicit AddonGameControllerLayout() = default; | ||
| 846 | AddonGameControllerLayout(const game_controller_layout& layout) | ||
| 847 | { | ||
| 848 | controller_id = layout.controller_id; | ||
| 849 | provides_input = layout.provides_input; | ||
| 850 | for (unsigned int i = 0; i < layout.digital_button_count; ++i) | ||
| 851 | digital_buttons.push_back(layout.digital_buttons[i]); | ||
| 852 | for (unsigned int i = 0; i < layout.analog_button_count; ++i) | ||
| 853 | analog_buttons.push_back(layout.analog_buttons[i]); | ||
| 854 | for (unsigned int i = 0; i < layout.analog_stick_count; ++i) | ||
| 855 | analog_sticks.push_back(layout.analog_sticks[i]); | ||
| 856 | for (unsigned int i = 0; i < layout.accelerometer_count; ++i) | ||
| 857 | accelerometers.push_back(layout.accelerometers[i]); | ||
| 858 | for (unsigned int i = 0; i < layout.key_count; ++i) | ||
| 859 | keys.push_back(layout.keys[i]); | ||
| 860 | for (unsigned int i = 0; i < layout.rel_pointer_count; ++i) | ||
| 861 | rel_pointers.push_back(layout.rel_pointers[i]); | ||
| 862 | for (unsigned int i = 0; i < layout.abs_pointer_count; ++i) | ||
| 863 | abs_pointers.push_back(layout.abs_pointers[i]); | ||
| 864 | for (unsigned int i = 0; i < layout.motor_count; ++i) | ||
| 865 | motors.push_back(layout.motors[i]); | ||
| 866 | } | ||
| 867 | /*! \endcond */ | ||
| 868 | |||
| 869 | /// @brief | ||
| 870 | std::string controller_id; | ||
| 871 | |||
| 872 | /// @brief False for multitaps | ||
| 873 | bool provides_input; | ||
| 874 | |||
| 875 | /// @brief | ||
| 876 | std::vector<std::string> digital_buttons; | ||
| 877 | |||
| 878 | /// @brief | ||
| 879 | std::vector<std::string> analog_buttons; | ||
| 880 | |||
| 881 | /// @brief | ||
| 882 | std::vector<std::string> analog_sticks; | ||
| 883 | |||
| 884 | /// @brief | ||
| 885 | std::vector<std::string> accelerometers; | ||
| 886 | |||
| 887 | /// @brief | ||
| 888 | std::vector<std::string> keys; | ||
| 889 | |||
| 890 | /// @brief | ||
| 891 | std::vector<std::string> rel_pointers; | ||
| 892 | |||
| 893 | /// @brief | ||
| 894 | std::vector<std::string> abs_pointers; | ||
| 895 | |||
| 896 | /// @brief | ||
| 897 | std::vector<std::string> motors; | ||
| 898 | }; | ||
| 899 | //------------------------------------------------------------------------------ | ||
| 900 | |||
| 901 | struct game_input_port; | ||
| 902 | |||
| 903 | //============================================================================== | ||
| 904 | /// @brief Device that can provide input | ||
| 905 | typedef struct game_input_device | ||
| 906 | { | ||
| 907 | /// @brief ID used in the Kodi controller API | ||
| 908 | const char* controller_id; | ||
| 909 | |||
| 910 | /// @brief | ||
| 911 | const char* port_address; | ||
| 912 | |||
| 913 | /// @brief | ||
| 914 | game_input_port* available_ports; | ||
| 915 | |||
| 916 | /// @brief | ||
| 917 | unsigned int port_count; | ||
| 918 | } ATTRIBUTE_PACKED game_input_device; | ||
| 919 | //------------------------------------------------------------------------------ | ||
| 920 | |||
| 921 | //============================================================================== | ||
| 922 | /// @brief Port that can provide input | ||
| 923 | /// | ||
| 924 | /// Ports can accept multiple devices and devices can have multiple ports, so | ||
| 925 | /// the topology of possible configurations is a tree structure of alternating | ||
| 926 | /// port and device nodes. | ||
| 927 | /// | ||
| 928 | typedef struct game_input_port | ||
| 929 | { | ||
| 930 | /// @brief | ||
| 931 | GAME_PORT_TYPE type; | ||
| 932 | |||
| 933 | /// @brief Required for GAME_PORT_CONTROLLER type | ||
| 934 | const char* port_id; | ||
| 935 | |||
| 936 | /// @brief | ||
| 937 | game_input_device* accepted_devices; | ||
| 938 | |||
| 939 | /// @brief | ||
| 940 | unsigned int device_count; | ||
| 941 | } ATTRIBUTE_PACKED game_input_port; | ||
| 942 | //------------------------------------------------------------------------------ | ||
| 943 | |||
| 944 | //============================================================================== | ||
| 945 | /// @brief The input topology is the possible ways to connect input devices | ||
| 946 | /// | ||
| 947 | /// This represents the logical topology, which is the possible connections that | ||
| 948 | /// the game client's logic can handle. It is strictly a subset of the physical | ||
| 949 | /// topology. Loops are not allowed. | ||
| 950 | /// | ||
| 951 | typedef struct game_input_topology | ||
| 952 | { | ||
| 953 | /// @brief The list of ports on the virtual game console | ||
| 954 | game_input_port *ports; | ||
| 955 | |||
| 956 | /// @brief The number of ports | ||
| 957 | unsigned int port_count; | ||
| 958 | |||
| 959 | /// @brief A limit on the number of input-providing devices, or -1 for no limit | ||
| 960 | int player_limit; | ||
| 961 | } ATTRIBUTE_PACKED game_input_topology; | ||
| 962 | //------------------------------------------------------------------------------ | ||
| 963 | |||
| 964 | //============================================================================== | ||
| 965 | /// @brief | ||
| 966 | typedef struct game_digital_button_event | ||
| 967 | { | ||
| 968 | /// @brief | ||
| 969 | bool pressed; | ||
| 970 | } ATTRIBUTE_PACKED game_digital_button_event; | ||
| 971 | //------------------------------------------------------------------------------ | ||
| 972 | |||
| 973 | //============================================================================== | ||
| 974 | /// @brief | ||
| 975 | typedef struct game_analog_button_event | ||
| 976 | { | ||
| 977 | /// @brief | ||
| 978 | float magnitude; | ||
| 979 | } ATTRIBUTE_PACKED game_analog_button_event; | ||
| 980 | //------------------------------------------------------------------------------ | ||
| 981 | |||
| 982 | //============================================================================== | ||
| 983 | /// @brief | ||
| 984 | typedef struct game_axis_event | ||
| 985 | { | ||
| 986 | /// @brief | ||
| 987 | float position; | ||
| 988 | } ATTRIBUTE_PACKED game_axis_event; | ||
| 989 | //------------------------------------------------------------------------------ | ||
| 990 | |||
| 991 | //============================================================================== | ||
| 992 | /// @brief | ||
| 993 | typedef struct game_analog_stick_event | ||
| 994 | { | ||
| 995 | /// @brief | ||
| 996 | float x; | ||
| 997 | |||
| 998 | /// @brief | ||
| 999 | float y; | ||
| 1000 | } ATTRIBUTE_PACKED game_analog_stick_event; | ||
| 1001 | //------------------------------------------------------------------------------ | ||
| 1002 | |||
| 1003 | //============================================================================== | ||
| 1004 | /// @brief | ||
| 1005 | typedef struct game_accelerometer_event | ||
| 1006 | { | ||
| 1007 | /// @brief | ||
| 1008 | float x; | ||
| 1009 | |||
| 1010 | /// @brief | ||
| 1011 | float y; | ||
| 1012 | |||
| 1013 | /// @brief | ||
| 1014 | float z; | ||
| 1015 | } ATTRIBUTE_PACKED game_accelerometer_event; | ||
| 1016 | //------------------------------------------------------------------------------ | ||
| 1017 | |||
| 1018 | //============================================================================== | ||
| 1019 | /// @brief | ||
| 1020 | typedef struct game_key_event | ||
| 1021 | { | ||
| 1022 | /// @brief | ||
| 1023 | bool pressed; | ||
| 1024 | |||
| 1025 | /// @brief If the keypress generates a printing character | ||
| 1026 | /// | ||
| 1027 | /// The unicode value contains the character generated. If the key is a | ||
| 1028 | /// non-printing character, e.g. a function or arrow key, the unicode value | ||
| 1029 | /// is zero. | ||
| 1030 | uint32_t unicode; | ||
| 1031 | |||
| 1032 | /// @brief | ||
| 1033 | GAME_KEY_MOD modifiers; | ||
| 1034 | } ATTRIBUTE_PACKED game_key_event; | ||
| 1035 | //------------------------------------------------------------------------------ | ||
| 1036 | |||
| 1037 | //============================================================================== | ||
| 1038 | /// @brief | ||
| 1039 | typedef struct game_rel_pointer_event | ||
| 1040 | { | ||
| 1041 | /// @brief | ||
| 1042 | int x; | ||
| 1043 | |||
| 1044 | /// @brief | ||
| 1045 | int y; | ||
| 1046 | } ATTRIBUTE_PACKED game_rel_pointer_event; | ||
| 1047 | //------------------------------------------------------------------------------ | ||
| 1048 | |||
| 1049 | //============================================================================== | ||
| 1050 | /// @brief | ||
| 1051 | typedef struct game_abs_pointer_event | ||
| 1052 | { | ||
| 1053 | /// @brief | ||
| 1054 | bool pressed; | ||
| 1055 | |||
| 1056 | /// @brief | ||
| 1057 | float x; | ||
| 1058 | |||
| 1059 | /// @brief | ||
| 1060 | float y; | ||
| 1061 | } ATTRIBUTE_PACKED game_abs_pointer_event; | ||
| 1062 | //------------------------------------------------------------------------------ | ||
| 1063 | |||
| 1064 | //============================================================================== | ||
| 1065 | /// @brief | ||
| 1066 | typedef struct game_motor_event | ||
| 1067 | { | ||
| 1068 | /// @brief | ||
| 1069 | float magnitude; | ||
| 1070 | } ATTRIBUTE_PACKED game_motor_event; | ||
| 1071 | //------------------------------------------------------------------------------ | ||
| 1072 | |||
| 1073 | //============================================================================== | ||
| 1074 | /// @brief | ||
| 1075 | typedef struct game_input_event | ||
| 1076 | { | ||
| 1077 | /// @brief | ||
| 1078 | GAME_INPUT_EVENT_SOURCE type; | ||
| 1079 | |||
| 1080 | /// @brief | ||
| 1081 | const char* controller_id; | ||
| 1082 | |||
| 1083 | /// @brief | ||
| 1084 | GAME_PORT_TYPE port_type; | ||
| 1085 | |||
| 1086 | /// @brief | ||
| 1087 | const char* port_address; | ||
| 1088 | |||
| 1089 | /// @brief | ||
| 1090 | const char* feature_name; | ||
| 1091 | union { | ||
| 1092 | /// @brief | ||
| 1093 | struct game_digital_button_event digital_button; | ||
| 1094 | |||
| 1095 | /// @brief | ||
| 1096 | struct game_analog_button_event analog_button; | ||
| 1097 | |||
| 1098 | /// @brief | ||
| 1099 | struct game_axis_event axis; | ||
| 1100 | |||
| 1101 | /// @brief | ||
| 1102 | struct game_analog_stick_event analog_stick; | ||
| 1103 | |||
| 1104 | /// @brief | ||
| 1105 | struct game_accelerometer_event accelerometer; | ||
| 1106 | |||
| 1107 | /// @brief | ||
| 1108 | struct game_key_event key; | ||
| 1109 | |||
| 1110 | /// @brief | ||
| 1111 | struct game_rel_pointer_event rel_pointer; | ||
| 1112 | |||
| 1113 | /// @brief | ||
| 1114 | struct game_abs_pointer_event abs_pointer; | ||
| 1115 | |||
| 1116 | /// @brief | ||
| 1117 | struct game_motor_event motor; | ||
| 1118 | }; | ||
| 1119 | } ATTRIBUTE_PACKED game_input_event; | ||
| 1120 | //------------------------------------------------------------------------------ | ||
| 1121 | |||
| 1122 | //@} | ||
| 1123 | |||
| 1124 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1125 | /// \defgroup cpp_kodi_addon_game_Defs_EnvironmentTypes 8. Environment types | ||
| 1126 | /// \ingroup cpp_kodi_addon_game_Defs | ||
| 1127 | /// @brief **Environment types** | ||
| 1128 | /// | ||
| 1129 | //@{ | ||
| 1130 | |||
| 1131 | //============================================================================== | ||
| 1132 | /// @brief Game system timing | ||
| 1133 | /// | ||
| 1134 | struct game_system_timing | ||
| 1135 | { | ||
| 1136 | /// @brief FPS of video content. | ||
| 1137 | double fps; | ||
| 1138 | |||
| 1139 | /// @brief Sampling rate of audio. | ||
| 1140 | double sample_rate; | ||
| 1141 | }; | ||
| 1142 | //------------------------------------------------------------------------------ | ||
| 1143 | |||
| 1144 | //@} | ||
| 1145 | |||
| 1146 | |||
| 1147 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1148 | |||
| 1149 | /*! | ||
| 1150 | * @brief Game properties | ||
| 1151 | * | ||
| 1152 | * Not to be used outside this header. | ||
| 1153 | */ | ||
| 1154 | typedef struct AddonProps_Game | ||
| 1155 | { | ||
| 1156 | /*! | ||
| 1157 | * The path of the game client being loaded. | ||
| 1158 | */ | ||
| 1159 | const char* game_client_dll_path; | ||
| 1160 | |||
| 1161 | /*! | ||
| 1162 | * Paths to proxy DLLs used to load the game client. | ||
| 1163 | */ | ||
| 1164 | const char** proxy_dll_paths; | ||
| 1165 | |||
| 1166 | /*! | ||
| 1167 | * Number of proxy DLL paths provided. | ||
| 1168 | */ | ||
| 1169 | unsigned int proxy_dll_count; | ||
| 1170 | |||
| 1171 | /*! | ||
| 1172 | * The "system" directories of the frontend. These directories can be used to | ||
| 1173 | * store system-specific ROMs such as BIOSes, configuration data, etc. | ||
| 1174 | */ | ||
| 1175 | const char** resource_directories; | ||
| 1176 | |||
| 1177 | /*! | ||
| 1178 | * Number of resource directories provided | ||
| 1179 | */ | ||
| 1180 | unsigned int resource_directory_count; | ||
| 1181 | |||
| 1182 | /*! | ||
| 1183 | * The writable directory of the frontend. This directory can be used to store | ||
| 1184 | * SRAM, memory cards, high scores, etc, if the game client cannot use the | ||
| 1185 | * regular memory interface, GetMemoryData(). | ||
| 1186 | */ | ||
| 1187 | const char* profile_directory; | ||
| 1188 | |||
| 1189 | /*! | ||
| 1190 | * The value of the <supports_vfs> property from addon.xml | ||
| 1191 | */ | ||
| 1192 | bool supports_vfs; | ||
| 1193 | |||
| 1194 | /*! | ||
| 1195 | * The extensions in the <extensions> property from addon.xml | ||
| 1196 | */ | ||
| 1197 | const char** extensions; | ||
| 1198 | |||
| 1199 | /*! | ||
| 1200 | * Number of extensions provided | ||
| 1201 | */ | ||
| 1202 | unsigned int extension_count; | ||
| 1203 | } AddonProps_Game; | ||
| 1204 | |||
| 1205 | typedef AddonProps_Game game_client_properties; | ||
| 1206 | |||
| 1207 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ | ||
| 1208 | |||
| 1209 | struct AddonInstance_Game; | ||
| 1210 | |||
| 1211 | /*! | ||
| 1212 | * @brief Game callbacks | ||
| 1213 | * | ||
| 1214 | * Not to be used outside this header. | ||
| 1215 | */ | ||
| 1216 | typedef struct AddonToKodiFuncTable_Game | ||
| 1217 | { | ||
| 1218 | KODI_HANDLE kodiInstance; | ||
| 1219 | |||
| 1220 | void (*CloseGame)(void* kodiInstance); | ||
| 1221 | void* (*OpenStream)(void*, const game_stream_properties*); | ||
| 1222 | bool (*GetStreamBuffer)(void*, void*, unsigned int, unsigned int, game_stream_buffer*); | ||
| 1223 | void (*AddStreamData)(void*, void*, const game_stream_packet*); | ||
| 1224 | void (*ReleaseStreamBuffer)(void*, void*, game_stream_buffer*); | ||
| 1225 | void (*CloseStream)(void*, void*); | ||
| 1226 | game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol); | ||
| 1227 | bool (*InputEvent)(void* kodiInstance, const game_input_event* event); | ||
| 1228 | } AddonToKodiFuncTable_Game; | ||
| 1229 | |||
| 1230 | /*! | ||
| 1231 | * @brief Game function hooks | ||
| 1232 | * | ||
| 1233 | * Not to be used outside this header. | ||
| 1234 | */ | ||
| 1235 | typedef struct KodiToAddonFuncTable_Game | ||
| 1236 | { | ||
| 1237 | kodi::addon::CInstanceGame* addonInstance; | ||
| 1238 | |||
| 1239 | GAME_ERROR(__cdecl* LoadGame)(const AddonInstance_Game*, const char*); | ||
| 1240 | GAME_ERROR(__cdecl* LoadGameSpecial) | ||
| 1241 | (const AddonInstance_Game*, SPECIAL_GAME_TYPE, const char**, size_t); | ||
| 1242 | GAME_ERROR(__cdecl* LoadStandalone)(const AddonInstance_Game*); | ||
| 1243 | GAME_ERROR(__cdecl* UnloadGame)(const AddonInstance_Game*); | ||
| 1244 | GAME_ERROR(__cdecl* GetGameTiming)(const AddonInstance_Game*, game_system_timing*); | ||
| 1245 | GAME_REGION(__cdecl* GetRegion)(const AddonInstance_Game*); | ||
| 1246 | bool(__cdecl* RequiresGameLoop)(const AddonInstance_Game*); | ||
| 1247 | GAME_ERROR(__cdecl* RunFrame)(const AddonInstance_Game*); | ||
| 1248 | GAME_ERROR(__cdecl* Reset)(const AddonInstance_Game*); | ||
| 1249 | GAME_ERROR(__cdecl* HwContextReset)(const AddonInstance_Game*); | ||
| 1250 | GAME_ERROR(__cdecl* HwContextDestroy)(const AddonInstance_Game*); | ||
| 1251 | bool(__cdecl* HasFeature)(const AddonInstance_Game*, const char*, const char*); | ||
| 1252 | game_input_topology*(__cdecl* GetTopology)(const AddonInstance_Game*); | ||
| 1253 | void(__cdecl* FreeTopology)(const AddonInstance_Game*, game_input_topology*); | ||
| 1254 | void(__cdecl* SetControllerLayouts)(const AddonInstance_Game*, | ||
| 1255 | const game_controller_layout*, | ||
| 1256 | unsigned int); | ||
| 1257 | bool(__cdecl* EnableKeyboard)(const AddonInstance_Game*, bool, const char*); | ||
| 1258 | bool(__cdecl* EnableMouse)(const AddonInstance_Game*, bool, const char*); | ||
| 1259 | bool(__cdecl* ConnectController)(const AddonInstance_Game*, bool, const char*, const char*); | ||
| 1260 | bool(__cdecl* InputEvent)(const AddonInstance_Game*, const game_input_event*); | ||
| 1261 | size_t(__cdecl* SerializeSize)(const AddonInstance_Game*); | ||
| 1262 | GAME_ERROR(__cdecl* Serialize)(const AddonInstance_Game*, uint8_t*, size_t); | ||
| 1263 | GAME_ERROR(__cdecl* Deserialize)(const AddonInstance_Game*, const uint8_t*, size_t); | ||
| 1264 | GAME_ERROR(__cdecl* CheatReset)(const AddonInstance_Game*); | ||
| 1265 | GAME_ERROR(__cdecl* GetMemory)(const AddonInstance_Game*, GAME_MEMORY, uint8_t**, size_t*); | ||
| 1266 | GAME_ERROR(__cdecl* SetCheat)(const AddonInstance_Game*, unsigned int, bool, const char*); | ||
| 1267 | } KodiToAddonFuncTable_Game; | ||
| 1268 | |||
| 1269 | /*! | ||
| 1270 | * @brief Game instance | ||
| 1271 | * | ||
| 1272 | * Not to be used outside this header. | ||
| 1273 | */ | ||
| 1274 | typedef struct AddonInstance_Game | ||
| 1275 | { | ||
| 1276 | AddonProps_Game props; | ||
| 1277 | AddonToKodiFuncTable_Game toKodi; | ||
| 1278 | KodiToAddonFuncTable_Game toAddon; | ||
| 1279 | } AddonInstance_Game; | ||
| 1280 | |||
| 1281 | } /* extern "C" */ | ||
| 1282 | |||
| 1283 | namespace kodi | ||
| 1284 | { | ||
| 1285 | namespace addon | ||
| 1286 | { | ||
| 1287 | |||
| 1288 | //============================================================================== | ||
| 1289 | /// | ||
| 1290 | /// \addtogroup cpp_kodi_addon_game | ||
| 1291 | /// @brief \cpp_class{ kodi::addon::CInstanceGame } | ||
| 1292 | /// **Game add-on instance** | ||
| 1293 | /// | ||
| 1294 | /// This class is created at addon by Kodi. | ||
| 1295 | /// | ||
| 1296 | //------------------------------------------------------------------------------ | ||
| 1297 | class ATTRIBUTE_HIDDEN CInstanceGame : public IAddonInstance | ||
| 1298 | { | ||
| 1299 | public: | ||
| 1300 | //============================================================================ | ||
| 1301 | /// | ||
| 1302 | /// @defgroup cpp_kodi_addon_game_Base 1. Basic functions | ||
| 1303 | /// @ingroup cpp_kodi_addon_game | ||
| 1304 | /// @brief **Functions to manage the addon and get basic information about it** | ||
| 1305 | /// | ||
| 1306 | /// | ||
| 1307 | //@{ | ||
| 1308 | |||
| 1309 | //============================================================================ | ||
| 1310 | /// | ||
| 1311 | /// @brief Game class constructor | ||
| 1312 | /// | ||
| 1313 | /// Used by an add-on that only supports only Game and only in one instance. | ||
| 1314 | /// | ||
| 1315 | /// This class is created at addon by Kodi. | ||
| 1316 | /// | ||
| 1317 | /// | ||
| 1318 | /// -------------------------------------------------------------------------- | ||
| 1319 | /// | ||
| 1320 | /// | ||
| 1321 | /// **Here's example about the use of this:** | ||
| 1322 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1323 | /// #include <kodi/addon-instance/Game.h> | ||
| 1324 | /// ... | ||
| 1325 | /// | ||
| 1326 | /// class ATTRIBUTE_HIDDEN CGameExample | ||
| 1327 | /// : public kodi::addon::CAddonBase, | ||
| 1328 | /// public kodi::addon::CInstanceGame | ||
| 1329 | /// { | ||
| 1330 | /// public: | ||
| 1331 | /// CGameExample() | ||
| 1332 | /// { | ||
| 1333 | /// } | ||
| 1334 | /// | ||
| 1335 | /// virtual ~CGameExample(); | ||
| 1336 | /// { | ||
| 1337 | /// } | ||
| 1338 | /// | ||
| 1339 | /// ... | ||
| 1340 | /// }; | ||
| 1341 | /// | ||
| 1342 | /// ADDONCREATOR(CGameExample) | ||
| 1343 | /// ~~~~~~~~~~~~~ | ||
| 1344 | /// | ||
| 1345 | CInstanceGame() : IAddonInstance(ADDON_INSTANCE_GAME, GetKodiTypeVersion(ADDON_INSTANCE_GAME)) | ||
| 1346 | { | ||
| 1347 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 1348 | throw std::logic_error("kodi::addon::CInstanceGame: Creation of more as one in single " | ||
| 1349 | "instance way is not allowed!"); | ||
| 1350 | |||
| 1351 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); | ||
| 1352 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 1353 | } | ||
| 1354 | //---------------------------------------------------------------------------- | ||
| 1355 | |||
| 1356 | //============================================================================ | ||
| 1357 | /// | ||
| 1358 | /// @brief Destructor | ||
| 1359 | /// | ||
| 1360 | ~CInstanceGame() override = default; | ||
| 1361 | //---------------------------------------------------------------------------- | ||
| 1362 | |||
| 1363 | //============================================================================ | ||
| 1364 | /// | ||
| 1365 | /// @brief **Callback to Kodi Function**<br>The path of the game client being loaded. | ||
| 1366 | /// | ||
| 1367 | /// @return the used game client Dll path | ||
| 1368 | /// | ||
| 1369 | /// @remarks Only called from addon itself | ||
| 1370 | /// | ||
| 1371 | std::string GameClientDllPath() const | ||
| 1372 | { | ||
| 1373 | return m_instanceData->props.game_client_dll_path; | ||
| 1374 | } | ||
| 1375 | //---------------------------------------------------------------------------- | ||
| 1376 | |||
| 1377 | //============================================================================ | ||
| 1378 | /// | ||
| 1379 | /// @brief **Callback to Kodi Function**<br>Paths to proxy DLLs used to load the game client. | ||
| 1380 | /// | ||
| 1381 | /// @param[out] paths vector list to store available dll paths | ||
| 1382 | /// @return true if success and dll paths present | ||
| 1383 | /// | ||
| 1384 | /// @remarks Only called from addon itself | ||
| 1385 | /// | ||
| 1386 | bool ProxyDllPaths(std::vector<std::string>& paths) | ||
| 1387 | { | ||
| 1388 | for (unsigned int i = 0; i < m_instanceData->props.proxy_dll_count; ++i) | ||
| 1389 | { | ||
| 1390 | if (m_instanceData->props.proxy_dll_paths[i] != nullptr) | ||
| 1391 | paths.push_back(m_instanceData->props.proxy_dll_paths[i]); | ||
| 1392 | } | ||
| 1393 | return !paths.empty(); | ||
| 1394 | } | ||
| 1395 | //---------------------------------------------------------------------------- | ||
| 1396 | |||
| 1397 | //============================================================================ | ||
| 1398 | /// | ||
| 1399 | /// @brief **Callback to Kodi Function**<br>The "system" directories of the frontend | ||
| 1400 | /// | ||
| 1401 | /// These directories can be used to store system-specific ROMs such as | ||
| 1402 | /// BIOSes, configuration data, etc. | ||
| 1403 | /// | ||
| 1404 | /// @return the used resource directory | ||
| 1405 | /// | ||
| 1406 | /// @remarks Only called from addon itself | ||
| 1407 | /// | ||
| 1408 | bool ResourceDirectories(std::vector<std::string>& dirs) | ||
| 1409 | { | ||
| 1410 | for (unsigned int i = 0; i < m_instanceData->props.resource_directory_count; ++i) | ||
| 1411 | { | ||
| 1412 | if (m_instanceData->props.resource_directories[i] != nullptr) | ||
| 1413 | dirs.push_back(m_instanceData->props.resource_directories[i]); | ||
| 1414 | } | ||
| 1415 | return !dirs.empty(); | ||
| 1416 | } | ||
| 1417 | //---------------------------------------------------------------------------- | ||
| 1418 | |||
| 1419 | //============================================================================ | ||
| 1420 | /// | ||
| 1421 | /// @brief **Callback to Kodi Function**<br>The writable directory of the frontend | ||
| 1422 | /// | ||
| 1423 | /// This directory can be used to store SRAM, memory cards, high scores, | ||
| 1424 | /// etc, if the game client cannot use the regular memory interface, | ||
| 1425 | /// GetMemoryData(). | ||
| 1426 | /// | ||
| 1427 | /// @return the used profile directory | ||
| 1428 | /// | ||
| 1429 | /// @remarks Only called from addon itself | ||
| 1430 | /// | ||
| 1431 | std::string ProfileDirectory() const | ||
| 1432 | { | ||
| 1433 | return m_instanceData->props.profile_directory; | ||
| 1434 | } | ||
| 1435 | //---------------------------------------------------------------------------- | ||
| 1436 | |||
| 1437 | //============================================================================ | ||
| 1438 | /// | ||
| 1439 | /// @brief **Callback to Kodi Function**<br>The value of the <supports_vfs> property from addon.xml | ||
| 1440 | /// | ||
| 1441 | /// @return true if VFS is supported | ||
| 1442 | /// | ||
| 1443 | /// @remarks Only called from addon itself | ||
| 1444 | /// | ||
| 1445 | bool SupportsVFS() const | ||
| 1446 | { | ||
| 1447 | return m_instanceData->props.supports_vfs; | ||
| 1448 | } | ||
| 1449 | //---------------------------------------------------------------------------- | ||
| 1450 | |||
| 1451 | //============================================================================ | ||
| 1452 | /// | ||
| 1453 | /// @brief **Callback to Kodi Function**<br>The extensions in the <extensions> property from addon.xml | ||
| 1454 | /// | ||
| 1455 | /// @param[out] extensions vector list to store available extension | ||
| 1456 | /// @return true if success and extensions present | ||
| 1457 | /// | ||
| 1458 | /// @remarks Only called from addon itself | ||
| 1459 | /// | ||
| 1460 | bool Extensions(std::vector<std::string>& extensions) | ||
| 1461 | { | ||
| 1462 | for (unsigned int i = 0; i < m_instanceData->props.extension_count; ++i) | ||
| 1463 | { | ||
| 1464 | if (m_instanceData->props.extensions[i] != nullptr) | ||
| 1465 | extensions.push_back(m_instanceData->props.extensions[i]); | ||
| 1466 | } | ||
| 1467 | return !extensions.empty(); | ||
| 1468 | } | ||
| 1469 | //---------------------------------------------------------------------------- | ||
| 1470 | |||
| 1471 | //@} | ||
| 1472 | |||
| 1473 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1474 | |||
| 1475 | //============================================================================ | ||
| 1476 | /// | ||
| 1477 | /// @defgroup cpp_kodi_addon_game_Operation 2. Game operations | ||
| 1478 | /// @ingroup cpp_kodi_addon_game | ||
| 1479 | /// @brief **Game operations** | ||
| 1480 | /// | ||
| 1481 | /// These are mandatory functions for using this addon to get the available | ||
| 1482 | /// channels. | ||
| 1483 | /// | ||
| 1484 | //@{ | ||
| 1485 | |||
| 1486 | //============================================================================ | ||
| 1487 | /// | ||
| 1488 | /// @brief Load a game | ||
| 1489 | /// | ||
| 1490 | /// @param[in] url The URL to load | ||
| 1491 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded | ||
| 1492 | /// | ||
| 1493 | virtual GAME_ERROR LoadGame(const std::string& url) | ||
| 1494 | { | ||
| 1495 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1496 | } | ||
| 1497 | //---------------------------------------------------------------------------- | ||
| 1498 | |||
| 1499 | //============================================================================ | ||
| 1500 | /// | ||
| 1501 | /// @brief Load a game that requires multiple files | ||
| 1502 | /// | ||
| 1503 | /// @param[in] type The game type | ||
| 1504 | /// @param[in] urls An array of urls | ||
| 1505 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded | ||
| 1506 | /// | ||
| 1507 | virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls) | ||
| 1508 | { | ||
| 1509 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1510 | } | ||
| 1511 | //---------------------------------------------------------------------------- | ||
| 1512 | |||
| 1513 | //============================================================================ | ||
| 1514 | /// | ||
| 1515 | /// @brief Begin playing without a game file | ||
| 1516 | /// | ||
| 1517 | /// If the add-on supports standalone mode, it must add the <supports_standalone> | ||
| 1518 | /// tag to the extension point in addon.xml: | ||
| 1519 | /// | ||
| 1520 | /// <supports_no_game>false</supports_no_game> | ||
| 1521 | /// | ||
| 1522 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game add-on was loaded | ||
| 1523 | /// | ||
| 1524 | virtual GAME_ERROR LoadStandalone() | ||
| 1525 | { | ||
| 1526 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1527 | } | ||
| 1528 | //---------------------------------------------------------------------------- | ||
| 1529 | |||
| 1530 | //============================================================================ | ||
| 1531 | /// | ||
| 1532 | /// @brief Unload the current game | ||
| 1533 | /// | ||
| 1534 | /// Unloads a currently loaded game | ||
| 1535 | /// | ||
| 1536 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was unloaded | ||
| 1537 | /// | ||
| 1538 | virtual GAME_ERROR UnloadGame() | ||
| 1539 | { | ||
| 1540 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1541 | } | ||
| 1542 | //---------------------------------------------------------------------------- | ||
| 1543 | |||
| 1544 | //============================================================================ | ||
| 1545 | /// | ||
| 1546 | /// @brief Get timing information about the loaded game | ||
| 1547 | /// | ||
| 1548 | /// @param[out] timing_info The info structure to fill | ||
| 1549 | /// | ||
| 1550 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if info was filled | ||
| 1551 | /// | ||
| 1552 | virtual GAME_ERROR GetGameTiming(game_system_timing& timing_info) | ||
| 1553 | { | ||
| 1554 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1555 | } | ||
| 1556 | //---------------------------------------------------------------------------- | ||
| 1557 | |||
| 1558 | //============================================================================ | ||
| 1559 | /// | ||
| 1560 | /// @brief Get region of the loaded game | ||
| 1561 | /// | ||
| 1562 | /// @return the region, or @ref GAME_REGION_UNKNOWN if unknown or no game is loaded | ||
| 1563 | /// | ||
| 1564 | virtual GAME_REGION GetRegion() | ||
| 1565 | { | ||
| 1566 | return GAME_REGION_UNKNOWN; | ||
| 1567 | } | ||
| 1568 | //---------------------------------------------------------------------------- | ||
| 1569 | |||
| 1570 | //============================================================================ | ||
| 1571 | /// | ||
| 1572 | /// @brief Return true if the client requires the frontend to provide a game loop | ||
| 1573 | /// | ||
| 1574 | /// The game loop is a thread that calls RunFrame() in a loop at a rate | ||
| 1575 | /// determined by the playback speed and the client's FPS. | ||
| 1576 | /// | ||
| 1577 | /// @return true if the frontend should provide a game loop, false otherwise | ||
| 1578 | /// | ||
| 1579 | virtual bool RequiresGameLoop() | ||
| 1580 | { | ||
| 1581 | return false; | ||
| 1582 | } | ||
| 1583 | //---------------------------------------------------------------------------- | ||
| 1584 | |||
| 1585 | //============================================================================ | ||
| 1586 | /// | ||
| 1587 | /// @brief Run a single frame for add-ons that use a game loop | ||
| 1588 | /// | ||
| 1589 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if there was no error | ||
| 1590 | /// | ||
| 1591 | virtual GAME_ERROR RunFrame() | ||
| 1592 | { | ||
| 1593 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1594 | } | ||
| 1595 | //---------------------------------------------------------------------------- | ||
| 1596 | |||
| 1597 | //============================================================================ | ||
| 1598 | /// | ||
| 1599 | /// @brief Reset the current game | ||
| 1600 | /// | ||
| 1601 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was reset | ||
| 1602 | /// | ||
| 1603 | virtual GAME_ERROR Reset() | ||
| 1604 | { | ||
| 1605 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1606 | } | ||
| 1607 | //---------------------------------------------------------------------------- | ||
| 1608 | |||
| 1609 | //========================================================================== | ||
| 1610 | /// | ||
| 1611 | /// @brief **Callback to Kodi Function**<br>Requests the frontend to stop the current game | ||
| 1612 | /// | ||
| 1613 | /// @remarks Only called from addon itself | ||
| 1614 | /// | ||
| 1615 | void CloseGame(void) { m_instanceData->toKodi.CloseGame(m_instanceData->toKodi.kodiInstance); } | ||
| 1616 | //---------------------------------------------------------------------------- | ||
| 1617 | |||
| 1618 | //============================================================================ | ||
| 1619 | /// | ||
| 1620 | /// @defgroup cpp_kodi_addon_game_Operation_CStream Class: CStream | ||
| 1621 | /// @ingroup cpp_kodi_addon_game_Operation | ||
| 1622 | /// @brief \cpp_class{ kodi::addon::CInstanceGame::CStream } | ||
| 1623 | /// **Game stream handler** | ||
| 1624 | /// | ||
| 1625 | /// This class will be integrated into the addon, which can then open it if | ||
| 1626 | /// necessary for the processing of an audio or video stream. | ||
| 1627 | /// | ||
| 1628 | /// | ||
| 1629 | /// @note Callback to Kodi class | ||
| 1630 | //@{ | ||
| 1631 | class CStream | ||
| 1632 | { | ||
| 1633 | public: | ||
| 1634 | CStream() = default; | ||
| 1635 | |||
| 1636 | CStream(const game_stream_properties& properties) | ||
| 1637 | { | ||
| 1638 | Open(properties); | ||
| 1639 | } | ||
| 1640 | |||
| 1641 | ~CStream() | ||
| 1642 | { | ||
| 1643 | Close(); | ||
| 1644 | } | ||
| 1645 | |||
| 1646 | //========================================================================== | ||
| 1647 | /// | ||
| 1648 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1649 | /// @brief Create a stream for gameplay data | ||
| 1650 | /// | ||
| 1651 | /// @param[in] properties The stream properties | ||
| 1652 | /// @return A stream handle, or `nullptr` on failure | ||
| 1653 | /// | ||
| 1654 | /// @remarks Only called from addon itself | ||
| 1655 | /// | ||
| 1656 | bool Open(const game_stream_properties& properties) | ||
| 1657 | { | ||
| 1658 | if (!CAddonBase::m_interface->globalSingleInstance) | ||
| 1659 | return false; | ||
| 1660 | |||
| 1661 | if (m_handle) | ||
| 1662 | { | ||
| 1663 | kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already becomes reopened"); | ||
| 1664 | Close(); | ||
| 1665 | } | ||
| 1666 | |||
| 1667 | AddonToKodiFuncTable_Game& cb = | ||
| 1668 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1669 | ->m_instanceData->toKodi; | ||
| 1670 | m_handle = cb.OpenStream(cb.kodiInstance, &properties); | ||
| 1671 | return m_handle != nullptr; | ||
| 1672 | } | ||
| 1673 | //-------------------------------------------------------------------------- | ||
| 1674 | |||
| 1675 | //========================================================================== | ||
| 1676 | /// | ||
| 1677 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1678 | /// @brief Free the specified stream | ||
| 1679 | /// | ||
| 1680 | /// @remarks Only called from addon itself | ||
| 1681 | /// | ||
| 1682 | void Close() | ||
| 1683 | { | ||
| 1684 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1685 | return; | ||
| 1686 | |||
| 1687 | AddonToKodiFuncTable_Game& cb = | ||
| 1688 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1689 | ->m_instanceData->toKodi; | ||
| 1690 | cb.CloseStream(cb.kodiInstance, m_handle); | ||
| 1691 | m_handle = nullptr; | ||
| 1692 | } | ||
| 1693 | //-------------------------------------------------------------------------- | ||
| 1694 | |||
| 1695 | //========================================================================== | ||
| 1696 | /// | ||
| 1697 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1698 | /// @brief Get a buffer for zero-copy stream data | ||
| 1699 | /// | ||
| 1700 | /// @param[in] width The framebuffer width, or 0 for no width specified | ||
| 1701 | /// @param[in] height The framebuffer height, or 0 for no height specified | ||
| 1702 | /// @param[out] buffer The buffer, or unmodified if false is returned | ||
| 1703 | /// @return True if buffer was set, false otherwise | ||
| 1704 | /// | ||
| 1705 | /// @note If this returns true, buffer must be freed using \ref ReleaseBuffer(). | ||
| 1706 | /// | ||
| 1707 | /// @remarks Only called from addon itself | ||
| 1708 | /// | ||
| 1709 | bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer) | ||
| 1710 | { | ||
| 1711 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1712 | return false; | ||
| 1713 | |||
| 1714 | AddonToKodiFuncTable_Game& cb = | ||
| 1715 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1716 | ->m_instanceData->toKodi; | ||
| 1717 | return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer); | ||
| 1718 | } | ||
| 1719 | //-------------------------------------------------------------------------- | ||
| 1720 | |||
| 1721 | //========================================================================== | ||
| 1722 | /// | ||
| 1723 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1724 | /// @brief Add a data packet to a stream | ||
| 1725 | /// | ||
| 1726 | /// @param[in] packet The data packet | ||
| 1727 | /// | ||
| 1728 | /// @remarks Only called from addon itself | ||
| 1729 | /// | ||
| 1730 | void AddData(const game_stream_packet& packet) | ||
| 1731 | { | ||
| 1732 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1733 | return; | ||
| 1734 | |||
| 1735 | AddonToKodiFuncTable_Game& cb = | ||
| 1736 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1737 | ->m_instanceData->toKodi; | ||
| 1738 | cb.AddStreamData(cb.kodiInstance, m_handle, &packet); | ||
| 1739 | } | ||
| 1740 | //-------------------------------------------------------------------------- | ||
| 1741 | |||
| 1742 | //========================================================================== | ||
| 1743 | /// | ||
| 1744 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1745 | /// @brief Free an allocated buffer | ||
| 1746 | /// | ||
| 1747 | /// @param[in] buffer The buffer returned from GetStreamBuffer() | ||
| 1748 | /// | ||
| 1749 | /// @remarks Only called from addon itself | ||
| 1750 | /// | ||
| 1751 | void ReleaseBuffer(game_stream_buffer& buffer) | ||
| 1752 | { | ||
| 1753 | if (!m_handle || !CAddonBase::m_interface->globalSingleInstance) | ||
| 1754 | return; | ||
| 1755 | |||
| 1756 | AddonToKodiFuncTable_Game& cb = | ||
| 1757 | static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance) | ||
| 1758 | ->m_instanceData->toKodi; | ||
| 1759 | cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer); | ||
| 1760 | } | ||
| 1761 | //-------------------------------------------------------------------------- | ||
| 1762 | |||
| 1763 | //========================================================================== | ||
| 1764 | /// | ||
| 1765 | /// @ingroup cpp_kodi_addon_game_Operation_CStream | ||
| 1766 | /// @brief To check stream open was OK, e.g. after use of constructor | ||
| 1767 | /// | ||
| 1768 | /// @return true if stream was successfully opened | ||
| 1769 | /// | ||
| 1770 | /// @remarks Only called from addon itself | ||
| 1771 | /// | ||
| 1772 | bool IsOpen() const { return m_handle != nullptr; } | ||
| 1773 | //-------------------------------------------------------------------------- | ||
| 1774 | |||
| 1775 | private: | ||
| 1776 | void* m_handle = nullptr; | ||
| 1777 | }; | ||
| 1778 | //@} | ||
| 1779 | |||
| 1780 | //@} | ||
| 1781 | |||
| 1782 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1783 | |||
| 1784 | //============================================================================ | ||
| 1785 | /// | ||
| 1786 | /// @defgroup cpp_kodi_addon_game_HardwareRendering 3. Hardware rendering operations | ||
| 1787 | /// @ingroup cpp_kodi_addon_game | ||
| 1788 | /// @brief **Hardware rendering operations** | ||
| 1789 | /// | ||
| 1790 | //@{ | ||
| 1791 | |||
| 1792 | //============================================================================ | ||
| 1793 | /// | ||
| 1794 | /// @brief Invalidates the current HW context and reinitializes GPU resources | ||
| 1795 | /// | ||
| 1796 | /// Any GL state is lost, and must not be deinitialized explicitly. | ||
| 1797 | /// | ||
| 1798 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was reset | ||
| 1799 | /// | ||
| 1800 | virtual GAME_ERROR HwContextReset() | ||
| 1801 | { | ||
| 1802 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1803 | } | ||
| 1804 | //---------------------------------------------------------------------------- | ||
| 1805 | |||
| 1806 | //============================================================================ | ||
| 1807 | /// | ||
| 1808 | /// @brief Called before the context is destroyed | ||
| 1809 | /// | ||
| 1810 | /// Resources can be deinitialized at this step. | ||
| 1811 | /// | ||
| 1812 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was destroyed | ||
| 1813 | /// | ||
| 1814 | virtual GAME_ERROR HwContextDestroy() | ||
| 1815 | { | ||
| 1816 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | //============================================================================ | ||
| 1820 | /// | ||
| 1821 | /// @brief **Callback to Kodi Function**<br>Get a symbol from the hardware context | ||
| 1822 | /// | ||
| 1823 | /// @param[in] sym The symbol's name | ||
| 1824 | /// | ||
| 1825 | /// @return A function pointer for the specified symbol | ||
| 1826 | /// | ||
| 1827 | /// @remarks Only called from addon itself | ||
| 1828 | /// | ||
| 1829 | game_proc_address_t HwGetProcAddress(const char* sym) | ||
| 1830 | { | ||
| 1831 | return m_instanceData->toKodi.HwGetProcAddress(m_instanceData->toKodi.kodiInstance, sym); | ||
| 1832 | } | ||
| 1833 | //---------------------------------------------------------------------------- | ||
| 1834 | |||
| 1835 | //@} | ||
| 1836 | |||
| 1837 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 1838 | |||
| 1839 | //============================================================================ | ||
| 1840 | /// | ||
| 1841 | /// @defgroup cpp_kodi_addon_game_InputOperations 4. Input operations | ||
| 1842 | /// @ingroup cpp_kodi_addon_game | ||
| 1843 | /// @brief **Input operations** | ||
| 1844 | /// | ||
| 1845 | //@{ | ||
| 1846 | |||
| 1847 | //============================================================================ | ||
| 1848 | /// | ||
| 1849 | /// @brief Check if input is accepted for a feature on the controller | ||
| 1850 | /// | ||
| 1851 | /// If only a subset of the controller profile is used, this can return false | ||
| 1852 | /// for unsupported features to not absorb their input. | ||
| 1853 | /// | ||
| 1854 | /// If the entire controller profile is used, this should always return true. | ||
| 1855 | /// | ||
| 1856 | /// @param[in] controller_id The ID of the controller profile | ||
| 1857 | /// @param[in] feature_name The name of a feature in that profile | ||
| 1858 | /// @return true if input is accepted for the feature, false otherwise | ||
| 1859 | /// | ||
| 1860 | virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name) | ||
| 1861 | { | ||
| 1862 | return false; | ||
| 1863 | } | ||
| 1864 | //---------------------------------------------------------------------------- | ||
| 1865 | |||
| 1866 | //============================================================================ | ||
| 1867 | /// | ||
| 1868 | /// @brief Get the input topology that specifies which controllers can be connected | ||
| 1869 | /// | ||
| 1870 | /// @return The input topology, or null to use the default | ||
| 1871 | /// | ||
| 1872 | /// If this returns non-null, topology must be freed using FreeTopology(). | ||
| 1873 | /// | ||
| 1874 | /// If this returns null, the topology will default to a single port that can | ||
| 1875 | /// accept all controllers imported by addon.xml. The port ID is set to | ||
| 1876 | /// the @ref DEFAULT_PORT_ID constant. | ||
| 1877 | /// | ||
| 1878 | virtual game_input_topology* GetTopology() | ||
| 1879 | { | ||
| 1880 | return nullptr; | ||
| 1881 | } | ||
| 1882 | //---------------------------------------------------------------------------- | ||
| 1883 | |||
| 1884 | //============================================================================ | ||
| 1885 | /// | ||
| 1886 | /// @brief Free the topology's resources | ||
| 1887 | /// | ||
| 1888 | /// @param[in] topology The topology returned by GetTopology() | ||
| 1889 | /// | ||
| 1890 | virtual void FreeTopology(game_input_topology* topology) | ||
| 1891 | { | ||
| 1892 | } | ||
| 1893 | //---------------------------------------------------------------------------- | ||
| 1894 | |||
| 1895 | //============================================================================ | ||
| 1896 | /// | ||
| 1897 | /// @brief Set the layouts for known controllers | ||
| 1898 | /// | ||
| 1899 | /// @param[in] controllers The controller layouts | ||
| 1900 | /// | ||
| 1901 | /// After loading the input topology, the frontend will call this with | ||
| 1902 | /// controller layouts for all controllers discovered in the topology. | ||
| 1903 | /// | ||
| 1904 | virtual void SetControllerLayouts(const std::vector<AddonGameControllerLayout>& controllers) | ||
| 1905 | { | ||
| 1906 | } | ||
| 1907 | //---------------------------------------------------------------------------- | ||
| 1908 | |||
| 1909 | //============================================================================ | ||
| 1910 | /// | ||
| 1911 | /// @brief Enable/disable keyboard input using the specified controller | ||
| 1912 | /// | ||
| 1913 | /// @param[in] enable True to enable input, false otherwise | ||
| 1914 | /// @param[in] controller_id The controller ID if enabling, or unused if disabling | ||
| 1915 | /// | ||
| 1916 | /// @return True if keyboard input was enabled, false otherwise | ||
| 1917 | /// | ||
| 1918 | virtual bool EnableKeyboard(bool enable, const std::string& controller_id) | ||
| 1919 | { | ||
| 1920 | return false; | ||
| 1921 | } | ||
| 1922 | //---------------------------------------------------------------------------- | ||
| 1923 | |||
| 1924 | //============================================================================ | ||
| 1925 | /// | ||
| 1926 | /// @brief Enable/disable mouse input using the specified controller | ||
| 1927 | /// | ||
| 1928 | /// @param[in] enable True to enable input, false otherwise | ||
| 1929 | /// @param[in] controller_id The controller ID if enabling, or unused if disabling | ||
| 1930 | /// | ||
| 1931 | /// @return True if mouse input was enabled, false otherwise | ||
| 1932 | /// | ||
| 1933 | virtual bool EnableMouse(bool enable, const std::string& controller_id) | ||
| 1934 | { | ||
| 1935 | return false; | ||
| 1936 | } | ||
| 1937 | //-------------------------------------------------------------------------- | ||
| 1938 | |||
| 1939 | //========================================================================== | ||
| 1940 | /// | ||
| 1941 | /// @brief Connect/disconnect a controller to a port on the virtual game console | ||
| 1942 | /// | ||
| 1943 | /// @param[in] connect True to connect a controller, false to disconnect | ||
| 1944 | /// @param[in] port_address The address of the port | ||
| 1945 | /// @param[in] controller_id The controller ID if connecting, or unused if disconnecting | ||
| 1946 | /// @return True if the \p controller was (dis-)connected to the port, false otherwise | ||
| 1947 | /// | ||
| 1948 | /// The address is a string that allows traversal of the controller topology. | ||
| 1949 | /// It is formed by alternating port IDs and controller IDs separated by "/". | ||
| 1950 | /// | ||
| 1951 | /// For example, assume that the topology represented in XML for Snes9x is: | ||
| 1952 | /// | ||
| 1953 | /// ~~~~~~~~~~~~~{.xml} | ||
| 1954 | /// <logicaltopology> | ||
| 1955 | /// <port type="controller" id="1"> | ||
| 1956 | /// <accepts controller="game.controller.snes"/> | ||
| 1957 | /// <accepts controller="game.controller.snes.multitap"> | ||
| 1958 | /// <port type="controller" id="1"> | ||
| 1959 | /// <accepts controller="game.controller.snes"/> | ||
| 1960 | /// </port> | ||
| 1961 | /// <port type="controller" id="2"> | ||
| 1962 | /// <accepts controller="game.controller.snes"/> | ||
| 1963 | /// </port> | ||
| 1964 | /// ... | ||
| 1965 | /// </accepts> | ||
| 1966 | /// </port> | ||
| 1967 | /// </logicaltopology> | ||
| 1968 | /// ~~~~~~~~~~~~~ | ||
| 1969 | /// | ||
| 1970 | /// To connect a multitap to the console's first port, the multitap's controller | ||
| 1971 | /// info is set using the port address: | ||
| 1972 | /// | ||
| 1973 | /// 1 | ||
| 1974 | /// | ||
| 1975 | /// To connect a SNES controller to the second port of the multitap, the | ||
| 1976 | /// controller info is next set using the address: | ||
| 1977 | /// | ||
| 1978 | /// 1/game.controller.multitap/2 | ||
| 1979 | /// | ||
| 1980 | /// Any attempts to connect a controller to a port on a disconnected multitap | ||
| 1981 | /// will return false. | ||
| 1982 | /// | ||
| 1983 | virtual bool ConnectController(bool connect, | ||
| 1984 | const std::string& port_address, | ||
| 1985 | const std::string& controller_id) | ||
| 1986 | { | ||
| 1987 | return false; | ||
| 1988 | } | ||
| 1989 | //---------------------------------------------------------------------------- | ||
| 1990 | |||
| 1991 | //============================================================================ | ||
| 1992 | /// | ||
| 1993 | /// @brief Notify the add-on of an input event | ||
| 1994 | /// | ||
| 1995 | /// @param[in] event The input event | ||
| 1996 | /// | ||
| 1997 | /// @return true if the event was handled, false otherwise | ||
| 1998 | /// | ||
| 1999 | virtual bool InputEvent(const game_input_event& event) | ||
| 2000 | { | ||
| 2001 | return false; | ||
| 2002 | } | ||
| 2003 | //---------------------------------------------------------------------------- | ||
| 2004 | |||
| 2005 | //============================================================================ | ||
| 2006 | /// | ||
| 2007 | /// @brief **Callback to Kodi Function**<br>Notify the port of an input event | ||
| 2008 | /// | ||
| 2009 | /// @param[in] event The input event | ||
| 2010 | /// @return true if the event was handled, false otherwise | ||
| 2011 | /// | ||
| 2012 | /// @note Input events can arrive for the following sources: | ||
| 2013 | /// - \ref GAME_INPUT_EVENT_MOTOR | ||
| 2014 | /// | ||
| 2015 | /// @remarks Only called from addon itself | ||
| 2016 | /// | ||
| 2017 | bool KodiInputEvent(const game_input_event& event) | ||
| 2018 | { | ||
| 2019 | return m_instanceData->toKodi.InputEvent(m_instanceData->toKodi.kodiInstance, &event); | ||
| 2020 | } | ||
| 2021 | //---------------------------------------------------------------------------- | ||
| 2022 | |||
| 2023 | //@} | ||
| 2024 | |||
| 2025 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 2026 | |||
| 2027 | //============================================================================ | ||
| 2028 | /// | ||
| 2029 | /// @defgroup cpp_kodi_addon_game_SerializationOperations 5. Serialization operations | ||
| 2030 | /// @ingroup cpp_kodi_addon_game | ||
| 2031 | /// @brief **Serialization operations** | ||
| 2032 | /// | ||
| 2033 | //@{ | ||
| 2034 | |||
| 2035 | //============================================================================ | ||
| 2036 | /// | ||
| 2037 | /// @brief Get the number of bytes required to serialize the game | ||
| 2038 | /// | ||
| 2039 | /// @return the number of bytes, or 0 if serialization is not supported | ||
| 2040 | /// | ||
| 2041 | virtual size_t SerializeSize() | ||
| 2042 | { | ||
| 2043 | return 0; | ||
| 2044 | } | ||
| 2045 | //---------------------------------------------------------------------------- | ||
| 2046 | |||
| 2047 | //============================================================================ | ||
| 2048 | /// | ||
| 2049 | /// @brief Serialize the state of the game | ||
| 2050 | /// | ||
| 2051 | /// @param[in] data The buffer receiving the serialized game data | ||
| 2052 | /// @param[in] size The size of the buffer | ||
| 2053 | /// | ||
| 2054 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was serialized into the buffer | ||
| 2055 | /// | ||
| 2056 | virtual GAME_ERROR Serialize(uint8_t* data, size_t size) | ||
| 2057 | { | ||
| 2058 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2059 | } | ||
| 2060 | //---------------------------------------------------------------------------- | ||
| 2061 | |||
| 2062 | //============================================================================ | ||
| 2063 | /// | ||
| 2064 | /// @brief Deserialize the game from the given state | ||
| 2065 | /// | ||
| 2066 | /// @param[in] data A buffer containing the game's new state | ||
| 2067 | /// @param[in] size The size of the buffer | ||
| 2068 | /// | ||
| 2069 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game deserialized | ||
| 2070 | /// | ||
| 2071 | virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size) | ||
| 2072 | { | ||
| 2073 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2074 | } | ||
| 2075 | //---------------------------------------------------------------------------- | ||
| 2076 | |||
| 2077 | //@} | ||
| 2078 | |||
| 2079 | //--==----==----==----==----==----==----==----==----==----==----==----==----==-- | ||
| 2080 | |||
| 2081 | //============================================================================ | ||
| 2082 | /// | ||
| 2083 | /// @defgroup cpp_kodi_addon_game_CheatOperations 6. Cheat operations | ||
| 2084 | /// @ingroup cpp_kodi_addon_game | ||
| 2085 | /// @brief **Cheat operations** | ||
| 2086 | /// | ||
| 2087 | //@{ | ||
| 2088 | |||
| 2089 | //============================================================================ | ||
| 2090 | /// | ||
| 2091 | /// @brief Reset the cheat system | ||
| 2092 | /// | ||
| 2093 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat system was reset | ||
| 2094 | /// | ||
| 2095 | virtual GAME_ERROR CheatReset() | ||
| 2096 | { | ||
| 2097 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2098 | } | ||
| 2099 | //---------------------------------------------------------------------------- | ||
| 2100 | |||
| 2101 | //============================================================================ | ||
| 2102 | /// | ||
| 2103 | /// @brief Get a region of memory | ||
| 2104 | /// | ||
| 2105 | /// @param[in] type The type of memory to retrieve | ||
| 2106 | /// @param[in] data Set to the region of memory; must remain valid until UnloadGame() is called | ||
| 2107 | /// @param[in] size Set to the size of the region of memory | ||
| 2108 | /// | ||
| 2109 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if data was set to a valid buffer | ||
| 2110 | /// | ||
| 2111 | virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size) | ||
| 2112 | { | ||
| 2113 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2114 | } | ||
| 2115 | //---------------------------------------------------------------------------- | ||
| 2116 | |||
| 2117 | //============================================================================ | ||
| 2118 | /// | ||
| 2119 | /// @brief Set a cheat code | ||
| 2120 | /// | ||
| 2121 | /// @param[in] index | ||
| 2122 | /// @param[in] enabled | ||
| 2123 | /// @param[in] code | ||
| 2124 | /// | ||
| 2125 | /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat was set | ||
| 2126 | /// | ||
| 2127 | virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code) | ||
| 2128 | { | ||
| 2129 | return GAME_ERROR_NOT_IMPLEMENTED; | ||
| 2130 | } | ||
| 2131 | //---------------------------------------------------------------------------- | ||
| 2132 | |||
| 2133 | //@} | ||
| 2134 | |||
| 2135 | private: | ||
| 2136 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 2137 | { | ||
| 2138 | if (instance == nullptr) | ||
| 2139 | throw std::logic_error("kodi::addon::CInstanceGame: Creation with empty addon structure not" | ||
| 2140 | "allowed, table must be given from Kodi!"); | ||
| 2141 | |||
| 2142 | m_instanceData = static_cast<AddonInstance_Game*>(instance); | ||
| 2143 | m_instanceData->toAddon.addonInstance = this; | ||
| 2144 | |||
| 2145 | m_instanceData->toAddon.LoadGame = ADDON_LoadGame; | ||
| 2146 | m_instanceData->toAddon.LoadGameSpecial = ADDON_LoadGameSpecial; | ||
| 2147 | m_instanceData->toAddon.LoadStandalone = ADDON_LoadStandalone; | ||
| 2148 | m_instanceData->toAddon.UnloadGame = ADDON_UnloadGame; | ||
| 2149 | m_instanceData->toAddon.GetGameTiming = ADDON_GetGameTiming; | ||
| 2150 | m_instanceData->toAddon.GetRegion = ADDON_GetRegion; | ||
| 2151 | m_instanceData->toAddon.RequiresGameLoop = ADDON_RequiresGameLoop; | ||
| 2152 | m_instanceData->toAddon.RunFrame = ADDON_RunFrame; | ||
| 2153 | m_instanceData->toAddon.Reset = ADDON_Reset; | ||
| 2154 | |||
| 2155 | m_instanceData->toAddon.HwContextReset = ADDON_HwContextReset; | ||
| 2156 | m_instanceData->toAddon.HwContextDestroy = ADDON_HwContextDestroy; | ||
| 2157 | |||
| 2158 | m_instanceData->toAddon.HasFeature = ADDON_HasFeature; | ||
| 2159 | m_instanceData->toAddon.GetTopology = ADDON_GetTopology; | ||
| 2160 | m_instanceData->toAddon.FreeTopology = ADDON_FreeTopology; | ||
| 2161 | m_instanceData->toAddon.SetControllerLayouts = ADDON_SetControllerLayouts; | ||
| 2162 | m_instanceData->toAddon.EnableKeyboard = ADDON_EnableKeyboard; | ||
| 2163 | m_instanceData->toAddon.EnableMouse = ADDON_EnableMouse; | ||
| 2164 | m_instanceData->toAddon.ConnectController = ADDON_ConnectController; | ||
| 2165 | m_instanceData->toAddon.InputEvent = ADDON_InputEvent; | ||
| 2166 | |||
| 2167 | m_instanceData->toAddon.SerializeSize = ADDON_SerializeSize; | ||
| 2168 | m_instanceData->toAddon.Serialize = ADDON_Serialize; | ||
| 2169 | m_instanceData->toAddon.Deserialize = ADDON_Deserialize; | ||
| 2170 | |||
| 2171 | m_instanceData->toAddon.CheatReset = ADDON_CheatReset; | ||
| 2172 | m_instanceData->toAddon.GetMemory = ADDON_GetMemory; | ||
| 2173 | m_instanceData->toAddon.SetCheat = ADDON_SetCheat; | ||
| 2174 | } | ||
| 2175 | |||
| 2176 | // --- Game operations --------------------------------------------------------- | ||
| 2177 | |||
| 2178 | inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url) | ||
| 2179 | { | ||
| 2180 | return instance->toAddon.addonInstance->LoadGame(url); | ||
| 2181 | } | ||
| 2182 | |||
| 2183 | inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance, | ||
| 2184 | SPECIAL_GAME_TYPE type, | ||
| 2185 | const char** urls, | ||
| 2186 | size_t urlCount) | ||
| 2187 | { | ||
| 2188 | std::vector<std::string> urlList; | ||
| 2189 | for (size_t i = 0; i < urlCount; ++i) | ||
| 2190 | { | ||
| 2191 | if (urls[i] != nullptr) | ||
| 2192 | urlList.push_back(urls[i]); | ||
| 2193 | } | ||
| 2194 | |||
| 2195 | return instance->toAddon.addonInstance->LoadGameSpecial(type, urlList); | ||
| 2196 | } | ||
| 2197 | |||
| 2198 | inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance) | ||
| 2199 | { | ||
| 2200 | return instance->toAddon.addonInstance->LoadStandalone(); | ||
| 2201 | } | ||
| 2202 | |||
| 2203 | inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance) | ||
| 2204 | { | ||
| 2205 | return instance->toAddon.addonInstance->UnloadGame(); | ||
| 2206 | } | ||
| 2207 | |||
| 2208 | inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance, | ||
| 2209 | game_system_timing* timing_info) | ||
| 2210 | { | ||
| 2211 | return instance->toAddon.addonInstance->GetGameTiming(*timing_info); | ||
| 2212 | } | ||
| 2213 | |||
| 2214 | inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance) | ||
| 2215 | { | ||
| 2216 | return instance->toAddon.addonInstance->GetRegion(); | ||
| 2217 | } | ||
| 2218 | |||
| 2219 | inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance) | ||
| 2220 | { | ||
| 2221 | return instance->toAddon.addonInstance->RequiresGameLoop(); | ||
| 2222 | } | ||
| 2223 | |||
| 2224 | inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance) | ||
| 2225 | { | ||
| 2226 | return instance->toAddon.addonInstance->RunFrame(); | ||
| 2227 | } | ||
| 2228 | |||
| 2229 | inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance) | ||
| 2230 | { | ||
| 2231 | return instance->toAddon.addonInstance->Reset(); | ||
| 2232 | } | ||
| 2233 | |||
| 2234 | |||
| 2235 | // --- Hardware rendering operations ------------------------------------------- | ||
| 2236 | |||
| 2237 | inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance) | ||
| 2238 | { | ||
| 2239 | return instance->toAddon.addonInstance->HwContextReset(); | ||
| 2240 | } | ||
| 2241 | |||
| 2242 | inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance) | ||
| 2243 | { | ||
| 2244 | return instance->toAddon.addonInstance->HwContextDestroy(); | ||
| 2245 | } | ||
| 2246 | |||
| 2247 | |||
| 2248 | // --- Input operations -------------------------------------------------------- | ||
| 2249 | |||
| 2250 | inline static bool ADDON_HasFeature(const AddonInstance_Game* instance, | ||
| 2251 | const char* controller_id, | ||
| 2252 | const char* feature_name) | ||
| 2253 | { | ||
| 2254 | return instance->toAddon.addonInstance->HasFeature(controller_id, feature_name); | ||
| 2255 | } | ||
| 2256 | |||
| 2257 | inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance) | ||
| 2258 | { | ||
| 2259 | return instance->toAddon.addonInstance->GetTopology(); | ||
| 2260 | } | ||
| 2261 | |||
| 2262 | inline static void ADDON_FreeTopology(const AddonInstance_Game* instance, | ||
| 2263 | game_input_topology* topology) | ||
| 2264 | { | ||
| 2265 | instance->toAddon.addonInstance->FreeTopology(topology); | ||
| 2266 | } | ||
| 2267 | |||
| 2268 | inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance, | ||
| 2269 | const game_controller_layout* controllers, | ||
| 2270 | unsigned int controller_count) | ||
| 2271 | { | ||
| 2272 | if (controllers == nullptr) | ||
| 2273 | return; | ||
| 2274 | |||
| 2275 | std::vector<AddonGameControllerLayout> controllerList; | ||
| 2276 | for (unsigned int i = 0; i < controller_count; ++i) | ||
| 2277 | controllerList.push_back(controllers[i]); | ||
| 2278 | |||
| 2279 | instance->toAddon.addonInstance->SetControllerLayouts(controllerList); | ||
| 2280 | } | ||
| 2281 | |||
| 2282 | inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance, | ||
| 2283 | bool enable, | ||
| 2284 | const char* controller_id) | ||
| 2285 | { | ||
| 2286 | return instance->toAddon.addonInstance->EnableKeyboard(enable, controller_id); | ||
| 2287 | } | ||
| 2288 | |||
| 2289 | inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance, | ||
| 2290 | bool enable, | ||
| 2291 | const char* controller_id) | ||
| 2292 | { | ||
| 2293 | return instance->toAddon.addonInstance->EnableMouse(enable, controller_id); | ||
| 2294 | } | ||
| 2295 | |||
| 2296 | inline static bool ADDON_ConnectController(const AddonInstance_Game* instance, | ||
| 2297 | bool connect, | ||
| 2298 | const char* port_address, | ||
| 2299 | const char* controller_id) | ||
| 2300 | { | ||
| 2301 | return instance->toAddon.addonInstance->ConnectController(connect, port_address, controller_id); | ||
| 2302 | } | ||
| 2303 | |||
| 2304 | inline static bool ADDON_InputEvent(const AddonInstance_Game* instance, | ||
| 2305 | const game_input_event* event) | ||
| 2306 | { | ||
| 2307 | return instance->toAddon.addonInstance->InputEvent(*event); | ||
| 2308 | } | ||
| 2309 | |||
| 2310 | |||
| 2311 | // --- Serialization operations ------------------------------------------------ | ||
| 2312 | |||
| 2313 | inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance) | ||
| 2314 | { | ||
| 2315 | return instance->toAddon.addonInstance->SerializeSize(); | ||
| 2316 | } | ||
| 2317 | |||
| 2318 | inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance, | ||
| 2319 | uint8_t* data, | ||
| 2320 | size_t size) | ||
| 2321 | { | ||
| 2322 | return instance->toAddon.addonInstance->Serialize(data, size); | ||
| 2323 | } | ||
| 2324 | |||
| 2325 | inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance, | ||
| 2326 | const uint8_t* data, | ||
| 2327 | size_t size) | ||
| 2328 | { | ||
| 2329 | return instance->toAddon.addonInstance->Deserialize(data, size); | ||
| 2330 | } | ||
| 2331 | |||
| 2332 | |||
| 2333 | // --- Cheat operations -------------------------------------------------------- | ||
| 2334 | |||
| 2335 | inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance) | ||
| 2336 | { | ||
| 2337 | return instance->toAddon.addonInstance->CheatReset(); | ||
| 2338 | } | ||
| 2339 | |||
| 2340 | inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance, | ||
| 2341 | GAME_MEMORY type, | ||
| 2342 | uint8_t** data, | ||
| 2343 | size_t* size) | ||
| 2344 | { | ||
| 2345 | return instance->toAddon.addonInstance->GetMemory(type, *data, *size); | ||
| 2346 | } | ||
| 2347 | |||
| 2348 | inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance, | ||
| 2349 | unsigned int index, | ||
| 2350 | bool enabled, | ||
| 2351 | const char* code) | ||
| 2352 | { | ||
| 2353 | return instance->toAddon.addonInstance->SetCheat(index, enabled, code); | ||
| 2354 | } | ||
| 2355 | |||
| 2356 | AddonInstance_Game* m_instanceData; | ||
| 2357 | }; | ||
| 2358 | |||
| 2359 | } /* namespace addon */ | ||
| 2360 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h index 09ac6c9..e41e5ef 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h | |||
| @@ -9,144 +9,307 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../AddonBase.h" | 11 | #include "../AddonBase.h" |
| 12 | #include "../c-api/addon-instance/image_decoder.h" | ||
| 12 | 13 | ||
| 13 | namespace kodi { namespace addon { class CInstanceImageDecoder; }} | 14 | #ifdef __cplusplus |
| 14 | 15 | namespace kodi | |
| 15 | extern "C" | 16 | { |
| 17 | namespace addon | ||
| 16 | { | 18 | { |
| 17 | 19 | ||
| 18 | typedef struct AddonProps_ImageDecoder | 20 | //############################################################################## |
| 19 | { | 21 | /// @defgroup cpp_kodi_addon_imagedecoder_Defs Definitions, structures and enumerators |
| 20 | const char* mimetype; | 22 | /// @ingroup cpp_kodi_addon_imagedecoder |
| 21 | } AddonProps_ImageDecoder; | 23 | /// @brief **Image decoder add-on general variables** |
| 24 | /// | ||
| 25 | /// Used to exchange the available options between Kodi and addon. | ||
| 26 | /// | ||
| 27 | /// | ||
| 22 | 28 | ||
| 23 | typedef struct AddonToKodiFuncTable_ImageDecoder | 29 | //============================================================================== |
| 30 | /// | ||
| 31 | /// @addtogroup cpp_kodi_addon_imagedecoder | ||
| 32 | /// @brief @cpp_class{ kodi::addon::CInstanceImageDecoder } | ||
| 33 | /// **Image decoder add-on instance**\n | ||
| 34 | /// This instance type is used to allow Kodi various additional image format | ||
| 35 | /// types. | ||
| 36 | /// | ||
| 37 | /// This usage can be requested under various conditions, by a Mimetype protocol | ||
| 38 | /// defined in <b>`addon.xml`</b> or supported file extensions. | ||
| 39 | /// | ||
| 40 | /// Include the header @ref ImageDecoder.h "#include <kodi/addon-instance/ImageDecoder.h>" | ||
| 41 | /// to use this class. | ||
| 42 | /// | ||
| 43 | /// ---------------------------------------------------------------------------- | ||
| 44 | /// | ||
| 45 | /// Here is an example of what the <b>`addon.xml.in`</b> would look like for an | ||
| 46 | /// image decoder addon: | ||
| 47 | /// | ||
| 48 | /// ~~~~~~~~~~~~~{.xml} | ||
| 49 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 50 | /// <addon | ||
| 51 | /// id="imagedecoder.myspecialnamefor" | ||
| 52 | /// version="1.0.0" | ||
| 53 | /// name="My image decoder addon" | ||
| 54 | /// provider-name="Your Name"> | ||
| 55 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 56 | /// <extension | ||
| 57 | /// point="kodi.imagedecoder" | ||
| 58 | /// extension=".imga|.imgb" | ||
| 59 | /// mimetype="image/mymimea|image/mymimea" | ||
| 60 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 61 | /// <extension point="xbmc.addon.metadata"> | ||
| 62 | /// <summary lang="en_GB">My image decoder addon summary</summary> | ||
| 63 | /// <description lang="en_GB">My image decoder description</description> | ||
| 64 | /// <platform>@PLATFORM@</platform> | ||
| 65 | /// </extension> | ||
| 66 | /// </addon> | ||
| 67 | /// ~~~~~~~~~~~~~ | ||
| 68 | /// | ||
| 69 | /// ### Standard values that can be declared for processing in `addon.xml`. | ||
| 70 | /// | ||
| 71 | /// These values are used by Kodi to identify associated images and file | ||
| 72 | /// extensions and then to select the associated addon. | ||
| 73 | /// | ||
| 74 | /// \table_start | ||
| 75 | /// \table_h3{ Labels, Type, Description } | ||
| 76 | /// \table_row3{ <b>`point`</b>, | ||
| 77 | /// @anchor cpp_kodi_addon_imagedecoder_point | ||
| 78 | /// string, | ||
| 79 | /// The identification of the addon instance to image decoder is mandatory | ||
| 80 | /// <b>`kodi.imagedecoder`</b>. In addition\, the instance declared in the | ||
| 81 | /// first <b>`<extension ... />`</b> is also the main type of addon. | ||
| 82 | /// } | ||
| 83 | /// \table_row3{ <b>`extension`</b>, | ||
| 84 | /// @anchor cpp_kodi_addon_imagedecoder_defaultPort | ||
| 85 | /// string, | ||
| 86 | /// The from addon operated and supported image file endings.\n | ||
| 87 | /// Use a <b>`|`</b> to separate between different ones. | ||
| 88 | /// } | ||
| 89 | /// \table_row3{ <b>`defaultPort`</b>, | ||
| 90 | /// @anchor cpp_kodi_addon_imagedecoder_defaultPort | ||
| 91 | /// string, | ||
| 92 | /// The from addon operated image [mimetypes](https://en.wikipedia.org/wiki/Media_type).\n | ||
| 93 | /// Use a <b>`|`</b> to separate between different ones. | ||
| 94 | /// } | ||
| 95 | /// \table_row3{ <b>`library_@PLATFORM@`</b>, | ||
| 96 | /// @anchor cpp_kodi_addon_imagedecoder_library | ||
| 97 | /// string, | ||
| 98 | /// The runtime library used for the addon. This is usually declared by `cmake` and correctly displayed in the translated <b>`addon.xml`</b>. | ||
| 99 | /// } | ||
| 100 | /// \table_end | ||
| 101 | /// | ||
| 102 | /// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml. | ||
| 103 | /// | ||
| 104 | /// | ||
| 105 | /// -------------------------------------------------------------------------- | ||
| 106 | /// | ||
| 107 | /// | ||
| 108 | /// **Example:** | ||
| 109 | /// | ||
| 110 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 111 | /// #include <kodi/addon-instance/ImageDecoder.h> | ||
| 112 | /// | ||
| 113 | /// class ATTRIBUTE_HIDDEN CMyImageDecoder : public kodi::addon::CInstanceImageDecoder | ||
| 114 | /// { | ||
| 115 | /// public: | ||
| 116 | /// CMyImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion); | ||
| 117 | /// | ||
| 118 | /// bool LoadImageFromMemory(unsigned char* buffer, | ||
| 119 | /// unsigned int bufSize, | ||
| 120 | /// unsigned int& width, | ||
| 121 | /// unsigned int& height) override; | ||
| 122 | /// | ||
| 123 | /// bool Decode(unsigned char* pixels, | ||
| 124 | /// unsigned int width, | ||
| 125 | /// unsigned int height, | ||
| 126 | /// unsigned int pitch, | ||
| 127 | /// ImageFormat format) override; | ||
| 128 | /// | ||
| 129 | /// ... | ||
| 130 | /// }; | ||
| 131 | /// | ||
| 132 | /// CMyImageDecoder::CMyImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 133 | /// : CInstanceImageDecoder(instance, kodiVersion) | ||
| 134 | /// { | ||
| 135 | /// ... | ||
| 136 | /// } | ||
| 137 | /// | ||
| 138 | /// bool CMyImageDecoder::LoadImageFromMemory(unsigned char* buffer, | ||
| 139 | /// unsigned int bufSize, | ||
| 140 | /// unsigned int& width, | ||
| 141 | /// unsigned int& height) | ||
| 142 | /// { | ||
| 143 | /// ... | ||
| 144 | /// return true; | ||
| 145 | /// } | ||
| 146 | /// | ||
| 147 | /// bool CMyImageDecoder::Decode(unsigned char* pixels, | ||
| 148 | /// unsigned int width, | ||
| 149 | /// unsigned int height, | ||
| 150 | /// unsigned int pitch, | ||
| 151 | /// ImageFormat format) override; | ||
| 152 | /// { | ||
| 153 | /// ... | ||
| 154 | /// return true; | ||
| 155 | /// } | ||
| 156 | /// | ||
| 157 | /// //---------------------------------------------------------------------- | ||
| 158 | /// | ||
| 159 | /// class ATTRIBUTE_HIDDEN CMyAddon : public kodi::addon::CAddonBase | ||
| 160 | /// { | ||
| 161 | /// public: | ||
| 162 | /// CMyAddon() = default; | ||
| 163 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 164 | /// const std::string& instanceID, | ||
| 165 | /// KODI_HANDLE instance, | ||
| 166 | /// const std::string& version, | ||
| 167 | /// KODI_HANDLE& addonInstance) override; | ||
| 168 | /// }; | ||
| 169 | /// | ||
| 170 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 171 | /// // instanceID ignored | ||
| 172 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 173 | /// const std::string& instanceID, | ||
| 174 | /// KODI_HANDLE instance, | ||
| 175 | /// const std::string& version, | ||
| 176 | /// KODI_HANDLE& addonInstance) | ||
| 177 | /// { | ||
| 178 | /// if (instanceType == ADDON_INSTANCE_IMAGEDECODER) | ||
| 179 | /// { | ||
| 180 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my image decoder instance"); | ||
| 181 | /// addonInstance = new CMyImageDecoder(instance, version); | ||
| 182 | /// return ADDON_STATUS_OK; | ||
| 183 | /// } | ||
| 184 | /// else if (...) | ||
| 185 | /// { | ||
| 186 | /// ... | ||
| 187 | /// } | ||
| 188 | /// return ADDON_STATUS_UNKNOWN; | ||
| 189 | /// } | ||
| 190 | /// | ||
| 191 | /// ADDONCREATOR(CMyAddon) | ||
| 192 | /// ~~~~~~~~~~~~~ | ||
| 193 | /// | ||
| 194 | /// The destruction of the example class `CMyImageDecoder` is called from | ||
| 195 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 196 | /// | ||
| 197 | //------------------------------------------------------------------------------ | ||
| 198 | class ATTRIBUTE_HIDDEN CInstanceImageDecoder : public IAddonInstance | ||
| 199 | { | ||
| 200 | public: | ||
| 201 | //============================================================================ | ||
| 202 | /// @ingroup cpp_kodi_addon_imagedecoder | ||
| 203 | /// @brief Class constructor. | ||
| 204 | /// | ||
| 205 | /// @param[in] instance The from Kodi given instance given be add-on | ||
| 206 | /// CreateInstance call with instance id | ||
| 207 | /// @ref ADDON_INSTANCE_IMAGEDECODER. | ||
| 208 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 209 | /// allow compatibility to older Kodi versions. | ||
| 210 | /// | ||
| 211 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 212 | /// | ||
| 213 | explicit CInstanceImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 214 | : IAddonInstance(ADDON_INSTANCE_IMAGEDECODER, | ||
| 215 | !kodiVersion.empty() ? kodiVersion | ||
| 216 | : GetKodiTypeVersion(ADDON_INSTANCE_IMAGEDECODER)) | ||
| 24 | { | 217 | { |
| 25 | KODI_HANDLE kodi_instance; | 218 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 26 | } AddonToKodiFuncTable_ImageDecoder; | 219 | throw std::logic_error("kodi::addon::CInstanceImageDecoder: Creation of multiple together " |
| 220 | "with single instance way is not allowed!"); | ||
| 27 | 221 | ||
| 28 | struct AddonInstance_ImageDecoder; | 222 | SetAddonStruct(instance); |
| 29 | typedef struct KodiToAddonFuncTable_ImageDecoder | 223 | } |
| 30 | { | 224 | //---------------------------------------------------------------------------- |
| 31 | kodi::addon::CInstanceImageDecoder* addonInstance; | ||
| 32 | bool (__cdecl* load_image_from_memory) (const AddonInstance_ImageDecoder* instance, | ||
| 33 | unsigned char* buffer, unsigned int buf_size, | ||
| 34 | unsigned int* width, unsigned int* height); | ||
| 35 | |||
| 36 | bool (__cdecl* decode) (const AddonInstance_ImageDecoder* instance, | ||
| 37 | unsigned char* pixels, | ||
| 38 | unsigned int width, unsigned int height, | ||
| 39 | unsigned int pitch, unsigned int format); | ||
| 40 | } KodiToAddonFuncTable_ImageDecoder; | ||
| 41 | |||
| 42 | typedef struct AddonInstance_ImageDecoder | ||
| 43 | { | ||
| 44 | AddonProps_ImageDecoder props; | ||
| 45 | AddonToKodiFuncTable_ImageDecoder toKodi; | ||
| 46 | KodiToAddonFuncTable_ImageDecoder toAddon; | ||
| 47 | } AddonInstance_ImageDecoder; | ||
| 48 | 225 | ||
| 49 | } /* extern "C" */ | 226 | ~CInstanceImageDecoder() override = default; |
| 50 | 227 | ||
| 51 | typedef enum ImageFormat : unsigned int | 228 | //============================================================================ |
| 52 | { | 229 | /// @ingroup cpp_kodi_addon_imagedecoder |
| 53 | ADDON_IMG_FMT_A8R8G8B8 = 1, | 230 | /// @brief Initialize an encoder. |
| 54 | ADDON_IMG_FMT_A8 = 2, | 231 | /// |
| 55 | ADDON_IMG_FMT_RGBA8 = 3, | 232 | /// @param[in] buffer The data to read from memory |
| 56 | ADDON_IMG_FMT_RGB8 = 4 | 233 | /// @param[in] bufSize The buffer size |
| 57 | } ImageFormat; | 234 | /// @param[in,out] width The optimal width of image on entry, obtained width |
| 235 | /// on return | ||
| 236 | /// @param[in,out] height The optimal height of image, actual obtained height | ||
| 237 | /// on return | ||
| 238 | /// @return true if successful done, false on error | ||
| 239 | /// | ||
| 240 | virtual bool LoadImageFromMemory(unsigned char* buffer, | ||
| 241 | unsigned int bufSize, | ||
| 242 | unsigned int& width, | ||
| 243 | unsigned int& height) = 0; | ||
| 244 | //---------------------------------------------------------------------------- | ||
| 58 | 245 | ||
| 59 | namespace kodi | 246 | //============================================================================ |
| 60 | { | 247 | /// @ingroup cpp_kodi_addon_imagedecoder |
| 61 | namespace addon | 248 | /// @brief Decode previously loaded image. |
| 62 | { | 249 | /// |
| 250 | /// @param[in] pixels Output buffer | ||
| 251 | /// @param[in] width Width of output image | ||
| 252 | /// @param[in] height Height of output image | ||
| 253 | /// @param[in] pitch Pitch of output image | ||
| 254 | /// @param[in] format Format of output image | ||
| 255 | /// @return true if successful done, false on error | ||
| 256 | /// | ||
| 257 | virtual bool Decode(unsigned char* pixels, | ||
| 258 | unsigned int width, | ||
| 259 | unsigned int height, | ||
| 260 | unsigned int pitch, | ||
| 261 | ImageFormat format) = 0; | ||
| 262 | //---------------------------------------------------------------------------- | ||
| 263 | |||
| 264 | //============================================================================ | ||
| 265 | /// @ingroup cpp_kodi_addon_imagedecoder | ||
| 266 | /// @brief **Callback to Kodi Function**\n | ||
| 267 | /// Get the wanted mime type from Kodi. | ||
| 268 | /// | ||
| 269 | /// @return the mimetype wanted from Kodi | ||
| 270 | /// | ||
| 271 | /// @remarks Only called from addon itself. | ||
| 272 | /// | ||
| 273 | inline std::string MimeType() { return m_instanceData->props->mimetype; } | ||
| 274 | //---------------------------------------------------------------------------- | ||
| 275 | |||
| 276 | private: | ||
| 277 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 278 | { | ||
| 279 | if (instance == nullptr) | ||
| 280 | throw std::logic_error("kodi::addon::CInstanceImageDecoder: Creation with empty addon " | ||
| 281 | "structure not allowed, table must be given from Kodi!"); | ||
| 282 | |||
| 283 | m_instanceData = static_cast<AddonInstance_ImageDecoder*>(instance); | ||
| 284 | m_instanceData->toAddon->addonInstance = this; | ||
| 285 | m_instanceData->toAddon->load_image_from_memory = ADDON_LoadImageFromMemory; | ||
| 286 | m_instanceData->toAddon->decode = ADDON_Decode; | ||
| 287 | } | ||
| 63 | 288 | ||
| 64 | class CInstanceImageDecoder : public IAddonInstance | 289 | inline static bool ADDON_LoadImageFromMemory(const AddonInstance_ImageDecoder* instance, |
| 290 | unsigned char* buffer, | ||
| 291 | unsigned int bufSize, | ||
| 292 | unsigned int* width, | ||
| 293 | unsigned int* height) | ||
| 65 | { | 294 | { |
| 66 | public: | 295 | return static_cast<CInstanceImageDecoder*>(instance->toAddon->addonInstance) |
| 67 | //========================================================================== | 296 | ->LoadImageFromMemory(buffer, bufSize, *width, *height); |
| 68 | /// @brief Class constructor | 297 | } |
| 69 | /// | 298 | |
| 70 | /// @param[in] instance The from Kodi given instance given be | 299 | inline static bool ADDON_Decode(const AddonInstance_ImageDecoder* instance, |
| 71 | /// add-on CreateInstance call with instance | 300 | unsigned char* pixels, |
| 72 | /// id ADDON_INSTANCE_IMAGEDECODER. | 301 | unsigned int width, |
| 73 | explicit CInstanceImageDecoder(KODI_HANDLE instance) | 302 | unsigned int height, |
| 74 | : IAddonInstance(ADDON_INSTANCE_IMAGEDECODER) | 303 | unsigned int pitch, |
| 75 | { | 304 | enum ImageFormat format) |
| 76 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 305 | { |
| 77 | throw std::logic_error("kodi::addon::CInstanceImageDecoder: Creation of multiple together with single instance way is not allowed!"); | 306 | return static_cast<CInstanceImageDecoder*>(instance->toAddon->addonInstance) |
| 78 | 307 | ->Decode(pixels, width, height, pitch, format); | |
| 79 | SetAddonStruct(instance); | 308 | } |
| 80 | } | 309 | |
| 81 | //-------------------------------------------------------------------------- | 310 | AddonInstance_ImageDecoder* m_instanceData; |
| 82 | 311 | }; | |
| 83 | ~CInstanceImageDecoder() override = default; | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// @brief Initialize an encoder | ||
| 87 | /// | ||
| 88 | /// @param[in] buffer The data to read from memory | ||
| 89 | /// @param[in] bufSize The buffer size | ||
| 90 | /// @param[in,out] width The optimal width of image on entry, obtained width on return | ||
| 91 | /// @param[in,out] height The optimal height of image, actual obtained height on return | ||
| 92 | /// @return true if successful done, false on error | ||
| 93 | /// | ||
| 94 | virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, | ||
| 95 | unsigned int& width, unsigned int& height) = 0; | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //========================================================================== | ||
| 99 | /// @brief Decode previously loaded image | ||
| 100 | /// | ||
| 101 | /// @param[in] pixels Output buffer | ||
| 102 | /// @param[in] width Width of output image | ||
| 103 | /// @param[in] height Height of output image | ||
| 104 | /// @param[in] pitch Pitch of output image | ||
| 105 | /// @param[in] format Format of output image | ||
| 106 | /// @return true if successful done, false on error | ||
| 107 | /// | ||
| 108 | virtual bool Decode(unsigned char* pixels, | ||
| 109 | unsigned int width, unsigned int height, | ||
| 110 | unsigned int pitch, ImageFormat format) = 0; | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | |||
| 113 | //========================================================================== | ||
| 114 | /// @brief Get the wanted mime type from Kodi | ||
| 115 | /// | ||
| 116 | /// @return the mimetype wanted from Kodi | ||
| 117 | /// | ||
| 118 | inline std::string MimeType() { return m_instanceData->props.mimetype; } | ||
| 119 | //-------------------------------------------------------------------------- | ||
| 120 | |||
| 121 | private: | ||
| 122 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 123 | { | ||
| 124 | if (instance == nullptr) | ||
| 125 | throw std::logic_error("kodi::addon::CInstanceImageDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 126 | |||
| 127 | m_instanceData = static_cast<AddonInstance_ImageDecoder*>(instance); | ||
| 128 | m_instanceData->toAddon.addonInstance = this; | ||
| 129 | m_instanceData->toAddon.load_image_from_memory = ADDON_LoadImageFromMemory; | ||
| 130 | m_instanceData->toAddon.decode = ADDON_Decode; | ||
| 131 | } | ||
| 132 | |||
| 133 | inline static bool ADDON_LoadImageFromMemory(const AddonInstance_ImageDecoder* instance, | ||
| 134 | unsigned char* buffer, unsigned int bufSize, | ||
| 135 | unsigned int* width, unsigned int* height) | ||
| 136 | { | ||
| 137 | return instance->toAddon.addonInstance->LoadImageFromMemory(buffer, bufSize, *width, *height); | ||
| 138 | } | ||
| 139 | |||
| 140 | inline static bool ADDON_Decode(const AddonInstance_ImageDecoder* instance, | ||
| 141 | unsigned char* pixels, | ||
| 142 | unsigned int width, unsigned int height, | ||
| 143 | unsigned int pitch, unsigned int format) | ||
| 144 | { | ||
| 145 | return instance->toAddon.addonInstance->Decode(pixels, width, height, pitch, static_cast<ImageFormat>(format)); | ||
| 146 | } | ||
| 147 | |||
| 148 | AddonInstance_ImageDecoder* m_instanceData; | ||
| 149 | }; | ||
| 150 | 312 | ||
| 151 | } /* namespace addon */ | 313 | } /* namespace addon */ |
| 152 | } /* namespace kodi */ | 314 | } /* namespace kodi */ |
| 315 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h index 252edbf..354806e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h | |||
| @@ -14,25 +14,31 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include "../AddonBase.h" | 16 | #include "../AddonBase.h" |
| 17 | #include "../StreamCrypto.h" | ||
| 18 | #include "../StreamCodec.h" | 17 | #include "../StreamCodec.h" |
| 18 | #include "../StreamCrypto.h" | ||
| 19 | 19 | ||
| 20 | #ifdef BUILD_KODI_ADDON | 20 | #ifdef BUILD_KODI_ADDON |
| 21 | #include "../DemuxPacket.h" | 21 | #include "../DemuxPacket.h" |
| 22 | #include "../InputStreamConstants.h" | ||
| 22 | #else | 23 | #else |
| 23 | #include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" | 24 | #include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" |
| 25 | #include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" | ||
| 24 | #endif | 26 | #endif |
| 25 | 27 | ||
| 26 | namespace kodi { namespace addon { class CInstanceInputStream; }} | 28 | //Increment this level always if you add features which can lead to compile failures in the addon |
| 29 | #define INPUTSTREAM_VERSION_LEVEL 2 | ||
| 27 | 30 | ||
| 28 | extern "C" { | 31 | #ifdef __cplusplus |
| 32 | extern "C" | ||
| 33 | { | ||
| 34 | #endif /* __cplusplus */ | ||
| 29 | 35 | ||
| 30 | /*! | 36 | /*! |
| 31 | * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. | 37 | * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. |
| 32 | */ | 38 | */ |
| 33 | struct INPUTSTREAM_CAPABILITIES | 39 | struct INPUTSTREAM_CAPABILITIES |
| 34 | { | 40 | { |
| 35 | enum MASKTYPE: uint32_t | 41 | enum MASKTYPE : uint32_t |
| 36 | { | 42 | { |
| 37 | /// supports interface IDemux | 43 | /// supports interface IDemux |
| 38 | SUPPORTS_IDEMUX = (1 << 0), | 44 | SUPPORTS_IDEMUX = (1 << 0), |
| @@ -50,7 +56,10 @@ extern "C" { | |||
| 50 | SUPPORTS_PAUSE = (1 << 4), | 56 | SUPPORTS_PAUSE = (1 << 4), |
| 51 | 57 | ||
| 52 | /// supports interface ITime | 58 | /// supports interface ITime |
| 53 | SUPPORTS_ITIME = (1 << 5) | 59 | SUPPORTS_ITIME = (1 << 5), |
| 60 | |||
| 61 | /// supports interface IChapter | ||
| 62 | SUPPORTS_ICHAPTER = (1 << 6), | ||
| 54 | }; | 63 | }; |
| 55 | 64 | ||
| 56 | /// set of supported capabilities | 65 | /// set of supported capabilities |
| @@ -62,19 +71,18 @@ extern "C" { | |||
| 62 | */ | 71 | */ |
| 63 | struct INPUTSTREAM | 72 | struct INPUTSTREAM |
| 64 | { | 73 | { |
| 65 | static const unsigned int MAX_INFO_COUNT = 8; | 74 | const char* m_strURL; |
| 66 | 75 | const char* m_mimeType; | |
| 67 | const char *m_strURL; | ||
| 68 | 76 | ||
| 69 | unsigned int m_nCountInfoValues; | 77 | unsigned int m_nCountInfoValues; |
| 70 | struct LISTITEMPROPERTY | 78 | struct LISTITEMPROPERTY |
| 71 | { | 79 | { |
| 72 | const char *m_strKey; | 80 | const char* m_strKey; |
| 73 | const char *m_strValue; | 81 | const char* m_strValue; |
| 74 | } m_ListItemProperties[MAX_INFO_COUNT]; | 82 | } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT]; |
| 75 | 83 | ||
| 76 | const char *m_libFolder; | 84 | const char* m_libFolder; |
| 77 | const char *m_profileFolder; | 85 | const char* m_profileFolder; |
| 78 | }; | 86 | }; |
| 79 | 87 | ||
| 80 | /*! | 88 | /*! |
| @@ -82,23 +90,50 @@ extern "C" { | |||
| 82 | */ | 90 | */ |
| 83 | struct INPUTSTREAM_IDS | 91 | struct INPUTSTREAM_IDS |
| 84 | { | 92 | { |
| 85 | static const unsigned int MAX_STREAM_COUNT = 32; | 93 | static const unsigned int MAX_STREAM_COUNT = 256; |
| 86 | unsigned int m_streamCount; | 94 | unsigned int m_streamCount; |
| 87 | unsigned int m_streamIds[MAX_STREAM_COUNT]; | 95 | unsigned int m_streamIds[MAX_STREAM_COUNT]; |
| 88 | }; | 96 | }; |
| 89 | 97 | ||
| 90 | /*! | 98 | /*! |
| 99 | * @brief MASTERING Metadata | ||
| 100 | */ | ||
| 101 | struct INPUTSTREAM_MASTERING_METADATA | ||
| 102 | { | ||
| 103 | double primary_r_chromaticity_x; | ||
| 104 | double primary_r_chromaticity_y; | ||
| 105 | double primary_g_chromaticity_x; | ||
| 106 | double primary_g_chromaticity_y; | ||
| 107 | double primary_b_chromaticity_x; | ||
| 108 | double primary_b_chromaticity_y; | ||
| 109 | double white_point_chromaticity_x; | ||
| 110 | double white_point_chromaticity_y; | ||
| 111 | double luminance_max; | ||
| 112 | double luminance_min; | ||
| 113 | }; | ||
| 114 | |||
| 115 | /*! | ||
| 116 | * @brief CONTENTLIGHT Metadata | ||
| 117 | */ | ||
| 118 | struct INPUTSTREAM_CONTENTLIGHT_METADATA | ||
| 119 | { | ||
| 120 | uint64_t max_cll; | ||
| 121 | uint64_t max_fall; | ||
| 122 | }; | ||
| 123 | |||
| 124 | /*! | ||
| 91 | * @brief stream properties | 125 | * @brief stream properties |
| 92 | */ | 126 | */ |
| 93 | struct INPUTSTREAM_INFO | 127 | struct INPUTSTREAM_INFO |
| 94 | { | 128 | { |
| 95 | enum STREAM_TYPE | 129 | enum STREAM_TYPE |
| 96 | { | 130 | { |
| 97 | TYPE_NONE, | 131 | TYPE_NONE = 0, |
| 98 | TYPE_VIDEO, | 132 | TYPE_VIDEO, |
| 99 | TYPE_AUDIO, | 133 | TYPE_AUDIO, |
| 100 | TYPE_SUBTITLE, | 134 | TYPE_SUBTITLE, |
| 101 | TYPE_TELETEXT | 135 | TYPE_TELETEXT, |
| 136 | TYPE_RDS, | ||
| 102 | } m_streamType; | 137 | } m_streamType; |
| 103 | 138 | ||
| 104 | enum Codec_FEATURES : uint32_t | 139 | enum Codec_FEATURES : uint32_t |
| @@ -118,65 +153,130 @@ extern "C" { | |||
| 118 | FLAG_KARAOKE = 0x0020, | 153 | FLAG_KARAOKE = 0x0020, |
| 119 | FLAG_FORCED = 0x0040, | 154 | FLAG_FORCED = 0x0040, |
| 120 | FLAG_HEARING_IMPAIRED = 0x0080, | 155 | FLAG_HEARING_IMPAIRED = 0x0080, |
| 121 | FLAG_VISUAL_IMPAIRED = 0x0100 | 156 | FLAG_VISUAL_IMPAIRED = 0x0100, |
| 122 | }; | 157 | }; |
| 123 | 158 | ||
| 124 | enum INPUTSTREAM_COLORSPACE | 159 | // Keep in sync with AVColorSpace |
| 125 | { | 160 | enum COLORSPACE |
| 126 | COLORSPACE_UNKNOWN, | 161 | { |
| 127 | COLORSPACE_BT709, | 162 | COLORSPACE_RGB = 0, |
| 128 | COLORSPACE_BT470M, | 163 | COLORSPACE_BT709 = 1, |
| 129 | COLORSPACE_BT470BG, | 164 | COLORSPACE_UNSPECIFIED = 2, |
| 130 | COLORSPACE_SMPTE170M, | 165 | COLORSPACE_UNKNOWN = COLORSPACE_UNSPECIFIED, // compatibility |
| 131 | COLORSPACE_SMPTE240M, | 166 | COLORSPACE_RESERVED = 3, |
| 132 | COLORSPACE_FILM, | 167 | COLORSPACE_FCC = 4, |
| 133 | COLORSPACE_BT2020, | 168 | COLORSPACE_BT470BG = 5, |
| 134 | COLORSPACE_SMPTE428, | 169 | COLORSPACE_SMPTE170M = 6, |
| 135 | COLORSPACE_SMPTEST428_1, | 170 | COLORSPACE_SMPTE240M = 7, |
| 136 | COLORSPACE_SMPTE431, | 171 | COLORSPACE_YCGCO = 8, |
| 137 | COLORSPACE_SMPTE432, | 172 | COLORSPACE_YCOCG = COLORSPACE_YCGCO, |
| 138 | COLORSPACE_JEDEC_P22 | 173 | COLORSPACE_BT2020_NCL = 9, |
| 174 | COLORSPACE_BT2020_CL = 10, | ||
| 175 | COLORSPACE_SMPTE2085 = 11, | ||
| 176 | COLORSPACE_CHROMA_DERIVED_NCL = 12, | ||
| 177 | COLORSPACE_CHROMA_DERIVED_CL = 13, | ||
| 178 | COLORSPACE_ICTCP = 14, | ||
| 179 | COLORSPACE_MAX | ||
| 180 | }; | ||
| 181 | |||
| 182 | // Keep in sync with AVColorPrimaries | ||
| 183 | enum COLORPRIMARIES : int32_t | ||
| 184 | { | ||
| 185 | COLORPRIMARY_RESERVED0 = 0, | ||
| 186 | COLORPRIMARY_BT709 = 1, | ||
| 187 | COLORPRIMARY_UNSPECIFIED = 2, | ||
| 188 | COLORPRIMARY_RESERVED = 3, | ||
| 189 | COLORPRIMARY_BT470M = 4, | ||
| 190 | COLORPRIMARY_BT470BG = 5, | ||
| 191 | COLORPRIMARY_SMPTE170M = 6, | ||
| 192 | COLORPRIMARY_SMPTE240M = 7, | ||
| 193 | COLORPRIMARY_FILM = 8, | ||
| 194 | COLORPRIMARY_BT2020 = 9, | ||
| 195 | COLORPRIMARY_SMPTE428 = 10, | ||
| 196 | COLORPRIMARY_SMPTEST428_1 = COLORPRIMARY_SMPTE428, | ||
| 197 | COLORPRIMARY_SMPTE431 = 11, | ||
| 198 | COLORPRIMARY_SMPTE432 = 12, | ||
| 199 | COLORPRIMARY_JEDEC_P22 = 22, | ||
| 200 | COLORPRIMARY_MAX | ||
| 139 | }; | 201 | }; |
| 140 | 202 | ||
| 141 | enum INPUTSTREAM_COLORRANGE | 203 | // Keep in sync with AVColorRange |
| 204 | enum COLORRANGE | ||
| 142 | { | 205 | { |
| 143 | COLORRANGE_UNKNOWN, | 206 | COLORRANGE_UNKNOWN = 0, |
| 144 | COLORRANGE_LIMITED, | 207 | COLORRANGE_LIMITED, |
| 145 | COLORRANGE_FULLRANGE | 208 | COLORRANGE_FULLRANGE, |
| 209 | COLORRANGE_MAX | ||
| 210 | }; | ||
| 211 | |||
| 212 | // keep in sync with AVColorTransferCharacteristic | ||
| 213 | enum COLORTRC : int32_t | ||
| 214 | { | ||
| 215 | COLORTRC_RESERVED0 = 0, | ||
| 216 | COLORTRC_BT709 = 1, | ||
| 217 | COLORTRC_UNSPECIFIED = 2, | ||
| 218 | COLORTRC_RESERVED = 3, | ||
| 219 | COLORTRC_GAMMA22 = 4, | ||
| 220 | COLORTRC_GAMMA28 = 5, | ||
| 221 | COLORTRC_SMPTE170M = 6, | ||
| 222 | COLORTRC_SMPTE240M = 7, | ||
| 223 | COLORTRC_LINEAR = 8, | ||
| 224 | COLORTRC_LOG = 9, | ||
| 225 | COLORTRC_LOG_SQRT = 10, | ||
| 226 | COLORTRC_IEC61966_2_4 = 11, | ||
| 227 | COLORTRC_BT1361_ECG = 12, | ||
| 228 | COLORTRC_IEC61966_2_1 = 13, | ||
| 229 | COLORTRC_BT2020_10 = 14, | ||
| 230 | COLORTRC_BT2020_12 = 15, | ||
| 231 | COLORTRC_SMPTE2084 = 16, | ||
| 232 | COLORTRC_SMPTEST2084 = COLORTRC_SMPTE2084, | ||
| 233 | COLORTRC_SMPTE428 = 17, | ||
| 234 | COLORTRC_SMPTEST428_1 = COLORTRC_SMPTE428, | ||
| 235 | COLORTRC_ARIB_STD_B67 = 18, | ||
| 236 | COLORTRC_MAX | ||
| 146 | }; | 237 | }; |
| 147 | 238 | ||
| 148 | uint32_t m_flags; | 239 | uint32_t m_flags; |
| 149 | 240 | ||
| 150 | char m_name[256]; /*!< @brief (optinal) name of the stream, \0 for default handling */ | 241 | char m_name[256]; /*!< @brief (optinal) name of the stream, \0 for default handling */ |
| 151 | char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ | 242 | char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ |
| 152 | char m_codecInternalName[32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ | 243 | char m_codecInternalName |
| 153 | STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */ | 244 | [32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ |
| 154 | unsigned int m_pID; /*!< @brief (required) physical index */ | 245 | STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */ |
| 246 | unsigned int m_pID; /*!< @brief (required) physical index */ | ||
| 155 | 247 | ||
| 156 | const uint8_t *m_ExtraData; | 248 | const uint8_t* m_ExtraData; |
| 157 | unsigned int m_ExtraSize; | 249 | unsigned int m_ExtraSize; |
| 158 | 250 | ||
| 159 | char m_language[64]; /*!< @brief RFC 5646 language code (empty string if undefined) */ | 251 | char m_language[64]; /*!< @brief RFC 5646 language code (empty string if undefined) */ |
| 160 | 252 | ||
| 161 | unsigned int m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */ | 253 | unsigned int |
| 254 | m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */ | ||
| 162 | unsigned int m_FpsRate; | 255 | unsigned int m_FpsRate; |
| 163 | unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */ | 256 | unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */ |
| 164 | unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */ | 257 | unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */ |
| 165 | float m_Aspect; /*!< @brief display aspect of stream */ | 258 | float m_Aspect; /*!< @brief display aspect of stream */ |
| 166 | 259 | ||
| 167 | 260 | ||
| 168 | unsigned int m_Channels; /*!< @brief (required) amount of channels */ | 261 | unsigned int m_Channels; /*!< @brief (required) amount of channels */ |
| 169 | unsigned int m_SampleRate; /*!< @brief (required) sample rate */ | 262 | unsigned int m_SampleRate; /*!< @brief (required) sample rate */ |
| 170 | unsigned int m_BitRate; /*!< @brief (required) bit rate */ | 263 | unsigned int m_BitRate; /*!< @brief (required) bit rate */ |
| 171 | unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */ | 264 | unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */ |
| 172 | unsigned int m_BlockAlign; | 265 | unsigned int m_BlockAlign; |
| 173 | 266 | ||
| 174 | CRYPTO_INFO m_cryptoInfo; | 267 | CRYPTO_INFO m_cryptoInfo; |
| 175 | 268 | ||
| 176 | // new in API version 2.0.8 | 269 | // new in API version 2.0.8 |
| 177 | unsigned int m_codecFourCC; /*!< @brief Codec If available, the fourcc code codec */ | 270 | unsigned int m_codecFourCC; /*!< @brief Codec If available, the fourcc code codec */ |
| 178 | INPUTSTREAM_COLORSPACE m_colorSpace; /*!< @brief definition of colorspace */ | 271 | COLORSPACE m_colorSpace; /*!< @brief definition of colorspace */ |
| 179 | INPUTSTREAM_COLORRANGE m_colorRange; /*!< @brief color range if available */ | 272 | COLORRANGE m_colorRange; /*!< @brief color range if available */ |
| 273 | |||
| 274 | //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1 | ||
| 275 | COLORPRIMARIES m_colorPrimaries; | ||
| 276 | COLORTRC m_colorTransferCharacteristic; | ||
| 277 | INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; /*!< @brief mastering static Metadata */ | ||
| 278 | INPUTSTREAM_CONTENTLIGHT_METADATA* | ||
| 279 | m_contentLightMetadata; /*!< @brief content light static Metadata */ | ||
| 180 | }; | 280 | }; |
| 181 | 281 | ||
| 182 | struct INPUTSTREAM_TIMES | 282 | struct INPUTSTREAM_TIMES |
| @@ -188,7 +288,7 @@ extern "C" { | |||
| 188 | }; | 288 | }; |
| 189 | 289 | ||
| 190 | /*! | 290 | /*! |
| 191 | * @brief Structure to transfer the methods from xbmc_inputstream_dll.h to XBMC | 291 | * @brief "C" ABI Structures to transfer the methods from this to Kodi |
| 192 | */ | 292 | */ |
| 193 | 293 | ||
| 194 | // this are properties given to the addon on create | 294 | // this are properties given to the addon on create |
| @@ -202,53 +302,72 @@ extern "C" { | |||
| 202 | { | 302 | { |
| 203 | KODI_HANDLE kodiInstance; | 303 | KODI_HANDLE kodiInstance; |
| 204 | DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size); | 304 | DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size); |
| 205 | DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance, unsigned int data_size, unsigned int encrypted_subsample_count); | 305 | DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance, |
| 306 | unsigned int data_size, | ||
| 307 | unsigned int encrypted_subsample_count); | ||
| 206 | void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet); | 308 | void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet); |
| 207 | } AddonToKodiFuncTable_InputStream; | 309 | } AddonToKodiFuncTable_InputStream; |
| 208 | 310 | ||
| 209 | struct AddonInstance_InputStream; | 311 | struct AddonInstance_InputStream; |
| 210 | typedef struct KodiToAddonFuncTable_InputStream /* internal */ | 312 | typedef struct KodiToAddonFuncTable_InputStream /* internal */ |
| 211 | { | 313 | { |
| 212 | kodi::addon::CInstanceInputStream* addonInstance; | 314 | KODI_HANDLE addonInstance; |
| 213 | 315 | ||
| 214 | bool (__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props); | 316 | bool(__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props); |
| 215 | void (__cdecl* close)(const AddonInstance_InputStream* instance); | 317 | void(__cdecl* close)(const AddonInstance_InputStream* instance); |
| 216 | const char* (__cdecl* get_path_list)(const AddonInstance_InputStream* instance); | 318 | const char*(__cdecl* get_path_list)(const AddonInstance_InputStream* instance); |
| 217 | void (__cdecl* get_capabilities)(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities); | 319 | void(__cdecl* get_capabilities)(const AddonInstance_InputStream* instance, |
| 320 | INPUTSTREAM_CAPABILITIES* capabilities); | ||
| 218 | 321 | ||
| 219 | // IDemux | 322 | // IDemux |
| 220 | struct INPUTSTREAM_IDS (__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance); | 323 | struct INPUTSTREAM_IDS(__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance); |
| 221 | struct INPUTSTREAM_INFO (__cdecl* get_stream)(const AddonInstance_InputStream* instance, int streamid); | 324 | struct INPUTSTREAM_INFO(__cdecl* get_stream)(const AddonInstance_InputStream* instance, |
| 222 | void (__cdecl* enable_stream)(const AddonInstance_InputStream* instance, int streamid, bool enable); | 325 | int streamid); |
| 326 | void(__cdecl* enable_stream)(const AddonInstance_InputStream* instance, | ||
| 327 | int streamid, | ||
| 328 | bool enable); | ||
| 223 | bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid); | 329 | bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid); |
| 224 | void (__cdecl* demux_reset)(const AddonInstance_InputStream* instance); | 330 | void(__cdecl* demux_reset)(const AddonInstance_InputStream* instance); |
| 225 | void (__cdecl* demux_abort)(const AddonInstance_InputStream* instance); | 331 | void(__cdecl* demux_abort)(const AddonInstance_InputStream* instance); |
| 226 | void (__cdecl* demux_flush)(const AddonInstance_InputStream* instance); | 332 | void(__cdecl* demux_flush)(const AddonInstance_InputStream* instance); |
| 227 | DemuxPacket* (__cdecl* demux_read)(const AddonInstance_InputStream* instance); | 333 | DemuxPacket*(__cdecl* demux_read)(const AddonInstance_InputStream* instance); |
| 228 | bool (__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance, double time, bool backwards, double* startpts); | 334 | bool(__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance, |
| 229 | void (__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed); | 335 | double time, |
| 230 | void (__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance, int width, int height); | 336 | bool backwards, |
| 337 | double* startpts); | ||
| 338 | void(__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed); | ||
| 339 | void(__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance, | ||
| 340 | int width, | ||
| 341 | int height); | ||
| 231 | 342 | ||
| 232 | // IDisplayTime | 343 | // IDisplayTime |
| 233 | int (__cdecl* get_total_time)(const AddonInstance_InputStream* instance); | 344 | int(__cdecl* get_total_time)(const AddonInstance_InputStream* instance); |
| 234 | int (__cdecl* get_time)(const AddonInstance_InputStream* instance); | 345 | int(__cdecl* get_time)(const AddonInstance_InputStream* instance); |
| 235 | 346 | ||
| 236 | // ITime | 347 | // ITime |
| 237 | bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES *times); | 348 | bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times); |
| 238 | 349 | ||
| 239 | // IPosTime | 350 | // IPosTime |
| 240 | bool (__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms); | 351 | bool(__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms); |
| 241 | 352 | ||
| 242 | // Seekable (mandatory) | 353 | int(__cdecl* read_stream)(const AddonInstance_InputStream* instance, |
| 243 | bool (__cdecl* can_pause_stream)(const AddonInstance_InputStream* instance); | 354 | uint8_t* buffer, |
| 244 | bool (__cdecl* can_seek_stream)(const AddonInstance_InputStream* instance); | 355 | unsigned int bufferSize); |
| 245 | 356 | int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance, | |
| 246 | int (__cdecl* read_stream)(const AddonInstance_InputStream* instance, uint8_t* buffer, unsigned int bufferSize); | 357 | int64_t position, |
| 247 | int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance, int64_t position, int whence); | 358 | int whence); |
| 248 | int64_t (__cdecl* position_stream)(const AddonInstance_InputStream* instance); | 359 | int64_t(__cdecl* position_stream)(const AddonInstance_InputStream* instance); |
| 249 | int64_t (__cdecl* length_stream)(const AddonInstance_InputStream* instance); | 360 | int64_t(__cdecl* length_stream)(const AddonInstance_InputStream* instance); |
| 250 | void (__cdecl* pause_stream)(const AddonInstance_InputStream* instance, double time); | 361 | bool(__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance); |
| 251 | bool (__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance); | 362 | |
| 363 | // IChapter | ||
| 364 | int(__cdecl* get_chapter)(const AddonInstance_InputStream* instance); | ||
| 365 | int(__cdecl* get_chapter_count)(const AddonInstance_InputStream* instance); | ||
| 366 | const char*(__cdecl* get_chapter_name)(const AddonInstance_InputStream* instance, int ch); | ||
| 367 | int64_t(__cdecl* get_chapter_pos)(const AddonInstance_InputStream* instance, int ch); | ||
| 368 | bool(__cdecl* seek_chapter)(const AddonInstance_InputStream* instance, int ch); | ||
| 369 | |||
| 370 | int(__cdecl* block_size_stream)(const AddonInstance_InputStream* instance); | ||
| 252 | } KodiToAddonFuncTable_InputStream; | 371 | } KodiToAddonFuncTable_InputStream; |
| 253 | 372 | ||
| 254 | typedef struct AddonInstance_InputStream /* internal */ | 373 | typedef struct AddonInstance_InputStream /* internal */ |
| @@ -258,6 +377,7 @@ extern "C" { | |||
| 258 | KodiToAddonFuncTable_InputStream toAddon; | 377 | KodiToAddonFuncTable_InputStream toAddon; |
| 259 | } AddonInstance_InputStream; | 378 | } AddonInstance_InputStream; |
| 260 | 379 | ||
| 380 | #ifdef __cplusplus | ||
| 261 | } /* extern "C" */ | 381 | } /* extern "C" */ |
| 262 | 382 | ||
| 263 | namespace kodi | 383 | namespace kodi |
| @@ -265,90 +385,93 @@ namespace kodi | |||
| 265 | namespace addon | 385 | namespace addon |
| 266 | { | 386 | { |
| 267 | 387 | ||
| 268 | class CInstanceInputStream : public IAddonInstance | 388 | class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance |
| 389 | { | ||
| 390 | public: | ||
| 391 | explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 392 | : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM, | ||
| 393 | !kodiVersion.empty() ? kodiVersion | ||
| 394 | : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM)) | ||
| 269 | { | 395 | { |
| 270 | public: | 396 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 271 | explicit CInstanceInputStream(KODI_HANDLE instance) | 397 | throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together " |
| 272 | : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM) | 398 | "with single instance way is not allowed!"); |
| 273 | { | ||
| 274 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 275 | throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together with single instance way is not allowed!"); | ||
| 276 | 399 | ||
| 277 | SetAddonStruct(instance); | 400 | SetAddonStruct(instance, m_kodiVersion); |
| 278 | } | 401 | } |
| 279 | 402 | ||
| 280 | ~CInstanceInputStream() override = default; | 403 | ~CInstanceInputStream() override = default; |
| 281 | 404 | ||
| 282 | /*! | 405 | /*! |
| 283 | * Open a stream. | 406 | * Open a stream. |
| 284 | * @param props | 407 | * @param props |
| 285 | * @return True if the stream has been opened successfully, false otherwise. | 408 | * @return True if the stream has been opened successfully, false otherwise. |
| 286 | * @remarks | 409 | * @remarks |
| 287 | */ | 410 | */ |
| 288 | virtual bool Open(INPUTSTREAM& props) = 0; | 411 | virtual bool Open(INPUTSTREAM& props) = 0; |
| 289 | 412 | ||
| 290 | /*! | 413 | /*! |
| 291 | * Close an open stream. | 414 | * Close an open stream. |
| 292 | * @remarks | 415 | * @remarks |
| 293 | */ | 416 | */ |
| 294 | virtual void Close() = 0; | 417 | virtual void Close() = 0; |
| 295 | 418 | ||
| 296 | /*! | 419 | /*! |
| 297 | * Get Capabilities of this addon. | 420 | * Get Capabilities of this addon. |
| 298 | * @param capabilities The add-on's capabilities. | 421 | * @param capabilities The add-on's capabilities. |
| 299 | * @remarks | 422 | * @remarks |
| 300 | */ | 423 | */ |
| 301 | virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0; | 424 | virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0; |
| 302 | 425 | ||
| 303 | /*! | 426 | /*! |
| 304 | * Get IDs of available streams | 427 | * Get IDs of available streams |
| 305 | * @remarks | 428 | * @remarks |
| 306 | */ | 429 | */ |
| 307 | virtual INPUTSTREAM_IDS GetStreamIds() = 0; | 430 | virtual INPUTSTREAM_IDS GetStreamIds() = 0; |
| 308 | 431 | ||
| 309 | /*! | 432 | /*! |
| 310 | * Get stream properties of a stream. | 433 | * Get stream properties of a stream. |
| 311 | * @param streamid unique id of stream | 434 | * @param streamid unique id of stream |
| 312 | * @return struc of stream properties | 435 | * @return struc of stream properties |
| 313 | * @remarks | 436 | * @remarks |
| 314 | */ | 437 | */ |
| 315 | virtual INPUTSTREAM_INFO GetStream(int streamid) = 0; | 438 | virtual INPUTSTREAM_INFO GetStream(int streamid) = 0; |
| 316 | 439 | ||
| 317 | /*! | 440 | /*! |
| 318 | * Enable or disable a stream. | 441 | * Enable or disable a stream. |
| 319 | * A disabled stream does not send demux packets | 442 | * A disabled stream does not send demux packets |
| 320 | * @param streamid unique id of stream | 443 | * @param streamid unique id of stream |
| 321 | * @param enable true for enable, false for disable | 444 | * @param enable true for enable, false for disable |
| 322 | * @remarks | 445 | * @remarks |
| 323 | */ | 446 | */ |
| 324 | virtual void EnableStream(int streamid, bool enable) = 0; | 447 | virtual void EnableStream(int streamid, bool enable) = 0; |
| 325 | 448 | ||
| 326 | /*! | 449 | /*! |
| 327 | * Opens a stream for playback. | 450 | * Opens a stream for playback. |
| 328 | * @param streamid unique id of stream | 451 | * @param streamid unique id of stream |
| 329 | * @remarks | 452 | * @remarks |
| 330 | */ | 453 | */ |
| 331 | virtual bool OpenStream(int streamid) = 0; | 454 | virtual bool OpenStream(int streamid) = 0; |
| 332 | 455 | ||
| 333 | /*! | 456 | /*! |
| 334 | * Reset the demultiplexer in the add-on. | 457 | * Reset the demultiplexer in the add-on. |
| 335 | * @remarks Required if bHandlesDemuxing is set to true. | 458 | * @remarks Required if bHandlesDemuxing is set to true. |
| 336 | */ | 459 | */ |
| 337 | virtual void DemuxReset() { } | 460 | virtual void DemuxReset() {} |
| 338 | 461 | ||
| 339 | /*! | 462 | /*! |
| 340 | * Abort the demultiplexer thread in the add-on. | 463 | * Abort the demultiplexer thread in the add-on. |
| 341 | * @remarks Required if bHandlesDemuxing is set to true. | 464 | * @remarks Required if bHandlesDemuxing is set to true. |
| 342 | */ | 465 | */ |
| 343 | virtual void DemuxAbort() { } | 466 | virtual void DemuxAbort() {} |
| 344 | 467 | ||
| 345 | /*! | 468 | /*! |
| 346 | * Flush all data that's currently in the demultiplexer buffer in the add-on. | 469 | * Flush all data that's currently in the demultiplexer buffer in the add-on. |
| 347 | * @remarks Required if bHandlesDemuxing is set to true. | 470 | * @remarks Required if bHandlesDemuxing is set to true. |
| 348 | */ | 471 | */ |
| 349 | virtual void DemuxFlush() { } | 472 | virtual void DemuxFlush() {} |
| 350 | 473 | ||
| 351 | /*! | 474 | /*! |
| 352 | * Read the next packet from the demultiplexer, if there is one. | 475 | * Read the next packet from the demultiplexer, if there is one. |
| 353 | * @return The next packet. | 476 | * @return The next packet. |
| 354 | * If there is no next packet, then the add-on should return the | 477 | * If there is no next packet, then the add-on should return the |
| @@ -357,12 +480,12 @@ namespace addon | |||
| 357 | * then, the add-on should call AllocateDemuxPacket(0) on the | 480 | * then, the add-on should call AllocateDemuxPacket(0) on the |
| 358 | * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and | 481 | * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and |
| 359 | * return the value. | 482 | * return the value. |
| 360 | * The add-on should return NULL if an error occured. | 483 | * The add-on should return NULL if an error occurred. |
| 361 | * @remarks Return NULL if this add-on won't provide this function. | 484 | * @remarks Return NULL if this add-on won't provide this function. |
| 362 | */ | 485 | */ |
| 363 | virtual DemuxPacket* DemuxRead() { return nullptr; } | 486 | virtual DemuxPacket* DemuxRead() { return nullptr; } |
| 364 | 487 | ||
| 365 | /*! | 488 | /*! |
| 366 | * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time | 489 | * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time |
| 367 | * Demuxer is required to set stream to an IDR frame | 490 | * Demuxer is required to set stream to an IDR frame |
| 368 | * @param time The absolute time since stream start | 491 | * @param time The absolute time since stream start |
| @@ -371,314 +494,388 @@ namespace addon | |||
| 371 | * @return True if the seek operation was possible | 494 | * @return True if the seek operation was possible |
| 372 | * @remarks Optional, and only used if addon has its own demuxer. | 495 | * @remarks Optional, and only used if addon has its own demuxer. |
| 373 | */ | 496 | */ |
| 374 | virtual bool DemuxSeekTime(double time, bool backwards, double &startpts) { return false; } | 497 | virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; } |
| 375 | 498 | ||
| 376 | /*! | 499 | /*! |
| 377 | * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed | 500 | * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed |
| 378 | * @param speed The requested playback speed | 501 | * @param speed The requested playback speed |
| 379 | * @remarks Optional, and only used if addon has its own demuxer. | 502 | * @remarks Optional, and only used if addon has its own demuxer. |
| 380 | */ | 503 | */ |
| 381 | virtual void DemuxSetSpeed(int speed) { } | 504 | virtual void DemuxSetSpeed(int speed) {} |
| 382 | 505 | ||
| 383 | /*! | 506 | /*! |
| 384 | * Sets desired width / height | 507 | * Sets desired width / height |
| 385 | * @param width / hight | 508 | * @param width / hight |
| 386 | */ | 509 | */ |
| 387 | virtual void SetVideoResolution(int width, int height) { } | 510 | virtual void SetVideoResolution(int width, int height) {} |
| 388 | 511 | ||
| 389 | /*! | 512 | /*! |
| 390 | * Totel time in ms | 513 | * Totel time in ms |
| 391 | * @remarks | 514 | * @remarks |
| 392 | */ | 515 | */ |
| 393 | virtual int GetTotalTime() { return -1; } | 516 | virtual int GetTotalTime() { return -1; } |
| 394 | 517 | ||
| 395 | /*! | 518 | /*! |
| 396 | * Playing time in ms | 519 | * Playing time in ms |
| 397 | * @remarks | 520 | * @remarks |
| 398 | */ | 521 | */ |
| 399 | virtual int GetTime() { return -1; } | 522 | virtual int GetTime() { return -1; } |
| 400 | 523 | ||
| 401 | /*! | 524 | /*! |
| 402 | * Get current timing values in PTS scale | 525 | * Get current timing values in PTS scale |
| 403 | * @remarks | 526 | * @remarks |
| 404 | */ | 527 | */ |
| 405 | virtual bool GetTimes(INPUTSTREAM_TIMES ×) { return false; } | 528 | virtual bool GetTimes(INPUTSTREAM_TIMES& times) { return false; } |
| 406 | 529 | ||
| 407 | /*! | 530 | /*! |
| 408 | * Positions inputstream to playing time given in ms | 531 | * Positions inputstream to playing time given in ms |
| 409 | * @remarks | 532 | * @remarks |
| 410 | */ | 533 | */ |
| 411 | virtual bool PosTime(int ms) { return false; } | 534 | virtual bool PosTime(int ms) { return false; } |
| 412 | 535 | ||
| 536 | /*! | ||
| 537 | * Return currently selected chapter | ||
| 538 | * @remarks | ||
| 539 | */ | ||
| 540 | virtual int GetChapter() { return -1; }; | ||
| 413 | 541 | ||
| 414 | /*! | 542 | /*! |
| 415 | * Check if the backend support pausing the currently playing stream | 543 | * Return number of available chapters |
| 416 | * This will enable/disable the pause button in Kodi based on the return value | 544 | * @remarks |
| 417 | * @return false if the InputStream addon/backend does not support pausing, true if possible | 545 | */ |
| 418 | */ | 546 | virtual int GetChapterCount() { return 0; }; |
| 419 | virtual bool CanPauseStream() { return false; } | ||
| 420 | 547 | ||
| 421 | /*! | 548 | /*! |
| 422 | * Check if the backend supports seeking for the currently playing stream | 549 | * Return name of chapter # ch |
| 423 | * This will enable/disable the rewind/forward buttons in Kodi based on the return value | 550 | * @remarks |
| 424 | * @return false if the InputStream addon/backend does not support seeking, true if possible | 551 | */ |
| 425 | */ | 552 | virtual const char* GetChapterName(int ch) { return nullptr; }; |
| 426 | virtual bool CanSeekStream() { return false; } | 553 | |
| 554 | /*! | ||
| 555 | * Return position if chapter # ch in milliseconds | ||
| 556 | * @remarks | ||
| 557 | */ | ||
| 558 | virtual int64_t GetChapterPos(int ch) { return 0; }; | ||
| 559 | |||
| 560 | /*! | ||
| 561 | * Seek to the beginning of chapter # ch | ||
| 562 | * @remarks | ||
| 563 | */ | ||
| 564 | virtual bool SeekChapter(int ch) { return false; }; | ||
| 427 | 565 | ||
| 428 | /*! | 566 | /*! |
| 429 | * Read from an open stream. | 567 | * Read from an open stream. |
| 430 | * @param buffer The buffer to store the data in. | 568 | * @param buffer The buffer to store the data in. |
| 431 | * @param bufferSize The amount of bytes to read. | 569 | * @param bufferSize The amount of bytes to read. |
| 432 | * @return The amount of bytes that were actually read from the stream. | 570 | * @return The amount of bytes that were actually read from the stream. |
| 433 | * @remarks Return -1 if this add-on won't provide this function. | 571 | * @remarks Return -1 if this add-on won't provide this function. |
| 434 | */ | 572 | */ |
| 435 | virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; } | 573 | virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; } |
| 436 | 574 | ||
| 437 | /*! | 575 | /*! |
| 438 | * Seek in a stream. | 576 | * Seek in a stream. |
| 439 | * @param position The position to seek to. | 577 | * @param position The position to seek to. |
| 440 | * @param whence ? | 578 | * @param whence ? |
| 441 | * @return The new position. | 579 | * @return The new position. |
| 442 | * @remarks Return -1 if this add-on won't provide this function. | 580 | * @remarks Return -1 if this add-on won't provide this function. |
| 443 | */ | 581 | */ |
| 444 | virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; } | 582 | virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; } |
| 445 | 583 | ||
| 446 | /*! | 584 | /*! |
| 447 | * @return The position in the stream that's currently being read. | 585 | * @return The position in the stream that's currently being read. |
| 448 | * @remarks Return -1 if this add-on won't provide this function. | 586 | * @remarks Return -1 if this add-on won't provide this function. |
| 449 | */ | 587 | */ |
| 450 | virtual int64_t PositionStream() { return -1; } | 588 | virtual int64_t PositionStream() { return -1; } |
| 451 | 589 | ||
| 452 | /*! | 590 | /*! |
| 453 | * @return The total length of the stream that's currently being read. | 591 | * @return The total length of the stream that's currently being read. |
| 454 | * @remarks Return -1 if this add-on won't provide this function. | 592 | * @remarks Return -1 if this add-on won't provide this function. |
| 455 | */ | 593 | */ |
| 456 | virtual int64_t LengthStream() { return -1; } | 594 | virtual int64_t LengthStream() { return -1; } |
| 457 | |||
| 458 | 595 | ||
| 459 | /*! | 596 | /*! |
| 460 | * @brief Notify the InputStream addon that Kodi (un)paused the currently playing stream | 597 | * @return Obtain the chunk size to use when reading streams. |
| 598 | * @remarks Return 0 if this add-on won't provide this function. | ||
| 461 | */ | 599 | */ |
| 462 | virtual void PauseStream(double time) { } | 600 | virtual int GetBlockSize() { return 0; } |
| 463 | |||
| 464 | 601 | ||
| 465 | /*! | 602 | /*! |
| 466 | * Check for real-time streaming | 603 | * Check for real-time streaming |
| 467 | * @return true if current stream is real-time | 604 | * @return true if current stream is real-time |
| 468 | */ | 605 | */ |
| 469 | virtual bool IsRealTimeStream() { return true; } | 606 | virtual bool IsRealTimeStream() { return true; } |
| 470 | 607 | ||
| 471 | /*! | 608 | /*! |
| 472 | * @brief Allocate a demux packet. Free with FreeDemuxPacket | 609 | * @brief Allocate a demux packet. Free with FreeDemuxPacket |
| 473 | * @param dataSize The size of the data that will go into the packet | 610 | * @param dataSize The size of the data that will go into the packet |
| 474 | * @return The allocated packet | 611 | * @return The allocated packet |
| 475 | */ | 612 | */ |
| 476 | DemuxPacket* AllocateDemuxPacket(int dataSize) | 613 | DemuxPacket* AllocateDemuxPacket(int dataSize) |
| 477 | { | 614 | { |
| 478 | return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance, dataSize); | 615 | return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance, |
| 479 | } | 616 | dataSize); |
| 617 | } | ||
| 480 | 618 | ||
| 481 | /*! | 619 | /*! |
| 482 | * @brief Allocate a demux packet. Free with FreeDemuxPacket | 620 | * @brief Allocate a demux packet. Free with FreeDemuxPacket |
| 483 | * @param dataSize The size of the data that will go into the packet | 621 | * @param dataSize The size of the data that will go into the packet |
| 484 | * @return The allocated packet | 622 | * @return The allocated packet |
| 485 | */ | 623 | */ |
| 486 | DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) | 624 | DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) |
| 487 | { | 625 | { |
| 488 | return m_instanceData->toKodi.allocate_encrypted_demux_packet(m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount); | 626 | return m_instanceData->toKodi.allocate_encrypted_demux_packet( |
| 489 | } | 627 | m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount); |
| 628 | } | ||
| 490 | 629 | ||
| 491 | /*! | 630 | /*! |
| 492 | * @brief Free a packet that was allocated with AllocateDemuxPacket | 631 | * @brief Free a packet that was allocated with AllocateDemuxPacket |
| 493 | * @param packet The packet to free | 632 | * @param packet The packet to free |
| 494 | */ | 633 | */ |
| 495 | void FreeDemuxPacket(DemuxPacket* packet) | 634 | void FreeDemuxPacket(DemuxPacket* packet) |
| 496 | { | 635 | { |
| 497 | return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet); | 636 | return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet); |
| 498 | } | 637 | } |
| 499 | 638 | ||
| 500 | private: | 639 | private: |
| 501 | void SetAddonStruct(KODI_HANDLE instance) | 640 | static int compareVersion(const int v1[3], const int v2[3]) |
| 502 | { | 641 | { |
| 503 | if (instance == nullptr) | 642 | for (unsigned i(0); i < 3; ++i) |
| 504 | throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon structure not allowed, table must be given from Kodi!"); | 643 | if (v1[i] != v2[i]) |
| 505 | 644 | return v1[i] - v2[i]; | |
| 506 | m_instanceData = static_cast<AddonInstance_InputStream*>(instance); | 645 | return 0; |
| 507 | m_instanceData->toAddon.addonInstance = this; | 646 | } |
| 508 | m_instanceData->toAddon.open = ADDON_Open; | ||
| 509 | m_instanceData->toAddon.close = ADDON_Close; | ||
| 510 | m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities; | ||
| 511 | |||
| 512 | m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds; | ||
| 513 | m_instanceData->toAddon.get_stream = ADDON_GetStream; | ||
| 514 | m_instanceData->toAddon.enable_stream = ADDON_EnableStream; | ||
| 515 | m_instanceData->toAddon.open_stream = ADDON_OpenStream; | ||
| 516 | m_instanceData->toAddon.demux_reset = ADDON_DemuxReset; | ||
| 517 | m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort; | ||
| 518 | m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush; | ||
| 519 | m_instanceData->toAddon.demux_read = ADDON_DemuxRead; | ||
| 520 | m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime; | ||
| 521 | m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed; | ||
| 522 | m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution; | ||
| 523 | |||
| 524 | m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime; | ||
| 525 | m_instanceData->toAddon.get_time = ADDON_GetTime; | ||
| 526 | |||
| 527 | m_instanceData->toAddon.get_times = ADDON_GetTimes; | ||
| 528 | |||
| 529 | m_instanceData->toAddon.pos_time = ADDON_PosTime; | ||
| 530 | |||
| 531 | m_instanceData->toAddon.can_pause_stream = ADDON_CanPauseStream; | ||
| 532 | m_instanceData->toAddon.can_seek_stream = ADDON_CanSeekStream; | ||
| 533 | |||
| 534 | m_instanceData->toAddon.read_stream = ADDON_ReadStream; | ||
| 535 | m_instanceData->toAddon.seek_stream = ADDON_SeekStream; | ||
| 536 | m_instanceData->toAddon.position_stream = ADDON_PositionStream; | ||
| 537 | m_instanceData->toAddon.length_stream = ADDON_LengthStream; | ||
| 538 | m_instanceData->toAddon.pause_stream = ADDON_PauseStream; | ||
| 539 | m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream; | ||
| 540 | } | ||
| 541 | 647 | ||
| 542 | inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) | 648 | void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion) |
| 543 | { | 649 | { |
| 544 | return instance->toAddon.addonInstance->Open(*props); | 650 | if (instance == nullptr) |
| 651 | throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon " | ||
| 652 | "structure not allowed, table must be given from Kodi!"); | ||
| 653 | int api[3] = { 0, 0, 0 }; | ||
| 654 | sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]); | ||
| 655 | |||
| 656 | m_instanceData = static_cast<AddonInstance_InputStream*>(instance); | ||
| 657 | m_instanceData->toAddon.addonInstance = this; | ||
| 658 | m_instanceData->toAddon.open = ADDON_Open; | ||
| 659 | m_instanceData->toAddon.close = ADDON_Close; | ||
| 660 | m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities; | ||
| 661 | |||
| 662 | m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds; | ||
| 663 | m_instanceData->toAddon.get_stream = ADDON_GetStream; | ||
| 664 | m_instanceData->toAddon.enable_stream = ADDON_EnableStream; | ||
| 665 | m_instanceData->toAddon.open_stream = ADDON_OpenStream; | ||
| 666 | m_instanceData->toAddon.demux_reset = ADDON_DemuxReset; | ||
| 667 | m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort; | ||
| 668 | m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush; | ||
| 669 | m_instanceData->toAddon.demux_read = ADDON_DemuxRead; | ||
| 670 | m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime; | ||
| 671 | m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed; | ||
| 672 | m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution; | ||
| 673 | |||
| 674 | m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime; | ||
| 675 | m_instanceData->toAddon.get_time = ADDON_GetTime; | ||
| 676 | |||
| 677 | m_instanceData->toAddon.get_times = ADDON_GetTimes; | ||
| 678 | m_instanceData->toAddon.pos_time = ADDON_PosTime; | ||
| 679 | |||
| 680 | m_instanceData->toAddon.read_stream = ADDON_ReadStream; | ||
| 681 | m_instanceData->toAddon.seek_stream = ADDON_SeekStream; | ||
| 682 | m_instanceData->toAddon.position_stream = ADDON_PositionStream; | ||
| 683 | m_instanceData->toAddon.length_stream = ADDON_LengthStream; | ||
| 684 | m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream; | ||
| 685 | |||
| 686 | int minChapterVersion[3] = { 2, 0, 10 }; | ||
| 687 | if (compareVersion(api, minChapterVersion) >= 0) | ||
| 688 | { | ||
| 689 | m_instanceData->toAddon.get_chapter = ADDON_GetChapter; | ||
| 690 | m_instanceData->toAddon.get_chapter_count = ADDON_GetChapterCount; | ||
| 691 | m_instanceData->toAddon.get_chapter_name = ADDON_GetChapterName; | ||
| 692 | m_instanceData->toAddon.get_chapter_pos = ADDON_GetChapterPos; | ||
| 693 | m_instanceData->toAddon.seek_chapter = ADDON_SeekChapter; | ||
| 545 | } | 694 | } |
| 546 | 695 | ||
| 547 | inline static void ADDON_Close(const AddonInstance_InputStream* instance) | 696 | int minBlockSizeVersion[3] = {2, 0, 12}; |
| 697 | if (compareVersion(api, minBlockSizeVersion) >= 0) | ||
| 548 | { | 698 | { |
| 549 | instance->toAddon.addonInstance->Close(); | 699 | m_instanceData->toAddon.block_size_stream = ADDON_GetBlockSize; |
| 550 | } | 700 | } |
| 701 | } | ||
| 551 | 702 | ||
| 552 | inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities) | 703 | inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) |
| 553 | { | 704 | { |
| 554 | instance->toAddon.addonInstance->GetCapabilities(*capabilities); | 705 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Open(*props); |
| 555 | } | 706 | } |
| 556 | 707 | ||
| 708 | inline static void ADDON_Close(const AddonInstance_InputStream* instance) | ||
| 709 | { | ||
| 710 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Close(); | ||
| 711 | } | ||
| 557 | 712 | ||
| 558 | // IDemux | 713 | inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, |
| 559 | inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) | 714 | INPUTSTREAM_CAPABILITIES* capabilities) |
| 560 | { | 715 | { |
| 561 | return instance->toAddon.addonInstance->GetStreamIds(); | 716 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) |
| 562 | } | 717 | ->GetCapabilities(*capabilities); |
| 718 | } | ||
| 563 | 719 | ||
| 564 | inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, int streamid) | ||
| 565 | { | ||
| 566 | return instance->toAddon.addonInstance->GetStream(streamid); | ||
| 567 | } | ||
| 568 | 720 | ||
| 569 | inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, int streamid, bool enable) | 721 | // IDemux |
| 570 | { | 722 | inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) |
| 571 | instance->toAddon.addonInstance->EnableStream(streamid, enable); | 723 | { |
| 572 | } | 724 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStreamIds(); |
| 725 | } | ||
| 573 | 726 | ||
| 574 | inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid) | 727 | inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, |
| 575 | { | 728 | int streamid) |
| 576 | return instance->toAddon.addonInstance->OpenStream(streamid); | 729 | { |
| 577 | } | 730 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStream(streamid); |
| 731 | } | ||
| 578 | 732 | ||
| 579 | inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance) | 733 | inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, |
| 580 | { | 734 | int streamid, |
| 581 | instance->toAddon.addonInstance->DemuxReset(); | 735 | bool enable) |
| 582 | } | 736 | { |
| 737 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | ||
| 738 | ->EnableStream(streamid, enable); | ||
| 739 | } | ||
| 583 | 740 | ||
| 584 | inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance) | 741 | inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid) |
| 585 | { | 742 | { |
| 586 | instance->toAddon.addonInstance->DemuxAbort(); | 743 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) |
| 587 | } | 744 | ->OpenStream(streamid); |
| 745 | } | ||
| 588 | 746 | ||
| 589 | inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance) | 747 | inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance) |
| 590 | { | 748 | { |
| 591 | instance->toAddon.addonInstance->DemuxFlush(); | 749 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxReset(); |
| 592 | } | 750 | } |
| 593 | 751 | ||
| 594 | inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) | 752 | inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance) |
| 595 | { | 753 | { |
| 596 | return instance->toAddon.addonInstance->DemuxRead(); | 754 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxAbort(); |
| 597 | } | 755 | } |
| 598 | 756 | ||
| 599 | inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance, double time, bool backwards, double *startpts) | 757 | inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance) |
| 600 | { | 758 | { |
| 601 | return instance->toAddon.addonInstance->DemuxSeekTime(time, backwards, *startpts); | 759 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxFlush(); |
| 602 | } | 760 | } |
| 603 | 761 | ||
| 604 | inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed) | 762 | inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) |
| 605 | { | 763 | { |
| 606 | instance->toAddon.addonInstance->DemuxSetSpeed(speed); | 764 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxRead(); |
| 607 | } | 765 | } |
| 608 | 766 | ||
| 609 | inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance, int width, int height) | 767 | inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance, |
| 610 | { | 768 | double time, |
| 611 | instance->toAddon.addonInstance->SetVideoResolution(width, height); | 769 | bool backwards, |
| 612 | } | 770 | double* startpts) |
| 771 | { | ||
| 772 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | ||
| 773 | ->DemuxSeekTime(time, backwards, *startpts); | ||
| 774 | } | ||
| 613 | 775 | ||
| 776 | inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed) | ||
| 777 | { | ||
| 778 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxSetSpeed(speed); | ||
| 779 | } | ||
| 614 | 780 | ||
| 615 | // IDisplayTime | 781 | inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance, |
| 616 | inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance) | 782 | int width, |
| 617 | { | 783 | int height) |
| 618 | return instance->toAddon.addonInstance->GetTotalTime(); | 784 | { |
| 619 | } | 785 | static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) |
| 786 | ->SetVideoResolution(width, height); | ||
| 787 | } | ||
| 620 | 788 | ||
| 621 | inline static int ADDON_GetTime(const AddonInstance_InputStream* instance) | ||
| 622 | { | ||
| 623 | return instance->toAddon.addonInstance->GetTime(); | ||
| 624 | } | ||
| 625 | 789 | ||
| 626 | // ITime | 790 | // IDisplayTime |
| 627 | inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES *times) | 791 | inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance) |
| 628 | { | 792 | { |
| 629 | return instance->toAddon.addonInstance->GetTimes(*times); | 793 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTotalTime(); |
| 630 | } | 794 | } |
| 631 | 795 | ||
| 632 | // IPosTime | 796 | inline static int ADDON_GetTime(const AddonInstance_InputStream* instance) |
| 633 | inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms) | 797 | { |
| 634 | { | 798 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTime(); |
| 635 | return instance->toAddon.addonInstance->PosTime(ms); | 799 | } |
| 636 | } | ||
| 637 | 800 | ||
| 638 | // Seekable (mandatory) | 801 | // ITime |
| 639 | inline static bool ADDON_CanPauseStream(const AddonInstance_InputStream* instance) | 802 | inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, |
| 640 | { | 803 | INPUTSTREAM_TIMES* times) |
| 641 | return instance->toAddon.addonInstance->CanPauseStream(); | 804 | { |
| 642 | } | 805 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTimes(*times); |
| 806 | } | ||
| 643 | 807 | ||
| 644 | inline static bool ADDON_CanSeekStream(const AddonInstance_InputStream* instance) | 808 | // IPosTime |
| 645 | { | 809 | inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms) |
| 646 | return instance->toAddon.addonInstance->CanSeekStream(); | 810 | { |
| 647 | } | 811 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PosTime(ms); |
| 812 | } | ||
| 648 | 813 | ||
| 814 | inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance) | ||
| 815 | { | ||
| 816 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapter(); | ||
| 817 | } | ||
| 649 | 818 | ||
| 650 | inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance, uint8_t* buffer, unsigned int bufferSize) | 819 | inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance) |
| 651 | { | 820 | { |
| 652 | return instance->toAddon.addonInstance->ReadStream(buffer, bufferSize); | 821 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterCount(); |
| 653 | } | 822 | } |
| 654 | 823 | ||
| 655 | inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance, int64_t position, int whence) | 824 | inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch) |
| 656 | { | 825 | { |
| 657 | return instance->toAddon.addonInstance->SeekStream(position, whence); | 826 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterName(ch); |
| 658 | } | 827 | } |
| 659 | 828 | ||
| 660 | inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance) | 829 | inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch) |
| 661 | { | 830 | { |
| 662 | return instance->toAddon.addonInstance->PositionStream(); | 831 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterPos(ch); |
| 663 | } | 832 | } |
| 664 | 833 | ||
| 665 | inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance) | 834 | inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch) |
| 666 | { | 835 | { |
| 667 | return instance->toAddon.addonInstance->LengthStream(); | 836 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->SeekChapter(ch); |
| 668 | } | 837 | } |
| 669 | 838 | ||
| 670 | inline static void ADDON_PauseStream(const AddonInstance_InputStream* instance, double time) | 839 | inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance, |
| 671 | { | 840 | uint8_t* buffer, |
| 672 | instance->toAddon.addonInstance->PauseStream(time); | 841 | unsigned int bufferSize) |
| 673 | } | 842 | { |
| 843 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | ||
| 844 | ->ReadStream(buffer, bufferSize); | ||
| 845 | } | ||
| 674 | 846 | ||
| 675 | inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance) | 847 | inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance, |
| 676 | { | 848 | int64_t position, |
| 677 | return instance->toAddon.addonInstance->IsRealTimeStream(); | 849 | int whence) |
| 678 | } | 850 | { |
| 851 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance) | ||
| 852 | ->SeekStream(position, whence); | ||
| 853 | } | ||
| 679 | 854 | ||
| 680 | AddonInstance_InputStream* m_instanceData; | 855 | inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance) |
| 681 | }; | 856 | { |
| 857 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PositionStream(); | ||
| 858 | } | ||
| 859 | |||
| 860 | inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance) | ||
| 861 | { | ||
| 862 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->LengthStream(); | ||
| 863 | } | ||
| 864 | |||
| 865 | inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance) | ||
| 866 | { | ||
| 867 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetBlockSize(); | ||
| 868 | } | ||
| 869 | |||
| 870 | inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance) | ||
| 871 | { | ||
| 872 | return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->IsRealTimeStream(); | ||
| 873 | } | ||
| 874 | |||
| 875 | AddonInstance_InputStream* m_instanceData; | ||
| 876 | }; | ||
| 682 | 877 | ||
| 683 | } /* namespace addon */ | 878 | } /* namespace addon */ |
| 684 | } /* namespace kodi */ | 879 | } /* namespace kodi */ |
| 880 | |||
| 881 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h new file mode 100644 index 0000000..0bca8e2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h | |||
| @@ -0,0 +1,3423 @@ | |||
| 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 "../c-api/addon-instance/pvr.h" | ||
| 12 | #include "pvr/ChannelGroups.h" | ||
| 13 | #include "pvr/Channels.h" | ||
| 14 | #include "pvr/EDL.h" | ||
| 15 | #include "pvr/EPG.h" | ||
| 16 | #include "pvr/General.h" | ||
| 17 | #include "pvr/MenuHook.h" | ||
| 18 | #include "pvr/Recordings.h" | ||
| 19 | #include "pvr/Stream.h" | ||
| 20 | #include "pvr/Timers.h" | ||
| 21 | |||
| 22 | #ifdef __cplusplus | ||
| 23 | |||
| 24 | /*! | ||
| 25 | * @internal | ||
| 26 | * @brief PVR "C++" API interface | ||
| 27 | * | ||
| 28 | * In this field are the pure addon-side C++ data. | ||
| 29 | * | ||
| 30 | * @note Changes can be made without problems and have no influence on other | ||
| 31 | * PVR addons that have already been created.\n | ||
| 32 | * \n | ||
| 33 | * Therefore, @ref ADDON_INSTANCE_VERSION_PVR_MIN can be ignored for these | ||
| 34 | * fields and only the @ref ADDON_INSTANCE_VERSION_PVR needs to be increased.\n | ||
| 35 | * \n | ||
| 36 | * Only must be min version increased if a new compile of addon breaks after | ||
| 37 | * changes here. | ||
| 38 | * | ||
| 39 | * Have by add of new parts a look about **Doxygen** `\\ingroup`, so that | ||
| 40 | * added parts included in documentation. | ||
| 41 | * | ||
| 42 | * If you add addon side related documentation, where his dev need know, use `///`. | ||
| 43 | * For parts only for Kodi make it like here. | ||
| 44 | * | ||
| 45 | * @endinternal | ||
| 46 | */ | ||
| 47 | |||
| 48 | namespace kodi | ||
| 49 | { | ||
| 50 | namespace addon | ||
| 51 | { | ||
| 52 | |||
| 53 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 54 | // "C++" Doxygen group set for the definitions | ||
| 55 | //{{{ | ||
| 56 | |||
| 57 | //============================================================================== | ||
| 58 | /// @defgroup cpp_kodi_addon_pvr_Defs Definitions, structures and enumerators | ||
| 59 | /// @ingroup cpp_kodi_addon_pvr | ||
| 60 | /// @brief **PVR client add-on instance definition values**\n | ||
| 61 | /// All PVR functions associated data structures. | ||
| 62 | /// | ||
| 63 | /// Used to exchange the available options between Kodi and addon.\n | ||
| 64 | /// The groups described here correspond to the groups of functions on PVR | ||
| 65 | /// instance class. | ||
| 66 | /// | ||
| 67 | |||
| 68 | //############################################################################## | ||
| 69 | /// @defgroup cpp_kodi_addon_pvr_Defs_General 1. General | ||
| 70 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 71 | /// @brief **PVR add-on general variables**\n | ||
| 72 | /// Used to exchange the available options between Kodi and addon. | ||
| 73 | /// | ||
| 74 | /// This group also includes @ref cpp_kodi_addon_pvr_Defs_PVRCapabilities with | ||
| 75 | /// which Kodi an @ref kodi::addon::CInstancePVRClient::GetCapabilities() | ||
| 76 | /// queries the supported **modules** of the addon. | ||
| 77 | /// | ||
| 78 | /// The standard values are also below, once for error messages and once to | ||
| 79 | /// @ref kodi::addon::CInstancePVRClient::ConnectionStateChange() to give Kodi | ||
| 80 | /// any information. | ||
| 81 | /// | ||
| 82 | ///@{ | ||
| 83 | //############################################################################## | ||
| 84 | /// @defgroup cpp_kodi_addon_pvr_Defs_General_Inputstream class PVRStreamProperty & definition PVR_STREAM_PROPERTY | ||
| 85 | /// @ingroup cpp_kodi_addon_pvr_Defs_General | ||
| 86 | /// @brief **Inputstream variables**\n | ||
| 87 | /// This includes values related to the outside of PVR available inputstream | ||
| 88 | /// system. | ||
| 89 | /// | ||
| 90 | /// This can be by separate instance on same addon, by handling in Kodi itself | ||
| 91 | /// or to reference of another addon where support needed inputstream. | ||
| 92 | /// | ||
| 93 | /// @note This is complete independent from own system included here | ||
| 94 | /// @ref cpp_kodi_addon_pvr_Streams "inputstream". | ||
| 95 | /// | ||
| 96 | //------------------------------------------------------------------------------ | ||
| 97 | ///@} | ||
| 98 | |||
| 99 | //############################################################################## | ||
| 100 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel 2. Channel | ||
| 101 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 102 | /// @brief **PVR add-on channel**\n | ||
| 103 | /// Used to exchange the available channel options between Kodi and addon. | ||
| 104 | /// | ||
| 105 | /// Modules here are mainly intended for @ref cpp_kodi_addon_pvr_Channels "channels", | ||
| 106 | /// but are also used on other modules to identify the respective TV/radio | ||
| 107 | /// channel. | ||
| 108 | /// | ||
| 109 | /// Because of @ref cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus and | ||
| 110 | /// @ref cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo is a special case at | ||
| 111 | /// this point. This is currently only used on running streams, but it may be | ||
| 112 | /// possible that this must always be usable in connection with PiP in the | ||
| 113 | /// future. | ||
| 114 | /// | ||
| 115 | //------------------------------------------------------------------------------ | ||
| 116 | |||
| 117 | //############################################################################## | ||
| 118 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup 3. Channel Group | ||
| 119 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 120 | /// @brief **PVR add-on channel group**\n | ||
| 121 | /// This group contains data classes and values which are used in PVR on | ||
| 122 | /// @ref cpp_kodi_addon_pvr_supportsChannelGroups "channel groups". | ||
| 123 | /// | ||
| 124 | //------------------------------------------------------------------------------ | ||
| 125 | |||
| 126 | //############################################################################## | ||
| 127 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg 4. EPG Tag | ||
| 128 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 129 | /// @brief **PVR add-on EPG data**\n | ||
| 130 | /// Used on @ref cpp_kodi_addon_pvr_EPGTag "EPG methods in PVR instance class". | ||
| 131 | /// | ||
| 132 | /// See related modules about, also below in this view are few macros where | ||
| 133 | /// default values of associated places. | ||
| 134 | /// | ||
| 135 | //------------------------------------------------------------------------------ | ||
| 136 | |||
| 137 | //############################################################################## | ||
| 138 | /// @defgroup cpp_kodi_addon_pvr_Defs_Recording 5. Recording | ||
| 139 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 140 | /// @brief **Representation of a recording**\n | ||
| 141 | /// Used to exchange the available recording data between Kodi and addon on | ||
| 142 | /// @ref cpp_kodi_addon_pvr_Recordings "Recordings methods in PVR instance class". | ||
| 143 | /// | ||
| 144 | //------------------------------------------------------------------------------ | ||
| 145 | |||
| 146 | //############################################################################## | ||
| 147 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer 6. Timer | ||
| 148 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 149 | /// @brief **PVR add-on timer data**\n | ||
| 150 | /// Used to exchange the available timer data between Kodi and addon on | ||
| 151 | /// @ref cpp_kodi_addon_pvr_Timers "Timers methods in PVR instance class". | ||
| 152 | /// | ||
| 153 | //------------------------------------------------------------------------------ | ||
| 154 | |||
| 155 | //############################################################################## | ||
| 156 | /// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook 7. Menuhook | ||
| 157 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 158 | /// @brief **PVR Context menu data**\n | ||
| 159 | /// Define data for the context menus available to the user | ||
| 160 | /// | ||
| 161 | //------------------------------------------------------------------------------ | ||
| 162 | |||
| 163 | //############################################################################## | ||
| 164 | /// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry 8. Edit decision list (EDL) | ||
| 165 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 166 | /// @brief **An edit decision list or EDL is used in the post-production process | ||
| 167 | /// of film editing and video editing**\n | ||
| 168 | /// Used on @ref kodi::addon::CInstancePVRClient::GetEPGTagEdl and | ||
| 169 | /// @ref kodi::addon::CInstancePVRClient::GetRecordingEdl | ||
| 170 | /// | ||
| 171 | //------------------------------------------------------------------------------ | ||
| 172 | |||
| 173 | //############################################################################## | ||
| 174 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream 9. Inputstream | ||
| 175 | /// @ingroup cpp_kodi_addon_pvr_Defs | ||
| 176 | /// @brief **Inputstream**\n | ||
| 177 | /// This includes classes and values that are used in the PVR inputstream. | ||
| 178 | /// | ||
| 179 | /// Used on @ref cpp_kodi_addon_pvr_Streams "Inputstream methods in PVR instance class". | ||
| 180 | /// | ||
| 181 | /// @note The parts here will be removed in the future and replaced by the | ||
| 182 | /// separate @ref cpp_kodi_addon_inputstream "inputstream addon instance". | ||
| 183 | /// If there is already a possibility, new addons should do it via the | ||
| 184 | /// inputstream instance. | ||
| 185 | /// | ||
| 186 | //------------------------------------------------------------------------------ | ||
| 187 | |||
| 188 | //}}} | ||
| 189 | //______________________________________________________________________________ | ||
| 190 | |||
| 191 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 192 | // "C++" PVR addon instance class | ||
| 193 | //{{{ | ||
| 194 | |||
| 195 | //============================================================================== | ||
| 196 | /// @addtogroup cpp_kodi_addon_pvr | ||
| 197 | /// @brief \cpp_class{ kodi::addon::CInstancePVRClient } | ||
| 198 | /// **PVR client add-on instance** | ||
| 199 | /// | ||
| 200 | /// Kodi features powerful [Live TV](https://kodi.wiki/view/Live_TV) and | ||
| 201 | /// [video recording (DVR/PVR)](http://en.wikipedia.org/wiki/Digital_video_recorder) | ||
| 202 | /// abilities using a very flexible distributed application structure. That is, by | ||
| 203 | /// leveraging other existing third-party | ||
| 204 | /// [PVR backend applications](https://kodi.wiki/view/PVR_backend) or | ||
| 205 | /// [DVR devices](https://kodi.wiki/view/PVR_backend) | ||
| 206 | /// that specialize in receiving television signals and also support the same type | ||
| 207 | /// of [client–server model](http://en.wikipedia.org/wiki/client%E2%80%93server_model) | ||
| 208 | /// which Kodi uses, (following a [frontend-backend](http://en.wikipedia.org/wiki/Front_and_back_ends) | ||
| 209 | /// design principle for [separation of concerns](http://en.wikipedia.org/wiki/Separation_of_concerns)), | ||
| 210 | /// these PVR features in Kodi allow you to watch Live TV, listen to radio, view an EPG TV-Guide | ||
| 211 | /// and schedule recordings, and also enables many other TV related features, all using | ||
| 212 | /// Kodi as your primary interface once the initial pairing connection and | ||
| 213 | /// configuration have been done. | ||
| 214 | /// | ||
| 215 | /// @note It is very important to understand that with "Live TV" in the reference | ||
| 216 | /// to PVR in Kodi, we do not mean [streaming video](http://en.wikipedia.org/wiki/Streaming_media) | ||
| 217 | /// from the internet via websites providing [free content](https://kodi.wiki/view/Free_content) | ||
| 218 | /// or online services such as Netflix, Hulu, Vudu and similar, no matter if that | ||
| 219 | /// content is actually streamed live or not. If that is what you are looking for | ||
| 220 | /// then you might want to look into [Video Addons](https://kodi.wiki/view/Add-ons) | ||
| 221 | /// for Kodi instead, (which again is not the same as the "PVR" or "Live TV" we | ||
| 222 | /// discuss in this article), but remember that [Kodi does not provide any video | ||
| 223 | /// content or video streaming services](https://kodi.wiki/view/Free_content). | ||
| 224 | /// | ||
| 225 | /// The use of the PVR is based on the @ref CInstancePVRClient. | ||
| 226 | /// | ||
| 227 | /// Include the header @ref PVR.h "#include <kodi/addon-instance/PVR.h>" | ||
| 228 | /// to use this class. | ||
| 229 | /// | ||
| 230 | /// | ||
| 231 | /// ---------------------------------------------------------------------------- | ||
| 232 | /// | ||
| 233 | /// Here is an example of what the <b>`addon.xml.in`</b> would look like for an PVR addon: | ||
| 234 | /// | ||
| 235 | /// ~~~~~~~~~~~~~{.xml} | ||
| 236 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 237 | /// <addon | ||
| 238 | /// id="pvr.myspecialnamefor" | ||
| 239 | /// version="1.0.0" | ||
| 240 | /// name="My special PVR addon" | ||
| 241 | /// provider-name="Your Name"> | ||
| 242 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 243 | /// <extension | ||
| 244 | /// point="kodi.pvrclient" | ||
| 245 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 246 | /// <extension point="xbmc.addon.metadata"> | ||
| 247 | /// <summary lang="en_GB">My PVR addon addon</summary> | ||
| 248 | /// <description lang="en_GB">My PVR addon description</description> | ||
| 249 | /// <platform>@PLATFORM@</platform> | ||
| 250 | /// </extension> | ||
| 251 | /// </addon> | ||
| 252 | /// ~~~~~~~~~~~~~ | ||
| 253 | /// | ||
| 254 | /// | ||
| 255 | /// At <b>`<extension point="kodi.pvrclient" ...>`</b> the basic instance definition is declared, this is intended to identify the addon as an PVR and to see its supported types: | ||
| 256 | /// | Name | Description | ||
| 257 | /// |------|---------------------- | ||
| 258 | /// | <b>`point`</b> | The identification of the addon instance to inputstream is mandatory <b>`kodi.pvrclient`</b>. In addition, the instance declared in the first <b>`<extension ... />`</b> is also the main type of addon. | ||
| 259 | /// | <b>`library_@PLATFORM@`</b> | The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated `addon.xml`. | ||
| 260 | /// | ||
| 261 | /// | ||
| 262 | /// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml. | ||
| 263 | /// | ||
| 264 | /// | ||
| 265 | /// -------------------------------------------------------------------------- | ||
| 266 | /// | ||
| 267 | /// **Example:** | ||
| 268 | /// | ||
| 269 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 270 | /// #include <kodi/addon-instance/PVR.h> | ||
| 271 | /// | ||
| 272 | /// class CMyPVRClient : public ::kodi::addon::CInstancePVRClient | ||
| 273 | /// { | ||
| 274 | /// public: | ||
| 275 | /// CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion); | ||
| 276 | /// | ||
| 277 | /// PVR_ERROR GetCapabilities(kodi::addon::PVRCapabilities& capabilities) override; | ||
| 278 | /// PVR_ERROR GetBackendName(std::string& name) override; | ||
| 279 | /// PVR_ERROR GetBackendVersion(std::string& version) override; | ||
| 280 | /// | ||
| 281 | /// PVR_ERROR GetChannelsAmount(int& amount) override; | ||
| 282 | /// PVR_ERROR GetChannels(bool radio, std::vector<kodi::addon::PVRChannel>& channels) override; | ||
| 283 | /// PVR_ERROR GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 284 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) override; | ||
| 285 | /// | ||
| 286 | /// private: | ||
| 287 | /// std::vector<kodi::addon::PVRChannel> m_myChannels; | ||
| 288 | /// }; | ||
| 289 | /// | ||
| 290 | /// CMyPVRClient::CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 291 | /// : CInstancePVRClient(instance, kodiVersion) | ||
| 292 | /// { | ||
| 293 | /// kodi::addon::PVRChannel channel; | ||
| 294 | /// channel.SetUniqueId(123); | ||
| 295 | /// channel.SetChannelNumber(1); | ||
| 296 | /// channel.SetChannelName("My test channel"); | ||
| 297 | /// m_myChannels.push_back(channel); | ||
| 298 | /// } | ||
| 299 | /// | ||
| 300 | /// PVR_ERROR CMyPVRClient::GetCapabilities(kodi::addon::PVRCapabilities& capabilities) | ||
| 301 | /// { | ||
| 302 | /// capabilities.SetSupportsTV(true); | ||
| 303 | /// return PVR_ERROR_NO_ERROR; | ||
| 304 | /// } | ||
| 305 | /// | ||
| 306 | /// PVR_ERROR CMyPVRClient::GetBackendName(std::string& name) | ||
| 307 | /// { | ||
| 308 | /// name = "My special PVR client"; | ||
| 309 | /// return PVR_ERROR_NO_ERROR; | ||
| 310 | /// } | ||
| 311 | /// | ||
| 312 | /// PVR_ERROR CMyPVRClient::GetBackendVersion(std::string& version) | ||
| 313 | /// { | ||
| 314 | /// version = "1.0.0"; | ||
| 315 | /// return PVR_ERROR_NO_ERROR; | ||
| 316 | /// } | ||
| 317 | /// | ||
| 318 | /// PVR_ERROR CMyInstance::GetChannelsAmount(int& amount) | ||
| 319 | /// { | ||
| 320 | /// amount = m_myChannels.size(); | ||
| 321 | /// return PVR_ERROR_NO_ERROR; | ||
| 322 | /// } | ||
| 323 | /// | ||
| 324 | /// PVR_ERROR CMyPVRClient::GetChannels(bool radio, std::vector<kodi::addon::PVRChannel>& channels) | ||
| 325 | /// { | ||
| 326 | /// channels = m_myChannels; | ||
| 327 | /// return PVR_ERROR_NO_ERROR; | ||
| 328 | /// } | ||
| 329 | /// | ||
| 330 | /// PVR_ERROR CMyPVRClient::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 331 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 332 | /// { | ||
| 333 | /// if (channel.GetUniqueId() == 123) | ||
| 334 | /// { | ||
| 335 | /// properties.push_back(PVR_STREAM_PROPERTY_STREAMURL, "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4"); | ||
| 336 | /// properties.push_back(PVR_STREAM_PROPERTY_ISREALTIMESTREAM, "true"); | ||
| 337 | /// return PVR_ERROR_NO_ERROR; | ||
| 338 | /// } | ||
| 339 | /// return PVR_ERROR_UNKNOWN; | ||
| 340 | /// } | ||
| 341 | /// | ||
| 342 | /// ... | ||
| 343 | /// | ||
| 344 | /// //---------------------------------------------------------------------- | ||
| 345 | /// | ||
| 346 | /// class CMyAddon : public ::kodi::addon::CAddonBase | ||
| 347 | /// { | ||
| 348 | /// public: | ||
| 349 | /// CMyAddon() = default; | ||
| 350 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 351 | /// const std::string& instanceID, | ||
| 352 | /// KODI_HANDLE instance, | ||
| 353 | /// const std::string& version, | ||
| 354 | /// KODI_HANDLE& addonInstance) override; | ||
| 355 | /// }; | ||
| 356 | /// | ||
| 357 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 358 | /// // instanceID ignored | ||
| 359 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 360 | /// const std::string& instanceID, | ||
| 361 | /// KODI_HANDLE instance, | ||
| 362 | /// const std::string& version, | ||
| 363 | /// KODI_HANDLE& addonInstance) | ||
| 364 | /// { | ||
| 365 | /// if (instanceType == ADDON_INSTANCE_PVR) | ||
| 366 | /// { | ||
| 367 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my PVR client instance"); | ||
| 368 | /// addonInstance = new CMyPVRClient(instance, version); | ||
| 369 | /// return ADDON_STATUS_OK; | ||
| 370 | /// } | ||
| 371 | /// else if (...) | ||
| 372 | /// { | ||
| 373 | /// ... | ||
| 374 | /// } | ||
| 375 | /// return ADDON_STATUS_UNKNOWN; | ||
| 376 | /// } | ||
| 377 | /// | ||
| 378 | /// ADDONCREATOR(CMyAddon) | ||
| 379 | /// ~~~~~~~~~~~~~ | ||
| 380 | /// | ||
| 381 | /// The destruction of the example class `CMyPVRClient` is called from | ||
| 382 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 383 | /// | ||
| 384 | class ATTRIBUTE_HIDDEN CInstancePVRClient : public IAddonInstance | ||
| 385 | { | ||
| 386 | public: | ||
| 387 | //============================================================================ | ||
| 388 | /// @defgroup cpp_kodi_addon_pvr_Base 1. Basic functions | ||
| 389 | /// @ingroup cpp_kodi_addon_pvr | ||
| 390 | /// @brief **Functions to manage the addon and get basic information about it**\n | ||
| 391 | /// These are e.g. @ref GetCapabilities to know supported groups at | ||
| 392 | /// this addon or the others to get information about the source of the PVR | ||
| 393 | /// stream. | ||
| 394 | /// | ||
| 395 | /// The with "Valid implementation required." declared functions are mandatory, | ||
| 396 | /// all others are an option. | ||
| 397 | /// | ||
| 398 | /// | ||
| 399 | ///--------------------------------------------------------------------------- | ||
| 400 | /// | ||
| 401 | /// **Basic parts in interface:**\n | ||
| 402 | /// Copy this to your project and extend with your parts or leave functions | ||
| 403 | /// complete away where not used or supported. | ||
| 404 | /// | ||
| 405 | /// @copydetails cpp_kodi_addon_pvr_Base_header_addon_auto_check | ||
| 406 | /// @copydetails cpp_kodi_addon_pvr_Base_source_addon_auto_check | ||
| 407 | /// | ||
| 408 | ///@{ | ||
| 409 | |||
| 410 | //============================================================================ | ||
| 411 | /// @brief PVR client class constructor. | ||
| 412 | /// | ||
| 413 | /// Used by an add-on that only supports only PVR and only in one instance. | ||
| 414 | /// | ||
| 415 | /// | ||
| 416 | /// -------------------------------------------------------------------------- | ||
| 417 | /// | ||
| 418 | /// **Here's example about the use of this:** | ||
| 419 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 420 | /// #include <kodi/addon-instance/PVR.h> | ||
| 421 | /// ... | ||
| 422 | /// | ||
| 423 | /// class ATTRIBUTE_HIDDEN CPVRExample | ||
| 424 | /// : public kodi::addon::CAddonBase, | ||
| 425 | /// public kodi::addon::CInstancePVRClient | ||
| 426 | /// { | ||
| 427 | /// public: | ||
| 428 | /// CPVRExample() | ||
| 429 | /// { | ||
| 430 | /// } | ||
| 431 | /// | ||
| 432 | /// ~CPVRExample() override; | ||
| 433 | /// { | ||
| 434 | /// } | ||
| 435 | /// | ||
| 436 | /// ... | ||
| 437 | /// }; | ||
| 438 | /// | ||
| 439 | /// ADDONCREATOR(CPVRExample) | ||
| 440 | /// ~~~~~~~~~~~~~ | ||
| 441 | /// | ||
| 442 | CInstancePVRClient() : IAddonInstance(ADDON_INSTANCE_PVR, GetKodiTypeVersion(ADDON_INSTANCE_PVR)) | ||
| 443 | { | ||
| 444 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 445 | throw std::logic_error("kodi::addon::CInstancePVRClient: Creation of more as one in single " | ||
| 446 | "instance way is not allowed!"); | ||
| 447 | |||
| 448 | SetAddonStruct(CAddonBase::m_interface->firstKodiInstance, m_kodiVersion); | ||
| 449 | CAddonBase::m_interface->globalSingleInstance = this; | ||
| 450 | } | ||
| 451 | //---------------------------------------------------------------------------- | ||
| 452 | |||
| 453 | //============================================================================ | ||
| 454 | /// @brief PVR client class constructor used to support multiple instance | ||
| 455 | /// types. | ||
| 456 | /// | ||
| 457 | /// @param[in] instance The instance value given to | ||
| 458 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 459 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 460 | /// allow compatibility to older Kodi versions. | ||
| 461 | /// | ||
| 462 | /// @note Recommended to set <b>`kodiVersion`</b>. | ||
| 463 | /// | ||
| 464 | /// | ||
| 465 | /// -------------------------------------------------------------------------- | ||
| 466 | /// | ||
| 467 | /// **Here's example about the use of this:** | ||
| 468 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 469 | /// class CMyPVRClient : public ::kodi::addon::CInstancePVRClient | ||
| 470 | /// { | ||
| 471 | /// public: | ||
| 472 | /// CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 473 | /// : CInstancePVRClient(instance, kodiVersion) | ||
| 474 | /// { | ||
| 475 | /// ... | ||
| 476 | /// } | ||
| 477 | /// | ||
| 478 | /// ... | ||
| 479 | /// }; | ||
| 480 | /// | ||
| 481 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 482 | /// const std::string& instanceID, | ||
| 483 | /// KODI_HANDLE instance, | ||
| 484 | /// const std::string& version, | ||
| 485 | /// KODI_HANDLE& addonInstance) | ||
| 486 | /// { | ||
| 487 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my PVR client instance"); | ||
| 488 | /// addonInstance = new CMyPVRClient(instance, version); | ||
| 489 | /// return ADDON_STATUS_OK; | ||
| 490 | /// } | ||
| 491 | /// ~~~~~~~~~~~~~ | ||
| 492 | /// | ||
| 493 | explicit CInstancePVRClient(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 494 | : IAddonInstance(ADDON_INSTANCE_PVR, | ||
| 495 | !kodiVersion.empty() ? kodiVersion : GetKodiTypeVersion(ADDON_INSTANCE_PVR)) | ||
| 496 | { | ||
| 497 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 498 | throw std::logic_error("kodi::addon::CInstancePVRClient: Creation of multiple together with " | ||
| 499 | "single instance way is not allowed!"); | ||
| 500 | |||
| 501 | SetAddonStruct(instance, m_kodiVersion); | ||
| 502 | } | ||
| 503 | //---------------------------------------------------------------------------- | ||
| 504 | |||
| 505 | //============================================================================ | ||
| 506 | /// @brief Destructor | ||
| 507 | /// | ||
| 508 | ~CInstancePVRClient() override = default; | ||
| 509 | //---------------------------------------------------------------------------- | ||
| 510 | |||
| 511 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 512 | |||
| 513 | //============================================================================ | ||
| 514 | /// @brief Get the list of features that this add-on provides. | ||
| 515 | /// | ||
| 516 | /// Called by Kodi to query the add-on's capabilities. | ||
| 517 | /// Used to check which options should be presented in the UI, which methods to call, etc. | ||
| 518 | /// All capabilities that the add-on supports should be set to true. | ||
| 519 | /// | ||
| 520 | /// @param capabilities The with @ref cpp_kodi_addon_pvr_Defs_PVRCapabilities defined add-on's capabilities. | ||
| 521 | /// @return @ref PVR_ERROR_NO_ERROR if the properties were fetched successfully. | ||
| 522 | /// | ||
| 523 | /// -------------------------------------------------------------------------- | ||
| 524 | /// | ||
| 525 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRCapabilities_Help | ||
| 526 | /// | ||
| 527 | /// | ||
| 528 | /// -------------------------------------------------------------------------- | ||
| 529 | /// | ||
| 530 | /// **Example:** | ||
| 531 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 532 | /// PVR_ERROR CMyPVRClient::GetCapabilities(kodi::addon::PVRCapabilities& capabilities) | ||
| 533 | /// { | ||
| 534 | /// capabilities.SetSupportsTV(true); | ||
| 535 | /// capabilities.SetSupportsEPG(true); | ||
| 536 | /// return PVR_ERROR_NO_ERROR; | ||
| 537 | /// } | ||
| 538 | /// ~~~~~~~~~~~~~ | ||
| 539 | /// | ||
| 540 | /// -------------------------------------------------------------------------- | ||
| 541 | /// | ||
| 542 | /// @note Valid implementation required. | ||
| 543 | /// | ||
| 544 | virtual PVR_ERROR GetCapabilities(kodi::addon::PVRCapabilities& capabilities) = 0; | ||
| 545 | //---------------------------------------------------------------------------- | ||
| 546 | |||
| 547 | //============================================================================ | ||
| 548 | /// @brief Get the name reported by the backend that will be displayed in the UI. | ||
| 549 | /// | ||
| 550 | /// @param[out] name The name reported by the backend that will be displayed in the UI. | ||
| 551 | /// @return @ref PVR_ERROR_NO_ERROR if successfully done | ||
| 552 | /// | ||
| 553 | /// | ||
| 554 | /// -------------------------------------------------------------------------- | ||
| 555 | /// | ||
| 556 | /// **Example:** | ||
| 557 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 558 | /// PVR_ERROR CMyPVRClient::GetBackendName(std::string& name) | ||
| 559 | /// { | ||
| 560 | /// name = "My special PVR client"; | ||
| 561 | /// return PVR_ERROR_NO_ERROR; | ||
| 562 | /// } | ||
| 563 | /// ~~~~~~~~~~~~~ | ||
| 564 | /// | ||
| 565 | /// -------------------------------------------------------------------------- | ||
| 566 | /// | ||
| 567 | /// @note Valid implementation required. | ||
| 568 | /// | ||
| 569 | virtual PVR_ERROR GetBackendName(std::string& name) = 0; | ||
| 570 | //---------------------------------------------------------------------------- | ||
| 571 | |||
| 572 | //============================================================================ | ||
| 573 | /// @brief Get the version string reported by the backend that will be | ||
| 574 | /// displayed in the UI. | ||
| 575 | /// | ||
| 576 | /// @param[out] version The version string reported by the backend that will be | ||
| 577 | /// displayed in the UI. | ||
| 578 | /// @return @ref PVR_ERROR_NO_ERROR if successfully done | ||
| 579 | /// | ||
| 580 | /// | ||
| 581 | /// -------------------------------------------------------------------------- | ||
| 582 | /// | ||
| 583 | /// **Example:** | ||
| 584 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 585 | /// PVR_ERROR CMyPVRClient::GetBackendVersion(std::string& version) | ||
| 586 | /// { | ||
| 587 | /// version = "1.0.0"; | ||
| 588 | /// return PVR_ERROR_NO_ERROR; | ||
| 589 | /// } | ||
| 590 | /// ~~~~~~~~~~~~~ | ||
| 591 | /// | ||
| 592 | /// -------------------------------------------------------------------------- | ||
| 593 | /// | ||
| 594 | /// @note Valid implementation required. | ||
| 595 | /// | ||
| 596 | virtual PVR_ERROR GetBackendVersion(std::string& version) = 0; | ||
| 597 | //---------------------------------------------------------------------------- | ||
| 598 | |||
| 599 | //============================================================================ | ||
| 600 | /// @brief Get the hostname of the pvr backend server | ||
| 601 | /// | ||
| 602 | /// @param[out] hostname Hostname as ip address or alias. If backend does not | ||
| 603 | /// utilize a server, return empty string. | ||
| 604 | /// @return @ref PVR_ERROR_NO_ERROR if successfully done | ||
| 605 | /// | ||
| 606 | virtual PVR_ERROR GetBackendHostname(std::string& hostname) { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 607 | //---------------------------------------------------------------------------- | ||
| 608 | |||
| 609 | //============================================================================ | ||
| 610 | /// @brief To get the connection string reported by the backend that will be | ||
| 611 | /// displayed in the UI. | ||
| 612 | /// | ||
| 613 | /// @param[out] connection The connection string reported by the backend that | ||
| 614 | /// will be displayed in the UI. | ||
| 615 | /// @return @ref PVR_ERROR_NO_ERROR if successfully done | ||
| 616 | /// | ||
| 617 | virtual PVR_ERROR GetConnectionString(std::string& connection) | ||
| 618 | { | ||
| 619 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 620 | } | ||
| 621 | //---------------------------------------------------------------------------- | ||
| 622 | |||
| 623 | //============================================================================ | ||
| 624 | /// @brief Get the disk space reported by the backend (if supported). | ||
| 625 | /// | ||
| 626 | /// @param[in] total The total disk space in bytes. | ||
| 627 | /// @param[in] used The used disk space in bytes. | ||
| 628 | /// @return @ref PVR_ERROR_NO_ERROR if the drive space has been fetched | ||
| 629 | /// successfully. | ||
| 630 | /// | ||
| 631 | /// | ||
| 632 | /// -------------------------------------------------------------------------- | ||
| 633 | /// | ||
| 634 | /// **Example:** | ||
| 635 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 636 | /// PVR_ERROR CMyPVRClient::GetDriveSpace(uint64_t& total, uint64_t& used) | ||
| 637 | /// { | ||
| 638 | /// total = 10 * 1024 * 1024 * 1024; // To set complete size of drive in bytes | ||
| 639 | /// used = 122324243; // To set the used amount | ||
| 640 | /// return PVR_ERROR_NO_ERROR; | ||
| 641 | /// } | ||
| 642 | /// ~~~~~~~~~~~~~ | ||
| 643 | /// | ||
| 644 | virtual PVR_ERROR GetDriveSpace(uint64_t& total, uint64_t& used) | ||
| 645 | { | ||
| 646 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 647 | } | ||
| 648 | //---------------------------------------------------------------------------- | ||
| 649 | |||
| 650 | //============================================================================ | ||
| 651 | /// @brief Call one of the settings related menu hooks (if supported). | ||
| 652 | /// | ||
| 653 | /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook "menu hook " | ||
| 654 | /// instances have to be added in `constructor()`, by calling @ref AddMenuHook() | ||
| 655 | /// on the callback. | ||
| 656 | /// | ||
| 657 | /// @param[in] menuhook The hook to call. | ||
| 658 | /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully. | ||
| 659 | /// | ||
| 660 | /// -------------------------------------------------------------------------- | ||
| 661 | /// | ||
| 662 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 663 | /// | ||
| 664 | /// | ||
| 665 | /// -------------------------------------------------------------------------- | ||
| 666 | /// | ||
| 667 | /// **Example:** | ||
| 668 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 669 | /// PVR_ERROR CMyPVRClient::CallSettingsMenuHook(const kodi::addon::PVRMenuhook& menuhook) | ||
| 670 | /// { | ||
| 671 | /// if (menuhook.GetHookId() == 2) | ||
| 672 | /// kodi::QueueNotification(QUEUE_INFO, "", kodi::GetLocalizedString(menuhook.GetLocalizedStringId())); | ||
| 673 | /// return PVR_ERROR_NO_ERROR; | ||
| 674 | /// } | ||
| 675 | /// ~~~~~~~~~~~~~ | ||
| 676 | /// | ||
| 677 | virtual PVR_ERROR CallSettingsMenuHook(const kodi::addon::PVRMenuhook& menuhook) | ||
| 678 | { | ||
| 679 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 680 | } | ||
| 681 | //---------------------------------------------------------------------------- | ||
| 682 | |||
| 683 | //========================================================================== | ||
| 684 | /// @brief **Callback to Kodi Function**\nAdd or replace a menu hook for the context menu for this add-on | ||
| 685 | /// | ||
| 686 | /// This is a callback function, called from addon to give Kodi his context menu's. | ||
| 687 | /// | ||
| 688 | /// @param[in] menuhook The with @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook defined hook to add | ||
| 689 | /// | ||
| 690 | /// @remarks Only called from addon itself | ||
| 691 | /// | ||
| 692 | /// -------------------------------------------------------------------------- | ||
| 693 | /// | ||
| 694 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 695 | /// | ||
| 696 | /// | ||
| 697 | /// -------------------------------------------------------------------------- | ||
| 698 | /// | ||
| 699 | /// **Here's an example of the use of it:** | ||
| 700 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 701 | /// #include <kodi/addon-instance/PVR.h> | ||
| 702 | /// ... | ||
| 703 | /// | ||
| 704 | /// { | ||
| 705 | /// kodi::addon::PVRMenuhook hook; | ||
| 706 | /// hook.SetHookId(1); | ||
| 707 | /// hook.SetCategory(PVR_MENUHOOK_CHANNEL); | ||
| 708 | /// hook.SetLocalizedStringId(30000); | ||
| 709 | /// AddMenuHook(hook); | ||
| 710 | /// } | ||
| 711 | /// | ||
| 712 | /// { | ||
| 713 | /// kodi::addon::PVRMenuhook hook; | ||
| 714 | /// hook.SetHookId(2); | ||
| 715 | /// hook.SetCategory(PVR_MENUHOOK_SETTING); | ||
| 716 | /// hook.SetLocalizedStringId(30001); | ||
| 717 | /// AddMenuHook(hook); | ||
| 718 | /// } | ||
| 719 | /// ... | ||
| 720 | /// ~~~~~~~~~~~~~ | ||
| 721 | /// | ||
| 722 | /// **Here another way:** | ||
| 723 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 724 | /// #include <kodi/addon-instance/PVR.h> | ||
| 725 | /// ... | ||
| 726 | /// | ||
| 727 | /// AddMenuHook(kodi::addon::PVRMenuhook(1, 30000, PVR_MENUHOOK_CHANNEL)); | ||
| 728 | /// AddMenuHook(kodi::addon::PVRMenuhook(2, 30001, PVR_MENUHOOK_SETTING)); | ||
| 729 | /// ... | ||
| 730 | /// ~~~~~~~~~~~~~ | ||
| 731 | /// | ||
| 732 | inline void AddMenuHook(const kodi::addon::PVRMenuhook& hook) | ||
| 733 | { | ||
| 734 | m_instanceData->toKodi->AddMenuHook(m_instanceData->toKodi->kodiInstance, hook); | ||
| 735 | } | ||
| 736 | //---------------------------------------------------------------------------- | ||
| 737 | |||
| 738 | //========================================================================== | ||
| 739 | /// @brief **Callback to Kodi Function**\n | ||
| 740 | /// Notify a state change for a PVR backend connection. | ||
| 741 | /// | ||
| 742 | /// @param[in] connectionString The connection string reported by the backend | ||
| 743 | /// that can be displayed in the UI. | ||
| 744 | /// @param[in] newState The by @ref PVR_CONNECTION_STATE defined new state. | ||
| 745 | /// @param[in] message A localized addon-defined string representing the new | ||
| 746 | /// state, that can be displayed in the UI or **empty** if | ||
| 747 | /// the Kodi-defined default string for the new state | ||
| 748 | /// shall be displayed. | ||
| 749 | /// | ||
| 750 | /// @remarks Only called from addon itself | ||
| 751 | /// | ||
| 752 | /// | ||
| 753 | /// -------------------------------------------------------------------------- | ||
| 754 | /// | ||
| 755 | /// | ||
| 756 | /// **Here's an example of the use of it:** | ||
| 757 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 758 | /// #include <kodi/addon-instance/PVR.h> | ||
| 759 | /// #include <kodi/General.h> /* for kodi::GetLocalizedString(...) */ | ||
| 760 | /// ... | ||
| 761 | /// | ||
| 762 | /// ConnectionStateChange("PVR demo connection lost", PVR_CONNECTION_STATE_DISCONNECTED, kodi::GetLocalizedString(30005, "Lost connection to Server");); | ||
| 763 | /// ... | ||
| 764 | /// ~~~~~~~~~~~~~ | ||
| 765 | /// | ||
| 766 | inline void ConnectionStateChange(const std::string& connectionString, | ||
| 767 | PVR_CONNECTION_STATE newState, | ||
| 768 | const std::string& message) | ||
| 769 | { | ||
| 770 | m_instanceData->toKodi->ConnectionStateChange( | ||
| 771 | m_instanceData->toKodi->kodiInstance, connectionString.c_str(), newState, message.c_str()); | ||
| 772 | } | ||
| 773 | //---------------------------------------------------------------------------- | ||
| 774 | |||
| 775 | //========================================================================== | ||
| 776 | /// @brief **Callback to Kodi Function**\n | ||
| 777 | /// Get user data path of the PVR addon. | ||
| 778 | /// | ||
| 779 | /// @return Path of current Kodi user | ||
| 780 | /// | ||
| 781 | /// @remarks Only called from addon itself | ||
| 782 | /// | ||
| 783 | /// @note Alternatively, @ref kodi::GetAddonPath() can be used for this. | ||
| 784 | /// | ||
| 785 | inline std::string UserPath() const { return m_instanceData->props->strUserPath; } | ||
| 786 | //---------------------------------------------------------------------------- | ||
| 787 | |||
| 788 | //========================================================================== | ||
| 789 | /// @brief **Callback to Kodi Function**\n | ||
| 790 | /// Get main client path of the PVR addon. | ||
| 791 | /// | ||
| 792 | /// @return Path of addon client | ||
| 793 | /// | ||
| 794 | /// @remarks Only called from addon itself. | ||
| 795 | /// | ||
| 796 | /// @note Alternatively, @ref kodi::GetBaseUserPath() can be used for this. | ||
| 797 | /// | ||
| 798 | inline std::string ClientPath() const { return m_instanceData->props->strClientPath; } | ||
| 799 | //---------------------------------------------------------------------------- | ||
| 800 | |||
| 801 | ///@} | ||
| 802 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 803 | |||
| 804 | //============================================================================ | ||
| 805 | /// @defgroup cpp_kodi_addon_pvr_Channels 2. Channels (required) | ||
| 806 | /// @ingroup cpp_kodi_addon_pvr | ||
| 807 | /// @brief **Functions to get available TV or Radio channels**\n | ||
| 808 | /// These are mandatory functions for using this addon to get the available | ||
| 809 | /// channels. | ||
| 810 | /// | ||
| 811 | /// @remarks Either @ref PVRCapabilities::SetSupportsTV "SetSupportsTV()" or | ||
| 812 | /// @ref PVRCapabilities::SetSupportsRadio "SetSupportsRadio()" is required to | ||
| 813 | /// be set to <b>`true`</b>.\n | ||
| 814 | /// If a channel changes after the initial import, or if a new one was added, | ||
| 815 | /// then the add-on should call @ref TriggerChannelUpdate(). | ||
| 816 | /// | ||
| 817 | /// | ||
| 818 | ///--------------------------------------------------------------------------- | ||
| 819 | /// | ||
| 820 | /// **Channel parts in interface:**\n | ||
| 821 | /// Copy this to your project and extend with your parts or leave functions | ||
| 822 | /// complete away where not used or supported. | ||
| 823 | /// | ||
| 824 | /// @copydetails cpp_kodi_addon_pvr_Channels_header_addon_auto_check | ||
| 825 | /// @copydetails cpp_kodi_addon_pvr_Channels_source_addon_auto_check | ||
| 826 | /// | ||
| 827 | ///@{ | ||
| 828 | |||
| 829 | //============================================================================ | ||
| 830 | /// @brief The total amount of channels on the backend | ||
| 831 | /// | ||
| 832 | /// @param[out] amount The total amount of channels on the backend | ||
| 833 | /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully. | ||
| 834 | /// | ||
| 835 | /// @remarks Valid implementation required. | ||
| 836 | /// | ||
| 837 | virtual PVR_ERROR GetChannelsAmount(int& amount) { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 838 | //---------------------------------------------------------------------------- | ||
| 839 | |||
| 840 | //============================================================================ | ||
| 841 | /// @brief Request the list of all channels from the backend. | ||
| 842 | /// | ||
| 843 | /// @param[in] radio True to get the radio channels, false to get the TV channels. | ||
| 844 | /// @param[out] results The channels defined with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRChannel | ||
| 845 | /// and available at the addon, them transferred with | ||
| 846 | /// @ref cpp_kodi_addon_pvr_Defs_Channel_PVRChannelsResultSet. | ||
| 847 | /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 848 | /// | ||
| 849 | /// -------------------------------------------------------------------------- | ||
| 850 | /// | ||
| 851 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help | ||
| 852 | /// | ||
| 853 | /// | ||
| 854 | /// -------------------------------------------------------------------------- | ||
| 855 | /// | ||
| 856 | /// @remarks | ||
| 857 | /// If @ref PVRCapabilities::SetSupportsTV() is set to | ||
| 858 | /// <b>`true`</b>, a valid result set needs to be provided for <b>`radio = false`</b>.\n | ||
| 859 | /// If @ref PVRCapabilities::SetSupportsRadio() is set to | ||
| 860 | /// <b>`true`</b>, a valid result set needs to be provided for <b>`radio = true`</b>. | ||
| 861 | /// At least one of these two must provide a valid result set. | ||
| 862 | /// | ||
| 863 | /// | ||
| 864 | ///--------------------------------------------------------------------------- | ||
| 865 | /// | ||
| 866 | /// **Example:** | ||
| 867 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 868 | /// ... | ||
| 869 | /// PVR_ERROR CMyPVRInstance::GetChannels(bool radio, kodi::addon::PVRChannelsResultSet& results) | ||
| 870 | /// { | ||
| 871 | /// // Minimal demo example, in reality bigger and loop to transfer all | ||
| 872 | /// kodi::addon::PVRChannel channel; | ||
| 873 | /// channel.SetUniqueId(123); | ||
| 874 | /// channel.SetIsRadio(false); | ||
| 875 | /// channel.SetChannelNumber(1); | ||
| 876 | /// channel.SetChannelName("My channel name"); | ||
| 877 | /// ... | ||
| 878 | /// | ||
| 879 | /// // Give it now to Kodi | ||
| 880 | /// results.Add(channel); | ||
| 881 | /// return PVR_ERROR_NO_ERROR; | ||
| 882 | /// } | ||
| 883 | /// ... | ||
| 884 | /// ~~~~~~~~~~~~~ | ||
| 885 | /// | ||
| 886 | virtual PVR_ERROR GetChannels(bool radio, kodi::addon::PVRChannelsResultSet& results) | ||
| 887 | { | ||
| 888 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 889 | } | ||
| 890 | //---------------------------------------------------------------------------- | ||
| 891 | |||
| 892 | //============================================================================ | ||
| 893 | /// @brief Get the stream properties for a channel from the backend. | ||
| 894 | /// | ||
| 895 | /// @param[in] channel The channel to get the stream properties for. | ||
| 896 | /// @param[out] properties the properties required to play the stream. | ||
| 897 | /// @return @ref PVR_ERROR_NO_ERROR if the stream is available. | ||
| 898 | /// | ||
| 899 | /// @remarks If @ref PVRCapabilities::SetSupportsTV "SetSupportsTV" or | ||
| 900 | /// @ref PVRCapabilities::SetSupportsRadio "SetSupportsRadio" are set to true | ||
| 901 | /// and @ref PVRCapabilities::SetHandlesInputStream "SetHandlesInputStream" is | ||
| 902 | /// set to false.\n\n | ||
| 903 | /// In this case the implementation must fill the property @ref PVR_STREAM_PROPERTY_STREAMURL | ||
| 904 | /// with the URL Kodi should resolve to playback the channel. | ||
| 905 | /// | ||
| 906 | /// @note The value directly related to inputstream must always begin with the | ||
| 907 | /// name of the associated add-on, e.g. <b>`"inputstream.adaptive.manifest_update_parameter"`</b>. | ||
| 908 | /// | ||
| 909 | /// | ||
| 910 | ///--------------------------------------------------------------------------- | ||
| 911 | /// | ||
| 912 | /// **Example:** | ||
| 913 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 914 | /// ... | ||
| 915 | /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 916 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 917 | /// { | ||
| 918 | /// ... | ||
| 919 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive"); | ||
| 920 | /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd"); | ||
| 921 | /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full"); | ||
| 922 | /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash"); | ||
| 923 | /// return PVR_ERROR_NO_ERROR; | ||
| 924 | /// } | ||
| 925 | /// ... | ||
| 926 | /// ~~~~~~~~~~~~~ | ||
| 927 | /// | ||
| 928 | virtual PVR_ERROR GetChannelStreamProperties( | ||
| 929 | const kodi::addon::PVRChannel& channel, | ||
| 930 | std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 931 | { | ||
| 932 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 933 | } | ||
| 934 | //---------------------------------------------------------------------------- | ||
| 935 | |||
| 936 | //============================================================================ | ||
| 937 | /// @brief Get the signal status of the stream that's currently open. | ||
| 938 | /// | ||
| 939 | /// @param[out] signalStatus The signal status. | ||
| 940 | /// @return @ref PVR_ERROR_NO_ERROR if the signal status has been read successfully, false otherwise. | ||
| 941 | /// | ||
| 942 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetHandlesInputStream "SetHandlesInputStream" | ||
| 943 | /// is set to true. | ||
| 944 | /// | ||
| 945 | /// -------------------------------------------------------------------------- | ||
| 946 | /// | ||
| 947 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus_Help | ||
| 948 | /// | ||
| 949 | /// | ||
| 950 | /// -------------------------------------------------------------------------- | ||
| 951 | /// | ||
| 952 | /// | ||
| 953 | /// **Here's example about the use of this:** | ||
| 954 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 955 | /// #include <kodi/addon-instance/PVR.h> | ||
| 956 | /// ... | ||
| 957 | /// | ||
| 958 | /// class ATTRIBUTE_HIDDEN CPVRExample | ||
| 959 | /// : public kodi::addon::CAddonBase, | ||
| 960 | /// public kodi::addon::CInstancePVRClient | ||
| 961 | /// { | ||
| 962 | /// public: | ||
| 963 | /// ... | ||
| 964 | /// PVR_ERROR SignalStatus(PVRSignalStatus &signalStatus) override | ||
| 965 | /// { | ||
| 966 | /// signalStatus.SetAapterName("Example adapter 1"); | ||
| 967 | /// signalStatus.SetAdapterStatus("OK"); | ||
| 968 | /// signalStatus.SetSignal(0xFFFF); // 100% | ||
| 969 | /// | ||
| 970 | /// return PVR_ERROR_NO_ERROR; | ||
| 971 | /// } | ||
| 972 | /// }; | ||
| 973 | /// | ||
| 974 | /// ADDONCREATOR(CPVRExample) | ||
| 975 | /// ~~~~~~~~~~~~~ | ||
| 976 | /// | ||
| 977 | virtual PVR_ERROR GetSignalStatus(int channelUid, kodi::addon::PVRSignalStatus& signalStatus) | ||
| 978 | { | ||
| 979 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 980 | } | ||
| 981 | //---------------------------------------------------------------------------- | ||
| 982 | |||
| 983 | //============================================================================ | ||
| 984 | /// @brief Get the descramble information of the stream that's currently open. | ||
| 985 | /// | ||
| 986 | /// @param[out] descrambleInfo The descramble information. | ||
| 987 | /// @return @ref PVR_ERROR_NO_ERROR if the descramble information has been | ||
| 988 | /// read successfully, false otherwise. | ||
| 989 | /// | ||
| 990 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsDescrambleInfo "supportsDescrambleInfo" | ||
| 991 | /// is set to true. | ||
| 992 | /// | ||
| 993 | /// -------------------------------------------------------------------------- | ||
| 994 | /// | ||
| 995 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo_Help | ||
| 996 | /// | ||
| 997 | virtual PVR_ERROR GetDescrambleInfo(int channelUid, | ||
| 998 | kodi::addon::PVRDescrambleInfo& descrambleInfo) | ||
| 999 | { | ||
| 1000 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1001 | } | ||
| 1002 | //---------------------------------------------------------------------------- | ||
| 1003 | |||
| 1004 | //============================================================================ | ||
| 1005 | /// @brief **Callback to Kodi Function**\n | ||
| 1006 | /// Request Kodi to update it's list of channels. | ||
| 1007 | /// | ||
| 1008 | /// @remarks Only called from addon itself. | ||
| 1009 | /// | ||
| 1010 | inline void TriggerChannelUpdate() | ||
| 1011 | { | ||
| 1012 | m_instanceData->toKodi->TriggerChannelUpdate(m_instanceData->toKodi->kodiInstance); | ||
| 1013 | } | ||
| 1014 | //---------------------------------------------------------------------------- | ||
| 1015 | |||
| 1016 | ///@} | ||
| 1017 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 1018 | |||
| 1019 | //============================================================================ | ||
| 1020 | /// @defgroup cpp_kodi_addon_pvr_supportsChannelGroups 3. Channel Groups (optional) | ||
| 1021 | /// @ingroup cpp_kodi_addon_pvr | ||
| 1022 | /// @brief <b>Bring in this functions if you have set @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups" | ||
| 1023 | /// to true</b>\n | ||
| 1024 | /// This is used to divide available addon channels into groups, which can | ||
| 1025 | /// then be selected by the user. | ||
| 1026 | /// | ||
| 1027 | /// | ||
| 1028 | ///--------------------------------------------------------------------------- | ||
| 1029 | /// | ||
| 1030 | /// **Channel group parts in interface:**\n | ||
| 1031 | /// Copy this to your project and extend with your parts or leave functions | ||
| 1032 | /// complete away where not used or supported. | ||
| 1033 | /// | ||
| 1034 | /// @copydetails cpp_kodi_addon_pvr_supportsChannelGroups_header_addon_auto_check | ||
| 1035 | /// @copydetails cpp_kodi_addon_pvr_supportsChannelGroups_source_addon_auto_check | ||
| 1036 | /// | ||
| 1037 | ///@{ | ||
| 1038 | |||
| 1039 | //============================================================================ | ||
| 1040 | /// @brief Get the total amount of channel groups on the backend if it supports channel groups. | ||
| 1041 | /// | ||
| 1042 | /// @param[out] amount The total amount of channel groups on the backend | ||
| 1043 | /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully. | ||
| 1044 | /// | ||
| 1045 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups" is set to true. | ||
| 1046 | /// | ||
| 1047 | virtual PVR_ERROR GetChannelGroupsAmount(int& amount) { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 1048 | //---------------------------------------------------------------------------- | ||
| 1049 | |||
| 1050 | //============================================================================ | ||
| 1051 | /// @brief Get a list of available channel groups on addon | ||
| 1052 | /// | ||
| 1053 | /// Request the list of all channel groups from the backend if it supports | ||
| 1054 | /// channel groups. | ||
| 1055 | /// | ||
| 1056 | /// @param[in] radio True to get the radio channel groups, false to get the | ||
| 1057 | /// TV channel groups. | ||
| 1058 | /// @param[out] results List of available groups on addon defined with | ||
| 1059 | /// @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup, | ||
| 1060 | /// them transferred with | ||
| 1061 | /// @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupsResultSet. | ||
| 1062 | /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 1063 | /// | ||
| 1064 | /// -------------------------------------------------------------------------- | ||
| 1065 | /// | ||
| 1066 | /// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup_Help | ||
| 1067 | /// | ||
| 1068 | /// | ||
| 1069 | /// -------------------------------------------------------------------------- | ||
| 1070 | /// | ||
| 1071 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups" | ||
| 1072 | /// is set to true. | ||
| 1073 | /// | ||
| 1074 | /// | ||
| 1075 | ///--------------------------------------------------------------------------- | ||
| 1076 | /// | ||
| 1077 | /// **Example:** | ||
| 1078 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1079 | /// ... | ||
| 1080 | /// PVR_ERROR CMyPVRInstance::GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& groups) | ||
| 1081 | /// { | ||
| 1082 | /// kodi::addon::PVRChannelGroup group; | ||
| 1083 | /// group.SetIsRadio(false); | ||
| 1084 | /// group.SetGroupName("My group name"); | ||
| 1085 | /// group.SetPosition(1); | ||
| 1086 | /// ... | ||
| 1087 | /// | ||
| 1088 | /// // Give it now to Kodi | ||
| 1089 | /// results.Add(group); | ||
| 1090 | /// return PVR_ERROR_NO_ERROR; | ||
| 1091 | /// } | ||
| 1092 | /// ... | ||
| 1093 | /// ~~~~~~~~~~~~~ | ||
| 1094 | /// | ||
| 1095 | virtual PVR_ERROR GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& results) | ||
| 1096 | { | ||
| 1097 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1098 | } | ||
| 1099 | //---------------------------------------------------------------------------- | ||
| 1100 | |||
| 1101 | //============================================================================ | ||
| 1102 | /// @brief Get a list of members on a group | ||
| 1103 | /// | ||
| 1104 | /// Request the list of all group members of a group from the backend if it | ||
| 1105 | /// supports channel groups. | ||
| 1106 | /// | ||
| 1107 | /// @param[in] group The group to get the members for. | ||
| 1108 | /// @param[out] results List of available group member channels defined with | ||
| 1109 | /// @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember, | ||
| 1110 | /// them transferred with | ||
| 1111 | /// @ref PVRChannelGroupMembersResultSet. | ||
| 1112 | /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 1113 | /// | ||
| 1114 | /// -------------------------------------------------------------------------- | ||
| 1115 | /// | ||
| 1116 | /// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember_Help | ||
| 1117 | /// | ||
| 1118 | /// -------------------------------------------------------------------------- | ||
| 1119 | /// | ||
| 1120 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups" | ||
| 1121 | /// is set to true. | ||
| 1122 | /// | ||
| 1123 | /// | ||
| 1124 | ///--------------------------------------------------------------------------- | ||
| 1125 | /// | ||
| 1126 | /// **Example:** | ||
| 1127 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1128 | /// ... | ||
| 1129 | /// PVR_ERROR CMyPVRInstance::GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group, | ||
| 1130 | /// kodi::addon::PVRChannelGroupMembersResultSet& results) | ||
| 1131 | /// { | ||
| 1132 | /// for (const auto& myGroup : m_myGroups) | ||
| 1133 | /// { | ||
| 1134 | /// if (myGroup.strGroupName == group.GetGroupName()) | ||
| 1135 | /// { | ||
| 1136 | /// for (unsigned int iChannelPtr = 0; iChannelPtr < myGroup.members.size(); iChannelPtr++) | ||
| 1137 | /// { | ||
| 1138 | /// int iId = myGroup.members.at(iChannelPtr) - 1; | ||
| 1139 | /// if (iId < 0 || iId > (int)m_channels.size() - 1) | ||
| 1140 | /// continue; | ||
| 1141 | /// | ||
| 1142 | /// PVRDemoChannel &channel = m_channels.at(iId); | ||
| 1143 | /// kodi::addon::PVRChannelGroupMember kodiGroupMember; | ||
| 1144 | /// kodiGroupMember.SetGroupName(group.GetGroupName()); | ||
| 1145 | /// kodiGroupMember.SetChannelUniqueId(channel.iUniqueId); | ||
| 1146 | /// kodiGroupMember.SetChannelNumber(channel.iChannelNumber); | ||
| 1147 | /// kodiGroupMember.SetSubChannelNumber(channel.iSubChannelNumber); | ||
| 1148 | /// | ||
| 1149 | /// results.Add(kodiGroupMember); | ||
| 1150 | /// } | ||
| 1151 | /// } | ||
| 1152 | /// } | ||
| 1153 | /// return PVR_ERROR_NO_ERROR; | ||
| 1154 | /// } | ||
| 1155 | /// ... | ||
| 1156 | /// ~~~~~~~~~~~~~ | ||
| 1157 | /// | ||
| 1158 | virtual PVR_ERROR GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group, | ||
| 1159 | kodi::addon::PVRChannelGroupMembersResultSet& results) | ||
| 1160 | { | ||
| 1161 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1162 | } | ||
| 1163 | //---------------------------------------------------------------------------- | ||
| 1164 | |||
| 1165 | //============================================================================ | ||
| 1166 | /// @brief **Callback to Kodi Function**\n | ||
| 1167 | /// Request Kodi to update it's list of channel groups. | ||
| 1168 | /// | ||
| 1169 | /// @remarks Only called from addon itself | ||
| 1170 | /// | ||
| 1171 | inline void TriggerChannelGroupsUpdate() | ||
| 1172 | { | ||
| 1173 | m_instanceData->toKodi->TriggerChannelGroupsUpdate(m_instanceData->toKodi->kodiInstance); | ||
| 1174 | } | ||
| 1175 | //---------------------------------------------------------------------------- | ||
| 1176 | |||
| 1177 | ///@} | ||
| 1178 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 1179 | |||
| 1180 | //============================================================================ | ||
| 1181 | /// @defgroup cpp_kodi_addon_pvr_supportsChannelEdit 4. Channel edit (optional) | ||
| 1182 | /// @ingroup cpp_kodi_addon_pvr | ||
| 1183 | /// @brief <b>Bring in this functions if you have set @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" | ||
| 1184 | /// to true or for @ref OpenDialogChannelScan() set @ref PVRCapabilities::SetSupportsChannelScan "supportsChannelScan" | ||
| 1185 | /// to true</b>\n | ||
| 1186 | /// The support of this is a pure option and not mandatory. | ||
| 1187 | /// | ||
| 1188 | /// | ||
| 1189 | ///--------------------------------------------------------------------------- | ||
| 1190 | /// | ||
| 1191 | /// **Channel edit parts in interface:**\n | ||
| 1192 | /// Copy this to your project and extend with your parts or leave functions | ||
| 1193 | /// complete away where not used or supported. | ||
| 1194 | /// | ||
| 1195 | /// @copydetails cpp_kodi_addon_pvr_supportsChannelEdit_header_addon_auto_check | ||
| 1196 | /// @copydetails cpp_kodi_addon_pvr_supportsChannelEdit_source_addon_auto_check | ||
| 1197 | /// | ||
| 1198 | ///@{ | ||
| 1199 | |||
| 1200 | //============================================================================ | ||
| 1201 | /// @brief Delete a channel from the backend. | ||
| 1202 | /// | ||
| 1203 | /// @param[in] channel The channel to delete. | ||
| 1204 | /// @return @ref PVR_ERROR_NO_ERROR if the channel has been deleted successfully. | ||
| 1205 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" | ||
| 1206 | /// is set to true. | ||
| 1207 | /// | ||
| 1208 | virtual PVR_ERROR DeleteChannel(const kodi::addon::PVRChannel& channel) | ||
| 1209 | { | ||
| 1210 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1211 | } | ||
| 1212 | //---------------------------------------------------------------------------- | ||
| 1213 | |||
| 1214 | //========================================================================== | ||
| 1215 | /// @brief Rename a channel on the backend. | ||
| 1216 | /// | ||
| 1217 | /// @param[in] channel The channel to rename, containing the new channel name. | ||
| 1218 | /// @return @ref PVR_ERROR_NO_ERROR if the channel has been renamed successfully. | ||
| 1219 | /// | ||
| 1220 | /// -------------------------------------------------------------------------- | ||
| 1221 | /// | ||
| 1222 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help | ||
| 1223 | /// | ||
| 1224 | /// | ||
| 1225 | /// -------------------------------------------------------------------------- | ||
| 1226 | /// | ||
| 1227 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" | ||
| 1228 | /// is set to true. | ||
| 1229 | /// | ||
| 1230 | virtual PVR_ERROR RenameChannel(const kodi::addon::PVRChannel& channel) | ||
| 1231 | { | ||
| 1232 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1233 | } | ||
| 1234 | //---------------------------------------------------------------------------- | ||
| 1235 | |||
| 1236 | //========================================================================== | ||
| 1237 | /// @brief Show the channel settings dialog, if supported by the backend. | ||
| 1238 | /// | ||
| 1239 | /// @param[in] channel The channel to show the dialog for. | ||
| 1240 | /// @return @ref PVR_ERROR_NO_ERROR if the dialog has been displayed successfully. | ||
| 1241 | /// | ||
| 1242 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" is set to true. | ||
| 1243 | /// @note Use @ref cpp_kodi_gui_CWindow "kodi::gui::CWindow" to create dialog for them. | ||
| 1244 | /// | ||
| 1245 | virtual PVR_ERROR OpenDialogChannelSettings(const kodi::addon::PVRChannel& channel) | ||
| 1246 | { | ||
| 1247 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1248 | } | ||
| 1249 | //---------------------------------------------------------------------------- | ||
| 1250 | |||
| 1251 | //========================================================================== | ||
| 1252 | /// @brief Show the dialog to add a channel on the backend, if supported by the backend. | ||
| 1253 | /// | ||
| 1254 | /// @param[in] channel The channel to add. | ||
| 1255 | /// @return @ref PVR_ERROR_NO_ERROR if the channel has been added successfully. | ||
| 1256 | /// | ||
| 1257 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" is set to true. | ||
| 1258 | /// @note Use @ref cpp_kodi_gui_CWindow "kodi::gui::CWindow" to create dialog for them. | ||
| 1259 | /// | ||
| 1260 | virtual PVR_ERROR OpenDialogChannelAdd(const kodi::addon::PVRChannel& channel) | ||
| 1261 | { | ||
| 1262 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1263 | } | ||
| 1264 | //---------------------------------------------------------------------------- | ||
| 1265 | |||
| 1266 | //========================================================================== | ||
| 1267 | /// @brief Show the channel scan dialog if this backend supports it. | ||
| 1268 | /// | ||
| 1269 | /// @return @ref PVR_ERROR_NO_ERROR if the dialog was displayed successfully. | ||
| 1270 | /// | ||
| 1271 | /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelScan "supportsChannelScan" is set to true. | ||
| 1272 | /// @note Use @ref cpp_kodi_gui_CWindow "kodi::gui::CWindow" to create dialog for them. | ||
| 1273 | /// | ||
| 1274 | virtual PVR_ERROR OpenDialogChannelScan() { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 1275 | //---------------------------------------------------------------------------- | ||
| 1276 | |||
| 1277 | //========================================================================== | ||
| 1278 | /// @brief Call one of the channel related menu hooks (if supported). | ||
| 1279 | /// | ||
| 1280 | /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have to be added in | ||
| 1281 | /// `constructor()`, by calling @ref AddMenuHook() on the callback. | ||
| 1282 | /// | ||
| 1283 | /// @param[in] menuhook The hook to call. | ||
| 1284 | /// @param[in] item The selected channel item for which the hook was called. | ||
| 1285 | /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully. | ||
| 1286 | /// | ||
| 1287 | /// -------------------------------------------------------------------------- | ||
| 1288 | /// | ||
| 1289 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 1290 | /// | ||
| 1291 | virtual PVR_ERROR CallChannelMenuHook(const kodi::addon::PVRMenuhook& menuhook, | ||
| 1292 | const kodi::addon::PVRChannel& item) | ||
| 1293 | { | ||
| 1294 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1295 | } | ||
| 1296 | //---------------------------------------------------------------------------- | ||
| 1297 | |||
| 1298 | ///@} | ||
| 1299 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 1300 | |||
| 1301 | //============================================================================ | ||
| 1302 | /// @defgroup cpp_kodi_addon_pvr_EPGTag 4. EPG methods (optional) | ||
| 1303 | /// @ingroup cpp_kodi_addon_pvr | ||
| 1304 | /// @brief **PVR EPG methods**\n | ||
| 1305 | /// These C ++ class functions of are intended for processing EPG information | ||
| 1306 | /// and for giving it to Kodi. | ||
| 1307 | /// | ||
| 1308 | /// The necessary data is transferred with @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag. | ||
| 1309 | /// | ||
| 1310 | /// @remarks Only used by Kodi if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" | ||
| 1311 | /// is set to true.\n\n | ||
| 1312 | /// | ||
| 1313 | /// | ||
| 1314 | ///--------------------------------------------------------------------------- | ||
| 1315 | /// | ||
| 1316 | /// **EPG parts in interface:**\n | ||
| 1317 | /// Copy this to your project and extend with your parts or leave functions | ||
| 1318 | /// complete away where not used or supported. | ||
| 1319 | /// | ||
| 1320 | /// @copydetails cpp_kodi_addon_pvr_EPGTag_header_addon_auto_check | ||
| 1321 | /// @copydetails cpp_kodi_addon_pvr_EPGTag_source_addon_auto_check | ||
| 1322 | /// | ||
| 1323 | ///@{ | ||
| 1324 | |||
| 1325 | //============================================================================ | ||
| 1326 | /// @brief Request the EPG for a channel from the backend. | ||
| 1327 | /// | ||
| 1328 | /// @param[in] channelUid The UID of the channel to get the EPG table for. | ||
| 1329 | /// @param[in] start Get events after this time (UTC). | ||
| 1330 | /// @param[in] end Get events before this time (UTC). | ||
| 1331 | /// @param[out] results List where available EPG information becomes | ||
| 1332 | /// transferred with @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag | ||
| 1333 | /// and given to Kodi | ||
| 1334 | /// @return @ref PVR_ERROR_NO_ERROR if the table has been fetched successfully. | ||
| 1335 | /// | ||
| 1336 | /// -------------------------------------------------------------------------- | ||
| 1337 | /// | ||
| 1338 | /// @copydetails cpp_kodi_addon_pvr_Defs_epg_PVREPGTag_Help | ||
| 1339 | /// | ||
| 1340 | /// | ||
| 1341 | /// -------------------------------------------------------------------------- | ||
| 1342 | /// | ||
| 1343 | /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true. | ||
| 1344 | /// | ||
| 1345 | /// | ||
| 1346 | ///--------------------------------------------------------------------------- | ||
| 1347 | /// | ||
| 1348 | /// **Example:** | ||
| 1349 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1350 | /// ... | ||
| 1351 | /// PVR_ERROR CMyPVRInstance::GetEPGForChannel(int channelUid, | ||
| 1352 | /// time_t start, | ||
| 1353 | /// time_t end, | ||
| 1354 | /// kodi::addon::PVREPGTagsResultSet& results) | ||
| 1355 | /// { | ||
| 1356 | /// // Minimal demo example, in reality bigger, loop to transfer all and to | ||
| 1357 | /// // match wanted times. | ||
| 1358 | /// kodi::addon::PVREPGTag tag; | ||
| 1359 | /// tag.SetUniqueBroadcastId(123); | ||
| 1360 | /// tag.SetUniqueChannelId(123); | ||
| 1361 | /// tag.SetTitle("My epg entry name"); | ||
| 1362 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA); | ||
| 1363 | /// tag.SetStartTime(1589148283); // Seconds elapsed since 00:00 hours, Jan 1, 1970 UTC | ||
| 1364 | /// tag.SetEndTime(1589151913); | ||
| 1365 | /// ... | ||
| 1366 | /// | ||
| 1367 | /// // Give it now to Kodi | ||
| 1368 | /// results.Add(tag); | ||
| 1369 | /// return PVR_ERROR_NO_ERROR; | ||
| 1370 | /// } | ||
| 1371 | /// ... | ||
| 1372 | /// ~~~~~~~~~~~~~ | ||
| 1373 | /// | ||
| 1374 | virtual PVR_ERROR GetEPGForChannel(int channelUid, | ||
| 1375 | time_t start, | ||
| 1376 | time_t end, | ||
| 1377 | kodi::addon::PVREPGTagsResultSet& results) | ||
| 1378 | { | ||
| 1379 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1380 | } | ||
| 1381 | //---------------------------------------------------------------------------- | ||
| 1382 | |||
| 1383 | //============================================================================ | ||
| 1384 | /// @brief Check if the given EPG tag can be recorded. | ||
| 1385 | /// | ||
| 1386 | /// @param[in] tag the @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag" to check. | ||
| 1387 | /// @param[out] isRecordable Set to true if the tag can be recorded. | ||
| 1388 | /// @return @ref PVR_ERROR_NO_ERROR if bIsRecordable has been set successfully. | ||
| 1389 | /// | ||
| 1390 | /// @remarks Optional, it return @ref PVR_ERROR_NOT_IMPLEMENTED by parent to let Kodi decide. | ||
| 1391 | /// | ||
| 1392 | virtual PVR_ERROR IsEPGTagRecordable(const kodi::addon::PVREPGTag& tag, bool& isRecordable) | ||
| 1393 | { | ||
| 1394 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1395 | } | ||
| 1396 | //---------------------------------------------------------------------------- | ||
| 1397 | |||
| 1398 | //============================================================================ | ||
| 1399 | /// @brief Check if the given EPG tag can be played. | ||
| 1400 | /// | ||
| 1401 | /// @param[in] tag the @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag" to check. | ||
| 1402 | /// @param[out] isPlayable Set to true if the tag can be played. | ||
| 1403 | /// @return @ref PVR_ERROR_NO_ERROR if bIsPlayable has been set successfully. | ||
| 1404 | /// | ||
| 1405 | /// @remarks Required if add-on supports playing epg tags. | ||
| 1406 | /// | ||
| 1407 | virtual PVR_ERROR IsEPGTagPlayable(const kodi::addon::PVREPGTag& tag, bool& isPlayable) | ||
| 1408 | { | ||
| 1409 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1410 | } | ||
| 1411 | //---------------------------------------------------------------------------- | ||
| 1412 | |||
| 1413 | //============================================================================ | ||
| 1414 | /// @brief Retrieve the edit decision list (EDL) of an EPG tag on the backend. | ||
| 1415 | /// | ||
| 1416 | /// @param[in] tag The @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag". | ||
| 1417 | /// @param[out] edl The function has to write the EDL into this array. | ||
| 1418 | /// @return @ref PVR_ERROR_NO_ERROR if the EDL was successfully read or no EDL exists. | ||
| 1419 | /// | ||
| 1420 | /// @remarks Required if @ref PVRCapabilities::SetSupportsEPGEdl "supportsEPGEdl" is set to true. | ||
| 1421 | /// | ||
| 1422 | /// -------------------------------------------------------------------------- | ||
| 1423 | /// | ||
| 1424 | /// @copydetails cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help | ||
| 1425 | /// | ||
| 1426 | /// | ||
| 1427 | /// -------------------------------------------------------------------------- | ||
| 1428 | /// | ||
| 1429 | /// @remarks Required if @ref PVRCapabilities::SetSupportsEPGEdl "supportsEPGEdl" is set to true. | ||
| 1430 | /// | ||
| 1431 | virtual PVR_ERROR GetEPGTagEdl(const kodi::addon::PVREPGTag& tag, | ||
| 1432 | std::vector<kodi::addon::PVREDLEntry>& edl) | ||
| 1433 | { | ||
| 1434 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1435 | } | ||
| 1436 | //---------------------------------------------------------------------------- | ||
| 1437 | |||
| 1438 | //============================================================================ | ||
| 1439 | /// @brief Get the stream properties for an epg tag from the backend. | ||
| 1440 | /// | ||
| 1441 | /// @param[in] tag The @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag" to get the stream properties for. | ||
| 1442 | /// @param[out] properties the properties required to play the stream. | ||
| 1443 | /// @return @ref PVR_ERROR_NO_ERROR if the stream is available. | ||
| 1444 | /// | ||
| 1445 | /// @remarks Required if add-on supports playing epg tags. | ||
| 1446 | /// In this case your implementation must fill the property @ref PVR_STREAM_PROPERTY_STREAMURL | ||
| 1447 | /// with the URL Kodi should resolve to playback the epg tag. | ||
| 1448 | /// It return @ref PVR_ERROR_NOT_IMPLEMENTED from parent if this add-on won't provide this function. | ||
| 1449 | /// | ||
| 1450 | /// @note The value directly related to inputstream must always begin with the | ||
| 1451 | /// name of the associated add-on, e.g. <b>`"inputstream.adaptive.manifest_update_parameter"`</b>. | ||
| 1452 | /// | ||
| 1453 | /// | ||
| 1454 | ///--------------------------------------------------------------------------- | ||
| 1455 | /// | ||
| 1456 | /// **Example:** | ||
| 1457 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1458 | /// ... | ||
| 1459 | /// PVR_ERROR CMyPVRInstance::GetEPGTagStreamProperties(const kodi::addon::PVREPGTag& tag, | ||
| 1460 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 1461 | /// { | ||
| 1462 | /// ... | ||
| 1463 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive"); | ||
| 1464 | /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd"); | ||
| 1465 | /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full"); | ||
| 1466 | /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash"); | ||
| 1467 | /// return PVR_ERROR_NO_ERROR; | ||
| 1468 | /// } | ||
| 1469 | /// ... | ||
| 1470 | /// ~~~~~~~~~~~~~ | ||
| 1471 | /// | ||
| 1472 | virtual PVR_ERROR GetEPGTagStreamProperties( | ||
| 1473 | const kodi::addon::PVREPGTag& tag, std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 1474 | { | ||
| 1475 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1476 | } | ||
| 1477 | //---------------------------------------------------------------------------- | ||
| 1478 | |||
| 1479 | //============================================================================ | ||
| 1480 | /// @brief Tell the client the time frame to use when notifying epg events back to Kodi | ||
| 1481 | /// | ||
| 1482 | /// The client might push epg events asynchronously to Kodi using the callback function | ||
| 1483 | /// @ref EpgEventStateChange. To be able to only push events that are actually of | ||
| 1484 | /// interest for Kodi, client needs to know about the epg time frame Kodi uses. Kodi | ||
| 1485 | /// supplies the current epg time frame value in @ref EpgMaxDays() when creating the | ||
| 1486 | /// addon and calls @ref SetEPGTimeFrame later whenever Kodi's epg time frame value | ||
| 1487 | /// changes. | ||
| 1488 | /// | ||
| 1489 | /// @param[in] days number of days from "now". @ref EPG_TIMEFRAME_UNLIMITED means that Kodi | ||
| 1490 | /// is interested in all epg events, regardless of event times. | ||
| 1491 | /// @return @ref PVR_ERROR_NO_ERROR if new value was successfully set. | ||
| 1492 | /// | ||
| 1493 | /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true. | ||
| 1494 | /// | ||
| 1495 | virtual PVR_ERROR SetEPGTimeFrame(int days) { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 1496 | //---------------------------------------------------------------------------- | ||
| 1497 | |||
| 1498 | //========================================================================== | ||
| 1499 | /// @brief Call one of the EPG related menu hooks (if supported). | ||
| 1500 | /// | ||
| 1501 | /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have to be added in | ||
| 1502 | /// `constructor()`, by calling @ref AddMenuHook() on the callback. | ||
| 1503 | /// | ||
| 1504 | /// @param[in] menuhook The hook to call. | ||
| 1505 | /// @param[in] tag The selected EPG item for which the hook was called. | ||
| 1506 | /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully. | ||
| 1507 | /// | ||
| 1508 | /// -------------------------------------------------------------------------- | ||
| 1509 | /// | ||
| 1510 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 1511 | /// | ||
| 1512 | virtual PVR_ERROR CallEPGMenuHook(const kodi::addon::PVRMenuhook& menuhook, | ||
| 1513 | const kodi::addon::PVREPGTag& tag) | ||
| 1514 | { | ||
| 1515 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1516 | } | ||
| 1517 | //---------------------------------------------------------------------------- | ||
| 1518 | |||
| 1519 | //========================================================================== | ||
| 1520 | /// @brief **Callback to Kodi Function**\n | ||
| 1521 | /// Get the Max days handled by Kodi. | ||
| 1522 | /// | ||
| 1523 | /// If > @ref EPG_TIMEFRAME_UNLIMITED, in async epg mode, deliver only events | ||
| 1524 | /// in the range from 'end time > now' to 'start time < now + EpgMaxDays(). | ||
| 1525 | /// @ref EPG_TIMEFRAME_UNLIMITED, notify all events. | ||
| 1526 | /// | ||
| 1527 | /// @return The Max days handled by Kodi | ||
| 1528 | /// | ||
| 1529 | inline int EpgMaxDays() const { return m_instanceData->props->iEpgMaxDays; } | ||
| 1530 | //---------------------------------------------------------------------------- | ||
| 1531 | |||
| 1532 | //========================================================================== | ||
| 1533 | /// @brief **Callback to Kodi Function**\n | ||
| 1534 | /// Schedule an EPG update for the given channel channel. | ||
| 1535 | /// | ||
| 1536 | /// @param[in] channelUid The unique id of the channel for this add-on | ||
| 1537 | /// | ||
| 1538 | /// @remarks Only called from addon itself | ||
| 1539 | /// | ||
| 1540 | inline void TriggerEpgUpdate(unsigned int channelUid) | ||
| 1541 | { | ||
| 1542 | m_instanceData->toKodi->TriggerEpgUpdate(m_instanceData->toKodi->kodiInstance, channelUid); | ||
| 1543 | } | ||
| 1544 | //---------------------------------------------------------------------------- | ||
| 1545 | |||
| 1546 | //========================================================================== | ||
| 1547 | /// @brief **Callback to Kodi Function**\n | ||
| 1548 | /// Notify a state change for an EPG event. | ||
| 1549 | /// | ||
| 1550 | /// @param[in] tag The @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag" where have event. | ||
| 1551 | /// @param[in] newState The new state. | ||
| 1552 | /// - For @ref EPG_EVENT_CREATED and @ref EPG_EVENT_UPDATED, tag must be filled with all available event data, not just a delta. | ||
| 1553 | /// - For @ref EPG_EVENT_DELETED, it is sufficient to fill @ref kodi::addon::PVREPGTag::SetUniqueBroadcastId | ||
| 1554 | /// | ||
| 1555 | /// @remarks Only called from addon itself, | ||
| 1556 | /// | ||
| 1557 | /// | ||
| 1558 | ///--------------------------------------------------------------------------- | ||
| 1559 | /// | ||
| 1560 | /// **Example:** | ||
| 1561 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1562 | /// ... | ||
| 1563 | /// | ||
| 1564 | /// void CMyPVRInstance::MyProcessFunction() | ||
| 1565 | /// { | ||
| 1566 | /// ... | ||
| 1567 | /// kodi::addon::PVREPGTag tag; // Here as mini add, in real it should be a complete tag | ||
| 1568 | /// tag.SetUniqueId(123); | ||
| 1569 | /// | ||
| 1570 | /// // added namespace here not needed to have, only to have more clear for where is | ||
| 1571 | /// kodi::addon::CInstancePVRClient::EpgEventStateChange(tag, EPG_EVENT_UPDATED); | ||
| 1572 | /// ... | ||
| 1573 | /// } | ||
| 1574 | /// | ||
| 1575 | /// ... | ||
| 1576 | /// ~~~~~~~~~~~~~ | ||
| 1577 | /// | ||
| 1578 | inline void EpgEventStateChange(kodi::addon::PVREPGTag& tag, EPG_EVENT_STATE newState) | ||
| 1579 | { | ||
| 1580 | m_instanceData->toKodi->EpgEventStateChange(m_instanceData->toKodi->kodiInstance, tag.GetTag(), | ||
| 1581 | newState); | ||
| 1582 | } | ||
| 1583 | //---------------------------------------------------------------------------- | ||
| 1584 | |||
| 1585 | ///@} | ||
| 1586 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 1587 | |||
| 1588 | //============================================================================ | ||
| 1589 | /// @defgroup cpp_kodi_addon_pvr_Recordings 5. Recordings (optional) | ||
| 1590 | /// @ingroup cpp_kodi_addon_pvr | ||
| 1591 | /// @brief **PVR recording methods**\n | ||
| 1592 | /// To transfer available recordings of the PVR backend and to allow possible | ||
| 1593 | /// playback. | ||
| 1594 | /// | ||
| 1595 | /// @remarks Only used by Kodi if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" | ||
| 1596 | /// is set to true.\n\n | ||
| 1597 | /// If a recordings changes after the initial import, or if a new one was added, | ||
| 1598 | /// then the add-on should call @ref TriggerRecordingUpdate(). | ||
| 1599 | /// | ||
| 1600 | /// | ||
| 1601 | ///--------------------------------------------------------------------------- | ||
| 1602 | /// | ||
| 1603 | /// **Recordings parts in interface:**\n | ||
| 1604 | /// Copy this to your project and extend with your parts or leave functions | ||
| 1605 | /// complete away where not used or supported. | ||
| 1606 | /// | ||
| 1607 | /// @copydetails cpp_kodi_addon_pvr_Recordings_header_addon_auto_check | ||
| 1608 | /// @copydetails cpp_kodi_addon_pvr_Recordings_source_addon_auto_check | ||
| 1609 | /// | ||
| 1610 | ///@{ | ||
| 1611 | |||
| 1612 | //============================================================================ | ||
| 1613 | /// @brief To get amount of recording present on backend | ||
| 1614 | /// | ||
| 1615 | /// @param[in] deleted if set return deleted recording (called if | ||
| 1616 | /// @ref PVRCapabilities::SetSupportsRecordingsUndelete "supportsRecordingsUndelete" | ||
| 1617 | /// set to true) | ||
| 1618 | /// @param[out] amount The total amount of recordings on the backend | ||
| 1619 | /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully. | ||
| 1620 | /// | ||
| 1621 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" is set to true. | ||
| 1622 | /// | ||
| 1623 | virtual PVR_ERROR GetRecordingsAmount(bool deleted, int& amount) | ||
| 1624 | { | ||
| 1625 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1626 | } | ||
| 1627 | //---------------------------------------------------------------------------- | ||
| 1628 | |||
| 1629 | //============================================================================ | ||
| 1630 | /// @brief Request the list of all recordings from the backend, if supported. | ||
| 1631 | /// | ||
| 1632 | /// Recording entries are added to Kodi by calling TransferRecordingEntry() on the callback. | ||
| 1633 | /// | ||
| 1634 | /// @param[in] deleted if set return deleted recording (called if | ||
| 1635 | /// @ref PVRCapabilities::SetSupportsRecordingsUndelete "supportsRecordingsUndelete" | ||
| 1636 | /// set to true) | ||
| 1637 | /// @param[out] results List of available recordings with @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 1638 | /// becomes transferred with @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecordingsResultSet | ||
| 1639 | /// and given to Kodi | ||
| 1640 | /// @return @ref PVR_ERROR_NO_ERROR if the recordings have been fetched successfully. | ||
| 1641 | /// | ||
| 1642 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" | ||
| 1643 | /// is set to true. | ||
| 1644 | /// | ||
| 1645 | /// -------------------------------------------------------------------------- | ||
| 1646 | /// | ||
| 1647 | /// @copydetails cpp_kodi_addon_pvr_Defs_Recording_PVRRecording_Help | ||
| 1648 | /// | ||
| 1649 | /// | ||
| 1650 | ///--------------------------------------------------------------------------- | ||
| 1651 | /// | ||
| 1652 | /// **Example:** | ||
| 1653 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1654 | /// ... | ||
| 1655 | /// PVR_ERROR CMyPVRInstance::GetRecordings(bool deleted, kodi::addon::PVRRecordingsResultSet& results) | ||
| 1656 | /// { | ||
| 1657 | /// // Minimal demo example, in reality bigger and loop to transfer all | ||
| 1658 | /// kodi::addon::PVRRecording recording; | ||
| 1659 | /// recording.SetRecordingId(123); | ||
| 1660 | /// recording.SetTitle("My recording name"); | ||
| 1661 | /// ... | ||
| 1662 | /// | ||
| 1663 | /// // Give it now to Kodi | ||
| 1664 | /// results.Add(recording); | ||
| 1665 | /// return PVR_ERROR_NO_ERROR; | ||
| 1666 | /// } | ||
| 1667 | /// ... | ||
| 1668 | /// ~~~~~~~~~~~~~ | ||
| 1669 | /// | ||
| 1670 | virtual PVR_ERROR GetRecordings(bool deleted, kodi::addon::PVRRecordingsResultSet& results) | ||
| 1671 | { | ||
| 1672 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1673 | } | ||
| 1674 | //---------------------------------------------------------------------------- | ||
| 1675 | |||
| 1676 | //============================================================================ | ||
| 1677 | /// @brief Delete a recording on the backend. | ||
| 1678 | /// | ||
| 1679 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording to delete. | ||
| 1680 | /// @return @ref PVR_ERROR_NO_ERROR if the recording has been deleted successfully. | ||
| 1681 | /// | ||
| 1682 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" | ||
| 1683 | /// is set to true. | ||
| 1684 | /// | ||
| 1685 | virtual PVR_ERROR DeleteRecording(const kodi::addon::PVRRecording& recording) | ||
| 1686 | { | ||
| 1687 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1688 | } | ||
| 1689 | //---------------------------------------------------------------------------- | ||
| 1690 | |||
| 1691 | //============================================================================ | ||
| 1692 | /// @brief Undelete a recording on the backend. | ||
| 1693 | /// | ||
| 1694 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording to undelete. | ||
| 1695 | /// @return @ref PVR_ERROR_NO_ERROR if the recording has been undeleted successfully. | ||
| 1696 | /// | ||
| 1697 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordingsUndelete "supportsRecordingsUndelete" | ||
| 1698 | /// is set to true. | ||
| 1699 | /// | ||
| 1700 | virtual PVR_ERROR UndeleteRecording(const kodi::addon::PVRRecording& recording) | ||
| 1701 | { | ||
| 1702 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1703 | } | ||
| 1704 | //---------------------------------------------------------------------------- | ||
| 1705 | |||
| 1706 | //============================================================================ | ||
| 1707 | /// @brief Delete all recordings permanent which in the deleted folder on the backend. | ||
| 1708 | /// | ||
| 1709 | /// @return @ref PVR_ERROR_NO_ERROR if the recordings has been deleted successfully. | ||
| 1710 | /// | ||
| 1711 | virtual PVR_ERROR DeleteAllRecordingsFromTrash() { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 1712 | //---------------------------------------------------------------------------- | ||
| 1713 | |||
| 1714 | //============================================================================ | ||
| 1715 | /// @brief Rename a recording on the backend. | ||
| 1716 | /// | ||
| 1717 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 1718 | /// to rename, containing the new name. | ||
| 1719 | /// @return @ref PVR_ERROR_NO_ERROR if the recording has been renamed successfully. | ||
| 1720 | /// | ||
| 1721 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" | ||
| 1722 | /// is set to true. | ||
| 1723 | /// | ||
| 1724 | virtual PVR_ERROR RenameRecording(const kodi::addon::PVRRecording& recording) | ||
| 1725 | { | ||
| 1726 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1727 | } | ||
| 1728 | //---------------------------------------------------------------------------- | ||
| 1729 | |||
| 1730 | //============================================================================ | ||
| 1731 | /// @brief Set the lifetime of a recording on the backend. | ||
| 1732 | /// | ||
| 1733 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 1734 | /// to change the lifetime for. recording.iLifetime | ||
| 1735 | /// contains the new lieftime value. | ||
| 1736 | /// @return @ref PVR_ERROR_NO_ERROR if the recording's lifetime has been set | ||
| 1737 | /// successfully. | ||
| 1738 | /// | ||
| 1739 | /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingsLifetimeChange "supportsRecordingsLifetimeChange" | ||
| 1740 | /// is set to true. | ||
| 1741 | /// | ||
| 1742 | virtual PVR_ERROR SetRecordingLifetime(const kodi::addon::PVRRecording& recording) | ||
| 1743 | { | ||
| 1744 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1745 | } | ||
| 1746 | //---------------------------------------------------------------------------- | ||
| 1747 | |||
| 1748 | //============================================================================ | ||
| 1749 | /// @brief Set the play count of a recording on the backend. | ||
| 1750 | /// | ||
| 1751 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 1752 | /// to change the play count. | ||
| 1753 | /// @param[in] count Play count. | ||
| 1754 | /// @return @ref PVR_ERROR_NO_ERROR if the recording's play count has been set | ||
| 1755 | /// successfully. | ||
| 1756 | /// | ||
| 1757 | /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingPlayCount "supportsRecordingPlayCount" | ||
| 1758 | /// is set to true. | ||
| 1759 | /// | ||
| 1760 | virtual PVR_ERROR SetRecordingPlayCount(const kodi::addon::PVRRecording& recording, int count) | ||
| 1761 | { | ||
| 1762 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1763 | } | ||
| 1764 | //---------------------------------------------------------------------------- | ||
| 1765 | |||
| 1766 | //============================================================================ | ||
| 1767 | /// @brief Set the last watched position of a recording on the backend. | ||
| 1768 | /// | ||
| 1769 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording. | ||
| 1770 | /// @param[in] lastplayedposition The last watched position in seconds | ||
| 1771 | /// @return @ref PVR_ERROR_NO_ERROR if the position has been stored successfully. | ||
| 1772 | /// | ||
| 1773 | /// @remarks Required if @ref PVRCapabilities::SetSupportsLastPlayedPosition "supportsLastPlayedPosition" | ||
| 1774 | /// is set to true. | ||
| 1775 | /// | ||
| 1776 | virtual PVR_ERROR SetRecordingLastPlayedPosition(const kodi::addon::PVRRecording& recording, | ||
| 1777 | int lastplayedposition) | ||
| 1778 | { | ||
| 1779 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1780 | } | ||
| 1781 | //---------------------------------------------------------------------------- | ||
| 1782 | |||
| 1783 | //============================================================================ | ||
| 1784 | /// @brief Retrieve the last watched position of a recording on the backend. | ||
| 1785 | /// | ||
| 1786 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording. | ||
| 1787 | /// @param[out] position The last watched position in seconds | ||
| 1788 | /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully. | ||
| 1789 | /// | ||
| 1790 | /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingPlayCount "supportsRecordingPlayCount" | ||
| 1791 | /// is set to true. | ||
| 1792 | /// | ||
| 1793 | virtual PVR_ERROR GetRecordingLastPlayedPosition(const kodi::addon::PVRRecording& recording, | ||
| 1794 | int& position) | ||
| 1795 | { | ||
| 1796 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1797 | } | ||
| 1798 | //---------------------------------------------------------------------------- | ||
| 1799 | |||
| 1800 | //============================================================================ | ||
| 1801 | /// @brief Retrieve the edit decision list (EDL) of a recording on the backend. | ||
| 1802 | /// | ||
| 1803 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording. | ||
| 1804 | /// @param[out] edl The function has to write the EDL into this array. | ||
| 1805 | /// @return @ref PVR_ERROR_NO_ERROR if the EDL was successfully read or no EDL exists. | ||
| 1806 | /// | ||
| 1807 | /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingEdl "supportsRecordingEdl" | ||
| 1808 | /// is set to true. | ||
| 1809 | /// | ||
| 1810 | /// -------------------------------------------------------------------------- | ||
| 1811 | /// | ||
| 1812 | /// @copydetails cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help | ||
| 1813 | /// | ||
| 1814 | virtual PVR_ERROR GetRecordingEdl(const kodi::addon::PVRRecording& recording, | ||
| 1815 | std::vector<kodi::addon::PVREDLEntry>& edl) | ||
| 1816 | { | ||
| 1817 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1818 | } | ||
| 1819 | //---------------------------------------------------------------------------- | ||
| 1820 | |||
| 1821 | //============================================================================ | ||
| 1822 | /// @brief Retrieve the size of a recording on the backend. | ||
| 1823 | /// | ||
| 1824 | /// @param[in] recording The recording to get the size in bytes for. | ||
| 1825 | /// @param[out] size The size in bytes of the recording | ||
| 1826 | /// @return @ref PVR_ERROR_NO_ERROR if the recording's size has been set successfully. | ||
| 1827 | /// | ||
| 1828 | /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingSize "supportsRecordingSize" | ||
| 1829 | /// is set to true. | ||
| 1830 | /// | ||
| 1831 | virtual PVR_ERROR GetRecordingSize(const kodi::addon::PVRRecording& recording, int64_t& size) | ||
| 1832 | { | ||
| 1833 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1834 | } | ||
| 1835 | //---------------------------------------------------------------------------- | ||
| 1836 | |||
| 1837 | //============================================================================ | ||
| 1838 | /// @brief Get the stream properties for a recording from the backend. | ||
| 1839 | /// | ||
| 1840 | /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 1841 | /// to get the stream properties for. | ||
| 1842 | /// @param[out] properties The properties required to play the stream. | ||
| 1843 | /// @return @ref PVR_ERROR_NO_ERROR if the stream is available. | ||
| 1844 | /// | ||
| 1845 | /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" | ||
| 1846 | /// is set to true and the add-on does not implement recording stream functions | ||
| 1847 | /// (@ref OpenRecordedStream, ...).\n | ||
| 1848 | /// In this case your implementation must fill the property @ref PVR_STREAM_PROPERTY_STREAMURL | ||
| 1849 | /// with the URL Kodi should resolve to playback the recording. | ||
| 1850 | /// | ||
| 1851 | /// @note The value directly related to inputstream must always begin with the | ||
| 1852 | /// name of the associated add-on, e.g. <b>`"inputstream.adaptive.manifest_update_parameter"`</b>. | ||
| 1853 | /// | ||
| 1854 | /// | ||
| 1855 | ///--------------------------------------------------------------------------- | ||
| 1856 | /// | ||
| 1857 | /// **Example:** | ||
| 1858 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 1859 | /// ... | ||
| 1860 | /// PVR_ERROR CMyPVRInstance::GetRecordingStreamProperties(const kodi::addon::PVRRecording& recording, | ||
| 1861 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 1862 | /// { | ||
| 1863 | /// ... | ||
| 1864 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive"); | ||
| 1865 | /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd"); | ||
| 1866 | /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full"); | ||
| 1867 | /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash"); | ||
| 1868 | /// return PVR_ERROR_NO_ERROR; | ||
| 1869 | /// } | ||
| 1870 | /// ... | ||
| 1871 | /// ~~~~~~~~~~~~~ | ||
| 1872 | /// | ||
| 1873 | virtual PVR_ERROR GetRecordingStreamProperties( | ||
| 1874 | const kodi::addon::PVRRecording& recording, | ||
| 1875 | std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 1876 | { | ||
| 1877 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1878 | } | ||
| 1879 | //---------------------------------------------------------------------------- | ||
| 1880 | |||
| 1881 | //========================================================================== | ||
| 1882 | /// @brief Call one of the recording related menu hooks (if supported). | ||
| 1883 | /// | ||
| 1884 | /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have to be added in | ||
| 1885 | /// `constructor()`, by calling @ref AddMenuHook() on the callback. | ||
| 1886 | /// | ||
| 1887 | /// @param[in] menuhook The hook to call. | ||
| 1888 | /// @param[in] item The selected recording item for which the hook was called. | ||
| 1889 | /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully. | ||
| 1890 | /// | ||
| 1891 | /// -------------------------------------------------------------------------- | ||
| 1892 | /// | ||
| 1893 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 1894 | /// | ||
| 1895 | virtual PVR_ERROR CallRecordingMenuHook(const kodi::addon::PVRMenuhook& menuhook, | ||
| 1896 | const kodi::addon::PVRRecording& item) | ||
| 1897 | { | ||
| 1898 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1899 | } | ||
| 1900 | //---------------------------------------------------------------------------- | ||
| 1901 | |||
| 1902 | //============================================================================ | ||
| 1903 | /// @brief **Callback to Kodi Function**\n | ||
| 1904 | /// Display a notification in Kodi that a recording started or stopped on the | ||
| 1905 | /// server. | ||
| 1906 | /// | ||
| 1907 | /// @param[in] recordingName The name of the recording to display | ||
| 1908 | /// @param[in] fileName The filename of the recording | ||
| 1909 | /// @param[in] on True when recording started, false when it stopped | ||
| 1910 | /// | ||
| 1911 | /// @remarks Only called from addon itself | ||
| 1912 | /// | ||
| 1913 | inline void RecordingNotification(const std::string& recordingName, | ||
| 1914 | const std::string& fileName, | ||
| 1915 | bool on) | ||
| 1916 | { | ||
| 1917 | m_instanceData->toKodi->RecordingNotification(m_instanceData->toKodi->kodiInstance, | ||
| 1918 | recordingName.c_str(), fileName.c_str(), on); | ||
| 1919 | } | ||
| 1920 | //---------------------------------------------------------------------------- | ||
| 1921 | |||
| 1922 | //============================================================================ | ||
| 1923 | /// @brief **Callback to Kodi Function**\n | ||
| 1924 | /// Request Kodi to update it's list of recordings. | ||
| 1925 | /// | ||
| 1926 | /// @remarks Only called from addon itself | ||
| 1927 | /// | ||
| 1928 | inline void TriggerRecordingUpdate() | ||
| 1929 | { | ||
| 1930 | m_instanceData->toKodi->TriggerRecordingUpdate(m_instanceData->toKodi->kodiInstance); | ||
| 1931 | } | ||
| 1932 | //---------------------------------------------------------------------------- | ||
| 1933 | |||
| 1934 | ///@} | ||
| 1935 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 1936 | |||
| 1937 | //============================================================================ | ||
| 1938 | /// @defgroup cpp_kodi_addon_pvr_Timers 6. Timers (optional) | ||
| 1939 | /// @ingroup cpp_kodi_addon_pvr | ||
| 1940 | /// @brief **PVR timer methods**\n | ||
| 1941 | /// For editing and displaying timed work, such as video recording. | ||
| 1942 | /// | ||
| 1943 | /// @remarks Only used by Kodi if @ref PVRCapabilities::SetSupportsTimers "supportsTimers" | ||
| 1944 | /// is set to true.\n\n | ||
| 1945 | /// If a timer changes after the initial import, or if a new one was added, | ||
| 1946 | /// then the add-on should call @ref TriggerTimerUpdate(). | ||
| 1947 | /// | ||
| 1948 | /// | ||
| 1949 | ///--------------------------------------------------------------------------- | ||
| 1950 | /// | ||
| 1951 | /// **Timer parts in interface:**\n | ||
| 1952 | /// Copy this to your project and extend with your parts or leave functions | ||
| 1953 | /// complete away where not used or supported. | ||
| 1954 | /// | ||
| 1955 | /// @copydetails cpp_kodi_addon_pvr_Timers_header_addon_auto_check | ||
| 1956 | /// @copydetails cpp_kodi_addon_pvr_Timers_source_addon_auto_check | ||
| 1957 | /// | ||
| 1958 | ///@{ | ||
| 1959 | |||
| 1960 | //============================================================================ | ||
| 1961 | /// @brief Retrieve the timer types supported by the backend. | ||
| 1962 | /// | ||
| 1963 | /// @param[out] types The function has to write the definition of the | ||
| 1964 | /// @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType types | ||
| 1965 | /// into this array. | ||
| 1966 | /// @return @ref PVR_ERROR_NO_ERROR if the types were successfully written to | ||
| 1967 | /// the array. | ||
| 1968 | /// | ||
| 1969 | /// @note Maximal 32 entries are allowed inside. | ||
| 1970 | /// | ||
| 1971 | /// -------------------------------------------------------------------------- | ||
| 1972 | /// | ||
| 1973 | /// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType_Help | ||
| 1974 | /// | ||
| 1975 | virtual PVR_ERROR GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& types) | ||
| 1976 | { | ||
| 1977 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 1978 | } | ||
| 1979 | //---------------------------------------------------------------------------- | ||
| 1980 | |||
| 1981 | //============================================================================ | ||
| 1982 | /// @brief To get total amount of timers on the backend or -1 on error. | ||
| 1983 | /// | ||
| 1984 | /// @param[out] amount The total amount of timers on the backend | ||
| 1985 | /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully. | ||
| 1986 | /// | ||
| 1987 | /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers" | ||
| 1988 | /// is set to true. | ||
| 1989 | /// | ||
| 1990 | virtual PVR_ERROR GetTimersAmount(int& amount) { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 1991 | //---------------------------------------------------------------------------- | ||
| 1992 | |||
| 1993 | //============================================================================ | ||
| 1994 | /// @brief Request the list of all timers from the backend if supported. | ||
| 1995 | /// | ||
| 1996 | /// @param[out] results List of available timers with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer | ||
| 1997 | /// becomes transferred with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimersResultSet | ||
| 1998 | /// and given to Kodi | ||
| 1999 | /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 2000 | /// | ||
| 2001 | /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers" | ||
| 2002 | /// is set to true. | ||
| 2003 | /// | ||
| 2004 | /// -------------------------------------------------------------------------- | ||
| 2005 | /// | ||
| 2006 | /// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimer_Help | ||
| 2007 | /// | ||
| 2008 | /// | ||
| 2009 | ///--------------------------------------------------------------------------- | ||
| 2010 | /// | ||
| 2011 | /// **Example:** | ||
| 2012 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 2013 | /// ... | ||
| 2014 | /// PVR_ERROR CMyPVRInstance::GetTimers(kodi::addon::PVRTimersResultSet& results) | ||
| 2015 | /// { | ||
| 2016 | /// // Minimal demo example, in reality bigger and loop to transfer all | ||
| 2017 | /// kodi::addon::PVRTimer timer; | ||
| 2018 | /// timer.SetClientIndex(123); | ||
| 2019 | /// timer.SetState(PVR_TIMER_STATE_SCHEDULED); | ||
| 2020 | /// timer.SetTitle("My timer name"); | ||
| 2021 | /// ... | ||
| 2022 | /// | ||
| 2023 | /// // Give it now to Kodi | ||
| 2024 | /// results.Add(timer); | ||
| 2025 | /// return PVR_ERROR_NO_ERROR; | ||
| 2026 | /// } | ||
| 2027 | /// ... | ||
| 2028 | /// ~~~~~~~~~~~~~ | ||
| 2029 | /// | ||
| 2030 | virtual PVR_ERROR GetTimers(kodi::addon::PVRTimersResultSet& results) | ||
| 2031 | { | ||
| 2032 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2033 | } | ||
| 2034 | //---------------------------------------------------------------------------- | ||
| 2035 | |||
| 2036 | //============================================================================ | ||
| 2037 | /// @brief Add a timer on the backend. | ||
| 2038 | /// | ||
| 2039 | /// @param[in] timer The timer to add. | ||
| 2040 | /// @return @ref PVR_ERROR_NO_ERROR if the timer has been added successfully. | ||
| 2041 | /// | ||
| 2042 | /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers" | ||
| 2043 | /// is set to true. | ||
| 2044 | /// | ||
| 2045 | virtual PVR_ERROR AddTimer(const kodi::addon::PVRTimer& timer) | ||
| 2046 | { | ||
| 2047 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2048 | } | ||
| 2049 | //---------------------------------------------------------------------------- | ||
| 2050 | |||
| 2051 | //============================================================================ | ||
| 2052 | /// @brief Delete a timer on the backend. | ||
| 2053 | /// | ||
| 2054 | /// @param[in] timer The timer to delete. | ||
| 2055 | /// @param[in] forceDelete Set to true to delete a timer that is currently | ||
| 2056 | /// recording a program. | ||
| 2057 | /// @return @ref PVR_ERROR_NO_ERROR if the timer has been deleted successfully. | ||
| 2058 | /// | ||
| 2059 | /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers" | ||
| 2060 | /// is set to true. | ||
| 2061 | /// | ||
| 2062 | virtual PVR_ERROR DeleteTimer(const kodi::addon::PVRTimer& timer, bool forceDelete) | ||
| 2063 | { | ||
| 2064 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2065 | } | ||
| 2066 | //---------------------------------------------------------------------------- | ||
| 2067 | |||
| 2068 | //============================================================================ | ||
| 2069 | /// @brief Update the timer information on the backend. | ||
| 2070 | /// | ||
| 2071 | /// @param[in] timer The timer to update. | ||
| 2072 | /// @return @ref PVR_ERROR_NO_ERROR if the timer has been updated successfully. | ||
| 2073 | /// | ||
| 2074 | /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers" | ||
| 2075 | /// is set to true. | ||
| 2076 | /// | ||
| 2077 | virtual PVR_ERROR UpdateTimer(const kodi::addon::PVRTimer& timer) | ||
| 2078 | { | ||
| 2079 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2080 | } | ||
| 2081 | //---------------------------------------------------------------------------- | ||
| 2082 | |||
| 2083 | //============================================================================ | ||
| 2084 | /// @brief Call one of the timer related menu hooks (if supported). | ||
| 2085 | /// | ||
| 2086 | /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have | ||
| 2087 | /// to be added in `constructor()`, by calling @ref AddMenuHook() on the | ||
| 2088 | /// callback. | ||
| 2089 | /// | ||
| 2090 | /// @param[in] menuhook The hook to call. | ||
| 2091 | /// @param[in] item The selected timer item for which the hook was called. | ||
| 2092 | /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully. | ||
| 2093 | /// | ||
| 2094 | /// -------------------------------------------------------------------------- | ||
| 2095 | /// | ||
| 2096 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 2097 | /// | ||
| 2098 | virtual PVR_ERROR CallTimerMenuHook(const kodi::addon::PVRMenuhook& menuhook, | ||
| 2099 | const kodi::addon::PVRTimer& item) | ||
| 2100 | { | ||
| 2101 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2102 | } | ||
| 2103 | //---------------------------------------------------------------------------- | ||
| 2104 | |||
| 2105 | //============================================================================ | ||
| 2106 | /// @brief **Callback to Kodi Function**\n | ||
| 2107 | /// Request Kodi to update it's list of timers. | ||
| 2108 | /// | ||
| 2109 | /// @remarks Only called from addon itself | ||
| 2110 | /// | ||
| 2111 | inline void TriggerTimerUpdate() | ||
| 2112 | { | ||
| 2113 | m_instanceData->toKodi->TriggerTimerUpdate(m_instanceData->toKodi->kodiInstance); | ||
| 2114 | } | ||
| 2115 | //---------------------------------------------------------------------------- | ||
| 2116 | |||
| 2117 | ///@} | ||
| 2118 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2119 | |||
| 2120 | //============================================================================ | ||
| 2121 | /// @defgroup cpp_kodi_addon_pvr_PowerManagement 7. Power management events (optional) | ||
| 2122 | /// @ingroup cpp_kodi_addon_pvr | ||
| 2123 | /// @brief **Used to notify the pvr addon for power management events**\n | ||
| 2124 | /// Used to allow any energy savings. | ||
| 2125 | /// | ||
| 2126 | /// | ||
| 2127 | ///--------------------------------------------------------------------------- | ||
| 2128 | /// | ||
| 2129 | /// **Power management events in interface:**\n | ||
| 2130 | /// Copy this to your project and extend with your parts or leave functions | ||
| 2131 | /// complete away where not used or supported. | ||
| 2132 | /// | ||
| 2133 | /// @copydetails cpp_kodi_addon_pvr_PowerManagement_header_addon_auto_check | ||
| 2134 | /// @copydetails cpp_kodi_addon_pvr_PowerManagement_source_addon_auto_check | ||
| 2135 | /// | ||
| 2136 | ///@{ | ||
| 2137 | |||
| 2138 | //============================================================================ | ||
| 2139 | /// @brief To notify addon about system sleep | ||
| 2140 | /// | ||
| 2141 | /// @return @ref PVR_ERROR_NO_ERROR If successfully done. | ||
| 2142 | /// | ||
| 2143 | virtual PVR_ERROR OnSystemSleep() { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 2144 | //---------------------------------------------------------------------------- | ||
| 2145 | |||
| 2146 | //============================================================================ | ||
| 2147 | /// @brief To notify addon about system wake up | ||
| 2148 | /// | ||
| 2149 | /// @return @ref PVR_ERROR_NO_ERROR If successfully done. | ||
| 2150 | /// | ||
| 2151 | virtual PVR_ERROR OnSystemWake() { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 2152 | //---------------------------------------------------------------------------- | ||
| 2153 | |||
| 2154 | //============================================================================ | ||
| 2155 | /// @brief To notify addon power saving on system is activated | ||
| 2156 | /// | ||
| 2157 | /// @return @ref PVR_ERROR_NO_ERROR If successfully done. | ||
| 2158 | /// | ||
| 2159 | virtual PVR_ERROR OnPowerSavingActivated() { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 2160 | //---------------------------------------------------------------------------- | ||
| 2161 | |||
| 2162 | //============================================================================ | ||
| 2163 | /// @brief To notify addon power saving on system is deactivated | ||
| 2164 | /// | ||
| 2165 | /// @return @ref PVR_ERROR_NO_ERROR If successfully done. | ||
| 2166 | /// | ||
| 2167 | virtual PVR_ERROR OnPowerSavingDeactivated() { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 2168 | //---------------------------------------------------------------------------- | ||
| 2169 | |||
| 2170 | ///@} | ||
| 2171 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2172 | |||
| 2173 | //============================================================================ | ||
| 2174 | /// @defgroup cpp_kodi_addon_pvr_Streams 8. Inputstream | ||
| 2175 | /// @ingroup cpp_kodi_addon_pvr | ||
| 2176 | /// @brief **PVR Inputstream**\n | ||
| 2177 | /// This includes functions that are used in the PVR inputstream. | ||
| 2178 | /// | ||
| 2179 | /// @warning The parts here will be removed in the future and replaced by the | ||
| 2180 | /// separate @ref cpp_kodi_addon_inputstream "inputstream addon instance". | ||
| 2181 | /// If there is already a possibility, new addons should do it via the | ||
| 2182 | /// inputstream instance. | ||
| 2183 | /// | ||
| 2184 | ///@{ | ||
| 2185 | |||
| 2186 | //============================================================================ | ||
| 2187 | /// @defgroup cpp_kodi_addon_pvr_Streams_TV 8.1. TV stream | ||
| 2188 | /// @ingroup cpp_kodi_addon_pvr_Streams | ||
| 2189 | /// @brief **PVR TV stream**\n | ||
| 2190 | /// Stream processing regarding live TV. | ||
| 2191 | /// | ||
| 2192 | /// | ||
| 2193 | ///--------------------------------------------------------------------------- | ||
| 2194 | /// | ||
| 2195 | /// **TV stream parts in interface:**\n | ||
| 2196 | /// Copy this to your project and extend with your parts or leave functions | ||
| 2197 | /// complete away where not used or supported. | ||
| 2198 | /// | ||
| 2199 | /// @copydetails cpp_kodi_addon_pvr_Streams_TV_header_addon_auto_check | ||
| 2200 | /// @copydetails cpp_kodi_addon_pvr_Streams_TV_source_addon_auto_check | ||
| 2201 | /// | ||
| 2202 | ///@{ | ||
| 2203 | |||
| 2204 | //============================================================================ | ||
| 2205 | /// @brief Open a live stream on the backend. | ||
| 2206 | /// | ||
| 2207 | /// @param[in] channel The channel to stream. | ||
| 2208 | /// @return True if the stream has been opened successfully, false otherwise. | ||
| 2209 | /// | ||
| 2210 | /// -------------------------------------------------------------------------- | ||
| 2211 | /// | ||
| 2212 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help | ||
| 2213 | /// | ||
| 2214 | /// | ||
| 2215 | /// -------------------------------------------------------------------------- | ||
| 2216 | /// | ||
| 2217 | /// @remarks Required if @ref PVRCapabilities::SetHandlesInputStream() or | ||
| 2218 | /// @ref PVRCapabilities::SetHandlesDemuxing() is set to true. | ||
| 2219 | /// @ref CloseLiveStream() will always be called by Kodi prior to calling this | ||
| 2220 | /// function. | ||
| 2221 | /// | ||
| 2222 | virtual bool OpenLiveStream(const kodi::addon::PVRChannel& channel) { return false; } | ||
| 2223 | //---------------------------------------------------------------------------- | ||
| 2224 | |||
| 2225 | //============================================================================ | ||
| 2226 | /// @brief Close an open live stream. | ||
| 2227 | /// | ||
| 2228 | /// @remarks Required if @ref PVRCapabilities::SetHandlesInputStream() or | ||
| 2229 | /// @ref PVRCapabilities::SetHandlesDemuxing() is set to true. | ||
| 2230 | /// | ||
| 2231 | virtual void CloseLiveStream() {} | ||
| 2232 | //---------------------------------------------------------------------------- | ||
| 2233 | |||
| 2234 | //============================================================================ | ||
| 2235 | /// @brief Read from an open live stream. | ||
| 2236 | /// | ||
| 2237 | /// @param[in] pBuffer The buffer to store the data in. | ||
| 2238 | /// @param[in] iBufferSize The amount of bytes to read. | ||
| 2239 | /// @return The amount of bytes that were actually read from the stream. | ||
| 2240 | /// | ||
| 2241 | /// @remarks Required if @ref PVRCapabilities::SetHandlesInputStream() is set | ||
| 2242 | /// to true. | ||
| 2243 | /// | ||
| 2244 | virtual int ReadLiveStream(unsigned char* buffer, unsigned int size) { return 0; } | ||
| 2245 | //---------------------------------------------------------------------------- | ||
| 2246 | |||
| 2247 | //============================================================================ | ||
| 2248 | /// @brief Seek in a live stream on a backend that supports timeshifting. | ||
| 2249 | /// | ||
| 2250 | /// @param[in] position The position to seek to. | ||
| 2251 | /// @param[in] whence [optional] offset relative to | ||
| 2252 | /// You can set the value of whence to one of three things: | ||
| 2253 | /// | Value | int | Description | | ||
| 2254 | /// |:--------:|:---:|:----------------------------------------------------| | ||
| 2255 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 2256 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 2257 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 2258 | /// | ||
| 2259 | /// @return The new position. | ||
| 2260 | /// | ||
| 2261 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetHandlesInputStream() | ||
| 2262 | /// is set to true. | ||
| 2263 | /// | ||
| 2264 | virtual int64_t SeekLiveStream(int64_t position, int whence) { return 0; } | ||
| 2265 | //---------------------------------------------------------------------------- | ||
| 2266 | |||
| 2267 | //============================================================================ | ||
| 2268 | /// @brief Obtain the length of a live stream. | ||
| 2269 | /// | ||
| 2270 | /// @return The total length of the stream that's currently being read. | ||
| 2271 | /// | ||
| 2272 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetHandlesInputStream() | ||
| 2273 | /// is set to true. | ||
| 2274 | /// | ||
| 2275 | virtual int64_t LengthLiveStream() { return 0; } | ||
| 2276 | //---------------------------------------------------------------------------- | ||
| 2277 | |||
| 2278 | //============================================================================ | ||
| 2279 | /// @defgroup cpp_kodi_addon_pvr_Streams_TV_Demux 8.1.1. Stream demuxing | ||
| 2280 | /// @ingroup cpp_kodi_addon_pvr_Streams_TV | ||
| 2281 | /// @brief **PVR stream demuxing**\n | ||
| 2282 | /// Read TV streams with own demux within addon. | ||
| 2283 | /// | ||
| 2284 | /// This is only on Live TV streams and only if @ref PVRCapabilities::SetHandlesDemuxing() | ||
| 2285 | /// has been set to "true". | ||
| 2286 | /// | ||
| 2287 | /// | ||
| 2288 | ///--------------------------------------------------------------------------- | ||
| 2289 | /// | ||
| 2290 | /// **Stream demuxing parts in interface:**\n | ||
| 2291 | /// Copy this to your project and extend with your parts or leave functions | ||
| 2292 | /// complete away where not used or supported. | ||
| 2293 | /// | ||
| 2294 | /// @copydetails cpp_kodi_addon_pvr_Streams_TV_Demux_header_addon_auto_check | ||
| 2295 | /// @copydetails cpp_kodi_addon_pvr_Streams_TV_Demux_source_addon_auto_check | ||
| 2296 | /// | ||
| 2297 | ///@{ | ||
| 2298 | |||
| 2299 | //============================================================================ | ||
| 2300 | /// @brief Get the stream properties of the stream that's currently being read. | ||
| 2301 | /// | ||
| 2302 | /// @param[in] properties The properties of the currently playing stream. | ||
| 2303 | /// @return @ref PVR_ERROR_NO_ERROR if the properties have been fetched successfully. | ||
| 2304 | /// | ||
| 2305 | /// @remarks Required, and only used if addon has its own demuxer. | ||
| 2306 | /// | ||
| 2307 | virtual PVR_ERROR GetStreamProperties(std::vector<kodi::addon::PVRStreamProperties>& properties) | ||
| 2308 | { | ||
| 2309 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2310 | } | ||
| 2311 | //---------------------------------------------------------------------------- | ||
| 2312 | |||
| 2313 | //============================================================================ | ||
| 2314 | /// @brief Read the next packet from the demultiplexer, if there is one. | ||
| 2315 | /// | ||
| 2316 | /// @return The next packet. | ||
| 2317 | /// If there is no next packet, then the add-on should return the packet | ||
| 2318 | /// created by calling @ref AllocateDemuxPacket(0) on the callback. | ||
| 2319 | /// If the stream changed and Kodi's player needs to be reinitialised, then, | ||
| 2320 | /// the add-on should call @ref AllocateDemuxPacket(0) on the callback, and set | ||
| 2321 | /// the streamid to @ref DMX_SPECIALID_STREAMCHANGE and return the value. | ||
| 2322 | /// The add-on should return `nullptr` if an error occurred. | ||
| 2323 | /// | ||
| 2324 | /// @remarks Required, and only used if addon has its own demuxer. | ||
| 2325 | /// Return `nullptr` if this add-on won't provide this function. | ||
| 2326 | /// | ||
| 2327 | virtual DemuxPacket* DemuxRead() { return nullptr; } | ||
| 2328 | //---------------------------------------------------------------------------- | ||
| 2329 | |||
| 2330 | //============================================================================ | ||
| 2331 | /// @brief Reset the demultiplexer in the add-on. | ||
| 2332 | /// | ||
| 2333 | /// @remarks Required, and only used if addon has its own demuxer. | ||
| 2334 | /// | ||
| 2335 | virtual void DemuxReset() {} | ||
| 2336 | //---------------------------------------------------------------------------- | ||
| 2337 | |||
| 2338 | //============================================================================ | ||
| 2339 | /// @brief Abort the demultiplexer thread in the add-on. | ||
| 2340 | /// | ||
| 2341 | /// @remarks Required, and only used if addon has its own demuxer. | ||
| 2342 | /// | ||
| 2343 | virtual void DemuxAbort() {} | ||
| 2344 | //---------------------------------------------------------------------------- | ||
| 2345 | |||
| 2346 | //============================================================================ | ||
| 2347 | /// @brief Flush all data that's currently in the demultiplexer buffer in the | ||
| 2348 | /// add-on. | ||
| 2349 | /// | ||
| 2350 | /// @remarks Required, and only used if addon has its own demuxer. | ||
| 2351 | /// | ||
| 2352 | virtual void DemuxFlush() {} | ||
| 2353 | //---------------------------------------------------------------------------- | ||
| 2354 | |||
| 2355 | //============================================================================ | ||
| 2356 | /// @brief Notify the pvr addon/demuxer that Kodi wishes to change playback | ||
| 2357 | /// speed. | ||
| 2358 | /// | ||
| 2359 | /// @param[in] speed The requested playback speed | ||
| 2360 | /// | ||
| 2361 | /// @remarks Optional, and only used if addon has its own demuxer. | ||
| 2362 | /// | ||
| 2363 | virtual void SetSpeed(int speed) {} | ||
| 2364 | //---------------------------------------------------------------------------- | ||
| 2365 | |||
| 2366 | //============================================================================ | ||
| 2367 | /// @brief Notify the pvr addon/demuxer that Kodi wishes to fill demux queue. | ||
| 2368 | /// | ||
| 2369 | /// @param[in] mode The requested filling mode | ||
| 2370 | /// | ||
| 2371 | /// @remarks Optional, and only used if addon has its own demuxer. | ||
| 2372 | /// | ||
| 2373 | virtual void FillBuffer(bool mode) {} | ||
| 2374 | //---------------------------------------------------------------------------- | ||
| 2375 | |||
| 2376 | //============================================================================ | ||
| 2377 | /// @brief Notify the pvr addon/demuxer that Kodi wishes to seek the stream by | ||
| 2378 | /// time. | ||
| 2379 | /// | ||
| 2380 | /// @param[in] time The absolute time since stream start | ||
| 2381 | /// @param[in] backwards True to seek to keyframe BEFORE time, else AFTER | ||
| 2382 | /// @param[in] startpts can be updated to point to where display should start | ||
| 2383 | /// @return True if the seek operation was possible | ||
| 2384 | /// | ||
| 2385 | /// @remarks Optional, and only used if addon has its own demuxer. | ||
| 2386 | /// Return False if this add-on won't provide this function. | ||
| 2387 | /// | ||
| 2388 | virtual bool SeekTime(double time, bool backwards, double& startpts) { return false; } | ||
| 2389 | //---------------------------------------------------------------------------- | ||
| 2390 | |||
| 2391 | //============================================================================ | ||
| 2392 | /// @brief **Callback to Kodi Function**\n | ||
| 2393 | /// Get the codec id used by Kodi. | ||
| 2394 | /// | ||
| 2395 | /// @param[in] codecName The name of the codec | ||
| 2396 | /// @return The codec_id, or a codec_id with 0 values when not supported | ||
| 2397 | /// | ||
| 2398 | /// @remarks Only called from addon itself | ||
| 2399 | /// | ||
| 2400 | inline PVRCodec GetCodecByName(const std::string& codecName) const | ||
| 2401 | { | ||
| 2402 | return PVRCodec(m_instanceData->toKodi->GetCodecByName(m_instanceData->toKodi->kodiInstance, | ||
| 2403 | codecName.c_str())); | ||
| 2404 | } | ||
| 2405 | //---------------------------------------------------------------------------- | ||
| 2406 | |||
| 2407 | //============================================================================ | ||
| 2408 | /// @brief **Callback to Kodi Function**\n | ||
| 2409 | /// Allocate a demux packet. Free with @ref FreeDemuxPacket(). | ||
| 2410 | /// | ||
| 2411 | /// @param[in] iDataSize The size of the data that will go into the packet | ||
| 2412 | /// @return The allocated packet | ||
| 2413 | /// | ||
| 2414 | /// @remarks Only called from addon itself | ||
| 2415 | /// | ||
| 2416 | inline DemuxPacket* AllocateDemuxPacket(int iDataSize) | ||
| 2417 | { | ||
| 2418 | return m_instanceData->toKodi->AllocateDemuxPacket(m_instanceData->toKodi->kodiInstance, | ||
| 2419 | iDataSize); | ||
| 2420 | } | ||
| 2421 | //---------------------------------------------------------------------------- | ||
| 2422 | |||
| 2423 | //============================================================================ | ||
| 2424 | /// @brief **Callback to Kodi Function**\n | ||
| 2425 | /// Free a packet that was allocated with @ref AllocateDemuxPacket(). | ||
| 2426 | /// | ||
| 2427 | /// @param[in] pPacket The packet to free | ||
| 2428 | /// | ||
| 2429 | /// @remarks Only called from addon itself. | ||
| 2430 | /// | ||
| 2431 | inline void FreeDemuxPacket(DemuxPacket* pPacket) | ||
| 2432 | { | ||
| 2433 | m_instanceData->toKodi->FreeDemuxPacket(m_instanceData->toKodi->kodiInstance, pPacket); | ||
| 2434 | } | ||
| 2435 | //---------------------------------------------------------------------------- | ||
| 2436 | ///@} | ||
| 2437 | |||
| 2438 | ///@} | ||
| 2439 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2440 | |||
| 2441 | //============================================================================ | ||
| 2442 | /// @defgroup cpp_kodi_addon_pvr_Streams_Recording 8.2. Recording stream | ||
| 2443 | /// @ingroup cpp_kodi_addon_pvr_Streams | ||
| 2444 | /// @brief **PVR Recording stream**\n | ||
| 2445 | /// Stream processing regarding recordings. | ||
| 2446 | /// | ||
| 2447 | /// @note Demuxing is not possible with the recordings. | ||
| 2448 | /// | ||
| 2449 | /// | ||
| 2450 | ///--------------------------------------------------------------------------- | ||
| 2451 | /// | ||
| 2452 | /// **Recording stream parts in interface:**\n | ||
| 2453 | /// Copy this to your project and extend with your parts or leave functions | ||
| 2454 | /// complete away where not used or supported. | ||
| 2455 | /// | ||
| 2456 | /// @copydetails cpp_kodi_addon_pvr_Streams_Recording_header_addon_auto_check | ||
| 2457 | /// @copydetails cpp_kodi_addon_pvr_Streams_Recording_source_addon_auto_check | ||
| 2458 | /// | ||
| 2459 | ///@{ | ||
| 2460 | |||
| 2461 | //============================================================================ | ||
| 2462 | /// @brief Open a stream to a recording on the backend. | ||
| 2463 | /// | ||
| 2464 | /// @param[in] recording The recording to open. | ||
| 2465 | /// @return True if the stream has been opened successfully, false otherwise. | ||
| 2466 | /// | ||
| 2467 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings() | ||
| 2468 | /// is set to true. @ref CloseRecordedStream() will always be called by Kodi | ||
| 2469 | /// prior to calling this function. | ||
| 2470 | /// | ||
| 2471 | virtual bool OpenRecordedStream(const kodi::addon::PVRRecording& recording) { return false; } | ||
| 2472 | //---------------------------------------------------------------------------- | ||
| 2473 | |||
| 2474 | //============================================================================ | ||
| 2475 | /// @brief Close an open stream from a recording. | ||
| 2476 | /// | ||
| 2477 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings() | ||
| 2478 | /// is set to true. | ||
| 2479 | /// | ||
| 2480 | virtual void CloseRecordedStream() {} | ||
| 2481 | //---------------------------------------------------------------------------- | ||
| 2482 | |||
| 2483 | //============================================================================ | ||
| 2484 | /// @brief Read from a recording. | ||
| 2485 | /// | ||
| 2486 | /// @param[in] buffer The buffer to store the data in. | ||
| 2487 | /// @param[in] size The amount of bytes to read. | ||
| 2488 | /// @return The amount of bytes that were actually read from the stream. | ||
| 2489 | /// | ||
| 2490 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings() | ||
| 2491 | /// is set to true. | ||
| 2492 | /// | ||
| 2493 | virtual int ReadRecordedStream(unsigned char* buffer, unsigned int size) { return 0; } | ||
| 2494 | //---------------------------------------------------------------------------- | ||
| 2495 | |||
| 2496 | //============================================================================ | ||
| 2497 | /// @brief Seek in a recorded stream. | ||
| 2498 | /// | ||
| 2499 | /// @param[in] position The position to seek to. | ||
| 2500 | /// @param[in] whence [optional] offset relative to | ||
| 2501 | /// You can set the value of whence to one of three things: | ||
| 2502 | /// | Value | int | Description | | ||
| 2503 | /// |:--------:|:---:|:----------------------------------------------------| | ||
| 2504 | /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence. | ||
| 2505 | /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes." | ||
| 2506 | /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion. | ||
| 2507 | /// | ||
| 2508 | /// @return The new position. | ||
| 2509 | /// | ||
| 2510 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings() | ||
| 2511 | /// is set to true. | ||
| 2512 | /// | ||
| 2513 | virtual int64_t SeekRecordedStream(int64_t position, int whence) { return 0; } | ||
| 2514 | //---------------------------------------------------------------------------- | ||
| 2515 | |||
| 2516 | //============================================================================ | ||
| 2517 | /// @brief Obtain the length of a recorded stream. | ||
| 2518 | /// | ||
| 2519 | /// @return The total length of the stream that's currently being read. | ||
| 2520 | /// | ||
| 2521 | /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings() | ||
| 2522 | /// is true (=> @ref ReadRecordedStream). | ||
| 2523 | /// | ||
| 2524 | virtual int64_t LengthRecordedStream() { return 0; } | ||
| 2525 | //---------------------------------------------------------------------------- | ||
| 2526 | |||
| 2527 | ///@} | ||
| 2528 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2529 | |||
| 2530 | //============================================================================ | ||
| 2531 | /// @defgroup cpp_kodi_addon_pvr_Streams_Various 8.3. Various functions | ||
| 2532 | /// @ingroup cpp_kodi_addon_pvr_Streams | ||
| 2533 | /// @brief **Various other PVR stream related functions**\n | ||
| 2534 | /// These apply to all other groups in inputstream and are therefore declared | ||
| 2535 | /// as several. | ||
| 2536 | /// | ||
| 2537 | /// | ||
| 2538 | ///--------------------------------------------------------------------------- | ||
| 2539 | /// | ||
| 2540 | /// **Various stream parts in interface:**\n | ||
| 2541 | /// Copy this to your project and extend with your parts or leave functions | ||
| 2542 | /// complete away where not used or supported. | ||
| 2543 | /// | ||
| 2544 | /// @copydetails cpp_kodi_addon_pvr_Streams_Various_header_addon_auto_check | ||
| 2545 | /// @copydetails cpp_kodi_addon_pvr_Streams_Various_source_addon_auto_check | ||
| 2546 | /// | ||
| 2547 | ///@{ | ||
| 2548 | |||
| 2549 | //============================================================================ | ||
| 2550 | /// | ||
| 2551 | /// @brief Check if the backend support pausing the currently playing stream. | ||
| 2552 | /// | ||
| 2553 | /// This will enable/disable the pause button in Kodi based on the return | ||
| 2554 | /// value. | ||
| 2555 | /// | ||
| 2556 | /// @return false if the PVR addon/backend does not support pausing, true if | ||
| 2557 | /// possible | ||
| 2558 | /// | ||
| 2559 | virtual bool CanPauseStream() { return false; } | ||
| 2560 | //---------------------------------------------------------------------------- | ||
| 2561 | |||
| 2562 | //============================================================================ | ||
| 2563 | /// | ||
| 2564 | /// @brief Check if the backend supports seeking for the currently playing | ||
| 2565 | /// stream. | ||
| 2566 | /// | ||
| 2567 | /// This will enable/disable the rewind/forward buttons in Kodi based on the | ||
| 2568 | /// return value. | ||
| 2569 | /// | ||
| 2570 | /// @return false if the PVR addon/backend does not support seeking, true if | ||
| 2571 | /// possible | ||
| 2572 | /// | ||
| 2573 | virtual bool CanSeekStream() { return false; } | ||
| 2574 | //---------------------------------------------------------------------------- | ||
| 2575 | |||
| 2576 | //============================================================================ | ||
| 2577 | /// | ||
| 2578 | /// @brief Notify the pvr addon that Kodi (un)paused the currently playing | ||
| 2579 | /// stream. | ||
| 2580 | /// | ||
| 2581 | /// @param[in] paused To inform by `true` is paused and with `false` playing | ||
| 2582 | /// | ||
| 2583 | virtual void PauseStream(bool paused) {} | ||
| 2584 | //---------------------------------------------------------------------------- | ||
| 2585 | |||
| 2586 | //============================================================================ | ||
| 2587 | /// | ||
| 2588 | /// @brief Check for real-time streaming. | ||
| 2589 | /// | ||
| 2590 | /// @return true if current stream is real-time | ||
| 2591 | /// | ||
| 2592 | virtual bool IsRealTimeStream() { return false; } | ||
| 2593 | //---------------------------------------------------------------------------- | ||
| 2594 | |||
| 2595 | //============================================================================ | ||
| 2596 | /// | ||
| 2597 | /// @brief Get stream times. | ||
| 2598 | /// | ||
| 2599 | /// @param[out] times A pointer to the data to be filled by the implementation. | ||
| 2600 | /// @return @ref PVR_ERROR_NO_ERROR on success. | ||
| 2601 | /// | ||
| 2602 | virtual PVR_ERROR GetStreamTimes(kodi::addon::PVRStreamTimes& times) | ||
| 2603 | { | ||
| 2604 | return PVR_ERROR_NOT_IMPLEMENTED; | ||
| 2605 | } | ||
| 2606 | //---------------------------------------------------------------------------- | ||
| 2607 | |||
| 2608 | //============================================================================ | ||
| 2609 | /// | ||
| 2610 | /// @brief Obtain the chunk size to use when reading streams. | ||
| 2611 | /// | ||
| 2612 | /// @param[out] chunksize must be filled with the chunk size in bytes. | ||
| 2613 | /// @return @ref PVR_ERROR_NO_ERROR if the chunk size has been fetched successfully. | ||
| 2614 | /// | ||
| 2615 | /// @remarks Optional, and only used if not reading from demuxer (=> @ref DemuxRead) and | ||
| 2616 | /// @ref PVRCapabilities::SetSupportsRecordings() is true (=> @ref ReadRecordedStream) or | ||
| 2617 | /// @ref PVRCapabilities::SetHandlesInputStream() is true (=> @ref ReadLiveStream). | ||
| 2618 | /// | ||
| 2619 | virtual PVR_ERROR GetStreamReadChunkSize(int& chunksize) { return PVR_ERROR_NOT_IMPLEMENTED; } | ||
| 2620 | //---------------------------------------------------------------------------- | ||
| 2621 | |||
| 2622 | ///@} | ||
| 2623 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2624 | |||
| 2625 | private: | ||
| 2626 | void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 2627 | { | ||
| 2628 | if (instance == nullptr) | ||
| 2629 | throw std::logic_error("kodi::addon::CInstancePVRClient: Creation with empty addon " | ||
| 2630 | "structure not allowed, table must be given from Kodi!"); | ||
| 2631 | |||
| 2632 | m_instanceData = static_cast<AddonInstance_PVR*>(instance); | ||
| 2633 | m_instanceData->toAddon->addonInstance = this; | ||
| 2634 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2635 | m_instanceData->toAddon->GetCapabilities = ADDON_GetCapabilities; | ||
| 2636 | m_instanceData->toAddon->GetConnectionString = ADDON_GetConnectionString; | ||
| 2637 | m_instanceData->toAddon->GetBackendName = ADDON_GetBackendName; | ||
| 2638 | m_instanceData->toAddon->GetBackendVersion = ADDON_GetBackendVersion; | ||
| 2639 | m_instanceData->toAddon->GetBackendHostname = ADDON_GetBackendHostname; | ||
| 2640 | m_instanceData->toAddon->GetDriveSpace = ADDON_GetDriveSpace; | ||
| 2641 | m_instanceData->toAddon->CallSettingsMenuHook = ADDON_CallSettingsMenuHook; | ||
| 2642 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2643 | m_instanceData->toAddon->GetChannelsAmount = ADDON_GetChannelsAmount; | ||
| 2644 | m_instanceData->toAddon->GetChannels = ADDON_GetChannels; | ||
| 2645 | m_instanceData->toAddon->GetChannelStreamProperties = ADDON_GetChannelStreamProperties; | ||
| 2646 | m_instanceData->toAddon->GetSignalStatus = ADDON_GetSignalStatus; | ||
| 2647 | m_instanceData->toAddon->GetDescrambleInfo = ADDON_GetDescrambleInfo; | ||
| 2648 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2649 | m_instanceData->toAddon->GetChannelGroupsAmount = ADDON_GetChannelGroupsAmount; | ||
| 2650 | m_instanceData->toAddon->GetChannelGroups = ADDON_GetChannelGroups; | ||
| 2651 | m_instanceData->toAddon->GetChannelGroupMembers = ADDON_GetChannelGroupMembers; | ||
| 2652 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2653 | m_instanceData->toAddon->DeleteChannel = ADDON_DeleteChannel; | ||
| 2654 | m_instanceData->toAddon->RenameChannel = ADDON_RenameChannel; | ||
| 2655 | m_instanceData->toAddon->OpenDialogChannelSettings = ADDON_OpenDialogChannelSettings; | ||
| 2656 | m_instanceData->toAddon->OpenDialogChannelAdd = ADDON_OpenDialogChannelAdd; | ||
| 2657 | m_instanceData->toAddon->OpenDialogChannelScan = ADDON_OpenDialogChannelScan; | ||
| 2658 | m_instanceData->toAddon->CallChannelMenuHook = ADDON_CallChannelMenuHook; | ||
| 2659 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2660 | m_instanceData->toAddon->GetEPGForChannel = ADDON_GetEPGForChannel; | ||
| 2661 | m_instanceData->toAddon->IsEPGTagRecordable = ADDON_IsEPGTagRecordable; | ||
| 2662 | m_instanceData->toAddon->IsEPGTagPlayable = ADDON_IsEPGTagPlayable; | ||
| 2663 | m_instanceData->toAddon->GetEPGTagEdl = ADDON_GetEPGTagEdl; | ||
| 2664 | m_instanceData->toAddon->GetEPGTagStreamProperties = ADDON_GetEPGTagStreamProperties; | ||
| 2665 | m_instanceData->toAddon->SetEPGTimeFrame = ADDON_SetEPGTimeFrame; | ||
| 2666 | m_instanceData->toAddon->CallEPGMenuHook = ADDON_CallEPGMenuHook; | ||
| 2667 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2668 | m_instanceData->toAddon->GetRecordingsAmount = ADDON_GetRecordingsAmount; | ||
| 2669 | m_instanceData->toAddon->GetRecordings = ADDON_GetRecordings; | ||
| 2670 | m_instanceData->toAddon->DeleteRecording = ADDON_DeleteRecording; | ||
| 2671 | m_instanceData->toAddon->UndeleteRecording = ADDON_UndeleteRecording; | ||
| 2672 | m_instanceData->toAddon->DeleteAllRecordingsFromTrash = ADDON_DeleteAllRecordingsFromTrash; | ||
| 2673 | m_instanceData->toAddon->RenameRecording = ADDON_RenameRecording; | ||
| 2674 | m_instanceData->toAddon->SetRecordingLifetime = ADDON_SetRecordingLifetime; | ||
| 2675 | m_instanceData->toAddon->SetRecordingPlayCount = ADDON_SetRecordingPlayCount; | ||
| 2676 | m_instanceData->toAddon->SetRecordingLastPlayedPosition = ADDON_SetRecordingLastPlayedPosition; | ||
| 2677 | m_instanceData->toAddon->GetRecordingLastPlayedPosition = ADDON_GetRecordingLastPlayedPosition; | ||
| 2678 | m_instanceData->toAddon->GetRecordingEdl = ADDON_GetRecordingEdl; | ||
| 2679 | m_instanceData->toAddon->GetRecordingSize = ADDON_GetRecordingSize; | ||
| 2680 | m_instanceData->toAddon->GetRecordingStreamProperties = ADDON_GetRecordingStreamProperties; | ||
| 2681 | m_instanceData->toAddon->CallRecordingMenuHook = ADDON_CallRecordingMenuHook; | ||
| 2682 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2683 | m_instanceData->toAddon->GetTimerTypes = ADDON_GetTimerTypes; | ||
| 2684 | m_instanceData->toAddon->GetTimersAmount = ADDON_GetTimersAmount; | ||
| 2685 | m_instanceData->toAddon->GetTimers = ADDON_GetTimers; | ||
| 2686 | m_instanceData->toAddon->AddTimer = ADDON_AddTimer; | ||
| 2687 | m_instanceData->toAddon->DeleteTimer = ADDON_DeleteTimer; | ||
| 2688 | m_instanceData->toAddon->UpdateTimer = ADDON_UpdateTimer; | ||
| 2689 | m_instanceData->toAddon->CallTimerMenuHook = ADDON_CallTimerMenuHook; | ||
| 2690 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2691 | m_instanceData->toAddon->OnSystemSleep = ADDON_OnSystemSleep; | ||
| 2692 | m_instanceData->toAddon->OnSystemWake = ADDON_OnSystemWake; | ||
| 2693 | m_instanceData->toAddon->OnPowerSavingActivated = ADDON_OnPowerSavingActivated; | ||
| 2694 | m_instanceData->toAddon->OnPowerSavingDeactivated = ADDON_OnPowerSavingDeactivated; | ||
| 2695 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2696 | m_instanceData->toAddon->OpenLiveStream = ADDON_OpenLiveStream; | ||
| 2697 | m_instanceData->toAddon->CloseLiveStream = ADDON_CloseLiveStream; | ||
| 2698 | m_instanceData->toAddon->ReadLiveStream = ADDON_ReadLiveStream; | ||
| 2699 | m_instanceData->toAddon->SeekLiveStream = ADDON_SeekLiveStream; | ||
| 2700 | m_instanceData->toAddon->LengthLiveStream = ADDON_LengthLiveStream; | ||
| 2701 | m_instanceData->toAddon->GetStreamProperties = ADDON_GetStreamProperties; | ||
| 2702 | m_instanceData->toAddon->GetStreamReadChunkSize = ADDON_GetStreamReadChunkSize; | ||
| 2703 | m_instanceData->toAddon->IsRealTimeStream = ADDON_IsRealTimeStream; | ||
| 2704 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2705 | m_instanceData->toAddon->OpenRecordedStream = ADDON_OpenRecordedStream; | ||
| 2706 | m_instanceData->toAddon->CloseRecordedStream = ADDON_CloseRecordedStream; | ||
| 2707 | m_instanceData->toAddon->ReadRecordedStream = ADDON_ReadRecordedStream; | ||
| 2708 | m_instanceData->toAddon->SeekRecordedStream = ADDON_SeekRecordedStream; | ||
| 2709 | m_instanceData->toAddon->LengthRecordedStream = ADDON_LengthRecordedStream; | ||
| 2710 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2711 | m_instanceData->toAddon->DemuxReset = ADDON_DemuxReset; | ||
| 2712 | m_instanceData->toAddon->DemuxAbort = ADDON_DemuxAbort; | ||
| 2713 | m_instanceData->toAddon->DemuxFlush = ADDON_DemuxFlush; | ||
| 2714 | m_instanceData->toAddon->DemuxRead = ADDON_DemuxRead; | ||
| 2715 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2716 | m_instanceData->toAddon->CanPauseStream = ADDON_CanPauseStream; | ||
| 2717 | m_instanceData->toAddon->PauseStream = ADDON_PauseStream; | ||
| 2718 | m_instanceData->toAddon->CanSeekStream = ADDON_CanSeekStream; | ||
| 2719 | m_instanceData->toAddon->SeekTime = ADDON_SeekTime; | ||
| 2720 | m_instanceData->toAddon->SetSpeed = ADDON_SetSpeed; | ||
| 2721 | m_instanceData->toAddon->FillBuffer = ADDON_FillBuffer; | ||
| 2722 | m_instanceData->toAddon->GetStreamTimes = ADDON_GetStreamTimes; | ||
| 2723 | } | ||
| 2724 | |||
| 2725 | inline static PVR_ERROR ADDON_GetCapabilities(const AddonInstance_PVR* instance, | ||
| 2726 | PVR_ADDON_CAPABILITIES* capabilities) | ||
| 2727 | { | ||
| 2728 | PVRCapabilities cppCapabilities(capabilities); | ||
| 2729 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2730 | ->GetCapabilities(cppCapabilities); | ||
| 2731 | } | ||
| 2732 | |||
| 2733 | inline static PVR_ERROR ADDON_GetBackendName(const AddonInstance_PVR* instance, | ||
| 2734 | char* str, | ||
| 2735 | int memSize) | ||
| 2736 | { | ||
| 2737 | std::string backendName; | ||
| 2738 | PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2739 | ->GetBackendName(backendName); | ||
| 2740 | if (err == PVR_ERROR_NO_ERROR) | ||
| 2741 | strncpy(str, backendName.c_str(), memSize); | ||
| 2742 | return err; | ||
| 2743 | } | ||
| 2744 | |||
| 2745 | inline static PVR_ERROR ADDON_GetBackendVersion(const AddonInstance_PVR* instance, | ||
| 2746 | char* str, | ||
| 2747 | int memSize) | ||
| 2748 | { | ||
| 2749 | std::string backendVersion; | ||
| 2750 | PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2751 | ->GetBackendVersion(backendVersion); | ||
| 2752 | if (err == PVR_ERROR_NO_ERROR) | ||
| 2753 | strncpy(str, backendVersion.c_str(), memSize); | ||
| 2754 | return err; | ||
| 2755 | } | ||
| 2756 | |||
| 2757 | inline static PVR_ERROR ADDON_GetBackendHostname(const AddonInstance_PVR* instance, | ||
| 2758 | char* str, | ||
| 2759 | int memSize) | ||
| 2760 | { | ||
| 2761 | std::string backendHostname; | ||
| 2762 | PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2763 | ->GetBackendHostname(backendHostname); | ||
| 2764 | if (err == PVR_ERROR_NO_ERROR) | ||
| 2765 | strncpy(str, backendHostname.c_str(), memSize); | ||
| 2766 | return err; | ||
| 2767 | } | ||
| 2768 | |||
| 2769 | inline static PVR_ERROR ADDON_GetConnectionString(const AddonInstance_PVR* instance, | ||
| 2770 | char* str, | ||
| 2771 | int memSize) | ||
| 2772 | { | ||
| 2773 | std::string connectionString; | ||
| 2774 | PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2775 | ->GetConnectionString(connectionString); | ||
| 2776 | if (err == PVR_ERROR_NO_ERROR) | ||
| 2777 | strncpy(str, connectionString.c_str(), memSize); | ||
| 2778 | return err; | ||
| 2779 | } | ||
| 2780 | |||
| 2781 | inline static PVR_ERROR ADDON_GetDriveSpace(const AddonInstance_PVR* instance, | ||
| 2782 | uint64_t* total, | ||
| 2783 | uint64_t* used) | ||
| 2784 | { | ||
| 2785 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2786 | ->GetDriveSpace(*total, *used); | ||
| 2787 | } | ||
| 2788 | |||
| 2789 | inline static PVR_ERROR ADDON_CallSettingsMenuHook(const AddonInstance_PVR* instance, | ||
| 2790 | const PVR_MENUHOOK* menuhook) | ||
| 2791 | { | ||
| 2792 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2793 | ->CallSettingsMenuHook(menuhook); | ||
| 2794 | } | ||
| 2795 | |||
| 2796 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2797 | |||
| 2798 | inline static PVR_ERROR ADDON_GetChannelsAmount(const AddonInstance_PVR* instance, int* amount) | ||
| 2799 | { | ||
| 2800 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2801 | ->GetChannelsAmount(*amount); | ||
| 2802 | } | ||
| 2803 | |||
| 2804 | inline static PVR_ERROR ADDON_GetChannels(const AddonInstance_PVR* instance, | ||
| 2805 | ADDON_HANDLE handle, | ||
| 2806 | bool radio) | ||
| 2807 | { | ||
| 2808 | PVRChannelsResultSet result(instance, handle); | ||
| 2809 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2810 | ->GetChannels(radio, result); | ||
| 2811 | } | ||
| 2812 | |||
| 2813 | inline static PVR_ERROR ADDON_GetChannelStreamProperties(const AddonInstance_PVR* instance, | ||
| 2814 | const PVR_CHANNEL* channel, | ||
| 2815 | PVR_NAMED_VALUE* properties, | ||
| 2816 | unsigned int* propertiesCount) | ||
| 2817 | { | ||
| 2818 | *propertiesCount = 0; | ||
| 2819 | std::vector<PVRStreamProperty> propertiesList; | ||
| 2820 | PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2821 | ->GetChannelStreamProperties(channel, propertiesList); | ||
| 2822 | if (error == PVR_ERROR_NO_ERROR) | ||
| 2823 | { | ||
| 2824 | for (const auto& property : propertiesList) | ||
| 2825 | { | ||
| 2826 | strncpy(properties[*propertiesCount].strName, property.GetCStructure()->strName, | ||
| 2827 | sizeof(properties[*propertiesCount].strName) - 1); | ||
| 2828 | strncpy(properties[*propertiesCount].strValue, property.GetCStructure()->strValue, | ||
| 2829 | sizeof(properties[*propertiesCount].strValue) - 1); | ||
| 2830 | ++*propertiesCount; | ||
| 2831 | if (*propertiesCount > STREAM_MAX_PROPERTY_COUNT) | ||
| 2832 | break; | ||
| 2833 | } | ||
| 2834 | } | ||
| 2835 | return error; | ||
| 2836 | } | ||
| 2837 | |||
| 2838 | inline static PVR_ERROR ADDON_GetSignalStatus(const AddonInstance_PVR* instance, | ||
| 2839 | int channelUid, | ||
| 2840 | PVR_SIGNAL_STATUS* signalStatus) | ||
| 2841 | { | ||
| 2842 | PVRSignalStatus cppSignalStatus(signalStatus); | ||
| 2843 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2844 | ->GetSignalStatus(channelUid, cppSignalStatus); | ||
| 2845 | } | ||
| 2846 | |||
| 2847 | inline static PVR_ERROR ADDON_GetDescrambleInfo(const AddonInstance_PVR* instance, | ||
| 2848 | int channelUid, | ||
| 2849 | PVR_DESCRAMBLE_INFO* descrambleInfo) | ||
| 2850 | { | ||
| 2851 | PVRDescrambleInfo cppDescrambleInfo(descrambleInfo); | ||
| 2852 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2853 | ->GetDescrambleInfo(channelUid, cppDescrambleInfo); | ||
| 2854 | } | ||
| 2855 | |||
| 2856 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2857 | |||
| 2858 | inline static PVR_ERROR ADDON_GetChannelGroupsAmount(const AddonInstance_PVR* instance, | ||
| 2859 | int* amount) | ||
| 2860 | { | ||
| 2861 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2862 | ->GetChannelGroupsAmount(*amount); | ||
| 2863 | } | ||
| 2864 | |||
| 2865 | inline static PVR_ERROR ADDON_GetChannelGroups(const AddonInstance_PVR* instance, | ||
| 2866 | ADDON_HANDLE handle, | ||
| 2867 | bool radio) | ||
| 2868 | { | ||
| 2869 | PVRChannelGroupsResultSet result(instance, handle); | ||
| 2870 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2871 | ->GetChannelGroups(radio, result); | ||
| 2872 | } | ||
| 2873 | |||
| 2874 | inline static PVR_ERROR ADDON_GetChannelGroupMembers(const AddonInstance_PVR* instance, | ||
| 2875 | ADDON_HANDLE handle, | ||
| 2876 | const PVR_CHANNEL_GROUP* group) | ||
| 2877 | { | ||
| 2878 | PVRChannelGroupMembersResultSet result(instance, handle); | ||
| 2879 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2880 | ->GetChannelGroupMembers(group, result); | ||
| 2881 | } | ||
| 2882 | |||
| 2883 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2884 | |||
| 2885 | inline static PVR_ERROR ADDON_DeleteChannel(const AddonInstance_PVR* instance, | ||
| 2886 | const PVR_CHANNEL* channel) | ||
| 2887 | { | ||
| 2888 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2889 | ->DeleteChannel(channel); | ||
| 2890 | } | ||
| 2891 | |||
| 2892 | inline static PVR_ERROR ADDON_RenameChannel(const AddonInstance_PVR* instance, | ||
| 2893 | const PVR_CHANNEL* channel) | ||
| 2894 | { | ||
| 2895 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2896 | ->RenameChannel(channel); | ||
| 2897 | } | ||
| 2898 | |||
| 2899 | inline static PVR_ERROR ADDON_OpenDialogChannelSettings(const AddonInstance_PVR* instance, | ||
| 2900 | const PVR_CHANNEL* channel) | ||
| 2901 | { | ||
| 2902 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2903 | ->OpenDialogChannelSettings(channel); | ||
| 2904 | } | ||
| 2905 | |||
| 2906 | inline static PVR_ERROR ADDON_OpenDialogChannelAdd(const AddonInstance_PVR* instance, | ||
| 2907 | const PVR_CHANNEL* channel) | ||
| 2908 | { | ||
| 2909 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2910 | ->OpenDialogChannelAdd(channel); | ||
| 2911 | } | ||
| 2912 | |||
| 2913 | inline static PVR_ERROR ADDON_OpenDialogChannelScan(const AddonInstance_PVR* instance) | ||
| 2914 | { | ||
| 2915 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2916 | ->OpenDialogChannelScan(); | ||
| 2917 | } | ||
| 2918 | |||
| 2919 | inline static PVR_ERROR ADDON_CallChannelMenuHook(const AddonInstance_PVR* instance, | ||
| 2920 | const PVR_MENUHOOK* menuhook, | ||
| 2921 | const PVR_CHANNEL* channel) | ||
| 2922 | { | ||
| 2923 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2924 | ->CallChannelMenuHook(menuhook, channel); | ||
| 2925 | } | ||
| 2926 | |||
| 2927 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 2928 | |||
| 2929 | inline static PVR_ERROR ADDON_GetEPGForChannel(const AddonInstance_PVR* instance, | ||
| 2930 | ADDON_HANDLE handle, | ||
| 2931 | int channelUid, | ||
| 2932 | time_t start, | ||
| 2933 | time_t end) | ||
| 2934 | { | ||
| 2935 | PVREPGTagsResultSet result(instance, handle); | ||
| 2936 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2937 | ->GetEPGForChannel(channelUid, start, end, result); | ||
| 2938 | } | ||
| 2939 | |||
| 2940 | inline static PVR_ERROR ADDON_IsEPGTagRecordable(const AddonInstance_PVR* instance, | ||
| 2941 | const EPG_TAG* tag, | ||
| 2942 | bool* isRecordable) | ||
| 2943 | { | ||
| 2944 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2945 | ->IsEPGTagRecordable(tag, *isRecordable); | ||
| 2946 | } | ||
| 2947 | |||
| 2948 | inline static PVR_ERROR ADDON_IsEPGTagPlayable(const AddonInstance_PVR* instance, | ||
| 2949 | const EPG_TAG* tag, | ||
| 2950 | bool* isPlayable) | ||
| 2951 | { | ||
| 2952 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2953 | ->IsEPGTagPlayable(tag, *isPlayable); | ||
| 2954 | } | ||
| 2955 | |||
| 2956 | inline static PVR_ERROR ADDON_GetEPGTagEdl(const AddonInstance_PVR* instance, | ||
| 2957 | const EPG_TAG* tag, | ||
| 2958 | PVR_EDL_ENTRY* edl, | ||
| 2959 | int* size) | ||
| 2960 | { | ||
| 2961 | *size = 0; | ||
| 2962 | std::vector<PVREDLEntry> edlList; | ||
| 2963 | PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2964 | ->GetEPGTagEdl(tag, edlList); | ||
| 2965 | if (error == PVR_ERROR_NO_ERROR) | ||
| 2966 | { | ||
| 2967 | for (const auto& edlEntry : edlList) | ||
| 2968 | { | ||
| 2969 | edl[*size] = *edlEntry; | ||
| 2970 | ++*size; | ||
| 2971 | } | ||
| 2972 | } | ||
| 2973 | return error; | ||
| 2974 | } | ||
| 2975 | |||
| 2976 | inline static PVR_ERROR ADDON_GetEPGTagStreamProperties(const AddonInstance_PVR* instance, | ||
| 2977 | const EPG_TAG* tag, | ||
| 2978 | PVR_NAMED_VALUE* properties, | ||
| 2979 | unsigned int* propertiesCount) | ||
| 2980 | { | ||
| 2981 | *propertiesCount = 0; | ||
| 2982 | std::vector<PVRStreamProperty> propertiesList; | ||
| 2983 | PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 2984 | ->GetEPGTagStreamProperties(tag, propertiesList); | ||
| 2985 | if (error == PVR_ERROR_NO_ERROR) | ||
| 2986 | { | ||
| 2987 | for (const auto& property : propertiesList) | ||
| 2988 | { | ||
| 2989 | strncpy(properties[*propertiesCount].strName, property.GetCStructure()->strName, | ||
| 2990 | sizeof(properties[*propertiesCount].strName) - 1); | ||
| 2991 | strncpy(properties[*propertiesCount].strValue, property.GetCStructure()->strValue, | ||
| 2992 | sizeof(properties[*propertiesCount].strValue) - 1); | ||
| 2993 | ++*propertiesCount; | ||
| 2994 | if (*propertiesCount > STREAM_MAX_PROPERTY_COUNT) | ||
| 2995 | break; | ||
| 2996 | } | ||
| 2997 | } | ||
| 2998 | return error; | ||
| 2999 | } | ||
| 3000 | |||
| 3001 | inline static PVR_ERROR ADDON_SetEPGTimeFrame(const AddonInstance_PVR* instance, int days) | ||
| 3002 | { | ||
| 3003 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3004 | ->SetEPGTimeFrame(days); | ||
| 3005 | } | ||
| 3006 | |||
| 3007 | inline static PVR_ERROR ADDON_CallEPGMenuHook(const AddonInstance_PVR* instance, | ||
| 3008 | const PVR_MENUHOOK* menuhook, | ||
| 3009 | const EPG_TAG* tag) | ||
| 3010 | { | ||
| 3011 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3012 | ->CallEPGMenuHook(menuhook, tag); | ||
| 3013 | } | ||
| 3014 | |||
| 3015 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 3016 | |||
| 3017 | inline static PVR_ERROR ADDON_GetRecordingsAmount(const AddonInstance_PVR* instance, | ||
| 3018 | bool deleted, | ||
| 3019 | int* amount) | ||
| 3020 | { | ||
| 3021 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3022 | ->GetRecordingsAmount(deleted, *amount); | ||
| 3023 | } | ||
| 3024 | |||
| 3025 | inline static PVR_ERROR ADDON_GetRecordings(const AddonInstance_PVR* instance, | ||
| 3026 | ADDON_HANDLE handle, | ||
| 3027 | bool deleted) | ||
| 3028 | { | ||
| 3029 | PVRRecordingsResultSet result(instance, handle); | ||
| 3030 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3031 | ->GetRecordings(deleted, result); | ||
| 3032 | } | ||
| 3033 | |||
| 3034 | inline static PVR_ERROR ADDON_DeleteRecording(const AddonInstance_PVR* instance, | ||
| 3035 | const PVR_RECORDING* recording) | ||
| 3036 | { | ||
| 3037 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3038 | ->DeleteRecording(recording); | ||
| 3039 | } | ||
| 3040 | |||
| 3041 | inline static PVR_ERROR ADDON_UndeleteRecording(const AddonInstance_PVR* instance, | ||
| 3042 | const PVR_RECORDING* recording) | ||
| 3043 | { | ||
| 3044 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3045 | ->UndeleteRecording(recording); | ||
| 3046 | } | ||
| 3047 | |||
| 3048 | inline static PVR_ERROR ADDON_DeleteAllRecordingsFromTrash(const AddonInstance_PVR* instance) | ||
| 3049 | { | ||
| 3050 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3051 | ->DeleteAllRecordingsFromTrash(); | ||
| 3052 | } | ||
| 3053 | |||
| 3054 | inline static PVR_ERROR ADDON_RenameRecording(const AddonInstance_PVR* instance, | ||
| 3055 | const PVR_RECORDING* recording) | ||
| 3056 | { | ||
| 3057 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3058 | ->RenameRecording(recording); | ||
| 3059 | } | ||
| 3060 | |||
| 3061 | inline static PVR_ERROR ADDON_SetRecordingLifetime(const AddonInstance_PVR* instance, | ||
| 3062 | const PVR_RECORDING* recording) | ||
| 3063 | { | ||
| 3064 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3065 | ->SetRecordingLifetime(recording); | ||
| 3066 | } | ||
| 3067 | |||
| 3068 | inline static PVR_ERROR ADDON_SetRecordingPlayCount(const AddonInstance_PVR* instance, | ||
| 3069 | const PVR_RECORDING* recording, | ||
| 3070 | int count) | ||
| 3071 | { | ||
| 3072 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3073 | ->SetRecordingPlayCount(recording, count); | ||
| 3074 | } | ||
| 3075 | |||
| 3076 | inline static PVR_ERROR ADDON_SetRecordingLastPlayedPosition(const AddonInstance_PVR* instance, | ||
| 3077 | const PVR_RECORDING* recording, | ||
| 3078 | int lastplayedposition) | ||
| 3079 | { | ||
| 3080 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3081 | ->SetRecordingLastPlayedPosition(recording, lastplayedposition); | ||
| 3082 | } | ||
| 3083 | |||
| 3084 | inline static PVR_ERROR ADDON_GetRecordingLastPlayedPosition(const AddonInstance_PVR* instance, | ||
| 3085 | const PVR_RECORDING* recording, | ||
| 3086 | int* position) | ||
| 3087 | { | ||
| 3088 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3089 | ->GetRecordingLastPlayedPosition(recording, *position); | ||
| 3090 | } | ||
| 3091 | |||
| 3092 | inline static PVR_ERROR ADDON_GetRecordingEdl(const AddonInstance_PVR* instance, | ||
| 3093 | const PVR_RECORDING* recording, | ||
| 3094 | PVR_EDL_ENTRY* edl, | ||
| 3095 | int* size) | ||
| 3096 | { | ||
| 3097 | *size = 0; | ||
| 3098 | std::vector<PVREDLEntry> edlList; | ||
| 3099 | PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3100 | ->GetRecordingEdl(recording, edlList); | ||
| 3101 | if (error == PVR_ERROR_NO_ERROR) | ||
| 3102 | { | ||
| 3103 | for (const auto& edlEntry : edlList) | ||
| 3104 | { | ||
| 3105 | edl[*size] = *edlEntry; | ||
| 3106 | ++*size; | ||
| 3107 | } | ||
| 3108 | } | ||
| 3109 | return error; | ||
| 3110 | } | ||
| 3111 | |||
| 3112 | inline static PVR_ERROR ADDON_GetRecordingSize(const AddonInstance_PVR* instance, | ||
| 3113 | const PVR_RECORDING* recording, | ||
| 3114 | int64_t* size) | ||
| 3115 | { | ||
| 3116 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3117 | ->GetRecordingSize(recording, *size); | ||
| 3118 | } | ||
| 3119 | |||
| 3120 | inline static PVR_ERROR ADDON_GetRecordingStreamProperties(const AddonInstance_PVR* instance, | ||
| 3121 | const PVR_RECORDING* recording, | ||
| 3122 | PVR_NAMED_VALUE* properties, | ||
| 3123 | unsigned int* propertiesCount) | ||
| 3124 | { | ||
| 3125 | *propertiesCount = 0; | ||
| 3126 | std::vector<PVRStreamProperty> propertiesList; | ||
| 3127 | PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3128 | ->GetRecordingStreamProperties(recording, propertiesList); | ||
| 3129 | if (error == PVR_ERROR_NO_ERROR) | ||
| 3130 | { | ||
| 3131 | for (const auto& property : propertiesList) | ||
| 3132 | { | ||
| 3133 | strncpy(properties[*propertiesCount].strName, property.GetCStructure()->strName, | ||
| 3134 | sizeof(properties[*propertiesCount].strName) - 1); | ||
| 3135 | strncpy(properties[*propertiesCount].strValue, property.GetCStructure()->strValue, | ||
| 3136 | sizeof(properties[*propertiesCount].strValue) - 1); | ||
| 3137 | ++*propertiesCount; | ||
| 3138 | if (*propertiesCount > STREAM_MAX_PROPERTY_COUNT) | ||
| 3139 | break; | ||
| 3140 | } | ||
| 3141 | } | ||
| 3142 | return error; | ||
| 3143 | } | ||
| 3144 | |||
| 3145 | inline static PVR_ERROR ADDON_CallRecordingMenuHook(const AddonInstance_PVR* instance, | ||
| 3146 | const PVR_MENUHOOK* menuhook, | ||
| 3147 | const PVR_RECORDING* recording) | ||
| 3148 | { | ||
| 3149 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3150 | ->CallRecordingMenuHook(menuhook, recording); | ||
| 3151 | } | ||
| 3152 | |||
| 3153 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 3154 | |||
| 3155 | |||
| 3156 | inline static PVR_ERROR ADDON_GetTimerTypes(const AddonInstance_PVR* instance, | ||
| 3157 | PVR_TIMER_TYPE* types, | ||
| 3158 | int* typesCount) | ||
| 3159 | { | ||
| 3160 | *typesCount = 0; | ||
| 3161 | std::vector<PVRTimerType> timerTypes; | ||
| 3162 | PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3163 | ->GetTimerTypes(timerTypes); | ||
| 3164 | if (error == PVR_ERROR_NO_ERROR) | ||
| 3165 | { | ||
| 3166 | for (const auto& timerType : timerTypes) | ||
| 3167 | { | ||
| 3168 | types[*typesCount] = *timerType; | ||
| 3169 | ++*typesCount; | ||
| 3170 | if (*typesCount >= PVR_ADDON_TIMERTYPE_ARRAY_SIZE) | ||
| 3171 | break; | ||
| 3172 | } | ||
| 3173 | } | ||
| 3174 | return error; | ||
| 3175 | } | ||
| 3176 | |||
| 3177 | inline static PVR_ERROR ADDON_GetTimersAmount(const AddonInstance_PVR* instance, int* amount) | ||
| 3178 | { | ||
| 3179 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3180 | ->GetTimersAmount(*amount); | ||
| 3181 | } | ||
| 3182 | |||
| 3183 | inline static PVR_ERROR ADDON_GetTimers(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 3184 | { | ||
| 3185 | PVRTimersResultSet result(instance, handle); | ||
| 3186 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->GetTimers(result); | ||
| 3187 | } | ||
| 3188 | |||
| 3189 | inline static PVR_ERROR ADDON_AddTimer(const AddonInstance_PVR* instance, const PVR_TIMER* timer) | ||
| 3190 | { | ||
| 3191 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->AddTimer(timer); | ||
| 3192 | } | ||
| 3193 | |||
| 3194 | inline static PVR_ERROR ADDON_DeleteTimer(const AddonInstance_PVR* instance, | ||
| 3195 | const PVR_TIMER* timer, | ||
| 3196 | bool forceDelete) | ||
| 3197 | { | ||
| 3198 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3199 | ->DeleteTimer(timer, forceDelete); | ||
| 3200 | } | ||
| 3201 | |||
| 3202 | inline static PVR_ERROR ADDON_UpdateTimer(const AddonInstance_PVR* instance, | ||
| 3203 | const PVR_TIMER* timer) | ||
| 3204 | { | ||
| 3205 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->UpdateTimer(timer); | ||
| 3206 | } | ||
| 3207 | |||
| 3208 | inline static PVR_ERROR ADDON_CallTimerMenuHook(const AddonInstance_PVR* instance, | ||
| 3209 | const PVR_MENUHOOK* menuhook, | ||
| 3210 | const PVR_TIMER* timer) | ||
| 3211 | { | ||
| 3212 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3213 | ->CallTimerMenuHook(menuhook, timer); | ||
| 3214 | } | ||
| 3215 | |||
| 3216 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 3217 | |||
| 3218 | inline static PVR_ERROR ADDON_OnSystemSleep(const AddonInstance_PVR* instance) | ||
| 3219 | { | ||
| 3220 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->OnSystemSleep(); | ||
| 3221 | } | ||
| 3222 | |||
| 3223 | inline static PVR_ERROR ADDON_OnSystemWake(const AddonInstance_PVR* instance) | ||
| 3224 | { | ||
| 3225 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->OnSystemWake(); | ||
| 3226 | } | ||
| 3227 | |||
| 3228 | inline static PVR_ERROR ADDON_OnPowerSavingActivated(const AddonInstance_PVR* instance) | ||
| 3229 | { | ||
| 3230 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3231 | ->OnPowerSavingActivated(); | ||
| 3232 | } | ||
| 3233 | |||
| 3234 | inline static PVR_ERROR ADDON_OnPowerSavingDeactivated(const AddonInstance_PVR* instance) | ||
| 3235 | { | ||
| 3236 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3237 | ->OnPowerSavingDeactivated(); | ||
| 3238 | } | ||
| 3239 | |||
| 3240 | // obsolete parts below | ||
| 3241 | ///@{ | ||
| 3242 | |||
| 3243 | inline static bool ADDON_OpenLiveStream(const AddonInstance_PVR* instance, | ||
| 3244 | const PVR_CHANNEL* channel) | ||
| 3245 | { | ||
| 3246 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3247 | ->OpenLiveStream(channel); | ||
| 3248 | } | ||
| 3249 | |||
| 3250 | inline static void ADDON_CloseLiveStream(const AddonInstance_PVR* instance) | ||
| 3251 | { | ||
| 3252 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CloseLiveStream(); | ||
| 3253 | } | ||
| 3254 | |||
| 3255 | inline static int ADDON_ReadLiveStream(const AddonInstance_PVR* instance, | ||
| 3256 | unsigned char* buffer, | ||
| 3257 | unsigned int size) | ||
| 3258 | { | ||
| 3259 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3260 | ->ReadLiveStream(buffer, size); | ||
| 3261 | } | ||
| 3262 | |||
| 3263 | inline static int64_t ADDON_SeekLiveStream(const AddonInstance_PVR* instance, | ||
| 3264 | int64_t position, | ||
| 3265 | int whence) | ||
| 3266 | { | ||
| 3267 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3268 | ->SeekLiveStream(position, whence); | ||
| 3269 | } | ||
| 3270 | |||
| 3271 | inline static int64_t ADDON_LengthLiveStream(const AddonInstance_PVR* instance) | ||
| 3272 | { | ||
| 3273 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->LengthLiveStream(); | ||
| 3274 | } | ||
| 3275 | |||
| 3276 | inline static PVR_ERROR ADDON_GetStreamProperties(const AddonInstance_PVR* instance, | ||
| 3277 | PVR_STREAM_PROPERTIES* properties) | ||
| 3278 | { | ||
| 3279 | properties->iStreamCount = 0; | ||
| 3280 | std::vector<PVRStreamProperties> cppProperties; | ||
| 3281 | PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3282 | ->GetStreamProperties(cppProperties); | ||
| 3283 | if (err == PVR_ERROR_NO_ERROR) | ||
| 3284 | { | ||
| 3285 | for (unsigned int i = 0; i < cppProperties.size(); ++i) | ||
| 3286 | { | ||
| 3287 | memcpy(&properties->stream[i], | ||
| 3288 | static_cast<PVR_STREAM_PROPERTIES::PVR_STREAM*>(cppProperties[i]), | ||
| 3289 | sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); | ||
| 3290 | ++properties->iStreamCount; | ||
| 3291 | |||
| 3292 | if (properties->iStreamCount >= PVR_STREAM_MAX_STREAMS) | ||
| 3293 | { | ||
| 3294 | kodi::Log( | ||
| 3295 | ADDON_LOG_ERROR, | ||
| 3296 | "CInstancePVRClient::%s: Addon given with '%li' more allowed streams where '%i'", | ||
| 3297 | __func__, cppProperties.size(), PVR_STREAM_MAX_STREAMS); | ||
| 3298 | break; | ||
| 3299 | } | ||
| 3300 | } | ||
| 3301 | } | ||
| 3302 | |||
| 3303 | return err; | ||
| 3304 | } | ||
| 3305 | |||
| 3306 | inline static PVR_ERROR ADDON_GetStreamReadChunkSize(const AddonInstance_PVR* instance, | ||
| 3307 | int* chunksize) | ||
| 3308 | { | ||
| 3309 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3310 | ->GetStreamReadChunkSize(*chunksize); | ||
| 3311 | } | ||
| 3312 | |||
| 3313 | inline static bool ADDON_IsRealTimeStream(const AddonInstance_PVR* instance) | ||
| 3314 | { | ||
| 3315 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->IsRealTimeStream(); | ||
| 3316 | } | ||
| 3317 | |||
| 3318 | inline static bool ADDON_OpenRecordedStream(const AddonInstance_PVR* instance, | ||
| 3319 | const PVR_RECORDING* recording) | ||
| 3320 | { | ||
| 3321 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3322 | ->OpenRecordedStream(recording); | ||
| 3323 | } | ||
| 3324 | |||
| 3325 | inline static void ADDON_CloseRecordedStream(const AddonInstance_PVR* instance) | ||
| 3326 | { | ||
| 3327 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CloseRecordedStream(); | ||
| 3328 | } | ||
| 3329 | |||
| 3330 | inline static int ADDON_ReadRecordedStream(const AddonInstance_PVR* instance, | ||
| 3331 | unsigned char* buffer, | ||
| 3332 | unsigned int size) | ||
| 3333 | { | ||
| 3334 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3335 | ->ReadRecordedStream(buffer, size); | ||
| 3336 | } | ||
| 3337 | |||
| 3338 | inline static int64_t ADDON_SeekRecordedStream(const AddonInstance_PVR* instance, | ||
| 3339 | int64_t position, | ||
| 3340 | int whence) | ||
| 3341 | { | ||
| 3342 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3343 | ->SeekRecordedStream(position, whence); | ||
| 3344 | } | ||
| 3345 | |||
| 3346 | inline static int64_t ADDON_LengthRecordedStream(const AddonInstance_PVR* instance) | ||
| 3347 | { | ||
| 3348 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3349 | ->LengthRecordedStream(); | ||
| 3350 | } | ||
| 3351 | |||
| 3352 | inline static void ADDON_DemuxReset(const AddonInstance_PVR* instance) | ||
| 3353 | { | ||
| 3354 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxReset(); | ||
| 3355 | } | ||
| 3356 | |||
| 3357 | inline static void ADDON_DemuxAbort(const AddonInstance_PVR* instance) | ||
| 3358 | { | ||
| 3359 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxAbort(); | ||
| 3360 | } | ||
| 3361 | |||
| 3362 | inline static void ADDON_DemuxFlush(const AddonInstance_PVR* instance) | ||
| 3363 | { | ||
| 3364 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxFlush(); | ||
| 3365 | } | ||
| 3366 | |||
| 3367 | inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_PVR* instance) | ||
| 3368 | { | ||
| 3369 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxRead(); | ||
| 3370 | } | ||
| 3371 | |||
| 3372 | inline static bool ADDON_CanPauseStream(const AddonInstance_PVR* instance) | ||
| 3373 | { | ||
| 3374 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CanPauseStream(); | ||
| 3375 | } | ||
| 3376 | |||
| 3377 | inline static bool ADDON_CanSeekStream(const AddonInstance_PVR* instance) | ||
| 3378 | { | ||
| 3379 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CanSeekStream(); | ||
| 3380 | } | ||
| 3381 | |||
| 3382 | inline static void ADDON_PauseStream(const AddonInstance_PVR* instance, bool bPaused) | ||
| 3383 | { | ||
| 3384 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->PauseStream(bPaused); | ||
| 3385 | } | ||
| 3386 | |||
| 3387 | inline static bool ADDON_SeekTime(const AddonInstance_PVR* instance, | ||
| 3388 | double time, | ||
| 3389 | bool backwards, | ||
| 3390 | double* startpts) | ||
| 3391 | { | ||
| 3392 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3393 | ->SeekTime(time, backwards, *startpts); | ||
| 3394 | } | ||
| 3395 | |||
| 3396 | inline static void ADDON_SetSpeed(const AddonInstance_PVR* instance, int speed) | ||
| 3397 | { | ||
| 3398 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->SetSpeed(speed); | ||
| 3399 | } | ||
| 3400 | |||
| 3401 | inline static void ADDON_FillBuffer(const AddonInstance_PVR* instance, bool mode) | ||
| 3402 | { | ||
| 3403 | static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->FillBuffer(mode); | ||
| 3404 | } | ||
| 3405 | |||
| 3406 | inline static PVR_ERROR ADDON_GetStreamTimes(const AddonInstance_PVR* instance, | ||
| 3407 | PVR_STREAM_TIMES* times) | ||
| 3408 | { | ||
| 3409 | PVRStreamTimes cppTimes(times); | ||
| 3410 | return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) | ||
| 3411 | ->GetStreamTimes(cppTimes); | ||
| 3412 | } | ||
| 3413 | ///@} | ||
| 3414 | |||
| 3415 | AddonInstance_PVR* m_instanceData = nullptr; | ||
| 3416 | }; | ||
| 3417 | //}}} | ||
| 3418 | //______________________________________________________________________________ | ||
| 3419 | |||
| 3420 | } /* namespace addon */ | ||
| 3421 | } /* namespace kodi */ | ||
| 3422 | |||
| 3423 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h index 2df8a36..2067d51 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h | |||
| @@ -453,11 +453,11 @@ namespace kodi | |||
| 453 | namespace addon | 453 | namespace addon |
| 454 | { | 454 | { |
| 455 | 455 | ||
| 456 | class CInstancePeripheral : public IAddonInstance | 456 | class ATTRIBUTE_HIDDEN CInstancePeripheral : public IAddonInstance |
| 457 | { | 457 | { |
| 458 | public: | 458 | public: |
| 459 | CInstancePeripheral() | 459 | CInstancePeripheral() |
| 460 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL) | 460 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL)) |
| 461 | { | 461 | { |
| 462 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 462 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 463 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of more as one in single instance way is not allowed!"); | 463 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of more as one in single instance way is not allowed!"); |
| @@ -466,8 +466,10 @@ namespace addon | |||
| 466 | CAddonBase::m_interface->globalSingleInstance = this; | 466 | CAddonBase::m_interface->globalSingleInstance = this; |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | explicit CInstancePeripheral(KODI_HANDLE instance) | 469 | explicit CInstancePeripheral(KODI_HANDLE instance, const std::string& kodiVersion = "") |
| 470 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL) | 470 | : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, |
| 471 | !kodiVersion.empty() ? kodiVersion | ||
| 472 | : GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL)) | ||
| 471 | { | 473 | { |
| 472 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 474 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 473 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of multiple together with single instance way is not allowed!"); | 475 | throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of multiple together with single instance way is not allowed!"); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h index 9b2a43f..62e5a93 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h | |||
| @@ -150,9 +150,7 @@ namespace addon | |||
| 150 | class PeripheralEvent | 150 | class PeripheralEvent |
| 151 | { | 151 | { |
| 152 | public: | 152 | public: |
| 153 | PeripheralEvent(void) | 153 | PeripheralEvent() = default; |
| 154 | { | ||
| 155 | } | ||
| 156 | 154 | ||
| 157 | PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) : | 155 | PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) : |
| 158 | m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON), | 156 | m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON), |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h index c4f8005..f8a7380 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "../AddonBase.h" | 11 | #include "../AddonBase.h" |
| 12 | #include "../gui/renderHelper.h" | ||
| 12 | 13 | ||
| 13 | namespace kodi { namespace addon { class CInstanceScreensaver; }} | 14 | namespace kodi { namespace addon { class CInstanceScreensaver; }} |
| 14 | 15 | ||
| @@ -218,7 +219,7 @@ namespace addon | |||
| 218 | /// Kodi's header. Manually deleting the add-on instance is not required. | 219 | /// Kodi's header. Manually deleting the add-on instance is not required. |
| 219 | /// | 220 | /// |
| 220 | //---------------------------------------------------------------------------- | 221 | //---------------------------------------------------------------------------- |
| 221 | class CInstanceScreensaver : public IAddonInstance | 222 | class ATTRIBUTE_HIDDEN CInstanceScreensaver : public IAddonInstance |
| 222 | { | 223 | { |
| 223 | public: | 224 | public: |
| 224 | //========================================================================== | 225 | //========================================================================== |
| @@ -229,7 +230,7 @@ namespace addon | |||
| 229 | /// Used by an add-on that only supports screensavers. | 230 | /// Used by an add-on that only supports screensavers. |
| 230 | /// | 231 | /// |
| 231 | CInstanceScreensaver() | 232 | CInstanceScreensaver() |
| 232 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) | 233 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER)) |
| 233 | { | 234 | { |
| 234 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 235 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 235 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single instance way is not allowed!"); | 236 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single instance way is not allowed!"); |
| @@ -247,11 +248,16 @@ namespace addon | |||
| 247 | /// | 248 | /// |
| 248 | /// @param[in] instance The instance value given to | 249 | /// @param[in] instance The instance value given to |
| 249 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | 250 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. |
| 251 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 252 | /// allow compatibility to older Kodi versions. | ||
| 253 | /// @note Recommended to set. | ||
| 250 | /// | 254 | /// |
| 251 | /// @warning Only use `instance` from the CreateInstance call | 255 | /// @warning Only use `instance` from the CreateInstance call |
| 252 | /// | 256 | /// |
| 253 | explicit CInstanceScreensaver(KODI_HANDLE instance) | 257 | explicit CInstanceScreensaver(KODI_HANDLE instance, const std::string& kodiVersion = "") |
| 254 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER) | 258 | : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, |
| 259 | !kodiVersion.empty() ? kodiVersion | ||
| 260 | : GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER)) | ||
| 255 | { | 261 | { |
| 256 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 262 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 257 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together with single instance way is not allowed!"); | 263 | throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together with single instance way is not allowed!"); |
| @@ -418,19 +424,35 @@ namespace addon | |||
| 418 | 424 | ||
| 419 | inline static bool ADDON_Start(AddonInstance_Screensaver* instance) | 425 | inline static bool ADDON_Start(AddonInstance_Screensaver* instance) |
| 420 | { | 426 | { |
| 427 | instance->toAddon.addonInstance->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 421 | return instance->toAddon.addonInstance->Start(); | 428 | return instance->toAddon.addonInstance->Start(); |
| 422 | } | 429 | } |
| 423 | 430 | ||
| 424 | inline static void ADDON_Stop(AddonInstance_Screensaver* instance) | 431 | inline static void ADDON_Stop(AddonInstance_Screensaver* instance) |
| 425 | { | 432 | { |
| 426 | instance->toAddon.addonInstance->Stop(); | 433 | instance->toAddon.addonInstance->Stop(); |
| 434 | instance->toAddon.addonInstance->m_renderHelper = nullptr; | ||
| 427 | } | 435 | } |
| 428 | 436 | ||
| 429 | inline static void ADDON_Render(AddonInstance_Screensaver* instance) | 437 | inline static void ADDON_Render(AddonInstance_Screensaver* instance) |
| 430 | { | 438 | { |
| 439 | if (!instance->toAddon.addonInstance->m_renderHelper) | ||
| 440 | return; | ||
| 441 | instance->toAddon.addonInstance->m_renderHelper->Begin(); | ||
| 431 | instance->toAddon.addonInstance->Render(); | 442 | instance->toAddon.addonInstance->Render(); |
| 443 | instance->toAddon.addonInstance->m_renderHelper->End(); | ||
| 432 | } | 444 | } |
| 433 | 445 | ||
| 446 | /* | ||
| 447 | * Background render helper holds here and in addon base. | ||
| 448 | * In addon base also to have for the others, and stored here for the worst | ||
| 449 | * case where this class is independent from base and base becomes closed | ||
| 450 | * before. | ||
| 451 | * | ||
| 452 | * This is on Kodi with GL unused and the calls to there are empty (no work) | ||
| 453 | * On Kodi with Direct X where angle is present becomes this used. | ||
| 454 | */ | ||
| 455 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 434 | AddonInstance_Screensaver* m_instanceData; | 456 | AddonInstance_Screensaver* m_instanceData; |
| 435 | }; | 457 | }; |
| 436 | 458 | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h index 3bdc059..efd5de2 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h | |||
| @@ -10,31 +10,162 @@ | |||
| 10 | #include "../AddonBase.h" | 10 | #include "../AddonBase.h" |
| 11 | #include "../Filesystem.h" | 11 | #include "../Filesystem.h" |
| 12 | 12 | ||
| 13 | #ifdef BUILD_KODI_ADDON | 13 | #if !defined(_WIN32) |
| 14 | #include "../IFileTypes.h" | 14 | #include <sys/stat.h> |
| 15 | #if !defined(__stat64) | ||
| 16 | #if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) | ||
| 17 | #define __stat64 stat | ||
| 15 | #else | 18 | #else |
| 16 | #include "filesystem/IFileTypes.h" | 19 | #define __stat64 stat64 |
| 17 | #include "PlatformDefs.h" | 20 | #endif |
| 21 | #endif | ||
| 18 | #endif | 22 | #endif |
| 19 | 23 | ||
| 20 | namespace kodi { namespace addon { class CInstanceVFS; }} | 24 | #ifdef __cplusplus |
| 21 | |||
| 22 | extern "C" | 25 | extern "C" |
| 23 | { | 26 | { |
| 24 | 27 | #endif /* __cplusplus */ | |
| 28 | |||
| 29 | //============================================================================ | ||
| 30 | /// @ingroup cpp_kodi_addon_vfs_Defs | ||
| 31 | /// @brief **VFS add-on URL data**\n | ||
| 32 | /// This class is used to inform the addon of the desired wanted connection. | ||
| 33 | /// | ||
| 34 | /// Used on mostly all addon functions to identify related target. | ||
| 35 | /// | ||
| 25 | struct VFSURL | 36 | struct VFSURL |
| 26 | { | 37 | { |
| 38 | /// @brief Desired URL of the file system to be edited | ||
| 39 | /// | ||
| 40 | /// This includes all available parts of the access and is structured as | ||
| 41 | /// follows: | ||
| 42 | /// - <b>`<PROTOCOL>`://`<USERNAME>`:`<PASSWORD>``@``<HOSTNAME>`:`<PORT>`/`<FILENAME>`?`<OPTIONS>`</b> | ||
| 27 | const char* url; | 43 | const char* url; |
| 44 | |||
| 45 | /// @brief The associated domain name, which is optional and not available | ||
| 46 | /// in all cases. | ||
| 28 | const char* domain; | 47 | const char* domain; |
| 48 | |||
| 49 | /// @brief This includes the network address (e.g. `192.168.0.123`) or if | ||
| 50 | /// the addon refers to file packages the path to it | ||
| 51 | /// (e.g. `/home/by_me/MyPacket.rar`). | ||
| 29 | const char* hostname; | 52 | const char* hostname; |
| 53 | |||
| 54 | /// @brief With this variable the desired path to a folder or file within | ||
| 55 | /// the hostname is given (e.g. `storage/videos/00001.ts`). | ||
| 30 | const char* filename; | 56 | const char* filename; |
| 57 | |||
| 58 | /// @brief [Networking port](https://en.wikipedia.org/wiki/Port_(computer_networking)) | ||
| 59 | /// to use for protocol. | ||
| 31 | unsigned int port; | 60 | unsigned int port; |
| 61 | |||
| 62 | /// @brief Special options on opened URL, this can e.g. on RAR packages | ||
| 63 | /// <b>`?flags=8&nextvalue=123`</b> to inform about to not cache a read. | ||
| 64 | /// | ||
| 65 | /// Available options from Kodi: | ||
| 66 | /// | Value: | Description: | ||
| 67 | /// |-----------|------------------- | ||
| 68 | /// | flags=8 | Used on RAR packages so that no data is cached from the requested source. | ||
| 69 | /// | cache=no | Used on ZIP packages so that no data from the requested source is stored in the cache. However, this is currently not available from addons! | ||
| 70 | /// | ||
| 71 | /// In addition, other addons can use the URLs given by them to give options | ||
| 72 | /// that fit the respective VFS addon and allow special operations. | ||
| 73 | /// | ||
| 74 | /// @note This procedure is not yet standardized and is currently not | ||
| 75 | /// exactly available which are handed over. | ||
| 32 | const char* options; | 76 | const char* options; |
| 77 | |||
| 78 | /// @brief Desired username. | ||
| 33 | const char* username; | 79 | const char* username; |
| 80 | |||
| 81 | /// @brief Desired password. | ||
| 34 | const char* password; | 82 | const char* password; |
| 83 | |||
| 84 | /// @brief The complete URL is passed on here, but the user name and | ||
| 85 | /// password are not shown and only appear to there as `USERNAME:PASSWORD`. | ||
| 86 | /// | ||
| 87 | /// As example <b>`sftp://USERNAME:PASSWORD@192.168.178.123/storage/videos/00001.ts`</b>. | ||
| 35 | const char* redacted; | 88 | const char* redacted; |
| 89 | |||
| 90 | /// @brief The name which is taken as the basis by source and would be first | ||
| 91 | /// in folder view. | ||
| 92 | /// | ||
| 93 | /// As example on <b>`sftp://dudu:isprivate@192.168.178.123/storage/videos/00001.ts`</b> | ||
| 94 | /// becomes then <b>`storage`</b> used here. | ||
| 36 | const char* sharename; | 95 | const char* sharename; |
| 96 | |||
| 97 | /// @brief Protocol name used on this stream, e.g. <b>`sftp`</b>. | ||
| 98 | const char* protocol; | ||
| 37 | }; | 99 | }; |
| 100 | //---------------------------------------------------------------------------- | ||
| 101 | |||
| 102 | //============================================================================ | ||
| 103 | /// @ingroup cpp_kodi_addon_vfs_Defs | ||
| 104 | /// @brief <b>In/out value which is queried at @ref kodi::addon::CInstanceVFS::IoControl.</b>\n | ||
| 105 | /// This declares the requested value on the addon, this gets or has to | ||
| 106 | /// transfer data depending on the value. | ||
| 107 | enum VFS_IOCTRL | ||
| 108 | { | ||
| 109 | /// @brief For cases where not supported control becomes asked. | ||
| 110 | /// | ||
| 111 | /// @note Should normally not given to addon. | ||
| 112 | VFS_IOCTRL_INVALID = 0, | ||
| 113 | |||
| 114 | /// @brief @ref VFS_IOCTRL_NATIVE_DATA structure, containing what should be | ||
| 115 | /// passed to native ioctrl. | ||
| 116 | VFS_IOCTRL_NATIVE = 1, | ||
| 117 | |||
| 118 | /// @brief To check seek is possible. | ||
| 119 | /// | ||
| 120 | //// Return 0 if known not to work, 1 if it should work on related calls. | ||
| 121 | VFS_IOCTRL_SEEK_POSSIBLE = 2, | ||
| 122 | |||
| 123 | /// @brief @ref VFS_IOCTRL_CACHE_STATUS_DATA structure structure on related call | ||
| 124 | VFS_IOCTRL_CACHE_STATUS = 3, | ||
| 125 | |||
| 126 | /// @brief Unsigned int with speed limit for caching in bytes per second | ||
| 127 | VFS_IOCTRL_CACHE_SETRATE = 4, | ||
| 128 | |||
| 129 | /// @brief Enable/disable retry within the protocol handler (if supported) | ||
| 130 | VFS_IOCTRL_SET_RETRY = 16, | ||
| 131 | }; | ||
| 132 | //---------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //============================================================================ | ||
| 135 | /// @ingroup cpp_kodi_addon_vfs_Defs | ||
| 136 | /// @brief <b>Structure used in @ref kodi::addon::CInstanceVFS::IoControl | ||
| 137 | /// if question value for @ref VFS_IOCTRL_NATIVE is set</b>\n | ||
| 138 | /// With this structure, data is transmitted to the Kodi addon. | ||
| 139 | /// | ||
| 140 | /// This corresponds to POSIX systems with regard to [ioctl](https://en.wikipedia.org/wiki/Ioctl) | ||
| 141 | /// data (emulated with Windows). | ||
| 142 | struct VFS_IOCTRL_NATIVE_DATA | ||
| 143 | { | ||
| 144 | unsigned long int request; | ||
| 145 | void* param; | ||
| 146 | }; | ||
| 147 | //---------------------------------------------------------------------------- | ||
| 148 | |||
| 149 | //============================================================================ | ||
| 150 | /// @ingroup cpp_kodi_addon_vfs_Defs | ||
| 151 | /// @brief <b>Structure used in @ref kodi::addon::CInstanceVFS::IoControl | ||
| 152 | /// if question value for @ref VFS_IOCTRL_CACHE_STATUS is set</b>\n | ||
| 153 | /// This data is filled by the addon and returned to Kodi | ||
| 154 | struct VFS_IOCTRL_CACHE_STATUS_DATA | ||
| 155 | { | ||
| 156 | /// @brief Number of bytes cached forward of current position. | ||
| 157 | uint64_t forward; | ||
| 158 | |||
| 159 | /// @brief Maximum number of bytes per second cache is allowed to fill. | ||
| 160 | unsigned int maxrate; | ||
| 161 | |||
| 162 | /// @brief Average read rate from source file since last position change. | ||
| 163 | unsigned int currate; | ||
| 164 | |||
| 165 | /// @brief Cache low speed condition detected? | ||
| 166 | bool lowspeed; | ||
| 167 | }; | ||
| 168 | //---------------------------------------------------------------------------- | ||
| 38 | 169 | ||
| 39 | typedef struct VFSGetDirectoryCallbacks /* internal */ | 170 | typedef struct VFSGetDirectoryCallbacks /* internal */ |
| 40 | { | 171 | { |
| @@ -57,555 +188,1078 @@ extern "C" | |||
| 57 | struct AddonInstance_VFSEntry; | 188 | struct AddonInstance_VFSEntry; |
| 58 | typedef struct KodiToAddonFuncTable_VFSEntry /* internal */ | 189 | typedef struct KodiToAddonFuncTable_VFSEntry /* internal */ |
| 59 | { | 190 | { |
| 60 | kodi::addon::CInstanceVFS* addonInstance; | 191 | KODI_HANDLE addonInstance; |
| 61 | 192 | ||
| 62 | void* (__cdecl* open) (const AddonInstance_VFSEntry* instance, const VFSURL* url); | 193 | void*(__cdecl* open)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url); |
| 63 | void* (__cdecl* open_for_write) (const AddonInstance_VFSEntry* instance, const VFSURL* url, bool overwrite); | 194 | void*(__cdecl* open_for_write)(const struct AddonInstance_VFSEntry* instance, |
| 64 | ssize_t (__cdecl* read) (const AddonInstance_VFSEntry* instance, void* context, void* buffer, size_t buf_size); | 195 | const struct VFSURL* url, |
| 65 | ssize_t (__cdecl* write) (const AddonInstance_VFSEntry* instance, void* context, const void* buffer, size_t buf_size); | 196 | bool overwrite); |
| 66 | int64_t (__cdecl* seek) (const AddonInstance_VFSEntry* instance, void* context, int64_t position, int whence); | 197 | ssize_t(__cdecl* read)(const struct AddonInstance_VFSEntry* instance, |
| 67 | int (__cdecl* truncate) (const AddonInstance_VFSEntry* instance, void* context, int64_t size); | 198 | void* context, |
| 68 | int64_t (__cdecl* get_length) (const AddonInstance_VFSEntry* instance, void* context); | 199 | void* buffer, |
| 69 | int64_t (__cdecl* get_position) (const AddonInstance_VFSEntry* instance, void* context); | 200 | size_t buf_size); |
| 70 | int (__cdecl* get_chunk_size) (const AddonInstance_VFSEntry* instance, void* context); | 201 | ssize_t(__cdecl* write)(const struct AddonInstance_VFSEntry* instance, |
| 71 | int (__cdecl* io_control) (const AddonInstance_VFSEntry* instance, void* context, XFILE::EIoControl request, void* param); | 202 | void* context, |
| 72 | int (__cdecl* stat) (const AddonInstance_VFSEntry* instance, const VFSURL* url, struct __stat64* buffer); | 203 | const void* buffer, |
| 73 | bool (__cdecl* close) (const AddonInstance_VFSEntry* instance, void* context); | 204 | size_t buf_size); |
| 74 | bool (__cdecl* exists) (const AddonInstance_VFSEntry* instance, const VFSURL* url); | 205 | int64_t(__cdecl* seek)(const struct AddonInstance_VFSEntry* instance, |
| 75 | void (__cdecl* clear_out_idle) (const AddonInstance_VFSEntry* instance); | 206 | void* context, |
| 76 | void (__cdecl* disconnect_all) (const AddonInstance_VFSEntry* instance); | 207 | int64_t position, |
| 77 | bool (__cdecl* delete_it) (const AddonInstance_VFSEntry* instance, const VFSURL* url); | 208 | int whence); |
| 78 | bool (__cdecl* rename) (const AddonInstance_VFSEntry* instance, const VFSURL* url, const VFSURL* url2); | 209 | int(__cdecl* truncate)(const struct AddonInstance_VFSEntry* instance, |
| 79 | bool (__cdecl* directory_exists) (const AddonInstance_VFSEntry* instance, const VFSURL* url); | 210 | void* context, |
| 80 | bool (__cdecl* remove_directory) (const AddonInstance_VFSEntry* instance, const VFSURL* url); | 211 | int64_t size); |
| 81 | bool (__cdecl* create_directory) (const AddonInstance_VFSEntry* instance, const VFSURL* url); | 212 | int64_t(__cdecl* get_length)(const struct AddonInstance_VFSEntry* instance, void* context); |
| 82 | bool (__cdecl* get_directory) (const AddonInstance_VFSEntry* instance, | 213 | int64_t(__cdecl* get_position)(const struct AddonInstance_VFSEntry* instance, void* context); |
| 83 | const VFSURL* url, | 214 | int(__cdecl* get_chunk_size)(const struct AddonInstance_VFSEntry* instance, void* context); |
| 84 | VFSDirEntry** entries, | 215 | int(__cdecl* io_control)(const struct AddonInstance_VFSEntry* instance, |
| 216 | void* context, | ||
| 217 | enum VFS_IOCTRL request, | ||
| 218 | void* param); | ||
| 219 | int(__cdecl* stat)(const struct AddonInstance_VFSEntry* instance, | ||
| 220 | const struct VFSURL* url, | ||
| 221 | struct __stat64* buffer); | ||
| 222 | bool(__cdecl* close)(const struct AddonInstance_VFSEntry* instance, void* context); | ||
| 223 | bool(__cdecl* exists)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url); | ||
| 224 | void(__cdecl* clear_out_idle)(const struct AddonInstance_VFSEntry* instance); | ||
| 225 | void(__cdecl* disconnect_all)(const struct AddonInstance_VFSEntry* instance); | ||
| 226 | bool(__cdecl* delete_it)(const struct AddonInstance_VFSEntry* instance, | ||
| 227 | const struct VFSURL* url); | ||
| 228 | bool(__cdecl* rename)(const struct AddonInstance_VFSEntry* instance, | ||
| 229 | const struct VFSURL* url, | ||
| 230 | const struct VFSURL* url2); | ||
| 231 | bool(__cdecl* directory_exists)(const struct AddonInstance_VFSEntry* instance, | ||
| 232 | const struct VFSURL* url); | ||
| 233 | bool(__cdecl* remove_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 234 | const struct VFSURL* url); | ||
| 235 | bool(__cdecl* create_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 236 | const struct VFSURL* url); | ||
| 237 | bool(__cdecl* get_directory)(const struct AddonInstance_VFSEntry* instance, | ||
| 238 | const struct VFSURL* url, | ||
| 239 | struct VFSDirEntry** entries, | ||
| 240 | int* num_entries, | ||
| 241 | VFSGetDirectoryCallbacks* callbacks); | ||
| 242 | bool(__cdecl* contains_files)(const struct AddonInstance_VFSEntry* instance, | ||
| 243 | const struct VFSURL* url, | ||
| 244 | struct VFSDirEntry** entries, | ||
| 85 | int* num_entries, | 245 | int* num_entries, |
| 86 | VFSGetDirectoryCallbacks* callbacks); | 246 | char* rootpath); |
| 87 | bool (__cdecl* contains_files) (const AddonInstance_VFSEntry* instance, | 247 | void(__cdecl* free_directory)(const struct AddonInstance_VFSEntry* instance, |
| 88 | const VFSURL* url, | 248 | struct VFSDirEntry* entries, |
| 89 | VFSDirEntry** entries, | 249 | int num_entries); |
| 90 | int* num_entries, | ||
| 91 | char* rootpath); | ||
| 92 | void (__cdecl* free_directory) (const AddonInstance_VFSEntry* instance, VFSDirEntry* entries, int num_entries); | ||
| 93 | } KodiToAddonFuncTable_VFSEntry; | 250 | } KodiToAddonFuncTable_VFSEntry; |
| 94 | 251 | ||
| 95 | typedef struct AddonInstance_VFSEntry /* internal */ | 252 | typedef struct AddonInstance_VFSEntry /* internal */ |
| 96 | { | 253 | { |
| 97 | AddonProps_VFSEntry props; | 254 | AddonProps_VFSEntry* props; |
| 98 | AddonToKodiFuncTable_VFSEntry toKodi; | 255 | AddonToKodiFuncTable_VFSEntry* toKodi; |
| 99 | KodiToAddonFuncTable_VFSEntry toAddon; | 256 | KodiToAddonFuncTable_VFSEntry* toAddon; |
| 100 | } AddonInstance_VFSEntry; | 257 | } AddonInstance_VFSEntry; |
| 101 | 258 | ||
| 259 | #ifdef __cplusplus | ||
| 102 | } /* extern "C" */ | 260 | } /* extern "C" */ |
| 103 | 261 | ||
| 104 | namespace kodi | 262 | namespace kodi |
| 105 | { | 263 | { |
| 106 | namespace addon | 264 | namespace addon |
| 107 | { | 265 | { |
| 108 | class CInstanceVFS : public IAddonInstance | 266 | |
| 267 | //############################################################################## | ||
| 268 | /// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators | ||
| 269 | /// \ingroup cpp_kodi_addon_vfs | ||
| 270 | /// @brief **VFS add-on general variables** | ||
| 271 | /// | ||
| 272 | /// Used to exchange the available options between Kodi and addon. | ||
| 273 | /// | ||
| 274 | /// | ||
| 275 | |||
| 276 | //============================================================================== | ||
| 277 | /// | ||
| 278 | /// \addtogroup cpp_kodi_addon_vfs | ||
| 279 | /// @brief \cpp_class{ kodi::addon::CInstanceVFS } | ||
| 280 | /// **Virtual Filesystem (VFS) add-on instance** | ||
| 281 | /// | ||
| 282 | /// This instance type is used to allow Kodi various additional file system | ||
| 283 | /// types. Be it a special file system, a compressed package or a system | ||
| 284 | /// available over the network, everything is possible with it. | ||
| 285 | /// | ||
| 286 | /// This usage can be requested under various conditions, for example explicitly | ||
| 287 | /// by another addon, by a Mimetype protocol defined in <b>`addon.xml`</b> or supported | ||
| 288 | /// file extensions. | ||
| 289 | /// | ||
| 290 | /// Include the header @ref VFS.h "#include <kodi/addon-instance/VFS.h>" | ||
| 291 | /// to use this class. | ||
| 292 | /// | ||
| 293 | /// ---------------------------------------------------------------------------- | ||
| 294 | /// | ||
| 295 | /// Here is an example of what the <b>`addon.xml.in`</b> would look like for an VFS addon: | ||
| 296 | /// | ||
| 297 | /// ~~~~~~~~~~~~~{.xml} | ||
| 298 | /// <?xml version="1.0" encoding="UTF-8"?> | ||
| 299 | /// <addon | ||
| 300 | /// id="vfs.myspecialnamefor" | ||
| 301 | /// version="1.0.0" | ||
| 302 | /// name="My VFS addon" | ||
| 303 | /// provider-name="Your Name"> | ||
| 304 | /// <requires>@ADDON_DEPENDS@</requires> | ||
| 305 | /// <extension | ||
| 306 | /// point="kodi.vfs" | ||
| 307 | /// protocols="myprot" | ||
| 308 | /// extensions=".abc|.def" | ||
| 309 | /// files="true" | ||
| 310 | /// filedirectories="true" | ||
| 311 | /// directories="true" | ||
| 312 | /// encodedhostname="true" | ||
| 313 | /// supportDialog="true" | ||
| 314 | /// supportPath="true" | ||
| 315 | /// supportUsername="true" | ||
| 316 | /// supportPassword="true" | ||
| 317 | /// supportPort="true" | ||
| 318 | /// supportBrowsing="true" | ||
| 319 | /// supportWrite="true" | ||
| 320 | /// defaultPort="1234" | ||
| 321 | /// label="30000" | ||
| 322 | /// zeroconf="your_special_zeroconf_allowed_identifier" | ||
| 323 | /// library_@PLATFORM@="@LIBRARY_FILENAME@"/> | ||
| 324 | /// <extension point="xbmc.addon.metadata"> | ||
| 325 | /// <summary lang="en_GB">My VFS addon summary</summary> | ||
| 326 | /// <description lang="en_GB">My VFS description</description> | ||
| 327 | /// <platform>@PLATFORM@</platform> | ||
| 328 | /// </extension> | ||
| 329 | /// </addon> | ||
| 330 | /// ~~~~~~~~~~~~~ | ||
| 331 | /// | ||
| 332 | /// @note Regarding boolean values with "false", these can also be omitted, | ||
| 333 | /// since this would be the default. | ||
| 334 | /// | ||
| 335 | /// | ||
| 336 | /// ### Standard values that can be declared for processing in `addon.xml`. | ||
| 337 | /// | ||
| 338 | /// These values are used by Kodi to identify associated streams and file | ||
| 339 | /// extensions and then to select the associated addon. | ||
| 340 | /// | ||
| 341 | /// \table_start | ||
| 342 | /// \table_h3{ Labels, Type, Description } | ||
| 343 | /// \table_row3{ <b>`point`</b>, | ||
| 344 | /// \anchor cpp_kodi_addon_vfs_point | ||
| 345 | /// string, | ||
| 346 | /// The identification of the addon instance to VFS is mandatory <b>`kodi.vfs`</b>. | ||
| 347 | /// In addition\, the instance declared in the first <b>`<extension ... />`</b> is also the main type of addon. | ||
| 348 | /// } | ||
| 349 | /// \table_row3{ <b>`defaultPort`</b>, | ||
| 350 | /// \anchor cpp_kodi_addon_vfs_defaultPort | ||
| 351 | /// integer, | ||
| 352 | /// Default [networking port](https://en.wikipedia.org/wiki/Port_(computer_networking)) | ||
| 353 | /// to use for protocol. | ||
| 354 | /// } | ||
| 355 | /// \table_row3{ <b>`directories`</b>, | ||
| 356 | /// \anchor cpp_kodi_addon_vfs_directories | ||
| 357 | /// boolean, | ||
| 358 | /// VFS entry can list directories. | ||
| 359 | /// } | ||
| 360 | /// \table_row3{ <b>`extensions`</b>, | ||
| 361 | /// \anchor cpp_kodi_addon_vfs_extensions | ||
| 362 | /// string, | ||
| 363 | /// Extensions for VFS entry.\n | ||
| 364 | /// It is possible to declare several using <b>`|`</b>\, e.g. <b>`.abc|.def|.ghi`</b>. | ||
| 365 | /// } | ||
| 366 | /// \table_row3{ <b>`encodedhostname`</b>, | ||
| 367 | /// \anchor cpp_kodi_addon_vfs_encodedhostname | ||
| 368 | /// boolean, | ||
| 369 | /// URL protocol from add-ons use encoded hostnames. | ||
| 370 | /// } | ||
| 371 | /// \table_row3{ <b>`filedirectories`</b>, | ||
| 372 | /// \anchor cpp_kodi_addon_vfs_filedirectories | ||
| 373 | /// boolean, | ||
| 374 | /// VFS entry contains file directories. | ||
| 375 | /// } | ||
| 376 | /// \table_row3{ <b>`files`</b>, | ||
| 377 | /// \anchor cpp_kodi_addon_vfs_directories | ||
| 378 | /// boolean, | ||
| 379 | /// Set to declare that VFS provides files. | ||
| 380 | /// } | ||
| 381 | /// \table_row3{ <b>`protocols`</b>, | ||
| 382 | /// \anchor cpp_kodi_addon_vfs_protocols | ||
| 383 | /// boolean, | ||
| 384 | /// Protocols for VFS entry.\n | ||
| 385 | /// It is possible to declare several using <b>`|`</b>\, e.g. <b>`myprot1|myprot2`</b>.\n | ||
| 386 | /// @note This field also used to show on GUI\, see <b>`supportBrowsing`</b> below about <b>*2:</b>. | ||
| 387 | /// When used there\, however\, only a **single** protocol is possible! | ||
| 388 | /// } | ||
| 389 | /// \table_row3{ <b>`supportWrite`</b>, | ||
| 390 | /// \anchor cpp_kodi_addon_vfs_supportWrite | ||
| 391 | /// boolean, | ||
| 392 | /// Protocol supports write operations. | ||
| 393 | /// } | ||
| 394 | /// \table_row3{ <b>`zeroconf`</b>, | ||
| 395 | /// \anchor cpp_kodi_addon_vfs_zeroconf | ||
| 396 | /// string, | ||
| 397 | /// [Zero conf](https://en.wikipedia.org/wiki/Zero-configuration_networking) announce string for VFS protocol. | ||
| 398 | /// } | ||
| 399 | /// \table_row3{ <b>`library_@PLATFORM@`</b>, | ||
| 400 | /// \anchor cpp_kodi_addon_vfs_library | ||
| 401 | /// string, | ||
| 402 | /// The runtime library used for the addon. This is usually declared by `cmake` and correctly displayed in the translated <b>`addon.xml`</b>. | ||
| 403 | /// } | ||
| 404 | /// \table_end | ||
| 405 | /// | ||
| 406 | /// | ||
| 407 | /// ### User selectable parts of the addon. | ||
| 408 | /// | ||
| 409 | /// The following table describes the values that can be defined by <b>`addon.xml`</b> | ||
| 410 | /// and which part they relate to for user input. | ||
| 411 | /// | ||
| 412 | /// \table_start | ||
| 413 | /// \table_h3{ Labels, Type, Description } | ||
| 414 | /// \table_row3{ <b>`supportBrowsing`</b>, | ||
| 415 | /// \anchor cpp_kodi_addon_vfs_protocol_supportBrowsing | ||
| 416 | /// boolean, | ||
| 417 | /// Protocol supports server browsing. Used to open related sources by users in the window.\n\n | ||
| 418 | /// | Associated places in Kodi: | | ||
| 419 | /// | :---- | | ||
| 420 | /// | \image html cpp_kodi_addon_vfs_protocol_1.png | | ||
| 421 | /// <br> | ||
| 422 | /// <b>*1:</b> The entry in the menu represented by this option corresponds to the text given with <b>`label`</b>. | ||
| 423 | /// When the button is pressed\, @ref CInstanceVFS::GetDirectory is called on the add-on to get its content.\n | ||
| 424 | /// <b>*2:</b> Protocol name of the stream defined with <b>`protocols`</b> in xml.\n | ||
| 425 | /// @remark See also <b>`supportDialog`</b> about <b>*3:</b>. | ||
| 426 | /// } | ||
| 427 | /// \table_row3{ <b>`supportDialog`</b>, | ||
| 428 | /// \anchor cpp_kodi_addon_vfs_protocol_supportDialog | ||
| 429 | /// boolean, | ||
| 430 | /// To point out that Kodi assigns a dialog to this VFS in order to compare it with other values e.g. query supportPassword in it.\n | ||
| 431 | /// This will be available when adding sources in Kodi under <b>"Add network location..."</b>.\n\n | ||
| 432 | /// | Associated places in Kodi: | | ||
| 433 | /// | :---- | | ||
| 434 | /// | \image html cpp_kodi_addon_vfs_protocol_2.png | | ||
| 435 | /// <br> | ||
| 436 | /// <b>*1:</b> Field for selecting the VFS handler\, the addon will be available if <b>`supportDialog`</b> is set to <b>`true`</b>.\n | ||
| 437 | /// <b>*2:</b> To set the associated server address. **Note:** *This field is always activated and cannot be changed by the addon.*\n | ||
| 438 | /// <b>*3:</b> If <b>`supportBrowsing`</b> is set to <b>`true`</b>\, the button for opening a file selection dialog is given here too\, as in the file window.\n | ||
| 439 | /// <b>*4:</b> This field is available if <b>`supportPath`</b> is set to <b>`true`</b>.\n | ||
| 440 | /// <b>*5:</b> To edit the connection port. This field is available if <b>`supportPort`</b> is set to <b>`true`</b>.\n | ||
| 441 | /// <b>*6:</b> This sets the required username and is available when <b>`supportUsername`</b> is set to <b>`true`</b>.\n | ||
| 442 | /// <b>*7:</b> This sets the required password and is available when <b>`supportPassword`</b> is set to <b>`true`</b>. | ||
| 443 | /// } | ||
| 444 | /// \table_row3{ <b>`supportPath`</b>, | ||
| 445 | /// \anchor cpp_kodi_addon_vfs_protocol_supportPath | ||
| 446 | /// boolean, | ||
| 447 | /// Protocol has path in addition to server name (see <b>`supportDialog`</b> about <b>*4:</b>). | ||
| 448 | /// } | ||
| 449 | /// \table_row3{ <b>`supportPort`</b>, | ||
| 450 | /// \anchor cpp_kodi_addon_vfs_protocol_supportPort | ||
| 451 | /// boolean, | ||
| 452 | /// Protocol supports port customization (see <b>`supportDialog`</b> about <b>*5:</b>). | ||
| 453 | /// } | ||
| 454 | /// \table_row3{ <b>`supportUsername`</b>, | ||
| 455 | /// \anchor cpp_kodi_addon_vfs_protocol_supportUsername | ||
| 456 | /// boolean, | ||
| 457 | /// Protocol uses logins (see <b>`supportDialog`</b> about <b>*6:</b>). | ||
| 458 | /// } | ||
| 459 | /// \table_row3{ <b>`supportPassword`</b>, | ||
| 460 | /// \anchor cpp_kodi_addon_vfs_protocol_supportPassword | ||
| 461 | /// boolean, | ||
| 462 | /// Protocol supports passwords (see <b>`supportDialog`</b> about <b>*7:</b>). | ||
| 463 | /// } | ||
| 464 | /// \table_row3{ <b>`protocols`</b>, | ||
| 465 | /// \anchor cpp_kodi_addon_vfs_protocol_protocols | ||
| 466 | /// string, | ||
| 467 | /// Protocols for VFS entry. | ||
| 468 | /// @note This field is not editable and only used on GUI to show his name\, see <b>`supportBrowsing`</b> about <b>*2:</b> | ||
| 469 | /// } | ||
| 470 | /// \table_row3{ <b>`label`</b>, | ||
| 471 | /// \anchor cpp_kodi_addon_vfs_protocol_label | ||
| 472 | /// integer, | ||
| 473 | /// The text identification number used in Kodi for display in the menu at <b>`supportDialog`</b> | ||
| 474 | /// as a selection option and at <b>`supportBrowsing`</b> (see his image reference <b>*1</b>) as a menu entry.\n | ||
| 475 | /// This can be a text identifier in Kodi or from addon.\n | ||
| 476 | /// @remark For addon within <b>30000</b>-<b>30999</b> or <b>32000</b>-<b>32999</b>. | ||
| 477 | /// } | ||
| 478 | /// \table_end | ||
| 479 | /// | ||
| 480 | /// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml. | ||
| 481 | /// | ||
| 482 | /// | ||
| 483 | /// -------------------------------------------------------------------------- | ||
| 484 | /// | ||
| 485 | /// | ||
| 486 | /// **Example:** | ||
| 487 | /// | ||
| 488 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 489 | /// #include <kodi/addon-instance/VFS.h> | ||
| 490 | /// | ||
| 491 | /// class CMyVFS : public kodi::addon::CInstanceVFS | ||
| 492 | /// { | ||
| 493 | /// public: | ||
| 494 | /// CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion); | ||
| 495 | /// | ||
| 496 | /// // Add all your required functions, the most CInstanceVFS functions of | ||
| 497 | /// // must be included to have addon working correctly. | ||
| 498 | /// ... | ||
| 499 | /// }; | ||
| 500 | /// | ||
| 501 | /// CMyVFS::CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion) | ||
| 502 | /// : CInstanceVFS(instance, kodiVersion) | ||
| 503 | /// { | ||
| 504 | /// ... | ||
| 505 | /// } | ||
| 506 | /// | ||
| 507 | /// ... | ||
| 508 | /// | ||
| 509 | /// /*----------------------------------------------------------------------*/ | ||
| 510 | /// | ||
| 511 | /// class CMyAddon : public kodi::addon::CAddonBase | ||
| 512 | /// { | ||
| 513 | /// public: | ||
| 514 | /// CMyAddon() { } | ||
| 515 | /// ADDON_STATUS CreateInstance(int instanceType, | ||
| 516 | /// const std::string& instanceID, | ||
| 517 | /// KODI_HANDLE instance, | ||
| 518 | /// const std::string& version, | ||
| 519 | /// KODI_HANDLE& addonInstance) override; | ||
| 520 | /// }; | ||
| 521 | /// | ||
| 522 | /// // If you use only one instance in your add-on, can be instanceType and | ||
| 523 | /// // instanceID ignored | ||
| 524 | /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType, | ||
| 525 | /// const std::string& instanceID, | ||
| 526 | /// KODI_HANDLE instance, | ||
| 527 | /// const std::string& version, | ||
| 528 | /// KODI_HANDLE& addonInstance) | ||
| 529 | /// { | ||
| 530 | /// if (instanceType == ADDON_INSTANCE_VFS) | ||
| 531 | /// { | ||
| 532 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my VFS instance"); | ||
| 533 | /// addonInstance = new CMyVFS(instance, version); | ||
| 534 | /// return ADDON_STATUS_OK; | ||
| 535 | /// } | ||
| 536 | /// else if (...) | ||
| 537 | /// { | ||
| 538 | /// ... | ||
| 539 | /// } | ||
| 540 | /// return ADDON_STATUS_UNKNOWN; | ||
| 541 | /// } | ||
| 542 | /// | ||
| 543 | /// ADDONCREATOR(CMyAddon) | ||
| 544 | /// ~~~~~~~~~~~~~ | ||
| 545 | /// | ||
| 546 | /// The destruction of the example class `CMyVFS` is called from | ||
| 547 | /// Kodi's header. Manually deleting the add-on instance is not required. | ||
| 548 | /// | ||
| 549 | //---------------------------------------------------------------------------- | ||
| 550 | class ATTRIBUTE_HIDDEN CInstanceVFS : public IAddonInstance | ||
| 551 | { | ||
| 552 | public: | ||
| 553 | //========================================================================== | ||
| 554 | /// | ||
| 555 | /// @ingroup cpp_kodi_addon_vfs | ||
| 556 | /// @brief VFS class constructor used to support multiple instance | ||
| 557 | /// types | ||
| 558 | /// | ||
| 559 | /// @param[in] instance The instance value given to | ||
| 560 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | ||
| 561 | /// @param[in] kodiVersion [opt] given from Kodi by @ref CAddonBase::CreateInstance | ||
| 562 | /// to identify his instance API version | ||
| 563 | /// | ||
| 564 | /// @note Instance path as a single is not supported by this type. It must | ||
| 565 | /// ensure that it can be called up several times. | ||
| 566 | /// | ||
| 567 | /// @warning Only use `instance` from the @ref CAddonBase::CreateInstance or | ||
| 568 | /// @ref CAddonBase::CreateInstance call. | ||
| 569 | /// | ||
| 570 | explicit CInstanceVFS(KODI_HANDLE instance, const std::string& kodiVersion = "") | ||
| 571 | : IAddonInstance(ADDON_INSTANCE_VFS, | ||
| 572 | !kodiVersion.empty() ? kodiVersion : GetKodiTypeVersion(ADDON_INSTANCE_VFS)) | ||
| 573 | { | ||
| 574 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 575 | throw std::logic_error("kodi::addon::CInstanceVFS: Creation of multiple together with single " | ||
| 576 | "instance way is not allowed!"); | ||
| 577 | |||
| 578 | SetAddonStruct(instance); | ||
| 579 | } | ||
| 580 | //-------------------------------------------------------------------------- | ||
| 581 | |||
| 582 | //========================================================================== | ||
| 583 | /// | ||
| 584 | /// @ingroup cpp_kodi_addon_vfs | ||
| 585 | /// @brief Destructor | ||
| 586 | /// | ||
| 587 | ~CInstanceVFS() override = default; | ||
| 588 | //-------------------------------------------------------------------------- | ||
| 589 | |||
| 590 | //========================================================================== | ||
| 591 | /// | ||
| 592 | /// @defgroup cpp_kodi_addon_vfs_general 1. General access functions | ||
| 593 | /// @ingroup cpp_kodi_addon_vfs | ||
| 594 | /// @brief **General access functions** | ||
| 595 | /// | ||
| 596 | /// This functions which are intended for getting folders, editing storage | ||
| 597 | /// locations and file system queries. | ||
| 598 | /// | ||
| 599 | |||
| 600 | //========================================================================== | ||
| 601 | /// | ||
| 602 | /// @defgroup cpp_kodi_addon_vfs_filecontrol 2. File editing functions | ||
| 603 | /// @ingroup cpp_kodi_addon_vfs | ||
| 604 | /// @brief **File editing functions.** | ||
| 605 | /// | ||
| 606 | /// This value represents the addon-side handlers and to be able to identify | ||
| 607 | /// his own parts in the event of further access. | ||
| 608 | /// | ||
| 609 | |||
| 610 | //@{ | ||
| 611 | //========================================================================== | ||
| 612 | /// | ||
| 613 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 614 | /// @brief Open a file for input | ||
| 615 | /// | ||
| 616 | /// @param[in] url The URL of the file | ||
| 617 | /// @return Context for the opened file | ||
| 618 | virtual void* Open(const VFSURL& url) { return nullptr; } | ||
| 619 | |||
| 620 | //========================================================================== | ||
| 621 | /// | ||
| 622 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 623 | /// @brief Open a file for output | ||
| 624 | /// | ||
| 625 | /// @param[in] url The URL of the file | ||
| 626 | /// @param[in] overWrite Whether or not to overwrite an existing file | ||
| 627 | /// @return Context for the opened file | ||
| 628 | /// | ||
| 629 | virtual void* OpenForWrite(const VFSURL& url, bool overWrite) { return nullptr; } | ||
| 630 | //-------------------------------------------------------------------------- | ||
| 631 | |||
| 632 | //========================================================================== | ||
| 633 | /// | ||
| 634 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 635 | /// @brief Close a file | ||
| 636 | /// | ||
| 637 | /// @param[in] context The context of the file | ||
| 638 | /// @return True on success, false on failure | ||
| 639 | /// | ||
| 640 | virtual bool Close(void* context) { return false; } | ||
| 641 | //-------------------------------------------------------------------------- | ||
| 642 | |||
| 643 | //========================================================================== | ||
| 644 | /// | ||
| 645 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 646 | /// @brief Read from a file | ||
| 647 | /// | ||
| 648 | /// @param[in] context The context of the file | ||
| 649 | /// @param[out] buffer The buffer to read data into | ||
| 650 | /// @param[in] uiBufSize Number of bytes to read | ||
| 651 | /// @return Number of bytes read | ||
| 652 | /// | ||
| 653 | virtual ssize_t Read(void* context, void* buffer, size_t uiBufSize) { return -1; } | ||
| 654 | //-------------------------------------------------------------------------- | ||
| 655 | |||
| 656 | //========================================================================== | ||
| 657 | /// | ||
| 658 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 659 | /// @brief Write to a file | ||
| 660 | /// | ||
| 661 | /// @param[in] context The context of the file | ||
| 662 | /// @param[in] buffer The buffer to read data from | ||
| 663 | /// @param[in] uiBufSize Number of bytes to write | ||
| 664 | /// @return Number of bytes written | ||
| 665 | /// | ||
| 666 | virtual ssize_t Write(void* context, const void* buffer, size_t uiBufSize) { return -1; } | ||
| 667 | //-------------------------------------------------------------------------- | ||
| 668 | |||
| 669 | //========================================================================== | ||
| 670 | /// | ||
| 671 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 672 | /// @brief Seek in a file | ||
| 673 | /// | ||
| 674 | /// @param[in] context The context of the file | ||
| 675 | /// @param[in] position The position to seek to | ||
| 676 | /// @param[in] whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END) | ||
| 677 | /// @return Offset in file after seek | ||
| 678 | /// | ||
| 679 | virtual int64_t Seek(void* context, int64_t position, int whence) { return -1; } | ||
| 680 | //-------------------------------------------------------------------------- | ||
| 681 | |||
| 682 | //========================================================================== | ||
| 683 | /// | ||
| 684 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 685 | /// @brief Truncate a file | ||
| 686 | /// | ||
| 687 | /// @param[in] context The context of the file | ||
| 688 | /// @param[in] size The size to truncate the file to | ||
| 689 | /// @return 0 on success, -1 on error | ||
| 690 | /// | ||
| 691 | virtual int Truncate(void* context, int64_t size) { return -1; } | ||
| 692 | //-------------------------------------------------------------------------- | ||
| 693 | |||
| 694 | //========================================================================== | ||
| 695 | /// | ||
| 696 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 697 | /// @brief Get total size of a file | ||
| 698 | /// | ||
| 699 | /// @param[in] context The context of the file | ||
| 700 | /// @return Total file size | ||
| 701 | /// | ||
| 702 | virtual int64_t GetLength(void* context) { return 0; } | ||
| 703 | //-------------------------------------------------------------------------- | ||
| 704 | |||
| 705 | //========================================================================== | ||
| 706 | /// | ||
| 707 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 708 | /// @brief Get current position in a file | ||
| 709 | /// | ||
| 710 | /// @param[in] context The context of the file | ||
| 711 | /// @return Current position | ||
| 712 | /// | ||
| 713 | virtual int64_t GetPosition(void* context) { return 0; } | ||
| 714 | //-------------------------------------------------------------------------- | ||
| 715 | |||
| 716 | //========================================================================== | ||
| 717 | /// | ||
| 718 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 719 | /// @brief Get chunk size of a file | ||
| 720 | /// | ||
| 721 | /// @param[in] context The context of the file | ||
| 722 | /// @return Chunk size | ||
| 723 | /// | ||
| 724 | virtual int GetChunkSize(void* context) { return 1; } | ||
| 725 | //-------------------------------------------------------------------------- | ||
| 726 | |||
| 727 | //========================================================================== | ||
| 728 | /// | ||
| 729 | /// @ingroup cpp_kodi_addon_vfs_filecontrol | ||
| 730 | /// @brief Perform an IO-control on the file | ||
| 731 | /// | ||
| 732 | /// @param[in] context The context of the file | ||
| 733 | /// @param[in] request The requested IO-control | ||
| 734 | /// @param[in] param Parameter attached to the IO-control | ||
| 735 | /// @return -1 on error, >= 0 on success | ||
| 736 | /// | ||
| 737 | virtual int IoControl(void* context, VFS_IOCTRL request, void* param) { return -1; } | ||
| 738 | //-------------------------------------------------------------------------- | ||
| 739 | //@} | ||
| 740 | |||
| 741 | //@{ | ||
| 742 | //========================================================================== | ||
| 743 | /// | ||
| 744 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 745 | /// @brief Stat a file | ||
| 746 | /// | ||
| 747 | /// @param[in] url The URL of the file | ||
| 748 | /// @param[in] buffer The buffer to store results in | ||
| 749 | /// @return -1 on error, 0 otherwise | ||
| 750 | /// | ||
| 751 | virtual int Stat(const VFSURL& url, struct __stat64* buffer) { return 0; } | ||
| 752 | //-------------------------------------------------------------------------- | ||
| 753 | |||
| 754 | //========================================================================== | ||
| 755 | /// | ||
| 756 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 757 | /// @brief Check for file existence | ||
| 758 | /// | ||
| 759 | /// @param[in] url The URL of the file | ||
| 760 | /// @return True if file exists, false otherwise | ||
| 761 | /// | ||
| 762 | virtual bool Exists(const VFSURL& url) { return false; } | ||
| 763 | //-------------------------------------------------------------------------- | ||
| 764 | |||
| 765 | //========================================================================== | ||
| 766 | /// | ||
| 767 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 768 | /// @brief Clear out any idle connections | ||
| 769 | /// | ||
| 770 | virtual void ClearOutIdle() {} | ||
| 771 | //-------------------------------------------------------------------------- | ||
| 772 | |||
| 773 | //========================================================================== | ||
| 774 | /// | ||
| 775 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 776 | /// @brief Disconnect all connections | ||
| 777 | /// | ||
| 778 | virtual void DisconnectAll() {} | ||
| 779 | //-------------------------------------------------------------------------- | ||
| 780 | |||
| 781 | //========================================================================== | ||
| 782 | /// | ||
| 783 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 784 | /// @brief Delete a file | ||
| 785 | /// | ||
| 786 | /// @param[in] url The URL of the file | ||
| 787 | /// @return True if deletion was successful, false otherwise | ||
| 788 | /// | ||
| 789 | virtual bool Delete(const VFSURL& url) { return false; } | ||
| 790 | //-------------------------------------------------------------------------- | ||
| 791 | |||
| 792 | //========================================================================== | ||
| 793 | /// | ||
| 794 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 795 | /// @brief Rename a file | ||
| 796 | /// | ||
| 797 | /// @param[in] url The URL of the source file | ||
| 798 | /// @param[in] url2 The URL of the destination file | ||
| 799 | /// @return True if deletion was successful, false otherwise | ||
| 800 | /// | ||
| 801 | virtual bool Rename(const VFSURL& url, const VFSURL& url2) { return false; } | ||
| 802 | //-------------------------------------------------------------------------- | ||
| 803 | |||
| 804 | //========================================================================== | ||
| 805 | /// | ||
| 806 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 807 | /// @brief Check for directory existence | ||
| 808 | /// | ||
| 809 | /// @param[in] url The URL of the file | ||
| 810 | /// @return True if directory exists, false otherwise | ||
| 811 | /// | ||
| 812 | virtual bool DirectoryExists(const VFSURL& url) { return false; } | ||
| 813 | //-------------------------------------------------------------------------- | ||
| 814 | |||
| 815 | //========================================================================== | ||
| 816 | /// | ||
| 817 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 818 | /// @brief Remove a directory | ||
| 819 | /// | ||
| 820 | /// @param[in] url The URL of the directory | ||
| 821 | /// @return True if removal was successful, false otherwise | ||
| 822 | /// | ||
| 823 | virtual bool RemoveDirectory(const VFSURL& url) { return false; } | ||
| 824 | //-------------------------------------------------------------------------- | ||
| 825 | |||
| 826 | //========================================================================== | ||
| 827 | /// | ||
| 828 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 829 | /// @brief Create a directory | ||
| 830 | /// | ||
| 831 | /// @param[in] url The URL of the file | ||
| 832 | /// @return True if creation was successful, false otherwise | ||
| 833 | /// | ||
| 834 | virtual bool CreateDirectory(const VFSURL& url) { return false; } | ||
| 835 | //-------------------------------------------------------------------------- | ||
| 836 | |||
| 837 | //========================================================================== | ||
| 838 | /// | ||
| 839 | /// @defgroup cpp_kodi_addon_vfs_general_cb_GetDirectory **Callbacks GetDirectory()** | ||
| 840 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 841 | /// @brief Callback functions on GetDirectory() | ||
| 842 | /// | ||
| 843 | /// This functions becomes available during call of GetDirectory() from | ||
| 844 | /// Kodi. | ||
| 845 | /// | ||
| 846 | /// If GetDirectory() returns false becomes the parts from here used on | ||
| 847 | /// next call of the function. | ||
| 848 | /// | ||
| 849 | /// **Example:** | ||
| 850 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 851 | /// | ||
| 852 | /// #include <kodi/addon-instance/VFS.h> | ||
| 853 | /// | ||
| 854 | /// ... | ||
| 855 | /// | ||
| 856 | /// bool CMyVFS::GetDirectory(const VFSURL& url, std::vector<kodi::vfs::CDirEntry>& items, CVFSCallbacks callbacks) | ||
| 857 | /// { | ||
| 858 | /// std::string neededString; | ||
| 859 | /// callbacks.GetKeyboardInput("Test", neededString, true); | ||
| 860 | /// if (neededString.empty()) | ||
| 861 | /// return false; | ||
| 862 | /// | ||
| 863 | /// // Do the work | ||
| 864 | /// ... | ||
| 865 | /// return true; | ||
| 866 | /// } | ||
| 867 | /// ~~~~~~~~~~~~~ | ||
| 868 | /// | ||
| 869 | class CVFSCallbacks | ||
| 109 | { | 870 | { |
| 110 | public: | 871 | public: |
| 111 | explicit CInstanceVFS(KODI_HANDLE instance) | 872 | /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory |
| 112 | : IAddonInstance(ADDON_INSTANCE_VFS) | 873 | /// @brief Require keyboard input |
| 113 | { | ||
| 114 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 115 | throw std::logic_error("kodi::addon::CInstanceVFS: Creation of multiple together with single instance way is not allowed!"); | ||
| 116 | |||
| 117 | SetAddonStruct(instance); | ||
| 118 | } | ||
| 119 | |||
| 120 | ~CInstanceVFS() override = default; | ||
| 121 | |||
| 122 | /// @brief Open a file for input | ||
| 123 | /// | ||
| 124 | /// @param[in] url The URL of the file | ||
| 125 | /// @return Context for the opened file | ||
| 126 | virtual void* Open(const VFSURL& url) { return nullptr; } | ||
| 127 | |||
| 128 | /// @brief Open a file for output | ||
| 129 | /// | ||
| 130 | /// @param[in] url The URL of the file | ||
| 131 | /// @param[in] overWrite Whether or not to overwrite an existing file | ||
| 132 | /// @return Context for the opened file | ||
| 133 | /// | ||
| 134 | virtual void* OpenForWrite(const VFSURL& url, bool overWrite) { return nullptr; } | ||
| 135 | |||
| 136 | /// @brief Read from a file | ||
| 137 | /// | ||
| 138 | /// @param[in] context The context of the file | ||
| 139 | /// @param[out] buffer The buffer to read data into | ||
| 140 | /// @param[in] uiBufSize Number of bytes to read | ||
| 141 | /// @return Number of bytes read | ||
| 142 | /// | ||
| 143 | virtual ssize_t Read(void* context, void* buffer, size_t uiBufSize) { return -1; } | ||
| 144 | |||
| 145 | /// @brief Write to a file | ||
| 146 | /// | ||
| 147 | /// @param[in] context The context of the file | ||
| 148 | /// @param[in] buffer The buffer to read data from | ||
| 149 | /// @param[in] uiBufSize Number of bytes to write | ||
| 150 | /// @return Number of bytes written | ||
| 151 | /// | ||
| 152 | virtual ssize_t Write(void* context, const void* buffer, size_t uiBufSize) { return -1; } | ||
| 153 | |||
| 154 | /// @brief Seek in a file | ||
| 155 | /// | ||
| 156 | /// @param[in] context The context of the file | ||
| 157 | /// @param[in] position The position to seek to | ||
| 158 | /// @param[in] whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END) | ||
| 159 | /// @return Offset in file after seek | ||
| 160 | /// | ||
| 161 | virtual int64_t Seek(void* context, int64_t position, int whence) { return -1; } | ||
| 162 | |||
| 163 | /// @brief Truncate a file | ||
| 164 | /// | ||
| 165 | /// @param[in] context The context of the file | ||
| 166 | /// @param[in] size The size to truncate the file to | ||
| 167 | /// @return 0 on success, -1 on error | ||
| 168 | /// | ||
| 169 | virtual int Truncate(void* context, int64_t size) { return -1; } | ||
| 170 | |||
| 171 | /// @brief Get total size of a file | ||
| 172 | /// | ||
| 173 | /// @param[in] context The context of the file | ||
| 174 | /// @return Total file size | ||
| 175 | /// | ||
| 176 | virtual int64_t GetLength(void* context) { return 0; } | ||
| 177 | |||
| 178 | /// @brief Get current position in a file | ||
| 179 | /// | ||
| 180 | /// @param[in] context The context of the file | ||
| 181 | /// @return Current position | ||
| 182 | /// | ||
| 183 | virtual int64_t GetPosition(void* context) { return 0; } | ||
| 184 | |||
| 185 | /// @brief Get chunk size of a file | ||
| 186 | /// | ||
| 187 | /// @param[in] context The context of the file | ||
| 188 | /// @return Chunk size | ||
| 189 | /// | ||
| 190 | virtual int GetChunkSize(void* context) { return 1; } | ||
| 191 | |||
| 192 | /// @brief Perform an IO-control on the file | ||
| 193 | /// | ||
| 194 | /// @param[in] context The context of the file | ||
| 195 | /// @param[in] request The requested IO-control | ||
| 196 | /// @param[in] param Parameter attached to the IO-control | ||
| 197 | /// @return -1 on error, >= 0 on success | ||
| 198 | /// | ||
| 199 | virtual int IoControl(void* context, XFILE::EIoControl request, void* param) { return -1; } | ||
| 200 | |||
| 201 | /// @brief Close a file | ||
| 202 | /// | ||
| 203 | /// @param[in] context The context of the file | ||
| 204 | /// @return True on success, false on failure | ||
| 205 | /// | ||
| 206 | virtual bool Close(void* context) { return false; } | ||
| 207 | |||
| 208 | /// @brief Stat a file | ||
| 209 | /// | ||
| 210 | /// @param[in] url The URL of the file | ||
| 211 | /// @param[in] buffer The buffer to store results in | ||
| 212 | /// @return -1 on error, 0 otherwise | ||
| 213 | /// | ||
| 214 | virtual int Stat(const VFSURL& url, struct __stat64* buffer) { return 0; } | ||
| 215 | |||
| 216 | /// @brief Check for file existence | ||
| 217 | /// | ||
| 218 | /// @param[in] url The URL of the file | ||
| 219 | /// @return True if file exists, false otherwise | ||
| 220 | /// | ||
| 221 | virtual bool Exists(const VFSURL& url) { return false; } | ||
| 222 | |||
| 223 | /// @brief Clear out any idle connections | ||
| 224 | /// | ||
| 225 | virtual void ClearOutIdle() { } | ||
| 226 | |||
| 227 | /// @brief Disconnect all connections | ||
| 228 | /// | ||
| 229 | virtual void DisconnectAll() { } | ||
| 230 | |||
| 231 | /// @brief Delete a file | ||
| 232 | /// | ||
| 233 | /// @param[in] url The URL of the file | ||
| 234 | /// @return True if deletion was successful, false otherwise | ||
| 235 | /// | ||
| 236 | virtual bool Delete(const VFSURL& url) { return false; } | ||
| 237 | |||
| 238 | /// @brief Rename a file | ||
| 239 | /// | ||
| 240 | /// @param[in] url The URL of the source file | ||
| 241 | /// @param[in] url2 The URL of the destination file | ||
| 242 | /// @return True if deletion was successful, false otherwise | ||
| 243 | /// | ||
| 244 | virtual bool Rename(const VFSURL& url, const VFSURL& url2) { return false; } | ||
| 245 | |||
| 246 | /// @brief Check for directory existence | ||
| 247 | /// | ||
| 248 | /// @param[in] url The URL of the file | ||
| 249 | /// @return True if directory exists, false otherwise | ||
| 250 | /// | ||
| 251 | virtual bool DirectoryExists(const VFSURL& url) { return false; } | ||
| 252 | |||
| 253 | /// @brief Remove a directory | ||
| 254 | /// | ||
| 255 | /// @param[in] url The URL of the directory | ||
| 256 | /// @return True if removal was successful, false otherwise | ||
| 257 | /// | ||
| 258 | virtual bool RemoveDirectory(const VFSURL& url) { return false; } | ||
| 259 | |||
| 260 | /// @brief Create a directory | ||
| 261 | /// | ||
| 262 | /// @param[in] url The URL of the file | ||
| 263 | /// @return True if creation was successful, false otherwise | ||
| 264 | /// | ||
| 265 | virtual bool CreateDirectory(const VFSURL& url) { return false; } | ||
| 266 | |||
| 267 | /// @brief Callback functions on GetDirectory() | ||
| 268 | /// | ||
| 269 | /// This functions becomes available during call of GetDirectory() from | ||
| 270 | /// Kodi. | ||
| 271 | /// | ||
| 272 | /// If GetDirectory() returns false becomes the parts from here used on | ||
| 273 | /// next call of the function. | ||
| 274 | /// | ||
| 275 | /// **Example:** | ||
| 276 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 277 | /// | 874 | /// |
| 278 | /// #include <kodi/addon-instance/VFS.h> | 875 | /// Becomes called if GetDirectory() returns false and GetDirectory() |
| 876 | /// becomes after entry called again. | ||
| 279 | /// | 877 | /// |
| 280 | /// ... | 878 | /// @param[in] heading The heading of the keyboard dialog |
| 879 | /// @param[out] input The resulting string. Returns string after | ||
| 880 | /// second call! | ||
| 881 | /// @param[in] hiddenInput To show input only as "*" on dialog | ||
| 882 | /// @return True if input was received, false otherwise | ||
| 281 | /// | 883 | /// |
| 282 | /// bool CMyFile::GetDirectory(const VFSURL& url, std::vector<kodi::vfs::CDirEntry>& items, CVFSCallbacks callbacks) | 884 | bool GetKeyboardInput(const std::string& heading, std::string& input, bool hiddenInput = false) |
| 283 | /// { | ||
| 284 | /// std::string neededString; | ||
| 285 | /// callbacks.GetKeyboardInput("Test", neededString, true); | ||
| 286 | /// if (neededString.empty()) | ||
| 287 | /// return false; | ||
| 288 | /// | ||
| 289 | /// /* Do the work */ | ||
| 290 | /// ... | ||
| 291 | /// return true; | ||
| 292 | /// } | ||
| 293 | /// ~~~~~~~~~~~~~ | ||
| 294 | /// | ||
| 295 | //@{ | ||
| 296 | class CVFSCallbacks | ||
| 297 | { | 885 | { |
| 298 | public: | 886 | char* cInput = nullptr; |
| 299 | /// @brief Require keyboard input | 887 | bool ret = m_cb->get_keyboard_input(m_cb->ctx, heading.c_str(), &cInput, hiddenInput); |
| 300 | /// | 888 | if (cInput) |
| 301 | /// Becomes called if GetDirectory() returns false and GetDirectory() | ||
| 302 | /// becomes after entry called again. | ||
| 303 | /// | ||
| 304 | /// @param[in] heading The heading of the keyboard dialog | ||
| 305 | /// @param[out] input The resulting string. Returns string after | ||
| 306 | /// second call! | ||
| 307 | /// @param[in] hiddenInput To show input only as "*" on dialog | ||
| 308 | /// @return True if input was received, false otherwise | ||
| 309 | /// | ||
| 310 | bool GetKeyboardInput(const std::string& heading, std::string& input, bool hiddenInput = false) | ||
| 311 | { | ||
| 312 | char* cInput = nullptr; | ||
| 313 | bool ret = m_cb->get_keyboard_input(m_cb->ctx, heading.c_str(), &cInput, hiddenInput); | ||
| 314 | if (cInput) | ||
| 315 | { | ||
| 316 | input = cInput; | ||
| 317 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cInput); | ||
| 318 | } | ||
| 319 | return ret; | ||
| 320 | } | ||
| 321 | |||
| 322 | /// @brief Display an error dialog | ||
| 323 | /// | ||
| 324 | /// @param[in] heading The heading of the error dialog | ||
| 325 | /// @param[in] line1 The first line of the error dialog | ||
| 326 | /// @param[in] line2 [opt] The second line of the error dialog | ||
| 327 | /// @param[in] line3 [opt] The third line of the error dialog | ||
| 328 | /// | ||
| 329 | void SetErrorDialog(const std::string& heading, const std::string& line1, const std::string& line2 = "", const std::string& line3 = "") | ||
| 330 | { | ||
| 331 | m_cb->set_error_dialog(m_cb->ctx, heading.c_str(), line1.c_str(), line2.c_str(), line3.c_str()); | ||
| 332 | } | ||
| 333 | |||
| 334 | /// @brief Prompt the user for authentication of a URL | ||
| 335 | /// | ||
| 336 | /// @param[in] url The URL | ||
| 337 | void RequireAuthentication(const std::string& url) | ||
| 338 | { | 889 | { |
| 339 | m_cb->require_authentication(m_cb->ctx, url.c_str()); | 890 | input = cInput; |
| 891 | ::kodi::addon::CAddonBase::m_interface->toKodi->free_string( | ||
| 892 | ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cInput); | ||
| 340 | } | 893 | } |
| 894 | return ret; | ||
| 895 | } | ||
| 341 | 896 | ||
| 342 | explicit CVFSCallbacks(const VFSGetDirectoryCallbacks* cb) : m_cb(cb) { } | 897 | /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory |
| 343 | 898 | /// @brief Display an error dialog | |
| 344 | private: | ||
| 345 | const VFSGetDirectoryCallbacks* m_cb; | ||
| 346 | }; | ||
| 347 | //@} | ||
| 348 | |||
| 349 | /// @brief List a directory | ||
| 350 | /// | ||
| 351 | /// @param[in] url The URL of the directory | ||
| 352 | /// @param[out] entries The entries in the directory | ||
| 353 | /// @param[in] callbacks A callback structure | ||
| 354 | /// @return Context for the directory listing | ||
| 355 | /// | ||
| 356 | virtual bool GetDirectory(const VFSURL& url, | ||
| 357 | std::vector<kodi::vfs::CDirEntry>& entries, | ||
| 358 | CVFSCallbacks callbacks) { return false; } | ||
| 359 | |||
| 360 | /// @brief Check if file should be presented as a directory (multiple streams) | ||
| 361 | /// | 899 | /// |
| 362 | /// @param[in] url The URL of the file | 900 | /// @param[in] heading The heading of the error dialog |
| 363 | /// @param[out] entries The entries in the directory | 901 | /// @param[in] line1 The first line of the error dialog |
| 364 | /// @param[out] rootPath Path to root directory if multiple entries | 902 | /// @param[in] line2 [opt] The second line of the error dialog |
| 365 | /// @return Context for the directory listing | 903 | /// @param[in] line3 [opt] The third line of the error dialog |
| 366 | /// | 904 | /// |
| 367 | virtual bool ContainsFiles(const VFSURL& url, | 905 | void SetErrorDialog(const std::string& heading, |
| 368 | std::vector<kodi::vfs::CDirEntry>& entries, | 906 | const std::string& line1, |
| 369 | std::string& rootPath) { return false; } | 907 | const std::string& line2 = "", |
| 370 | 908 | const std::string& line3 = "") | |
| 371 | private: | ||
| 372 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 373 | { | ||
| 374 | if (instance == nullptr) | ||
| 375 | throw std::logic_error("kodi::addon::CInstanceVFS: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 376 | |||
| 377 | m_instanceData = static_cast<AddonInstance_VFSEntry*>(instance); | ||
| 378 | m_instanceData->toAddon.addonInstance = this; | ||
| 379 | m_instanceData->toAddon.open = ADDON_Open; | ||
| 380 | m_instanceData->toAddon.open_for_write = ADDON_OpenForWrite; | ||
| 381 | m_instanceData->toAddon.read = ADDON_Read; | ||
| 382 | m_instanceData->toAddon.write = ADDON_Write; | ||
| 383 | m_instanceData->toAddon.seek = ADDON_Seek; | ||
| 384 | m_instanceData->toAddon.truncate = ADDON_Truncate; | ||
| 385 | m_instanceData->toAddon.get_length = ADDON_GetLength; | ||
| 386 | m_instanceData->toAddon.get_position = ADDON_GetPosition; | ||
| 387 | m_instanceData->toAddon.get_chunk_size = ADDON_GetChunkSize; | ||
| 388 | m_instanceData->toAddon.io_control = ADDON_IoControl; | ||
| 389 | m_instanceData->toAddon.stat = ADDON_Stat; | ||
| 390 | m_instanceData->toAddon.close = ADDON_Close; | ||
| 391 | m_instanceData->toAddon.exists = ADDON_Exists; | ||
| 392 | m_instanceData->toAddon.clear_out_idle = ADDON_ClearOutIdle; | ||
| 393 | m_instanceData->toAddon.disconnect_all = ADDON_DisconnectAll; | ||
| 394 | m_instanceData->toAddon.delete_it = ADDON_Delete; | ||
| 395 | m_instanceData->toAddon.rename = ADDON_Rename; | ||
| 396 | m_instanceData->toAddon.directory_exists = ADDON_DirectoryExists; | ||
| 397 | m_instanceData->toAddon.remove_directory = ADDON_RemoveDirectory; | ||
| 398 | m_instanceData->toAddon.create_directory = ADDON_CreateDirectory; | ||
| 399 | m_instanceData->toAddon.get_directory = ADDON_GetDirectory; | ||
| 400 | m_instanceData->toAddon.free_directory = ADDON_FreeDirectory; | ||
| 401 | m_instanceData->toAddon.contains_files = ADDON_ContainsFiles; | ||
| 402 | } | ||
| 403 | |||
| 404 | inline static void* ADDON_Open(const AddonInstance_VFSEntry* instance, const VFSURL* url) | ||
| 405 | { | 909 | { |
| 406 | return instance->toAddon.addonInstance->Open(*url); | 910 | m_cb->set_error_dialog(m_cb->ctx, heading.c_str(), line1.c_str(), line2.c_str(), |
| 911 | line3.c_str()); | ||
| 407 | } | 912 | } |
| 408 | 913 | ||
| 409 | inline static void* ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance, const VFSURL* url, bool overWrite) | 914 | /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory |
| 915 | /// @brief Prompt the user for authentication of a URL | ||
| 916 | /// | ||
| 917 | /// @param[in] url The URL | ||
| 918 | void RequireAuthentication(const std::string& url) | ||
| 410 | { | 919 | { |
| 411 | return instance->toAddon.addonInstance->OpenForWrite(*url, overWrite); | 920 | m_cb->require_authentication(m_cb->ctx, url.c_str()); |
| 412 | } | 921 | } |
| 413 | 922 | ||
| 414 | inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance, void* context, void* buffer, size_t uiBufSize) | 923 | explicit CVFSCallbacks(const VFSGetDirectoryCallbacks* cb) : m_cb(cb) {} |
| 415 | { | ||
| 416 | return instance->toAddon.addonInstance->Read(context, buffer, uiBufSize); | ||
| 417 | } | ||
| 418 | 924 | ||
| 419 | inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance, void* context, const void* buffer, size_t uiBufSize) | 925 | private: |
| 420 | { | 926 | const VFSGetDirectoryCallbacks* m_cb; |
| 421 | return instance->toAddon.addonInstance->Write(context, buffer, uiBufSize); | 927 | }; |
| 422 | } | 928 | //-------------------------------------------------------------------------- |
| 929 | |||
| 930 | //========================================================================== | ||
| 931 | /// | ||
| 932 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 933 | /// @brief List a directory | ||
| 934 | /// | ||
| 935 | /// @param[in] url The URL of the directory | ||
| 936 | /// @param[out] entries The entries in the directory, see | ||
| 937 | /// @ref cpp_kodi_vfs_CDirEntry "kodi::vfs::CDirEntry" | ||
| 938 | /// about his content | ||
| 939 | /// @param[in] callbacks A callback structure | ||
| 940 | /// @return Context for the directory listing | ||
| 941 | /// | ||
| 942 | /// | ||
| 943 | /// -------------------------------------------------------------------------- | ||
| 944 | /// | ||
| 945 | /// ### Callbacks: | ||
| 946 | /// @copydetails cpp_kodi_addon_vfs_general_cb_GetDirectory | ||
| 947 | /// | ||
| 948 | /// **Available callback functions** | ||
| 949 | /// | Function: | Description | ||
| 950 | /// |--|-- | ||
| 951 | /// | CVFSCallbacks::GetKeyboardInput | @copybrief CVFSCallbacks::GetKeyboardInput @copydetails CVFSCallbacks::GetKeyboardInput | ||
| 952 | /// | CVFSCallbacks::SetErrorDialog | @copybrief CVFSCallbacks::SetErrorDialog @copydetails CVFSCallbacks::SetErrorDialog | ||
| 953 | /// | CVFSCallbacks::RequireAuthentication | @copybrief CVFSCallbacks::RequireAuthentication @copydetails CVFSCallbacks::RequireAuthentication | ||
| 954 | /// | ||
| 955 | virtual bool GetDirectory(const VFSURL& url, | ||
| 956 | std::vector<kodi::vfs::CDirEntry>& entries, | ||
| 957 | CVFSCallbacks callbacks) | ||
| 958 | { | ||
| 959 | return false; | ||
| 960 | } | ||
| 961 | //-------------------------------------------------------------------------- | ||
| 962 | |||
| 963 | //========================================================================== | ||
| 964 | /// | ||
| 965 | /// @ingroup cpp_kodi_addon_vfs_general | ||
| 966 | /// @brief Check if file should be presented as a directory (multiple streams) | ||
| 967 | /// | ||
| 968 | /// @param[in] url The URL of the file | ||
| 969 | /// @param[out] entries The entries in the directory, see | ||
| 970 | /// @ref cpp_kodi_vfs_CDirEntry "kodi::vfs::CDirEntry" | ||
| 971 | /// about his content | ||
| 972 | /// @param[out] rootPath Path to root directory if multiple entries | ||
| 973 | /// @return Context for the directory listing | ||
| 974 | /// | ||
| 975 | virtual bool ContainsFiles(const VFSURL& url, | ||
| 976 | std::vector<kodi::vfs::CDirEntry>& entries, | ||
| 977 | std::string& rootPath) | ||
| 978 | { | ||
| 979 | return false; | ||
| 980 | } | ||
| 981 | //-------------------------------------------------------------------------- | ||
| 982 | //@} | ||
| 423 | 983 | ||
| 424 | inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance, void* context, int64_t position, int whence) | 984 | private: |
| 425 | { | 985 | void SetAddonStruct(KODI_HANDLE instance) |
| 426 | return instance->toAddon.addonInstance->Seek(context, position, whence); | 986 | { |
| 427 | } | 987 | if (instance == nullptr) |
| 988 | throw std::logic_error("kodi::addon::CInstanceVFS: Creation with empty addon structure not " | ||
| 989 | "allowed, table must be given from Kodi!"); | ||
| 990 | |||
| 991 | m_instanceData = static_cast<AddonInstance_VFSEntry*>(instance); | ||
| 992 | m_instanceData->toAddon->addonInstance = this; | ||
| 993 | m_instanceData->toAddon->open = ADDON_Open; | ||
| 994 | m_instanceData->toAddon->open_for_write = ADDON_OpenForWrite; | ||
| 995 | m_instanceData->toAddon->read = ADDON_Read; | ||
| 996 | m_instanceData->toAddon->write = ADDON_Write; | ||
| 997 | m_instanceData->toAddon->seek = ADDON_Seek; | ||
| 998 | m_instanceData->toAddon->truncate = ADDON_Truncate; | ||
| 999 | m_instanceData->toAddon->get_length = ADDON_GetLength; | ||
| 1000 | m_instanceData->toAddon->get_position = ADDON_GetPosition; | ||
| 1001 | m_instanceData->toAddon->get_chunk_size = ADDON_GetChunkSize; | ||
| 1002 | m_instanceData->toAddon->io_control = ADDON_IoControl; | ||
| 1003 | m_instanceData->toAddon->stat = ADDON_Stat; | ||
| 1004 | m_instanceData->toAddon->close = ADDON_Close; | ||
| 1005 | m_instanceData->toAddon->exists = ADDON_Exists; | ||
| 1006 | m_instanceData->toAddon->clear_out_idle = ADDON_ClearOutIdle; | ||
| 1007 | m_instanceData->toAddon->disconnect_all = ADDON_DisconnectAll; | ||
| 1008 | m_instanceData->toAddon->delete_it = ADDON_Delete; | ||
| 1009 | m_instanceData->toAddon->rename = ADDON_Rename; | ||
| 1010 | m_instanceData->toAddon->directory_exists = ADDON_DirectoryExists; | ||
| 1011 | m_instanceData->toAddon->remove_directory = ADDON_RemoveDirectory; | ||
| 1012 | m_instanceData->toAddon->create_directory = ADDON_CreateDirectory; | ||
| 1013 | m_instanceData->toAddon->get_directory = ADDON_GetDirectory; | ||
| 1014 | m_instanceData->toAddon->free_directory = ADDON_FreeDirectory; | ||
| 1015 | m_instanceData->toAddon->contains_files = ADDON_ContainsFiles; | ||
| 1016 | } | ||
| 1017 | |||
| 1018 | inline static void* ADDON_Open(const AddonInstance_VFSEntry* instance, const VFSURL* url) | ||
| 1019 | { | ||
| 1020 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(*url); | ||
| 1021 | } | ||
| 428 | 1022 | ||
| 429 | inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance, void* context, int64_t size) | 1023 | inline static void* ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance, |
| 430 | { | 1024 | const VFSURL* url, |
| 431 | return instance->toAddon.addonInstance->Truncate(context, size); | 1025 | bool overWrite) |
| 432 | } | 1026 | { |
| 1027 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1028 | ->OpenForWrite(*url, overWrite); | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance, | ||
| 1032 | void* context, | ||
| 1033 | void* buffer, | ||
| 1034 | size_t uiBufSize) | ||
| 1035 | { | ||
| 1036 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1037 | ->Read(context, buffer, uiBufSize); | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance, | ||
| 1041 | void* context, | ||
| 1042 | const void* buffer, | ||
| 1043 | size_t uiBufSize) | ||
| 1044 | { | ||
| 1045 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1046 | ->Write(context, buffer, uiBufSize); | ||
| 1047 | } | ||
| 1048 | |||
| 1049 | inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance, | ||
| 1050 | void* context, | ||
| 1051 | int64_t position, | ||
| 1052 | int whence) | ||
| 1053 | { | ||
| 1054 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1055 | ->Seek(context, position, whence); | ||
| 1056 | } | ||
| 433 | 1057 | ||
| 434 | inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance, void* context) | 1058 | inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance, |
| 435 | { | 1059 | void* context, |
| 436 | return instance->toAddon.addonInstance->GetLength(context); | 1060 | int64_t size) |
| 437 | } | 1061 | { |
| 1062 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size); | ||
| 1063 | } | ||
| 438 | 1064 | ||
| 439 | inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance, void* context) | 1065 | inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance, void* context) |
| 440 | { | 1066 | { |
| 441 | return instance->toAddon.addonInstance->GetPosition(context); | 1067 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context); |
| 442 | } | 1068 | } |
| 443 | 1069 | ||
| 444 | inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance, void* context) | 1070 | inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance, void* context) |
| 445 | { | 1071 | { |
| 446 | return instance->toAddon.addonInstance->GetChunkSize(context); | 1072 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context); |
| 447 | } | 1073 | } |
| 448 | 1074 | ||
| 449 | inline static int ADDON_IoControl(const AddonInstance_VFSEntry* instance, void* context, XFILE::EIoControl request, void* param) | 1075 | inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance, void* context) |
| 450 | { | 1076 | { |
| 451 | return instance->toAddon.addonInstance->IoControl(context, request, param); | 1077 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context); |
| 452 | } | 1078 | } |
| 453 | 1079 | ||
| 454 | inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance, const VFSURL* url, struct __stat64* buffer) | 1080 | inline static int ADDON_IoControl(const AddonInstance_VFSEntry* instance, |
| 455 | { | 1081 | void* context, |
| 456 | return instance->toAddon.addonInstance->Stat(*url, buffer); | 1082 | enum VFS_IOCTRL request, |
| 457 | } | 1083 | void* param) |
| 1084 | { | ||
| 1085 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1086 | ->IoControl(context, request, param); | ||
| 1087 | } | ||
| 458 | 1088 | ||
| 459 | inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, void* context) | 1089 | inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance, |
| 460 | { | 1090 | const VFSURL* url, |
| 461 | return instance->toAddon.addonInstance->Close(context); | 1091 | struct __stat64* buffer) |
| 462 | } | 1092 | { |
| 1093 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(*url, buffer); | ||
| 1094 | } | ||
| 463 | 1095 | ||
| 464 | inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1096 | inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, void* context) |
| 465 | { | 1097 | { |
| 466 | return instance->toAddon.addonInstance->Exists(*url); | 1098 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context); |
| 467 | } | 1099 | } |
| 468 | 1100 | ||
| 469 | inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance) | 1101 | inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url) |
| 470 | { | 1102 | { |
| 471 | return instance->toAddon.addonInstance->ClearOutIdle(); | 1103 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(*url); |
| 472 | } | 1104 | } |
| 473 | 1105 | ||
| 474 | inline static void ADDON_DisconnectAll(const AddonInstance_VFSEntry* instance) | 1106 | inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance) |
| 475 | { | 1107 | { |
| 476 | return instance->toAddon.addonInstance->DisconnectAll(); | 1108 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->ClearOutIdle(); |
| 477 | } | 1109 | } |
| 478 | 1110 | ||
| 479 | inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1111 | inline static void ADDON_DisconnectAll(const AddonInstance_VFSEntry* instance) |
| 480 | { | 1112 | { |
| 481 | return instance->toAddon.addonInstance->Delete(*url); | 1113 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DisconnectAll(); |
| 482 | } | 1114 | } |
| 483 | 1115 | ||
| 484 | inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance, const VFSURL* url, const VFSURL* url2) | 1116 | inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url) |
| 485 | { | 1117 | { |
| 486 | return instance->toAddon.addonInstance->Rename(*url, *url2); | 1118 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(*url); |
| 487 | } | 1119 | } |
| 488 | 1120 | ||
| 489 | inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1121 | inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance, |
| 490 | { | 1122 | const VFSURL* url, |
| 491 | return instance->toAddon.addonInstance->DirectoryExists(*url); | 1123 | const VFSURL* url2) |
| 492 | } | 1124 | { |
| 1125 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(*url, *url2); | ||
| 1126 | } | ||
| 493 | 1127 | ||
| 494 | inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1128 | inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance, |
| 495 | { | 1129 | const VFSURL* url) |
| 496 | return instance->toAddon.addonInstance->RemoveDirectory(*url); | 1130 | { |
| 497 | } | 1131 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(*url); |
| 1132 | } | ||
| 498 | 1133 | ||
| 499 | inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance, const VFSURL* url) | 1134 | inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance, |
| 500 | { | 1135 | const VFSURL* url) |
| 501 | return instance->toAddon.addonInstance->CreateDirectory(*url); | 1136 | { |
| 502 | } | 1137 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(*url); |
| 1138 | } | ||
| 503 | 1139 | ||
| 504 | inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance, | 1140 | inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance, |
| 505 | const VFSURL* url, | 1141 | const VFSURL* url) |
| 506 | VFSDirEntry** retEntries, | 1142 | { |
| 507 | int* num_entries, | 1143 | return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(*url); |
| 508 | VFSGetDirectoryCallbacks* callbacks) | 1144 | } |
| 1145 | |||
| 1146 | inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance, | ||
| 1147 | const VFSURL* url, | ||
| 1148 | VFSDirEntry** retEntries, | ||
| 1149 | int* num_entries, | ||
| 1150 | VFSGetDirectoryCallbacks* callbacks) | ||
| 1151 | { | ||
| 1152 | std::vector<kodi::vfs::CDirEntry> addonEntries; | ||
| 1153 | bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1154 | ->GetDirectory(*url, addonEntries, CVFSCallbacks(callbacks)); | ||
| 1155 | if (ret) | ||
| 509 | { | 1156 | { |
| 510 | std::vector<kodi::vfs::CDirEntry> addonEntries; | 1157 | VFSDirEntry* entries = |
| 511 | bool ret = instance->toAddon.addonInstance->GetDirectory(*url, addonEntries, CVFSCallbacks(callbacks)); | 1158 | static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size())); |
| 512 | if (ret) | 1159 | for (unsigned int i = 0; i < addonEntries.size(); ++i) |
| 513 | { | 1160 | { |
| 514 | VFSDirEntry* entries = static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size())); | 1161 | entries[i].label = strdup(addonEntries[i].Label().c_str()); |
| 515 | for (unsigned int i = 0; i < addonEntries.size(); ++i) | 1162 | entries[i].title = strdup(addonEntries[i].Title().c_str()); |
| 1163 | entries[i].path = strdup(addonEntries[i].Path().c_str()); | ||
| 1164 | entries[i].folder = addonEntries[i].IsFolder(); | ||
| 1165 | entries[i].size = addonEntries[i].Size(); | ||
| 1166 | entries[i].date_time = addonEntries[i].DateTime(); | ||
| 1167 | |||
| 1168 | entries[i].num_props = 0; | ||
| 1169 | const std::map<std::string, std::string>& props = addonEntries[i].GetProperties(); | ||
| 1170 | if (!props.empty()) | ||
| 516 | { | 1171 | { |
| 517 | entries[i].label = strdup(addonEntries[i].Label().c_str()); | 1172 | entries[i].properties = |
| 518 | entries[i].title = strdup(addonEntries[i].Title().c_str()); | 1173 | static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size())); |
| 519 | entries[i].path = strdup(addonEntries[i].Path().c_str()); | 1174 | for (const auto& prop : props) |
| 520 | entries[i].folder = addonEntries[i].IsFolder(); | ||
| 521 | entries[i].size = addonEntries[i].Size(); | ||
| 522 | |||
| 523 | entries[i].num_props = 0; | ||
| 524 | const std::map<std::string, std::string>& props = addonEntries[i].GetProperties(); | ||
| 525 | if (!props.empty()) | ||
| 526 | { | 1175 | { |
| 527 | entries[i].properties = static_cast<VFSProperty*>(malloc(sizeof(VFSProperty)*props.size())); | 1176 | entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str()); |
| 528 | for (const auto& prop : props) | 1177 | entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str()); |
| 529 | { | 1178 | ++entries[i].num_props; |
| 530 | entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str()); | ||
| 531 | entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str()); | ||
| 532 | ++entries[i].num_props; | ||
| 533 | } | ||
| 534 | } | 1179 | } |
| 535 | else | ||
| 536 | entries[i].properties = nullptr; | ||
| 537 | } | 1180 | } |
| 538 | *retEntries = entries; | 1181 | else |
| 539 | *num_entries = static_cast<int>(addonEntries.size()); | 1182 | entries[i].properties = nullptr; |
| 540 | } | 1183 | } |
| 541 | return ret; | 1184 | *retEntries = entries; |
| 1185 | *num_entries = static_cast<int>(addonEntries.size()); | ||
| 542 | } | 1186 | } |
| 1187 | return ret; | ||
| 1188 | } | ||
| 543 | 1189 | ||
| 544 | inline static void ADDON_FreeDirectory(const AddonInstance_VFSEntry* instance, VFSDirEntry* entries, int num_entries) | 1190 | inline static void ADDON_FreeDirectory(const AddonInstance_VFSEntry* instance, |
| 1191 | VFSDirEntry* entries, | ||
| 1192 | int num_entries) | ||
| 1193 | { | ||
| 1194 | for (int i = 0; i < num_entries; ++i) | ||
| 545 | { | 1195 | { |
| 546 | for (int i = 0; i < num_entries; ++i) | 1196 | if (entries[i].properties) |
| 547 | { | 1197 | { |
| 548 | if (entries[i].properties) | 1198 | for (unsigned int j = 0; j < entries[i].num_props; ++j) |
| 549 | { | 1199 | { |
| 550 | for (unsigned int j = 0; j < entries[i].num_props; ++j) | 1200 | free(entries[i].properties[j].name); |
| 551 | { | 1201 | free(entries[i].properties[j].val); |
| 552 | free(entries[i].properties[j].name); | ||
| 553 | free(entries[i].properties[j].val); | ||
| 554 | } | ||
| 555 | free(entries[i].properties); | ||
| 556 | } | 1202 | } |
| 557 | free(entries[i].label); | 1203 | free(entries[i].properties); |
| 558 | free(entries[i].title); | ||
| 559 | free(entries[i].path); | ||
| 560 | } | 1204 | } |
| 561 | free(entries); | 1205 | free(entries[i].label); |
| 1206 | free(entries[i].title); | ||
| 1207 | free(entries[i].path); | ||
| 562 | } | 1208 | } |
| 563 | 1209 | free(entries); | |
| 564 | inline static bool ADDON_ContainsFiles(const AddonInstance_VFSEntry* instance, | 1210 | } |
| 565 | const VFSURL* url, | 1211 | |
| 566 | VFSDirEntry** retEntries, | 1212 | inline static bool ADDON_ContainsFiles(const AddonInstance_VFSEntry* instance, |
| 567 | int* num_entries, | 1213 | const VFSURL* url, |
| 568 | char* rootpath) | 1214 | VFSDirEntry** retEntries, |
| 1215 | int* num_entries, | ||
| 1216 | char* rootpath) | ||
| 1217 | { | ||
| 1218 | std::string cppRootPath; | ||
| 1219 | std::vector<kodi::vfs::CDirEntry> addonEntries; | ||
| 1220 | bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance) | ||
| 1221 | ->ContainsFiles(*url, addonEntries, cppRootPath); | ||
| 1222 | if (ret) | ||
| 569 | { | 1223 | { |
| 570 | std::string cppRootPath; | 1224 | strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH); |
| 571 | std::vector<kodi::vfs::CDirEntry> addonEntries; | ||
| 572 | bool ret = instance->toAddon.addonInstance->ContainsFiles(*url, addonEntries, cppRootPath); | ||
| 573 | if (ret) | ||
| 574 | { | ||
| 575 | strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH); | ||
| 576 | 1225 | ||
| 577 | VFSDirEntry* entries = static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size())); | 1226 | VFSDirEntry* entries = |
| 578 | for (size_t i = 0; i < addonEntries.size(); ++i) | 1227 | static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size())); |
| 1228 | for (size_t i = 0; i < addonEntries.size(); ++i) | ||
| 1229 | { | ||
| 1230 | entries[i].label = strdup(addonEntries[i].Label().c_str()); | ||
| 1231 | entries[i].title = strdup(addonEntries[i].Title().c_str()); | ||
| 1232 | entries[i].path = strdup(addonEntries[i].Path().c_str()); | ||
| 1233 | entries[i].folder = addonEntries[i].IsFolder(); | ||
| 1234 | entries[i].size = addonEntries[i].Size(); | ||
| 1235 | entries[i].date_time = addonEntries[i].DateTime(); | ||
| 1236 | |||
| 1237 | entries[i].num_props = 0; | ||
| 1238 | const std::map<std::string, std::string>& props = addonEntries[i].GetProperties(); | ||
| 1239 | if (!props.empty()) | ||
| 579 | { | 1240 | { |
| 580 | entries[i].label = strdup(addonEntries[i].Label().c_str()); | 1241 | entries[i].properties = |
| 581 | entries[i].title = strdup(addonEntries[i].Title().c_str()); | 1242 | static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size())); |
| 582 | entries[i].path = strdup(addonEntries[i].Path().c_str()); | 1243 | for (const auto& prop : props) |
| 583 | entries[i].folder = addonEntries[i].IsFolder(); | ||
| 584 | entries[i].size = addonEntries[i].Size(); | ||
| 585 | |||
| 586 | entries[i].num_props = 0; | ||
| 587 | const std::map<std::string, std::string>& props = addonEntries[i].GetProperties(); | ||
| 588 | if (!props.empty()) | ||
| 589 | { | 1244 | { |
| 590 | entries[i].properties = static_cast<VFSProperty*>(malloc(sizeof(VFSProperty)*props.size())); | 1245 | entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str()); |
| 591 | for (const auto& prop : props) | 1246 | entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str()); |
| 592 | { | 1247 | ++entries[i].num_props; |
| 593 | entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str()); | ||
| 594 | entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str()); | ||
| 595 | ++entries[i].num_props; | ||
| 596 | } | ||
| 597 | } | 1248 | } |
| 598 | else | ||
| 599 | entries[i].properties = nullptr; | ||
| 600 | } | 1249 | } |
| 601 | *retEntries = entries; | 1250 | else |
| 602 | *num_entries = static_cast<int>(addonEntries.size()); | 1251 | entries[i].properties = nullptr; |
| 603 | } | 1252 | } |
| 604 | return ret; | 1253 | *retEntries = entries; |
| 1254 | *num_entries = static_cast<int>(addonEntries.size()); | ||
| 605 | } | 1255 | } |
| 1256 | return ret; | ||
| 1257 | } | ||
| 606 | 1258 | ||
| 607 | AddonInstance_VFSEntry* m_instanceData; | 1259 | AddonInstance_VFSEntry* m_instanceData; |
| 608 | }; | 1260 | }; |
| 609 | 1261 | ||
| 610 | } /* namespace addon */ | 1262 | } /* namespace addon */ |
| 611 | } /* namespace kodi */ | 1263 | } /* namespace kodi */ |
| 1264 | |||
| 1265 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h index 9c33fbf..54246f0 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h | |||
| @@ -80,13 +80,13 @@ extern "C" | |||
| 80 | 80 | ||
| 81 | int64_t pts; | 81 | int64_t pts; |
| 82 | 82 | ||
| 83 | void *buffer; //< will be passed in release_frame_buffer | 83 | KODI_HANDLE buffer; //< will be passed in release_frame_buffer |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | enum VIDEOCODEC_RETVAL | 86 | enum VIDEOCODEC_RETVAL |
| 87 | { | 87 | { |
| 88 | VC_NONE = 0, //< noop | 88 | VC_NONE = 0, //< noop |
| 89 | VC_ERROR, //< an error occured, no other messages will be returned | 89 | VC_ERROR, //< an error occurred, no other messages will be returned |
| 90 | VC_BUFFER, //< the decoder needs more data | 90 | VC_BUFFER, //< the decoder needs more data |
| 91 | VC_PICTURE, //< the decoder got a picture | 91 | VC_PICTURE, //< the decoder got a picture |
| 92 | VC_EOF, //< the decoder signals EOF | 92 | VC_EOF, //< the decoder signals EOF |
| @@ -143,11 +143,13 @@ namespace kodi | |||
| 143 | namespace addon | 143 | namespace addon |
| 144 | { | 144 | { |
| 145 | 145 | ||
| 146 | class CInstanceVideoCodec : public IAddonInstance | 146 | class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance |
| 147 | { | 147 | { |
| 148 | public: | 148 | public: |
| 149 | explicit CInstanceVideoCodec(KODI_HANDLE instance) | 149 | explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "") |
| 150 | : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC) | 150 | : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC, |
| 151 | !kodiVersion.empty() ? kodiVersion | ||
| 152 | : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC)) | ||
| 151 | { | 153 | { |
| 152 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 154 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 153 | throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with single instance way is not allowed!"); | 155 | throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with single instance way is not allowed!"); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h index 6c29693..4be785d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include "../AddonBase.h" | 16 | #include "../AddonBase.h" |
| 17 | #include "../gui/renderHelper.h" | ||
| 17 | 18 | ||
| 18 | namespace kodi { namespace addon { class CInstanceVisualization; }} | 19 | namespace kodi { namespace addon { class CInstanceVisualization; }} |
| 19 | 20 | ||
| @@ -59,6 +60,7 @@ typedef struct AddonToKodiFuncTable_Visualization /* internal */ | |||
| 59 | { | 60 | { |
| 60 | KODI_HANDLE kodiInstance; | 61 | KODI_HANDLE kodiInstance; |
| 61 | void (__cdecl* transfer_preset) (void* kodiInstance, const char* preset); | 62 | void (__cdecl* transfer_preset) (void* kodiInstance, const char* preset); |
| 63 | void (__cdecl* clear_presets) (void* kodiInstance); | ||
| 62 | } AddonToKodiFuncTable_Visualization; | 64 | } AddonToKodiFuncTable_Visualization; |
| 63 | 65 | ||
| 64 | typedef struct KodiToAddonFuncTable_Visualization /* internal */ | 66 | typedef struct KodiToAddonFuncTable_Visualization /* internal */ |
| @@ -78,9 +80,9 @@ typedef struct KodiToAddonFuncTable_Visualization /* internal */ | |||
| 78 | 80 | ||
| 79 | typedef struct AddonInstance_Visualization /* internal */ | 81 | typedef struct AddonInstance_Visualization /* internal */ |
| 80 | { | 82 | { |
| 81 | AddonProps_Visualization props; | 83 | AddonProps_Visualization* props; |
| 82 | AddonToKodiFuncTable_Visualization toKodi; | 84 | AddonToKodiFuncTable_Visualization* toKodi; |
| 83 | KodiToAddonFuncTable_Visualization toAddon; | 85 | KodiToAddonFuncTable_Visualization* toAddon; |
| 84 | } AddonInstance_Visualization; | 86 | } AddonInstance_Visualization; |
| 85 | 87 | ||
| 86 | //============================================================================ | 88 | //============================================================================ |
| @@ -296,7 +298,7 @@ namespace addon | |||
| 296 | /// Kodi's header. Manually deleting the add-on instance is not required. | 298 | /// Kodi's header. Manually deleting the add-on instance is not required. |
| 297 | /// | 299 | /// |
| 298 | //---------------------------------------------------------------------------- | 300 | //---------------------------------------------------------------------------- |
| 299 | class CInstanceVisualization : public IAddonInstance | 301 | class ATTRIBUTE_HIDDEN CInstanceVisualization : public IAddonInstance |
| 300 | { | 302 | { |
| 301 | public: | 303 | public: |
| 302 | //========================================================================== | 304 | //========================================================================== |
| @@ -307,7 +309,8 @@ namespace addon | |||
| 307 | /// Used by an add-on that only supports visualizations. | 309 | /// Used by an add-on that only supports visualizations. |
| 308 | /// | 310 | /// |
| 309 | CInstanceVisualization() | 311 | CInstanceVisualization() |
| 310 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION) | 312 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, |
| 313 | GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION)) | ||
| 311 | { | 314 | { |
| 312 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 315 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 313 | throw std::logic_error("kodi::addon::CInstanceVisualization: Cannot create multiple instances of add-on."); | 316 | throw std::logic_error("kodi::addon::CInstanceVisualization: Cannot create multiple instances of add-on."); |
| @@ -325,11 +328,16 @@ namespace addon | |||
| 325 | /// | 328 | /// |
| 326 | /// @param[in] instance The instance value given to | 329 | /// @param[in] instance The instance value given to |
| 327 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. | 330 | /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>. |
| 331 | /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to | ||
| 332 | /// allow compatibility to older Kodi versions. | ||
| 333 | /// @note Recommended to set. | ||
| 328 | /// | 334 | /// |
| 329 | /// @warning Only use `instance` from the CreateInstance call | 335 | /// @warning Only use `instance` from the CreateInstance call |
| 330 | /// | 336 | /// |
| 331 | explicit CInstanceVisualization(KODI_HANDLE instance) | 337 | explicit CInstanceVisualization(KODI_HANDLE instance, const std::string& kodiVersion = "") |
| 332 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION) | 338 | : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, |
| 339 | !kodiVersion.empty() ? kodiVersion | ||
| 340 | : GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION)) | ||
| 333 | { | 341 | { |
| 334 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | 342 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) |
| 335 | throw std::logic_error("kodi::addon::CInstanceVisualization: Creation of multiple together with single instance way is not allowed!"); | 343 | throw std::logic_error("kodi::addon::CInstanceVisualization: Creation of multiple together with single instance way is not allowed!"); |
| @@ -548,6 +556,26 @@ namespace addon | |||
| 548 | //========================================================================== | 556 | //========================================================================== |
| 549 | /// | 557 | /// |
| 550 | /// @ingroup cpp_kodi_addon_visualization_CB | 558 | /// @ingroup cpp_kodi_addon_visualization_CB |
| 559 | /// @brief To transfer available presets on addon | ||
| 560 | /// | ||
| 561 | /// Used if @ref GetPresets not possible to use, e.g. where available presets | ||
| 562 | /// are only known during @ref Start call. | ||
| 563 | /// | ||
| 564 | /// @param[in] presets List to store available presets. | ||
| 565 | /// | ||
| 566 | /// @note The function should only be called once, if possible | ||
| 567 | /// | ||
| 568 | inline void TransferPresets(const std::vector<std::string>& presets) | ||
| 569 | { | ||
| 570 | m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance); | ||
| 571 | for (auto it : presets) | ||
| 572 | m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str()); | ||
| 573 | } | ||
| 574 | //-------------------------------------------------------------------------- | ||
| 575 | |||
| 576 | //========================================================================== | ||
| 577 | /// | ||
| 578 | /// @ingroup cpp_kodi_addon_visualization_CB | ||
| 551 | /// @brief Device that represents the display adapter | 579 | /// @brief Device that represents the display adapter |
| 552 | /// | 580 | /// |
| 553 | /// @return A pointer to the used device | 581 | /// @return A pointer to the used device |
| @@ -555,7 +583,7 @@ namespace addon | |||
| 555 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on | 583 | /// @note This is only available on **DirectX**, It us unused (`nullptr`) on |
| 556 | /// **OpenGL** | 584 | /// **OpenGL** |
| 557 | /// | 585 | /// |
| 558 | inline void* Device() { return m_instanceData->props.device; } | 586 | inline void* Device() { return m_instanceData->props->device; } |
| 559 | //-------------------------------------------------------------------------- | 587 | //-------------------------------------------------------------------------- |
| 560 | 588 | ||
| 561 | //========================================================================== | 589 | //========================================================================== |
| @@ -565,7 +593,7 @@ namespace addon | |||
| 565 | /// | 593 | /// |
| 566 | /// @return The X position, in pixels | 594 | /// @return The X position, in pixels |
| 567 | /// | 595 | /// |
| 568 | inline int X() { return m_instanceData->props.x; } | 596 | inline int X() { return m_instanceData->props->x; } |
| 569 | //-------------------------------------------------------------------------- | 597 | //-------------------------------------------------------------------------- |
| 570 | 598 | ||
| 571 | //========================================================================== | 599 | //========================================================================== |
| @@ -575,7 +603,7 @@ namespace addon | |||
| 575 | /// | 603 | /// |
| 576 | /// @return The Y position, in pixels | 604 | /// @return The Y position, in pixels |
| 577 | /// | 605 | /// |
| 578 | inline int Y() { return m_instanceData->props.y; } | 606 | inline int Y() { return m_instanceData->props->y; } |
| 579 | //-------------------------------------------------------------------------- | 607 | //-------------------------------------------------------------------------- |
| 580 | 608 | ||
| 581 | //========================================================================== | 609 | //========================================================================== |
| @@ -585,7 +613,7 @@ namespace addon | |||
| 585 | /// | 613 | /// |
| 586 | /// @return The width, in pixels | 614 | /// @return The width, in pixels |
| 587 | /// | 615 | /// |
| 588 | inline int Width() { return m_instanceData->props.width; } | 616 | inline int Width() { return m_instanceData->props->width; } |
| 589 | //-------------------------------------------------------------------------- | 617 | //-------------------------------------------------------------------------- |
| 590 | 618 | ||
| 591 | //========================================================================== | 619 | //========================================================================== |
| @@ -595,7 +623,7 @@ namespace addon | |||
| 595 | /// | 623 | /// |
| 596 | /// @return The height, in pixels | 624 | /// @return The height, in pixels |
| 597 | /// | 625 | /// |
| 598 | inline int Height() { return m_instanceData->props.height; } | 626 | inline int Height() { return m_instanceData->props->height; } |
| 599 | //-------------------------------------------------------------------------- | 627 | //-------------------------------------------------------------------------- |
| 600 | 628 | ||
| 601 | //========================================================================== | 629 | //========================================================================== |
| @@ -606,7 +634,7 @@ namespace addon | |||
| 606 | /// | 634 | /// |
| 607 | /// @return The pixel aspect ratio used by the display | 635 | /// @return The pixel aspect ratio used by the display |
| 608 | /// | 636 | /// |
| 609 | inline float PixelRatio() { return m_instanceData->props.pixelRatio; } | 637 | inline float PixelRatio() { return m_instanceData->props->pixelRatio; } |
| 610 | //-------------------------------------------------------------------------- | 638 | //-------------------------------------------------------------------------- |
| 611 | 639 | ||
| 612 | //========================================================================== | 640 | //========================================================================== |
| @@ -616,7 +644,7 @@ namespace addon | |||
| 616 | /// | 644 | /// |
| 617 | /// @return The add-on name | 645 | /// @return The add-on name |
| 618 | /// | 646 | /// |
| 619 | inline std::string Name() { return m_instanceData->props.name; } | 647 | inline std::string Name() { return m_instanceData->props->name; } |
| 620 | //-------------------------------------------------------------------------- | 648 | //-------------------------------------------------------------------------- |
| 621 | 649 | ||
| 622 | //========================================================================== | 650 | //========================================================================== |
| @@ -626,7 +654,7 @@ namespace addon | |||
| 626 | /// | 654 | /// |
| 627 | /// @return The add-on installation path | 655 | /// @return The add-on installation path |
| 628 | /// | 656 | /// |
| 629 | inline std::string Presets() { return m_instanceData->props.presets; } | 657 | inline std::string Presets() { return m_instanceData->props->presets; } |
| 630 | //-------------------------------------------------------------------------- | 658 | //-------------------------------------------------------------------------- |
| 631 | 659 | ||
| 632 | //========================================================================== | 660 | //========================================================================== |
| @@ -640,7 +668,7 @@ namespace addon | |||
| 640 | /// | 668 | /// |
| 641 | /// @return Path to the user profile | 669 | /// @return Path to the user profile |
| 642 | /// | 670 | /// |
| 643 | inline std::string Profile() { return m_instanceData->props.profile; } | 671 | inline std::string Profile() { return m_instanceData->props->profile; } |
| 644 | //-------------------------------------------------------------------------- | 672 | //-------------------------------------------------------------------------- |
| 645 | //@} | 673 | //@} |
| 646 | 674 | ||
| @@ -651,46 +679,53 @@ namespace addon | |||
| 651 | throw std::logic_error("kodi::addon::CInstanceVisualization: Null pointer instance passed."); | 679 | throw std::logic_error("kodi::addon::CInstanceVisualization: Null pointer instance passed."); |
| 652 | 680 | ||
| 653 | m_instanceData = static_cast<AddonInstance_Visualization*>(instance); | 681 | m_instanceData = static_cast<AddonInstance_Visualization*>(instance); |
| 654 | m_instanceData->toAddon.addonInstance = this; | 682 | m_instanceData->toAddon->addonInstance = this; |
| 655 | m_instanceData->toAddon.start = ADDON_Start; | 683 | m_instanceData->toAddon->start = ADDON_Start; |
| 656 | m_instanceData->toAddon.stop = ADDON_Stop; | 684 | m_instanceData->toAddon->stop = ADDON_Stop; |
| 657 | m_instanceData->toAddon.audio_data = ADDON_AudioData; | 685 | m_instanceData->toAddon->audio_data = ADDON_AudioData; |
| 658 | m_instanceData->toAddon.render = ADDON_Render; | 686 | m_instanceData->toAddon->is_dirty = ADDON_IsDirty; |
| 659 | m_instanceData->toAddon.get_info = ADDON_GetInfo; | 687 | m_instanceData->toAddon->render = ADDON_Render; |
| 660 | m_instanceData->toAddon.on_action = ADDON_OnAction; | 688 | m_instanceData->toAddon->get_info = ADDON_GetInfo; |
| 661 | m_instanceData->toAddon.get_presets = ADDON_GetPresets; | 689 | m_instanceData->toAddon->on_action = ADDON_OnAction; |
| 662 | m_instanceData->toAddon.get_active_preset = ADDON_GetActivePreset; | 690 | m_instanceData->toAddon->get_presets = ADDON_GetPresets; |
| 663 | m_instanceData->toAddon.is_locked = ADDON_IsLocked; | 691 | m_instanceData->toAddon->get_active_preset = ADDON_GetActivePreset; |
| 692 | m_instanceData->toAddon->is_locked = ADDON_IsLocked; | ||
| 664 | } | 693 | } |
| 665 | 694 | ||
| 666 | inline static bool ADDON_Start(const AddonInstance_Visualization* addon, int channels, int samplesPerSec, int bitsPerSample, const char* songName) | 695 | inline static bool ADDON_Start(const AddonInstance_Visualization* addon, int channels, int samplesPerSec, int bitsPerSample, const char* songName) |
| 667 | { | 696 | { |
| 668 | return addon->toAddon.addonInstance->Start(channels, samplesPerSec, bitsPerSample, songName); | 697 | addon->toAddon->addonInstance->m_renderHelper = kodi::gui::GetRenderHelper(); |
| 698 | return addon->toAddon->addonInstance->Start(channels, samplesPerSec, bitsPerSample, songName); | ||
| 669 | } | 699 | } |
| 670 | 700 | ||
| 671 | inline static void ADDON_Stop(const AddonInstance_Visualization* addon) | 701 | inline static void ADDON_Stop(const AddonInstance_Visualization* addon) |
| 672 | { | 702 | { |
| 673 | addon->toAddon.addonInstance->Stop(); | 703 | addon->toAddon->addonInstance->Stop(); |
| 704 | addon->toAddon->addonInstance->m_renderHelper = nullptr; | ||
| 674 | } | 705 | } |
| 675 | 706 | ||
| 676 | inline static void ADDON_AudioData(const AddonInstance_Visualization* addon, const float* audioData, int audioDataLength, float *freqData, int freqDataLength) | 707 | inline static void ADDON_AudioData(const AddonInstance_Visualization* addon, const float* audioData, int audioDataLength, float *freqData, int freqDataLength) |
| 677 | { | 708 | { |
| 678 | addon->toAddon.addonInstance->AudioData(audioData, audioDataLength, freqData, freqDataLength); | 709 | addon->toAddon->addonInstance->AudioData(audioData, audioDataLength, freqData, freqDataLength); |
| 679 | } | 710 | } |
| 680 | 711 | ||
| 681 | inline static bool ADDON_IsDirty(const AddonInstance_Visualization* addon) | 712 | inline static bool ADDON_IsDirty(const AddonInstance_Visualization* addon) |
| 682 | { | 713 | { |
| 683 | return addon->toAddon.addonInstance->IsDirty(); | 714 | return addon->toAddon->addonInstance->IsDirty(); |
| 684 | } | 715 | } |
| 685 | 716 | ||
| 686 | inline static void ADDON_Render(const AddonInstance_Visualization* addon) | 717 | inline static void ADDON_Render(const AddonInstance_Visualization* addon) |
| 687 | { | 718 | { |
| 688 | addon->toAddon.addonInstance->Render(); | 719 | if (!addon->toAddon->addonInstance->m_renderHelper) |
| 720 | return; | ||
| 721 | addon->toAddon->addonInstance->m_renderHelper->Begin(); | ||
| 722 | addon->toAddon->addonInstance->Render(); | ||
| 723 | addon->toAddon->addonInstance->m_renderHelper->End(); | ||
| 689 | } | 724 | } |
| 690 | 725 | ||
| 691 | inline static void ADDON_GetInfo(const AddonInstance_Visualization* addon, VIS_INFO *info) | 726 | inline static void ADDON_GetInfo(const AddonInstance_Visualization* addon, VIS_INFO *info) |
| 692 | { | 727 | { |
| 693 | addon->toAddon.addonInstance->GetInfo(info->bWantsFreq, info->iSyncDelay); | 728 | addon->toAddon->addonInstance->GetInfo(info->bWantsFreq, info->iSyncDelay); |
| 694 | } | 729 | } |
| 695 | 730 | ||
| 696 | inline static bool ADDON_OnAction(const AddonInstance_Visualization* addon, VIS_ACTION action, const void *param) | 731 | inline static bool ADDON_OnAction(const AddonInstance_Visualization* addon, VIS_ACTION action, const void *param) |
| @@ -698,24 +733,24 @@ namespace addon | |||
| 698 | switch (action) | 733 | switch (action) |
| 699 | { | 734 | { |
| 700 | case VIS_ACTION_NEXT_PRESET: | 735 | case VIS_ACTION_NEXT_PRESET: |
| 701 | return addon->toAddon.addonInstance->NextPreset(); | 736 | return addon->toAddon->addonInstance->NextPreset(); |
| 702 | case VIS_ACTION_PREV_PRESET: | 737 | case VIS_ACTION_PREV_PRESET: |
| 703 | return addon->toAddon.addonInstance->PrevPreset(); | 738 | return addon->toAddon->addonInstance->PrevPreset(); |
| 704 | case VIS_ACTION_LOAD_PRESET: | 739 | case VIS_ACTION_LOAD_PRESET: |
| 705 | return addon->toAddon.addonInstance->LoadPreset(*static_cast<const int*>(param)); | 740 | return addon->toAddon->addonInstance->LoadPreset(*static_cast<const int*>(param)); |
| 706 | case VIS_ACTION_RANDOM_PRESET: | 741 | case VIS_ACTION_RANDOM_PRESET: |
| 707 | return addon->toAddon.addonInstance->RandomPreset(); | 742 | return addon->toAddon->addonInstance->RandomPreset(); |
| 708 | case VIS_ACTION_LOCK_PRESET: | 743 | case VIS_ACTION_LOCK_PRESET: |
| 709 | addon->toAddon.addonInstance->m_presetLockedByUser = !addon->toAddon.addonInstance->m_presetLockedByUser; | 744 | addon->toAddon->addonInstance->m_presetLockedByUser = !addon->toAddon->addonInstance->m_presetLockedByUser; |
| 710 | return addon->toAddon.addonInstance->LockPreset(addon->toAddon.addonInstance->m_presetLockedByUser); | 745 | return addon->toAddon->addonInstance->LockPreset(addon->toAddon->addonInstance->m_presetLockedByUser); |
| 711 | case VIS_ACTION_RATE_PRESET_PLUS: | 746 | case VIS_ACTION_RATE_PRESET_PLUS: |
| 712 | return addon->toAddon.addonInstance->RatePreset(true); | 747 | return addon->toAddon->addonInstance->RatePreset(true); |
| 713 | case VIS_ACTION_RATE_PRESET_MINUS: | 748 | case VIS_ACTION_RATE_PRESET_MINUS: |
| 714 | return addon->toAddon.addonInstance->RatePreset(false); | 749 | return addon->toAddon->addonInstance->RatePreset(false); |
| 715 | case VIS_ACTION_UPDATE_ALBUMART: | 750 | case VIS_ACTION_UPDATE_ALBUMART: |
| 716 | return addon->toAddon.addonInstance->UpdateAlbumart(static_cast<const char*>(param)); | 751 | return addon->toAddon->addonInstance->UpdateAlbumart(static_cast<const char*>(param)); |
| 717 | case VIS_ACTION_UPDATE_TRACK: | 752 | case VIS_ACTION_UPDATE_TRACK: |
| 718 | return addon->toAddon.addonInstance->UpdateTrack(*static_cast<const VisTrack*>(param)); | 753 | return addon->toAddon->addonInstance->UpdateTrack(*static_cast<const VisTrack*>(param)); |
| 719 | case VIS_ACTION_NONE: | 754 | case VIS_ACTION_NONE: |
| 720 | default: | 755 | default: |
| 721 | break; | 756 | break; |
| @@ -726,10 +761,10 @@ namespace addon | |||
| 726 | inline static unsigned int ADDON_GetPresets(const AddonInstance_Visualization* addon) | 761 | inline static unsigned int ADDON_GetPresets(const AddonInstance_Visualization* addon) |
| 727 | { | 762 | { |
| 728 | std::vector<std::string> presets; | 763 | std::vector<std::string> presets; |
| 729 | if (addon->toAddon.addonInstance->GetPresets(presets)) | 764 | if (addon->toAddon->addonInstance->GetPresets(presets)) |
| 730 | { | 765 | { |
| 731 | for (auto it : presets) | 766 | for (auto it : presets) |
| 732 | addon->toAddon.addonInstance->m_instanceData->toKodi.transfer_preset(addon->toKodi.kodiInstance, it.c_str()); | 767 | addon->toAddon->addonInstance->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str()); |
| 733 | } | 768 | } |
| 734 | 769 | ||
| 735 | return static_cast<unsigned int>(presets.size()); | 770 | return static_cast<unsigned int>(presets.size()); |
| @@ -737,14 +772,15 @@ namespace addon | |||
| 737 | 772 | ||
| 738 | inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon) | 773 | inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon) |
| 739 | { | 774 | { |
| 740 | return addon->toAddon.addonInstance->GetActivePreset(); | 775 | return addon->toAddon->addonInstance->GetActivePreset(); |
| 741 | } | 776 | } |
| 742 | 777 | ||
| 743 | inline static bool ADDON_IsLocked(const AddonInstance_Visualization* addon) | 778 | inline static bool ADDON_IsLocked(const AddonInstance_Visualization* addon) |
| 744 | { | 779 | { |
| 745 | return addon->toAddon.addonInstance->IsLocked(); | 780 | return addon->toAddon->addonInstance->IsLocked(); |
| 746 | } | 781 | } |
| 747 | 782 | ||
| 783 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 748 | bool m_presetLockedByUser = false; | 784 | bool m_presetLockedByUser = false; |
| 749 | AddonInstance_Visualization* m_instanceData; | 785 | AddonInstance_Visualization* m_instanceData; |
| 750 | }; | 786 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt new file mode 100644 index 0000000..946849e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | set(HEADERS ChannelGroups.h | ||
| 2 | Channels.h | ||
| 3 | EDL.h | ||
| 4 | EPG.h | ||
| 5 | General.h | ||
| 6 | MenuHook.h | ||
| 7 | Recordings.h | ||
| 8 | Stream.h | ||
| 9 | Timers.h) | ||
| 10 | |||
| 11 | if(NOT ENABLE_STATIC_LIBS) | ||
| 12 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_addon-instance_pvr) | ||
| 13 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h new file mode 100644 index 0000000..17995bb --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h | |||
| @@ -0,0 +1,271 @@ | |||
| 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.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 3 - PVR channel group | ||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace addon | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup class PVRChannelGroup | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup | ||
| 26 | /// @brief **PVR add-on channel group**\n | ||
| 27 | /// To define a group for channels, this becomes be asked from | ||
| 28 | /// @ref kodi::addon::CInstancePVRClient::GetChannelGroups() and used on | ||
| 29 | /// @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers() to get his | ||
| 30 | /// content with @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember "PVRChannelGroupMember". | ||
| 31 | /// | ||
| 32 | /// ---------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup_Help | ||
| 35 | /// | ||
| 36 | ///@{ | ||
| 37 | class PVRChannelGroup : public CStructHdl<PVRChannelGroup, PVR_CHANNEL_GROUP> | ||
| 38 | { | ||
| 39 | friend class CInstancePVRClient; | ||
| 40 | |||
| 41 | public: | ||
| 42 | /*! \cond PRIVATE */ | ||
| 43 | PVRChannelGroup() { memset(m_cStructure, 0, sizeof(PVR_CHANNEL_GROUP)); } | ||
| 44 | PVRChannelGroup(const PVRChannelGroup& channel) : CStructHdl(channel) {} | ||
| 45 | /*! \endcond */ | ||
| 46 | |||
| 47 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup_Help Value Help | ||
| 48 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup | ||
| 49 | /// | ||
| 50 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup :</b> | ||
| 51 | /// | Name | Type | Set call | Get call | Usage | ||
| 52 | /// |------|------|----------|----------|----------- | ||
| 53 | /// | **Group name** | `std::string` | @ref PVRChannelGroup::SetGroupName "SetGroupName" | @ref PVRChannelGroup::GetGroupName "GetGroupName" | *required to set* | ||
| 54 | /// | **Is radio** | `bool` | @ref PVRChannelGroup::SetIsRadio "SetIsRadio" | @ref PVRChannelGroup::GetIsRadio "GetIsRadio" | *required to set* | ||
| 55 | /// | **Position** | `unsigned int` | @ref PVRChannelGroup::SetPosition "SetPosition" | @ref PVRChannelGroup::GetPosition "GetPosition" | *optional* | ||
| 56 | /// | ||
| 57 | |||
| 58 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup | ||
| 59 | ///@{ | ||
| 60 | |||
| 61 | /// @brief **required**\n | ||
| 62 | /// Name of this channel group. | ||
| 63 | void SetGroupName(const std::string& groupName) | ||
| 64 | { | ||
| 65 | strncpy(m_cStructure->strGroupName, groupName.c_str(), sizeof(m_cStructure->strGroupName) - 1); | ||
| 66 | } | ||
| 67 | |||
| 68 | /// @brief To get with @ref SetGroupName changed values. | ||
| 69 | std::string GetGroupName() const { return m_cStructure->strGroupName; } | ||
| 70 | |||
| 71 | /// @brief **required**\n | ||
| 72 | /// **true** If this is a radio channel group, **false** otherwise. | ||
| 73 | void SetIsRadio(bool isRadio) { m_cStructure->bIsRadio = isRadio; } | ||
| 74 | |||
| 75 | /// @brief To get with @ref SetIsRadio changed values. | ||
| 76 | bool GetIsRadio() const { return m_cStructure->bIsRadio; } | ||
| 77 | |||
| 78 | /// @brief **optional**\n | ||
| 79 | /// Sort position of the group (<b>`0`</b> indicates that the backend doesn't | ||
| 80 | /// support sorting of groups). | ||
| 81 | void SetPosition(unsigned int position) { m_cStructure->iPosition = position; } | ||
| 82 | |||
| 83 | /// @brief To get with @ref SetPosition changed values. | ||
| 84 | unsigned int GetPosition() const { return m_cStructure->iPosition; } | ||
| 85 | |||
| 86 | ///@} | ||
| 87 | |||
| 88 | private: | ||
| 89 | PVRChannelGroup(const PVR_CHANNEL_GROUP* channel) : CStructHdl(channel) {} | ||
| 90 | PVRChannelGroup(PVR_CHANNEL_GROUP* channel) : CStructHdl(channel) {} | ||
| 91 | }; | ||
| 92 | ///@} | ||
| 93 | //------------------------------------------------------------------------------ | ||
| 94 | |||
| 95 | //============================================================================== | ||
| 96 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupsResultSet class PVRChannelGroupsResultSet | ||
| 97 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup | ||
| 98 | /// @brief **PVR add-on channel group member transfer class**\n | ||
| 99 | /// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetChannelGroups(). | ||
| 100 | /// | ||
| 101 | ///@{ | ||
| 102 | class PVRChannelGroupsResultSet | ||
| 103 | { | ||
| 104 | public: | ||
| 105 | /*! \cond PRIVATE */ | ||
| 106 | PVRChannelGroupsResultSet() = delete; | ||
| 107 | PVRChannelGroupsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 108 | : m_instance(instance), m_handle(handle) | ||
| 109 | { | ||
| 110 | } | ||
| 111 | /*! \endcond */ | ||
| 112 | |||
| 113 | |||
| 114 | /// @addtogroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupsResultSet | ||
| 115 | ///@{ | ||
| 116 | |||
| 117 | /// @brief To add and give content from addon to Kodi on related call. | ||
| 118 | /// | ||
| 119 | /// @param[in] tag The to transferred data. | ||
| 120 | void Add(const kodi::addon::PVRChannelGroup& tag) | ||
| 121 | { | ||
| 122 | m_instance->toKodi->TransferChannelGroup(m_instance->toKodi->kodiInstance, m_handle, tag); | ||
| 123 | } | ||
| 124 | |||
| 125 | ///@} | ||
| 126 | |||
| 127 | private: | ||
| 128 | const AddonInstance_PVR* m_instance = nullptr; | ||
| 129 | const ADDON_HANDLE m_handle; | ||
| 130 | }; | ||
| 131 | ///@} | ||
| 132 | //------------------------------------------------------------------------------ | ||
| 133 | |||
| 134 | //============================================================================== | ||
| 135 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember class PVRChannelGroupMember | ||
| 136 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup | ||
| 137 | /// @brief **PVR add-on channel group member**\n | ||
| 138 | /// To define the content of @ref kodi::addon::CInstancePVRClient::GetChannelGroups() | ||
| 139 | /// given groups. | ||
| 140 | /// | ||
| 141 | /// This content becomes then requested with @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers(). | ||
| 142 | /// | ||
| 143 | /// ---------------------------------------------------------------------------- | ||
| 144 | /// | ||
| 145 | /// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember_Help | ||
| 146 | /// | ||
| 147 | ///@{ | ||
| 148 | class PVRChannelGroupMember : public CStructHdl<PVRChannelGroupMember, PVR_CHANNEL_GROUP_MEMBER> | ||
| 149 | { | ||
| 150 | friend class CInstancePVRClient; | ||
| 151 | |||
| 152 | public: | ||
| 153 | /*! \cond PRIVATE */ | ||
| 154 | PVRChannelGroupMember() { memset(m_cStructure, 0, sizeof(PVR_CHANNEL_GROUP_MEMBER)); } | ||
| 155 | PVRChannelGroupMember(const PVRChannelGroupMember& channel) : CStructHdl(channel) {} | ||
| 156 | /*! \endcond */ | ||
| 157 | |||
| 158 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember_Help Value Help | ||
| 159 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember | ||
| 160 | /// | ||
| 161 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember :</b> | ||
| 162 | /// | Name | Type | Set call | Get call | Usage | ||
| 163 | /// |-------|-------|-----------|----------|----------- | ||
| 164 | /// | **Group name** | `std::string` | @ref PVRChannelGroupMember::SetGroupName "SetGroupName" | @ref PVRChannelGroupMember::GetGroupName "GetGroupName" | *required to set* | ||
| 165 | /// | **Channel unique id** | `unsigned int` | @ref PVRChannelGroupMember::SetChannelUniqueId "SetChannelUniqueId" | @ref PVRChannelGroupMember::GetChannelUniqueId "GetChannelUniqueId" | *required to set* | ||
| 166 | /// | **Channel Number** | `unsigned int` | @ref PVRChannelGroupMember::SetChannelNumber "SetChannelNumber" | @ref PVRChannelGroupMember::GetChannelNumber "GetChannelNumber" | *optional* | ||
| 167 | /// | **Sub channel number** | `unsigned int` | @ref PVRChannelGroupMember::SetSubChannelNumber "SetSubChannelNumber"| @ref PVRChannelGroupMember::GetSubChannelNumber "GetSubChannelNumber" | *optional* | ||
| 168 | /// | **Order** | `int` | @ref PVRChannel::SetOrder "SetOrder" | @ref PVRChannel::GetOrder "GetOrder" | *optional* | ||
| 169 | /// | ||
| 170 | |||
| 171 | /// @addtogroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember | ||
| 172 | ///@{ | ||
| 173 | |||
| 174 | /// @brief **required**\n | ||
| 175 | /// Name of the channel group to add the channel to. | ||
| 176 | void SetGroupName(const std::string& groupName) | ||
| 177 | { | ||
| 178 | strncpy(m_cStructure->strGroupName, groupName.c_str(), sizeof(m_cStructure->strGroupName) - 1); | ||
| 179 | } | ||
| 180 | |||
| 181 | /// @brief To get with @ref SetGroupName changed values. | ||
| 182 | std::string GetGroupName() const { return m_cStructure->strGroupName; } | ||
| 183 | |||
| 184 | /// @brief **required**\n | ||
| 185 | /// Unique id of the member. | ||
| 186 | void SetChannelUniqueId(unsigned int channelUniqueId) | ||
| 187 | { | ||
| 188 | m_cStructure->iChannelUniqueId = channelUniqueId; | ||
| 189 | } | ||
| 190 | |||
| 191 | /// @brief To get with @ref SetChannelUniqueId changed values. | ||
| 192 | unsigned int GetChannelUniqueId() const { return m_cStructure->iChannelUniqueId; } | ||
| 193 | |||
| 194 | /// @brief **optional**\n | ||
| 195 | /// Channel number within the group. | ||
| 196 | void SetChannelNumber(unsigned int channelNumber) | ||
| 197 | { | ||
| 198 | m_cStructure->iChannelNumber = channelNumber; | ||
| 199 | } | ||
| 200 | |||
| 201 | /// @brief To get with @ref SetChannelNumber changed values. | ||
| 202 | unsigned int GetChannelNumber() const { return m_cStructure->iChannelNumber; } | ||
| 203 | |||
| 204 | /// @brief **optional**\n | ||
| 205 | /// Sub channel number within the group (ATSC). | ||
| 206 | void SetSubChannelNumber(unsigned int subChannelNumber) | ||
| 207 | { | ||
| 208 | m_cStructure->iSubChannelNumber = subChannelNumber; | ||
| 209 | } | ||
| 210 | |||
| 211 | /// @brief To get with @ref SetSubChannelNumber changed values. | ||
| 212 | unsigned int GetSubChannelNumber() const { return m_cStructure->iSubChannelNumber; } | ||
| 213 | |||
| 214 | /// @brief **optional**\n | ||
| 215 | /// The value denoting the order of this channel in the <b>'All channels'</b> group. | ||
| 216 | void SetOrder(bool order) { m_cStructure->iOrder = order; } | ||
| 217 | |||
| 218 | /// @brief To get with @ref SetOrder changed values. | ||
| 219 | bool GetOrder() const { return m_cStructure->iOrder; } | ||
| 220 | |||
| 221 | ///@} | ||
| 222 | |||
| 223 | private: | ||
| 224 | PVRChannelGroupMember(const PVR_CHANNEL_GROUP_MEMBER* channel) : CStructHdl(channel) {} | ||
| 225 | PVRChannelGroupMember(PVR_CHANNEL_GROUP_MEMBER* channel) : CStructHdl(channel) {} | ||
| 226 | }; | ||
| 227 | ///@} | ||
| 228 | //------------------------------------------------------------------------------ | ||
| 229 | |||
| 230 | //============================================================================== | ||
| 231 | /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMembersResultSet class PVRChannelGroupMembersResultSet | ||
| 232 | /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember | ||
| 233 | /// @brief **PVR add-on channel group member transfer class**\n | ||
| 234 | /// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers(). | ||
| 235 | /// | ||
| 236 | ///@{ | ||
| 237 | class PVRChannelGroupMembersResultSet | ||
| 238 | { | ||
| 239 | public: | ||
| 240 | /*! \cond PRIVATE */ | ||
| 241 | PVRChannelGroupMembersResultSet() = delete; | ||
| 242 | PVRChannelGroupMembersResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 243 | : m_instance(instance), m_handle(handle) | ||
| 244 | { | ||
| 245 | } | ||
| 246 | /*! \endcond */ | ||
| 247 | |||
| 248 | /// @addtogroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMembersResultSet | ||
| 249 | ///@{ | ||
| 250 | |||
| 251 | /// @brief To add and give content from addon to Kodi on related call. | ||
| 252 | /// | ||
| 253 | /// @param[in] tag The to transferred data. | ||
| 254 | void Add(const kodi::addon::PVRChannelGroupMember& tag) | ||
| 255 | { | ||
| 256 | m_instance->toKodi->TransferChannelGroupMember(m_instance->toKodi->kodiInstance, m_handle, tag); | ||
| 257 | } | ||
| 258 | |||
| 259 | ///@} | ||
| 260 | |||
| 261 | private: | ||
| 262 | const AddonInstance_PVR* m_instance = nullptr; | ||
| 263 | const ADDON_HANDLE m_handle; | ||
| 264 | }; | ||
| 265 | ///@} | ||
| 266 | //------------------------------------------------------------------------------ | ||
| 267 | |||
| 268 | } /* namespace addon */ | ||
| 269 | } /* namespace kodi */ | ||
| 270 | |||
| 271 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h new file mode 100644 index 0000000..9c2f5d2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h | |||
| @@ -0,0 +1,518 @@ | |||
| 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.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 2 - PVR channel | ||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace addon | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel class PVRChannel | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel | ||
| 26 | /// @brief **Channel data structure**\n | ||
| 27 | /// Representation of a TV or radio channel. | ||
| 28 | /// | ||
| 29 | /// This is used to store all the necessary TV or radio channel data and can | ||
| 30 | /// either provide the necessary data from / to Kodi for the associated | ||
| 31 | /// functions or can also be used in the addon to store its data. | ||
| 32 | /// | ||
| 33 | /// ---------------------------------------------------------------------------- | ||
| 34 | /// | ||
| 35 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help | ||
| 36 | /// | ||
| 37 | ///@{ | ||
| 38 | class PVRChannel : public CStructHdl<PVRChannel, PVR_CHANNEL> | ||
| 39 | { | ||
| 40 | friend class CInstancePVRClient; | ||
| 41 | |||
| 42 | public: | ||
| 43 | /*! \cond PRIVATE */ | ||
| 44 | PVRChannel() { memset(m_cStructure, 0, sizeof(PVR_CHANNEL)); } | ||
| 45 | PVRChannel(const PVRChannel& channel) : CStructHdl(channel) {} | ||
| 46 | /*! \endcond */ | ||
| 47 | |||
| 48 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help Value Help | ||
| 49 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel | ||
| 50 | /// | ||
| 51 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRChannel :</b> | ||
| 52 | /// | Name | Type | Set call | Get call | Usage | ||
| 53 | /// |------|------|----------|----------|----------- | ||
| 54 | /// | **Unique id** | `unsigned int` | @ref PVRChannel::SetUniqueId "SetUniqueId" | @ref PVRChannel::GetUniqueId "GetUniqueId" | *required to set* | ||
| 55 | /// | **Is radio** | `bool` | @ref PVRChannel::SetIsRadio "SetIsRadio" | @ref PVRChannel::GetIsRadio "GetIsRadio" | *required to set* | ||
| 56 | /// | **Channel number** | `unsigned int` | @ref PVRChannel::SetChannelNumber "SetChannelNumber" | @ref PVRChannel::GetChannelNumber "GetChannelNumber" | *optional* | ||
| 57 | /// | **Sub channel number** | `unsigned int` | @ref PVRChannel::SetSubChannelNumber "SetSubChannelNumber" | @ref PVRChannel::GetSubChannelNumber "GetSubChannelNumber" | *optional* | ||
| 58 | /// | **Channel name** | `std::string` | @ref PVRChannel::SetChannelName "SetChannelName" | @ref PVRChannel::GetChannelName "GetChannelName" | *optional* | ||
| 59 | /// | **Mime type** | `std::string` | @ref PVRChannel::SetMimeType "SetMimeType" | @ref PVRChannel::GetMimeType "GetMimeType" | *optional* | ||
| 60 | /// | **Encryption system** | `unsigned int` | @ref PVRChannel::SetEncryptionSystem "SetEncryptionSystem" | @ref PVRChannel::GetEncryptionSystem "GetEncryptionSystem" | *optional* | ||
| 61 | /// | **Icon path** | `std::string` | @ref PVRChannel::SetIconPath "SetIconPath" | @ref PVRChannel::GetIconPath "GetIconPath" | *optional* | ||
| 62 | /// | **Is hidden** | `bool` | @ref PVRChannel::SetIsHidden "SetIsHidden" | @ref PVRChannel::GetIsHidden "GetIsHidden" | *optional* | ||
| 63 | /// | **Has archive** | `bool` | @ref PVRChannel::SetHasArchive "SetHasArchive" | @ref PVRChannel::GetHasArchive "GetHasArchive" | *optional* | ||
| 64 | /// | **Order** | `int` | @ref PVRChannel::SetOrder "SetOrder" | @ref PVRChannel::GetOrder "GetOrder" | *optional* | ||
| 65 | /// | ||
| 66 | |||
| 67 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel | ||
| 68 | ///@{ | ||
| 69 | |||
| 70 | /// @brief **required**\n | ||
| 71 | /// Unique identifier for this channel. | ||
| 72 | void SetUniqueId(unsigned int uniqueId) { m_cStructure->iUniqueId = uniqueId; } | ||
| 73 | |||
| 74 | /// @brief To get with @ref SetUniqueId changed values. | ||
| 75 | unsigned int GetUniqueId() const { return m_cStructure->iUniqueId; } | ||
| 76 | |||
| 77 | /// @brief **required**\n | ||
| 78 | /// **true** if this is a radio channel, **false** if it's a TV channel. | ||
| 79 | void SetIsRadio(bool isRadio) { m_cStructure->bIsRadio = isRadio; } | ||
| 80 | |||
| 81 | /// @brief To get with @ref SetIsRadio changed values. | ||
| 82 | bool GetIsRadio() const { return m_cStructure->bIsRadio; } | ||
| 83 | |||
| 84 | /// @brief **optional**\n | ||
| 85 | /// Channel number of this channel on the backend. | ||
| 86 | void SetChannelNumber(unsigned int channelNumber) | ||
| 87 | { | ||
| 88 | m_cStructure->iChannelNumber = channelNumber; | ||
| 89 | } | ||
| 90 | |||
| 91 | /// @brief To get with @ref SetChannelNumber changed values. | ||
| 92 | unsigned int GetChannelNumber() const { return m_cStructure->iChannelNumber; } | ||
| 93 | |||
| 94 | /// @brief **optional**\n | ||
| 95 | /// Sub channel number of this channel on the backend (ATSC). | ||
| 96 | void SetSubChannelNumber(unsigned int subChannelNumber) | ||
| 97 | { | ||
| 98 | m_cStructure->iSubChannelNumber = subChannelNumber; | ||
| 99 | } | ||
| 100 | |||
| 101 | /// @brief To get with @ref SetSubChannelNumber changed values. | ||
| 102 | unsigned int GetSubChannelNumber() const { return m_cStructure->iSubChannelNumber; } | ||
| 103 | |||
| 104 | /// @brief **optional**\n | ||
| 105 | /// Channel name given to this channel. | ||
| 106 | void SetChannelName(const std::string& channelName) | ||
| 107 | { | ||
| 108 | strncpy(m_cStructure->strChannelName, channelName.c_str(), | ||
| 109 | sizeof(m_cStructure->strChannelName) - 1); | ||
| 110 | } | ||
| 111 | |||
| 112 | /// @brief To get with @ref SetChannelName changed values. | ||
| 113 | std::string GetChannelName() const { return m_cStructure->strChannelName; } | ||
| 114 | |||
| 115 | /// @brief **optional**\n | ||
| 116 | /// Input format mime type. | ||
| 117 | /// | ||
| 118 | /// Available types can be found in https://www.iana.org/assignments/media-types/media-types.xhtml | ||
| 119 | /// on "application" and "video" or leave empty if unknown. | ||
| 120 | /// | ||
| 121 | void SetMimeType(const std::string& inputFormat) | ||
| 122 | { | ||
| 123 | strncpy(m_cStructure->strMimeType, inputFormat.c_str(), sizeof(m_cStructure->strMimeType) - 1); | ||
| 124 | } | ||
| 125 | |||
| 126 | /// @brief To get with @ref SetMimeType changed values. | ||
| 127 | std::string GetMimeType() const { return m_cStructure->strMimeType; } | ||
| 128 | |||
| 129 | /// @brief **optional**\n | ||
| 130 | /// The encryption ID or CaID of this channel (Conditional access systems). | ||
| 131 | /// | ||
| 132 | /// Lists about available ID's: | ||
| 133 | /// - http://www.dvb.org/index.php?id=174 | ||
| 134 | /// - http://en.wikipedia.org/wiki/Conditional_access_system | ||
| 135 | /// | ||
| 136 | void SetEncryptionSystem(unsigned int encryptionSystem) | ||
| 137 | { | ||
| 138 | m_cStructure->iEncryptionSystem = encryptionSystem; | ||
| 139 | } | ||
| 140 | |||
| 141 | /// @brief To get with @ref SetEncryptionSystem changed values. | ||
| 142 | unsigned int GetEncryptionSystem() const { return m_cStructure->iEncryptionSystem; } | ||
| 143 | |||
| 144 | /// @brief **optional**\n | ||
| 145 | /// Path to the channel icon (if present). | ||
| 146 | void SetIconPath(const std::string& iconPath) | ||
| 147 | { | ||
| 148 | strncpy(m_cStructure->strIconPath, iconPath.c_str(), sizeof(m_cStructure->strIconPath) - 1); | ||
| 149 | } | ||
| 150 | |||
| 151 | /// @brief To get with @ref SetIconPath changed values. | ||
| 152 | std::string GetIconPath() const { return m_cStructure->strIconPath; } | ||
| 153 | |||
| 154 | /// @brief **optional**\n | ||
| 155 | /// **true** if this channel is marked as hidden. | ||
| 156 | void SetIsHidden(bool isHidden) { m_cStructure->bIsHidden = isHidden; } | ||
| 157 | |||
| 158 | /// @brief To get with @ref GetIsRadio changed values. | ||
| 159 | bool GetIsHidden() const { return m_cStructure->bIsHidden; } | ||
| 160 | |||
| 161 | /// @brief **optional**\n | ||
| 162 | /// **true** if this channel has a server-side back buffer. | ||
| 163 | void SetHasArchive(bool hasArchive) { m_cStructure->bHasArchive = hasArchive; } | ||
| 164 | |||
| 165 | /// @brief To get with @ref GetIsRadio changed values. | ||
| 166 | bool GetHasArchive() const { return m_cStructure->bHasArchive; } | ||
| 167 | |||
| 168 | /// @brief **optional**\n | ||
| 169 | /// The value denoting the order of this channel in the 'All channels' group. | ||
| 170 | void SetOrder(bool order) { m_cStructure->iOrder = order; } | ||
| 171 | |||
| 172 | /// @brief To get with @ref SetOrder changed values. | ||
| 173 | bool GetOrder() const { return m_cStructure->iOrder; } | ||
| 174 | ///@} | ||
| 175 | |||
| 176 | private: | ||
| 177 | PVRChannel(const PVR_CHANNEL* channel) : CStructHdl(channel) {} | ||
| 178 | PVRChannel(PVR_CHANNEL* channel) : CStructHdl(channel) {} | ||
| 179 | }; | ||
| 180 | ///@} | ||
| 181 | //------------------------------------------------------------------------------ | ||
| 182 | |||
| 183 | //============================================================================== | ||
| 184 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannelsResultSet class PVRChannelsResultSet | ||
| 185 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel | ||
| 186 | /// @brief **PVR add-on channel transfer class**\n | ||
| 187 | /// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetChannels(). | ||
| 188 | /// | ||
| 189 | ///@{ | ||
| 190 | class PVRChannelsResultSet | ||
| 191 | { | ||
| 192 | public: | ||
| 193 | /*! \cond PRIVATE */ | ||
| 194 | PVRChannelsResultSet() = delete; | ||
| 195 | PVRChannelsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 196 | : m_instance(instance), m_handle(handle) | ||
| 197 | { | ||
| 198 | } | ||
| 199 | /*! \endcond */ | ||
| 200 | |||
| 201 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannelsResultSet | ||
| 202 | ///@{ | ||
| 203 | |||
| 204 | /// @brief To add and give content from addon to Kodi on related call. | ||
| 205 | /// | ||
| 206 | /// @param[in] tag The to transferred data. | ||
| 207 | void Add(const kodi::addon::PVRChannel& tag) | ||
| 208 | { | ||
| 209 | m_instance->toKodi->TransferChannelEntry(m_instance->toKodi->kodiInstance, m_handle, tag); | ||
| 210 | } | ||
| 211 | |||
| 212 | ///@} | ||
| 213 | |||
| 214 | private: | ||
| 215 | const AddonInstance_PVR* m_instance = nullptr; | ||
| 216 | const ADDON_HANDLE m_handle; | ||
| 217 | }; | ||
| 218 | ///@} | ||
| 219 | //------------------------------------------------------------------------------ | ||
| 220 | |||
| 221 | //============================================================================== | ||
| 222 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus class PVRSignalStatus | ||
| 223 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel | ||
| 224 | /// @brief **PVR Signal status information**\n | ||
| 225 | /// This class gives current status information from stream to Kodi. | ||
| 226 | /// | ||
| 227 | /// Used to get information for user by call of @ref kodi::addon::CInstancePVRClient::GetSignalStatus() | ||
| 228 | /// to see current quality and source. | ||
| 229 | /// | ||
| 230 | /// ---------------------------------------------------------------------------- | ||
| 231 | /// | ||
| 232 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus_Help | ||
| 233 | /// | ||
| 234 | ///@{ | ||
| 235 | class PVRSignalStatus : public CStructHdl<PVRSignalStatus, PVR_SIGNAL_STATUS> | ||
| 236 | { | ||
| 237 | friend class CInstancePVRClient; | ||
| 238 | |||
| 239 | public: | ||
| 240 | /*! \cond PRIVATE */ | ||
| 241 | PVRSignalStatus() = default; | ||
| 242 | PVRSignalStatus(const PVRSignalStatus& type) : CStructHdl(type) {} | ||
| 243 | /*! \endcond */ | ||
| 244 | |||
| 245 | |||
| 246 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus_Help Value Help | ||
| 247 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus | ||
| 248 | /// | ||
| 249 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus :</b> | ||
| 250 | /// | Name | Type | Set call | Get call | Usage | ||
| 251 | /// |------|------|----------|----------|----------- | ||
| 252 | /// | **Adapter name** | `std::string` | @ref PVRSignalStatus::SetAdapterName "SetAdapterName" | @ref PVRSignalStatus::GetAdapterName "GetAdapterName" | *optional* | ||
| 253 | /// | **Adapter status** | `std::string` | @ref PVRSignalStatus::SetAdapterStatus "SetAdapterStatus" | @ref PVRSignalStatus::GetAdapterStatus "GetAdapterStatus" | *optional* | ||
| 254 | /// | **Service name** | `std::string` | @ref PVRSignalStatus::SetServiceName "SetServiceName" | @ref PVRSignalStatus::GetServiceName "GetServiceName" | *optional* | ||
| 255 | /// | **Provider name** | `std::string` | @ref PVRSignalStatus::SetProviderName "SetProviderName" | @ref PVRSignalStatus::GetProviderName "GetProviderName" | *optional* | ||
| 256 | /// | **Mux name** | `std::string` | @ref PVRSignalStatus::SetMuxName "SetMuxName" | @ref PVRSignalStatus::GetMuxName "GetMuxName" | *optional* | ||
| 257 | /// | **Signal/noise ratio** | `int` | @ref PVRSignalStatus::SetSNR "SetSNR" | @ref PVRSignalStatus::GetSNR "GetSNR" | *optional* | ||
| 258 | /// | **Signal strength** | `int` | @ref PVRSignalStatus::SetSignal "SetSignal" | @ref PVRSignalStatus::GetSignal "GetSignal" | *optional* | ||
| 259 | /// | **Bit error rate** | `long` | @ref PVRSignalStatus::SetBER "SetBER" | @ref PVRSignalStatus::GetBER "GetBER" | *optional* | ||
| 260 | /// | **Uncorrected blocks** | `long` | @ref PVRSignalStatus::SetUNC "SetUNC" | @ref PVRSignalStatus::GetUNC "GetUNC" | *optional* | ||
| 261 | /// | ||
| 262 | |||
| 263 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus | ||
| 264 | ///@{ | ||
| 265 | |||
| 266 | /// @brief **optional**\n | ||
| 267 | /// Name of the adapter that's being used. | ||
| 268 | void SetAdapterName(const std::string& adapterName) | ||
| 269 | { | ||
| 270 | strncpy(m_cStructure->strAdapterName, adapterName.c_str(), | ||
| 271 | sizeof(m_cStructure->strAdapterName) - 1); | ||
| 272 | } | ||
| 273 | |||
| 274 | /// @brief To get with @ref SetAdapterName changed values. | ||
| 275 | std::string GetAdapterName() const { return m_cStructure->strAdapterName; } | ||
| 276 | |||
| 277 | /// @brief **optional**\n | ||
| 278 | /// Status of the adapter that's being used. | ||
| 279 | void SetAdapterStatus(const std::string& adapterStatus) | ||
| 280 | { | ||
| 281 | strncpy(m_cStructure->strAdapterStatus, adapterStatus.c_str(), | ||
| 282 | sizeof(m_cStructure->strAdapterStatus) - 1); | ||
| 283 | } | ||
| 284 | |||
| 285 | /// @brief To get with @ref SetAdapterStatus changed values. | ||
| 286 | std::string GetAdapterStatus() const { return m_cStructure->strAdapterStatus; } | ||
| 287 | |||
| 288 | /// @brief **optional**\n | ||
| 289 | /// Name of the current service. | ||
| 290 | void SetServiceName(const std::string& serviceName) | ||
| 291 | { | ||
| 292 | strncpy(m_cStructure->strServiceName, serviceName.c_str(), | ||
| 293 | sizeof(m_cStructure->strServiceName) - 1); | ||
| 294 | } | ||
| 295 | |||
| 296 | /// @brief To get with @ref SetServiceName changed values. | ||
| 297 | std::string GetServiceName() const { return m_cStructure->strServiceName; } | ||
| 298 | |||
| 299 | /// @brief **optional**\n | ||
| 300 | /// Name of the current service's provider. | ||
| 301 | void SetProviderName(const std::string& providerName) | ||
| 302 | { | ||
| 303 | strncpy(m_cStructure->strProviderName, providerName.c_str(), | ||
| 304 | sizeof(m_cStructure->strProviderName) - 1); | ||
| 305 | } | ||
| 306 | |||
| 307 | /// @brief To get with @ref SetProviderName changed values. | ||
| 308 | std::string GetProviderName() const { return m_cStructure->strProviderName; } | ||
| 309 | |||
| 310 | /// @brief **optional**\n | ||
| 311 | /// Name of the current mux. | ||
| 312 | void SetMuxName(const std::string& muxName) | ||
| 313 | { | ||
| 314 | strncpy(m_cStructure->strMuxName, muxName.c_str(), sizeof(m_cStructure->strMuxName) - 1); | ||
| 315 | } | ||
| 316 | |||
| 317 | /// @brief To get with @ref SetMuxName changed values. | ||
| 318 | std::string GetMuxName() const { return m_cStructure->strMuxName; } | ||
| 319 | |||
| 320 | /// @brief **optional**\n | ||
| 321 | /// Signal/noise ratio. | ||
| 322 | /// | ||
| 323 | /// @note 100% is 0xFFFF 65535 | ||
| 324 | void SetSNR(int snr) { m_cStructure->iSNR = snr; } | ||
| 325 | |||
| 326 | /// @brief To get with @ref SetSNR changed values. | ||
| 327 | int GetSNR() const { return m_cStructure->iSNR; } | ||
| 328 | |||
| 329 | /// @brief **optional**\n | ||
| 330 | /// Signal strength. | ||
| 331 | /// | ||
| 332 | /// @note 100% is 0xFFFF 65535 | ||
| 333 | void SetSignal(int signal) { m_cStructure->iSignal = signal; } | ||
| 334 | |||
| 335 | /// @brief To get with @ref SetSignal changed values. | ||
| 336 | int GetSignal() const { return m_cStructure->iSignal; } | ||
| 337 | |||
| 338 | /// @brief **optional**\n | ||
| 339 | /// Bit error rate. | ||
| 340 | void SetBER(long ber) { m_cStructure->iBER = ber; } | ||
| 341 | |||
| 342 | /// @brief To get with @ref SetBER changed values. | ||
| 343 | long GetBER() const { return m_cStructure->iBER; } | ||
| 344 | |||
| 345 | /// @brief **optional**\n | ||
| 346 | /// Uncorrected blocks: | ||
| 347 | void SetUNC(long unc) { m_cStructure->iUNC = unc; } | ||
| 348 | |||
| 349 | /// @brief To get with @ref SetBER changed values. | ||
| 350 | long GetUNC() const { return m_cStructure->iUNC; } | ||
| 351 | ///@} | ||
| 352 | |||
| 353 | private: | ||
| 354 | PVRSignalStatus(const PVR_SIGNAL_STATUS* type) : CStructHdl(type) {} | ||
| 355 | PVRSignalStatus(PVR_SIGNAL_STATUS* type) : CStructHdl(type) {} | ||
| 356 | }; | ||
| 357 | ///@} | ||
| 358 | //------------------------------------------------------------------------------ | ||
| 359 | |||
| 360 | //============================================================================== | ||
| 361 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo class PVRDescrambleInfo | ||
| 362 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel | ||
| 363 | /// @brief **Data structure for descrample info**\n | ||
| 364 | /// Information data to give via this to Kodi. | ||
| 365 | /// | ||
| 366 | /// As description see also here https://en.wikipedia.org/wiki/Conditional_access. | ||
| 367 | /// | ||
| 368 | /// Used on @ref kodi::addon::CInstancePVRClient::GetDescrambleInfo(). | ||
| 369 | /// | ||
| 370 | /// ---------------------------------------------------------------------------- | ||
| 371 | /// | ||
| 372 | /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo_Help | ||
| 373 | /// | ||
| 374 | ///@{ | ||
| 375 | class PVRDescrambleInfo : public CStructHdl<PVRDescrambleInfo, PVR_DESCRAMBLE_INFO> | ||
| 376 | { | ||
| 377 | friend class CInstancePVRClient; | ||
| 378 | |||
| 379 | public: | ||
| 380 | /*! \cond PRIVATE */ | ||
| 381 | PVRDescrambleInfo() | ||
| 382 | { | ||
| 383 | m_cStructure->iPid = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE; | ||
| 384 | m_cStructure->iCaid = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE; | ||
| 385 | m_cStructure->iProvid = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE; | ||
| 386 | m_cStructure->iEcmTime = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE; | ||
| 387 | m_cStructure->iHops = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE; | ||
| 388 | } | ||
| 389 | PVRDescrambleInfo(const PVRDescrambleInfo& type) : CStructHdl(type) {} | ||
| 390 | /*! \endcond */ | ||
| 391 | |||
| 392 | /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo_Help Value Help | ||
| 393 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo | ||
| 394 | /// | ||
| 395 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo :</b> | ||
| 396 | /// | Name | Type | Set call | Get call | Usage | ||
| 397 | /// |------|------|----------|----------|----------- | ||
| 398 | /// | **Packet identifier** | `int` | @ref PVRDescrambleInfo::SetPID "SetPID" | @ref PVRDescrambleInfo::GetPID "GetPID" | *optional* | ||
| 399 | /// | **Conditional access identifier** | `int` | @ref PVRDescrambleInfo::SetCAID "SetCAID" | @ref PVRDescrambleInfo::GetCAID "GetCAID" | *optional* | ||
| 400 | /// | **Provider-ID** | `int` | @ref PVRDescrambleInfo::SetProviderID "SetProviderID" | @ref PVRDescrambleInfo::GetProviderID "GetProviderID" | *optional* | ||
| 401 | /// | **ECM time** | `int` | @ref PVRDescrambleInfo::SetECMTime "SetECMTime" | @ref PVRDescrambleInfo::GetECMTime "GetECMTime" | *optional* | ||
| 402 | /// | **Hops** | `int` | @ref PVRDescrambleInfo::SetHops "SetHops" | @ref PVRDescrambleInfo::GetHops "GetHops" | *optional* | ||
| 403 | /// | **Descramble card system** | `std::string` | @ref PVRDescrambleInfo::SetHops "SetHops" | @ref PVRDescrambleInfo::GetHops "GetHops" | *optional* | ||
| 404 | /// | **Reader** | `std::string` | @ref PVRDescrambleInfo::SetReader "SetReader" | @ref PVRDescrambleInfo::GetReader "GetReader" | *optional* | ||
| 405 | /// | **From** | `std::string` | @ref PVRDescrambleInfo::SetFrom "SetFrom" | @ref PVRDescrambleInfo::GetFrom "GetFrom" | *optional* | ||
| 406 | /// | **Protocol** | `std::string` | @ref PVRDescrambleInfo::SetProtocol "SetProtocol" | @ref PVRDescrambleInfo::GetProtocol "GetProtocol" | *optional* | ||
| 407 | /// | ||
| 408 | |||
| 409 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo | ||
| 410 | ///@{ | ||
| 411 | |||
| 412 | /// @brief **optional**\n | ||
| 413 | /// Packet identifier. | ||
| 414 | /// | ||
| 415 | /// Each table or elementary stream in a transport stream is identified by | ||
| 416 | /// a 13-bit packet identifier (PID). | ||
| 417 | /// | ||
| 418 | /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available | ||
| 419 | void SetPID(int pid) { m_cStructure->iPid = pid; } | ||
| 420 | |||
| 421 | /// @brief To get with @ref SetPID changed values | ||
| 422 | int GetPID() const { return m_cStructure->iPid; } | ||
| 423 | |||
| 424 | /// @brief **optional**\n | ||
| 425 | /// Conditional access identifier. | ||
| 426 | /// | ||
| 427 | /// Conditional access (abbreviated CA) or conditional access system (abbreviated CAS) | ||
| 428 | /// is the protection of content by requiring certain criteria to be met before granting | ||
| 429 | /// access to the content. | ||
| 430 | /// | ||
| 431 | /// Available CA system ID's listed here https://www.dvbservices.com/identifiers/ca_system_id. | ||
| 432 | /// | ||
| 433 | /// @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available. | ||
| 434 | void SetCAID(int iCaid) { m_cStructure->iCaid = iCaid; } | ||
| 435 | |||
| 436 | /// @brief To get with @ref SetCAID changed values. | ||
| 437 | int GetCAID() const { return m_cStructure->iCaid; } | ||
| 438 | |||
| 439 | /// @brief **optional**\n | ||
| 440 | /// Provider-ID. | ||
| 441 | /// | ||
| 442 | /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available. | ||
| 443 | void SetProviderID(int provid) { m_cStructure->iProvid = provid; } | ||
| 444 | |||
| 445 | /// @brief To get with @ref SetProviderID changed values | ||
| 446 | int GetProviderID() const { return m_cStructure->iProvid; } | ||
| 447 | |||
| 448 | /// @brief **optional**\n | ||
| 449 | /// ECM time. | ||
| 450 | /// | ||
| 451 | /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available. | ||
| 452 | void SetECMTime(int ecmTime) { m_cStructure->iEcmTime = ecmTime; } | ||
| 453 | |||
| 454 | /// @brief To get with @ref SetECMTime changed values. | ||
| 455 | int GetECMTime() const { return m_cStructure->iEcmTime; } | ||
| 456 | |||
| 457 | /// @brief **optional**\n | ||
| 458 | /// Hops. | ||
| 459 | /// | ||
| 460 | /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available. | ||
| 461 | void SetHops(int hops) { m_cStructure->iHops = hops; } | ||
| 462 | |||
| 463 | /// @brief To get with @ref SetHops changed values. | ||
| 464 | int GetHops() const { return m_cStructure->iHops; } | ||
| 465 | |||
| 466 | /// @brief **optional**\n | ||
| 467 | /// Empty string if not available. | ||
| 468 | void SetCardSystem(const std::string& cardSystem) | ||
| 469 | { | ||
| 470 | strncpy(m_cStructure->strCardSystem, cardSystem.c_str(), | ||
| 471 | sizeof(m_cStructure->strCardSystem) - 1); | ||
| 472 | } | ||
| 473 | |||
| 474 | /// @brief To get with @ref SetCardSystem changed values. | ||
| 475 | std::string GetCardSystem() const { return m_cStructure->strCardSystem; } | ||
| 476 | |||
| 477 | /// @brief **optional**\n | ||
| 478 | /// Empty string if not available. | ||
| 479 | void SetReader(const std::string& reader) | ||
| 480 | { | ||
| 481 | strncpy(m_cStructure->strReader, reader.c_str(), sizeof(m_cStructure->strReader) - 1); | ||
| 482 | } | ||
| 483 | |||
| 484 | /// @brief To get with @ref SetReader changed values. | ||
| 485 | std::string GetReader() const { return m_cStructure->strReader; } | ||
| 486 | |||
| 487 | /// @brief **optional**\n | ||
| 488 | /// Empty string if not available. | ||
| 489 | void SetFrom(const std::string& from) | ||
| 490 | { | ||
| 491 | strncpy(m_cStructure->strFrom, from.c_str(), sizeof(m_cStructure->strFrom) - 1); | ||
| 492 | } | ||
| 493 | |||
| 494 | /// @brief To get with @ref SetFrom changed values. | ||
| 495 | std::string GetFrom() const { return m_cStructure->strFrom; } | ||
| 496 | |||
| 497 | /// @brief **optional**\n | ||
| 498 | /// Empty string if not available. | ||
| 499 | void SetProtocol(const std::string& protocol) | ||
| 500 | { | ||
| 501 | strncpy(m_cStructure->strProtocol, protocol.c_str(), sizeof(m_cStructure->strProtocol) - 1); | ||
| 502 | } | ||
| 503 | |||
| 504 | /// @brief To get with @ref SetProtocol changed values. | ||
| 505 | std::string GetProtocol() const { return m_cStructure->strProtocol; } | ||
| 506 | ///@} | ||
| 507 | |||
| 508 | private: | ||
| 509 | PVRDescrambleInfo(const PVR_DESCRAMBLE_INFO* type) : CStructHdl(type) {} | ||
| 510 | PVRDescrambleInfo(PVR_DESCRAMBLE_INFO* type) : CStructHdl(type) {} | ||
| 511 | }; | ||
| 512 | ///@} | ||
| 513 | //------------------------------------------------------------------------------ | ||
| 514 | |||
| 515 | } /* namespace addon */ | ||
| 516 | } /* namespace kodi */ | ||
| 517 | |||
| 518 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h new file mode 100644 index 0000000..34c7c41 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h | |||
| @@ -0,0 +1,90 @@ | |||
| 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_edl.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 8 - PVR Edit definition list (EDL) | ||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace addon | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry class PVREDLEntry | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_EDLEntry | ||
| 26 | /// @brief **Edit definition list (EDL) entry**\n | ||
| 27 | /// Time places and type of related fields. | ||
| 28 | /// | ||
| 29 | /// This used within @ref cpp_kodi_addon_pvr_EPGTag "EPG" and | ||
| 30 | /// @ref cpp_kodi_addon_pvr_Recordings "recordings". | ||
| 31 | /// | ||
| 32 | /// ---------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// @copydetails cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help | ||
| 35 | /// | ||
| 36 | ///@{ | ||
| 37 | class PVREDLEntry : public CStructHdl<PVREDLEntry, PVR_EDL_ENTRY> | ||
| 38 | { | ||
| 39 | friend class CInstancePVRClient; | ||
| 40 | |||
| 41 | public: | ||
| 42 | /*! \cond PRIVATE */ | ||
| 43 | PVREDLEntry() { memset(m_cStructure, 0, sizeof(PVR_EDL_ENTRY)); } | ||
| 44 | PVREDLEntry(const PVREDLEntry& type) : CStructHdl(type) {} | ||
| 45 | /*! \endcond */ | ||
| 46 | |||
| 47 | /// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help Value Help | ||
| 48 | /// @ingroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry | ||
| 49 | /// | ||
| 50 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry :</b> | ||
| 51 | /// | Name | Type | Set call | Get call | Usage | ||
| 52 | /// |------|------|----------|----------|----------- | ||
| 53 | /// | **Start time** | `int64_t` | @ref PVREDLEntry::SetStart "SetStart" | @ref PVREDLEntry::GetStart "GetStart" | *required to set* | ||
| 54 | /// | **End time** | `int64_t` | @ref PVREDLEntry::SetEnd "SetEnd" | @ref PVREDLEntry::GetEnd "GetEnd" | *required to set* | ||
| 55 | /// | **Type** | @ref PVR_EDL_TYPE | @ref PVREDLEntry::SetType "SetType" | @ref PVREDLEntry::GetType "GetType" | *required to set* | ||
| 56 | /// | ||
| 57 | |||
| 58 | /// @addtogroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry | ||
| 59 | ///@{ | ||
| 60 | |||
| 61 | /// @brief Start time in milliseconds. | ||
| 62 | void SetStart(int64_t start) { m_cStructure->start = start; } | ||
| 63 | |||
| 64 | /// @brief To get with @ref SetStart() changed values. | ||
| 65 | int64_t GetStart() const { return m_cStructure->start; } | ||
| 66 | |||
| 67 | /// @brief End time in milliseconds. | ||
| 68 | void SetEnd(int64_t end) { m_cStructure->end = end; } | ||
| 69 | |||
| 70 | /// @brief To get with @ref SetEnd() changed values. | ||
| 71 | int64_t GetEnd() const { return m_cStructure->end; } | ||
| 72 | |||
| 73 | /// @brief The with @ref PVR_EDL_TYPE used definition list type. | ||
| 74 | void SetType(PVR_EDL_TYPE type) { m_cStructure->type = type; } | ||
| 75 | |||
| 76 | /// @brief To get with @ref SetType() changed values. | ||
| 77 | PVR_EDL_TYPE GetType() const { return m_cStructure->type; } | ||
| 78 | ///@} | ||
| 79 | |||
| 80 | private: | ||
| 81 | PVREDLEntry(const PVR_EDL_ENTRY* type) : CStructHdl(type) {} | ||
| 82 | PVREDLEntry(PVR_EDL_ENTRY* type) : CStructHdl(type) {} | ||
| 83 | }; | ||
| 84 | ///@} | ||
| 85 | //------------------------------------------------------------------------------ | ||
| 86 | |||
| 87 | } /* namespace addon */ | ||
| 88 | } /* namespace kodi */ | ||
| 89 | |||
| 90 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h new file mode 100644 index 0000000..e1fc04f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h | |||
| @@ -0,0 +1,500 @@ | |||
| 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.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 4 - PVR EPG | ||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace addon | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag class PVREPGTag | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 26 | /// @brief **PVR add-on EPG data tag**\n | ||
| 27 | /// Representation of an EPG event. | ||
| 28 | /// | ||
| 29 | /// Herewith all EPG related data are saved in one class whereby the data can | ||
| 30 | /// be exchanged with Kodi, or can also be used on the addon to save there. | ||
| 31 | /// | ||
| 32 | /// See @ref cpp_kodi_addon_pvr_EPGTag "EPG methods" about usage. | ||
| 33 | /// | ||
| 34 | /// ---------------------------------------------------------------------------- | ||
| 35 | /// | ||
| 36 | /// @copydetails cpp_kodi_addon_pvr_Defs_epg_PVREPGTag_Help | ||
| 37 | /// | ||
| 38 | ///@{ | ||
| 39 | class PVREPGTag : public CStructHdl<PVREPGTag, EPG_TAG> | ||
| 40 | { | ||
| 41 | friend class CInstancePVRClient; | ||
| 42 | |||
| 43 | public: | ||
| 44 | /*! \cond PRIVATE */ | ||
| 45 | PVREPGTag() | ||
| 46 | { | ||
| 47 | memset(m_cStructure, 0, sizeof(EPG_TAG)); | ||
| 48 | m_cStructure->iSeriesNumber = EPG_TAG_INVALID_SERIES_EPISODE; | ||
| 49 | m_cStructure->iEpisodeNumber = EPG_TAG_INVALID_SERIES_EPISODE; | ||
| 50 | m_cStructure->iEpisodePartNumber = EPG_TAG_INVALID_SERIES_EPISODE; | ||
| 51 | } | ||
| 52 | PVREPGTag(const PVREPGTag& epg) : CStructHdl(epg) | ||
| 53 | { | ||
| 54 | m_title = epg.m_title; | ||
| 55 | m_plotOutline = epg.m_plotOutline; | ||
| 56 | m_plot = epg.m_plot; | ||
| 57 | m_originalTitle = epg.m_originalTitle; | ||
| 58 | m_cast = epg.m_cast; | ||
| 59 | m_director = epg.m_director; | ||
| 60 | m_writer = epg.m_writer; | ||
| 61 | m_IMDBNumber = epg.m_IMDBNumber; | ||
| 62 | m_iconPath = epg.m_iconPath; | ||
| 63 | m_genreDescription = epg.m_genreDescription; | ||
| 64 | m_episodeName = epg.m_episodeName; | ||
| 65 | m_seriesLink = epg.m_seriesLink; | ||
| 66 | m_firstAired = epg.m_firstAired; | ||
| 67 | } | ||
| 68 | /*! \endcond */ | ||
| 69 | |||
| 70 | |||
| 71 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag_Help Value Help | ||
| 72 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag | ||
| 73 | /// | ||
| 74 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag :</b> | ||
| 75 | /// | Name | Type | Set call | Get call | Usage | ||
| 76 | /// |------|------|----------|----------|--------- | ||
| 77 | /// | **Unique broadcast id** | `unsigned int` | @ref PVREPGTag::SetUniqueBroadcastId "SetUniqueBroadcastId" | @ref PVREPGTag::GetUniqueBroadcastId "GetUniqueBroadcastId" | *required to set* | ||
| 78 | /// | **Unique channel id** | `unsigned int` | @ref PVREPGTag::SetUniqueChannelId "SetUniqueChannelId" | @ref PVREPGTag::GetUniqueChannelId "GetUniqueChannelId" | *required to set* | ||
| 79 | /// | **Title** | `std::string` | @ref PVREPGTag::SetTitle "SetTitle" | @ref PVREPGTag::GetTitle "GetTitle" | *required to set* | ||
| 80 | /// | **Start time** | `time_t` | @ref PVREPGTag::SetStartTime "SetStartTime" | @ref PVREPGTag::GetStartTime "GetStartTime" | *required to set* | ||
| 81 | /// | **End time** | `time_t` | @ref PVREPGTag::SetEndTime "SetEndTime" | @ref PVREPGTag::GetEndTime "GetEndTime" | *required to set* | ||
| 82 | /// | **Plot outline** | `std::string` | @ref PVREPGTag::SetPlotOutline "SetPlotOutline" | @ref PVREPGTag::GetPlotOutline "GetPlotOutline" | *optional* | ||
| 83 | /// | **Plot** | `std::string` | @ref PVREPGTag::SetPlot "SetPlot" | @ref PVREPGTag::GetPlot "GetPlot" | *optional* | ||
| 84 | /// | **Original title** | `std::string` | @ref PVREPGTag::SetOriginalTitle "SetOriginalTitle" | @ref PVREPGTag::GetOriginalTitle "GetOriginalTitle" | *optional* | ||
| 85 | /// | **Cast** | `std::string` | @ref PVREPGTag::SetCast "SetCast" | @ref PVREPGTag::GetCast "GetCast" | *optional* | ||
| 86 | /// | **Director** | `std::string` | @ref PVREPGTag::SetDirector "SetDirector" | @ref PVREPGTag::GetDirector "GetDirector" | *optional* | ||
| 87 | /// | **Writer** | `std::string` | @ref PVREPGTag::SetWriter "SetWriter" | @ref PVREPGTag::GetWriter "GetWriter" | *optional* | ||
| 88 | /// | **Year** | `int` | @ref PVREPGTag::SetYear "SetYear" | @ref PVREPGTag::GetYear "GetYear" | *optional* | ||
| 89 | /// | **IMDB number** | `std::string` | @ref PVREPGTag::SetIMDBNumber "SetIMDBNumber" | @ref PVREPGTag::GetIMDBNumber "GetIMDBNumber" | *optional* | ||
| 90 | /// | **Icon path** | `std::string` | @ref PVREPGTag::SetIconPath "SetIconPath" | @ref PVREPGTag::GetIconPath "GetIconPath" | *optional* | ||
| 91 | /// | **Genre type** | `int` | @ref PVREPGTag::SetGenreType "SetGenreType" | @ref PVREPGTag::GetGenreType "GetGenreType" | *optional* | ||
| 92 | /// | **Genre sub type** | `int` | @ref PVREPGTag::SetGenreSubType "SetGenreSubType" | @ref PVREPGTag::GetGenreSubType "GetGenreSubType" | *optional* | ||
| 93 | /// | **Genre description** | `std::string` | @ref PVREPGTag::SetGenreDescription "SetGenreDescription" | @ref PVREPGTag::GetGenreDescription "GetGenreDescription" | *optional* | ||
| 94 | /// | **First aired** | `time_t` | @ref PVREPGTag::SetFirstAired "SetFirstAired" | @ref PVREPGTag::GetFirstAired "GetFirstAired" | *optional* | ||
| 95 | /// | **Parental rating** | `int` | @ref PVREPGTag::SetParentalRating "SetParentalRating" | @ref PVREPGTag::GetParentalRating "GetParentalRating" | *optional* | ||
| 96 | /// | **Star rating** | `int` | @ref PVREPGTag::SetStarRating "SetStarRating" | @ref PVREPGTag::GetStarRating "GetStarRating" | *optional* | ||
| 97 | /// | **Series number** | `int` | @ref PVREPGTag::SetSeriesNumber "SetSeriesNumber" | @ref PVREPGTag::GetSeriesNumber "GetSeriesNumber" | *optional* | ||
| 98 | /// | **Episode number** | `int` | @ref PVREPGTag::SetEpisodeNumber "SetEpisodeNumber" | @ref PVREPGTag::GetEpisodeNumber "GetEpisodeNumber" | *optional* | ||
| 99 | /// | **Episode part number** | `int` | @ref PVREPGTag::SetEpisodePartNumber "SetEpisodePartNumber" | @ref PVREPGTag::GetEpisodePartNumber "GetEpisodePartNumber" | *optional* | ||
| 100 | /// | **Episode name** | `std::string` | @ref PVREPGTag::SetEpisodeName "SetEpisodeName" | @ref PVREPGTag::GetEpisodeName "GetEpisodeName" | *optional* | ||
| 101 | /// | **Flags** | `unsigned int` | @ref PVREPGTag::SetFlags "SetFlags" | @ref PVREPGTag::GetFlags "GetFlags" | *optional* | ||
| 102 | /// | **Series link** | `std::string` | @ref PVREPGTag::SetSeriesLink "SetSeriesLink" | @ref PVREPGTag::GetSeriesLink "GetSeriesLink" | *optional* | ||
| 103 | /// | ||
| 104 | |||
| 105 | /// @addtogroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag | ||
| 106 | ///@{ | ||
| 107 | |||
| 108 | /// @brief **required**\n | ||
| 109 | /// Identifier for this event. Event uids must be unique for a channel. Valid uids must be greater than @ref EPG_TAG_INVALID_UID. | ||
| 110 | void SetUniqueBroadcastId(unsigned int uniqueBroadcastId) | ||
| 111 | { | ||
| 112 | m_cStructure->iUniqueBroadcastId = uniqueBroadcastId; | ||
| 113 | } | ||
| 114 | |||
| 115 | /// @brief To get with @ref SetUniqueBroadcastId changed values. | ||
| 116 | unsigned int GetUniqueBroadcastId() const { return m_cStructure->iUniqueBroadcastId; } | ||
| 117 | |||
| 118 | /// @brief **required**\n | ||
| 119 | /// Unique identifier of the channel this event belongs to. | ||
| 120 | void SetUniqueChannelId(unsigned int uniqueChannelId) | ||
| 121 | { | ||
| 122 | m_cStructure->iUniqueChannelId = uniqueChannelId; | ||
| 123 | } | ||
| 124 | |||
| 125 | /// @brief To get with @ref SetUniqueChannelId changed values | ||
| 126 | unsigned int GetUniqueChannelId() const { return m_cStructure->iUniqueChannelId; } | ||
| 127 | |||
| 128 | /// @brief **required**\n | ||
| 129 | /// This event's title. | ||
| 130 | void SetTitle(const std::string& title) { m_title = title; } | ||
| 131 | |||
| 132 | /// @brief To get with @ref SetTitle changed values. | ||
| 133 | std::string GetTitle() const { return m_title; } | ||
| 134 | |||
| 135 | /// @brief **required**\n | ||
| 136 | /// Start time in UTC. | ||
| 137 | /// | ||
| 138 | /// Seconds elapsed since 00:00 hours, Jan 1, 1970 UTC. | ||
| 139 | void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; } | ||
| 140 | |||
| 141 | /// @brief To get with @ref SetStartTime changed values. | ||
| 142 | time_t GetStartTime() const { return m_cStructure->startTime; } | ||
| 143 | |||
| 144 | /// @brief **required**\n | ||
| 145 | /// End time in UTC. | ||
| 146 | /// | ||
| 147 | /// Seconds elapsed since 00:00 hours, Jan 1, 1970 UTC. | ||
| 148 | void SetEndTime(time_t endTime) { m_cStructure->endTime = endTime; } | ||
| 149 | |||
| 150 | /// @brief To get with @ref SetEndTime changed values. | ||
| 151 | time_t GetEndTime() const { return m_cStructure->endTime; } | ||
| 152 | |||
| 153 | /// @brief **optional**\n | ||
| 154 | /// Plot outline name. | ||
| 155 | void SetPlotOutline(const std::string& plotOutline) { m_plotOutline = plotOutline; } | ||
| 156 | |||
| 157 | /// @brief To get with @ref SetPlotOutline changed values. | ||
| 158 | std::string GetPlotOutline() const { return m_plotOutline; } | ||
| 159 | |||
| 160 | /// @brief **optional**\n | ||
| 161 | /// Plot name. | ||
| 162 | void SetPlot(const std::string& plot) { m_plot = plot; } | ||
| 163 | |||
| 164 | /// @brief To get with @ref GetPlot changed values. | ||
| 165 | std::string GetPlot() const { return m_plot; } | ||
| 166 | |||
| 167 | /// @brief **optional**\n | ||
| 168 | /// Original title. | ||
| 169 | void SetOriginalTitle(const std::string& originalTitle) { m_originalTitle = originalTitle; } | ||
| 170 | |||
| 171 | /// @brief To get with @ref SetOriginalTitle changed values | ||
| 172 | std::string GetOriginalTitle() const { return m_originalTitle; } | ||
| 173 | |||
| 174 | /// @brief **optional**\n | ||
| 175 | /// Cast name(s). | ||
| 176 | /// | ||
| 177 | /// @note Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different persons. | ||
| 178 | void SetCast(const std::string& cast) { m_cast = cast; } | ||
| 179 | |||
| 180 | /// @brief To get with @ref SetCast changed values | ||
| 181 | std::string GetCast() const { return m_cast; } | ||
| 182 | |||
| 183 | /// @brief **optional**\n | ||
| 184 | /// Director name(s). | ||
| 185 | /// | ||
| 186 | /// @note Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different persons. | ||
| 187 | void SetDirector(const std::string& director) { m_director = director; } | ||
| 188 | |||
| 189 | /// @brief To get with @ref SetDirector changed values. | ||
| 190 | std::string GetDirector() const { return m_director; } | ||
| 191 | |||
| 192 | /// @brief **optional**\n | ||
| 193 | /// Writer name(s). | ||
| 194 | /// | ||
| 195 | /// @note Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different persons. | ||
| 196 | void SetWriter(const std::string& writer) { m_writer = writer; } | ||
| 197 | |||
| 198 | /// @brief To get with @ref SetDirector changed values | ||
| 199 | std::string GetWriter() const { return m_writer; } | ||
| 200 | |||
| 201 | /// @brief **optional**\n | ||
| 202 | /// Year. | ||
| 203 | void SetYear(int year) { m_cStructure->iYear = year; } | ||
| 204 | |||
| 205 | /// @brief To get with @ref SetYear changed values. | ||
| 206 | int GetYear() const { return m_cStructure->iYear; } | ||
| 207 | |||
| 208 | /// @brief **optional**\n | ||
| 209 | /// [IMDB](https://en.wikipedia.org/wiki/IMDb) identification number. | ||
| 210 | void SetIMDBNumber(const std::string& IMDBNumber) { m_IMDBNumber = IMDBNumber; } | ||
| 211 | |||
| 212 | /// @brief To get with @ref SetIMDBNumber changed values. | ||
| 213 | std::string GetIMDBNumber() const { return m_IMDBNumber; } | ||
| 214 | |||
| 215 | /// @brief **optional**\n | ||
| 216 | /// Icon path. | ||
| 217 | void SetIconPath(const std::string& iconPath) { m_iconPath = iconPath; } | ||
| 218 | |||
| 219 | /// @brief To get with @ref SetIconPath changed values. | ||
| 220 | std::string GetIconPath() const { return m_iconPath; } | ||
| 221 | |||
| 222 | /// @brief **optional**\n | ||
| 223 | /// Genre type. | ||
| 224 | /// | ||
| 225 | /// -------------------------------------------------------------------------- | ||
| 226 | /// | ||
| 227 | /// @copydetails EPG_EVENT_CONTENTMASK | ||
| 228 | /// | ||
| 229 | /// Use @ref EPG_GENRE_USE_STRING if type becomes given by @ref SetGenreDescription. | ||
| 230 | /// | ||
| 231 | /// @note If confirmed that backend brings the types in [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 232 | /// conform values, can be @ref EPG_EVENT_CONTENTMASK ignored and to set here | ||
| 233 | /// with backend value. | ||
| 234 | /// | ||
| 235 | /// | ||
| 236 | /// -------------------------------------------------------------------------- | ||
| 237 | /// | ||
| 238 | /// **Example 1:** | ||
| 239 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 240 | /// kodi::addon::PVREPGTag tag; | ||
| 241 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA); | ||
| 242 | /// ~~~~~~~~~~~~~ | ||
| 243 | /// | ||
| 244 | /// -------------------------------------------------------------------------- | ||
| 245 | /// | ||
| 246 | /// **Example 2** (in case of other, not ETSI EN 300 468 conform genre types): | ||
| 247 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 248 | /// kodi::addon::PVREPGTag tag; | ||
| 249 | /// tag.SetGenreType(EPG_GENRE_USE_STRING); | ||
| 250 | /// tag.SetGenreDescription("My special genre name"); // Should use (if possible) kodi::GetLocalizedString(...) to have match user language. | ||
| 251 | /// ~~~~~~~~~~~~~ | ||
| 252 | /// | ||
| 253 | void SetGenreType(int genreType) { m_cStructure->iGenreType = genreType; } | ||
| 254 | |||
| 255 | /// @brief To get with @ref SetGenreType changed values | ||
| 256 | int GetGenreType() const { return m_cStructure->iGenreType; } | ||
| 257 | |||
| 258 | /// @brief **optional**\n | ||
| 259 | /// Genre sub type. | ||
| 260 | /// | ||
| 261 | /// @copydetails EPG_EVENT_CONTENTMASK | ||
| 262 | /// | ||
| 263 | /// Subtypes groups related to set by @ref SetGenreType: | ||
| 264 | /// | Main genre type | List with available sub genre types | ||
| 265 | /// |-----------------|----------------------------------------- | ||
| 266 | /// | @ref EPG_EVENT_CONTENTMASK_UNDEFINED | Nothing, should be 0 | ||
| 267 | /// | @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA | ||
| 268 | /// | @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS | ||
| 269 | /// | @ref EPG_EVENT_CONTENTMASK_SHOW | @ref EPG_EVENT_CONTENTSUBMASK_SHOW | ||
| 270 | /// | @ref EPG_EVENT_CONTENTMASK_SPORTS | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS | ||
| 271 | /// | @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH | ||
| 272 | /// | @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE | ||
| 273 | /// | @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE | ||
| 274 | /// | @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS | ||
| 275 | /// | @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE | ||
| 276 | /// | @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES | ||
| 277 | /// | @ref EPG_EVENT_CONTENTMASK_SPECIAL | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL | ||
| 278 | /// | @ref EPG_EVENT_CONTENTMASK_USERDEFINED | Can be defined by you | ||
| 279 | /// | @ref EPG_GENRE_USE_STRING | **Kodi's own value**, which declares that the type with @ref SetGenreDescription is given. | ||
| 280 | /// | ||
| 281 | /// -------------------------------------------------------------------------- | ||
| 282 | /// | ||
| 283 | /// **Example:** | ||
| 284 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 285 | /// kodi::addon::PVREPGTag tag; | ||
| 286 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE); | ||
| 287 | /// tag.SetGenreSubType(EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ); | ||
| 288 | /// ~~~~~~~~~~~~~ | ||
| 289 | /// | ||
| 290 | void SetGenreSubType(int genreSubType) { m_cStructure->iGenreSubType = genreSubType; } | ||
| 291 | |||
| 292 | /// @brief To get with @ref SetGenreSubType changed values. | ||
| 293 | int GetGenreSubType() const { return m_cStructure->iGenreSubType; } | ||
| 294 | |||
| 295 | /// @brief **optional**\n genre. Will be used only when genreType == @ref EPG_GENRE_USE_STRING | ||
| 296 | /// or genreSubType == @ref EPG_GENRE_USE_STRING. | ||
| 297 | /// | ||
| 298 | /// Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different genres. | ||
| 299 | /// | ||
| 300 | /// In case of other, not [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 301 | /// conform genre types or something special. | ||
| 302 | /// | ||
| 303 | /// -------------------------------------------------------------------------- | ||
| 304 | /// | ||
| 305 | /// **Example:** | ||
| 306 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 307 | /// kodi::addon::PVREPGTag tag; | ||
| 308 | /// tag.SetGenreType(EPG_GENRE_USE_STRING); | ||
| 309 | /// tag.SetGenreDescription("Action" + EPG_STRING_TOKEN_SEPARATOR + "Thriller"); | ||
| 310 | /// ~~~~~~~~~~~~~ | ||
| 311 | /// | ||
| 312 | void SetGenreDescription(const std::string& genreDescription) | ||
| 313 | { | ||
| 314 | m_genreDescription = genreDescription; | ||
| 315 | } | ||
| 316 | |||
| 317 | /// @brief To get with @ref SetGenreDescription changed values. | ||
| 318 | std::string GetGenreDescription() const { return m_genreDescription; } | ||
| 319 | |||
| 320 | /// @brief **optional**\n | ||
| 321 | /// First aired in UTC. | ||
| 322 | void SetFirstAired(const std::string& firstAired) { m_firstAired = firstAired; } | ||
| 323 | |||
| 324 | /// @brief To get with @ref SetFirstAired changed values. | ||
| 325 | std::string GetFirstAired() const { return m_firstAired; } | ||
| 326 | |||
| 327 | /// @brief **optional**\n | ||
| 328 | /// Parental rating. | ||
| 329 | void SetParentalRating(int parentalRating) { m_cStructure->iParentalRating = parentalRating; } | ||
| 330 | |||
| 331 | /// @brief To get with @ref SetParentalRatinge changed values. | ||
| 332 | int GetParentalRating() const { return m_cStructure->iParentalRating; } | ||
| 333 | |||
| 334 | /// @brief **optional**\n | ||
| 335 | /// Star rating. | ||
| 336 | void SetStarRating(int starRating) { m_cStructure->iStarRating = starRating; } | ||
| 337 | |||
| 338 | /// @brief To get with @ref SetStarRating changed values. | ||
| 339 | int GetStarRating() const { return m_cStructure->iStarRating; } | ||
| 340 | |||
| 341 | /// @brief **optional**\n | ||
| 342 | /// Series number. | ||
| 343 | void SetSeriesNumber(int seriesNumber) { m_cStructure->iSeriesNumber = seriesNumber; } | ||
| 344 | |||
| 345 | /// @brief To get with @ref SetSeriesNumber changed values. | ||
| 346 | int GetSeriesNumber() const { return m_cStructure->iSeriesNumber; } | ||
| 347 | |||
| 348 | /// @brief **optional**\n | ||
| 349 | /// Episode number. | ||
| 350 | void SetEpisodeNumber(int episodeNumber) { m_cStructure->iEpisodeNumber = episodeNumber; } | ||
| 351 | |||
| 352 | /// @brief To get with @ref SetEpisodeNumber changed values. | ||
| 353 | int GetEpisodeNumber() const { return m_cStructure->iEpisodeNumber; } | ||
| 354 | |||
| 355 | /// @brief **optional**\n | ||
| 356 | /// Episode part number. | ||
| 357 | void SetEpisodePartNumber(int episodePartNumber) | ||
| 358 | { | ||
| 359 | m_cStructure->iEpisodePartNumber = episodePartNumber; | ||
| 360 | } | ||
| 361 | |||
| 362 | /// @brief To get with @ref SetEpisodePartNumber changed values. | ||
| 363 | int GetEpisodePartNumber() const { return m_cStructure->iEpisodePartNumber; } | ||
| 364 | |||
| 365 | /// @brief **optional**\n | ||
| 366 | /// Episode name. | ||
| 367 | void SetEpisodeName(const std::string& episodeName) { m_episodeName = episodeName; } | ||
| 368 | |||
| 369 | /// @brief To get with @ref SetEpisodeName changed values. | ||
| 370 | std::string GetEpisodeName() const { return m_episodeName; } | ||
| 371 | |||
| 372 | /// @brief **optional**\n | ||
| 373 | /// Bit field of independent flags associated with the EPG entry. | ||
| 374 | /// | ||
| 375 | /// See @ref cpp_kodi_addon_pvr_Defs_epg_EPG_TAG_FLAG for available bit flags. | ||
| 376 | /// | ||
| 377 | /// -------------------------------------------------------------------------- | ||
| 378 | /// | ||
| 379 | /// @copydetails cpp_kodi_addon_pvr_Defs_epg_EPG_TAG_FLAG | ||
| 380 | /// | ||
| 381 | void SetFlags(unsigned int flags) { m_cStructure->iFlags = flags; } | ||
| 382 | |||
| 383 | /// @brief To get with @ref SetFlags changed values. | ||
| 384 | unsigned int GetFlags() const { return m_cStructure->iFlags; } | ||
| 385 | |||
| 386 | /// @brief **optional**\n | ||
| 387 | /// Series link for this event. | ||
| 388 | void SetSeriesLink(const std::string& seriesLink) { m_seriesLink = seriesLink; } | ||
| 389 | |||
| 390 | /// @brief To get with @ref SetSeriesLink changed values. | ||
| 391 | std::string GetSeriesLink() const { return m_seriesLink; } | ||
| 392 | |||
| 393 | ///@} | ||
| 394 | |||
| 395 | // Internal used, as this have own memory for strings and to translate them to "C" | ||
| 396 | EPG_TAG* GetTag() const | ||
| 397 | { | ||
| 398 | m_cStructure->strTitle = m_title.c_str(); | ||
| 399 | m_cStructure->strPlotOutline = m_plotOutline.c_str(); | ||
| 400 | m_cStructure->strPlot = m_plot.c_str(); | ||
| 401 | m_cStructure->strOriginalTitle = m_originalTitle.c_str(); | ||
| 402 | m_cStructure->strCast = m_cast.c_str(); | ||
| 403 | m_cStructure->strDirector = m_director.c_str(); | ||
| 404 | m_cStructure->strWriter = m_writer.c_str(); | ||
| 405 | m_cStructure->strIMDBNumber = m_IMDBNumber.c_str(); | ||
| 406 | m_cStructure->strIconPath = m_iconPath.c_str(); | ||
| 407 | m_cStructure->strGenreDescription = m_genreDescription.c_str(); | ||
| 408 | m_cStructure->strEpisodeName = m_episodeName.c_str(); | ||
| 409 | m_cStructure->strSeriesLink = m_seriesLink.c_str(); | ||
| 410 | m_cStructure->strFirstAired = m_firstAired.c_str(); | ||
| 411 | |||
| 412 | return m_cStructure; | ||
| 413 | } | ||
| 414 | |||
| 415 | private: | ||
| 416 | PVREPGTag(const EPG_TAG* epg) : CStructHdl(epg) { SetData(epg); } | ||
| 417 | PVREPGTag(EPG_TAG* epg) : CStructHdl(epg) { SetData(epg); } | ||
| 418 | |||
| 419 | const PVREPGTag& operator=(const PVREPGTag& right); | ||
| 420 | const PVREPGTag& operator=(const EPG_TAG& right); | ||
| 421 | operator EPG_TAG*(); | ||
| 422 | |||
| 423 | std::string m_title; | ||
| 424 | std::string m_plotOutline; | ||
| 425 | std::string m_plot; | ||
| 426 | std::string m_originalTitle; | ||
| 427 | std::string m_cast; | ||
| 428 | std::string m_director; | ||
| 429 | std::string m_writer; | ||
| 430 | std::string m_IMDBNumber; | ||
| 431 | std::string m_episodeName; | ||
| 432 | std::string m_iconPath; | ||
| 433 | std::string m_seriesLink; | ||
| 434 | std::string m_genreDescription; | ||
| 435 | std::string m_firstAired; | ||
| 436 | |||
| 437 | void SetData(const EPG_TAG* tag) | ||
| 438 | { | ||
| 439 | m_title = tag->strTitle == nullptr ? "" : tag->strTitle; | ||
| 440 | m_plotOutline = tag->strPlotOutline == nullptr ? "" : tag->strPlotOutline; | ||
| 441 | m_plot = tag->strPlot == nullptr ? "" : tag->strPlot; | ||
| 442 | m_originalTitle = tag->strOriginalTitle == nullptr ? "" : tag->strOriginalTitle; | ||
| 443 | m_cast = tag->strCast == nullptr ? "" : tag->strCast; | ||
| 444 | m_director = tag->strDirector == nullptr ? "" : tag->strDirector; | ||
| 445 | m_writer = tag->strWriter == nullptr ? "" : tag->strWriter; | ||
| 446 | m_IMDBNumber = tag->strIMDBNumber == nullptr ? "" : tag->strIMDBNumber; | ||
| 447 | m_iconPath = tag->strIconPath == nullptr ? "" : tag->strIconPath; | ||
| 448 | m_genreDescription = tag->strGenreDescription == nullptr ? "" : tag->strGenreDescription; | ||
| 449 | m_episodeName = tag->strEpisodeName == nullptr ? "" : tag->strEpisodeName; | ||
| 450 | m_seriesLink = tag->strSeriesLink == nullptr ? "" : tag->strSeriesLink; | ||
| 451 | m_firstAired = tag->strFirstAired == nullptr ? "" : tag->strFirstAired; | ||
| 452 | } | ||
| 453 | }; | ||
| 454 | ///@} | ||
| 455 | //------------------------------------------------------------------------------ | ||
| 456 | |||
| 457 | //============================================================================== | ||
| 458 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTagsResultSet class PVREPGTagsResultSet | ||
| 459 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag | ||
| 460 | /// @brief **PVR add-on EPG entry transfer class**\n | ||
| 461 | /// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetEPGForChannel(). | ||
| 462 | /// | ||
| 463 | /// @note This becomes only be used on addon call above, not usable outside on | ||
| 464 | /// addon itself. | ||
| 465 | ///@{ | ||
| 466 | class PVREPGTagsResultSet | ||
| 467 | { | ||
| 468 | public: | ||
| 469 | /*! \cond PRIVATE */ | ||
| 470 | PVREPGTagsResultSet() = delete; | ||
| 471 | PVREPGTagsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 472 | : m_instance(instance), m_handle(handle) | ||
| 473 | { | ||
| 474 | } | ||
| 475 | /*! \endcond */ | ||
| 476 | |||
| 477 | /// @addtogroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTagsResultSet | ||
| 478 | ///@{ | ||
| 479 | |||
| 480 | /// @brief To add and give content from addon to Kodi on related call. | ||
| 481 | /// | ||
| 482 | /// @param[in] tag The to transferred data. | ||
| 483 | void Add(const kodi::addon::PVREPGTag& tag) | ||
| 484 | { | ||
| 485 | m_instance->toKodi->TransferEpgEntry(m_instance->toKodi->kodiInstance, m_handle, tag.GetTag()); | ||
| 486 | } | ||
| 487 | |||
| 488 | ///@} | ||
| 489 | |||
| 490 | private: | ||
| 491 | const AddonInstance_PVR* m_instance = nullptr; | ||
| 492 | const ADDON_HANDLE m_handle; | ||
| 493 | }; | ||
| 494 | ///@} | ||
| 495 | //------------------------------------------------------------------------------ | ||
| 496 | |||
| 497 | } /* namespace addon */ | ||
| 498 | } /* namespace kodi */ | ||
| 499 | |||
| 500 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h new file mode 100644 index 0000000..c7977c2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h | |||
| @@ -0,0 +1,511 @@ | |||
| 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 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue class PVRTypeIntValue | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_General | ||
| 26 | /// @brief **PVR add-on type value**\n | ||
| 27 | /// Representation of a <b>`<int, std::string>`</b> event related value. | ||
| 28 | /// | ||
| 29 | /// ---------------------------------------------------------------------------- | ||
| 30 | /// | ||
| 31 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 32 | /// | ||
| 33 | ///@{ | ||
| 34 | class PVRTypeIntValue : public CStructHdl<PVRTypeIntValue, PVR_ATTRIBUTE_INT_VALUE> | ||
| 35 | { | ||
| 36 | friend class CInstancePVRClient; | ||
| 37 | |||
| 38 | public: | ||
| 39 | /*! \cond PRIVATE */ | ||
| 40 | PVRTypeIntValue(const PVRTypeIntValue& data) : CStructHdl(data) {} | ||
| 41 | /*! \endcond */ | ||
| 42 | |||
| 43 | /// @defgroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help Value Help | ||
| 44 | /// @ingroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue | ||
| 45 | /// | ||
| 46 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue :</b> | ||
| 47 | /// | Name | Type | Set call | Get call | ||
| 48 | /// |------|------|----------|---------- | ||
| 49 | /// | **Value** | `int` | @ref PVRTypeIntValue::SetValue "SetValue" | @ref PVRTypeIntValue::GetValue "GetValue" | ||
| 50 | /// | **Description** | `std::string` | @ref PVRTypeIntValue::SetDescription "SetDescription" | @ref PVRTypeIntValue::GetDescription "GetDescription" | ||
| 51 | /// | ||
| 52 | /// @remark Further can there be used his class constructor to set values. | ||
| 53 | |||
| 54 | /// @addtogroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue | ||
| 55 | ///@{ | ||
| 56 | |||
| 57 | /// @brief Default class constructor. | ||
| 58 | /// | ||
| 59 | /// @note Values must be set afterwards. | ||
| 60 | PVRTypeIntValue() = default; | ||
| 61 | |||
| 62 | /// @brief Class constructor with integrated value set. | ||
| 63 | /// | ||
| 64 | /// @param[in] value Type identification value | ||
| 65 | /// @param[in] description Type description text | ||
| 66 | PVRTypeIntValue(int value, const std::string& description) | ||
| 67 | { | ||
| 68 | SetValue(value); | ||
| 69 | SetDescription(description); | ||
| 70 | } | ||
| 71 | |||
| 72 | /// @brief To set with the identification value. | ||
| 73 | void SetValue(int value) { m_cStructure->iValue = value; } | ||
| 74 | |||
| 75 | /// @brief To get with the identification value. | ||
| 76 | int GetValue() const { return m_cStructure->iValue; } | ||
| 77 | |||
| 78 | /// @brief To set with the description text of the value. | ||
| 79 | void SetDescription(const std::string& description) | ||
| 80 | { | ||
| 81 | strncpy(m_cStructure->strDescription, description.c_str(), | ||
| 82 | sizeof(m_cStructure->strDescription) - 1); | ||
| 83 | } | ||
| 84 | |||
| 85 | /// @brief To get with the description text of the value. | ||
| 86 | std::string GetDescription() const { return m_cStructure->strDescription; } | ||
| 87 | ///@} | ||
| 88 | |||
| 89 | private: | ||
| 90 | PVRTypeIntValue(const PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {} | ||
| 91 | PVRTypeIntValue(PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {} | ||
| 92 | }; | ||
| 93 | ///@} | ||
| 94 | //------------------------------------------------------------------------------ | ||
| 95 | |||
| 96 | //============================================================================== | ||
| 97 | /// @defgroup cpp_kodi_addon_pvr_Defs_PVRCapabilities class PVRCapabilities | ||
| 98 | /// @ingroup cpp_kodi_addon_pvr_Defs_General | ||
| 99 | /// @brief **PVR add-on capabilities**\n | ||
| 100 | /// This class is needed to tell Kodi which options are supported on the addon. | ||
| 101 | /// | ||
| 102 | /// If a capability is set to **true**, then the corresponding methods from | ||
| 103 | /// @ref cpp_kodi_addon_pvr "kodi::addon::CInstancePVRClient" need to be | ||
| 104 | /// implemented. | ||
| 105 | /// | ||
| 106 | /// As default them all set to **false**. | ||
| 107 | /// | ||
| 108 | /// Used on @ref kodi::addon::CInstancePVRClient::GetCapabilities(). | ||
| 109 | /// | ||
| 110 | /// ---------------------------------------------------------------------------- | ||
| 111 | /// | ||
| 112 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRCapabilities_Help | ||
| 113 | /// | ||
| 114 | ///@{ | ||
| 115 | class PVRCapabilities | ||
| 116 | { | ||
| 117 | friend class CInstancePVRClient; | ||
| 118 | |||
| 119 | public: | ||
| 120 | /*! \cond PRIVATE */ | ||
| 121 | explicit PVRCapabilities() = delete; | ||
| 122 | /*! \endcond */ | ||
| 123 | |||
| 124 | /// @defgroup cpp_kodi_addon_pvr_Defs_PVRCapabilities_Help Value Help | ||
| 125 | /// @ingroup cpp_kodi_addon_pvr_Defs_PVRCapabilities | ||
| 126 | /// ---------------------------------------------------------------------------- | ||
| 127 | /// | ||
| 128 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_PVRCapabilities :</b> | ||
| 129 | /// | Name | Type | Set call | Get call | ||
| 130 | /// |------|------|----------|---------- | ||
| 131 | /// | **Supports EPG** | `boolean` | @ref PVRCapabilities::SetSupportsEPG "SetSupportsEPG" | @ref PVRCapabilities::GetSupportsEPG "GetSupportsEPG" | ||
| 132 | /// | **Supports EPG EDL** | `boolean` | @ref PVRCapabilities::SetSupportsEPGEdl "SetSupportsEPGEdl" | @ref PVRCapabilities::GetSupportsEPGEdl "GetSupportsEPGEdl" | ||
| 133 | /// | **Supports TV** | `boolean` | @ref PVRCapabilities::SetSupportsTV "SetSupportsTV" | @ref PVRCapabilities::GetSupportsTV "GetSupportsTV" | ||
| 134 | /// | **Supports radio** | `boolean` | @ref PVRCapabilities::SetSupportsRadio "SetSupportsRadio" | @ref PVRCapabilities::GetSupportsRadio "GetSupportsRadio" | ||
| 135 | /// | **Supports recordings** | `boolean` | @ref PVRCapabilities::SetSupportsRecordings "SetSupportsRecordings" | @ref PVRCapabilities::GetSupportsRecordings "GetSupportsRecordings" | ||
| 136 | /// | **Supports recordings undelete** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingsUndelete "SetSupportsRecordingsUndelete" | @ref PVRCapabilities::GetSupportsRecordingsUndelete "SetSupportsRecordingsUndelete" | ||
| 137 | /// | **Supports timers** | `boolean` | @ref PVRCapabilities::SetSupportsTimers "SetSupportsTimers" | @ref PVRCapabilities::GetSupportsTimers "GetSupportsTimers" | ||
| 138 | /// | **Supports channel groups** | `boolean` | @ref PVRCapabilities::SetSupportsChannelGroups "SetSupportsChannelGroups" | @ref PVRCapabilities::GetSupportsChannelGroups "GetSupportsChannelGroups" | ||
| 139 | /// | **Supports channel scan** | `boolean` | @ref PVRCapabilities::SetSupportsChannelScan "SetSupportsChannelScan" | @ref PVRCapabilities::GetSupportsChannelScan "GetSupportsChannelScan" | ||
| 140 | /// | **Supports channel settings** | `boolean` | @ref PVRCapabilities::SetSupportsChannelSettings "SetSupportsChannelSettings" | @ref PVRCapabilities::GetSupportsChannelSettings "GetSupportsChannelSettings" | ||
| 141 | /// | **Handles input stream** | `boolean` | @ref PVRCapabilities::SetHandlesInputStream "SetHandlesInputStream" | @ref PVRCapabilities::GetHandlesInputStream "GetHandlesInputStream" | ||
| 142 | /// | **Handles demuxing** | `boolean` | @ref PVRCapabilities::SetHandlesDemuxing "SetHandlesDemuxing" | @ref PVRCapabilities::GetHandlesDemuxing "GetHandlesDemuxing" | ||
| 143 | /// | **Supports recording play count** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingPlayCount "SetSupportsRecordingPlayCount" | @ref PVRCapabilities::GetSupportsRecordingPlayCount "GetSupportsRecordingPlayCount" | ||
| 144 | /// | **Supports last played position** | `boolean` | @ref PVRCapabilities::SetSupportsLastPlayedPosition "SetSupportsLastPlayedPosition" | @ref PVRCapabilities::GetSupportsLastPlayedPosition "GetSupportsLastPlayedPosition" | ||
| 145 | /// | **Supports recording EDL** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingEdl "SetSupportsRecordingEdl" | @ref PVRCapabilities::GetSupportsRecordingEdl "GetSupportsRecordingEdl" | ||
| 146 | /// | **Supports recordings rename** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingsRename "SetSupportsRecordingsRename" | @ref PVRCapabilities::GetSupportsRecordingsRename "GetSupportsRecordingsRename" | ||
| 147 | /// | **Supports recordings lifetime change** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingsLifetimeChange "SetSupportsRecordingsLifetimeChange" | @ref PVRCapabilities::GetSupportsRecordingsLifetimeChange "GetSupportsRecordingsLifetimeChange" | ||
| 148 | /// | **Supports descramble info** | `boolean` | @ref PVRCapabilities::SetSupportsDescrambleInfo "SetSupportsDescrambleInfo" | @ref PVRCapabilities::GetSupportsDescrambleInfo "GetSupportsDescrambleInfo" | ||
| 149 | /// | **Supports async EPG transfer** | `boolean` | @ref PVRCapabilities::SetSupportsAsyncEPGTransfer "SetSupportsAsyncEPGTransfer" | @ref PVRCapabilities::GetSupportsAsyncEPGTransfer "GetSupportsAsyncEPGTransfer" | ||
| 150 | /// | **Supports recording size** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingSize "SetSupportsRecordingSize" | @ref PVRCapabilities::GetSupportsRecordingSize "GetSupportsRecordingSize" | ||
| 151 | /// | **Recordings lifetime values** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRCapabilities::SetRecordingsLifetimeValues "SetRecordingsLifetimeValues" | @ref PVRCapabilities::GetRecordingsLifetimeValues "GetRecordingsLifetimeValues" | ||
| 152 | /// | ||
| 153 | /// @warning This class can not be used outside of @ref kodi::addon::CInstancePVRClient::GetCapabilities() | ||
| 154 | /// | ||
| 155 | |||
| 156 | /// @addtogroup cpp_kodi_addon_pvr_Defs_PVRCapabilities | ||
| 157 | ///@{ | ||
| 158 | |||
| 159 | /// @brief Set **true** if the add-on provides EPG information. | ||
| 160 | void SetSupportsEPG(bool supportsEPG) { m_capabilities->bSupportsEPG = supportsEPG; } | ||
| 161 | |||
| 162 | /// @brief To get with @ref SetSupportsEPG changed values. | ||
| 163 | bool GetSupportsEPG() const { return m_capabilities->bSupportsEPG; } | ||
| 164 | |||
| 165 | /// @brief Set **true** if the backend supports retrieving an edit decision | ||
| 166 | /// list for an EPG tag. | ||
| 167 | void SetSupportsEPGEdl(bool supportsEPGEdl) { m_capabilities->bSupportsEPGEdl = supportsEPGEdl; } | ||
| 168 | |||
| 169 | /// @brief To get with @ref SetSupportsEPGEdl changed values. | ||
| 170 | bool GetSupportsEPGEdl() const { return m_capabilities->bSupportsEPGEdl; } | ||
| 171 | |||
| 172 | /// @brief Set **true** if this add-on provides TV channels. | ||
| 173 | void SetSupportsTV(bool supportsTV) { m_capabilities->bSupportsTV = supportsTV; } | ||
| 174 | |||
| 175 | /// @brief To get with @ref SetSupportsTV changed values. | ||
| 176 | bool GetSupportsTV() const { return m_capabilities->bSupportsTV; } | ||
| 177 | |||
| 178 | /// @brief Set **true** if this add-on provides TV channels. | ||
| 179 | void SetSupportsRadio(bool supportsRadio) { m_capabilities->bSupportsRadio = supportsRadio; } | ||
| 180 | |||
| 181 | /// @brief To get with @ref SetSupportsRadio changed values. | ||
| 182 | bool GetSupportsRadio() const { return m_capabilities->bSupportsRadio; } | ||
| 183 | |||
| 184 | /// @brief **true** if this add-on supports playback of recordings stored on | ||
| 185 | /// the backend. | ||
| 186 | void SetSupportsRecordings(bool supportsRecordings) | ||
| 187 | { | ||
| 188 | m_capabilities->bSupportsRecordings = supportsRecordings; | ||
| 189 | } | ||
| 190 | |||
| 191 | /// @brief To get with @ref SetSupportsRecordings changed values. | ||
| 192 | bool GetSupportsRecordings() const { return m_capabilities->bSupportsRecordings; } | ||
| 193 | |||
| 194 | /// @brief Set **true** if this add-on supports undelete of recordings stored | ||
| 195 | /// on the backend. | ||
| 196 | void SetSupportsRecordingsUndelete(bool supportsRecordingsUndelete) | ||
| 197 | { | ||
| 198 | m_capabilities->bSupportsRecordingsUndelete = supportsRecordingsUndelete; | ||
| 199 | } | ||
| 200 | |||
| 201 | /// @brief To get with @ref SetSupportsRecordings changed values. | ||
| 202 | bool GetSupportsRecordingsUndelete() const { return m_capabilities->bSupportsRecordingsUndelete; } | ||
| 203 | |||
| 204 | /// @brief Set **true** if this add-on supports the creation and editing of | ||
| 205 | /// timers. | ||
| 206 | void SetSupportsTimers(bool supportsTimers) { m_capabilities->bSupportsTimers = supportsTimers; } | ||
| 207 | |||
| 208 | /// @brief To get with @ref SetSupportsTimers changed values. | ||
| 209 | bool GetSupportsTimers() const { return m_capabilities->bSupportsTimers; } | ||
| 210 | |||
| 211 | /// @brief Set **true** if this add-on supports channel groups. | ||
| 212 | /// | ||
| 213 | /// It use the following functions: | ||
| 214 | /// - @ref kodi::addon::CInstancePVRClient::GetChannelGroupsAmount() | ||
| 215 | /// - @ref kodi::addon::CInstancePVRClient::GetChannelGroups() | ||
| 216 | /// - @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers() | ||
| 217 | void SetSupportsChannelGroups(bool supportsChannelGroups) | ||
| 218 | { | ||
| 219 | m_capabilities->bSupportsChannelGroups = supportsChannelGroups; | ||
| 220 | } | ||
| 221 | |||
| 222 | /// @brief To get with @ref SetSupportsChannelGroups changed values. | ||
| 223 | bool GetSupportsChannelGroups() const { return m_capabilities->bSupportsChannelGroups; } | ||
| 224 | |||
| 225 | /// @brief Set **true** if this add-on support scanning for new channels on | ||
| 226 | /// the backend. | ||
| 227 | /// | ||
| 228 | /// It use the following function: | ||
| 229 | /// - @ref kodi::addon::CInstancePVRClient::OpenDialogChannelScan() | ||
| 230 | void SetSupportsChannelScan(bool supportsChannelScan) | ||
| 231 | { | ||
| 232 | m_capabilities->bSupportsChannelScan = supportsChannelScan; | ||
| 233 | } | ||
| 234 | |||
| 235 | /// @brief To get with @ref SetSupportsChannelScan changed values. | ||
| 236 | bool GetSupportsChannelScan() const { return m_capabilities->bSupportsChannelScan; } | ||
| 237 | |||
| 238 | /// @brief Set **true** if this add-on supports channel edit. | ||
| 239 | /// | ||
| 240 | /// It use the following functions: | ||
| 241 | /// - @ref kodi::addon::CInstancePVRClient::DeleteChannel() | ||
| 242 | /// - @ref kodi::addon::CInstancePVRClient::RenameChannel() | ||
| 243 | /// - @ref kodi::addon::CInstancePVRClient::OpenDialogChannelSettings() | ||
| 244 | /// - @ref kodi::addon::CInstancePVRClient::OpenDialogChannelAdd() | ||
| 245 | void SetSupportsChannelSettings(bool supportsChannelSettings) | ||
| 246 | { | ||
| 247 | m_capabilities->bSupportsChannelSettings = supportsChannelSettings; | ||
| 248 | } | ||
| 249 | |||
| 250 | /// @brief To get with @ref SetSupportsChannelSettings changed values. | ||
| 251 | bool GetSupportsChannelSettings() const { return m_capabilities->bSupportsChannelSettings; } | ||
| 252 | |||
| 253 | /// @brief Set **true** if this add-on provides an input stream. false if Kodi | ||
| 254 | /// handles the stream. | ||
| 255 | void SetHandlesInputStream(bool handlesInputStream) | ||
| 256 | { | ||
| 257 | m_capabilities->bHandlesInputStream = handlesInputStream; | ||
| 258 | } | ||
| 259 | |||
| 260 | /// @brief To get with @ref SetHandlesInputStream changed values. | ||
| 261 | bool GetHandlesInputStream() const { return m_capabilities->bHandlesInputStream; } | ||
| 262 | |||
| 263 | /// @brief Set **true** if this add-on demultiplexes packets. | ||
| 264 | void SetHandlesDemuxing(bool handlesDemuxing) | ||
| 265 | { | ||
| 266 | m_capabilities->bHandlesDemuxing = handlesDemuxing; | ||
| 267 | } | ||
| 268 | |||
| 269 | /// @brief To get with @ref SetHandlesDemuxing changed values. | ||
| 270 | bool GetHandlesDemuxing() const { return m_capabilities->bHandlesDemuxing; } | ||
| 271 | |||
| 272 | /// @brief Set **true** if the backend supports play count for recordings. | ||
| 273 | void SetSupportsRecordingPlayCount(bool supportsRecordingPlayCount) | ||
| 274 | { | ||
| 275 | m_capabilities->bSupportsRecordingPlayCount = supportsRecordingPlayCount; | ||
| 276 | } | ||
| 277 | |||
| 278 | /// @brief To get with @ref SetSupportsRecordingPlayCount changed values. | ||
| 279 | bool GetSupportsRecordingPlayCount() const { return m_capabilities->bSupportsRecordingPlayCount; } | ||
| 280 | |||
| 281 | /// @brief Set **true** if the backend supports store/retrieve of last played | ||
| 282 | /// position for recordings. | ||
| 283 | void SetSupportsLastPlayedPosition(bool supportsLastPlayedPosition) | ||
| 284 | { | ||
| 285 | m_capabilities->bSupportsLastPlayedPosition = supportsLastPlayedPosition; | ||
| 286 | } | ||
| 287 | |||
| 288 | /// @brief To get with @ref SetSupportsLastPlayedPosition changed values. | ||
| 289 | bool GetSupportsLastPlayedPosition() const { return m_capabilities->bSupportsLastPlayedPosition; } | ||
| 290 | |||
| 291 | /// @brief Set **true** if the backend supports retrieving an edit decision | ||
| 292 | /// list for recordings. | ||
| 293 | void SetSupportsRecordingEdl(bool supportsRecordingEdl) | ||
| 294 | { | ||
| 295 | m_capabilities->bSupportsRecordingEdl = supportsRecordingEdl; | ||
| 296 | } | ||
| 297 | |||
| 298 | /// @brief To get with @ref SetSupportsRecordingEdl changed values. | ||
| 299 | bool GetSupportsRecordingEdl() const { return m_capabilities->bSupportsRecordingEdl; } | ||
| 300 | |||
| 301 | /// @brief Set **true** if the backend supports renaming recordings. | ||
| 302 | void SetSupportsRecordingsRename(bool supportsRecordingsRename) | ||
| 303 | { | ||
| 304 | m_capabilities->bSupportsRecordingsRename = supportsRecordingsRename; | ||
| 305 | } | ||
| 306 | |||
| 307 | /// @brief To get with @ref SetSupportsRecordingsRename changed values. | ||
| 308 | bool GetSupportsRecordingsRename() const { return m_capabilities->bSupportsRecordingsRename; } | ||
| 309 | |||
| 310 | /// @brief Set **true** if the backend supports changing lifetime for | ||
| 311 | /// recordings. | ||
| 312 | void SetSupportsRecordingsLifetimeChange(bool supportsRecordingsLifetimeChange) | ||
| 313 | { | ||
| 314 | m_capabilities->bSupportsRecordingsLifetimeChange = supportsRecordingsLifetimeChange; | ||
| 315 | } | ||
| 316 | |||
| 317 | /// @brief To get with @ref SetSupportsRecordingsLifetimeChange changed | ||
| 318 | /// values. | ||
| 319 | bool GetSupportsRecordingsLifetimeChange() const | ||
| 320 | { | ||
| 321 | return m_capabilities->bSupportsRecordingsLifetimeChange; | ||
| 322 | } | ||
| 323 | |||
| 324 | /// @brief Set **true** if the backend supports descramble information for | ||
| 325 | /// playing channels. | ||
| 326 | void SetSupportsDescrambleInfo(bool supportsDescrambleInfo) | ||
| 327 | { | ||
| 328 | m_capabilities->bSupportsDescrambleInfo = supportsDescrambleInfo; | ||
| 329 | } | ||
| 330 | |||
| 331 | /// @brief To get with @ref SetSupportsDescrambleInfo changed values. | ||
| 332 | bool GetSupportsDescrambleInfo() const { return m_capabilities->bSupportsDescrambleInfo; } | ||
| 333 | |||
| 334 | /// @brief Set **true** if this addon-on supports asynchronous transfer of epg | ||
| 335 | /// events to Kodi using the callback function | ||
| 336 | /// @ref kodi::addon::CInstancePVRClient::EpgEventStateChange(). | ||
| 337 | void SetSupportsAsyncEPGTransfer(bool supportsAsyncEPGTransfer) | ||
| 338 | { | ||
| 339 | m_capabilities->bSupportsAsyncEPGTransfer = supportsAsyncEPGTransfer; | ||
| 340 | } | ||
| 341 | |||
| 342 | /// @brief To get with @ref SetSupportsAsyncEPGTransfer changed values. | ||
| 343 | bool GetSupportsAsyncEPGTransfer() const { return m_capabilities->bSupportsAsyncEPGTransfer; } | ||
| 344 | |||
| 345 | /// @brief Set **true** if this addon-on supports retrieving size of recordings. | ||
| 346 | void SetSupportsRecordingSize(bool supportsRecordingSize) | ||
| 347 | { | ||
| 348 | m_capabilities->bSupportsRecordingSize = supportsRecordingSize; | ||
| 349 | } | ||
| 350 | |||
| 351 | /// @brief To get with @ref SetSupportsRecordingSize changed values. | ||
| 352 | bool GetSupportsRecordingSize() const { return m_capabilities->bSupportsRecordingSize; } | ||
| 353 | |||
| 354 | /// @brief **optional**\n | ||
| 355 | /// Set array containing the possible values for @ref PVRRecording::SetLifetime(). | ||
| 356 | /// | ||
| 357 | /// -------------------------------------------------------------------------- | ||
| 358 | /// | ||
| 359 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 360 | void SetRecordingsLifetimeValues( | ||
| 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 | |||
| 377 | /// @brief To get with @ref SetRecordingsLifetimeValues changed values. | ||
| 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 | } | ||
| 387 | ///@} | ||
| 388 | |||
| 389 | private: | ||
| 390 | PVRCapabilities(PVR_ADDON_CAPABILITIES* capabilities) : m_capabilities(capabilities) {} | ||
| 391 | |||
| 392 | PVR_ADDON_CAPABILITIES* m_capabilities; | ||
| 393 | }; | ||
| 394 | ///@} | ||
| 395 | //------------------------------------------------------------------------------ | ||
| 396 | |||
| 397 | //============================================================================== | ||
| 398 | /// @defgroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty class PVRStreamProperty | ||
| 399 | /// @ingroup cpp_kodi_addon_pvr_Defs_General_Inputstream | ||
| 400 | /// @brief **PVR stream property value handler**\n | ||
| 401 | /// To set for Kodi wanted stream properties. | ||
| 402 | /// | ||
| 403 | /// ---------------------------------------------------------------------------- | ||
| 404 | /// | ||
| 405 | /// @copydetails cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty_Help | ||
| 406 | /// | ||
| 407 | ///--------------------------------------------------------------------------- | ||
| 408 | /// | ||
| 409 | /// **Example:** | ||
| 410 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 411 | /// ... | ||
| 412 | /// | ||
| 413 | /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 414 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 415 | /// { | ||
| 416 | /// ... | ||
| 417 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive"); | ||
| 418 | /// return PVR_ERROR_NO_ERROR; | ||
| 419 | /// } | ||
| 420 | /// | ||
| 421 | /// ... | ||
| 422 | /// ~~~~~~~~~~~~~ | ||
| 423 | /// | ||
| 424 | /// | ||
| 425 | /// **Example 2:** | ||
| 426 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 427 | /// ... | ||
| 428 | /// | ||
| 429 | /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 430 | /// std::vector<kodi::addon::PVRStreamProperty>& properties) | ||
| 431 | /// { | ||
| 432 | /// ... | ||
| 433 | /// kodi::addon::PVRStreamProperty property; | ||
| 434 | /// property.SetName(PVR_STREAM_PROPERTY_INPUTSTREAM); | ||
| 435 | /// property.SetValue("inputstream.adaptive"); | ||
| 436 | /// properties.emplace_back(property); | ||
| 437 | /// return PVR_ERROR_NO_ERROR; | ||
| 438 | /// } | ||
| 439 | /// | ||
| 440 | /// ... | ||
| 441 | /// ~~~~~~~~~~~~~ | ||
| 442 | /// | ||
| 443 | ///@{ | ||
| 444 | class PVRStreamProperty : public CStructHdl<PVRStreamProperty, PVR_NAMED_VALUE> | ||
| 445 | { | ||
| 446 | friend class CInstancePVRClient; | ||
| 447 | |||
| 448 | public: | ||
| 449 | /*! \cond PRIVATE */ | ||
| 450 | PVRStreamProperty(const PVRStreamProperty& data) : CStructHdl(data) {} | ||
| 451 | /*! \endcond */ | ||
| 452 | |||
| 453 | /// @defgroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty_Help Value Help | ||
| 454 | /// @ingroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty | ||
| 455 | /// | ||
| 456 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty :</b> | ||
| 457 | /// | Name | Type | Set call | Get call | ||
| 458 | /// |------|------|----------|---------- | ||
| 459 | /// | **Name** | `int` | @ref PVRStreamProperty::SetValue "SetName" | @ref PVRStreamProperty::GetName "GetName" | ||
| 460 | /// | **Value** | `std::string` | @ref PVRStreamProperty::SetValue "SetValue" | @ref PVRStreamProperty::GetValue "GetValue" | ||
| 461 | /// | ||
| 462 | /// @remark Further can there be used his class constructor to set values. | ||
| 463 | |||
| 464 | /// @addtogroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty | ||
| 465 | ///@{ | ||
| 466 | |||
| 467 | /// @brief Default class constructor. | ||
| 468 | /// | ||
| 469 | /// @note Values must be set afterwards. | ||
| 470 | PVRStreamProperty() = default; | ||
| 471 | |||
| 472 | /// @brief Class constructor with integrated value set. | ||
| 473 | /// | ||
| 474 | /// @param[in] name Type identification | ||
| 475 | /// @param[in] value Type used property value | ||
| 476 | PVRStreamProperty(const std::string& name, const std::string& value) | ||
| 477 | { | ||
| 478 | SetName(name); | ||
| 479 | SetValue(value); | ||
| 480 | } | ||
| 481 | |||
| 482 | /// @brief To set with the identification name. | ||
| 483 | void SetName(const std::string& name) | ||
| 484 | { | ||
| 485 | strncpy(m_cStructure->strName, name.c_str(), sizeof(m_cStructure->strName) - 1); | ||
| 486 | } | ||
| 487 | |||
| 488 | /// @brief To get with the identification name. | ||
| 489 | std::string GetName() const { return m_cStructure->strName; } | ||
| 490 | |||
| 491 | /// @brief To set with the used property value. | ||
| 492 | void SetValue(const std::string& value) | ||
| 493 | { | ||
| 494 | strncpy(m_cStructure->strValue, value.c_str(), sizeof(m_cStructure->strValue) - 1); | ||
| 495 | } | ||
| 496 | |||
| 497 | /// @brief To get with the used property value. | ||
| 498 | std::string GetValue() const { return m_cStructure->strValue; } | ||
| 499 | ///@} | ||
| 500 | |||
| 501 | private: | ||
| 502 | PVRStreamProperty(const PVR_NAMED_VALUE* data) : CStructHdl(data) {} | ||
| 503 | PVRStreamProperty(PVR_NAMED_VALUE* data) : CStructHdl(data) {} | ||
| 504 | }; | ||
| 505 | ///@} | ||
| 506 | //------------------------------------------------------------------------------ | ||
| 507 | |||
| 508 | } /* namespace addon */ | ||
| 509 | } /* namespace kodi */ | ||
| 510 | |||
| 511 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h new file mode 100644 index 0000000..053a4d5 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h | |||
| @@ -0,0 +1,130 @@ | |||
| 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_menu_hook.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 7 - Menu hook | ||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace addon | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook class PVRMenuhook | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_Menuhook | ||
| 26 | /// @brief **Context menu hook**\n | ||
| 27 | /// Menu hooks that are available in the context menus while playing a stream via this add-on. | ||
| 28 | /// And in the Live TV settings dialog. | ||
| 29 | /// | ||
| 30 | /// Possible menu's given to Kodi. | ||
| 31 | /// | ||
| 32 | /// This can be becomes used on this, if @ref kodi::addon::CInstancePVRClient::AddMenuHook() | ||
| 33 | /// was set to related type: | ||
| 34 | /// - @ref kodi::addon::CInstancePVRClient::CallSettingsMenuHook() | ||
| 35 | /// - @ref kodi::addon::CInstancePVRClient::CallChannelMenuHook() | ||
| 36 | /// - @ref kodi::addon::CInstancePVRClient::CallEPGMenuHook() | ||
| 37 | /// - @ref kodi::addon::CInstancePVRClient::CallRecordingMenuHook() | ||
| 38 | /// - @ref kodi::addon::CInstancePVRClient::CallTimerMenuHook() | ||
| 39 | /// | ||
| 40 | /// ---------------------------------------------------------------------------- | ||
| 41 | /// | ||
| 42 | /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help | ||
| 43 | /// | ||
| 44 | ///@{ | ||
| 45 | class PVRMenuhook : public CStructHdl<PVRMenuhook, PVR_MENUHOOK> | ||
| 46 | { | ||
| 47 | friend class CInstancePVRClient; | ||
| 48 | |||
| 49 | public: | ||
| 50 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook | ||
| 51 | /// @brief Optional class constructor with value set. | ||
| 52 | /// | ||
| 53 | /// @param[in] hookId This hook's identifier | ||
| 54 | /// @param[in] localizedStringId Localized string identifier | ||
| 55 | /// @param[in] category Category of menu hook, defined with @ref PVR_MENUHOOK_CAT | ||
| 56 | /// | ||
| 57 | /// | ||
| 58 | /// -------------------------------------------------------------------------- | ||
| 59 | /// | ||
| 60 | /// Example: | ||
| 61 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 62 | /// AddMenuHook(kodi::addon::PVRMenuhook(1, 30001, PVR_MENUHOOK_CHANNEL)); | ||
| 63 | /// ~~~~~~~~~~~~~ | ||
| 64 | /// | ||
| 65 | PVRMenuhook(unsigned int hookId, unsigned int localizedStringId, PVR_MENUHOOK_CAT category) | ||
| 66 | { | ||
| 67 | m_cStructure->iHookId = hookId; | ||
| 68 | m_cStructure->iLocalizedStringId = localizedStringId; | ||
| 69 | m_cStructure->category = category; | ||
| 70 | } | ||
| 71 | |||
| 72 | /*! \cond PRIVATE */ | ||
| 73 | PVRMenuhook() | ||
| 74 | { | ||
| 75 | m_cStructure->iHookId = 0; | ||
| 76 | m_cStructure->iLocalizedStringId = 0; | ||
| 77 | m_cStructure->category = PVR_MENUHOOK_UNKNOWN; | ||
| 78 | } | ||
| 79 | PVRMenuhook(const PVRMenuhook& data) : CStructHdl(data) {} | ||
| 80 | /*! \endcond */ | ||
| 81 | |||
| 82 | /// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help Value Help | ||
| 83 | /// @ingroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook | ||
| 84 | /// | ||
| 85 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook :</b> | ||
| 86 | /// | Name | Type | Set call | Get call | Usage | ||
| 87 | /// |------|------|----------|----------|----------- | ||
| 88 | /// | **This hook's identifier** | `unsigned int` | @ref PVRMenuhook::SetHookId "SetHookId" | @ref PVRMenuhook::GetHookId "GetHookId" | *required to set* | ||
| 89 | /// | **Localized string Identifier** | `unsigned int` | @ref PVRMenuhook::SetLocalizedStringId "SetLocalizedStringId" | @ref PVRMenuhook::GetLocalizedStringId "GetLocalizedStringId" | *required to set* | ||
| 90 | /// | **Category of menu hook** | @ref PVR_MENUHOOK_CAT | @ref PVRMenuhook::SetCategory "SetCategory" | @ref PVRMenuhook::GetCategory "GetCategory" | *required to set* | ||
| 91 | |||
| 92 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook | ||
| 93 | ///@{ | ||
| 94 | |||
| 95 | /// @brief **required**\n | ||
| 96 | /// This hook's identifier. | ||
| 97 | void SetHookId(unsigned int hookId) { m_cStructure->iHookId = hookId; } | ||
| 98 | |||
| 99 | /// @brief To get with @ref SetHookId() changed values. | ||
| 100 | unsigned int GetHookId() const { return m_cStructure->iHookId; } | ||
| 101 | |||
| 102 | /// @brief **required**\n | ||
| 103 | /// The id of the label for this hook in @ref kodi::GetLocalizedString(). | ||
| 104 | void SetLocalizedStringId(unsigned int localizedStringId) | ||
| 105 | { | ||
| 106 | m_cStructure->iLocalizedStringId = localizedStringId; | ||
| 107 | } | ||
| 108 | |||
| 109 | /// @brief To get with @ref SetLocalizedStringId() changed values. | ||
| 110 | unsigned int GetLocalizedStringId() const { return m_cStructure->iLocalizedStringId; } | ||
| 111 | |||
| 112 | /// @brief **required**\n | ||
| 113 | /// Category of menu hook. | ||
| 114 | void SetCategory(PVR_MENUHOOK_CAT category) { m_cStructure->category = category; } | ||
| 115 | |||
| 116 | /// @brief To get with @ref SetCategory() changed values. | ||
| 117 | PVR_MENUHOOK_CAT GetCategory() const { return m_cStructure->category; } | ||
| 118 | ///@} | ||
| 119 | |||
| 120 | private: | ||
| 121 | PVRMenuhook(const PVR_MENUHOOK* data) : CStructHdl(data) {} | ||
| 122 | PVRMenuhook(PVR_MENUHOOK* data) : CStructHdl(data) {} | ||
| 123 | }; | ||
| 124 | ///@} | ||
| 125 | //------------------------------------------------------------------------------ | ||
| 126 | |||
| 127 | } /* namespace addon */ | ||
| 128 | } /* namespace kodi */ | ||
| 129 | |||
| 130 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h new file mode 100644 index 0000000..24ecf11 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h | |||
| @@ -0,0 +1,520 @@ | |||
| 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.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 5 - PVR recordings | ||
| 16 | #ifdef __cplusplus | ||
| 17 | |||
| 18 | namespace kodi | ||
| 19 | { | ||
| 20 | namespace addon | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording class PVRRecording | ||
| 25 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording | ||
| 26 | /// @brief **Data structure with available recordings data**\n | ||
| 27 | /// With this, recordings related data are transferred between addon and Kodi | ||
| 28 | /// and can also be used by the addon itself. | ||
| 29 | /// | ||
| 30 | /// The related values here are automatically initiated to defaults and need | ||
| 31 | /// only be set if supported and used. | ||
| 32 | /// | ||
| 33 | /// ---------------------------------------------------------------------------- | ||
| 34 | /// | ||
| 35 | /// @copydetails cpp_kodi_addon_pvr_Defs_Recording_PVRRecording_Help | ||
| 36 | /// | ||
| 37 | ///@{ | ||
| 38 | class PVRRecording : public CStructHdl<PVRRecording, PVR_RECORDING> | ||
| 39 | { | ||
| 40 | friend class CInstancePVRClient; | ||
| 41 | |||
| 42 | public: | ||
| 43 | /*! \cond PRIVATE */ | ||
| 44 | PVRRecording() | ||
| 45 | { | ||
| 46 | m_cStructure->iSeriesNumber = PVR_RECORDING_INVALID_SERIES_EPISODE; | ||
| 47 | m_cStructure->iEpisodeNumber = PVR_RECORDING_INVALID_SERIES_EPISODE; | ||
| 48 | m_cStructure->recordingTime = 0; | ||
| 49 | m_cStructure->iDuration = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 50 | m_cStructure->iPriority = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 51 | m_cStructure->iLifetime = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 52 | m_cStructure->iGenreType = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 53 | m_cStructure->iGenreSubType = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 54 | m_cStructure->iPlayCount = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 55 | m_cStructure->iLastPlayedPosition = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 56 | m_cStructure->bIsDeleted = false; | ||
| 57 | m_cStructure->iEpgEventId = 0; | ||
| 58 | m_cStructure->iChannelUid = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 59 | m_cStructure->channelType = PVR_RECORDING_CHANNEL_TYPE_UNKNOWN; | ||
| 60 | m_cStructure->iFlags = 0; | ||
| 61 | m_cStructure->sizeInBytes = PVR_RECORDING_VALUE_NOT_AVAILABLE; | ||
| 62 | } | ||
| 63 | PVRRecording(const PVRRecording& recording) : CStructHdl(recording) {} | ||
| 64 | /*! \endcond */ | ||
| 65 | |||
| 66 | /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording_Help Value Help | ||
| 67 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 68 | /// | ||
| 69 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording :</b> | ||
| 70 | /// | Name | Type | Set call | Get call | Usage | ||
| 71 | /// |------|------|----------|----------|----------- | ||
| 72 | /// | **Recording id** | `std::string` | @ref PVRRecording::SetRecordingId "SetRecordingId" | @ref PVRRecording::GetRecordingId "GetRecordingId" | *required to set* | ||
| 73 | /// | **Title** | `std::string` | @ref PVRRecording::SetTitle "SetTitle" | @ref PVRRecording::GetTitle "GetTitle" | *required to set* | ||
| 74 | /// | **Episode name** | `std::string` | @ref PVRRecording::SetEpisodeName "SetEpisodeName" | @ref PVRRecording::GetEpisodeName "GetEpisodeName" | *optional* | ||
| 75 | /// | **Series number** | `int` | @ref PVRRecording::SetSeriesNumber "SetSeriesNumber" | @ref PVRRecording::GetSeriesNumber "GetSeriesNumber" | *optional* | ||
| 76 | /// | **Episode number** | `int` | @ref PVRRecording::SetEpisodeNumber "SetEpisodeNumber" | @ref PVRRecording::GetEpisodeNumber "GetEpisodeNumber" | *optional* | ||
| 77 | /// | **Year** | `int` | @ref PVRRecording::SetYear "SetYear" | @ref PVRRecording::GetYear "GetYear" | *optional* | ||
| 78 | /// | **Directory** | `std::string` | @ref PVRRecording::SetDirectory "SetDirectory" | @ref PVRRecording::GetDirectory "GetDirectory" | *optional* | ||
| 79 | /// | **Plot outline** | `std::string` | @ref PVRRecording::SetPlotOutline "SetPlotOutline" | @ref PVRRecording::GetPlotOutline "GetPlotOutline" | *optional* | ||
| 80 | /// | **Plot** | `std::string` | @ref PVRRecording::SetPlot "SetPlot" | @ref PVRRecording::GetPlot "GetPlot" | *optional* | ||
| 81 | /// | **Genre description** | `std::string` | @ref PVRRecording::SetGenreDescription "SetGenreDescription" | @ref PVRRecording::GetGenreDescription "GetGenreDescription" | *optional* | ||
| 82 | /// | **Channel name** | `std::string` | @ref PVRRecording::SetChannelName "SetChannelName" | @ref PVRRecording::GetChannelName "GetChannelName" | *optional* | ||
| 83 | /// | **Icon path** | `std::string` | @ref PVRRecording::SetIconPath "SetIconPath" | @ref PVRRecording::GetIconPath "GetIconPath" | *optional* | ||
| 84 | /// | **Thumbnail path** | `std::string` | @ref PVRRecording::SetThumbnailPath "SetThumbnailPath" | @ref PVRRecording::GetThumbnailPath "GetThumbnailPath" | *optional* | ||
| 85 | /// | **Fanart path** | `std::string` | @ref PVRRecording::SetFanartPath "SetFanartPath" | @ref PVRRecording::GetFanartPath "GetFanartPath" | *optional* | ||
| 86 | /// | **Recording time** | `time_t` | @ref PVRRecording::SetRecordingTime "SetRecordingTime" | @ref PVRRecording::GetRecordingTime "GetRecordingTime" | *optional* | ||
| 87 | /// | **Duration** | `int` | @ref PVRRecording::SetDuration "SetDuration" | @ref PVRRecording::GetDuration "GetDuration" | *optional* | ||
| 88 | /// | **Priority** | `int` | @ref PVRRecording::SetPriority "SetPriority" | @ref PVRRecording::GetPriority "GetPriority" | *optional* | ||
| 89 | /// | **Lifetime** | `int` | @ref PVRRecording::SetLifetime "SetLifetime" | @ref PVRRecording::GetLifetime "GetLifetime" | *optional* | ||
| 90 | /// | **Genre type** | `int` | @ref PVRRecording::SetGenreType "SetGenreType" | @ref PVRRecording::GetGenreType "GetGenreType" | *optional* | ||
| 91 | /// | **Genre sub type** | `int` | @ref PVRRecording::SetGenreSubType "SetGenreSubType" | @ref PVRRecording::GetGenreSubType "GetGenreSubType" | *optional* | ||
| 92 | /// | **Play count** | `int` | @ref PVRRecording::SetPlayCount "SetPlayCount" | @ref PVRRecording::GetPlayCount "GetPlayCount" | *optional* | ||
| 93 | /// | **Last played position** | `int` | @ref PVRRecording::SetLastPlayedPosition "SetLastPlayedPosition" | @ref PVRRecording::GetLastPlayedPosition "GetLastPlayedPosition" | *optional* | ||
| 94 | /// | **Is deleted** | `bool` | @ref PVRRecording::SetIsDeleted "SetIsDeleted" | @ref PVRRecording::GetIsDeleted "GetIsDeleted" | *optional* | ||
| 95 | /// | **EPG event id** | `unsigned int` | @ref PVRRecording::SetEPGEventId "SetEPGEventId" | @ref PVRRecording::GetEPGEventId "GetEPGEventId" | *optional* | ||
| 96 | /// | **Channel unique id** | `int` | @ref PVRRecording::SetChannelUid "SetChannelUid" | @ref PVRRecording::GetChannelUid "GetChannelUid" | *optional* | ||
| 97 | /// | **Channel type** | @ref PVR_RECORDING_CHANNEL_TYPE | @ref PVRRecording::SetChannelType "SetChannelType" | @ref PVRRecording::GetChannelType "GetChannelType" | *optional* | ||
| 98 | /// | **First aired** | `std::string` | @ref PVRRecording::SetFirstAired "SetFirstAired" | @ref PVRRecording::GetFirstAired "GetFirstAired" | *optional* | ||
| 99 | /// | **Flags** | `std::string` | @ref PVRRecording::SetFlags "SetFlags" | @ref PVRRecording::GetFlags "GetFlags" | *optional* | ||
| 100 | /// | **Size in bytes** | `std::string` | @ref PVRRecording::SetSizeInBytes "SetSizeInBytes" | @ref PVRRecording::GetSizeInBytes "GetSizeInBytes" | *optional* | ||
| 101 | |||
| 102 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 103 | ///@{ | ||
| 104 | |||
| 105 | /// @brief **required**\n | ||
| 106 | /// Unique identifier of the recording on the client. | ||
| 107 | void SetRecordingId(const std::string& recordingId) | ||
| 108 | { | ||
| 109 | strncpy(m_cStructure->strRecordingId, recordingId.c_str(), | ||
| 110 | sizeof(m_cStructure->strRecordingId) - 1); | ||
| 111 | } | ||
| 112 | |||
| 113 | /// @brief To get with @ref SetRecordingId changed values. | ||
| 114 | std::string GetRecordingId() const { return m_cStructure->strRecordingId; } | ||
| 115 | |||
| 116 | /// @brief **required**\n | ||
| 117 | /// The title of this recording. | ||
| 118 | void SetTitle(const std::string& title) | ||
| 119 | { | ||
| 120 | strncpy(m_cStructure->strTitle, title.c_str(), sizeof(m_cStructure->strTitle) - 1); | ||
| 121 | } | ||
| 122 | |||
| 123 | /// @brief To get with @ref SetTitle changed values. | ||
| 124 | std::string GetTitle() const { return m_cStructure->strTitle; } | ||
| 125 | |||
| 126 | /// @brief **optional**\n | ||
| 127 | /// Episode name (also known as subtitle). | ||
| 128 | void SetEpisodeName(const std::string& episodeName) | ||
| 129 | { | ||
| 130 | strncpy(m_cStructure->strEpisodeName, episodeName.c_str(), | ||
| 131 | sizeof(m_cStructure->strEpisodeName) - 1); | ||
| 132 | } | ||
| 133 | |||
| 134 | /// @brief To get with @ref SetEpisodeName changed values. | ||
| 135 | std::string GetEpisodeName() const { return m_cStructure->strEpisodeName; } | ||
| 136 | |||
| 137 | /// @brief **optional**\n | ||
| 138 | /// Series number (usually called season). | ||
| 139 | /// | ||
| 140 | /// Set to "0" for specials/pilot. For 'invalid' see @ref SetEpisodeNumber or set to -1. | ||
| 141 | void SetSeriesNumber(int seriesNumber) { m_cStructure->iSeriesNumber = seriesNumber; } | ||
| 142 | |||
| 143 | /// @brief To get with @ref SetSeriesNumber changed values. | ||
| 144 | int GetSeriesNumber() const { return m_cStructure->iSeriesNumber; } | ||
| 145 | |||
| 146 | /// @brief **optional**\n | ||
| 147 | /// Eepisode number within the "iSeriesNumber" season. | ||
| 148 | /// | ||
| 149 | /// For 'invalid' set to -1 or seriesNumber=episodeNumber=0 to show both are invalid. | ||
| 150 | void SetEpisodeNumber(int episodeNumber) { m_cStructure->iEpisodeNumber = episodeNumber; } | ||
| 151 | |||
| 152 | /// @brief To get with @ref SetEpisodeNumber changed values. | ||
| 153 | int GetEpisodeNumber() const { return m_cStructure->iEpisodeNumber; } | ||
| 154 | |||
| 155 | /// @brief **optional**\n | ||
| 156 | /// Year of first release (use to identify a specific movie re-make) / first | ||
| 157 | /// airing for TV shows. | ||
| 158 | /// | ||
| 159 | /// Set to '0' for invalid. | ||
| 160 | void SetYear(int year) { m_cStructure->iYear = year; } | ||
| 161 | |||
| 162 | /// @brief To get with @ref SetYear changed values. | ||
| 163 | int GetYear() const { return m_cStructure->iYear; } | ||
| 164 | |||
| 165 | /// @brief **optional**\n | ||
| 166 | /// | ||
| 167 | /// Directory of this recording on the client. | ||
| 168 | void SetDirectory(const std::string& directory) | ||
| 169 | { | ||
| 170 | strncpy(m_cStructure->strDirectory, directory.c_str(), sizeof(m_cStructure->strDirectory) - 1); | ||
| 171 | } | ||
| 172 | |||
| 173 | /// @brief To get with @ref SetDirectory changed values. | ||
| 174 | std::string GetDirectory() const { return m_cStructure->strDirectory; } | ||
| 175 | |||
| 176 | /// @brief **optional**\n | ||
| 177 | /// Plot outline name. | ||
| 178 | void SetPlotOutline(const std::string& plotOutline) | ||
| 179 | { | ||
| 180 | strncpy(m_cStructure->strPlotOutline, plotOutline.c_str(), | ||
| 181 | sizeof(m_cStructure->strPlotOutline) - 1); | ||
| 182 | } | ||
| 183 | |||
| 184 | /// @brief To get with @ref SetPlotOutline changed values. | ||
| 185 | std::string GetPlotOutline() const { return m_cStructure->strPlotOutline; } | ||
| 186 | |||
| 187 | /// @brief **optional**\n | ||
| 188 | /// Plot name. | ||
| 189 | void SetPlot(const std::string& plot) | ||
| 190 | { | ||
| 191 | strncpy(m_cStructure->strPlot, plot.c_str(), sizeof(m_cStructure->strPlot) - 1); | ||
| 192 | } | ||
| 193 | |||
| 194 | /// @brief To get with @ref SetPlot changed values. | ||
| 195 | std::string GetPlot() const { return m_cStructure->strPlot; } | ||
| 196 | |||
| 197 | /// @brief **optional**\n | ||
| 198 | /// Channel name. | ||
| 199 | void SetChannelName(const std::string& channelName) | ||
| 200 | { | ||
| 201 | strncpy(m_cStructure->strChannelName, channelName.c_str(), | ||
| 202 | sizeof(m_cStructure->strChannelName) - 1); | ||
| 203 | } | ||
| 204 | |||
| 205 | /// @brief To get with @ref SetChannelName changed values. | ||
| 206 | std::string GetChannelName() const { return m_cStructure->strChannelName; } | ||
| 207 | |||
| 208 | /// @brief **optional**\n | ||
| 209 | /// Channel logo (icon) path. | ||
| 210 | void SetIconPath(const std::string& iconPath) | ||
| 211 | { | ||
| 212 | strncpy(m_cStructure->strIconPath, iconPath.c_str(), sizeof(m_cStructure->strIconPath) - 1); | ||
| 213 | } | ||
| 214 | |||
| 215 | /// @brief To get with @ref SetIconPath changed values. | ||
| 216 | std::string GetIconPath() const { return m_cStructure->strIconPath; } | ||
| 217 | |||
| 218 | /// @brief **optional**\n | ||
| 219 | /// Thumbnail path. | ||
| 220 | void SetThumbnailPath(const std::string& thumbnailPath) | ||
| 221 | { | ||
| 222 | strncpy(m_cStructure->strThumbnailPath, thumbnailPath.c_str(), | ||
| 223 | sizeof(m_cStructure->strThumbnailPath) - 1); | ||
| 224 | } | ||
| 225 | |||
| 226 | /// @brief To get with @ref SetThumbnailPath changed values. | ||
| 227 | std::string GetThumbnailPath() const { return m_cStructure->strThumbnailPath; } | ||
| 228 | |||
| 229 | /// @brief **optional**\n | ||
| 230 | /// Fanart path. | ||
| 231 | void SetFanartPath(const std::string& fanartPath) | ||
| 232 | { | ||
| 233 | strncpy(m_cStructure->strFanartPath, fanartPath.c_str(), | ||
| 234 | sizeof(m_cStructure->strFanartPath) - 1); | ||
| 235 | } | ||
| 236 | |||
| 237 | /// @brief To get with @ref SetFanartPath changed values. | ||
| 238 | std::string GetFanartPath() const { return m_cStructure->strFanartPath; } | ||
| 239 | |||
| 240 | /// @brief **optional**\n | ||
| 241 | /// Start time of the recording. | ||
| 242 | void SetRecordingTime(time_t recordingTime) { m_cStructure->recordingTime = recordingTime; } | ||
| 243 | |||
| 244 | /// @brief To get with @ref SetRecordingTime changed values. | ||
| 245 | time_t GetRecordingTime() const { return m_cStructure->recordingTime; } | ||
| 246 | |||
| 247 | /// @brief **optional**\n | ||
| 248 | /// Duration of the recording in seconds. | ||
| 249 | void SetDuration(int duration) { m_cStructure->iDuration = duration; } | ||
| 250 | |||
| 251 | /// @brief To get with @ref SetDuration changed values. | ||
| 252 | int GetDuration() const { return m_cStructure->iDuration; } | ||
| 253 | |||
| 254 | /// @brief **optional**\n | ||
| 255 | /// Priority of this recording (from 0 - 100). | ||
| 256 | void SetPriority(int priority) { m_cStructure->iPriority = priority; } | ||
| 257 | |||
| 258 | /// @brief To get with @ref SetPriority changed values. | ||
| 259 | int GetPriority() const { return m_cStructure->iPriority; } | ||
| 260 | |||
| 261 | /// @brief **optional**\n | ||
| 262 | /// Life time in days of this recording. | ||
| 263 | void SetLifetime(int lifetime) { m_cStructure->iLifetime = lifetime; } | ||
| 264 | |||
| 265 | /// @brief To get with @ref SetLifetime changed values. | ||
| 266 | int GetLifetime() const { return m_cStructure->iLifetime; } | ||
| 267 | |||
| 268 | /// @brief **optional**\n | ||
| 269 | /// Genre type. | ||
| 270 | /// | ||
| 271 | /// Use @ref EPG_GENRE_USE_STRING if type becomes given by @ref SetGenreDescription. | ||
| 272 | /// | ||
| 273 | /// @note If confirmed that backend brings the types in [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 274 | /// conform values, can be @ref EPG_EVENT_CONTENTMASK ignored and to set here | ||
| 275 | /// with backend value. | ||
| 276 | /// | ||
| 277 | /// | ||
| 278 | /// -------------------------------------------------------------------------- | ||
| 279 | /// | ||
| 280 | /// **Example 1:** | ||
| 281 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 282 | /// kodi::addon::PVRRecording tag; | ||
| 283 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA); | ||
| 284 | /// ~~~~~~~~~~~~~ | ||
| 285 | /// | ||
| 286 | /// -------------------------------------------------------------------------- | ||
| 287 | /// | ||
| 288 | /// **Example 2** (in case of other, not ETSI EN 300 468 conform genre types): | ||
| 289 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 290 | /// kodi::addon::PVRRecording tag; | ||
| 291 | /// tag.SetGenreType(EPG_GENRE_USE_STRING); | ||
| 292 | /// tag.SetGenreDescription("My special genre name"); // Should use (if possible) kodi::GetLocalizedString(...) to have match user language. | ||
| 293 | /// ~~~~~~~~~~~~~ | ||
| 294 | /// | ||
| 295 | void SetGenreType(int genreType) { m_cStructure->iGenreType = genreType; } | ||
| 296 | |||
| 297 | /// @brief To get with @ref SetGenreType changed values. | ||
| 298 | int GetGenreType() const { return m_cStructure->iGenreType; } | ||
| 299 | |||
| 300 | /// @brief **optional**\n | ||
| 301 | /// Genre sub type. | ||
| 302 | /// | ||
| 303 | /// Subtypes groups related to set by @ref SetGenreType: | ||
| 304 | /// | Main genre type | List with available sub genre types | ||
| 305 | /// |-----------------|----------------------------------------- | ||
| 306 | /// | @ref EPG_EVENT_CONTENTMASK_UNDEFINED | Nothing, should be 0 | ||
| 307 | /// | @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA | ||
| 308 | /// | @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS | ||
| 309 | /// | @ref EPG_EVENT_CONTENTMASK_SHOW | @ref EPG_EVENT_CONTENTSUBMASK_SHOW | ||
| 310 | /// | @ref EPG_EVENT_CONTENTMASK_SPORTS | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS | ||
| 311 | /// | @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH | ||
| 312 | /// | @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE | ||
| 313 | /// | @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE | ||
| 314 | /// | @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS | ||
| 315 | /// | @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE | ||
| 316 | /// | @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES | ||
| 317 | /// | @ref EPG_EVENT_CONTENTMASK_SPECIAL | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL | ||
| 318 | /// | @ref EPG_EVENT_CONTENTMASK_USERDEFINED | Can be defined by you | ||
| 319 | /// | @ref EPG_GENRE_USE_STRING | **Kodi's own value**, which declares that the type with @ref SetGenreDescription is given. | ||
| 320 | /// | ||
| 321 | /// -------------------------------------------------------------------------- | ||
| 322 | /// | ||
| 323 | /// **Example:** | ||
| 324 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 325 | /// kodi::addon::PVRRecording tag; | ||
| 326 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE); | ||
| 327 | /// tag.SetGenreSubType(EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ); | ||
| 328 | /// ~~~~~~~~~~~~~ | ||
| 329 | /// | ||
| 330 | void SetGenreSubType(int genreSubType) { m_cStructure->iGenreSubType = genreSubType; } | ||
| 331 | |||
| 332 | /// @brief To get with @ref SetGenreSubType changed values. | ||
| 333 | int GetGenreSubType() const { return m_cStructure->iGenreSubType; } | ||
| 334 | |||
| 335 | /// @brief **optional**\n | ||
| 336 | /// To set own genre description name. | ||
| 337 | /// | ||
| 338 | /// Will be used only when genreType == @ref EPG_GENRE_USE_STRING or | ||
| 339 | /// genreSubType == @ref EPG_GENRE_USE_STRING. | ||
| 340 | /// | ||
| 341 | /// Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different genres. | ||
| 342 | /// | ||
| 343 | /// In case of other, not [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 344 | /// conform genre types or something special. | ||
| 345 | /// | ||
| 346 | /// -------------------------------------------------------------------------- | ||
| 347 | /// | ||
| 348 | /// **Example:** | ||
| 349 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 350 | /// kodi::addon::PVRRecording tag; | ||
| 351 | /// tag.SetGenreType(EPG_GENRE_USE_STRING); | ||
| 352 | /// tag.SetGenreDescription("Action" + EPG_STRING_TOKEN_SEPARATOR + "Thriller"); | ||
| 353 | /// ~~~~~~~~~~~~~ | ||
| 354 | /// | ||
| 355 | void SetGenreDescription(const std::string& genreDescription) | ||
| 356 | { | ||
| 357 | strncpy(m_cStructure->strGenreDescription, genreDescription.c_str(), | ||
| 358 | sizeof(m_cStructure->strGenreDescription) - 1); | ||
| 359 | } | ||
| 360 | |||
| 361 | /// @brief To get with @ref SetGenreDescription changed values. | ||
| 362 | std::string GetGenreDescription() const { return m_cStructure->strGenreDescription; } | ||
| 363 | |||
| 364 | /// @brief **optional**\n | ||
| 365 | /// Play count of this recording on the client. | ||
| 366 | void SetPlayCount(int playCount) { m_cStructure->iPlayCount = playCount; } | ||
| 367 | |||
| 368 | /// @brief To get with @ref SetPlayCount changed values. | ||
| 369 | int GetPlayCount() const { return m_cStructure->iPlayCount; } | ||
| 370 | |||
| 371 | /// @brief **optional**\n | ||
| 372 | /// Last played position of this recording on the client. | ||
| 373 | void SetLastPlayedPosition(int lastPlayedPosition) | ||
| 374 | { | ||
| 375 | m_cStructure->iLastPlayedPosition = lastPlayedPosition; | ||
| 376 | } | ||
| 377 | |||
| 378 | /// @brief To get with @ref SetLastPlayedPosition changed values. | ||
| 379 | int GetLastPlayedPosition() const { return m_cStructure->iLastPlayedPosition; } | ||
| 380 | |||
| 381 | /// @brief **optional**\n | ||
| 382 | /// Shows this recording is deleted and can be undelete. | ||
| 383 | void SetIsDeleted(int isDeleted) { m_cStructure->bIsDeleted = isDeleted; } | ||
| 384 | |||
| 385 | /// @brief To get with @ref SetIsDeleted changed values. | ||
| 386 | int GetIsDeleted() const { return m_cStructure->bIsDeleted; } | ||
| 387 | |||
| 388 | /// @brief **optional**\n | ||
| 389 | /// EPG event id associated with this recording. Valid ids must be greater than @ref EPG_TAG_INVALID_UID. | ||
| 390 | void SetEPGEventId(unsigned int epgEventId) { m_cStructure->iEpgEventId = epgEventId; } | ||
| 391 | |||
| 392 | /// @brief To get with @ref SetEPGEventId changed values. | ||
| 393 | unsigned int GetEPGEventId() const { return m_cStructure->iEpgEventId; } | ||
| 394 | |||
| 395 | /// @brief **optional**\n | ||
| 396 | /// Unique identifier of the channel for this recording. @ref PVR_CHANNEL_INVALID_UID | ||
| 397 | /// denotes that channel uid is not available. | ||
| 398 | void SetChannelUid(int channelUid) { m_cStructure->iChannelUid = channelUid; } | ||
| 399 | |||
| 400 | /// @brief To get with @ref SetChannelUid changed values | ||
| 401 | int GetChannelUid() const { return m_cStructure->iChannelUid; } | ||
| 402 | |||
| 403 | /// @brief **optional**\n | ||
| 404 | /// Channel type. | ||
| 405 | /// | ||
| 406 | /// Set to @ref PVR_RECORDING_CHANNEL_TYPE_UNKNOWN if the type cannot be | ||
| 407 | /// determined. | ||
| 408 | /// | ||
| 409 | /// -------------------------------------------------------------------------- | ||
| 410 | /// | ||
| 411 | /// Example: | ||
| 412 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 413 | /// kodi::addon::PVRRecording tag; | ||
| 414 | /// tag.SetChannelType(PVR_RECORDING_CHANNEL_TYPE_TV); | ||
| 415 | /// ~~~~~~~~~~~~~ | ||
| 416 | /// | ||
| 417 | void SetChannelType(PVR_RECORDING_CHANNEL_TYPE channelType) | ||
| 418 | { | ||
| 419 | m_cStructure->channelType = channelType; | ||
| 420 | } | ||
| 421 | |||
| 422 | /// @brief To get with @ref SetChannelType changed values | ||
| 423 | PVR_RECORDING_CHANNEL_TYPE GetChannelType() const { return m_cStructure->channelType; } | ||
| 424 | |||
| 425 | /// @brief **optional**\n | ||
| 426 | /// First aired date of this recording. | ||
| 427 | /// | ||
| 428 | /// Used only for display purposes. Specify in W3C date format "YYYY-MM-DD". | ||
| 429 | /// | ||
| 430 | /// -------------------------------------------------------------------------- | ||
| 431 | /// | ||
| 432 | /// Example: | ||
| 433 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 434 | /// kodi::addon::PVRRecording tag; | ||
| 435 | /// tag.SetFirstAired(1982-10-22); | ||
| 436 | /// ~~~~~~~~~~~~~ | ||
| 437 | /// | ||
| 438 | void SetFirstAired(const std::string& firstAired) | ||
| 439 | { | ||
| 440 | strncpy(m_cStructure->strFirstAired, firstAired.c_str(), | ||
| 441 | sizeof(m_cStructure->strFirstAired) - 1); | ||
| 442 | } | ||
| 443 | |||
| 444 | /// @brief To get with @ref SetFirstAired changed values | ||
| 445 | std::string GetFirstAired() const { return m_cStructure->strFirstAired; } | ||
| 446 | |||
| 447 | /// @brief **optional**\n | ||
| 448 | /// Bit field of independent flags associated with the recording. | ||
| 449 | /// | ||
| 450 | /// See @ref cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_FLAG for | ||
| 451 | /// available bit flags. | ||
| 452 | /// | ||
| 453 | /// -------------------------------------------------------------------------- | ||
| 454 | /// | ||
| 455 | /// @copydetails cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_FLAG | ||
| 456 | /// | ||
| 457 | void SetFlags(unsigned int flags) { m_cStructure->iFlags = flags; } | ||
| 458 | |||
| 459 | /// @brief To get with @ref SetFlags changed values. | ||
| 460 | unsigned int GetFlags() const { return m_cStructure->iFlags; } | ||
| 461 | |||
| 462 | /// @brief **optional**\n | ||
| 463 | /// Size of the recording in bytes. | ||
| 464 | void SetSizeInBytes(int64_t sizeInBytes) { m_cStructure->sizeInBytes = sizeInBytes; } | ||
| 465 | |||
| 466 | /// @brief To get with @ref SetSizeInBytes changed values. | ||
| 467 | int64_t GetSizeInBytes() const { return m_cStructure->sizeInBytes; } | ||
| 468 | ///@} | ||
| 469 | |||
| 470 | private: | ||
| 471 | PVRRecording(const PVR_RECORDING* recording) : CStructHdl(recording) {} | ||
| 472 | PVRRecording(PVR_RECORDING* recording) : CStructHdl(recording) {} | ||
| 473 | }; | ||
| 474 | ///@} | ||
| 475 | //------------------------------------------------------------------------------ | ||
| 476 | |||
| 477 | //============================================================================== | ||
| 478 | /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecordingsResultSet class PVRRecordingsResultSet | ||
| 479 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 480 | /// @brief **PVR add-on recording transfer class**\n | ||
| 481 | /// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetRecordings(). | ||
| 482 | /// | ||
| 483 | /// @note This becomes only be used on addon call above, not usable outside on | ||
| 484 | /// addon itself. | ||
| 485 | ///@{ | ||
| 486 | class PVRRecordingsResultSet | ||
| 487 | { | ||
| 488 | public: | ||
| 489 | /*! \cond PRIVATE */ | ||
| 490 | PVRRecordingsResultSet() = delete; | ||
| 491 | PVRRecordingsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 492 | : m_instance(instance), m_handle(handle) | ||
| 493 | { | ||
| 494 | } | ||
| 495 | /*! \endcond */ | ||
| 496 | |||
| 497 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecordingsResultSet | ||
| 498 | ///@{ | ||
| 499 | |||
| 500 | /// @brief To add and give content from addon to Kodi on related call. | ||
| 501 | /// | ||
| 502 | /// @param[in] tag The to transferred data. | ||
| 503 | void Add(const kodi::addon::PVRRecording& tag) | ||
| 504 | { | ||
| 505 | m_instance->toKodi->TransferRecordingEntry(m_instance->toKodi->kodiInstance, m_handle, tag); | ||
| 506 | } | ||
| 507 | |||
| 508 | ///@} | ||
| 509 | |||
| 510 | private: | ||
| 511 | const AddonInstance_PVR* m_instance = nullptr; | ||
| 512 | const ADDON_HANDLE m_handle; | ||
| 513 | }; | ||
| 514 | ///@} | ||
| 515 | //------------------------------------------------------------------------------ | ||
| 516 | |||
| 517 | } /* namespace addon */ | ||
| 518 | } /* namespace kodi */ | ||
| 519 | |||
| 520 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h new file mode 100644 index 0000000..5613947 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h | |||
| @@ -0,0 +1,330 @@ | |||
| 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_stream.h" | ||
| 13 | |||
| 14 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 15 | // "C++" Definitions group 9 - PVR stream definitions (NOTE: Becomes replaced | ||
| 16 | // in future by inputstream addon instance way) | ||
| 17 | |||
| 18 | #ifdef __cplusplus | ||
| 19 | |||
| 20 | namespace kodi | ||
| 21 | { | ||
| 22 | namespace addon | ||
| 23 | { | ||
| 24 | |||
| 25 | //============================================================================== | ||
| 26 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec class PVRCodec | ||
| 27 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 28 | /// @brief **PVR codec identifier**\n | ||
| 29 | /// Used to exchange the desired codec type between Kodi and addon. | ||
| 30 | /// | ||
| 31 | /// @ref kodi::addon::CInstancePVRClient::GetCodecByName is used to get this data. | ||
| 32 | /// | ||
| 33 | /// ---------------------------------------------------------------------------- | ||
| 34 | /// | ||
| 35 | /// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRCodec_Help | ||
| 36 | /// | ||
| 37 | ///@{ | ||
| 38 | class PVRCodec : public CStructHdl<PVRCodec, PVR_CODEC> | ||
| 39 | { | ||
| 40 | friend class CInstancePVRClient; | ||
| 41 | |||
| 42 | public: | ||
| 43 | /*! \cond PRIVATE */ | ||
| 44 | PVRCodec() | ||
| 45 | { | ||
| 46 | m_cStructure->codec_type = PVR_CODEC_TYPE_UNKNOWN; | ||
| 47 | m_cStructure->codec_id = PVR_INVALID_CODEC_ID; | ||
| 48 | } | ||
| 49 | PVRCodec(const PVRCodec& type) : CStructHdl(type) {} | ||
| 50 | /*! \endcond */ | ||
| 51 | |||
| 52 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec_Help Value Help | ||
| 53 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec | ||
| 54 | /// | ||
| 55 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRCodec :</b> | ||
| 56 | /// | Name | Type | Set call | Get call | ||
| 57 | /// |------|------|----------|---------- | ||
| 58 | /// | **Codec type** | @ref PVR_CODEC_TYPE | @ref PVRCodec::SetCodecType "SetCodecType" | @ref PVRCodec::GetCodecType "GetCodecType" | ||
| 59 | /// | **Codec identifier** | `unsigned int` | @ref PVRCodec::SetCodecId "SetCodecId" | @ref PVRCodec::GetCodecId "GetCodecId" | ||
| 60 | /// | ||
| 61 | |||
| 62 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec | ||
| 63 | ///@{ | ||
| 64 | |||
| 65 | /// @brief Codec type. | ||
| 66 | void SetCodecType(PVR_CODEC_TYPE codecType) { m_cStructure->codec_type = codecType; } | ||
| 67 | |||
| 68 | /// @brief To get with @ref SetCodecType() changed values. | ||
| 69 | PVR_CODEC_TYPE GetCodecType() const { return m_cStructure->codec_type; } | ||
| 70 | |||
| 71 | /// @brief Codec id. | ||
| 72 | /// | ||
| 73 | /// Related codec identifier, normally match the ffmpeg id's. | ||
| 74 | void SetCodecId(unsigned int codecId) { m_cStructure->codec_id = codecId; } | ||
| 75 | |||
| 76 | /// @brief To get with @ref SetCodecId() changed values. | ||
| 77 | unsigned int GetCodecId() const { return m_cStructure->codec_id; } | ||
| 78 | ///@} | ||
| 79 | |||
| 80 | private: | ||
| 81 | PVRCodec(const PVR_CODEC& type) : CStructHdl(&type) {} | ||
| 82 | PVRCodec(const PVR_CODEC* type) : CStructHdl(type) {} | ||
| 83 | PVRCodec(PVR_CODEC* type) : CStructHdl(type) {} | ||
| 84 | }; | ||
| 85 | ///@} | ||
| 86 | //------------------------------------------------------------------------------ | ||
| 87 | |||
| 88 | //============================================================================== | ||
| 89 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties class PVRStreamProperties | ||
| 90 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 91 | /// @brief **PVR stream properties**\n | ||
| 92 | /// All information about a respective stream is stored in this, so that Kodi | ||
| 93 | /// can process the data given by the addon after demux. | ||
| 94 | /// | ||
| 95 | /// ---------------------------------------------------------------------------- | ||
| 96 | /// | ||
| 97 | /// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties_Help | ||
| 98 | /// | ||
| 99 | ///@{ | ||
| 100 | class PVRStreamProperties | ||
| 101 | : public CStructHdl<PVRStreamProperties, PVR_STREAM_PROPERTIES::PVR_STREAM> | ||
| 102 | { | ||
| 103 | friend class CInstancePVRClient; | ||
| 104 | |||
| 105 | public: | ||
| 106 | /*! \cond PRIVATE */ | ||
| 107 | PVRStreamProperties() { memset(m_cStructure, 0, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); } | ||
| 108 | PVRStreamProperties(const PVRStreamProperties& type) : CStructHdl(type) {} | ||
| 109 | /*! \endcond */ | ||
| 110 | |||
| 111 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties_Help Value Help | ||
| 112 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties | ||
| 113 | /// ---------------------------------------------------------------------------- | ||
| 114 | /// | ||
| 115 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties :</b> | ||
| 116 | /// | Name | Type | Set call | Get call | ||
| 117 | /// |------|------|----------|---------- | ||
| 118 | /// | **PID** | `unsigned int` | @ref PVRStreamProperties::SetPID "SetPID" | @ref PVRStreamProperties::GetPID "GetPID" | ||
| 119 | /// | **Codec type** | @ref PVR_CODEC_TYPE | @ref PVRStreamProperties::SetCodecType "SetCodecType" | @ref PVRStreamProperties::GetCodecType "GetCodecType" | ||
| 120 | /// | **Codec identifier** | `unsigned int` | @ref PVRStreamProperties::SetCodecId "SetCodecId" | @ref PVRStreamProperties::GetCodecId "GetCodecId" | ||
| 121 | /// | **Language** | `std::string` | @ref PVRStreamProperties::SetLanguage "SetLanguage" | @ref PVRStreamProperties::GetLanguage "GetLanguage" | ||
| 122 | /// | **Subtitle info** | `int` | @ref PVRStreamProperties::SetSubtitleInfo "SetSubtitleInfo" | @ref PVRStreamProperties::GetSubtitleInfo "GetSubtitleInfo" | ||
| 123 | /// | **FPS scale** | `int` | @ref PVRStreamProperties::SetFPSScale "SetFPSScale" | @ref PVRStreamProperties::GetFPSScale "GetFPSScale" | ||
| 124 | /// | **FPS rate** | `int` | @ref PVRStreamProperties::SetFPSRate "SetFPSRate" | @ref PVRStreamProperties::GetFPSRate "GetFPSRate" | ||
| 125 | /// | **Height** | `int` | @ref PVRStreamProperties::SetHeight "SetHeight" | @ref PVRStreamProperties::GetHeight "GetHeight" | ||
| 126 | /// | **Width** | `int` | @ref PVRStreamProperties::SetWidth "SetWidth" | @ref PVRStreamProperties::GetWidth "GetWidth" | ||
| 127 | /// | **Aspect ratio** | `float` | @ref PVRStreamProperties::SetAspect "SetAspect" | @ref PVRStreamProperties::GetAspect "GetAspect" | ||
| 128 | /// | **Channels** | `int` | @ref PVRStreamProperties::SetChannels "SetChannels" | @ref PVRStreamProperties::GetChannels "GetChannels" | ||
| 129 | /// | **Samplerate** | `int` | @ref PVRStreamProperties::SetSampleRate "SetSampleRate" | @ref PVRStreamProperties::GetSampleRate "GetSampleRate" | ||
| 130 | /// | **Block align** | `int` | @ref PVRStreamProperties::SetBlockAlign "SetBlockAlign" | @ref PVRStreamProperties::GetBlockAlign "GetBlockAlign" | ||
| 131 | /// | **Bit rate** | `int` | @ref PVRStreamProperties::SetBitRate "SetBitRate" | @ref PVRStreamProperties::GetBitRate "GetBitRate" | ||
| 132 | /// | **Bits per sample** | `int` | @ref PVRStreamProperties::SetBitsPerSample "SetBitsPerSample" | @ref PVRStreamProperties::GetBitsPerSample "GetBitsPerSample" | ||
| 133 | /// | ||
| 134 | |||
| 135 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties | ||
| 136 | ///@{ | ||
| 137 | |||
| 138 | /// @brief PID. | ||
| 139 | void SetPID(unsigned int pid) { m_cStructure->iPID = pid; } | ||
| 140 | |||
| 141 | /// @brief To get with @ref SetPID() changed values. | ||
| 142 | unsigned int GetPID() const { return m_cStructure->iPID; } | ||
| 143 | |||
| 144 | /// @brief Codec type this stream. | ||
| 145 | void SetCodecType(PVR_CODEC_TYPE codecType) { m_cStructure->iCodecType = codecType; } | ||
| 146 | |||
| 147 | /// @brief To get with @ref SetCodecType() changed values. | ||
| 148 | PVR_CODEC_TYPE GetCodecType() const { return m_cStructure->iCodecType; } | ||
| 149 | |||
| 150 | /// @brief Codec id of this stream. | ||
| 151 | void SetCodecId(unsigned int codecId) { m_cStructure->iCodecId = codecId; } | ||
| 152 | |||
| 153 | /// @brief To get with @ref SetCodecId() changed values. | ||
| 154 | unsigned int GetCodecId() const { return m_cStructure->iCodecId; } | ||
| 155 | |||
| 156 | /// @brief 3 letter language id. | ||
| 157 | void SetLanguage(const std::string& language) | ||
| 158 | { | ||
| 159 | if (language.size() > 3) | ||
| 160 | { | ||
| 161 | kodi::Log(ADDON_LOG_ERROR, | ||
| 162 | "PVRStreamProperties::%s: Language string size '%li' higher as needed 3", __func__, | ||
| 163 | language.size()); | ||
| 164 | return; | ||
| 165 | } | ||
| 166 | m_cStructure->strLanguage[0] = language[0]; | ||
| 167 | m_cStructure->strLanguage[1] = language[1]; | ||
| 168 | m_cStructure->strLanguage[2] = language[2]; | ||
| 169 | m_cStructure->strLanguage[2] = 0; | ||
| 170 | } | ||
| 171 | |||
| 172 | /// @brief To get with @ref SetLanguage() changed values. | ||
| 173 | std::string GetLanguage() const { return m_cStructure->strLanguage; } | ||
| 174 | |||
| 175 | /// @brief Subtitle Info | ||
| 176 | void SetSubtitleInfo(int subtitleInfo) { m_cStructure->iSubtitleInfo = subtitleInfo; } | ||
| 177 | |||
| 178 | /// @brief To get with @ref SetSubtitleInfo() changed values. | ||
| 179 | int GetSubtitleInfo() const { return m_cStructure->iSubtitleInfo; } | ||
| 180 | |||
| 181 | /// @brief To set scale of 1000 and a rate of 29970 will result in 29.97 fps. | ||
| 182 | void SetFPSScale(int fpsScale) { m_cStructure->iFPSScale = fpsScale; } | ||
| 183 | |||
| 184 | /// @brief To get with @ref SetFPSScale() changed values. | ||
| 185 | int GetFPSScale() const { return m_cStructure->iFPSScale; } | ||
| 186 | |||
| 187 | /// @brief FPS rate | ||
| 188 | void SetFPSRate(int fpsRate) { m_cStructure->iFPSRate = fpsRate; } | ||
| 189 | |||
| 190 | /// @brief To get with @ref SetFPSRate() changed values. | ||
| 191 | int GetFPSRate() const { return m_cStructure->iFPSRate; } | ||
| 192 | |||
| 193 | /// @brief Height of the stream reported by the demuxer | ||
| 194 | void SetHeight(int height) { m_cStructure->iHeight = height; } | ||
| 195 | |||
| 196 | /// @brief To get with @ref SetHeight() changed values. | ||
| 197 | int GetHeight() const { return m_cStructure->iHeight; } | ||
| 198 | |||
| 199 | /// @brief Width of the stream reported by the demuxer. | ||
| 200 | void SetWidth(int width) { m_cStructure->iWidth = width; } | ||
| 201 | |||
| 202 | /// @brief To get with @ref SetWidth() changed values. | ||
| 203 | int GetWidth() const { return m_cStructure->iWidth; } | ||
| 204 | |||
| 205 | /// @brief Display aspect ratio of the stream. | ||
| 206 | void SetAspect(float aspect) { m_cStructure->fAspect = aspect; } | ||
| 207 | |||
| 208 | /// @brief To get with @ref SetAspect() changed values. | ||
| 209 | float GetAspect() const { return m_cStructure->fAspect; } | ||
| 210 | |||
| 211 | /// @brief Amount of channels. | ||
| 212 | void SetChannels(int channels) { m_cStructure->iChannels = channels; } | ||
| 213 | |||
| 214 | /// @brief To get with @ref SetChannels() changed values. | ||
| 215 | int GetChannels() const { return m_cStructure->iChannels; } | ||
| 216 | |||
| 217 | /// @brief Sample rate. | ||
| 218 | void SetSampleRate(int sampleRate) { m_cStructure->iSampleRate = sampleRate; } | ||
| 219 | |||
| 220 | /// @brief To get with @ref SetSampleRate() changed values. | ||
| 221 | int GetSampleRate() const { return m_cStructure->iSampleRate; } | ||
| 222 | |||
| 223 | /// @brief Block alignment | ||
| 224 | void SetBlockAlign(int blockAlign) { m_cStructure->iBlockAlign = blockAlign; } | ||
| 225 | |||
| 226 | /// @brief To get with @ref SetBlockAlign() changed values. | ||
| 227 | int GetBlockAlign() const { return m_cStructure->iBlockAlign; } | ||
| 228 | |||
| 229 | /// @brief Bit rate. | ||
| 230 | void SetBitRate(int bitRate) { m_cStructure->iBitRate = bitRate; } | ||
| 231 | |||
| 232 | /// @brief To get with @ref SetBitRate() changed values. | ||
| 233 | int GetBitRate() const { return m_cStructure->iBitRate; } | ||
| 234 | |||
| 235 | /// @brief Bits per sample. | ||
| 236 | void SetBitsPerSample(int bitsPerSample) { m_cStructure->iBitsPerSample = bitsPerSample; } | ||
| 237 | |||
| 238 | /// @brief To get with @ref SetBitsPerSample() changed values. | ||
| 239 | int GetBitsPerSample() const { return m_cStructure->iBitsPerSample; } | ||
| 240 | ///@} | ||
| 241 | |||
| 242 | private: | ||
| 243 | PVRStreamProperties(const PVR_STREAM_PROPERTIES::PVR_STREAM* type) : CStructHdl(type) {} | ||
| 244 | PVRStreamProperties(PVR_STREAM_PROPERTIES::PVR_STREAM* type) : CStructHdl(type) {} | ||
| 245 | }; | ||
| 246 | ///@} | ||
| 247 | //------------------------------------------------------------------------------ | ||
| 248 | |||
| 249 | //============================================================================== | ||
| 250 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes class PVRStreamTimes | ||
| 251 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 252 | /// @brief **Times of playing stream (Live TV and recordings)**\n | ||
| 253 | /// This class is used to transfer the necessary data when | ||
| 254 | /// @ref kodi::addon::PVRStreamProperties::GetStreamTimes is called. | ||
| 255 | /// | ||
| 256 | /// ---------------------------------------------------------------------------- | ||
| 257 | /// | ||
| 258 | /// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes_Help | ||
| 259 | /// | ||
| 260 | ///@{ | ||
| 261 | class PVRStreamTimes : public CStructHdl<PVRStreamTimes, PVR_STREAM_TIMES> | ||
| 262 | { | ||
| 263 | friend class CInstancePVRClient; | ||
| 264 | |||
| 265 | public: | ||
| 266 | /*! \cond PRIVATE */ | ||
| 267 | PVRStreamTimes() { memset(m_cStructure, 0, sizeof(PVR_STREAM_TIMES)); } | ||
| 268 | PVRStreamTimes(const PVRStreamTimes& type) : CStructHdl(type) {} | ||
| 269 | /*! \endcond */ | ||
| 270 | |||
| 271 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes_Help Value Help | ||
| 272 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes | ||
| 273 | /// ---------------------------------------------------------------------------- | ||
| 274 | /// | ||
| 275 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes :</b> | ||
| 276 | /// | Name | Type | Set call | Get call | ||
| 277 | /// |------|------|----------|---------- | ||
| 278 | /// | **Start time** | `time_t` | @ref PVRStreamTimes::SetStartTime "SetStartTime" | @ref PVRStreamTimes::GetStartTime "GetStartTime" | ||
| 279 | /// | **PTS start** | `int64_t` | @ref PVRStreamTimes::SetPTSStart "SetPTSStart" | @ref PVRStreamTimes::GetPTSStart "GetPTSStart" | ||
| 280 | /// | **PTS begin** | `int64_t` | @ref PVRStreamTimes::SetPTSBegin "SetPTSBegin" | @ref PVRStreamTimes::GetPTSBegin "GetPTSBegin" | ||
| 281 | /// | **PTS end** | `int64_t` | @ref PVRStreamTimes::SetPTSEnd "SetPTSEnd" | @ref PVRStreamTimes::GetPTSEnd "GetPTSEnd" | ||
| 282 | /// | ||
| 283 | |||
| 284 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes | ||
| 285 | ///@{ | ||
| 286 | |||
| 287 | /// @brief For recordings, this must be zero. For Live TV, this is a reference | ||
| 288 | /// time in units of time_t (UTC) from which time elapsed starts. Ideally start | ||
| 289 | /// of tv show, but can be any other value. | ||
| 290 | void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; } | ||
| 291 | |||
| 292 | /// @brief To get with @ref SetStartTime() changed values. | ||
| 293 | time_t GetStartTime() const { return m_cStructure->startTime; } | ||
| 294 | |||
| 295 | /// @brief The pts of startTime. | ||
| 296 | void SetPTSStart(int64_t ptsStart) { m_cStructure->ptsStart = ptsStart; } | ||
| 297 | |||
| 298 | /// @brief To get with @ref SetPTSStart() changed values. | ||
| 299 | int64_t GetPTSStart() const { return m_cStructure->ptsStart; } | ||
| 300 | |||
| 301 | /// @brief Earliest pts player can seek back. Value is in micro seconds, | ||
| 302 | /// relative to PTS start. For recordings, this must be zero. For Live TV, this | ||
| 303 | /// must be zero if not timeshifting and must point to begin of the timeshift | ||
| 304 | /// buffer, otherwise. | ||
| 305 | void SetPTSBegin(int64_t ptsBegin) { m_cStructure->ptsBegin = ptsBegin; } | ||
| 306 | |||
| 307 | /// @brief To get with @ref SetPTSBegin() changed values. | ||
| 308 | int64_t GetPTSBegin() const { return m_cStructure->ptsBegin; } | ||
| 309 | |||
| 310 | /// @brief Latest pts player can seek forward. Value is in micro seconds, | ||
| 311 | /// relative to PTS start. For recordings, this must be the total length. For | ||
| 312 | /// Live TV, this must be zero if not timeshifting and must point to end of | ||
| 313 | /// the timeshift buffer, otherwise. | ||
| 314 | void SetPTSEnd(int64_t ptsEnd) { m_cStructure->ptsEnd = ptsEnd; } | ||
| 315 | |||
| 316 | /// @brief To get with @ref SetPTSEnd() changed values. | ||
| 317 | int64_t GetPTSEnd() const { return m_cStructure->ptsEnd; } | ||
| 318 | ///@} | ||
| 319 | |||
| 320 | private: | ||
| 321 | PVRStreamTimes(const PVR_STREAM_TIMES* type) : CStructHdl(type) {} | ||
| 322 | PVRStreamTimes(PVR_STREAM_TIMES* type) : CStructHdl(type) {} | ||
| 323 | }; | ||
| 324 | ///@} | ||
| 325 | //------------------------------------------------------------------------------ | ||
| 326 | |||
| 327 | } /* namespace addon */ | ||
| 328 | } /* namespace kodi */ | ||
| 329 | |||
| 330 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h new file mode 100644 index 0000000..6e05e55 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h | |||
| @@ -0,0 +1,896 @@ | |||
| 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 "General.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | #include "../../c-api/addon-instance/pvr.h" | ||
| 14 | |||
| 15 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 16 | // "C++" Definitions group 6 - PVR timers | ||
| 17 | #ifdef __cplusplus | ||
| 18 | |||
| 19 | namespace kodi | ||
| 20 | { | ||
| 21 | namespace addon | ||
| 22 | { | ||
| 23 | |||
| 24 | //============================================================================== | ||
| 25 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer class PVRTimer | ||
| 26 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer | ||
| 27 | /// @brief **PVR add-on timer type**\n | ||
| 28 | /// Representation of a timer event. | ||
| 29 | /// | ||
| 30 | /// The related values here are automatically initiated to defaults and need | ||
| 31 | /// only be set if supported and used. | ||
| 32 | /// | ||
| 33 | /// ---------------------------------------------------------------------------- | ||
| 34 | /// | ||
| 35 | /// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimer_Help | ||
| 36 | /// | ||
| 37 | ///@{ | ||
| 38 | class PVRTimer : public CStructHdl<PVRTimer, PVR_TIMER> | ||
| 39 | { | ||
| 40 | friend class CInstancePVRClient; | ||
| 41 | |||
| 42 | public: | ||
| 43 | /*! \cond PRIVATE */ | ||
| 44 | PVRTimer() | ||
| 45 | { | ||
| 46 | m_cStructure->iClientIndex = 0; | ||
| 47 | m_cStructure->state = PVR_TIMER_STATE_NEW; | ||
| 48 | m_cStructure->iTimerType = PVR_TIMER_TYPE_NONE; | ||
| 49 | m_cStructure->iParentClientIndex = 0; | ||
| 50 | m_cStructure->iClientChannelUid = PVR_TIMER_VALUE_NOT_AVAILABLE; | ||
| 51 | m_cStructure->startTime = 0; | ||
| 52 | m_cStructure->endTime = 0; | ||
| 53 | m_cStructure->bStartAnyTime = false; | ||
| 54 | m_cStructure->bEndAnyTime = false; | ||
| 55 | m_cStructure->bFullTextEpgSearch = false; | ||
| 56 | m_cStructure->iPriority = PVR_TIMER_VALUE_NOT_AVAILABLE; | ||
| 57 | m_cStructure->iLifetime = PVR_TIMER_VALUE_NOT_AVAILABLE; | ||
| 58 | m_cStructure->iMaxRecordings = PVR_TIMER_VALUE_NOT_AVAILABLE; | ||
| 59 | m_cStructure->iRecordingGroup = 0; | ||
| 60 | m_cStructure->firstDay = 0; | ||
| 61 | m_cStructure->iWeekdays = PVR_WEEKDAY_NONE; | ||
| 62 | m_cStructure->iPreventDuplicateEpisodes = 0; | ||
| 63 | m_cStructure->iEpgUid = 0; | ||
| 64 | m_cStructure->iMarginStart = 0; | ||
| 65 | m_cStructure->iMarginEnd = 0; | ||
| 66 | m_cStructure->iGenreType = PVR_TIMER_VALUE_NOT_AVAILABLE; | ||
| 67 | m_cStructure->iGenreSubType = PVR_TIMER_VALUE_NOT_AVAILABLE; | ||
| 68 | } | ||
| 69 | PVRTimer(const PVRTimer& data) : CStructHdl(data) {} | ||
| 70 | /*! \endcond */ | ||
| 71 | |||
| 72 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer_Help Value Help | ||
| 73 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer | ||
| 74 | /// | ||
| 75 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer :</b> | ||
| 76 | /// | Name | Type | Set call | Get call | Usage | ||
| 77 | /// |------|------|----------|----------|----------- | ||
| 78 | /// | **Client index** | `unsigned int` | @ref PVRTimer::SetClientIndex "SetClientIndex" | @ref PVRTimer::GetClientIndex "GetClientIndex" | *required to set* | ||
| 79 | /// | **State** | @ref PVR_TIMER_STATE | @ref PVRTimer::SetState "SetState" | @ref PVRTimer::GetState "GetState" | *required to set* | ||
| 80 | /// | **Type** | `unsigned int` | @ref PVRTimer::SetTimerType "SetTimerType" | @ref PVRTimer::GetTimerType "GetTimerType" | *required to set* | ||
| 81 | /// | **Title** | `std::string` | @ref PVRTimer::SetTitle "SetTitle" | @ref PVRTimer::GetTitle "GetTitle" | *required to set* | ||
| 82 | /// | **Parent client index** | `unsigned int` | @ref PVRTimer::SetParentClientIndex "SetParentClientIndex" | @ref PVRTimer::GetParentClientIndex "GetParentClientIndex" | *optional* | ||
| 83 | /// | **Client channel unique identifier** | `int` | @ref PVRTimer::SetClientChannelUid "SetClientChannelUid" | @ref PVRTimer::GetClientChannelUid "GetClientChannelUid" | *optional* | ||
| 84 | /// | **Start time** | `time_t` | @ref PVRTimer::SetStartTime "SetStartTime" | @ref PVRTimer::GetStartTime "GetStartTime" | *optional* | ||
| 85 | /// | **End time** | `time_t` | @ref PVRTimer::SetEndTime "SetEndTime" | @ref PVRTimer::GetEndTime "GetEndTime" | *optional* | ||
| 86 | /// | **Start any time** | `bool` | @ref PVRTimer::SetStartAnyTime "SetStartAnyTime" | @ref PVRTimer::GetStartAnyTime "GetStartAnyTime" | *optional* | ||
| 87 | /// | **End any time** | `bool` | @ref PVRTimer::SetEndAnyTime "SetEndAnyTime" | @ref PVRTimer::GetEndAnyTime "GetEndAnyTime" | *optional* | ||
| 88 | /// | **EPG search string** | `std::string` | @ref PVRTimer::SetEPGSearchString "SetEPGSearchString" | @ref PVRTimer::GetEPGSearchString "GetEPGSearchString" | *optional* | ||
| 89 | /// | **Full text EPG search** | `bool` | @ref PVRTimer::SetFullTextEpgSearch "SetFullTextEpgSearch" | @ref PVRTimer::GetFullTextEpgSearch "GetFullTextEpgSearch" | *optional* | ||
| 90 | /// | **Recording store directory** | `std::string` | @ref PVRTimer::SetDirectory "SetDirectory" | @ref PVRTimer::GetDirectory "GetDirectory" | *optional* | ||
| 91 | /// | **Timer priority** | `int` | @ref PVRTimer::SetPriority "SetPriority" | @ref PVRTimer::GetPriority "GetPriority" | *optional* | ||
| 92 | /// | **Timer lifetime** | `int` | @ref PVRTimer::SetLifetime "SetLifetime" | @ref PVRTimer::GetLifetime "GetLifetime" | *optional* | ||
| 93 | /// | **Max recordings** | `int` | @ref PVRTimer::SetMaxRecordings "SetMaxRecordings" | @ref PVRTimer::GetMaxRecordings "GetMaxRecordings" | *optional* | ||
| 94 | /// | **Recording group** | `unsigned int` | @ref PVRTimer::SetRecordingGroup "SetRecordingGroup" | @ref PVRTimer::GetRecordingGroup "GetRecordingGroup" | *optional* | ||
| 95 | /// | **First start day** | `time_t` | @ref PVRTimer::SetFirstDay "SetFirstDay" | @ref PVRTimer::GetFirstDay "GetFirstDay" | *optional* | ||
| 96 | /// | **Used timer weekdays** | `unsigned int` | @ref PVRTimer::SetWeekdays "SetWeekdays" | @ref PVRTimer::GetWeekdays "GetWeekdays" | *optional* | ||
| 97 | /// | **Prevent duplicate episodes** | `unsigned int` | @ref PVRTimer::SetPreventDuplicateEpisodes "SetPreventDuplicateEpisodes" | @ref PVRTimer::GetPreventDuplicateEpisodes "GetPreventDuplicateEpisodes" | *optional* | ||
| 98 | /// | **EPG unique identifier** | `unsigned int` | @ref PVRTimer::SetEPGUid "SetEPGUid" | @ref PVRTimer::GetEPGUid "GetEPGUid" | *optional* | ||
| 99 | /// | **Margin start** | `unsigned int` | @ref PVRTimer::SetMarginStart "SetMarginStart" | @ref PVRTimer::GetMarginStart "GetMarginStart" | *optional* | ||
| 100 | /// | **Margin end** | `unsigned int` | @ref PVRTimer::SetMarginEnd "SetMarginEnd" | @ref PVRTimer::GetMarginEnd "GetMarginEnd" | *optional* | ||
| 101 | /// | **Genre type** | `int` | @ref PVRTimer::SetGenreType "SetGenreType" | @ref PVRTimer::GetGenreType "GetGenreType" | *optional* | ||
| 102 | /// | **Genre sub type** | `int` | @ref PVRTimer::SetGenreSubType "SetGenreSubType" | @ref PVRTimer::GetGenreSubType "GetGenreSubType" | *optional* | ||
| 103 | /// | **Series link** | `std::string` | @ref PVRTimer::SetSeriesLink "SetSeriesLink" | @ref PVRTimer::GetSeriesLink "GetSeriesLink" | *optional* | ||
| 104 | |||
| 105 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer | ||
| 106 | ///@{ | ||
| 107 | |||
| 108 | /// @brief **required**\n | ||
| 109 | /// The index of this timer given by the client. | ||
| 110 | /// | ||
| 111 | /// @ref PVR_TIMER_NO_CLIENT_INDEX indicates that the index was not yet set | ||
| 112 | /// by the client, for example for new timers created by Kodi and passed the | ||
| 113 | /// first time to the client. A valid index must be greater than | ||
| 114 | /// @ref PVR_TIMER_NO_CLIENT_INDEX. | ||
| 115 | /// | ||
| 116 | void SetClientIndex(unsigned int clientIndex) { m_cStructure->iClientIndex = clientIndex; } | ||
| 117 | |||
| 118 | /// @brief To get with @ref SetClientIndex changed values. | ||
| 119 | unsigned int GetClientIndex() const { return m_cStructure->iClientIndex; } | ||
| 120 | |||
| 121 | /// @brief **required**\n | ||
| 122 | /// The state of this timer. | ||
| 123 | /// | ||
| 124 | /// @note @ref PVR_TIMER_STATE_NEW is default. | ||
| 125 | /// | ||
| 126 | /// | ||
| 127 | /// -------------------------------------------------------------------------- | ||
| 128 | /// | ||
| 129 | /// **Example:** | ||
| 130 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 131 | /// kodi::addon::PVRTimer tag; | ||
| 132 | /// tag.SetState(PVR_TIMER_STATE_RECORDING); | ||
| 133 | /// ~~~~~~~~~~~~~ | ||
| 134 | /// | ||
| 135 | void SetState(PVR_TIMER_STATE state) { m_cStructure->state = state; } | ||
| 136 | |||
| 137 | /// @brief To get with @ref SetState changed values. | ||
| 138 | PVR_TIMER_STATE GetState() const { return m_cStructure->state; } | ||
| 139 | |||
| 140 | /// @brief **required**\n | ||
| 141 | /// The type of this timer. | ||
| 142 | /// | ||
| 143 | /// It is private to the addon and can be freely defined by the addon. | ||
| 144 | /// The value must be greater than @ref PVR_TIMER_TYPE_NONE. | ||
| 145 | /// | ||
| 146 | /// Kodi does not interpret this value (except for checking for @ref PVR_TIMER_TYPE_NONE), | ||
| 147 | /// but will pass the right id to the addon with every @ref PVRTimer instance, | ||
| 148 | /// thus the addon easily can determine the timer type. | ||
| 149 | /// | ||
| 150 | /// @note @ref PVR_TIMER_TYPE_NONE is default. | ||
| 151 | /// | ||
| 152 | /// | ||
| 153 | /// -------------------------------------------------------------------------- | ||
| 154 | /// | ||
| 155 | /// **Example:** | ||
| 156 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 157 | /// kodi::addon::PVRTimer tag; | ||
| 158 | /// tag.SetTimerType(123); | ||
| 159 | /// ~~~~~~~~~~~~~ | ||
| 160 | /// | ||
| 161 | void SetTimerType(unsigned int timerType) { m_cStructure->iTimerType = timerType; } | ||
| 162 | |||
| 163 | /// @brief To get with @ref SetTimerType changed values. | ||
| 164 | unsigned int GetTimerType() const { return m_cStructure->iTimerType; } | ||
| 165 | |||
| 166 | /// @brief **required**\n | ||
| 167 | /// A title for this timer. | ||
| 168 | void SetTitle(const std::string& title) | ||
| 169 | { | ||
| 170 | strncpy(m_cStructure->strTitle, title.c_str(), sizeof(m_cStructure->strTitle) - 1); | ||
| 171 | } | ||
| 172 | |||
| 173 | /// @brief To get with @ref SetTitle changed values. | ||
| 174 | std::string GetTitle() const { return m_cStructure->strTitle; } | ||
| 175 | |||
| 176 | /// @brief **optional**\n | ||
| 177 | /// For timers scheduled by a repeating timer. | ||
| 178 | /// | ||
| 179 | /// The index of the repeating timer that scheduled this timer (it's | ||
| 180 | /// @ref clientIndex value). Use @ref PVR_TIMER_NO_PARENT to indicate that | ||
| 181 | /// this timer was no scheduled by a repeating timer. | ||
| 182 | void SetParentClientIndex(unsigned int parentClientIndex) | ||
| 183 | { | ||
| 184 | m_cStructure->iParentClientIndex = parentClientIndex; | ||
| 185 | } | ||
| 186 | |||
| 187 | /// @brief To get with @ref SetParentClientIndex changed values. | ||
| 188 | unsigned int GetParentClientIndex() const { return m_cStructure->iParentClientIndex; } | ||
| 189 | |||
| 190 | /// @brief **optional**\n | ||
| 191 | /// Unique identifier of the channel to record on. | ||
| 192 | /// | ||
| 193 | /// @ref PVR_TIMER_ANY_CHANNEL will denote "any channel", not a specific one. | ||
| 194 | /// @ref PVR_CHANNEL_INVALID_UID denotes that channel uid is not available. | ||
| 195 | void SetClientChannelUid(int clientChannelUid) | ||
| 196 | { | ||
| 197 | m_cStructure->iClientChannelUid = clientChannelUid; | ||
| 198 | } | ||
| 199 | |||
| 200 | /// @brief To get with @ref SetClientChannelUid changed values | ||
| 201 | int GetClientChannelUid() const { return m_cStructure->iClientChannelUid; } | ||
| 202 | |||
| 203 | /// @brief **optional**\n | ||
| 204 | /// Start time of the recording in UTC. | ||
| 205 | /// | ||
| 206 | /// Instant timers that are sent to the add-on by Kodi will have this value | ||
| 207 | /// set to 0. | ||
| 208 | void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; } | ||
| 209 | |||
| 210 | /// @brief To get with @ref SetStartTime changed values. | ||
| 211 | time_t GetStartTime() const { return m_cStructure->startTime; } | ||
| 212 | |||
| 213 | /// @brief **optional**\n | ||
| 214 | /// End time of the recording in UTC. | ||
| 215 | void SetEndTime(time_t endTime) { m_cStructure->endTime = endTime; } | ||
| 216 | |||
| 217 | /// @brief To get with @ref SetEndTime changed values. | ||
| 218 | time_t GetEndTime() const { return m_cStructure->endTime; } | ||
| 219 | |||
| 220 | /// @brief **optional**\n | ||
| 221 | /// For EPG based (not Manual) timers indicates startTime does not apply. | ||
| 222 | /// | ||
| 223 | /// Default = false. | ||
| 224 | void SetStartAnyTime(bool startAnyTime) { m_cStructure->bStartAnyTime = startAnyTime; } | ||
| 225 | |||
| 226 | /// @brief To get with @ref SetStartAnyTime changed values. | ||
| 227 | bool GetStartAnyTime() const { return m_cStructure->bStartAnyTime; } | ||
| 228 | |||
| 229 | /// @brief **optional**\n | ||
| 230 | /// For EPG based (not Manual) timers indicates endTime does not apply. | ||
| 231 | /// | ||
| 232 | /// Default = false | ||
| 233 | void SetEndAnyTime(bool endAnyTime) { m_cStructure->bEndAnyTime = endAnyTime; } | ||
| 234 | |||
| 235 | /// @brief To get with @ref SetEndAnyTime changed values. | ||
| 236 | bool GetEndAnyTime() const { return m_cStructure->bEndAnyTime; } | ||
| 237 | |||
| 238 | /// @brief **optional**\n | ||
| 239 | /// A string used to search epg data for repeating epg-based timers. | ||
| 240 | /// | ||
| 241 | /// Format is backend-dependent, for example regexp. | ||
| 242 | void SetEPGSearchString(const std::string& epgSearchString) | ||
| 243 | { | ||
| 244 | strncpy(m_cStructure->strEpgSearchString, epgSearchString.c_str(), | ||
| 245 | sizeof(m_cStructure->strEpgSearchString) - 1); | ||
| 246 | } | ||
| 247 | |||
| 248 | /// @brief To get with @ref SetEPGSearchString changed values | ||
| 249 | std::string GetEPGSearchString() const { return m_cStructure->strEpgSearchString; } | ||
| 250 | |||
| 251 | /// @brief **optional**\n | ||
| 252 | /// Indicates, whether @ref SetEPGSearchString() is to match against the epg | ||
| 253 | /// episode title only or also against "other" epg data (backend-dependent). | ||
| 254 | void SetFullTextEpgSearch(bool fullTextEpgSearch) | ||
| 255 | { | ||
| 256 | m_cStructure->bFullTextEpgSearch = fullTextEpgSearch; | ||
| 257 | } | ||
| 258 | |||
| 259 | /// @brief To get with @ref SetFullTextEpgSearch changed values. | ||
| 260 | bool GetFullTextEpgSearch() const { return m_cStructure->bFullTextEpgSearch; } | ||
| 261 | |||
| 262 | /// @brief **optional**\n | ||
| 263 | /// The (relative) directory where the recording will be stored in. | ||
| 264 | void SetDirectory(const std::string& directory) | ||
| 265 | { | ||
| 266 | strncpy(m_cStructure->strDirectory, directory.c_str(), sizeof(m_cStructure->strDirectory) - 1); | ||
| 267 | } | ||
| 268 | |||
| 269 | /// @brief To get with @ref SetDirectory changed values. | ||
| 270 | std::string GetDirectory() const { return m_cStructure->strDirectory; } | ||
| 271 | |||
| 272 | /// @brief **optional**\n | ||
| 273 | /// The summary for this timer. | ||
| 274 | void SetSummary(const std::string& summary) | ||
| 275 | { | ||
| 276 | strncpy(m_cStructure->strSummary, summary.c_str(), sizeof(m_cStructure->strSummary) - 1); | ||
| 277 | } | ||
| 278 | |||
| 279 | /// @brief To get with @ref SetDirectory changed values. | ||
| 280 | std::string GetSummary() const { return m_cStructure->strSummary; } | ||
| 281 | |||
| 282 | /// @brief **optional**\n | ||
| 283 | /// The priority of this timer. | ||
| 284 | void SetPriority(int priority) { m_cStructure->iPriority = priority; } | ||
| 285 | |||
| 286 | /// @brief To get with @ref SetPriority changed values. | ||
| 287 | int GetPriority() const { return m_cStructure->iPriority; } | ||
| 288 | |||
| 289 | /// @brief **optional**\n | ||
| 290 | /// Lifetime of recordings created by this timer. | ||
| 291 | /// | ||
| 292 | /// Value > 0 days after which recordings will be deleted by the backend, < 0 | ||
| 293 | /// addon defined integer list reference, == 0 disabled. | ||
| 294 | void SetLifetime(int priority) { m_cStructure->iLifetime = priority; } | ||
| 295 | |||
| 296 | /// @brief To get with @ref SetLifetime changed values. | ||
| 297 | int GetLifetime() const { return m_cStructure->iLifetime; } | ||
| 298 | |||
| 299 | /// @brief **optional**\n | ||
| 300 | /// Maximum number of recordings this timer shall create. | ||
| 301 | /// | ||
| 302 | /// Value > 0 number of recordings, < 0 addon defined integer list reference, == 0 disabled. | ||
| 303 | void SetMaxRecordings(int maxRecordings) { m_cStructure->iMaxRecordings = maxRecordings; } | ||
| 304 | |||
| 305 | /// @brief To get with @ref SetMaxRecordings changed values. | ||
| 306 | int GetMaxRecordings() const { return m_cStructure->iMaxRecordings; } | ||
| 307 | |||
| 308 | /// @brief **optional**\n | ||
| 309 | /// Integer ref to addon/backend defined list of recording groups. | ||
| 310 | void SetRecordingGroup(unsigned int recordingGroup) | ||
| 311 | { | ||
| 312 | m_cStructure->iRecordingGroup = recordingGroup; | ||
| 313 | } | ||
| 314 | |||
| 315 | /// @brief To get with @ref SetRecordingGroup changed values. | ||
| 316 | unsigned int GetRecordingGroup() const { return m_cStructure->iRecordingGroup; } | ||
| 317 | |||
| 318 | /// @brief **optional**\n | ||
| 319 | /// The first day this timer is active, for repeating timers. | ||
| 320 | void SetFirstDay(time_t firstDay) { m_cStructure->firstDay = firstDay; } | ||
| 321 | |||
| 322 | /// @brief To get with @ref SetFirstDay changed values. | ||
| 323 | time_t GetFirstDay() const { return m_cStructure->firstDay; } | ||
| 324 | |||
| 325 | /// @brief **optional**\n | ||
| 326 | /// Week days, for repeating timers (see | ||
| 327 | /// @ref cpp_kodi_addon_pvr_Defs_Timer_PVR_WEEKDAY "PVR_WEEKDAY_*" constant values) | ||
| 328 | /// | ||
| 329 | /// @note @ref PVR_WEEKDAY_NONE is default. | ||
| 330 | /// | ||
| 331 | /// | ||
| 332 | /// -------------------------------------------------------------------------- | ||
| 333 | /// | ||
| 334 | /// **Example:** | ||
| 335 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 336 | /// ... | ||
| 337 | /// kodi::addon::PVRTimer tag; | ||
| 338 | /// tag.SetWeekdays(PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_SATURDAY); | ||
| 339 | /// ... | ||
| 340 | /// ~~~~~~~~~~~~~ | ||
| 341 | void SetWeekdays(unsigned int weekdays) { m_cStructure->iWeekdays = weekdays; } | ||
| 342 | |||
| 343 | /// @brief To get with @ref SetFirstDay changed values. | ||
| 344 | unsigned int GetWeekdays() const { return m_cStructure->iWeekdays; } | ||
| 345 | |||
| 346 | /// @brief **optional**\n | ||
| 347 | /// Prevent duplicate episodes. | ||
| 348 | /// | ||
| 349 | /// Should 1 if backend should only record new episodes in case of a repeating | ||
| 350 | /// epg-based timer, 0 if all episodes shall be recorded (no duplicate detection). | ||
| 351 | /// | ||
| 352 | /// Actual algorithm for duplicate detection is defined by the backend. | ||
| 353 | /// Addons may define own values for different duplicate detection | ||
| 354 | /// algorithms, thus this is not just a bool. | ||
| 355 | void SetPreventDuplicateEpisodes(unsigned int preventDuplicateEpisodes) | ||
| 356 | { | ||
| 357 | m_cStructure->iPreventDuplicateEpisodes = preventDuplicateEpisodes; | ||
| 358 | } | ||
| 359 | |||
| 360 | /// @brief To get with @ref SetPreventDuplicateEpisodes changed values. | ||
| 361 | unsigned int GetPreventDuplicateEpisodes() const | ||
| 362 | { | ||
| 363 | return m_cStructure->iPreventDuplicateEpisodes; | ||
| 364 | } | ||
| 365 | |||
| 366 | /// @brief **optional**\n | ||
| 367 | /// EPG event id associated with this timer. Event ids must be unique for a | ||
| 368 | /// channel. | ||
| 369 | /// | ||
| 370 | /// Valid ids must be greater than @ref EPG_TAG_INVALID_UID. | ||
| 371 | void SetEPGUid(unsigned int epgUid) { m_cStructure->iEpgUid = epgUid; } | ||
| 372 | |||
| 373 | /// @brief To get with @ref SetEPGUid changed values. | ||
| 374 | unsigned int GetEPGUid() const { return m_cStructure->iEpgUid; } | ||
| 375 | |||
| 376 | /// @brief **optional**\n | ||
| 377 | /// If set, the backend starts the recording selected minutes before | ||
| 378 | /// @ref SetStartTime. | ||
| 379 | void SetMarginStart(unsigned int marginStart) { m_cStructure->iMarginStart = marginStart; } | ||
| 380 | |||
| 381 | /// @brief To get with @ref SetMarginStart changed values. | ||
| 382 | unsigned int GetMarginStart() const { return m_cStructure->iMarginStart; } | ||
| 383 | |||
| 384 | /// @brief **optional**\n | ||
| 385 | /// If set, the backend ends the recording selected minutes after | ||
| 386 | /// @ref SetEndTime. | ||
| 387 | void SetMarginEnd(unsigned int marginEnd) { m_cStructure->iMarginEnd = marginEnd; } | ||
| 388 | |||
| 389 | /// @brief To get with @ref SetMarginEnd changed values. | ||
| 390 | unsigned int GetMarginEnd() const { return m_cStructure->iMarginEnd; } | ||
| 391 | |||
| 392 | /// @brief **optional**\n | ||
| 393 | /// Genre type. | ||
| 394 | /// | ||
| 395 | /// @copydetails EPG_EVENT_CONTENTMASK | ||
| 396 | /// | ||
| 397 | /// -------------------------------------------------------------------------- | ||
| 398 | /// | ||
| 399 | /// **Example:** | ||
| 400 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 401 | /// ... | ||
| 402 | /// kodi::addon::PVRTimer tag; | ||
| 403 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA); | ||
| 404 | /// ... | ||
| 405 | /// ~~~~~~~~~~~~~ | ||
| 406 | /// | ||
| 407 | /// @note If confirmed that backend brings the types in [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 408 | /// conform values, can be @ref EPG_EVENT_CONTENTMASK ignored and to set here | ||
| 409 | /// with backend value. | ||
| 410 | /// | ||
| 411 | void SetGenreType(int genreType) { m_cStructure->iGenreType = genreType; } | ||
| 412 | |||
| 413 | /// @brief To get with @ref SetGenreType changed values. | ||
| 414 | int GetGenreType() const { return m_cStructure->iGenreType; } | ||
| 415 | |||
| 416 | /// @brief **optional**\n | ||
| 417 | /// Genre sub type. | ||
| 418 | /// | ||
| 419 | /// @copydetails EPG_EVENT_CONTENTMASK | ||
| 420 | /// | ||
| 421 | /// Subtypes groups related to set by @ref SetGenreType: | ||
| 422 | /// | Main genre type | List with available sub genre types | ||
| 423 | /// |-----------------|----------------------------------------- | ||
| 424 | /// | @ref EPG_EVENT_CONTENTMASK_UNDEFINED | Nothing, should be 0 | ||
| 425 | /// | @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA | ||
| 426 | /// | @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS | ||
| 427 | /// | @ref EPG_EVENT_CONTENTMASK_SHOW | @ref EPG_EVENT_CONTENTSUBMASK_SHOW | ||
| 428 | /// | @ref EPG_EVENT_CONTENTMASK_SPORTS | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS | ||
| 429 | /// | @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH | ||
| 430 | /// | @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE | ||
| 431 | /// | @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE | ||
| 432 | /// | @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS | ||
| 433 | /// | @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE | ||
| 434 | /// | @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES | ||
| 435 | /// | @ref EPG_EVENT_CONTENTMASK_SPECIAL | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL | ||
| 436 | /// | @ref EPG_EVENT_CONTENTMASK_USERDEFINED | Can be defined by you | ||
| 437 | /// | ||
| 438 | /// -------------------------------------------------------------------------- | ||
| 439 | /// | ||
| 440 | /// **Example:** | ||
| 441 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 442 | /// ... | ||
| 443 | /// kodi::addon::PVRTimer tag; | ||
| 444 | /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE); | ||
| 445 | /// tag.SetGenreSubType(EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ); | ||
| 446 | /// ... | ||
| 447 | /// ~~~~~~~~~~~~~ | ||
| 448 | /// | ||
| 449 | void SetGenreSubType(int genreSubType) { m_cStructure->iGenreSubType = genreSubType; } | ||
| 450 | |||
| 451 | /// @brief To get with @ref SetGenreType changed values. | ||
| 452 | int GetGenreSubType() const { return m_cStructure->iGenreSubType; } | ||
| 453 | |||
| 454 | /// @brief **optional**\n | ||
| 455 | /// Series link for this timer. | ||
| 456 | /// | ||
| 457 | /// If set for an epg-based timer rule, matching events will be found by | ||
| 458 | /// checking with here, instead of @ref SetTitle() (and @ref SetFullTextEpgSearch()). | ||
| 459 | void SetSeriesLink(const std::string& seriesLink) | ||
| 460 | { | ||
| 461 | strncpy(m_cStructure->strSeriesLink, seriesLink.c_str(), | ||
| 462 | sizeof(m_cStructure->strSeriesLink) - 1); | ||
| 463 | } | ||
| 464 | |||
| 465 | /// @brief To get with @ref SetSeriesLink changed values. | ||
| 466 | std::string GetSeriesLink() const { return m_cStructure->strSeriesLink; } | ||
| 467 | ///@} | ||
| 468 | |||
| 469 | private: | ||
| 470 | PVRTimer(const PVR_TIMER* data) : CStructHdl(data) {} | ||
| 471 | PVRTimer(PVR_TIMER* data) : CStructHdl(data) {} | ||
| 472 | }; | ||
| 473 | |||
| 474 | ///@} | ||
| 475 | //------------------------------------------------------------------------------ | ||
| 476 | |||
| 477 | //============================================================================== | ||
| 478 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimersResultSet class PVRTimersResultSet | ||
| 479 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer | ||
| 480 | /// @brief **PVR add-on timer transfer class**\n | ||
| 481 | /// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetTimers(). | ||
| 482 | /// | ||
| 483 | /// @note This becomes only be used on addon call above, not usable outside on | ||
| 484 | /// addon itself. | ||
| 485 | ///@{ | ||
| 486 | class PVRTimersResultSet | ||
| 487 | { | ||
| 488 | public: | ||
| 489 | /*! \cond PRIVATE */ | ||
| 490 | PVRTimersResultSet() = delete; | ||
| 491 | PVRTimersResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle) | ||
| 492 | : m_instance(instance), m_handle(handle) | ||
| 493 | { | ||
| 494 | } | ||
| 495 | /*! \endcond */ | ||
| 496 | |||
| 497 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimersResultSet | ||
| 498 | ///@{ | ||
| 499 | |||
| 500 | /// @brief To add and give content from addon to Kodi on related call. | ||
| 501 | /// | ||
| 502 | /// @param[in] tag The to transferred data. | ||
| 503 | void Add(const kodi::addon::PVRTimer& tag) | ||
| 504 | { | ||
| 505 | m_instance->toKodi->TransferTimerEntry(m_instance->toKodi->kodiInstance, m_handle, tag); | ||
| 506 | } | ||
| 507 | |||
| 508 | ///@} | ||
| 509 | |||
| 510 | private: | ||
| 511 | const AddonInstance_PVR* m_instance = nullptr; | ||
| 512 | const ADDON_HANDLE m_handle; | ||
| 513 | }; | ||
| 514 | ///@} | ||
| 515 | //------------------------------------------------------------------------------ | ||
| 516 | |||
| 517 | //============================================================================== | ||
| 518 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType class PVRTimerType | ||
| 519 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer | ||
| 520 | /// @brief **PVR add-on timer type**\n | ||
| 521 | /// To define the content of @ref kodi::addon::CInstancePVRClient::GetTimerTypes() | ||
| 522 | /// given groups. | ||
| 523 | /// | ||
| 524 | /// ---------------------------------------------------------------------------- | ||
| 525 | /// | ||
| 526 | /// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType_Help | ||
| 527 | /// | ||
| 528 | ///@{ | ||
| 529 | class PVRTimerType : public CStructHdl<PVRTimerType, PVR_TIMER_TYPE> | ||
| 530 | { | ||
| 531 | friend class CInstancePVRClient; | ||
| 532 | |||
| 533 | public: | ||
| 534 | /*! \cond PRIVATE */ | ||
| 535 | PVRTimerType() | ||
| 536 | { | ||
| 537 | memset(m_cStructure, 0, sizeof(PVR_TIMER_TYPE)); | ||
| 538 | m_cStructure->iPrioritiesDefault = -1; | ||
| 539 | m_cStructure->iLifetimesDefault = -1; | ||
| 540 | m_cStructure->iPreventDuplicateEpisodesDefault = -1; | ||
| 541 | m_cStructure->iRecordingGroupDefault = -1; | ||
| 542 | m_cStructure->iMaxRecordingsDefault = -1; | ||
| 543 | } | ||
| 544 | PVRTimerType(const PVRTimerType& type) : CStructHdl(type) {} | ||
| 545 | /*! \endcond */ | ||
| 546 | |||
| 547 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType_Help Value Help | ||
| 548 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType | ||
| 549 | /// ---------------------------------------------------------------------------- | ||
| 550 | /// | ||
| 551 | /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType :</b> | ||
| 552 | /// | Name | Type | Set call | Get call | Usage | ||
| 553 | /// |------|------|----------|----------|----------- | ||
| 554 | /// | **Identifier** | `unsigned int` | @ref PVRTimerType::SetId "SetId" | @ref PVRTimerType::GetId "GetId" | *required to set* | ||
| 555 | /// | **Attributes** | `unsigned int` | @ref PVRTimerType::SetAttributes "SetAttributes" | @ref PVRTimerType::GetAttributes "GetAttributes" | *required to set* | ||
| 556 | /// | **Description** | `std::string` | @ref PVRTimerType::SetDescription "SetDescription" | @ref PVRTimerType::GetDescription "GetDescription" | *optional* | ||
| 557 | /// | | | | | | | ||
| 558 | /// | **Priority selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetPriorities "SetPriorities" | @ref PVRTimerType::GetPriorities "GetPriorities" | *optional* | ||
| 559 | /// | **Priority default selection** | `int`| @ref PVRTimerType::SetPrioritiesDefault "SetPrioritiesDefault" | @ref PVRTimerType::GetPrioritiesDefault "GetPrioritiesDefault" | *optional* | ||
| 560 | /// | | | | | | | ||
| 561 | /// | **Lifetime selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetLifetimes "SetLifetimes" | @ref PVRTimerType::GetLifetimes "GetLifetimes" | *optional* | ||
| 562 | /// | **Lifetime default selection** | `int`| @ref PVRTimerType::SetLifetimesDefault "SetLifetimesDefault" | @ref PVRTimerType::GetLifetimesDefault "GetLifetimesDefault" | *optional* | ||
| 563 | /// | | | | | | | ||
| 564 | /// | **Prevent duplicate episodes selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetPreventDuplicateEpisodes "SetPreventDuplicateEpisodes" | @ref PVRTimerType::GetPreventDuplicateEpisodes "GetPreventDuplicateEpisodes" | *optional* | ||
| 565 | /// | **Prevent duplicate episodes default** | `int`| @ref PVRTimerType::SetPreventDuplicateEpisodesDefault "SetPreventDuplicateEpisodesDefault" | @ref PVRTimerType::GetPreventDuplicateEpisodesDefault "GetPreventDuplicateEpisodesDefault" | *optional* | ||
| 566 | /// | | | | | | | ||
| 567 | /// | **Recording group selection**| @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetRecordingGroups "SetRecordingGroups" | @ref PVRTimerType::GetRecordingGroups "GetRecordingGroups" | *optional* | ||
| 568 | /// | **Recording group default** | `int`| @ref PVRTimerType::SetRecordingGroupDefault "SetRecordingGroupDefault" | @ref PVRTimerType::GetRecordingGroupDefault "GetRecordingGroupDefault" | *optional* | ||
| 569 | /// | | | | | | | ||
| 570 | /// | **Max recordings selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetMaxRecordings "SetMaxRecordings" | @ref PVRTimerType::GetMaxRecordings "GetMaxRecordings" | *optional* | ||
| 571 | /// | **Max recordings default** | `int`| @ref PVRTimerType::SetMaxRecordingsDefault "SetMaxRecordingsDefault" | @ref PVRTimerType::GetMaxRecordingsDefault "GetMaxRecordingsDefault" | *optional* | ||
| 572 | /// | ||
| 573 | |||
| 574 | /// @addtogroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType | ||
| 575 | ///@{ | ||
| 576 | |||
| 577 | /// @brief **required**\n | ||
| 578 | /// This type's identifier. Ids must be > @ref PVR_TIMER_TYPE_NONE. | ||
| 579 | void SetId(unsigned int id) { m_cStructure->iId = id; } | ||
| 580 | |||
| 581 | /// @brief To get with @ref SetAttributes changed values. | ||
| 582 | unsigned int GetId() const { return m_cStructure->iId; } | ||
| 583 | |||
| 584 | /// @brief **required**\n | ||
| 585 | /// Defines the attributes for this type (@ref cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_TYPE "PVR_TIMER_TYPE_*" constants). | ||
| 586 | /// | ||
| 587 | /// To defines the attributes for a type. These values are bit fields that can be | ||
| 588 | /// used together. | ||
| 589 | /// | ||
| 590 | ///-------------------------------------------------------------------------- | ||
| 591 | /// | ||
| 592 | /// **Example:** | ||
| 593 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 594 | /// kodi::addon::PVRTimerType tag; | ||
| 595 | /// tag.SetAttributes(PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_IS_REPEATING); | ||
| 596 | /// ~~~~~~~~~~~~~ | ||
| 597 | /// | ||
| 598 | void SetAttributes(uint64_t attributes) { m_cStructure->iAttributes = attributes; } | ||
| 599 | |||
| 600 | /// @brief To get with @ref SetAttributes changed values. | ||
| 601 | uint64_t GetAttributes() const { return m_cStructure->iAttributes; } | ||
| 602 | |||
| 603 | /// @brief **optional**\n | ||
| 604 | /// A short localized string describing the purpose of the type. (e.g. | ||
| 605 | /// "Any time at this channel if title matches"). | ||
| 606 | /// | ||
| 607 | /// If left blank, Kodi will generate a description based on the attributes | ||
| 608 | /// REPEATING and MANUAL. (e.g. "Repeating EPG-based.") | ||
| 609 | void SetDescription(const std::string& description) | ||
| 610 | { | ||
| 611 | strncpy(m_cStructure->strDescription, description.c_str(), | ||
| 612 | sizeof(m_cStructure->strDescription) - 1); | ||
| 613 | } | ||
| 614 | |||
| 615 | /// @brief To get with @ref SetDescription changed values. | ||
| 616 | std::string GetDescription() const { return m_cStructure->strDescription; } | ||
| 617 | |||
| 618 | //---------------------------------------------------------------------------- | ||
| 619 | |||
| 620 | /// @brief **optional**\n | ||
| 621 | /// Priority value definitions. | ||
| 622 | /// | ||
| 623 | /// Array containing the possible values for @ref PVRTimer::SetPriority(). | ||
| 624 | /// | ||
| 625 | /// @param[in] priorities List of priority values | ||
| 626 | /// @param[in] prioritiesDefault [opt] The default value in list, can also be | ||
| 627 | /// set by @ref SetPrioritiesDefault() | ||
| 628 | /// | ||
| 629 | /// -------------------------------------------------------------------------- | ||
| 630 | /// | ||
| 631 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 632 | void SetPriorities(const std::vector<PVRTypeIntValue>& priorities, int prioritiesDefault = -1) | ||
| 633 | { | ||
| 634 | m_cStructure->iPrioritiesSize = static_cast<unsigned int>(priorities.size()); | ||
| 635 | for (unsigned int i = 0; | ||
| 636 | i < m_cStructure->iPrioritiesSize && i < sizeof(m_cStructure->priorities); ++i) | ||
| 637 | { | ||
| 638 | m_cStructure->priorities[i].iValue = priorities[i].GetCStructure()->iValue; | ||
| 639 | strncpy(m_cStructure->priorities[i].strDescription, | ||
| 640 | priorities[i].GetCStructure()->strDescription, | ||
| 641 | sizeof(m_cStructure->priorities[i].strDescription) - 1); | ||
| 642 | } | ||
| 643 | if (prioritiesDefault != -1) | ||
| 644 | m_cStructure->iPrioritiesDefault = prioritiesDefault; | ||
| 645 | } | ||
| 646 | |||
| 647 | /// @brief To get with @ref SetPriorities changed values. | ||
| 648 | std::vector<PVRTypeIntValue> GetPriorities() const | ||
| 649 | { | ||
| 650 | std::vector<PVRTypeIntValue> ret; | ||
| 651 | for (unsigned int i = 0; i < m_cStructure->iPrioritiesSize; ++i) | ||
| 652 | ret.emplace_back(m_cStructure->priorities[i].iValue, | ||
| 653 | m_cStructure->priorities[i].strDescription); | ||
| 654 | return ret; | ||
| 655 | } | ||
| 656 | |||
| 657 | /// @brief **optional**\n | ||
| 658 | /// The default value for @ref PVRTimer::SetPriority(). | ||
| 659 | /// | ||
| 660 | /// @note Must be filled if @ref SetPriorities contain values and not | ||
| 661 | /// defined there on second function value. | ||
| 662 | void SetPrioritiesDefault(int prioritiesDefault) | ||
| 663 | { | ||
| 664 | m_cStructure->iPrioritiesDefault = prioritiesDefault; | ||
| 665 | } | ||
| 666 | |||
| 667 | /// @brief To get with @ref SetPrioritiesDefault changed values. | ||
| 668 | int GetPrioritiesDefault() const { return m_cStructure->iPrioritiesDefault; } | ||
| 669 | |||
| 670 | //---------------------------------------------------------------------------- | ||
| 671 | |||
| 672 | /// @brief **optional**\n | ||
| 673 | /// Lifetime value definitions. | ||
| 674 | /// | ||
| 675 | /// Array containing the possible values for @ref PVRTimer::SetLifetime(). | ||
| 676 | /// | ||
| 677 | /// @param[in] lifetimes List of lifetimes values | ||
| 678 | /// @param[in] lifetimesDefault [opt] The default value in list, can also be | ||
| 679 | /// set by @ref SetLifetimesDefault() | ||
| 680 | /// | ||
| 681 | /// -------------------------------------------------------------------------- | ||
| 682 | /// | ||
| 683 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 684 | void SetLifetimes(const std::vector<PVRTypeIntValue>& lifetimes, int lifetimesDefault = -1) | ||
| 685 | { | ||
| 686 | m_cStructure->iLifetimesSize = static_cast<unsigned int>(lifetimes.size()); | ||
| 687 | for (unsigned int i = 0; | ||
| 688 | i < m_cStructure->iLifetimesSize && i < sizeof(m_cStructure->lifetimes); ++i) | ||
| 689 | { | ||
| 690 | m_cStructure->lifetimes[i].iValue = lifetimes[i].GetCStructure()->iValue; | ||
| 691 | strncpy(m_cStructure->lifetimes[i].strDescription, | ||
| 692 | lifetimes[i].GetCStructure()->strDescription, | ||
| 693 | sizeof(m_cStructure->lifetimes[i].strDescription) - 1); | ||
| 694 | } | ||
| 695 | if (lifetimesDefault != -1) | ||
| 696 | m_cStructure->iLifetimesDefault = lifetimesDefault; | ||
| 697 | } | ||
| 698 | |||
| 699 | /// @brief To get with @ref SetLifetimes changed values. | ||
| 700 | std::vector<PVRTypeIntValue> GetLifetimes() const | ||
| 701 | { | ||
| 702 | std::vector<PVRTypeIntValue> ret; | ||
| 703 | for (unsigned int i = 0; i < m_cStructure->iLifetimesSize; ++i) | ||
| 704 | ret.emplace_back(m_cStructure->lifetimes[i].iValue, | ||
| 705 | m_cStructure->lifetimes[i].strDescription); | ||
| 706 | return ret; | ||
| 707 | } | ||
| 708 | |||
| 709 | /// @brief **optional**\n | ||
| 710 | /// The default value for @ref SetLifetimes(). | ||
| 711 | /// | ||
| 712 | /// @note Must be filled if @ref SetLifetimes contain values and not | ||
| 713 | /// defined there on second function value. | ||
| 714 | void SetLifetimesDefault(int lifetimesDefault) | ||
| 715 | { | ||
| 716 | m_cStructure->iLifetimesDefault = lifetimesDefault; | ||
| 717 | } | ||
| 718 | |||
| 719 | /// @brief To get with @ref SetLifetimesDefault changed values. | ||
| 720 | int GetLifetimesDefault() const { return m_cStructure->iLifetimesDefault; } | ||
| 721 | |||
| 722 | //---------------------------------------------------------------------------- | ||
| 723 | |||
| 724 | /// @brief **optional**\n | ||
| 725 | /// Prevent duplicate episodes value definitions. | ||
| 726 | /// | ||
| 727 | /// Array containing the possible values for @ref PVRTimer::SetPreventDuplicateEpisodes(). | ||
| 728 | /// | ||
| 729 | /// @note Must be filled if @ref PVRTimer::SetPreventDuplicateEpisodes() is not empty. | ||
| 730 | /// | ||
| 731 | /// @param[in] preventDuplicateEpisodes List of duplicate episodes values | ||
| 732 | /// @param[in] preventDuplicateEpisodesDefault [opt] The default value in list, can also be | ||
| 733 | /// set by @ref SetPreventDuplicateEpisodesDefault() | ||
| 734 | /// | ||
| 735 | /// -------------------------------------------------------------------------- | ||
| 736 | /// | ||
| 737 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 738 | void SetPreventDuplicateEpisodes( | ||
| 739 | const std::vector<PVRTypeIntValue>& preventDuplicateEpisodes, | ||
| 740 | int preventDuplicateEpisodesDefault = -1) | ||
| 741 | { | ||
| 742 | m_cStructure->iPreventDuplicateEpisodesSize = | ||
| 743 | static_cast<unsigned int>(preventDuplicateEpisodes.size()); | ||
| 744 | for (unsigned int i = 0; i < m_cStructure->iPreventDuplicateEpisodesSize && | ||
| 745 | i < sizeof(m_cStructure->preventDuplicateEpisodes); | ||
| 746 | ++i) | ||
| 747 | { | ||
| 748 | m_cStructure->preventDuplicateEpisodes[i].iValue = | ||
| 749 | preventDuplicateEpisodes[i].GetCStructure()->iValue; | ||
| 750 | strncpy(m_cStructure->preventDuplicateEpisodes[i].strDescription, | ||
| 751 | preventDuplicateEpisodes[i].GetCStructure()->strDescription, | ||
| 752 | sizeof(m_cStructure->preventDuplicateEpisodes[i].strDescription) - 1); | ||
| 753 | } | ||
| 754 | if (preventDuplicateEpisodesDefault != -1) | ||
| 755 | m_cStructure->iPreventDuplicateEpisodesDefault = preventDuplicateEpisodesDefault; | ||
| 756 | } | ||
| 757 | |||
| 758 | /// @brief To get with @ref SetPreventDuplicateEpisodes changed values. | ||
| 759 | std::vector<PVRTypeIntValue> GetPreventDuplicateEpisodes() const | ||
| 760 | { | ||
| 761 | std::vector<PVRTypeIntValue> ret; | ||
| 762 | for (unsigned int i = 0; i < m_cStructure->iPreventDuplicateEpisodesSize; ++i) | ||
| 763 | ret.emplace_back(m_cStructure->preventDuplicateEpisodes[i].iValue, | ||
| 764 | m_cStructure->preventDuplicateEpisodes[i].strDescription); | ||
| 765 | return ret; | ||
| 766 | } | ||
| 767 | |||
| 768 | /// @brief **optional**\n | ||
| 769 | /// The default value for @ref PVRTimer::SetPreventDuplicateEpisodes(). | ||
| 770 | /// | ||
| 771 | /// @note Must be filled if @ref SetPreventDuplicateEpisodes contain values and not | ||
| 772 | /// defined there on second function value. | ||
| 773 | void SetPreventDuplicateEpisodesDefault(int preventDuplicateEpisodesDefault) | ||
| 774 | { | ||
| 775 | m_cStructure->iPreventDuplicateEpisodesDefault = preventDuplicateEpisodesDefault; | ||
| 776 | } | ||
| 777 | |||
| 778 | /// @brief To get with @ref SetPreventDuplicateEpisodesDefault changed values. | ||
| 779 | int GetPreventDuplicateEpisodesDefault() const | ||
| 780 | { | ||
| 781 | return m_cStructure->iPreventDuplicateEpisodesDefault; | ||
| 782 | } | ||
| 783 | |||
| 784 | //---------------------------------------------------------------------------- | ||
| 785 | |||
| 786 | /// @brief **optional**\n | ||
| 787 | /// Array containing the possible values of @ref PVRTimer::SetRecordingGroup() | ||
| 788 | /// | ||
| 789 | /// @param[in] recordingGroup List of recording group values | ||
| 790 | /// @param[in] recordingGroupDefault [opt] The default value in list, can also be | ||
| 791 | /// set by @ref SetRecordingGroupDefault() | ||
| 792 | /// | ||
| 793 | /// -------------------------------------------------------------------------- | ||
| 794 | /// | ||
| 795 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 796 | void SetRecordingGroups(const std::vector<PVRTypeIntValue>& recordingGroup, | ||
| 797 | int recordingGroupDefault = -1) | ||
| 798 | { | ||
| 799 | m_cStructure->iRecordingGroupSize = static_cast<unsigned int>(recordingGroup.size()); | ||
| 800 | for (unsigned int i = 0; | ||
| 801 | i < m_cStructure->iRecordingGroupSize && i < sizeof(m_cStructure->recordingGroup); ++i) | ||
| 802 | { | ||
| 803 | m_cStructure->recordingGroup[i].iValue = recordingGroup[i].GetCStructure()->iValue; | ||
| 804 | strncpy(m_cStructure->recordingGroup[i].strDescription, | ||
| 805 | recordingGroup[i].GetCStructure()->strDescription, | ||
| 806 | sizeof(m_cStructure->recordingGroup[i].strDescription) - 1); | ||
| 807 | } | ||
| 808 | if (recordingGroupDefault != -1) | ||
| 809 | m_cStructure->iRecordingGroupDefault = recordingGroupDefault; | ||
| 810 | } | ||
| 811 | |||
| 812 | /// @brief To get with @ref SetRecordingGroups changed values | ||
| 813 | std::vector<PVRTypeIntValue> GetRecordingGroups() const | ||
| 814 | { | ||
| 815 | std::vector<PVRTypeIntValue> ret; | ||
| 816 | for (unsigned int i = 0; i < m_cStructure->iRecordingGroupSize; ++i) | ||
| 817 | ret.emplace_back(m_cStructure->recordingGroup[i].iValue, | ||
| 818 | m_cStructure->recordingGroup[i].strDescription); | ||
| 819 | return ret; | ||
| 820 | } | ||
| 821 | |||
| 822 | /// @brief **optional**\n | ||
| 823 | /// The default value for @ref PVRTimer::SetRecordingGroup(). | ||
| 824 | /// | ||
| 825 | /// @note Must be filled if @ref SetRecordingGroups contain values and not | ||
| 826 | /// defined there on second function value. | ||
| 827 | void SetRecordingGroupDefault(int recordingGroupDefault) | ||
| 828 | { | ||
| 829 | m_cStructure->iRecordingGroupDefault = recordingGroupDefault; | ||
| 830 | } | ||
| 831 | |||
| 832 | /// @brief To get with @ref SetRecordingGroupDefault changed values | ||
| 833 | int GetRecordingGroupDefault() const { return m_cStructure->iRecordingGroupDefault; } | ||
| 834 | |||
| 835 | //---------------------------------------------------------------------------- | ||
| 836 | |||
| 837 | /// @brief **optional**\n | ||
| 838 | /// Array containing the possible values of @ref PVRTimer::SetMaxRecordings(). | ||
| 839 | /// | ||
| 840 | /// @param[in] maxRecordings List of lifetimes values | ||
| 841 | /// @param[in] maxRecordingsDefault [opt] The default value in list, can also be | ||
| 842 | /// set by @ref SetMaxRecordingsDefault() | ||
| 843 | /// | ||
| 844 | /// -------------------------------------------------------------------------- | ||
| 845 | /// | ||
| 846 | /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help | ||
| 847 | void SetMaxRecordings(const std::vector<PVRTypeIntValue>& maxRecordings, | ||
| 848 | int maxRecordingsDefault = -1) | ||
| 849 | { | ||
| 850 | m_cStructure->iMaxRecordingsSize = static_cast<unsigned int>(maxRecordings.size()); | ||
| 851 | for (unsigned int i = 0; | ||
| 852 | i < m_cStructure->iMaxRecordingsSize && i < sizeof(m_cStructure->maxRecordings); ++i) | ||
| 853 | { | ||
| 854 | m_cStructure->maxRecordings[i].iValue = maxRecordings[i].GetCStructure()->iValue; | ||
| 855 | strncpy(m_cStructure->maxRecordings[i].strDescription, | ||
| 856 | maxRecordings[i].GetCStructure()->strDescription, | ||
| 857 | sizeof(m_cStructure->maxRecordings[i].strDescription) - 1); | ||
| 858 | } | ||
| 859 | if (maxRecordingsDefault != -1) | ||
| 860 | m_cStructure->iMaxRecordingsDefault = maxRecordingsDefault; | ||
| 861 | } | ||
| 862 | |||
| 863 | /// @brief To get with @ref SetMaxRecordings changed values | ||
| 864 | std::vector<PVRTypeIntValue> GetMaxRecordings() const | ||
| 865 | { | ||
| 866 | std::vector<PVRTypeIntValue> ret; | ||
| 867 | for (unsigned int i = 0; i < m_cStructure->iMaxRecordingsSize; ++i) | ||
| 868 | ret.emplace_back(m_cStructure->maxRecordings[i].iValue, | ||
| 869 | m_cStructure->maxRecordings[i].strDescription); | ||
| 870 | return ret; | ||
| 871 | } | ||
| 872 | |||
| 873 | /// @brief **optional**\n | ||
| 874 | /// The default value for @ref SetMaxRecordings(). | ||
| 875 | /// | ||
| 876 | /// Can be set with here if on @ref SetMaxRecordings not given as second value. | ||
| 877 | void SetMaxRecordingsDefault(int maxRecordingsDefault) | ||
| 878 | { | ||
| 879 | m_cStructure->iMaxRecordingsDefault = maxRecordingsDefault; | ||
| 880 | } | ||
| 881 | |||
| 882 | /// @brief To get with @ref SetMaxRecordingsDefault changed values | ||
| 883 | int GetMaxRecordingsDefault() const { return m_cStructure->iMaxRecordingsDefault; } | ||
| 884 | ///@} | ||
| 885 | |||
| 886 | private: | ||
| 887 | PVRTimerType(const PVR_TIMER_TYPE* type) : CStructHdl(type) {} | ||
| 888 | PVRTimerType(PVR_TIMER_TYPE* type) : CStructHdl(type) {} | ||
| 889 | }; | ||
| 890 | ///@} | ||
| 891 | //------------------------------------------------------------------------------ | ||
| 892 | |||
| 893 | } /* namespace addon */ | ||
| 894 | } /* namespace kodi */ | ||
| 895 | |||
| 896 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/CMakeLists.txt new file mode 100644 index 0000000..d7b2269 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/CMakeLists.txt | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | set(HEADERS addon_base.h | ||
| 2 | audio_engine.h | ||
| 3 | filesystem.h | ||
| 4 | general.h | ||
| 5 | network.h) | ||
| 6 | |||
| 7 | if(NOT ENABLE_STATIC_LIBS) | ||
| 8 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_c-api) | ||
| 9 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt new file mode 100644 index 0000000..dfcfe66 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | set(HEADERS image_decoder.h | ||
| 2 | pvr.h) | ||
| 3 | |||
| 4 | if(NOT ENABLE_STATIC_LIBS) | ||
| 5 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_c-api_addon-instance) | ||
| 6 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h new file mode 100644 index 0000000..595a5dc --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h | |||
| @@ -0,0 +1,78 @@ | |||
| 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 "../addon_base.h" | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" | ||
| 15 | { | ||
| 16 | #endif /* __cplusplus */ | ||
| 17 | |||
| 18 | //============================================================================ | ||
| 19 | /// @ingroup cpp_kodi_addon_imagedecoder_Defs | ||
| 20 | /// @brief **Image format types**\n | ||
| 21 | /// Used to define wanted target format where image decoder should give to | ||
| 22 | /// Kodi. | ||
| 23 | /// | ||
| 24 | typedef enum ImageFormat | ||
| 25 | { | ||
| 26 | /// @brief A 32-bit ARGB pixel format, with alpha, that uses 8 bits per | ||
| 27 | /// channel, ARGBARGB... | ||
| 28 | ADDON_IMG_FMT_A8R8G8B8 = 1, | ||
| 29 | |||
| 30 | /// @brief A 8, alpha only, 8bpp, AAA... | ||
| 31 | ADDON_IMG_FMT_A8 = 2, | ||
| 32 | |||
| 33 | /// @brief RGBA 8:8:8:8, with alpha, 32bpp, RGBARGBA... | ||
| 34 | ADDON_IMG_FMT_RGBA8 = 3, | ||
| 35 | |||
| 36 | /// @brief RGB 8:8:8, with alpha, 24bpp, RGBRGB... | ||
| 37 | ADDON_IMG_FMT_RGB8 = 4 | ||
| 38 | } ImageFormat; | ||
| 39 | //---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | typedef struct AddonProps_ImageDecoder | ||
| 42 | { | ||
| 43 | const char* mimetype; | ||
| 44 | } AddonProps_ImageDecoder; | ||
| 45 | |||
| 46 | typedef struct AddonToKodiFuncTable_ImageDecoder | ||
| 47 | { | ||
| 48 | KODI_HANDLE kodi_instance; | ||
| 49 | } AddonToKodiFuncTable_ImageDecoder; | ||
| 50 | |||
| 51 | struct AddonInstance_ImageDecoder; | ||
| 52 | typedef struct KodiToAddonFuncTable_ImageDecoder | ||
| 53 | { | ||
| 54 | KODI_HANDLE addonInstance; | ||
| 55 | bool(__cdecl* load_image_from_memory)(const struct AddonInstance_ImageDecoder* instance, | ||
| 56 | unsigned char* buffer, | ||
| 57 | unsigned int buf_size, | ||
| 58 | unsigned int* width, | ||
| 59 | unsigned int* height); | ||
| 60 | |||
| 61 | bool(__cdecl* decode)(const struct AddonInstance_ImageDecoder* instance, | ||
| 62 | unsigned char* pixels, | ||
| 63 | unsigned int width, | ||
| 64 | unsigned int height, | ||
| 65 | unsigned int pitch, | ||
| 66 | enum ImageFormat format); | ||
| 67 | } KodiToAddonFuncTable_ImageDecoder; | ||
| 68 | |||
| 69 | typedef struct AddonInstance_ImageDecoder | ||
| 70 | { | ||
| 71 | struct AddonProps_ImageDecoder* props; | ||
| 72 | struct AddonToKodiFuncTable_ImageDecoder* toKodi; | ||
| 73 | struct KodiToAddonFuncTable_ImageDecoder* toAddon; | ||
| 74 | } AddonInstance_ImageDecoder; | ||
| 75 | |||
| 76 | #ifdef __cplusplus | ||
| 77 | } /* extern "C" */ | ||
| 78 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr.h new file mode 100644 index 0000000..2d255ad --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr.h | |||
| @@ -0,0 +1,327 @@ | |||
| 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 "pvr/pvr_channel_groups.h" | ||
| 13 | #include "pvr/pvr_channels.h" | ||
| 14 | #include "pvr/pvr_defines.h" | ||
| 15 | #include "pvr/pvr_edl.h" | ||
| 16 | #include "pvr/pvr_epg.h" | ||
| 17 | #include "pvr/pvr_general.h" | ||
| 18 | #include "pvr/pvr_menu_hook.h" | ||
| 19 | #include "pvr/pvr_recordings.h" | ||
| 20 | #include "pvr/pvr_stream.h" | ||
| 21 | #include "pvr/pvr_timers.h" | ||
| 22 | |||
| 23 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 24 | // "C" main interface function tables between Kodi and addon | ||
| 25 | // | ||
| 26 | // Values related to all parts and not used direct on addon, are to define here. | ||
| 27 | // | ||
| 28 | #ifdef __cplusplus | ||
| 29 | extern "C" | ||
| 30 | { | ||
| 31 | #endif /* __cplusplus */ | ||
| 32 | |||
| 33 | /*! | ||
| 34 | * @internal | ||
| 35 | * @brief PVR "C" basis API interface | ||
| 36 | * | ||
| 37 | * This field contains things that are exchanged between Kodi and Addon | ||
| 38 | * and is the basis of the PVR-side "C" API. | ||
| 39 | * | ||
| 40 | * @warning Care should be taken when making changes in this fields!\n | ||
| 41 | * Changes can destroy API in addons that have already been created. If a | ||
| 42 | * necessary change or new feature is added, the version of the PVR | ||
| 43 | * at @ref ADDON_INSTANCE_VERSION_PVR_MIN must be increased too.\n | ||
| 44 | * \n | ||
| 45 | * Conditional changes can be made in some places, without min PVR version | ||
| 46 | * increase. The add-on should then use CreateInstanceEx and add partial tests | ||
| 47 | * for this in the C++ header. | ||
| 48 | * | ||
| 49 | * Have by add of new parts a look about **Doxygen** `\\ingroup`, so that | ||
| 50 | * added parts included in documentation. | ||
| 51 | * | ||
| 52 | * If you add addon side related documentation, where his dev need know, | ||
| 53 | * use `///`. For parts only for Kodi make it like here. | ||
| 54 | * | ||
| 55 | * @endinternal | ||
| 56 | */ | ||
| 57 | |||
| 58 | struct AddonInstance_PVR; | ||
| 59 | |||
| 60 | /*! | ||
| 61 | * @brief Structure to define typical standard values | ||
| 62 | */ | ||
| 63 | typedef struct AddonProperties_PVR | ||
| 64 | { | ||
| 65 | const char* strUserPath; | ||
| 66 | const char* strClientPath; | ||
| 67 | int iEpgMaxDays; | ||
| 68 | } AddonProperties_PVR; | ||
| 69 | |||
| 70 | /*! | ||
| 71 | * @brief Structure to transfer the methods from Kodi to addon | ||
| 72 | */ | ||
| 73 | typedef struct AddonToKodiFuncTable_PVR | ||
| 74 | { | ||
| 75 | // Pointer inside Kodi where used from him to find his class | ||
| 76 | KODI_HANDLE kodiInstance; | ||
| 77 | |||
| 78 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 79 | // General callback functions | ||
| 80 | void (*AddMenuHook)(void* kodiInstance, const struct PVR_MENUHOOK* hook); | ||
| 81 | void (*RecordingNotification)(void* kodiInstance, | ||
| 82 | const char* name, | ||
| 83 | const char* fileName, | ||
| 84 | bool on); | ||
| 85 | void (*ConnectionStateChange)(void* kodiInstance, | ||
| 86 | const char* strConnectionString, | ||
| 87 | enum PVR_CONNECTION_STATE newState, | ||
| 88 | const char* strMessage); | ||
| 89 | void (*EpgEventStateChange)(void* kodiInstance, | ||
| 90 | struct EPG_TAG* tag, | ||
| 91 | enum EPG_EVENT_STATE newState); | ||
| 92 | |||
| 93 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 94 | // Transfer functions where give data back to Kodi, e.g. GetChannels calls TransferChannelEntry | ||
| 95 | void (*TransferChannelEntry)(void* kodiInstance, | ||
| 96 | const ADDON_HANDLE handle, | ||
| 97 | const struct PVR_CHANNEL* chan); | ||
| 98 | void (*TransferChannelGroup)(void* kodiInstance, | ||
| 99 | const ADDON_HANDLE handle, | ||
| 100 | const struct PVR_CHANNEL_GROUP* group); | ||
| 101 | void (*TransferChannelGroupMember)(void* kodiInstance, | ||
| 102 | const ADDON_HANDLE handle, | ||
| 103 | const struct PVR_CHANNEL_GROUP_MEMBER* member); | ||
| 104 | void (*TransferEpgEntry)(void* kodiInstance, | ||
| 105 | const ADDON_HANDLE handle, | ||
| 106 | const struct EPG_TAG* epgentry); | ||
| 107 | void (*TransferRecordingEntry)(void* kodiInstance, | ||
| 108 | const ADDON_HANDLE handle, | ||
| 109 | const struct PVR_RECORDING* recording); | ||
| 110 | void (*TransferTimerEntry)(void* kodiInstance, | ||
| 111 | const ADDON_HANDLE handle, | ||
| 112 | const struct PVR_TIMER* timer); | ||
| 113 | |||
| 114 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 115 | // Kodi inform interface functions | ||
| 116 | void (*TriggerChannelUpdate)(void* kodiInstance); | ||
| 117 | void (*TriggerChannelGroupsUpdate)(void* kodiInstance); | ||
| 118 | void (*TriggerEpgUpdate)(void* kodiInstance, unsigned int iChannelUid); | ||
| 119 | void (*TriggerRecordingUpdate)(void* kodiInstance); | ||
| 120 | void (*TriggerTimerUpdate)(void* kodiInstance); | ||
| 121 | |||
| 122 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 123 | // Stream demux interface functions | ||
| 124 | void (*FreeDemuxPacket)(void* kodiInstance, struct DemuxPacket* pPacket); | ||
| 125 | struct DemuxPacket* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize); | ||
| 126 | struct PVR_CODEC (*GetCodecByName)(const void* kodiInstance, const char* strCodecName); | ||
| 127 | |||
| 128 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 129 | // New functions becomes added below and can be on another API change (where | ||
| 130 | // breaks min API version) moved up. | ||
| 131 | } AddonToKodiFuncTable_PVR; | ||
| 132 | |||
| 133 | /*! | ||
| 134 | * @brief Structure to transfer the methods from addon to Kodi | ||
| 135 | */ | ||
| 136 | typedef struct KodiToAddonFuncTable_PVR | ||
| 137 | { | ||
| 138 | // Pointer inside addon where used on them to find his instance class (currently unused!) | ||
| 139 | KODI_HANDLE addonInstance; | ||
| 140 | |||
| 141 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 142 | // General interface functions | ||
| 143 | enum PVR_ERROR(__cdecl* GetCapabilities)(const struct AddonInstance_PVR*, | ||
| 144 | struct PVR_ADDON_CAPABILITIES*); | ||
| 145 | enum PVR_ERROR(__cdecl* GetBackendName)(const struct AddonInstance_PVR*, char*, int); | ||
| 146 | enum PVR_ERROR(__cdecl* GetBackendVersion)(const struct AddonInstance_PVR*, char*, int); | ||
| 147 | enum PVR_ERROR(__cdecl* GetBackendHostname)(const struct AddonInstance_PVR*, char*, int); | ||
| 148 | enum PVR_ERROR(__cdecl* GetConnectionString)(const struct AddonInstance_PVR*, char*, int); | ||
| 149 | enum PVR_ERROR(__cdecl* GetDriveSpace)(const struct AddonInstance_PVR*, uint64_t*, uint64_t*); | ||
| 150 | enum PVR_ERROR(__cdecl* CallSettingsMenuHook)(const struct AddonInstance_PVR*, | ||
| 151 | const struct PVR_MENUHOOK*); | ||
| 152 | |||
| 153 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 154 | // Channel interface functions | ||
| 155 | |||
| 156 | enum PVR_ERROR(__cdecl* GetChannelsAmount)(const struct AddonInstance_PVR*, int*); | ||
| 157 | enum PVR_ERROR(__cdecl* GetChannels)(const struct AddonInstance_PVR*, ADDON_HANDLE, bool); | ||
| 158 | enum PVR_ERROR(__cdecl* GetChannelStreamProperties)(const struct AddonInstance_PVR*, | ||
| 159 | const struct PVR_CHANNEL*, | ||
| 160 | struct PVR_NAMED_VALUE*, | ||
| 161 | unsigned int*); | ||
| 162 | enum PVR_ERROR(__cdecl* GetSignalStatus)(const struct AddonInstance_PVR*, | ||
| 163 | int, | ||
| 164 | struct PVR_SIGNAL_STATUS*); | ||
| 165 | enum PVR_ERROR(__cdecl* GetDescrambleInfo)(const struct AddonInstance_PVR*, | ||
| 166 | int, | ||
| 167 | struct PVR_DESCRAMBLE_INFO*); | ||
| 168 | |||
| 169 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 170 | // Channel group interface functions | ||
| 171 | enum PVR_ERROR(__cdecl* GetChannelGroupsAmount)(const struct AddonInstance_PVR*, int*); | ||
| 172 | enum PVR_ERROR(__cdecl* GetChannelGroups)(const struct AddonInstance_PVR*, ADDON_HANDLE, bool); | ||
| 173 | enum PVR_ERROR(__cdecl* GetChannelGroupMembers)(const struct AddonInstance_PVR*, | ||
| 174 | ADDON_HANDLE, | ||
| 175 | const struct PVR_CHANNEL_GROUP*); | ||
| 176 | |||
| 177 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 178 | // Channel edit interface functions | ||
| 179 | enum PVR_ERROR(__cdecl* DeleteChannel)(const struct AddonInstance_PVR*, | ||
| 180 | const struct PVR_CHANNEL*); | ||
| 181 | enum PVR_ERROR(__cdecl* RenameChannel)(const struct AddonInstance_PVR*, | ||
| 182 | const struct PVR_CHANNEL*); | ||
| 183 | enum PVR_ERROR(__cdecl* OpenDialogChannelSettings)(const struct AddonInstance_PVR*, | ||
| 184 | const struct PVR_CHANNEL*); | ||
| 185 | enum PVR_ERROR(__cdecl* OpenDialogChannelAdd)(const struct AddonInstance_PVR*, | ||
| 186 | const struct PVR_CHANNEL*); | ||
| 187 | enum PVR_ERROR(__cdecl* OpenDialogChannelScan)(const struct AddonInstance_PVR*); | ||
| 188 | enum PVR_ERROR(__cdecl* CallChannelMenuHook)(const struct AddonInstance_PVR*, | ||
| 189 | const PVR_MENUHOOK*, | ||
| 190 | const PVR_CHANNEL*); | ||
| 191 | |||
| 192 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 193 | // EPG interface functions | ||
| 194 | enum PVR_ERROR(__cdecl* GetEPGForChannel)( | ||
| 195 | const struct AddonInstance_PVR*, ADDON_HANDLE, int, time_t, time_t); | ||
| 196 | enum PVR_ERROR(__cdecl* IsEPGTagRecordable)(const struct AddonInstance_PVR*, | ||
| 197 | const struct EPG_TAG*, | ||
| 198 | bool*); | ||
| 199 | enum PVR_ERROR(__cdecl* IsEPGTagPlayable)(const struct AddonInstance_PVR*, | ||
| 200 | const struct EPG_TAG*, | ||
| 201 | bool*); | ||
| 202 | enum PVR_ERROR(__cdecl* GetEPGTagEdl)(const struct AddonInstance_PVR*, | ||
| 203 | const struct EPG_TAG*, | ||
| 204 | struct PVR_EDL_ENTRY[], | ||
| 205 | int*); | ||
| 206 | enum PVR_ERROR(__cdecl* GetEPGTagStreamProperties)(const struct AddonInstance_PVR*, | ||
| 207 | const struct EPG_TAG*, | ||
| 208 | struct PVR_NAMED_VALUE*, | ||
| 209 | unsigned int*); | ||
| 210 | enum PVR_ERROR(__cdecl* SetEPGTimeFrame)(const struct AddonInstance_PVR*, int); | ||
| 211 | enum PVR_ERROR(__cdecl* CallEPGMenuHook)(const struct AddonInstance_PVR*, | ||
| 212 | const struct PVR_MENUHOOK*, | ||
| 213 | const struct EPG_TAG*); | ||
| 214 | |||
| 215 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 216 | // Recording interface functions | ||
| 217 | enum PVR_ERROR(__cdecl* GetRecordingsAmount)(const struct AddonInstance_PVR*, bool, int*); | ||
| 218 | enum PVR_ERROR(__cdecl* GetRecordings)(const struct AddonInstance_PVR*, ADDON_HANDLE, bool); | ||
| 219 | enum PVR_ERROR(__cdecl* DeleteRecording)(const struct AddonInstance_PVR*, | ||
| 220 | const struct PVR_RECORDING*); | ||
| 221 | enum PVR_ERROR(__cdecl* UndeleteRecording)(const struct AddonInstance_PVR*, | ||
| 222 | const struct PVR_RECORDING*); | ||
| 223 | enum PVR_ERROR(__cdecl* DeleteAllRecordingsFromTrash)(const struct AddonInstance_PVR*); | ||
| 224 | enum PVR_ERROR(__cdecl* RenameRecording)(const struct AddonInstance_PVR*, | ||
| 225 | const struct PVR_RECORDING*); | ||
| 226 | enum PVR_ERROR(__cdecl* SetRecordingLifetime)(const struct AddonInstance_PVR*, | ||
| 227 | const struct PVR_RECORDING*); | ||
| 228 | enum PVR_ERROR(__cdecl* SetRecordingPlayCount)(const struct AddonInstance_PVR*, | ||
| 229 | const struct PVR_RECORDING*, | ||
| 230 | int); | ||
| 231 | enum PVR_ERROR(__cdecl* SetRecordingLastPlayedPosition)(const struct AddonInstance_PVR*, | ||
| 232 | const struct PVR_RECORDING*, | ||
| 233 | int); | ||
| 234 | enum PVR_ERROR(__cdecl* GetRecordingLastPlayedPosition)(const struct AddonInstance_PVR*, | ||
| 235 | const struct PVR_RECORDING*, | ||
| 236 | int*); | ||
| 237 | enum PVR_ERROR(__cdecl* GetRecordingEdl)(const struct AddonInstance_PVR*, | ||
| 238 | const struct PVR_RECORDING*, | ||
| 239 | struct PVR_EDL_ENTRY[], | ||
| 240 | int*); | ||
| 241 | enum PVR_ERROR(__cdecl* GetRecordingSize)(const struct AddonInstance_PVR*, | ||
| 242 | const PVR_RECORDING*, | ||
| 243 | int64_t*); | ||
| 244 | enum PVR_ERROR(__cdecl* GetRecordingStreamProperties)(const struct AddonInstance_PVR*, | ||
| 245 | const struct PVR_RECORDING*, | ||
| 246 | struct PVR_NAMED_VALUE*, | ||
| 247 | unsigned int*); | ||
| 248 | enum PVR_ERROR(__cdecl* CallRecordingMenuHook)(const struct AddonInstance_PVR*, | ||
| 249 | const struct PVR_MENUHOOK*, | ||
| 250 | const struct PVR_RECORDING*); | ||
| 251 | |||
| 252 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 253 | // Timer interface functions | ||
| 254 | enum PVR_ERROR(__cdecl* GetTimerTypes)(const struct AddonInstance_PVR*, | ||
| 255 | struct PVR_TIMER_TYPE[], | ||
| 256 | int*); | ||
| 257 | enum PVR_ERROR(__cdecl* GetTimersAmount)(const struct AddonInstance_PVR*, int*); | ||
| 258 | enum PVR_ERROR(__cdecl* GetTimers)(const struct AddonInstance_PVR*, ADDON_HANDLE); | ||
| 259 | enum PVR_ERROR(__cdecl* AddTimer)(const struct AddonInstance_PVR*, const struct PVR_TIMER*); | ||
| 260 | enum PVR_ERROR(__cdecl* DeleteTimer)(const struct AddonInstance_PVR*, | ||
| 261 | const struct PVR_TIMER*, | ||
| 262 | bool); | ||
| 263 | enum PVR_ERROR(__cdecl* UpdateTimer)(const struct AddonInstance_PVR*, const struct PVR_TIMER*); | ||
| 264 | enum PVR_ERROR(__cdecl* CallTimerMenuHook)(const struct AddonInstance_PVR*, | ||
| 265 | const struct PVR_MENUHOOK*, | ||
| 266 | const struct PVR_TIMER*); | ||
| 267 | |||
| 268 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 269 | // Powersaving interface functions | ||
| 270 | enum PVR_ERROR(__cdecl* OnSystemSleep)(const struct AddonInstance_PVR*); | ||
| 271 | enum PVR_ERROR(__cdecl* OnSystemWake)(const struct AddonInstance_PVR*); | ||
| 272 | enum PVR_ERROR(__cdecl* OnPowerSavingActivated)(const struct AddonInstance_PVR*); | ||
| 273 | enum PVR_ERROR(__cdecl* OnPowerSavingDeactivated)(const struct AddonInstance_PVR*); | ||
| 274 | |||
| 275 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 276 | // Live stream read interface functions | ||
| 277 | bool(__cdecl* OpenLiveStream)(const struct AddonInstance_PVR*, const struct PVR_CHANNEL*); | ||
| 278 | void(__cdecl* CloseLiveStream)(const struct AddonInstance_PVR*); | ||
| 279 | int(__cdecl* ReadLiveStream)(const struct AddonInstance_PVR*, unsigned char*, unsigned int); | ||
| 280 | int64_t(__cdecl* SeekLiveStream)(const struct AddonInstance_PVR*, int64_t, int); | ||
| 281 | int64_t(__cdecl* LengthLiveStream)(const struct AddonInstance_PVR*); | ||
| 282 | |||
| 283 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 284 | // Recording stream read interface functions | ||
| 285 | bool(__cdecl* OpenRecordedStream)(const struct AddonInstance_PVR*, const struct PVR_RECORDING*); | ||
| 286 | void(__cdecl* CloseRecordedStream)(const struct AddonInstance_PVR*); | ||
| 287 | int(__cdecl* ReadRecordedStream)(const struct AddonInstance_PVR*, unsigned char*, unsigned int); | ||
| 288 | int64_t(__cdecl* SeekRecordedStream)(const struct AddonInstance_PVR*, int64_t, int); | ||
| 289 | int64_t(__cdecl* LengthRecordedStream)(const struct AddonInstance_PVR*); | ||
| 290 | |||
| 291 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 292 | // Stream demux interface functions | ||
| 293 | enum PVR_ERROR(__cdecl* GetStreamProperties)(const struct AddonInstance_PVR*, | ||
| 294 | struct PVR_STREAM_PROPERTIES*); | ||
| 295 | struct DemuxPacket*(__cdecl* DemuxRead)(const struct AddonInstance_PVR*); | ||
| 296 | void(__cdecl* DemuxReset)(const struct AddonInstance_PVR*); | ||
| 297 | void(__cdecl* DemuxAbort)(const struct AddonInstance_PVR*); | ||
| 298 | void(__cdecl* DemuxFlush)(const struct AddonInstance_PVR*); | ||
| 299 | void(__cdecl* SetSpeed)(const struct AddonInstance_PVR*, int); | ||
| 300 | void(__cdecl* FillBuffer)(const struct AddonInstance_PVR*, bool); | ||
| 301 | bool(__cdecl* SeekTime)(const struct AddonInstance_PVR*, double, bool, double*); | ||
| 302 | |||
| 303 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 304 | // General stream interface functions | ||
| 305 | bool(__cdecl* CanPauseStream)(const struct AddonInstance_PVR*); | ||
| 306 | void(__cdecl* PauseStream)(const struct AddonInstance_PVR*, bool); | ||
| 307 | bool(__cdecl* CanSeekStream)(const struct AddonInstance_PVR*); | ||
| 308 | bool(__cdecl* IsRealTimeStream)(const struct AddonInstance_PVR*); | ||
| 309 | enum PVR_ERROR(__cdecl* GetStreamTimes)(const struct AddonInstance_PVR*, | ||
| 310 | struct PVR_STREAM_TIMES*); | ||
| 311 | enum PVR_ERROR(__cdecl* GetStreamReadChunkSize)(const struct AddonInstance_PVR*, int*); | ||
| 312 | |||
| 313 | //--==----==----==----==----==----==----==----==----==----==----==----==----== | ||
| 314 | // New functions becomes added below and can be on another API change (where | ||
| 315 | // breaks min API version) moved up. | ||
| 316 | } KodiToAddonFuncTable_PVR; | ||
| 317 | |||
| 318 | typedef struct AddonInstance_PVR | ||
| 319 | { | ||
| 320 | struct AddonProperties_PVR* props; | ||
| 321 | struct AddonToKodiFuncTable_PVR* toKodi; | ||
| 322 | struct KodiToAddonFuncTable_PVR* toAddon; | ||
| 323 | } AddonInstance_PVR; | ||
| 324 | |||
| 325 | #ifdef __cplusplus | ||
| 326 | } | ||
| 327 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt new file mode 100644 index 0000000..6617084 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | set(HEADERS pvr_channel_groups.h | ||
| 2 | pvr_channels.h | ||
| 3 | pvr_defines.h | ||
| 4 | pvr_edl.h | ||
| 5 | pvr_epg.h | ||
| 6 | pvr_general.h | ||
| 7 | pvr_menu_hook.h | ||
| 8 | pvr_recordings.h | ||
| 9 | pvr_stream.h | ||
| 10 | pvr_timers.h) | ||
| 11 | |||
| 12 | if(NOT ENABLE_STATIC_LIBS) | ||
| 13 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_c-api_addon-instance_pvr) | ||
| 14 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h new file mode 100644 index 0000000..36f9ed6 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h | |||
| @@ -0,0 +1,54 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #include <stdbool.h> | ||
| 14 | |||
| 15 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 16 | // "C" Definitions group 3 - PVR channel group | ||
| 17 | #ifdef __cplusplus | ||
| 18 | extern "C" | ||
| 19 | { | ||
| 20 | #endif /* __cplusplus */ | ||
| 21 | |||
| 22 | /*! | ||
| 23 | * @brief "C" PVR add-on channel group. | ||
| 24 | * | ||
| 25 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 26 | * | ||
| 27 | * See @ref kodi::addon::PVRChannelGroup for description of values. | ||
| 28 | */ | ||
| 29 | typedef struct PVR_CHANNEL_GROUP | ||
| 30 | { | ||
| 31 | char strGroupName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 32 | bool bIsRadio; | ||
| 33 | unsigned int iPosition; | ||
| 34 | } PVR_CHANNEL_GROUP; | ||
| 35 | |||
| 36 | /*! | ||
| 37 | * @brief "C" PVR add-on channel group member. | ||
| 38 | * | ||
| 39 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 40 | * | ||
| 41 | * See @ref kodi::addon::PVRChannelGroupMember for description of values. | ||
| 42 | */ | ||
| 43 | typedef struct PVR_CHANNEL_GROUP_MEMBER | ||
| 44 | { | ||
| 45 | char strGroupName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 46 | unsigned int iChannelUniqueId; | ||
| 47 | unsigned int iChannelNumber; | ||
| 48 | unsigned int iSubChannelNumber; | ||
| 49 | int iOrder; | ||
| 50 | } PVR_CHANNEL_GROUP_MEMBER; | ||
| 51 | |||
| 52 | #ifdef __cplusplus | ||
| 53 | } | ||
| 54 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h new file mode 100644 index 0000000..a2ce591 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h | |||
| @@ -0,0 +1,104 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #include <stdbool.h> | ||
| 14 | |||
| 15 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 16 | // "C" Definitions group 2 - PVR channel | ||
| 17 | #ifdef __cplusplus | ||
| 18 | extern "C" | ||
| 19 | { | ||
| 20 | #endif /* __cplusplus */ | ||
| 21 | |||
| 22 | //============================================================================ | ||
| 23 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel | ||
| 24 | /// @brief Denotes that no channel uid is available. | ||
| 25 | /// | ||
| 26 | /// Special @ref kodi::addon::PVRTimer::SetClientChannelUid() and | ||
| 27 | /// @ref kodi::addon::PVRRecording::SetChannelUid() value to indicate that no | ||
| 28 | /// channel uid is available. | ||
| 29 | #define PVR_CHANNEL_INVALID_UID -1 | ||
| 30 | //---------------------------------------------------------------------------- | ||
| 31 | |||
| 32 | /*! | ||
| 33 | * @brief "C" PVR add-on channel. | ||
| 34 | * | ||
| 35 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 36 | * | ||
| 37 | * See @ref kodi::addon::PVRChannel for description of values. | ||
| 38 | */ | ||
| 39 | typedef struct PVR_CHANNEL | ||
| 40 | { | ||
| 41 | unsigned int iUniqueId; | ||
| 42 | bool bIsRadio; | ||
| 43 | unsigned int iChannelNumber; | ||
| 44 | unsigned int iSubChannelNumber; | ||
| 45 | char strChannelName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 46 | char strMimeType[PVR_ADDON_INPUT_FORMAT_STRING_LENGTH]; | ||
| 47 | unsigned int iEncryptionSystem; | ||
| 48 | char strIconPath[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 49 | bool bIsHidden; | ||
| 50 | bool bHasArchive; | ||
| 51 | int iOrder; | ||
| 52 | } PVR_CHANNEL; | ||
| 53 | |||
| 54 | /*! | ||
| 55 | * @brief "C" PVR add-on signal status information. | ||
| 56 | * | ||
| 57 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 58 | * | ||
| 59 | * See @ref kodi::addon::PVRSignalStatus for description of values. | ||
| 60 | */ | ||
| 61 | typedef struct PVR_SIGNAL_STATUS | ||
| 62 | { | ||
| 63 | char strAdapterName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 64 | char strAdapterStatus[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 65 | char strServiceName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 66 | char strProviderName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 67 | char strMuxName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 68 | int iSNR; | ||
| 69 | int iSignal; | ||
| 70 | long iBER; | ||
| 71 | long iUNC; | ||
| 72 | } PVR_SIGNAL_STATUS; | ||
| 73 | |||
| 74 | //============================================================================ | ||
| 75 | /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo | ||
| 76 | /// @brief Special @ref cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo | ||
| 77 | /// value to indicate that a struct member's value is not available | ||
| 78 | /// | ||
| 79 | #define PVR_DESCRAMBLE_INFO_NOT_AVAILABLE -1 | ||
| 80 | //---------------------------------------------------------------------------- | ||
| 81 | |||
| 82 | /*! | ||
| 83 | * @brief "C" PVR add-on descramble information. | ||
| 84 | * | ||
| 85 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 86 | * | ||
| 87 | * See @ref kodi::addon::PVRDescrambleInfo for description of values. | ||
| 88 | */ | ||
| 89 | typedef struct PVR_DESCRAMBLE_INFO | ||
| 90 | { | ||
| 91 | int iPid; | ||
| 92 | int iCaid; | ||
| 93 | int iProvid; | ||
| 94 | int iEcmTime; | ||
| 95 | int iHops; | ||
| 96 | char strCardSystem[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; | ||
| 97 | char strReader[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; | ||
| 98 | char strFrom[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; | ||
| 99 | char strProtocol[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; | ||
| 100 | } PVR_DESCRAMBLE_INFO; | ||
| 101 | |||
| 102 | #ifdef __cplusplus | ||
| 103 | } | ||
| 104 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h new file mode 100644 index 0000000..af1daae --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h | |||
| @@ -0,0 +1,61 @@ | |||
| 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 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 12 | // "C" Standard PVR definitions | ||
| 13 | // | ||
| 14 | // Values related to all parts and not used direct on addon, are to define here. | ||
| 15 | // | ||
| 16 | #ifdef __cplusplus | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | #endif /* __cplusplus */ | ||
| 20 | |||
| 21 | /*! | ||
| 22 | * @brief API array sizes which are used for data exchange between | ||
| 23 | * Kodi and addon. | ||
| 24 | */ | ||
| 25 | ///@{ | ||
| 26 | #define PVR_ADDON_NAME_STRING_LENGTH 1024 | ||
| 27 | #define PVR_ADDON_URL_STRING_LENGTH 1024 | ||
| 28 | #define PVR_ADDON_DESC_STRING_LENGTH 1024 | ||
| 29 | #define PVR_ADDON_INPUT_FORMAT_STRING_LENGTH 32 | ||
| 30 | #define PVR_ADDON_EDL_LENGTH 32 | ||
| 31 | #define PVR_ADDON_TIMERTYPE_ARRAY_SIZE 32 | ||
| 32 | #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE 512 | ||
| 33 | #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL 128 | ||
| 34 | #define PVR_ADDON_TIMERTYPE_STRING_LENGTH 128 | ||
| 35 | #define PVR_ADDON_ATTRIBUTE_DESC_LENGTH 128 | ||
| 36 | #define PVR_ADDON_ATTRIBUTE_VALUES_ARRAY_SIZE 512 | ||
| 37 | #define PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH 64 | ||
| 38 | #define PVR_ADDON_DATE_STRING_LENGTH 32 | ||
| 39 | ///@} | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * @brief "C" Representation of a general attribute integer value. | ||
| 43 | */ | ||
| 44 | typedef struct PVR_ATTRIBUTE_INT_VALUE | ||
| 45 | { | ||
| 46 | int iValue; | ||
| 47 | char strDescription[PVR_ADDON_ATTRIBUTE_DESC_LENGTH]; | ||
| 48 | } PVR_ATTRIBUTE_INT_VALUE; | ||
| 49 | |||
| 50 | /*! | ||
| 51 | * @brief "C" Representation of a named value. | ||
| 52 | */ | ||
| 53 | typedef struct PVR_NAMED_VALUE | ||
| 54 | { | ||
| 55 | char strName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 56 | char strValue[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 57 | } PVR_NAMED_VALUE; | ||
| 58 | |||
| 59 | #ifdef __cplusplus | ||
| 60 | } | ||
| 61 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h new file mode 100644 index 0000000..8378eaf --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h | |||
| @@ -0,0 +1,62 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #include <stdint.h> | ||
| 14 | |||
| 15 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 16 | // "C" Definitions group 8 - PVR Edit definition list (EDL) | ||
| 17 | #ifdef __cplusplus | ||
| 18 | extern "C" | ||
| 19 | { | ||
| 20 | #endif /* __cplusplus */ | ||
| 21 | |||
| 22 | //============================================================================ | ||
| 23 | /// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVR_EDL_TYPE enum PVR_EDL_TYPE | ||
| 24 | /// @ingroup cpp_kodi_addon_pvr_Defs_EDLEntry | ||
| 25 | /// @brief **Edit definition list types**\n | ||
| 26 | /// Possible type values for @ref cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry. | ||
| 27 | /// | ||
| 28 | ///@{ | ||
| 29 | typedef enum PVR_EDL_TYPE | ||
| 30 | { | ||
| 31 | /// @brief __0__ : cut (completely remove content) | ||
| 32 | PVR_EDL_TYPE_CUT = 0, | ||
| 33 | |||
| 34 | /// @brief __1__ : mute audio | ||
| 35 | PVR_EDL_TYPE_MUTE = 1, | ||
| 36 | |||
| 37 | /// @brief __2__ : scene markers (chapter seeking) | ||
| 38 | PVR_EDL_TYPE_SCENE = 2, | ||
| 39 | |||
| 40 | /// @brief __3__ : commercial breaks | ||
| 41 | PVR_EDL_TYPE_COMBREAK = 3 | ||
| 42 | } PVR_EDL_TYPE; | ||
| 43 | ///@} | ||
| 44 | //---------------------------------------------------------------------------- | ||
| 45 | |||
| 46 | /*! | ||
| 47 | * @brief "C" Edit definition list entry. | ||
| 48 | * | ||
| 49 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 50 | * | ||
| 51 | * See @ref kodi::addon::PVREDLEntry for description of values. | ||
| 52 | */ | ||
| 53 | typedef struct PVR_EDL_ENTRY | ||
| 54 | { | ||
| 55 | int64_t start; | ||
| 56 | int64_t end; | ||
| 57 | enum PVR_EDL_TYPE type; | ||
| 58 | } PVR_EDL_ENTRY; | ||
| 59 | |||
| 60 | #ifdef __cplusplus | ||
| 61 | } | ||
| 62 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h new file mode 100644 index 0000000..57c603f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h | |||
| @@ -0,0 +1,653 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #include <time.h> | ||
| 14 | |||
| 15 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 16 | // "C" Definitions group 4 - PVR EPG | ||
| 17 | #ifdef __cplusplus | ||
| 18 | extern "C" | ||
| 19 | { | ||
| 20 | #endif /* __cplusplus */ | ||
| 21 | |||
| 22 | //============================================================================ | ||
| 23 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT enum EPG_EVENT_CONTENTMASK (and sub types) | ||
| 24 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 25 | /// @brief **EPG entry content event types.**\n | ||
| 26 | /// These ID's come from the DVB-SI EIT table "content descriptor" | ||
| 27 | /// Also known under the name "E-book genre assignments". | ||
| 28 | /// | ||
| 29 | /// See [ETSI EN 300 468 V1.14.1 (2014-05)](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 30 | /// about. | ||
| 31 | /// | ||
| 32 | /// Values used by this functions: | ||
| 33 | /// - @ref kodi::addon::PVREPGTag::SetGenreType() | ||
| 34 | /// - @ref kodi::addon::PVREPGTag::SetGenreSubType() | ||
| 35 | /// - @ref kodi::addon::PVRRecording::SetGenreType() | ||
| 36 | /// - @ref kodi::addon::PVRRecording::SetGenreSubType() | ||
| 37 | /// | ||
| 38 | /// Following types are listed here: | ||
| 39 | /// | emum Type | Description | ||
| 40 | /// |-----------|-------------------- | ||
| 41 | /// | @ref EPG_EVENT_CONTENTMASK | EPG entry main content to use. | ||
| 42 | /// | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA event types for sub type of <b>"Movie/Drama"</b>. | ||
| 43 | /// | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS event types for sub type of <b>"News/Current affairs"</b>. | ||
| 44 | /// | @ref EPG_EVENT_CONTENTSUBMASK_SHOW | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SHOW event types for sub type of <b>"Show/Game show"</b>. | ||
| 45 | /// | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS | @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPORTS event types for sub type of <b>"Sports"</b>. | ||
| 46 | /// | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH event types for sub type of <b>"Children's/Youth programmes"</b>. | ||
| 47 | /// | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE event types for sub type of <b>"Music/Ballet/Dance"</b>. | ||
| 48 | /// | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE event types for sub type of <b>"Arts/Culture (without music)"</b>. | ||
| 49 | /// | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS event types for sub type of <b>"Social/Political issues/Economics"</b>. | ||
| 50 | /// | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE event types for sub type of <b>"Education/Science/Factual topics"</b>. | ||
| 51 | /// | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES event types for sub type of <b>"Leisure hobbies"</b>. | ||
| 52 | /// | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPECIAL event types for sub type of <b>"Special characteristics"</b>. | ||
| 53 | ///@{ | ||
| 54 | |||
| 55 | //============================================================================ | ||
| 56 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 57 | /// @brief EPG entry main content to use. | ||
| 58 | /// | ||
| 59 | ///@{ | ||
| 60 | typedef enum EPG_EVENT_CONTENTMASK | ||
| 61 | { | ||
| 62 | /// @brief __0x00__ : Undefined content mask entry. | ||
| 63 | EPG_EVENT_CONTENTMASK_UNDEFINED = 0x00, | ||
| 64 | |||
| 65 | /// @brief __0x10__ : Movie/Drama.\n | ||
| 66 | /// \n | ||
| 67 | /// See @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA about related sub types. | ||
| 68 | EPG_EVENT_CONTENTMASK_MOVIEDRAMA = 0x10, | ||
| 69 | |||
| 70 | /// @brief __0x20__ : News/Current affairs.\n | ||
| 71 | /// \n | ||
| 72 | /// See @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS about related sub types. | ||
| 73 | EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS = 0x20, | ||
| 74 | |||
| 75 | /// @brief __0x30__ : Show/Game show.\n | ||
| 76 | /// \n | ||
| 77 | /// See @ref EPG_EVENT_CONTENTSUBMASK_SHOW about related sub types. | ||
| 78 | EPG_EVENT_CONTENTMASK_SHOW = 0x30, | ||
| 79 | |||
| 80 | /// @brief __0x40__ : Sports.\n | ||
| 81 | /// \n | ||
| 82 | /// See @ref EPG_EVENT_CONTENTSUBMASK_SPORTS about related sub types. | ||
| 83 | EPG_EVENT_CONTENTMASK_SPORTS = 0x40, | ||
| 84 | |||
| 85 | /// @brief __0x50__ : Children's/Youth programmes.\n | ||
| 86 | /// \n | ||
| 87 | /// See @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH about related sub types. | ||
| 88 | EPG_EVENT_CONTENTMASK_CHILDRENYOUTH = 0x50, | ||
| 89 | |||
| 90 | /// @brief __0x60__ : Music/Ballet/Dance.\n | ||
| 91 | /// \n | ||
| 92 | /// See @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE about related sub types. | ||
| 93 | EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE = 0x60, | ||
| 94 | |||
| 95 | /// @brief __0x70__ : Arts/Culture (without music).\n | ||
| 96 | /// \n | ||
| 97 | /// See @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE about related sub types. | ||
| 98 | EPG_EVENT_CONTENTMASK_ARTSCULTURE = 0x70, | ||
| 99 | |||
| 100 | /// @brief __0x80__ : Social/Political issues/Economics.\n | ||
| 101 | /// \n | ||
| 102 | /// See @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS about related sub types. | ||
| 103 | EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS = 0x80, | ||
| 104 | |||
| 105 | /// @brief __0x90__ : Education/Science/Factual topics.\n | ||
| 106 | /// \n | ||
| 107 | /// See @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE about related sub types. | ||
| 108 | EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE = 0x90, | ||
| 109 | |||
| 110 | /// @brief __0xA0__ : Leisure hobbies.\n | ||
| 111 | /// \n | ||
| 112 | /// See @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES about related sub types. | ||
| 113 | EPG_EVENT_CONTENTMASK_LEISUREHOBBIES = 0xA0, | ||
| 114 | |||
| 115 | /// @brief __0xB0__ : Special characteristics.\n | ||
| 116 | /// \n | ||
| 117 | /// See @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL about related sub types. | ||
| 118 | EPG_EVENT_CONTENTMASK_SPECIAL = 0xB0, | ||
| 119 | |||
| 120 | /// @brief __0xF0__ User defined. | ||
| 121 | EPG_EVENT_CONTENTMASK_USERDEFINED = 0xF0, | ||
| 122 | |||
| 123 | /// @brief Used to override standard genre types with a own name about.\n | ||
| 124 | /// \n | ||
| 125 | /// Set to this value @ref EPG_GENRE_USE_STRING on following places: | ||
| 126 | /// - @ref kodi::addon::PVREPGTag::SetGenreType() | ||
| 127 | /// - @ref kodi::addon::PVREPGTag::SetGenreSubType() | ||
| 128 | /// - @ref kodi::addon::PVRRecording::SetGenreType() | ||
| 129 | /// - @ref kodi::addon::PVRRecording::SetGenreSubType() | ||
| 130 | /// | ||
| 131 | /// @warning Value here is not a [ETSI EN 300 468 V1.14.1 (2014-05)](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf) | ||
| 132 | /// conform. | ||
| 133 | /// | ||
| 134 | /// @note This is a own Kodi definition to set that genre is given by own | ||
| 135 | /// string. Used on @ref kodi::addon::PVREPGTag::SetGenreDescription() and | ||
| 136 | /// @ref kodi::addon::PVRRecording::SetGenreDescription() | ||
| 137 | EPG_GENRE_USE_STRING = 0x100 | ||
| 138 | } EPG_EVENT_CONTENTMASK; | ||
| 139 | ///@} | ||
| 140 | //---------------------------------------------------------------------------- | ||
| 141 | |||
| 142 | //============================================================================ | ||
| 143 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 144 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA event | ||
| 145 | /// types for sub type of <b>"Movie/Drama"</b>. | ||
| 146 | /// | ||
| 147 | ///@{ | ||
| 148 | typedef enum EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA | ||
| 149 | { | ||
| 150 | /// @brief __0x0__ : Movie/drama (general). | ||
| 151 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_GENERAL = 0x0, | ||
| 152 | |||
| 153 | /// @brief __0x1__ : Detective/thriller. | ||
| 154 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_DETECTIVE_THRILLER = 0x1, | ||
| 155 | |||
| 156 | /// @brief __0x2__ : Adventure/western/war. | ||
| 157 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_ADVENTURE_WESTERN_WAR = 0x2, | ||
| 158 | |||
| 159 | /// @brief __0x3__ : Science fiction/fantasy/horror. | ||
| 160 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_SCIENCEFICTION_FANTASY_HORROR = 0x3, | ||
| 161 | |||
| 162 | /// @brief __0x4__ : Comedy. | ||
| 163 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_COMEDY = 0x4, | ||
| 164 | |||
| 165 | /// @brief __0x5__ : Soap/melodrama/folkloric. | ||
| 166 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_SOAP_MELODRAMA_FOLKLORIC = 0x5, | ||
| 167 | |||
| 168 | /// @brief __0x6__ : Romance. | ||
| 169 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_ROMANCE = 0x6, | ||
| 170 | |||
| 171 | /// @brief __0x7__ : Serious/classical/religious/historical movie/drama. | ||
| 172 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_SERIOUS_CLASSICAL_RELIGIOUS_HISTORICAL = 0x7, | ||
| 173 | |||
| 174 | /// @brief __0x8__ : Adult movie/drama. | ||
| 175 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_ADULT = 0x8, | ||
| 176 | |||
| 177 | /// @brief __0xF__ : User defined. | ||
| 178 | EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_USERDEFINED = 0xF | ||
| 179 | } EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA; | ||
| 180 | ///@} | ||
| 181 | //---------------------------------------------------------------------------- | ||
| 182 | |||
| 183 | //============================================================================ | ||
| 184 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 185 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS event | ||
| 186 | /// types for sub type of <b>"News/Current affairs"</b>. | ||
| 187 | /// | ||
| 188 | typedef enum EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS | ||
| 189 | { | ||
| 190 | /// @brief __0x0__ : News/current affairs (general). | ||
| 191 | EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_GENERAL = 0x0, | ||
| 192 | |||
| 193 | /// @brief __0x1__ : News/weather report. | ||
| 194 | EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_WEATHER = 0x1, | ||
| 195 | |||
| 196 | /// @brief __0x2__ : News magazine. | ||
| 197 | EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_MAGAZINE = 0x2, | ||
| 198 | |||
| 199 | /// @brief __0x3__ : Documentary. | ||
| 200 | EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_DOCUMENTARY = 0x3, | ||
| 201 | |||
| 202 | /// @brief __0x4__ : Discussion/interview/debate | ||
| 203 | EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_DISCUSSION_INTERVIEW_DEBATE = 0x4, | ||
| 204 | |||
| 205 | /// @brief __0xF__ : User defined. | ||
| 206 | EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_USERDEFINED = 0xF | ||
| 207 | } EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS; | ||
| 208 | //---------------------------------------------------------------------------- | ||
| 209 | |||
| 210 | //============================================================================ | ||
| 211 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 212 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SHOW event | ||
| 213 | /// types for sub type of <b>"Show/Game show"</b>. | ||
| 214 | /// | ||
| 215 | typedef enum EPG_EVENT_CONTENTSUBMASK_SHOW | ||
| 216 | { | ||
| 217 | /// @brief __0x0__ : Show/game show (general). | ||
| 218 | EPG_EVENT_CONTENTSUBMASK_SHOW_GENERAL = 0x0, | ||
| 219 | |||
| 220 | /// @brief __0x1__ : Game show/quiz/contest. | ||
| 221 | EPG_EVENT_CONTENTSUBMASK_SHOW_GAMESHOW_QUIZ_CONTEST = 0x1, | ||
| 222 | |||
| 223 | /// @brief __0x2__ : Variety show. | ||
| 224 | EPG_EVENT_CONTENTSUBMASK_SHOW_VARIETY_SHOW = 0x2, | ||
| 225 | |||
| 226 | /// @brief __0x3__ : Talk show. | ||
| 227 | EPG_EVENT_CONTENTSUBMASK_SHOW_TALK_SHOW = 0x3, | ||
| 228 | |||
| 229 | /// @brief __0xF__ : User defined. | ||
| 230 | EPG_EVENT_CONTENTSUBMASK_SHOW_USERDEFINED = 0xF | ||
| 231 | } EPG_EVENT_CONTENTSUBMASK_SHOW; | ||
| 232 | //---------------------------------------------------------------------------- | ||
| 233 | |||
| 234 | //============================================================================ | ||
| 235 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 236 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPORTS event | ||
| 237 | /// types for sub type of <b>"Sports"</b>. | ||
| 238 | /// | ||
| 239 | typedef enum EPG_EVENT_CONTENTSUBMASK_SPORTS | ||
| 240 | { | ||
| 241 | /// @brief __0x0__ : Sports (general). | ||
| 242 | EPG_EVENT_CONTENTSUBMASK_SPORTS_GENERAL = 0x0, | ||
| 243 | |||
| 244 | /// @brief __0x1__ : Special events (Olympic Games, World Cup, etc.). | ||
| 245 | EPG_EVENT_CONTENTSUBMASK_SPORTS_OLYMPICGAMES_WORLDCUP = 0x1, | ||
| 246 | |||
| 247 | /// @brief __0x2__ : Sports magazines. | ||
| 248 | EPG_EVENT_CONTENTSUBMASK_SPORTS_SPORTS_MAGAZINES = 0x2, | ||
| 249 | |||
| 250 | /// @brief __0x3__ : Football/soccer. | ||
| 251 | EPG_EVENT_CONTENTSUBMASK_SPORTS_FOOTBALL_SOCCER = 0x3, | ||
| 252 | |||
| 253 | /// @brief __0x4__ : Tennis/squash. | ||
| 254 | EPG_EVENT_CONTENTSUBMASK_SPORTS_TENNIS_SQUASH = 0x4, | ||
| 255 | |||
| 256 | /// @brief __0x5__ : Team sports (excluding football). | ||
| 257 | EPG_EVENT_CONTENTSUBMASK_SPORTS_TEAMSPORTS = 0x5, | ||
| 258 | |||
| 259 | /// @brief __0x6__ : Athletics. | ||
| 260 | EPG_EVENT_CONTENTSUBMASK_SPORTS_ATHLETICS = 0x6, | ||
| 261 | |||
| 262 | /// @brief __0x7__ : Motor sport. | ||
| 263 | EPG_EVENT_CONTENTSUBMASK_SPORTS_MOTORSPORT = 0x7, | ||
| 264 | |||
| 265 | /// @brief __0x8__ : Water sport. | ||
| 266 | EPG_EVENT_CONTENTSUBMASK_SPORTS_WATERSPORT = 0x8, | ||
| 267 | |||
| 268 | /// @brief __0x9__ : Winter sports. | ||
| 269 | EPG_EVENT_CONTENTSUBMASK_SPORTS_WINTERSPORTS = 0x9, | ||
| 270 | |||
| 271 | /// @brief __0xA__ : Equestrian. | ||
| 272 | EPG_EVENT_CONTENTSUBMASK_SPORTS_EQUESTRIAN = 0xA, | ||
| 273 | |||
| 274 | /// @brief __0xB__ : Martial sports. | ||
| 275 | EPG_EVENT_CONTENTSUBMASK_SPORTS_MARTIALSPORTS = 0xB, | ||
| 276 | |||
| 277 | /// @brief __0xF__ : User defined. | ||
| 278 | EPG_EVENT_CONTENTSUBMASK_SPORTS_USERDEFINED = 0xF | ||
| 279 | } EPG_EVENT_CONTENTSUBMASK_SPORTS; | ||
| 280 | //---------------------------------------------------------------------------- | ||
| 281 | |||
| 282 | //============================================================================ | ||
| 283 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 284 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH event | ||
| 285 | /// types for sub type of <b>"Children's/Youth programmes"</b>. | ||
| 286 | /// | ||
| 287 | typedef enum EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH | ||
| 288 | { | ||
| 289 | /// @brief __0x0__ : Children's/youth programmes (general). | ||
| 290 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_GENERAL = 0x0, | ||
| 291 | |||
| 292 | /// @brief __0x1__ : Pre-school children's programmes. | ||
| 293 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_PRESCHOOL_CHILDREN = 0x1, | ||
| 294 | |||
| 295 | /// @brief __0x2__ : Entertainment programmes for 6 to 14. | ||
| 296 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_ENTERTAIN_6TO14 = 0x2, | ||
| 297 | |||
| 298 | /// @brief __0x3__ : Entertainment programmes for 10 to 16. | ||
| 299 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_ENTERTAIN_10TO16 = 0x3, | ||
| 300 | |||
| 301 | /// @brief __0x4__ : Informational/educational/school programmes. | ||
| 302 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_INFORMATIONAL_EDUCATIONAL_SCHOOL = 0x4, | ||
| 303 | |||
| 304 | /// @brief __0x5__ : Cartoons/puppets. | ||
| 305 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_CARTOONS_PUPPETS = 0x5, | ||
| 306 | |||
| 307 | /// @brief __0xF__ : User defined. | ||
| 308 | EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_USERDEFINED = 0xF | ||
| 309 | } EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH; | ||
| 310 | //---------------------------------------------------------------------------- | ||
| 311 | |||
| 312 | //============================================================================ | ||
| 313 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 314 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE event | ||
| 315 | /// types for sub type of <b>"Music/Ballet/Dance"</b>. | ||
| 316 | /// | ||
| 317 | typedef enum EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE | ||
| 318 | { | ||
| 319 | /// @brief __0x0__ : Music/ballet/dance (general). | ||
| 320 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_GENERAL = 0x0, | ||
| 321 | |||
| 322 | /// @brief __0x1__ : Rock/pop. | ||
| 323 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_ROCKPOP = 0x1, | ||
| 324 | |||
| 325 | /// @brief __0x2__ : Serious music/classical music. | ||
| 326 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_SERIOUSMUSIC_CLASSICALMUSIC = 0x2, | ||
| 327 | |||
| 328 | /// @brief __0x3__ : Folk/traditional music. | ||
| 329 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_FOLK_TRADITIONAL_MUSIC = 0x3, | ||
| 330 | |||
| 331 | /// @brief __0x4__ : Jazz. | ||
| 332 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ = 0x4, | ||
| 333 | |||
| 334 | /// @brief __0x5__ : Musical/opera. | ||
| 335 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_MUSICAL_OPERA = 0x5, | ||
| 336 | |||
| 337 | /// @brief __0x6__ : Ballet. | ||
| 338 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_BALLET = 0x6, | ||
| 339 | |||
| 340 | /// @brief __0xF__ : User defined. | ||
| 341 | EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_USERDEFINED = 0xF | ||
| 342 | } EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE; | ||
| 343 | //---------------------------------------------------------------------------- | ||
| 344 | |||
| 345 | //============================================================================ | ||
| 346 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 347 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE event | ||
| 348 | /// types for sub type of <b>"Arts/Culture (without music)"</b>. | ||
| 349 | /// | ||
| 350 | typedef enum EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE | ||
| 351 | { | ||
| 352 | /// @brief __0x0__ : Arts/culture (without music, general). | ||
| 353 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_GENERAL = 0x0, | ||
| 354 | |||
| 355 | /// @brief __0x1__ : Performing arts. | ||
| 356 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_PERFORMINGARTS = 0x1, | ||
| 357 | |||
| 358 | /// @brief __0x2__ : Fine arts. | ||
| 359 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_FINEARTS = 0x2, | ||
| 360 | |||
| 361 | /// @brief __0x3__ : Religion. | ||
| 362 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_RELIGION = 0x3, | ||
| 363 | |||
| 364 | /// @brief __0x4__ : Popular culture/traditional arts. | ||
| 365 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_POPULARCULTURE_TRADITIONALARTS = 0x4, | ||
| 366 | |||
| 367 | /// @brief __0x5__ : Literature. | ||
| 368 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_LITERATURE = 0x5, | ||
| 369 | |||
| 370 | /// @brief __0x6__ : Film/cinema. | ||
| 371 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_FILM_CINEMA = 0x6, | ||
| 372 | |||
| 373 | /// @brief __0x7__ : Experimental film/video. | ||
| 374 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_EXPERIMENTALFILM_VIDEO = 0x7, | ||
| 375 | |||
| 376 | /// @brief __0x8__ : Broadcasting/press. | ||
| 377 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_BROADCASTING_PRESS = 0x8, | ||
| 378 | |||
| 379 | /// @brief __0x9__ : New media. | ||
| 380 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_NEWMEDIA = 0x9, | ||
| 381 | |||
| 382 | /// @brief __0xA__ : Arts/culture magazines. | ||
| 383 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_ARTS_CULTUREMAGAZINES = 0xA, | ||
| 384 | |||
| 385 | /// @brief __0xB__ : Fashion. | ||
| 386 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_FASHION = 0xB, | ||
| 387 | |||
| 388 | /// @brief __0xF__ : User defined. | ||
| 389 | EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_USERDEFINED = 0xF | ||
| 390 | } EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE; | ||
| 391 | //---------------------------------------------------------------------------- | ||
| 392 | |||
| 393 | //============================================================================ | ||
| 394 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 395 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS event | ||
| 396 | /// types for sub type of <b>"Social/Political issues/Economics"</b>. | ||
| 397 | /// | ||
| 398 | typedef enum EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS | ||
| 399 | { | ||
| 400 | /// @brief __0x0__ : Social/political issues/economics (general). | ||
| 401 | EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_GENERAL = 0x0, | ||
| 402 | |||
| 403 | /// @brief __0x1__ : Magazines/reports/documentary. | ||
| 404 | EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_MAGAZINES_REPORTS_DOCUMENTARY = 0x1, | ||
| 405 | |||
| 406 | /// @brief __0x2__ : Economics/social advisory. | ||
| 407 | EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_ECONOMICS_SOCIALADVISORY = 0x2, | ||
| 408 | |||
| 409 | /// @brief __0x3__ : Remarkable people. | ||
| 410 | EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_REMARKABLEPEOPLE = 0x3, | ||
| 411 | |||
| 412 | /// @brief __0xF__ : User defined. | ||
| 413 | EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_USERDEFINED = 0xF | ||
| 414 | } EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS; | ||
| 415 | //---------------------------------------------------------------------------- | ||
| 416 | |||
| 417 | //============================================================================ | ||
| 418 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 419 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE event | ||
| 420 | /// types for sub type of <b>"Education/Science/Factual topics"</b>. | ||
| 421 | /// | ||
| 422 | typedef enum EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE | ||
| 423 | { | ||
| 424 | /// @brief __0x0__ : Education/science/factual topics (general). | ||
| 425 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_GENERAL = 0x0, | ||
| 426 | |||
| 427 | /// @brief __0x1__ : Nature/animals/environment. | ||
| 428 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_NATURE_ANIMALS_ENVIRONMENT = 0x1, | ||
| 429 | |||
| 430 | /// @brief __0x2__ : Technology/natural sciences. | ||
| 431 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_TECHNOLOGY_NATURALSCIENCES = 0x2, | ||
| 432 | |||
| 433 | /// @brief __0x3__ : Medicine/physiology/psychology. | ||
| 434 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_MEDICINE_PHYSIOLOGY_PSYCHOLOGY = 0x3, | ||
| 435 | |||
| 436 | /// @brief __0x4__ : Foreign countries/expeditions. | ||
| 437 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_FOREIGNCOUNTRIES_EXPEDITIONS = 0x4, | ||
| 438 | |||
| 439 | /// @brief __0x5__ : Social/spiritual sciences. | ||
| 440 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_SOCIAL_SPIRITUALSCIENCES = 0x5, | ||
| 441 | |||
| 442 | /// @brief __0x6__ : Further education. | ||
| 443 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_FURTHEREDUCATION = 0x6, | ||
| 444 | |||
| 445 | /// @brief __0x7__ : Languages. | ||
| 446 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_LANGUAGES = 0x7, | ||
| 447 | |||
| 448 | /// @brief __0xF__ : User defined. | ||
| 449 | EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_USERDEFINED = 0xF | ||
| 450 | } EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE; | ||
| 451 | //---------------------------------------------------------------------------- | ||
| 452 | |||
| 453 | //============================================================================ | ||
| 454 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 455 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES event | ||
| 456 | /// types for sub type of <b>"Leisure hobbies"</b>. | ||
| 457 | /// | ||
| 458 | typedef enum EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES | ||
| 459 | { | ||
| 460 | /// @brief __0x0__ : Leisure hobbies (general) . | ||
| 461 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_GENERAL = 0x0, | ||
| 462 | |||
| 463 | /// @brief __0x1__ : Tourism/travel. | ||
| 464 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_TOURISM_TRAVEL = 0x1, | ||
| 465 | |||
| 466 | /// @brief __0x2__ : Handicraft. | ||
| 467 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_HANDICRAFT = 0x2, | ||
| 468 | |||
| 469 | /// @brief __0x3__ : Motoring. | ||
| 470 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_MOTORING = 0x3, | ||
| 471 | |||
| 472 | /// @brief __0x4__ : Fitness and health. | ||
| 473 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_FITNESSANDHEALTH = 0x4, | ||
| 474 | |||
| 475 | /// @brief __0x5__ : Cooking. | ||
| 476 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_COOKING = 0x5, | ||
| 477 | |||
| 478 | /// @brief __0x6__ : Advertisement/shopping. | ||
| 479 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_ADVERTISEMENT_SHOPPING = 0x6, | ||
| 480 | |||
| 481 | /// @brief __0x7__ : Gardening. | ||
| 482 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_GARDENING = 0x7, | ||
| 483 | |||
| 484 | /// @brief __0xF__ : User defined. | ||
| 485 | EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_USERDEFINED = 0xF | ||
| 486 | } EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES; | ||
| 487 | //---------------------------------------------------------------------------- | ||
| 488 | |||
| 489 | //============================================================================ | ||
| 490 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT | ||
| 491 | /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPECIAL event | ||
| 492 | /// types for sub type of <b>"Special characteristics"</b>. | ||
| 493 | /// | ||
| 494 | typedef enum EPG_EVENT_CONTENTSUBMASK_SPECIAL | ||
| 495 | { | ||
| 496 | /// @brief __0x0__ : Special characteristics / Original language (general). | ||
| 497 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_GENERAL = 0x0, | ||
| 498 | |||
| 499 | /// @brief __0x1__ : Black and white. | ||
| 500 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_BLACKANDWHITE = 0x1, | ||
| 501 | |||
| 502 | /// @brief __0x2__ : Unpublished. | ||
| 503 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_UNPUBLISHED = 0x2, | ||
| 504 | |||
| 505 | /// @brief __0x3__ : Live broadcast. | ||
| 506 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_LIVEBROADCAST = 0x3, | ||
| 507 | |||
| 508 | /// @brief __0x4__ : Plano-stereoscopic. | ||
| 509 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_PLANOSTEREOSCOPIC = 0x4, | ||
| 510 | |||
| 511 | /// @brief __0x5__ : Local or regional. | ||
| 512 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_LOCALORREGIONAL = 0x5, | ||
| 513 | |||
| 514 | /// @brief __0xF__ : User defined. | ||
| 515 | EPG_EVENT_CONTENTSUBMASK_SPECIAL_USERDEFINED = 0xF | ||
| 516 | } EPG_EVENT_CONTENTSUBMASK_SPECIAL; | ||
| 517 | //---------------------------------------------------------------------------- | ||
| 518 | |||
| 519 | ///@} | ||
| 520 | |||
| 521 | //============================================================================ | ||
| 522 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 523 | /// @brief Separator to use in strings containing different tokens, for example | ||
| 524 | /// writers, directors, actors of an event. | ||
| 525 | /// | ||
| 526 | #define EPG_STRING_TOKEN_SEPARATOR "," | ||
| 527 | //---------------------------------------------------------------------------- | ||
| 528 | |||
| 529 | //============================================================================ | ||
| 530 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg_EPG_TAG_FLAG enum EPG_TAG_FLAG | ||
| 531 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 532 | /// @brief <b>Bit field of independent flags associated with the EPG entry.</b>\n | ||
| 533 | /// Values used by @ref kodi::addon::PVREPGTag::SetFlags(). | ||
| 534 | /// | ||
| 535 | /// Here's example about the use of this: | ||
| 536 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 537 | /// kodi::addon::PVREPGTag tag; | ||
| 538 | /// tag.SetFlags(EPG_TAG_FLAG_IS_SERIES | EPG_TAG_FLAG_IS_NEW); | ||
| 539 | /// ~~~~~~~~~~~~~ | ||
| 540 | /// | ||
| 541 | ///@{ | ||
| 542 | typedef enum EPG_TAG_FLAG | ||
| 543 | { | ||
| 544 | /// @brief __0000 0000__ : Nothing special to say about this entry. | ||
| 545 | EPG_TAG_FLAG_UNDEFINED = 0, | ||
| 546 | |||
| 547 | /// @brief __0000 0001__ : This EPG entry is part of a series. | ||
| 548 | EPG_TAG_FLAG_IS_SERIES = (1 << 0), | ||
| 549 | |||
| 550 | /// @brief __0000 0010__ : This EPG entry will be flagged as new. | ||
| 551 | EPG_TAG_FLAG_IS_NEW = (1 << 1), | ||
| 552 | |||
| 553 | /// @brief __0000 0100__ : This EPG entry will be flagged as a premiere. | ||
| 554 | EPG_TAG_FLAG_IS_PREMIERE = (1 << 2), | ||
| 555 | |||
| 556 | /// @brief __0000 1000__ : This EPG entry will be flagged as a finale. | ||
| 557 | EPG_TAG_FLAG_IS_FINALE = (1 << 3), | ||
| 558 | |||
| 559 | /// @brief __0001 0000__ : This EPG entry will be flagged as live. | ||
| 560 | EPG_TAG_FLAG_IS_LIVE = (1 << 4), | ||
| 561 | } EPG_TAG_FLAG; | ||
| 562 | ///@} | ||
| 563 | //---------------------------------------------------------------------------- | ||
| 564 | |||
| 565 | //============================================================================ | ||
| 566 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 567 | /// @brief Special PVREPGTag::SetUniqueBroadcastId value | ||
| 568 | /// | ||
| 569 | /// Special @ref kodi::addon::PVREPGTag::SetUniqueBroadcastId() value to | ||
| 570 | /// indicate that a tag has not a valid EPG event uid. | ||
| 571 | /// | ||
| 572 | #define EPG_TAG_INVALID_UID 0 | ||
| 573 | //---------------------------------------------------------------------------- | ||
| 574 | |||
| 575 | //============================================================================ | ||
| 576 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 577 | /// @brief Special @ref kodi::addon::PVREPGTag::SetSeriesNumber(), @ref kodi::addon::PVREPGTag::SetEpisodeNumber() | ||
| 578 | /// and @ref kodi::addon::PVREPGTag::SetEpisodePartNumber() value to indicate | ||
| 579 | /// it is not to be used. | ||
| 580 | /// | ||
| 581 | #define EPG_TAG_INVALID_SERIES_EPISODE -1 | ||
| 582 | //---------------------------------------------------------------------------- | ||
| 583 | |||
| 584 | //============================================================================ | ||
| 585 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 586 | /// @brief Timeframe value for use with @ref kodi::addon::CInstancePVRClient::SetEPGTimeFrame() | ||
| 587 | /// function to indicate "no timeframe". | ||
| 588 | /// | ||
| 589 | #define EPG_TIMEFRAME_UNLIMITED -1 | ||
| 590 | //---------------------------------------------------------------------------- | ||
| 591 | |||
| 592 | //============================================================================ | ||
| 593 | /// @defgroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT_STATE enum EPG_EVENT_STATE | ||
| 594 | /// @ingroup cpp_kodi_addon_pvr_Defs_epg | ||
| 595 | /// @brief **EPG event states.**\n | ||
| 596 | /// Used with @ref kodi::addon::CInstancePVRClient::EpgEventStateChange() | ||
| 597 | /// callback. | ||
| 598 | /// | ||
| 599 | ///@{ | ||
| 600 | typedef enum EPG_EVENT_STATE | ||
| 601 | { | ||
| 602 | /// @brief __0__ : Event created. | ||
| 603 | EPG_EVENT_CREATED = 0, | ||
| 604 | |||
| 605 | /// @brief __1__ : Event updated. | ||
| 606 | EPG_EVENT_UPDATED = 1, | ||
| 607 | |||
| 608 | /// @brief __2__ : Event deleted. | ||
| 609 | EPG_EVENT_DELETED = 2, | ||
| 610 | } EPG_EVENT_STATE; | ||
| 611 | ///@} | ||
| 612 | //---------------------------------------------------------------------------- | ||
| 613 | |||
| 614 | /*! | ||
| 615 | * @brief "C" PVR add-on channel group member. | ||
| 616 | * | ||
| 617 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 618 | * | ||
| 619 | * See @ref kodi::addon::PVREPGTag for description of values. | ||
| 620 | */ | ||
| 621 | typedef struct EPG_TAG | ||
| 622 | { | ||
| 623 | unsigned int iUniqueBroadcastId; | ||
| 624 | unsigned int iUniqueChannelId; | ||
| 625 | const char* strTitle; | ||
| 626 | time_t startTime; | ||
| 627 | time_t endTime; | ||
| 628 | const char* strPlotOutline; | ||
| 629 | const char* strPlot; | ||
| 630 | const char* strOriginalTitle; | ||
| 631 | const char* strCast; | ||
| 632 | const char* strDirector; | ||
| 633 | const char* strWriter; | ||
| 634 | int iYear; | ||
| 635 | const char* strIMDBNumber; | ||
| 636 | const char* strIconPath; | ||
| 637 | int iGenreType; | ||
| 638 | int iGenreSubType; | ||
| 639 | const char* strGenreDescription; | ||
| 640 | const char* strFirstAired; | ||
| 641 | int iParentalRating; | ||
| 642 | int iStarRating; | ||
| 643 | int iSeriesNumber; | ||
| 644 | int iEpisodeNumber; | ||
| 645 | int iEpisodePartNumber; | ||
| 646 | const char* strEpisodeName; | ||
| 647 | unsigned int iFlags; | ||
| 648 | const char* strSeriesLink; | ||
| 649 | } EPG_TAG; | ||
| 650 | |||
| 651 | #ifdef __cplusplus | ||
| 652 | } | ||
| 653 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h new file mode 100644 index 0000000..52787b0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h | |||
| @@ -0,0 +1,288 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #ifdef BUILD_KODI_ADDON | ||
| 14 | #include "../../../InputStreamConstants.h" | ||
| 15 | #else | ||
| 16 | #include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h" | ||
| 17 | #endif | ||
| 18 | |||
| 19 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 20 | // "C" Definitions group 1 - General PVR | ||
| 21 | #ifdef __cplusplus | ||
| 22 | extern "C" | ||
| 23 | { | ||
| 24 | #endif /* __cplusplus */ | ||
| 25 | |||
| 26 | //============================================================================ | ||
| 27 | /// @defgroup cpp_kodi_addon_pvr_Defs_General_PVR_ERROR enum PVR_ERROR | ||
| 28 | /// @ingroup cpp_kodi_addon_pvr_Defs_General | ||
| 29 | /// @brief **PVR add-on error codes**\n | ||
| 30 | /// Used as return values on most PVR related functions. | ||
| 31 | /// | ||
| 32 | /// In this way, a PVR instance signals errors in its processing and, under | ||
| 33 | /// certain conditions, allows Kodi to make corrections. | ||
| 34 | /// | ||
| 35 | ///@{ | ||
| 36 | typedef enum PVR_ERROR | ||
| 37 | { | ||
| 38 | /// @brief __0__ : No error occurred. | ||
| 39 | PVR_ERROR_NO_ERROR = 0, | ||
| 40 | |||
| 41 | /// @brief __-1__ : An unknown error occurred. | ||
| 42 | PVR_ERROR_UNKNOWN = -1, | ||
| 43 | |||
| 44 | /// @brief __-2__ : The method that Kodi called is not implemented by the add-on. | ||
| 45 | PVR_ERROR_NOT_IMPLEMENTED = -2, | ||
| 46 | |||
| 47 | /// @brief __-3__ : The backend reported an error, or the add-on isn't connected. | ||
| 48 | PVR_ERROR_SERVER_ERROR = -3, | ||
| 49 | |||
| 50 | /// @brief __-4__ : The command was sent to the backend, but the response timed out. | ||
| 51 | PVR_ERROR_SERVER_TIMEOUT = -4, | ||
| 52 | |||
| 53 | /// @brief __-5__ : The command was rejected by the backend. | ||
| 54 | PVR_ERROR_REJECTED = -5, | ||
| 55 | |||
| 56 | /// @brief __-6__ : The requested item can not be added, because it's already present. | ||
| 57 | PVR_ERROR_ALREADY_PRESENT = -6, | ||
| 58 | |||
| 59 | /// @brief __-7__ : The parameters of the method that was called are invalid for this | ||
| 60 | /// operation. | ||
| 61 | PVR_ERROR_INVALID_PARAMETERS = -7, | ||
| 62 | |||
| 63 | /// @brief __-8__ : A recording is running, so the timer can't be deleted without | ||
| 64 | /// doing a forced delete. | ||
| 65 | PVR_ERROR_RECORDING_RUNNING = -8, | ||
| 66 | |||
| 67 | /// @brief __-9__ : The command failed. | ||
| 68 | PVR_ERROR_FAILED = -9, | ||
| 69 | } PVR_ERROR; | ||
| 70 | ///@} | ||
| 71 | //---------------------------------------------------------------------------- | ||
| 72 | |||
| 73 | //============================================================================ | ||
| 74 | /// @defgroup cpp_kodi_addon_pvr_Defs_General_PVR_CONNECTION_STATE enum PVR_CONNECTION_STATE | ||
| 75 | /// @ingroup cpp_kodi_addon_pvr_Defs_General | ||
| 76 | /// @brief **PVR backend connection states**\n | ||
| 77 | /// Used with @ref kodi::addon::CInstancePVRClient::ConnectionStateChange() callback. | ||
| 78 | /// | ||
| 79 | /// With this, a PVR instance signals that Kodi should perform special | ||
| 80 | /// operations. | ||
| 81 | /// | ||
| 82 | ///@{ | ||
| 83 | typedef enum PVR_CONNECTION_STATE | ||
| 84 | { | ||
| 85 | /// @brief __0__ : Unknown state (e.g. not yet tried to connect). | ||
| 86 | PVR_CONNECTION_STATE_UNKNOWN = 0, | ||
| 87 | |||
| 88 | /// @brief __1__ : Backend server is not reachable (e.g. server not existing or | ||
| 89 | /// network down). | ||
| 90 | PVR_CONNECTION_STATE_SERVER_UNREACHABLE = 1, | ||
| 91 | |||
| 92 | /// @brief __2__ : Backend server is reachable, but there is not the expected type of | ||
| 93 | /// server running (e.g. HTSP required, but FTP running at given server:port). | ||
| 94 | PVR_CONNECTION_STATE_SERVER_MISMATCH = 2, | ||
| 95 | |||
| 96 | /// @brief __3__ : Backend server is reachable, but server version does not match | ||
| 97 | /// client requirements. | ||
| 98 | PVR_CONNECTION_STATE_VERSION_MISMATCH = 3, | ||
| 99 | |||
| 100 | /// @brief __4__ : Backend server is reachable, but denies client access (e.g. due | ||
| 101 | /// to wrong credentials). | ||
| 102 | PVR_CONNECTION_STATE_ACCESS_DENIED = 4, | ||
| 103 | |||
| 104 | /// @brief __5__ : Connection to backend server is established. | ||
| 105 | PVR_CONNECTION_STATE_CONNECTED = 5, | ||
| 106 | |||
| 107 | /// @brief __6__ : No connection to backend server (e.g. due to network errors or | ||
| 108 | /// client initiated disconnect). | ||
| 109 | PVR_CONNECTION_STATE_DISCONNECTED = 6, | ||
| 110 | |||
| 111 | /// @brief __7__ : Connecting to backend. | ||
| 112 | PVR_CONNECTION_STATE_CONNECTING = 7, | ||
| 113 | } PVR_CONNECTION_STATE; | ||
| 114 | ///@} | ||
| 115 | //---------------------------------------------------------------------------- | ||
| 116 | |||
| 117 | //============================================================================ | ||
| 118 | /// @defgroup cpp_kodi_addon_pvr_Defs_General_PVR_STREAM_PROPERTY definition PVR_STREAM_PROPERTY | ||
| 119 | /// @ingroup cpp_kodi_addon_pvr_Defs_General_Inputstream | ||
| 120 | /// @brief **PVR related stream property values**\n | ||
| 121 | /// This is used to pass additional data to Kodi on a given PVR stream. | ||
| 122 | /// | ||
| 123 | /// Then transferred to livestream, recordings or EPG Tag stream using the | ||
| 124 | /// properties. | ||
| 125 | /// | ||
| 126 | /// This defines are used by: | ||
| 127 | /// - @ref kodi::addon::CInstancePVRClient::GetChannelStreamProperties() | ||
| 128 | /// - @ref kodi::addon::CInstancePVRClient::GetEPGTagStreamProperties() | ||
| 129 | /// - @ref kodi::addon::CInstancePVRClient::GetRecordingStreamProperties() | ||
| 130 | /// | ||
| 131 | /// | ||
| 132 | ///--------------------------------------------------------------------------- | ||
| 133 | /// | ||
| 134 | /// **Example:** | ||
| 135 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 136 | /// ... | ||
| 137 | /// | ||
| 138 | /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 139 | /// std::vector<PVRStreamProperty>& properties) | ||
| 140 | /// { | ||
| 141 | /// ... | ||
| 142 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive"); | ||
| 143 | /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd"); | ||
| 144 | /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full"); | ||
| 145 | /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash"); | ||
| 146 | /// return PVR_ERROR_NO_ERROR; | ||
| 147 | /// } | ||
| 148 | /// | ||
| 149 | /// ... | ||
| 150 | /// ~~~~~~~~~~~~~ | ||
| 151 | /// | ||
| 152 | ///@{ | ||
| 153 | |||
| 154 | /// @brief the URL of the stream that should be played. | ||
| 155 | /// | ||
| 156 | #define PVR_STREAM_PROPERTY_STREAMURL "streamurl" | ||
| 157 | |||
| 158 | /// @brief To define in stream properties the name of the inputstream add-on | ||
| 159 | /// that should be used. | ||
| 160 | /// | ||
| 161 | /// Leave blank to use Kodi's built-in playing capabilities or to allow ffmpeg | ||
| 162 | /// to handle directly set to @ref PVR_STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG. | ||
| 163 | /// | ||
| 164 | #define PVR_STREAM_PROPERTY_INPUTSTREAM STREAM_PROPERTY_INPUTSTREAM | ||
| 165 | |||
| 166 | /// @brief Identification string for an input stream. | ||
| 167 | /// | ||
| 168 | /// This value can be used in addition to @ref PVR_STREAM_PROPERTY_INPUTSTREAM. | ||
| 169 | /// It is used to provide the respective inpustream addon with additional | ||
| 170 | /// identification. | ||
| 171 | /// | ||
| 172 | /// The difference between this and other stream properties is that it is also | ||
| 173 | /// passed in the associated @ref kodi::addon::CAddonBase::CreateInstance() | ||
| 174 | /// call. | ||
| 175 | /// | ||
| 176 | /// This makes it possible to select different processing classes within the | ||
| 177 | /// associated add-on. | ||
| 178 | /// | ||
| 179 | /// | ||
| 180 | ///--------------------------------------------------------------------------- | ||
| 181 | /// | ||
| 182 | /// **Example:** | ||
| 183 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 184 | /// ... | ||
| 185 | /// | ||
| 186 | /// // On PVR instance of addon | ||
| 187 | /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, | ||
| 188 | /// std::vector<PVRStreamProperty>& properties) | ||
| 189 | /// { | ||
| 190 | /// ... | ||
| 191 | /// // For here on example the inpustream is also inside the PVR addon | ||
| 192 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "pvr.my_one"); | ||
| 193 | /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID, "my_special_id_1"); | ||
| 194 | /// return PVR_ERROR_NO_ERROR; | ||
| 195 | /// } | ||
| 196 | /// | ||
| 197 | /// ... | ||
| 198 | /// | ||
| 199 | /// // On CAddonBase part of addon | ||
| 200 | /// ADDON_STATUS CMyAddon::CreateInstanceEx(int instanceType, | ||
| 201 | /// std::string instanceID, | ||
| 202 | /// KODI_HANDLE instance, | ||
| 203 | /// KODI_HANDLE& addonInstance | ||
| 204 | /// const std::string& version) | ||
| 205 | /// { | ||
| 206 | /// if (instanceType == ADDON_INSTANCE_INPUTSTREAM) | ||
| 207 | /// { | ||
| 208 | /// kodi::Log(ADDON_LOG_NOTICE, "Creating my special inputstream"); | ||
| 209 | /// if (instanceID == "my_special_id_1") | ||
| 210 | /// addonInstance = new CMyPVRClientInstance_Type1(instance, version); | ||
| 211 | /// else if (instanceID == "my_special_id_2") | ||
| 212 | /// addonInstance = new CMyPVRClientInstance_Type2(instance, version); | ||
| 213 | /// return ADDON_STATUS_OK; | ||
| 214 | /// } | ||
| 215 | /// else if (...) | ||
| 216 | /// { | ||
| 217 | /// ... | ||
| 218 | /// } | ||
| 219 | /// return ADDON_STATUS_UNKNOWN; | ||
| 220 | /// } | ||
| 221 | /// | ||
| 222 | /// ... | ||
| 223 | /// ~~~~~~~~~~~~~ | ||
| 224 | /// | ||
| 225 | #define PVR_STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID | ||
| 226 | |||
| 227 | /// @brief the MIME type of the stream that should be played. | ||
| 228 | /// | ||
| 229 | #define PVR_STREAM_PROPERTY_MIMETYPE "mimetype" | ||
| 230 | |||
| 231 | /// @brief <b>"true"</b> to denote that the stream that should be played is a | ||
| 232 | /// realtime stream. | ||
| 233 | /// | ||
| 234 | /// Any other value indicates that this is no realtime stream. | ||
| 235 | /// | ||
| 236 | #define PVR_STREAM_PROPERTY_ISREALTIMESTREAM STREAM_PROPERTY_ISREALTIMESTREAM | ||
| 237 | |||
| 238 | /// @brief <b>"true"</b> to denote that if the stream is from an EPG tag. | ||
| 239 | /// | ||
| 240 | /// It should be played is a live stream. Otherwise if it's a EPG tag it will | ||
| 241 | /// play as normal video. | ||
| 242 | /// | ||
| 243 | #define PVR_STREAM_PROPERTY_EPGPLAYBACKASLIVE "epgplaybackaslive" | ||
| 244 | |||
| 245 | /// @brief Special value for @ref PVR_STREAM_PROPERTY_INPUTSTREAM to use | ||
| 246 | /// ffmpeg to directly play a stream URL. | ||
| 247 | #define PVR_STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG | ||
| 248 | |||
| 249 | ///@} | ||
| 250 | //----------------------------------------------------------------------------- | ||
| 251 | |||
| 252 | /*! | ||
| 253 | * @brief "C" PVR add-on capabilities. | ||
| 254 | * | ||
| 255 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 256 | * | ||
| 257 | * See @ref kodi::addon::PVRCapabilities for description of values. | ||
| 258 | */ | ||
| 259 | typedef struct PVR_ADDON_CAPABILITIES | ||
| 260 | { | ||
| 261 | bool bSupportsEPG; | ||
| 262 | bool bSupportsEPGEdl; | ||
| 263 | bool bSupportsTV; | ||
| 264 | bool bSupportsRadio; | ||
| 265 | bool bSupportsRecordings; | ||
| 266 | bool bSupportsRecordingsUndelete; | ||
| 267 | bool bSupportsTimers; | ||
| 268 | bool bSupportsChannelGroups; | ||
| 269 | bool bSupportsChannelScan; | ||
| 270 | bool bSupportsChannelSettings; | ||
| 271 | bool bHandlesInputStream; | ||
| 272 | bool bHandlesDemuxing; | ||
| 273 | bool bSupportsRecordingPlayCount; | ||
| 274 | bool bSupportsLastPlayedPosition; | ||
| 275 | bool bSupportsRecordingEdl; | ||
| 276 | bool bSupportsRecordingsRename; | ||
| 277 | bool bSupportsRecordingsLifetimeChange; | ||
| 278 | bool bSupportsDescrambleInfo; | ||
| 279 | bool bSupportsAsyncEPGTransfer; | ||
| 280 | bool bSupportsRecordingSize; | ||
| 281 | |||
| 282 | unsigned int iRecordingsLifetimesSize; | ||
| 283 | struct PVR_ATTRIBUTE_INT_VALUE recordingsLifetimeValues[PVR_ADDON_ATTRIBUTE_VALUES_ARRAY_SIZE]; | ||
| 284 | } PVR_ADDON_CAPABILITIES; | ||
| 285 | |||
| 286 | #ifdef __cplusplus | ||
| 287 | } | ||
| 288 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h new file mode 100644 index 0000000..df2216f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h | |||
| @@ -0,0 +1,72 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 14 | // "C" Definitions group 7 - Menu hook | ||
| 15 | #ifdef __cplusplus | ||
| 16 | extern "C" | ||
| 17 | { | ||
| 18 | #endif /* __cplusplus */ | ||
| 19 | |||
| 20 | //============================================================================ | ||
| 21 | /// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook_PVR_MENUHOOK_CAT enum PVR_MENUHOOK_CAT | ||
| 22 | /// @ingroup cpp_kodi_addon_pvr_Defs_Menuhook | ||
| 23 | /// @brief **PVR context menu hook categories**\n | ||
| 24 | /// Possible menu types given to Kodi with @ref kodi::addon::CInstancePVRClient::AddMenuHook(). | ||
| 25 | /// | ||
| 26 | ///@{ | ||
| 27 | typedef enum PVR_MENUHOOK_CAT | ||
| 28 | { | ||
| 29 | /// @brief __-1__ : Unknown menu hook. | ||
| 30 | PVR_MENUHOOK_UNKNOWN = -1, | ||
| 31 | |||
| 32 | /// @brief __0__ : All categories. | ||
| 33 | PVR_MENUHOOK_ALL = 0, | ||
| 34 | |||
| 35 | /// @brief __1__ : For channels. | ||
| 36 | PVR_MENUHOOK_CHANNEL = 1, | ||
| 37 | |||
| 38 | /// @brief __2__ : For timers. | ||
| 39 | PVR_MENUHOOK_TIMER = 2, | ||
| 40 | |||
| 41 | /// @brief __3__ : For EPG. | ||
| 42 | PVR_MENUHOOK_EPG = 3, | ||
| 43 | |||
| 44 | /// @brief __4__ : For recordings. | ||
| 45 | PVR_MENUHOOK_RECORDING = 4, | ||
| 46 | |||
| 47 | /// @brief __5__ : For deleted recordings. | ||
| 48 | PVR_MENUHOOK_DELETED_RECORDING = 5, | ||
| 49 | |||
| 50 | /// @brief __6__ : For settings. | ||
| 51 | PVR_MENUHOOK_SETTING = 6, | ||
| 52 | } PVR_MENUHOOK_CAT; | ||
| 53 | ///@} | ||
| 54 | //---------------------------------------------------------------------------- | ||
| 55 | |||
| 56 | /*! | ||
| 57 | * @brief "C" PVR add-on menu hook. | ||
| 58 | * | ||
| 59 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 60 | * | ||
| 61 | * See @ref kodi::addon::PVRMenuhook for description of values. | ||
| 62 | */ | ||
| 63 | typedef struct PVR_MENUHOOK | ||
| 64 | { | ||
| 65 | unsigned int iHookId; | ||
| 66 | unsigned int iLocalizedStringId; | ||
| 67 | enum PVR_MENUHOOK_CAT category; | ||
| 68 | } PVR_MENUHOOK; | ||
| 69 | |||
| 70 | #ifdef __cplusplus | ||
| 71 | } | ||
| 72 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h new file mode 100644 index 0000000..1a7fc66 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h | |||
| @@ -0,0 +1,143 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #include <stdbool.h> | ||
| 14 | #include <stdint.h> | ||
| 15 | #include <time.h> | ||
| 16 | |||
| 17 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 18 | // "C" Definitions group 5 - PVR recordings | ||
| 19 | #ifdef __cplusplus | ||
| 20 | extern "C" | ||
| 21 | { | ||
| 22 | #endif /* __cplusplus */ | ||
| 23 | |||
| 24 | //============================================================================ | ||
| 25 | /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_FLAG enum PVR_RECORDING_FLAG | ||
| 26 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording | ||
| 27 | /// @brief **Bit field of independent flags associated with the EPG entry.**\n | ||
| 28 | /// Values used by @ref kodi::addon::PVRRecording::SetFlags(). | ||
| 29 | /// | ||
| 30 | /// Here's example about the use of this: | ||
| 31 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 32 | /// kodi::addon::PVRRecording tag; | ||
| 33 | /// tag.SetFlags(PVR_RECORDING_FLAG_IS_SERIES | PVR_RECORDING_FLAG_IS_PREMIERE); | ||
| 34 | /// ~~~~~~~~~~~~~ | ||
| 35 | /// | ||
| 36 | ///@{ | ||
| 37 | typedef enum PVR_RECORDING_FLAG | ||
| 38 | { | ||
| 39 | /// @brief __0000 0000__ : Nothing special to say about this recording. | ||
| 40 | PVR_RECORDING_FLAG_UNDEFINED = 0, | ||
| 41 | |||
| 42 | /// @brief __0000 0001__ : This recording is part of a series. | ||
| 43 | PVR_RECORDING_FLAG_IS_SERIES = (1 << 0), | ||
| 44 | |||
| 45 | /// @brief __0000 0010__ : This recording will be flagged as new. | ||
| 46 | PVR_RECORDING_FLAG_IS_NEW = (1 << 1), | ||
| 47 | |||
| 48 | /// @brief __0000 0100__ : This recording will be flagged as a premiere. | ||
| 49 | PVR_RECORDING_FLAG_IS_PREMIERE = (1 << 2), | ||
| 50 | |||
| 51 | /// @brief __0000 1000__ : This recording will be flagged as a finale. | ||
| 52 | PVR_RECORDING_FLAG_IS_FINALE = (1 << 3), | ||
| 53 | |||
| 54 | /// @brief __0001 0000__ : This recording will be flagged as live. | ||
| 55 | PVR_RECORDING_FLAG_IS_LIVE = (1 << 4), | ||
| 56 | } PVR_RECORDING_FLAG; | ||
| 57 | ///@} | ||
| 58 | //---------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //============================================================================ | ||
| 61 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 62 | /// @brief Special @ref kodi::addon::PVRRecording::SetSeriesNumber() and | ||
| 63 | /// @ref kodi::addon::PVRRecording::SetEpisodeNumber() value to indicate it is | ||
| 64 | /// not to be used. | ||
| 65 | /// | ||
| 66 | /// Used if recording has no valid season and/or episode info. | ||
| 67 | /// | ||
| 68 | #define PVR_RECORDING_INVALID_SERIES_EPISODE EPG_TAG_INVALID_SERIES_EPISODE | ||
| 69 | //---------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //============================================================================ | ||
| 72 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording | ||
| 73 | /// @brief Value where set in background to inform that related part not used. | ||
| 74 | /// | ||
| 75 | /// Normally this related parts need not to set by this as it is default. | ||
| 76 | #define PVR_RECORDING_VALUE_NOT_AVAILABLE -1 | ||
| 77 | //---------------------------------------------------------------------------- | ||
| 78 | |||
| 79 | //============================================================================ | ||
| 80 | /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_CHANNEL_TYPE enum PVR_RECORDING_CHANNEL_TYPE | ||
| 81 | /// @ingroup cpp_kodi_addon_pvr_Defs_Recording | ||
| 82 | /// @brief **PVR recording channel types**\n | ||
| 83 | /// Used on @ref kodi::addon::PVRRecording::SetChannelType() value to set related | ||
| 84 | /// type. | ||
| 85 | /// | ||
| 86 | ///@{ | ||
| 87 | typedef enum PVR_RECORDING_CHANNEL_TYPE | ||
| 88 | { | ||
| 89 | /// @brief __0__ : Unknown type. | ||
| 90 | PVR_RECORDING_CHANNEL_TYPE_UNKNOWN = 0, | ||
| 91 | |||
| 92 | /// @brief __1__ : TV channel. | ||
| 93 | PVR_RECORDING_CHANNEL_TYPE_TV = 1, | ||
| 94 | |||
| 95 | /// @brief __2__ : Radio channel. | ||
| 96 | PVR_RECORDING_CHANNEL_TYPE_RADIO = 2, | ||
| 97 | } PVR_RECORDING_CHANNEL_TYPE; | ||
| 98 | ///@} | ||
| 99 | //---------------------------------------------------------------------------- | ||
| 100 | |||
| 101 | /*! | ||
| 102 | * @brief "C" PVR add-on recording. | ||
| 103 | * | ||
| 104 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 105 | * | ||
| 106 | * See @ref kodi::addon::PVRRecording for description of values. | ||
| 107 | */ | ||
| 108 | typedef struct PVR_RECORDING | ||
| 109 | { | ||
| 110 | char strRecordingId[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 111 | char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 112 | char strEpisodeName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 113 | int iSeriesNumber; | ||
| 114 | int iEpisodeNumber; | ||
| 115 | int iYear; | ||
| 116 | char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 117 | char strPlotOutline[PVR_ADDON_DESC_STRING_LENGTH]; | ||
| 118 | char strPlot[PVR_ADDON_DESC_STRING_LENGTH]; | ||
| 119 | char strGenreDescription[PVR_ADDON_DESC_STRING_LENGTH]; | ||
| 120 | char strChannelName[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 121 | char strIconPath[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 122 | char strThumbnailPath[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 123 | char strFanartPath[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 124 | time_t recordingTime; | ||
| 125 | int iDuration; | ||
| 126 | int iPriority; | ||
| 127 | int iLifetime; | ||
| 128 | int iGenreType; | ||
| 129 | int iGenreSubType; | ||
| 130 | int iPlayCount; | ||
| 131 | int iLastPlayedPosition; | ||
| 132 | bool bIsDeleted; | ||
| 133 | unsigned int iEpgEventId; | ||
| 134 | int iChannelUid; | ||
| 135 | enum PVR_RECORDING_CHANNEL_TYPE channelType; | ||
| 136 | char strFirstAired[PVR_ADDON_DATE_STRING_LENGTH]; | ||
| 137 | unsigned int iFlags; | ||
| 138 | int64_t sizeInBytes; | ||
| 139 | } PVR_RECORDING; | ||
| 140 | |||
| 141 | #ifdef __cplusplus | ||
| 142 | } | ||
| 143 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h new file mode 100644 index 0000000..04b4059 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h | |||
| @@ -0,0 +1,155 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #ifdef BUILD_KODI_ADDON | ||
| 14 | #include "../../../DemuxPacket.h" | ||
| 15 | #else | ||
| 16 | #include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #include <stdint.h> | ||
| 20 | #include <time.h> | ||
| 21 | |||
| 22 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 23 | // "C" Definitions group 9 - PVR stream definitions (NOTE: Becomes replaced | ||
| 24 | // in future by inputstream addon instance way) | ||
| 25 | #ifdef __cplusplus | ||
| 26 | extern "C" | ||
| 27 | { | ||
| 28 | #endif /* __cplusplus */ | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 32 | /// @brief Maximum of allowed streams | ||
| 33 | /// | ||
| 34 | #define PVR_STREAM_MAX_STREAMS 20 | ||
| 35 | //---------------------------------------------------------------------------- | ||
| 36 | |||
| 37 | //============================================================================ | ||
| 38 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 39 | /// @brief Invalid codec identifier | ||
| 40 | /// | ||
| 41 | #define PVR_INVALID_CODEC_ID 0 | ||
| 42 | //---------------------------------------------------------------------------- | ||
| 43 | |||
| 44 | //============================================================================ | ||
| 45 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 46 | /// @brief Invalid codec | ||
| 47 | /// | ||
| 48 | #define PVR_INVALID_CODEC \ | ||
| 49 | { \ | ||
| 50 | PVR_CODEC_TYPE_UNKNOWN, PVR_INVALID_CODEC_ID \ | ||
| 51 | } | ||
| 52 | //---------------------------------------------------------------------------- | ||
| 53 | |||
| 54 | //============================================================================ | ||
| 55 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVR_CODEC_TYPE enum PVR_CODEC_TYPE | ||
| 56 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 57 | /// @brief **Inputstream types**\n | ||
| 58 | /// To identify type on stream. | ||
| 59 | /// | ||
| 60 | /// Used on @ref kodi::addon::PVRStreamProperties::SetCodecType and @ref kodi::addon::PVRStreamProperties::SetCodecType. | ||
| 61 | /// | ||
| 62 | ///@{ | ||
| 63 | typedef enum PVR_CODEC_TYPE | ||
| 64 | { | ||
| 65 | /// @brief To set nothing defined. | ||
| 66 | PVR_CODEC_TYPE_UNKNOWN = -1, | ||
| 67 | |||
| 68 | /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Video. | ||
| 69 | PVR_CODEC_TYPE_VIDEO, | ||
| 70 | |||
| 71 | /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Audio. | ||
| 72 | PVR_CODEC_TYPE_AUDIO, | ||
| 73 | |||
| 74 | /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Data. | ||
| 75 | /// | ||
| 76 | /// With codec id related source identified. | ||
| 77 | PVR_CODEC_TYPE_DATA, | ||
| 78 | |||
| 79 | /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Subtitle. | ||
| 80 | PVR_CODEC_TYPE_SUBTITLE, | ||
| 81 | |||
| 82 | /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Radio RDS. | ||
| 83 | PVR_CODEC_TYPE_RDS, | ||
| 84 | |||
| 85 | PVR_CODEC_TYPE_NB | ||
| 86 | } PVR_CODEC_TYPE; | ||
| 87 | ///@} | ||
| 88 | //---------------------------------------------------------------------------- | ||
| 89 | |||
| 90 | //============================================================================ | ||
| 91 | /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVR_CODEC struct PVR_CODEC | ||
| 92 | /// @ingroup cpp_kodi_addon_pvr_Defs_Stream | ||
| 93 | /// @brief **Codec identification structure**\n | ||
| 94 | /// Identifier about stream between Kodi and addon. | ||
| 95 | /// | ||
| 96 | ///@{ | ||
| 97 | typedef struct PVR_CODEC | ||
| 98 | { | ||
| 99 | /// @brief Used codec type for stream. | ||
| 100 | enum PVR_CODEC_TYPE codec_type; | ||
| 101 | |||
| 102 | /// @brief Related codec identifier, normally match the ffmpeg id's. | ||
| 103 | unsigned int codec_id; | ||
| 104 | } PVR_CODEC; | ||
| 105 | ///@} | ||
| 106 | //---------------------------------------------------------------------------- | ||
| 107 | |||
| 108 | /*! | ||
| 109 | * @brief "C" Stream properties | ||
| 110 | * | ||
| 111 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 112 | * | ||
| 113 | * See @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties for description of values. | ||
| 114 | */ | ||
| 115 | typedef struct PVR_STREAM_PROPERTIES | ||
| 116 | { | ||
| 117 | unsigned int iStreamCount; | ||
| 118 | struct PVR_STREAM | ||
| 119 | { | ||
| 120 | unsigned int iPID; | ||
| 121 | enum PVR_CODEC_TYPE iCodecType; | ||
| 122 | unsigned int iCodecId; | ||
| 123 | char strLanguage[4]; | ||
| 124 | int iSubtitleInfo; | ||
| 125 | int iFPSScale; | ||
| 126 | int iFPSRate; | ||
| 127 | int iHeight; | ||
| 128 | int iWidth; | ||
| 129 | float fAspect; | ||
| 130 | int iChannels; | ||
| 131 | int iSampleRate; | ||
| 132 | int iBlockAlign; | ||
| 133 | int iBitRate; | ||
| 134 | int iBitsPerSample; | ||
| 135 | } stream[PVR_STREAM_MAX_STREAMS]; | ||
| 136 | } PVR_STREAM_PROPERTIES; | ||
| 137 | |||
| 138 | /*! | ||
| 139 | * @brief "C" Times of playing stream (Live TV and recordings) | ||
| 140 | * | ||
| 141 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 142 | * | ||
| 143 | * See @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes for description of values. | ||
| 144 | */ | ||
| 145 | typedef struct PVR_STREAM_TIMES | ||
| 146 | { | ||
| 147 | time_t startTime; | ||
| 148 | int64_t ptsStart; | ||
| 149 | int64_t ptsBegin; | ||
| 150 | int64_t ptsEnd; | ||
| 151 | } PVR_STREAM_TIMES; | ||
| 152 | |||
| 153 | #ifdef __cplusplus | ||
| 154 | } | ||
| 155 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h new file mode 100644 index 0000000..bc16adb --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h | |||
| @@ -0,0 +1,407 @@ | |||
| 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 "pvr_defines.h" | ||
| 12 | |||
| 13 | #include <stdbool.h> | ||
| 14 | #include <stdint.h> | ||
| 15 | #include <time.h> | ||
| 16 | |||
| 17 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 18 | // "C" Definitions group 6 - PVR timers | ||
| 19 | #ifdef __cplusplus | ||
| 20 | extern "C" | ||
| 21 | { | ||
| 22 | #endif /* __cplusplus */ | ||
| 23 | |||
| 24 | //============================================================================ | ||
| 25 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_ definition PVR_TIMER (various) | ||
| 26 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer | ||
| 27 | /// @brief **PVR timer various different definitions**\n | ||
| 28 | /// This mostly used on @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer "kodi::addon::PVRTimer" | ||
| 29 | /// to define default or not available. | ||
| 30 | /// | ||
| 31 | ///@{ | ||
| 32 | |||
| 33 | //============================================================================ | ||
| 34 | /// @brief Numeric PVR timer type definitions (@ref kodi::addon::PVRTimer::SetTimerType() | ||
| 35 | /// values). | ||
| 36 | /// | ||
| 37 | /// "Null" value for a numeric timer type. | ||
| 38 | #define PVR_TIMER_TYPE_NONE 0 | ||
| 39 | //---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | //============================================================================ | ||
| 42 | /// @brief Special @ref kodi::addon::PVRTimer::SetClientIndex() value to indicate | ||
| 43 | /// that a timer has not (yet) a valid client index. | ||
| 44 | /// | ||
| 45 | /// Timer has not (yet) a valid client index. | ||
| 46 | #define PVR_TIMER_NO_CLIENT_INDEX 0 | ||
| 47 | //---------------------------------------------------------------------------- | ||
| 48 | |||
| 49 | //============================================================================ | ||
| 50 | /// @brief Special @ref kodi::addon::PVRTimer::SetParentClientIndex() value to | ||
| 51 | /// indicate that a timer has no parent. | ||
| 52 | /// | ||
| 53 | /// Timer has no parent; it was not scheduled by a repeating timer. | ||
| 54 | #define PVR_TIMER_NO_PARENT PVR_TIMER_NO_CLIENT_INDEX | ||
| 55 | //---------------------------------------------------------------------------- | ||
| 56 | |||
| 57 | //============================================================================ | ||
| 58 | /// @brief Special @ref kodi::addon::PVRTimer::SetEPGUid() value to indicate | ||
| 59 | /// that a timer has no EPG event uid. | ||
| 60 | /// | ||
| 61 | /// Timer has no EPG event unique identifier. | ||
| 62 | #define PVR_TIMER_NO_EPG_UID EPG_TAG_INVALID_UID | ||
| 63 | //---------------------------------------------------------------------------- | ||
| 64 | |||
| 65 | //============================================================================ | ||
| 66 | /// @brief Special @ref kodi::addon::PVRTimer::SetClientChannelUid() value to | ||
| 67 | /// indicate "any channel". Useful for some repeating timer types. | ||
| 68 | /// | ||
| 69 | /// denotes "any channel", not a specific one. | ||
| 70 | /// | ||
| 71 | #define PVR_TIMER_ANY_CHANNEL -1 | ||
| 72 | //---------------------------------------------------------------------------- | ||
| 73 | |||
| 74 | //============================================================================ | ||
| 75 | /// @brief Value where set in background to inform that related part not used. | ||
| 76 | /// | ||
| 77 | /// Normally this related parts need not to set by this as it is default. | ||
| 78 | #define PVR_TIMER_VALUE_NOT_AVAILABLE -1 | ||
| 79 | //---------------------------------------------------------------------------- | ||
| 80 | |||
| 81 | ///@} | ||
| 82 | //---------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | |||
| 85 | //============================================================================ | ||
| 86 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_TYPES enum PVR_TIMER_TYPES | ||
| 87 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer | ||
| 88 | /// @brief **PVR timer type attributes (@ref kodi::addon::PVRTimerType::SetAttributes() values).**\n | ||
| 89 | /// To defines the attributes for a type. These values are bit fields that can be | ||
| 90 | /// used together. | ||
| 91 | /// | ||
| 92 | ///-------------------------------------------------------------------------- | ||
| 93 | /// | ||
| 94 | /// **Example:** | ||
| 95 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 96 | /// kodi::addon::PVRTimerType tag; | ||
| 97 | /// tag.SetAttributes(PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_IS_REPEATING); | ||
| 98 | /// ~~~~~~~~~~~~~ | ||
| 99 | /// | ||
| 100 | ///@{ | ||
| 101 | typedef enum PVR_TIMER_TYPES | ||
| 102 | { | ||
| 103 | /// @brief __0000 0000 0000 0000 0000 0000 0000 0000__ :\n Empty attribute value. | ||
| 104 | PVR_TIMER_TYPE_ATTRIBUTE_NONE = 0, | ||
| 105 | |||
| 106 | /// @brief __0000 0000 0000 0000 0000 0000 0000 0001__ :\n Defines whether this is a type for | ||
| 107 | /// manual (time-based) or epg-based timers. | ||
| 108 | PVR_TIMER_TYPE_IS_MANUAL = (1 << 0), | ||
| 109 | |||
| 110 | /// @brief __0000 0000 0000 0000 0000 0000 0000 0010__ :\n Defines whether this is a type for | ||
| 111 | /// repeating or one-shot timers. | ||
| 112 | PVR_TIMER_TYPE_IS_REPEATING = (1 << 1), | ||
| 113 | |||
| 114 | /// @brief __0000 0000 0000 0000 0000 0000 0000 0100__ :\n Timers of this type must not be edited | ||
| 115 | /// by Kodi. | ||
| 116 | PVR_TIMER_TYPE_IS_READONLY = (1 << 2), | ||
| 117 | |||
| 118 | /// @brief __0000 0000 0000 0000 0000 0000 0000 1000__ :\n Timers of this type must not be created | ||
| 119 | /// by Kodi. All other operations are allowed, though. | ||
| 120 | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES = (1 << 3), | ||
| 121 | |||
| 122 | /// @brief __0000 0000 0000 0000 0000 0000 0001 0000__ :\n This type supports enabling/disabling | ||
| 123 | /// of the timer (@ref kodi::addon::PVRTimer::SetState() with | ||
| 124 | /// @ref PVR_TIMER_STATE_SCHEDULED | @ref PVR_TIMER_STATE_DISABLED). | ||
| 125 | PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE = (1 << 4), | ||
| 126 | |||
| 127 | /// @brief __0000 0000 0000 0000 0000 0000 0010 0000__ :\n This type supports channels | ||
| 128 | /// (@ref kodi::addon::PVRTimer::SetClientChannelUid()). | ||
| 129 | PVR_TIMER_TYPE_SUPPORTS_CHANNELS = (1 << 5), | ||
| 130 | |||
| 131 | /// @brief __0000 0000 0000 0000 0000 0000 0100 0000__ :\n This type supports a recording start | ||
| 132 | /// time (@ref kodi::addon::PVRTimer::SetStartTime()). | ||
| 133 | PVR_TIMER_TYPE_SUPPORTS_START_TIME = (1 << 6), | ||
| 134 | |||
| 135 | /// @brief __0000 0000 0000 0000 0000 0000 1000 0000__ :\n This type supports matching epg episode | ||
| 136 | /// title using@ref kodi::addon::PVRTimer::SetEPGSearchString(). | ||
| 137 | PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH = (1 << 7), | ||
| 138 | |||
| 139 | /// @brief __0000 0000 0000 0000 0000 0001 0000 0000__ :\n This type supports matching "more" epg | ||
| 140 | /// data (not just episode title) using @ref kodi::addon::PVRTimer::SetEPGSearchString(). | ||
| 141 | /// Setting @ref PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH implies | ||
| 142 | /// @ref PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH. | ||
| 143 | PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH = (1 << 8), | ||
| 144 | |||
| 145 | /// @brief __0000 0000 0000 0000 0000 0010 0000 0000__ :\n This type supports a first day the | ||
| 146 | /// timer gets active (@ref kodi::addon::PVRTimer::SetFirstDay()). | ||
| 147 | PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY = (1 << 9), | ||
| 148 | |||
| 149 | /// @brief __0000 0000 0000 0000 0000 0100 0000 0000__ :\n This type supports weekdays for | ||
| 150 | /// defining the recording schedule (@ref kodi::addon::PVRTimer::SetWeekdays()). | ||
| 151 | PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS = (1 << 10), | ||
| 152 | |||
| 153 | /// @brief __0000 0000 0000 0000 0000 1000 0000 0000__ :\n This type supports the <b>"record only new episodes"</b> feature | ||
| 154 | /// (@ref kodi::addon::PVRTimer::SetPreventDuplicateEpisodes()). | ||
| 155 | PVR_TIMER_TYPE_SUPPORTS_RECORD_ONLY_NEW_EPISODES = (1 << 11), | ||
| 156 | |||
| 157 | /// @brief __0000 0000 0000 0000 0001 0000 0000 0000__ :\n This type supports pre and post record time (@ref kodi::addon::PVRTimer::SetMarginStart(), | ||
| 158 | /// @ref kodi::addon::PVRTimer::SetMarginEnd()). | ||
| 159 | PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN = (1 << 12), | ||
| 160 | |||
| 161 | /// @brief __0000 0000 0000 0000 0010 0000 0000 0000__ :\n This type supports recording priority (@ref kodi::addon::PVRTimer::SetPriority()). | ||
| 162 | PVR_TIMER_TYPE_SUPPORTS_PRIORITY = (1 << 13), | ||
| 163 | |||
| 164 | /// @brief __0000 0000 0000 0000 0100 0000 0000 0000__ :\n This type supports recording lifetime (@ref kodi::addon::PVRTimer::SetLifetime()). | ||
| 165 | PVR_TIMER_TYPE_SUPPORTS_LIFETIME = (1 << 14), | ||
| 166 | |||
| 167 | /// @brief __0000 0000 0000 0000 1000 0000 0000 0000__ :\n This type supports placing recordings in user defined folders | ||
| 168 | /// (@ref kodi::addon::PVRTimer::SetDirectory()). | ||
| 169 | PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS = (1 << 15), | ||
| 170 | |||
| 171 | /// @brief __0000 0000 0000 0001 0000 0000 0000 0000__ :\n This type supports a list of recording groups | ||
| 172 | /// (@ref kodi::addon::PVRTimer::SetRecordingGroup()). | ||
| 173 | PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP = (1 << 16), | ||
| 174 | |||
| 175 | /// @brief __0000 0000 0000 0010 0000 0000 0000 0000__ :\n This type supports a recording end time (@ref kodi::addon::PVRTimer::SetEndTime()). | ||
| 176 | PVR_TIMER_TYPE_SUPPORTS_END_TIME = (1 << 17), | ||
| 177 | |||
| 178 | /// @brief __0000 0000 0000 0100 0000 0000 0000 0000__ :\n Enables an 'Any Time' over-ride option for start time | ||
| 179 | /// (using @ref kodi::addon::PVRTimer::SetStartAnyTime()). | ||
| 180 | PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME = (1 << 18), | ||
| 181 | |||
| 182 | /// @brief __0000 0000 0000 1000 0000 0000 0000 0000__ :\n Enables a separate <b>'Any Time'</b> over-ride for end time | ||
| 183 | /// (using @ref kodi::addon::PVRTimer::SetEndAnyTime()). | ||
| 184 | PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME = (1 << 19), | ||
| 185 | |||
| 186 | /// @brief __0000 0000 0001 0000 0000 0000 0000 0000__ :\n This type supports specifying a maximum recordings setting' | ||
| 187 | /// (@ref kodi::addon::PVRTimer::SetMaxRecordings()). | ||
| 188 | PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS = (1 << 20), | ||
| 189 | |||
| 190 | /// @brief __0000 0000 0010 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus which don't | ||
| 191 | /// provide an associated @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag". | ||
| 192 | PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE = (1 << 21), | ||
| 193 | |||
| 194 | /// @brief __0000 0000 0100 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus which provide an | ||
| 195 | /// associated @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag". | ||
| 196 | PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE = (1 << 22), | ||
| 197 | |||
| 198 | /// @brief __0000 0000 1000 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus unless associated | ||
| 199 | /// with an @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag" with | ||
| 200 | /// 'series' attributes. | ||
| 201 | /// | ||
| 202 | /// Following conditions allow this: | ||
| 203 | /// - @ref kodi::addon::PVREPGTag::SetFlags() have flag @ref EPG_TAG_FLAG_IS_SERIES | ||
| 204 | /// - @ref kodi::addon::PVREPGTag::SetSeriesNumber() > 0 | ||
| 205 | /// - @ref kodi::addon::PVREPGTag::SetEpisodeNumber() > 0 | ||
| 206 | /// - @ref kodi::addon::PVREPGTag::SetEpisodePartNumber() > 0 | ||
| 207 | /// | ||
| 208 | /// Implies @ref PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE. | ||
| 209 | PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE = (1 << 23), | ||
| 210 | |||
| 211 | /// @brief __0000 0001 0000 0000 0000 0000 0000 0000__ :\n This type supports 'any channel', for example when defining a timer | ||
| 212 | /// rule that should match any channel instaed of a particular channel. | ||
| 213 | PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL = (1 << 24), | ||
| 214 | |||
| 215 | /// @brief __0000 0010 0000 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus which don't provide | ||
| 216 | /// an associated @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag" with | ||
| 217 | /// a series link. | ||
| 218 | PVR_TIMER_TYPE_REQUIRES_EPG_SERIESLINK_ON_CREATE = (1 << 25), | ||
| 219 | |||
| 220 | /// @brief __0000 0100 0000 0000 0000 0000 0000 0000__ :\n This type allows deletion of an otherwise read-only timer. | ||
| 221 | PVR_TIMER_TYPE_SUPPORTS_READONLY_DELETE = (1 << 26), | ||
| 222 | |||
| 223 | /// @brief __0000 1000 0000 0000 0000 0000 0000 0000__ :\n Timers of this type do trigger a reminder if time is up. | ||
| 224 | PVR_TIMER_TYPE_IS_REMINDER = (1 << 27), | ||
| 225 | |||
| 226 | /// @brief __0001 0000 0000 0000 0000 0000 0000 0000__ :\n This type supports pre record time (@ref kodi::addon::PVRTimer::SetMarginStart()). | ||
| 227 | PVR_TIMER_TYPE_SUPPORTS_START_MARGIN = (1 << 28), | ||
| 228 | |||
| 229 | /// @brief __0010 0000 0000 0000 0000 0000 0000 0000__ :\n This type supports post record time (@ref kodi::addon::PVRTimer::SetMarginEnd()). | ||
| 230 | PVR_TIMER_TYPE_SUPPORTS_END_MARGIN = (1 << 29), | ||
| 231 | } PVR_TIMER_TYPES; | ||
| 232 | ///@} | ||
| 233 | //---------------------------------------------------------------------------- | ||
| 234 | |||
| 235 | //============================================================================ | ||
| 236 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_WEEKDAY enum PVR_WEEKDAY | ||
| 237 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer | ||
| 238 | /// @brief **PVR timer weekdays** (@ref kodi::addon::PVRTimer::SetWeekdays() **values**)\n | ||
| 239 | /// Used to select the days of a week you want. | ||
| 240 | /// | ||
| 241 | /// It can be also used to select several days e.g.: | ||
| 242 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 243 | /// ... | ||
| 244 | /// unsigned int day = PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_SATURDAY; | ||
| 245 | /// ... | ||
| 246 | /// ~~~~~~~~~~~~~ | ||
| 247 | /// | ||
| 248 | ///@{ | ||
| 249 | typedef enum PVR_WEEKDAYS | ||
| 250 | { | ||
| 251 | /// @brief __0000 0000__ : Nothing selected. | ||
| 252 | PVR_WEEKDAY_NONE = 0, | ||
| 253 | |||
| 254 | /// @brief __0000 0001__ : To select Monday. | ||
| 255 | PVR_WEEKDAY_MONDAY = (1 << 0), | ||
| 256 | |||
| 257 | /// @brief __0000 0010__ : To select Tuesday. | ||
| 258 | PVR_WEEKDAY_TUESDAY = (1 << 1), | ||
| 259 | |||
| 260 | /// @brief __0000 0100__ : To select Wednesday. | ||
| 261 | PVR_WEEKDAY_WEDNESDAY = (1 << 2), | ||
| 262 | |||
| 263 | /// @brief __0000 1000__ : To select Thursday. | ||
| 264 | PVR_WEEKDAY_THURSDAY = (1 << 3), | ||
| 265 | |||
| 266 | /// @brief __0001 0000__ : To select Friday. | ||
| 267 | PVR_WEEKDAY_FRIDAY = (1 << 4), | ||
| 268 | |||
| 269 | /// @brief __0010 0000__ : To select Saturday. | ||
| 270 | PVR_WEEKDAY_SATURDAY = (1 << 5), | ||
| 271 | |||
| 272 | /// @brief __0100 0000__ : To select Sunday. | ||
| 273 | PVR_WEEKDAY_SUNDAY = (1 << 6), | ||
| 274 | |||
| 275 | /// @brief __0111 1111__ : To select all days of week. | ||
| 276 | PVR_WEEKDAY_ALLDAYS = PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_TUESDAY | PVR_WEEKDAY_WEDNESDAY | | ||
| 277 | PVR_WEEKDAY_THURSDAY | PVR_WEEKDAY_FRIDAY | PVR_WEEKDAY_SATURDAY | | ||
| 278 | PVR_WEEKDAY_SUNDAY | ||
| 279 | } PVR_WEEKDAY; | ||
| 280 | ///@} | ||
| 281 | //---------------------------------------------------------------------------- | ||
| 282 | |||
| 283 | //============================================================================ | ||
| 284 | /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_STATE enum PVR_TIMER_STATE | ||
| 285 | /// @ingroup cpp_kodi_addon_pvr_Defs_Timer | ||
| 286 | /// @brief **PVR timer states**\n | ||
| 287 | /// To set within @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer "kodi::addon::PVRTimer" | ||
| 288 | /// the needed state about. | ||
| 289 | /// | ||
| 290 | ///@{ | ||
| 291 | typedef enum PVR_TIMER_STATE | ||
| 292 | { | ||
| 293 | /// @brief __0__ : The timer was just created on the backend and is not yet active. | ||
| 294 | /// | ||
| 295 | /// This state must not be used for timers just created on the client side. | ||
| 296 | PVR_TIMER_STATE_NEW = 0, | ||
| 297 | |||
| 298 | /// @brief __1__ : The timer is scheduled for recording. | ||
| 299 | PVR_TIMER_STATE_SCHEDULED = 1, | ||
| 300 | |||
| 301 | /// @brief __2__ : The timer is currently recordings. | ||
| 302 | PVR_TIMER_STATE_RECORDING = 2, | ||
| 303 | |||
| 304 | /// @brief __3__ : The recording completed successfully. | ||
| 305 | PVR_TIMER_STATE_COMPLETED = 3, | ||
| 306 | |||
| 307 | /// @brief __4__ : Recording started, but was aborted. | ||
| 308 | PVR_TIMER_STATE_ABORTED = 4, | ||
| 309 | |||
| 310 | /// @brief __5__ : The timer was scheduled, but was canceled. | ||
| 311 | PVR_TIMER_STATE_CANCELLED = 5, | ||
| 312 | |||
| 313 | /// @brief __6__ : The scheduled timer conflicts with another one, but will be | ||
| 314 | /// recorded. | ||
| 315 | PVR_TIMER_STATE_CONFLICT_OK = 6, | ||
| 316 | |||
| 317 | /// @brief __7__ : The scheduled timer conflicts with another one and won't be | ||
| 318 | /// recorded. | ||
| 319 | PVR_TIMER_STATE_CONFLICT_NOK = 7, | ||
| 320 | |||
| 321 | /// @brief __8__ : The timer is scheduled, but can't be recorded for some reason. | ||
| 322 | PVR_TIMER_STATE_ERROR = 8, | ||
| 323 | |||
| 324 | /// @brief __9__ : The timer was disabled by the user, can be enabled via setting | ||
| 325 | /// the state to @ref PVR_TIMER_STATE_SCHEDULED. | ||
| 326 | PVR_TIMER_STATE_DISABLED = 9, | ||
| 327 | } PVR_TIMER_STATE; | ||
| 328 | ///@} | ||
| 329 | //---------------------------------------------------------------------------- | ||
| 330 | |||
| 331 | /*! | ||
| 332 | * @brief "C" PVR add-on timer event. | ||
| 333 | * | ||
| 334 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 335 | * | ||
| 336 | * See @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer "kodi::addon::PVRTimer" for | ||
| 337 | * description of values. | ||
| 338 | */ | ||
| 339 | typedef struct PVR_TIMER | ||
| 340 | { | ||
| 341 | unsigned int iClientIndex; | ||
| 342 | unsigned int iParentClientIndex; | ||
| 343 | int iClientChannelUid; | ||
| 344 | time_t startTime; | ||
| 345 | time_t endTime; | ||
| 346 | bool bStartAnyTime; | ||
| 347 | bool bEndAnyTime; | ||
| 348 | enum PVR_TIMER_STATE state; | ||
| 349 | unsigned int iTimerType; | ||
| 350 | char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 351 | char strEpgSearchString[PVR_ADDON_NAME_STRING_LENGTH]; | ||
| 352 | bool bFullTextEpgSearch; | ||
| 353 | char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 354 | char strSummary[PVR_ADDON_DESC_STRING_LENGTH]; | ||
| 355 | int iPriority; | ||
| 356 | int iLifetime; | ||
| 357 | int iMaxRecordings; | ||
| 358 | unsigned int iRecordingGroup; | ||
| 359 | time_t firstDay; | ||
| 360 | unsigned int iWeekdays; | ||
| 361 | unsigned int iPreventDuplicateEpisodes; | ||
| 362 | unsigned int iEpgUid; | ||
| 363 | unsigned int iMarginStart; | ||
| 364 | unsigned int iMarginEnd; | ||
| 365 | int iGenreType; | ||
| 366 | int iGenreSubType; | ||
| 367 | char strSeriesLink[PVR_ADDON_URL_STRING_LENGTH]; | ||
| 368 | } PVR_TIMER; | ||
| 369 | |||
| 370 | /*! | ||
| 371 | * @brief "C" PVR add-on timer event type. | ||
| 372 | * | ||
| 373 | * Structure used to interface in "C" between Kodi and Addon. | ||
| 374 | * | ||
| 375 | * See @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType "kodi::addon::PVRTimerType" for | ||
| 376 | * description of values. | ||
| 377 | */ | ||
| 378 | typedef struct PVR_TIMER_TYPE | ||
| 379 | { | ||
| 380 | unsigned int iId; | ||
| 381 | uint64_t iAttributes; | ||
| 382 | char strDescription[PVR_ADDON_TIMERTYPE_STRING_LENGTH]; | ||
| 383 | |||
| 384 | unsigned int iPrioritiesSize; | ||
| 385 | struct PVR_ATTRIBUTE_INT_VALUE priorities[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; | ||
| 386 | int iPrioritiesDefault; | ||
| 387 | |||
| 388 | unsigned int iLifetimesSize; | ||
| 389 | struct PVR_ATTRIBUTE_INT_VALUE lifetimes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; | ||
| 390 | int iLifetimesDefault; | ||
| 391 | |||
| 392 | unsigned int iPreventDuplicateEpisodesSize; | ||
| 393 | struct PVR_ATTRIBUTE_INT_VALUE preventDuplicateEpisodes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; | ||
| 394 | unsigned int iPreventDuplicateEpisodesDefault; | ||
| 395 | |||
| 396 | unsigned int iRecordingGroupSize; | ||
| 397 | struct PVR_ATTRIBUTE_INT_VALUE recordingGroup[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; | ||
| 398 | unsigned int iRecordingGroupDefault; | ||
| 399 | |||
| 400 | unsigned int iMaxRecordingsSize; | ||
| 401 | struct PVR_ATTRIBUTE_INT_VALUE maxRecordings[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL]; | ||
| 402 | int iMaxRecordingsDefault; | ||
| 403 | } PVR_TIMER_TYPE; | ||
| 404 | |||
| 405 | #ifdef __cplusplus | ||
| 406 | } | ||
| 407 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon_base.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon_base.h new file mode 100644 index 0000000..1924d77 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/addon_base.h | |||
| @@ -0,0 +1,252 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 "stdbool.h" | ||
| 12 | #include "stdint.h" | ||
| 13 | |||
| 14 | #ifndef TARGET_WINDOWS | ||
| 15 | #ifndef __cdecl | ||
| 16 | #define __cdecl | ||
| 17 | #endif | ||
| 18 | #ifndef __declspec | ||
| 19 | #define __declspec(X) | ||
| 20 | #endif | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #undef ATTRIBUTE_PACKED | ||
| 24 | #undef PRAGMA_PACK_BEGIN | ||
| 25 | #undef PRAGMA_PACK_END | ||
| 26 | |||
| 27 | #if defined(__GNUC__) | ||
| 28 | #define ATTRIBUTE_PACKED __attribute__((packed)) | ||
| 29 | #define PRAGMA_PACK 0 | ||
| 30 | #define ATTRIBUTE_HIDDEN __attribute__((visibility("hidden"))) | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #if !defined(ATTRIBUTE_PACKED) | ||
| 34 | #define ATTRIBUTE_PACKED | ||
| 35 | #define PRAGMA_PACK 1 | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #if !defined(ATTRIBUTE_HIDDEN) | ||
| 39 | #define ATTRIBUTE_HIDDEN | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifdef _MSC_VER | ||
| 43 | #define ATTRIBUTE_FORCEINLINE __forceinline | ||
| 44 | #elif defined(__GNUC__) | ||
| 45 | #define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__)) | ||
| 46 | #elif defined(__CLANG__) | ||
| 47 | #if __has_attribute(__always_inline__) | ||
| 48 | #define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__)) | ||
| 49 | #else | ||
| 50 | #define ATTRIBUTE_FORCEINLINE inline | ||
| 51 | #endif | ||
| 52 | #else | ||
| 53 | #define ATTRIBUTE_FORCEINLINE inline | ||
| 54 | #endif | ||
| 55 | |||
| 56 | /* | ||
| 57 | * To have a on add-on and kodi itself handled string always on known size! | ||
| 58 | */ | ||
| 59 | #define ADDON_STANDARD_STRING_LENGTH 1024 | ||
| 60 | #define ADDON_STANDARD_STRING_LENGTH_SMALL 256 | ||
| 61 | |||
| 62 | #ifdef __cplusplus | ||
| 63 | extern "C" | ||
| 64 | { | ||
| 65 | #endif /* __cplusplus */ | ||
| 66 | |||
| 67 | //============================================================================ | ||
| 68 | /// @ingroup cpp_kodi_addon_addonbase | ||
| 69 | /// @brief Return value of functions in @ref cpp_kodi_addon_addonbase "kodi::addon::CAddonBase" | ||
| 70 | /// and associated classes. | ||
| 71 | /// | ||
| 72 | ///@{ | ||
| 73 | typedef enum ADDON_STATUS | ||
| 74 | { | ||
| 75 | /// @brief For everything OK and no error | ||
| 76 | ADDON_STATUS_OK, | ||
| 77 | |||
| 78 | /// @brief A needed connection was lost | ||
| 79 | ADDON_STATUS_LOST_CONNECTION, | ||
| 80 | |||
| 81 | /// @brief Addon needs a restart inside Kodi | ||
| 82 | ADDON_STATUS_NEED_RESTART, | ||
| 83 | |||
| 84 | /// @brief Necessary settings are not yet set | ||
| 85 | ADDON_STATUS_NEED_SETTINGS, | ||
| 86 | |||
| 87 | /// @brief Unknown and incomprehensible error | ||
| 88 | ADDON_STATUS_UNKNOWN, | ||
| 89 | |||
| 90 | /// @brief Permanent failure, like failing to resolve methods | ||
| 91 | ADDON_STATUS_PERMANENT_FAILURE, | ||
| 92 | |||
| 93 | /* internal used return error if function becomes not used from child on | ||
| 94 | * addon */ | ||
| 95 | ADDON_STATUS_NOT_IMPLEMENTED | ||
| 96 | } ADDON_STATUS; | ||
| 97 | ///@} | ||
| 98 | //---------------------------------------------------------------------------- | ||
| 99 | |||
| 100 | //============================================================================ | ||
| 101 | /// @defgroup cpp_kodi_Defs_AddonLog enum AddonLog | ||
| 102 | /// @ingroup cpp_kodi_Defs | ||
| 103 | /// @brief **Log file type definitions**\n | ||
| 104 | /// These define the types of log entries given with @ref kodi::Log() to Kodi. | ||
| 105 | /// | ||
| 106 | /// ------------------------------------------------------------------------- | ||
| 107 | /// | ||
| 108 | /// **Example:** | ||
| 109 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 110 | /// #include <kodi/General.h> | ||
| 111 | /// | ||
| 112 | /// kodi::Log(ADDON_LOG_ERROR, "%s: There is an error occurred!", __func__); | ||
| 113 | /// | ||
| 114 | /// ~~~~~~~~~~~~~ | ||
| 115 | /// | ||
| 116 | ///@{ | ||
| 117 | typedef enum AddonLog | ||
| 118 | { | ||
| 119 | /// @brief **0** : To include debug information in the log file. | ||
| 120 | ADDON_LOG_DEBUG = 0, | ||
| 121 | |||
| 122 | /// @brief **1** : To include information messages in the log file. | ||
| 123 | ADDON_LOG_INFO = 1, | ||
| 124 | |||
| 125 | /// @brief **2** : To write warnings in the log file. | ||
| 126 | ADDON_LOG_WARNING = 2, | ||
| 127 | |||
| 128 | /// @brief **3** : To report error messages in the log file. | ||
| 129 | ADDON_LOG_ERROR = 3, | ||
| 130 | |||
| 131 | /// @brief **4** : To notify fatal unrecoverable errors, which can may also indicate | ||
| 132 | /// upcoming crashes. | ||
| 133 | ADDON_LOG_FATAL = 4 | ||
| 134 | } AddonLog; | ||
| 135 | ///@} | ||
| 136 | //---------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | /*! @brief Standard undefined pointer handle */ | ||
| 139 | typedef void* KODI_HANDLE; | ||
| 140 | |||
| 141 | /*! | ||
| 142 | * @brief Handle used to return data from the PVR add-on to CPVRClient | ||
| 143 | */ | ||
| 144 | struct ADDON_HANDLE_STRUCT | ||
| 145 | { | ||
| 146 | void* callerAddress; /*!< address of the caller */ | ||
| 147 | void* dataAddress; /*!< address to store data in */ | ||
| 148 | int dataIdentifier; /*!< parameter to pass back when calling the callback */ | ||
| 149 | }; | ||
| 150 | typedef struct ADDON_HANDLE_STRUCT* ADDON_HANDLE; | ||
| 151 | |||
| 152 | /*! | ||
| 153 | * @brief Callback function tables from addon to Kodi | ||
| 154 | * Set complete from Kodi! | ||
| 155 | */ | ||
| 156 | struct AddonToKodiFuncTable_kodi; | ||
| 157 | struct AddonToKodiFuncTable_kodi_audioengine; | ||
| 158 | struct AddonToKodiFuncTable_kodi_filesystem; | ||
| 159 | struct AddonToKodiFuncTable_kodi_network; | ||
| 160 | struct AddonToKodiFuncTable_kodi_gui; | ||
| 161 | typedef struct AddonToKodiFuncTable_Addon | ||
| 162 | { | ||
| 163 | // Pointer inside Kodi, used on callback functions to give related handle | ||
| 164 | // class, for this ADDON::CAddonDll inside Kodi. | ||
| 165 | KODI_HANDLE kodiBase; | ||
| 166 | |||
| 167 | // Function addresses used for callbacks from addon to Kodi | ||
| 168 | char* (*get_type_version)(void* kodiBase, int type); | ||
| 169 | |||
| 170 | void (*free_string)(void* kodiBase, char* str); | ||
| 171 | void (*free_string_array)(void* kodiBase, char** arr, int numElements); | ||
| 172 | char* (*get_addon_path)(void* kodiBase); | ||
| 173 | char* (*get_base_user_path)(void* kodiBase); | ||
| 174 | void (*addon_log_msg)(void* kodiBase, const int loglevel, const char* msg); | ||
| 175 | |||
| 176 | bool (*get_setting_bool)(void* kodiBase, const char* id, bool* value); | ||
| 177 | bool (*get_setting_int)(void* kodiBase, const char* id, int* value); | ||
| 178 | bool (*get_setting_float)(void* kodiBase, const char* id, float* value); | ||
| 179 | bool (*get_setting_string)(void* kodiBase, const char* id, char** value); | ||
| 180 | |||
| 181 | bool (*set_setting_bool)(void* kodiBase, const char* id, bool value); | ||
| 182 | bool (*set_setting_int)(void* kodiBase, const char* id, int value); | ||
| 183 | bool (*set_setting_float)(void* kodiBase, const char* id, float value); | ||
| 184 | bool (*set_setting_string)(void* kodiBase, const char* id, const char* value); | ||
| 185 | |||
| 186 | void* (*get_interface)(void* kodiBase, const char* name, const char* version); | ||
| 187 | |||
| 188 | struct AddonToKodiFuncTable_kodi* kodi; | ||
| 189 | struct AddonToKodiFuncTable_kodi_audioengine* kodi_audioengine; | ||
| 190 | struct AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem; | ||
| 191 | struct AddonToKodiFuncTable_kodi_gui* kodi_gui; | ||
| 192 | struct AddonToKodiFuncTable_kodi_network* kodi_network; | ||
| 193 | |||
| 194 | // Move up by min version change about | ||
| 195 | bool (*is_setting_using_default)(void* kodiBase, const char* id); | ||
| 196 | } AddonToKodiFuncTable_Addon; | ||
| 197 | |||
| 198 | /*! | ||
| 199 | * @brief Function tables from Kodi to addon | ||
| 200 | */ | ||
| 201 | typedef struct KodiToAddonFuncTable_Addon | ||
| 202 | { | ||
| 203 | void (*destroy)(); | ||
| 204 | ADDON_STATUS (*get_status)(); | ||
| 205 | ADDON_STATUS(*create_instance) | ||
| 206 | (int instanceType, | ||
| 207 | const char* instanceID, | ||
| 208 | KODI_HANDLE instance, | ||
| 209 | const char* version, | ||
| 210 | KODI_HANDLE* addonInstance, | ||
| 211 | KODI_HANDLE parent); | ||
| 212 | void (*destroy_instance)(int instanceType, KODI_HANDLE instance); | ||
| 213 | ADDON_STATUS (*set_setting)(const char* settingName, const void* settingValue); | ||
| 214 | } KodiToAddonFuncTable_Addon; | ||
| 215 | |||
| 216 | /*! | ||
| 217 | * @brief Main structure passed from kodi to addon with basic information needed to | ||
| 218 | * create add-on. | ||
| 219 | */ | ||
| 220 | typedef struct AddonGlobalInterface | ||
| 221 | { | ||
| 222 | // String with full path where add-on is installed (without his name on end) | ||
| 223 | // Set from Kodi! | ||
| 224 | const char* libBasePath; | ||
| 225 | |||
| 226 | // Master API version of Kodi itself (ADDON_GLOBAL_VERSION_MAIN) | ||
| 227 | const char* kodi_base_api_version; | ||
| 228 | |||
| 229 | // Pointer of first created instance, used in case this add-on goes with single way | ||
| 230 | // Set from Kodi! | ||
| 231 | KODI_HANDLE firstKodiInstance; | ||
| 232 | |||
| 233 | // Pointer to master base class inside add-on | ||
| 234 | // Set from addon header (kodi::addon::CAddonBase)! | ||
| 235 | KODI_HANDLE addonBase; | ||
| 236 | |||
| 237 | // Pointer to a instance used on single way (together with this class) | ||
| 238 | // Set from addon header (kodi::addon::IAddonInstance)! | ||
| 239 | KODI_HANDLE globalSingleInstance; | ||
| 240 | |||
| 241 | // Callback function tables from addon to Kodi | ||
| 242 | // Set from Kodi! | ||
| 243 | AddonToKodiFuncTable_Addon* toKodi; | ||
| 244 | |||
| 245 | // Function tables from Kodi to addon | ||
| 246 | // Set from addon header! | ||
| 247 | KodiToAddonFuncTable_Addon* toAddon; | ||
| 248 | } AddonGlobalInterface; | ||
| 249 | |||
| 250 | #ifdef __cplusplus | ||
| 251 | } | ||
| 252 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h new file mode 100644 index 0000000..02e96ac --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h | |||
| @@ -0,0 +1,308 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 "stdint.h" | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" | ||
| 15 | { | ||
| 16 | #endif /* __cplusplus */ | ||
| 17 | |||
| 18 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 19 | // "C" Definitions, structures and enumerators of audio engine | ||
| 20 | //{{{ | ||
| 21 | |||
| 22 | //============================================================================ | ||
| 23 | /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineStreamOptions enum AudioEngineStreamOptions | ||
| 24 | /// @ingroup cpp_kodi_audioengine_Defs | ||
| 25 | /// @brief **Bit options to pass to CAEStream**\n | ||
| 26 | /// A bit field of stream options. | ||
| 27 | /// | ||
| 28 | /// | ||
| 29 | /// ------------------------------------------------------------------------ | ||
| 30 | /// | ||
| 31 | /// **Usage example:** | ||
| 32 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 33 | /// // Here only as minimal, "format" must be set to wanted types | ||
| 34 | /// kodi::audioengine::AudioEngineFormat format; | ||
| 35 | /// m_audioengine = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_FORCE_RESAMPLE | AUDIO_STREAM_AUTOSTART); | ||
| 36 | /// ~~~~~~~~~~~~~ | ||
| 37 | /// | ||
| 38 | //@{ | ||
| 39 | typedef enum AudioEngineStreamOptions | ||
| 40 | { | ||
| 41 | /// force resample even if rates match | ||
| 42 | AUDIO_STREAM_FORCE_RESAMPLE = 1 << 0, | ||
| 43 | /// create the stream paused | ||
| 44 | AUDIO_STREAM_PAUSED = 1 << 1, | ||
| 45 | /// autostart the stream when enough data is buffered | ||
| 46 | AUDIO_STREAM_AUTOSTART = 1 << 2, | ||
| 47 | } AudioEngineStreamOptions; | ||
| 48 | //@} | ||
| 49 | //---------------------------------------------------------------------------- | ||
| 50 | |||
| 51 | //============================================================================ | ||
| 52 | /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineChannel enum AudioEngineChannel | ||
| 53 | /// @ingroup cpp_kodi_audioengine_Defs | ||
| 54 | /// @brief **The possible channels**\n | ||
| 55 | /// Used to set available or used channels on stream. | ||
| 56 | /// | ||
| 57 | /// | ||
| 58 | /// ------------------------------------------------------------------------ | ||
| 59 | /// | ||
| 60 | /// **Usage example:** | ||
| 61 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 62 | /// kodi::audioengine::AudioEngineFormat format; | ||
| 63 | /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR)); | ||
| 64 | /// ~~~~~~~~~~~~~ | ||
| 65 | /// | ||
| 66 | //@{ | ||
| 67 | enum AudioEngineChannel | ||
| 68 | { | ||
| 69 | /// Used inside to indicate the end of a list and not for addon use directly. | ||
| 70 | AUDIOENGINE_CH_NULL = -1, | ||
| 71 | /// RAW Audio format | ||
| 72 | AUDIOENGINE_CH_RAW, | ||
| 73 | /// Front left | ||
| 74 | AUDIOENGINE_CH_FL, | ||
| 75 | /// Front right | ||
| 76 | AUDIOENGINE_CH_FR, | ||
| 77 | /// Front center | ||
| 78 | AUDIOENGINE_CH_FC, | ||
| 79 | /// LFE / Subwoofer | ||
| 80 | AUDIOENGINE_CH_LFE, | ||
| 81 | /// Back left | ||
| 82 | AUDIOENGINE_CH_BL, | ||
| 83 | /// Back right | ||
| 84 | AUDIOENGINE_CH_BR, | ||
| 85 | /// Front left over center | ||
| 86 | AUDIOENGINE_CH_FLOC, | ||
| 87 | /// Front right over center | ||
| 88 | AUDIOENGINE_CH_FROC, | ||
| 89 | /// Back center | ||
| 90 | AUDIOENGINE_CH_BC, | ||
| 91 | /// Side left | ||
| 92 | AUDIOENGINE_CH_SL, | ||
| 93 | /// Side right | ||
| 94 | AUDIOENGINE_CH_SR, | ||
| 95 | /// Top front left | ||
| 96 | AUDIOENGINE_CH_TFL, | ||
| 97 | /// Top front right | ||
| 98 | AUDIOENGINE_CH_TFR, | ||
| 99 | /// Top front center | ||
| 100 | AUDIOENGINE_CH_TFC, | ||
| 101 | /// Top center | ||
| 102 | AUDIOENGINE_CH_TC, | ||
| 103 | /// Top back left | ||
| 104 | AUDIOENGINE_CH_TBL, | ||
| 105 | /// Top back right | ||
| 106 | AUDIOENGINE_CH_TBR, | ||
| 107 | /// Top back center | ||
| 108 | AUDIOENGINE_CH_TBC, | ||
| 109 | /// Back left over center | ||
| 110 | AUDIOENGINE_CH_BLOC, | ||
| 111 | /// Back right over center | ||
| 112 | AUDIOENGINE_CH_BROC, | ||
| 113 | /// Maximum possible value, to use e.g. as size inside list | ||
| 114 | AUDIOENGINE_CH_MAX | ||
| 115 | }; | ||
| 116 | //@} | ||
| 117 | //---------------------------------------------------------------------------- | ||
| 118 | |||
| 119 | //============================================================================ | ||
| 120 | /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineDataFormat enum AudioEngineDataFormat | ||
| 121 | /// @ingroup cpp_kodi_audioengine_Defs | ||
| 122 | /// @brief **Audio sample formats**\n | ||
| 123 | /// The bit layout of the audio data. | ||
| 124 | /// | ||
| 125 | /// LE = Little Endian, BE = Big Endian, NE = Native Endian | ||
| 126 | /// | ||
| 127 | /// For planar sample formats, each audio channel is in a separate data plane, | ||
| 128 | /// and linesize is the buffer size, in bytes, for a single plane. All data | ||
| 129 | /// planes must be the same size. For packed sample formats, only the first | ||
| 130 | /// data plane is used, and samples for each channel are interleaved. In this | ||
| 131 | /// case, linesize is the buffer size, in bytes, for the 1 plane. | ||
| 132 | /// | ||
| 133 | /// @note This is ordered from the worst to best preferred formats | ||
| 134 | /// | ||
| 135 | /// | ||
| 136 | /// ------------------------------------------------------------------------ | ||
| 137 | /// | ||
| 138 | /// **Usage example:** | ||
| 139 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 140 | /// kodi::audioengine::AudioEngineFormat format; | ||
| 141 | /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP); | ||
| 142 | /// ~~~~~~~~~~~~~ | ||
| 143 | /// | ||
| 144 | //@{ | ||
| 145 | enum AudioEngineDataFormat | ||
| 146 | { | ||
| 147 | /// To define format as invalid | ||
| 148 | AUDIOENGINE_FMT_INVALID = -1, | ||
| 149 | |||
| 150 | /// Unsigned integer 8 bit | ||
| 151 | AUDIOENGINE_FMT_U8, | ||
| 152 | |||
| 153 | /// Big Endian signed integer 16 bit | ||
| 154 | AUDIOENGINE_FMT_S16BE, | ||
| 155 | /// Little Endian signed integer 16 bit | ||
| 156 | AUDIOENGINE_FMT_S16LE, | ||
| 157 | /// Native Endian signed integer 16 bit | ||
| 158 | AUDIOENGINE_FMT_S16NE, | ||
| 159 | |||
| 160 | /// Big Endian signed integer 32 bit | ||
| 161 | AUDIOENGINE_FMT_S32BE, | ||
| 162 | /// Little Endian signed integer 32 bit | ||
| 163 | AUDIOENGINE_FMT_S32LE, | ||
| 164 | /// Native Endian signed integer 32 bit | ||
| 165 | AUDIOENGINE_FMT_S32NE, | ||
| 166 | |||
| 167 | /// Big Endian signed integer 24 bit (in 4 bytes) | ||
| 168 | AUDIOENGINE_FMT_S24BE4, | ||
| 169 | /// Little Endian signed integer 24 bit (in 4 bytes) | ||
| 170 | AUDIOENGINE_FMT_S24LE4, | ||
| 171 | /// Native Endian signed integer 24 bit (in 4 bytes) | ||
| 172 | AUDIOENGINE_FMT_S24NE4, | ||
| 173 | /// S32 with bits_per_sample < 32 | ||
| 174 | AUDIOENGINE_FMT_S24NE4MSB, | ||
| 175 | |||
| 176 | /// Big Endian signed integer 24 bit (3 bytes) | ||
| 177 | AUDIOENGINE_FMT_S24BE3, | ||
| 178 | /// Little Endian signed integer 24 bit (3 bytes) | ||
| 179 | AUDIOENGINE_FMT_S24LE3, | ||
| 180 | /// Native Endian signed integer 24 bit (3 bytes) | ||
| 181 | AUDIOENGINE_FMT_S24NE3, | ||
| 182 | |||
| 183 | /// Double floating point | ||
| 184 | AUDIOENGINE_FMT_DOUBLE, | ||
| 185 | /// Floating point | ||
| 186 | AUDIOENGINE_FMT_FLOAT, | ||
| 187 | |||
| 188 | /// **Bitstream**\n | ||
| 189 | /// RAW Audio format | ||
| 190 | AUDIOENGINE_FMT_RAW, | ||
| 191 | |||
| 192 | /// **Planar format**\n | ||
| 193 | /// Unsigned byte | ||
| 194 | AUDIOENGINE_FMT_U8P, | ||
| 195 | /// **Planar format**\n | ||
| 196 | /// Native Endian signed 16 bit | ||
| 197 | AUDIOENGINE_FMT_S16NEP, | ||
| 198 | /// **Planar format**\n | ||
| 199 | /// Native Endian signed 32 bit | ||
| 200 | AUDIOENGINE_FMT_S32NEP, | ||
| 201 | /// **Planar format**\n | ||
| 202 | /// Native Endian signed integer 24 bit (in 4 bytes) | ||
| 203 | AUDIOENGINE_FMT_S24NE4P, | ||
| 204 | /// **Planar format**\n | ||
| 205 | /// S32 with bits_per_sample < 32 | ||
| 206 | AUDIOENGINE_FMT_S24NE4MSBP, | ||
| 207 | /// **Planar format**\n | ||
| 208 | /// Native Endian signed integer 24 bit (in 3 bytes) | ||
| 209 | AUDIOENGINE_FMT_S24NE3P, | ||
| 210 | /// **Planar format**\n | ||
| 211 | /// Double floating point | ||
| 212 | AUDIOENGINE_FMT_DOUBLEP, | ||
| 213 | /// **Planar format**\n | ||
| 214 | /// Floating point | ||
| 215 | AUDIOENGINE_FMT_FLOATP, | ||
| 216 | |||
| 217 | /// Amount of sample formats. | ||
| 218 | AUDIOENGINE_FMT_MAX | ||
| 219 | }; | ||
| 220 | //@} | ||
| 221 | //---------------------------------------------------------------------------- | ||
| 222 | |||
| 223 | /*! | ||
| 224 | * @brief Internal API structure which are used for data exchange between | ||
| 225 | * Kodi and addon. | ||
| 226 | */ | ||
| 227 | struct AUDIO_ENGINE_FORMAT | ||
| 228 | { | ||
| 229 | /*! The stream's data format (eg, AUDIOENGINE_FMT_S16LE) */ | ||
| 230 | enum AudioEngineDataFormat m_dataFormat; | ||
| 231 | |||
| 232 | /*! The stream's sample rate (eg, 48000) */ | ||
| 233 | unsigned int m_sampleRate; | ||
| 234 | |||
| 235 | /*! The encoded streams sample rate if a bitstream, otherwise undefined */ | ||
| 236 | unsigned int m_encodedRate; | ||
| 237 | |||
| 238 | /*! The amount of used speaker channels */ | ||
| 239 | unsigned int m_channelCount; | ||
| 240 | |||
| 241 | /*! The stream's channel layout */ | ||
| 242 | enum AudioEngineChannel m_channels[AUDIOENGINE_CH_MAX]; | ||
| 243 | |||
| 244 | /*! The number of frames per period */ | ||
| 245 | unsigned int m_frames; | ||
| 246 | |||
| 247 | /*! The size of one frame in bytes */ | ||
| 248 | unsigned int m_frameSize; | ||
| 249 | }; | ||
| 250 | |||
| 251 | /* A stream handle pointer, which is only used internally by the addon stream handle */ | ||
| 252 | typedef void AEStreamHandle; | ||
| 253 | |||
| 254 | //}}} | ||
| 255 | |||
| 256 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 257 | // "C" Internal interface tables for intercommunications between addon and kodi | ||
| 258 | //{{{ | ||
| 259 | |||
| 260 | /* | ||
| 261 | * Function address structure, not need to visible on dev kit doxygen | ||
| 262 | * documentation | ||
| 263 | */ | ||
| 264 | typedef struct AddonToKodiFuncTable_kodi_audioengine | ||
| 265 | { | ||
| 266 | AEStreamHandle* (*make_stream)(void* kodiBase, | ||
| 267 | struct AUDIO_ENGINE_FORMAT* format, | ||
| 268 | unsigned int options); | ||
| 269 | void (*free_stream)(void* kodiBase, AEStreamHandle* stream); | ||
| 270 | bool (*get_current_sink_format)(void* kodiBase, struct AUDIO_ENGINE_FORMAT* sink_format); | ||
| 271 | |||
| 272 | // Audio Engine Stream definitions | ||
| 273 | unsigned int (*aestream_get_space)(void* kodiBase, AEStreamHandle* handle); | ||
| 274 | unsigned int (*aestream_add_data)(void* kodiBase, | ||
| 275 | AEStreamHandle* handle, | ||
| 276 | uint8_t* const* data, | ||
| 277 | unsigned int offset, | ||
| 278 | unsigned int frames, | ||
| 279 | double pts, | ||
| 280 | bool hasDownmix, | ||
| 281 | double centerMixLevel); | ||
| 282 | double (*aestream_get_delay)(void* kodiBase, AEStreamHandle* handle); | ||
| 283 | bool (*aestream_is_buffering)(void* kodiBase, AEStreamHandle* handle); | ||
| 284 | double (*aestream_get_cache_time)(void* kodiBase, AEStreamHandle* handle); | ||
| 285 | double (*aestream_get_cache_total)(void* kodiBase, AEStreamHandle* handle); | ||
| 286 | void (*aestream_pause)(void* kodiBase, AEStreamHandle* handle); | ||
| 287 | void (*aestream_resume)(void* kodiBase, AEStreamHandle* handle); | ||
| 288 | void (*aestream_drain)(void* kodiBase, AEStreamHandle* handle, bool wait); | ||
| 289 | bool (*aestream_is_draining)(void* kodiBase, AEStreamHandle* handle); | ||
| 290 | bool (*aestream_is_drained)(void* kodiBase, AEStreamHandle* handle); | ||
| 291 | void (*aestream_flush)(void* kodiBase, AEStreamHandle* handle); | ||
| 292 | float (*aestream_get_volume)(void* kodiBase, AEStreamHandle* handle); | ||
| 293 | void (*aestream_set_volume)(void* kodiBase, AEStreamHandle* handle, float volume); | ||
| 294 | float (*aestream_get_amplification)(void* kodiBase, AEStreamHandle* handle); | ||
| 295 | void (*aestream_set_amplification)(void* kodiBase, AEStreamHandle* handle, float amplify); | ||
| 296 | unsigned int (*aestream_get_frame_size)(void* kodiBase, AEStreamHandle* handle); | ||
| 297 | unsigned int (*aestream_get_channel_count)(void* kodiBase, AEStreamHandle* handle); | ||
| 298 | unsigned int (*aestream_get_sample_rate)(void* kodiBase, AEStreamHandle* handle); | ||
| 299 | enum AudioEngineDataFormat (*aestream_get_data_format)(void* kodiBase, AEStreamHandle* handle); | ||
| 300 | double (*aestream_get_resample_ratio)(void* kodiBase, AEStreamHandle* handle); | ||
| 301 | void (*aestream_set_resample_ratio)(void* kodiBase, AEStreamHandle* handle, double ratio); | ||
| 302 | } AddonToKodiFuncTable_kodi_audioengine; | ||
| 303 | |||
| 304 | //}}} | ||
| 305 | |||
| 306 | #ifdef __cplusplus | ||
| 307 | } | ||
| 308 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/filesystem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/filesystem.h new file mode 100644 index 0000000..b68a24c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/filesystem.h | |||
| @@ -0,0 +1,299 @@ | |||
| 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 <stdbool.h> | ||
| 12 | #include <stdint.h> | ||
| 13 | #include <time.h> | ||
| 14 | |||
| 15 | #ifdef _WIN32 // windows | ||
| 16 | #ifndef _SSIZE_T_DEFINED | ||
| 17 | typedef intptr_t ssize_t; | ||
| 18 | #define _SSIZE_T_DEFINED | ||
| 19 | #endif // !_SSIZE_T_DEFINED | ||
| 20 | |||
| 21 | // Prevent conflicts with Windows macros where have this names. | ||
| 22 | #ifdef CreateDirectory | ||
| 23 | #undef CreateDirectory | ||
| 24 | #endif // CreateDirectory | ||
| 25 | #ifdef DeleteFile | ||
| 26 | #undef DeleteFile | ||
| 27 | #endif // DeleteFile | ||
| 28 | #endif // _WIN32 | ||
| 29 | |||
| 30 | #ifdef __cplusplus | ||
| 31 | extern "C" | ||
| 32 | { | ||
| 33 | #endif /* __cplusplus */ | ||
| 34 | |||
| 35 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 36 | // "C" Definitions, structures and enumerators of filesystem | ||
| 37 | //{{{ | ||
| 38 | |||
| 39 | //============================================================================ | ||
| 40 | /// @defgroup cpp_kodi_vfs_Defs_OpenFileFlags enum OpenFileFlags | ||
| 41 | /// @ingroup cpp_kodi_vfs_Defs | ||
| 42 | /// @brief **Flags to define way how file becomes opened**\n | ||
| 43 | /// The values can be used together, e.g. <b>`file.Open("myfile", ADDON_READ_TRUNCATED | ADDON_READ_CHUNKED);`</b> | ||
| 44 | /// | ||
| 45 | /// Used on @ref kodi::vfs::CFile::OpenFile(). | ||
| 46 | /// | ||
| 47 | ///@{ | ||
| 48 | typedef enum OpenFileFlags | ||
| 49 | { | ||
| 50 | /// @brief **0000 0000 0001** :\n | ||
| 51 | /// Indicate that caller can handle truncated reads, where function | ||
| 52 | /// returns before entire buffer has been filled. | ||
| 53 | ADDON_READ_TRUNCATED = 0x01, | ||
| 54 | |||
| 55 | /// @brief **0000 0000 0010** :\n | ||
| 56 | /// Indicate that that caller support read in the minimum defined | ||
| 57 | /// chunk size, this disables internal cache then. | ||
| 58 | ADDON_READ_CHUNKED = 0x02, | ||
| 59 | |||
| 60 | /// @brief **0000 0000 0100** :\n | ||
| 61 | /// Use cache to access this file. | ||
| 62 | ADDON_READ_CACHED = 0x04, | ||
| 63 | |||
| 64 | /// @brief **0000 0000 1000** :\n | ||
| 65 | /// Open without caching. regardless to file type. | ||
| 66 | ADDON_READ_NO_CACHE = 0x08, | ||
| 67 | |||
| 68 | /// @brief **0000 0001 0000** :\n | ||
| 69 | /// Calcuate bitrate for file while reading. | ||
| 70 | ADDON_READ_BITRATE = 0x10, | ||
| 71 | |||
| 72 | /// @brief **0000 0010 0000** :\n | ||
| 73 | /// Indicate to the caller we will seek between multiple streams in | ||
| 74 | /// the file frequently. | ||
| 75 | ADDON_READ_MULTI_STREAM = 0x20, | ||
| 76 | |||
| 77 | /// @brief **0000 0100 0000** :\n | ||
| 78 | /// indicate to the caller file is audio and/or video (and e.g. may | ||
| 79 | /// grow). | ||
| 80 | ADDON_READ_AUDIO_VIDEO = 0x40, | ||
| 81 | |||
| 82 | /// @brief **0000 1000 0000** :\n | ||
| 83 | /// Indicate that caller will do write operations before reading. | ||
| 84 | ADDON_READ_AFTER_WRITE = 0x80, | ||
| 85 | |||
| 86 | /// @brief **0001 0000 0000** :\n | ||
| 87 | /// Indicate that caller want to reopen a file if its already open. | ||
| 88 | ADDON_READ_REOPEN = 0x100 | ||
| 89 | } OpenFileFlags; | ||
| 90 | ///@} | ||
| 91 | //---------------------------------------------------------------------------- | ||
| 92 | |||
| 93 | //============================================================================ | ||
| 94 | /// @defgroup cpp_kodi_vfs_Defs_CURLOptiontype enum CURLOptiontype | ||
| 95 | /// @ingroup cpp_kodi_vfs_Defs | ||
| 96 | /// @brief **CURL message types**\n | ||
| 97 | /// Used on kodi::vfs::CFile::CURLAddOption(). | ||
| 98 | /// | ||
| 99 | //@{ | ||
| 100 | typedef enum CURLOptiontype | ||
| 101 | { | ||
| 102 | /// @brief Set a general option. | ||
| 103 | ADDON_CURL_OPTION_OPTION, | ||
| 104 | |||
| 105 | /// @brief Set a protocol option. | ||
| 106 | /// | ||
| 107 | /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible: | ||
| 108 | /// | ||
| 109 | /// | Option name | Description | ||
| 110 | /// |------------------------------------:|:-------------------------------- | ||
| 111 | /// | <b>`accept-charset`</b> | Set the "accept-charset" header | ||
| 112 | /// | <b>`acceptencoding or encoding`</b> | Set the "accept-encoding" header | ||
| 113 | /// | <b>`active-remote`</b> | Set the "active-remote" header | ||
| 114 | /// | <b>`auth`</b> | Set the authentication method. Possible values: any, anysafe, digest, ntlm | ||
| 115 | /// | <b>`connection-timeout`</b> | Set the connection timeout in seconds | ||
| 116 | /// | <b>`cookie`</b> | Set the "cookie" header | ||
| 117 | /// | <b>`customrequest`</b> | Set a custom HTTP request like DELETE | ||
| 118 | /// | <b>`noshout`</b> | Set to true if kodi detects a stream as shoutcast by mistake. | ||
| 119 | /// | <b>`postdata`</b> | Set the post body (value needs to be base64 encoded). (Implicitly sets the request to POST) | ||
| 120 | /// | <b>`referer`</b> | Set the "referer" header | ||
| 121 | /// | <b>`user-agent`</b> | Set the "user-agent" header | ||
| 122 | /// | <b>`seekable`</b> | Set the stream seekable. 1: enable, 0: disable | ||
| 123 | /// | <b>`sslcipherlist`</b> | Set list of accepted SSL ciphers. | ||
| 124 | /// | ||
| 125 | ADDON_CURL_OPTION_PROTOCOL, | ||
| 126 | |||
| 127 | /// @brief Set User and password | ||
| 128 | ADDON_CURL_OPTION_CREDENTIALS, | ||
| 129 | |||
| 130 | /// @brief Add a Header | ||
| 131 | ADDON_CURL_OPTION_HEADER | ||
| 132 | } CURLOptiontype; | ||
| 133 | //@} | ||
| 134 | //---------------------------------------------------------------------------- | ||
| 135 | |||
| 136 | //============================================================================ | ||
| 137 | /// @defgroup cpp_kodi_vfs_Defs_FilePropertyTypes enum FilePropertyTypes | ||
| 138 | /// @ingroup cpp_kodi_vfs_Defs | ||
| 139 | /// @brief **File property types**\n | ||
| 140 | /// Mostly to read internet sources. | ||
| 141 | /// | ||
| 142 | /// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues(). | ||
| 143 | /// | ||
| 144 | //@{ | ||
| 145 | typedef enum FilePropertyTypes | ||
| 146 | { | ||
| 147 | /// @brief Get protocol response line. | ||
| 148 | ADDON_FILE_PROPERTY_RESPONSE_PROTOCOL, | ||
| 149 | /// @brief Get a response header. | ||
| 150 | ADDON_FILE_PROPERTY_RESPONSE_HEADER, | ||
| 151 | /// @brief Get file content type. | ||
| 152 | ADDON_FILE_PROPERTY_CONTENT_TYPE, | ||
| 153 | /// @brief Get file content charset. | ||
| 154 | ADDON_FILE_PROPERTY_CONTENT_CHARSET, | ||
| 155 | /// @brief Get file mime type. | ||
| 156 | ADDON_FILE_PROPERTY_MIME_TYPE, | ||
| 157 | /// @brief Get file effective URL (last one if redirected). | ||
| 158 | ADDON_FILE_PROPERTY_EFFECTIVE_URL | ||
| 159 | } FilePropertyTypes; | ||
| 160 | //@} | ||
| 161 | //---------------------------------------------------------------------------- | ||
| 162 | |||
| 163 | //}}} | ||
| 164 | |||
| 165 | //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
| 166 | // "C" Internal interface tables for intercommunications between addon and kodi | ||
| 167 | //{{{ | ||
| 168 | |||
| 169 | struct KODI_HTTP_HEADER | ||
| 170 | { | ||
| 171 | void* handle; | ||
| 172 | |||
| 173 | char* (*get_value)(void* kodiBase, void* handle, const char* param); | ||
| 174 | char** (*get_values)(void* kodiBase, void* handle, const char* param, int* length); | ||
| 175 | char* (*get_header)(void* kodiBase, void* handle); | ||
| 176 | char* (*get_mime_type)(void* kodiBase, void* handle); | ||
| 177 | char* (*get_charset)(void* kodiBase, void* handle); | ||
| 178 | char* (*get_proto_line)(void* kodiBase, void* handle); | ||
| 179 | }; | ||
| 180 | |||
| 181 | struct STAT_STRUCTURE | ||
| 182 | { | ||
| 183 | /// ID of device containing file | ||
| 184 | uint32_t deviceId; | ||
| 185 | /// Total size, in bytes | ||
| 186 | uint64_t size; | ||
| 187 | /// Time of last access | ||
| 188 | time_t accessTime; | ||
| 189 | /// Time of last modification | ||
| 190 | time_t modificationTime; | ||
| 191 | /// Time of last status change | ||
| 192 | time_t statusTime; | ||
| 193 | /// The stat url is a directory | ||
| 194 | bool isDirectory; | ||
| 195 | /// The stat url is a symbolic link | ||
| 196 | bool isSymLink; | ||
| 197 | }; | ||
| 198 | |||
| 199 | struct VFS_CACHE_STATUS_DATA | ||
| 200 | { | ||
| 201 | uint64_t forward; | ||
| 202 | unsigned int maxrate; | ||
| 203 | unsigned int currate; | ||
| 204 | bool lowspeed; | ||
| 205 | }; | ||
| 206 | |||
| 207 | struct VFSProperty | ||
| 208 | { | ||
| 209 | char* name; | ||
| 210 | char* val; | ||
| 211 | }; | ||
| 212 | |||
| 213 | struct VFSDirEntry | ||
| 214 | { | ||
| 215 | char* label; //!< item label | ||
| 216 | char* title; //!< item title | ||
| 217 | char* path; //!< item path | ||
| 218 | unsigned int num_props; //!< Number of properties attached to item | ||
| 219 | struct VFSProperty* properties; //!< Properties | ||
| 220 | time_t date_time; //!< file creation date & time | ||
| 221 | bool folder; //!< Item is a folder | ||
| 222 | uint64_t size; //!< Size of file represented by item | ||
| 223 | }; | ||
| 224 | |||
| 225 | typedef struct AddonToKodiFuncTable_kodi_filesystem | ||
| 226 | { | ||
| 227 | bool (*can_open_directory)(void* kodiBase, const char* url); | ||
| 228 | bool (*create_directory)(void* kodiBase, const char* path); | ||
| 229 | bool (*remove_directory)(void* kodiBase, const char* path); | ||
| 230 | bool (*directory_exists)(void* kodiBase, const char* path); | ||
| 231 | bool (*get_directory)(void* kodiBase, | ||
| 232 | const char* path, | ||
| 233 | const char* mask, | ||
| 234 | struct VFSDirEntry** items, | ||
| 235 | unsigned int* num_items); | ||
| 236 | void (*free_directory)(void* kodiBase, struct VFSDirEntry* items, unsigned int num_items); | ||
| 237 | |||
| 238 | bool (*file_exists)(void* kodiBase, const char* filename, bool useCache); | ||
| 239 | bool (*stat_file)(void* kodiBase, const char* filename, struct STAT_STRUCTURE* buffer); | ||
| 240 | bool (*delete_file)(void* kodiBase, const char* filename); | ||
| 241 | bool (*rename_file)(void* kodiBase, const char* filename, const char* newFileName); | ||
| 242 | bool (*copy_file)(void* kodiBase, const char* filename, const char* dest); | ||
| 243 | |||
| 244 | char* (*get_file_md5)(void* kodiBase, const char* filename); | ||
| 245 | char* (*get_cache_thumb_name)(void* kodiBase, const char* filename); | ||
| 246 | char* (*make_legal_filename)(void* kodiBase, const char* filename); | ||
| 247 | char* (*make_legal_path)(void* kodiBase, const char* path); | ||
| 248 | char* (*translate_special_protocol)(void* kodiBase, const char* strSource); | ||
| 249 | bool (*is_internet_stream)(void* kodiBase, const char* path, bool strictCheck); | ||
| 250 | bool (*is_on_lan)(void* kodiBase, const char* path); | ||
| 251 | bool (*is_remote)(void* kodiBase, const char* path); | ||
| 252 | bool (*is_local)(void* kodiBase, const char* path); | ||
| 253 | bool (*is_url)(void* kodiBase, const char* path); | ||
| 254 | bool (*get_http_header)(void* kodiBase, const char* url, struct KODI_HTTP_HEADER* headers); | ||
| 255 | bool (*get_mime_type)(void* kodiBase, const char* url, char** content, const char* useragent); | ||
| 256 | bool (*get_content_type)(void* kodiBase, | ||
| 257 | const char* url, | ||
| 258 | char** content, | ||
| 259 | const char* useragent); | ||
| 260 | bool (*get_cookies)(void* kodiBase, const char* url, char** cookies); | ||
| 261 | bool (*http_header_create)(void* kodiBase, struct KODI_HTTP_HEADER* headers); | ||
| 262 | void (*http_header_free)(void* kodiBase, struct KODI_HTTP_HEADER* headers); | ||
| 263 | |||
| 264 | void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags); | ||
| 265 | void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite); | ||
| 266 | ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size); | ||
| 267 | bool (*read_file_string)(void* kodiBase, void* file, char* szLine, int iLineLength); | ||
| 268 | ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size); | ||
| 269 | void (*flush_file)(void* kodiBase, void* file); | ||
| 270 | int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence); | ||
| 271 | int (*truncate_file)(void* kodiBase, void* file, int64_t size); | ||
| 272 | int64_t (*get_file_position)(void* kodiBase, void* file); | ||
| 273 | int64_t (*get_file_length)(void* kodiBase, void* file); | ||
| 274 | double (*get_file_download_speed)(void* kodiBase, void* file); | ||
| 275 | void (*close_file)(void* kodiBase, void* file); | ||
| 276 | int (*get_file_chunk_size)(void* kodiBase, void* file); | ||
| 277 | bool (*io_control_get_seek_possible)(void* kodiBase, void* file); | ||
| 278 | bool (*io_control_get_cache_status)(void* kodiBase, | ||
| 279 | void* file, | ||
| 280 | struct VFS_CACHE_STATUS_DATA* status); | ||
| 281 | bool (*io_control_set_cache_rate)(void* kodiBase, void* file, unsigned int rate); | ||
| 282 | bool (*io_control_set_retry)(void* kodiBase, void* file, bool retry); | ||
| 283 | char** (*get_property_values)( | ||
| 284 | void* kodiBase, void* file, int type, const char* name, int* numValues); | ||
| 285 | |||
| 286 | void* (*curl_create)(void* kodiBase, const char* url); | ||
| 287 | bool (*curl_add_option)( | ||
| 288 | void* kodiBase, void* file, int type, const char* name, const char* value); | ||
| 289 | bool (*curl_open)(void* kodiBase, void* file, unsigned int flags); | ||
| 290 | |||
| 291 | bool (*get_disk_space)( | ||
| 292 | void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available); | ||
| 293 | } AddonToKodiFuncTable_kodi_filesystem; | ||
| 294 | |||
| 295 | //}}} | ||
| 296 | |||
| 297 | #ifdef __cplusplus | ||
| 298 | } /* extern "C" */ | ||
| 299 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/general.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/general.h new file mode 100644 index 0000000..ede8e94 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/general.h | |||
| @@ -0,0 +1,123 @@ | |||
| 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 | #ifdef __cplusplus | ||
| 12 | extern "C" | ||
| 13 | { | ||
| 14 | #endif /* __cplusplus */ | ||
| 15 | |||
| 16 | //============================================================================ | ||
| 17 | /// \ingroup cpp_kodi_Defs | ||
| 18 | /// @brief For kodi::CurrentKeyboardLayout used defines | ||
| 19 | /// | ||
| 20 | typedef enum StdKbButtons | ||
| 21 | { | ||
| 22 | /// The quantity of buttons per row on Kodi's standard keyboard | ||
| 23 | STD_KB_BUTTONS_PER_ROW = 20, | ||
| 24 | /// The quantity of rows on Kodi's standard keyboard | ||
| 25 | STD_KB_BUTTONS_MAX_ROWS = 4, | ||
| 26 | /// Keyboard layout type, this for initial standard | ||
| 27 | STD_KB_MODIFIER_KEY_NONE = 0x00, | ||
| 28 | /// Keyboard layout type, this for shift controled layout (uppercase) | ||
| 29 | STD_KB_MODIFIER_KEY_SHIFT = 0x01, | ||
| 30 | /// Keyboard layout type, this to show symbols | ||
| 31 | STD_KB_MODIFIER_KEY_SYMBOL = 0x02 | ||
| 32 | } StdKbButtons; | ||
| 33 | //---------------------------------------------------------------------------- | ||
| 34 | |||
| 35 | //============================================================================ | ||
| 36 | /// \ingroup cpp_kodi_Defs | ||
| 37 | /// @brief For kodi::QueueNotification() used message types | ||
| 38 | /// | ||
| 39 | typedef enum QueueMsg | ||
| 40 | { | ||
| 41 | /// Show info notification message | ||
| 42 | QUEUE_INFO, | ||
| 43 | /// Show warning notification message | ||
| 44 | QUEUE_WARNING, | ||
| 45 | /// Show error notification message | ||
| 46 | QUEUE_ERROR, | ||
| 47 | /// Show with own given image and parts if set on values | ||
| 48 | QUEUE_OWN_STYLE | ||
| 49 | } QueueMsg; | ||
| 50 | //---------------------------------------------------------------------------- | ||
| 51 | |||
| 52 | //============================================================================ | ||
| 53 | /// \ingroup cpp_kodi_Defs | ||
| 54 | /// @brief Format codes to get string from them. | ||
| 55 | /// | ||
| 56 | /// Used on kodi::GetLanguage(). | ||
| 57 | /// | ||
| 58 | typedef enum LangFormats | ||
| 59 | { | ||
| 60 | /// two letter code as defined in ISO 639-1 | ||
| 61 | LANG_FMT_ISO_639_1, | ||
| 62 | /// three letter code as defined in ISO 639-2/T or ISO 639-2/B | ||
| 63 | LANG_FMT_ISO_639_2, | ||
| 64 | /// full language name in English | ||
| 65 | LANG_FMT_ENGLISH_NAME | ||
| 66 | } LangFormats; | ||
| 67 | //---------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | /* | ||
| 70 | * For interface between add-on and kodi. | ||
| 71 | * | ||
| 72 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 73 | * are then available for the add-on to call | ||
| 74 | * | ||
| 75 | * All function pointers there are used by the C++ interface functions below. | ||
| 76 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 77 | * | ||
| 78 | * Note: For add-on development itself this is not needed | ||
| 79 | */ | ||
| 80 | typedef struct AddonKeyboardKeyTable | ||
| 81 | { | ||
| 82 | char* keys[STD_KB_BUTTONS_MAX_ROWS][STD_KB_BUTTONS_PER_ROW]; | ||
| 83 | } AddonKeyboardKeyTable; | ||
| 84 | typedef struct AddonToKodiFuncTable_kodi | ||
| 85 | { | ||
| 86 | char* (*get_addon_info)(void* kodiBase, const char* id); | ||
| 87 | bool (*open_settings_dialog)(void* kodiBase); | ||
| 88 | char* (*unknown_to_utf8)(void* kodiBase, const char* source, bool* ret, bool failOnBadChar); | ||
| 89 | char* (*get_localized_string)(void* kodiBase, long label_id); | ||
| 90 | char* (*get_language)(void* kodiBase, int format, bool region); | ||
| 91 | bool (*queue_notification)(void* kodiBase, | ||
| 92 | int type, | ||
| 93 | const char* header, | ||
| 94 | const char* message, | ||
| 95 | const char* imageFile, | ||
| 96 | unsigned int displayTime, | ||
| 97 | bool withSound, | ||
| 98 | unsigned int messageTime); | ||
| 99 | void (*get_md5)(void* kodiBase, const char* text, char* md5); | ||
| 100 | char* (*get_temp_path)(void* kodiBase); | ||
| 101 | char* (*get_region)(void* kodiBase, const char* id); | ||
| 102 | void (*get_free_mem)(void* kodiBase, long* free, long* total, bool as_bytes); | ||
| 103 | int (*get_global_idle_time)(void* kodiBase); | ||
| 104 | bool (*is_addon_avilable)(void* kodiBase, const char* id, char** version, bool* enabled); | ||
| 105 | void (*kodi_version)(void* kodiBase, | ||
| 106 | char** compile_name, | ||
| 107 | int* major, | ||
| 108 | int* minor, | ||
| 109 | char** revision, | ||
| 110 | char** tag, | ||
| 111 | char** tagversion); | ||
| 112 | char* (*get_current_skin_id)(void* kodiBase); | ||
| 113 | bool (*get_keyboard_layout)(void* kodiBase, | ||
| 114 | char** layout_name, | ||
| 115 | int modifier_key, | ||
| 116 | struct AddonKeyboardKeyTable* layout); | ||
| 117 | bool (*change_keyboard_layout)(void* kodiBase, char** layout_name); | ||
| 118 | } AddonToKodiFuncTable_kodi; | ||
| 119 | |||
| 120 | |||
| 121 | #ifdef __cplusplus | ||
| 122 | } /* extern "C" */ | ||
| 123 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/network.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/network.h new file mode 100644 index 0000000..6c0441f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/network.h | |||
| @@ -0,0 +1,43 @@ | |||
| 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 <stddef.h> | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" | ||
| 15 | { | ||
| 16 | #endif /* __cplusplus */ | ||
| 17 | |||
| 18 | /* | ||
| 19 | * For interface between add-on and kodi. | ||
| 20 | * | ||
| 21 | * This structure defines the addresses of functions stored inside Kodi which | ||
| 22 | * are then available for the add-on to call | ||
| 23 | * | ||
| 24 | * All function pointers there are used by the C++ interface functions below. | ||
| 25 | * You find the set of them on xbmc/addons/interfaces/General.cpp | ||
| 26 | * | ||
| 27 | * Note: For add-on development itself this is not needed | ||
| 28 | */ | ||
| 29 | typedef struct AddonToKodiFuncTable_kodi_network | ||
| 30 | { | ||
| 31 | bool (*wake_on_lan)(void* kodiBase, const char* mac); | ||
| 32 | char* (*get_ip_address)(void* kodiBase); | ||
| 33 | char* (*dns_lookup)(void* kodiBase, const char* url, bool* ret); | ||
| 34 | char* (*url_encode)(void* kodiBase, const char* url); | ||
| 35 | char* (*get_hostname)(void* kodiBase); | ||
| 36 | bool (*is_local_host)(void* kodiBase, const char* hostname); | ||
| 37 | bool (*is_host_on_lan)(void* kodiBase, const char* hostname, bool offLineCheck); | ||
| 38 | char* (*get_user_agent)(void* kodiBase); | ||
| 39 | } AddonToKodiFuncTable_kodi_network; | ||
| 40 | |||
| 41 | #ifdef __cplusplus | ||
| 42 | } /* extern "C" */ | ||
| 43 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt index 91cef7f..834ec00 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | set(HEADERS General.h | 1 | set(HEADERS General.h |
| 2 | ListItem.h | 2 | ListItem.h |
| 3 | Window.h | 3 | Window.h |
| 4 | definitions.h) | 4 | definitions.h |
| 5 | renderHelper.h) | ||
| 5 | 6 | ||
| 6 | if(NOT ENABLE_STATIC_LIBS) | 7 | if(NOT ENABLE_STATIC_LIBS) |
| 7 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui) | 8 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h index a3b8bcb..b5a6393 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h | |||
| @@ -37,7 +37,7 @@ namespace gui | |||
| 37 | /// \ingroup cpp_kodi_gui | 37 | /// \ingroup cpp_kodi_gui |
| 38 | /// @brief Performs a graphical lock of rendering engine | 38 | /// @brief Performs a graphical lock of rendering engine |
| 39 | /// | 39 | /// |
| 40 | inline void Lock() | 40 | inline void ATTRIBUTE_HIDDEN Lock() |
| 41 | { | 41 | { |
| 42 | using namespace ::kodi::addon; | 42 | using namespace ::kodi::addon; |
| 43 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); | 43 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); |
| @@ -50,7 +50,7 @@ namespace gui | |||
| 50 | /// \ingroup cpp_kodi_gui | 50 | /// \ingroup cpp_kodi_gui |
| 51 | /// @brief Performs a graphical unlock of previous locked rendering engine | 51 | /// @brief Performs a graphical unlock of previous locked rendering engine |
| 52 | /// | 52 | /// |
| 53 | inline void Unlock() | 53 | inline void ATTRIBUTE_HIDDEN Unlock() |
| 54 | { | 54 | { |
| 55 | using namespace ::kodi::addon; | 55 | using namespace ::kodi::addon; |
| 56 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); | 56 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); |
| @@ -62,7 +62,7 @@ namespace gui | |||
| 62 | /// \ingroup cpp_kodi_gui | 62 | /// \ingroup cpp_kodi_gui |
| 63 | /// @brief Return the the current screen height with pixel | 63 | /// @brief Return the the current screen height with pixel |
| 64 | /// | 64 | /// |
| 65 | inline int GetScreenHeight() | 65 | inline int ATTRIBUTE_HIDDEN GetScreenHeight() |
| 66 | { | 66 | { |
| 67 | using namespace ::kodi::addon; | 67 | using namespace ::kodi::addon; |
| 68 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); | 68 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); |
| @@ -74,7 +74,7 @@ namespace gui | |||
| 74 | /// \ingroup cpp_kodi_gui | 74 | /// \ingroup cpp_kodi_gui |
| 75 | /// @brief Return the the current screen width with pixel | 75 | /// @brief Return the the current screen width with pixel |
| 76 | /// | 76 | /// |
| 77 | inline int GetScreenWidth() | 77 | inline int ATTRIBUTE_HIDDEN GetScreenWidth() |
| 78 | { | 78 | { |
| 79 | using namespace ::kodi::addon; | 79 | using namespace ::kodi::addon; |
| 80 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); | 80 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); |
| @@ -86,7 +86,7 @@ namespace gui | |||
| 86 | /// \ingroup cpp_kodi_gui | 86 | /// \ingroup cpp_kodi_gui |
| 87 | /// @brief Return the the current screen rendering resolution | 87 | /// @brief Return the the current screen rendering resolution |
| 88 | /// | 88 | /// |
| 89 | inline int GetVideoResolution() | 89 | inline int ATTRIBUTE_HIDDEN GetVideoResolution() |
| 90 | { | 90 | { |
| 91 | using namespace ::kodi::addon; | 91 | using namespace ::kodi::addon; |
| 92 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); | 92 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); |
| @@ -110,7 +110,7 @@ namespace gui | |||
| 110 | /// .. | 110 | /// .. |
| 111 | /// ~~~~~~~~~~~~~ | 111 | /// ~~~~~~~~~~~~~ |
| 112 | /// | 112 | /// |
| 113 | inline int GetCurrentWindowDialogId() | 113 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowDialogId() |
| 114 | { | 114 | { |
| 115 | using namespace ::kodi::addon; | 115 | using namespace ::kodi::addon; |
| 116 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); | 116 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); |
| @@ -134,7 +134,7 @@ namespace gui | |||
| 134 | /// .. | 134 | /// .. |
| 135 | /// ~~~~~~~~~~~~~ | 135 | /// ~~~~~~~~~~~~~ |
| 136 | /// | 136 | /// |
| 137 | inline int GetCurrentWindowId() | 137 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowId() |
| 138 | { | 138 | { |
| 139 | using namespace ::kodi::addon; | 139 | using namespace ::kodi::addon; |
| 140 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); | 140 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h index f13b96e..1af4863 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h | |||
| @@ -20,7 +20,7 @@ namespace gui | |||
| 20 | 20 | ||
| 21 | class CWindow; | 21 | class CWindow; |
| 22 | 22 | ||
| 23 | class CAddonGUIControlBase | 23 | class ATTRIBUTE_HIDDEN CAddonGUIControlBase |
| 24 | { | 24 | { |
| 25 | public: | 25 | public: |
| 26 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | 26 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } |
| @@ -69,7 +69,7 @@ namespace gui | |||
| 69 | /// @brief **Library definition values** | 69 | /// @brief **Library definition values** |
| 70 | /// | 70 | /// |
| 71 | 71 | ||
| 72 | class CListItem : public CAddonGUIControlBase | 72 | class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase |
| 73 | { | 73 | { |
| 74 | public: | 74 | public: |
| 75 | //========================================================================== | 75 | //========================================================================== |
| @@ -188,43 +188,6 @@ namespace gui | |||
| 188 | //========================================================================== | 188 | //========================================================================== |
| 189 | /// | 189 | /// |
| 190 | /// \ingroup cpp_kodi_gui_CListItem | 190 | /// \ingroup cpp_kodi_gui_CListItem |
| 191 | /// @brief To get current icon image of entry | ||
| 192 | /// | ||
| 193 | /// @return The current icon image path (if present) | ||
| 194 | /// | ||
| 195 | std::string GetIconImage() | ||
| 196 | { | ||
| 197 | std::string image; | ||
| 198 | char* ret = m_interface->kodi_gui->listItem->get_icon_image(m_interface->kodiBase, m_controlHandle); | ||
| 199 | if (ret != nullptr) | ||
| 200 | { | ||
| 201 | if (std::strlen(ret)) | ||
| 202 | image = ret; | ||
| 203 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 204 | } | ||
| 205 | return image; | ||
| 206 | } | ||
| 207 | //-------------------------------------------------------------------------- | ||
| 208 | |||
| 209 | //========================================================================== | ||
| 210 | /// | ||
| 211 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 212 | /// @brief To set icon image of entry | ||
| 213 | /// | ||
| 214 | /// @param image The image to use for. | ||
| 215 | /// | ||
| 216 | /// @note Alternative can be \ref SetArt used | ||
| 217 | /// | ||
| 218 | /// | ||
| 219 | void SetIconImage(const std::string& image) | ||
| 220 | { | ||
| 221 | m_interface->kodi_gui->listItem->set_icon_image(m_interface->kodiBase, m_controlHandle, image.c_str()); | ||
| 222 | } | ||
| 223 | //-------------------------------------------------------------------------- | ||
| 224 | |||
| 225 | //========================================================================== | ||
| 226 | /// | ||
| 227 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 228 | /// @brief Sets the listitem's art | 191 | /// @brief Sets the listitem's art |
| 229 | /// | 192 | /// |
| 230 | /// @param[in] type Type of Art to set | 193 | /// @param[in] type Type of Art to set |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h index e7a8a05..5011374 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h | |||
| @@ -60,7 +60,7 @@ namespace gui | |||
| 60 | /// @brief <b>Library definition values</b> | 60 | /// @brief <b>Library definition values</b> |
| 61 | /// | 61 | /// |
| 62 | 62 | ||
| 63 | class CWindow : public CAddonGUIControlBase | 63 | class ATTRIBUTE_HIDDEN CWindow : public CAddonGUIControlBase |
| 64 | { | 64 | { |
| 65 | public: | 65 | public: |
| 66 | //========================================================================== | 66 | //========================================================================== |
| @@ -205,6 +205,36 @@ namespace gui | |||
| 205 | //========================================================================== | 205 | //========================================================================== |
| 206 | /// | 206 | /// |
| 207 | /// \ingroup cpp_kodi_gui_CWindow | 207 | /// \ingroup cpp_kodi_gui_CWindow |
| 208 | /// @brief To set the visibility on given control id | ||
| 209 | /// | ||
| 210 | /// @param[in] controlId Control id where visibility is changed | ||
| 211 | /// @param[in] visible Boolean value with `true` for visible, `false` for hidden | ||
| 212 | /// | ||
| 213 | /// | ||
| 214 | void SetControlVisible(int controlId, bool visible) | ||
| 215 | { | ||
| 216 | m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle, controlId, visible); | ||
| 217 | } | ||
| 218 | //-------------------------------------------------------------------------- | ||
| 219 | |||
| 220 | //========================================================================== | ||
| 221 | /// | ||
| 222 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 223 | /// @brief To set the selection on given control id | ||
| 224 | /// | ||
| 225 | /// @param[in] controlId Control id where selection is changed | ||
| 226 | /// @param[in] selected Boolean value with `true` for selected, `false` for not | ||
| 227 | /// | ||
| 228 | /// | ||
| 229 | void SetControlSelected(int controlId, bool selected) | ||
| 230 | { | ||
| 231 | m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle, controlId, selected); | ||
| 232 | } | ||
| 233 | //-------------------------------------------------------------------------- | ||
| 234 | |||
| 235 | //========================================================================== | ||
| 236 | /// | ||
| 237 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 208 | /// @brief Sets a window property, similar to an infolabel. | 238 | /// @brief Sets a window property, similar to an infolabel. |
| 209 | /// | 239 | /// |
| 210 | /// @param[in] key string - property name. | 240 | /// @param[in] key string - property name. |
| @@ -705,7 +735,7 @@ namespace gui | |||
| 705 | /// .. | 735 | /// .. |
| 706 | /// ~~~~~~~~~~~~~ | 736 | /// ~~~~~~~~~~~~~ |
| 707 | /// | 737 | /// |
| 708 | virtual bool OnAction(int actionId) | 738 | virtual bool OnAction(int actionId, uint32_t buttoncode, wchar_t unicode) |
| 709 | { | 739 | { |
| 710 | switch (actionId) | 740 | switch (actionId) |
| 711 | { | 741 | { |
| @@ -811,7 +841,7 @@ namespace gui | |||
| 811 | bool (*CBOnInit) (GUIHANDLE cbhdl), | 841 | bool (*CBOnInit) (GUIHANDLE cbhdl), |
| 812 | bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), | 842 | bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), |
| 813 | bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), | 843 | bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), |
| 814 | bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId), | 844 | bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode), |
| 815 | void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, | 845 | void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, |
| 816 | bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) | 846 | bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) |
| 817 | { | 847 | { |
| @@ -845,9 +875,9 @@ namespace gui | |||
| 845 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); | 875 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); |
| 846 | } | 876 | } |
| 847 | 877 | ||
| 848 | static bool CBOnAction(GUIHANDLE cbhdl, int actionId) | 878 | static bool CBOnAction(GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode) |
| 849 | { | 879 | { |
| 850 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId); | 880 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId, buttoncode, unicode); |
| 851 | } | 881 | } |
| 852 | 882 | ||
| 853 | static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) | 883 | static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h index a38de1a..081ab06 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h | |||
| @@ -18,147 +18,153 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CButton Control Button | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CButton } | ||
| 26 | /// **Standard push button control for window** | ||
| 27 | /// | ||
| 28 | /// The button control is used for creating push buttons in Kodi. You can | ||
| 29 | /// choose the position, size, and look of the button, as well as choosing | ||
| 30 | /// what action(s) should be performed when pushed. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Button.h "#include <kodi/gui/controls/Button.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref skin_Button_control "button control" | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 22 | /// | 50 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CButton Control Button | 51 | CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 24 | /// \ingroup cpp_kodi_gui | 52 | { |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CButton } | 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_button( |
| 26 | /// **Standard push button control for window** | 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); |
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 27 | /// | 61 | /// |
| 28 | /// The button control is used for creating push buttons in Kodi. You can | 62 | /// @ingroup cpp_kodi_gui_control_CButton |
| 29 | /// choose the position, size, and look of the button, as well as choosing | 63 | /// @brief Destructor |
| 30 | /// what action(s) should be performed when pushed. | ||
| 31 | /// | 64 | /// |
| 32 | /// It has the header \ref Button.h "#include <kodi/gui/controls/Button.h>" | 65 | ~CButton() override = default; |
| 33 | /// be included to enjoy it. | 66 | //-------------------------------------------------------------------------- |
| 67 | |||
| 68 | //========================================================================== | ||
| 34 | /// | 69 | /// |
| 35 | /// Here you find the needed skin part for a \ref skin_Button_control "button control" | 70 | /// @ingroup cpp_kodi_gui_control_CButton |
| 71 | /// @brief Set the control on window to visible | ||
| 36 | /// | 72 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 73 | /// @param[in] visible If true visible, otherwise hidden |
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | 74 | /// |
| 40 | class CButton : public CAddonGUIControlBase | 75 | void SetVisible(bool visible) |
| 41 | { | 76 | { |
| 42 | public: | 77 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, |
| 43 | //========================================================================== | 78 | visible); |
| 44 | /// | 79 | } |
| 45 | /// @ingroup cpp_kodi_gui_control_CButton | 80 | //-------------------------------------------------------------------------- |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CButton(CWindow* window, int controlId) | ||
| 52 | : CAddonGUIControlBase(window) | ||
| 53 | { | ||
| 54 | m_controlHandle = m_interface->kodi_gui->window->get_control_button(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | 81 | ||
| 60 | //========================================================================== | 82 | //========================================================================== |
| 61 | /// | 83 | /// |
| 62 | /// @ingroup cpp_kodi_gui_control_CButton | 84 | /// @ingroup cpp_kodi_gui_control_CButton |
| 63 | /// @brief Destructor | 85 | /// @brief Set's the control's enabled/disabled state |
| 64 | /// | 86 | /// |
| 65 | ~CButton() override = default; | 87 | /// @param[in] enabled If true enabled, otherwise disabled |
| 66 | //-------------------------------------------------------------------------- | 88 | /// |
| 67 | 89 | void SetEnabled(bool enabled) | |
| 68 | //========================================================================== | 90 | { |
| 69 | /// | 91 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 70 | /// @ingroup cpp_kodi_gui_control_CButton | 92 | enabled); |
| 71 | /// @brief Set the control on window to visible | 93 | } |
| 72 | /// | 94 | //-------------------------------------------------------------------------- |
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 78 | } | ||
| 79 | //-------------------------------------------------------------------------- | ||
| 80 | |||
| 81 | //========================================================================== | ||
| 82 | /// | ||
| 83 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 84 | /// @brief Set's the control's enabled/disabled state | ||
| 85 | /// | ||
| 86 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 87 | /// | ||
| 88 | void SetEnabled(bool enabled) | ||
| 89 | { | ||
| 90 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | ||
| 91 | } | ||
| 92 | //-------------------------------------------------------------------------- | ||
| 93 | 95 | ||
| 94 | //========================================================================== | 96 | //========================================================================== |
| 95 | /// | 97 | /// |
| 96 | /// @ingroup cpp_kodi_gui_control_CButton | 98 | /// @ingroup cpp_kodi_gui_control_CButton |
| 97 | /// @brief To set the text string on button | 99 | /// @brief To set the text string on button |
| 98 | /// | 100 | /// |
| 99 | /// @param[in] label Text to show | 101 | /// @param[in] label Text to show |
| 100 | /// | 102 | /// |
| 101 | void SetLabel(const std::string& label) | 103 | void SetLabel(const std::string& label) |
| 102 | { | 104 | { |
| 103 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | 105 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, |
| 104 | } | 106 | label.c_str()); |
| 105 | //-------------------------------------------------------------------------- | 107 | } |
| 108 | //-------------------------------------------------------------------------- | ||
| 106 | 109 | ||
| 107 | //========================================================================== | 110 | //========================================================================== |
| 108 | /// | 111 | /// |
| 109 | /// @ingroup cpp_kodi_gui_control_CButton | 112 | /// @ingroup cpp_kodi_gui_control_CButton |
| 110 | /// @brief Get the used text from button | 113 | /// @brief Get the used text from button |
| 111 | /// | 114 | /// |
| 112 | /// @return Text shown | 115 | /// @return Text shown |
| 113 | /// | 116 | /// |
| 114 | std::string GetLabel() const | 117 | std::string GetLabel() const |
| 118 | { | ||
| 119 | std::string label; | ||
| 120 | char* ret = | ||
| 121 | m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 122 | if (ret != nullptr) | ||
| 115 | { | 123 | { |
| 116 | std::string label; | 124 | if (std::strlen(ret)) |
| 117 | char* ret = m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); | 125 | label = ret; |
| 118 | if (ret != nullptr) | 126 | m_interface->free_string(m_interface->kodiBase, ret); |
| 119 | { | ||
| 120 | if (std::strlen(ret)) | ||
| 121 | label = ret; | ||
| 122 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 123 | } | ||
| 124 | return label; | ||
| 125 | } | 127 | } |
| 126 | //-------------------------------------------------------------------------- | 128 | return label; |
| 129 | } | ||
| 130 | //-------------------------------------------------------------------------- | ||
| 127 | 131 | ||
| 128 | //========================================================================== | 132 | //========================================================================== |
| 129 | /// | 133 | /// |
| 130 | /// @ingroup cpp_kodi_gui_control_CButton | 134 | /// @ingroup cpp_kodi_gui_control_CButton |
| 131 | /// @brief If two labels are used for button becomes it set with them | 135 | /// @brief If two labels are used for button becomes it set with them |
| 132 | /// | 136 | /// |
| 133 | /// @param[in] label Text for second label | 137 | /// @param[in] label Text for second label |
| 134 | /// | 138 | /// |
| 135 | void SetLabel2(const std::string& label) | 139 | void SetLabel2(const std::string& label) |
| 136 | { | 140 | { |
| 137 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); | 141 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, |
| 138 | } | 142 | label.c_str()); |
| 139 | //-------------------------------------------------------------------------- | 143 | } |
| 144 | //-------------------------------------------------------------------------- | ||
| 140 | 145 | ||
| 141 | //========================================================================== | 146 | //========================================================================== |
| 142 | /// | 147 | /// |
| 143 | /// @ingroup cpp_kodi_gui_control_CButton | 148 | /// @ingroup cpp_kodi_gui_control_CButton |
| 144 | /// @brief Get the second label if present | 149 | /// @brief Get the second label if present |
| 145 | /// | 150 | /// |
| 146 | /// @return Second label | 151 | /// @return Second label |
| 147 | /// | 152 | /// |
| 148 | std::string GetLabel2() const | 153 | std::string GetLabel2() const |
| 154 | { | ||
| 155 | std::string label; | ||
| 156 | char* ret = | ||
| 157 | m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 158 | if (ret != nullptr) | ||
| 149 | { | 159 | { |
| 150 | std::string label; | 160 | if (std::strlen(ret)) |
| 151 | char* ret = m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); | 161 | label = ret; |
| 152 | if (ret != nullptr) | 162 | m_interface->free_string(m_interface->kodiBase, ret); |
| 153 | { | ||
| 154 | if (std::strlen(ret)) | ||
| 155 | label = ret; | ||
| 156 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 157 | } | ||
| 158 | return label; | ||
| 159 | } | 163 | } |
| 160 | //-------------------------------------------------------------------------- | 164 | return label; |
| 161 | }; | 165 | } |
| 166 | //-------------------------------------------------------------------------- | ||
| 167 | }; | ||
| 162 | 168 | ||
| 163 | } /* namespace controls */ | 169 | } /* namespace controls */ |
| 164 | } /* namespace gui */ | 170 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h index 5d30160..99c01de 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h | |||
| @@ -95,170 +95,180 @@ namespace gui | |||
| 95 | namespace controls | 95 | namespace controls |
| 96 | { | 96 | { |
| 97 | 97 | ||
| 98 | class CEdit : public CAddonGUIControlBase | 98 | class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase |
| 99 | { | ||
| 100 | public: | ||
| 101 | //========================================================================== | ||
| 102 | /// | ||
| 103 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 104 | /// @brief Construct a new control | ||
| 105 | /// | ||
| 106 | /// @param[in] window related window control class | ||
| 107 | /// @param[in] controlId Used skin xml control id | ||
| 108 | /// | ||
| 109 | CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 99 | { | 110 | { |
| 100 | public: | 111 | m_controlHandle = m_interface->kodi_gui->window->get_control_edit( |
| 101 | //========================================================================== | 112 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); |
| 102 | /// | 113 | if (!m_controlHandle) |
| 103 | /// \ingroup cpp_kodi_gui_controls_CEdit | 114 | kodi::Log(ADDON_LOG_FATAL, |
| 104 | /// @brief Construct a new control | 115 | "kodi::gui::control::CEdit can't create control class from Kodi !!!"); |
| 105 | /// | 116 | } |
| 106 | /// @param[in] window related window control class | 117 | //-------------------------------------------------------------------------- |
| 107 | /// @param[in] controlId Used skin xml control id | ||
| 108 | /// | ||
| 109 | CEdit(CWindow* window, int controlId) | ||
| 110 | : CAddonGUIControlBase(window) | ||
| 111 | { | ||
| 112 | m_controlHandle = m_interface->kodi_gui->window->get_control_edit(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 113 | if (!m_controlHandle) | ||
| 114 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::control::CEdit can't create control class from Kodi !!!"); | ||
| 115 | } | ||
| 116 | //-------------------------------------------------------------------------- | ||
| 117 | 118 | ||
| 118 | //========================================================================== | 119 | //========================================================================== |
| 119 | /// | 120 | /// |
| 120 | /// \ingroup cpp_kodi_gui_controls_CEdit | 121 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 121 | /// @brief Destructor | 122 | /// @brief Destructor |
| 122 | /// | 123 | /// |
| 123 | ~CEdit() override = default; | 124 | ~CEdit() override = default; |
| 124 | //-------------------------------------------------------------------------- | 125 | //-------------------------------------------------------------------------- |
| 125 | 126 | ||
| 126 | //========================================================================== | 127 | //========================================================================== |
| 127 | /// | 128 | /// |
| 128 | /// \ingroup cpp_kodi_gui_controls_CEdit | 129 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 129 | /// @brief Set the control on window to visible | 130 | /// @brief Set the control on window to visible |
| 130 | /// | 131 | /// |
| 131 | /// @param[in] visible If true visible, otherwise hidden | 132 | /// @param[in] visible If true visible, otherwise hidden |
| 132 | /// | 133 | /// |
| 133 | void SetVisible(bool visible) | 134 | void SetVisible(bool visible) |
| 134 | { | 135 | { |
| 135 | m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, visible); | 136 | m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, |
| 136 | } | 137 | visible); |
| 137 | //-------------------------------------------------------------------------- | 138 | } |
| 139 | //-------------------------------------------------------------------------- | ||
| 138 | 140 | ||
| 139 | //========================================================================== | 141 | //========================================================================== |
| 140 | /// | 142 | /// |
| 141 | /// \ingroup cpp_kodi_gui_controls_CEdit | 143 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 142 | /// @brief Set's the control's enabled/disabled state | 144 | /// @brief Set's the control's enabled/disabled state |
| 143 | /// | 145 | /// |
| 144 | /// @param[in] enabled If true enabled, otherwise disabled | 146 | /// @param[in] enabled If true enabled, otherwise disabled |
| 145 | /// | 147 | /// |
| 146 | void SetEnabled(bool enabled) | 148 | void SetEnabled(bool enabled) |
| 147 | { | 149 | { |
| 148 | m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | 150 | m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 149 | } | 151 | enabled); |
| 150 | //-------------------------------------------------------------------------- | 152 | } |
| 153 | //-------------------------------------------------------------------------- | ||
| 151 | 154 | ||
| 152 | //========================================================================== | 155 | //========================================================================== |
| 153 | /// | 156 | /// |
| 154 | /// \ingroup cpp_kodi_gui_controls_CEdit | 157 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 155 | /// @brief To set the text string on edit control | 158 | /// @brief To set the text string on edit control |
| 156 | /// | 159 | /// |
| 157 | /// @param[in] label Text to show | 160 | /// @param[in] label Text to show |
| 158 | /// | 161 | /// |
| 159 | void SetLabel(const std::string& label) | 162 | void SetLabel(const std::string& label) |
| 160 | { | 163 | { |
| 161 | m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | 164 | m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, |
| 162 | } | 165 | label.c_str()); |
| 163 | //-------------------------------------------------------------------------- | 166 | } |
| 167 | //-------------------------------------------------------------------------- | ||
| 164 | 168 | ||
| 165 | //========================================================================== | 169 | //========================================================================== |
| 166 | /// | 170 | /// |
| 167 | /// \ingroup cpp_kodi_gui_controls_CEdit | 171 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 168 | /// @brief Returns the text heading for this edit control. | 172 | /// @brief Returns the text heading for this edit control. |
| 169 | /// | 173 | /// |
| 170 | /// @return Heading text | 174 | /// @return Heading text |
| 171 | /// | 175 | /// |
| 172 | std::string GetLabel() const | 176 | std::string GetLabel() const |
| 177 | { | ||
| 178 | std::string label; | ||
| 179 | char* ret = | ||
| 180 | m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 181 | if (ret != nullptr) | ||
| 173 | { | 182 | { |
| 174 | std::string label; | 183 | if (std::strlen(ret)) |
| 175 | char* ret = m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle); | 184 | label = ret; |
| 176 | if (ret != nullptr) | 185 | m_interface->free_string(m_interface->kodiBase, ret); |
| 177 | { | ||
| 178 | if (std::strlen(ret)) | ||
| 179 | label = ret; | ||
| 180 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 181 | } | ||
| 182 | return label; | ||
| 183 | } | 186 | } |
| 184 | //-------------------------------------------------------------------------- | 187 | return label; |
| 188 | } | ||
| 189 | //-------------------------------------------------------------------------- | ||
| 185 | 190 | ||
| 186 | //========================================================================== | 191 | //========================================================================== |
| 187 | /// | 192 | /// |
| 188 | /// \ingroup cpp_kodi_gui_controls_CEdit | 193 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 189 | /// @brief Set's text heading for this edit control. | 194 | /// @brief Set's text heading for this edit control. |
| 190 | /// | 195 | /// |
| 191 | /// @param[in] text string or unicode - text string. | 196 | /// @param[in] text string or unicode - text string. |
| 192 | /// | 197 | /// |
| 193 | void SetText(const std::string& text) | 198 | void SetText(const std::string& text) |
| 194 | { | 199 | { |
| 195 | m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); | 200 | m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, |
| 196 | } | 201 | text.c_str()); |
| 197 | //-------------------------------------------------------------------------- | 202 | } |
| 203 | //-------------------------------------------------------------------------- | ||
| 198 | 204 | ||
| 199 | //========================================================================== | 205 | //========================================================================== |
| 200 | /// | 206 | /// |
| 201 | /// \ingroup cpp_kodi_gui_controls_CEdit | 207 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 202 | /// @brief Returns the text value for this edit control. | 208 | /// @brief Returns the text value for this edit control. |
| 203 | /// | 209 | /// |
| 204 | /// @return Text value of control | 210 | /// @return Text value of control |
| 205 | /// | 211 | /// |
| 206 | std::string GetText() const | 212 | std::string GetText() const |
| 213 | { | ||
| 214 | std::string text; | ||
| 215 | char* ret = | ||
| 216 | m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle); | ||
| 217 | if (ret != nullptr) | ||
| 207 | { | 218 | { |
| 208 | std::string text; | 219 | if (std::strlen(ret)) |
| 209 | char* ret = m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle); | 220 | text = ret; |
| 210 | if (ret != nullptr) | 221 | m_interface->free_string(m_interface->kodiBase, ret); |
| 211 | { | ||
| 212 | if (std::strlen(ret)) | ||
| 213 | text = ret; | ||
| 214 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 215 | } | ||
| 216 | return text; | ||
| 217 | } | 222 | } |
| 218 | //-------------------------------------------------------------------------- | 223 | return text; |
| 224 | } | ||
| 225 | //-------------------------------------------------------------------------- | ||
| 219 | 226 | ||
| 220 | //========================================================================== | 227 | //========================================================================== |
| 221 | /// | 228 | /// |
| 222 | /// \ingroup cpp_kodi_gui_controls_CEdit | 229 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 223 | /// @brief Set the cursor position on text. | 230 | /// @brief Set the cursor position on text. |
| 224 | /// | 231 | /// |
| 225 | /// @param[in] iPosition The position to set | 232 | /// @param[in] iPosition The position to set |
| 226 | /// | 233 | /// |
| 227 | void SetCursorPosition(unsigned int iPosition) | 234 | void SetCursorPosition(unsigned int iPosition) |
| 228 | { | 235 | { |
| 229 | m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, iPosition); | 236 | m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, |
| 230 | } | 237 | iPosition); |
| 231 | //-------------------------------------------------------------------------- | 238 | } |
| 239 | //-------------------------------------------------------------------------- | ||
| 232 | 240 | ||
| 233 | //========================================================================== | 241 | //========================================================================== |
| 234 | /// | 242 | /// |
| 235 | /// \ingroup cpp_kodi_gui_controls_CEdit | 243 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 236 | /// @brief To get current cursor position on text field | 244 | /// @brief To get current cursor position on text field |
| 237 | /// | 245 | /// |
| 238 | /// @return The current cursor position | 246 | /// @return The current cursor position |
| 239 | /// | 247 | /// |
| 240 | unsigned int GetCursorPosition() | 248 | unsigned int GetCursorPosition() |
| 241 | { | 249 | { |
| 242 | return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, m_controlHandle); | 250 | return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, |
| 243 | } | 251 | m_controlHandle); |
| 244 | //-------------------------------------------------------------------------- | 252 | } |
| 253 | //-------------------------------------------------------------------------- | ||
| 245 | 254 | ||
| 246 | //========================================================================== | 255 | //========================================================================== |
| 247 | /// | 256 | /// |
| 248 | /// \ingroup cpp_kodi_gui_controls_CEdit | 257 | /// \ingroup cpp_kodi_gui_controls_CEdit |
| 249 | /// @brief To set field input type which are defined on \ref AddonGUIInputType | 258 | /// @brief To set field input type which are defined on \ref AddonGUIInputType |
| 250 | /// | 259 | /// |
| 251 | /// @param[in] type The \ref AddonGUIInputType "Add-on input type" | 260 | /// @param[in] type The \ref AddonGUIInputType "Add-on input type" |
| 252 | /// to use | 261 | /// to use |
| 253 | /// @param[in] heading The heading text for related keyboard | 262 | /// @param[in] heading The heading text for related keyboard |
| 254 | /// dialog | 263 | /// dialog |
| 255 | /// | 264 | /// |
| 256 | void SetInputType(AddonGUIInputType type, const std::string& heading) | 265 | void SetInputType(AddonGUIInputType type, const std::string& heading) |
| 257 | { | 266 | { |
| 258 | m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, static_cast<int>(type), heading.c_str()); | 267 | m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, |
| 259 | } | 268 | static_cast<int>(type), heading.c_str()); |
| 260 | //-------------------------------------------------------------------------- | 269 | } |
| 261 | }; | 270 | //-------------------------------------------------------------------------- |
| 271 | }; | ||
| 262 | 272 | ||
| 263 | } /* namespace controls */ | 273 | } /* namespace controls */ |
| 264 | } /* namespace gui */ | 274 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h index aab8929..02c843f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h | |||
| @@ -18,130 +18,135 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CFadeLabel Control Fade Label | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CFadeLabel } | ||
| 26 | /// **Window control used to show multiple pieces of text in the same position, | ||
| 27 | /// by fading from one to the other** | ||
| 28 | /// | ||
| 29 | /// The fade label control is used for displaying multiple pieces of text in | ||
| 30 | /// the same space in Kodi. You can choose the font, size, colour, location | ||
| 31 | /// and contents of the text to be displayed. The first piece of information | ||
| 32 | /// to display fades in over 50 frames, then scrolls off to the left. Once it | ||
| 33 | /// is finished scrolling off screen, the second piece of information fades | ||
| 34 | /// in and the process repeats. A fade label control is not supported in a | ||
| 35 | /// list container. | ||
| 36 | /// | ||
| 37 | /// It has the header \ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>" | ||
| 38 | /// be included to enjoy it. | ||
| 39 | /// | ||
| 40 | /// Here you find the needed skin part for a \ref Fade_Label_Control "fade label control" | ||
| 41 | /// | ||
| 42 | /// @note The call of the control is only possible from the corresponding | ||
| 43 | /// window as its class and identification number is required. | ||
| 44 | /// | ||
| 45 | class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase | ||
| 46 | { | ||
| 47 | public: | ||
| 48 | //========================================================================== | ||
| 22 | /// | 49 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CFadeLabel Control Fade Label | 50 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 24 | /// \ingroup cpp_kodi_gui | 51 | /// @brief Construct a new control. |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CFadeLabel } | ||
| 26 | /// **Window control used to show multiple pieces of text in the same position, | ||
| 27 | /// by fading from one to the other** | ||
| 28 | /// | 52 | /// |
| 29 | /// The fade label control is used for displaying multiple pieces of text in | 53 | /// @param[in] window related window control class |
| 30 | /// the same space in Kodi. You can choose the font, size, colour, location | 54 | /// @param[in] controlId Used skin xml control id |
| 31 | /// and contents of the text to be displayed. The first piece of information | ||
| 32 | /// to display fades in over 50 frames, then scrolls off to the left. Once it | ||
| 33 | /// is finished scrolling off screen, the second piece of information fades | ||
| 34 | /// in and the process repeats. A fade label control is not supported in a | ||
| 35 | /// list container. | ||
| 36 | /// | 55 | /// |
| 37 | /// It has the header \ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>" | 56 | CFadeLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 38 | /// be included to enjoy it. | 57 | { |
| 58 | m_controlHandle = m_interface->kodi_gui->window->get_control_fade_label( | ||
| 59 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 60 | if (!m_controlHandle) | ||
| 61 | kodi::Log(ADDON_LOG_FATAL, | ||
| 62 | "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); | ||
| 63 | } | ||
| 64 | //-------------------------------------------------------------------------- | ||
| 65 | |||
| 66 | //========================================================================== | ||
| 39 | /// | 67 | /// |
| 40 | /// Here you find the needed skin part for a \ref Fade_Label_Control "fade label control" | 68 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 69 | /// @brief Destructor. | ||
| 70 | /// | ||
| 71 | ~CFadeLabel() override = default; | ||
| 72 | //-------------------------------------------------------------------------- | ||
| 73 | |||
| 74 | //========================================================================== | ||
| 41 | /// | 75 | /// |
| 42 | /// @note The call of the control is only possible from the corresponding | 76 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 43 | /// window as its class and identification number is required. | 77 | /// @brief Set the control on window to visible. |
| 44 | /// | 78 | /// |
| 45 | class CFadeLabel : public CAddonGUIControlBase | 79 | /// @param[in] visible If true visible, otherwise hidden |
| 80 | /// | ||
| 81 | void SetVisible(bool visible) | ||
| 46 | { | 82 | { |
| 47 | public: | 83 | m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, |
| 48 | //========================================================================== | 84 | visible); |
| 49 | /// | 85 | } |
| 50 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 86 | //-------------------------------------------------------------------------- |
| 51 | /// @brief Construct a new control. | ||
| 52 | /// | ||
| 53 | /// @param[in] window related window control class | ||
| 54 | /// @param[in] controlId Used skin xml control id | ||
| 55 | /// | ||
| 56 | CFadeLabel(CWindow* window, int controlId) | ||
| 57 | : CAddonGUIControlBase(window) | ||
| 58 | { | ||
| 59 | m_controlHandle = m_interface->kodi_gui->window->get_control_fade_label(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 60 | if (!m_controlHandle) | ||
| 61 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); | ||
| 62 | } | ||
| 63 | //-------------------------------------------------------------------------- | ||
| 64 | |||
| 65 | //========================================================================== | ||
| 66 | /// | ||
| 67 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 68 | /// @brief Destructor. | ||
| 69 | /// | ||
| 70 | ~CFadeLabel() override = default; | ||
| 71 | //-------------------------------------------------------------------------- | ||
| 72 | 87 | ||
| 73 | //========================================================================== | 88 | //========================================================================== |
| 74 | /// | 89 | /// |
| 75 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 90 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 76 | /// @brief Set the control on window to visible. | 91 | /// @brief To add additional text string on fade label. |
| 77 | /// | 92 | /// |
| 78 | /// @param[in] visible If true visible, otherwise hidden | 93 | /// @param[in] label Text to show |
| 79 | /// | 94 | /// |
| 80 | void SetVisible(bool visible) | 95 | void AddLabel(const std::string& label) |
| 81 | { | 96 | { |
| 82 | m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, visible); | 97 | m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, |
| 83 | } | 98 | label.c_str()); |
| 84 | //-------------------------------------------------------------------------- | 99 | } |
| 85 | 100 | //-------------------------------------------------------------------------- | |
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 89 | /// @brief To add additional text string on fade label. | ||
| 90 | /// | ||
| 91 | /// @param[in] label Text to show | ||
| 92 | /// | ||
| 93 | void AddLabel(const std::string& label) | ||
| 94 | { | ||
| 95 | m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 96 | } | ||
| 97 | //-------------------------------------------------------------------------- | ||
| 98 | 101 | ||
| 99 | //========================================================================== | 102 | //========================================================================== |
| 100 | /// | 103 | /// |
| 101 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 104 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 102 | /// @brief Get the used text from button | 105 | /// @brief Get the used text from button |
| 103 | /// | 106 | /// |
| 104 | /// @return Text shown | 107 | /// @return Text shown |
| 105 | /// | 108 | /// |
| 106 | std::string GetLabel() const | 109 | std::string GetLabel() const |
| 110 | { | ||
| 111 | std::string label; | ||
| 112 | char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase, | ||
| 113 | m_controlHandle); | ||
| 114 | if (ret != nullptr) | ||
| 107 | { | 115 | { |
| 108 | std::string label; | 116 | if (std::strlen(ret)) |
| 109 | char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase, m_controlHandle); | 117 | label = ret; |
| 110 | if (ret != nullptr) | 118 | m_interface->free_string(m_interface->kodiBase, ret); |
| 111 | { | ||
| 112 | if (std::strlen(ret)) | ||
| 113 | label = ret; | ||
| 114 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 115 | } | ||
| 116 | return label; | ||
| 117 | } | 119 | } |
| 118 | //-------------------------------------------------------------------------- | 120 | return label; |
| 121 | } | ||
| 122 | //-------------------------------------------------------------------------- | ||
| 119 | 123 | ||
| 120 | //========================================================================== | 124 | //========================================================================== |
| 121 | /// | 125 | /// |
| 122 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 126 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 123 | /// @brief To enable or disable scrolling on fade label | 127 | /// @brief To enable or disable scrolling on fade label |
| 124 | /// | 128 | /// |
| 125 | /// @param[in] scroll To enable scrolling set to true, otherwise is | 129 | /// @param[in] scroll To enable scrolling set to true, otherwise is |
| 126 | /// disabled | 130 | /// disabled |
| 127 | /// | 131 | /// |
| 128 | void SetScrolling(bool scroll) | 132 | void SetScrolling(bool scroll) |
| 129 | { | 133 | { |
| 130 | m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, scroll); | 134 | m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, |
| 131 | } | 135 | scroll); |
| 132 | //-------------------------------------------------------------------------- | 136 | } |
| 137 | //-------------------------------------------------------------------------- | ||
| 133 | 138 | ||
| 134 | //========================================================================== | 139 | //========================================================================== |
| 135 | /// | 140 | /// |
| 136 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | 141 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel |
| 137 | /// @brief To reset al inserted labels. | 142 | /// @brief To reset al inserted labels. |
| 138 | /// | 143 | /// |
| 139 | void Reset() | 144 | void Reset() |
| 140 | { | 145 | { |
| 141 | m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); | 146 | m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); |
| 142 | } | 147 | } |
| 143 | //-------------------------------------------------------------------------- | 148 | //-------------------------------------------------------------------------- |
| 144 | }; | 149 | }; |
| 145 | 150 | ||
| 146 | } /* namespace controls */ | 151 | } /* namespace controls */ |
| 147 | } /* namespace gui */ | 152 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h index a872ab0..b4d092f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h | |||
| @@ -18,94 +18,98 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CImage Control Image | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CImage } | ||
| 26 | /// **Window control used to show an image.** | ||
| 27 | /// | ||
| 28 | /// The image control is used for displaying images in Kodi. You can choose | ||
| 29 | /// the position, size, transparency and contents of the image to be displayed. | ||
| 30 | /// | ||
| 31 | /// It has the header \ref Image.h "#include <kodi/gui/controls/Image.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// Here you find the needed skin part for a \ref Image_Control "image control" | ||
| 35 | /// | ||
| 36 | /// @note The call of the control is only possible from the corresponding | ||
| 37 | /// window as its class and identification number is required. | ||
| 38 | /// | ||
| 39 | class ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase | ||
| 40 | { | ||
| 41 | public: | ||
| 42 | //========================================================================== | ||
| 43 | /// | ||
| 44 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 45 | /// @brief Construct a new control | ||
| 22 | /// | 46 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CImage Control Image | 47 | /// @param[in] window related window control class |
| 24 | /// \ingroup cpp_kodi_gui | 48 | /// @param[in] controlId Used skin xml control id |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CImage } | 49 | /// |
| 26 | /// **Window control used to show an image.** | 50 | CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 51 | { | ||
| 52 | m_controlHandle = m_interface->kodi_gui->window->get_control_image( | ||
| 53 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 54 | if (!m_controlHandle) | ||
| 55 | kodi::Log(ADDON_LOG_FATAL, | ||
| 56 | "kodi::gui::controls::CImage can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 27 | /// | 61 | /// |
| 28 | /// The image control is used for displaying images in Kodi. You can choose | 62 | /// \ingroup cpp_kodi_gui_controls_CImage |
| 29 | /// the position, size, transparency and contents of the image to be displayed. | 63 | /// @brief Destructor |
| 30 | /// | 64 | /// |
| 31 | /// It has the header \ref Image.h "#include <kodi/gui/controls/Image.h>" | 65 | ~CImage() override = default; |
| 32 | /// be included to enjoy it. | 66 | //-------------------------------------------------------------------------- |
| 67 | |||
| 68 | //========================================================================== | ||
| 33 | /// | 69 | /// |
| 34 | /// Here you find the needed skin part for a \ref Image_Control "image control" | 70 | /// \ingroup cpp_kodi_gui_controls_CImage |
| 71 | /// @brief Set the control on window to visible | ||
| 35 | /// | 72 | /// |
| 36 | /// @note The call of the control is only possible from the corresponding | 73 | /// @param[in] visible If true visible, otherwise hidden |
| 37 | /// window as its class and identification number is required. | ||
| 38 | /// | 74 | /// |
| 39 | class CImage : public CAddonGUIControlBase | 75 | void SetVisible(bool visible) |
| 40 | { | 76 | { |
| 41 | public: | 77 | m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle, |
| 42 | //========================================================================== | 78 | visible); |
| 43 | /// | 79 | } |
| 44 | /// \ingroup cpp_kodi_gui_controls_CImage | 80 | //-------------------------------------------------------------------------- |
| 45 | /// @brief Construct a new control | ||
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 49 | /// | ||
| 50 | CImage(CWindow* window, int controlId) | ||
| 51 | : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_image(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 54 | if (!m_controlHandle) | ||
| 55 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CImage can't create control class from Kodi !!!"); | ||
| 56 | } | ||
| 57 | //-------------------------------------------------------------------------- | ||
| 58 | |||
| 59 | //========================================================================== | ||
| 60 | /// | ||
| 61 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 62 | /// @brief Destructor | ||
| 63 | /// | ||
| 64 | ~CImage() override = default; | ||
| 65 | //-------------------------------------------------------------------------- | ||
| 66 | |||
| 67 | //========================================================================== | ||
| 68 | /// | ||
| 69 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 70 | /// @brief Set the control on window to visible | ||
| 71 | /// | ||
| 72 | /// @param[in] visible If true visible, otherwise hidden | ||
| 73 | /// | ||
| 74 | void SetVisible(bool visible) | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 77 | } | ||
| 78 | //-------------------------------------------------------------------------- | ||
| 79 | 81 | ||
| 80 | //========================================================================== | 82 | //========================================================================== |
| 81 | /// | 83 | /// |
| 82 | /// \ingroup cpp_kodi_gui_controls_CImage | 84 | /// \ingroup cpp_kodi_gui_controls_CImage |
| 83 | /// @brief To set the filename used on image control. | 85 | /// @brief To set the filename used on image control. |
| 84 | /// | 86 | /// |
| 85 | /// @param[in] filename Image file to use | 87 | /// @param[in] filename Image file to use |
| 86 | /// @param[in] useCache To define storage of image, default is | 88 | /// @param[in] useCache To define storage of image, default is |
| 87 | /// in cache, if false becomes it loaded | 89 | /// in cache, if false becomes it loaded |
| 88 | /// always on changes again | 90 | /// always on changes again |
| 89 | /// | 91 | /// |
| 90 | void SetFileName(const std::string& filename, bool useCache = true) | 92 | void SetFileName(const std::string& filename, bool useCache = true) |
| 91 | { | 93 | { |
| 92 | m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle, filename.c_str(), useCache); | 94 | m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle, |
| 93 | } | 95 | filename.c_str(), useCache); |
| 94 | //-------------------------------------------------------------------------- | 96 | } |
| 97 | //-------------------------------------------------------------------------- | ||
| 95 | 98 | ||
| 96 | //========================================================================== | 99 | //========================================================================== |
| 97 | /// | 100 | /// |
| 98 | /// \ingroup cpp_kodi_gui_controls_CImage | 101 | /// \ingroup cpp_kodi_gui_controls_CImage |
| 99 | /// @brief To set set the diffuse color on image. | 102 | /// @brief To set set the diffuse color on image. |
| 100 | /// | 103 | /// |
| 101 | /// @param[in] colorDiffuse Color to use for diffuse | 104 | /// @param[in] colorDiffuse Color to use for diffuse |
| 102 | /// | 105 | /// |
| 103 | void SetColorDiffuse(uint32_t colorDiffuse) | 106 | void SetColorDiffuse(uint32_t colorDiffuse) |
| 104 | { | 107 | { |
| 105 | m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle, colorDiffuse); | 108 | m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle, |
| 106 | } | 109 | colorDiffuse); |
| 107 | //-------------------------------------------------------------------------- | 110 | } |
| 108 | }; | 111 | //-------------------------------------------------------------------------- |
| 112 | }; | ||
| 109 | 113 | ||
| 110 | } /* namespace controls */ | 114 | } /* namespace controls */ |
| 111 | } /* namespace gui */ | 115 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h index eecfd8b..82604bd 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h | |||
| @@ -18,99 +18,103 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CLabel Control Label | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CLabel } | ||
| 26 | /// **Window control used to show some lines of text.** | ||
| 27 | /// | ||
| 28 | /// The label control is used for displaying text in Kodi. You can choose | ||
| 29 | /// the font, size, colour, location and contents of the text to be displayed. | ||
| 30 | /// | ||
| 31 | /// It has the header \ref Label.h "#include <kodi/gui/controls/Label.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// Here you find the needed skin part for a \ref Label_Control "label control" | ||
| 35 | /// | ||
| 36 | /// @note The call of the control is only possible from the corresponding | ||
| 37 | /// window as its class and identification number is required. | ||
| 38 | /// | ||
| 39 | class ATTRIBUTE_HIDDEN CLabel : public CAddonGUIControlBase | ||
| 40 | { | ||
| 41 | public: | ||
| 42 | //========================================================================== | ||
| 43 | /// | ||
| 44 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 45 | /// @brief Construct a new control | ||
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 22 | /// | 49 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CLabel Control Label | 50 | CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 24 | /// \ingroup cpp_kodi_gui | 51 | { |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CLabel } | 52 | m_controlHandle = m_interface->kodi_gui->window->get_control_label( |
| 26 | /// **Window control used to show some lines of text.** | 53 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); |
| 54 | if (!m_controlHandle) | ||
| 55 | kodi::Log(ADDON_LOG_FATAL, | ||
| 56 | "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 27 | /// | 61 | /// |
| 28 | /// The label control is used for displaying text in Kodi. You can choose | 62 | /// \ingroup cpp_kodi_gui_controls_CLabel |
| 29 | /// the font, size, colour, location and contents of the text to be displayed. | 63 | /// @brief Destructor |
| 30 | /// | 64 | /// |
| 31 | /// It has the header \ref Label.h "#include <kodi/gui/controls/Label.h>" | 65 | ~CLabel() override = default; |
| 32 | /// be included to enjoy it. | 66 | //-------------------------------------------------------------------------- |
| 67 | |||
| 68 | //========================================================================== | ||
| 33 | /// | 69 | /// |
| 34 | /// Here you find the needed skin part for a \ref Label_Control "label control" | 70 | /// \ingroup cpp_kodi_gui_controls_CLabel |
| 71 | /// @brief Set the control on window to visible | ||
| 35 | /// | 72 | /// |
| 36 | /// @note The call of the control is only possible from the corresponding | 73 | /// @param[in] visible If true visible, otherwise hidden |
| 37 | /// window as its class and identification number is required. | ||
| 38 | /// | 74 | /// |
| 39 | class CLabel : public CAddonGUIControlBase | 75 | void SetVisible(bool visible) |
| 40 | { | 76 | { |
| 41 | public: | 77 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, |
| 42 | //========================================================================== | 78 | visible); |
| 43 | /// | 79 | } |
| 44 | /// \ingroup cpp_kodi_gui_controls_CLabel | 80 | //-------------------------------------------------------------------------- |
| 45 | /// @brief Construct a new control | ||
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 49 | /// | ||
| 50 | CLabel(CWindow* window, int controlId) | ||
| 51 | : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_label(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 54 | if (!m_controlHandle) | ||
| 55 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); | ||
| 56 | } | ||
| 57 | //-------------------------------------------------------------------------- | ||
| 58 | |||
| 59 | //========================================================================== | ||
| 60 | /// | ||
| 61 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 62 | /// @brief Destructor | ||
| 63 | /// | ||
| 64 | ~CLabel() override = default; | ||
| 65 | //-------------------------------------------------------------------------- | ||
| 66 | |||
| 67 | //========================================================================== | ||
| 68 | /// | ||
| 69 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 70 | /// @brief Set the control on window to visible | ||
| 71 | /// | ||
| 72 | /// @param[in] visible If true visible, otherwise hidden | ||
| 73 | /// | ||
| 74 | void SetVisible(bool visible) | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 77 | } | ||
| 78 | //-------------------------------------------------------------------------- | ||
| 79 | 81 | ||
| 80 | //========================================================================== | 82 | //========================================================================== |
| 81 | /// | 83 | /// |
| 82 | /// \ingroup cpp_kodi_gui_controls_CLabel | 84 | /// \ingroup cpp_kodi_gui_controls_CLabel |
| 83 | /// @brief To set the text string on label | 85 | /// @brief To set the text string on label |
| 84 | /// | 86 | /// |
| 85 | /// @param[in] text Text to show | 87 | /// @param[in] text Text to show |
| 86 | /// | 88 | /// |
| 87 | void SetLabel(const std::string& text) | 89 | void SetLabel(const std::string& text) |
| 88 | { | 90 | { |
| 89 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, text.c_str()); | 91 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, |
| 90 | } | 92 | text.c_str()); |
| 91 | //-------------------------------------------------------------------------- | 93 | } |
| 94 | //-------------------------------------------------------------------------- | ||
| 92 | 95 | ||
| 93 | //========================================================================== | 96 | //========================================================================== |
| 94 | /// | 97 | /// |
| 95 | /// \ingroup cpp_kodi_gui_controls_CLabel | 98 | /// \ingroup cpp_kodi_gui_controls_CLabel |
| 96 | /// @brief Get the used text from control | 99 | /// @brief Get the used text from control |
| 97 | /// | 100 | /// |
| 98 | /// @return Used text on label control | 101 | /// @return Used text on label control |
| 99 | /// | 102 | /// |
| 100 | std::string GetLabel() const | 103 | std::string GetLabel() const |
| 104 | { | ||
| 105 | std::string label; | ||
| 106 | char* ret = | ||
| 107 | m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 108 | if (ret != nullptr) | ||
| 101 | { | 109 | { |
| 102 | std::string label; | 110 | if (std::strlen(ret)) |
| 103 | char* ret = m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); | 111 | label = ret; |
| 104 | if (ret != nullptr) | 112 | m_interface->free_string(m_interface->kodiBase, ret); |
| 105 | { | ||
| 106 | if (std::strlen(ret)) | ||
| 107 | label = ret; | ||
| 108 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 109 | } | ||
| 110 | return label; | ||
| 111 | } | 113 | } |
| 112 | //-------------------------------------------------------------------------- | 114 | return label; |
| 113 | }; | 115 | } |
| 116 | //-------------------------------------------------------------------------- | ||
| 117 | }; | ||
| 114 | 118 | ||
| 115 | } /* namespace controls */ | 119 | } /* namespace controls */ |
| 116 | } /* namespace gui */ | 120 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h index 78880c4..8cb582b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h | |||
| @@ -18,92 +18,96 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CProgress Control Progress | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CProgress } | ||
| 26 | /// **Window control to show the progress of a particular operation** | ||
| 27 | /// | ||
| 28 | /// The progress control is used to show the progress of an item that may take | ||
| 29 | /// a long time, or to show how far through a movie you are. You can choose | ||
| 30 | /// the position, size, and look of the progress control. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Progress.h "#include <kodi/gui/controls/Progress.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref Progress_Control "progress control" | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 46 | /// @brief Construct a new control | ||
| 22 | /// | 47 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CProgress Control Progress | 48 | /// @param[in] window related window control class |
| 24 | /// \ingroup cpp_kodi_gui | 49 | /// @param[in] controlId Used skin xml control id |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CProgress } | 50 | /// |
| 26 | /// **Window control to show the progress of a particular operation** | 51 | CProgress(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_progress( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //-------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //========================================================================== | ||
| 27 | /// | 62 | /// |
| 28 | /// The progress control is used to show the progress of an item that may take | 63 | /// \ingroup cpp_kodi_gui_controls_CProgress |
| 29 | /// a long time, or to show how far through a movie you are. You can choose | 64 | /// @brief Destructor |
| 30 | /// the position, size, and look of the progress control. | ||
| 31 | /// | 65 | /// |
| 32 | /// It has the header \ref Progress.h "#include <kodi/gui/controls/Progress.h>" | 66 | ~CProgress() override = default; |
| 33 | /// be included to enjoy it. | 67 | //-------------------------------------------------------------------------- |
| 68 | |||
| 69 | //========================================================================== | ||
| 34 | /// | 70 | /// |
| 35 | /// Here you find the needed skin part for a \ref Progress_Control "progress control" | 71 | /// \ingroup cpp_kodi_gui_controls_CProgress |
| 72 | /// @brief Set the control on window to visible | ||
| 36 | /// | 73 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 74 | /// @param[in] visible If true visible, otherwise hidden |
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | 75 | /// |
| 40 | class CProgress : public CAddonGUIControlBase | 76 | void SetVisible(bool visible) |
| 41 | { | 77 | { |
| 42 | public: | 78 | m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, |
| 43 | //========================================================================== | 79 | visible); |
| 44 | /// | 80 | } |
| 45 | /// \ingroup cpp_kodi_gui_controls_CProgress | 81 | //-------------------------------------------------------------------------- |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CProgress(CWindow* window, int controlId) | ||
| 52 | : CAddonGUIControlBase(window) | ||
| 53 | { | ||
| 54 | m_controlHandle = m_interface->kodi_gui->window->get_control_progress(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 63 | /// @brief Destructor | ||
| 64 | /// | ||
| 65 | ~CProgress() override = default; | ||
| 66 | //-------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //========================================================================== | ||
| 69 | /// | ||
| 70 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 78 | } | ||
| 79 | //-------------------------------------------------------------------------- | ||
| 80 | 82 | ||
| 81 | //========================================================================== | 83 | //========================================================================== |
| 82 | /// | 84 | /// |
| 83 | /// \ingroup cpp_kodi_gui_controls_CProgress | 85 | /// \ingroup cpp_kodi_gui_controls_CProgress |
| 84 | /// @brief To set Percent position of control | 86 | /// @brief To set Percent position of control |
| 85 | /// | 87 | /// |
| 86 | /// @param[in] percent The percent position to use | 88 | /// @param[in] percent The percent position to use |
| 87 | /// | 89 | /// |
| 88 | void SetPercentage(float percent) | 90 | void SetPercentage(float percent) |
| 89 | { | 91 | { |
| 90 | m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, percent); | 92 | m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, |
| 91 | } | 93 | percent); |
| 92 | //-------------------------------------------------------------------------- | 94 | } |
| 95 | //-------------------------------------------------------------------------- | ||
| 93 | 96 | ||
| 94 | //========================================================================== | 97 | //========================================================================== |
| 95 | /// | 98 | /// |
| 96 | /// \ingroup cpp_kodi_gui_controls_CProgress | 99 | /// \ingroup cpp_kodi_gui_controls_CProgress |
| 97 | /// @brief Get the active percent position of progress bar | 100 | /// @brief Get the active percent position of progress bar |
| 98 | /// | 101 | /// |
| 99 | /// @return Progress position as percent | 102 | /// @return Progress position as percent |
| 100 | /// | 103 | /// |
| 101 | float GetPercentage() const | 104 | float GetPercentage() const |
| 102 | { | 105 | { |
| 103 | return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, m_controlHandle); | 106 | return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, |
| 104 | } | 107 | m_controlHandle); |
| 105 | //-------------------------------------------------------------------------- | 108 | } |
| 106 | }; | 109 | //-------------------------------------------------------------------------- |
| 110 | }; | ||
| 107 | 111 | ||
| 108 | } /* namespace controls */ | 112 | } /* namespace controls */ |
| 109 | } /* namespace gui */ | 113 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h index 1721759..305195d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h | |||
| @@ -18,142 +18,149 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CRadioButton } | ||
| 26 | /// **Window control for a radio button (as used for on/off settings)** | ||
| 27 | /// | ||
| 28 | /// The radio button control is used for creating push button on/off settings | ||
| 29 | /// in Kodi. You can choose the position, size, and look of the button. When | ||
| 30 | /// the user clicks on the radio button, the state will change, toggling the | ||
| 31 | /// extra textures (textureradioon and textureradiooff). Used for settings | ||
| 32 | /// controls. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a \ref Radio_button_control "radio button control" | ||
| 38 | /// | ||
| 39 | /// @note The call of the control is only possible from the corresponding | ||
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | ||
| 42 | class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase | ||
| 43 | { | ||
| 44 | public: | ||
| 45 | //========================================================================== | ||
| 46 | /// | ||
| 47 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 48 | /// @brief Construct a new control | ||
| 49 | /// | ||
| 50 | /// @param[in] window related window control class | ||
| 51 | /// @param[in] controlId Used skin xml control id | ||
| 22 | /// | 52 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button | 53 | CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 24 | /// \ingroup cpp_kodi_gui | 54 | { |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CRadioButton } | 55 | m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button( |
| 26 | /// **Window control for a radio button (as used for on/off settings)** | 56 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); |
| 57 | if (!m_controlHandle) | ||
| 58 | kodi::Log(ADDON_LOG_FATAL, | ||
| 59 | "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); | ||
| 60 | } | ||
| 61 | //-------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //========================================================================== | ||
| 27 | /// | 64 | /// |
| 28 | /// The radio button control is used for creating push button on/off settings | 65 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 29 | /// in Kodi. You can choose the position, size, and look of the button. When | 66 | /// @brief Destructor |
| 30 | /// the user clicks on the radio button, the state will change, toggling the | ||
| 31 | /// extra textures (textureradioon and textureradiooff). Used for settings | ||
| 32 | /// controls. | ||
| 33 | /// | 67 | /// |
| 34 | /// It has the header \ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" | 68 | ~CRadioButton() override = default; |
| 35 | /// be included to enjoy it. | 69 | //-------------------------------------------------------------------------- |
| 70 | |||
| 71 | //========================================================================== | ||
| 36 | /// | 72 | /// |
| 37 | /// Here you find the needed skin part for a \ref Radio_button_control "radio button control" | 73 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 74 | /// @brief Set the control on window to visible | ||
| 38 | /// | 75 | /// |
| 39 | /// @note The call of the control is only possible from the corresponding | 76 | /// @param[in] visible If true visible, otherwise hidden |
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | 77 | /// |
| 42 | class CRadioButton : public CAddonGUIControlBase | 78 | void SetVisible(bool visible) |
| 43 | { | 79 | { |
| 44 | public: | 80 | m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, |
| 45 | //========================================================================== | 81 | visible); |
| 46 | /// | 82 | } |
| 47 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 83 | //-------------------------------------------------------------------------- |
| 48 | /// @brief Construct a new control | ||
| 49 | /// | ||
| 50 | /// @param[in] window related window control class | ||
| 51 | /// @param[in] controlId Used skin xml control id | ||
| 52 | /// | ||
| 53 | CRadioButton(CWindow* window, int controlId) | ||
| 54 | : CAddonGUIControlBase(window) | ||
| 55 | { | ||
| 56 | m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 57 | if (!m_controlHandle) | ||
| 58 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); | ||
| 59 | } | ||
| 60 | //-------------------------------------------------------------------------- | ||
| 61 | |||
| 62 | //========================================================================== | ||
| 63 | /// | ||
| 64 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 65 | /// @brief Destructor | ||
| 66 | /// | ||
| 67 | ~CRadioButton() override = default; | ||
| 68 | //-------------------------------------------------------------------------- | ||
| 69 | |||
| 70 | //========================================================================== | ||
| 71 | /// | ||
| 72 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 73 | /// @brief Set the control on window to visible | ||
| 74 | /// | ||
| 75 | /// @param[in] visible If true visible, otherwise hidden | ||
| 76 | /// | ||
| 77 | void SetVisible(bool visible) | ||
| 78 | { | ||
| 79 | m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | 84 | ||
| 83 | //========================================================================== | 85 | //========================================================================== |
| 84 | /// | 86 | /// |
| 85 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 87 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 86 | /// @brief Set's the control's enabled/disabled state | 88 | /// @brief Set's the control's enabled/disabled state |
| 87 | /// | 89 | /// |
| 88 | /// @param[in] enabled If true enabled, otherwise disabled | 90 | /// @param[in] enabled If true enabled, otherwise disabled |
| 89 | /// | 91 | /// |
| 90 | void SetEnabled(bool enabled) | 92 | void SetEnabled(bool enabled) |
| 91 | { | 93 | { |
| 92 | m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | 94 | m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 93 | } | 95 | enabled); |
| 94 | //-------------------------------------------------------------------------- | 96 | } |
| 97 | //-------------------------------------------------------------------------- | ||
| 95 | 98 | ||
| 96 | //========================================================================== | 99 | //========================================================================== |
| 97 | /// | 100 | /// |
| 98 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 101 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 99 | /// @brief To set the text string on radio button | 102 | /// @brief To set the text string on radio button |
| 100 | /// | 103 | /// |
| 101 | /// @param[in] label Text to show | 104 | /// @param[in] label Text to show |
| 102 | /// | 105 | /// |
| 103 | void SetLabel(const std::string& label) | 106 | void SetLabel(const std::string& label) |
| 104 | { | 107 | { |
| 105 | m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | 108 | m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, |
| 106 | } | 109 | label.c_str()); |
| 107 | //-------------------------------------------------------------------------- | 110 | } |
| 111 | //-------------------------------------------------------------------------- | ||
| 108 | 112 | ||
| 109 | //========================================================================== | 113 | //========================================================================== |
| 110 | /// | 114 | /// |
| 111 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 115 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 112 | /// @brief Get the used text from control | 116 | /// @brief Get the used text from control |
| 113 | /// | 117 | /// |
| 114 | /// @return Text shown | 118 | /// @return Text shown |
| 115 | /// | 119 | /// |
| 116 | std::string GetLabel() const | 120 | std::string GetLabel() const |
| 121 | { | ||
| 122 | std::string label; | ||
| 123 | char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, | ||
| 124 | m_controlHandle); | ||
| 125 | if (ret != nullptr) | ||
| 117 | { | 126 | { |
| 118 | std::string label; | 127 | if (std::strlen(ret)) |
| 119 | char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, m_controlHandle); | 128 | label = ret; |
| 120 | if (ret != nullptr) | 129 | m_interface->free_string(m_interface->kodiBase, ret); |
| 121 | { | ||
| 122 | if (std::strlen(ret)) | ||
| 123 | label = ret; | ||
| 124 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 125 | } | ||
| 126 | return label; | ||
| 127 | } | 130 | } |
| 128 | //-------------------------------------------------------------------------- | 131 | return label; |
| 132 | } | ||
| 133 | //-------------------------------------------------------------------------- | ||
| 129 | 134 | ||
| 130 | //========================================================================== | 135 | //========================================================================== |
| 131 | /// | 136 | /// |
| 132 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 137 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 133 | /// @brief To set radio button condition to on or off | 138 | /// @brief To set radio button condition to on or off |
| 134 | /// | 139 | /// |
| 135 | /// @param[in] selected true set radio button to selection on, otherwise | 140 | /// @param[in] selected true set radio button to selection on, otherwise |
| 136 | /// off | 141 | /// off |
| 137 | /// | 142 | /// |
| 138 | void SetSelected(bool selected) | 143 | void SetSelected(bool selected) |
| 139 | { | 144 | { |
| 140 | m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, m_controlHandle, selected); | 145 | m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, |
| 141 | } | 146 | m_controlHandle, selected); |
| 142 | //-------------------------------------------------------------------------- | 147 | } |
| 148 | //-------------------------------------------------------------------------- | ||
| 143 | 149 | ||
| 144 | //========================================================================== | 150 | //========================================================================== |
| 145 | /// | 151 | /// |
| 146 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | 152 | /// \ingroup cpp_kodi_gui_controls_CRadioButton |
| 147 | /// @brief Get the current selected condition of radio button | 153 | /// @brief Get the current selected condition of radio button |
| 148 | /// | 154 | /// |
| 149 | /// @return Selected condition | 155 | /// @return Selected condition |
| 150 | /// | 156 | /// |
| 151 | bool IsSelected() const | 157 | bool IsSelected() const |
| 152 | { | 158 | { |
| 153 | return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, m_controlHandle); | 159 | return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, |
| 154 | } | 160 | m_controlHandle); |
| 155 | //-------------------------------------------------------------------------- | 161 | } |
| 156 | }; | 162 | //-------------------------------------------------------------------------- |
| 163 | }; | ||
| 157 | 164 | ||
| 158 | } /* namespace controls */ | 165 | } /* namespace controls */ |
| 159 | } /* namespace gui */ | 166 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h index b3dadcd..7cc9b24 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../AddonBase.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | #include "../renderHelper.h" | ||
| 13 | 14 | ||
| 14 | namespace kodi | 15 | namespace kodi |
| 15 | { | 16 | { |
| @@ -18,186 +19,186 @@ namespace gui | |||
| 18 | namespace controls | 19 | namespace controls |
| 19 | { | 20 | { |
| 20 | 21 | ||
| 21 | //============================================================================ | 22 | //============================================================================ |
| 23 | /// | ||
| 24 | /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering | ||
| 25 | /// \ingroup cpp_kodi_gui | ||
| 26 | /// @brief \cpp_class{ kodi::gui::controls::CRendering } | ||
| 27 | /// **Window control for rendering own parts** | ||
| 28 | /// | ||
| 29 | /// This rendering control is used when own parts are needed. You have the | ||
| 30 | /// control over them to render direct OpenGL or DirectX content to the | ||
| 31 | /// screen set by the size of them. | ||
| 32 | /// | ||
| 33 | /// Alternative can be the virtual functions from t his been ignored if the | ||
| 34 | /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and | ||
| 35 | /// class is used as single and not as a parent class. | ||
| 36 | /// | ||
| 37 | /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | ||
| 38 | /// be included to enjoy it. | ||
| 39 | /// | ||
| 40 | /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" | ||
| 41 | /// | ||
| 42 | /// @note The call of the control is only possible from the corresponding | ||
| 43 | /// window as its class and identification number is required. | ||
| 44 | /// | ||
| 45 | |||
| 46 | //============================================================================ | ||
| 47 | /// | ||
| 48 | /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators | ||
| 49 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 50 | /// @brief **Library definition values** | ||
| 51 | /// | ||
| 52 | |||
| 53 | class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase | ||
| 54 | { | ||
| 55 | public: | ||
| 56 | //========================================================================== | ||
| 57 | /// | ||
| 58 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 59 | /// @brief Construct a new control | ||
| 60 | /// | ||
| 61 | /// @param[in] window related window control class | ||
| 62 | /// @param[in] controlId Used skin xml control id | ||
| 63 | /// | ||
| 64 | CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 65 | { | ||
| 66 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( | ||
| 67 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 68 | if (m_controlHandle) | ||
| 69 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, | ||
| 70 | m_controlHandle, this, OnCreateCB, | ||
| 71 | OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 72 | else | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", | ||
| 74 | __FUNCTION__); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 81 | /// @brief Destructor | ||
| 82 | /// | ||
| 83 | ~CRendering() override | ||
| 84 | { | ||
| 85 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 22 | /// | 90 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering | 91 | /// \ingroup cpp_kodi_gui_controls_CRendering |
| 24 | /// \ingroup cpp_kodi_gui | 92 | /// @brief To create rendering control on Add-on |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CRendering } | ||
| 26 | /// **Window control for rendering own parts** | ||
| 27 | /// | 93 | /// |
| 28 | /// This rendering control is used when own parts are needed. You have the | 94 | /// Function creates the needed rendering control for Kodi which becomes |
| 29 | /// control over them to render direct OpenGL or DirectX content to the | 95 | /// handled and processed from Add-on |
| 30 | /// screen set by the size of them. | ||
| 31 | /// | 96 | /// |
| 32 | /// Alternative can be the virtual functions from t his been ignored if the | 97 | /// @note This is callback function from Kodi to Add-on and not to use |
| 33 | /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and | 98 | /// for calls from add-on to this function. |
| 34 | /// class is used as single and not as a parent class. | ||
| 35 | /// | 99 | /// |
| 36 | /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | 100 | /// @param[in] x Horizontal position |
| 37 | /// be included to enjoy it. | 101 | /// @param[in] y Vertical position |
| 102 | /// @param[in] w Width of control | ||
| 103 | /// @param[in] h Height of control | ||
| 104 | /// @param[in] device The device to use. For OpenGL is empty | ||
| 105 | /// on Direct X is the needed device send. | ||
| 106 | /// @return Add-on needs to return true if successed, | ||
| 107 | /// otherwise false. | ||
| 38 | /// | 108 | /// |
| 39 | /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" | 109 | virtual bool Create(int x, int y, int w, int h, void* device) { return false; } |
| 110 | //-------------------------------------------------------------------------- | ||
| 111 | |||
| 112 | //========================================================================== | ||
| 113 | /// | ||
| 114 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 115 | /// @brief Render process call from Kodi | ||
| 40 | /// | 116 | /// |
| 41 | /// @note The call of the control is only possible from the corresponding | 117 | /// @note This is callback function from Kodi to Add-on and not to use |
| 42 | /// window as its class and identification number is required. | 118 | /// for calls from add-on to this function. |
| 43 | /// | 119 | /// |
| 120 | virtual void Render() {} | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 44 | 122 | ||
| 45 | //============================================================================ | 123 | //========================================================================== |
| 46 | /// | 124 | /// |
| 47 | /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators | ||
| 48 | /// \ingroup cpp_kodi_gui_controls_CRendering | 125 | /// \ingroup cpp_kodi_gui_controls_CRendering |
| 49 | /// @brief **Library definition values** | 126 | /// @brief Call from Kodi to stop rendering process |
| 50 | /// | 127 | /// |
| 128 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 129 | /// for calls from add-on to this function. | ||
| 130 | /// | ||
| 131 | virtual void Stop() {} | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 51 | 133 | ||
| 52 | class CRendering : public CAddonGUIControlBase | 134 | //========================================================================== |
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 137 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 138 | /// region. | ||
| 139 | /// | ||
| 140 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 141 | /// for calls from add-on to this function. | ||
| 142 | /// | ||
| 143 | virtual bool Dirty() { return false; } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 149 | /// \anchor CRendering_SetIndependentCallbacks | ||
| 150 | /// @brief If the class is used independent (with "new CRendering") | ||
| 151 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 152 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 153 | /// | ||
| 154 | void SetIndependentCallbacks( | ||
| 155 | GUIHANDLE cbhdl, | ||
| 156 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device), | ||
| 157 | void (*CBRender)(GUIHANDLE cbhdl), | ||
| 158 | void (*CBStop)(GUIHANDLE cbhdl), | ||
| 159 | bool (*CBDirty)(GUIHANDLE cbhdl)) | ||
| 53 | { | 160 | { |
| 54 | public: | 161 | if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) |
| 55 | //========================================================================== | ||
| 56 | /// | ||
| 57 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 58 | /// @brief Construct a new control | ||
| 59 | /// | ||
| 60 | /// @param[in] window related window control class | ||
| 61 | /// @param[in] controlId Used skin xml control id | ||
| 62 | /// | ||
| 63 | CRendering(CWindow* window, int controlId) | ||
| 64 | : CAddonGUIControlBase(window) | ||
| 65 | { | ||
| 66 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 67 | if (m_controlHandle) | ||
| 68 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 69 | OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 70 | else | ||
| 71 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", __FUNCTION__); | ||
| 72 | } | ||
| 73 | //-------------------------------------------------------------------------- | ||
| 74 | |||
| 75 | //========================================================================== | ||
| 76 | /// | ||
| 77 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 78 | /// @brief Destructor | ||
| 79 | /// | ||
| 80 | ~CRendering() override | ||
| 81 | { | ||
| 82 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 83 | } | ||
| 84 | //-------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 89 | /// @brief To create rendering control on Add-on | ||
| 90 | /// | ||
| 91 | /// Function creates the needed rendering control for Kodi which becomes | ||
| 92 | /// handled and processed from Add-on | ||
| 93 | /// | ||
| 94 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 95 | /// for calls from add-on to this function. | ||
| 96 | /// | ||
| 97 | /// @param[in] x Horizontal position | ||
| 98 | /// @param[in] y Vertical position | ||
| 99 | /// @param[in] w Width of control | ||
| 100 | /// @param[in] h Height of control | ||
| 101 | /// @param[in] device The device to use. For OpenGL is empty | ||
| 102 | /// on Direct X is the needed device send. | ||
| 103 | /// @return Add-on needs to return true if successed, | ||
| 104 | /// otherwise false. | ||
| 105 | /// | ||
| 106 | virtual bool Create(int x, int y, int w, int h, void* device) { return false; } | ||
| 107 | //-------------------------------------------------------------------------- | ||
| 108 | |||
| 109 | //========================================================================== | ||
| 110 | /// | ||
| 111 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 112 | /// @brief Render process call from Kodi | ||
| 113 | /// | ||
| 114 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 115 | /// for calls from add-on to this function. | ||
| 116 | /// | ||
| 117 | virtual void Render() { } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 123 | /// @brief Call from Kodi to stop rendering process | ||
| 124 | /// | ||
| 125 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 126 | /// for calls from add-on to this function. | ||
| 127 | /// | ||
| 128 | virtual void Stop() { } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 134 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 135 | /// region. | ||
| 136 | /// | ||
| 137 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 138 | /// for calls from add-on to this function. | ||
| 139 | /// | ||
| 140 | virtual bool Dirty() { return false; } | ||
| 141 | //-------------------------------------------------------------------------- | ||
| 142 | |||
| 143 | //========================================================================== | ||
| 144 | /// | ||
| 145 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 146 | /// \anchor CRendering_SetIndependentCallbacks | ||
| 147 | /// @brief If the class is used independent (with "new CRendering") | ||
| 148 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 149 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 150 | /// | ||
| 151 | void SetIndependentCallbacks( | ||
| 152 | GUIHANDLE cbhdl, | ||
| 153 | bool (*CBCreate)(GUIHANDLE cbhdl, | ||
| 154 | int x, | ||
| 155 | int y, | ||
| 156 | int w, | ||
| 157 | int h, | ||
| 158 | void* device), | ||
| 159 | void (*CBRender)(GUIHANDLE cbhdl), | ||
| 160 | void (*CBStop) (GUIHANDLE cbhdl), | ||
| 161 | bool (*CBDirty) (GUIHANDLE cbhdl)) | ||
| 162 | { | ||
| 163 | if (!cbhdl || | ||
| 164 | !CBCreate || !CBRender || !CBStop || !CBDirty) | ||
| 165 | { | ||
| 166 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); | ||
| 167 | return; | ||
| 168 | } | ||
| 169 | |||
| 170 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 171 | CBCreate, CBRender, CBStop, CBDirty); | ||
| 172 | } | ||
| 173 | //-------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | private: | ||
| 176 | /* | ||
| 177 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 178 | * (is private)! | ||
| 179 | */ | ||
| 180 | static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) | ||
| 181 | { | 162 | { |
| 182 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | 163 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); |
| 164 | return; | ||
| 183 | } | 165 | } |
| 184 | 166 | ||
| 185 | static void OnRenderCB(void* cbhdl) | 167 | m_interface->kodi_gui->control_rendering->set_callbacks( |
| 186 | { | 168 | m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); |
| 187 | static_cast<CRendering*>(cbhdl)->Render(); | 169 | } |
| 188 | } | 170 | //-------------------------------------------------------------------------- |
| 171 | |||
| 172 | private: | ||
| 173 | /* | ||
| 174 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 175 | * (is private)! | ||
| 176 | */ | ||
| 177 | static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) | ||
| 178 | { | ||
| 179 | static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 180 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | ||
| 181 | } | ||
| 189 | 182 | ||
| 190 | static void OnStopCB(void* cbhdl) | 183 | static void OnRenderCB(void* cbhdl) |
| 191 | { | 184 | { |
| 192 | static_cast<CRendering*>(cbhdl)->Stop(); | 185 | if (!static_cast<CRendering*>(cbhdl)->m_renderHelper) |
| 193 | } | 186 | return; |
| 187 | static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin(); | ||
| 188 | static_cast<CRendering*>(cbhdl)->Render(); | ||
| 189 | static_cast<CRendering*>(cbhdl)->m_renderHelper->End(); | ||
| 190 | } | ||
| 191 | |||
| 192 | static void OnStopCB(void* cbhdl) | ||
| 193 | { | ||
| 194 | static_cast<CRendering*>(cbhdl)->Stop(); | ||
| 195 | static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr; | ||
| 196 | } | ||
| 194 | 197 | ||
| 195 | static bool OnDirtyCB(void* cbhdl) | 198 | static bool OnDirtyCB(void* cbhdl) { return static_cast<CRendering*>(cbhdl)->Dirty(); } |
| 196 | { | ||
| 197 | return static_cast<CRendering*>(cbhdl)->Dirty(); | ||
| 198 | } | ||
| 199 | 199 | ||
| 200 | }; | 200 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; |
| 201 | }; | ||
| 201 | 202 | ||
| 202 | } /* namespace controls */ | 203 | } /* namespace controls */ |
| 203 | } /* namespace gui */ | 204 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h index 4f97ba5..76a02aa 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h | |||
| @@ -18,294 +18,308 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CSettingsSlider Control Settings Slider | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSettingsSlider } | ||
| 26 | /// **Window control for moveable slider with text name** | ||
| 27 | /// | ||
| 28 | /// The settings slider control is used in the settings screens for when an | ||
| 29 | /// option is best specified on a sliding scale. You can choose the position, | ||
| 30 | /// size, and look of the slider control. It is basically a cross between the | ||
| 31 | /// button control and a slider control. It has a label and focus and non | ||
| 32 | /// focus textures, as well as a slider control on the right. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a \ref Settings_Slider_Control "settings slider control" | ||
| 38 | /// | ||
| 39 | /// @note The call of the control is only possible from the corresponding | ||
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | ||
| 42 | class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase | ||
| 43 | { | ||
| 44 | public: | ||
| 45 | //========================================================================== | ||
| 22 | /// | 46 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CSettingsSlider Control Settings Slider | 47 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 24 | /// \ingroup cpp_kodi_gui | 48 | /// @brief Construct a new control |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSettingsSlider } | ||
| 26 | /// **Window control for moveable slider with text name** | ||
| 27 | /// | 49 | /// |
| 28 | /// The settings slider control is used in the settings screens for when an | 50 | /// @param[in] window related window control class |
| 29 | /// option is best specified on a sliding scale. You can choose the position, | 51 | /// @param[in] controlId Used skin xml control id |
| 30 | /// size, and look of the slider control. It is basically a cross between the | ||
| 31 | /// button control and a slider control. It has a label and focus and non | ||
| 32 | /// focus textures, as well as a slider control on the right. | ||
| 33 | /// | 52 | /// |
| 34 | /// It has the header \ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>" | 53 | CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 35 | /// be included to enjoy it. | 54 | { |
| 55 | m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider( | ||
| 56 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 57 | if (!m_controlHandle) | ||
| 58 | kodi::Log(ADDON_LOG_FATAL, | ||
| 59 | "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); | ||
| 60 | } | ||
| 61 | //-------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //========================================================================== | ||
| 36 | /// | 64 | /// |
| 37 | /// Here you find the needed skin part for a \ref Settings_Slider_Control "settings slider control" | 65 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 66 | /// @brief Destructor | ||
| 67 | /// | ||
| 68 | ~CSettingsSlider() override = default; | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 38 | /// | 72 | /// |
| 39 | /// @note The call of the control is only possible from the corresponding | 73 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 40 | /// window as its class and identification number is required. | 74 | /// @brief Set the control on window to visible |
| 41 | /// | 75 | /// |
| 42 | class CSettingsSlider : public CAddonGUIControlBase | 76 | /// @param[in] visible If true visible, otherwise hidden |
| 77 | /// | ||
| 78 | void SetVisible(bool visible) | ||
| 43 | { | 79 | { |
| 44 | public: | 80 | m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, |
| 45 | //========================================================================== | 81 | m_controlHandle, visible); |
| 46 | /// | 82 | } |
| 47 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 83 | //-------------------------------------------------------------------------- |
| 48 | /// @brief Construct a new control | ||
| 49 | /// | ||
| 50 | /// @param[in] window related window control class | ||
| 51 | /// @param[in] controlId Used skin xml control id | ||
| 52 | /// | ||
| 53 | CSettingsSlider(CWindow* window, int controlId) | ||
| 54 | : CAddonGUIControlBase(window) | ||
| 55 | { | ||
| 56 | m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 57 | if (!m_controlHandle) | ||
| 58 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); | ||
| 59 | } | ||
| 60 | //-------------------------------------------------------------------------- | ||
| 61 | |||
| 62 | //========================================================================== | ||
| 63 | /// | ||
| 64 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 65 | /// @brief Destructor | ||
| 66 | /// | ||
| 67 | ~CSettingsSlider() override = default; | ||
| 68 | //-------------------------------------------------------------------------- | ||
| 69 | 84 | ||
| 70 | //========================================================================== | 85 | //========================================================================== |
| 71 | /// | 86 | /// |
| 72 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 87 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 73 | /// @brief Set the control on window to visible | 88 | /// @brief Set's the control's enabled/disabled state |
| 74 | /// | 89 | /// |
| 75 | /// @param[in] visible If true visible, otherwise hidden | 90 | /// @param[in] enabled If true enabled, otherwise disabled |
| 76 | /// | 91 | /// |
| 77 | void SetVisible(bool visible) | 92 | void SetEnabled(bool enabled) |
| 78 | { | 93 | { |
| 79 | m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, m_controlHandle, visible); | 94 | m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, |
| 80 | } | 95 | m_controlHandle, enabled); |
| 81 | //-------------------------------------------------------------------------- | 96 | } |
| 82 | 97 | //-------------------------------------------------------------------------- | |
| 83 | //========================================================================== | ||
| 84 | /// | ||
| 85 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 86 | /// @brief Set's the control's enabled/disabled state | ||
| 87 | /// | ||
| 88 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 89 | /// | ||
| 90 | void SetEnabled(bool enabled) | ||
| 91 | { | ||
| 92 | m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | ||
| 93 | } | ||
| 94 | //-------------------------------------------------------------------------- | ||
| 95 | 98 | ||
| 96 | //========================================================================== | 99 | //========================================================================== |
| 97 | /// | 100 | /// |
| 98 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 101 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 99 | /// @brief To set the text string on settings slider | 102 | /// @brief To set the text string on settings slider |
| 100 | /// | 103 | /// |
| 101 | /// @param[in] text Text to show | 104 | /// @param[in] text Text to show |
| 102 | /// | 105 | /// |
| 103 | void SetText(const std::string& text) | 106 | void SetText(const std::string& text) |
| 104 | { | 107 | { |
| 105 | m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); | 108 | m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, |
| 106 | } | 109 | text.c_str()); |
| 107 | //-------------------------------------------------------------------------- | 110 | } |
| 111 | //-------------------------------------------------------------------------- | ||
| 108 | 112 | ||
| 109 | //========================================================================== | 113 | //========================================================================== |
| 110 | /// | 114 | /// |
| 111 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 115 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 112 | /// @brief To reset slider on defaults | 116 | /// @brief To reset slider on defaults |
| 113 | /// | 117 | /// |
| 114 | void Reset() | 118 | void Reset() |
| 115 | { | 119 | { |
| 116 | m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); | 120 | m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); |
| 117 | } | 121 | } |
| 118 | //-------------------------------------------------------------------------- | 122 | //-------------------------------------------------------------------------- |
| 119 | 123 | ||
| 120 | //========================================================================== | 124 | //========================================================================== |
| 121 | /// | 125 | /// |
| 122 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 126 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 123 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | 127 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider |
| 124 | /// start and e.g. +10 is the from here defined position where it reach the | 128 | /// start and e.g. +10 is the from here defined position where it reach the |
| 125 | /// end. | 129 | /// end. |
| 126 | /// | 130 | /// |
| 127 | /// Ad default is the range from 0 to 100. | 131 | /// Ad default is the range from 0 to 100. |
| 128 | /// | 132 | /// |
| 129 | /// The integer interval is as default 1 and can be changed with | 133 | /// The integer interval is as default 1 and can be changed with |
| 130 | /// @ref SetIntInterval. | 134 | /// @ref SetIntInterval. |
| 131 | /// | 135 | /// |
| 132 | /// @param[in] start Integer start value | 136 | /// @param[in] start Integer start value |
| 133 | /// @param[in] end Integer end value | 137 | /// @param[in] end Integer end value |
| 134 | /// | 138 | /// |
| 135 | /// @note Percent, floating point or integer are alone possible. Combining | 139 | /// @note Percent, floating point or integer are alone possible. Combining |
| 136 | /// these different values can be not together and can, therefore, only | 140 | /// these different values can be not together and can, therefore, only |
| 137 | /// one each can be used. | 141 | /// one each can be used. |
| 138 | /// | 142 | /// |
| 139 | void SetIntRange(int start, int end) | 143 | void SetIntRange(int start, int end) |
| 140 | { | 144 | { |
| 141 | m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); | 145 | m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, |
| 142 | } | 146 | m_controlHandle, start, end); |
| 143 | //-------------------------------------------------------------------------- | 147 | } |
| 148 | //-------------------------------------------------------------------------- | ||
| 144 | 149 | ||
| 145 | //========================================================================== | 150 | //========================================================================== |
| 146 | /// | 151 | /// |
| 147 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 152 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 148 | /// @brief Set the slider position with the given integer value. The Range | 153 | /// @brief Set the slider position with the given integer value. The Range |
| 149 | /// must be defined with a call from \ref SetIntRange before. | 154 | /// must be defined with a call from \ref SetIntRange before. |
| 150 | /// | 155 | /// |
| 151 | /// @param[in] value Position in range to set with integer | 156 | /// @param[in] value Position in range to set with integer |
| 152 | /// | 157 | /// |
| 153 | /// @note Percent, floating point or integer are alone possible. Combining | 158 | /// @note Percent, floating point or integer are alone possible. Combining |
| 154 | /// these different values ​​can be not together and can, therefore, only | 159 | /// these different values ​​can be not together and can, therefore, only |
| 155 | /// one each can be used. | 160 | /// one each can be used. |
| 156 | /// | 161 | /// |
| 157 | void SetIntValue(int value) | 162 | void SetIntValue(int value) |
| 158 | { | 163 | { |
| 159 | m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, m_controlHandle, value); | 164 | m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, |
| 160 | } | 165 | m_controlHandle, value); |
| 161 | //-------------------------------------------------------------------------- | 166 | } |
| 167 | //-------------------------------------------------------------------------- | ||
| 162 | 168 | ||
| 163 | //========================================================================== | 169 | //========================================================================== |
| 164 | /// | 170 | /// |
| 165 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 171 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 166 | /// @brief To get the current position as integer value. | 172 | /// @brief To get the current position as integer value. |
| 167 | /// | 173 | /// |
| 168 | /// @return The position as integer | 174 | /// @return The position as integer |
| 169 | /// | 175 | /// |
| 170 | /// @note Percent, floating point or integer are alone possible. Combining | 176 | /// @note Percent, floating point or integer are alone possible. Combining |
| 171 | /// these different values ​​can be not together and can, therefore, only | 177 | /// these different values ​​can be not together and can, therefore, only |
| 172 | /// one each can be used. | 178 | /// one each can be used. |
| 173 | /// | 179 | /// |
| 174 | int GetIntValue() const | 180 | int GetIntValue() const |
| 175 | { | 181 | { |
| 176 | return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, m_controlHandle); | 182 | return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, |
| 177 | } | 183 | m_controlHandle); |
| 178 | //-------------------------------------------------------------------------- | 184 | } |
| 185 | //-------------------------------------------------------------------------- | ||
| 179 | 186 | ||
| 180 | //========================================================================== | 187 | //========================================================================== |
| 181 | /// | 188 | /// |
| 182 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 189 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 183 | /// @brief To set the interval steps of slider, as default is it 1. If it | 190 | /// @brief To set the interval steps of slider, as default is it 1. If it |
| 184 | /// becomes changed with this function will a step of the user with the | 191 | /// becomes changed with this function will a step of the user with the |
| 185 | /// value fixed here be executed. | 192 | /// value fixed here be executed. |
| 186 | /// | 193 | /// |
| 187 | /// @param[in] interval Intervall step to set. | 194 | /// @param[in] interval Intervall step to set. |
| 188 | /// | 195 | /// |
| 189 | /// @note Percent, floating point or integer are alone possible. Combining | 196 | /// @note Percent, floating point or integer are alone possible. Combining |
| 190 | /// these different values ​​can be not together and can, therefore, only | 197 | /// these different values ​​can be not together and can, therefore, only |
| 191 | /// one each can be used. | 198 | /// one each can be used. |
| 192 | /// | 199 | /// |
| 193 | void SetIntInterval(int interval) | 200 | void SetIntInterval(int interval) |
| 194 | { | 201 | { |
| 195 | m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, interval); | 202 | m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, |
| 196 | } | 203 | m_controlHandle, interval); |
| 197 | //-------------------------------------------------------------------------- | 204 | } |
| 205 | //-------------------------------------------------------------------------- | ||
| 198 | 206 | ||
| 199 | //========================================================================== | 207 | //========================================================================== |
| 200 | /// | 208 | /// |
| 201 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 209 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 202 | /// @brief Sets the percent of the slider. | 210 | /// @brief Sets the percent of the slider. |
| 203 | /// | 211 | /// |
| 204 | /// @param[in] percent float - Percent value of slide | 212 | /// @param[in] percent float - Percent value of slide |
| 205 | /// | 213 | /// |
| 206 | /// @note Percent, floating point or integer are alone possible. Combining | 214 | /// @note Percent, floating point or integer are alone possible. Combining |
| 207 | /// these different values ​​can be not together and can, therefore, only | 215 | /// these different values ​​can be not together and can, therefore, only |
| 208 | /// one each can be used. | 216 | /// one each can be used. |
| 209 | /// | 217 | /// |
| 210 | void SetPercentage(float percent) | 218 | void SetPercentage(float percent) |
| 211 | { | 219 | { |
| 212 | m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, m_controlHandle, percent); | 220 | m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, |
| 213 | } | 221 | m_controlHandle, percent); |
| 214 | //-------------------------------------------------------------------------- | 222 | } |
| 223 | //-------------------------------------------------------------------------- | ||
| 215 | 224 | ||
| 216 | //========================================================================== | 225 | //========================================================================== |
| 217 | /// | 226 | /// |
| 218 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 227 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 219 | /// @brief Returns a float of the percent of the slider. | 228 | /// @brief Returns a float of the percent of the slider. |
| 220 | /// | 229 | /// |
| 221 | /// @return float - Percent of slider | 230 | /// @return float - Percent of slider |
| 222 | /// | 231 | /// |
| 223 | /// @note Percent, floating point or integer are alone possible. Combining | 232 | /// @note Percent, floating point or integer are alone possible. Combining |
| 224 | /// these different values ​​can be not together and can, therefore, only | 233 | /// these different values ​​can be not together and can, therefore, only |
| 225 | /// one each can be used. | 234 | /// one each can be used. |
| 226 | /// | 235 | /// |
| 227 | float GetPercentage() const | 236 | float GetPercentage() const |
| 228 | { | 237 | { |
| 229 | return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, m_controlHandle); | 238 | return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, |
| 230 | } | 239 | m_controlHandle); |
| 231 | //-------------------------------------------------------------------------- | 240 | } |
| 241 | //-------------------------------------------------------------------------- | ||
| 232 | 242 | ||
| 233 | //========================================================================== | 243 | //========================================================================== |
| 234 | /// | 244 | /// |
| 235 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 245 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 236 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | 246 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider |
| 237 | /// start and e.g. +25.0 is the from here defined position where it reach | 247 | /// start and e.g. +25.0 is the from here defined position where it reach |
| 238 | /// the end. | 248 | /// the end. |
| 239 | /// | 249 | /// |
| 240 | /// As default is the range 0.0 to 1.0. | 250 | /// As default is the range 0.0 to 1.0. |
| 241 | /// | 251 | /// |
| 242 | /// The float interval is as default 0.1 and can be changed with | 252 | /// The float interval is as default 0.1 and can be changed with |
| 243 | /// @ref SetFloatInterval. | 253 | /// @ref SetFloatInterval. |
| 244 | /// | 254 | /// |
| 245 | /// @param[in] start Integer start value | 255 | /// @param[in] start Integer start value |
| 246 | /// @param[in] end Integer end value | 256 | /// @param[in] end Integer end value |
| 247 | /// | 257 | /// |
| 248 | /// @note Percent, floating point or integer are alone possible. Combining | 258 | /// @note Percent, floating point or integer are alone possible. Combining |
| 249 | /// these different values ​​ can be not together and can, therefore, only | 259 | /// these different values ​​ can be not together and can, therefore, only |
| 250 | /// one each can be used. | 260 | /// one each can be used. |
| 251 | /// | 261 | /// |
| 252 | void SetFloatRange(float start, float end) | 262 | void SetFloatRange(float start, float end) |
| 253 | { | 263 | { |
| 254 | m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); | 264 | m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, |
| 255 | } | 265 | m_controlHandle, start, end); |
| 256 | //-------------------------------------------------------------------------- | 266 | } |
| 267 | //-------------------------------------------------------------------------- | ||
| 257 | 268 | ||
| 258 | //========================================================================== | 269 | //========================================================================== |
| 259 | /// | 270 | /// |
| 260 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 271 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 261 | /// @brief Set the slider position with the given float value. The Range | 272 | /// @brief Set the slider position with the given float value. The Range |
| 262 | /// can be defined with a call from \ref SetIntRange before, as default it | 273 | /// can be defined with a call from \ref SetIntRange before, as default it |
| 263 | /// is 0.0 to 1.0. | 274 | /// is 0.0 to 1.0. |
| 264 | /// | 275 | /// |
| 265 | /// @param[in] value Position in range to set with float | 276 | /// @param[in] value Position in range to set with float |
| 266 | /// | 277 | /// |
| 267 | /// @note Percent, floating point or integer are alone possible. Combining | 278 | /// @note Percent, floating point or integer are alone possible. Combining |
| 268 | /// these different values ​​can be not together and can, therefore, only | 279 | /// these different values ​​can be not together and can, therefore, only |
| 269 | /// one each can be used. | 280 | /// one each can be used. |
| 270 | /// | 281 | /// |
| 271 | void SetFloatValue(float value) | 282 | void SetFloatValue(float value) |
| 272 | { | 283 | { |
| 273 | m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, m_controlHandle, value); | 284 | m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, |
| 274 | } | 285 | m_controlHandle, value); |
| 275 | //-------------------------------------------------------------------------- | 286 | } |
| 287 | //-------------------------------------------------------------------------- | ||
| 276 | 288 | ||
| 277 | //========================================================================== | 289 | //========================================================================== |
| 278 | /// | 290 | /// |
| 279 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 291 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 280 | /// @brief To get the current position as float value. | 292 | /// @brief To get the current position as float value. |
| 281 | /// | 293 | /// |
| 282 | /// @return The position as float | 294 | /// @return The position as float |
| 283 | /// | 295 | /// |
| 284 | float GetFloatValue() const | 296 | float GetFloatValue() const |
| 285 | { | 297 | { |
| 286 | return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, m_controlHandle); | 298 | return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, |
| 287 | } | 299 | m_controlHandle); |
| 288 | //-------------------------------------------------------------------------- | 300 | } |
| 301 | //-------------------------------------------------------------------------- | ||
| 289 | 302 | ||
| 290 | //========================================================================== | 303 | //========================================================================== |
| 291 | /// | 304 | /// |
| 292 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | 305 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider |
| 293 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | 306 | /// @brief To set the interval steps of slider, as default is it 0.1 If it |
| 294 | /// becomes changed with this function will a step of the user with the | 307 | /// becomes changed with this function will a step of the user with the |
| 295 | /// value fixed here be executed. | 308 | /// value fixed here be executed. |
| 296 | /// | 309 | /// |
| 297 | /// @param[in] interval Intervall step to set. | 310 | /// @param[in] interval Intervall step to set. |
| 298 | /// | 311 | /// |
| 299 | /// @note Percent, floating point or integer are alone possible. Combining | 312 | /// @note Percent, floating point or integer are alone possible. Combining |
| 300 | /// these different values ​​can be not together and can, therefore, only | 313 | /// these different values ​​can be not together and can, therefore, only |
| 301 | /// one each can be used. | 314 | /// one each can be used. |
| 302 | /// | 315 | /// |
| 303 | void SetFloatInterval(float interval) | 316 | void SetFloatInterval(float interval) |
| 304 | { | 317 | { |
| 305 | m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); | 318 | m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, |
| 306 | } | 319 | m_controlHandle, interval); |
| 307 | //-------------------------------------------------------------------------- | 320 | } |
| 308 | }; | 321 | //-------------------------------------------------------------------------- |
| 322 | }; | ||
| 309 | 323 | ||
| 310 | } /* namespace controls */ | 324 | } /* namespace controls */ |
| 311 | } /* namespace gui */ | 325 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h index 6eae70a..715cc7d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h | |||
| @@ -18,307 +18,321 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSlider } | ||
| 26 | /// **Window control for moveable slider** | ||
| 27 | /// | ||
| 28 | /// The slider control is used for things where a sliding bar best represents | ||
| 29 | /// the operation at hand (such as a volume control or seek control). You can | ||
| 30 | /// choose the position, size, and look of the slider control. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Slider.h "#include <kodi/gui/controls/Slider.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref Slider_Control "slider control" | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 22 | /// | 44 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider | 45 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 24 | /// \ingroup cpp_kodi_gui | 46 | /// @brief Construct a new control |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSlider } | ||
| 26 | /// **Window control for moveable slider** | ||
| 27 | /// | 47 | /// |
| 28 | /// The slider control is used for things where a sliding bar best represents | 48 | /// @param[in] window related window control class |
| 29 | /// the operation at hand (such as a volume control or seek control). You can | 49 | /// @param[in] controlId Used skin xml control id |
| 30 | /// choose the position, size, and look of the slider control. | ||
| 31 | /// | 50 | /// |
| 32 | /// It has the header \ref Slider.h "#include <kodi/gui/controls/Slider.h>" | 51 | CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 33 | /// be included to enjoy it. | 52 | { |
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_slider( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //-------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //========================================================================== | ||
| 34 | /// | 62 | /// |
| 35 | /// Here you find the needed skin part for a \ref Slider_Control "slider control" | 63 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 64 | /// @brief Destructor | ||
| 36 | /// | 65 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 66 | ~CSlider() override = default; |
| 38 | /// window as its class and identification number is required. | 67 | //-------------------------------------------------------------------------- |
| 68 | |||
| 69 | //========================================================================== | ||
| 39 | /// | 70 | /// |
| 40 | class CSlider : public CAddonGUIControlBase | 71 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | ||
| 74 | /// @param[in] visible If true visible, otherwise hidden | ||
| 75 | /// | ||
| 76 | void SetVisible(bool visible) | ||
| 41 | { | 77 | { |
| 42 | public: | 78 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, |
| 43 | //========================================================================== | 79 | visible); |
| 44 | /// | 80 | } |
| 45 | /// \ingroup cpp_kodi_gui_controls_CSlider | 81 | //-------------------------------------------------------------------------- |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CSlider(CWindow* window, int controlId) | ||
| 52 | : CAddonGUIControlBase(window) | ||
| 53 | { | ||
| 54 | m_controlHandle = m_interface->kodi_gui->window->get_control_slider(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 63 | /// @brief Destructor | ||
| 64 | /// | ||
| 65 | ~CSlider() override = default; | ||
| 66 | //-------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //========================================================================== | ||
| 69 | /// | ||
| 70 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 78 | } | ||
| 79 | //-------------------------------------------------------------------------- | ||
| 80 | 82 | ||
| 81 | //========================================================================== | 83 | //========================================================================== |
| 82 | /// | 84 | /// |
| 83 | /// \ingroup cpp_kodi_gui_controls_CSlider | 85 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 84 | /// @brief Set's the control's enabled/disabled state | 86 | /// @brief Set's the control's enabled/disabled state |
| 85 | /// | 87 | /// |
| 86 | /// @param[in] enabled If true enabled, otherwise disabled | 88 | /// @param[in] enabled If true enabled, otherwise disabled |
| 87 | /// | 89 | /// |
| 88 | void SetEnabled(bool enabled) | 90 | void SetEnabled(bool enabled) |
| 89 | { | 91 | { |
| 90 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | 92 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, |
| 91 | } | 93 | enabled); |
| 92 | //-------------------------------------------------------------------------- | 94 | } |
| 95 | //-------------------------------------------------------------------------- | ||
| 93 | 96 | ||
| 94 | //========================================================================== | 97 | //========================================================================== |
| 95 | /// | 98 | /// |
| 96 | /// \ingroup cpp_kodi_gui_controls_CSlider | 99 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 97 | /// @brief To reset slider on defaults | 100 | /// @brief To reset slider on defaults |
| 98 | /// | 101 | /// |
| 99 | void Reset() | 102 | void Reset() |
| 100 | { | 103 | { |
| 101 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); | 104 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); |
| 102 | } | 105 | } |
| 103 | //-------------------------------------------------------------------------- | 106 | //-------------------------------------------------------------------------- |
| 104 | 107 | ||
| 105 | //========================================================================== | 108 | //========================================================================== |
| 106 | /// | 109 | /// |
| 107 | /// \ingroup cpp_kodi_gui_controls_CSlider | 110 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 108 | /// @brief With GetDescription becomes a string value of position returned. | 111 | /// @brief With GetDescription becomes a string value of position returned. |
| 109 | /// | 112 | /// |
| 110 | /// @return Text string about current slider position | 113 | /// @return Text string about current slider position |
| 111 | /// | 114 | /// |
| 112 | /// The following are the text definition returned from this: | 115 | /// The following are the text definition returned from this: |
| 113 | /// | Value | Without range selection | With range selection | | 116 | /// | Value | Without range selection | With range selection | |
| 114 | /// |:---------:|:------------------------|:-------------------------------| | 117 | /// |:---------:|:------------------------|:-------------------------------| |
| 115 | /// | float | <c>%2.2f</c> | <c>[%2.2f, %2.2f]</c> | | 118 | /// | float | <c>%2.2f</c> | <c>[%2.2f, %2.2f]</c> | |
| 116 | /// | integer | <c>%i</c> | <c>[%i, %i]</c> | | 119 | /// | integer | <c>%i</c> | <c>[%i, %i]</c> | |
| 117 | /// | percent | <c>%i%%</c> | <c>[%i%%, %i%%]</c> | | 120 | /// | percent | <c>%i%%</c> | <c>[%i%%, %i%%]</c> | |
| 118 | /// | 121 | /// |
| 119 | std::string GetDescription() const | 122 | std::string GetDescription() const |
| 123 | { | ||
| 124 | std::string text; | ||
| 125 | char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, | ||
| 126 | m_controlHandle); | ||
| 127 | if (ret != nullptr) | ||
| 120 | { | 128 | { |
| 121 | std::string text; | 129 | if (std::strlen(ret)) |
| 122 | char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, m_controlHandle); | 130 | text = ret; |
| 123 | if (ret != nullptr) | 131 | m_interface->free_string(m_interface->kodiBase, ret); |
| 124 | { | ||
| 125 | if (std::strlen(ret)) | ||
| 126 | text = ret; | ||
| 127 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 128 | } | ||
| 129 | return text; | ||
| 130 | } | 132 | } |
| 131 | //-------------------------------------------------------------------------- | 133 | return text; |
| 134 | } | ||
| 135 | //-------------------------------------------------------------------------- | ||
| 132 | 136 | ||
| 133 | //========================================================================== | 137 | //========================================================================== |
| 134 | /// | 138 | /// |
| 135 | /// \ingroup cpp_kodi_gui_controls_CSlider | 139 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 136 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | 140 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider |
| 137 | /// start and e.g. +10 is the from here defined position where it reach the | 141 | /// start and e.g. +10 is the from here defined position where it reach the |
| 138 | /// end. | 142 | /// end. |
| 139 | /// | 143 | /// |
| 140 | /// Ad default is the range from 0 to 100. | 144 | /// Ad default is the range from 0 to 100. |
| 141 | /// | 145 | /// |
| 142 | /// The integer interval is as default 1 and can be changed with | 146 | /// The integer interval is as default 1 and can be changed with |
| 143 | /// @ref SetIntInterval. | 147 | /// @ref SetIntInterval. |
| 144 | /// | 148 | /// |
| 145 | /// @param[in] start Integer start value | 149 | /// @param[in] start Integer start value |
| 146 | /// @param[in] end Integer end value | 150 | /// @param[in] end Integer end value |
| 147 | /// | 151 | /// |
| 148 | /// @note Percent, floating point or integer are alone possible. Combining | 152 | /// @note Percent, floating point or integer are alone possible. Combining |
| 149 | /// these different values can be not together and can, therefore, only one | 153 | /// these different values can be not together and can, therefore, only one |
| 150 | /// each can be used. | 154 | /// each can be used. |
| 151 | /// | 155 | /// |
| 152 | void SetIntRange(int start, int end) | 156 | void SetIntRange(int start, int end) |
| 153 | { | 157 | { |
| 154 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); | 158 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, |
| 155 | } | 159 | start, end); |
| 156 | //-------------------------------------------------------------------------- | 160 | } |
| 161 | //-------------------------------------------------------------------------- | ||
| 157 | 162 | ||
| 158 | //========================================================================== | 163 | //========================================================================== |
| 159 | /// | 164 | /// |
| 160 | /// \ingroup CSlider | 165 | /// \ingroup CSlider |
| 161 | /// @brief Set the slider position with the given integer value. The Range | 166 | /// @brief Set the slider position with the given integer value. The Range |
| 162 | /// must be defined with a call from \ref SetIntRange before. | 167 | /// must be defined with a call from \ref SetIntRange before. |
| 163 | /// | 168 | /// |
| 164 | /// @param[in] value Position in range to set with integer | 169 | /// @param[in] value Position in range to set with integer |
| 165 | /// | 170 | /// |
| 166 | /// @note Percent, floating point or integer are alone possible. Combining | 171 | /// @note Percent, floating point or integer are alone possible. Combining |
| 167 | /// these different values can be not together and can, therefore, only one | 172 | /// these different values can be not together and can, therefore, only one |
| 168 | /// each can be used. | 173 | /// each can be used. |
| 169 | /// | 174 | /// |
| 170 | void SetIntValue(int value) | 175 | void SetIntValue(int value) |
| 171 | { | 176 | { |
| 172 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, value); | 177 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, |
| 173 | } | 178 | value); |
| 174 | //-------------------------------------------------------------------------- | 179 | } |
| 180 | //-------------------------------------------------------------------------- | ||
| 175 | 181 | ||
| 176 | //========================================================================== | 182 | //========================================================================== |
| 177 | /// | 183 | /// |
| 178 | /// \ingroup cpp_kodi_gui_controls_CSlider | 184 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 179 | /// @brief To get the current position as integer value. | 185 | /// @brief To get the current position as integer value. |
| 180 | /// | 186 | /// |
| 181 | /// @return The position as integer | 187 | /// @return The position as integer |
| 182 | /// | 188 | /// |
| 183 | /// @note Percent, floating point or integer are alone possible. Combining | 189 | /// @note Percent, floating point or integer are alone possible. Combining |
| 184 | /// these different values can be not together and can, therefore, only | 190 | /// these different values can be not together and can, therefore, only |
| 185 | /// one each can be used. | 191 | /// one each can be used. |
| 186 | /// | 192 | /// |
| 187 | int GetIntValue() const | 193 | int GetIntValue() const |
| 188 | { | 194 | { |
| 189 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, m_controlHandle); | 195 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, |
| 190 | } | 196 | m_controlHandle); |
| 191 | //-------------------------------------------------------------------------- | 197 | } |
| 198 | //-------------------------------------------------------------------------- | ||
| 192 | 199 | ||
| 193 | //========================================================================== | 200 | //========================================================================== |
| 194 | /// | 201 | /// |
| 195 | /// \ingroup cpp_kodi_gui_controls_CSlider | 202 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 196 | /// @brief To set the interval steps of slider, as default is it 1. If it | 203 | /// @brief To set the interval steps of slider, as default is it 1. If it |
| 197 | /// becomes changed with this function will a step of the user with the | 204 | /// becomes changed with this function will a step of the user with the |
| 198 | /// value fixed here be executed. | 205 | /// value fixed here be executed. |
| 199 | /// | 206 | /// |
| 200 | /// @param[in] interval Intervall step to set. | 207 | /// @param[in] interval Intervall step to set. |
| 201 | /// | 208 | /// |
| 202 | /// @note Percent, floating point or integer are alone possible. Combining | 209 | /// @note Percent, floating point or integer are alone possible. Combining |
| 203 | /// these different values can be not together and can, therefore, only one | 210 | /// these different values can be not together and can, therefore, only one |
| 204 | /// each can be used. | 211 | /// each can be used. |
| 205 | /// | 212 | /// |
| 206 | void SetIntInterval(int interval) | 213 | void SetIntInterval(int interval) |
| 207 | { | 214 | { |
| 208 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, interval); | 215 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, |
| 209 | } | 216 | interval); |
| 210 | //-------------------------------------------------------------------------- | 217 | } |
| 218 | //-------------------------------------------------------------------------- | ||
| 211 | 219 | ||
| 212 | //========================================================================== | 220 | //========================================================================== |
| 213 | /// | 221 | /// |
| 214 | /// \ingroup cpp_kodi_gui_controls_CSlider | 222 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 215 | /// @brief Sets the percent of the slider. | 223 | /// @brief Sets the percent of the slider. |
| 216 | /// | 224 | /// |
| 217 | /// @param[in] percent float - Percent value of slide | 225 | /// @param[in] percent float - Percent value of slide |
| 218 | /// | 226 | /// |
| 219 | /// @note Percent, floating point or integer are alone possible. Combining | 227 | /// @note Percent, floating point or integer are alone possible. Combining |
| 220 | /// these different values can be not together and can, therefore, only one | 228 | /// these different values can be not together and can, therefore, only one |
| 221 | /// each can be used. | 229 | /// each can be used. |
| 222 | /// | 230 | /// |
| 223 | void SetPercentage(float percent) | 231 | void SetPercentage(float percent) |
| 224 | { | 232 | { |
| 225 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, percent); | 233 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, |
| 226 | } | 234 | percent); |
| 227 | //-------------------------------------------------------------------------- | 235 | } |
| 236 | //-------------------------------------------------------------------------- | ||
| 228 | 237 | ||
| 229 | //========================================================================== | 238 | //========================================================================== |
| 230 | /// | 239 | /// |
| 231 | /// \ingroup cpp_kodi_gui_controls_CSlider | 240 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 232 | /// @brief Returns a float of the percent of the slider. | 241 | /// @brief Returns a float of the percent of the slider. |
| 233 | /// | 242 | /// |
| 234 | /// @return float - Percent of slider | 243 | /// @return float - Percent of slider |
| 235 | /// | 244 | /// |
| 236 | /// @note Percent, floating point or integer are alone possible. Combining | 245 | /// @note Percent, floating point or integer are alone possible. Combining |
| 237 | /// these different values can be not together and can, therefore, only one | 246 | /// these different values can be not together and can, therefore, only one |
| 238 | /// each can be used. | 247 | /// each can be used. |
| 239 | /// | 248 | /// |
| 240 | float GetPercentage() const | 249 | float GetPercentage() const |
| 241 | { | 250 | { |
| 242 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, m_controlHandle); | 251 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, |
| 243 | } | 252 | m_controlHandle); |
| 244 | //-------------------------------------------------------------------------- | 253 | } |
| 254 | //-------------------------------------------------------------------------- | ||
| 245 | 255 | ||
| 246 | //========================================================================== | 256 | //========================================================================== |
| 247 | /// | 257 | /// |
| 248 | /// \ingroup cpp_kodi_gui_controls_CSlider | 258 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 249 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | 259 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider |
| 250 | /// start and e.g. +25.0 is the from here defined position where it reach | 260 | /// start and e.g. +25.0 is the from here defined position where it reach |
| 251 | /// the end. | 261 | /// the end. |
| 252 | /// | 262 | /// |
| 253 | /// As default is the range 0.0 to 1.0. | 263 | /// As default is the range 0.0 to 1.0. |
| 254 | /// | 264 | /// |
| 255 | /// The float interval is as default 0.1 and can be changed with | 265 | /// The float interval is as default 0.1 and can be changed with |
| 256 | /// @ref SetFloatInterval. | 266 | /// @ref SetFloatInterval. |
| 257 | /// | 267 | /// |
| 258 | /// @param[in] start Integer start value | 268 | /// @param[in] start Integer start value |
| 259 | /// @param[in] end Integer end value | 269 | /// @param[in] end Integer end value |
| 260 | /// | 270 | /// |
| 261 | /// @note Percent, floating point or integer are alone possible. Combining | 271 | /// @note Percent, floating point or integer are alone possible. Combining |
| 262 | /// these different values can be not together and can, therefore, only | 272 | /// these different values can be not together and can, therefore, only |
| 263 | /// one each can be used. | 273 | /// one each can be used. |
| 264 | /// | 274 | /// |
| 265 | void SetFloatRange(float start, float end) | 275 | void SetFloatRange(float start, float end) |
| 266 | { | 276 | { |
| 267 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); | 277 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, |
| 268 | } | 278 | start, end); |
| 269 | //-------------------------------------------------------------------------- | 279 | } |
| 280 | //-------------------------------------------------------------------------- | ||
| 270 | 281 | ||
| 271 | //========================================================================== | 282 | //========================================================================== |
| 272 | /// | 283 | /// |
| 273 | /// \ingroup cpp_kodi_gui_controls_CSlider | 284 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 274 | /// @brief Set the slider position with the given float value. The Range | 285 | /// @brief Set the slider position with the given float value. The Range |
| 275 | /// can be defined with a call from \ref SetIntRange before, as default it | 286 | /// can be defined with a call from \ref SetIntRange before, as default it |
| 276 | /// is 0.0 to 1.0. | 287 | /// is 0.0 to 1.0. |
| 277 | /// | 288 | /// |
| 278 | /// @param[in] value Position in range to set with float | 289 | /// @param[in] value Position in range to set with float |
| 279 | /// | 290 | /// |
| 280 | /// @note Percent, floating point or integer are alone possible. Combining | 291 | /// @note Percent, floating point or integer are alone possible. Combining |
| 281 | /// these different values can be not together and can, therefore, only one | 292 | /// these different values can be not together and can, therefore, only one |
| 282 | /// each can be used. | 293 | /// each can be used. |
| 283 | /// | 294 | /// |
| 284 | void SetFloatValue(float value) | 295 | void SetFloatValue(float value) |
| 285 | { | 296 | { |
| 286 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, value); | 297 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, |
| 287 | } | 298 | value); |
| 288 | //-------------------------------------------------------------------------- | 299 | } |
| 300 | //-------------------------------------------------------------------------- | ||
| 289 | 301 | ||
| 290 | //========================================================================== | 302 | //========================================================================== |
| 291 | /// | 303 | /// |
| 292 | /// \ingroup cpp_kodi_gui_controls_CSlider | 304 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 293 | /// @brief To get the current position as float value. | 305 | /// @brief To get the current position as float value. |
| 294 | /// | 306 | /// |
| 295 | /// @return The position as float | 307 | /// @return The position as float |
| 296 | /// | 308 | /// |
| 297 | float GetFloatValue() const | 309 | float GetFloatValue() const |
| 298 | { | 310 | { |
| 299 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, m_controlHandle); | 311 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, |
| 300 | } | 312 | m_controlHandle); |
| 301 | //-------------------------------------------------------------------------- | 313 | } |
| 314 | //-------------------------------------------------------------------------- | ||
| 302 | 315 | ||
| 303 | //========================================================================== | 316 | //========================================================================== |
| 304 | /// | 317 | /// |
| 305 | /// \ingroup cpp_kodi_gui_controls_CSlider | 318 | /// \ingroup cpp_kodi_gui_controls_CSlider |
| 306 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | 319 | /// @brief To set the interval steps of slider, as default is it 0.1 If it |
| 307 | /// becomes changed with this function will a step of the user with the | 320 | /// becomes changed with this function will a step of the user with the |
| 308 | /// value fixed here be executed. | 321 | /// value fixed here be executed. |
| 309 | /// | 322 | /// |
| 310 | /// @param[in] interval Intervall step to set. | 323 | /// @param[in] interval Intervall step to set. |
| 311 | /// | 324 | /// |
| 312 | /// @note Percent, floating point or integer are alone possible. Combining | 325 | /// @note Percent, floating point or integer are alone possible. Combining |
| 313 | /// these different values can be not together and can, therefore, only | 326 | /// these different values can be not together and can, therefore, only |
| 314 | /// one each can be used. | 327 | /// one each can be used. |
| 315 | /// | 328 | /// |
| 316 | void SetFloatInterval(float interval) | 329 | void SetFloatInterval(float interval) |
| 317 | { | 330 | { |
| 318 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); | 331 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, |
| 319 | } | 332 | m_controlHandle, interval); |
| 320 | //-------------------------------------------------------------------------- | 333 | } |
| 321 | }; | 334 | //-------------------------------------------------------------------------- |
| 335 | }; | ||
| 322 | 336 | ||
| 323 | } /* namespace controls */ | 337 | } /* namespace controls */ |
| 324 | } /* namespace gui */ | 338 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h index f3017b5..db8d491 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h | |||
| @@ -61,7 +61,7 @@ namespace controls | |||
| 61 | } AddonGUISpinControlType; | 61 | } AddonGUISpinControlType; |
| 62 | //---------------------------------------------------------------------------- | 62 | //---------------------------------------------------------------------------- |
| 63 | 63 | ||
| 64 | class CSpin : public CAddonGUIControlBase | 64 | class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase |
| 65 | { | 65 | { |
| 66 | public: | 66 | public: |
| 67 | //========================================================================== | 67 | //========================================================================== |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h index 13ce1da..b4e8ae0 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h | |||
| @@ -18,147 +18,150 @@ namespace gui | |||
| 18 | namespace controls | 18 | namespace controls |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CTextBox } | ||
| 26 | /// **Used to show a multi-page piece of text** | ||
| 27 | /// | ||
| 28 | /// The text box control can be used to display descriptions, help texts or | ||
| 29 | /// other larger texts. It corresponds to the representation which is also to | ||
| 30 | /// be seen on the CDialogTextViewer. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref TextBox.h "#include <kodi/gui/controls/TextBox.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref Text_Box "textbox control". | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CTextBox : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 22 | /// | 50 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box | 51 | CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window) |
| 24 | /// \ingroup cpp_kodi_gui | 52 | { |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CTextBox } | 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_text_box( |
| 26 | /// **Used to show a multi-page piece of text** | 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); |
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CTextBox can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //-------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //========================================================================== | ||
| 27 | /// | 62 | /// |
| 28 | /// The text box control can be used to display descriptions, help texts or | 63 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 29 | /// other larger texts. It corresponds to the representation which is also to | 64 | /// @brief Destructor |
| 30 | /// be seen on the CDialogTextViewer. | ||
| 31 | /// | 65 | /// |
| 32 | /// It has the header \ref TextBox.h "#include <kodi/gui/controls/TextBox.h>" | 66 | ~CTextBox() override = default; |
| 33 | /// be included to enjoy it. | 67 | //-------------------------------------------------------------------------- |
| 68 | |||
| 69 | //========================================================================== | ||
| 34 | /// | 70 | /// |
| 35 | /// Here you find the needed skin part for a \ref Text_Box "textbox control". | 71 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 72 | /// @brief Set the control on window to visible | ||
| 36 | /// | 73 | /// |
| 37 | /// @note The call of the control is only possible from the corresponding | 74 | /// @param[in] visible If true visible, otherwise hidden |
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | 75 | /// |
| 40 | class CTextBox : public CAddonGUIControlBase | 76 | void SetVisible(bool visible) |
| 41 | { | 77 | { |
| 42 | public: | 78 | m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle, |
| 43 | //========================================================================== | 79 | visible); |
| 44 | /// | 80 | } |
| 45 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 81 | //-------------------------------------------------------------------------- |
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CTextBox(CWindow* window, int controlId) | ||
| 52 | : CAddonGUIControlBase(window) | ||
| 53 | { | ||
| 54 | m_controlHandle = m_interface->kodi_gui->window->get_control_text_box(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CTextBox can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 63 | /// @brief Destructor | ||
| 64 | /// | ||
| 65 | ~CTextBox() override = default; | ||
| 66 | //-------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //========================================================================== | ||
| 69 | /// | ||
| 70 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 78 | } | ||
| 79 | //-------------------------------------------------------------------------- | ||
| 80 | 82 | ||
| 81 | //========================================================================== | 83 | //========================================================================== |
| 82 | /// | 84 | /// |
| 83 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 85 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 84 | /// @brief To reset box an remove all the text | 86 | /// @brief To reset box an remove all the text |
| 85 | /// | 87 | /// |
| 86 | void Reset() | 88 | void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); } |
| 87 | { | 89 | //-------------------------------------------------------------------------- |
| 88 | m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); | ||
| 89 | } | ||
| 90 | //-------------------------------------------------------------------------- | ||
| 91 | 90 | ||
| 92 | //========================================================================== | 91 | //========================================================================== |
| 93 | /// | 92 | /// |
| 94 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 93 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 95 | /// @brief To set the text on box | 94 | /// @brief To set the text on box |
| 96 | /// | 95 | /// |
| 97 | /// @param[in] text Text to show | 96 | /// @param[in] text Text to show |
| 98 | /// | 97 | /// |
| 99 | void SetText(const std::string& text) | 98 | void SetText(const std::string& text) |
| 100 | { | 99 | { |
| 101 | m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); | 100 | m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, |
| 102 | } | 101 | text.c_str()); |
| 103 | //-------------------------------------------------------------------------- | 102 | } |
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | 104 | ||
| 105 | //========================================================================== | 105 | //========================================================================== |
| 106 | /// | 106 | /// |
| 107 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 107 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 108 | /// @brief Get the used text from control | 108 | /// @brief Get the used text from control |
| 109 | /// | 109 | /// |
| 110 | /// @return Text shown | 110 | /// @return Text shown |
| 111 | /// | 111 | /// |
| 112 | std::string GetText() const | 112 | std::string GetText() const |
| 113 | { | ||
| 114 | std::string text; | ||
| 115 | char* ret = | ||
| 116 | m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle); | ||
| 117 | if (ret != nullptr) | ||
| 113 | { | 118 | { |
| 114 | std::string text; | 119 | if (std::strlen(ret)) |
| 115 | char* ret = m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle); | 120 | text = ret; |
| 116 | if (ret != nullptr) | 121 | m_interface->free_string(m_interface->kodiBase, ret); |
| 117 | { | ||
| 118 | if (std::strlen(ret)) | ||
| 119 | text = ret; | ||
| 120 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 121 | } | ||
| 122 | return text; | ||
| 123 | } | 122 | } |
| 124 | //-------------------------------------------------------------------------- | 123 | return text; |
| 124 | } | ||
| 125 | //-------------------------------------------------------------------------- | ||
| 125 | 126 | ||
| 126 | //========================================================================== | 127 | //========================================================================== |
| 127 | /// | 128 | /// |
| 128 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 129 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 129 | /// @brief To scroll text on other position | 130 | /// @brief To scroll text on other position |
| 130 | /// | 131 | /// |
| 131 | /// @param[in] position The line position to scroll to | 132 | /// @param[in] position The line position to scroll to |
| 132 | /// | 133 | /// |
| 133 | void Scroll(unsigned int position) | 134 | void Scroll(unsigned int position) |
| 134 | { | 135 | { |
| 135 | m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, position); | 136 | m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, |
| 136 | } | 137 | position); |
| 137 | //-------------------------------------------------------------------------- | 138 | } |
| 139 | //-------------------------------------------------------------------------- | ||
| 138 | 140 | ||
| 139 | //========================================================================== | 141 | //========================================================================== |
| 140 | /// | 142 | /// |
| 141 | /// \ingroup cpp_kodi_gui_controls_CTextBox | 143 | /// \ingroup cpp_kodi_gui_controls_CTextBox |
| 142 | /// @brief To set automatic scrolling of textbox | 144 | /// @brief To set automatic scrolling of textbox |
| 143 | /// | 145 | /// |
| 144 | /// Specifies the timing and conditions of any autoscrolling this textbox | 146 | /// Specifies the timing and conditions of any autoscrolling this textbox |
| 145 | /// should have. Times are in milliseconds. The content is delayed for the | 147 | /// should have. Times are in milliseconds. The content is delayed for the |
| 146 | /// given delay, then scrolls at a rate of one line per time interval until | 148 | /// given delay, then scrolls at a rate of one line per time interval until |
| 147 | /// the end. If the repeat tag is present, it then delays for the repeat | 149 | /// the end. If the repeat tag is present, it then delays for the repeat |
| 148 | /// time, fades out over 1 second, and repeats. It does not wrap or reset | 150 | /// time, fades out over 1 second, and repeats. It does not wrap or reset |
| 149 | /// to the top at the end of the scroll. | 151 | /// to the top at the end of the scroll. |
| 150 | /// | 152 | /// |
| 151 | /// @param[in] delay Content delay | 153 | /// @param[in] delay Content delay |
| 152 | /// @param[in] time One line per time interval | 154 | /// @param[in] time One line per time interval |
| 153 | /// @param[in] repeat Delays with given time, fades out over 1 | 155 | /// @param[in] repeat Delays with given time, fades out over 1 |
| 154 | /// second, and repeats | 156 | /// second, and repeats |
| 155 | /// | 157 | /// |
| 156 | void SetAutoScrolling(int delay, int time, int repeat) | 158 | void SetAutoScrolling(int delay, int time, int repeat) |
| 157 | { | 159 | { |
| 158 | m_interface->kodi_gui->control_text_box->set_auto_scrolling(m_interface->kodiBase, m_controlHandle, delay, time, repeat); | 160 | m_interface->kodi_gui->control_text_box->set_auto_scrolling( |
| 159 | } | 161 | m_interface->kodiBase, m_controlHandle, delay, time, repeat); |
| 160 | //-------------------------------------------------------------------------- | 162 | } |
| 161 | }; | 163 | //-------------------------------------------------------------------------- |
| 164 | }; | ||
| 162 | 165 | ||
| 163 | } /* namespace controls */ | 166 | } /* namespace controls */ |
| 164 | } /* namespace gui */ | 167 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h index b8b4cbf..4eb64c7 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h | |||
| @@ -200,6 +200,8 @@ typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser | |||
| 200 | void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); | 200 | void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); |
| 201 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | 201 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; |
| 202 | 202 | ||
| 203 | // typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString); | ||
| 204 | |||
| 203 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard | 205 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard |
| 204 | { | 206 | { |
| 205 | bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); | 207 | bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); |
| @@ -276,8 +278,6 @@ typedef struct AddonToKodiFuncTable_kodi_gui_listItem | |||
| 276 | void (*set_label)(void* kodiBase, void* handle, const char* label); | 278 | void (*set_label)(void* kodiBase, void* handle, const char* label); |
| 277 | char* (*get_label2)(void* kodiBase, void* handle); | 279 | char* (*get_label2)(void* kodiBase, void* handle); |
| 278 | void (*set_label2)(void* kodiBase, void* handle, const char* label); | 280 | void (*set_label2)(void* kodiBase, void* handle, const char* label); |
| 279 | char* (*get_icon_image)(void* kodiBase, void* handle); | ||
| 280 | void (*set_icon_image)(void* kodiBase, void* handle, const char* image); | ||
| 281 | char* (*get_art)(void* kodiBase, void* handle, const char* type); | 281 | char* (*get_art)(void* kodiBase, void* handle, const char* type); |
| 282 | void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); | 282 | void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); |
| 283 | char* (*get_path)(void* kodiBase, void* handle); | 283 | char* (*get_path)(void* kodiBase, void* handle); |
| @@ -302,12 +302,12 @@ typedef struct AddonToKodiFuncTable_kodi_gui_window | |||
| 302 | void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); | 302 | void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); |
| 303 | void (*destroy)(void* kodiBase, void* handle); | 303 | void (*destroy)(void* kodiBase, void* handle); |
| 304 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | 304 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, |
| 305 | bool (*)(void* handle), | 305 | bool (*CBInit)(void*), |
| 306 | bool (*)(void* handle, int), | 306 | bool (*CBFocus)(void*, int), |
| 307 | bool (*)(void* handle, int), | 307 | bool (*CBClick)(void*, int), |
| 308 | bool (*)(void* handle, int), | 308 | bool (*CBOnAction)(void*, int, uint32_t, wchar_t), |
| 309 | void (*)(void* handle, int, gui_context_menu_pair*, unsigned int*), | 309 | void (*CBGetContextButtons)(void*, int, gui_context_menu_pair*, unsigned int*), |
| 310 | bool (*)(void* handle, int, unsigned int)); | 310 | bool (*CBOnContextButton)(void*, int, unsigned int)); |
| 311 | bool (*show)(void* kodiBase, void* handle); | 311 | bool (*show)(void* kodiBase, void* handle); |
| 312 | bool (*close)(void* kodiBase, void* handle); | 312 | bool (*close)(void* kodiBase, void* handle); |
| 313 | bool (*do_modal)(void* kodiBase, void* handle); | 313 | bool (*do_modal)(void* kodiBase, void* handle); |
| @@ -316,6 +316,8 @@ typedef struct AddonToKodiFuncTable_kodi_gui_window | |||
| 316 | bool (*set_focus_id)(void* kodiBase, void* handle, int control_id); | 316 | bool (*set_focus_id)(void* kodiBase, void* handle, int control_id); |
| 317 | int (*get_focus_id)(void* kodiBase, void* handle); | 317 | int (*get_focus_id)(void* kodiBase, void* handle); |
| 318 | void (*set_control_label)(void* kodiBase, void* handle, int control_id, const char* label); | 318 | void (*set_control_label)(void* kodiBase, void* handle, int control_id, const char* label); |
| 319 | void (*set_control_visible)(void* kodiBase, void* handle, int control_id, bool visible); | ||
| 320 | void (*set_control_selected)(void* kodiBase, void* handle, int control_id, bool selected); | ||
| 319 | 321 | ||
| 320 | /* Window property functions */ | 322 | /* Window property functions */ |
| 321 | void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); | 323 | void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h index 26d6386..d545030 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h | |||
| @@ -66,16 +66,18 @@ namespace dialogs | |||
| 66 | /// fprintf(stderr, "Selected item is: %i\n", selected); | 66 | /// fprintf(stderr, "Selected item is: %i\n", selected); |
| 67 | /// ~~~~~~~~~~~~~ | 67 | /// ~~~~~~~~~~~~~ |
| 68 | /// | 68 | /// |
| 69 | inline int Show(const std::string& heading, const std::vector<std::string>& entries) | 69 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, |
| 70 | const std::vector<std::string>& entries) | ||
| 70 | { | 71 | { |
| 71 | using namespace ::kodi::addon; | 72 | using namespace ::kodi::addon; |
| 72 | unsigned int size = entries.size(); | 73 | unsigned int size = static_cast<unsigned int>(entries.size()); |
| 73 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | 74 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); |
| 74 | for (unsigned int i = 0; i < size; ++i) | 75 | for (unsigned int i = 0; i < size; ++i) |
| 75 | { | 76 | { |
| 76 | cEntries[i] = entries[i].c_str(); | 77 | cEntries[i] = entries[i].c_str(); |
| 77 | } | 78 | } |
| 78 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | 79 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( |
| 80 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 79 | free(cEntries); | 81 | free(cEntries); |
| 80 | return ret; | 82 | return ret; |
| 81 | } | 83 | } |
| @@ -113,10 +115,11 @@ namespace dialogs | |||
| 113 | /// fprintf(stderr, "Selected item is: %i\n", selected); | 115 | /// fprintf(stderr, "Selected item is: %i\n", selected); |
| 114 | /// ~~~~~~~~~~~~~ | 116 | /// ~~~~~~~~~~~~~ |
| 115 | /// | 117 | /// |
| 116 | inline int Show(const std::string& heading, const std::vector<std::pair<std::string, std::string>>& entries) | 118 | inline int ATTRIBUTE_HIDDEN Show( |
| 119 | const std::string& heading, const std::vector<std::pair<std::string, std::string>>& entries) | ||
| 117 | { | 120 | { |
| 118 | using namespace ::kodi::addon; | 121 | using namespace ::kodi::addon; |
| 119 | unsigned int size = entries.size(); | 122 | unsigned int size = static_cast<unsigned int>(entries.size()); |
| 120 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | 123 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); |
| 121 | for (unsigned int i = 0; i < size; ++i) | 124 | for (unsigned int i = 0; i < size; ++i) |
| 122 | { | 125 | { |
| @@ -160,10 +163,11 @@ namespace dialogs | |||
| 160 | /// fprintf(stderr, "Selected item is: %i\n", selected); | 163 | /// fprintf(stderr, "Selected item is: %i\n", selected); |
| 161 | /// ~~~~~~~~~~~~~ | 164 | /// ~~~~~~~~~~~~~ |
| 162 | /// | 165 | /// |
| 163 | inline int Show(const std::string& heading, const std::vector<std::pair<int, std::string>>& entries) | 166 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, |
| 167 | const std::vector<std::pair<int, std::string>>& entries) | ||
| 164 | { | 168 | { |
| 165 | using namespace ::kodi::addon; | 169 | using namespace ::kodi::addon; |
| 166 | unsigned int size = entries.size(); | 170 | unsigned int size = static_cast<unsigned int>(entries.size()); |
| 167 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | 171 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); |
| 168 | for (unsigned int i = 0; i < size; ++i) | 172 | for (unsigned int i = 0; i < size; ++i) |
| 169 | { | 173 | { |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h index 417d5db..5a49b70 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h | |||
| @@ -18,218 +18,232 @@ namespace gui | |||
| 18 | namespace dialogs | 18 | namespace dialogs |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | 22 | /// |
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress | 23 | /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress |
| 24 | /// \ingroup cpp_kodi_gui | 24 | /// \ingroup cpp_kodi_gui |
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } | 25 | /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } |
| 26 | /// **Progress dialog shown for background work** | 26 | /// **Progress dialog shown for background work** |
| 27 | /// | ||
| 28 | /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" | ||
| 29 | /// given class are basically used to create Kodi's extended progress. | ||
| 30 | /// | ||
| 31 | /// | ||
| 32 | /// -------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// **Example:** | ||
| 35 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 36 | /// #include <kodi/gui/dialogs/ExtendedProgress.h> | ||
| 37 | /// | ||
| 38 | /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); | ||
| 39 | /// ext_progress->SetText("Test progress"); | ||
| 40 | /// for (unsigned int i = 0; i < 50; i += 10) | ||
| 41 | /// { | ||
| 42 | /// ext_progress->SetProgress(i, 100); | ||
| 43 | /// sleep(1); | ||
| 44 | /// } | ||
| 45 | /// | ||
| 46 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | ||
| 47 | /// ext_progress->SetText("Test progress - Step 2"); | ||
| 48 | /// | ||
| 49 | /// for (unsigned int i = 50; i < 100; i += 10) | ||
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// delete ext_progress; | ||
| 55 | /// ~~~~~~~~~~~~~ | ||
| 56 | /// | ||
| 57 | class ATTRIBUTE_HIDDEN CExtendedProgress | ||
| 58 | { | ||
| 59 | public: | ||
| 60 | //========================================================================== | ||
| 27 | /// | 61 | /// |
| 28 | /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" | 62 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 29 | /// given class are basically used to create Kodi's extended progress. | 63 | /// Construct a new dialog |
| 30 | /// | 64 | /// |
| 65 | /// @param[in] title Title string | ||
| 31 | /// | 66 | /// |
| 32 | /// -------------------------------------------------------------------------- | 67 | explicit CExtendedProgress(const std::string& title = "") |
| 68 | { | ||
| 69 | using namespace ::kodi::addon; | ||
| 70 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog( | ||
| 71 | CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 72 | if (!m_DialogHandle) | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, | ||
| 74 | "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 33 | /// | 79 | /// |
| 34 | /// **Example:** | 80 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 35 | /// ~~~~~~~~~~~~~{.cpp} | 81 | /// Destructor |
| 36 | /// #include <kodi/gui/dialogs/ExtendedProgress.h> | ||
| 37 | /// | 82 | /// |
| 38 | /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); | 83 | ~CExtendedProgress() |
| 39 | /// ext_progress->SetText("Test progress"); | 84 | { |
| 40 | /// for (unsigned int i = 0; i < 50; i += 10) | 85 | using namespace ::kodi::addon; |
| 41 | /// { | 86 | if (m_DialogHandle) |
| 42 | /// ext_progress->SetProgress(i, 100); | 87 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog( |
| 43 | /// sleep(1); | 88 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 44 | /// } | 89 | } |
| 90 | //-------------------------------------------------------------------------- | ||
| 91 | |||
| 92 | //========================================================================== | ||
| 45 | /// | 93 | /// |
| 46 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | 94 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 47 | /// ext_progress->SetText("Test progress - Step 2"); | 95 | /// @brief Get the used title |
| 48 | /// | 96 | /// |
| 49 | /// for (unsigned int i = 50; i < 100; i += 10) | 97 | /// @return Title string |
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// delete ext_progress; | ||
| 55 | /// ~~~~~~~~~~~~~ | ||
| 56 | /// | 98 | /// |
| 57 | class CExtendedProgress | 99 | std::string Title() const |
| 58 | { | 100 | { |
| 59 | public: | 101 | using namespace ::kodi::addon; |
| 60 | //========================================================================== | 102 | std::string text; |
| 61 | /// | 103 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title( |
| 62 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 104 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 63 | /// Construct a new dialog | 105 | if (strMsg != nullptr) |
| 64 | /// | ||
| 65 | /// @param[in] title Title string | ||
| 66 | /// | ||
| 67 | explicit CExtendedProgress(const std::string& title = "") | ||
| 68 | { | ||
| 69 | using namespace ::kodi::addon; | ||
| 70 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 71 | if (!m_DialogHandle) | ||
| 72 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 73 | } | ||
| 74 | //-------------------------------------------------------------------------- | ||
| 75 | |||
| 76 | //========================================================================== | ||
| 77 | /// | ||
| 78 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 79 | /// Destructor | ||
| 80 | /// | ||
| 81 | ~CExtendedProgress() | ||
| 82 | { | ||
| 83 | using namespace ::kodi::addon; | ||
| 84 | if (m_DialogHandle) | ||
| 85 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// | ||
| 91 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 92 | /// @brief Get the used title | ||
| 93 | /// | ||
| 94 | /// @return Title string | ||
| 95 | /// | ||
| 96 | std::string Title() const | ||
| 97 | { | ||
| 98 | using namespace ::kodi::addon; | ||
| 99 | std::string text; | ||
| 100 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 101 | if (strMsg != nullptr) | ||
| 102 | { | ||
| 103 | if (std::strlen(strMsg)) | ||
| 104 | text = strMsg; | ||
| 105 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 106 | } | ||
| 107 | return text; | ||
| 108 | } | ||
| 109 | //-------------------------------------------------------------------------- | ||
| 110 | |||
| 111 | //========================================================================== | ||
| 112 | /// | ||
| 113 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 114 | /// @brief To set the title of dialog | ||
| 115 | /// | ||
| 116 | /// @param[in] title Title string | ||
| 117 | /// | ||
| 118 | void SetTitle(const std::string& title) | ||
| 119 | { | ||
| 120 | using namespace ::kodi::addon; | ||
| 121 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 122 | } | ||
| 123 | //-------------------------------------------------------------------------- | ||
| 124 | |||
| 125 | //========================================================================== | ||
| 126 | /// | ||
| 127 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 128 | /// @brief Get the used text information string | ||
| 129 | /// | ||
| 130 | /// @return Text string | ||
| 131 | /// | ||
| 132 | std::string Text() const | ||
| 133 | { | ||
| 134 | using namespace ::kodi::addon; | ||
| 135 | std::string text; | ||
| 136 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 137 | if (strMsg != nullptr) | ||
| 138 | { | ||
| 139 | if (std::strlen(strMsg)) | ||
| 140 | text = strMsg; | ||
| 141 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 142 | } | ||
| 143 | return text; | ||
| 144 | } | ||
| 145 | //-------------------------------------------------------------------------- | ||
| 146 | |||
| 147 | //========================================================================== | ||
| 148 | /// | ||
| 149 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 150 | /// @brief To set the used text information string | ||
| 151 | /// | ||
| 152 | /// @param[in] text information text to set | ||
| 153 | /// | ||
| 154 | void SetText(const std::string& text) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 158 | } | ||
| 159 | //-------------------------------------------------------------------------- | ||
| 160 | |||
| 161 | //========================================================================== | ||
| 162 | /// | ||
| 163 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 164 | /// @brief To ask dialog is finished | ||
| 165 | /// | ||
| 166 | /// @return True if on end | ||
| 167 | /// | ||
| 168 | bool IsFinished() const | ||
| 169 | { | ||
| 170 | using namespace ::kodi::addon; | ||
| 171 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 172 | } | ||
| 173 | //-------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | //========================================================================== | ||
| 176 | /// | ||
| 177 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 178 | /// @brief Mark progress finished | ||
| 179 | /// | ||
| 180 | void MarkFinished() | ||
| 181 | { | ||
| 182 | using namespace ::kodi::addon; | ||
| 183 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 184 | } | ||
| 185 | //-------------------------------------------------------------------------- | ||
| 186 | |||
| 187 | //========================================================================== | ||
| 188 | /// | ||
| 189 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 190 | /// @brief Get the current progress position as percent | ||
| 191 | /// | ||
| 192 | /// @return Position | ||
| 193 | /// | ||
| 194 | float Percentage() const | ||
| 195 | { | ||
| 196 | using namespace ::kodi::addon; | ||
| 197 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 204 | /// @brief To set the current progress position as percent | ||
| 205 | /// | ||
| 206 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 207 | /// | ||
| 208 | void SetPercentage(float percentage) | ||
| 209 | { | 106 | { |
| 210 | using namespace ::kodi::addon; | 107 | if (std::strlen(strMsg)) |
| 211 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | 108 | text = strMsg; |
| 109 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 110 | strMsg); | ||
| 212 | } | 111 | } |
| 213 | //-------------------------------------------------------------------------- | 112 | return text; |
| 214 | 113 | } | |
| 215 | //========================================================================== | 114 | //-------------------------------------------------------------------------- |
| 216 | /// | 115 | |
| 217 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | 116 | //========================================================================== |
| 218 | /// @brief To set progress position with predefined places | 117 | /// |
| 219 | /// | 118 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 220 | /// @param[in] currentItem Place position to use | 119 | /// @brief To set the title of dialog |
| 221 | /// @param[in] itemCount Amount of used places | 120 | /// |
| 222 | /// | 121 | /// @param[in] title Title string |
| 223 | void SetProgress(int currentItem, int itemCount) | 122 | /// |
| 123 | void SetTitle(const std::string& title) | ||
| 124 | { | ||
| 125 | using namespace ::kodi::addon; | ||
| 126 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title( | ||
| 127 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 134 | /// @brief Get the used text information string | ||
| 135 | /// | ||
| 136 | /// @return Text string | ||
| 137 | /// | ||
| 138 | std::string Text() const | ||
| 139 | { | ||
| 140 | using namespace ::kodi::addon; | ||
| 141 | std::string text; | ||
| 142 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text( | ||
| 143 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 144 | if (strMsg != nullptr) | ||
| 224 | { | 145 | { |
| 225 | using namespace ::kodi::addon; | 146 | if (std::strlen(strMsg)) |
| 226 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | 147 | text = strMsg; |
| 148 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 149 | strMsg); | ||
| 227 | } | 150 | } |
| 228 | //-------------------------------------------------------------------------- | 151 | return text; |
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | //========================================================================== | ||
| 156 | /// | ||
| 157 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 158 | /// @brief To set the used text information string | ||
| 159 | /// | ||
| 160 | /// @param[in] text information text to set | ||
| 161 | /// | ||
| 162 | void SetText(const std::string& text) | ||
| 163 | { | ||
| 164 | using namespace ::kodi::addon; | ||
| 165 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text( | ||
| 166 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 173 | /// @brief To ask dialog is finished | ||
| 174 | /// | ||
| 175 | /// @return True if on end | ||
| 176 | /// | ||
| 177 | bool IsFinished() const | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished( | ||
| 181 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 182 | } | ||
| 183 | //-------------------------------------------------------------------------- | ||
| 184 | |||
| 185 | //========================================================================== | ||
| 186 | /// | ||
| 187 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 188 | /// @brief Mark progress finished | ||
| 189 | /// | ||
| 190 | void MarkFinished() | ||
| 191 | { | ||
| 192 | using namespace ::kodi::addon; | ||
| 193 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished( | ||
| 194 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 195 | } | ||
| 196 | //-------------------------------------------------------------------------- | ||
| 197 | |||
| 198 | //========================================================================== | ||
| 199 | /// | ||
| 200 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 201 | /// @brief Get the current progress position as percent | ||
| 202 | /// | ||
| 203 | /// @return Position | ||
| 204 | /// | ||
| 205 | float Percentage() const | ||
| 206 | { | ||
| 207 | using namespace ::kodi::addon; | ||
| 208 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage( | ||
| 209 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 210 | } | ||
| 211 | //-------------------------------------------------------------------------- | ||
| 229 | 212 | ||
| 230 | private: | 213 | //========================================================================== |
| 231 | void* m_DialogHandle; | 214 | /// |
| 232 | }; | 215 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress |
| 216 | /// @brief To set the current progress position as percent | ||
| 217 | /// | ||
| 218 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 219 | /// | ||
| 220 | void SetPercentage(float percentage) | ||
| 221 | { | ||
| 222 | using namespace ::kodi::addon; | ||
| 223 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage( | ||
| 224 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 225 | } | ||
| 226 | //-------------------------------------------------------------------------- | ||
| 227 | |||
| 228 | //========================================================================== | ||
| 229 | /// | ||
| 230 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 231 | /// @brief To set progress position with predefined places | ||
| 232 | /// | ||
| 233 | /// @param[in] currentItem Place position to use | ||
| 234 | /// @param[in] itemCount Amount of used places | ||
| 235 | /// | ||
| 236 | void SetProgress(int currentItem, int itemCount) | ||
| 237 | { | ||
| 238 | using namespace ::kodi::addon; | ||
| 239 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress( | ||
| 240 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | ||
| 241 | } | ||
| 242 | //-------------------------------------------------------------------------- | ||
| 243 | |||
| 244 | private: | ||
| 245 | void* m_DialogHandle; | ||
| 246 | }; | ||
| 233 | 247 | ||
| 234 | } /* namespace dialogs */ | 248 | } /* namespace dialogs */ |
| 235 | } /* namespace gui */ | 249 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h index bb1065d..90da063 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h | |||
| @@ -71,17 +71,22 @@ namespace dialogs | |||
| 71 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | 71 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); |
| 72 | /// ~~~~~~~~~~~~~ | 72 | /// ~~~~~~~~~~~~~ |
| 73 | /// | 73 | /// |
| 74 | inline bool ShowAndGetDirectory(const std::string& shares, const std::string& heading, std::string& path, bool writeOnly = false) | 74 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares, |
| 75 | const std::string& heading, | ||
| 76 | std::string& path, | ||
| 77 | bool writeOnly = false) | ||
| 75 | { | 78 | { |
| 76 | using namespace ::kodi::addon; | 79 | using namespace ::kodi::addon; |
| 77 | char* retString = nullptr; | 80 | char* retString = nullptr; |
| 78 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(CAddonBase::m_interface->toKodi->kodiBase, | 81 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory( |
| 79 | shares.c_str(), heading.c_str(), path.c_str(), &retString, writeOnly); | 82 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), |
| 83 | &retString, writeOnly); | ||
| 80 | if (retString != nullptr) | 84 | if (retString != nullptr) |
| 81 | { | 85 | { |
| 82 | if (std::strlen(retString)) | 86 | if (std::strlen(retString)) |
| 83 | path = retString; | 87 | path = retString; |
| 84 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | 88 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, |
| 89 | retString); | ||
| 85 | } | 90 | } |
| 86 | return ret; | 91 | return ret; |
| 87 | } | 92 | } |
| @@ -104,8 +109,12 @@ namespace dialogs | |||
| 104 | /// handled as directories. | 109 | /// handled as directories. |
| 105 | /// @return False if selection becomes canceled. | 110 | /// @return False if selection becomes canceled. |
| 106 | /// | 111 | /// |
| 107 | inline bool ShowAndGetFile(const std::string& shares, const std::string& mask, const std::string& heading, | 112 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares, |
| 108 | std::string& path, bool useThumbs = false, bool useFileDirectories = false) | 113 | const std::string& mask, |
| 114 | const std::string& heading, | ||
| 115 | std::string& path, | ||
| 116 | bool useThumbs = false, | ||
| 117 | bool useFileDirectories = false) | ||
| 109 | { | 118 | { |
| 110 | using namespace ::kodi::addon; | 119 | using namespace ::kodi::addon; |
| 111 | char* retString = nullptr; | 120 | char* retString = nullptr; |
| @@ -141,8 +150,13 @@ namespace dialogs | |||
| 141 | /// @param[in] singleList | 150 | /// @param[in] singleList |
| 142 | /// @return False if selection becomes canceled. | 151 | /// @return False if selection becomes canceled. |
| 143 | /// | 152 | /// |
| 144 | inline bool ShowAndGetFileFromDir(const std::string& directory, const std::string& mask, const std::string& heading, std::string& path, | 153 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory, |
| 145 | bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) | 154 | const std::string& mask, |
| 155 | const std::string& heading, | ||
| 156 | std::string& path, | ||
| 157 | bool useThumbs = false, | ||
| 158 | bool useFileDirectories = false, | ||
| 159 | bool singleList = false) | ||
| 146 | { | 160 | { |
| 147 | using namespace ::kodi::addon; | 161 | using namespace ::kodi::addon; |
| 148 | char* retString = nullptr; | 162 | char* retString = nullptr; |
| @@ -176,8 +190,12 @@ namespace dialogs | |||
| 176 | /// handled as directories. | 190 | /// handled as directories. |
| 177 | /// @return False if selection becomes canceled. | 191 | /// @return False if selection becomes canceled. |
| 178 | /// | 192 | /// |
| 179 | inline bool ShowAndGetFileList(const std::string& shares, const std::string& mask, const std::string& heading, | 193 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares, |
| 180 | std::vector<std::string>& fileList, bool useThumbs = false, bool useFileDirectories = false) | 194 | const std::string& mask, |
| 195 | const std::string& heading, | ||
| 196 | std::vector<std::string>& fileList, | ||
| 197 | bool useThumbs = false, | ||
| 198 | bool useFileDirectories = false) | ||
| 181 | { | 199 | { |
| 182 | using namespace ::kodi::addon; | 200 | using namespace ::kodi::addon; |
| 183 | char** list = nullptr; | 201 | char** list = nullptr; |
| @@ -188,7 +206,7 @@ namespace dialogs | |||
| 188 | if (ret) | 206 | if (ret) |
| 189 | { | 207 | { |
| 190 | for (unsigned int i = 0; i < listSize; ++i) | 208 | for (unsigned int i = 0; i < listSize; ++i) |
| 191 | fileList.push_back(list[i]); | 209 | fileList.emplace_back(list[i]); |
| 192 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | 210 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); |
| 193 | } | 211 | } |
| 194 | return ret; | 212 | return ret; |
| @@ -208,7 +226,10 @@ namespace dialogs | |||
| 208 | /// @param[in] type | 226 | /// @param[in] type |
| 209 | /// @return False if selection becomes canceled. | 227 | /// @return False if selection becomes canceled. |
| 210 | /// | 228 | /// |
| 211 | inline bool ShowAndGetSource(std::string& path, bool allowNetworkShares, const std::string& additionalShare = "", const std::string& type = "") | 229 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path, |
| 230 | bool allowNetworkShares, | ||
| 231 | const std::string& additionalShare = "", | ||
| 232 | const std::string& type = "") | ||
| 212 | { | 233 | { |
| 213 | using namespace ::kodi::addon; | 234 | using namespace ::kodi::addon; |
| 214 | char* retString = nullptr; | 235 | char* retString = nullptr; |
| @@ -235,7 +256,9 @@ namespace dialogs | |||
| 235 | /// @param[out] path Return value about selected image | 256 | /// @param[out] path Return value about selected image |
| 236 | /// @return False if selection becomes canceled. | 257 | /// @return False if selection becomes canceled. |
| 237 | /// | 258 | /// |
| 238 | inline bool ShowAndGetImage(const std::string& shares, const std::string& heading, std::string& path) | 259 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares, |
| 260 | const std::string& heading, | ||
| 261 | std::string& path) | ||
| 239 | { | 262 | { |
| 240 | using namespace ::kodi::addon; | 263 | using namespace ::kodi::addon; |
| 241 | char* retString = nullptr; | 264 | char* retString = nullptr; |
| @@ -262,7 +285,9 @@ namespace dialogs | |||
| 262 | /// @param[out] file_list Return value about selected images | 285 | /// @param[out] file_list Return value about selected images |
| 263 | /// @return False if selection becomes canceled. | 286 | /// @return False if selection becomes canceled. |
| 264 | /// | 287 | /// |
| 265 | inline bool ShowAndGetImageList(const std::string& shares, const std::string& heading, std::vector<std::string>& file_list) | 288 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares, |
| 289 | const std::string& heading, | ||
| 290 | std::vector<std::string>& file_list) | ||
| 266 | { | 291 | { |
| 267 | using namespace ::kodi::addon; | 292 | using namespace ::kodi::addon; |
| 268 | char** list = nullptr; | 293 | char** list = nullptr; |
| @@ -272,7 +297,7 @@ namespace dialogs | |||
| 272 | if (ret) | 297 | if (ret) |
| 273 | { | 298 | { |
| 274 | for (unsigned int i = 0; i < listSize; ++i) | 299 | for (unsigned int i = 0; i < listSize; ++i) |
| 275 | file_list.push_back(list[i]); | 300 | file_list.emplace_back(list[i]); |
| 276 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | 301 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); |
| 277 | } | 302 | } |
| 278 | return ret; | 303 | return ret; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h index 76284d8..843bdfa 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h | |||
| @@ -76,17 +76,23 @@ namespace dialogs | |||
| 76 | /// text.c_str(), bRet ? "OK" : "Canceled"); | 76 | /// text.c_str(), bRet ? "OK" : "Canceled"); |
| 77 | /// ~~~~~~~~~~~~~ | 77 | /// ~~~~~~~~~~~~~ |
| 78 | /// | 78 | /// |
| 79 | inline bool ShowAndGetInput(std::string& text, const std::string& heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0) | 79 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, |
| 80 | const std::string& heading, | ||
| 81 | bool allowEmptyResult, | ||
| 82 | bool hiddenInput = false, | ||
| 83 | unsigned int autoCloseMs = 0) | ||
| 80 | { | 84 | { |
| 81 | using namespace ::kodi::addon; | 85 | using namespace ::kodi::addon; |
| 82 | char* retString = nullptr; | 86 | char* retString = nullptr; |
| 83 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(CAddonBase::m_interface->toKodi->kodiBase, | 87 | bool ret = |
| 84 | text.c_str(), &retString, heading.c_str(), allowEmptyResult, | 88 | CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head( |
| 85 | hiddenInput, autoCloseMs); | 89 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(), |
| 90 | allowEmptyResult, hiddenInput, autoCloseMs); | ||
| 86 | if (retString != nullptr) | 91 | if (retString != nullptr) |
| 87 | { | 92 | { |
| 88 | text = retString; | 93 | text = retString; |
| 89 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | 94 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, |
| 95 | retString); | ||
| 90 | } | 96 | } |
| 91 | return ret; | 97 | return ret; |
| 92 | } | 98 | } |
| @@ -108,7 +114,9 @@ namespace dialogs | |||
| 108 | /// false if unsuccessful display, no user | 114 | /// false if unsuccessful display, no user |
| 109 | /// input, or canceled editing. | 115 | /// input, or canceled editing. |
| 110 | /// | 116 | /// |
| 111 | inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) | 117 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, |
| 118 | bool allowEmptyResult, | ||
| 119 | unsigned int autoCloseMs = 0) | ||
| 112 | { | 120 | { |
| 113 | using namespace ::kodi::addon; | 121 | using namespace ::kodi::addon; |
| 114 | char* retString = nullptr; | 122 | char* retString = nullptr; |
| @@ -140,7 +148,10 @@ namespace dialogs | |||
| 140 | /// false if unsuccessful display, no user | 148 | /// false if unsuccessful display, no user |
| 141 | /// input, or canceled editing. | 149 | /// input, or canceled editing. |
| 142 | /// | 150 | /// |
| 143 | inline bool ShowAndGetNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | 151 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, |
| 152 | const std::string& heading, | ||
| 153 | bool allowEmptyResult, | ||
| 154 | unsigned int autoCloseMs = 0) | ||
| 144 | { | 155 | { |
| 145 | using namespace ::kodi::addon; | 156 | using namespace ::kodi::addon; |
| 146 | char* retString = nullptr; | 157 | char* retString = nullptr; |
| @@ -170,7 +181,8 @@ namespace dialogs | |||
| 170 | /// false if unsuccessful display, no user | 181 | /// false if unsuccessful display, no user |
| 171 | /// input, or canceled editing. | 182 | /// input, or canceled editing. |
| 172 | /// | 183 | /// |
| 173 | inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) | 184 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, |
| 185 | unsigned int autoCloseMs = 0) | ||
| 174 | { | 186 | { |
| 175 | using namespace ::kodi::addon; | 187 | using namespace ::kodi::addon; |
| 176 | char* retString = nullptr; | 188 | char* retString = nullptr; |
| @@ -251,7 +263,10 @@ namespace dialogs | |||
| 251 | /// } | 263 | /// } |
| 252 | /// ~~~~~~~~~~~~~ | 264 | /// ~~~~~~~~~~~~~ |
| 253 | /// | 265 | /// |
| 254 | inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | 266 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, |
| 267 | const std::string& heading, | ||
| 268 | bool allowEmptyResult, | ||
| 269 | unsigned int autoCloseMs = 0) | ||
| 255 | { | 270 | { |
| 256 | using namespace ::kodi::addon; | 271 | using namespace ::kodi::addon; |
| 257 | char* retString = nullptr; | 272 | char* retString = nullptr; |
| @@ -281,7 +296,8 @@ namespace dialogs | |||
| 281 | /// false if unsuccessful display, no user | 296 | /// false if unsuccessful display, no user |
| 282 | /// input, or canceled editing. | 297 | /// input, or canceled editing. |
| 283 | /// | 298 | /// |
| 284 | inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) | 299 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, |
| 300 | unsigned int autoCloseMs = 0) | ||
| 285 | { | 301 | { |
| 286 | using namespace ::kodi::addon; | 302 | using namespace ::kodi::addon; |
| 287 | char* retString = nullptr; | 303 | char* retString = nullptr; |
| @@ -313,7 +329,10 @@ namespace dialogs | |||
| 313 | /// unsuccessful input. -1 if no user input or | 329 | /// unsuccessful input. -1 if no user input or |
| 314 | /// canceled editing. | 330 | /// canceled editing. |
| 315 | /// | 331 | /// |
| 316 | inline int ShowAndVerifyPassword(std::string& password, const std::string& heading, int retries, unsigned int autoCloseMs = 0) | 332 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password, |
| 333 | const std::string& heading, | ||
| 334 | int retries, | ||
| 335 | unsigned int autoCloseMs = 0) | ||
| 317 | { | 336 | { |
| 318 | using namespace ::kodi::addon; | 337 | using namespace ::kodi::addon; |
| 319 | char* retString = nullptr; | 338 | char* retString = nullptr; |
| @@ -347,7 +366,9 @@ namespace dialogs | |||
| 347 | /// false if unsuccessful display, no user | 366 | /// false if unsuccessful display, no user |
| 348 | /// input, or canceled editing. | 367 | /// input, or canceled editing. |
| 349 | /// | 368 | /// |
| 350 | inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) | 369 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text, |
| 370 | bool searching, | ||
| 371 | unsigned int autoCloseMs = 0) | ||
| 351 | { | 372 | { |
| 352 | using namespace ::kodi::addon; | 373 | using namespace ::kodi::addon; |
| 353 | char* retString = nullptr; | 374 | char* retString = nullptr; |
| @@ -372,7 +393,8 @@ namespace dialogs | |||
| 372 | /// @return true if successful done, false if | 393 | /// @return true if successful done, false if |
| 373 | /// unsuccessful or keyboard not present. | 394 | /// unsuccessful or keyboard not present. |
| 374 | /// | 395 | /// |
| 375 | inline bool SendTextToActiveKeyboard(const std::string& text, bool closeKeyboard = false) | 396 | inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text, |
| 397 | bool closeKeyboard = false) | ||
| 376 | { | 398 | { |
| 377 | using namespace ::kodi::addon; | 399 | using namespace ::kodi::addon; |
| 378 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, | 400 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, |
| @@ -387,7 +409,7 @@ namespace dialogs | |||
| 387 | /// | 409 | /// |
| 388 | /// @return true if keyboard present, false if not present | 410 | /// @return true if keyboard present, false if not present |
| 389 | /// | 411 | /// |
| 390 | inline bool IsKeyboardActivated() | 412 | inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated() |
| 391 | { | 413 | { |
| 392 | using namespace ::kodi::addon; | 414 | using namespace ::kodi::addon; |
| 393 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); | 415 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h index 4a8eccb..bff7683 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h | |||
| @@ -50,11 +50,13 @@ namespace dialogs | |||
| 50 | /// false if unsuccessful display, no user | 50 | /// false if unsuccessful display, no user |
| 51 | /// input, or canceled editing. | 51 | /// input, or canceled editing. |
| 52 | /// | 52 | /// |
| 53 | inline bool ShowAndVerifyNewPassword(std::string& newPassword) | 53 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword) |
| 54 | { | 54 | { |
| 55 | using namespace ::kodi::addon; | 55 | using namespace ::kodi::addon; |
| 56 | char* pw = nullptr; | 56 | char* pw = nullptr; |
| 57 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, &pw); | 57 | bool ret = |
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password( | ||
| 59 | CAddonBase::m_interface->toKodi->kodiBase, &pw); | ||
| 58 | if (pw != nullptr) | 60 | if (pw != nullptr) |
| 59 | { | 61 | { |
| 60 | newPassword = pw; | 62 | newPassword = pw; |
| @@ -131,7 +133,9 @@ namespace dialogs | |||
| 131 | /// } | 133 | /// } |
| 132 | /// ~~~~~~~~~~~~~ | 134 | /// ~~~~~~~~~~~~~ |
| 133 | /// | 135 | /// |
| 134 | inline int ShowAndVerifyPassword(const std::string& password, const std::string& heading, int retries) | 136 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password, |
| 137 | const std::string& heading, | ||
| 138 | int retries) | ||
| 135 | { | 139 | { |
| 136 | using namespace ::kodi::addon; | 140 | using namespace ::kodi::addon; |
| 137 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | 141 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, |
| @@ -152,7 +156,9 @@ namespace dialogs | |||
| 152 | /// input. false if unsuccessful display, no | 156 | /// input. false if unsuccessful display, no |
| 153 | /// user input, or canceled editing. | 157 | /// user input, or canceled editing. |
| 154 | /// | 158 | /// |
| 155 | inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) | 159 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify, |
| 160 | const std::string& heading, | ||
| 161 | bool verifyInput) | ||
| 156 | { | 162 | { |
| 157 | using namespace ::kodi::addon; | 163 | using namespace ::kodi::addon; |
| 158 | char* retString = nullptr; | 164 | char* retString = nullptr; |
| @@ -199,7 +205,7 @@ namespace dialogs | |||
| 199 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | 205 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); |
| 200 | /// ~~~~~~~~~~~~~ | 206 | /// ~~~~~~~~~~~~~ |
| 201 | /// | 207 | /// |
| 202 | inline bool ShowAndGetTime(tm& time, const std::string& heading) | 208 | inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading) |
| 203 | { | 209 | { |
| 204 | using namespace ::kodi::addon; | 210 | using namespace ::kodi::addon; |
| 205 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); | 211 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); |
| @@ -238,7 +244,7 @@ namespace dialogs | |||
| 238 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | 244 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); |
| 239 | /// ~~~~~~~~~~~~~ | 245 | /// ~~~~~~~~~~~~~ |
| 240 | /// | 246 | /// |
| 241 | inline bool ShowAndGetDate(tm& date, const std::string& heading) | 247 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading) |
| 242 | { | 248 | { |
| 243 | using namespace ::kodi::addon; | 249 | using namespace ::kodi::addon; |
| 244 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); | 250 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); |
| @@ -258,7 +264,8 @@ namespace dialogs | |||
| 258 | /// display, no user input, or canceled | 264 | /// display, no user input, or canceled |
| 259 | /// editing. | 265 | /// editing. |
| 260 | /// | 266 | /// |
| 261 | inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) | 267 | inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress, |
| 268 | const std::string& heading) | ||
| 262 | { | 269 | { |
| 263 | using namespace ::kodi::addon; | 270 | using namespace ::kodi::addon; |
| 264 | char* retString = nullptr; | 271 | char* retString = nullptr; |
| @@ -304,7 +311,9 @@ namespace dialogs | |||
| 304 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); | 311 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); |
| 305 | /// ~~~~~~~~~~~~~ | 312 | /// ~~~~~~~~~~~~~ |
| 306 | /// | 313 | /// |
| 307 | inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) | 314 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input, |
| 315 | const std::string& heading, | ||
| 316 | unsigned int autoCloseTimeoutMs = 0) | ||
| 308 | { | 317 | { |
| 309 | using namespace ::kodi::addon; | 318 | using namespace ::kodi::addon; |
| 310 | char* retString = nullptr; | 319 | char* retString = nullptr; |
| @@ -331,7 +340,7 @@ namespace dialogs | |||
| 331 | /// if unsuccessful display, no user input, or | 340 | /// if unsuccessful display, no user input, or |
| 332 | /// canceled editing. | 341 | /// canceled editing. |
| 333 | /// | 342 | /// |
| 334 | inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) | 343 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading) |
| 335 | { | 344 | { |
| 336 | using namespace ::kodi::addon; | 345 | using namespace ::kodi::addon; |
| 337 | char* retString = nullptr; | 346 | char* retString = nullptr; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h index a47880f..b9a3a0d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h | |||
| @@ -52,11 +52,11 @@ namespace dialogs | |||
| 52 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); | 52 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); |
| 53 | /// ~~~~~~~~~~~~~ | 53 | /// ~~~~~~~~~~~~~ |
| 54 | /// | 54 | /// |
| 55 | inline void ShowAndGetInput(const std::string& heading, const std::string& text) | 55 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, const std::string& text) |
| 56 | { | 56 | { |
| 57 | using namespace ::kodi::addon; | 57 | using namespace ::kodi::addon; |
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, | 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text( |
| 59 | heading.c_str(), text.c_str()); | 59 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); |
| 60 | } | 60 | } |
| 61 | //-------------------------------------------------------------------------- | 61 | //-------------------------------------------------------------------------- |
| 62 | 62 | ||
| @@ -80,7 +80,10 @@ namespace dialogs | |||
| 80 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); | 80 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); |
| 81 | /// ~~~~~~~~~~~~~ | 81 | /// ~~~~~~~~~~~~~ |
| 82 | /// | 82 | /// |
| 83 | inline void ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2) | 83 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, |
| 84 | const std::string& line0, | ||
| 85 | const std::string& line1, | ||
| 86 | const std::string& line2) | ||
| 84 | { | 87 | { |
| 85 | using namespace ::kodi::addon; | 88 | using namespace ::kodi::addon; |
| 86 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | 89 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h index bbaa98d..b1f8cc5 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h | |||
| @@ -18,223 +18,237 @@ namespace gui | |||
| 18 | namespace dialogs | 18 | namespace dialogs |
| 19 | { | 19 | { |
| 20 | 20 | ||
| 21 | //============================================================================ | 21 | //============================================================================ |
| 22 | /// | 22 | /// |
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress | 23 | /// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress |
| 24 | /// \ingroup cpp_kodi_gui | 24 | /// \ingroup cpp_kodi_gui |
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::CProgress } | 25 | /// @brief \cpp_class{ kodi::gui::dialogs::CProgress } |
| 26 | /// **Progress dialog shown in center** | 26 | /// **Progress dialog shown in center** |
| 27 | /// | 27 | /// |
| 28 | /// The with \ref DialogProgress.h "#include <kodi/gui/dialogs/Progress.h>" | 28 | /// The with \ref DialogProgress.h "#include <kodi/gui/dialogs/Progress.h>" |
| 29 | /// given class are basically used to create Kodi's progress dialog with named | 29 | /// given class are basically used to create Kodi's progress dialog with named |
| 30 | /// text fields. | 30 | /// text fields. |
| 31 | /// | 31 | /// |
| 32 | /// **Example:** | 32 | /// **Example:** |
| 33 | /// ~~~~~~~~~~~~~{.cpp} | 33 | /// ~~~~~~~~~~~~~{.cpp} |
| 34 | /// #include <kodi/gui/dialogs/Progress.h> | 34 | /// #include <kodi/gui/dialogs/Progress.h> |
| 35 | /// | 35 | /// |
| 36 | /// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress; | 36 | /// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress; |
| 37 | /// progress->SetHeading("Test progress"); | 37 | /// progress->SetHeading("Test progress"); |
| 38 | /// progress->SetLine(1, "line 1"); | 38 | /// progress->SetLine(1, "line 1"); |
| 39 | /// progress->SetLine(2, "line 2"); | 39 | /// progress->SetLine(2, "line 2"); |
| 40 | /// progress->SetLine(3, "line 3"); | 40 | /// progress->SetLine(3, "line 3"); |
| 41 | /// progress->SetCanCancel(true); | 41 | /// progress->SetCanCancel(true); |
| 42 | /// progress->ShowProgressBar(true); | 42 | /// progress->ShowProgressBar(true); |
| 43 | /// progress->Open(); | 43 | /// progress->Open(); |
| 44 | /// for (unsigned int i = 0; i < 100; i += 10) | 44 | /// for (unsigned int i = 0; i < 100; i += 10) |
| 45 | /// { | 45 | /// { |
| 46 | /// progress->SetPercentage(i); | 46 | /// progress->SetPercentage(i); |
| 47 | /// sleep(1); | 47 | /// sleep(1); |
| 48 | /// } | 48 | /// } |
| 49 | /// delete progress; | 49 | /// delete progress; |
| 50 | /// ~~~~~~~~~~~~~ | 50 | /// ~~~~~~~~~~~~~ |
| 51 | /// | 51 | /// |
| 52 | class CProgress | 52 | class ATTRIBUTE_HIDDEN CProgress |
| 53 | { | ||
| 54 | public: | ||
| 55 | //========================================================================== | ||
| 56 | /// | ||
| 57 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 58 | /// @brief Construct a new dialog | ||
| 59 | /// | ||
| 60 | CProgress() | ||
| 61 | { | ||
| 62 | using namespace ::kodi::addon; | ||
| 63 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog( | ||
| 64 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 65 | if (!m_DialogHandle) | ||
| 66 | kodi::Log(ADDON_LOG_FATAL, | ||
| 67 | "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); | ||
| 68 | } | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 72 | /// | ||
| 73 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 74 | /// @brief Destructor | ||
| 75 | /// | ||
| 76 | ~CProgress() | ||
| 77 | { | ||
| 78 | using namespace ::kodi::addon; | ||
| 79 | if (m_DialogHandle) | ||
| 80 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog( | ||
| 81 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 82 | } | ||
| 83 | //-------------------------------------------------------------------------- | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// | ||
| 87 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 88 | /// @brief To open the dialog | ||
| 89 | /// | ||
| 90 | void Open() | ||
| 91 | { | ||
| 92 | using namespace ::kodi::addon; | ||
| 93 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open( | ||
| 94 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //========================================================================== | ||
| 99 | /// | ||
| 100 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 101 | /// @brief Set the heading title of dialog | ||
| 102 | /// | ||
| 103 | /// @param[in] heading Title string to use | ||
| 104 | /// | ||
| 105 | void SetHeading(const std::string& heading) | ||
| 106 | { | ||
| 107 | using namespace ::kodi::addon; | ||
| 108 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading( | ||
| 109 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | ||
| 110 | } | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | |||
| 113 | //========================================================================== | ||
| 114 | /// | ||
| 115 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 116 | /// @brief To set the line text field on dialog from 0 - 2 | ||
| 117 | /// | ||
| 118 | /// @param[in] iLine Line number | ||
| 119 | /// @param[in] line Text string | ||
| 120 | /// | ||
| 121 | void SetLine(unsigned int iLine, const std::string& line) | ||
| 122 | { | ||
| 123 | using namespace ::kodi::addon; | ||
| 124 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line( | ||
| 125 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | ||
| 126 | } | ||
| 127 | //-------------------------------------------------------------------------- | ||
| 128 | |||
| 129 | //========================================================================== | ||
| 130 | /// | ||
| 131 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 132 | /// @brief To enable and show cancel button on dialog | ||
| 133 | /// | ||
| 134 | /// @param[in] canCancel if true becomes it shown | ||
| 135 | /// | ||
| 136 | void SetCanCancel(bool canCancel) | ||
| 137 | { | ||
| 138 | using namespace ::kodi::addon; | ||
| 139 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel( | ||
| 140 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | ||
| 141 | } | ||
| 142 | //-------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //========================================================================== | ||
| 145 | /// | ||
| 146 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 147 | /// @brief To check dialog for clicked cancel button | ||
| 148 | /// | ||
| 149 | /// @return True if canceled | ||
| 150 | /// | ||
| 151 | bool IsCanceled() const | ||
| 152 | { | ||
| 153 | using namespace ::kodi::addon; | ||
| 154 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled( | ||
| 155 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 156 | } | ||
| 157 | //-------------------------------------------------------------------------- | ||
| 158 | |||
| 159 | //========================================================================== | ||
| 160 | /// | ||
| 161 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 162 | /// @brief Get the current progress position as percent | ||
| 163 | /// | ||
| 164 | /// @param[in] percentage Position to use from 0 to 100 | ||
| 165 | /// | ||
| 166 | void SetPercentage(int percentage) | ||
| 167 | { | ||
| 168 | using namespace ::kodi::addon; | ||
| 169 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage( | ||
| 170 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | //========================================================================== | ||
| 175 | /// | ||
| 176 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 177 | /// @brief To set the current progress position as percent | ||
| 178 | /// | ||
| 179 | /// @return Current Position used from 0 to 100 | ||
| 180 | /// | ||
| 181 | int GetPercentage() const | ||
| 182 | { | ||
| 183 | using namespace ::kodi::addon; | ||
| 184 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage( | ||
| 185 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 186 | } | ||
| 187 | //-------------------------------------------------------------------------- | ||
| 188 | |||
| 189 | //========================================================================== | ||
| 190 | /// | ||
| 191 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 192 | /// @brief To show or hide progress bar dialog | ||
| 193 | /// | ||
| 194 | /// @param[in] onOff If true becomes it shown | ||
| 195 | /// | ||
| 196 | void ShowProgressBar(bool onOff) | ||
| 197 | { | ||
| 198 | using namespace ::kodi::addon; | ||
| 199 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar( | ||
| 200 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | ||
| 201 | } | ||
| 202 | //-------------------------------------------------------------------------- | ||
| 203 | |||
| 204 | //========================================================================== | ||
| 205 | /// | ||
| 206 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 207 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | ||
| 208 | /// | ||
| 209 | /// @param[in] max Biggest usable position to use | ||
| 210 | /// | ||
| 211 | void SetProgressMax(int max) | ||
| 212 | { | ||
| 213 | using namespace ::kodi::addon; | ||
| 214 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max( | ||
| 215 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | ||
| 216 | } | ||
| 217 | //-------------------------------------------------------------------------- | ||
| 218 | |||
| 219 | //========================================================================== | ||
| 220 | /// | ||
| 221 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 222 | /// @brief To increase progress bar by defined step size until reach of maximum position | ||
| 223 | /// | ||
| 224 | /// @param[in] steps Step size to increase, default is 1 | ||
| 225 | /// | ||
| 226 | void SetProgressAdvance(int steps = 1) | ||
| 227 | { | ||
| 228 | using namespace ::kodi::addon; | ||
| 229 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance( | ||
| 230 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | ||
| 231 | } | ||
| 232 | //-------------------------------------------------------------------------- | ||
| 233 | |||
| 234 | //========================================================================== | ||
| 235 | /// | ||
| 236 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 237 | /// @brief To check progress was canceled on work | ||
| 238 | /// | ||
| 239 | /// @return True if aborted | ||
| 240 | /// | ||
| 241 | bool Abort() | ||
| 53 | { | 242 | { |
| 54 | public: | 243 | using namespace ::kodi::addon; |
| 55 | //========================================================================== | 244 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort( |
| 56 | /// | 245 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); |
| 57 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | 246 | } |
| 58 | /// @brief Construct a new dialog | 247 | //-------------------------------------------------------------------------- |
| 59 | /// | 248 | |
| 60 | CProgress() | 249 | private: |
| 61 | { | 250 | void* m_DialogHandle; |
| 62 | using namespace ::kodi::addon; | 251 | }; |
| 63 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 64 | if (!m_DialogHandle) | ||
| 65 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); | ||
| 66 | } | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 72 | /// @brief Destructor | ||
| 73 | /// | ||
| 74 | ~CProgress() | ||
| 75 | { | ||
| 76 | using namespace ::kodi::addon; | ||
| 77 | if (m_DialogHandle) | ||
| 78 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 79 | } | ||
| 80 | //-------------------------------------------------------------------------- | ||
| 81 | |||
| 82 | //========================================================================== | ||
| 83 | /// | ||
| 84 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 85 | /// @brief To open the dialog | ||
| 86 | /// | ||
| 87 | void Open() | ||
| 88 | { | ||
| 89 | using namespace ::kodi::addon; | ||
| 90 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 91 | } | ||
| 92 | //-------------------------------------------------------------------------- | ||
| 93 | |||
| 94 | //========================================================================== | ||
| 95 | /// | ||
| 96 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 97 | /// @brief Set the heading title of dialog | ||
| 98 | /// | ||
| 99 | /// @param[in] heading Title string to use | ||
| 100 | /// | ||
| 101 | void SetHeading(const std::string& heading) | ||
| 102 | { | ||
| 103 | using namespace ::kodi::addon; | ||
| 104 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | ||
| 105 | } | ||
| 106 | //-------------------------------------------------------------------------- | ||
| 107 | |||
| 108 | //========================================================================== | ||
| 109 | /// | ||
| 110 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 111 | /// @brief To set the line text field on dialog from 0 - 2 | ||
| 112 | /// | ||
| 113 | /// @param[in] iLine Line number | ||
| 114 | /// @param[in] line Text string | ||
| 115 | /// | ||
| 116 | void SetLine(unsigned int iLine, const std::string& line) | ||
| 117 | { | ||
| 118 | using namespace ::kodi::addon; | ||
| 119 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | ||
| 120 | } | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //========================================================================== | ||
| 124 | /// | ||
| 125 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 126 | /// @brief To enable and show cancel button on dialog | ||
| 127 | /// | ||
| 128 | /// @param[in] canCancel if true becomes it shown | ||
| 129 | /// | ||
| 130 | void SetCanCancel(bool canCancel) | ||
| 131 | { | ||
| 132 | using namespace ::kodi::addon; | ||
| 133 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | ||
| 134 | } | ||
| 135 | //-------------------------------------------------------------------------- | ||
| 136 | |||
| 137 | //========================================================================== | ||
| 138 | /// | ||
| 139 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 140 | /// @brief To check dialog for clicked cancel button | ||
| 141 | /// | ||
| 142 | /// @return True if canceled | ||
| 143 | /// | ||
| 144 | bool IsCanceled() const | ||
| 145 | { | ||
| 146 | using namespace ::kodi::addon; | ||
| 147 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 148 | } | ||
| 149 | //-------------------------------------------------------------------------- | ||
| 150 | |||
| 151 | //========================================================================== | ||
| 152 | /// | ||
| 153 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 154 | /// @brief Get the current progress position as percent | ||
| 155 | /// | ||
| 156 | /// @param[in] percentage Position to use from 0 to 100 | ||
| 157 | /// | ||
| 158 | void SetPercentage(int percentage) | ||
| 159 | { | ||
| 160 | using namespace ::kodi::addon; | ||
| 161 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 162 | } | ||
| 163 | //-------------------------------------------------------------------------- | ||
| 164 | |||
| 165 | //========================================================================== | ||
| 166 | /// | ||
| 167 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 168 | /// @brief To set the current progress position as percent | ||
| 169 | /// | ||
| 170 | /// @return Current Position used from 0 to 100 | ||
| 171 | /// | ||
| 172 | int GetPercentage() const | ||
| 173 | { | ||
| 174 | using namespace ::kodi::addon; | ||
| 175 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 176 | } | ||
| 177 | //-------------------------------------------------------------------------- | ||
| 178 | |||
| 179 | //========================================================================== | ||
| 180 | /// | ||
| 181 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 182 | /// @brief To show or hide progress bar dialog | ||
| 183 | /// | ||
| 184 | /// @param[in] onOff If true becomes it shown | ||
| 185 | /// | ||
| 186 | void ShowProgressBar(bool onOff) | ||
| 187 | { | ||
| 188 | using namespace ::kodi::addon; | ||
| 189 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | ||
| 190 | } | ||
| 191 | //-------------------------------------------------------------------------- | ||
| 192 | |||
| 193 | //========================================================================== | ||
| 194 | /// | ||
| 195 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 196 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | ||
| 197 | /// | ||
| 198 | /// @param[in] max Biggest usable position to use | ||
| 199 | /// | ||
| 200 | void SetProgressMax(int max) | ||
| 201 | { | ||
| 202 | using namespace ::kodi::addon; | ||
| 203 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | ||
| 204 | } | ||
| 205 | //-------------------------------------------------------------------------- | ||
| 206 | |||
| 207 | //========================================================================== | ||
| 208 | /// | ||
| 209 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 210 | /// @brief To increase progress bar by defined step size until reach of maximum position | ||
| 211 | /// | ||
| 212 | /// @param[in] steps Step size to increase, default is 1 | ||
| 213 | /// | ||
| 214 | void SetProgressAdvance(int steps=1) | ||
| 215 | { | ||
| 216 | using namespace ::kodi::addon; | ||
| 217 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | ||
| 218 | } | ||
| 219 | //-------------------------------------------------------------------------- | ||
| 220 | |||
| 221 | //========================================================================== | ||
| 222 | /// | ||
| 223 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 224 | /// @brief To check progress was canceled on work | ||
| 225 | /// | ||
| 226 | /// @return True if aborted | ||
| 227 | /// | ||
| 228 | bool Abort() | ||
| 229 | { | ||
| 230 | using namespace ::kodi::addon; | ||
| 231 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 232 | } | ||
| 233 | //-------------------------------------------------------------------------- | ||
| 234 | |||
| 235 | private: | ||
| 236 | void* m_DialogHandle; | ||
| 237 | }; | ||
| 238 | 252 | ||
| 239 | } /* namespace dialogs */ | 253 | } /* namespace dialogs */ |
| 240 | } /* namespace gui */ | 254 | } /* namespace gui */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h index ba0db1d..39a98fe 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h | |||
| @@ -104,16 +104,21 @@ namespace dialogs | |||
| 104 | /// fprintf(stderr, "Selected item is: %i\n", selected); | 104 | /// fprintf(stderr, "Selected item is: %i\n", selected); |
| 105 | /// ~~~~~~~~~~~~~ | 105 | /// ~~~~~~~~~~~~~ |
| 106 | /// | 106 | /// |
| 107 | inline int Show(const std::string& heading, const std::vector<std::string>& entries, int selected = -1, unsigned int autoclose = 0) | 107 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, |
| 108 | const std::vector<std::string>& entries, | ||
| 109 | int selected = -1, | ||
| 110 | unsigned int autoclose = 0) | ||
| 108 | { | 111 | { |
| 109 | using namespace ::kodi::addon; | 112 | using namespace ::kodi::addon; |
| 110 | unsigned int size = entries.size(); | 113 | unsigned int size = static_cast<unsigned int>(entries.size()); |
| 111 | const char** cEntries = (const char**)malloc(size*sizeof(const char**)); | 114 | const char** cEntries = (const char**)malloc(size * sizeof(const char**)); |
| 112 | for (unsigned int i = 0; i < size; ++i) | 115 | for (unsigned int i = 0; i < size; ++i) |
| 113 | { | 116 | { |
| 114 | cEntries[i] = entries[i].c_str(); | 117 | cEntries[i] = entries[i].c_str(); |
| 115 | } | 118 | } |
| 116 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose); | 119 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open( |
| 120 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, | ||
| 121 | autoclose); | ||
| 117 | free(cEntries); | 122 | free(cEntries); |
| 118 | return ret; | 123 | return ret; |
| 119 | } | 124 | } |
| @@ -159,10 +164,13 @@ namespace dialogs | |||
| 159 | /// fprintf(stderr, "Selected item is: %i\n", selected); | 164 | /// fprintf(stderr, "Selected item is: %i\n", selected); |
| 160 | /// ~~~~~~~~~~~~~ | 165 | /// ~~~~~~~~~~~~~ |
| 161 | /// | 166 | /// |
| 162 | inline int Show(const std::string& heading, std::vector<SSelectionEntry>& entries, int selected = -1, unsigned int autoclose = 0) | 167 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, |
| 168 | std::vector<SSelectionEntry>& entries, | ||
| 169 | int selected = -1, | ||
| 170 | unsigned int autoclose = 0) | ||
| 163 | { | 171 | { |
| 164 | using namespace ::kodi::addon; | 172 | using namespace ::kodi::addon; |
| 165 | unsigned int size = entries.size(); | 173 | unsigned int size = static_cast<unsigned int>(entries.size()); |
| 166 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char*))); | 174 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char*))); |
| 167 | for (unsigned int i = 0; i < size; ++i) | 175 | for (unsigned int i = 0; i < size; ++i) |
| 168 | { | 176 | { |
| @@ -224,10 +232,12 @@ namespace dialogs | |||
| 224 | /// } | 232 | /// } |
| 225 | /// ~~~~~~~~~~~~~ | 233 | /// ~~~~~~~~~~~~~ |
| 226 | /// | 234 | /// |
| 227 | inline bool ShowMultiSelect(const std::string& heading, std::vector<SSelectionEntry>& entries, int autoclose = 0) | 235 | inline bool ATTRIBUTE_HIDDEN ShowMultiSelect(const std::string& heading, |
| 236 | std::vector<SSelectionEntry>& entries, | ||
| 237 | int autoclose = 0) | ||
| 228 | { | 238 | { |
| 229 | using namespace ::kodi::addon; | 239 | using namespace ::kodi::addon; |
| 230 | unsigned int size = entries.size(); | 240 | unsigned int size = static_cast<unsigned int>(entries.size()); |
| 231 | const char** cEntryIDs = static_cast<const char**>(malloc(size*sizeof(const char*))); | 241 | const char** cEntryIDs = static_cast<const char**>(malloc(size*sizeof(const char*))); |
| 232 | const char** cEntryNames = static_cast<const char**>(malloc(size*sizeof(const char*))); | 242 | const char** cEntryNames = static_cast<const char**>(malloc(size*sizeof(const char*))); |
| 233 | bool* cEntriesSelected = static_cast<bool*>(malloc(size*sizeof(bool))); | 243 | bool* cEntriesSelected = static_cast<bool*>(malloc(size*sizeof(bool))); |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h index da38f7c..5c81837 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h | |||
| @@ -93,10 +93,11 @@ namespace dialogs | |||
| 93 | /// "interspersed renderings from classical composers.\n"); | 93 | /// "interspersed renderings from classical composers.\n"); |
| 94 | /// ~~~~~~~~~~~~~ | 94 | /// ~~~~~~~~~~~~~ |
| 95 | /// | 95 | /// |
| 96 | inline void Show(const std::string& heading, const std::string& text) | 96 | inline void ATTRIBUTE_HIDDEN Show(const std::string& heading, const std::string& text) |
| 97 | { | 97 | { |
| 98 | using namespace ::kodi::addon; | 98 | using namespace ::kodi::addon; |
| 99 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | 99 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open( |
| 100 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 100 | } | 101 | } |
| 101 | //-------------------------------------------------------------------------- | 102 | //-------------------------------------------------------------------------- |
| 102 | }; | 103 | }; |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h index c694bf5..67c2fc4 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h | |||
| @@ -73,14 +73,16 @@ namespace dialogs | |||
| 73 | /// canceled ? "canceled" : "not canceled"); | 73 | /// canceled ? "canceled" : "not canceled"); |
| 74 | /// ~~~~~~~~~~~~~ | 74 | /// ~~~~~~~~~~~~~ |
| 75 | /// | 75 | /// |
| 76 | inline bool ShowAndGetInput(const std::string& heading, const std::string& text, | 76 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, |
| 77 | bool& canceled, const std::string& noLabel = "", | 77 | const std::string& text, |
| 78 | const std::string& yesLabel = "") | 78 | bool& canceled, |
| 79 | const std::string& noLabel = "", | ||
| 80 | const std::string& yesLabel = "") | ||
| 79 | { | 81 | { |
| 80 | using namespace ::kodi::addon; | 82 | using namespace ::kodi::addon; |
| 81 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, | 83 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text( |
| 82 | heading.c_str(), text.c_str(), &canceled, | 84 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled, |
| 83 | noLabel.c_str(), yesLabel.c_str()); | 85 | noLabel.c_str(), yesLabel.c_str()); |
| 84 | } | 86 | } |
| 85 | //-------------------------------------------------------------------------- | 87 | //-------------------------------------------------------------------------- |
| 86 | 88 | ||
| @@ -115,9 +117,12 @@ namespace dialogs | |||
| 115 | /// ret ? "yes" : "no"); | 117 | /// ret ? "yes" : "no"); |
| 116 | /// ~~~~~~~~~~~~~ | 118 | /// ~~~~~~~~~~~~~ |
| 117 | /// | 119 | /// |
| 118 | inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, | 120 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, |
| 119 | const std::string& line2, const std::string& noLabel = "", | 121 | const std::string& line0, |
| 120 | const std::string& yesLabel = "") | 122 | const std::string& line1, |
| 123 | const std::string& line2, | ||
| 124 | const std::string& noLabel = "", | ||
| 125 | const std::string& yesLabel = "") | ||
| 121 | { | 126 | { |
| 122 | using namespace ::kodi::addon; | 127 | using namespace ::kodi::addon; |
| 123 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | 128 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, |
| @@ -161,9 +166,13 @@ namespace dialogs | |||
| 161 | /// canceled ? "canceled" : "not canceled"); | 166 | /// canceled ? "canceled" : "not canceled"); |
| 162 | /// ~~~~~~~~~~~~~ | 167 | /// ~~~~~~~~~~~~~ |
| 163 | /// | 168 | /// |
| 164 | inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, | 169 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, |
| 165 | const std::string& line2, bool& canceled, const std::string& noLabel = "", | 170 | const std::string& line0, |
| 166 | const std::string& yesLabel = "") | 171 | const std::string& line1, |
| 172 | const std::string& line2, | ||
| 173 | bool& canceled, | ||
| 174 | const std::string& noLabel = "", | ||
| 175 | const std::string& yesLabel = "") | ||
| 167 | { | 176 | { |
| 168 | using namespace ::kodi::addon; | 177 | using namespace ::kodi::addon; |
| 169 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, | 178 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt new file mode 100644 index 0000000..a9ab70c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | set(HEADERS GL.h | ||
| 2 | GLonDX.h | ||
| 3 | Shader.h) | ||
| 4 | |||
| 5 | if(NOT ENABLE_STATIC_LIBS) | ||
| 6 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_gl) | ||
| 7 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h new file mode 100644 index 0000000..943c7d0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h | |||
| @@ -0,0 +1,111 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 | //============================================================================== | ||
| 12 | /// | ||
| 13 | /// \defgroup cpp_kodi_gui_gl OpenGL helpers | ||
| 14 | /// \ingroup cpp_kodi_gui | ||
| 15 | /// \brief Auxiliary functions for Open GL | ||
| 16 | /// | ||
| 17 | /// This group includes help for definitions, functions, and classes for | ||
| 18 | /// OpenGL. | ||
| 19 | /// | ||
| 20 | /// To use OpenGL for your system, add the \ref GL.h "#include <kodi/gui/gl/GL.h>". | ||
| 21 | /// | ||
| 22 | /// | ||
| 23 | ///----------------------------------------------------------------------------- | ||
| 24 | /// | ||
| 25 | /// The \ref HAS_GL is declared if Open GL is required and \ref HAS_GLES if Open GL | ||
| 26 | /// Embedded Systems (ES) is required, with ES the version is additionally given | ||
| 27 | /// in the definition, this can be "2" or "3". | ||
| 28 | /// | ||
| 29 | /// | ||
| 30 | ///----------------------------------------------------------------------------- | ||
| 31 | /// | ||
| 32 | /// Following \ref GL_TYPE_STRING define can be used, for example, to manage | ||
| 33 | /// different folders for GL and GLES and make the selection easier. | ||
| 34 | /// This are on OpenGL <b>"GL"</b> and on Open GL|ES <b>"GLES"</b>. | ||
| 35 | /// | ||
| 36 | /// **Example:** | ||
| 37 | /// ~~~~~~~~~~~~~~~~~{.cpp} | ||
| 38 | /// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); | ||
| 39 | /// ~~~~~~~~~~~~~~~~~ | ||
| 40 | /// | ||
| 41 | /// | ||
| 42 | ///---------------------------------------------------------------------------- | ||
| 43 | /// | ||
| 44 | /// In addition, \ref BUFFER_OFFSET is declared in it which can be used to give an | ||
| 45 | /// offset on the array to GL. | ||
| 46 | /// | ||
| 47 | /// **Example:** | ||
| 48 | /// ~~~~~~~~~~~~~~~~~{.cpp} | ||
| 49 | /// const struct PackedVertex { | ||
| 50 | /// float position[3]; // Position x, y, z | ||
| 51 | /// float color[4]; // Color r, g, b, a | ||
| 52 | /// } vertices[3] = { | ||
| 53 | /// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }, | ||
| 54 | /// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, | ||
| 55 | /// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } } | ||
| 56 | /// }; | ||
| 57 | /// | ||
| 58 | /// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position))); | ||
| 59 | /// glEnableVertexAttribArray(m_aPosition); | ||
| 60 | /// | ||
| 61 | /// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color))); | ||
| 62 | /// glEnableVertexAttribArray(m_aColor); | ||
| 63 | /// ~~~~~~~~~~~~~~~~~ | ||
| 64 | |||
| 65 | #if HAS_GL | ||
| 66 | #define GL_TYPE_STRING "GL" | ||
| 67 | // always define GL_GLEXT_PROTOTYPES before include gl headers | ||
| 68 | #if !defined(GL_GLEXT_PROTOTYPES) | ||
| 69 | #define GL_GLEXT_PROTOTYPES | ||
| 70 | #endif | ||
| 71 | #if defined(TARGET_LINUX) | ||
| 72 | #include <GL/gl.h> | ||
| 73 | #include <GL/glext.h> | ||
| 74 | #elif defined(TARGET_FREEBSD) | ||
| 75 | #include <GL/gl.h> | ||
| 76 | #elif defined(TARGET_DARWIN) | ||
| 77 | #include <OpenGL/gl3.h> | ||
| 78 | #include <OpenGL/gl3ext.h> | ||
| 79 | #elif defined(WIN32) | ||
| 80 | #error Use of GL under Windows is not possible | ||
| 81 | #endif | ||
| 82 | #elif HAS_GLES >= 2 | ||
| 83 | #define GL_TYPE_STRING "GLES" | ||
| 84 | #if defined(WIN32) | ||
| 85 | #if defined(HAS_ANGLE) | ||
| 86 | #include <angle_gl.h> | ||
| 87 | #else | ||
| 88 | #error Use of GLES only be available under Windows by the use of angle | ||
| 89 | #endif | ||
| 90 | #elif defined(TARGET_DARWIN) | ||
| 91 | #if HAS_GLES == 3 | ||
| 92 | #include <OpenGLES/ES3/gl.h> | ||
| 93 | #include <OpenGLES/ES3/glext.h> | ||
| 94 | #else | ||
| 95 | #include <OpenGLES/ES2/gl.h> | ||
| 96 | #include <OpenGLES/ES2/glext.h> | ||
| 97 | #endif | ||
| 98 | #else | ||
| 99 | #if HAS_GLES == 3 | ||
| 100 | #include <GLES3/gl3.h> | ||
| 101 | #include <GLES3/gl3ext.h> | ||
| 102 | #else | ||
| 103 | #include <GLES2/gl2.h> | ||
| 104 | #include <GLES2/gl2ext.h> | ||
| 105 | #endif | ||
| 106 | #endif | ||
| 107 | #endif | ||
| 108 | |||
| 109 | #ifndef BUFFER_OFFSET | ||
| 110 | #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) | ||
| 111 | #endif | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h new file mode 100644 index 0000000..7a6a0a1 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h | |||
| @@ -0,0 +1,369 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 <angle_gl.h> | ||
| 12 | #include <d3d11.h> | ||
| 13 | #include <d3dcompiler.h> | ||
| 14 | #include <EGL/egl.h> | ||
| 15 | #include <EGL/eglext.h> | ||
| 16 | #include <kodi/AddonBase.h> | ||
| 17 | #include <kodi/gui/General.h> | ||
| 18 | #include <wrl/client.h> | ||
| 19 | |||
| 20 | #pragma comment( lib, "d3dcompiler.lib" ) | ||
| 21 | #ifndef GL_CLIENT_VERSION | ||
| 22 | #define GL_CLIENT_VERSION 3 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | namespace gl | ||
| 30 | { | ||
| 31 | |||
| 32 | class ATTRIBUTE_HIDDEN CGLonDX : public kodi::gui::IRenderHelper | ||
| 33 | { | ||
| 34 | public: | ||
| 35 | explicit CGLonDX() : m_pContext(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext())) {} | ||
| 36 | ~CGLonDX() override { destruct(); } | ||
| 37 | |||
| 38 | bool Init() override | ||
| 39 | { | ||
| 40 | EGLint egl_display_attrs[] = | ||
| 41 | { | ||
| 42 | EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, | ||
| 43 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, | ||
| 44 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, | ||
| 45 | EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE, | ||
| 46 | EGL_NONE | ||
| 47 | }; | ||
| 48 | EGLint egl_config_attrs[] = | ||
| 49 | { | ||
| 50 | EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, | ||
| 51 | EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE, | ||
| 52 | EGL_RENDERABLE_TYPE, GL_CLIENT_VERSION == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, | ||
| 53 | EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, | ||
| 54 | EGL_NONE | ||
| 55 | }; | ||
| 56 | EGLint egl_context_attrs[] = | ||
| 57 | { | ||
| 58 | EGL_CONTEXT_CLIENT_VERSION, GL_CLIENT_VERSION, EGL_NONE | ||
| 59 | }; | ||
| 60 | |||
| 61 | m_eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, egl_display_attrs); | ||
| 62 | if (m_eglDisplay == EGL_NO_DISPLAY) | ||
| 63 | { | ||
| 64 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL display (%s)", eglGetErrorString()); | ||
| 65 | return false; | ||
| 66 | } | ||
| 67 | |||
| 68 | if (eglInitialize(m_eglDisplay, nullptr, nullptr) != EGL_TRUE) | ||
| 69 | { | ||
| 70 | Log(ADDON_LOG_ERROR, "GLonDX: unable to init EGL display (%s)", eglGetErrorString()); | ||
| 71 | return false; | ||
| 72 | } | ||
| 73 | |||
| 74 | EGLint numConfigs = 0; | ||
| 75 | if (eglChooseConfig(m_eglDisplay, egl_config_attrs, &m_eglConfig, 1, &numConfigs) != EGL_TRUE || numConfigs == 0) | ||
| 76 | { | ||
| 77 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL config (%s)", eglGetErrorString()); | ||
| 78 | return false; | ||
| 79 | } | ||
| 80 | |||
| 81 | m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, egl_context_attrs); | ||
| 82 | if (m_eglContext == EGL_NO_CONTEXT) | ||
| 83 | { | ||
| 84 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL context (%s)", eglGetErrorString()); | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | |||
| 88 | if (!createD3DResources()) | ||
| 89 | return false; | ||
| 90 | |||
| 91 | if (eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext) != EGL_TRUE) | ||
| 92 | { | ||
| 93 | Log(ADDON_LOG_ERROR, "GLonDX: unable to make current EGL (%s)", eglGetErrorString()); | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | return true; | ||
| 97 | } | ||
| 98 | |||
| 99 | void CheckGL(ID3D11DeviceContext* device) | ||
| 100 | { | ||
| 101 | if (m_pContext != device) | ||
| 102 | { | ||
| 103 | m_pSRView = nullptr; | ||
| 104 | m_pVShader = nullptr; | ||
| 105 | m_pPShader = nullptr; | ||
| 106 | m_pContext = device; | ||
| 107 | |||
| 108 | if (m_eglBuffer != EGL_NO_SURFACE) | ||
| 109 | { | ||
| 110 | eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||
| 111 | eglDestroySurface(m_eglDisplay, m_eglBuffer); | ||
| 112 | m_eglBuffer = EGL_NO_SURFACE; | ||
| 113 | } | ||
| 114 | |||
| 115 | // create new resources | ||
| 116 | if (!createD3DResources()) | ||
| 117 | return; | ||
| 118 | |||
| 119 | eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | void Begin() override | ||
| 124 | { | ||
| 125 | // confirm on begin D3D context is correct | ||
| 126 | CheckGL(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext())); | ||
| 127 | |||
| 128 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | ||
| 129 | glClear(GL_COLOR_BUFFER_BIT); | ||
| 130 | } | ||
| 131 | |||
| 132 | void End() override | ||
| 133 | { | ||
| 134 | glFlush(); | ||
| 135 | |||
| 136 | // set our primitive shaders | ||
| 137 | m_pContext->VSSetShader(m_pVShader.Get(), nullptr, 0); | ||
| 138 | m_pContext->PSSetShader(m_pPShader.Get(), nullptr, 0); | ||
| 139 | m_pContext->PSSetShaderResources(0, 1, m_pSRView.GetAddressOf()); | ||
| 140 | // draw texture | ||
| 141 | m_pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); | ||
| 142 | m_pContext->IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr); | ||
| 143 | m_pContext->IASetInputLayout(nullptr); | ||
| 144 | m_pContext->Draw(4, 0); | ||
| 145 | // unset shaders | ||
| 146 | m_pContext->PSSetShader(nullptr, nullptr, 0); | ||
| 147 | m_pContext->VSSetShader(nullptr, nullptr, 0); | ||
| 148 | // unbind our view | ||
| 149 | ID3D11ShaderResourceView* views[1] = {}; | ||
| 150 | m_pContext->PSSetShaderResources(0, 1, views); | ||
| 151 | } | ||
| 152 | |||
| 153 | private: | ||
| 154 | enum ShaderType | ||
| 155 | { | ||
| 156 | VERTEX_SHADER, | ||
| 157 | PIXEL_SHADER | ||
| 158 | }; | ||
| 159 | |||
| 160 | bool createD3DResources() | ||
| 161 | { | ||
| 162 | HANDLE sharedHandle; | ||
| 163 | Microsoft::WRL::ComPtr<ID3D11Device> pDevice; | ||
| 164 | Microsoft::WRL::ComPtr<ID3D11RenderTargetView> pRTView; | ||
| 165 | Microsoft::WRL::ComPtr<ID3D11Resource> pRTResource; | ||
| 166 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pRTTexture; | ||
| 167 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pOffScreenTexture; | ||
| 168 | Microsoft::WRL::ComPtr<IDXGIResource> dxgiResource; | ||
| 169 | |||
| 170 | m_pContext->GetDevice(&pDevice); | ||
| 171 | m_pContext->OMGetRenderTargets(1, &pRTView, nullptr); | ||
| 172 | if (!pRTView) | ||
| 173 | return false; | ||
| 174 | |||
| 175 | pRTView->GetResource(&pRTResource); | ||
| 176 | if (FAILED(pRTResource.As(&pRTTexture))) | ||
| 177 | return false; | ||
| 178 | |||
| 179 | D3D11_TEXTURE2D_DESC texDesc; | ||
| 180 | pRTTexture->GetDesc(&texDesc); | ||
| 181 | texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; | ||
| 182 | texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; | ||
| 183 | texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; | ||
| 184 | if (FAILED(pDevice->CreateTexture2D(&texDesc, nullptr, &pOffScreenTexture))) | ||
| 185 | { | ||
| 186 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create intermediate texture"); | ||
| 187 | return false; | ||
| 188 | } | ||
| 189 | |||
| 190 | CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pOffScreenTexture.Get(), D3D11_SRV_DIMENSION_TEXTURE2D); | ||
| 191 | if (FAILED(pDevice->CreateShaderResourceView(pOffScreenTexture.Get(), &srvDesc, &m_pSRView))) | ||
| 192 | { | ||
| 193 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create shader view"); | ||
| 194 | return false; | ||
| 195 | } | ||
| 196 | |||
| 197 | if (FAILED(pOffScreenTexture.As(&dxgiResource)) || | ||
| 198 | FAILED(dxgiResource->GetSharedHandle(&sharedHandle))) | ||
| 199 | { | ||
| 200 | Log(ADDON_LOG_ERROR, "GLonDX: unable get shared handle for texture"); | ||
| 201 | return false; | ||
| 202 | } | ||
| 203 | |||
| 204 | // initiate simple shaders | ||
| 205 | if (FAILED(d3dCreateShader(VERTEX_SHADER, vs_out_shader_text, &m_pVShader))) | ||
| 206 | { | ||
| 207 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create vertex shader view"); | ||
| 208 | return false; | ||
| 209 | } | ||
| 210 | |||
| 211 | if (FAILED(d3dCreateShader(PIXEL_SHADER, ps_out_shader_text, &m_pPShader))) | ||
| 212 | { | ||
| 213 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create pixel shader view"); | ||
| 214 | return false; | ||
| 215 | } | ||
| 216 | |||
| 217 | // create EGL buffer from D3D shared texture | ||
| 218 | EGLint egl_buffer_attrs[] = | ||
| 219 | { | ||
| 220 | EGL_WIDTH, static_cast<EGLint>(texDesc.Width), | ||
| 221 | EGL_HEIGHT, static_cast<EGLint>(texDesc.Height), | ||
| 222 | EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, | ||
| 223 | EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, | ||
| 224 | EGL_NONE | ||
| 225 | }; | ||
| 226 | |||
| 227 | m_eglBuffer = eglCreatePbufferFromClientBuffer(m_eglDisplay, | ||
| 228 | EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, | ||
| 229 | sharedHandle, m_eglConfig, egl_buffer_attrs); | ||
| 230 | |||
| 231 | if (m_eglBuffer == EGL_NO_SURFACE) | ||
| 232 | { | ||
| 233 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL buffer (%s)", eglGetErrorString()); | ||
| 234 | return false; | ||
| 235 | } | ||
| 236 | return true; | ||
| 237 | } | ||
| 238 | |||
| 239 | HRESULT d3dCreateShader(ShaderType shaderType, const std::string& source, IUnknown** ppShader) const | ||
| 240 | { | ||
| 241 | Microsoft::WRL::ComPtr<ID3DBlob> pBlob; | ||
| 242 | Microsoft::WRL::ComPtr<ID3DBlob> pErrors; | ||
| 243 | |||
| 244 | auto hr = D3DCompile(source.c_str(), source.length(), nullptr, nullptr, nullptr, "main", | ||
| 245 | shaderType == PIXEL_SHADER ? "ps_4_0" : "vs_4_0", 0, 0, &pBlob, &pErrors); | ||
| 246 | |||
| 247 | if (SUCCEEDED(hr)) | ||
| 248 | { | ||
| 249 | Microsoft::WRL::ComPtr<ID3D11Device> pDevice; | ||
| 250 | m_pContext->GetDevice(&pDevice); | ||
| 251 | |||
| 252 | if (shaderType == PIXEL_SHADER) | ||
| 253 | { | ||
| 254 | hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, | ||
| 255 | reinterpret_cast<ID3D11PixelShader**>(ppShader)); | ||
| 256 | } | ||
| 257 | else | ||
| 258 | { | ||
| 259 | hr = pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, | ||
| 260 | reinterpret_cast<ID3D11VertexShader**>(ppShader)); | ||
| 261 | } | ||
| 262 | |||
| 263 | if (FAILED(hr)) | ||
| 264 | { | ||
| 265 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create %s shader", | ||
| 266 | shaderType == PIXEL_SHADER ? "pixel" : "vertex"); | ||
| 267 | } | ||
| 268 | } | ||
| 269 | else | ||
| 270 | { | ||
| 271 | Log(ADDON_LOG_ERROR, "GLonDX: unable to compile shader (%s)", pErrors->GetBufferPointer()); | ||
| 272 | } | ||
| 273 | return hr; | ||
| 274 | } | ||
| 275 | |||
| 276 | static const char* eglGetErrorString() | ||
| 277 | { | ||
| 278 | #define CASE_STR( value ) case value: return #value | ||
| 279 | switch (eglGetError()) | ||
| 280 | { | ||
| 281 | CASE_STR(EGL_SUCCESS); | ||
| 282 | CASE_STR(EGL_NOT_INITIALIZED); | ||
| 283 | CASE_STR(EGL_BAD_ACCESS); | ||
| 284 | CASE_STR(EGL_BAD_ALLOC); | ||
| 285 | CASE_STR(EGL_BAD_ATTRIBUTE); | ||
| 286 | CASE_STR(EGL_BAD_CONTEXT); | ||
| 287 | CASE_STR(EGL_BAD_CONFIG); | ||
| 288 | CASE_STR(EGL_BAD_CURRENT_SURFACE); | ||
| 289 | CASE_STR(EGL_BAD_DISPLAY); | ||
| 290 | CASE_STR(EGL_BAD_SURFACE); | ||
| 291 | CASE_STR(EGL_BAD_MATCH); | ||
| 292 | CASE_STR(EGL_BAD_PARAMETER); | ||
| 293 | CASE_STR(EGL_BAD_NATIVE_PIXMAP); | ||
| 294 | CASE_STR(EGL_BAD_NATIVE_WINDOW); | ||
| 295 | CASE_STR(EGL_CONTEXT_LOST); | ||
| 296 | default: | ||
| 297 | return "Unknown"; | ||
| 298 | } | ||
| 299 | #undef CASE_STR | ||
| 300 | } | ||
| 301 | |||
| 302 | void destruct() | ||
| 303 | { | ||
| 304 | if (m_eglDisplay != EGL_NO_DISPLAY) | ||
| 305 | { | ||
| 306 | eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||
| 307 | |||
| 308 | if (m_eglBuffer != EGL_NO_SURFACE) | ||
| 309 | { | ||
| 310 | eglDestroySurface(m_eglDisplay, m_eglBuffer); | ||
| 311 | m_eglBuffer = EGL_NO_SURFACE; | ||
| 312 | } | ||
| 313 | |||
| 314 | if (m_eglContext != EGL_NO_CONTEXT) | ||
| 315 | { | ||
| 316 | eglDestroyContext(m_eglDisplay, m_eglContext); | ||
| 317 | m_eglContext = EGL_NO_CONTEXT; | ||
| 318 | } | ||
| 319 | |||
| 320 | eglTerminate(m_eglDisplay); | ||
| 321 | m_eglDisplay = EGL_NO_DISPLAY; | ||
| 322 | } | ||
| 323 | |||
| 324 | m_pSRView = nullptr; | ||
| 325 | m_pVShader = nullptr; | ||
| 326 | m_pPShader = nullptr; | ||
| 327 | m_pContext = nullptr; | ||
| 328 | } | ||
| 329 | |||
| 330 | EGLConfig m_eglConfig = EGL_NO_CONFIG_KHR; | ||
| 331 | EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; | ||
| 332 | EGLContext m_eglContext = EGL_NO_CONTEXT; | ||
| 333 | EGLSurface m_eglBuffer = EGL_NO_SURFACE; | ||
| 334 | |||
| 335 | ID3D11DeviceContext* m_pContext = nullptr; // don't hold context | ||
| 336 | Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_pSRView = nullptr; | ||
| 337 | Microsoft::WRL::ComPtr<ID3D11VertexShader> m_pVShader = nullptr; | ||
| 338 | Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pPShader = nullptr; | ||
| 339 | |||
| 340 | #define TO_STRING(...) #__VA_ARGS__ | ||
| 341 | std::string vs_out_shader_text = TO_STRING( | ||
| 342 | void main(uint id : SV_VertexId, out float2 tex : TEXCOORD0, out float4 pos : SV_POSITION) | ||
| 343 | { | ||
| 344 | tex = float2(id % 2, (id % 4) >> 1); | ||
| 345 | pos = float4((tex.x - 0.5f) * 2, -(tex.y - 0.5f) * 2, 0, 1); | ||
| 346 | }); | ||
| 347 | |||
| 348 | std::string ps_out_shader_text = TO_STRING( | ||
| 349 | Texture2D texMain : register(t0); | ||
| 350 | SamplerState Sampler | ||
| 351 | { | ||
| 352 | Filter = MIN_MAG_MIP_LINEAR; | ||
| 353 | AddressU = CLAMP; | ||
| 354 | AddressV = CLAMP; | ||
| 355 | Comparison = NEVER; | ||
| 356 | }; | ||
| 357 | |||
| 358 | float4 main(in float2 tex : TEXCOORD0) : SV_TARGET | ||
| 359 | { | ||
| 360 | return texMain.Sample(Sampler, tex); | ||
| 361 | }); | ||
| 362 | #undef TO_STRING | ||
| 363 | }; /* class CGLonDX */ | ||
| 364 | |||
| 365 | } /* namespace gl */ | ||
| 366 | |||
| 367 | using CRenderHelper = gl::CGLonDX; | ||
| 368 | } /* namespace gui */ | ||
| 369 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h new file mode 100644 index 0000000..209f274 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h | |||
| @@ -0,0 +1,594 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 "GL.h" | ||
| 12 | |||
| 13 | #include <stdio.h> | ||
| 14 | #include <vector> | ||
| 15 | #include <string> | ||
| 16 | |||
| 17 | #include <kodi/AddonBase.h> | ||
| 18 | #include <kodi/Filesystem.h> | ||
| 19 | |||
| 20 | #define LOG_SIZE 1024 | ||
| 21 | #define GLchar char | ||
| 22 | |||
| 23 | namespace kodi | ||
| 24 | { | ||
| 25 | namespace gui | ||
| 26 | { | ||
| 27 | namespace gl | ||
| 28 | { | ||
| 29 | |||
| 30 | //======================================================================== | ||
| 31 | /// CShader - base class | ||
| 32 | class ATTRIBUTE_HIDDEN CShader | ||
| 33 | { | ||
| 34 | public: | ||
| 35 | CShader() = default; | ||
| 36 | virtual ~CShader() = default; | ||
| 37 | virtual bool Compile(const std::string& extraBegin = "", | ||
| 38 | const std::string& extraEnd = "") = 0; | ||
| 39 | virtual void Free() = 0; | ||
| 40 | virtual GLuint Handle() = 0; | ||
| 41 | |||
| 42 | bool LoadSource(const std::string& file) | ||
| 43 | { | ||
| 44 | char buffer[16384]; | ||
| 45 | |||
| 46 | kodi::vfs::CFile source; | ||
| 47 | if (!source.OpenFile(file)) | ||
| 48 | { | ||
| 49 | kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__, file.c_str()); | ||
| 50 | return false; | ||
| 51 | } | ||
| 52 | size_t len = source.Read(buffer, sizeof(buffer)); | ||
| 53 | m_source.assign(buffer); | ||
| 54 | m_source[len] = 0; | ||
| 55 | source.Close(); | ||
| 56 | return true; | ||
| 57 | } | ||
| 58 | |||
| 59 | bool OK() const { return m_compiled; } | ||
| 60 | |||
| 61 | protected: | ||
| 62 | std::string m_source; | ||
| 63 | std::string m_lastLog; | ||
| 64 | bool m_compiled = false; | ||
| 65 | }; | ||
| 66 | //------------------------------------------------------------------------ | ||
| 67 | |||
| 68 | //======================================================================== | ||
| 69 | /// CVertexShader | ||
| 70 | class ATTRIBUTE_HIDDEN CVertexShader : public CShader | ||
| 71 | { | ||
| 72 | public: | ||
| 73 | CVertexShader() = default; | ||
| 74 | ~CVertexShader() override { Free(); } | ||
| 75 | |||
| 76 | void Free() override | ||
| 77 | { | ||
| 78 | if (m_vertexShader) | ||
| 79 | glDeleteShader(m_vertexShader); | ||
| 80 | m_vertexShader = 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | bool Compile(const std::string& extraBegin = "", | ||
| 84 | const std::string& extraEnd = "") override | ||
| 85 | { | ||
| 86 | GLint params[4]; | ||
| 87 | |||
| 88 | Free(); | ||
| 89 | |||
| 90 | m_vertexShader = glCreateShader(GL_VERTEX_SHADER); | ||
| 91 | |||
| 92 | GLsizei count = 0; | ||
| 93 | const char *sources[3]; | ||
| 94 | if (!extraBegin.empty()) | ||
| 95 | sources[count++] = extraBegin.c_str(); | ||
| 96 | if (!m_source.empty()) | ||
| 97 | sources[count++] = m_source.c_str(); | ||
| 98 | if (!extraEnd.empty()) | ||
| 99 | sources[count++] = extraEnd.c_str(); | ||
| 100 | |||
| 101 | glShaderSource(m_vertexShader, count, sources, nullptr); | ||
| 102 | glCompileShader(m_vertexShader); | ||
| 103 | glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params); | ||
| 104 | if (params[0] != GL_TRUE) | ||
| 105 | { | ||
| 106 | GLchar log[LOG_SIZE]; | ||
| 107 | glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); | ||
| 108 | kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); | ||
| 109 | fprintf(stderr, "CVertexShader::%s: %s\n", __FUNCTION__, log); | ||
| 110 | m_lastLog = log; | ||
| 111 | m_compiled = false; | ||
| 112 | } | ||
| 113 | else | ||
| 114 | { | ||
| 115 | GLchar log[LOG_SIZE]; | ||
| 116 | glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); | ||
| 117 | m_lastLog = log; | ||
| 118 | m_compiled = true; | ||
| 119 | } | ||
| 120 | return m_compiled; | ||
| 121 | } | ||
| 122 | |||
| 123 | GLuint Handle() override { return m_vertexShader; } | ||
| 124 | |||
| 125 | protected: | ||
| 126 | GLuint m_vertexShader = 0; | ||
| 127 | }; | ||
| 128 | //------------------------------------------------------------------------ | ||
| 129 | |||
| 130 | //======================================================================== | ||
| 131 | /// CPixelShader | ||
| 132 | class ATTRIBUTE_HIDDEN CPixelShader : public CShader | ||
| 133 | { | ||
| 134 | public: | ||
| 135 | CPixelShader() = default; | ||
| 136 | ~CPixelShader() { Free(); } | ||
| 137 | void Free() override | ||
| 138 | { | ||
| 139 | if (m_pixelShader) | ||
| 140 | glDeleteShader(m_pixelShader); | ||
| 141 | m_pixelShader = 0; | ||
| 142 | } | ||
| 143 | |||
| 144 | bool Compile(const std::string& extraBegin = "", | ||
| 145 | const std::string& extraEnd = "") override | ||
| 146 | { | ||
| 147 | GLint params[4]; | ||
| 148 | |||
| 149 | Free(); | ||
| 150 | |||
| 151 | m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); | ||
| 152 | |||
| 153 | GLsizei count = 0; | ||
| 154 | const char *sources[3]; | ||
| 155 | if (!extraBegin.empty()) | ||
| 156 | sources[count++] = extraBegin.c_str(); | ||
| 157 | if (!m_source.empty()) | ||
| 158 | sources[count++] = m_source.c_str(); | ||
| 159 | if (!extraEnd.empty()) | ||
| 160 | sources[count++] = extraEnd.c_str(); | ||
| 161 | |||
| 162 | glShaderSource(m_pixelShader, count, sources, 0); | ||
| 163 | glCompileShader(m_pixelShader); | ||
| 164 | glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params); | ||
| 165 | if (params[0] != GL_TRUE) | ||
| 166 | { | ||
| 167 | GLchar log[LOG_SIZE]; | ||
| 168 | glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); | ||
| 169 | kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); | ||
| 170 | fprintf(stderr, "CPixelShader::%s: %s\n", __FUNCTION__, log); | ||
| 171 | m_lastLog = log; | ||
| 172 | m_compiled = false; | ||
| 173 | } | ||
| 174 | else | ||
| 175 | { | ||
| 176 | GLchar log[LOG_SIZE]; | ||
| 177 | glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); | ||
| 178 | m_lastLog = log; | ||
| 179 | m_compiled = true; | ||
| 180 | } | ||
| 181 | return m_compiled; | ||
| 182 | } | ||
| 183 | |||
| 184 | GLuint Handle() override { return m_pixelShader; } | ||
| 185 | |||
| 186 | protected: | ||
| 187 | GLuint m_pixelShader = 0; | ||
| 188 | }; | ||
| 189 | //------------------------------------------------------------------------ | ||
| 190 | |||
| 191 | //============================================================================ | ||
| 192 | /// | ||
| 193 | /// \defgroup cpp_kodi_gui_gl_CShaderProgram GL Shader Program | ||
| 194 | /// \ingroup cpp_kodi_gui_gl | ||
| 195 | /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram } | ||
| 196 | /// **Class to manage an OpenGL shader program** | ||
| 197 | /// | ||
| 198 | /// With this class the used GL shader code can be defined on the GPU and | ||
| 199 | /// its variables can be managed between CPU and GPU. | ||
| 200 | /// | ||
| 201 | /// It has the header \ref Shader.h "#include <kodi/gui/gl/Shader.h>" | ||
| 202 | /// be included to enjoy it. | ||
| 203 | /// | ||
| 204 | /// ---------------------------------------------------------------------------- | ||
| 205 | /// | ||
| 206 | /// <b>Example:</b> | ||
| 207 | /// | ||
| 208 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 209 | /// | ||
| 210 | /// #include <kodi/gui/gl/Shader.h> | ||
| 211 | /// ... | ||
| 212 | /// | ||
| 213 | /// class ATTRIBUTE_HIDDEN CExample | ||
| 214 | /// : ..., | ||
| 215 | /// public kodi::gui::gl::CShaderProgram | ||
| 216 | /// { | ||
| 217 | /// public: | ||
| 218 | /// CExample() = default; | ||
| 219 | /// | ||
| 220 | /// bool Start(); | ||
| 221 | /// void Render(); | ||
| 222 | /// | ||
| 223 | /// // override functions for kodi::gui::gl::CShaderProgram | ||
| 224 | /// void OnCompiledAndLinked() override; | ||
| 225 | /// bool OnEnabled() override; | ||
| 226 | /// | ||
| 227 | /// private: | ||
| 228 | /// ... | ||
| 229 | /// GLint m_aPosition = -1; | ||
| 230 | /// GLint m_aColor = -1; | ||
| 231 | /// }; | ||
| 232 | /// | ||
| 233 | /// bool CExample::Start() | ||
| 234 | /// { | ||
| 235 | /// // Define shaders and load | ||
| 236 | /// std::string fraqShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.frag"); | ||
| 237 | /// std::string vertShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.vert"); | ||
| 238 | /// if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink()) | ||
| 239 | /// return false; | ||
| 240 | /// | ||
| 241 | /// ... | ||
| 242 | /// return true; | ||
| 243 | /// } | ||
| 244 | /// | ||
| 245 | /// ... | ||
| 246 | /// | ||
| 247 | /// void CExample::Render() | ||
| 248 | /// { | ||
| 249 | /// ... | ||
| 250 | /// | ||
| 251 | /// EnableShader(); | ||
| 252 | /// ... | ||
| 253 | /// DO WORK | ||
| 254 | /// ... | ||
| 255 | /// DisableShader(); | ||
| 256 | /// } | ||
| 257 | /// | ||
| 258 | /// void CExample::OnCompiledAndLinked() | ||
| 259 | /// { | ||
| 260 | /// ... | ||
| 261 | /// DO YOUR WORK HERE FOR WHAT IS ONE TIME REQUIRED DURING COMPILE OF SHADER, E.G.: | ||
| 262 | /// | ||
| 263 | /// m_aPosition = glGetAttribLocation(ProgramHandle(), "a_position"); | ||
| 264 | /// m_aColor = glGetAttribLocation(ProgramHandle(), "a_color"); | ||
| 265 | /// } | ||
| 266 | /// | ||
| 267 | /// bool OnEnabled() override | ||
| 268 | /// { | ||
| 269 | /// ... | ||
| 270 | /// DO YOUR WORK HERE FOR WHAT REQUIRED DURING ENABLE OF SHADER | ||
| 271 | /// ... | ||
| 272 | /// return true; | ||
| 273 | /// } | ||
| 274 | /// | ||
| 275 | /// ADDONCREATOR(CExample); | ||
| 276 | /// ~~~~~~~~~~~~~ | ||
| 277 | /// | ||
| 278 | |||
| 279 | //======================================================================== | ||
| 280 | /// CShaderProgram | ||
| 281 | class ATTRIBUTE_HIDDEN CShaderProgram | ||
| 282 | { | ||
| 283 | public: | ||
| 284 | //========================================================================== | ||
| 285 | /// | ||
| 286 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 287 | /// @brief Construct a new shader | ||
| 288 | /// | ||
| 289 | /// Load must be done later with \ref LoadShaderFiles. | ||
| 290 | /// | ||
| 291 | CShaderProgram() = default; | ||
| 292 | //-------------------------------------------------------------------------- | ||
| 293 | |||
| 294 | //========================================================================== | ||
| 295 | /// | ||
| 296 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 297 | /// @brief Construct a new shader and load defined shader files | ||
| 298 | /// | ||
| 299 | /// @param[in] vert Path to used GL vertext shader | ||
| 300 | /// @param[in] frag Path to used GL fragment shader | ||
| 301 | /// | ||
| 302 | CShaderProgram(const std::string& vert, const std::string& frag) | ||
| 303 | { | ||
| 304 | LoadShaderFiles(vert, frag); | ||
| 305 | } | ||
| 306 | //-------------------------------------------------------------------------- | ||
| 307 | |||
| 308 | //========================================================================== | ||
| 309 | /// | ||
| 310 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 311 | /// @brief Destructor | ||
| 312 | /// | ||
| 313 | virtual ~CShaderProgram() | ||
| 314 | { | ||
| 315 | ShaderFree(); | ||
| 316 | } | ||
| 317 | //-------------------------------------------------------------------------- | ||
| 318 | |||
| 319 | //========================================================================== | ||
| 320 | /// | ||
| 321 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 322 | /// @brief To load manually the needed shader files | ||
| 323 | /// | ||
| 324 | /// @param[in] vert Path to used GL vertext shader | ||
| 325 | /// @param[in] frag Path to used GL fragment shader | ||
| 326 | /// | ||
| 327 | /// | ||
| 328 | /// @note The use of the files is optional, but it must either be passed over | ||
| 329 | /// here or via \ref CompileAndLink, or both of the source code. | ||
| 330 | /// | ||
| 331 | bool LoadShaderFiles(const std::string& vert, const std::string& frag) | ||
| 332 | { | ||
| 333 | if (!kodi::vfs::FileExists(vert) || !m_pVP.LoadSource(vert)) | ||
| 334 | { | ||
| 335 | kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, vert.c_str()); | ||
| 336 | return false; | ||
| 337 | } | ||
| 338 | |||
| 339 | if (!kodi::vfs::FileExists(frag) || !m_pFP.LoadSource(frag)) | ||
| 340 | { | ||
| 341 | kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, frag.c_str()); | ||
| 342 | return false; | ||
| 343 | } | ||
| 344 | |||
| 345 | return true; | ||
| 346 | } | ||
| 347 | //-------------------------------------------------------------------------- | ||
| 348 | |||
| 349 | //========================================================================== | ||
| 350 | /// | ||
| 351 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 352 | /// @brief To compile and link the shader to the GL interface | ||
| 353 | /// | ||
| 354 | /// Optionally, additional source code can be transferred here, or it can be | ||
| 355 | /// used independently without any files | ||
| 356 | /// | ||
| 357 | /// @param[in] vertexExtraBegin [opt] To additionally add vextex source | ||
| 358 | /// code to the beginning of the loaded file | ||
| 359 | /// source code | ||
| 360 | /// @param[in] vertexExtraEnd [opt] To additionally add vextex source | ||
| 361 | /// code to the end of the loaded file | ||
| 362 | /// source code | ||
| 363 | /// @param[in] fragmentExtraBegin [opt] To additionally add fragment source | ||
| 364 | /// code to the beginning of the loaded file | ||
| 365 | /// source code | ||
| 366 | /// @param[in] fragmentExtraEnd [opt] To additionally add fragment source | ||
| 367 | /// code to the end of the loaded file | ||
| 368 | /// source code | ||
| 369 | /// @return true if compile was successed | ||
| 370 | /// | ||
| 371 | /// | ||
| 372 | /// @note In the case of a compile error, it will be written once into the Kodi | ||
| 373 | /// log and in addition to the console output to quickly detect the errors when | ||
| 374 | /// writing the damage. | ||
| 375 | /// | ||
| 376 | /// | ||
| 377 | bool CompileAndLink(const std::string& vertexExtraBegin = "", | ||
| 378 | const std::string& vertexExtraEnd = "", | ||
| 379 | const std::string& fragmentExtraBegin = "", | ||
| 380 | const std::string& fragmentExtraEnd = "") | ||
| 381 | { | ||
| 382 | GLint params[4]; | ||
| 383 | |||
| 384 | // free resources | ||
| 385 | ShaderFree(); | ||
| 386 | m_ok = false; | ||
| 387 | |||
| 388 | // compiled vertex shader | ||
| 389 | if (!m_pVP.Compile(vertexExtraBegin, vertexExtraEnd)) | ||
| 390 | { | ||
| 391 | kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling vertex shader"); | ||
| 392 | return false; | ||
| 393 | } | ||
| 394 | |||
| 395 | // compile pixel shader | ||
| 396 | if (!m_pFP.Compile(fragmentExtraBegin, fragmentExtraEnd)) | ||
| 397 | { | ||
| 398 | m_pVP.Free(); | ||
| 399 | kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling fragment shader"); | ||
| 400 | return false; | ||
| 401 | } | ||
| 402 | |||
| 403 | // create program object | ||
| 404 | m_shaderProgram = glCreateProgram(); | ||
| 405 | if (!m_shaderProgram) | ||
| 406 | { | ||
| 407 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: Failed to create GL program", __FUNCTION__); | ||
| 408 | ShaderFree(); | ||
| 409 | return false; | ||
| 410 | } | ||
| 411 | |||
| 412 | // attach the vertex shader | ||
| 413 | glAttachShader(m_shaderProgram, m_pVP.Handle()); | ||
| 414 | glAttachShader(m_shaderProgram, m_pFP.Handle()); | ||
| 415 | |||
| 416 | // link the program | ||
| 417 | glLinkProgram(m_shaderProgram); | ||
| 418 | glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); | ||
| 419 | if (params[0] != GL_TRUE) | ||
| 420 | { | ||
| 421 | GLchar log[LOG_SIZE]; | ||
| 422 | glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); | ||
| 423 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); | ||
| 424 | fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); | ||
| 425 | ShaderFree(); | ||
| 426 | return false; | ||
| 427 | } | ||
| 428 | |||
| 429 | m_validated = false; | ||
| 430 | m_ok = true; | ||
| 431 | OnCompiledAndLinked(); | ||
| 432 | return true; | ||
| 433 | } | ||
| 434 | //-------------------------------------------------------------------------- | ||
| 435 | |||
| 436 | //========================================================================== | ||
| 437 | /// | ||
| 438 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 439 | /// @brief To activate the shader and use it on the GPU | ||
| 440 | /// | ||
| 441 | /// @return true if enable was successfull done | ||
| 442 | /// | ||
| 443 | /// | ||
| 444 | /// @note During this call, the \ref OnEnabled stored in the child is also | ||
| 445 | /// called | ||
| 446 | /// | ||
| 447 | bool EnableShader() | ||
| 448 | { | ||
| 449 | if (ShaderOK()) | ||
| 450 | { | ||
| 451 | glUseProgram(m_shaderProgram); | ||
| 452 | if (OnEnabled()) | ||
| 453 | { | ||
| 454 | if (!m_validated) | ||
| 455 | { | ||
| 456 | // validate the program | ||
| 457 | GLint params[4]; | ||
| 458 | glValidateProgram(m_shaderProgram); | ||
| 459 | glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params); | ||
| 460 | if (params[0] != GL_TRUE) | ||
| 461 | { | ||
| 462 | GLchar log[LOG_SIZE]; | ||
| 463 | glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); | ||
| 464 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); | ||
| 465 | fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); | ||
| 466 | } | ||
| 467 | m_validated = true; | ||
| 468 | } | ||
| 469 | return true; | ||
| 470 | } | ||
| 471 | else | ||
| 472 | { | ||
| 473 | glUseProgram(0); | ||
| 474 | return false; | ||
| 475 | } | ||
| 476 | return true; | ||
| 477 | } | ||
| 478 | return false; | ||
| 479 | } | ||
| 480 | //-------------------------------------------------------------------------- | ||
| 481 | |||
| 482 | //========================================================================== | ||
| 483 | /// | ||
| 484 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 485 | /// @brief To deactivate the shader use on the GPU | ||
| 486 | /// | ||
| 487 | void DisableShader() | ||
| 488 | { | ||
| 489 | if (ShaderOK()) | ||
| 490 | { | ||
| 491 | glUseProgram(0); | ||
| 492 | OnDisabled(); | ||
| 493 | } | ||
| 494 | } | ||
| 495 | //-------------------------------------------------------------------------- | ||
| 496 | |||
| 497 | //========================================================================== | ||
| 498 | /// | ||
| 499 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 500 | /// @brief Used to check if shader has been loaded before. | ||
| 501 | /// | ||
| 502 | /// @return true if enable was successfull done | ||
| 503 | /// | ||
| 504 | /// @note The CompileAndLink call sets these values | ||
| 505 | /// | ||
| 506 | ATTRIBUTE_FORCEINLINE bool ShaderOK() const { return m_ok; } | ||
| 507 | //-------------------------------------------------------------------------- | ||
| 508 | |||
| 509 | //========================================================================== | ||
| 510 | /// | ||
| 511 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 512 | /// @brief To get the vertex shader class used by Kodi at the addon | ||
| 513 | /// | ||
| 514 | /// @return pointer to vertex shader class | ||
| 515 | /// | ||
| 516 | ATTRIBUTE_FORCEINLINE CVertexShader& VertexShader() { return m_pVP; } | ||
| 517 | //-------------------------------------------------------------------------- | ||
| 518 | |||
| 519 | //========================================================================== | ||
| 520 | /// | ||
| 521 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 522 | /// @brief To get the fragment shader class used by Kodi at the addon | ||
| 523 | /// | ||
| 524 | /// @return pointer to fragment shader class | ||
| 525 | /// | ||
| 526 | ATTRIBUTE_FORCEINLINE CPixelShader& PixelShader() { return m_pFP; } | ||
| 527 | //-------------------------------------------------------------------------- | ||
| 528 | |||
| 529 | //========================================================================== | ||
| 530 | /// | ||
| 531 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 532 | /// @brief Used to get the definition created in the OpenGL itself | ||
| 533 | /// | ||
| 534 | /// @return GLuint of GL shader program handler | ||
| 535 | /// | ||
| 536 | ATTRIBUTE_FORCEINLINE GLuint ProgramHandle() { return m_shaderProgram; } | ||
| 537 | //-------------------------------------------------------------------------- | ||
| 538 | |||
| 539 | //========================================================================== | ||
| 540 | /// | ||
| 541 | /// \defgroup cpp_kodi_gui_gl_CShaderProgram_child Child Functions | ||
| 542 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 543 | /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram child functions } | ||
| 544 | /// | ||
| 545 | /// Functions that are added by parent in the child | ||
| 546 | //@{ | ||
| 547 | //========================================================================== | ||
| 548 | /// | ||
| 549 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 550 | /// @brief Mandatory child function to set the necessary CPU to GPU data | ||
| 551 | /// | ||
| 552 | virtual void OnCompiledAndLinked() {}; | ||
| 553 | //-------------------------------------------------------------------------- | ||
| 554 | |||
| 555 | //========================================================================== | ||
| 556 | /// | ||
| 557 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 558 | /// @brief Optional function to exchange data between CPU and GPU while | ||
| 559 | /// activating the shader | ||
| 560 | /// | ||
| 561 | /// @return true if enable was successfull done | ||
| 562 | /// | ||
| 563 | virtual bool OnEnabled() { return true; }; | ||
| 564 | //-------------------------------------------------------------------------- | ||
| 565 | |||
| 566 | //========================================================================== | ||
| 567 | /// | ||
| 568 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 569 | /// @brief Optional child function that may have to be performed when | ||
| 570 | /// switching off the shader | ||
| 571 | virtual void OnDisabled() {}; | ||
| 572 | //-------------------------------------------------------------------------- | ||
| 573 | //@} | ||
| 574 | |||
| 575 | private: | ||
| 576 | void ShaderFree() | ||
| 577 | { | ||
| 578 | if (m_shaderProgram) | ||
| 579 | glDeleteProgram(m_shaderProgram); | ||
| 580 | m_shaderProgram = 0; | ||
| 581 | m_ok = false; | ||
| 582 | } | ||
| 583 | |||
| 584 | CVertexShader m_pVP; | ||
| 585 | CPixelShader m_pFP; | ||
| 586 | GLuint m_shaderProgram = 0; | ||
| 587 | bool m_ok = false; | ||
| 588 | bool m_validated = false; | ||
| 589 | }; | ||
| 590 | //------------------------------------------------------------------------ | ||
| 591 | |||
| 592 | } /* namespace gl */ | ||
| 593 | } /* namespace gui */ | ||
| 594 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h new file mode 100644 index 0000000..2e96d21 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 | |||
| 13 | namespace kodi | ||
| 14 | { | ||
| 15 | namespace gui | ||
| 16 | { | ||
| 17 | struct ATTRIBUTE_HIDDEN IRenderHelper | ||
| 18 | { | ||
| 19 | virtual ~IRenderHelper() = default; | ||
| 20 | virtual bool Init() = 0; | ||
| 21 | virtual void Begin() = 0; | ||
| 22 | virtual void End() = 0; | ||
| 23 | }; /* class IRenderHelper */ | ||
| 24 | } /* namespace gui */ | ||
| 25 | } /* namespace kodi */ | ||
| 26 | |||
| 27 | #if defined(WIN32) && defined(HAS_ANGLE) | ||
| 28 | #include "gl/GLonDX.h" | ||
| 29 | #else | ||
| 30 | /* | ||
| 31 | * Default background GUI render helper class | ||
| 32 | */ | ||
| 33 | namespace kodi | ||
| 34 | { | ||
| 35 | namespace gui | ||
| 36 | { | ||
| 37 | struct ATTRIBUTE_HIDDEN CRenderHelperStub : public IRenderHelper | ||
| 38 | { | ||
| 39 | bool Init() override { return true; } | ||
| 40 | void Begin() override { } | ||
| 41 | void End() override { } | ||
| 42 | }; /* class CRenderHelperStub */ | ||
| 43 | |||
| 44 | using CRenderHelper = CRenderHelperStub; | ||
| 45 | } /* namespace gui */ | ||
| 46 | } /* namespace kodi */ | ||
| 47 | #endif | ||
| 48 | |||
| 49 | namespace kodi | ||
| 50 | { | ||
| 51 | namespace gui | ||
| 52 | { | ||
| 53 | |||
| 54 | /* | ||
| 55 | * Create render background handler, e.g. becomes on "Windows" Angle used | ||
| 56 | * to emulate GL. | ||
| 57 | * | ||
| 58 | * This only be used internal and not from addon's direct. | ||
| 59 | * | ||
| 60 | * Function defines here and not in CAddonBase because of a hen and egg problem. | ||
| 61 | */ | ||
| 62 | inline std::shared_ptr<IRenderHelper> ATTRIBUTE_HIDDEN GetRenderHelper() | ||
| 63 | { | ||
| 64 | using namespace ::kodi::addon; | ||
| 65 | if (static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper) | ||
| 66 | return static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper; | ||
| 67 | |||
| 68 | const std::shared_ptr<kodi::gui::IRenderHelper> renderHelper(new CRenderHelper()); | ||
| 69 | if (!renderHelper->Init()) | ||
| 70 | return nullptr; | ||
| 71 | |||
| 72 | static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper = | ||
| 73 | renderHelper; // Hold on base for other types | ||
| 74 | return renderHelper; | ||
| 75 | } | ||
| 76 | |||
| 77 | } /* namespace gui */ | ||
| 78 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h deleted file mode 100644 index 4338606..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h +++ /dev/null | |||
| @@ -1,340 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-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 "kodi_game_types.h" | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" { | ||
| 15 | #endif | ||
| 16 | |||
| 17 | // --- Game operations --------------------------------------------------------- | ||
| 18 | |||
| 19 | /*! | ||
| 20 | * \brief Load a game | ||
| 21 | * | ||
| 22 | * \param url The URL to load | ||
| 23 | * | ||
| 24 | * return the error, or GAME_ERROR_NO_ERROR if the game was loaded | ||
| 25 | */ | ||
| 26 | GAME_ERROR LoadGame(const char* url); | ||
| 27 | |||
| 28 | /*! | ||
| 29 | * \brief Load a game that requires multiple files | ||
| 30 | * | ||
| 31 | * \param type The game type | ||
| 32 | * \param urls An array of urls | ||
| 33 | * \param urlCount The number of urls in the array | ||
| 34 | * | ||
| 35 | * \return the error, or GAME_ERROR_NO_ERROR if the game was loaded | ||
| 36 | */ | ||
| 37 | GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const char** urls, size_t urlCount); | ||
| 38 | |||
| 39 | /*! | ||
| 40 | * \brief Begin playing without a game file | ||
| 41 | * | ||
| 42 | * If the add-on supports standalone mode, it must add the <supports_standalone> | ||
| 43 | * tag to the extension point in addon.xml: | ||
| 44 | * | ||
| 45 | * <supports_no_game>false</supports_no_game> | ||
| 46 | * | ||
| 47 | * \return the error, or GAME_ERROR_NO_ERROR if the game add-on was loaded | ||
| 48 | */ | ||
| 49 | GAME_ERROR LoadStandalone(void); | ||
| 50 | |||
| 51 | /*! | ||
| 52 | * \brief Unload the current game | ||
| 53 | * | ||
| 54 | * \return the error, or GAME_ERROR_NO_ERROR if the game was unloaded | ||
| 55 | */ | ||
| 56 | /*! Unloads a currently loaded game */ | ||
| 57 | GAME_ERROR UnloadGame(void); | ||
| 58 | |||
| 59 | /*! | ||
| 60 | * \brief Get timing information about the loaded game | ||
| 61 | * | ||
| 62 | * \param[out] timing_info The info structure to fill | ||
| 63 | * | ||
| 64 | * \return the error, or GAME_ERROR_NO_ERROR if info was filled | ||
| 65 | */ | ||
| 66 | GAME_ERROR GetGameTiming(game_system_timing* timing_info); | ||
| 67 | |||
| 68 | /*! | ||
| 69 | * \brief Get region of the loaded game | ||
| 70 | * | ||
| 71 | * \return the region, or GAME_REGION_UNKNOWN if unknown or no game is loaded | ||
| 72 | */ | ||
| 73 | GAME_REGION GetRegion(void); | ||
| 74 | |||
| 75 | /*! | ||
| 76 | * \brief Return true if the client requires the frontend to provide a game loop | ||
| 77 | * | ||
| 78 | * The game loop is a thread that calls RunFrame() in a loop at a rate | ||
| 79 | * determined by the playback speed and the client's FPS. | ||
| 80 | * | ||
| 81 | * \return true if the frontend should provide a game loop, false otherwise | ||
| 82 | */ | ||
| 83 | bool RequiresGameLoop(void); | ||
| 84 | |||
| 85 | /*! | ||
| 86 | * \brief Run a single frame for add-ons that use a game loop | ||
| 87 | * | ||
| 88 | * \return the error, or GAME_ERROR_NO_ERROR if there was no error | ||
| 89 | */ | ||
| 90 | GAME_ERROR RunFrame(void); | ||
| 91 | |||
| 92 | /*! | ||
| 93 | * \brief Reset the current game | ||
| 94 | * | ||
| 95 | * \return the error, or GAME_ERROR_NO_ERROR if the game was reset | ||
| 96 | */ | ||
| 97 | GAME_ERROR Reset(void); | ||
| 98 | |||
| 99 | // --- Hardware rendering operations ------------------------------------------- | ||
| 100 | |||
| 101 | /*! | ||
| 102 | * \brief Invalidates the current HW context and reinitializes GPU resources | ||
| 103 | * | ||
| 104 | * Any GL state is lost, and must not be deinitialized explicitly. | ||
| 105 | * | ||
| 106 | * \return the error, or GAME_ERROR_NO_ERROR if the HW context was reset | ||
| 107 | */ | ||
| 108 | GAME_ERROR HwContextReset(void); | ||
| 109 | |||
| 110 | /*! | ||
| 111 | * \brief Called before the context is destroyed | ||
| 112 | * | ||
| 113 | * Resources can be deinitialized at this step. | ||
| 114 | * | ||
| 115 | * \return the error, or GAME_ERROR_NO_ERROR if the HW context was destroyed | ||
| 116 | */ | ||
| 117 | GAME_ERROR HwContextDestroy(void); | ||
| 118 | |||
| 119 | // --- Input operations -------------------------------------------------------- | ||
| 120 | |||
| 121 | /*! | ||
| 122 | * \brief Check if input is accepted for a feature on the controller | ||
| 123 | * | ||
| 124 | * If only a subset of the controller profile is used, this can return false | ||
| 125 | * for unsupported features to not absorb their input. | ||
| 126 | * | ||
| 127 | * If the entire controller profile is used, this should always return true. | ||
| 128 | * | ||
| 129 | * \param controller_id The ID of the controller profile | ||
| 130 | * \param feature_name The name of a feature in that profile | ||
| 131 | * \return true if input is accepted for the feature, false otherwise | ||
| 132 | */ | ||
| 133 | bool HasFeature(const char* controller_id, const char* feature_name); | ||
| 134 | |||
| 135 | /*! | ||
| 136 | * \brief Get the input topology that specifies which controllers can be connected | ||
| 137 | * | ||
| 138 | * \return The input topology, or null to use the default | ||
| 139 | * | ||
| 140 | * If this returns non-null, topology must be freed using FreeTopology(). | ||
| 141 | * | ||
| 142 | * If this returns null, the topology will default to a single port that can | ||
| 143 | * accept all controllers imported by addon.xml. The port ID is set to | ||
| 144 | * the DEFAULT_PORT_ID constant. | ||
| 145 | */ | ||
| 146 | game_input_topology* GetTopology(); | ||
| 147 | |||
| 148 | /*! | ||
| 149 | * \brief Free the topology's resources | ||
| 150 | * | ||
| 151 | * \param topology The topology returned by GetTopology() | ||
| 152 | */ | ||
| 153 | void FreeTopology(game_input_topology* topology); | ||
| 154 | |||
| 155 | /*! | ||
| 156 | * \brief Set the layouts for known controllers | ||
| 157 | * | ||
| 158 | * \param controllers The controller layouts | ||
| 159 | * \param controller_count The number of items in the array | ||
| 160 | * | ||
| 161 | * After loading the input topology, the frontend will call this with | ||
| 162 | * controller layouts for all controllers discovered in the topology. | ||
| 163 | */ | ||
| 164 | void SetControllerLayouts(const game_controller_layout* controllers, unsigned int controller_count); | ||
| 165 | |||
| 166 | /*! | ||
| 167 | * \brief Enable/disable keyboard input using the specified controller | ||
| 168 | * | ||
| 169 | * \param enable True to enable input, false otherwise | ||
| 170 | * \param controller_id The controller ID if enabling, or unused if disabling | ||
| 171 | * | ||
| 172 | * \return True if keyboard input was enabled, false otherwise | ||
| 173 | */ | ||
| 174 | bool EnableKeyboard(bool enable, const char* controller_id); | ||
| 175 | |||
| 176 | /*! | ||
| 177 | * \brief Enable/disable mouse input using the specified controller | ||
| 178 | * | ||
| 179 | * \param enable True to enable input, false otherwise | ||
| 180 | * \param controller_id The controller ID if enabling, or unused if disabling | ||
| 181 | * | ||
| 182 | * \return True if mouse input was enabled, false otherwise | ||
| 183 | */ | ||
| 184 | bool EnableMouse(bool enable, const char* controller_id); | ||
| 185 | |||
| 186 | /*! | ||
| 187 | * \brief Connect/disconnect a controller to a port on the virtual game console | ||
| 188 | * | ||
| 189 | * \param connect True to connect a controller, false to disconnect | ||
| 190 | * \param port_address The address of the port | ||
| 191 | * \param controller_id The controller ID if connecting, or unused if disconnecting | ||
| 192 | * \return True if the \p controller was (dis-)connected to the port, false otherwise | ||
| 193 | * | ||
| 194 | * The address is a string that allows traversal of the controller topology. | ||
| 195 | * It is formed by alternating port IDs and controller IDs separated by "/". | ||
| 196 | * | ||
| 197 | * For example, assume that the topology represented in XML for Snes9x is: | ||
| 198 | * | ||
| 199 | * <logicaltopology> | ||
| 200 | * <port type="controller" id="1"> | ||
| 201 | * <accepts controller="game.controller.snes"/> | ||
| 202 | * <accepts controller="game.controller.snes.multitap"> | ||
| 203 | * <port type="controller" id="1"> | ||
| 204 | * <accepts controller="game.controller.snes"/> | ||
| 205 | * </port> | ||
| 206 | * <port type="controller" id="2"> | ||
| 207 | * <accepts controller="game.controller.snes"/> | ||
| 208 | * </port> | ||
| 209 | * ... | ||
| 210 | * </accepts> | ||
| 211 | * </port> | ||
| 212 | * </logicaltopology> | ||
| 213 | * | ||
| 214 | * To connect a multitap to the console's first port, the multitap's controller | ||
| 215 | * info is set using the port address: | ||
| 216 | * | ||
| 217 | * /1 | ||
| 218 | * | ||
| 219 | * To connect a SNES controller to the second port of the multitap, the | ||
| 220 | * controller info is next set using the address: | ||
| 221 | * | ||
| 222 | * /1/game.controller.multitap/2 | ||
| 223 | * | ||
| 224 | * Any attempts to connect a controller to a port on a disconnected multitap | ||
| 225 | * will return false. | ||
| 226 | */ | ||
| 227 | bool ConnectController(bool connect, const char* port_address, const char* controller_id); | ||
| 228 | |||
| 229 | /*! | ||
| 230 | * \brief Notify the add-on of an input event | ||
| 231 | * | ||
| 232 | * \param event The input event | ||
| 233 | * | ||
| 234 | * \return true if the event was handled, false otherwise | ||
| 235 | */ | ||
| 236 | bool InputEvent(const game_input_event* event); | ||
| 237 | |||
| 238 | // --- Serialization operations ------------------------------------------------ | ||
| 239 | |||
| 240 | /*! | ||
| 241 | * \brief Get the number of bytes required to serialize the game | ||
| 242 | * | ||
| 243 | * \return the number of bytes, or 0 if serialization is not supported | ||
| 244 | */ | ||
| 245 | size_t SerializeSize(void); | ||
| 246 | |||
| 247 | /*! | ||
| 248 | * \brief Serialize the state of the game | ||
| 249 | * | ||
| 250 | * \param data The buffer receiving the serialized game data | ||
| 251 | * \param size The size of the buffer | ||
| 252 | * | ||
| 253 | * \return the error, or GAME_ERROR_NO_ERROR if the game was serialized into the buffer | ||
| 254 | */ | ||
| 255 | GAME_ERROR Serialize(uint8_t* data, size_t size); | ||
| 256 | |||
| 257 | /*! | ||
| 258 | * \brief Deserialize the game from the given state | ||
| 259 | * | ||
| 260 | * \param data A buffer containing the game's new state | ||
| 261 | * \param size The size of the buffer | ||
| 262 | * | ||
| 263 | * \return the error, or GAME_ERROR_NO_ERROR if the game deserialized | ||
| 264 | */ | ||
| 265 | GAME_ERROR Deserialize(const uint8_t* data, size_t size); | ||
| 266 | |||
| 267 | // --- Cheat operations -------------------------------------------------------- | ||
| 268 | |||
| 269 | /*! | ||
| 270 | * \brief Reset the cheat system | ||
| 271 | * | ||
| 272 | * \return the error, or GAME_ERROR_NO_ERROR if the cheat system was reset | ||
| 273 | */ | ||
| 274 | GAME_ERROR CheatReset(void); | ||
| 275 | |||
| 276 | /*! | ||
| 277 | * \brief Get a region of memory | ||
| 278 | * | ||
| 279 | * \param type The type of memory to retrieve | ||
| 280 | * \param data Set to the region of memory; must remain valid until UnloadGame() is called | ||
| 281 | * \param size Set to the size of the region of memory | ||
| 282 | * | ||
| 283 | * \return the error, or GAME_ERROR_NO_ERROR if data was set to a valid buffer | ||
| 284 | */ | ||
| 285 | GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t** data, size_t* size); | ||
| 286 | |||
| 287 | /*! | ||
| 288 | * \brief Set a cheat code | ||
| 289 | * | ||
| 290 | * \param index | ||
| 291 | * \param enabled | ||
| 292 | * \param code | ||
| 293 | * | ||
| 294 | * \return the error, or GAME_ERROR_NO_ERROR if the cheat was set | ||
| 295 | */ | ||
| 296 | GAME_ERROR SetCheat(unsigned int index, bool enabled, const char* code); | ||
| 297 | |||
| 298 | // --- Add-on helper implementation -------------------------------------------- | ||
| 299 | |||
| 300 | /*! | ||
| 301 | * \brief Called by Kodi to assign the function pointers of this add-on to pClient | ||
| 302 | * | ||
| 303 | * Note that get_addon() is defined here, so it will be available in all | ||
| 304 | * compiled game clients. | ||
| 305 | */ | ||
| 306 | void __declspec(dllexport) get_addon(void* ptr) | ||
| 307 | { | ||
| 308 | AddonInstance_Game* pClient = static_cast<AddonInstance_Game*>(ptr); | ||
| 309 | |||
| 310 | pClient->toAddon.LoadGame = LoadGame; | ||
| 311 | pClient->toAddon.LoadGameSpecial = LoadGameSpecial; | ||
| 312 | pClient->toAddon.LoadStandalone = LoadStandalone; | ||
| 313 | pClient->toAddon.UnloadGame = UnloadGame; | ||
| 314 | pClient->toAddon.GetGameTiming = GetGameTiming; | ||
| 315 | pClient->toAddon.GetRegion = GetRegion; | ||
| 316 | pClient->toAddon.RequiresGameLoop = RequiresGameLoop; | ||
| 317 | pClient->toAddon.RunFrame = RunFrame; | ||
| 318 | pClient->toAddon.Reset = Reset; | ||
| 319 | pClient->toAddon.HwContextReset = HwContextReset; | ||
| 320 | pClient->toAddon.HwContextDestroy = HwContextDestroy; | ||
| 321 | pClient->toAddon.HasFeature = HasFeature; | ||
| 322 | pClient->toAddon.GetTopology = GetTopology; | ||
| 323 | pClient->toAddon.FreeTopology = FreeTopology; | ||
| 324 | pClient->toAddon.SetControllerLayouts = SetControllerLayouts; | ||
| 325 | pClient->toAddon.EnableKeyboard = EnableKeyboard; | ||
| 326 | pClient->toAddon.EnableMouse = EnableMouse; | ||
| 327 | pClient->toAddon.ConnectController = ConnectController; | ||
| 328 | pClient->toAddon.InputEvent = InputEvent; | ||
| 329 | pClient->toAddon.SerializeSize = SerializeSize; | ||
| 330 | pClient->toAddon.Serialize = Serialize; | ||
| 331 | pClient->toAddon.Deserialize = Deserialize; | ||
| 332 | pClient->toAddon.CheatReset = CheatReset; | ||
| 333 | pClient->toAddon.GetMemory = GetMemory; | ||
| 334 | pClient->toAddon.SetCheat = SetCheat; | ||
| 335 | } | ||
| 336 | |||
| 337 | #ifdef __cplusplus | ||
| 338 | } | ||
| 339 | #endif | ||
| 340 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h deleted file mode 100644 index ec9d472..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h +++ /dev/null | |||
| @@ -1,714 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-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 "versions.h" | ||
| 12 | #include "xbmc_addon_types.h" | ||
| 13 | |||
| 14 | #include <stddef.h> | ||
| 15 | #include <stdint.h> | ||
| 16 | |||
| 17 | #ifndef TARGET_WINDOWS | ||
| 18 | #ifndef __cdecl | ||
| 19 | #define __cdecl | ||
| 20 | #endif | ||
| 21 | #ifndef __declspec | ||
| 22 | #define __declspec(X) | ||
| 23 | #endif | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #undef ATTRIBUTE_PACKED | ||
| 27 | #undef PRAGMA_PACK_BEGIN | ||
| 28 | #undef PRAGMA_PACK_END | ||
| 29 | |||
| 30 | #if defined(__GNUC__) | ||
| 31 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 32 | #define PRAGMA_PACK 0 | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #if !defined(ATTRIBUTE_PACKED) | ||
| 36 | #define ATTRIBUTE_PACKED | ||
| 37 | #define PRAGMA_PACK 1 | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #ifdef BUILD_KODI_ADDON | ||
| 41 | #include "XBMC_vkeys.h" | ||
| 42 | #else | ||
| 43 | #include "input/XBMC_vkeys.h" | ||
| 44 | #endif | ||
| 45 | |||
| 46 | /*! Port ID used when topology is unknown */ | ||
| 47 | #define DEFAULT_PORT_ID "1" | ||
| 48 | |||
| 49 | #ifdef __cplusplus | ||
| 50 | extern "C" { | ||
| 51 | #endif | ||
| 52 | |||
| 53 | /// @name Add-on types | ||
| 54 | ///{ | ||
| 55 | /*! Game add-on error codes */ | ||
| 56 | typedef enum GAME_ERROR | ||
| 57 | { | ||
| 58 | GAME_ERROR_NO_ERROR, // no error occurred | ||
| 59 | GAME_ERROR_UNKNOWN, // an unknown error occurred | ||
| 60 | GAME_ERROR_NOT_IMPLEMENTED, // the method that the frontend called is not implemented | ||
| 61 | GAME_ERROR_REJECTED, // the command was rejected by the game client | ||
| 62 | GAME_ERROR_INVALID_PARAMETERS, // the parameters of the method that was called are invalid for this operation | ||
| 63 | GAME_ERROR_FAILED, // the command failed | ||
| 64 | GAME_ERROR_NOT_LOADED, // no game is loaded | ||
| 65 | GAME_ERROR_RESTRICTED, // game requires restricted resources | ||
| 66 | } GAME_ERROR; | ||
| 67 | ///} | ||
| 68 | |||
| 69 | /// @name Audio stream | ||
| 70 | ///{ | ||
| 71 | typedef enum GAME_PCM_FORMAT | ||
| 72 | { | ||
| 73 | GAME_PCM_FORMAT_UNKNOWN, | ||
| 74 | GAME_PCM_FORMAT_S16NE, | ||
| 75 | } GAME_PCM_FORMAT; | ||
| 76 | |||
| 77 | typedef enum GAME_AUDIO_CHANNEL | ||
| 78 | { | ||
| 79 | GAME_CH_NULL, // Channel list terminator | ||
| 80 | GAME_CH_FL, | ||
| 81 | GAME_CH_FR, | ||
| 82 | GAME_CH_FC, | ||
| 83 | GAME_CH_LFE, | ||
| 84 | GAME_CH_BL, | ||
| 85 | GAME_CH_BR, | ||
| 86 | GAME_CH_FLOC, | ||
| 87 | GAME_CH_FROC, | ||
| 88 | GAME_CH_BC, | ||
| 89 | GAME_CH_SL, | ||
| 90 | GAME_CH_SR, | ||
| 91 | GAME_CH_TFL, | ||
| 92 | GAME_CH_TFR, | ||
| 93 | GAME_CH_TFC, | ||
| 94 | GAME_CH_TC, | ||
| 95 | GAME_CH_TBL, | ||
| 96 | GAME_CH_TBR, | ||
| 97 | GAME_CH_TBC, | ||
| 98 | GAME_CH_BLOC, | ||
| 99 | GAME_CH_BROC, | ||
| 100 | } GAME_AUDIO_CHANNEL; | ||
| 101 | |||
| 102 | typedef struct game_stream_audio_properties | ||
| 103 | { | ||
| 104 | GAME_PCM_FORMAT format; | ||
| 105 | const GAME_AUDIO_CHANNEL* channel_map; | ||
| 106 | } ATTRIBUTE_PACKED game_stream_audio_properties; | ||
| 107 | |||
| 108 | typedef struct game_stream_audio_packet | ||
| 109 | { | ||
| 110 | const uint8_t *data; | ||
| 111 | size_t size; | ||
| 112 | } ATTRIBUTE_PACKED game_stream_audio_packet; | ||
| 113 | ///} | ||
| 114 | |||
| 115 | /// @name Video stream | ||
| 116 | ///{ | ||
| 117 | typedef enum GAME_PIXEL_FORMAT | ||
| 118 | { | ||
| 119 | GAME_PIXEL_FORMAT_UNKNOWN, | ||
| 120 | GAME_PIXEL_FORMAT_0RGB8888, | ||
| 121 | GAME_PIXEL_FORMAT_RGB565, | ||
| 122 | GAME_PIXEL_FORMAT_0RGB1555, | ||
| 123 | } GAME_PIXEL_FORMAT; | ||
| 124 | |||
| 125 | typedef enum GAME_VIDEO_ROTATION | ||
| 126 | { | ||
| 127 | GAME_VIDEO_ROTATION_0, | ||
| 128 | GAME_VIDEO_ROTATION_90_CCW, | ||
| 129 | GAME_VIDEO_ROTATION_180_CCW, | ||
| 130 | GAME_VIDEO_ROTATION_270_CCW, | ||
| 131 | } GAME_VIDEO_ROTATION; | ||
| 132 | |||
| 133 | typedef struct game_stream_video_properties | ||
| 134 | { | ||
| 135 | GAME_PIXEL_FORMAT format; | ||
| 136 | unsigned int nominal_width; | ||
| 137 | unsigned int nominal_height; | ||
| 138 | unsigned int max_width; | ||
| 139 | unsigned int max_height; | ||
| 140 | float aspect_ratio; // If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed | ||
| 141 | } ATTRIBUTE_PACKED game_stream_video_properties; | ||
| 142 | |||
| 143 | typedef struct game_stream_video_packet | ||
| 144 | { | ||
| 145 | unsigned int width; | ||
| 146 | unsigned int height; | ||
| 147 | GAME_VIDEO_ROTATION rotation; | ||
| 148 | const uint8_t *data; | ||
| 149 | size_t size; | ||
| 150 | } ATTRIBUTE_PACKED game_stream_video_packet; | ||
| 151 | ///} | ||
| 152 | |||
| 153 | /// @name Hardware framebuffer stream | ||
| 154 | ///{ | ||
| 155 | typedef enum GAME_HW_CONTEXT_TYPE | ||
| 156 | { | ||
| 157 | GAME_HW_CONTEXT_NONE, | ||
| 158 | |||
| 159 | // OpenGL 2.x. Driver can choose to use latest compatibility context | ||
| 160 | GAME_HW_CONTEXT_OPENGL, | ||
| 161 | |||
| 162 | // OpenGL ES 2.0 | ||
| 163 | GAME_HW_CONTEXT_OPENGLES2, | ||
| 164 | |||
| 165 | // Modern desktop core GL context. Use major/minor fields to set GL version | ||
| 166 | GAME_HW_CONTEXT_OPENGL_CORE, | ||
| 167 | |||
| 168 | // OpenGL ES 3.0 | ||
| 169 | GAME_HW_CONTEXT_OPENGLES3, | ||
| 170 | |||
| 171 | // OpenGL ES 3.1+. Set major/minor fields. | ||
| 172 | GAME_HW_CONTEXT_OPENGLES_VERSION, | ||
| 173 | |||
| 174 | // Vulkan | ||
| 175 | GAME_HW_CONTEXT_VULKAN | ||
| 176 | } GAME_HW_CONTEXT_TYPE; | ||
| 177 | |||
| 178 | typedef struct game_stream_hw_framebuffer_properties | ||
| 179 | { | ||
| 180 | /*! | ||
| 181 | * The API to use. | ||
| 182 | */ | ||
| 183 | GAME_HW_CONTEXT_TYPE context_type; | ||
| 184 | |||
| 185 | /*! | ||
| 186 | * Set if render buffers should have depth component attached. | ||
| 187 | * | ||
| 188 | * TODO: Obsolete | ||
| 189 | */ | ||
| 190 | bool depth; | ||
| 191 | |||
| 192 | /*! | ||
| 193 | * Set if stencil buffers should be attached. If depth and stencil are true, | ||
| 194 | * a packed 24/8 buffer will be added. Only attaching stencil is invalid and | ||
| 195 | * will be ignored. | ||
| 196 | * | ||
| 197 | * TODO: Obsolete. | ||
| 198 | */ | ||
| 199 | bool stencil; | ||
| 200 | |||
| 201 | /*! | ||
| 202 | * Use conventional bottom-left origin convention. If false, standard top-left | ||
| 203 | * origin semantics are used. | ||
| 204 | * | ||
| 205 | * TODO: Move to GL specific interface | ||
| 206 | */ | ||
| 207 | bool bottom_left_origin; | ||
| 208 | |||
| 209 | /*! | ||
| 210 | * Major version number for core GL context or GLES 3.1+. | ||
| 211 | */ | ||
| 212 | unsigned int version_major; | ||
| 213 | |||
| 214 | /*! | ||
| 215 | * Minor version number for core GL context or GLES 3.1+. | ||
| 216 | */ | ||
| 217 | unsigned int version_minor; | ||
| 218 | |||
| 219 | /*! | ||
| 220 | * If this is true, the frontend will go very far to avoid resetting context | ||
| 221 | * in scenarios like toggling fullscreen, etc. | ||
| 222 | * | ||
| 223 | * TODO: Obsolete? Maybe frontend should just always assume this... | ||
| 224 | * | ||
| 225 | * The reset callback might still be called in extreme situations such as if | ||
| 226 | * the context is lost beyond recovery. | ||
| 227 | * | ||
| 228 | * For optimal stability, set this to false, and allow context to be reset at | ||
| 229 | * any time. | ||
| 230 | */ | ||
| 231 | bool cache_context; | ||
| 232 | |||
| 233 | /*! | ||
| 234 | * Creates a debug context. | ||
| 235 | */ | ||
| 236 | bool debug_context; | ||
| 237 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties; | ||
| 238 | |||
| 239 | typedef struct game_stream_hw_framebuffer_buffer | ||
| 240 | { | ||
| 241 | uintptr_t framebuffer; | ||
| 242 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer; | ||
| 243 | |||
| 244 | typedef struct game_stream_hw_framebuffer_packet | ||
| 245 | { | ||
| 246 | uintptr_t framebuffer; | ||
| 247 | } ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet; | ||
| 248 | |||
| 249 | typedef void (*game_proc_address_t)(void); | ||
| 250 | ///} | ||
| 251 | |||
| 252 | /// @name Software framebuffer stream | ||
| 253 | ///{ | ||
| 254 | typedef game_stream_video_properties game_stream_sw_framebuffer_properties; | ||
| 255 | |||
| 256 | typedef struct game_stream_sw_framebuffer_buffer | ||
| 257 | { | ||
| 258 | GAME_PIXEL_FORMAT format; | ||
| 259 | uint8_t *data; | ||
| 260 | size_t size; | ||
| 261 | } ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer; | ||
| 262 | |||
| 263 | typedef game_stream_video_packet game_stream_sw_framebuffer_packet; | ||
| 264 | ///} | ||
| 265 | |||
| 266 | /// @name Stream types | ||
| 267 | ///{ | ||
| 268 | typedef enum GAME_STREAM_TYPE | ||
| 269 | { | ||
| 270 | GAME_STREAM_UNKNOWN, | ||
| 271 | GAME_STREAM_AUDIO, | ||
| 272 | GAME_STREAM_VIDEO, | ||
| 273 | GAME_STREAM_HW_FRAMEBUFFER, | ||
| 274 | GAME_STREAM_SW_FRAMEBUFFER, | ||
| 275 | } GAME_STREAM_TYPE; | ||
| 276 | |||
| 277 | /*! | ||
| 278 | * \brief Immutable stream metadata | ||
| 279 | * | ||
| 280 | * This metadata is provided when the stream is opened. If any stream | ||
| 281 | * properties change, a new stream must be opened. | ||
| 282 | */ | ||
| 283 | typedef struct game_stream_properties | ||
| 284 | { | ||
| 285 | GAME_STREAM_TYPE type; | ||
| 286 | union | ||
| 287 | { | ||
| 288 | game_stream_audio_properties audio; | ||
| 289 | game_stream_video_properties video; | ||
| 290 | game_stream_hw_framebuffer_properties hw_framebuffer; | ||
| 291 | game_stream_sw_framebuffer_properties sw_framebuffer; | ||
| 292 | }; | ||
| 293 | } ATTRIBUTE_PACKED game_stream_properties; | ||
| 294 | |||
| 295 | /*! | ||
| 296 | * \brief Stream buffers for hardware rendering and zero-copy support | ||
| 297 | */ | ||
| 298 | typedef struct game_stream_buffer | ||
| 299 | { | ||
| 300 | GAME_STREAM_TYPE type; | ||
| 301 | union | ||
| 302 | { | ||
| 303 | game_stream_hw_framebuffer_buffer hw_framebuffer; | ||
| 304 | game_stream_sw_framebuffer_buffer sw_framebuffer; | ||
| 305 | }; | ||
| 306 | } ATTRIBUTE_PACKED game_stream_buffer; | ||
| 307 | |||
| 308 | /*! | ||
| 309 | * \brief Stream packet and ephemeral metadata | ||
| 310 | * | ||
| 311 | * This packet contains stream data and accompanying metadata. The metadata | ||
| 312 | * is ephemeral, meaning it only applies to the current packet and can change | ||
| 313 | * from packet to packet in the same stream. | ||
| 314 | */ | ||
| 315 | typedef struct game_stream_packet | ||
| 316 | { | ||
| 317 | GAME_STREAM_TYPE type; | ||
| 318 | union | ||
| 319 | { | ||
| 320 | game_stream_audio_packet audio; | ||
| 321 | game_stream_video_packet video; | ||
| 322 | game_stream_hw_framebuffer_packet hw_framebuffer; | ||
| 323 | game_stream_sw_framebuffer_packet sw_framebuffer; | ||
| 324 | }; | ||
| 325 | } ATTRIBUTE_PACKED game_stream_packet; | ||
| 326 | ///} | ||
| 327 | |||
| 328 | /// @name Game types | ||
| 329 | ///{ | ||
| 330 | |||
| 331 | /*! Returned from game_get_region() */ | ||
| 332 | typedef enum GAME_REGION | ||
| 333 | { | ||
| 334 | GAME_REGION_UNKNOWN, | ||
| 335 | GAME_REGION_NTSC, | ||
| 336 | GAME_REGION_PAL, | ||
| 337 | } GAME_REGION; | ||
| 338 | |||
| 339 | /*! | ||
| 340 | * Special game types passed into game_load_game_special(). Only used when | ||
| 341 | * multiple ROMs are required. | ||
| 342 | */ | ||
| 343 | typedef enum SPECIAL_GAME_TYPE | ||
| 344 | { | ||
| 345 | SPECIAL_GAME_TYPE_BSX, | ||
| 346 | SPECIAL_GAME_TYPE_BSX_SLOTTED, | ||
| 347 | SPECIAL_GAME_TYPE_SUFAMI_TURBO, | ||
| 348 | SPECIAL_GAME_TYPE_SUPER_GAME_BOY, | ||
| 349 | } SPECIAL_GAME_TYPE; | ||
| 350 | |||
| 351 | typedef enum GAME_MEMORY | ||
| 352 | { | ||
| 353 | /*! | ||
| 354 | * Passed to game_get_memory_data/size(). If the memory type doesn't apply | ||
| 355 | * to the implementation NULL/0 can be returned. | ||
| 356 | */ | ||
| 357 | GAME_MEMORY_MASK = 0xff, | ||
| 358 | |||
| 359 | /*! | ||
| 360 | * Regular save ram. This ram is usually found on a game cartridge, backed | ||
| 361 | * up by a battery. If save game data is too complex for a single memory | ||
| 362 | * buffer, the SYSTEM_DIRECTORY environment callback can be used. | ||
| 363 | */ | ||
| 364 | GAME_MEMORY_SAVE_RAM = 0, | ||
| 365 | |||
| 366 | /*! | ||
| 367 | * Some games have a built-in clock to keep track of time. This memory is | ||
| 368 | * usually just a couple of bytes to keep track of time. | ||
| 369 | */ | ||
| 370 | GAME_MEMORY_RTC = 1, | ||
| 371 | |||
| 372 | /*! System ram lets a frontend peek into a game systems main RAM */ | ||
| 373 | GAME_MEMORY_SYSTEM_RAM = 2, | ||
| 374 | |||
| 375 | /*! Video ram lets a frontend peek into a game systems video RAM (VRAM) */ | ||
| 376 | GAME_MEMORY_VIDEO_RAM = 3, | ||
| 377 | |||
| 378 | /*! Special memory types */ | ||
| 379 | GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 380 | GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 381 | GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM= ((3 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 382 | GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM= ((4 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 383 | GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM), | ||
| 384 | GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC), | ||
| 385 | } GAME_MEMORY; | ||
| 386 | |||
| 387 | /*! ID values for SIMD CPU features */ | ||
| 388 | typedef enum GAME_SIMD | ||
| 389 | { | ||
| 390 | GAME_SIMD_SSE = (1 << 0), | ||
| 391 | GAME_SIMD_SSE2 = (1 << 1), | ||
| 392 | GAME_SIMD_VMX = (1 << 2), | ||
| 393 | GAME_SIMD_VMX128 = (1 << 3), | ||
| 394 | GAME_SIMD_AVX = (1 << 4), | ||
| 395 | GAME_SIMD_NEON = (1 << 5), | ||
| 396 | GAME_SIMD_SSE3 = (1 << 6), | ||
| 397 | GAME_SIMD_SSSE3 = (1 << 7), | ||
| 398 | GAME_SIMD_MMX = (1 << 8), | ||
| 399 | GAME_SIMD_MMXEXT = (1 << 9), | ||
| 400 | GAME_SIMD_SSE4 = (1 << 10), | ||
| 401 | GAME_SIMD_SSE42 = (1 << 11), | ||
| 402 | GAME_SIMD_AVX2 = (1 << 12), | ||
| 403 | GAME_SIMD_VFPU = (1 << 13), | ||
| 404 | } GAME_SIMD; | ||
| 405 | ///} | ||
| 406 | |||
| 407 | /// @name Input types | ||
| 408 | ///{ | ||
| 409 | |||
| 410 | typedef enum GAME_INPUT_EVENT_SOURCE | ||
| 411 | { | ||
| 412 | GAME_INPUT_EVENT_DIGITAL_BUTTON, | ||
| 413 | GAME_INPUT_EVENT_ANALOG_BUTTON, | ||
| 414 | GAME_INPUT_EVENT_AXIS, | ||
| 415 | GAME_INPUT_EVENT_ANALOG_STICK, | ||
| 416 | GAME_INPUT_EVENT_ACCELEROMETER, | ||
| 417 | GAME_INPUT_EVENT_KEY, | ||
| 418 | GAME_INPUT_EVENT_RELATIVE_POINTER, | ||
| 419 | GAME_INPUT_EVENT_ABSOLUTE_POINTER, | ||
| 420 | GAME_INPUT_EVENT_MOTOR, | ||
| 421 | } GAME_INPUT_EVENT_SOURCE; | ||
| 422 | |||
| 423 | typedef enum GAME_KEY_MOD | ||
| 424 | { | ||
| 425 | GAME_KEY_MOD_NONE = 0x0000, | ||
| 426 | |||
| 427 | GAME_KEY_MOD_SHIFT = 0x0001, | ||
| 428 | GAME_KEY_MOD_CTRL = 0x0002, | ||
| 429 | GAME_KEY_MOD_ALT = 0x0004, | ||
| 430 | GAME_KEY_MOD_META = 0x0008, | ||
| 431 | GAME_KEY_MOD_SUPER = 0x0010, | ||
| 432 | |||
| 433 | GAME_KEY_MOD_NUMLOCK = 0x0100, | ||
| 434 | GAME_KEY_MOD_CAPSLOCK = 0x0200, | ||
| 435 | GAME_KEY_MOD_SCROLLOCK = 0x0400, | ||
| 436 | } GAME_KEY_MOD; | ||
| 437 | |||
| 438 | /*! | ||
| 439 | * \brief Type of port on the virtual game console | ||
| 440 | */ | ||
| 441 | typedef enum GAME_PORT_TYPE | ||
| 442 | { | ||
| 443 | GAME_PORT_UNKNOWN, | ||
| 444 | GAME_PORT_KEYBOARD, | ||
| 445 | GAME_PORT_MOUSE, | ||
| 446 | GAME_PORT_CONTROLLER, | ||
| 447 | } GAME_PORT_TYPE; | ||
| 448 | |||
| 449 | typedef struct game_controller_layout | ||
| 450 | { | ||
| 451 | char* controller_id; | ||
| 452 | bool provides_input; // False for multitaps | ||
| 453 | char** digital_buttons; | ||
| 454 | unsigned int digital_button_count; | ||
| 455 | char** analog_buttons; | ||
| 456 | unsigned int analog_button_count; | ||
| 457 | char** analog_sticks; | ||
| 458 | unsigned int analog_stick_count; | ||
| 459 | char** accelerometers; | ||
| 460 | unsigned int accelerometer_count; | ||
| 461 | char** keys; | ||
| 462 | unsigned int key_count; | ||
| 463 | char** rel_pointers; | ||
| 464 | unsigned int rel_pointer_count; | ||
| 465 | char** abs_pointers; | ||
| 466 | unsigned int abs_pointer_count; | ||
| 467 | char** motors; | ||
| 468 | unsigned int motor_count; | ||
| 469 | } ATTRIBUTE_PACKED game_controller_layout; | ||
| 470 | |||
| 471 | struct game_input_port; | ||
| 472 | |||
| 473 | /*! | ||
| 474 | * \brief Device that can provide input | ||
| 475 | */ | ||
| 476 | typedef struct game_input_device | ||
| 477 | { | ||
| 478 | const char* controller_id; // ID used in the Kodi controller API | ||
| 479 | const char* port_address; | ||
| 480 | game_input_port* available_ports; | ||
| 481 | unsigned int port_count; | ||
| 482 | } ATTRIBUTE_PACKED game_input_device; | ||
| 483 | |||
| 484 | /*! | ||
| 485 | * \brief Port that can provide input | ||
| 486 | * | ||
| 487 | * Ports can accept multiple devices and devices can have multiple ports, so | ||
| 488 | * the topology of possible configurations is a tree structure of alternating | ||
| 489 | * port and device nodes. | ||
| 490 | */ | ||
| 491 | typedef struct game_input_port | ||
| 492 | { | ||
| 493 | GAME_PORT_TYPE type; | ||
| 494 | const char* port_id; // Required for GAME_PORT_CONTROLLER type | ||
| 495 | game_input_device* accepted_devices; | ||
| 496 | unsigned int device_count; | ||
| 497 | } ATTRIBUTE_PACKED game_input_port; | ||
| 498 | |||
| 499 | /*! | ||
| 500 | * \brief The input topology is the possible ways to connect input devices | ||
| 501 | * | ||
| 502 | * This represents the logical topology, which is the possible connections that | ||
| 503 | * the game client's logic can handle. It is strictly a subset of the physical | ||
| 504 | * topology. Loops are not allowed. | ||
| 505 | */ | ||
| 506 | typedef struct game_input_topology | ||
| 507 | { | ||
| 508 | game_input_port *ports; //! The list of ports on the virtual game console | ||
| 509 | unsigned int port_count; //! The number of ports | ||
| 510 | int player_limit; //! A limit on the number of input-providing devices, or -1 for no limit | ||
| 511 | } ATTRIBUTE_PACKED game_input_topology; | ||
| 512 | |||
| 513 | typedef struct game_digital_button_event | ||
| 514 | { | ||
| 515 | bool pressed; | ||
| 516 | } ATTRIBUTE_PACKED game_digital_button_event; | ||
| 517 | |||
| 518 | typedef struct game_analog_button_event | ||
| 519 | { | ||
| 520 | float magnitude; | ||
| 521 | } ATTRIBUTE_PACKED game_analog_button_event; | ||
| 522 | |||
| 523 | typedef struct game_axis_event | ||
| 524 | { | ||
| 525 | float position; | ||
| 526 | } ATTRIBUTE_PACKED game_axis_event; | ||
| 527 | |||
| 528 | typedef struct game_analog_stick_event | ||
| 529 | { | ||
| 530 | float x; | ||
| 531 | float y; | ||
| 532 | } ATTRIBUTE_PACKED game_analog_stick_event; | ||
| 533 | |||
| 534 | typedef struct game_accelerometer_event | ||
| 535 | { | ||
| 536 | float x; | ||
| 537 | float y; | ||
| 538 | float z; | ||
| 539 | } ATTRIBUTE_PACKED game_accelerometer_event; | ||
| 540 | |||
| 541 | typedef struct game_key_event | ||
| 542 | { | ||
| 543 | bool pressed; | ||
| 544 | |||
| 545 | /*! | ||
| 546 | * If the keypress generates a printing character, the unicode value | ||
| 547 | * contains the character generated. If the key is a non-printing character, | ||
| 548 | * e.g. a function or arrow key, the unicode value is zero. | ||
| 549 | */ | ||
| 550 | uint32_t unicode; | ||
| 551 | |||
| 552 | GAME_KEY_MOD modifiers; | ||
| 553 | } ATTRIBUTE_PACKED game_key_event; | ||
| 554 | |||
| 555 | typedef struct game_rel_pointer_event | ||
| 556 | { | ||
| 557 | int x; | ||
| 558 | int y; | ||
| 559 | } ATTRIBUTE_PACKED game_rel_pointer_event; | ||
| 560 | |||
| 561 | typedef struct game_abs_pointer_event | ||
| 562 | { | ||
| 563 | bool pressed; | ||
| 564 | float x; | ||
| 565 | float y; | ||
| 566 | } ATTRIBUTE_PACKED game_abs_pointer_event; | ||
| 567 | |||
| 568 | typedef struct game_motor_event | ||
| 569 | { | ||
| 570 | float magnitude; | ||
| 571 | } ATTRIBUTE_PACKED game_motor_event; | ||
| 572 | |||
| 573 | typedef struct game_input_event | ||
| 574 | { | ||
| 575 | GAME_INPUT_EVENT_SOURCE type; | ||
| 576 | const char* controller_id; | ||
| 577 | GAME_PORT_TYPE port_type; | ||
| 578 | const char* port_address; | ||
| 579 | const char* feature_name; | ||
| 580 | union | ||
| 581 | { | ||
| 582 | struct game_digital_button_event digital_button; | ||
| 583 | struct game_analog_button_event analog_button; | ||
| 584 | struct game_axis_event axis; | ||
| 585 | struct game_analog_stick_event analog_stick; | ||
| 586 | struct game_accelerometer_event accelerometer; | ||
| 587 | struct game_key_event key; | ||
| 588 | struct game_rel_pointer_event rel_pointer; | ||
| 589 | struct game_abs_pointer_event abs_pointer; | ||
| 590 | struct game_motor_event motor; | ||
| 591 | }; | ||
| 592 | } ATTRIBUTE_PACKED game_input_event; | ||
| 593 | ///} | ||
| 594 | |||
| 595 | /// @name Environment types | ||
| 596 | ///{ | ||
| 597 | struct game_system_timing | ||
| 598 | { | ||
| 599 | double fps; // FPS of video content. | ||
| 600 | double sample_rate; // Sampling rate of audio. | ||
| 601 | }; | ||
| 602 | ///} | ||
| 603 | |||
| 604 | /*! Properties passed to the ADDON_Create() method of a game client */ | ||
| 605 | typedef struct AddonProps_Game | ||
| 606 | { | ||
| 607 | /*! | ||
| 608 | * The path of the game client being loaded. | ||
| 609 | */ | ||
| 610 | const char* game_client_dll_path; | ||
| 611 | |||
| 612 | /*! | ||
| 613 | * Paths to proxy DLLs used to load the game client. | ||
| 614 | */ | ||
| 615 | const char** proxy_dll_paths; | ||
| 616 | |||
| 617 | /*! | ||
| 618 | * Number of proxy DLL paths provided. | ||
| 619 | */ | ||
| 620 | unsigned int proxy_dll_count; | ||
| 621 | |||
| 622 | /*! | ||
| 623 | * The "system" directories of the frontend. These directories can be used to | ||
| 624 | * store system-specific ROMs such as BIOSes, configuration data, etc. | ||
| 625 | */ | ||
| 626 | const char** resource_directories; | ||
| 627 | |||
| 628 | /*! | ||
| 629 | * Number of resource directories provided | ||
| 630 | */ | ||
| 631 | unsigned int resource_directory_count; | ||
| 632 | |||
| 633 | /*! | ||
| 634 | * The writable directory of the frontend. This directory can be used to store | ||
| 635 | * SRAM, memory cards, high scores, etc, if the game client cannot use the | ||
| 636 | * regular memory interface, GetMemoryData(). | ||
| 637 | */ | ||
| 638 | const char* profile_directory; | ||
| 639 | |||
| 640 | /*! | ||
| 641 | * The value of the <supports_vfs> property from addon.xml | ||
| 642 | */ | ||
| 643 | bool supports_vfs; | ||
| 644 | |||
| 645 | /*! | ||
| 646 | * The extensions in the <extensions> property from addon.xml | ||
| 647 | */ | ||
| 648 | const char** extensions; | ||
| 649 | |||
| 650 | /*! | ||
| 651 | * Number of extensions provided | ||
| 652 | */ | ||
| 653 | unsigned int extension_count; | ||
| 654 | } AddonProps_Game; | ||
| 655 | |||
| 656 | typedef AddonProps_Game game_client_properties; | ||
| 657 | |||
| 658 | /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */ | ||
| 659 | |||
| 660 | typedef struct AddonToKodiFuncTable_Game | ||
| 661 | { | ||
| 662 | KODI_HANDLE kodiInstance; | ||
| 663 | |||
| 664 | void (*CloseGame)(void* kodiInstance); | ||
| 665 | void* (*OpenStream)(void*, const game_stream_properties*); | ||
| 666 | bool (*GetStreamBuffer)(void*, void*, unsigned int, unsigned int, game_stream_buffer*); | ||
| 667 | void (*AddStreamData)(void*, void*, const game_stream_packet*); | ||
| 668 | void (*ReleaseStreamBuffer)(void*, void*, game_stream_buffer*); | ||
| 669 | void (*CloseStream)(void*, void*); | ||
| 670 | game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol); | ||
| 671 | bool (*InputEvent)(void* kodiInstance, const game_input_event* event); | ||
| 672 | |||
| 673 | } AddonToKodiFuncTable_Game; | ||
| 674 | |||
| 675 | typedef struct KodiToAddonFuncTable_Game | ||
| 676 | { | ||
| 677 | GAME_ERROR (__cdecl* LoadGame)(const char*); | ||
| 678 | GAME_ERROR (__cdecl* LoadGameSpecial)(SPECIAL_GAME_TYPE, const char**, size_t); | ||
| 679 | GAME_ERROR (__cdecl* LoadStandalone)(void); | ||
| 680 | GAME_ERROR (__cdecl* UnloadGame)(void); | ||
| 681 | GAME_ERROR (__cdecl* GetGameTiming)(game_system_timing*); | ||
| 682 | GAME_REGION (__cdecl* GetRegion)(void); | ||
| 683 | bool (__cdecl* RequiresGameLoop)(void); | ||
| 684 | GAME_ERROR (__cdecl* RunFrame)(void); | ||
| 685 | GAME_ERROR (__cdecl* Reset)(void); | ||
| 686 | GAME_ERROR (__cdecl* HwContextReset)(void); | ||
| 687 | GAME_ERROR (__cdecl* HwContextDestroy)(void); | ||
| 688 | bool (__cdecl* HasFeature)(const char*, const char*); | ||
| 689 | game_input_topology* (__cdecl* GetTopology)(); | ||
| 690 | void (__cdecl* FreeTopology)(game_input_topology*); | ||
| 691 | void (__cdecl* SetControllerLayouts)(const game_controller_layout*, unsigned int); | ||
| 692 | bool (__cdecl* EnableKeyboard)(bool, const char*); | ||
| 693 | bool (__cdecl* EnableMouse)(bool, const char*); | ||
| 694 | bool (__cdecl* ConnectController)(bool, const char*, const char*); | ||
| 695 | bool (__cdecl* InputEvent)(const game_input_event*); | ||
| 696 | size_t (__cdecl* SerializeSize)(void); | ||
| 697 | GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t); | ||
| 698 | GAME_ERROR (__cdecl* Deserialize)(const uint8_t*, size_t); | ||
| 699 | GAME_ERROR (__cdecl* CheatReset)(void); | ||
| 700 | GAME_ERROR (__cdecl* GetMemory)(GAME_MEMORY, uint8_t**, size_t*); | ||
| 701 | GAME_ERROR (__cdecl* SetCheat)(unsigned int, bool, const char*); | ||
| 702 | } KodiToAddonFuncTable_Game; | ||
| 703 | |||
| 704 | typedef struct AddonInstance_Game | ||
| 705 | { | ||
| 706 | AddonProps_Game props; | ||
| 707 | AddonToKodiFuncTable_Game toKodi; | ||
| 708 | KodiToAddonFuncTable_Game toAddon; | ||
| 709 | } AddonInstance_Game; | ||
| 710 | |||
| 711 | #ifdef __cplusplus | ||
| 712 | } | ||
| 713 | #endif | ||
| 714 | |||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h deleted file mode 100644 index 233f682..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_vfs_types.h +++ /dev/null | |||
| @@ -1,261 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015-2018 Team Kodi | ||
| 3 | * | ||
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 5 | * See LICENSES/README.md for more information. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #ifndef TARGET_WINDOWS | ||
| 11 | #ifndef __cdecl | ||
| 12 | #define __cdecl | ||
| 13 | #endif | ||
| 14 | #ifndef __declspec | ||
| 15 | #define __declspec(X) | ||
| 16 | #endif | ||
| 17 | #endif | ||
| 18 | |||
| 19 | #include <stdint.h> | ||
| 20 | #include "xbmc_addon_types.h" | ||
| 21 | #ifdef BUILD_KODI_ADDON | ||
| 22 | #include "IFileTypes.h" | ||
| 23 | #else | ||
| 24 | #include "filesystem/IFileTypes.h" | ||
| 25 | #include "PlatformDefs.h" | ||
| 26 | #endif | ||
| 27 | |||
| 28 | extern "C" | ||
| 29 | { | ||
| 30 | |||
| 31 | struct VFSProperty | ||
| 32 | { | ||
| 33 | char* name; | ||
| 34 | char* val; | ||
| 35 | }; | ||
| 36 | |||
| 37 | struct VFSDirEntry | ||
| 38 | { | ||
| 39 | char* label; //!< item label | ||
| 40 | char* title; //!< item title | ||
| 41 | char* path; //!< item path | ||
| 42 | int num_props; //!< Number of properties attached to item | ||
| 43 | VFSProperty* properties; //!< Properties | ||
| 44 | //FILETIME mtime; //!< Mtime for file represented by item | ||
| 45 | bool folder; //!< Item is a folder | ||
| 46 | uint64_t size; //!< Size of file represented by item | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct VFSURL | ||
| 50 | { | ||
| 51 | const char* url; | ||
| 52 | const char* domain; | ||
| 53 | const char* hostname; | ||
| 54 | const char* filename; | ||
| 55 | unsigned int port; | ||
| 56 | const char* options; | ||
| 57 | const char* username; | ||
| 58 | const char* password; | ||
| 59 | const char* redacted; | ||
| 60 | const char* sharename; | ||
| 61 | }; | ||
| 62 | |||
| 63 | struct VFSCallbacks | ||
| 64 | { | ||
| 65 | //! \brief Require keyboard input | ||
| 66 | //! \param heading The heading of the keyboard dialog | ||
| 67 | //! \param input A pointer to the resulting string. Must be free'd by caller. | ||
| 68 | //! \return True if input was received, false otherwise | ||
| 69 | bool (__cdecl* GetKeyboardInput)(void* ctx, const char* heading, char** input); | ||
| 70 | |||
| 71 | //! \brief Display an error dialog | ||
| 72 | //! \param heading The heading of the error dialog | ||
| 73 | //! \param line1 The first line of the error dialog | ||
| 74 | //! \param line2 The second line of the error dialog. Can be NULL | ||
| 75 | //! \param line3 The third line of the error dialog. Can be NULL | ||
| 76 | void (__cdecl* SetErrorDialog)(void* ctx, const char* heading, const char* line1, const char* line2, const char* line3); | ||
| 77 | |||
| 78 | //! \brief Prompt the user for authentication of a URL | ||
| 79 | //! \param url The URL | ||
| 80 | void (__cdecl* RequireAuthentication)(void* ctx, const char* url); | ||
| 81 | |||
| 82 | //! \brief The context to be passed to the callbacks | ||
| 83 | void* ctx; | ||
| 84 | }; | ||
| 85 | |||
| 86 | typedef struct AddonProps_VFSEntry | ||
| 87 | { | ||
| 88 | int dummy; | ||
| 89 | } AddonProps_VFSEntry; | ||
| 90 | |||
| 91 | typedef AddonProps_VFSEntry VFS_PROPS; | ||
| 92 | |||
| 93 | typedef struct AddonToKodiFuncTable_VFSEntry | ||
| 94 | { | ||
| 95 | KODI_HANDLE kodiInstance; | ||
| 96 | } AddonToKodiFuncTable_VFSEntry; | ||
| 97 | |||
| 98 | typedef struct KodiToAddonFuncTable_VFSEntry | ||
| 99 | { | ||
| 100 | //! \brief Open a file for input | ||
| 101 | //! \param url The URL of the file | ||
| 102 | //! \return Context for the opened file | ||
| 103 | //! \sa IFile::Open | ||
| 104 | void* (__cdecl* Open) (VFSURL* url); | ||
| 105 | |||
| 106 | //! \brief Open a file for output | ||
| 107 | //! \param url The URL of the file | ||
| 108 | //! \param bOverwrite Whether or not to overwrite an existing file | ||
| 109 | //! \return Context for the opened file | ||
| 110 | //! \sa IFile::OpenForWrite | ||
| 111 | void* (__cdecl* OpenForWrite) (VFSURL* url, bool bOverWrite); | ||
| 112 | |||
| 113 | //! \brief Read from a file | ||
| 114 | //! \param context The context of the file | ||
| 115 | //! \param buffer The buffer to read data into | ||
| 116 | //! \param uiBufSize Number of bytes to read | ||
| 117 | //! \return Number of bytes read | ||
| 118 | //! \sa IFile::Read | ||
| 119 | ssize_t (__cdecl* Read) (void* context, void* buffer, size_t uiBufSize); | ||
| 120 | |||
| 121 | //! \brief Write to a file | ||
| 122 | //! \param context The context of the file | ||
| 123 | //! \param buffer The buffer to read data from | ||
| 124 | //! \param uiBufSize Number of bytes to write | ||
| 125 | //! \return Number of bytes written | ||
| 126 | //! \sa IFile::Write | ||
| 127 | ssize_t (__cdecl* Write) (void* context, const void* buffer, size_t uiBufSize); | ||
| 128 | |||
| 129 | //! \brief Seek in a file | ||
| 130 | //! \param context The context of the file | ||
| 131 | //! \param position The position to seek to | ||
| 132 | //! \param whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END) | ||
| 133 | //! \return Offset in file after seek | ||
| 134 | //! \sa IFile::Seek | ||
| 135 | int64_t (__cdecl* Seek) (void* context, int64_t position, int whence); | ||
| 136 | |||
| 137 | //! \brief Truncate a file | ||
| 138 | //! \param context The context of the file | ||
| 139 | //! \param size The size to truncate the file to | ||
| 140 | //! \return 0 on success, -1 on error | ||
| 141 | //! \sa IFile::Truncate | ||
| 142 | int (__cdecl* Truncate) (void* context, int64_t size); | ||
| 143 | |||
| 144 | //! \brief Get total size of a file | ||
| 145 | //! \param context The context of the file | ||
| 146 | //! \return Total file size | ||
| 147 | //! \sa IFile::GetLength | ||
| 148 | int64_t (__cdecl* GetLength) (void* context); | ||
| 149 | |||
| 150 | //! \brief Get current position in a file | ||
| 151 | //! \param context The context of the file | ||
| 152 | //! \return Current position | ||
| 153 | //! \sa IFile::GetPosition | ||
| 154 | int64_t (__cdecl* GetPosition) (void* context); | ||
| 155 | |||
| 156 | //! \brief Get chunk size of a file | ||
| 157 | //! \param context The context of the file | ||
| 158 | //! \return Chunk size | ||
| 159 | //! \sa IFile::GetChunkSize() | ||
| 160 | int (__cdecl* GetChunkSize)(void* context); | ||
| 161 | |||
| 162 | //! \brief Perform an IO-control on the file | ||
| 163 | //! \param context The context of the file | ||
| 164 | //! \param request The requested IO-control | ||
| 165 | //! \param param Parameter attached to the IO-control | ||
| 166 | //! \return -1 on error, >= 0 on success | ||
| 167 | //! \sa IFile::IoControl | ||
| 168 | int (__cdecl* IoControl) (void* context, XFILE::EIoControl request, void* param); | ||
| 169 | |||
| 170 | //! \brief Stat a file | ||
| 171 | //! \param url The URL of the file | ||
| 172 | //! \param buffer The buffer to store results in | ||
| 173 | //! \return -1 on error, 0 otherwise | ||
| 174 | //! \sa IFile::Stat | ||
| 175 | int (__cdecl* Stat) (VFSURL* url, struct __stat64* buffer); | ||
| 176 | //! \brief Close a file | ||
| 177 | //! \param context The context of the file | ||
| 178 | //! \return True on success, false on failure | ||
| 179 | //! \sa IFile::Close | ||
| 180 | |||
| 181 | bool (__cdecl* Close) (void* context); | ||
| 182 | |||
| 183 | //! \brief Check for file existence | ||
| 184 | //! \param url The URL of the file | ||
| 185 | //! \return True if file exists, false otherwise | ||
| 186 | //! \sa IFile::Exists | ||
| 187 | bool (__cdecl* Exists) (VFSURL* url); | ||
| 188 | |||
| 189 | //! \brief Clear out any idle connections | ||
| 190 | void (__cdecl* ClearOutIdle) (); | ||
| 191 | |||
| 192 | //! \brief Disconnect all connections | ||
| 193 | void (__cdecl* DisconnectAll) (); | ||
| 194 | |||
| 195 | //! \brief Delete a file | ||
| 196 | //! \param url The URL of the file | ||
| 197 | //! \return True if deletion was successful, false otherwise | ||
| 198 | //! \sa IFile::Delete | ||
| 199 | bool (__cdecl* Delete) (VFSURL* url); | ||
| 200 | |||
| 201 | //! \brief Rename a file | ||
| 202 | //! \param url The URL of the source file | ||
| 203 | //! \param url2 The URL of the destination file | ||
| 204 | //! \return True if deletion was successful, false otherwise | ||
| 205 | //! \sa IFile::Rename | ||
| 206 | bool (__cdecl* Rename) (VFSURL* url, VFSURL* url2); | ||
| 207 | |||
| 208 | //! \brief Check for directory existence | ||
| 209 | //! \param url The URL of the file | ||
| 210 | //! \return True if directory exists, false otherwise | ||
| 211 | //! \sa IDirectory::Exists | ||
| 212 | bool (__cdecl* DirectoryExists) (VFSURL* url); | ||
| 213 | |||
| 214 | //! \brief Remove a directory | ||
| 215 | //! \param url The URL of the directory | ||
| 216 | //! \return True if removal was successful, false otherwise | ||
| 217 | //! \sa IDirectory::Remove | ||
| 218 | bool (__cdecl* RemoveDirectory) (VFSURL* url); | ||
| 219 | |||
| 220 | //! \brief Create a directory | ||
| 221 | //! \param url The URL of the file | ||
| 222 | //! \return True if creation was successful, false otherwise | ||
| 223 | //! \sa IDirectory::Create | ||
| 224 | bool (__cdecl* CreateDirectory) (VFSURL* url); | ||
| 225 | |||
| 226 | //! \brief List a directory | ||
| 227 | //! \param url The URL of the directory | ||
| 228 | //! \param entries The entries in the directory | ||
| 229 | //! \param num_entries Number of entries in the directory | ||
| 230 | //! \param callbacks A callback structure | ||
| 231 | //! \return Context for the directory listing | ||
| 232 | //! \sa IDirectory::GetDirectory | ||
| 233 | void* (__cdecl* GetDirectory) (VFSURL* url, | ||
| 234 | VFSDirEntry** entries, | ||
| 235 | int* num_entries, | ||
| 236 | VFSCallbacks* callbacks); | ||
| 237 | |||
| 238 | //! \brief Free up resources after listing a directory | ||
| 239 | void (__cdecl* FreeDirectory) (void* ctx); | ||
| 240 | |||
| 241 | //! \brief Check if file should be presented as a directory (multiple streams) | ||
| 242 | //! \param url The URL of the file | ||
| 243 | //! \param entries The entries in the directory | ||
| 244 | //! \param num_entries Number of entries in the directory | ||
| 245 | //! \param rootpath Path to root directory if multiple entries | ||
| 246 | //! \return Context for the directory listing | ||
| 247 | //! \sa IFileDirectory::ContainsFiles, FreeDirectory | ||
| 248 | void* (__cdecl* ContainsFiles) (VFSURL* url, | ||
| 249 | VFSDirEntry** entries, | ||
| 250 | int* num_entries, | ||
| 251 | char* rootpath); | ||
| 252 | } KodiToAddonFuncTable_VFSEntry; | ||
| 253 | |||
| 254 | typedef struct AddonInstance_VFSEntry | ||
| 255 | { | ||
| 256 | AddonProps_VFSEntry props; | ||
| 257 | AddonToKodiFuncTable_VFSEntry toKodi; | ||
| 258 | KodiToAddonFuncTable_VFSEntry toAddon; | ||
| 259 | } AddonInstance_VFSEntry; | ||
| 260 | |||
| 261 | } | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h deleted file mode 100644 index 2e6459b..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h +++ /dev/null | |||
| @@ -1,155 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-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 "libXBMC_addon.h" | ||
| 12 | #include "kodi_game_types.h" | ||
| 13 | |||
| 14 | #include <string> | ||
| 15 | #include <stdio.h> | ||
| 16 | |||
| 17 | #if defined(ANDROID) | ||
| 18 | #include <sys/stat.h> | ||
| 19 | #endif | ||
| 20 | |||
| 21 | class CHelper_libKODI_game | ||
| 22 | { | ||
| 23 | public: | ||
| 24 | CHelper_libKODI_game(void) : | ||
| 25 | m_handle(nullptr), | ||
| 26 | m_callbacks(nullptr) | ||
| 27 | { | ||
| 28 | } | ||
| 29 | |||
| 30 | ~CHelper_libKODI_game(void) | ||
| 31 | { | ||
| 32 | } | ||
| 33 | |||
| 34 | /*! | ||
| 35 | * @brief Resolve all callback methods | ||
| 36 | * @param handle Pointer to the add-on | ||
| 37 | * @return True when all methods were resolved, false otherwise. | ||
| 38 | */ | ||
| 39 | bool RegisterMe(void* handle) | ||
| 40 | { | ||
| 41 | m_handle = static_cast<AddonCB*>(handle); | ||
| 42 | if (m_handle) | ||
| 43 | m_callbacks = (AddonInstance_Game*)m_handle->GameLib_RegisterMe(m_handle->addonData); | ||
| 44 | if (!m_callbacks) | ||
| 45 | fprintf(stderr, "libKODI_game-ERROR: GameLib_RegisterMe can't get callback table from Kodi !!!\n"); | ||
| 46 | |||
| 47 | return m_callbacks != nullptr; | ||
| 48 | } | ||
| 49 | |||
| 50 | // --- Game callbacks -------------------------------------------------------- | ||
| 51 | |||
| 52 | /*! | ||
| 53 | * \brief Requests the frontend to stop the current game | ||
| 54 | */ | ||
| 55 | void CloseGame(void) | ||
| 56 | { | ||
| 57 | m_callbacks->toKodi.CloseGame(m_callbacks->toKodi.kodiInstance); | ||
| 58 | } | ||
| 59 | |||
| 60 | /*! | ||
| 61 | * \brief Create a stream for gameplay data | ||
| 62 | * | ||
| 63 | * \param properties The stream properties | ||
| 64 | * | ||
| 65 | * \return A stream handle, or NULL on failure | ||
| 66 | */ | ||
| 67 | void* OpenStream(const game_stream_properties &properties) | ||
| 68 | { | ||
| 69 | return m_callbacks->toKodi.OpenStream(m_callbacks->toKodi.kodiInstance, &properties); | ||
| 70 | } | ||
| 71 | |||
| 72 | /*! | ||
| 73 | * \brief Get a buffer for zero-copy stream data | ||
| 74 | * | ||
| 75 | * \param stream The stream handle | ||
| 76 | * \param width The framebuffer width, or 0 for no width specified | ||
| 77 | * \param height The framebuffer height, or 0 for no height specified | ||
| 78 | * \param[out] buffer The buffer, or unmodified if false is returned | ||
| 79 | * | ||
| 80 | * If this returns true, buffer must be freed using ReleaseStreamBuffer(). | ||
| 81 | * | ||
| 82 | * \return True if buffer was set, false otherwise | ||
| 83 | */ | ||
| 84 | bool GetStreamBuffer(void *stream, unsigned int width, unsigned int height, game_stream_buffer &buffer) | ||
| 85 | { | ||
| 86 | return m_callbacks->toKodi.GetStreamBuffer(m_callbacks->toKodi.kodiInstance, stream, width, height, &buffer); | ||
| 87 | } | ||
| 88 | |||
| 89 | /*! | ||
| 90 | * \brief Add a data packet to a stream | ||
| 91 | * | ||
| 92 | * \param stream The target stream | ||
| 93 | * \param packet The data packet | ||
| 94 | */ | ||
| 95 | void AddStreamData(void *stream, const game_stream_packet &packet) | ||
| 96 | { | ||
| 97 | m_callbacks->toKodi.AddStreamData(m_callbacks->toKodi.kodiInstance, stream, &packet); | ||
| 98 | } | ||
| 99 | |||
| 100 | /*! | ||
| 101 | * \brief Free an allocated buffer | ||
| 102 | * | ||
| 103 | * \param stream The stream handle | ||
| 104 | * \param buffer The buffer returned from GetStreamBuffer() | ||
| 105 | */ | ||
| 106 | void ReleaseStreamBuffer(void *stream, game_stream_buffer &buffer) | ||
| 107 | { | ||
| 108 | m_callbacks->toKodi.ReleaseStreamBuffer(m_callbacks->toKodi.kodiInstance, stream, &buffer); | ||
| 109 | } | ||
| 110 | |||
| 111 | /*! | ||
| 112 | * \brief Free the specified stream | ||
| 113 | * | ||
| 114 | * \param stream The stream to close | ||
| 115 | */ | ||
| 116 | void CloseStream(void *stream) | ||
| 117 | { | ||
| 118 | m_callbacks->toKodi.CloseStream(m_callbacks->toKodi.kodiInstance, stream); | ||
| 119 | } | ||
| 120 | |||
| 121 | // -- Hardware rendering callbacks ------------------------------------------- | ||
| 122 | |||
| 123 | /*! | ||
| 124 | * \brief Get a symbol from the hardware context | ||
| 125 | * | ||
| 126 | * \param sym The symbol's name | ||
| 127 | * | ||
| 128 | * \return A function pointer for the specified symbol | ||
| 129 | */ | ||
| 130 | game_proc_address_t HwGetProcAddress(const char* sym) | ||
| 131 | { | ||
| 132 | return m_callbacks->toKodi.HwGetProcAddress(m_callbacks->toKodi.kodiInstance, sym); | ||
| 133 | } | ||
| 134 | |||
| 135 | // --- Input callbacks ------------------------------------------------------- | ||
| 136 | |||
| 137 | /*! | ||
| 138 | * \brief Notify the port of an input event | ||
| 139 | * | ||
| 140 | * \param event The input event | ||
| 141 | * | ||
| 142 | * Input events can arrive for the following sources: | ||
| 143 | * - GAME_INPUT_EVENT_MOTOR | ||
| 144 | * | ||
| 145 | * \return true if the event was handled, false otherwise | ||
| 146 | */ | ||
| 147 | bool InputEvent(const game_input_event& event) | ||
| 148 | { | ||
| 149 | return m_callbacks->toKodi.InputEvent(m_callbacks->toKodi.kodiInstance, &event); | ||
| 150 | } | ||
| 151 | |||
| 152 | private: | ||
| 153 | AddonCB* m_handle; | ||
| 154 | AddonInstance_Game* m_callbacks; | ||
| 155 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h deleted file mode 100644 index ff51c98..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h +++ /dev/null | |||
| @@ -1,1186 +0,0 @@ | |||
| 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 <string> | ||
| 12 | #include <vector> | ||
| 13 | #include <string.h> | ||
| 14 | #include <stdlib.h> | ||
| 15 | #include <stdio.h> | ||
| 16 | #include "libXBMC_addon.h" | ||
| 17 | |||
| 18 | typedef void* GUIHANDLE; | ||
| 19 | |||
| 20 | namespace KodiAPI | ||
| 21 | { | ||
| 22 | namespace GUI | ||
| 23 | { | ||
| 24 | |||
| 25 | typedef struct CB_GUILib | ||
| 26 | { | ||
| 27 | void (*Lock)(); | ||
| 28 | void (*Unlock)(); | ||
| 29 | int (*GetScreenHeight)(); | ||
| 30 | int (*GetScreenWidth)(); | ||
| 31 | int (*GetVideoResolution)(); | ||
| 32 | GUIHANDLE (*Window_New)(void *addonData, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); | ||
| 33 | void (*Window_Delete)(void *addonData, GUIHANDLE handle); | ||
| 34 | void (*Window_SetCallbacks)(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*)(GUIHANDLE handle), bool (*)(GUIHANDLE handle, int), bool (*)(GUIHANDLE handle, int), bool (*)(GUIHANDLE handle, int)); | ||
| 35 | bool (*Window_Show)(void *addonData, GUIHANDLE handle); | ||
| 36 | bool (*Window_Close)(void *addonData, GUIHANDLE handle); | ||
| 37 | bool (*Window_DoModal)(void *addonData, GUIHANDLE handle); | ||
| 38 | bool (*Window_SetFocusId)(void *addonData, GUIHANDLE handle, int iControlId); | ||
| 39 | int (*Window_GetFocusId)(void *addonData, GUIHANDLE handle); | ||
| 40 | bool (*Window_SetCoordinateResolution)(void *addonData, GUIHANDLE handle, int res); | ||
| 41 | void (*Window_SetProperty)(void *addonData, GUIHANDLE handle, const char *key, const char *value); | ||
| 42 | void (*Window_SetPropertyInt)(void *addonData, GUIHANDLE handle, const char *key, int value); | ||
| 43 | void (*Window_SetPropertyBool)(void *addonData, GUIHANDLE handle, const char *key, bool value); | ||
| 44 | void (*Window_SetPropertyDouble)(void *addonData, GUIHANDLE handle, const char *key, double value); | ||
| 45 | const char* (*Window_GetProperty)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 46 | int (*Window_GetPropertyInt)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 47 | bool (*Window_GetPropertyBool)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 48 | double (*Window_GetPropertyDouble)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 49 | void (*Window_ClearProperties)(void *addonData, GUIHANDLE handle); | ||
| 50 | int (*Window_GetListSize)(void *addonData, GUIHANDLE handle); | ||
| 51 | void (*Window_ClearList)(void *addonData, GUIHANDLE handle); | ||
| 52 | GUIHANDLE (*Window_AddItem)(void *addonData, GUIHANDLE handle, GUIHANDLE item, int itemPosition); | ||
| 53 | GUIHANDLE (*Window_AddStringItem)(void *addonData, GUIHANDLE handle, const char *itemName, int itemPosition); | ||
| 54 | void (*Window_RemoveItem)(void *addonData, GUIHANDLE handle, int itemPosition); | ||
| 55 | GUIHANDLE (*Window_GetListItem)(void *addonData, GUIHANDLE handle, int listPos); | ||
| 56 | void (*Window_SetCurrentListPosition)(void *addonData, GUIHANDLE handle, int listPos); | ||
| 57 | int (*Window_GetCurrentListPosition)(void *addonData, GUIHANDLE handle); | ||
| 58 | GUIHANDLE (*Window_GetControl_Spin)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 59 | GUIHANDLE (*Window_GetControl_Button)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 60 | GUIHANDLE (*Window_GetControl_RadioButton)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 61 | GUIHANDLE (*Window_GetControl_Edit)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 62 | GUIHANDLE (*Window_GetControl_Progress)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 63 | GUIHANDLE (*Window_GetControl_RenderAddon)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 64 | void (*Window_SetControlLabel)(void *addonData, GUIHANDLE handle, int controlId, const char *label); | ||
| 65 | void (*Window_MarkDirtyRegion)(void *addonData, GUIHANDLE handle); | ||
| 66 | void (*Control_Spin_SetVisible)(void *addonData, GUIHANDLE spinhandle, bool yesNo); | ||
| 67 | void (*Control_Spin_SetText)(void *addonData, GUIHANDLE spinhandle, const char *label); | ||
| 68 | void (*Control_Spin_Clear)(void *addonData, GUIHANDLE spinhandle); | ||
| 69 | void (*Control_Spin_AddLabel)(void *addonData, GUIHANDLE spinhandle, const char *label, int iValue); | ||
| 70 | int (*Control_Spin_GetValue)(void *addonData, GUIHANDLE spinhandle); | ||
| 71 | void (*Control_Spin_SetValue)(void *addonData, GUIHANDLE spinhandle, int iValue); | ||
| 72 | void (*Control_RadioButton_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 73 | void (*Control_RadioButton_SetText)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 74 | void (*Control_RadioButton_SetSelected)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 75 | bool (*Control_RadioButton_IsSelected)(void *addonData, GUIHANDLE handle); | ||
| 76 | void (*Control_Progress_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 77 | float (*Control_Progress_GetPercentage)(void *addonData, GUIHANDLE handle); | ||
| 78 | void (*Control_Progress_SetInfo)(void *addonData, GUIHANDLE handle, int iInfo); | ||
| 79 | int (*Control_Progress_GetInfo)(void *addonData, GUIHANDLE handle); | ||
| 80 | const char* (*Control_Progress_GetDescription)(void *addonData, GUIHANDLE handle); | ||
| 81 | GUIHANDLE (*Window_GetControl_Slider)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 82 | void (*Control_Slider_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 83 | const char *(*Control_Slider_GetDescription)(void *addonData, GUIHANDLE handle); | ||
| 84 | void (*Control_Slider_SetIntRange)(void *addonData, GUIHANDLE handle, int iStart, int iEnd); | ||
| 85 | void (*Control_Slider_SetIntValue)(void *addonData, GUIHANDLE handle, int iValue); | ||
| 86 | int (*Control_Slider_GetIntValue)(void *addonData, GUIHANDLE handle); | ||
| 87 | void (*Control_Slider_SetIntInterval)(void *addonData, GUIHANDLE handle, int iInterval); | ||
| 88 | void (*Control_Slider_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 89 | float (*Control_Slider_GetPercentage)(void *addonData, GUIHANDLE handle); | ||
| 90 | void (*Control_Slider_SetFloatRange)(void *addonData, GUIHANDLE handle, float fStart, float fEnd); | ||
| 91 | void (*Control_Slider_SetFloatValue)(void *addonData, GUIHANDLE handle, float fValue); | ||
| 92 | float (*Control_Slider_GetFloatValue)(void *addonData, GUIHANDLE handle); | ||
| 93 | void (*Control_Slider_SetFloatInterval)(void *addonData, GUIHANDLE handle, float fInterval); | ||
| 94 | GUIHANDLE (*Window_GetControl_SettingsSlider)(void *addonData, GUIHANDLE handle, int controlId); | ||
| 95 | void (*Control_SettingsSlider_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 96 | void (*Control_SettingsSlider_SetText)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 97 | const char *(*Control_SettingsSlider_GetDescription)(void *addonData, GUIHANDLE handle); | ||
| 98 | void (*Control_SettingsSlider_SetIntRange)(void *addonData, GUIHANDLE handle, int iStart, int iEnd); | ||
| 99 | void (*Control_SettingsSlider_SetIntValue)(void *addonData, GUIHANDLE handle, int iValue); | ||
| 100 | int (*Control_SettingsSlider_GetIntValue)(void *addonData, GUIHANDLE handle); | ||
| 101 | void (*Control_SettingsSlider_SetIntInterval)(void *addonData, GUIHANDLE handle, int iInterval); | ||
| 102 | void (*Control_SettingsSlider_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 103 | float (*Control_SettingsSlider_GetPercentage)(void *addonData, GUIHANDLE handle); | ||
| 104 | void (*Control_SettingsSlider_SetFloatRange)(void *addonData, GUIHANDLE handle, float fStart, float fEnd); | ||
| 105 | void (*Control_SettingsSlider_SetFloatValue)(void *addonData, GUIHANDLE handle, float fValue); | ||
| 106 | float (*Control_SettingsSlider_GetFloatValue)(void *addonData, GUIHANDLE handle); | ||
| 107 | void (*Control_SettingsSlider_SetFloatInterval)(void *addonData, GUIHANDLE handle, float fInterval); | ||
| 108 | GUIHANDLE (*ListItem_Create)(void *addonData, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); | ||
| 109 | const char* (*ListItem_GetLabel)(void *addonData, GUIHANDLE handle); | ||
| 110 | void (*ListItem_SetLabel)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 111 | const char* (*ListItem_GetLabel2)(void *addonData, GUIHANDLE handle); | ||
| 112 | void (*ListItem_SetLabel2)(void *addonData, GUIHANDLE handle, const char *label); | ||
| 113 | void (*ListItem_SetIconImage)(void *addonData, GUIHANDLE handle, const char *image); | ||
| 114 | void (*ListItem_SetThumbnailImage)(void *addonData, GUIHANDLE handle, const char *image); | ||
| 115 | void (*ListItem_SetInfo)(void *addonData, GUIHANDLE handle, const char *info); | ||
| 116 | void (*ListItem_SetProperty)(void *addonData, GUIHANDLE handle, const char *key, const char *value); | ||
| 117 | const char* (*ListItem_GetProperty)(void *addonData, GUIHANDLE handle, const char *key); | ||
| 118 | void (*ListItem_SetPath)(void *addonData, GUIHANDLE handle, const char *path); | ||
| 119 | void (*RenderAddon_SetCallbacks)(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*createCB)(GUIHANDLE,int,int,int,int,void*), void (*renderCB)(GUIHANDLE), void (*stopCB)(GUIHANDLE), bool (*dirtyCB)(GUIHANDLE)); | ||
| 120 | void (*RenderAddon_Delete)(void *addonData, GUIHANDLE handle); | ||
| 121 | void (*RenderAddon_MarkDirty)(void *addonData, GUIHANDLE handle); | ||
| 122 | |||
| 123 | bool (*Dialog_Keyboard_ShowAndGetInputWithHead)(char &strTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); | ||
| 124 | bool (*Dialog_Keyboard_ShowAndGetInput)(char &strTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 125 | bool (*Dialog_Keyboard_ShowAndGetNewPasswordWithHead)(char &newPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 126 | bool (*Dialog_Keyboard_ShowAndGetNewPassword)(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 127 | bool (*Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead)(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmpty, unsigned int autoCloseMs); | ||
| 128 | bool (*Dialog_Keyboard_ShowAndVerifyNewPassword)(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 129 | int (*Dialog_Keyboard_ShowAndVerifyPassword)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); | ||
| 130 | bool (*Dialog_Keyboard_ShowAndGetFilter)(char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); | ||
| 131 | bool (*Dialog_Keyboard_SendTextToActiveKeyboard)(const char *aTextString, bool closeKeyboard); | ||
| 132 | bool (*Dialog_Keyboard_isKeyboardActivated)(); | ||
| 133 | |||
| 134 | bool (*Dialog_Numeric_ShowAndVerifyNewPassword)(char &strNewPassword, unsigned int iMaxStringSize); | ||
| 135 | int (*Dialog_Numeric_ShowAndVerifyPassword)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); | ||
| 136 | bool (*Dialog_Numeric_ShowAndVerifyInput)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); | ||
| 137 | bool (*Dialog_Numeric_ShowAndGetTime)(tm &time, const char *strHeading); | ||
| 138 | bool (*Dialog_Numeric_ShowAndGetDate)(tm &date, const char *strHeading); | ||
| 139 | bool (*Dialog_Numeric_ShowAndGetIPAddress)(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading); | ||
| 140 | bool (*Dialog_Numeric_ShowAndGetNumber)(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); | ||
| 141 | bool (*Dialog_Numeric_ShowAndGetSeconds)(char &timeString, unsigned int iMaxStringSize, const char *strHeading); | ||
| 142 | |||
| 143 | bool (*Dialog_FileBrowser_ShowAndGetFile)(const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); | ||
| 144 | |||
| 145 | void (*Dialog_OK_ShowAndGetInputSingleText)(const char *heading, const char *text); | ||
| 146 | void (*Dialog_OK_ShowAndGetInputLineText)(const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 147 | |||
| 148 | bool (*Dialog_YesNo_ShowAndGetInputSingleText)(const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); | ||
| 149 | bool (*Dialog_YesNo_ShowAndGetInputLineText)(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 150 | bool (*Dialog_YesNo_ShowAndGetInputLineButtonText)(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); | ||
| 151 | |||
| 152 | void (*Dialog_TextViewer)(const char *heading, const char *text); | ||
| 153 | |||
| 154 | int (*Dialog_Select)(const char *heading, const char *entries[], unsigned int size, int selected); | ||
| 155 | } CB_GUILib; | ||
| 156 | |||
| 157 | } /* namespace GUI */ | ||
| 158 | } /* namespace KodiAPI */ | ||
| 159 | |||
| 160 | |||
| 161 | #define ADDON_ACTION_PREVIOUS_MENU 10 | ||
| 162 | #define ADDON_ACTION_CLOSE_DIALOG 51 | ||
| 163 | #define ADDON_ACTION_NAV_BACK 92 | ||
| 164 | |||
| 165 | class CAddonGUIControlBase | ||
| 166 | { | ||
| 167 | public: | ||
| 168 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 169 | |||
| 170 | protected: | ||
| 171 | CAddonGUIControlBase(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIControlBase* window) | ||
| 172 | : m_controlHandle(nullptr), m_Handle(hdl), m_cb(cb), m_Window(window) {} | ||
| 173 | virtual ~CAddonGUIControlBase() = default; | ||
| 174 | |||
| 175 | GUIHANDLE m_controlHandle; | ||
| 176 | AddonCB* m_Handle; | ||
| 177 | KodiAPI::GUI::CB_GUILib* m_cb; | ||
| 178 | CAddonGUIControlBase* m_Window; | ||
| 179 | |||
| 180 | private: | ||
| 181 | CAddonGUIControlBase() = delete; | ||
| 182 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 183 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 184 | }; | ||
| 185 | |||
| 186 | class CAddonListItem : public CAddonGUIControlBase | ||
| 187 | { | ||
| 188 | public: | ||
| 189 | CAddonListItem(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) | ||
| 190 | : CAddonGUIControlBase(hdl, cb, nullptr) | ||
| 191 | { | ||
| 192 | m_controlHandle = m_cb->ListItem_Create(m_Handle->addonData, label, label2, iconImage, thumbnailImage, path); | ||
| 193 | } | ||
| 194 | |||
| 195 | ~CAddonListItem() override = default; | ||
| 196 | |||
| 197 | const char *GetLabel() | ||
| 198 | { | ||
| 199 | if (!m_controlHandle) | ||
| 200 | return ""; | ||
| 201 | |||
| 202 | return m_cb->ListItem_GetLabel(m_Handle->addonData, m_controlHandle); | ||
| 203 | } | ||
| 204 | |||
| 205 | void SetLabel(const char *label) | ||
| 206 | { | ||
| 207 | if (m_controlHandle) | ||
| 208 | m_cb->ListItem_SetLabel(m_Handle->addonData, m_controlHandle, label); | ||
| 209 | } | ||
| 210 | |||
| 211 | const char *GetLabel2() | ||
| 212 | { | ||
| 213 | if (!m_controlHandle) | ||
| 214 | return ""; | ||
| 215 | |||
| 216 | return m_cb->ListItem_GetLabel2(m_Handle->addonData, m_controlHandle); | ||
| 217 | } | ||
| 218 | |||
| 219 | void SetLabel2(const char *label) | ||
| 220 | { | ||
| 221 | if (m_controlHandle) | ||
| 222 | m_cb->ListItem_SetLabel2(m_Handle->addonData, m_controlHandle, label); | ||
| 223 | } | ||
| 224 | |||
| 225 | void SetIconImage(const char *image) | ||
| 226 | { | ||
| 227 | if (m_controlHandle) | ||
| 228 | m_cb->ListItem_SetIconImage(m_Handle->addonData, m_controlHandle, image); | ||
| 229 | } | ||
| 230 | |||
| 231 | void SetThumbnailImage(const char *image) | ||
| 232 | { | ||
| 233 | if (m_controlHandle) | ||
| 234 | m_cb->ListItem_SetThumbnailImage(m_Handle->addonData, m_controlHandle, image); | ||
| 235 | } | ||
| 236 | |||
| 237 | void SetInfo(const char *Info) | ||
| 238 | { | ||
| 239 | if (m_controlHandle) | ||
| 240 | m_cb->ListItem_SetInfo(m_Handle->addonData, m_controlHandle, Info); | ||
| 241 | } | ||
| 242 | |||
| 243 | void SetProperty(const char *key, const char *value) | ||
| 244 | { | ||
| 245 | if (m_controlHandle) | ||
| 246 | m_cb->ListItem_SetProperty(m_Handle->addonData, m_controlHandle, key, value); | ||
| 247 | } | ||
| 248 | |||
| 249 | const char *GetProperty(const char *key) const | ||
| 250 | { | ||
| 251 | if (!m_controlHandle) | ||
| 252 | return ""; | ||
| 253 | |||
| 254 | return m_cb->ListItem_GetProperty(m_Handle->addonData, m_controlHandle, key); | ||
| 255 | } | ||
| 256 | |||
| 257 | void SetPath(const char *Path) | ||
| 258 | { | ||
| 259 | if (m_controlHandle) | ||
| 260 | m_cb->ListItem_SetPath(m_Handle->addonData, m_controlHandle, Path); | ||
| 261 | } | ||
| 262 | }; | ||
| 263 | |||
| 264 | class CAddonGUIWindow : public CAddonGUIControlBase | ||
| 265 | { | ||
| 266 | public: | ||
| 267 | CAddonGUIWindow(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) | ||
| 268 | : CAddonGUIControlBase(hdl, cb, nullptr) | ||
| 269 | , m_cbhdl(nullptr) | ||
| 270 | , CBOnInit(nullptr) | ||
| 271 | , CBOnFocus(nullptr) | ||
| 272 | , CBOnClick(nullptr) | ||
| 273 | , CBOnAction(nullptr) | ||
| 274 | { | ||
| 275 | if (hdl && cb) | ||
| 276 | { | ||
| 277 | m_controlHandle = m_cb->Window_New(m_Handle->addonData, xmlFilename, defaultSkin, forceFallback, asDialog); | ||
| 278 | if (!m_controlHandle) | ||
| 279 | fprintf(stderr, "libKODI_guilib: ERROR: Can't create window class !!!\n"); | ||
| 280 | |||
| 281 | m_cb->Window_SetCallbacks(m_Handle->addonData, m_controlHandle, this, OnInitCB, OnClickCB, OnFocusCB, OnActionCB); | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | ~CAddonGUIWindow() override | ||
| 286 | { | ||
| 287 | if (m_Handle && m_cb && m_controlHandle) | ||
| 288 | { | ||
| 289 | m_cb->Window_Delete(m_Handle->addonData, m_controlHandle); | ||
| 290 | m_controlHandle = nullptr; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 | bool Show() | ||
| 295 | { | ||
| 296 | return m_cb->Window_Show(m_Handle->addonData, m_controlHandle); | ||
| 297 | } | ||
| 298 | |||
| 299 | void Close() | ||
| 300 | { | ||
| 301 | m_cb->Window_Close(m_Handle->addonData, m_controlHandle); | ||
| 302 | } | ||
| 303 | |||
| 304 | void DoModal() | ||
| 305 | { | ||
| 306 | m_cb->Window_DoModal(m_Handle->addonData, m_controlHandle); | ||
| 307 | } | ||
| 308 | |||
| 309 | bool SetFocusId(int iControlId) | ||
| 310 | { | ||
| 311 | return m_cb->Window_SetFocusId(m_Handle->addonData, m_controlHandle, iControlId); | ||
| 312 | } | ||
| 313 | |||
| 314 | int GetFocusId() | ||
| 315 | { | ||
| 316 | return m_cb->Window_GetFocusId(m_Handle->addonData, m_controlHandle); | ||
| 317 | } | ||
| 318 | |||
| 319 | bool SetCoordinateResolution(int res) | ||
| 320 | { | ||
| 321 | return m_cb->Window_SetCoordinateResolution(m_Handle->addonData, m_controlHandle, res); | ||
| 322 | } | ||
| 323 | |||
| 324 | void SetProperty(const char *key, const char *value) | ||
| 325 | { | ||
| 326 | m_cb->Window_SetProperty(m_Handle->addonData, m_controlHandle, key, value); | ||
| 327 | } | ||
| 328 | |||
| 329 | void SetPropertyInt(const char *key, int value) | ||
| 330 | { | ||
| 331 | m_cb->Window_SetPropertyInt(m_Handle->addonData, m_controlHandle, key, value); | ||
| 332 | } | ||
| 333 | |||
| 334 | void SetPropertyBool(const char *key, bool value) | ||
| 335 | { | ||
| 336 | m_cb->Window_SetPropertyBool(m_Handle->addonData, m_controlHandle, key, value); | ||
| 337 | } | ||
| 338 | |||
| 339 | void SetPropertyDouble(const char *key, double value) | ||
| 340 | { | ||
| 341 | m_cb->Window_SetPropertyDouble(m_Handle->addonData, m_controlHandle, key, value); | ||
| 342 | } | ||
| 343 | |||
| 344 | const char *GetProperty(const char *key) const | ||
| 345 | { | ||
| 346 | return m_cb->Window_GetProperty(m_Handle->addonData, m_controlHandle, key); | ||
| 347 | } | ||
| 348 | |||
| 349 | int GetPropertyInt(const char *key) const | ||
| 350 | { | ||
| 351 | return m_cb->Window_GetPropertyInt(m_Handle->addonData, m_controlHandle, key); | ||
| 352 | } | ||
| 353 | |||
| 354 | bool GetPropertyBool(const char *key) const | ||
| 355 | { | ||
| 356 | return m_cb->Window_GetPropertyBool(m_Handle->addonData, m_controlHandle, key); | ||
| 357 | } | ||
| 358 | |||
| 359 | double GetPropertyDouble(const char *key) const | ||
| 360 | { | ||
| 361 | return m_cb->Window_GetPropertyDouble(m_Handle->addonData, m_controlHandle, key); | ||
| 362 | } | ||
| 363 | |||
| 364 | void ClearProperties() | ||
| 365 | { | ||
| 366 | m_cb->Window_ClearProperties(m_Handle->addonData, m_controlHandle); | ||
| 367 | } | ||
| 368 | |||
| 369 | int GetListSize() | ||
| 370 | { | ||
| 371 | return m_cb->Window_GetListSize(m_Handle->addonData, m_controlHandle); | ||
| 372 | } | ||
| 373 | |||
| 374 | void ClearList() | ||
| 375 | { | ||
| 376 | m_cb->Window_ClearList(m_Handle->addonData, m_controlHandle); | ||
| 377 | } | ||
| 378 | |||
| 379 | GUIHANDLE AddStringItem(const char *name, int itemPosition = -1) | ||
| 380 | { | ||
| 381 | return m_cb->Window_AddStringItem(m_Handle->addonData, m_controlHandle, name, itemPosition); | ||
| 382 | } | ||
| 383 | |||
| 384 | void AddItem(GUIHANDLE item, int itemPosition = -1) | ||
| 385 | { | ||
| 386 | m_cb->Window_AddItem(m_Handle->addonData, m_controlHandle, item, itemPosition); | ||
| 387 | } | ||
| 388 | |||
| 389 | void AddItem(CAddonListItem *item, int itemPosition = -1) | ||
| 390 | { | ||
| 391 | m_cb->Window_AddItem(m_Handle->addonData, m_controlHandle, item->GetControlHandle(), itemPosition); | ||
| 392 | } | ||
| 393 | |||
| 394 | void RemoveItem(int itemPosition) | ||
| 395 | { | ||
| 396 | m_cb->Window_RemoveItem(m_Handle->addonData, m_controlHandle, itemPosition); | ||
| 397 | } | ||
| 398 | |||
| 399 | GUIHANDLE GetListItem(int listPos) | ||
| 400 | { | ||
| 401 | return m_cb->Window_GetListItem(m_Handle->addonData, m_controlHandle, listPos); | ||
| 402 | } | ||
| 403 | |||
| 404 | void SetCurrentListPosition(int listPos) | ||
| 405 | { | ||
| 406 | m_cb->Window_SetCurrentListPosition(m_Handle->addonData, m_controlHandle, listPos); | ||
| 407 | } | ||
| 408 | |||
| 409 | int GetCurrentListPosition() | ||
| 410 | { | ||
| 411 | return m_cb->Window_GetCurrentListPosition(m_Handle->addonData, m_controlHandle); | ||
| 412 | } | ||
| 413 | |||
| 414 | void SetControlLabel(int controlId, const char *label) | ||
| 415 | { | ||
| 416 | m_cb->Window_SetControlLabel(m_Handle->addonData, m_controlHandle, controlId, label); | ||
| 417 | } | ||
| 418 | |||
| 419 | void MarkDirtyRegion() | ||
| 420 | { | ||
| 421 | m_cb->Window_MarkDirtyRegion(m_Handle->addonData, m_controlHandle); | ||
| 422 | } | ||
| 423 | |||
| 424 | bool OnClick(int controlId) | ||
| 425 | { | ||
| 426 | if (!CBOnClick) | ||
| 427 | return false; | ||
| 428 | |||
| 429 | return CBOnClick(m_cbhdl, controlId); | ||
| 430 | } | ||
| 431 | |||
| 432 | bool OnFocus(int controlId) | ||
| 433 | { | ||
| 434 | if (!CBOnFocus) | ||
| 435 | return false; | ||
| 436 | |||
| 437 | return CBOnFocus(m_cbhdl, controlId); | ||
| 438 | } | ||
| 439 | |||
| 440 | bool OnInit() | ||
| 441 | { | ||
| 442 | if (!CBOnInit) | ||
| 443 | return false; | ||
| 444 | |||
| 445 | return CBOnInit(m_cbhdl); | ||
| 446 | } | ||
| 447 | |||
| 448 | bool OnAction(int actionId) | ||
| 449 | { | ||
| 450 | if (!CBOnAction) | ||
| 451 | return false; | ||
| 452 | |||
| 453 | return CBOnAction(m_cbhdl, actionId); | ||
| 454 | } | ||
| 455 | |||
| 456 | GUIHANDLE m_cbhdl; | ||
| 457 | bool (*CBOnInit)(GUIHANDLE cbhdl); | ||
| 458 | bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); | ||
| 459 | bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); | ||
| 460 | bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId); | ||
| 461 | |||
| 462 | protected: | ||
| 463 | static bool OnInitCB(GUIHANDLE cbhdl); | ||
| 464 | static bool OnFocusCB(GUIHANDLE cbhdl, int controlId); | ||
| 465 | static bool OnClickCB(GUIHANDLE cbhdl, int controlId); | ||
| 466 | static bool OnActionCB(GUIHANDLE cbhdl, int actionId); | ||
| 467 | }; | ||
| 468 | |||
| 469 | |||
| 470 | inline bool CAddonGUIWindow::OnInitCB(GUIHANDLE cbhdl) | ||
| 471 | { | ||
| 472 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnInit(); | ||
| 473 | } | ||
| 474 | |||
| 475 | inline bool CAddonGUIWindow::OnClickCB(GUIHANDLE cbhdl, int controlId) | ||
| 476 | { | ||
| 477 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnClick(controlId); | ||
| 478 | } | ||
| 479 | |||
| 480 | inline bool CAddonGUIWindow::OnFocusCB(GUIHANDLE cbhdl, int controlId) | ||
| 481 | { | ||
| 482 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnFocus(controlId); | ||
| 483 | } | ||
| 484 | |||
| 485 | inline bool CAddonGUIWindow::OnActionCB(GUIHANDLE cbhdl, int actionId) | ||
| 486 | { | ||
| 487 | return static_cast<CAddonGUIWindow*>(cbhdl)->OnAction(actionId); | ||
| 488 | } | ||
| 489 | |||
| 490 | class CAddonGUISpinControl: public CAddonGUIControlBase | ||
| 491 | { | ||
| 492 | public: | ||
| 493 | CAddonGUISpinControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 494 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 495 | { | ||
| 496 | m_controlHandle = m_cb->Window_GetControl_Spin(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 497 | } | ||
| 498 | ~CAddonGUISpinControl(void) override = default; | ||
| 499 | |||
| 500 | void SetVisible(bool yesNo) | ||
| 501 | { | ||
| 502 | if (m_controlHandle) | ||
| 503 | m_cb->Control_Spin_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 504 | } | ||
| 505 | |||
| 506 | void SetText(const char *label) | ||
| 507 | { | ||
| 508 | if (m_controlHandle) | ||
| 509 | m_cb->Control_Spin_SetText(m_Handle->addonData, m_controlHandle, label); | ||
| 510 | } | ||
| 511 | |||
| 512 | void Clear() | ||
| 513 | { | ||
| 514 | if (m_controlHandle) | ||
| 515 | m_cb->Control_Spin_Clear(m_Handle->addonData, m_controlHandle); | ||
| 516 | } | ||
| 517 | |||
| 518 | void AddLabel(const char *label, int iValue) | ||
| 519 | { | ||
| 520 | if (m_controlHandle) | ||
| 521 | m_cb->Control_Spin_AddLabel(m_Handle->addonData, m_controlHandle, label, iValue); | ||
| 522 | } | ||
| 523 | |||
| 524 | int GetValue() | ||
| 525 | { | ||
| 526 | if (!m_controlHandle) | ||
| 527 | return -1; | ||
| 528 | |||
| 529 | return m_cb->Control_Spin_GetValue(m_Handle->addonData, m_controlHandle); | ||
| 530 | } | ||
| 531 | |||
| 532 | void SetValue(int iValue) | ||
| 533 | { | ||
| 534 | if (m_controlHandle) | ||
| 535 | m_cb->Control_Spin_SetValue(m_Handle->addonData, m_controlHandle, iValue); | ||
| 536 | } | ||
| 537 | }; | ||
| 538 | |||
| 539 | class CAddonGUIRadioButton : public CAddonGUIControlBase | ||
| 540 | { | ||
| 541 | public: | ||
| 542 | CAddonGUIRadioButton(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 543 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 544 | { | ||
| 545 | m_controlHandle = m_cb->Window_GetControl_RadioButton(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 546 | } | ||
| 547 | ~CAddonGUIRadioButton() override = default; | ||
| 548 | |||
| 549 | void SetVisible(bool yesNo) | ||
| 550 | { | ||
| 551 | if (m_controlHandle) | ||
| 552 | m_cb->Control_RadioButton_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 553 | } | ||
| 554 | |||
| 555 | void SetText(const char *label) | ||
| 556 | { | ||
| 557 | if (m_controlHandle) | ||
| 558 | m_cb->Control_RadioButton_SetText(m_Handle->addonData, m_controlHandle, label); | ||
| 559 | } | ||
| 560 | |||
| 561 | void SetSelected(bool yesNo) | ||
| 562 | { | ||
| 563 | if (m_controlHandle) | ||
| 564 | m_cb->Control_RadioButton_SetSelected(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 565 | } | ||
| 566 | |||
| 567 | bool IsSelected() | ||
| 568 | { | ||
| 569 | if (!m_controlHandle) | ||
| 570 | return false; | ||
| 571 | |||
| 572 | return m_cb->Control_RadioButton_IsSelected(m_Handle->addonData, m_controlHandle); | ||
| 573 | } | ||
| 574 | }; | ||
| 575 | |||
| 576 | class CAddonGUIProgressControl : public CAddonGUIControlBase | ||
| 577 | { | ||
| 578 | public: | ||
| 579 | CAddonGUIProgressControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 580 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 581 | { | ||
| 582 | m_controlHandle = m_cb->Window_GetControl_Progress(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 583 | } | ||
| 584 | |||
| 585 | ~CAddonGUIProgressControl(void) override = default; | ||
| 586 | |||
| 587 | void SetPercentage(float fPercent) | ||
| 588 | { | ||
| 589 | if (m_controlHandle) | ||
| 590 | m_cb->Control_Progress_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); | ||
| 591 | } | ||
| 592 | |||
| 593 | float GetPercentage() const | ||
| 594 | { | ||
| 595 | if (!m_controlHandle) | ||
| 596 | return 0.0f; | ||
| 597 | |||
| 598 | return m_cb->Control_Progress_GetPercentage(m_Handle->addonData, m_controlHandle); | ||
| 599 | } | ||
| 600 | |||
| 601 | void SetInfo(int iInfo) | ||
| 602 | { | ||
| 603 | if (m_controlHandle) | ||
| 604 | m_cb->Control_Progress_SetInfo(m_Handle->addonData, m_controlHandle, iInfo); | ||
| 605 | } | ||
| 606 | |||
| 607 | int GetInfo() const | ||
| 608 | { | ||
| 609 | if (!m_controlHandle) | ||
| 610 | return -1; | ||
| 611 | |||
| 612 | return m_cb->Control_Progress_GetInfo(m_Handle->addonData, m_controlHandle); | ||
| 613 | } | ||
| 614 | |||
| 615 | std::string GetDescription() const | ||
| 616 | { | ||
| 617 | if (!m_controlHandle) | ||
| 618 | return ""; | ||
| 619 | |||
| 620 | return m_cb->Control_Progress_GetDescription(m_Handle->addonData, m_controlHandle); | ||
| 621 | } | ||
| 622 | }; | ||
| 623 | |||
| 624 | class CAddonGUISliderControl : public CAddonGUIControlBase | ||
| 625 | { | ||
| 626 | public: | ||
| 627 | CAddonGUISliderControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 628 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 629 | { | ||
| 630 | m_controlHandle = m_cb->Window_GetControl_Slider(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 631 | } | ||
| 632 | |||
| 633 | ~CAddonGUISliderControl(void) override = default; | ||
| 634 | |||
| 635 | void SetVisible(bool yesNo) | ||
| 636 | { | ||
| 637 | if (m_controlHandle) | ||
| 638 | m_cb->Control_Slider_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 639 | } | ||
| 640 | |||
| 641 | std::string GetDescription() const | ||
| 642 | { | ||
| 643 | if (!m_controlHandle) | ||
| 644 | return ""; | ||
| 645 | |||
| 646 | return m_cb->Control_Slider_GetDescription(m_Handle->addonData, m_controlHandle); | ||
| 647 | } | ||
| 648 | |||
| 649 | void SetIntRange(int iStart, int iEnd) | ||
| 650 | { | ||
| 651 | if (m_controlHandle) | ||
| 652 | m_cb->Control_Slider_SetIntRange(m_Handle->addonData, m_controlHandle, iStart, iEnd); | ||
| 653 | } | ||
| 654 | |||
| 655 | void SetIntValue(int iValue) | ||
| 656 | { | ||
| 657 | if (m_controlHandle) | ||
| 658 | m_cb->Control_Slider_SetIntValue(m_Handle->addonData, m_controlHandle, iValue); | ||
| 659 | } | ||
| 660 | |||
| 661 | int GetIntValue() const | ||
| 662 | { | ||
| 663 | if (!m_controlHandle) | ||
| 664 | return 0; | ||
| 665 | return m_cb->Control_Slider_GetIntValue(m_Handle->addonData, m_controlHandle); | ||
| 666 | } | ||
| 667 | |||
| 668 | void SetIntInterval(int iInterval) | ||
| 669 | { | ||
| 670 | if (m_controlHandle) | ||
| 671 | m_cb->Control_Slider_SetIntInterval(m_Handle->addonData, m_controlHandle, iInterval); | ||
| 672 | } | ||
| 673 | |||
| 674 | void SetPercentage(float fPercent) | ||
| 675 | { | ||
| 676 | if (m_controlHandle) | ||
| 677 | m_cb->Control_Slider_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); | ||
| 678 | } | ||
| 679 | |||
| 680 | float GetPercentage() const | ||
| 681 | { | ||
| 682 | if (!m_controlHandle) | ||
| 683 | return 0.0f; | ||
| 684 | |||
| 685 | return m_cb->Control_Slider_GetPercentage(m_Handle->addonData, m_controlHandle); | ||
| 686 | } | ||
| 687 | |||
| 688 | void SetFloatRange(float fStart, float fEnd) | ||
| 689 | { | ||
| 690 | if (m_controlHandle) | ||
| 691 | m_cb->Control_Slider_SetFloatRange(m_Handle->addonData, m_controlHandle, fStart, fEnd); | ||
| 692 | } | ||
| 693 | |||
| 694 | void SetFloatValue(float fValue) | ||
| 695 | { | ||
| 696 | if (m_controlHandle) | ||
| 697 | m_cb->Control_Slider_SetFloatValue(m_Handle->addonData, m_controlHandle, fValue); | ||
| 698 | } | ||
| 699 | |||
| 700 | float GetFloatValue() const | ||
| 701 | { | ||
| 702 | if (!m_controlHandle) | ||
| 703 | return 0.0f; | ||
| 704 | return m_cb->Control_Slider_GetFloatValue(m_Handle->addonData, m_controlHandle); | ||
| 705 | } | ||
| 706 | |||
| 707 | void SetFloatInterval(float fInterval) | ||
| 708 | { | ||
| 709 | if (m_controlHandle) | ||
| 710 | m_cb->Control_Slider_SetFloatInterval(m_Handle->addonData, m_controlHandle, fInterval); | ||
| 711 | } | ||
| 712 | }; | ||
| 713 | |||
| 714 | class CAddonGUISettingsSliderControl : public CAddonGUIControlBase | ||
| 715 | { | ||
| 716 | public: | ||
| 717 | CAddonGUISettingsSliderControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 718 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 719 | { | ||
| 720 | m_controlHandle = m_cb->Window_GetControl_SettingsSlider(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 721 | } | ||
| 722 | |||
| 723 | ~CAddonGUISettingsSliderControl(void) override = default; | ||
| 724 | |||
| 725 | void SetVisible(bool yesNo) | ||
| 726 | { | ||
| 727 | if (m_controlHandle) | ||
| 728 | m_cb->Control_SettingsSlider_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); | ||
| 729 | } | ||
| 730 | |||
| 731 | void SetText(const char *label) | ||
| 732 | { | ||
| 733 | if (m_controlHandle) | ||
| 734 | m_cb->Control_SettingsSlider_SetText(m_Handle->addonData, m_controlHandle, label); | ||
| 735 | } | ||
| 736 | |||
| 737 | std::string GetDescription() const | ||
| 738 | { | ||
| 739 | if (!m_controlHandle) | ||
| 740 | return ""; | ||
| 741 | |||
| 742 | return m_cb->Control_SettingsSlider_GetDescription(m_Handle->addonData, m_controlHandle); | ||
| 743 | } | ||
| 744 | |||
| 745 | void SetIntRange(int iStart, int iEnd) | ||
| 746 | { | ||
| 747 | if (m_controlHandle) | ||
| 748 | m_cb->Control_SettingsSlider_SetIntRange(m_Handle->addonData, m_controlHandle, iStart, iEnd); | ||
| 749 | } | ||
| 750 | |||
| 751 | void SetIntValue(int iValue) | ||
| 752 | { | ||
| 753 | if (m_controlHandle) | ||
| 754 | m_cb->Control_SettingsSlider_SetIntValue(m_Handle->addonData, m_controlHandle, iValue); | ||
| 755 | } | ||
| 756 | |||
| 757 | int GetIntValue() const | ||
| 758 | { | ||
| 759 | if (!m_controlHandle) | ||
| 760 | return 0; | ||
| 761 | return m_cb->Control_SettingsSlider_GetIntValue(m_Handle->addonData, m_controlHandle); | ||
| 762 | } | ||
| 763 | |||
| 764 | void SetIntInterval(int iInterval) | ||
| 765 | { | ||
| 766 | if (m_controlHandle) | ||
| 767 | m_cb->Control_SettingsSlider_SetIntInterval(m_Handle->addonData, m_controlHandle, iInterval); | ||
| 768 | } | ||
| 769 | |||
| 770 | void SetPercentage(float fPercent) | ||
| 771 | { | ||
| 772 | if (m_controlHandle) | ||
| 773 | m_cb->Control_SettingsSlider_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); | ||
| 774 | } | ||
| 775 | |||
| 776 | float GetPercentage() const | ||
| 777 | { | ||
| 778 | if (!m_controlHandle) | ||
| 779 | return 0.0f; | ||
| 780 | |||
| 781 | return m_cb->Control_SettingsSlider_GetPercentage(m_Handle->addonData, m_controlHandle); | ||
| 782 | } | ||
| 783 | |||
| 784 | void SetFloatRange(float fStart, float fEnd) | ||
| 785 | { | ||
| 786 | if (m_controlHandle) | ||
| 787 | m_cb->Control_SettingsSlider_SetFloatRange(m_Handle->addonData, m_controlHandle, fStart, fEnd); | ||
| 788 | } | ||
| 789 | |||
| 790 | void SetFloatValue(float fValue) | ||
| 791 | { | ||
| 792 | if (m_controlHandle) | ||
| 793 | m_cb->Control_SettingsSlider_SetFloatValue(m_Handle->addonData, m_controlHandle, fValue); | ||
| 794 | } | ||
| 795 | |||
| 796 | float GetFloatValue() const | ||
| 797 | { | ||
| 798 | if (!m_controlHandle) | ||
| 799 | return 0.0f; | ||
| 800 | return m_cb->Control_SettingsSlider_GetFloatValue(m_Handle->addonData, m_controlHandle); | ||
| 801 | } | ||
| 802 | |||
| 803 | void SetFloatInterval(float fInterval) | ||
| 804 | { | ||
| 805 | if (m_controlHandle) | ||
| 806 | m_cb->Control_SettingsSlider_SetFloatInterval(m_Handle->addonData, m_controlHandle, fInterval); | ||
| 807 | } | ||
| 808 | }; | ||
| 809 | |||
| 810 | class CAddonGUIRenderingControl : public CAddonGUIControlBase | ||
| 811 | { | ||
| 812 | public: | ||
| 813 | CAddonGUIRenderingControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) | ||
| 814 | : CAddonGUIControlBase(hdl, cb, window) | ||
| 815 | , m_cbhdl(nullptr) | ||
| 816 | , CBCreate(nullptr) | ||
| 817 | , CBRender(nullptr) | ||
| 818 | , CBStop(nullptr) | ||
| 819 | , CBDirty(nullptr) | ||
| 820 | { | ||
| 821 | m_controlHandle = m_cb->Window_GetControl_RenderAddon(m_Handle->addonData, m_Window->GetControlHandle(), controlId); | ||
| 822 | } | ||
| 823 | |||
| 824 | ~CAddonGUIRenderingControl() override | ||
| 825 | { | ||
| 826 | m_cb->RenderAddon_Delete(m_Handle->addonData, m_controlHandle); | ||
| 827 | } | ||
| 828 | |||
| 829 | void Init() | ||
| 830 | { | ||
| 831 | m_cb->RenderAddon_SetCallbacks(m_Handle->addonData, m_controlHandle, this, OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 832 | } | ||
| 833 | |||
| 834 | bool Create(int x, int y, int w, int h, void *device) | ||
| 835 | { | ||
| 836 | if (!CBCreate) | ||
| 837 | return false; | ||
| 838 | |||
| 839 | return CBCreate(m_cbhdl, x, y, w, h, device); | ||
| 840 | } | ||
| 841 | |||
| 842 | void Render() | ||
| 843 | { | ||
| 844 | if (!CBRender) | ||
| 845 | return; | ||
| 846 | |||
| 847 | CBRender(m_cbhdl); | ||
| 848 | } | ||
| 849 | |||
| 850 | void Stop() | ||
| 851 | { | ||
| 852 | if (!CBStop) | ||
| 853 | return; | ||
| 854 | |||
| 855 | CBStop(m_cbhdl); | ||
| 856 | } | ||
| 857 | |||
| 858 | bool Dirty() | ||
| 859 | { | ||
| 860 | if (!CBDirty) | ||
| 861 | return true; | ||
| 862 | |||
| 863 | return CBDirty(m_cbhdl); | ||
| 864 | } | ||
| 865 | |||
| 866 | GUIHANDLE m_cbhdl; | ||
| 867 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void *device); | ||
| 868 | void (*CBRender)(GUIHANDLE cbhdl); | ||
| 869 | void (*CBStop)(GUIHANDLE cbhdl); | ||
| 870 | bool (*CBDirty)(GUIHANDLE cbhdl); | ||
| 871 | |||
| 872 | private: | ||
| 873 | static bool OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device); | ||
| 874 | static void OnRenderCB(GUIHANDLE cbhdl); | ||
| 875 | static void OnStopCB(GUIHANDLE cbhdl); | ||
| 876 | static bool OnDirtyCB(GUIHANDLE cbhdl); | ||
| 877 | }; | ||
| 878 | |||
| 879 | inline bool CAddonGUIRenderingControl::OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device) | ||
| 880 | { | ||
| 881 | return static_cast<CAddonGUIRenderingControl*>(cbhdl)->Create(x, y, w, h, device); | ||
| 882 | } | ||
| 883 | |||
| 884 | inline void CAddonGUIRenderingControl::OnRenderCB(GUIHANDLE cbhdl) | ||
| 885 | { | ||
| 886 | static_cast<CAddonGUIRenderingControl*>(cbhdl)->Render(); | ||
| 887 | } | ||
| 888 | |||
| 889 | inline void CAddonGUIRenderingControl::OnStopCB(GUIHANDLE cbhdl) | ||
| 890 | { | ||
| 891 | static_cast<CAddonGUIRenderingControl*>(cbhdl)->Stop(); | ||
| 892 | } | ||
| 893 | |||
| 894 | inline bool CAddonGUIRenderingControl::OnDirtyCB(GUIHANDLE cbhdl) | ||
| 895 | { | ||
| 896 | return static_cast<CAddonGUIRenderingControl*>(cbhdl)->Dirty(); | ||
| 897 | } | ||
| 898 | |||
| 899 | class CHelper_libKODI_guilib | ||
| 900 | { | ||
| 901 | public: | ||
| 902 | CHelper_libKODI_guilib() | ||
| 903 | { | ||
| 904 | m_Handle = nullptr; | ||
| 905 | m_Callbacks = nullptr; | ||
| 906 | } | ||
| 907 | |||
| 908 | ~CHelper_libKODI_guilib() | ||
| 909 | { | ||
| 910 | if (m_Handle && m_Callbacks) | ||
| 911 | { | ||
| 912 | m_Handle->GUILib_UnRegisterMe(m_Handle->addonData, m_Callbacks); | ||
| 913 | } | ||
| 914 | } | ||
| 915 | |||
| 916 | bool RegisterMe(void *handle) | ||
| 917 | { | ||
| 918 | m_Handle = static_cast<AddonCB*>(handle); | ||
| 919 | if (m_Handle) | ||
| 920 | m_Callbacks = (KodiAPI::GUI::CB_GUILib*)m_Handle->GUILib_RegisterMe(m_Handle->addonData); | ||
| 921 | if (!m_Callbacks) | ||
| 922 | fprintf(stderr, "libKODI_guilib-ERROR: GUILib_RegisterMe can't get callback table from Kodi !!!\n"); | ||
| 923 | |||
| 924 | return m_Callbacks != nullptr; | ||
| 925 | } | ||
| 926 | |||
| 927 | void Lock() | ||
| 928 | { | ||
| 929 | m_Callbacks->Lock(); | ||
| 930 | } | ||
| 931 | |||
| 932 | void Unlock() | ||
| 933 | { | ||
| 934 | m_Callbacks->Unlock(); | ||
| 935 | } | ||
| 936 | |||
| 937 | int GetScreenHeight() | ||
| 938 | { | ||
| 939 | return m_Callbacks->GetScreenHeight(); | ||
| 940 | } | ||
| 941 | |||
| 942 | int GetScreenWidth() | ||
| 943 | { | ||
| 944 | return m_Callbacks->GetScreenWidth(); | ||
| 945 | } | ||
| 946 | |||
| 947 | int GetVideoResolution() | ||
| 948 | { | ||
| 949 | return m_Callbacks->GetVideoResolution(); | ||
| 950 | } | ||
| 951 | |||
| 952 | CAddonGUIWindow* Window_create(const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) | ||
| 953 | { | ||
| 954 | return new CAddonGUIWindow(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog); | ||
| 955 | } | ||
| 956 | |||
| 957 | void Window_destroy(CAddonGUIWindow* p) | ||
| 958 | { | ||
| 959 | delete p; | ||
| 960 | } | ||
| 961 | |||
| 962 | CAddonGUISpinControl* Control_getSpin(CAddonGUIWindow *window, int controlId) | ||
| 963 | { | ||
| 964 | return new CAddonGUISpinControl(m_Handle, m_Callbacks, window, controlId); | ||
| 965 | } | ||
| 966 | |||
| 967 | void Control_releaseSpin(CAddonGUISpinControl* p) | ||
| 968 | { | ||
| 969 | delete p; | ||
| 970 | } | ||
| 971 | |||
| 972 | CAddonGUIRadioButton* Control_getRadioButton(CAddonGUIWindow *window, int controlId) | ||
| 973 | { | ||
| 974 | return new CAddonGUIRadioButton(m_Handle, m_Callbacks, window, controlId); | ||
| 975 | } | ||
| 976 | |||
| 977 | void Control_releaseRadioButton(CAddonGUIRadioButton* p) | ||
| 978 | { | ||
| 979 | delete p; | ||
| 980 | } | ||
| 981 | |||
| 982 | CAddonGUIProgressControl* Control_getProgress(CAddonGUIWindow *window, int controlId) | ||
| 983 | { | ||
| 984 | return new CAddonGUIProgressControl(m_Handle, m_Callbacks, window, controlId); | ||
| 985 | } | ||
| 986 | |||
| 987 | void Control_releaseProgress(CAddonGUIProgressControl* p) | ||
| 988 | { | ||
| 989 | delete p; | ||
| 990 | } | ||
| 991 | |||
| 992 | CAddonListItem* ListItem_create(const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) | ||
| 993 | { | ||
| 994 | return new CAddonListItem(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path); | ||
| 995 | } | ||
| 996 | |||
| 997 | void ListItem_destroy(CAddonListItem* p) | ||
| 998 | { | ||
| 999 | delete p; | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | CAddonGUIRenderingControl* Control_getRendering(CAddonGUIWindow *window, int controlId) | ||
| 1003 | { | ||
| 1004 | return new CAddonGUIRenderingControl(m_Handle, m_Callbacks, window, controlId); | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | void Control_releaseRendering(CAddonGUIRenderingControl* p) | ||
| 1008 | { | ||
| 1009 | delete p; | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | CAddonGUISliderControl* Control_getSlider(CAddonGUIWindow *window, int controlId) | ||
| 1013 | { | ||
| 1014 | return new CAddonGUISliderControl(m_Handle, m_Callbacks, window, controlId); | ||
| 1015 | } | ||
| 1016 | |||
| 1017 | void Control_releaseSlider(CAddonGUISliderControl* p) | ||
| 1018 | { | ||
| 1019 | delete p; | ||
| 1020 | } | ||
| 1021 | |||
| 1022 | CAddonGUISettingsSliderControl* Control_getSettingsSlider(CAddonGUIWindow *window, int controlId) | ||
| 1023 | { | ||
| 1024 | return new CAddonGUISettingsSliderControl(m_Handle, m_Callbacks, window, controlId); | ||
| 1025 | } | ||
| 1026 | |||
| 1027 | void Control_releaseSettingsSlider(CAddonGUISettingsSliderControl* p) | ||
| 1028 | { | ||
| 1029 | delete p; | ||
| 1030 | } | ||
| 1031 | |||
| 1032 | /*! @name GUI Keyboard functions */ | ||
| 1033 | //@{ | ||
| 1034 | bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs = 0) | ||
| 1035 | { | ||
| 1036 | return m_Callbacks->Dialog_Keyboard_ShowAndGetInputWithHead(strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs); | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 1040 | { | ||
| 1041 | return m_Callbacks->Dialog_Keyboard_ShowAndGetInput(strText, iMaxStringSize, allowEmptyResult, autoCloseMs); | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 1045 | { | ||
| 1046 | return m_Callbacks->Dialog_Keyboard_ShowAndGetNewPasswordWithHead(strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); | ||
| 1047 | } | ||
| 1048 | |||
| 1049 | bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) | ||
| 1050 | { | ||
| 1051 | return m_Callbacks->Dialog_Keyboard_ShowAndGetNewPassword(strNewPassword, iMaxStringSize, autoCloseMs); | ||
| 1052 | } | ||
| 1053 | |||
| 1054 | bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 1055 | { | ||
| 1056 | return m_Callbacks->Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead(strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) | ||
| 1060 | { | ||
| 1061 | return m_Callbacks->Dialog_Keyboard_ShowAndVerifyNewPassword(strNewPassword, iMaxStringSize, autoCloseMs); | ||
| 1062 | } | ||
| 1063 | |||
| 1064 | int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs = 0) | ||
| 1065 | { | ||
| 1066 | return m_Callbacks->Dialog_Keyboard_ShowAndVerifyPassword(strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs); | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | bool Dialog_Keyboard_ShowAndGetFilter(char &strText, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs = 0) | ||
| 1070 | { | ||
| 1071 | return m_Callbacks->Dialog_Keyboard_ShowAndGetFilter(strText, iMaxStringSize, searching, autoCloseMs); | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard = false) | ||
| 1075 | { | ||
| 1076 | return m_Callbacks->Dialog_Keyboard_SendTextToActiveKeyboard(aTextString, closeKeyboard); | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | bool Dialog_Keyboard_isKeyboardActivated() | ||
| 1080 | { | ||
| 1081 | return m_Callbacks->Dialog_Keyboard_isKeyboardActivated(); | ||
| 1082 | } | ||
| 1083 | //@} | ||
| 1084 | |||
| 1085 | /*! @name GUI Numeric functions */ | ||
| 1086 | //@{ | ||
| 1087 | bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize) | ||
| 1088 | { | ||
| 1089 | return m_Callbacks->Dialog_Numeric_ShowAndVerifyNewPassword(strNewPassword, iMaxStringSize); | ||
| 1090 | } | ||
| 1091 | |||
| 1092 | int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries) | ||
| 1093 | { | ||
| 1094 | return m_Callbacks->Dialog_Numeric_ShowAndVerifyPassword(strPassword, iMaxStringSize, strHeading, iRetries); | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput) | ||
| 1098 | { | ||
| 1099 | return m_Callbacks->Dialog_Numeric_ShowAndVerifyInput(strPassword, iMaxStringSize, strHeading, bGetUserInput); | ||
| 1100 | } | ||
| 1101 | |||
| 1102 | bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading) | ||
| 1103 | { | ||
| 1104 | return m_Callbacks->Dialog_Numeric_ShowAndGetTime(time, strHeading); | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading) | ||
| 1108 | { | ||
| 1109 | return m_Callbacks->Dialog_Numeric_ShowAndGetDate(date, strHeading); | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading) | ||
| 1113 | { | ||
| 1114 | return m_Callbacks->Dialog_Numeric_ShowAndGetIPAddress(strIPAddress, iMaxStringSize, strHeading); | ||
| 1115 | } | ||
| 1116 | |||
| 1117 | bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs = 0) | ||
| 1118 | { | ||
| 1119 | return m_Callbacks->Dialog_Numeric_ShowAndGetNumber(strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs); | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | bool Dialog_Numeric_ShowAndGetSeconds(char &strTime, unsigned int iMaxStringSize, const char *strHeading) | ||
| 1123 | { | ||
| 1124 | return m_Callbacks->Dialog_Numeric_ShowAndGetSeconds(strTime, iMaxStringSize, strHeading); | ||
| 1125 | } | ||
| 1126 | //@} | ||
| 1127 | |||
| 1128 | /*! @name GUI File browser functions */ | ||
| 1129 | //@{ | ||
| 1130 | bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &strPath, unsigned int iMaxStringSize, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) | ||
| 1131 | { | ||
| 1132 | return m_Callbacks->Dialog_FileBrowser_ShowAndGetFile(directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList); | ||
| 1133 | } | ||
| 1134 | //@} | ||
| 1135 | |||
| 1136 | /*! @name GUI OK Dialog functions */ | ||
| 1137 | //@{ | ||
| 1138 | void Dialog_OK_ShowAndGetInput(const char *heading, const char *text) | ||
| 1139 | { | ||
| 1140 | return m_Callbacks->Dialog_OK_ShowAndGetInputSingleText(heading, text); | ||
| 1141 | } | ||
| 1142 | |||
| 1143 | void Dialog_OK_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2) | ||
| 1144 | { | ||
| 1145 | return m_Callbacks->Dialog_OK_ShowAndGetInputLineText(heading, line0, line1, line2); | ||
| 1146 | } | ||
| 1147 | //@} | ||
| 1148 | |||
| 1149 | /*! @name GUI Yes No Dialog functions */ | ||
| 1150 | //@{ | ||
| 1151 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *text, bool& bCanceled, const char *noLabel = "", const char *yesLabel = "") | ||
| 1152 | { | ||
| 1153 | return m_Callbacks->Dialog_YesNo_ShowAndGetInputSingleText(heading, text, bCanceled, noLabel, yesLabel); | ||
| 1154 | } | ||
| 1155 | |||
| 1156 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel = "", const char *yesLabel = "") | ||
| 1157 | { | ||
| 1158 | return m_Callbacks->Dialog_YesNo_ShowAndGetInputLineText(heading, line0, line1, line2, noLabel, yesLabel); | ||
| 1159 | } | ||
| 1160 | |||
| 1161 | bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel = "", const char *yesLabel = "") | ||
| 1162 | { | ||
| 1163 | return m_Callbacks->Dialog_YesNo_ShowAndGetInputLineButtonText(heading, line0, line1, line2, bCanceled, noLabel, yesLabel); | ||
| 1164 | } | ||
| 1165 | //@} | ||
| 1166 | |||
| 1167 | /*! @name GUI Text viewer Dialog */ | ||
| 1168 | //@{ | ||
| 1169 | void Dialog_TextViewer(const char *heading, const char *text) | ||
| 1170 | { | ||
| 1171 | return m_Callbacks->Dialog_TextViewer(heading, text); | ||
| 1172 | } | ||
| 1173 | //@} | ||
| 1174 | |||
| 1175 | /*! @name GUI select Dialog */ | ||
| 1176 | //@{ | ||
| 1177 | int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected = -1) | ||
| 1178 | { | ||
| 1179 | return m_Callbacks->Dialog_Select(heading, entries, size, selected); | ||
| 1180 | } | ||
| 1181 | //@} | ||
| 1182 | |||
| 1183 | private: | ||
| 1184 | AddonCB* m_Handle; | ||
| 1185 | KodiAPI::GUI::CB_GUILib* m_Callbacks; | ||
| 1186 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h deleted file mode 100644 index 43e3022..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h +++ /dev/null | |||
| @@ -1,602 +0,0 @@ | |||
| 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 <string> | ||
| 12 | #include <vector> | ||
| 13 | #include <string.h> | ||
| 14 | #include <stdlib.h> | ||
| 15 | #include <stdio.h> | ||
| 16 | #include <stdint.h> | ||
| 17 | #include <stdarg.h> | ||
| 18 | |||
| 19 | #include "versions.h" | ||
| 20 | #if defined(BUILD_KODI_ADDON) | ||
| 21 | #include "IFileTypes.h" | ||
| 22 | #else | ||
| 23 | #include "filesystem/IFileTypes.h" | ||
| 24 | #endif | ||
| 25 | |||
| 26 | struct VFSDirEntry; | ||
| 27 | struct __stat64; | ||
| 28 | |||
| 29 | #ifdef _WIN32 // windows | ||
| 30 | #ifndef _SSIZE_T_DEFINED | ||
| 31 | typedef intptr_t ssize_t; | ||
| 32 | #define _SSIZE_T_DEFINED | ||
| 33 | #endif // !_SSIZE_T_DEFINED | ||
| 34 | |||
| 35 | #if defined(BUILD_KODI_ADDON) | ||
| 36 | #include "p8-platform/windows/dlfcn-win32.h" | ||
| 37 | #endif | ||
| 38 | #else // windows | ||
| 39 | #include <dlfcn.h> // linux+osx | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifdef LOG_DEBUG | ||
| 43 | #undef LOG_DEBUG | ||
| 44 | #endif | ||
| 45 | #ifdef LOG_INFO | ||
| 46 | #undef LOG_INFO | ||
| 47 | #endif | ||
| 48 | #ifdef LOG_NOTICE | ||
| 49 | #undef LOG_NOTICE | ||
| 50 | #endif | ||
| 51 | #ifdef LOG_ERROR | ||
| 52 | #undef LOG_ERROR | ||
| 53 | #endif | ||
| 54 | |||
| 55 | typedef void* (*KODIAddOnLib_RegisterMe)(void *addonData); | ||
| 56 | typedef void (*KODIAddOnLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 57 | typedef void* (*KODIAudioEngineLib_RegisterMe)(void *addonData); | ||
| 58 | typedef void (*KODIAudioEngineLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 59 | typedef void* (*KODIGUILib_RegisterMe)(void *addonData); | ||
| 60 | typedef void (*KODIGUILib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 61 | typedef void* (*KODIPVRLib_RegisterMe)(void *addonData); | ||
| 62 | typedef void (*KODIPVRLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 63 | typedef void* (*KODICodecLib_RegisterMe)(void *addonData); | ||
| 64 | typedef void (*KODICodecLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 65 | typedef void* (*KODIINPUTSTREAMLib_RegisterMe)(void *addonData); | ||
| 66 | typedef void (*KODIINPUTSTREAMLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 67 | typedef void* (*KODIPeripheralLib_RegisterMe)(void *addonData); | ||
| 68 | typedef void (*KODIPeripheralLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 69 | typedef void* (*KODIGameLib_RegisterMe)(void *addonData); | ||
| 70 | typedef void (*KODIGameLib_UnRegisterMe)(void *addonData, void *cbTable); | ||
| 71 | |||
| 72 | typedef struct AddonCB | ||
| 73 | { | ||
| 74 | const char* libBasePath; ///< Never, never change this!!! | ||
| 75 | void* addonData; | ||
| 76 | KODIAddOnLib_RegisterMe AddOnLib_RegisterMe; | ||
| 77 | KODIAddOnLib_UnRegisterMe AddOnLib_UnRegisterMe; | ||
| 78 | KODIAudioEngineLib_RegisterMe AudioEngineLib_RegisterMe; | ||
| 79 | KODIAudioEngineLib_UnRegisterMe AudioEngineLib_UnRegisterMe; | ||
| 80 | KODICodecLib_RegisterMe CodecLib_RegisterMe; | ||
| 81 | KODICodecLib_UnRegisterMe CodecLib_UnRegisterMe; | ||
| 82 | KODIGUILib_RegisterMe GUILib_RegisterMe; | ||
| 83 | KODIGUILib_UnRegisterMe GUILib_UnRegisterMe; | ||
| 84 | KODIPVRLib_RegisterMe PVRLib_RegisterMe; | ||
| 85 | KODIPVRLib_UnRegisterMe PVRLib_UnRegisterMe; | ||
| 86 | KODIINPUTSTREAMLib_RegisterMe INPUTSTREAMLib_RegisterMe; | ||
| 87 | KODIINPUTSTREAMLib_UnRegisterMe INPUTSTREAMLib_UnRegisterMe; | ||
| 88 | KODIPeripheralLib_RegisterMe PeripheralLib_RegisterMe; | ||
| 89 | KODIPeripheralLib_UnRegisterMe PeripheralLib_UnRegisterMe; | ||
| 90 | KODIGameLib_RegisterMe GameLib_RegisterMe; | ||
| 91 | KODIGameLib_UnRegisterMe GameLib_UnRegisterMe; | ||
| 92 | } AddonCB; | ||
| 93 | |||
| 94 | namespace ADDON | ||
| 95 | { | ||
| 96 | typedef enum addon_log | ||
| 97 | { | ||
| 98 | LOG_DEBUG, | ||
| 99 | LOG_INFO, | ||
| 100 | LOG_NOTICE, | ||
| 101 | LOG_ERROR | ||
| 102 | } addon_log_t; | ||
| 103 | |||
| 104 | typedef enum queue_msg | ||
| 105 | { | ||
| 106 | QUEUE_INFO, | ||
| 107 | QUEUE_WARNING, | ||
| 108 | QUEUE_ERROR | ||
| 109 | } queue_msg_t; | ||
| 110 | } | ||
| 111 | |||
| 112 | namespace KodiAPI | ||
| 113 | { | ||
| 114 | namespace AddOn | ||
| 115 | { | ||
| 116 | typedef struct CB_AddOn | ||
| 117 | { | ||
| 118 | void (*Log)(void *addonData, const ADDON::addon_log_t loglevel, const char *msg); | ||
| 119 | void (*QueueNotification)(void *addonData, const ADDON::queue_msg_t type, const char *msg); | ||
| 120 | bool (*WakeOnLan)(const char* mac); | ||
| 121 | bool (*GetSetting)(void *addonData, const char *settingName, void *settingValue); | ||
| 122 | char* (*TranslateSpecialProtocol)(const char *strSource); | ||
| 123 | char* (*UnknownToUTF8)(const char *sourceDest); | ||
| 124 | char* (*GetLocalizedString)(const void* addonData, long dwCode); | ||
| 125 | char* (*GetDVDMenuLanguage)(const void* addonData); | ||
| 126 | void (*FreeString)(const void* addonData, char* str); | ||
| 127 | void (*FreeStringArray)(const void* addonData, char** arr, int numElements); | ||
| 128 | |||
| 129 | void* (*OpenFile)(const void* addonData, const char* strFileName, unsigned int flags); | ||
| 130 | void* (*OpenFileForWrite)(const void* addonData, const char* strFileName, bool bOverWrite); | ||
| 131 | ssize_t (*ReadFile)(const void* addonData, void* file, void* lpBuf, size_t uiBufSize); | ||
| 132 | bool (*ReadFileString)(const void* addonData, void* file, char *szLine, int iLineLength); | ||
| 133 | ssize_t (*WriteFile)(const void* addonData, void* file, const void* lpBuf, size_t uiBufSize); | ||
| 134 | void (*FlushFile)(const void* addonData, void* file); | ||
| 135 | int64_t (*SeekFile)(const void* addonData, void* file, int64_t iFilePosition, int iWhence); | ||
| 136 | int (*TruncateFile)(const void* addonData, void* file, int64_t iSize); | ||
| 137 | int64_t (*GetFilePosition)(const void* addonData, void* file); | ||
| 138 | int64_t (*GetFileLength)(const void* addonData, void* file); | ||
| 139 | double (*GetFileDownloadSpeed)(const void* addonData, void* file); | ||
| 140 | void (*CloseFile)(const void* addonData, void* file); | ||
| 141 | int (*GetFileChunkSize)(const void* addonData, void* file); | ||
| 142 | bool (*FileExists)(const void* addonData, const char *strFileName, bool bUseCache); | ||
| 143 | int (*StatFile)(const void* addonData, const char *strFileName, struct __stat64* buffer); | ||
| 144 | char *(*GetFilePropertyValue)(const void* addonData, void* file, XFILE::FileProperty type, const char *name); | ||
| 145 | char **(*GetFilePropertyValues)(const void* addonData, void* file, XFILE::FileProperty type, const char *name, int *numPorperties); | ||
| 146 | bool (*DeleteFile)(const void* addonData, const char *strFileName); | ||
| 147 | bool (*CanOpenDirectory)(const void* addonData, const char* strURL); | ||
| 148 | bool (*CreateDirectory)(const void* addonData, const char *strPath); | ||
| 149 | bool (*DirectoryExists)(const void* addonData, const char *strPath); | ||
| 150 | bool (*RemoveDirectory)(const void* addonData, const char *strPath); | ||
| 151 | bool (*GetDirectory)(const void* addonData, const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items); | ||
| 152 | void (*FreeDirectory)(const void* addonData, VFSDirEntry* items, unsigned int num_items); | ||
| 153 | void* (*CURLCreate)(const void* addonData, const char* strURL); | ||
| 154 | bool (*CURLAddOption)(const void* addonData, void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value); | ||
| 155 | bool (*CURLOpen)(const void* addonData, void* file, unsigned int flags); | ||
| 156 | } CB_AddOnLib; | ||
| 157 | |||
| 158 | } /* namespace AddOn */ | ||
| 159 | } /* namespace KodiAPI */ | ||
| 160 | |||
| 161 | namespace ADDON | ||
| 162 | { | ||
| 163 | class CHelper_libXBMC_addon | ||
| 164 | { | ||
| 165 | public: | ||
| 166 | CHelper_libXBMC_addon() | ||
| 167 | { | ||
| 168 | m_Handle = nullptr; | ||
| 169 | m_Callbacks = nullptr; | ||
| 170 | } | ||
| 171 | |||
| 172 | ~CHelper_libXBMC_addon() | ||
| 173 | { | ||
| 174 | if (m_Handle && m_Callbacks) | ||
| 175 | { | ||
| 176 | m_Handle->AddOnLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | |||
| 180 | bool RegisterMe(void *handle) | ||
| 181 | { | ||
| 182 | m_Handle = static_cast<AddonCB*>(handle); | ||
| 183 | if (m_Handle) | ||
| 184 | m_Callbacks = (KodiAPI::AddOn::CB_AddOnLib*)m_Handle->AddOnLib_RegisterMe(m_Handle->addonData); | ||
| 185 | if (!m_Callbacks) | ||
| 186 | fprintf(stderr, "libXBMC_addon-ERROR: AddOnLib_RegisterMe can't get callback table from Kodi !!!\n"); | ||
| 187 | |||
| 188 | return m_Callbacks != nullptr; | ||
| 189 | } | ||
| 190 | |||
| 191 | /*! | ||
| 192 | * @brief Add a message to XBMC's log. | ||
| 193 | * @param loglevel The log level of the message. | ||
| 194 | * @param format The format of the message to pass to XBMC. | ||
| 195 | * @note This method uses limited buffer (16k) for the formatted output. | ||
| 196 | * So data, which will not fit into it, will be silently discarded. | ||
| 197 | */ | ||
| 198 | void Log(const addon_log_t loglevel, const char *format, ... ) | ||
| 199 | { | ||
| 200 | char buffer[16384]; | ||
| 201 | static constexpr size_t len = sizeof (buffer) - 1; | ||
| 202 | va_list args; | ||
| 203 | va_start (args, format); | ||
| 204 | vsnprintf (buffer, len, format, args); | ||
| 205 | va_end (args); | ||
| 206 | buffer[len] = '\0'; // to be sure it's null-terminated | ||
| 207 | m_Callbacks->Log(m_Handle->addonData, loglevel, buffer); | ||
| 208 | } | ||
| 209 | |||
| 210 | /*! | ||
| 211 | * @brief Get a settings value for this add-on. | ||
| 212 | * @param settingName The name of the setting to get. | ||
| 213 | * @param settingValue The value. | ||
| 214 | * @return True if the settings was fetched successfully, false otherwise. | ||
| 215 | */ | ||
| 216 | bool GetSetting(const char* settingName, void *settingValue) | ||
| 217 | { | ||
| 218 | return m_Callbacks->GetSetting(m_Handle->addonData, settingName, settingValue); | ||
| 219 | } | ||
| 220 | |||
| 221 | /*! | ||
| 222 | * @brief Translates a special protocol folder. | ||
| 223 | * @param source The file / folder to translate. | ||
| 224 | * @return The string translated to resolved path. Must be freed by calling FreeString() when done. | ||
| 225 | */ | ||
| 226 | char *TranslateSpecialProtocol(const char *source) | ||
| 227 | { | ||
| 228 | return m_Callbacks->TranslateSpecialProtocol(source); | ||
| 229 | } | ||
| 230 | |||
| 231 | /*! | ||
| 232 | * @brief Queue a notification in the GUI. | ||
| 233 | * @param type The message type. | ||
| 234 | * @param format The format of the message to pass to display in XBMC. | ||
| 235 | */ | ||
| 236 | void QueueNotification(const queue_msg_t type, const char *format, ... ) | ||
| 237 | { | ||
| 238 | char buffer[16384]; | ||
| 239 | va_list args; | ||
| 240 | va_start (args, format); | ||
| 241 | vsprintf (buffer, format, args); | ||
| 242 | va_end (args); | ||
| 243 | m_Callbacks->QueueNotification(m_Handle->addonData, type, buffer); | ||
| 244 | } | ||
| 245 | |||
| 246 | /*! | ||
| 247 | * @brief Send WakeOnLan magic packet. | ||
| 248 | * @param mac Network address of the host to wake. | ||
| 249 | * @return True if the magic packet was successfully sent, false otherwise. | ||
| 250 | */ | ||
| 251 | bool WakeOnLan(const char* mac) | ||
| 252 | { | ||
| 253 | return m_Callbacks->WakeOnLan(mac); | ||
| 254 | } | ||
| 255 | |||
| 256 | /*! | ||
| 257 | * @brief Translate a string with an unknown encoding to UTF8. | ||
| 258 | * @param str The string to translate. | ||
| 259 | * @return The string translated to UTF8. Must be freed by calling FreeString() when done. | ||
| 260 | */ | ||
| 261 | char* UnknownToUTF8(const char* str) | ||
| 262 | { | ||
| 263 | return m_Callbacks->UnknownToUTF8(str); | ||
| 264 | } | ||
| 265 | |||
| 266 | /*! | ||
| 267 | * @brief Get a localised message. | ||
| 268 | * @param dwCode The code of the message to get. | ||
| 269 | * @return The message. Must be freed by calling FreeString() when done. | ||
| 270 | */ | ||
| 271 | char* GetLocalizedString(int dwCode) | ||
| 272 | { | ||
| 273 | return m_Callbacks->GetLocalizedString(m_Handle->addonData, dwCode); | ||
| 274 | } | ||
| 275 | |||
| 276 | /*! | ||
| 277 | * @brief Get the DVD menu language. | ||
| 278 | * @return The language. Must be freed by calling FreeString() when done. | ||
| 279 | */ | ||
| 280 | char* GetDVDMenuLanguage() | ||
| 281 | { | ||
| 282 | return m_Callbacks->GetDVDMenuLanguage(m_Handle->addonData); | ||
| 283 | } | ||
| 284 | |||
| 285 | /*! | ||
| 286 | * @brief Free the memory used by str | ||
| 287 | * @param str The string to free | ||
| 288 | */ | ||
| 289 | void FreeString(char* str) | ||
| 290 | { | ||
| 291 | m_Callbacks->FreeString(m_Handle->addonData, str); | ||
| 292 | } | ||
| 293 | |||
| 294 | /*! | ||
| 295 | * @brief Free the memory used by arr including its elements | ||
| 296 | * @param arr The string array to free | ||
| 297 | * @param numElements The length of the array | ||
| 298 | */ | ||
| 299 | void FreeStringArray(char** arr, int numElements) | ||
| 300 | { | ||
| 301 | m_Callbacks->FreeStringArray(m_Handle->addonData, arr, numElements); | ||
| 302 | } | ||
| 303 | |||
| 304 | /*! | ||
| 305 | * @brief Open the file with filename via XBMC's CFile. Needs to be closed by calling CloseFile() when done. | ||
| 306 | * @param strFileName The filename to open. | ||
| 307 | * @param flags The flags to pass. Documented in XBMC's File.h | ||
| 308 | * @return A handle for the file, or NULL if it couldn't be opened. | ||
| 309 | */ | ||
| 310 | void* OpenFile(const char* strFileName, unsigned int flags) | ||
| 311 | { | ||
| 312 | return m_Callbacks->OpenFile(m_Handle->addonData, strFileName, flags); | ||
| 313 | } | ||
| 314 | |||
| 315 | /*! | ||
| 316 | * @brief Open the file with filename via XBMC's CFile in write mode. Needs to be closed by calling CloseFile() when done. | ||
| 317 | * @param strFileName The filename to open. | ||
| 318 | * @param bOverWrite True to overwrite, false otherwise. | ||
| 319 | * @return A handle for the file, or NULL if it couldn't be opened. | ||
| 320 | */ | ||
| 321 | void* OpenFileForWrite(const char* strFileName, bool bOverWrite) | ||
| 322 | { | ||
| 323 | return m_Callbacks->OpenFileForWrite(m_Handle->addonData, strFileName, bOverWrite); | ||
| 324 | } | ||
| 325 | |||
| 326 | /*! | ||
| 327 | * @brief Read from an open file. | ||
| 328 | * @param file The file handle to read from. | ||
| 329 | * @param lpBuf The buffer to store the data in. | ||
| 330 | * @param uiBufSize The size of the buffer. | ||
| 331 | * @return number of successfully read bytes if any bytes were read and stored in | ||
| 332 | * buffer, zero if no bytes are available to read (end of file was reached) | ||
| 333 | * or undetectable error occur, -1 in case of any explicit error | ||
| 334 | */ | ||
| 335 | ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize) | ||
| 336 | { | ||
| 337 | return m_Callbacks->ReadFile(m_Handle->addonData, file, lpBuf, uiBufSize); | ||
| 338 | } | ||
| 339 | |||
| 340 | /*! | ||
| 341 | * @brief Read a string from an open file. | ||
| 342 | * @param file The file handle to read from. | ||
| 343 | * @param szLine The buffer to store the data in. | ||
| 344 | * @param iLineLength The size of the buffer. | ||
| 345 | * @return True when a line was read, false otherwise. | ||
| 346 | */ | ||
| 347 | bool ReadFileString(void* file, char *szLine, int iLineLength) | ||
| 348 | { | ||
| 349 | return m_Callbacks->ReadFileString(m_Handle->addonData, file, szLine, iLineLength); | ||
| 350 | } | ||
| 351 | |||
| 352 | /*! | ||
| 353 | * @brief Write to a file opened in write mode. | ||
| 354 | * @param file The file handle to write to. | ||
| 355 | * @param lpBuf The data to write. | ||
| 356 | * @param uiBufSize Size of the data to write. | ||
| 357 | * @return number of successfully written bytes if any bytes were written, | ||
| 358 | * zero if no bytes were written and no detectable error occur, | ||
| 359 | * -1 in case of any explicit error | ||
| 360 | */ | ||
| 361 | ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize) | ||
| 362 | { | ||
| 363 | return m_Callbacks->WriteFile(m_Handle->addonData, file, lpBuf, uiBufSize); | ||
| 364 | } | ||
| 365 | |||
| 366 | /*! | ||
| 367 | * @brief Flush buffered data. | ||
| 368 | * @param file The file handle to flush the data for. | ||
| 369 | */ | ||
| 370 | void FlushFile(void* file) | ||
| 371 | { | ||
| 372 | m_Callbacks->FlushFile(m_Handle->addonData, file); | ||
| 373 | } | ||
| 374 | |||
| 375 | /*! | ||
| 376 | * @brief Seek in an open file. | ||
| 377 | * @param file The file handle to see in. | ||
| 378 | * @param iFilePosition The new position. | ||
| 379 | * @param iWhence Seek argument. See stdio.h for possible values. | ||
| 380 | * @return The new position. | ||
| 381 | */ | ||
| 382 | int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence) | ||
| 383 | { | ||
| 384 | return m_Callbacks->SeekFile(m_Handle->addonData, file, iFilePosition, iWhence); | ||
| 385 | } | ||
| 386 | |||
| 387 | /*! | ||
| 388 | * @brief Truncate a file to the requested size. | ||
| 389 | * @param file The file handle to truncate. | ||
| 390 | * @param iSize The new max size. | ||
| 391 | * @return New size? | ||
| 392 | */ | ||
| 393 | int TruncateFile(void* file, int64_t iSize) | ||
| 394 | { | ||
| 395 | return m_Callbacks->TruncateFile(m_Handle->addonData, file, iSize); | ||
| 396 | } | ||
| 397 | |||
| 398 | /*! | ||
| 399 | * @brief The current position in an open file. | ||
| 400 | * @param file The file handle to get the position for. | ||
| 401 | * @return The requested position. | ||
| 402 | */ | ||
| 403 | int64_t GetFilePosition(void* file) | ||
| 404 | { | ||
| 405 | return m_Callbacks->GetFilePosition(m_Handle->addonData, file); | ||
| 406 | } | ||
| 407 | |||
| 408 | /*! | ||
| 409 | * @brief Get the file size of an open file. | ||
| 410 | * @param file The file to get the size for. | ||
| 411 | * @return The requested size. | ||
| 412 | */ | ||
| 413 | int64_t GetFileLength(void* file) | ||
| 414 | { | ||
| 415 | return m_Callbacks->GetFileLength(m_Handle->addonData, file); | ||
| 416 | } | ||
| 417 | |||
| 418 | /*! | ||
| 419 | * @brief Get the download speed of an open file if available. | ||
| 420 | * @param file The file to get the size for. | ||
| 421 | * @return The download speed in seconds. | ||
| 422 | */ | ||
| 423 | double GetFileDownloadSpeed(void* file) | ||
| 424 | { | ||
| 425 | return m_Callbacks->GetFileDownloadSpeed(m_Handle->addonData, file); | ||
| 426 | } | ||
| 427 | |||
| 428 | /*! | ||
| 429 | * @brief Close an open file. | ||
| 430 | * @param file The file handle to close. | ||
| 431 | */ | ||
| 432 | void CloseFile(void* file) | ||
| 433 | { | ||
| 434 | m_Callbacks->CloseFile(m_Handle->addonData, file); | ||
| 435 | } | ||
| 436 | |||
| 437 | /*! | ||
| 438 | * @brief Get the chunk size for an open file. | ||
| 439 | * @param file the file handle to get the size for. | ||
| 440 | * @return The requested size. | ||
| 441 | */ | ||
| 442 | int GetFileChunkSize(void* file) | ||
| 443 | { | ||
| 444 | return m_Callbacks->GetFileChunkSize(m_Handle->addonData, file); | ||
| 445 | } | ||
| 446 | |||
| 447 | /*! | ||
| 448 | * @brief Check if a file exists. | ||
| 449 | * @param strFileName The filename to check. | ||
| 450 | * @param bUseCache Check in file cache. | ||
| 451 | * @return true if the file exists false otherwise. | ||
| 452 | */ | ||
| 453 | bool FileExists(const char *strFileName, bool bUseCache) | ||
| 454 | { | ||
| 455 | return m_Callbacks->FileExists(m_Handle->addonData, strFileName, bUseCache); | ||
| 456 | } | ||
| 457 | |||
| 458 | /*! | ||
| 459 | * @brief Reads file status. | ||
| 460 | * @param strFileName The filename to read the status from. | ||
| 461 | * @param buffer The file status is written into this buffer. | ||
| 462 | * @return The file status was successfully read. | ||
| 463 | */ | ||
| 464 | int StatFile(const char *strFileName, struct __stat64* buffer) | ||
| 465 | { | ||
| 466 | return m_Callbacks->StatFile(m_Handle->addonData, strFileName, buffer); | ||
| 467 | } | ||
| 468 | |||
| 469 | /*! | ||
| 470 | * @brief Get a property from an open file. | ||
| 471 | * @param file The file to get an property for | ||
| 472 | * @param type Type of the requested property. | ||
| 473 | * @param name Name of the requested property / can be null. | ||
| 474 | * @return The value of the requested property, must be FreeString'ed. | ||
| 475 | */ | ||
| 476 | char *GetFilePropertyValue(void* file, XFILE::FileProperty type, const char *name) | ||
| 477 | { | ||
| 478 | return m_Callbacks->GetFilePropertyValue(m_Handle->addonData, file, type, name); | ||
| 479 | } | ||
| 480 | |||
| 481 | /*! | ||
| 482 | * @brief Get multiple property values from an open file. | ||
| 483 | * @param file The file to get the property values for | ||
| 484 | * @param type Type of the requested property. | ||
| 485 | * @param name Name of the requested property / can be null. | ||
| 486 | * @param numValues Number of property values returned. | ||
| 487 | * @return List of values of the requested property, must be FreeStringArray'ed. | ||
| 488 | */ | ||
| 489 | char **GetFilePropertyValues(void* file, XFILE::FileProperty type, const char *name, int *numValues) | ||
| 490 | { | ||
| 491 | return m_Callbacks->GetFilePropertyValues(m_Handle->addonData, file, type, name, numValues); | ||
| 492 | } | ||
| 493 | |||
| 494 | /*! | ||
| 495 | * @brief Deletes a file. | ||
| 496 | * @param strFileName The filename to delete. | ||
| 497 | * @return The file was successfully deleted. | ||
| 498 | */ | ||
| 499 | bool DeleteFile(const char *strFileName) | ||
| 500 | { | ||
| 501 | return m_Callbacks->DeleteFile(m_Handle->addonData, strFileName); | ||
| 502 | } | ||
| 503 | |||
| 504 | /*! | ||
| 505 | * @brief Checks whether a directory can be opened. | ||
| 506 | * @param strUrl The URL of the directory to check. | ||
| 507 | * @return True when it can be opened, false otherwise. | ||
| 508 | */ | ||
| 509 | bool CanOpenDirectory(const char* strUrl) | ||
| 510 | { | ||
| 511 | return m_Callbacks->CanOpenDirectory(m_Handle->addonData, strUrl); | ||
| 512 | } | ||
| 513 | |||
| 514 | /*! | ||
| 515 | * @brief Creates a directory. | ||
| 516 | * @param strPath Path to the directory. | ||
| 517 | * @return True when it was created, false otherwise. | ||
| 518 | */ | ||
| 519 | bool CreateDirectory(const char *strPath) | ||
| 520 | { | ||
| 521 | return m_Callbacks->CreateDirectory(m_Handle->addonData, strPath); | ||
| 522 | } | ||
| 523 | |||
| 524 | /*! | ||
| 525 | * @brief Checks if a directory exists. | ||
| 526 | * @param strPath Path to the directory. | ||
| 527 | * @return True when it exists, false otherwise. | ||
| 528 | */ | ||
| 529 | bool DirectoryExists(const char *strPath) | ||
| 530 | { | ||
| 531 | return m_Callbacks->DirectoryExists(m_Handle->addonData, strPath); | ||
| 532 | } | ||
| 533 | |||
| 534 | /*! | ||
| 535 | * @brief Removes a directory. | ||
| 536 | * @param strPath Path to the directory. | ||
| 537 | * @return True when it was removed, false otherwise. | ||
| 538 | */ | ||
| 539 | bool RemoveDirectory(const char *strPath) | ||
| 540 | { | ||
| 541 | return m_Callbacks->RemoveDirectory(m_Handle->addonData, strPath); | ||
| 542 | } | ||
| 543 | |||
| 544 | /*! | ||
| 545 | * @brief Lists a directory. | ||
| 546 | * @param strPath Path to the directory. | ||
| 547 | * @param mask File mask | ||
| 548 | * @param items The directory entries | ||
| 549 | * @param num_items Number of entries in directory | ||
| 550 | * @return True if listing was successful, false otherwise. | ||
| 551 | */ | ||
| 552 | bool GetDirectory(const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items) | ||
| 553 | { | ||
| 554 | return m_Callbacks->GetDirectory(m_Handle->addonData, strPath, mask, items, num_items); | ||
| 555 | } | ||
| 556 | |||
| 557 | /*! | ||
| 558 | * @brief Free a directory list | ||
| 559 | * @param items The directory entries | ||
| 560 | * @param num_items Number of entries in directory | ||
| 561 | */ | ||
| 562 | void FreeDirectory(VFSDirEntry* items, unsigned int num_items) | ||
| 563 | { | ||
| 564 | m_Callbacks->FreeDirectory(m_Handle->addonData, items, num_items); | ||
| 565 | } | ||
| 566 | |||
| 567 | /*! | ||
| 568 | * @brief Create a Curl representation | ||
| 569 | * @param strURL the URL of the Type. | ||
| 570 | */ | ||
| 571 | void* CURLCreate(const char* strURL) | ||
| 572 | { | ||
| 573 | return m_Callbacks->CURLCreate(m_Handle->addonData, strURL); | ||
| 574 | } | ||
| 575 | |||
| 576 | /*! | ||
| 577 | * @brief Adds options to the curl file created with CURLCeate | ||
| 578 | * @param file file pointer to the file returned by CURLCeate | ||
| 579 | * @param type option type to set | ||
| 580 | * @param name name of the option | ||
| 581 | * @param value value of the option | ||
| 582 | */ | ||
| 583 | bool CURLAddOption(void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value) | ||
| 584 | { | ||
| 585 | return m_Callbacks->CURLAddOption(m_Handle->addonData, file, type, name, value); | ||
| 586 | } | ||
| 587 | |||
| 588 | /*! | ||
| 589 | * @brief Opens the curl file created with CURLCeate | ||
| 590 | * @param file file pointer to the file returned by CURLCeate | ||
| 591 | * @param flags one or more bitwise or combinded flags form XFILE | ||
| 592 | */ | ||
| 593 | bool CURLOpen(void* file, unsigned int flags) | ||
| 594 | { | ||
| 595 | return m_Callbacks->CURLOpen(m_Handle->addonData, file, flags); | ||
| 596 | } | ||
| 597 | |||
| 598 | private: | ||
| 599 | AddonCB* m_Handle; | ||
| 600 | KodiAPI::AddOn::CB_AddOnLib *m_Callbacks; | ||
| 601 | }; | ||
| 602 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h deleted file mode 100644 index 2a94f75..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h +++ /dev/null | |||
| @@ -1,235 +0,0 @@ | |||
| 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 <string> | ||
| 12 | #include <vector> | ||
| 13 | #include <string.h> | ||
| 14 | #include <stdlib.h> | ||
| 15 | #include <stdio.h> | ||
| 16 | #include "xbmc_pvr_types.h" | ||
| 17 | #include "libXBMC_addon.h" | ||
| 18 | |||
| 19 | #define DVD_TIME_BASE 1000000 | ||
| 20 | |||
| 21 | //! @todo original definition is in DVDClock.h | ||
| 22 | #define DVD_NOPTS_VALUE 0xFFF0000000000000 | ||
| 23 | |||
| 24 | class CHelper_libXBMC_pvr | ||
| 25 | { | ||
| 26 | public: | ||
| 27 | CHelper_libXBMC_pvr(void) | ||
| 28 | { | ||
| 29 | m_Handle = nullptr; | ||
| 30 | m_Callbacks = nullptr; | ||
| 31 | } | ||
| 32 | |||
| 33 | ~CHelper_libXBMC_pvr(void) | ||
| 34 | { | ||
| 35 | if (m_Handle && m_Callbacks) | ||
| 36 | { | ||
| 37 | m_Handle->PVRLib_UnRegisterMe(m_Handle->addonData, m_Callbacks); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * @brief Resolve all callback methods | ||
| 43 | * @param handle Pointer to the add-on | ||
| 44 | * @return True when all methods were resolved, false otherwise. | ||
| 45 | */ | ||
| 46 | bool RegisterMe(void* handle) | ||
| 47 | { | ||
| 48 | m_Handle = static_cast<AddonCB*>(handle); | ||
| 49 | if (m_Handle) | ||
| 50 | m_Callbacks = (AddonInstance_PVR*)m_Handle->PVRLib_RegisterMe(m_Handle->addonData); | ||
| 51 | if (!m_Callbacks) | ||
| 52 | fprintf(stderr, "libXBMC_pvr-ERROR: PVRLib_register_me can't get callback table from Kodi !!!\n"); | ||
| 53 | |||
| 54 | return m_Callbacks != NULL; | ||
| 55 | } | ||
| 56 | |||
| 57 | /*! | ||
| 58 | * @brief Transfer an EPG tag from the add-on to XBMC | ||
| 59 | * @param handle The handle parameter that XBMC used when requesting the EPG data | ||
| 60 | * @param entry The entry to transfer to XBMC | ||
| 61 | */ | ||
| 62 | void TransferEpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry) | ||
| 63 | { | ||
| 64 | return m_Callbacks->toKodi.TransferEpgEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); | ||
| 65 | } | ||
| 66 | |||
| 67 | /*! | ||
| 68 | * @brief Transfer a channel entry from the add-on to XBMC | ||
| 69 | * @param handle The handle parameter that XBMC used when requesting the channel list | ||
| 70 | * @param entry The entry to transfer to XBMC | ||
| 71 | */ | ||
| 72 | void TransferChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry) | ||
| 73 | { | ||
| 74 | return m_Callbacks->toKodi.TransferChannelEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); | ||
| 75 | } | ||
| 76 | |||
| 77 | /*! | ||
| 78 | * @brief Transfer a timer entry from the add-on to XBMC | ||
| 79 | * @param handle The handle parameter that XBMC used when requesting the timers list | ||
| 80 | * @param entry The entry to transfer to XBMC | ||
| 81 | */ | ||
| 82 | void TransferTimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry) | ||
| 83 | { | ||
| 84 | return m_Callbacks->toKodi.TransferTimerEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); | ||
| 85 | } | ||
| 86 | |||
| 87 | /*! | ||
| 88 | * @brief Transfer a recording entry from the add-on to XBMC | ||
| 89 | * @param handle The handle parameter that XBMC used when requesting the recordings list | ||
| 90 | * @param entry The entry to transfer to XBMC | ||
| 91 | */ | ||
| 92 | void TransferRecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry) | ||
| 93 | { | ||
| 94 | return m_Callbacks->toKodi.TransferRecordingEntry(m_Callbacks->toKodi.kodiInstance, handle, entry); | ||
| 95 | } | ||
| 96 | |||
| 97 | /*! | ||
| 98 | * @brief Transfer a channel group from the add-on to XBMC. The group will be created if it doesn't exist. | ||
| 99 | * @param handle The handle parameter that XBMC used when requesting the channel groups list | ||
| 100 | * @param entry The entry to transfer to XBMC | ||
| 101 | */ | ||
| 102 | void TransferChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry) | ||
| 103 | { | ||
| 104 | return m_Callbacks->toKodi.TransferChannelGroup(m_Callbacks->toKodi.kodiInstance, handle, entry); | ||
| 105 | } | ||
| 106 | |||
| 107 | /*! | ||
| 108 | * @brief Transfer a channel group member entry from the add-on to XBMC. The channel will be added to the group if the group can be found. | ||
| 109 | * @param handle The handle parameter that XBMC used when requesting the channel group members list | ||
| 110 | * @param entry The entry to transfer to XBMC | ||
| 111 | */ | ||
| 112 | void TransferChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry) | ||
| 113 | { | ||
| 114 | return m_Callbacks->toKodi.TransferChannelGroupMember(m_Callbacks->toKodi.kodiInstance, handle, entry); | ||
| 115 | } | ||
| 116 | |||
| 117 | /*! | ||
| 118 | * @brief Add or replace a menu hook for the context menu for this add-on | ||
| 119 | * @param hook The hook to add | ||
| 120 | */ | ||
| 121 | void AddMenuHook(PVR_MENUHOOK* hook) | ||
| 122 | { | ||
| 123 | return m_Callbacks->toKodi.AddMenuHook(m_Callbacks->toKodi.kodiInstance, hook); | ||
| 124 | } | ||
| 125 | |||
| 126 | /*! | ||
| 127 | * @brief Display a notification in XBMC that a recording started or stopped on the server | ||
| 128 | * @param strRecordingName The name of the recording to display | ||
| 129 | * @param strFileName The filename of the recording | ||
| 130 | * @param bOn True when recording started, false when it stopped | ||
| 131 | */ | ||
| 132 | void Recording(const char* strRecordingName, const char* strFileName, bool bOn) | ||
| 133 | { | ||
| 134 | return m_Callbacks->toKodi.Recording(m_Callbacks->toKodi.kodiInstance, strRecordingName, strFileName, bOn); | ||
| 135 | } | ||
| 136 | |||
| 137 | /*! | ||
| 138 | * @brief Request XBMC to update it's list of timers | ||
| 139 | */ | ||
| 140 | void TriggerTimerUpdate(void) | ||
| 141 | { | ||
| 142 | return m_Callbacks->toKodi.TriggerTimerUpdate(m_Callbacks->toKodi.kodiInstance); | ||
| 143 | } | ||
| 144 | |||
| 145 | /*! | ||
| 146 | * @brief Request XBMC to update it's list of recordings | ||
| 147 | */ | ||
| 148 | void TriggerRecordingUpdate(void) | ||
| 149 | { | ||
| 150 | return m_Callbacks->toKodi.TriggerRecordingUpdate(m_Callbacks->toKodi.kodiInstance); | ||
| 151 | } | ||
| 152 | |||
| 153 | /*! | ||
| 154 | * @brief Request XBMC to update it's list of channels | ||
| 155 | */ | ||
| 156 | void TriggerChannelUpdate(void) | ||
| 157 | { | ||
| 158 | return m_Callbacks->toKodi.TriggerChannelUpdate(m_Callbacks->toKodi.kodiInstance); | ||
| 159 | } | ||
| 160 | |||
| 161 | /*! | ||
| 162 | * @brief Schedule an EPG update for the given channel channel | ||
| 163 | * @param iChannelUid The unique id of the channel for this add-on | ||
| 164 | */ | ||
| 165 | void TriggerEpgUpdate(unsigned int iChannelUid) | ||
| 166 | { | ||
| 167 | return m_Callbacks->toKodi.TriggerEpgUpdate(m_Callbacks->toKodi.kodiInstance, iChannelUid); | ||
| 168 | } | ||
| 169 | |||
| 170 | /*! | ||
| 171 | * @brief Request XBMC to update it's list of channel groups | ||
| 172 | */ | ||
| 173 | void TriggerChannelGroupsUpdate(void) | ||
| 174 | { | ||
| 175 | return m_Callbacks->toKodi.TriggerChannelGroupsUpdate(m_Callbacks->toKodi.kodiInstance); | ||
| 176 | } | ||
| 177 | |||
| 178 | #ifdef USE_DEMUX | ||
| 179 | /*! | ||
| 180 | * @brief Free a packet that was allocated with AllocateDemuxPacket | ||
| 181 | * @param pPacket The packet to free | ||
| 182 | */ | ||
| 183 | void FreeDemuxPacket(DemuxPacket* pPacket) | ||
| 184 | { | ||
| 185 | return m_Callbacks->toKodi.FreeDemuxPacket(m_Callbacks->toKodi.kodiInstance, pPacket); | ||
| 186 | } | ||
| 187 | |||
| 188 | /*! | ||
| 189 | * @brief Allocate a demux packet. Free with FreeDemuxPacket | ||
| 190 | * @param iDataSize The size of the data that will go into the packet | ||
| 191 | * @return The allocated packet | ||
| 192 | */ | ||
| 193 | DemuxPacket* AllocateDemuxPacket(int iDataSize) | ||
| 194 | { | ||
| 195 | return m_Callbacks->toKodi.AllocateDemuxPacket(m_Callbacks->toKodi.kodiInstance, iDataSize); | ||
| 196 | } | ||
| 197 | #endif | ||
| 198 | |||
| 199 | /*! | ||
| 200 | * @brief Notify a state change for a PVR backend connection | ||
| 201 | * @param strConnectionString The connection string reported by the backend that can be displayed in the UI. | ||
| 202 | * @param newState The new state. | ||
| 203 | * @param strMessage A localized addon-defined string representing the new state, that can be displayed | ||
| 204 | * in the UI or NULL if the Kodi-defined default string for the new state shall be displayed. | ||
| 205 | */ | ||
| 206 | void ConnectionStateChange(const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage) | ||
| 207 | { | ||
| 208 | return m_Callbacks->toKodi.ConnectionStateChange(m_Callbacks->toKodi.kodiInstance, strConnectionString, newState, strMessage); | ||
| 209 | } | ||
| 210 | |||
| 211 | /*! | ||
| 212 | * @brief Notify a state change for an EPG event | ||
| 213 | * @param tag The EPG event. | ||
| 214 | * @param newState The new state. For EPG_EVENT_CREATED and EPG_EVENT_UPDATED, tag must be filled with all available | ||
| 215 | * event data, not just a delta. For EPG_EVENT_DELETED, it is sufficient to fill EPG_TAG.iUniqueBroadcastId | ||
| 216 | */ | ||
| 217 | void EpgEventStateChange(EPG_TAG *tag, EPG_EVENT_STATE newState) | ||
| 218 | { | ||
| 219 | return m_Callbacks->toKodi.EpgEventStateChange(m_Callbacks->toKodi.kodiInstance, tag, newState); | ||
| 220 | } | ||
| 221 | |||
| 222 | /*! | ||
| 223 | * @brief Get the codec id used by XBMC | ||
| 224 | * @param strCodecName The name of the codec | ||
| 225 | * @return The codec_id, or a codec_id with 0 values when not supported | ||
| 226 | */ | ||
| 227 | xbmc_codec_t GetCodecByName(const char* strCodecName) | ||
| 228 | { | ||
| 229 | return m_Callbacks->toKodi.GetCodecByName(m_Callbacks->toKodi.kodiInstance, strCodecName); | ||
| 230 | } | ||
| 231 | |||
| 232 | private: | ||
| 233 | AddonCB* m_Handle; | ||
| 234 | AddonInstance_PVR *m_Callbacks; | ||
| 235 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h index aad3a28..ef2d728 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h | |||
| @@ -47,67 +47,68 @@ namespace kodi | |||
| 47 | { | 47 | { |
| 48 | namespace platform | 48 | namespace platform |
| 49 | { | 49 | { |
| 50 | class CInterfaceAndroidSystem | 50 | class ATTRIBUTE_HIDDEN CInterfaceAndroidSystem |
| 51 | { | ||
| 52 | public: | ||
| 53 | CInterfaceAndroidSystem() | ||
| 54 | : m_interface(static_cast<AddonToKodiFuncTable_android_system*>( | ||
| 55 | GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))){}; | ||
| 56 | |||
| 57 | //============================================================================ | ||
| 58 | /// | ||
| 59 | /// \ingroup cpp_kodi_platform | ||
| 60 | /// @brief request an JNI env pointer for the calling thread. | ||
| 61 | /// JNI env has to be controlled by kodi because of the underlying | ||
| 62 | /// threading concep. | ||
| 63 | /// | ||
| 64 | /// @param[in]: | ||
| 65 | /// @return JNI env pointer for the calling thread | ||
| 66 | /// | ||
| 67 | inline void* GetJNIEnv() | ||
| 51 | { | 68 | { |
| 52 | public: | 69 | if (m_interface) |
| 53 | CInterfaceAndroidSystem() | 70 | return m_interface->get_jni_env(); |
| 54 | : m_interface(static_cast<AddonToKodiFuncTable_android_system*>(GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))) | ||
| 55 | {}; | ||
| 56 | 71 | ||
| 57 | //============================================================================ | 72 | return nullptr; |
| 58 | /// | 73 | } |
| 59 | /// \ingroup cpp_kodi_platform | 74 | //---------------------------------------------------------------------------- |
| 60 | /// @brief request an JNI env pointer for the calling thread. | ||
| 61 | /// JNI env has to be controlled by kodi because of the underlying | ||
| 62 | /// threading concep. | ||
| 63 | /// | ||
| 64 | /// @param[in]: | ||
| 65 | /// @return JNI env pointer for the calling thread | ||
| 66 | /// | ||
| 67 | inline void * GetJNIEnv() | ||
| 68 | { | ||
| 69 | if (m_interface) | ||
| 70 | return m_interface->get_jni_env(); | ||
| 71 | 75 | ||
| 72 | return nullptr; | 76 | //============================================================================ |
| 73 | } | 77 | /// |
| 74 | //---------------------------------------------------------------------------- | 78 | /// \ingroup cpp_kodi_platform |
| 79 | /// @brief request the android sdk version to e.g. initialize JNIBase. | ||
| 80 | /// | ||
| 81 | /// @param[in]: | ||
| 82 | /// @return Android SDK version | ||
| 83 | /// | ||
| 84 | inline int GetSDKVersion() | ||
| 85 | { | ||
| 86 | if (m_interface) | ||
| 87 | return m_interface->get_sdk_version(); | ||
| 75 | 88 | ||
| 76 | //============================================================================ | 89 | return 0; |
| 77 | /// | 90 | } |
| 78 | /// \ingroup cpp_kodi_platform | ||
| 79 | /// @brief request the android sdk version to e.g. initialize JNIBase. | ||
| 80 | /// | ||
| 81 | /// @param[in]: | ||
| 82 | /// @return Android SDK version | ||
| 83 | /// | ||
| 84 | inline int GetSDKVersion() | ||
| 85 | { | ||
| 86 | if (m_interface) | ||
| 87 | return m_interface->get_sdk_version(); | ||
| 88 | 91 | ||
| 89 | return 0; | 92 | //============================================================================ |
| 90 | } | 93 | /// |
| 94 | /// \ingroup cpp_kodi_platform | ||
| 95 | /// @brief request the android main class name e.g. org.xbmc.kodi. | ||
| 96 | /// | ||
| 97 | /// @param[in]: | ||
| 98 | /// @return package class name | ||
| 99 | /// | ||
| 100 | inline std::string GetClassName() | ||
| 101 | { | ||
| 102 | if (m_interface) | ||
| 103 | return m_interface->get_class_name(); | ||
| 91 | 104 | ||
| 92 | //============================================================================ | 105 | return std::string(); |
| 93 | /// | 106 | } |
| 94 | /// \ingroup cpp_kodi_platform | ||
| 95 | /// @brief request the android main class name e.g. org.xbmc.kodi. | ||
| 96 | /// | ||
| 97 | /// @param[in]: | ||
| 98 | /// @return package class name | ||
| 99 | /// | ||
| 100 | inline std::string GetClassName() | ||
| 101 | { | ||
| 102 | if (m_interface) | ||
| 103 | return m_interface->get_class_name(); | ||
| 104 | 107 | ||
| 105 | return std::string(); | 108 | private: |
| 106 | } | 109 | AddonToKodiFuncTable_android_system* m_interface; |
| 110 | }; | ||
| 111 | //---------------------------------------------------------------------------- | ||
| 107 | 112 | ||
| 108 | private: | ||
| 109 | AddonToKodiFuncTable_android_system *m_interface; | ||
| 110 | }; | ||
| 111 | //---------------------------------------------------------------------------- | ||
| 112 | } /* namespace platform */ | 113 | } /* namespace platform */ |
| 113 | } /* namespace kodi */ | 114 | } /* namespace kodi */ |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt index ef2fa25..939585c 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/CMakeLists.txt | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | set(HEADERS DllHelper.h | 1 | set(HEADERS DllHelper.h ) |
| 2 | Time.h) | ||
| 3 | 2 | ||
| 4 | if(NOT ENABLE_STATIC_LIBS) | 3 | if(NOT ENABLE_STATIC_LIBS) |
| 5 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_tools) | 4 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_tools) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/DllHelper.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/DllHelper.h index 1ae1a0e..3cc9eea 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/DllHelper.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/DllHelper.h | |||
| @@ -8,24 +8,42 @@ | |||
| 8 | 8 | ||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #ifdef __cplusplus | ||
| 12 | |||
| 11 | #include <string> | 13 | #include <string> |
| 12 | #include <kodi/AddonBase.h> | ||
| 13 | 14 | ||
| 14 | #ifdef _WIN32 // windows | 15 | #include <dlfcn.h> |
| 15 | #include <p8-platform/windows/dlfcn-win32.h> | 16 | #include <kodi/AddonBase.h> |
| 16 | #else | 17 | #include <kodi/Filesystem.h> |
| 17 | #include <dlfcn.h> // linux+osx | ||
| 18 | #endif | ||
| 19 | 18 | ||
| 19 | //============================================================================== | ||
| 20 | /// @ingroup cpp_kodi_tools_CDllHelper | ||
| 21 | /// @brief Macro to translate the given pointer value name of functions to | ||
| 22 | /// requested function name. | ||
| 23 | /// | ||
| 24 | /// @note This should always be used and does the work of | ||
| 25 | /// @ref kodi::tools::CDllHelper::RegisterSymbol(). | ||
| 26 | /// | ||
| 20 | #define REGISTER_DLL_SYMBOL(functionPtr) \ | 27 | #define REGISTER_DLL_SYMBOL(functionPtr) \ |
| 21 | CDllHelper::RegisterSymbol(functionPtr, #functionPtr) | 28 | kodi::tools::CDllHelper::RegisterSymbol(functionPtr, #functionPtr) |
| 29 | //------------------------------------------------------------------------------ | ||
| 22 | 30 | ||
| 23 | /// @brief Class to help with load of shared library functions | 31 | namespace kodi |
| 24 | /// | 32 | { |
| 33 | namespace tools | ||
| 34 | { | ||
| 35 | |||
| 36 | //============================================================================== | ||
| 37 | /// @defgroup cpp_kodi_tools_CDllHelper class CDllHelper | ||
| 38 | /// @ingroup cpp_kodi_tools | ||
| 39 | /// @brief **Class to help with load of shared library functions**\n | ||
| 25 | /// You can add them as parent to your class and to help with load of shared | 40 | /// You can add them as parent to your class and to help with load of shared |
| 26 | /// library functions. | 41 | /// library functions. |
| 27 | /// | 42 | /// |
| 28 | /// @note To use on Windows must you also include p8-platform on your addon! | 43 | /// @note To use on Windows must you also include [dlfcn-win32](https://github.com/dlfcn-win32/dlfcn-win32) |
| 44 | /// on your addon!\n\n | ||
| 45 | /// Furthermore, this allows the use of Android where the required library is | ||
| 46 | /// copied to an EXE useable folder. | ||
| 29 | /// | 47 | /// |
| 30 | /// | 48 | /// |
| 31 | /// ---------------------------------------------------------------------------- | 49 | /// ---------------------------------------------------------------------------- |
| @@ -37,22 +55,22 @@ | |||
| 37 | /// | 55 | /// |
| 38 | /// ... | 56 | /// ... |
| 39 | /// class CMyInstance : public kodi::addon::CInstanceAudioDecoder, | 57 | /// class CMyInstance : public kodi::addon::CInstanceAudioDecoder, |
| 40 | /// private CDllHelper | 58 | /// private kodi::tools::CDllHelper |
| 41 | /// { | 59 | /// { |
| 42 | /// public: | 60 | /// public: |
| 43 | /// CMyInstance(KODI_HANDLE instance); | 61 | /// CMyInstance(KODI_HANDLE instance, const std::string& kodiVersion); |
| 44 | /// bool Start(); | 62 | /// bool Start(); |
| 45 | /// | 63 | /// |
| 46 | /// ... | 64 | /// ... |
| 47 | /// | 65 | /// |
| 48 | /// /* The pointers for on shared library exported functions */ | 66 | /// // The pointers for on shared library exported functions |
| 49 | /// int (*Init)(); | 67 | /// int (*Init)(); |
| 50 | /// void (*Cleanup)(); | 68 | /// void (*Cleanup)(); |
| 51 | /// int (*GetLength)(); | 69 | /// int (*GetLength)(); |
| 52 | /// }; | 70 | /// }; |
| 53 | /// | 71 | /// |
| 54 | /// CMyInstance::CMyInstance(KODI_HANDLE instance) | 72 | /// CMyInstance::CMyInstance(KODI_HANDLE instance, const std::string& kodiVersion) |
| 55 | /// : CInstanceAudioDecoder(instance) | 73 | /// : CInstanceAudioDecoder(instance, kodiVersion) |
| 56 | /// { | 74 | /// { |
| 57 | /// } | 75 | /// } |
| 58 | /// | 76 | /// |
| @@ -70,23 +88,80 @@ | |||
| 70 | /// ... | 88 | /// ... |
| 71 | /// ~~~~~~~~~~~~~ | 89 | /// ~~~~~~~~~~~~~ |
| 72 | /// | 90 | /// |
| 73 | class CDllHelper | 91 | ///@{ |
| 92 | class ATTRIBUTE_HIDDEN CDllHelper | ||
| 74 | { | 93 | { |
| 75 | public: | 94 | public: |
| 76 | CDllHelper() : m_dll(nullptr) { } | 95 | //============================================================================ |
| 96 | /// @ingroup cpp_kodi_tools_CDllHelper | ||
| 97 | /// @brief Class constructor. | ||
| 98 | /// | ||
| 99 | CDllHelper() = default; | ||
| 100 | //---------------------------------------------------------------------------- | ||
| 101 | |||
| 102 | //============================================================================ | ||
| 103 | /// @ingroup cpp_kodi_tools_CDllHelper | ||
| 104 | /// @brief Class destructor. | ||
| 105 | /// | ||
| 77 | virtual ~CDllHelper() | 106 | virtual ~CDllHelper() |
| 78 | { | 107 | { |
| 79 | if (m_dll) | 108 | if (m_dll) |
| 80 | dlclose(m_dll); | 109 | dlclose(m_dll); |
| 81 | } | 110 | } |
| 111 | //---------------------------------------------------------------------------- | ||
| 82 | 112 | ||
| 83 | /// @brief Function to load requested library | 113 | //============================================================================ |
| 114 | /// @ingroup cpp_kodi_tools_CDllHelper | ||
| 115 | /// @brief Function to load requested library. | ||
| 84 | /// | 116 | /// |
| 85 | /// @param[in] path The path with filename of shared library to load | 117 | /// @param[in] path The path with filename of shared library to load |
| 86 | /// @return true if load was successful done | 118 | /// @return true if load was successful done |
| 87 | /// | 119 | /// |
| 88 | bool LoadDll(const std::string& path) | 120 | bool LoadDll(std::string path) |
| 89 | { | 121 | { |
| 122 | #if defined(TARGET_ANDROID) | ||
| 123 | if (kodi::vfs::FileExists(path)) | ||
| 124 | { | ||
| 125 | // Check already defined for "xbmcaltbinaddons", if yes no copy necassary. | ||
| 126 | std::string xbmcaltbinaddons = | ||
| 127 | kodi::vfs::TranslateSpecialProtocol("special://xbmcaltbinaddons/"); | ||
| 128 | if (path.compare(0, xbmcaltbinaddons.length(), xbmcaltbinaddons) != 0) | ||
| 129 | { | ||
| 130 | bool doCopy = true; | ||
| 131 | std::string dstfile = xbmcaltbinaddons + kodi::vfs::GetFileName(path); | ||
| 132 | |||
| 133 | kodi::vfs::FileStatus dstFileStat; | ||
| 134 | if (kodi::vfs::StatFile(dstfile, dstFileStat)) | ||
| 135 | { | ||
| 136 | kodi::vfs::FileStatus srcFileStat; | ||
| 137 | if (kodi::vfs::StatFile(path, srcFileStat)) | ||
| 138 | { | ||
| 139 | if (dstFileStat.GetSize() == srcFileStat.GetSize() && | ||
| 140 | dstFileStat.GetModificationTime() > srcFileStat.GetModificationTime()) | ||
| 141 | doCopy = false; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | if (doCopy) | ||
| 146 | { | ||
| 147 | kodi::Log(ADDON_LOG_DEBUG, "Caching '%s' to '%s'", path.c_str(), dstfile.c_str()); | ||
| 148 | if (!kodi::vfs::CopyFile(path, dstfile)) | ||
| 149 | { | ||
| 150 | kodi::Log(ADDON_LOG_ERROR, "Failed to cache '%s' to '%s'", path.c_str(), | ||
| 151 | dstfile.c_str()); | ||
| 152 | return false; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | path = dstfile; | ||
| 157 | } | ||
| 158 | } | ||
| 159 | else | ||
| 160 | { | ||
| 161 | return false; | ||
| 162 | } | ||
| 163 | #endif | ||
| 164 | |||
| 90 | m_dll = dlopen(path.c_str(), RTLD_LAZY); | 165 | m_dll = dlopen(path.c_str(), RTLD_LAZY); |
| 91 | if (m_dll == nullptr) | 166 | if (m_dll == nullptr) |
| 92 | { | 167 | { |
| @@ -95,11 +170,21 @@ public: | |||
| 95 | } | 170 | } |
| 96 | return true; | 171 | return true; |
| 97 | } | 172 | } |
| 173 | //---------------------------------------------------------------------------- | ||
| 98 | 174 | ||
| 99 | /// @brief Function to register requested library symbol | 175 | //============================================================================ |
| 176 | /// @ingroup cpp_kodi_tools_CDllHelper | ||
| 177 | /// @brief Function to register requested library symbol. | ||
| 178 | /// | ||
| 179 | /// @warning This function should not be used, use instead the macro | ||
| 180 | /// @ref REGISTER_DLL_SYMBOL to register the symbol pointer. | ||
| 100 | /// | 181 | /// |
| 101 | /// @note This function should not be used, use instead the macro | 182 | /// |
| 102 | /// REGISTER_DLL_SYMBOL to register the symbol pointer. | 183 | /// Use this always via Macro, e.g.: |
| 184 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 185 | /// if (!REGISTER_DLL_SYMBOL(Init)) | ||
| 186 | /// return false; | ||
| 187 | /// ~~~~~~~~~~~~~ | ||
| 103 | /// | 188 | /// |
| 104 | template <typename T> | 189 | template <typename T> |
| 105 | bool RegisterSymbol(T& functionPtr, const char* strFunctionPtr) | 190 | bool RegisterSymbol(T& functionPtr, const char* strFunctionPtr) |
| @@ -112,7 +197,15 @@ public: | |||
| 112 | } | 197 | } |
| 113 | return true; | 198 | return true; |
| 114 | } | 199 | } |
| 200 | //---------------------------------------------------------------------------- | ||
| 115 | 201 | ||
| 116 | private: | 202 | private: |
| 117 | void* m_dll; | 203 | void* m_dll = nullptr; |
| 118 | }; | 204 | }; |
| 205 | ///@} | ||
| 206 | //------------------------------------------------------------------------------ | ||
| 207 | |||
| 208 | } /* namespace tools */ | ||
| 209 | } /* namespace kodi */ | ||
| 210 | |||
| 211 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/Time.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/Time.h deleted file mode 100644 index 31c29fd..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/tools/Time.h +++ /dev/null | |||
| @@ -1,91 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2019 Team Kodi | ||
| 4 | * Copyright (C) 2011-2012 Pulse-Eight Limited. | ||
| 5 | * This file is part of Kodi - https://kodi.tv | ||
| 6 | * | ||
| 7 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 8 | * See LICENSES/README.md for more information. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #if defined(TARGET_DARWIN) | ||
| 12 | #include <mach/mach_time.h> | ||
| 13 | #include <CoreVideo/CVHostTime.h> | ||
| 14 | #elif defined(TARGET_WINDOWS) | ||
| 15 | #include <Windows.h> | ||
| 16 | #include <time.h> | ||
| 17 | #else | ||
| 18 | #include <time.h> | ||
| 19 | #endif | ||
| 20 | |||
| 21 | namespace kodi | ||
| 22 | { | ||
| 23 | namespace time | ||
| 24 | { | ||
| 25 | |||
| 26 | //=============================================================================== | ||
| 27 | /// @brief Function to get current time in milliseconds | ||
| 28 | /// | ||
| 29 | /// @return Current time in milliseconds as a double value | ||
| 30 | /// | ||
| 31 | /// | ||
| 32 | /// ----------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// **Example:** | ||
| 35 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 36 | /// | ||
| 37 | /// #include <kodi/tools/Time.h> | ||
| 38 | /// | ||
| 39 | /// ... | ||
| 40 | /// double time = kodi::time::GetTimeMs(); | ||
| 41 | /// ... | ||
| 42 | /// ~~~~~~~~~~~~~ | ||
| 43 | /// | ||
| 44 | inline double GetTimeMs() | ||
| 45 | { | ||
| 46 | #if defined(TARGET_DARWIN) | ||
| 47 | return static_cast<double>(CVGetCurrentHostTime() / static_cast<double>(CVGetHostClockFrequency() * 0.001)); | ||
| 48 | #elif defined(TARGET_WINDOWS) | ||
| 49 | LARGE_INTEGER tickPerSecond; | ||
| 50 | LARGE_INTEGER tick; | ||
| 51 | if (QueryPerformanceFrequency(&tickPerSecond)) | ||
| 52 | { | ||
| 53 | QueryPerformanceCounter(&tick); | ||
| 54 | return static_cast<double>(tick.QuadPart) / (tickPerSecond.QuadPart / 1000.0); | ||
| 55 | } | ||
| 56 | return 0.0; | ||
| 57 | #else | ||
| 58 | timespec time; | ||
| 59 | clock_gettime(CLOCK_MONOTONIC, &time); | ||
| 60 | return static_cast<double>(time.tv_sec) * 1000.0 + time.tv_nsec / 1000000.0; | ||
| 61 | #endif | ||
| 62 | } | ||
| 63 | //------------------------------------------------------------------------------- | ||
| 64 | |||
| 65 | //=============================================================================== | ||
| 66 | /// @brief Function to get current time in seconds | ||
| 67 | /// | ||
| 68 | /// @return Current time in seconds with the value type defined in the template | ||
| 69 | /// | ||
| 70 | /// | ||
| 71 | /// ----------------------------------------------------------------------------- | ||
| 72 | /// | ||
| 73 | /// **Example:** | ||
| 74 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 75 | /// | ||
| 76 | /// #include <kodi/tools/Time.h> | ||
| 77 | /// | ||
| 78 | /// ... | ||
| 79 | /// double time = kodi::time::GetTimeSec<double>(); | ||
| 80 | /// ... | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | template <class T> | ||
| 84 | inline T GetTimeSec() | ||
| 85 | { | ||
| 86 | return static_cast<T>(GetTimeMs()) / static_cast<T>(1000.0); | ||
| 87 | } | ||
| 88 | //------------------------------------------------------------------------------- | ||
| 89 | |||
| 90 | } /* namespace time */ | ||
| 91 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h index a9f1798..041e22b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h | |||
| @@ -30,105 +30,135 @@ | |||
| 30 | * overview. | 30 | * overview. |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #define ADDON_GLOBAL_VERSION_MAIN "1.0.14" | 33 | // Ignore clang here, as this must be good in overview and as the main reason, |
| 34 | #define ADDON_GLOBAL_VERSION_MAIN_MIN "1.0.12" | 34 | // because cmake uses this area in this form to perform its addon dependency |
| 35 | // check. | ||
| 36 | // clang-format off | ||
| 37 | #define ADDON_GLOBAL_VERSION_MAIN "1.2.4" | ||
| 38 | #define ADDON_GLOBAL_VERSION_MAIN_MIN "1.2.0" | ||
| 35 | #define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main" | 39 | #define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main" |
| 36 | #define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \ | 40 | #define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \ |
| 37 | "xbmc_addon_dll.h" \ | 41 | "addon-instance/" \ |
| 38 | "xbmc_addon_types.h" \ | 42 | "c-api/addon_base.h" |
| 39 | "libXBMC_addon.h" \ | ||
| 40 | "addon-instance/" | ||
| 41 | 43 | ||
| 42 | #define ADDON_GLOBAL_VERSION_GENERAL "1.0.3" | 44 | #define ADDON_GLOBAL_VERSION_GENERAL "1.0.5" |
| 43 | #define ADDON_GLOBAL_VERSION_GENERAL_MIN "1.0.2" | 45 | #define ADDON_GLOBAL_VERSION_GENERAL_MIN "1.0.4" |
| 44 | #define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general" | 46 | #define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general" |
| 45 | #define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h" | 47 | #define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h" |
| 46 | 48 | ||
| 47 | #define ADDON_GLOBAL_VERSION_GUI "5.12.1" | 49 | #define ADDON_GLOBAL_VERSION_GUI "5.14.1" |
| 48 | #define ADDON_GLOBAL_VERSION_GUI_MIN "5.10.0" | 50 | #define ADDON_GLOBAL_VERSION_GUI_MIN "5.14.0" |
| 49 | #define ADDON_GLOBAL_VERSION_GUI_XML_ID "kodi.binary.global.gui" | 51 | #define ADDON_GLOBAL_VERSION_GUI_XML_ID "kodi.binary.global.gui" |
| 50 | #define ADDON_GLOBAL_VERSION_GUI_DEPENDS "libKODI_guilib.h" \ | 52 | #define ADDON_GLOBAL_VERSION_GUI_DEPENDS "ActionIDs.h" \ |
| 51 | "gui/" | 53 | "gui/" |
| 52 | 54 | ||
| 53 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE "1.0.1" | 55 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE "1.1.1" |
| 54 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN "1.0.1" | 56 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN "1.1.0" |
| 55 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_XML_ID "kodi.binary.global.audioengine" | 57 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_XML_ID "kodi.binary.global.audioengine" |
| 56 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS "AudioEngine.h" | 58 | #define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS "AudioEngine.h" \ |
| 59 | "c-api/audio_engine.h" | ||
| 57 | 60 | ||
| 58 | #define ADDON_GLOBAL_VERSION_FILESYSTEM "1.0.2" | 61 | #define ADDON_GLOBAL_VERSION_FILESYSTEM "1.1.4" |
| 59 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_MIN "1.0.2" | 62 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_MIN "1.1.0" |
| 60 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_XML_ID "kodi.binary.global.filesystem" | 63 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_XML_ID "kodi.binary.global.filesystem" |
| 61 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_DEPENDS "Filesystem.h" | 64 | #define ADDON_GLOBAL_VERSION_FILESYSTEM_DEPENDS "Filesystem.h" \ |
| 65 | "c-api/filesystem.h" \ | ||
| 66 | "gui/gl/Shader.h" \ | ||
| 67 | "tools/DllHelper.h" | ||
| 62 | 68 | ||
| 63 | #define ADDON_GLOBAL_VERSION_NETWORK "1.0.0" | 69 | #define ADDON_GLOBAL_VERSION_NETWORK "1.0.4" |
| 64 | #define ADDON_GLOBAL_VERSION_NETWORK_MIN "1.0.0" | 70 | #define ADDON_GLOBAL_VERSION_NETWORK_MIN "1.0.0" |
| 65 | #define ADDON_GLOBAL_VERSION_NETWORK_XML_ID "kodi.binary.global.network" | 71 | #define ADDON_GLOBAL_VERSION_NETWORK_XML_ID "kodi.binary.global.network" |
| 66 | #define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" | 72 | #define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" \ |
| 73 | "c-api/network.h" | ||
| 67 | 74 | ||
| 68 | #define ADDON_INSTANCE_VERSION_AUDIODECODER "2.0.0" | 75 | #define ADDON_GLOBAL_VERSION_TOOLS "1.0.1" |
| 69 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "2.0.0" | 76 | #define ADDON_GLOBAL_VERSION_TOOLS_MIN "1.0.0" |
| 77 | #define ADDON_GLOBAL_VERSION_TOOLS_XML_ID "kodi.binary.global.tools" | ||
| 78 | #define ADDON_GLOBAL_VERSION_TOOLS_DEPENDS "tools/DllHelper.h" | ||
| 79 | |||
| 80 | #define ADDON_INSTANCE_VERSION_AUDIODECODER "2.0.2" | ||
| 81 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "2.0.1" | ||
| 70 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder" | 82 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder" |
| 71 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_DEPENDS "addon-instance/AudioDecoder.h" | 83 | #define ADDON_INSTANCE_VERSION_AUDIODECODER_DEPENDS "addon-instance/AudioDecoder.h" |
| 72 | 84 | ||
| 73 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER "2.0.0" | 85 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER "2.0.2" |
| 74 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN "2.0.0" | 86 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN "2.0.1" |
| 75 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder" | 87 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder" |
| 76 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "addon-instance/AudioEncoder.h" | 88 | #define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "addon-instance/AudioEncoder.h" |
| 77 | 89 | ||
| 78 | #define ADDON_INSTANCE_VERSION_GAME "1.1.0" | 90 | #define ADDON_INSTANCE_VERSION_GAME "2.0.2" |
| 79 | #define ADDON_INSTANCE_VERSION_GAME_MIN "1.1.0" | 91 | #define ADDON_INSTANCE_VERSION_GAME_MIN "2.0.1" |
| 80 | #define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game" | 92 | #define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game" |
| 81 | #define ADDON_INSTANCE_VERSION_GAME_DEPENDS "kodi_game_dll.h" \ | 93 | #define ADDON_INSTANCE_VERSION_GAME_DEPENDS "addon-instance/Game.h" |
| 82 | "kodi_game_types.h" \ | ||
| 83 | "libKODI_game.h" | ||
| 84 | 94 | ||
| 85 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER "2.0.0" | 95 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER "2.1.1" |
| 86 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN "2.0.0" | 96 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN "2.1.0" |
| 87 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder" | 97 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder" |
| 88 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "addon-instance/ImageDecoder.h" | 98 | #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "addon-instance/ImageDecoder.h" |
| 89 | 99 | ||
| 90 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM "2.0.8" | 100 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM "2.3.3" |
| 91 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "2.0.7" | 101 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "2.3.1" |
| 92 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" | 102 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" |
| 93 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h" | 103 | #define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h" |
| 94 | 104 | ||
| 95 | #define ADDON_INSTANCE_VERSION_PERIPHERAL "1.3.7" | 105 | #define ADDON_INSTANCE_VERSION_PERIPHERAL "1.3.9" |
| 96 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "1.3.4" | 106 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "1.3.8" |
| 97 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" | 107 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" |
| 98 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ | 108 | #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ |
| 99 | "addon-instance/PeripheralUtils.h" | 109 | "addon-instance/PeripheralUtils.h" |
| 100 | 110 | ||
| 101 | #define ADDON_INSTANCE_VERSION_PVR "6.0.0" | 111 | #define ADDON_INSTANCE_VERSION_PVR "7.0.1" |
| 102 | #define ADDON_INSTANCE_VERSION_PVR_MIN "6.0.0" | 112 | #define ADDON_INSTANCE_VERSION_PVR_MIN "7.0.0" |
| 103 | #define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr" | 113 | #define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr" |
| 104 | #define ADDON_INSTANCE_VERSION_PVR_DEPENDS "xbmc_pvr_dll.h" \ | 114 | #define ADDON_INSTANCE_VERSION_PVR_DEPENDS "c-api/addon-instance/pvr.h" \ |
| 105 | "xbmc_pvr_types.h" \ | 115 | "c-api/addon-instance/pvr/pvr_channel_groups.h" \ |
| 106 | "xbmc_epg_types.h" \ | 116 | "c-api/addon-instance/pvr/pvr_channels.h" \ |
| 107 | "libXBMC_pvr.h" | 117 | "c-api/addon-instance/pvr/pvr_defines.h" \ |
| 108 | 118 | "c-api/addon-instance/pvr/pvr_edl.h" \ | |
| 109 | #define ADDON_INSTANCE_VERSION_SCREENSAVER "2.0.0" | 119 | "c-api/addon-instance/pvr/pvr_epg.h" \ |
| 110 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_MIN "2.0.0" | 120 | "c-api/addon-instance/pvr/pvr_general.h" \ |
| 121 | "c-api/addon-instance/pvr/pvr_menu_hook.h" \ | ||
| 122 | "c-api/addon-instance/pvr/pvr_recordings.h" \ | ||
| 123 | "c-api/addon-instance/pvr/pvr_stream.h" \ | ||
| 124 | "c-api/addon-instance/pvr/pvr_timers.h" \ | ||
| 125 | "addon-instance/PVR.h" \ | ||
| 126 | "addon-instance/pvr/ChannelGroups.h" \ | ||
| 127 | "addon-instance/pvr/Channels.h" \ | ||
| 128 | "addon-instance/pvr/EDL.h" \ | ||
| 129 | "addon-instance/pvr/EPG.h" \ | ||
| 130 | "addon-instance/pvr/General.h" \ | ||
| 131 | "addon-instance/pvr/MenuHook.h" \ | ||
| 132 | "addon-instance/pvr/Recordings.h" \ | ||
| 133 | "addon-instance/pvr/Stream.h" \ | ||
| 134 | "addon-instance/pvr/Timers.h" | ||
| 135 | |||
| 136 | #define ADDON_INSTANCE_VERSION_SCREENSAVER "2.0.2" | ||
| 137 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_MIN "2.0.1" | ||
| 111 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_XML_ID "kodi.binary.instance.screensaver" | 138 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_XML_ID "kodi.binary.instance.screensaver" |
| 112 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_DEPENDS "addon-instance/Screensaver.h" | 139 | #define ADDON_INSTANCE_VERSION_SCREENSAVER_DEPENDS "addon-instance/Screensaver.h" |
| 113 | 140 | ||
| 114 | #define ADDON_INSTANCE_VERSION_VFS "2.0.0" | 141 | #define ADDON_INSTANCE_VERSION_VFS "2.3.2" |
| 115 | #define ADDON_INSTANCE_VERSION_VFS_MIN "2.0.0" | 142 | #define ADDON_INSTANCE_VERSION_VFS_MIN "2.3.1" |
| 116 | #define ADDON_INSTANCE_VERSION_VFS_XML_ID "kodi.binary.instance.vfs" | 143 | #define ADDON_INSTANCE_VERSION_VFS_XML_ID "kodi.binary.instance.vfs" |
| 117 | #define ADDON_INSTANCE_VERSION_VFS_DEPENDS "addon-instance/VFS.h" | 144 | #define ADDON_INSTANCE_VERSION_VFS_DEPENDS "addon-instance/VFS.h" |
| 118 | 145 | ||
| 119 | #define ADDON_INSTANCE_VERSION_VISUALIZATION "2.0.1" | 146 | #define ADDON_INSTANCE_VERSION_VISUALIZATION "2.0.4" |
| 120 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_MIN "2.0.0" | 147 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_MIN "2.0.3" |
| 121 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_XML_ID "kodi.binary.instance.visualization" | 148 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_XML_ID "kodi.binary.instance.visualization" |
| 122 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" | 149 | #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" |
| 123 | 150 | ||
| 124 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC "1.0.1" | 151 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC "1.0.3" |
| 125 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "1.0.1" | 152 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "1.0.2" |
| 126 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec" | 153 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec" |
| 127 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "addon-instance/VideoCodec.h" \ | 154 | #define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "addon-instance/VideoCodec.h" \ |
| 128 | "StreamCodec.h" \ | 155 | "StreamCodec.h" \ |
| 129 | "StreamCrypto.h" | 156 | "StreamCrypto.h" |
| 157 | // clang-format on | ||
| 130 | 158 | ||
| 159 | //============================================================================== | ||
| 131 | /// | 160 | /// |
| 161 | /// @ingroup cpp_kodi_addon_addonbase | ||
| 132 | /// The currently available instance types for Kodi add-ons | 162 | /// The currently available instance types for Kodi add-ons |
| 133 | /// | 163 | /// |
| 134 | /// \internal | 164 | /// \internal |
| @@ -145,21 +175,47 @@ typedef enum ADDON_TYPE | |||
| 145 | ADDON_GLOBAL_GENERAL = 3, | 175 | ADDON_GLOBAL_GENERAL = 3, |
| 146 | ADDON_GLOBAL_NETWORK = 4, | 176 | ADDON_GLOBAL_NETWORK = 4, |
| 147 | ADDON_GLOBAL_FILESYSTEM = 5, | 177 | ADDON_GLOBAL_FILESYSTEM = 5, |
| 148 | ADDON_GLOBAL_MAX = 5, // Last used global id, used in loops to check versions. Need to change if new global type becomes added. | 178 | ADDON_GLOBAL_TOOLS = 6, |
| 179 | // Last used global id, used in loops to check versions. | ||
| 180 | // Need to change if new global type becomes added! | ||
| 181 | ADDON_GLOBAL_MAX = 6, | ||
| 149 | 182 | ||
| 150 | /* addon type instances */ | 183 | /* addon type instances */ |
| 184 | |||
| 185 | /// Audio decoder instance, see \ref cpp_kodi_addon_audiodecoder "kodi::addon::CInstanceAudioDecoder" | ||
| 151 | ADDON_INSTANCE_AUDIODECODER = 102, | 186 | ADDON_INSTANCE_AUDIODECODER = 102, |
| 187 | |||
| 188 | /// Audio encoder instance, see \ref cpp_kodi_addon_audioencoder "kodi::addon::CInstanceAudioEncoder" | ||
| 152 | ADDON_INSTANCE_AUDIOENCODER = 103, | 189 | ADDON_INSTANCE_AUDIOENCODER = 103, |
| 190 | |||
| 191 | /// Game instance, see \ref cpp_kodi_addon_game "kodi::addon::CInstanceGame" | ||
| 153 | ADDON_INSTANCE_GAME = 104, | 192 | ADDON_INSTANCE_GAME = 104, |
| 193 | |||
| 194 | /// Input stream instance, see \ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream" | ||
| 154 | ADDON_INSTANCE_INPUTSTREAM = 105, | 195 | ADDON_INSTANCE_INPUTSTREAM = 105, |
| 196 | |||
| 197 | /// Peripheral instance, see \ref cpp_kodi_addon_peripheral "kodi::addon::CInstancePeripheral" | ||
| 155 | ADDON_INSTANCE_PERIPHERAL = 106, | 198 | ADDON_INSTANCE_PERIPHERAL = 106, |
| 199 | |||
| 200 | /// Game instance, see \ref cpp_kodi_addon_pvr "kodi::addon::CInstancePVRClient" | ||
| 156 | ADDON_INSTANCE_PVR = 107, | 201 | ADDON_INSTANCE_PVR = 107, |
| 202 | |||
| 203 | /// PVR client instance, see \ref cpp_kodi_addon_screensaver "kodi::addon::CInstanceScreensaver" | ||
| 157 | ADDON_INSTANCE_SCREENSAVER = 108, | 204 | ADDON_INSTANCE_SCREENSAVER = 108, |
| 205 | |||
| 206 | /// Music visualization instance, see \ref cpp_kodi_addon_visualization "kodi::addon::CInstanceVisualization" | ||
| 158 | ADDON_INSTANCE_VISUALIZATION = 109, | 207 | ADDON_INSTANCE_VISUALIZATION = 109, |
| 208 | |||
| 209 | /// Virtual Filesystem (VFS) instance, see \ref cpp_kodi_addon_vfs "kodi::addon::CInstanceVFS" | ||
| 159 | ADDON_INSTANCE_VFS = 110, | 210 | ADDON_INSTANCE_VFS = 110, |
| 211 | |||
| 212 | /// Image Decoder instance, see \ref cpp_kodi_addon_imagedecoder "kodi::addon::CInstanceImageDecoder" | ||
| 160 | ADDON_INSTANCE_IMAGEDECODER = 111, | 213 | ADDON_INSTANCE_IMAGEDECODER = 111, |
| 214 | |||
| 215 | /// Video Decoder instance, see \ref cpp_kodi_addon_videocodec "kodi::addon::CInstanceVideoCodec" | ||
| 161 | ADDON_INSTANCE_VIDEOCODEC = 112, | 216 | ADDON_INSTANCE_VIDEOCODEC = 112, |
| 162 | } ADDON_TYPE; | 217 | } ADDON_TYPE; |
| 218 | //------------------------------------------------------------------------------ | ||
| 163 | 219 | ||
| 164 | #ifdef __cplusplus | 220 | #ifdef __cplusplus |
| 165 | extern "C" { | 221 | extern "C" { |
| @@ -205,6 +261,10 @@ inline const char* GetTypeVersion(int type) | |||
| 205 | case ADDON_GLOBAL_NETWORK: | 261 | case ADDON_GLOBAL_NETWORK: |
| 206 | return ADDON_GLOBAL_VERSION_NETWORK; | 262 | return ADDON_GLOBAL_VERSION_NETWORK; |
| 207 | #endif | 263 | #endif |
| 264 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_TOOLS_USED) | ||
| 265 | case ADDON_GLOBAL_TOOLS: | ||
| 266 | return ADDON_GLOBAL_VERSION_TOOLS; | ||
| 267 | #endif | ||
| 208 | 268 | ||
| 209 | /* addon type instances */ | 269 | /* addon type instances */ |
| 210 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIODECODER_USED) | 270 | #if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIODECODER_USED) |
| @@ -280,6 +340,8 @@ inline const char* GetTypeMinVersion(int type) | |||
| 280 | return ADDON_GLOBAL_VERSION_FILESYSTEM_MIN; | 340 | return ADDON_GLOBAL_VERSION_FILESYSTEM_MIN; |
| 281 | case ADDON_GLOBAL_NETWORK: | 341 | case ADDON_GLOBAL_NETWORK: |
| 282 | return ADDON_GLOBAL_VERSION_NETWORK_MIN; | 342 | return ADDON_GLOBAL_VERSION_NETWORK_MIN; |
| 343 | case ADDON_GLOBAL_TOOLS: | ||
| 344 | return ADDON_GLOBAL_VERSION_TOOLS_MIN; | ||
| 283 | 345 | ||
| 284 | /* addon type instances */ | 346 | /* addon type instances */ |
| 285 | case ADDON_INSTANCE_AUDIODECODER: | 347 | case ADDON_INSTANCE_AUDIODECODER: |
| @@ -332,6 +394,8 @@ inline const char* GetTypeName(int type) | |||
| 332 | return "Filesystem"; | 394 | return "Filesystem"; |
| 333 | case ADDON_GLOBAL_NETWORK: | 395 | case ADDON_GLOBAL_NETWORK: |
| 334 | return "Network"; | 396 | return "Network"; |
| 397 | case ADDON_GLOBAL_TOOLS: | ||
| 398 | return "Tools"; | ||
| 335 | 399 | ||
| 336 | /* addon type instances */ | 400 | /* addon type instances */ |
| 337 | case ADDON_INSTANCE_AUDIODECODER: | 401 | case ADDON_INSTANCE_AUDIODECODER: |
| @@ -383,6 +447,8 @@ inline int GetTypeId(const char* name) | |||
| 383 | return ADDON_GLOBAL_FILESYSTEM; | 447 | return ADDON_GLOBAL_FILESYSTEM; |
| 384 | else if (strcmp(name, "network") == 0) | 448 | else if (strcmp(name, "network") == 0) |
| 385 | return ADDON_GLOBAL_NETWORK; | 449 | return ADDON_GLOBAL_NETWORK; |
| 450 | else if (strcmp(name, "tools") == 0) | ||
| 451 | return ADDON_GLOBAL_TOOLS; | ||
| 386 | else if (strcmp(name, "audiodecoder") == 0) | 452 | else if (strcmp(name, "audiodecoder") == 0) |
| 387 | return ADDON_INSTANCE_AUDIODECODER; | 453 | return ADDON_INSTANCE_AUDIODECODER; |
| 388 | else if (strcmp(name, "audioencoder") == 0) | 454 | else if (strcmp(name, "audioencoder") == 0) |
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h deleted file mode 100644 index ce2bc98..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 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 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" { | ||
| 15 | #endif | ||
| 16 | |||
| 17 | ADDON_STATUS __declspec(dllexport) ADDON_Create(void *callbacks, void* props); | ||
| 18 | ADDON_STATUS __declspec(dllexport) ADDON_CreateEx(void *callbacks, const char* globalApiVersion, void* props); | ||
| 19 | void __declspec(dllexport) ADDON_Destroy(); | ||
| 20 | ADDON_STATUS __declspec(dllexport) ADDON_GetStatus(); | ||
| 21 | ADDON_STATUS __declspec(dllexport) ADDON_SetSetting(const char *settingName, const void *settingValue); | ||
| 22 | __declspec(dllexport) const char* ADDON_GetTypeVersion(int type) | ||
| 23 | { | ||
| 24 | return kodi::addon::GetTypeVersion(type); | ||
| 25 | } | ||
| 26 | __declspec(dllexport) const char* ADDON_GetTypeMinVersion(int type) | ||
| 27 | { | ||
| 28 | return kodi::addon::GetTypeMinVersion(type); | ||
| 29 | } | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | }; | ||
| 33 | #endif | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h deleted file mode 100644 index bfd85c2..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 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" // compatibility fallback | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h deleted file mode 100644 index 30503d5..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h +++ /dev/null | |||
| @@ -1,113 +0,0 @@ | |||
| 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 <string.h> | ||
| 12 | #include <time.h> | ||
| 13 | |||
| 14 | #undef ATTRIBUTE_PACKED | ||
| 15 | #undef PRAGMA_PACK_BEGIN | ||
| 16 | #undef PRAGMA_PACK_END | ||
| 17 | |||
| 18 | #if defined(__GNUC__) | ||
| 19 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 20 | #define PRAGMA_PACK 0 | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #if !defined(ATTRIBUTE_PACKED) | ||
| 24 | #define ATTRIBUTE_PACKED | ||
| 25 | #define PRAGMA_PACK 1 | ||
| 26 | #endif | ||
| 27 | |||
| 28 | /*! @name EPG entry content event types */ | ||
| 29 | //@{ | ||
| 30 | /* These IDs come from the DVB-SI EIT table "content descriptor" | ||
| 31 | * Also known under the name "E-book genre assignments" | ||
| 32 | */ | ||
| 33 | #define EPG_EVENT_CONTENTMASK_UNDEFINED 0x00 | ||
| 34 | #define EPG_EVENT_CONTENTMASK_MOVIEDRAMA 0x10 | ||
| 35 | #define EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS 0x20 | ||
| 36 | #define EPG_EVENT_CONTENTMASK_SHOW 0x30 | ||
| 37 | #define EPG_EVENT_CONTENTMASK_SPORTS 0x40 | ||
| 38 | #define EPG_EVENT_CONTENTMASK_CHILDRENYOUTH 0x50 | ||
| 39 | #define EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE 0x60 | ||
| 40 | #define EPG_EVENT_CONTENTMASK_ARTSCULTURE 0x70 | ||
| 41 | #define EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS 0x80 | ||
| 42 | #define EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE 0x90 | ||
| 43 | #define EPG_EVENT_CONTENTMASK_LEISUREHOBBIES 0xA0 | ||
| 44 | #define EPG_EVENT_CONTENTMASK_SPECIAL 0xB0 | ||
| 45 | #define EPG_EVENT_CONTENTMASK_USERDEFINED 0xF0 | ||
| 46 | //@} | ||
| 47 | |||
| 48 | /* Set EPGTAG.iGenreType to EPG_GENRE_USE_STRING to transfer genre strings to Kodi */ | ||
| 49 | #define EPG_GENRE_USE_STRING 0x100 | ||
| 50 | |||
| 51 | /* Separator to use in strings containing different tokens, for example writers, directors, actors of an event. */ | ||
| 52 | #define EPG_STRING_TOKEN_SEPARATOR "," | ||
| 53 | |||
| 54 | #ifdef __cplusplus | ||
| 55 | extern "C" { | ||
| 56 | #endif | ||
| 57 | |||
| 58 | /* EPG_TAG.iFlags values */ | ||
| 59 | const unsigned int EPG_TAG_FLAG_UNDEFINED = 0x00000000; /*!< @brief nothing special to say about this entry */ | ||
| 60 | const unsigned int EPG_TAG_FLAG_IS_SERIES = 0x00000001; /*!< @brief this EPG entry is part of a series */ | ||
| 61 | |||
| 62 | /* Special EPG_TAG.iUniqueBroadcastId value */ | ||
| 63 | |||
| 64 | /*! | ||
| 65 | * @brief special EPG_TAG.iUniqueBroadcastId value to indicate that a tag has not a valid EPG event uid. | ||
| 66 | */ | ||
| 67 | const unsigned int EPG_TAG_INVALID_UID = 0; | ||
| 68 | |||
| 69 | /*! | ||
| 70 | * @brief EPG event states. Used with EpgEventStateChange callback. | ||
| 71 | */ | ||
| 72 | typedef enum | ||
| 73 | { | ||
| 74 | EPG_EVENT_CREATED = 0, /*!< @brief event created */ | ||
| 75 | EPG_EVENT_UPDATED = 1, /*!< @brief event updated */ | ||
| 76 | EPG_EVENT_DELETED = 2, /*!< @brief event deleted */ | ||
| 77 | } EPG_EVENT_STATE; | ||
| 78 | |||
| 79 | /*! | ||
| 80 | * @brief Representation of an EPG event. | ||
| 81 | */ | ||
| 82 | typedef struct EPG_TAG { | ||
| 83 | unsigned int iUniqueBroadcastId; /*!< @brief (required) identifier for this event. Event uids must be unique for a channel. Valid uids must be greater than EPG_TAG_INVALID_UID. */ | ||
| 84 | unsigned int iUniqueChannelId; /*!< @brief (required) unique identifier of the channel this event belongs to. */ | ||
| 85 | const char * strTitle; /*!< @brief (required) this event's title */ | ||
| 86 | time_t startTime; /*!< @brief (required) start time in UTC */ | ||
| 87 | time_t endTime; /*!< @brief (required) end time in UTC */ | ||
| 88 | const char * strPlotOutline; /*!< @brief (optional) plot outline */ | ||
| 89 | const char * strPlot; /*!< @brief (optional) plot */ | ||
| 90 | const char * strOriginalTitle; /*!< @brief (optional) originaltitle */ | ||
| 91 | const char * strCast; /*!< @brief (optional) cast. Use EPG_STRING_TOKEN_SEPARATOR to separate different persons. */ | ||
| 92 | const char * strDirector; /*!< @brief (optional) director(s). Use EPG_STRING_TOKEN_SEPARATOR to separate different persons. */ | ||
| 93 | const char * strWriter; /*!< @brief (optional) writer(s). Use EPG_STRING_TOKEN_SEPARATOR to separate different persons. */ | ||
| 94 | int iYear; /*!< @brief (optional) year */ | ||
| 95 | const char * strIMDBNumber; /*!< @brief (optional) IMDBNumber */ | ||
| 96 | const char * strIconPath; /*!< @brief (optional) icon path */ | ||
| 97 | int iGenreType; /*!< @brief (optional) genre type */ | ||
| 98 | int iGenreSubType; /*!< @brief (optional) genre sub type */ | ||
| 99 | const char * strGenreDescription; /*!< @brief (optional) genre. Will be used only when iGenreType == EPG_GENRE_USE_STRING. Use EPG_STRING_TOKEN_SEPARATOR to separate different genres. */ | ||
| 100 | time_t firstAired; /*!< @brief (optional) first aired in UTC */ | ||
| 101 | int iParentalRating; /*!< @brief (optional) parental rating */ | ||
| 102 | int iStarRating; /*!< @brief (optional) star rating */ | ||
| 103 | int iSeriesNumber; /*!< @brief (optional) series number */ | ||
| 104 | int iEpisodeNumber; /*!< @brief (optional) episode number */ | ||
| 105 | int iEpisodePartNumber; /*!< @brief (optional) episode part number */ | ||
| 106 | const char * strEpisodeName; /*!< @brief (optional) episode name */ | ||
| 107 | unsigned int iFlags; /*!< @brief (optional) bit field of independent flags associated with the EPG entry */ | ||
| 108 | const char * strSeriesLink; /*!< @brief (optional) series link for this event */ | ||
| 109 | } ATTRIBUTE_PACKED EPG_TAG; | ||
| 110 | |||
| 111 | #ifdef __cplusplus | ||
| 112 | } | ||
| 113 | #endif | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h deleted file mode 100644 index 26e9099..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h +++ /dev/null | |||
| @@ -1,784 +0,0 @@ | |||
| 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 "xbmc_addon_dll.h" | ||
| 12 | #include "xbmc_pvr_types.h" | ||
| 13 | |||
| 14 | /*! | ||
| 15 | * Functions that the PVR client add-on must implement, but some can be empty. | ||
| 16 | * | ||
| 17 | * The 'remarks' field indicates which methods should be implemented, and which ones are optional. | ||
| 18 | */ | ||
| 19 | |||
| 20 | extern "C" | ||
| 21 | { | ||
| 22 | /*! @name PVR add-on methods */ | ||
| 23 | //@{ | ||
| 24 | /*! | ||
| 25 | * Get the list of features that this add-on provides. | ||
| 26 | * Called by Kodi to query the add-on's capabilities. | ||
| 27 | * Used to check which options should be presented in the UI, which methods to call, etc. | ||
| 28 | * All capabilities that the add-on supports should be set to true. | ||
| 29 | * @param pCapabilities The add-on's capabilities. | ||
| 30 | * @return PVR_ERROR_NO_ERROR if the properties were fetched successfully. | ||
| 31 | * @remarks Valid implementation required. | ||
| 32 | */ | ||
| 33 | PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities); | ||
| 34 | |||
| 35 | /*! | ||
| 36 | * @return The name reported by the backend that will be displayed in the UI. | ||
| 37 | * @remarks Valid implementation required. | ||
| 38 | */ | ||
| 39 | const char* GetBackendName(void); | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * @return The version string reported by the backend that will be displayed in the UI. | ||
| 43 | * @remarks Valid implementation required. | ||
| 44 | */ | ||
| 45 | const char* GetBackendVersion(void); | ||
| 46 | |||
| 47 | /*! | ||
| 48 | * @return The connection string reported by the backend that will be displayed in the UI. | ||
| 49 | * @remarks Valid implementation required. | ||
| 50 | */ | ||
| 51 | const char* GetConnectionString(void); | ||
| 52 | |||
| 53 | /*! | ||
| 54 | * Get the disk space reported by the backend (if supported). | ||
| 55 | * @param iTotal The total disk space in bytes. | ||
| 56 | * @param iUsed The used disk space in bytes. | ||
| 57 | * @return PVR_ERROR_NO_ERROR if the drive space has been fetched successfully. | ||
| 58 | * @remarks Optional. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 59 | */ | ||
| 60 | PVR_ERROR GetDriveSpace(long long* iTotal, long long* iUsed); | ||
| 61 | |||
| 62 | /*! | ||
| 63 | * Call one of the menu hooks (if supported). | ||
| 64 | * Supported PVR_MENUHOOK instances have to be added in ADDON_Create(), by calling AddMenuHook() on the callback. | ||
| 65 | * @param menuhook The hook to call. | ||
| 66 | * @param item The selected item for which the hook was called. | ||
| 67 | * @return PVR_ERROR_NO_ERROR if the hook was called successfully. | ||
| 68 | * @remarks Optional. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 69 | */ | ||
| 70 | PVR_ERROR CallMenuHook(const PVR_MENUHOOK& menuhook, const PVR_MENUHOOK_DATA &item); | ||
| 71 | //@} | ||
| 72 | |||
| 73 | /*! @name PVR EPG methods | ||
| 74 | * @remarks Only used by Kodi if bSupportsEPG is set to true. | ||
| 75 | */ | ||
| 76 | //@{ | ||
| 77 | /*! | ||
| 78 | * Request the EPG for a channel from the backend. | ||
| 79 | * EPG entries are added to Kodi by calling TransferEpgEntry() on the callback. | ||
| 80 | * @param handle Handle to pass to the callback method. | ||
| 81 | * @param iChannelUid The UID of the channel to get the EPG table for. | ||
| 82 | * @param iStart Get events after this time (UTC). | ||
| 83 | * @param iEnd Get events before this time (UTC). | ||
| 84 | * @return PVR_ERROR_NO_ERROR if the table has been fetched successfully. | ||
| 85 | * @remarks Required if bSupportsEPG is set to true. | ||
| 86 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 87 | */ | ||
| 88 | PVR_ERROR GetEPGForChannel(ADDON_HANDLE handle, int iChannelUid, time_t iStart, time_t iEnd); | ||
| 89 | |||
| 90 | /* | ||
| 91 | * Check if the given EPG tag can be recorded. | ||
| 92 | * @param tag the epg tag to check. | ||
| 93 | * @param [out] bIsRecordable Set to true if the tag can be recorded. | ||
| 94 | * @return PVR_ERROR_NO_ERROR if bIsRecordable has been set successfully. | ||
| 95 | * @remarks Optional, return PVR_ERROR_NOT_IMPLEMENTED to let Kodi decide. | ||
| 96 | */ | ||
| 97 | PVR_ERROR IsEPGTagRecordable(const EPG_TAG* tag, bool* bIsRecordable); | ||
| 98 | |||
| 99 | /* | ||
| 100 | * Check if the given EPG tag can be played. | ||
| 101 | * @param tag the epg tag to check. | ||
| 102 | * @param [out] bIsPlayable Set to true if the tag can be played. | ||
| 103 | * @return PVR_ERROR_NO_ERROR if bIsPlayable has been set successfully. | ||
| 104 | * @remarks Required if add-on supports playing epg tags. | ||
| 105 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 106 | */ | ||
| 107 | PVR_ERROR IsEPGTagPlayable(const EPG_TAG* tag, bool* bIsPlayable); | ||
| 108 | |||
| 109 | /*! | ||
| 110 | * Retrieve the edit decision list (EDL) of an EPG tag on the backend. | ||
| 111 | * @param epgTag The EPG tag. | ||
| 112 | * @param edl out: The function has to write the EDL into this array. | ||
| 113 | * @param size in: The maximum size of the EDL, out: the actual size of the EDL. | ||
| 114 | * @return PVR_ERROR_NO_ERROR if the EDL was successfully read or no EDL exists. | ||
| 115 | * @remarks Required if bSupportsEpgEdl is set to true. | ||
| 116 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 117 | */ | ||
| 118 | PVR_ERROR GetEPGTagEdl(const EPG_TAG* epgTag, PVR_EDL_ENTRY edl[], int *size); | ||
| 119 | |||
| 120 | /*! | ||
| 121 | * Get the stream properties for an epg tag from the backend. | ||
| 122 | * @param[in] tag The epg tag to get the stream properties for. | ||
| 123 | * @param[inout] properties in: an array for the properties to return, out: the properties required to play the stream. | ||
| 124 | * @param[inout] iPropertiesCount in: the size of the properties array, out: the number of properties returned. | ||
| 125 | * @return PVR_ERROR_NO_ERROR if the stream is available. | ||
| 126 | * @remarks Required if add-on supports playing epg tags. | ||
| 127 | * In this case your implementation must fill the property PVR_STREAM_PROPERTY_STREAMURL with the URL Kodi should resolve to playback the epg tag. | ||
| 128 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 129 | */ | ||
| 130 | PVR_ERROR GetEPGTagStreamProperties(const EPG_TAG* tag, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount); | ||
| 131 | |||
| 132 | //@} | ||
| 133 | |||
| 134 | /*! @name PVR channel group methods | ||
| 135 | * @remarks Only used by Kodi if bSupportsChannelGroups is set to true. | ||
| 136 | * If a group or one of the group members changes after the initial import, or if a new one was added, then the add-on | ||
| 137 | * should call TriggerChannelGroupsUpdate() | ||
| 138 | */ | ||
| 139 | //@{ | ||
| 140 | /*! | ||
| 141 | * Get the total amount of channel groups on the backend if it supports channel groups. | ||
| 142 | * @return The amount of channels, or -1 on error. | ||
| 143 | * @remarks Required if bSupportsChannelGroups is set to true. | ||
| 144 | * Return -1 if this add-on won't provide this function. | ||
| 145 | */ | ||
| 146 | int GetChannelGroupsAmount(void); | ||
| 147 | |||
| 148 | /*! | ||
| 149 | * Request the list of all channel groups from the backend if it supports channel groups. | ||
| 150 | * Channel group entries are added to Kodi by calling TransferChannelGroup() on the callback. | ||
| 151 | * @param handle Handle to pass to the callback method. | ||
| 152 | * @param bRadio True to get the radio channel groups, false to get the TV channel groups. | ||
| 153 | * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 154 | * @remarks Required if bSupportsChannelGroups is set to true. | ||
| 155 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 156 | */ | ||
| 157 | PVR_ERROR GetChannelGroups(ADDON_HANDLE handle, bool bRadio); | ||
| 158 | |||
| 159 | /*! | ||
| 160 | * Request the list of all group members of a group from the backend if it supports channel groups. | ||
| 161 | * Member entries are added to Kodi by calling TransferChannelGroupMember() on the callback. | ||
| 162 | * @param handle Handle to pass to the callback method. | ||
| 163 | * @param group The group to get the members for. | ||
| 164 | * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 165 | * @remarks Required if bSupportsChannelGroups is set to true. | ||
| 166 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 167 | */ | ||
| 168 | PVR_ERROR GetChannelGroupMembers(ADDON_HANDLE handle, const PVR_CHANNEL_GROUP& group); | ||
| 169 | //@} | ||
| 170 | |||
| 171 | /** @name PVR channel methods | ||
| 172 | * @remarks Either bSupportsTV or bSupportsRadio is required to be set to true. | ||
| 173 | * If a channel changes after the initial import, or if a new one was added, then the add-on | ||
| 174 | * should call TriggerChannelUpdate() | ||
| 175 | */ | ||
| 176 | //@{ | ||
| 177 | /*! | ||
| 178 | * Show the channel scan dialog if this backend supports it. | ||
| 179 | * @return PVR_ERROR_NO_ERROR if the dialog was displayed successfully. | ||
| 180 | * @remarks Required if bSupportsChannelScan is set to true. | ||
| 181 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 182 | * @note see libKODI_guilib.h about related parts | ||
| 183 | */ | ||
| 184 | PVR_ERROR OpenDialogChannelScan(void); | ||
| 185 | |||
| 186 | /*! | ||
| 187 | * @return The total amount of channels on the backend, or -1 on error. | ||
| 188 | * @remarks Valid implementation required. | ||
| 189 | */ | ||
| 190 | int GetChannelsAmount(void); | ||
| 191 | |||
| 192 | /*! | ||
| 193 | * Request the list of all channels from the backend. | ||
| 194 | * Channel entries are added to Kodi by calling TransferChannelEntry() on the callback. | ||
| 195 | * @param handle Handle to pass to the callback method. | ||
| 196 | * @param bRadio True to get the radio channels, false to get the TV channels. | ||
| 197 | * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 198 | * @remarks If bSupportsTV is set to true, a valid result set needs to be provided for bRadio = false. | ||
| 199 | * If bSupportsRadio is set to true, a valid result set needs to be provided for bRadio = true. | ||
| 200 | * At least one of these two must provide a valid result set. | ||
| 201 | */ | ||
| 202 | PVR_ERROR GetChannels(ADDON_HANDLE handle, bool bRadio); | ||
| 203 | |||
| 204 | /*! | ||
| 205 | * Delete a channel from the backend. | ||
| 206 | * @param channel The channel to delete. | ||
| 207 | * @return PVR_ERROR_NO_ERROR if the channel has been deleted successfully. | ||
| 208 | * @remarks Required if bSupportsChannelSettings is set to true. | ||
| 209 | */ | ||
| 210 | PVR_ERROR DeleteChannel(const PVR_CHANNEL& channel); | ||
| 211 | |||
| 212 | /*! | ||
| 213 | * Rename a channel on the backend. | ||
| 214 | * @param channel The channel to rename, containing the new channel name. | ||
| 215 | * @return PVR_ERROR_NO_ERROR if the channel has been renamed successfully. | ||
| 216 | * @remarks Optional, and only used if bSupportsChannelSettings is set to true. | ||
| 217 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 218 | */ | ||
| 219 | PVR_ERROR RenameChannel(const PVR_CHANNEL& channel); | ||
| 220 | |||
| 221 | /*! | ||
| 222 | * Show the channel settings dialog, if supported by the backend. | ||
| 223 | * @param channel The channel to show the dialog for. | ||
| 224 | * @return PVR_ERROR_NO_ERROR if the dialog has been displayed successfully. | ||
| 225 | * @remarks Required if bSupportsChannelSettings is set to true. | ||
| 226 | * @note see libKODI_guilib.h about related parts | ||
| 227 | */ | ||
| 228 | PVR_ERROR OpenDialogChannelSettings(const PVR_CHANNEL& channel); | ||
| 229 | |||
| 230 | /*! | ||
| 231 | * Show the dialog to add a channel on the backend, if supported by the backend. | ||
| 232 | * @param channel The channel to add. | ||
| 233 | * @return PVR_ERROR_NO_ERROR if the channel has been added successfully. | ||
| 234 | * @remarks Required if bSupportsChannelSettings is set to true. | ||
| 235 | * @note see libKODI_guilib.h about related parts | ||
| 236 | */ | ||
| 237 | PVR_ERROR OpenDialogChannelAdd(const PVR_CHANNEL& channel); | ||
| 238 | //@} | ||
| 239 | |||
| 240 | /** @name PVR recording methods | ||
| 241 | * @remarks Only used by Kodi if bSupportsRecordings is set to true. | ||
| 242 | * If a recording changes after the initial import, or if a new one was added, | ||
| 243 | * then the add-on should call TriggerRecordingUpdate() | ||
| 244 | */ | ||
| 245 | //@{ | ||
| 246 | /*! | ||
| 247 | * @return The total amount of recordings on the backend or -1 on error. | ||
| 248 | * @param deleted if set return deleted recording (called if bSupportsRecordingsUndelete set to true) | ||
| 249 | * @remarks Required if bSupportsRecordings is set to true. Return -1 if this add-on won't provide this function. | ||
| 250 | */ | ||
| 251 | int GetRecordingsAmount(bool deleted); | ||
| 252 | |||
| 253 | /*! | ||
| 254 | * Request the list of all recordings from the backend, if supported. | ||
| 255 | * Recording entries are added to Kodi by calling TransferRecordingEntry() on the callback. | ||
| 256 | * @param handle Handle to pass to the callback method. | ||
| 257 | * @param deleted if set return deleted recording (called if bSupportsRecordingsUndelete set to true) | ||
| 258 | * @return PVR_ERROR_NO_ERROR if the recordings have been fetched successfully. | ||
| 259 | * @remarks Required if bSupportsRecordings is set to true. | ||
| 260 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 261 | */ | ||
| 262 | PVR_ERROR GetRecordings(ADDON_HANDLE handle, bool deleted); | ||
| 263 | |||
| 264 | /*! | ||
| 265 | * Delete a recording on the backend. | ||
| 266 | * @param recording The recording to delete. | ||
| 267 | * @return PVR_ERROR_NO_ERROR if the recording has been deleted successfully. | ||
| 268 | * @remarks Optional, and only used if bSupportsRecordings is set to true. | ||
| 269 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 270 | */ | ||
| 271 | PVR_ERROR DeleteRecording(const PVR_RECORDING& recording); | ||
| 272 | |||
| 273 | /*! | ||
| 274 | * Undelete a recording on the backend. | ||
| 275 | * @param recording The recording to undelete. | ||
| 276 | * @return PVR_ERROR_NO_ERROR if the recording has been undeleted successfully. | ||
| 277 | * @remarks Optional, and only used if bSupportsRecordingsUndelete is set to true. | ||
| 278 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 279 | */ | ||
| 280 | PVR_ERROR UndeleteRecording(const PVR_RECORDING& recording); | ||
| 281 | |||
| 282 | /*! | ||
| 283 | * @brief Delete all recordings permanent which in the deleted folder on the backend. | ||
| 284 | * @return PVR_ERROR_NO_ERROR if the recordings has been deleted successfully. | ||
| 285 | */ | ||
| 286 | PVR_ERROR DeleteAllRecordingsFromTrash(); | ||
| 287 | |||
| 288 | /*! | ||
| 289 | * Rename a recording on the backend. | ||
| 290 | * @param recording The recording to rename, containing the new name. | ||
| 291 | * @return PVR_ERROR_NO_ERROR if the recording has been renamed successfully. | ||
| 292 | * @remarks Optional, and only used if bSupportsRecordings is set to true. | ||
| 293 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 294 | */ | ||
| 295 | PVR_ERROR RenameRecording(const PVR_RECORDING& recording); | ||
| 296 | |||
| 297 | /*! | ||
| 298 | * Set the lifetime of a recording on the backend. | ||
| 299 | * @param recording The recording to change the lifetime for. recording.iLifetime contains the new lieftime value. | ||
| 300 | * @return PVR_ERROR_NO_ERROR if the recording's lifetime has been set successfully. | ||
| 301 | * @remarks Required if bSupportsRecordingsLifetimeChange is set to true. | ||
| 302 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 303 | */ | ||
| 304 | PVR_ERROR SetRecordingLifetime(const PVR_RECORDING* recording); | ||
| 305 | |||
| 306 | /*! | ||
| 307 | * Set the play count of a recording on the backend. | ||
| 308 | * @param recording The recording to change the play count. | ||
| 309 | * @param count Play count. | ||
| 310 | * @return PVR_ERROR_NO_ERROR if the recording's play count has been set successfully. | ||
| 311 | * @remarks Required if bSupportsRecordingPlayCount is set to true. | ||
| 312 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 313 | */ | ||
| 314 | PVR_ERROR SetRecordingPlayCount(const PVR_RECORDING& recording, int count); | ||
| 315 | |||
| 316 | /*! | ||
| 317 | * Set the last watched position of a recording on the backend. | ||
| 318 | * @param recording The recording. | ||
| 319 | * @param lastplayedposition The last watched position in seconds | ||
| 320 | * @return PVR_ERROR_NO_ERROR if the position has been stored successfully. | ||
| 321 | * @remarks Required if bSupportsLastPlayedPosition is set to true. | ||
| 322 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 323 | */ | ||
| 324 | PVR_ERROR SetRecordingLastPlayedPosition(const PVR_RECORDING& recording, int lastplayedposition); | ||
| 325 | |||
| 326 | /*! | ||
| 327 | * Retrieve the last watched position of a recording on the backend. | ||
| 328 | * @param recording The recording. | ||
| 329 | * @return The last watched position in seconds or -1 on error | ||
| 330 | * @remarks Required if bSupportsRecordingPlayCount is set to true. | ||
| 331 | * Return -1 if this add-on won't provide this function. | ||
| 332 | */ | ||
| 333 | int GetRecordingLastPlayedPosition(const PVR_RECORDING& recording); | ||
| 334 | |||
| 335 | /*! | ||
| 336 | * Retrieve the edit decision list (EDL) of a recording on the backend. | ||
| 337 | * @param recording The recording. | ||
| 338 | * @param edl out: The function has to write the EDL into this array. | ||
| 339 | * @param size in: The maximum size of the EDL, out: the actual size of the EDL. | ||
| 340 | * @return PVR_ERROR_NO_ERROR if the EDL was successfully read or no EDL exists. | ||
| 341 | * @remarks Required if bSupportsRecordingEdl is set to true. | ||
| 342 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 343 | */ | ||
| 344 | PVR_ERROR GetRecordingEdl(const PVR_RECORDING& recording, PVR_EDL_ENTRY edl[], int *size); | ||
| 345 | |||
| 346 | /*! | ||
| 347 | * Retrieve the timer types supported by the backend. | ||
| 348 | * @param types out: The function has to write the definition of the supported timer types into this array. | ||
| 349 | * @param typesCount in: The maximum size of the list, out: the actual size of the list. default: PVR_ADDON_TIMERTYPE_ARRAY_SIZE | ||
| 350 | * @return PVR_ERROR_NO_ERROR if the types were successfully written to the array. | ||
| 351 | * @remarks Required if bSupportsTimers is set to true. | ||
| 352 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 353 | */ | ||
| 354 | PVR_ERROR GetTimerTypes(PVR_TIMER_TYPE types[], int *typesCount); | ||
| 355 | |||
| 356 | //@} | ||
| 357 | /** @name PVR timer methods | ||
| 358 | * @remarks Only used by Kodi if bSupportsTimers is set to true. | ||
| 359 | * If a timer changes after the initial import, or if a new one was added, | ||
| 360 | * then the add-on should call TriggerTimerUpdate() | ||
| 361 | */ | ||
| 362 | //@{ | ||
| 363 | /*! | ||
| 364 | * @return The total amount of timers on the backend or -1 on error. | ||
| 365 | * @remarks Required if bSupportsTimers is set to true. Return -1 if this add-on won't provide this function. | ||
| 366 | */ | ||
| 367 | int GetTimersAmount(void); | ||
| 368 | |||
| 369 | /*! | ||
| 370 | * Request the list of all timers from the backend if supported. | ||
| 371 | * Timer entries are added to Kodi by calling TransferTimerEntry() on the callback. | ||
| 372 | * @param handle Handle to pass to the callback method. | ||
| 373 | * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. | ||
| 374 | * @remarks Required if bSupportsTimers is set to true. | ||
| 375 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 376 | */ | ||
| 377 | PVR_ERROR GetTimers(ADDON_HANDLE handle); | ||
| 378 | |||
| 379 | /*! | ||
| 380 | * Add a timer on the backend. | ||
| 381 | * @param timer The timer to add. | ||
| 382 | * @return PVR_ERROR_NO_ERROR if the timer has been added successfully. | ||
| 383 | * @remarks Required if bSupportsTimers is set to true. | ||
| 384 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 385 | */ | ||
| 386 | PVR_ERROR AddTimer(const PVR_TIMER& timer); | ||
| 387 | |||
| 388 | /*! | ||
| 389 | * Delete a timer on the backend. | ||
| 390 | * @param timer The timer to delete. | ||
| 391 | * @param bForceDelete Set to true to delete a timer that is currently recording a program. | ||
| 392 | * @return PVR_ERROR_NO_ERROR if the timer has been deleted successfully. | ||
| 393 | * @remarks Required if bSupportsTimers is set to true. | ||
| 394 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 395 | */ | ||
| 396 | PVR_ERROR DeleteTimer(const PVR_TIMER& timer, bool bForceDelete); | ||
| 397 | |||
| 398 | /*! | ||
| 399 | * Update the timer information on the backend. | ||
| 400 | * @param timer The timer to update. | ||
| 401 | * @return PVR_ERROR_NO_ERROR if the timer has been updated successfully. | ||
| 402 | * @remarks Required if bSupportsTimers is set to true. | ||
| 403 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 404 | */ | ||
| 405 | PVR_ERROR UpdateTimer(const PVR_TIMER& timer); | ||
| 406 | |||
| 407 | //@} | ||
| 408 | |||
| 409 | /** @name PVR live stream methods, used to open and close a stream to a channel, and optionally perform read operations on the stream */ | ||
| 410 | //@{ | ||
| 411 | /*! | ||
| 412 | * Open a live stream on the backend. | ||
| 413 | * @param channel The channel to stream. | ||
| 414 | * @return True if the stream has been opened successfully, false otherwise. | ||
| 415 | * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. | ||
| 416 | * CloseLiveStream() will always be called by Kodi prior to calling this function. | ||
| 417 | * Return false if this add-on won't provide this function. | ||
| 418 | */ | ||
| 419 | bool OpenLiveStream(const PVR_CHANNEL& channel); | ||
| 420 | |||
| 421 | /*! | ||
| 422 | * Close an open live stream. | ||
| 423 | * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. | ||
| 424 | */ | ||
| 425 | void CloseLiveStream(void); | ||
| 426 | |||
| 427 | /*! | ||
| 428 | * Read from an open live stream. | ||
| 429 | * @param pBuffer The buffer to store the data in. | ||
| 430 | * @param iBufferSize The amount of bytes to read. | ||
| 431 | * @return The amount of bytes that were actually read from the stream. | ||
| 432 | * @remarks Required if bHandlesInputStream is set to true. | ||
| 433 | * Return -1 if this add-on won't provide this function. | ||
| 434 | */ | ||
| 435 | int ReadLiveStream(unsigned char* pBuffer, unsigned int iBufferSize); | ||
| 436 | |||
| 437 | /*! | ||
| 438 | * Seek in a live stream on a backend that supports timeshifting. | ||
| 439 | * @param iPosition The position to seek to. | ||
| 440 | * @param iWhence ? | ||
| 441 | * @return The new position. | ||
| 442 | * @remarks Optional, and only used if bHandlesInputStream is set to true. | ||
| 443 | * Return -1 if this add-on won't provide this function. | ||
| 444 | */ | ||
| 445 | long long SeekLiveStream(long long iPosition, int iWhence = SEEK_SET); | ||
| 446 | |||
| 447 | /*! | ||
| 448 | * Obtain the length of a live stream. | ||
| 449 | * @return The total length of the stream that's currently being read. | ||
| 450 | * @remarks Optional, and only used if bHandlesInputStream is set to true. | ||
| 451 | * Return -1 if this add-on won't provide this function. | ||
| 452 | */ | ||
| 453 | long long LengthLiveStream(void); | ||
| 454 | |||
| 455 | /*! | ||
| 456 | * Get the signal status of the stream that's currently open. | ||
| 457 | * @param signalStatus The signal status. | ||
| 458 | * @return PVR_ERROR_NO_ERROR if the signal status has been read successfully, false otherwise. | ||
| 459 | * @remarks Optional, and only used if PVR_ADDON_CAPABILITIES::bHandlesInputStream or PVR_ADDON_CAPABILITIES::bHandlesDemuxing is set to true. | ||
| 460 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 461 | */ | ||
| 462 | PVR_ERROR SignalStatus(PVR_SIGNAL_STATUS& signalStatus); | ||
| 463 | |||
| 464 | /*! | ||
| 465 | * Get the descramble information of the stream that's currently open. | ||
| 466 | * @param [out] descrambleInfo The descramble information. | ||
| 467 | * @return PVR_ERROR_NO_ERROR if the descramble information has been read successfully, false otherwise. | ||
| 468 | * @remarks Optional, and only used if PVR_ADDON_CAPABILITIES::bSupportsDescrambleInfo is set to true. | ||
| 469 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 470 | */ | ||
| 471 | PVR_ERROR GetDescrambleInfo(PVR_DESCRAMBLE_INFO* descrambleInfo); | ||
| 472 | |||
| 473 | /*! | ||
| 474 | * Get the stream properties for a channel from the backend. | ||
| 475 | * @param[in] channel The channel to get the stream properties for. | ||
| 476 | * @param[inout] properties in: an array for the properties to return, out: the properties required to play the stream. | ||
| 477 | * @param[inout] iPropertiesCount in: the size of the properties array, out: the number of properties returned. | ||
| 478 | * @return PVR_ERROR_NO_ERROR if the stream is available. | ||
| 479 | * @remarks Required if PVR_ADDON_CAPABILITIES::bSupportsTV or PVR_ADDON_CAPABILITIES::bSupportsRadio are set to true and PVR_ADDON_CAPABILITIES::bHandlesInputStream is set to false. | ||
| 480 | * In this case the implementation must fill the property PVR_STREAM_PROPERTY_STREAMURL with the URL Kodi should resolve to playback the channel. | ||
| 481 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 482 | */ | ||
| 483 | PVR_ERROR GetChannelStreamProperties(const PVR_CHANNEL* channel, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount); | ||
| 484 | |||
| 485 | /*! | ||
| 486 | * Get the stream properties for a recording from the backend. | ||
| 487 | * @param[in] recording The recording to get the stream properties for. | ||
| 488 | * @param[inout] properties in: an array for the properties to return, out: the properties required to play the stream. | ||
| 489 | * @param[inout] iPropertiesCount in: the size of the properties array, out: the number of properties returned. | ||
| 490 | * @return PVR_ERROR_NO_ERROR if the stream is available. | ||
| 491 | * @remarks Required if PVR_ADDON_CAPABILITIES::bSupportsRecordings is set to true and the add-on does not implement recording stream functions (OpenRecordedStream, ...). | ||
| 492 | * In this case your implementation must fill the property PVR_STREAM_PROPERTY_STREAMURL with the URL Kodi should resolve to playback the recording. | ||
| 493 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 494 | */ | ||
| 495 | PVR_ERROR GetRecordingStreamProperties(const PVR_RECORDING* recording, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount); | ||
| 496 | |||
| 497 | /*! | ||
| 498 | * Get the stream properties of the stream that's currently being read. | ||
| 499 | * @param pProperties The properties of the currently playing stream. | ||
| 500 | * @return PVR_ERROR_NO_ERROR if the properties have been fetched successfully. | ||
| 501 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 502 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 503 | */ | ||
| 504 | PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES* pProperties); | ||
| 505 | //@} | ||
| 506 | |||
| 507 | /** @name PVR recording stream methods, used to open and close a stream to a recording, and perform read operations on the stream. | ||
| 508 | * @remarks This will only be used if the backend doesn't provide a direct URL in the recording tag. | ||
| 509 | */ | ||
| 510 | //@{ | ||
| 511 | /*! | ||
| 512 | * Obtain the chunk size to use when reading streams. | ||
| 513 | * @param chunksize must be filled with the chunk size in bytes. | ||
| 514 | * @return PVR_ERROR_NO_ERROR if the chunk size has been fetched successfully. | ||
| 515 | * @remarks Optional, and only used if not reading from demuxer (=> DemuxRead) and | ||
| 516 | * PVR_ADDON_CAPABILITIES::bSupportsRecordings is true (=> ReadRecordedStream) or | ||
| 517 | * PVR_ADDON_CAPABILITIES::bHandlesInputStream is true (=> ReadLiveStream). | ||
| 518 | * Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. In this case Kodi will decide on the chunk size to use. | ||
| 519 | */ | ||
| 520 | PVR_ERROR GetStreamReadChunkSize(int* chunksize); | ||
| 521 | |||
| 522 | /*! | ||
| 523 | * Open a stream to a recording on the backend. | ||
| 524 | * @param recording The recording to open. | ||
| 525 | * @return True if the stream has been opened successfully, false otherwise. | ||
| 526 | * @remarks Optional, and only used if bSupportsRecordings is set to true. | ||
| 527 | * CloseRecordedStream() will always be called by Kodi prior to calling this function. | ||
| 528 | * Return false if this add-on won't provide this function. | ||
| 529 | */ | ||
| 530 | bool OpenRecordedStream(const PVR_RECORDING& recording); | ||
| 531 | |||
| 532 | /*! | ||
| 533 | * Close an open stream from a recording. | ||
| 534 | * @remarks Optional, and only used if bSupportsRecordings is set to true. | ||
| 535 | */ | ||
| 536 | void CloseRecordedStream(void); | ||
| 537 | |||
| 538 | /*! | ||
| 539 | * Read from a recording. | ||
| 540 | * @param pBuffer The buffer to store the data in. | ||
| 541 | * @param iBufferSize The amount of bytes to read. | ||
| 542 | * @return The amount of bytes that were actually read from the stream. | ||
| 543 | * @remarks Optional, and only used if bSupportsRecordings is set to true, but required if OpenRecordedStream() is implemented. | ||
| 544 | * Return -1 if this add-on won't provide this function. | ||
| 545 | */ | ||
| 546 | int ReadRecordedStream(unsigned char* pBuffer, unsigned int iBufferSize); | ||
| 547 | |||
| 548 | /*! | ||
| 549 | * Seek in a recorded stream. | ||
| 550 | * @param iPosition The position to seek to. | ||
| 551 | * @param iWhence ? | ||
| 552 | * @return The new position. | ||
| 553 | * @remarks Optional, and only used if bSupportsRecordings is set to true. | ||
| 554 | * Return -1 if this add-on won't provide this function. | ||
| 555 | */ | ||
| 556 | long long SeekRecordedStream(long long iPosition, int iWhence = SEEK_SET); | ||
| 557 | |||
| 558 | /*! | ||
| 559 | * Obtain the length of a recorded stream. | ||
| 560 | * @return The total length of the stream that's currently being read. | ||
| 561 | * @remarks Optional, and only used if bSupportsRecordings is set to true. | ||
| 562 | * Return -1 if this add-on won't provide this function. | ||
| 563 | */ | ||
| 564 | long long LengthRecordedStream(void); | ||
| 565 | |||
| 566 | //@} | ||
| 567 | |||
| 568 | /** @name PVR demultiplexer methods | ||
| 569 | * @remarks Only used by Kodi if bHandlesDemuxing is set to true. | ||
| 570 | */ | ||
| 571 | //@{ | ||
| 572 | /*! | ||
| 573 | * Reset the demultiplexer in the add-on. | ||
| 574 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 575 | */ | ||
| 576 | void DemuxReset(void); | ||
| 577 | |||
| 578 | /*! | ||
| 579 | * Abort the demultiplexer thread in the add-on. | ||
| 580 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 581 | */ | ||
| 582 | void DemuxAbort(void); | ||
| 583 | |||
| 584 | /*! | ||
| 585 | * Flush all data that's currently in the demultiplexer buffer in the add-on. | ||
| 586 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 587 | */ | ||
| 588 | void DemuxFlush(void); | ||
| 589 | |||
| 590 | /*! | ||
| 591 | * Read the next packet from the demultiplexer, if there is one. | ||
| 592 | * @return The next packet. | ||
| 593 | * If there is no next packet, then the add-on should return the | ||
| 594 | * packet created by calling AllocateDemuxPacket(0) on the callback. | ||
| 595 | * If the stream changed and Kodi's player needs to be reinitialised, | ||
| 596 | * then, the add-on should call AllocateDemuxPacket(0) on the | ||
| 597 | * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and | ||
| 598 | * return the value. | ||
| 599 | * The add-on should return NULL if an error occured. | ||
| 600 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 601 | * Return NULL if this add-on won't provide this function. | ||
| 602 | */ | ||
| 603 | DemuxPacket* DemuxRead(void); | ||
| 604 | //@} | ||
| 605 | |||
| 606 | /*! | ||
| 607 | * Check if the backend support pausing the currently playing stream | ||
| 608 | * This will enable/disable the pause button in Kodi based on the return value | ||
| 609 | * @return false if the PVR addon/backend does not support pausing, true if possible | ||
| 610 | */ | ||
| 611 | bool CanPauseStream(); | ||
| 612 | |||
| 613 | /*! | ||
| 614 | * Check if the backend supports seeking for the currently playing stream | ||
| 615 | * This will enable/disable the rewind/forward buttons in Kodi based on the return value | ||
| 616 | * @return false if the PVR addon/backend does not support seeking, true if possible | ||
| 617 | */ | ||
| 618 | bool CanSeekStream(); | ||
| 619 | |||
| 620 | /*! | ||
| 621 | * @brief Notify the pvr addon that Kodi (un)paused the currently playing stream | ||
| 622 | */ | ||
| 623 | void PauseStream(bool bPaused); | ||
| 624 | |||
| 625 | /*! | ||
| 626 | * Notify the pvr addon/demuxer that Kodi wishes to seek the stream by time | ||
| 627 | * @param time The absolute time since stream start | ||
| 628 | * @param backwards True to seek to keyframe BEFORE time, else AFTER | ||
| 629 | * @param startpts can be updated to point to where display should start | ||
| 630 | * @return True if the seek operation was possible | ||
| 631 | * @remarks Optional, and only used if addon has its own demuxer. | ||
| 632 | * Return False if this add-on won't provide this function. | ||
| 633 | */ | ||
| 634 | bool SeekTime(double time, bool backwards, double *startpts); | ||
| 635 | |||
| 636 | /*! | ||
| 637 | * Notify the pvr addon/demuxer that Kodi wishes to change playback speed | ||
| 638 | * @param speed The requested playback speed | ||
| 639 | * @remarks Optional, and only used if addon has its own demuxer. | ||
| 640 | */ | ||
| 641 | void SetSpeed(int speed); | ||
| 642 | |||
| 643 | /*! | ||
| 644 | * Notify the pvr addon/demuxer that Kodi wishes to fill demux queue | ||
| 645 | * @param mode The requested filling mode | ||
| 646 | * @remarks Optional, and only used if addon has its own demuxer. | ||
| 647 | */ | ||
| 648 | void FillBuffer(bool mode); | ||
| 649 | |||
| 650 | /*! | ||
| 651 | * Get the hostname of the pvr backend server | ||
| 652 | * @return hostname as ip address or alias. If backend does not utilize a server, return empty string. | ||
| 653 | */ | ||
| 654 | const char* GetBackendHostname(); | ||
| 655 | |||
| 656 | /*! | ||
| 657 | * Check for real-time streaming | ||
| 658 | * @return true if current stream is real-time | ||
| 659 | */ | ||
| 660 | bool IsRealTimeStream(); | ||
| 661 | |||
| 662 | /*! | ||
| 663 | * Tell the client the time frame to use when notifying epg events back to Kodi. The client might push epg events asynchronously | ||
| 664 | * to Kodi using the callback function EpgEventStateChange. To be able to only push events that are actually of interest for Kodi, | ||
| 665 | * client needs to know about the epg time frame Kodi uses. Kodi supplies the current epg time frame value in PVR_PROPERTIES.iEpgMaxDays | ||
| 666 | * when creating the addon and calls SetEPGTimeFrame later whenever Kodi's epg time frame value changes. | ||
| 667 | * @param iDays number of days from "now". EPG_TIMEFRAME_UNLIMITED means that Kodi is interested in all epg events, regardless of event times. | ||
| 668 | * @return PVR_ERROR_NO_ERROR if new value was successfully set. | ||
| 669 | * @remarks Required if bSupportsEPG is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. | ||
| 670 | */ | ||
| 671 | PVR_ERROR SetEPGTimeFrame(int iDays); | ||
| 672 | |||
| 673 | /*! | ||
| 674 | * Notify the pvr addon for power management events | ||
| 675 | */ | ||
| 676 | void OnSystemSleep(); | ||
| 677 | void OnSystemWake(); | ||
| 678 | void OnPowerSavingActivated(); | ||
| 679 | void OnPowerSavingDeactivated(); | ||
| 680 | |||
| 681 | /*! | ||
| 682 | * Get stream times. | ||
| 683 | * @param times A pointer to the data to be filled by the implementation. | ||
| 684 | * @return PVR_ERROR_NO_ERROR on success. | ||
| 685 | */ | ||
| 686 | PVR_ERROR GetStreamTimes(PVR_STREAM_TIMES *times); | ||
| 687 | |||
| 688 | /*! | ||
| 689 | * Called by Kodi to assign the function pointers of this add-on to pClient. | ||
| 690 | * @param ptr The struct to assign the function pointers to. | ||
| 691 | */ | ||
| 692 | void __declspec(dllexport) get_addon(void* ptr) | ||
| 693 | { | ||
| 694 | AddonInstance_PVR* pClient = static_cast<AddonInstance_PVR*>(ptr); | ||
| 695 | |||
| 696 | pClient->toAddon.addonInstance = nullptr; // used in future | ||
| 697 | |||
| 698 | pClient->toAddon.GetAddonCapabilities = GetAddonCapabilities; | ||
| 699 | pClient->toAddon.GetStreamProperties = GetStreamProperties; | ||
| 700 | pClient->toAddon.GetConnectionString = GetConnectionString; | ||
| 701 | pClient->toAddon.GetBackendName = GetBackendName; | ||
| 702 | pClient->toAddon.GetBackendVersion = GetBackendVersion; | ||
| 703 | pClient->toAddon.GetDriveSpace = GetDriveSpace; | ||
| 704 | pClient->toAddon.OpenDialogChannelScan = OpenDialogChannelScan; | ||
| 705 | pClient->toAddon.MenuHook = CallMenuHook; | ||
| 706 | |||
| 707 | pClient->toAddon.GetEPGForChannel = GetEPGForChannel; | ||
| 708 | pClient->toAddon.IsEPGTagRecordable = IsEPGTagRecordable; | ||
| 709 | pClient->toAddon.IsEPGTagPlayable = IsEPGTagPlayable; | ||
| 710 | pClient->toAddon.GetEPGTagEdl = GetEPGTagEdl; | ||
| 711 | pClient->toAddon.GetEPGTagStreamProperties = GetEPGTagStreamProperties; | ||
| 712 | |||
| 713 | pClient->toAddon.GetChannelGroupsAmount = GetChannelGroupsAmount; | ||
| 714 | pClient->toAddon.GetChannelGroups = GetChannelGroups; | ||
| 715 | pClient->toAddon.GetChannelGroupMembers = GetChannelGroupMembers; | ||
| 716 | |||
| 717 | pClient->toAddon.GetChannelsAmount = GetChannelsAmount; | ||
| 718 | pClient->toAddon.GetChannels = GetChannels; | ||
| 719 | pClient->toAddon.DeleteChannel = DeleteChannel; | ||
| 720 | pClient->toAddon.RenameChannel = RenameChannel; | ||
| 721 | pClient->toAddon.OpenDialogChannelSettings = OpenDialogChannelSettings; | ||
| 722 | pClient->toAddon.OpenDialogChannelAdd = OpenDialogChannelAdd; | ||
| 723 | |||
| 724 | pClient->toAddon.GetRecordingsAmount = GetRecordingsAmount; | ||
| 725 | pClient->toAddon.GetRecordings = GetRecordings; | ||
| 726 | pClient->toAddon.DeleteRecording = DeleteRecording; | ||
| 727 | pClient->toAddon.UndeleteRecording = UndeleteRecording; | ||
| 728 | pClient->toAddon.DeleteAllRecordingsFromTrash = DeleteAllRecordingsFromTrash; | ||
| 729 | pClient->toAddon.RenameRecording = RenameRecording; | ||
| 730 | pClient->toAddon.SetRecordingLifetime = SetRecordingLifetime; | ||
| 731 | pClient->toAddon.SetRecordingPlayCount = SetRecordingPlayCount; | ||
| 732 | pClient->toAddon.SetRecordingLastPlayedPosition = SetRecordingLastPlayedPosition; | ||
| 733 | pClient->toAddon.GetRecordingLastPlayedPosition = GetRecordingLastPlayedPosition; | ||
| 734 | pClient->toAddon.GetRecordingEdl = GetRecordingEdl; | ||
| 735 | |||
| 736 | pClient->toAddon.GetTimerTypes = GetTimerTypes; | ||
| 737 | pClient->toAddon.GetTimersAmount = GetTimersAmount; | ||
| 738 | pClient->toAddon.GetTimers = GetTimers; | ||
| 739 | pClient->toAddon.AddTimer = AddTimer; | ||
| 740 | pClient->toAddon.DeleteTimer = DeleteTimer; | ||
| 741 | pClient->toAddon.UpdateTimer = UpdateTimer; | ||
| 742 | |||
| 743 | pClient->toAddon.OpenLiveStream = OpenLiveStream; | ||
| 744 | pClient->toAddon.CloseLiveStream = CloseLiveStream; | ||
| 745 | pClient->toAddon.ReadLiveStream = ReadLiveStream; | ||
| 746 | pClient->toAddon.SeekLiveStream = SeekLiveStream; | ||
| 747 | pClient->toAddon.LengthLiveStream = LengthLiveStream; | ||
| 748 | pClient->toAddon.SignalStatus = SignalStatus; | ||
| 749 | pClient->toAddon.GetDescrambleInfo = GetDescrambleInfo; | ||
| 750 | pClient->toAddon.GetChannelStreamProperties = GetChannelStreamProperties; | ||
| 751 | pClient->toAddon.GetRecordingStreamProperties = GetRecordingStreamProperties; | ||
| 752 | pClient->toAddon.CanPauseStream = CanPauseStream; | ||
| 753 | pClient->toAddon.PauseStream = PauseStream; | ||
| 754 | pClient->toAddon.CanSeekStream = CanSeekStream; | ||
| 755 | pClient->toAddon.SeekTime = SeekTime; | ||
| 756 | pClient->toAddon.SetSpeed = SetSpeed; | ||
| 757 | pClient->toAddon.FillBuffer = FillBuffer; | ||
| 758 | |||
| 759 | pClient->toAddon.OpenRecordedStream = OpenRecordedStream; | ||
| 760 | pClient->toAddon.CloseRecordedStream = CloseRecordedStream; | ||
| 761 | pClient->toAddon.ReadRecordedStream = ReadRecordedStream; | ||
| 762 | pClient->toAddon.SeekRecordedStream = SeekRecordedStream; | ||
| 763 | pClient->toAddon.LengthRecordedStream = LengthRecordedStream; | ||
| 764 | |||
| 765 | pClient->toAddon.DemuxReset = DemuxReset; | ||
| 766 | pClient->toAddon.DemuxAbort = DemuxAbort; | ||
| 767 | pClient->toAddon.DemuxFlush = DemuxFlush; | ||
| 768 | pClient->toAddon.DemuxRead = DemuxRead; | ||
| 769 | |||
| 770 | pClient->toAddon.GetBackendHostname = GetBackendHostname; | ||
| 771 | |||
| 772 | pClient->toAddon.IsRealTimeStream = IsRealTimeStream; | ||
| 773 | |||
| 774 | pClient->toAddon.SetEPGTimeFrame = SetEPGTimeFrame; | ||
| 775 | |||
| 776 | pClient->toAddon.OnSystemSleep = OnSystemSleep; | ||
| 777 | pClient->toAddon.OnSystemWake = OnSystemWake; | ||
| 778 | pClient->toAddon.OnPowerSavingActivated = OnPowerSavingActivated; | ||
| 779 | pClient->toAddon.OnPowerSavingDeactivated = OnPowerSavingDeactivated; | ||
| 780 | pClient->toAddon.GetStreamTimes = GetStreamTimes; | ||
| 781 | |||
| 782 | pClient->toAddon.GetStreamReadChunkSize = GetStreamReadChunkSize; | ||
| 783 | }; | ||
| 784 | }; | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h deleted file mode 100644 index 999d3b3..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h +++ /dev/null | |||
| @@ -1,714 +0,0 @@ | |||
| 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 | #ifndef TARGET_WINDOWS | ||
| 12 | #ifndef __cdecl | ||
| 13 | #define __cdecl | ||
| 14 | #endif | ||
| 15 | #ifndef __declspec | ||
| 16 | #define __declspec(X) | ||
| 17 | #endif | ||
| 18 | #endif | ||
| 19 | #include <string.h> | ||
| 20 | #include <stdint.h> | ||
| 21 | #include <stdio.h> | ||
| 22 | |||
| 23 | #include "xbmc_addon_types.h" | ||
| 24 | #include "xbmc_epg_types.h" | ||
| 25 | |||
| 26 | /*! @note Define "USE_DEMUX" at compile time if demuxing in the PVR add-on is used. | ||
| 27 | * Also, "DVDDemuxPacket.h" file must be in the include path of the add-on, | ||
| 28 | * and the add-on should set bHandlesDemuxing to true. | ||
| 29 | */ | ||
| 30 | #ifdef USE_DEMUX | ||
| 31 | #include "DemuxPacket.h" | ||
| 32 | #else | ||
| 33 | struct DemuxPacket; | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #undef ATTRIBUTE_PACKED | ||
| 37 | #undef PRAGMA_PACK_BEGIN | ||
| 38 | #undef PRAGMA_PACK_END | ||
| 39 | |||
| 40 | #if defined(__GNUC__) | ||
| 41 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) | ||
| 42 | #define PRAGMA_PACK 0 | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #if !defined(ATTRIBUTE_PACKED) | ||
| 46 | #define ATTRIBUTE_PACKED | ||
| 47 | #define PRAGMA_PACK 1 | ||
| 48 | #endif | ||
| 49 | |||
| 50 | #define PVR_ADDON_NAME_STRING_LENGTH 1024 | ||
| 51 | #define PVR_ADDON_URL_STRING_LENGTH 1024 | ||
| 52 | #define PVR_ADDON_DESC_STRING_LENGTH 1024 | ||
| 53 | #define PVR_ADDON_INPUT_FORMAT_STRING_LENGTH 32 | ||
| 54 | #define PVR_ADDON_EDL_LENGTH 32 | ||
| 55 | #define PVR_ADDON_TIMERTYPE_ARRAY_SIZE 32 | ||
| 56 | #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE 512 | ||
| 57 | #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL 128 | ||
| 58 | #define PVR_ADDON_TIMERTYPE_STRING_LENGTH 128 | ||
| 59 | #define PVR_ADDON_ATTRIBUTE_DESC_LENGTH 128 | ||
| 60 | #define PVR_ADDON_ATTRIBUTE_VALUES_ARRAY_SIZE 512 | ||
| 61 | #define PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH 64 | ||
| 62 | |||
| 63 | #define XBMC_INVALID_CODEC_ID 0 | ||
| 64 | #define XBMC_INVALID_CODEC { XBMC_CODEC_TYPE_UNKNOWN, XBMC_INVALID_CODEC_ID } | ||
| 65 | |||
| 66 | /* defines for GetChannelStreamProperties, GetRecordingStreamProperties and GetEPGTagStreamProperties */ | ||
| 67 | #define PVR_STREAM_MAX_PROPERTIES 20 | ||
| 68 | #define PVR_STREAM_PROPERTY_STREAMURL "streamurl" /*!< @brief the URL of the stream that should be played. */ | ||
| 69 | #define PVR_STREAM_PROPERTY_INPUTSTREAMADDON "inputstreamaddon" /*!< @brief the name of the inputstream add-on that should be used by Kodi to play the stream denoted by PVR_STREAM_PROPERTY_STREAMURL. Leave blank to use Kodi's built-in playing capabilities. */ | ||
| 70 | #define PVR_STREAM_PROPERTY_MIMETYPE "mimetype" /*!< @brief the MIME type of the stream that should be played. */ | ||
| 71 | #define PVR_STREAM_PROPERTY_ISREALTIMESTREAM "isrealtimestream" /*!< @brief "true" to denote that the stream that should be played is a realtime stream. Any other value indicates that this is no realtime stream.*/ | ||
| 72 | |||
| 73 | /* using the default avformat's MAX_STREAMS value to be safe */ | ||
| 74 | #define PVR_STREAM_MAX_STREAMS 20 | ||
| 75 | |||
| 76 | #ifdef __cplusplus | ||
| 77 | extern "C" { | ||
| 78 | #endif | ||
| 79 | |||
| 80 | typedef unsigned int xbmc_codec_id_t; | ||
| 81 | |||
| 82 | typedef enum | ||
| 83 | { | ||
| 84 | XBMC_CODEC_TYPE_UNKNOWN = -1, | ||
| 85 | XBMC_CODEC_TYPE_VIDEO, | ||
| 86 | XBMC_CODEC_TYPE_AUDIO, | ||
| 87 | XBMC_CODEC_TYPE_DATA, | ||
| 88 | XBMC_CODEC_TYPE_SUBTITLE, | ||
| 89 | XBMC_CODEC_TYPE_RDS, | ||
| 90 | XBMC_CODEC_TYPE_NB | ||
| 91 | } xbmc_codec_type_t; | ||
| 92 | |||
| 93 | typedef struct | ||
| 94 | { | ||
| 95 | xbmc_codec_type_t codec_type; | ||
| 96 | xbmc_codec_id_t codec_id; | ||
| 97 | } xbmc_codec_t; | ||
| 98 | |||
| 99 | /*! | ||
| 100 | * @brief numeric PVR timer type definitions (PVR_TIMER.iTimerType values) | ||
| 101 | */ | ||
| 102 | const unsigned int PVR_TIMER_TYPE_NONE = 0; /*!< @brief "Null" value for a numeric timer type. */ | ||
| 103 | |||
| 104 | /*! | ||
| 105 | * @brief special PVR_TIMER.iClientIndex value to indicate that a timer has not (yet) a valid client index. | ||
| 106 | */ | ||
| 107 | const unsigned int PVR_TIMER_NO_CLIENT_INDEX = 0; /*!< @brief timer has not (yet) a valid client index. */ | ||
| 108 | |||
| 109 | /*! | ||
| 110 | * @brief special PVR_TIMER.iParentClientIndex value to indicate that a timer has no parent. | ||
| 111 | */ | ||
| 112 | const unsigned int PVR_TIMER_NO_PARENT = PVR_TIMER_NO_CLIENT_INDEX; /*!< @brief timer has no parent; it was not scheduled by a repeating timer. */ | ||
| 113 | |||
| 114 | /*! | ||
| 115 | * @brief special PVR_TIMER.iEpgUid value to indicate that a timer has no EPG event uid. | ||
| 116 | */ | ||
| 117 | const unsigned int PVR_TIMER_NO_EPG_UID = EPG_TAG_INVALID_UID; /*!< @brief timer has no EPG event uid. */ | ||
| 118 | |||
| 119 | /*! | ||
| 120 | * @brief special PVR_TIMER.iClientChannelUid value to indicate "any channel". Useful for some repeating timer types. | ||
| 121 | */ | ||
| 122 | const int PVR_TIMER_ANY_CHANNEL = -1; /*!< @brief denotes "any channel", not a specific one. */ | ||
| 123 | |||
| 124 | /*! | ||
| 125 | * @brief PVR timer type attributes (PVR_TIMER_TYPE.iAttributes values) | ||
| 126 | */ | ||
| 127 | const unsigned int PVR_TIMER_TYPE_ATTRIBUTE_NONE = 0x00000000; | ||
| 128 | |||
| 129 | const unsigned int PVR_TIMER_TYPE_IS_MANUAL = 0x00000001; /*!< @brief defines whether this is a type for manual (time-based) or epg-based timers */ | ||
| 130 | const unsigned int PVR_TIMER_TYPE_IS_REPEATING = 0x00000002; /*!< @brief defines whether this is a type for repeating or one-shot timers */ | ||
| 131 | const unsigned int PVR_TIMER_TYPE_IS_READONLY = 0x00000004; /*!< @brief timers of this type must not be edited by Kodi */ | ||
| 132 | const unsigned int PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES = 0x00000008; /*!< @brief timers of this type must not be created by Kodi. All other operations are allowed, though */ | ||
| 133 | |||
| 134 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE = 0x00000010; /*!< @brief this type supports enabling/disabling of the timer (PVR_TIMER.state SCHEDULED|DISABLED) */ | ||
| 135 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_CHANNELS = 0x00000020; /*!< @brief this type supports channels (PVR_TIMER.iClientChannelUid) */ | ||
| 136 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_TIME = 0x00000040; /*!< @brief this type supports a recording start time (PVR_TIMER.startTime) */ | ||
| 137 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH = 0x00000080; /*!< @brief this type supports matching epg episode title using PVR_TIMER.strEpgSearchString */ | ||
| 138 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH = 0x00000100; /*!< @brief this type supports matching "more" epg data (not just episode title) using PVR_TIMER.strEpgSearchString. Setting FULLTEXT_EPG_MATCH implies TITLE_EPG_MATCH */ | ||
| 139 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY = 0x00000200; /*!< @brief this type supports a first day the timer gets active (PVR_TIMER.firstday) */ | ||
| 140 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS = 0x00000400; /*!< @brief this type supports weekdays for defining the recording schedule (PVR_TIMER.iWeekdays) */ | ||
| 141 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_RECORD_ONLY_NEW_EPISODES = 0x00000800; /*!< @brief this type supports the "record only new episodes" feature (PVR_TIMER.iPreventDuplicateEpisodes) */ | ||
| 142 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN = 0x00001000; /*!< @brief this type supports pre and post record time (PVR_TIMER.iMarginStart, PVR_TIMER.iMarginEnd) */ | ||
| 143 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_PRIORITY = 0x00002000; /*!< @brief this type supports recording priority (PVR_TIMER.iPriority) */ | ||
| 144 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_LIFETIME = 0x00004000; /*!< @brief this type supports recording lifetime (PVR_TIMER.iLifetime) */ | ||
| 145 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS = 0x00008000; /*!< @brief this type supports placing recordings in user defined folders (PVR_TIMER.strDirectory) */ | ||
| 146 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP = 0x00010000; /*!< @brief this type supports a list of recording groups (PVR_TIMER.iRecordingGroup) */ | ||
| 147 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_END_TIME = 0x00020000; /*!< @brief this type supports a recording end time (PVR_TIMER.endTime) */ | ||
| 148 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME = 0x00040000; /*!< @brief enables an 'Any Time' over-ride option for startTime (using PVR_TIMER.bStartAnyTime) */ | ||
| 149 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME = 0x00080000; /*!< @brief enables a separate 'Any Time' over-ride for endTime (using PVR_TIMER.bEndAnyTime) */ | ||
| 150 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS = 0x00100000; /*!< @brief this type supports specifying a maximum recordings setting' (PVR_TIMER.iMaxRecordings) */ | ||
| 151 | const unsigned int PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE = 0x00200000; /*!< @brief this type should not appear on any create menus which don't provide an associated EPG tag */ | ||
| 152 | const unsigned int PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE = 0x00400000; /*!< @brief this type should not appear on any create menus which provide an associated EPG tag */ | ||
| 153 | const unsigned int PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE = 0x00800000; /*!< @brief this type should not appear on any create menus unless associated with an EPG tag with 'series' attributes (EPG_TAG.iFlags & EPG_TAG_FLAG_IS_SERIES || EPG_TAG.iSeriesNumber > 0 || EPG_TAG.iEpisodeNumber > 0 || EPG_TAG.iEpisodePartNumber > 0). Implies PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE */ | ||
| 154 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL = 0x01000000; /*!< @brief this type supports 'any channel', for example when defining a timer rule that should match any channel instaed of a particular channel */ | ||
| 155 | const unsigned int PVR_TIMER_TYPE_REQUIRES_EPG_SERIESLINK_ON_CREATE = 0x02000000; /*!< @brief this type should not appear on any create menus which don't provide an associated EPG tag with a series link */ | ||
| 156 | const unsigned int PVR_TIMER_TYPE_SUPPORTS_READONLY_DELETE = 0x04000000; /*!< @brief this type allows deletion of an otherwise read-only timer */ | ||
| 157 | const unsigned int PVR_TIMER_TYPE_IS_REMINDER = 0x08000000; /*!< @brief timers of this type do trigger a reminder if time is up by calling the Kodi callback 'ReminderNotification'. */ | ||
| 158 | |||
| 159 | /*! | ||
| 160 | * @brief PVR timer weekdays (PVR_TIMER.iWeekdays values) | ||
| 161 | */ | ||
| 162 | const unsigned int PVR_WEEKDAY_NONE = 0x00; | ||
| 163 | const unsigned int PVR_WEEKDAY_MONDAY = 0x01; | ||
| 164 | const unsigned int PVR_WEEKDAY_TUESDAY = 0x02; | ||
| 165 | const unsigned int PVR_WEEKDAY_WEDNESDAY = 0x04; | ||
| 166 | const unsigned int PVR_WEEKDAY_THURSDAY = 0x08; | ||
| 167 | const unsigned int PVR_WEEKDAY_FRIDAY = 0x10; | ||
| 168 | const unsigned int PVR_WEEKDAY_SATURDAY = 0x20; | ||
| 169 | const unsigned int PVR_WEEKDAY_SUNDAY = 0x40; | ||
| 170 | const unsigned int PVR_WEEKDAY_ALLDAYS = PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_TUESDAY | PVR_WEEKDAY_WEDNESDAY | | ||
| 171 | PVR_WEEKDAY_THURSDAY | PVR_WEEKDAY_FRIDAY | PVR_WEEKDAY_SATURDAY | | ||
| 172 | PVR_WEEKDAY_SUNDAY; | ||
| 173 | |||
| 174 | /*! | ||
| 175 | * @brief timeframe value for use with SetEPGTimeFrame function to indicate "no timeframe". | ||
| 176 | */ | ||
| 177 | const int EPG_TIMEFRAME_UNLIMITED = -1; | ||
| 178 | |||
| 179 | /*! | ||
| 180 | * @brief special PVR_TIMER.iClientChannelUid and PVR_RECORDING.iChannelUid value to indicate that no channel uid is available. | ||
| 181 | */ | ||
| 182 | const int PVR_CHANNEL_INVALID_UID = -1; /*!< @brief denotes that no channel uid is available. */ | ||
| 183 | |||
| 184 | /*! | ||
| 185 | * @brief special PVR_DESCRAMBLE_INFO value to indicate that a struct member's value is not available. | ||
| 186 | */ | ||
| 187 | const int PVR_DESCRAMBLE_INFO_NOT_AVAILABLE = -1; | ||
| 188 | |||
| 189 | /*! | ||
| 190 | * @brief PVR add-on error codes | ||
| 191 | */ | ||
| 192 | typedef enum | ||
| 193 | { | ||
| 194 | PVR_ERROR_NO_ERROR = 0, /*!< @brief no error occurred */ | ||
| 195 | PVR_ERROR_UNKNOWN = -1, /*!< @brief an unknown error occurred */ | ||
| 196 | PVR_ERROR_NOT_IMPLEMENTED = -2, /*!< @brief the method that Kodi called is not implemented by the add-on */ | ||
| 197 | PVR_ERROR_SERVER_ERROR = -3, /*!< @brief the backend reported an error, or the add-on isn't connected */ | ||
| 198 | PVR_ERROR_SERVER_TIMEOUT = -4, /*!< @brief the command was sent to the backend, but the response timed out */ | ||
| 199 | PVR_ERROR_REJECTED = -5, /*!< @brief the command was rejected by the backend */ | ||
| 200 | PVR_ERROR_ALREADY_PRESENT = -6, /*!< @brief the requested item can not be added, because it's already present */ | ||
| 201 | PVR_ERROR_INVALID_PARAMETERS = -7, /*!< @brief the parameters of the method that was called are invalid for this operation */ | ||
| 202 | PVR_ERROR_RECORDING_RUNNING = -8, /*!< @brief a recording is running, so the timer can't be deleted without doing a forced delete */ | ||
| 203 | PVR_ERROR_FAILED = -9, /*!< @brief the command failed */ | ||
| 204 | } PVR_ERROR; | ||
| 205 | |||
| 206 | /*! | ||
| 207 | * @brief PVR timer states | ||
| 208 | */ | ||
| 209 | typedef enum | ||
| 210 | { | ||
| 211 | PVR_TIMER_STATE_NEW = 0, /*!< @brief the timer was just created on the backend and is not yet active. This state must not be used for timers just created on the client side. */ | ||
| 212 | PVR_TIMER_STATE_SCHEDULED = 1, /*!< @brief the timer is scheduled for recording */ | ||
| 213 | PVR_TIMER_STATE_RECORDING = 2, /*!< @brief the timer is currently recordings */ | ||
| 214 | PVR_TIMER_STATE_COMPLETED = 3, /*!< @brief the recording completed successfully */ | ||
| 215 | PVR_TIMER_STATE_ABORTED = 4, /*!< @brief recording started, but was aborted */ | ||
| 216 | PVR_TIMER_STATE_CANCELLED = 5, /*!< @brief the timer was scheduled, but was canceled */ | ||
| 217 | PVR_TIMER_STATE_CONFLICT_OK = 6, /*!< @brief the scheduled timer conflicts with another one, but will be recorded */ | ||
| 218 | PVR_TIMER_STATE_CONFLICT_NOK = 7, /*!< @brief the scheduled timer conflicts with another one and won't be recorded */ | ||
| 219 | PVR_TIMER_STATE_ERROR = 8, /*!< @brief the timer is scheduled, but can't be recorded for some reason */ | ||
| 220 | PVR_TIMER_STATE_DISABLED = 9, /*!< @brief the timer was disabled by the user, can be enabled via setting the state to PVR_TIMER_STATE_SCHEDULED */ | ||
| 221 | } PVR_TIMER_STATE; | ||
| 222 | |||
| 223 | /*! | ||
| 224 | * @brief PVR menu hook categories | ||
| 225 | */ | ||
| 226 | typedef enum | ||
| 227 | { | ||
| 228 | PVR_MENUHOOK_UNKNOWN =-1, /*!< @brief unknown menu hook */ | ||
| 229 | PVR_MENUHOOK_ALL = 0, /*!< @brief all categories */ | ||
| 230 | PVR_MENUHOOK_CHANNEL = 1, /*!< @brief for channels */ | ||
| 231 | PVR_MENUHOOK_TIMER = 2, /*!< @brief for timers */ | ||
| 232 | PVR_MENUHOOK_EPG = 3, /*!< @brief for EPG */ | ||
| 233 | PVR_MENUHOOK_RECORDING = 4, /*!< @brief for recordings */ | ||
| 234 | PVR_MENUHOOK_DELETED_RECORDING = 5, /*!< @brief for deleted recordings */ | ||
| 235 | PVR_MENUHOOK_SETTING = 6, /*!< @brief for settings */ | ||
| 236 | } PVR_MENUHOOK_CAT; | ||
| 237 | |||
| 238 | /*! | ||
| 239 | * @brief PVR backend connection states. Used with ConnectionStateChange callback. | ||
| 240 | */ | ||
| 241 | typedef enum | ||
| 242 | { | ||
| 243 | PVR_CONNECTION_STATE_UNKNOWN = 0, /*!< @brief unknown state (e.g. not yet tried to connect) */ | ||
| 244 | PVR_CONNECTION_STATE_SERVER_UNREACHABLE = 1, /*!< @brief backend server is not reachable (e.g. server not existing or network down)*/ | ||
| 245 | PVR_CONNECTION_STATE_SERVER_MISMATCH = 2, /*!< @brief backend server is reachable, but there is not the expected type of server running (e.g. HTSP required, but FTP running at given server:port) */ | ||
| 246 | PVR_CONNECTION_STATE_VERSION_MISMATCH = 3, /*!< @brief backend server is reachable, but server version does not match client requirements */ | ||
| 247 | PVR_CONNECTION_STATE_ACCESS_DENIED = 4, /*!< @brief backend server is reachable, but denies client access (e.g. due to wrong credentials) */ | ||
| 248 | PVR_CONNECTION_STATE_CONNECTED = 5, /*!< @brief connection to backend server is established */ | ||
| 249 | PVR_CONNECTION_STATE_DISCONNECTED = 6, /*!< @brief no connection to backend server (e.g. due to network errors or client initiated disconnect)*/ | ||
| 250 | PVR_CONNECTION_STATE_CONNECTING = 7, /*!< @brief connecting to backend */ | ||
| 251 | } PVR_CONNECTION_STATE; | ||
| 252 | |||
| 253 | /*! | ||
| 254 | * @brief PVR recording channel types | ||
| 255 | */ | ||
| 256 | typedef enum | ||
| 257 | { | ||
| 258 | PVR_RECORDING_CHANNEL_TYPE_UNKNOWN = 0, /*!< @brief unknown */ | ||
| 259 | PVR_RECORDING_CHANNEL_TYPE_TV = 1, /*!< @brief TV channel */ | ||
| 260 | PVR_RECORDING_CHANNEL_TYPE_RADIO = 2, /*!< @brief radio channel */ | ||
| 261 | } PVR_RECORDING_CHANNEL_TYPE; | ||
| 262 | |||
| 263 | /*! | ||
| 264 | * @brief Representation of a named value | ||
| 265 | */ | ||
| 266 | typedef struct PVR_NAMED_VALUE { | ||
| 267 | char strName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) name */ | ||
| 268 | char strValue[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) value */ | ||
| 269 | } ATTRIBUTE_PACKED PVR_NAMED_VALUE; | ||
| 270 | |||
| 271 | /*! | ||
| 272 | * @brief Properties passed to the Create() method of an add-on. | ||
| 273 | */ | ||
| 274 | typedef struct PVR_PROPERTIES | ||
| 275 | { | ||
| 276 | const char* strUserPath; /*!< @brief path to the user profile */ | ||
| 277 | const char* strClientPath; /*!< @brief path to this add-on */ | ||
| 278 | int iEpgMaxDays; /*!< @brief if > EPG_TIMEFRAME_UNLIMITED, in async epg mode, deliver only events in the range from 'end time > now' to 'start time < now + iEpgMaxDays. EPG_TIMEFRAME_UNLIMITED, notify all events. */ | ||
| 279 | } PVR_PROPERTIES; | ||
| 280 | |||
| 281 | /*! | ||
| 282 | * @brief Representation of a general attribute integer value. | ||
| 283 | */ | ||
| 284 | typedef struct PVR_ATTRIBUTE_INT_VALUE | ||
| 285 | { | ||
| 286 | int iValue; /*!< @brief (required) an integer value for a certain attribute */ | ||
| 287 | char strDescription[PVR_ADDON_ATTRIBUTE_DESC_LENGTH]; /*!< @brief (optional) a localized string describing the value. If left blank, Kodi will generate a suitable representation (like the integer value as string) */ | ||
| 288 | } ATTRIBUTE_PACKED PVR_ATTRIBUTE_INT_VALUE; | ||
| 289 | |||
| 290 | /*! | ||
| 291 | * @brief PVR add-on capabilities. All capabilities are set to "false" or 0 as default | ||
| 292 | * If a capability is set to true, then the corresponding methods from xbmc_pvr_dll.h need to be implemented. | ||
| 293 | */ | ||
| 294 | typedef struct PVR_ADDON_CAPABILITIES | ||
| 295 | { | ||
| 296 | bool bSupportsEPG; /*!< @brief true if the add-on provides EPG information */ | ||
| 297 | bool bSupportsEPGEdl; /*!< @brief true if the backend supports retrieving an edit decision list for an EPG tag. */ | ||
| 298 | bool bSupportsTV; /*!< @brief true if this add-on provides TV channels */ | ||
| 299 | bool bSupportsRadio; /*!< @brief true if this add-on supports radio channels */ | ||
| 300 | bool bSupportsRecordings; /*!< @brief true if this add-on supports playback of recordings stored on the backend */ | ||
| 301 | bool bSupportsRecordingsUndelete; /*!< @brief true if this add-on supports undelete of recordings stored on the backend */ | ||
| 302 | bool bSupportsTimers; /*!< @brief true if this add-on supports the creation and editing of timers */ | ||
| 303 | bool bSupportsChannelGroups; /*!< @brief true if this add-on supports channel groups */ | ||
| 304 | bool bSupportsChannelScan; /*!< @brief true if this add-on support scanning for new channels on the backend */ | ||
| 305 | bool bSupportsChannelSettings; /*!< @brief true if this add-on supports the following functions: DeleteChannel, RenameChannel, DialogChannelSettings and DialogAddChannel */ | ||
| 306 | bool bHandlesInputStream; /*!< @brief true if this add-on provides an input stream. false if Kodi handles the stream. */ | ||
| 307 | bool bHandlesDemuxing; /*!< @brief true if this add-on demultiplexes packets. */ | ||
| 308 | bool bSupportsRecordingPlayCount; /*!< @brief true if the backend supports play count for recordings. */ | ||
| 309 | bool bSupportsLastPlayedPosition; /*!< @brief true if the backend supports store/retrieve of last played position for recordings. */ | ||
| 310 | bool bSupportsRecordingEdl; /*!< @brief true if the backend supports retrieving an edit decision list for recordings. */ | ||
| 311 | bool bSupportsRecordingsRename; /*!< @brief true if the backend supports renaming recordings. */ | ||
| 312 | bool bSupportsRecordingsLifetimeChange; /*!< @brief true if the backend supports changing lifetime for recordings. */ | ||
| 313 | bool bSupportsDescrambleInfo; /*!< @brief true if the backend supports descramble information for playing channels. */ | ||
| 314 | bool bSupportsAsyncEPGTransfer; /*!< @brief true if this addon-on supports asynchronous transfer of epg events to Kodi using the callback function EpgEventStateChange. */ | ||
| 315 | |||
| 316 | unsigned int iRecordingsLifetimesSize; /*!< @brief (required) Count of possible values for PVR_RECORDING.iLifetime. 0 means lifetime is not supported for recordings or no own value definition wanted, but to use Kodi defaults of 1..365. */ | ||
| 317 | PVR_ATTRIBUTE_INT_VALUE recordingsLifetimeValues[PVR_ADDON_ATTRIBUTE_VALUES_ARRAY_SIZE]; /*!< @brief (optional) Array containing the possible values for PVR_RECORDING.iLifetime. Must be filled if iLifetimesSize > 0 */ | ||
| 318 | } ATTRIBUTE_PACKED PVR_ADDON_CAPABILITIES; | ||
| 319 | |||
| 320 | /*! | ||
| 321 | * @brief PVR stream properties | ||
| 322 | */ | ||
| 323 | typedef struct PVR_STREAM_PROPERTIES | ||
| 324 | { | ||
| 325 | unsigned int iStreamCount; | ||
| 326 | struct PVR_STREAM | ||
| 327 | { | ||
| 328 | unsigned int iPID; /*!< @brief (required) PID */ | ||
| 329 | xbmc_codec_type_t iCodecType; /*!< @brief (required) codec type this stream */ | ||
| 330 | xbmc_codec_id_t iCodecId; /*!< @brief (required) codec id of this stream */ | ||
| 331 | char strLanguage[4]; /*!< @brief (required) language id */ | ||
| 332 | int iSubtitleInfo; /*!< @brief (required) Subtitle Info */ | ||
| 333 | int iFPSScale; /*!< @brief (required) scale of 1000 and a rate of 29970 will result in 29.97 fps */ | ||
| 334 | int iFPSRate; /*!< @brief (required) FPS rate */ | ||
| 335 | int iHeight; /*!< @brief (required) height of the stream reported by the demuxer */ | ||
| 336 | int iWidth; /*!< @brief (required) width of the stream reported by the demuxer */ | ||
| 337 | float fAspect; /*!< @brief (required) display aspect ratio of the stream */ | ||
| 338 | int iChannels; /*!< @brief (required) amount of channels */ | ||
| 339 | int iSampleRate; /*!< @brief (required) sample rate */ | ||
| 340 | int iBlockAlign; /*!< @brief (required) block alignment */ | ||
| 341 | int iBitRate; /*!< @brief (required) bit rate */ | ||
| 342 | int iBitsPerSample; /*!< @brief (required) bits per sample */ | ||
| 343 | } stream[PVR_STREAM_MAX_STREAMS]; /*!< @brief (required) the streams */ | ||
| 344 | } ATTRIBUTE_PACKED PVR_STREAM_PROPERTIES; | ||
| 345 | |||
| 346 | /*! | ||
| 347 | * @brief Signal status information | ||
| 348 | */ | ||
| 349 | typedef struct PVR_SIGNAL_STATUS | ||
| 350 | { | ||
| 351 | char strAdapterName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the adapter that's being used */ | ||
| 352 | char strAdapterStatus[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) status of the adapter that's being used */ | ||
| 353 | char strServiceName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the current service */ | ||
| 354 | char strProviderName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the current service's provider */ | ||
| 355 | char strMuxName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the current mux */ | ||
| 356 | int iSNR; /*!< @brief (optional) signal/noise ratio */ | ||
| 357 | int iSignal; /*!< @brief (optional) signal strength */ | ||
| 358 | long iBER; /*!< @brief (optional) bit error rate */ | ||
| 359 | long iUNC; /*!< @brief (optional) uncorrected blocks */ | ||
| 360 | } ATTRIBUTE_PACKED PVR_SIGNAL_STATUS; | ||
| 361 | |||
| 362 | /*! | ||
| 363 | * @brief descramble information | ||
| 364 | */ | ||
| 365 | typedef struct PVR_DESCRAMBLE_INFO | ||
| 366 | { | ||
| 367 | int iPid; /*!< @brief (optional) pid; PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available */ | ||
| 368 | int iCaid; /*!< @brief (optional) caid; PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available */ | ||
| 369 | int iProvid; /*!< @brief (optional) provid; PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available */ | ||
| 370 | int iEcmTime; /*!< @brief (optional) ecm time; PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available */ | ||
| 371 | int iHops; /*!< @brief (optional) hops; PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available */ | ||
| 372 | char strCardSystem[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; /*!< @brief (optional); empty string if not available */ | ||
| 373 | char strReader[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; /*!< @brief (optional); empty string if not available */ | ||
| 374 | char strFrom[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; /*!< @brief (optional); empty string if not available */ | ||
| 375 | char strProtocol[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH]; /*!< @brief (optional); empty string if not available */ | ||
| 376 | } ATTRIBUTE_PACKED PVR_DESCRAMBLE_INFO; | ||
| 377 | |||
| 378 | /*! | ||
| 379 | * @brief Menu hooks that are available in the context menus while playing a stream via this add-on. | ||
| 380 | * And in the Live TV settings dialog | ||
| 381 | */ | ||
| 382 | typedef struct PVR_MENUHOOK | ||
| 383 | { | ||
| 384 | unsigned int iHookId; /*!< @brief (required) this hook's identifier */ | ||
| 385 | unsigned int iLocalizedStringId; /*!< @brief (required) the id of the label for this hook in g_localizeStrings */ | ||
| 386 | PVR_MENUHOOK_CAT category; /*!< @brief (required) category of menu hook */ | ||
| 387 | } ATTRIBUTE_PACKED PVR_MENUHOOK; | ||
| 388 | |||
| 389 | /*! | ||
| 390 | * @brief Representation of a TV or radio channel. | ||
| 391 | */ | ||
| 392 | typedef struct PVR_CHANNEL | ||
| 393 | { | ||
| 394 | unsigned int iUniqueId; /*!< @brief (required) unique identifier for this channel */ | ||
| 395 | bool bIsRadio; /*!< @brief (required) true if this is a radio channel, false if it's a TV channel */ | ||
| 396 | unsigned int iChannelNumber; /*!< @brief (optional) channel number of this channel on the backend */ | ||
| 397 | unsigned int iSubChannelNumber; /*!< @brief (optional) sub channel number of this channel on the backend (ATSC) */ | ||
| 398 | char strChannelName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) channel name given to this channel */ | ||
| 399 | char strInputFormat[PVR_ADDON_INPUT_FORMAT_STRING_LENGTH]; /*!< @brief (optional) input format type. types can be found in ffmpeg/libavformat/allformats.c | ||
| 400 | leave empty if unknown */ | ||
| 401 | unsigned int iEncryptionSystem; /*!< @brief (optional) the encryption ID or CaID of this channel */ | ||
| 402 | char strIconPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) path to the channel icon (if present) */ | ||
| 403 | bool bIsHidden; /*!< @brief (optional) true if this channel is marked as hidden */ | ||
| 404 | bool bHasArchive; /*!< @brief (optional) true if this channel has a server-side back buffer */ | ||
| 405 | } ATTRIBUTE_PACKED PVR_CHANNEL; | ||
| 406 | |||
| 407 | typedef struct PVR_CHANNEL_GROUP | ||
| 408 | { | ||
| 409 | char strGroupName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) name of this channel group */ | ||
| 410 | bool bIsRadio; /*!< @brief (required) true if this is a radio channel group, false otherwise. */ | ||
| 411 | unsigned int iPosition; /*!< @brief (optional) sort position of the group (0 indicates that the backend doesn't support sorting of groups) */ | ||
| 412 | } ATTRIBUTE_PACKED PVR_CHANNEL_GROUP; | ||
| 413 | |||
| 414 | typedef struct PVR_CHANNEL_GROUP_MEMBER | ||
| 415 | { | ||
| 416 | char strGroupName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) name of the channel group to add the channel to */ | ||
| 417 | unsigned int iChannelUniqueId; /*!< @brief (required) unique id of the member */ | ||
| 418 | unsigned int iChannelNumber; /*!< @brief (optional) channel number within the group */ | ||
| 419 | unsigned int iSubChannelNumber; /*!< @brief (optional) sub channel number within the group (ATSC) */ | ||
| 420 | } ATTRIBUTE_PACKED PVR_CHANNEL_GROUP_MEMBER; | ||
| 421 | |||
| 422 | /*! | ||
| 423 | * @brief Representation of a timer type's attribute integer value. | ||
| 424 | */ | ||
| 425 | typedef PVR_ATTRIBUTE_INT_VALUE PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE; | ||
| 426 | |||
| 427 | /*! | ||
| 428 | * @brief Representation of a timer type. | ||
| 429 | */ | ||
| 430 | typedef struct PVR_TIMER_TYPE | ||
| 431 | { | ||
| 432 | unsigned int iId; /*!< @brief (required) this type's identifier. Ids must be > PVR_TIMER_TYPE_NONE. */ | ||
| 433 | unsigned int iAttributes; /*!< @brief (required) defines the attributes for this type (PVR_TIMER_TYPE_* constants). */ | ||
| 434 | char strDescription[PVR_ADDON_TIMERTYPE_STRING_LENGTH]; /*!< @brief (optional) a short localized string describing the purpose of the type. (e.g. | ||
| 435 | "Any time at this channel if title matches"). If left blank, Kodi will generate a | ||
| 436 | description based on the attributes REPEATING and MANUAL. (e.g. "Repeating EPG-based." */ | ||
| 437 | /* priority value definitions */ | ||
| 438 | unsigned int iPrioritiesSize; /*!< @brief (required) Count of possible values for PVR_TMER.iPriority. 0 means priority | ||
| 439 | is not supported by this timer type or no own value definition wanted, but to use Kodi defaults | ||
| 440 | of 1..100. */ | ||
| 441 | PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE | ||
| 442 | priorities[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; /*!< @brief (optional) Array containing the possible values for PVR_TMER.iPriority. Must be | ||
| 443 | filled if iPrioritiesSize > 0 */ | ||
| 444 | int iPrioritiesDefault; /*!< @brief (optional) The default value for PVR_TMER.iPriority. Must be filled if iPrioritiesSize > 0 */ | ||
| 445 | |||
| 446 | /* lifetime value definitions */ | ||
| 447 | unsigned int iLifetimesSize; /*!< @brief (required) Count of possible values for PVR_TMER.iLifetime. 0 means lifetime | ||
| 448 | is not supported by this timer type or no own value definition wanted, but to use Kodi defaults | ||
| 449 | of 1..365. */ | ||
| 450 | PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE | ||
| 451 | lifetimes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; /*!< @brief (optional) Array containing the possible values for PVR_TMER.iLifetime. Must be | ||
| 452 | filled if iLifetimesSize > 0 */ | ||
| 453 | int iLifetimesDefault; /*!< @brief (optional) The default value for PVR_TMER.iLifetime. Must be filled if iLifetimesSize > 0 */ | ||
| 454 | |||
| 455 | /* prevent duplicate episodes value definitions */ | ||
| 456 | unsigned int iPreventDuplicateEpisodesSize; /*!< @brief (required) Count of possible values for PVR_TMER.iPreventDuplicateEpisodes. 0 means duplicate | ||
| 457 | episodes prevention is not supported by this timer type or no own value definition wanted, but to use | ||
| 458 | Kodi defaults. */ | ||
| 459 | PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE | ||
| 460 | preventDuplicateEpisodes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; | ||
| 461 | /*!< @brief (optional) Array containing the possible values for PVR_TMER.iPreventDuplicateEpisodes.. Must | ||
| 462 | be filled if iPreventDuplicateEpisodesSize > 0 */ | ||
| 463 | unsigned int iPreventDuplicateEpisodesDefault; /*!< @brief (optional) The default value for PVR_TMER.iPreventDuplicateEpisodesSize. Must be filled if iPreventDuplicateEpisodesSize > 0 */ | ||
| 464 | |||
| 465 | /* recording folder list value definitions */ | ||
| 466 | unsigned int iRecordingGroupSize; /*!< @brief (required) Count of possible values of PVR_TIMER.iRecordingGroup. 0 means folder lists are not supported by this timer type */ | ||
| 467 | PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE | ||
| 468 | recordingGroup[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; | ||
| 469 | /*!< @brief (optional) Array containing the possible values of PVR_TMER.iRecordingGroup. Must be filled if iRecordingGroupSize > 0 */ | ||
| 470 | unsigned int iRecordingGroupDefault; /*!< @brief (optional) The default value for PVR_TIMER.iRecordingGroup. Must be filled in if PVR_TIMER.iRecordingGroupSize > 0 */ | ||
| 471 | |||
| 472 | /* max recordings value definitions */ | ||
| 473 | unsigned int iMaxRecordingsSize; /*!< @brief (required) Count of possible values of PVR_TIMER.iMaxRecordings. 0 means max recordings are not supported by this timer type */ | ||
| 474 | PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE | ||
| 475 | maxRecordings[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL]; | ||
| 476 | /*!< @brief (optional) Array containing the possible values of PVR_TMER.iMaxRecordings. */ | ||
| 477 | int iMaxRecordingsDefault; /*!< @brief (optional) The default value for PVR_TIMER.iMaxRecordings. Must be filled in if PVR_TIMER.iMaxRecordingsSize > 0 */ | ||
| 478 | |||
| 479 | } ATTRIBUTE_PACKED PVR_TIMER_TYPE; | ||
| 480 | |||
| 481 | /*! | ||
| 482 | * @brief Representation of a timer event. | ||
| 483 | */ | ||
| 484 | typedef struct PVR_TIMER { | ||
| 485 | unsigned int iClientIndex; /*!< @brief (required) the index of this timer given by the client. PVR_TIMER_NO_CLIENT_INDEX indicates that the index was not yet set by the client, for example for new timers created by | ||
| 486 | Kodi and passed the first time to the client. A valid index must be greater than PVR_TIMER_NO_CLIENT_INDEX. */ | ||
| 487 | unsigned int iParentClientIndex; /*!< @brief (optional) for timers scheduled by a repeating timer, the index of the repeating timer that scheduled this timer (it's PVR_TIMER.iClientIndex value). Use PVR_TIMER_NO_PARENT | ||
| 488 | to indicate that this timer was no scheduled by a repeating timer. */ | ||
| 489 | int iClientChannelUid; /*!< @brief (optional) unique identifier of the channel to record on. PVR_TIMER_ANY_CHANNEL will denote "any channel", not a specific one. PVR_CHANNEL_INVALID_UID denotes that channel uid is not available.*/ | ||
| 490 | time_t startTime; /*!< @brief (optional) start time of the recording in UTC. Instant timers that are sent to the add-on by Kodi will have this value set to 0.*/ | ||
| 491 | time_t endTime; /*!< @brief (optional) end time of the recording in UTC. */ | ||
| 492 | bool bStartAnyTime; /*!< @brief (optional) for EPG based (not Manual) timers indicates startTime does not apply. Default = false */ | ||
| 493 | bool bEndAnyTime; /*!< @brief (optional) for EPG based (not Manual) timers indicates endTime does not apply. Default = false */ | ||
| 494 | PVR_TIMER_STATE state; /*!< @brief (required) the state of this timer */ | ||
| 495 | unsigned int iTimerType; /*!< @brief (required) the type of this timer. It is private to the addon and can be freely defined by the addon. The value must be greater than PVR_TIMER_TYPE_NONE. | ||
| 496 | Kodi does not interpret this value (except for checking for PVR_TIMER_TYPE_NONE), but will pass the right id to the addon with every PVR_TIMER instance, thus the addon easily can determine | ||
| 497 | the timer type. */ | ||
| 498 | char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) a title for this timer */ | ||
| 499 | char strEpgSearchString[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) a string used to search epg data for repeating epg-based timers. Format is backend-dependent, for example regexp */ | ||
| 500 | bool bFullTextEpgSearch; /*!< @brief (optional) indicates, whether strEpgSearchString is to match against the epg episode title only or also against "other" epg data (backend-dependent) */ | ||
| 501 | char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) the (relative) directory where the recording will be stored in */ | ||
| 502 | char strSummary[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) the summary for this timer */ | ||
| 503 | int iPriority; /*!< @brief (optional) the priority of this timer */ | ||
| 504 | int iLifetime; /*!< @brief (optional) lifetime of recordings created by this timer. > 0 days after which recordings will be deleted by the backend, < 0 addon defined integer list reference, == 0 disabled */ | ||
| 505 | int iMaxRecordings; /*!< @brief (optional) maximum number of recordings this timer shall create. > 0 number of recordings, < 0 addon defined integer list reference, == 0 disabled */ | ||
| 506 | unsigned int iRecordingGroup; /*!< @brief (optional) integer ref to addon/backend defined list of recording groups*/ | ||
| 507 | time_t firstDay; /*!< @brief (optional) the first day this timer is active, for repeating timers */ | ||
| 508 | unsigned int iWeekdays; /*!< @brief (optional) week days, for repeating timers (see PVR_WEEKDAY_* constant values) */ | ||
| 509 | unsigned int iPreventDuplicateEpisodes; /*!< @brief (optional) 1 if backend should only record new episodes in case of a repeating epg-based timer, 0 if all episodes shall be recorded (no duplicate detection). Actual algorithm for | ||
| 510 | duplicate detection is defined by the backend. Addons may define own values for different duplicate detection algorithms, thus this is not just a bool.*/ | ||
| 511 | unsigned int iEpgUid; /*!< @brief (optional) EPG event id associated with this timer. Event ids must be unique for a channel. Valid ids must be greater than EPG_TAG_INVALID_UID. */ | ||
| 512 | unsigned int iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */ | ||
| 513 | unsigned int iMarginEnd; /*!< @brief (optional) if set, the backend ends the recording iMarginEnd minutes after endTime. */ | ||
| 514 | int iGenreType; /*!< @brief (optional) genre type */ | ||
| 515 | int iGenreSubType; /*!< @brief (optional) genre sub type */ | ||
| 516 | char strSeriesLink[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) series link for this timer. If set for an epg-based timer rule, matching events will be found by checking strSeriesLink instead of strTitle (and bFullTextEpgSearch) */ | ||
| 517 | |||
| 518 | } ATTRIBUTE_PACKED PVR_TIMER; | ||
| 519 | |||
| 520 | /*! | ||
| 521 | * @brief Representation of a recording. | ||
| 522 | */ | ||
| 523 | typedef struct PVR_RECORDING { | ||
| 524 | char strRecordingId[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) unique id of the recording on the client. */ | ||
| 525 | char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) the title of this recording */ | ||
| 526 | char strEpisodeName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) episode name (also known as subtitle) */ | ||
| 527 | int iSeriesNumber; /*!< @brief (optional) series number (usually called season). Set to "0" for specials/pilot. For 'invalid' see iEpisodeNumber or set to -1 */ | ||
| 528 | int iEpisodeNumber; /*!< @brief (optional) episode number within the "iSeriesNumber" season. For 'invalid' set to -1 or iSeriesNumber=iEpisodeNumber=0 to show both are invalid */ | ||
| 529 | int iYear; /*!< @brief (optional) year of first release (use to identify a specific movie re-make) / first airing for TV shows. Set to '0' for invalid. */ | ||
| 530 | char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) directory of this recording on the client */ | ||
| 531 | char strPlotOutline[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) plot outline */ | ||
| 532 | char strPlot[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) plot */ | ||
| 533 | char strGenreDescription[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) genre. Will be used only when iGenreType = EPG_GENRE_USE_STRING */ | ||
| 534 | char strChannelName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) channel name */ | ||
| 535 | char strIconPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) channel logo (icon) path */ | ||
| 536 | char strThumbnailPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) thumbnail path */ | ||
| 537 | char strFanartPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) fanart path */ | ||
| 538 | time_t recordingTime; /*!< @brief (optional) start time of the recording */ | ||
| 539 | int iDuration; /*!< @brief (optional) duration of the recording in seconds */ | ||
| 540 | int iPriority; /*!< @brief (optional) priority of this recording (from 0 - 100) */ | ||
| 541 | int iLifetime; /*!< @brief (optional) life time in days of this recording */ | ||
| 542 | int iGenreType; /*!< @brief (optional) genre type */ | ||
| 543 | int iGenreSubType; /*!< @brief (optional) genre sub type */ | ||
| 544 | int iPlayCount; /*!< @brief (optional) play count of this recording on the client */ | ||
| 545 | int iLastPlayedPosition; /*!< @brief (optional) last played position of this recording on the client */ | ||
| 546 | bool bIsDeleted; /*!< @brief (optional) shows this recording is deleted and can be undelete */ | ||
| 547 | unsigned int iEpgEventId; /*!< @brief (optional) EPG event id associated with this recording. Valid ids must be greater than EPG_TAG_INVALID_UID. */ | ||
| 548 | int iChannelUid; /*!< @brief (optional) unique identifier of the channel for this recording. PVR_CHANNEL_INVALID_UID denotes that channel uid is not available. */ | ||
| 549 | PVR_RECORDING_CHANNEL_TYPE channelType; /*!< @brief (optional) channel type. Set to PVR_RECORDING_CHANNEL_TYPE_UNKNOWN if the type cannot be determined. */ | ||
| 550 | } ATTRIBUTE_PACKED PVR_RECORDING; | ||
| 551 | |||
| 552 | /*! | ||
| 553 | * @brief Edit definition list (EDL) | ||
| 554 | */ | ||
| 555 | typedef enum | ||
| 556 | { | ||
| 557 | PVR_EDL_TYPE_CUT = 0, /*!< @brief cut (completely remove content) */ | ||
| 558 | PVR_EDL_TYPE_MUTE = 1, /*!< @brief mute audio */ | ||
| 559 | PVR_EDL_TYPE_SCENE = 2, /*!< @brief scene markers (chapter seeking) */ | ||
| 560 | PVR_EDL_TYPE_COMBREAK = 3 /*!< @brief commercial breaks */ | ||
| 561 | } PVR_EDL_TYPE; | ||
| 562 | |||
| 563 | typedef struct PVR_EDL_ENTRY | ||
| 564 | { | ||
| 565 | int64_t start; // ms | ||
| 566 | int64_t end; // ms | ||
| 567 | PVR_EDL_TYPE type; | ||
| 568 | } ATTRIBUTE_PACKED PVR_EDL_ENTRY; | ||
| 569 | |||
| 570 | /*! | ||
| 571 | * @brief PVR menu hook data | ||
| 572 | */ | ||
| 573 | typedef struct PVR_MENUHOOK_DATA | ||
| 574 | { | ||
| 575 | PVR_MENUHOOK_CAT cat; | ||
| 576 | union data { | ||
| 577 | int iEpgUid; | ||
| 578 | PVR_CHANNEL channel; | ||
| 579 | PVR_TIMER timer; | ||
| 580 | PVR_RECORDING recording; | ||
| 581 | } data; | ||
| 582 | } ATTRIBUTE_PACKED PVR_MENUHOOK_DATA; | ||
| 583 | |||
| 584 | /*! | ||
| 585 | * @brief times of playing stream (Live TV and recordings) | ||
| 586 | */ | ||
| 587 | typedef struct PVR_STREAM_TIMES | ||
| 588 | { | ||
| 589 | time_t startTime; /*!< @brief For recordings, this must be zero. For Live TV, this is a reference time in units of time_t (UTC) from which time elapsed starts. Ideally start of tv show, but can be any other value. */ | ||
| 590 | int64_t ptsStart; /*!< @brief the pts of startTime */ | ||
| 591 | int64_t ptsBegin; /*!< @brief earliest pts player can seek back. Value is in micro seconds, relative to ptsStart. For recordings, this must be zero. For Live TV, this must be zero if not timeshifting and must point to begin of the timeshift buffer, otherwise. */ | ||
| 592 | int64_t ptsEnd; /*!< @brief latest pts player can seek forward. Value is in micro seconds, relative to ptsStart. For recordings, this must be the total length. For Live TV, this must be zero if not timeshifting and must point to end of the timeshift buffer, otherwise. */ | ||
| 593 | } ATTRIBUTE_PACKED PVR_STREAM_TIMES; | ||
| 594 | |||
| 595 | typedef struct AddonToKodiFuncTable_PVR | ||
| 596 | { | ||
| 597 | KODI_HANDLE kodiInstance; | ||
| 598 | |||
| 599 | void (*TransferEpgEntry)(void* kodiInstance, const ADDON_HANDLE handle, const EPG_TAG *epgentry); | ||
| 600 | void (*TransferChannelEntry)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL *chan); | ||
| 601 | void (*TransferTimerEntry)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_TIMER *timer); | ||
| 602 | void (*TransferRecordingEntry)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_RECORDING *recording); | ||
| 603 | void (*AddMenuHook)(void* kodiInstance, PVR_MENUHOOK *hook); | ||
| 604 | void (*Recording)(void* kodiInstance, const char *Name, const char *FileName, bool On); | ||
| 605 | void (*TriggerChannelUpdate)(void* kodiInstance); | ||
| 606 | void (*TriggerTimerUpdate)(void* kodiInstance); | ||
| 607 | void (*TriggerRecordingUpdate)(void* kodiInstance); | ||
| 608 | void (*TriggerChannelGroupsUpdate)(void* kodiInstance); | ||
| 609 | void (*TriggerEpgUpdate)(void* kodiInstance, unsigned int iChannelUid); | ||
| 610 | |||
| 611 | void (*TransferChannelGroup)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group); | ||
| 612 | void (*TransferChannelGroupMember)(void* kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member); | ||
| 613 | |||
| 614 | void (*FreeDemuxPacket)(void* kodiInstance, DemuxPacket* pPacket); | ||
| 615 | DemuxPacket* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize); | ||
| 616 | |||
| 617 | void (*ConnectionStateChange)(void* kodiInstance, const char* strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage); | ||
| 618 | void (*EpgEventStateChange)(void* kodiInstance, EPG_TAG* tag, EPG_EVENT_STATE newState); | ||
| 619 | |||
| 620 | xbmc_codec_t (*GetCodecByName)(const void* kodiInstance, const char* strCodecName); | ||
| 621 | } AddonToKodiFuncTable_PVR; | ||
| 622 | |||
| 623 | /*! | ||
| 624 | * @brief Structure to transfer the methods from xbmc_pvr_dll.h to Kodi | ||
| 625 | */ | ||
| 626 | typedef struct KodiToAddonFuncTable_PVR | ||
| 627 | { | ||
| 628 | KODI_HANDLE addonInstance; | ||
| 629 | |||
| 630 | PVR_ERROR (__cdecl* GetAddonCapabilities)(PVR_ADDON_CAPABILITIES*); | ||
| 631 | PVR_ERROR (__cdecl* GetStreamProperties)(PVR_STREAM_PROPERTIES*); | ||
| 632 | const char* (__cdecl* GetBackendName)(void); | ||
| 633 | const char* (__cdecl* GetBackendVersion)(void); | ||
| 634 | const char* (__cdecl* GetConnectionString)(void); | ||
| 635 | PVR_ERROR (__cdecl* GetDriveSpace)(long long*, long long*); | ||
| 636 | PVR_ERROR (__cdecl* MenuHook)(const PVR_MENUHOOK&, const PVR_MENUHOOK_DATA&); | ||
| 637 | PVR_ERROR (__cdecl* GetEPGForChannel)(ADDON_HANDLE, int, time_t, time_t); | ||
| 638 | PVR_ERROR (__cdecl* IsEPGTagRecordable)(const EPG_TAG*, bool*); | ||
| 639 | PVR_ERROR (__cdecl* IsEPGTagPlayable)(const EPG_TAG*, bool*); | ||
| 640 | PVR_ERROR (__cdecl* GetEPGTagEdl)(const EPG_TAG*, PVR_EDL_ENTRY[], int*); | ||
| 641 | PVR_ERROR (__cdecl* GetEPGTagStreamProperties)(const EPG_TAG*, PVR_NAMED_VALUE*, unsigned int*); | ||
| 642 | int (__cdecl* GetChannelGroupsAmount)(void); | ||
| 643 | PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool); | ||
| 644 | PVR_ERROR (__cdecl* GetChannelGroupMembers)(ADDON_HANDLE, const PVR_CHANNEL_GROUP&); | ||
| 645 | PVR_ERROR (__cdecl* OpenDialogChannelScan)(void); | ||
| 646 | int (__cdecl* GetChannelsAmount)(void); | ||
| 647 | PVR_ERROR (__cdecl* GetChannels)(ADDON_HANDLE, bool); | ||
| 648 | PVR_ERROR (__cdecl* DeleteChannel)(const PVR_CHANNEL&); | ||
| 649 | PVR_ERROR (__cdecl* RenameChannel)(const PVR_CHANNEL&); | ||
| 650 | PVR_ERROR (__cdecl* MoveChannel)(const PVR_CHANNEL&); | ||
| 651 | PVR_ERROR (__cdecl* OpenDialogChannelSettings)(const PVR_CHANNEL&); | ||
| 652 | PVR_ERROR (__cdecl* OpenDialogChannelAdd)(const PVR_CHANNEL&); | ||
| 653 | int (__cdecl* GetRecordingsAmount)(bool); | ||
| 654 | PVR_ERROR (__cdecl* GetRecordings)(ADDON_HANDLE, bool); | ||
| 655 | PVR_ERROR (__cdecl* DeleteRecording)(const PVR_RECORDING&); | ||
| 656 | PVR_ERROR (__cdecl* UndeleteRecording)(const PVR_RECORDING&); | ||
| 657 | PVR_ERROR (__cdecl* DeleteAllRecordingsFromTrash)(void); | ||
| 658 | PVR_ERROR (__cdecl* RenameRecording)(const PVR_RECORDING&); | ||
| 659 | PVR_ERROR (__cdecl* SetRecordingLifetime)(const PVR_RECORDING*); | ||
| 660 | PVR_ERROR (__cdecl* SetRecordingPlayCount)(const PVR_RECORDING&, int); | ||
| 661 | PVR_ERROR (__cdecl* SetRecordingLastPlayedPosition)(const PVR_RECORDING&, int); | ||
| 662 | int (__cdecl* GetRecordingLastPlayedPosition)(const PVR_RECORDING&); | ||
| 663 | PVR_ERROR (__cdecl* GetRecordingEdl)(const PVR_RECORDING&, PVR_EDL_ENTRY[], int*); | ||
| 664 | PVR_ERROR (__cdecl* GetTimerTypes)(PVR_TIMER_TYPE[], int*); | ||
| 665 | int (__cdecl* GetTimersAmount)(void); | ||
| 666 | PVR_ERROR (__cdecl* GetTimers)(ADDON_HANDLE); | ||
| 667 | PVR_ERROR (__cdecl* AddTimer)(const PVR_TIMER&); | ||
| 668 | PVR_ERROR (__cdecl* DeleteTimer)(const PVR_TIMER&, bool); | ||
| 669 | PVR_ERROR (__cdecl* UpdateTimer)(const PVR_TIMER&); | ||
| 670 | bool (__cdecl* OpenLiveStream)(const PVR_CHANNEL&); | ||
| 671 | void (__cdecl* CloseLiveStream)(void); | ||
| 672 | int (__cdecl* ReadLiveStream)(unsigned char*, unsigned int); | ||
| 673 | long long (__cdecl* SeekLiveStream)(long long, int); | ||
| 674 | long long (__cdecl* LengthLiveStream)(void); | ||
| 675 | PVR_ERROR (__cdecl* SignalStatus)(PVR_SIGNAL_STATUS&); | ||
| 676 | PVR_ERROR (__cdecl* GetDescrambleInfo)(PVR_DESCRAMBLE_INFO*); | ||
| 677 | PVR_ERROR (__cdecl* GetChannelStreamProperties)(const PVR_CHANNEL*, PVR_NAMED_VALUE*, unsigned int*); | ||
| 678 | PVR_ERROR (__cdecl* GetRecordingStreamProperties)(const PVR_RECORDING*, PVR_NAMED_VALUE*, unsigned int*); | ||
| 679 | bool (__cdecl* OpenRecordedStream)(const PVR_RECORDING&); | ||
| 680 | void (__cdecl* CloseRecordedStream)(void); | ||
| 681 | int (__cdecl* ReadRecordedStream)(unsigned char*, unsigned int); | ||
| 682 | long long (__cdecl* SeekRecordedStream)(long long, int); | ||
| 683 | long long (__cdecl* LengthRecordedStream)(void); | ||
| 684 | void (__cdecl* DemuxReset)(void); | ||
| 685 | void (__cdecl* DemuxAbort)(void); | ||
| 686 | void (__cdecl* DemuxFlush)(void); | ||
| 687 | DemuxPacket* (__cdecl* DemuxRead)(void); | ||
| 688 | bool (__cdecl* CanPauseStream)(void); | ||
| 689 | void (__cdecl* PauseStream)(bool); | ||
| 690 | bool (__cdecl* CanSeekStream)(void); | ||
| 691 | bool (__cdecl* SeekTime)(double, bool, double*); | ||
| 692 | void (__cdecl* SetSpeed)(int); | ||
| 693 | void (__cdecl* FillBuffer)(bool); | ||
| 694 | const char* (__cdecl* GetBackendHostname)(void); | ||
| 695 | bool (__cdecl* IsRealTimeStream)(void); | ||
| 696 | PVR_ERROR (__cdecl* SetEPGTimeFrame)(int); | ||
| 697 | void (__cdecl* OnSystemSleep)(void); | ||
| 698 | void (__cdecl* OnSystemWake)(void); | ||
| 699 | void (__cdecl* OnPowerSavingActivated)(void); | ||
| 700 | void (__cdecl* OnPowerSavingDeactivated)(void); | ||
| 701 | PVR_ERROR (__cdecl* GetStreamTimes)(PVR_STREAM_TIMES*); | ||
| 702 | PVR_ERROR (__cdecl* GetStreamReadChunkSize)(int*); | ||
| 703 | } KodiToAddonFuncTable_PVR; | ||
| 704 | |||
| 705 | typedef struct AddonInstance_PVR | ||
| 706 | { | ||
| 707 | PVR_PROPERTIES props; | ||
| 708 | AddonToKodiFuncTable_PVR toKodi; | ||
| 709 | KodiToAddonFuncTable_PVR toAddon; | ||
| 710 | } AddonInstance_PVR; | ||
| 711 | |||
| 712 | #ifdef __cplusplus | ||
| 713 | } | ||
| 714 | #endif | ||
diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxCrypto.h b/xbmc/cores/VideoPlayer/Interface/Addon/DemuxCrypto.h index b48ef34..416e159 100644 --- a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxCrypto.h +++ b/xbmc/cores/VideoPlayer/Interface/Addon/DemuxCrypto.h | |||
| @@ -13,11 +13,12 @@ | |||
| 13 | 13 | ||
| 14 | //CryptoSession is usually obtained once per stream, but could change if an key expires | 14 | //CryptoSession is usually obtained once per stream, but could change if an key expires |
| 15 | 15 | ||
| 16 | enum CryptoSessionSystem :uint8_t | 16 | enum CryptoSessionSystem : uint8_t |
| 17 | { | 17 | { |
| 18 | CRYPTO_SESSION_SYSTEM_NONE, | 18 | CRYPTO_SESSION_SYSTEM_NONE, |
| 19 | CRYPTO_SESSION_SYSTEM_WIDEVINE, | 19 | CRYPTO_SESSION_SYSTEM_WIDEVINE, |
| 20 | CRYPTO_SESSION_SYSTEM_PLAYREADY | 20 | CRYPTO_SESSION_SYSTEM_PLAYREADY, |
| 21 | CRYPTO_SESSION_SYSTEM_WISEPLAY, | ||
| 21 | }; | 22 | }; |
| 22 | 23 | ||
| 23 | struct DemuxCryptoSession | 24 | struct DemuxCryptoSession |
diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h b/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h index f8ceab2..6da4838 100644 --- a/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h +++ b/xbmc/cores/VideoPlayer/Interface/Addon/DemuxPacket.h | |||
| @@ -9,32 +9,43 @@ | |||
| 9 | #pragma once | 9 | #pragma once |
| 10 | 10 | ||
| 11 | #include "TimingConstants.h" | 11 | #include "TimingConstants.h" |
| 12 | |||
| 12 | #include <cstdint> | 13 | #include <cstdint> |
| 13 | #include <memory> | 14 | #include <memory> |
| 14 | 15 | ||
| 15 | #define DMX_SPECIALID_STREAMINFO -10 | 16 | #define DMX_SPECIALID_STREAMINFO -10 |
| 16 | #define DMX_SPECIALID_STREAMCHANGE -11 | 17 | #define DMX_SPECIALID_STREAMCHANGE -11 |
| 17 | 18 | ||
| 18 | struct DemuxCryptoInfo; | 19 | #ifdef __cplusplus |
| 19 | 20 | extern "C" | |
| 20 | typedef struct DemuxPacket | ||
| 21 | { | 21 | { |
| 22 | DemuxPacket() = default; | 22 | #endif /* __cplusplus */ |
| 23 | |||
| 24 | struct DemuxCryptoInfo; | ||
| 25 | |||
| 26 | typedef struct DemuxPacket | ||
| 27 | { | ||
| 28 | DemuxPacket() = default; | ||
| 29 | |||
| 30 | uint8_t* pData = nullptr; | ||
| 31 | int iSize = 0; | ||
| 32 | int iStreamId = -1; | ||
| 33 | int64_t demuxerId = -1; // id of the demuxer that created the packet | ||
| 34 | int iGroupId = | ||
| 35 | -1; // the group this data belongs to, used to group data from different streams together | ||
| 23 | 36 | ||
| 24 | uint8_t *pData = nullptr; | 37 | void* pSideData = nullptr; |
| 25 | int iSize = 0; | 38 | int iSideDataElems = 0; |
| 26 | int iStreamId = -1; | ||
| 27 | int64_t demuxerId = -1; // id of the demuxer that created the packet | ||
| 28 | int iGroupId = -1; // the group this data belongs to, used to group data from different streams together | ||
| 29 | 39 | ||
| 30 | void *pSideData = nullptr; | 40 | double pts = DVD_NOPTS_VALUE; |
| 31 | int iSideDataElems = 0; | 41 | double dts = DVD_NOPTS_VALUE; |
| 42 | double duration = 0; // duration in DVD_TIME_BASE if available | ||
| 43 | int dispTime = 0; | ||
| 44 | bool recoveryPoint = false; | ||
| 32 | 45 | ||
| 33 | double pts = DVD_NOPTS_VALUE; | 46 | std::shared_ptr<DemuxCryptoInfo> cryptoInfo; |
| 34 | double dts = DVD_NOPTS_VALUE; | 47 | } DemuxPacket; |
| 35 | double duration = 0; // duration in DVD_TIME_BASE if available | ||
| 36 | int dispTime = 0; | ||
| 37 | bool recoveryPoint = false; | ||
| 38 | 48 | ||
| 39 | std::shared_ptr<DemuxCryptoInfo> cryptoInfo; | 49 | #ifdef __cplusplus |
| 40 | } DemuxPacket; | 50 | } /* extern "C" */ |
| 51 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/InputStreamConstants.h b/xbmc/cores/VideoPlayer/Interface/Addon/InputStreamConstants.h new file mode 100644 index 0000000..ff4dbea --- /dev/null +++ b/xbmc/cores/VideoPlayer/Interface/Addon/InputStreamConstants.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2017-2019 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 | /*! | ||
| 12 | * @brief the name of the inputstream add-on that should be used by Kodi to | ||
| 13 | * play the stream denoted by STREAM_PROPERTY_STREAMURL. Leave blank to use | ||
| 14 | * Kodi's built-in playing capabilities or to allow ffmpeg to handle directly | ||
| 15 | * set to STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG. | ||
| 16 | */ | ||
| 17 | #define STREAM_PROPERTY_INPUTSTREAM "inputstream" | ||
| 18 | |||
| 19 | /*! | ||
| 20 | * @brief Identification string for an input stream. | ||
| 21 | * | ||
| 22 | * This value can be used in addition to @ref STREAM_PROPERTY_INPUTSTREAM. It is | ||
| 23 | * used to provide the respective inpustream addon with additional | ||
| 24 | * identification. | ||
| 25 | * | ||
| 26 | * The difference between this and other stream properties is that it is also | ||
| 27 | * passed in the associated @ref kodi::addon::CAddonBase::CreateInstance call. | ||
| 28 | * | ||
| 29 | * This makes it possible to select different processing classes within the | ||
| 30 | * associated add-on. | ||
| 31 | */ | ||
| 32 | #define STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID "inputstream-instance-id" | ||
| 33 | |||
| 34 | /*! | ||
| 35 | * @brief "true" to denote that the stream that should be played is a | ||
| 36 | * realtime stream. Any other value indicates that this is not a realtime | ||
| 37 | * stream. | ||
| 38 | */ | ||
| 39 | #define STREAM_PROPERTY_ISREALTIMESTREAM "isrealtimestream" | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * @brief special value for STREAM_PROPERTY_INPUTSTREAM to use | ||
| 43 | * ffmpeg to directly play a stream URL. | ||
| 44 | */ | ||
| 45 | #define STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG "inputstream.ffmpeg" | ||
| 46 | |||
| 47 | /*! | ||
| 48 | * @brief Max number of properties that can be sent to an Inputstream addon | ||
| 49 | */ | ||
| 50 | #define STREAM_MAX_PROPERTY_COUNT 30 | ||
diff --git a/xbmc/cores/VideoPlayer/Interface/Addon/TimingConstants.h b/xbmc/cores/VideoPlayer/Interface/Addon/TimingConstants.h index 0672002..c94e255 100644 --- a/xbmc/cores/VideoPlayer/Interface/Addon/TimingConstants.h +++ b/xbmc/cores/VideoPlayer/Interface/Addon/TimingConstants.h | |||
| @@ -11,9 +11,15 @@ | |||
| 11 | #define DVD_TIME_BASE 1000000 | 11 | #define DVD_TIME_BASE 1000000 |
| 12 | #define DVD_NOPTS_VALUE 0xFFF0000000000000 | 12 | #define DVD_NOPTS_VALUE 0xFFF0000000000000 |
| 13 | 13 | ||
| 14 | #ifdef __cplusplus | ||
| 14 | constexpr int DVD_TIME_TO_MSEC(double x) { return static_cast<int>(x * 1000 / DVD_TIME_BASE); } | 15 | constexpr int DVD_TIME_TO_MSEC(double x) { return static_cast<int>(x * 1000 / DVD_TIME_BASE); } |
| 15 | constexpr double DVD_SEC_TO_TIME(double x) { return x * DVD_TIME_BASE; } | 16 | constexpr double DVD_SEC_TO_TIME(double x) { return x * DVD_TIME_BASE; } |
| 16 | constexpr double DVD_MSEC_TO_TIME(double x) { return x * DVD_TIME_BASE / 1000; } | 17 | constexpr double DVD_MSEC_TO_TIME(double x) { return x * DVD_TIME_BASE / 1000; } |
| 18 | #else | ||
| 19 | #define DVD_TIME_TO_MSEC(x) ((int)((double)(x) * 1000 / DVD_TIME_BASE)) | ||
| 20 | #define DVD_SEC_TO_TIME(x) ((double)(x) * DVD_TIME_BASE) | ||
| 21 | #define DVD_MSEC_TO_TIME(x) ((double)(x) * DVD_TIME_BASE / 1000) | ||
| 22 | #endif | ||
| 17 | 23 | ||
| 18 | #define DVD_PLAYSPEED_PAUSE 0 // frame stepping | 24 | #define DVD_PLAYSPEED_PAUSE 0 // frame stepping |
| 19 | #define DVD_PLAYSPEED_NORMAL 1000 | 25 | #define DVD_PLAYSPEED_NORMAL 1000 |
diff --git a/xbmc/input/XBMC_vkeys.h b/xbmc/input/XBMC_vkeys.h index 496f336..833d2da 100644 --- a/xbmc/input/XBMC_vkeys.h +++ b/xbmc/input/XBMC_vkeys.h | |||
| @@ -18,256 +18,256 @@ | |||
| 18 | // Non-printing keypresses get a value in the range 0x80 - 0xFF. | 18 | // Non-printing keypresses get a value in the range 0x80 - 0xFF. |
| 19 | // Note that the vkey is a byte value so it cannot be greater than 0xFF. | 19 | // Note that the vkey is a byte value so it cannot be greater than 0xFF. |
| 20 | 20 | ||
| 21 | typedef enum { | 21 | typedef enum |
| 22 | XBMCVK_BACK = 0x08, | 22 | { |
| 23 | XBMCVK_TAB = 0x09, | 23 | XBMCVK_BACK = 0x08, |
| 24 | XBMCVK_RETURN = 0x0D, | 24 | XBMCVK_TAB = 0x09, |
| 25 | XBMCVK_ESCAPE = 0x1B, | 25 | XBMCVK_RETURN = 0x0D, |
| 26 | XBMCVK_ESCAPE = 0x1B, | ||
| 26 | 27 | ||
| 27 | XBMCVK_SPACE = 0x20, | 28 | XBMCVK_SPACE = 0x20, |
| 28 | XBMCVK_EXCLAIM = 0x21, | 29 | XBMCVK_EXCLAIM = 0x21, |
| 29 | XBMCVK_QUOTEDBL = 0x22, | 30 | XBMCVK_QUOTEDBL = 0x22, |
| 30 | XBMCVK_HASH = 0x23, | 31 | XBMCVK_HASH = 0x23, |
| 31 | XBMCVK_DOLLAR = 0x24, | 32 | XBMCVK_DOLLAR = 0x24, |
| 32 | XBMCVK_PERCENT = 0x25, | 33 | XBMCVK_PERCENT = 0x25, |
| 33 | XBMCVK_AMPERSAND = 0x26, | 34 | XBMCVK_AMPERSAND = 0x26, |
| 34 | XBMCVK_QUOTE = 0x27, | 35 | XBMCVK_QUOTE = 0x27, |
| 35 | XBMCVK_LEFTPAREN = 0x28, | 36 | XBMCVK_LEFTPAREN = 0x28, |
| 36 | XBMCVK_RIGHTPAREN = 0x29, | 37 | XBMCVK_RIGHTPAREN = 0x29, |
| 37 | XBMCVK_ASTERISK = 0x2A, | 38 | XBMCVK_ASTERISK = 0x2A, |
| 38 | XBMCVK_PLUS = 0x2B, | 39 | XBMCVK_PLUS = 0x2B, |
| 39 | XBMCVK_COMMA = 0x2C, | 40 | XBMCVK_COMMA = 0x2C, |
| 40 | XBMCVK_MINUS = 0x2D, | 41 | XBMCVK_MINUS = 0x2D, |
| 41 | XBMCVK_PERIOD = 0x2E, | 42 | XBMCVK_PERIOD = 0x2E, |
| 42 | XBMCVK_SLASH = 0x2F, | 43 | XBMCVK_SLASH = 0x2F, |
| 43 | 44 | ||
| 44 | XBMCVK_0 = 0x30, | 45 | XBMCVK_0 = 0x30, |
| 45 | XBMCVK_1 = 0x31, | 46 | XBMCVK_1 = 0x31, |
| 46 | XBMCVK_2 = 0x32, | 47 | XBMCVK_2 = 0x32, |
| 47 | XBMCVK_3 = 0x33, | 48 | XBMCVK_3 = 0x33, |
| 48 | XBMCVK_4 = 0x34, | 49 | XBMCVK_4 = 0x34, |
| 49 | XBMCVK_5 = 0x35, | 50 | XBMCVK_5 = 0x35, |
| 50 | XBMCVK_6 = 0x36, | 51 | XBMCVK_6 = 0x36, |
| 51 | XBMCVK_7 = 0x37, | 52 | XBMCVK_7 = 0x37, |
| 52 | XBMCVK_8 = 0x38, | 53 | XBMCVK_8 = 0x38, |
| 53 | XBMCVK_9 = 0x39, | 54 | XBMCVK_9 = 0x39, |
| 54 | 55 | ||
| 55 | XBMCVK_COLON = 0x3A, | 56 | XBMCVK_COLON = 0x3A, |
| 56 | XBMCVK_SEMICOLON = 0x3B, | 57 | XBMCVK_SEMICOLON = 0x3B, |
| 57 | XBMCVK_LESS = 0x3C, | 58 | XBMCVK_LESS = 0x3C, |
| 58 | XBMCVK_EQUALS = 0x3D, | 59 | XBMCVK_EQUALS = 0x3D, |
| 59 | XBMCVK_GREATER = 0x3E, | 60 | XBMCVK_GREATER = 0x3E, |
| 60 | XBMCVK_QUESTION = 0x3F, | 61 | XBMCVK_QUESTION = 0x3F, |
| 61 | XBMCVK_AT = 0x40, | 62 | XBMCVK_AT = 0x40, |
| 62 | 63 | ||
| 63 | XBMCVK_A = 0x41, | 64 | XBMCVK_A = 0x41, |
| 64 | XBMCVK_B = 0x42, | 65 | XBMCVK_B = 0x42, |
| 65 | XBMCVK_C = 0x43, | 66 | XBMCVK_C = 0x43, |
| 66 | XBMCVK_D = 0x44, | 67 | XBMCVK_D = 0x44, |
| 67 | XBMCVK_E = 0x45, | 68 | XBMCVK_E = 0x45, |
| 68 | XBMCVK_F = 0x46, | 69 | XBMCVK_F = 0x46, |
| 69 | XBMCVK_G = 0x47, | 70 | XBMCVK_G = 0x47, |
| 70 | XBMCVK_H = 0x48, | 71 | XBMCVK_H = 0x48, |
| 71 | XBMCVK_I = 0x49, | 72 | XBMCVK_I = 0x49, |
| 72 | XBMCVK_J = 0x4A, | 73 | XBMCVK_J = 0x4A, |
| 73 | XBMCVK_K = 0x4B, | 74 | XBMCVK_K = 0x4B, |
| 74 | XBMCVK_L = 0x4C, | 75 | XBMCVK_L = 0x4C, |
| 75 | XBMCVK_M = 0x4D, | 76 | XBMCVK_M = 0x4D, |
| 76 | XBMCVK_N = 0x4E, | 77 | XBMCVK_N = 0x4E, |
| 77 | XBMCVK_O = 0x4F, | 78 | XBMCVK_O = 0x4F, |
| 78 | XBMCVK_P = 0x50, | 79 | XBMCVK_P = 0x50, |
| 79 | XBMCVK_Q = 0x51, | 80 | XBMCVK_Q = 0x51, |
| 80 | XBMCVK_R = 0x52, | 81 | XBMCVK_R = 0x52, |
| 81 | XBMCVK_S = 0x53, | 82 | XBMCVK_S = 0x53, |
| 82 | XBMCVK_T = 0x54, | 83 | XBMCVK_T = 0x54, |
| 83 | XBMCVK_U = 0x55, | 84 | XBMCVK_U = 0x55, |
| 84 | XBMCVK_V = 0x56, | 85 | XBMCVK_V = 0x56, |
| 85 | XBMCVK_W = 0x57, | 86 | XBMCVK_W = 0x57, |
| 86 | XBMCVK_X = 0x58, | 87 | XBMCVK_X = 0x58, |
| 87 | XBMCVK_Y = 0x59, | 88 | XBMCVK_Y = 0x59, |
| 88 | XBMCVK_Z = 0x5A, | 89 | XBMCVK_Z = 0x5A, |
| 89 | 90 | ||
| 90 | XBMCVK_LEFTBRACKET = 0x5B, | 91 | XBMCVK_LEFTBRACKET = 0x5B, |
| 91 | XBMCVK_BACKSLASH = 0x5C, | 92 | XBMCVK_BACKSLASH = 0x5C, |
| 92 | XBMCVK_RIGHTBRACKET = 0x5D, | 93 | XBMCVK_RIGHTBRACKET = 0x5D, |
| 93 | XBMCVK_CARET = 0x5E, | 94 | XBMCVK_CARET = 0x5E, |
| 94 | XBMCVK_UNDERSCORE = 0x5F, | 95 | XBMCVK_UNDERSCORE = 0x5F, |
| 95 | XBMCVK_BACKQUOTE = 0x60, | 96 | XBMCVK_BACKQUOTE = 0x60, |
| 96 | 97 | ||
| 97 | // Lowercase letters 0x61 - 0x7a have the same vkey as uppercase, so | 98 | // Lowercase letters 0x61 - 0x7a have the same vkey as uppercase, so |
| 98 | // use this block for the numpad keys | 99 | // use this block for the numpad keys |
| 99 | XBMCVK_NUMPADDIVIDE = 0x61, | 100 | XBMCVK_NUMPADDIVIDE = 0x61, |
| 100 | XBMCVK_NUMPADTIMES = 0x62, | 101 | XBMCVK_NUMPADTIMES = 0x62, |
| 101 | XBMCVK_NUMPADMINUS = 0x63, | 102 | XBMCVK_NUMPADMINUS = 0x63, |
| 102 | XBMCVK_NUMPADPLUS = 0x64, | 103 | XBMCVK_NUMPADPLUS = 0x64, |
| 103 | XBMCVK_NUMPADENTER = 0x65, | 104 | XBMCVK_NUMPADENTER = 0x65, |
| 104 | XBMCVK_NUMPADPERIOD = 0x66, | 105 | XBMCVK_NUMPADPERIOD = 0x66, |
| 105 | XBMCVK_NUMPAD0 = 0x70, | 106 | XBMCVK_NUMPAD0 = 0x70, |
| 106 | XBMCVK_NUMPAD1 = 0x71, | 107 | XBMCVK_NUMPAD1 = 0x71, |
| 107 | XBMCVK_NUMPAD2 = 0x72, | 108 | XBMCVK_NUMPAD2 = 0x72, |
| 108 | XBMCVK_NUMPAD3 = 0x73, | 109 | XBMCVK_NUMPAD3 = 0x73, |
| 109 | XBMCVK_NUMPAD4 = 0x74, | 110 | XBMCVK_NUMPAD4 = 0x74, |
| 110 | XBMCVK_NUMPAD5 = 0x75, | 111 | XBMCVK_NUMPAD5 = 0x75, |
| 111 | XBMCVK_NUMPAD6 = 0x76, | 112 | XBMCVK_NUMPAD6 = 0x76, |
| 112 | XBMCVK_NUMPAD7 = 0x77, | 113 | XBMCVK_NUMPAD7 = 0x77, |
| 113 | XBMCVK_NUMPAD8 = 0x78, | 114 | XBMCVK_NUMPAD8 = 0x78, |
| 114 | XBMCVK_NUMPAD9 = 0x79, | 115 | XBMCVK_NUMPAD9 = 0x79, |
| 115 | 116 | ||
| 116 | XBMCVK_LEFTBRACE = 0x7B, | 117 | XBMCVK_LEFTBRACE = 0x7B, |
| 117 | XBMCVK_PIPE = 0x7C, | 118 | XBMCVK_PIPE = 0x7C, |
| 118 | XBMCVK_RIGHTBRACE = 0x7D, | 119 | XBMCVK_RIGHTBRACE = 0x7D, |
| 119 | XBMCVK_TILDE = 0x7E, | 120 | XBMCVK_TILDE = 0x7E, |
| 120 | 121 | ||
| 121 | // Non-printing characters | 122 | // Non-printing characters |
| 122 | 123 | ||
| 123 | XBMCVK_UP = 0x80, | 124 | XBMCVK_UP = 0x80, |
| 124 | XBMCVK_DOWN = 0x81, | 125 | XBMCVK_DOWN = 0x81, |
| 125 | XBMCVK_LEFT = 0x82, | 126 | XBMCVK_LEFT = 0x82, |
| 126 | XBMCVK_RIGHT = 0x83, | 127 | XBMCVK_RIGHT = 0x83, |
| 127 | XBMCVK_PAGEUP = 0x84, | 128 | XBMCVK_PAGEUP = 0x84, |
| 128 | XBMCVK_PAGEDOWN = 0x85, | 129 | XBMCVK_PAGEDOWN = 0x85, |
| 129 | XBMCVK_INSERT = 0x86, | 130 | XBMCVK_INSERT = 0x86, |
| 130 | XBMCVK_DELETE = 0x87, | 131 | XBMCVK_DELETE = 0x87, |
| 131 | XBMCVK_HOME = 0x88, | 132 | XBMCVK_HOME = 0x88, |
| 132 | XBMCVK_END = 0x89, | 133 | XBMCVK_END = 0x89, |
| 133 | 134 | ||
| 134 | XBMCVK_F1 = 0x90, | 135 | XBMCVK_F1 = 0x90, |
| 135 | XBMCVK_F2 = 0x91, | 136 | XBMCVK_F2 = 0x91, |
| 136 | XBMCVK_F3 = 0x92, | 137 | XBMCVK_F3 = 0x92, |
| 137 | XBMCVK_F4 = 0x93, | 138 | XBMCVK_F4 = 0x93, |
| 138 | XBMCVK_F5 = 0x94, | 139 | XBMCVK_F5 = 0x94, |
| 139 | XBMCVK_F6 = 0x95, | 140 | XBMCVK_F6 = 0x95, |
| 140 | XBMCVK_F7 = 0x96, | 141 | XBMCVK_F7 = 0x96, |
| 141 | XBMCVK_F8 = 0x97, | 142 | XBMCVK_F8 = 0x97, |
| 142 | XBMCVK_F9 = 0x98, | 143 | XBMCVK_F9 = 0x98, |
| 143 | XBMCVK_F10 = 0x99, | 144 | XBMCVK_F10 = 0x99, |
| 144 | XBMCVK_F11 = 0x9A, | 145 | XBMCVK_F11 = 0x9A, |
| 145 | XBMCVK_F12 = 0x9B, | 146 | XBMCVK_F12 = 0x9B, |
| 146 | XBMCVK_F13 = 0x9C, | 147 | XBMCVK_F13 = 0x9C, |
| 147 | XBMCVK_F14 = 0x9D, | 148 | XBMCVK_F14 = 0x9D, |
| 148 | XBMCVK_F15 = 0x9E, | 149 | XBMCVK_F15 = 0x9E, |
| 149 | XBMCVK_F16 = 0x9F, | 150 | XBMCVK_F16 = 0x9F, |
| 150 | XBMCVK_F17 = 0xA0, | 151 | XBMCVK_F17 = 0xA0, |
| 151 | XBMCVK_F18 = 0xA1, | 152 | XBMCVK_F18 = 0xA1, |
| 152 | XBMCVK_F19 = 0xA2, | 153 | XBMCVK_F19 = 0xA2, |
| 153 | XBMCVK_F20 = 0xA3, | 154 | XBMCVK_F20 = 0xA3, |
| 154 | XBMCVK_F21 = 0xA4, | 155 | XBMCVK_F21 = 0xA4, |
| 155 | XBMCVK_F22 = 0xA5, | 156 | XBMCVK_F22 = 0xA5, |
| 156 | XBMCVK_F23 = 0xA6, | 157 | XBMCVK_F23 = 0xA6, |
| 157 | XBMCVK_F24 = 0xA7, | 158 | XBMCVK_F24 = 0xA7, |
| 158 | 159 | ||
| 159 | XBMCVK_BROWSER_BACK = 0xB0, | 160 | XBMCVK_BROWSER_BACK = 0xB0, |
| 160 | XBMCVK_BROWSER_FORWARD = 0xB1, | 161 | XBMCVK_BROWSER_FORWARD = 0xB1, |
| 161 | XBMCVK_BROWSER_REFRESH = 0xB2, | 162 | XBMCVK_BROWSER_REFRESH = 0xB2, |
| 162 | XBMCVK_BROWSER_STOP = 0xB3, | 163 | XBMCVK_BROWSER_STOP = 0xB3, |
| 163 | XBMCVK_BROWSER_SEARCH = 0xB4, | 164 | XBMCVK_BROWSER_SEARCH = 0xB4, |
| 164 | XBMCVK_BROWSER_FAVORITES = 0xB5, | 165 | XBMCVK_BROWSER_FAVORITES = 0xB5, |
| 165 | XBMCVK_BROWSER_HOME = 0xB6, | 166 | XBMCVK_BROWSER_HOME = 0xB6, |
| 166 | XBMCVK_VOLUME_MUTE = 0xB7, | 167 | XBMCVK_VOLUME_MUTE = 0xB7, |
| 167 | XBMCVK_VOLUME_DOWN = 0xB8, | 168 | XBMCVK_VOLUME_DOWN = 0xB8, |
| 168 | XBMCVK_VOLUME_UP = 0xB9, | 169 | XBMCVK_VOLUME_UP = 0xB9, |
| 169 | XBMCVK_MEDIA_NEXT_TRACK = 0xBA, | 170 | XBMCVK_MEDIA_NEXT_TRACK = 0xBA, |
| 170 | XBMCVK_MEDIA_PREV_TRACK = 0xBB, | 171 | XBMCVK_MEDIA_PREV_TRACK = 0xBB, |
| 171 | XBMCVK_MEDIA_STOP = 0xBC, | 172 | XBMCVK_MEDIA_STOP = 0xBC, |
| 172 | XBMCVK_MEDIA_PLAY_PAUSE = 0xBD, | 173 | XBMCVK_MEDIA_PLAY_PAUSE = 0xBD, |
| 173 | XBMCVK_LAUNCH_MAIL = 0xBE, | 174 | XBMCVK_LAUNCH_MAIL = 0xBE, |
| 174 | XBMCVK_LAUNCH_MEDIA_SELECT = 0xBF, | 175 | XBMCVK_LAUNCH_MEDIA_SELECT = 0xBF, |
| 175 | XBMCVK_LAUNCH_APP1 = 0xC0, | 176 | XBMCVK_LAUNCH_APP1 = 0xC0, |
| 176 | XBMCVK_LAUNCH_APP2 = 0xC1, | 177 | XBMCVK_LAUNCH_APP2 = 0xC1, |
| 177 | XBMCVK_LAUNCH_FILE_BROWSER = 0xC2, | 178 | XBMCVK_LAUNCH_FILE_BROWSER = 0xC2, |
| 178 | XBMCVK_LAUNCH_MEDIA_CENTER = 0xC3, | 179 | XBMCVK_LAUNCH_MEDIA_CENTER = 0xC3, |
| 179 | XBMCVK_MEDIA_REWIND = 0xC4, | 180 | XBMCVK_MEDIA_REWIND = 0xC4, |
| 180 | XBMCVK_MEDIA_FASTFORWARD = 0xC5, | 181 | XBMCVK_MEDIA_FASTFORWARD = 0xC5, |
| 181 | XBMCVK_MEDIA_RECORD = 0xC6, | 182 | XBMCVK_MEDIA_RECORD = 0xC6, |
| 182 | 183 | ||
| 183 | XBMCVK_LCONTROL = 0xD0, | 184 | XBMCVK_LCONTROL = 0xD0, |
| 184 | XBMCVK_RCONTROL = 0xD1, | 185 | XBMCVK_RCONTROL = 0xD1, |
| 185 | XBMCVK_LSHIFT = 0xD2, | 186 | XBMCVK_LSHIFT = 0xD2, |
| 186 | XBMCVK_RSHIFT = 0xD3, | 187 | XBMCVK_RSHIFT = 0xD3, |
| 187 | XBMCVK_LMENU = 0xD4, | 188 | XBMCVK_LMENU = 0xD4, |
| 188 | XBMCVK_RMENU = 0xD5, | 189 | XBMCVK_RMENU = 0xD5, |
| 189 | XBMCVK_LWIN = 0xD6, | 190 | XBMCVK_LWIN = 0xD6, |
| 190 | XBMCVK_RWIN = 0xD7, | 191 | XBMCVK_RWIN = 0xD7, |
| 191 | XBMCVK_MENU = 0xD8, | 192 | XBMCVK_MENU = 0xD8, |
| 192 | XBMCVK_CAPSLOCK = 0xD9, | 193 | XBMCVK_CAPSLOCK = 0xD9, |
| 193 | XBMCVK_NUMLOCK = 0xDA, | 194 | XBMCVK_NUMLOCK = 0xDA, |
| 194 | 195 | ||
| 195 | XBMCVK_PRINTSCREEN = 0xDB, | 196 | XBMCVK_PRINTSCREEN = 0xDB, |
| 196 | XBMCVK_SCROLLLOCK = 0xDC, | 197 | XBMCVK_SCROLLLOCK = 0xDC, |
| 197 | XBMCVK_PAUSE = 0XDD, | 198 | XBMCVK_PAUSE = 0XDD, |
| 198 | XBMCVK_POWER = 0XDE, | 199 | XBMCVK_POWER = 0XDE, |
| 199 | XBMCVK_SLEEP = 0XDF, | 200 | XBMCVK_SLEEP = 0XDF, |
| 200 | XBMCVK_GUIDE = 0xE0, | 201 | XBMCVK_GUIDE = 0xE0, |
| 201 | XBMCVK_SETTINGS = 0xE1, | 202 | XBMCVK_SETTINGS = 0xE1, |
| 202 | XBMCVK_INFO = 0xE2, | 203 | XBMCVK_INFO = 0xE2, |
| 203 | XBMCVK_RED = 0xE3, | 204 | XBMCVK_RED = 0xE3, |
| 204 | XBMCVK_GREEN = 0xE4, | 205 | XBMCVK_GREEN = 0xE4, |
| 205 | XBMCVK_YELLOW = 0xE5, | 206 | XBMCVK_YELLOW = 0xE5, |
| 206 | XBMCVK_BLUE = 0xE6, | 207 | XBMCVK_BLUE = 0xE6, |
| 207 | XBMCVK_ZOOM = 0xE7, | 208 | XBMCVK_ZOOM = 0xE7, |
| 208 | XBMCVK_TEXT = 0xE8, | 209 | XBMCVK_TEXT = 0xE8, |
| 209 | XBMCVK_FAVORITES = 0xE9, | 210 | XBMCVK_FAVORITES = 0xE9, |
| 210 | XBMCVK_HOMEPAGE = 0xEA, | 211 | XBMCVK_HOMEPAGE = 0xEA, |
| 211 | XBMCVK_CONFIG = 0xEB, | 212 | XBMCVK_CONFIG = 0xEB, |
| 212 | XBMCVK_EPG = 0xEC, | 213 | XBMCVK_EPG = 0xEC, |
| 213 | 214 | ||
| 214 | XBMCVK_LAST = 0xFF | 215 | XBMCVK_LAST = 0xFF |
| 215 | } XBMCVKey; | 216 | } XBMCVKey; |
| 216 | 217 | ||
| 217 | // These should be in winuser.h. Not sure why they have been defined here | 218 | // These should be in winuser.h. Not sure why they have been defined here |
| 218 | #ifndef VK_0 | 219 | #ifndef VK_0 |
| 219 | #define VK_0 '0' | 220 | #define VK_0 '0' |
| 220 | #define VK_1 '1' | 221 | #define VK_1 '1' |
| 221 | #define VK_2 '2' | 222 | #define VK_2 '2' |
| 222 | #define VK_3 '3' | 223 | #define VK_3 '3' |
| 223 | #define VK_4 '4' | 224 | #define VK_4 '4' |
| 224 | #define VK_5 '5' | 225 | #define VK_5 '5' |
| 225 | #define VK_6 '6' | 226 | #define VK_6 '6' |
| 226 | #define VK_7 '7' | 227 | #define VK_7 '7' |
| 227 | #define VK_8 '8' | 228 | #define VK_8 '8' |
| 228 | #define VK_9 '9' | 229 | #define VK_9 '9' |
| 229 | #define VK_A 'A' | 230 | #define VK_A 'A' |
| 230 | #define VK_B 'B' | 231 | #define VK_B 'B' |
| 231 | #define VK_C 'C' | 232 | #define VK_C 'C' |
| 232 | #define VK_D 'D' | 233 | #define VK_D 'D' |
| 233 | #define VK_E 'E' | 234 | #define VK_E 'E' |
| 234 | #define VK_F 'F' | 235 | #define VK_F 'F' |
| 235 | #define VK_G 'G' | 236 | #define VK_G 'G' |
| 236 | #define VK_H 'H' | 237 | #define VK_H 'H' |
| 237 | #define VK_I 'I' | 238 | #define VK_I 'I' |
| 238 | #define VK_J 'J' | 239 | #define VK_J 'J' |
| 239 | #define VK_K 'K' | 240 | #define VK_K 'K' |
| 240 | #define VK_L 'L' | 241 | #define VK_L 'L' |
| 241 | #define VK_M 'M' | 242 | #define VK_M 'M' |
| 242 | #define VK_N 'N' | 243 | #define VK_N 'N' |
| 243 | #define VK_O 'O' | 244 | #define VK_O 'O' |
| 244 | #define VK_P 'P' | 245 | #define VK_P 'P' |
| 245 | #define VK_Q 'Q' | 246 | #define VK_Q 'Q' |
| 246 | #define VK_R 'R' | 247 | #define VK_R 'R' |
| 247 | #define VK_S 'S' | 248 | #define VK_S 'S' |
| 248 | #define VK_T 'T' | 249 | #define VK_T 'T' |
| 249 | #define VK_U 'U' | 250 | #define VK_U 'U' |
| 250 | #define VK_V 'V' | 251 | #define VK_V 'V' |
| 251 | #define VK_W 'W' | 252 | #define VK_W 'W' |
| 252 | #define VK_X 'X' | 253 | #define VK_X 'X' |
| 253 | #define VK_Y 'Y' | 254 | #define VK_Y 'Y' |
| 254 | #define VK_Z 'Z' | 255 | #define VK_Z 'Z' |
| 255 | #endif /* VK_0 */ | 256 | #endif /* VK_0 */ |
| 256 | 257 | ||
| 257 | /* These keys haven't been defined, but were experimentally determined */ | 258 | /* These keys haven't been defined, but were experimentally determined */ |
| 258 | #ifndef VK_SEMICOLON | 259 | #ifndef VK_SEMICOLON |
| 259 | #define VK_SEMICOLON 0xBA | 260 | #define VK_SEMICOLON 0xBA |
| 260 | #define VK_EQUALS 0xBB | 261 | #define VK_EQUALS 0xBB |
| 261 | #define VK_COMMA 0xBC | 262 | #define VK_COMMA 0xBC |
| 262 | #define VK_MINUS 0xBD | 263 | #define VK_MINUS 0xBD |
| 263 | #define VK_PERIOD 0xBE | 264 | #define VK_PERIOD 0xBE |
| 264 | #define VK_SLASH 0xBF | 265 | #define VK_SLASH 0xBF |
| 265 | #define VK_GRAVE 0xC0 | 266 | #define VK_GRAVE 0xC0 |
| 266 | #define VK_LBRACKET 0xDB | 267 | #define VK_LBRACKET 0xDB |
| 267 | #define VK_BACKSLASH 0xDC | 268 | #define VK_BACKSLASH 0xDC |
| 268 | #define VK_RBRACKET 0xDD | 269 | #define VK_RBRACKET 0xDD |
| 269 | #define VK_APOSTROPHE 0xDE | 270 | #define VK_APOSTROPHE 0xDE |
| 270 | #define VK_BACKTICK 0xDF | 271 | #define VK_BACKTICK 0xDF |
| 271 | #define VK_OEM_102 0xE2 | 272 | #define VK_OEM_102 0xE2 |
| 272 | #endif | 273 | #endif |
| 273 | |||
diff --git a/xbmc/input/actions/ActionIDs.h b/xbmc/input/actions/ActionIDs.h index 9fd9d80..760228d 100644 --- a/xbmc/input/actions/ActionIDs.h +++ b/xbmc/input/actions/ActionIDs.h | |||
| @@ -15,298 +15,369 @@ | |||
| 15 | * @{ | 15 | * @{ |
| 16 | * @brief Actions that we have defined. | 16 | * @brief Actions that we have defined. |
| 17 | */ | 17 | */ |
| 18 | #define ACTION_NONE 0 | 18 | #define ACTION_NONE 0 |
| 19 | #define ACTION_MOVE_LEFT 1 | 19 | #define ACTION_MOVE_LEFT 1 |
| 20 | #define ACTION_MOVE_RIGHT 2 | 20 | #define ACTION_MOVE_RIGHT 2 |
| 21 | #define ACTION_MOVE_UP 3 | 21 | #define ACTION_MOVE_UP 3 |
| 22 | #define ACTION_MOVE_DOWN 4 | 22 | #define ACTION_MOVE_DOWN 4 |
| 23 | #define ACTION_PAGE_UP 5 | 23 | #define ACTION_PAGE_UP 5 |
| 24 | #define ACTION_PAGE_DOWN 6 | 24 | #define ACTION_PAGE_DOWN 6 |
| 25 | #define ACTION_SELECT_ITEM 7 | 25 | #define ACTION_SELECT_ITEM 7 |
| 26 | #define ACTION_HIGHLIGHT_ITEM 8 | 26 | #define ACTION_HIGHLIGHT_ITEM 8 |
| 27 | #define ACTION_PARENT_DIR 9 | 27 | #define ACTION_PARENT_DIR 9 |
| 28 | #define ACTION_PREVIOUS_MENU 10 | 28 | #define ACTION_PREVIOUS_MENU 10 |
| 29 | #define ACTION_SHOW_INFO 11 | 29 | #define ACTION_SHOW_INFO 11 |
| 30 | 30 | ||
| 31 | #define ACTION_PAUSE 12 | 31 | #define ACTION_PAUSE 12 |
| 32 | #define ACTION_STOP 13 | 32 | #define ACTION_STOP 13 |
| 33 | #define ACTION_NEXT_ITEM 14 | 33 | #define ACTION_NEXT_ITEM 14 |
| 34 | #define ACTION_PREV_ITEM 15 | 34 | #define ACTION_PREV_ITEM 15 |
| 35 | #define ACTION_FORWARD 16 //!< Can be used to specify specific action in a window, Playback control is handled in ACTION_PLAYER_* | 35 | #define ACTION_FORWARD \ |
| 36 | #define ACTION_REWIND 17 //!< Can be used to specify specific action in a window, Playback control is handled in ACTION_PLAYER_* | 36 | 16 //!< Can be used to specify specific action in a window, Playback control is handled in |
| 37 | 37 | //!< ACTION_PLAYER_* | |
| 38 | #define ACTION_SHOW_GUI 18 //!< toggle between GUI and movie or GUI and visualisation. | 38 | #define ACTION_REWIND \ |
| 39 | #define ACTION_ASPECT_RATIO 19 //!< toggle quick-access zoom modes. Can b used in videoFullScreen.zml window id=2005 | 39 | 17 //!< Can be used to specify specific action in a window, Playback control is handled in |
| 40 | #define ACTION_STEP_FORWARD 20 //!< seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005 | 40 | //!< ACTION_PLAYER_* |
| 41 | #define ACTION_STEP_BACK 21 //!< seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005 | 41 | |
| 42 | #define ACTION_BIG_STEP_FORWARD 22 //!< seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005 | 42 | #define ACTION_SHOW_GUI 18 //!< toggle between GUI and movie or GUI and visualisation. |
| 43 | #define ACTION_BIG_STEP_BACK 23 //!< seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005 | 43 | #define ACTION_ASPECT_RATIO \ |
| 44 | #define ACTION_SHOW_OSD 24 //!< show/hide OSD. Can b used in videoFullScreen.xml window id=2005 | 44 | 19 //!< toggle quick-access zoom modes. Can b used in videoFullScreen.zml window id=2005 |
| 45 | #define ACTION_SHOW_SUBTITLES 25 //!< turn subtitles on/off. Can b used in videoFullScreen.xml window id=2005 | 45 | #define ACTION_STEP_FORWARD \ |
| 46 | #define ACTION_NEXT_SUBTITLE 26 //!< switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005 | 46 | 20 //!< seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005 |
| 47 | #define ACTION_BROWSE_SUBTITLE 247 //!< Browse for subtitle. Can be used in videofullscreen | 47 | #define ACTION_STEP_BACK \ |
| 48 | #define ACTION_PLAYER_DEBUG 27 //!< show debug info for VideoPlayer | 48 | 21 //!< seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005 |
| 49 | #define ACTION_NEXT_PICTURE 28 //!< show next picture of slideshow. Can b used in slideshow.xml window id=2007 | 49 | #define ACTION_BIG_STEP_FORWARD \ |
| 50 | #define ACTION_PREV_PICTURE 29 //!< show previous picture of slideshow. Can b used in slideshow.xml window id=2007 | 50 | 22 //!< seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005 |
| 51 | #define ACTION_ZOOM_OUT 30 //!< zoom in picture during slideshow. Can b used in slideshow.xml window id=2007 | 51 | #define ACTION_BIG_STEP_BACK \ |
| 52 | #define ACTION_ZOOM_IN 31 //!< zoom out picture during slideshow. Can b used in slideshow.xml window id=2007 | 52 | 23 //!< seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005 |
| 53 | #define ACTION_TOGGLE_SOURCE_DEST 32 //!< used to toggle between source view and destination view. Can be used in myfiles.xml window id=3 | 53 | #define ACTION_SHOW_OSD 24 //!< show/hide OSD. Can b used in videoFullScreen.xml window id=2005 |
| 54 | #define ACTION_SHOW_PLAYLIST 33 //!< used to toggle between current view and playlist view. Can b used in all mymusic xml files | 54 | #define ACTION_SHOW_SUBTITLES \ |
| 55 | #define ACTION_QUEUE_ITEM 34 //!< used to queue a item to the playlist. Can b used in all mymusic xml files | 55 | 25 //!< turn subtitles on/off. Can b used in videoFullScreen.xml window id=2005 |
| 56 | #define ACTION_REMOVE_ITEM 35 //!< not used anymore | 56 | #define ACTION_NEXT_SUBTITLE \ |
| 57 | #define ACTION_SHOW_FULLSCREEN 36 //!< not used anymore | 57 | 26 //!< switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005 |
| 58 | #define ACTION_ZOOM_LEVEL_NORMAL 37 //!< zoom 1x picture during slideshow. Can b used in slideshow.xml window id=2007 | 58 | #define ACTION_BROWSE_SUBTITLE 247 //!< Browse for subtitle. Can be used in videofullscreen |
| 59 | #define ACTION_ZOOM_LEVEL_1 38 //!< zoom 2x picture during slideshow. Can b used in slideshow.xml window id=2007 | 59 | #define ACTION_PLAYER_DEBUG 27 //!< show debug info for VideoPlayer |
| 60 | #define ACTION_ZOOM_LEVEL_2 39 //!< zoom 3x picture during slideshow. Can b used in slideshow.xml window id=2007 | 60 | #define ACTION_NEXT_PICTURE \ |
| 61 | #define ACTION_ZOOM_LEVEL_3 40 //!< zoom 4x picture during slideshow. Can b used in slideshow.xml window id=2007 | 61 | 28 //!< show next picture of slideshow. Can b used in slideshow.xml window id=2007 |
| 62 | #define ACTION_ZOOM_LEVEL_4 41 //!< zoom 5x picture during slideshow. Can b used in slideshow.xml window id=2007 | 62 | #define ACTION_PREV_PICTURE \ |
| 63 | #define ACTION_ZOOM_LEVEL_5 42 //!< zoom 6x picture during slideshow. Can b used in slideshow.xml window id=2007 | 63 | 29 //!< show previous picture of slideshow. Can b used in slideshow.xml window id=2007 |
| 64 | #define ACTION_ZOOM_LEVEL_6 43 //!< zoom 7x picture during slideshow. Can b used in slideshow.xml window id=2007 | 64 | #define ACTION_ZOOM_OUT \ |
| 65 | #define ACTION_ZOOM_LEVEL_7 44 //!< zoom 8x picture during slideshow. Can b used in slideshow.xml window id=2007 | 65 | 30 //!< zoom in picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 66 | #define ACTION_ZOOM_LEVEL_8 45 //!< zoom 9x picture during slideshow. Can b used in slideshow.xml window id=2007 | 66 | #define ACTION_ZOOM_IN \ |
| 67 | #define ACTION_ZOOM_LEVEL_9 46 //!< zoom 10x picture during slideshow. Can b used in slideshow.xml window id=2007 | 67 | 31 //!< zoom out picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 68 | 68 | #define ACTION_TOGGLE_SOURCE_DEST \ | |
| 69 | #define ACTION_CALIBRATE_SWAP_ARROWS 47 //!< select next arrow. Can b used in: settingsScreenCalibration.xml windowid=11 | 69 | 32 //!< used to toggle between source view and destination view. Can be used in myfiles.xml window |
| 70 | #define ACTION_CALIBRATE_RESET 48 //!< reset calibration to defaults. Can b used in: `settingsScreenCalibration.xml` windowid=11/settingsUICalibration.xml windowid=10 | 70 | //!< id=3 |
| 71 | #define ACTION_ANALOG_MOVE 49 //!< analog thumbstick move. Can b used in: `slideshow.xml` windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml windowid=10 | 71 | #define ACTION_SHOW_PLAYLIST \ |
| 72 | //!< @note see also ACTION_ANALOG_MOVE_X_LEFT, ACTION_ANALOG_MOVE_X_RIGHT, ACTION_ANALOG_MOVE_Y_UP, ACTION_ANALOG_MOVE_Y_DOWN | 72 | 33 //!< used to toggle between current view and playlist view. Can b used in all mymusic xml files |
| 73 | #define ACTION_ROTATE_PICTURE_CW 50 //!< rotate current picture clockwise during slideshow. Can be used in slideshow.xml window id=2007 | 73 | #define ACTION_QUEUE_ITEM \ |
| 74 | #define ACTION_ROTATE_PICTURE_CCW 51 //!< rotate current picture counterclockwise during slideshow. Can be used in slideshow.xml window id=2007 | 74 | 34 //!< used to queue a item to the playlist. Can b used in all mymusic xml files |
| 75 | 75 | #define ACTION_REMOVE_ITEM 35 //!< not used anymore | |
| 76 | #define ACTION_SUBTITLE_DELAY_MIN 52 //!< Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 | 76 | #define ACTION_SHOW_FULLSCREEN 36 //!< not used anymore |
| 77 | #define ACTION_SUBTITLE_DELAY_PLUS 53 //!< Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 | 77 | #define ACTION_ZOOM_LEVEL_NORMAL \ |
| 78 | #define ACTION_AUDIO_DELAY_MIN 54 //!< Increase avsync delay. Can b used in videoFullScreen.xml window id=2005 | 78 | 37 //!< zoom 1x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 79 | #define ACTION_AUDIO_DELAY_PLUS 55 //!< Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005 | 79 | #define ACTION_ZOOM_LEVEL_1 \ |
| 80 | #define ACTION_AUDIO_NEXT_LANGUAGE 56 //!< Select next language in movie. Can b used in videoFullScreen.xml window id=2005 | 80 | 38 //!< zoom 2x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 81 | #define ACTION_CHANGE_RESOLUTION 57 //!< switch 2 next resolution. Can b used during screen calibration settingsScreenCalibration.xml windowid=11 | 81 | #define ACTION_ZOOM_LEVEL_2 \ |
| 82 | 82 | 39 //!< zoom 3x picture during slideshow. Can b used in slideshow.xml window id=2007 | |
| 83 | #define REMOTE_0 58 //!< remote keys 0-9. are used by multiple windows | 83 | #define ACTION_ZOOM_LEVEL_3 \ |
| 84 | #define REMOTE_1 59 //!< for example in videoFullScreen.xml window id=2005 you can | 84 | 40 //!< zoom 4x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 85 | #define REMOTE_2 60 //!< enter time (mmss) to jump to particular point in the movie | 85 | #define ACTION_ZOOM_LEVEL_4 \ |
| 86 | #define REMOTE_3 61 | 86 | 41 //!< zoom 5x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 87 | #define REMOTE_4 62 //!< with spincontrols you can enter 3digit number to quickly set | 87 | #define ACTION_ZOOM_LEVEL_5 \ |
| 88 | #define REMOTE_5 63 //!< spincontrol to desired value | 88 | 42 //!< zoom 6x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 89 | #define REMOTE_6 64 | 89 | #define ACTION_ZOOM_LEVEL_6 \ |
| 90 | #define REMOTE_7 65 | 90 | 43 //!< zoom 7x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 91 | #define REMOTE_8 66 | 91 | #define ACTION_ZOOM_LEVEL_7 \ |
| 92 | #define REMOTE_9 67 | 92 | 44 //!< zoom 8x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 93 | 93 | #define ACTION_ZOOM_LEVEL_8 \ | |
| 94 | #define ACTION_PLAYER_PROCESS_INFO 69 //!< show player process info (video decoder, pixel format, pvr signal strength and the like | 94 | 45 //!< zoom 9x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 95 | #define ACTION_PLAYER_PROGRAM_SELECT 70 | 95 | #define ACTION_ZOOM_LEVEL_9 \ |
| 96 | #define ACTION_PLAYER_RESOLUTION_SELECT 71 | 96 | 46 //!< zoom 10x picture during slideshow. Can b used in slideshow.xml window id=2007 |
| 97 | #define ACTION_SMALL_STEP_BACK 76 //!< jumps a few seconds back during playback of movie. Can b used in videoFullScreen.xml window id=2005 | 97 | |
| 98 | 98 | #define ACTION_CALIBRATE_SWAP_ARROWS \ | |
| 99 | #define ACTION_PLAYER_FORWARD 77 //!< FF in current file played. global action, can be used anywhere | 99 | 47 //!< select next arrow. Can b used in: settingsScreenCalibration.xml windowid=11 |
| 100 | #define ACTION_PLAYER_REWIND 78 //!< RW in current file played. global action, can be used anywhere | 100 | #define ACTION_CALIBRATE_RESET \ |
| 101 | #define ACTION_PLAYER_PLAY 79 //!< Play current song. Unpauses song and sets playspeed to 1x. global action, can be used anywhere | 101 | 48 //!< reset calibration to defaults. Can b used in: `settingsScreenCalibration.xml` |
| 102 | 102 | //!< windowid=11/settingsUICalibration.xml windowid=10 | |
| 103 | #define ACTION_DELETE_ITEM 80 //!< delete current selected item. Can be used in myfiles.xml window id=3 and in myvideoTitle.xml window id=25 | 103 | #define ACTION_ANALOG_MOVE \ |
| 104 | #define ACTION_COPY_ITEM 81 //!< copy current selected item. Can be used in myfiles.xml window id=3 | 104 | 49 //!< analog thumbstick move. Can b used in: `slideshow.xml` |
| 105 | #define ACTION_MOVE_ITEM 82 //!< move current selected item. Can be used in myfiles.xml window id=3 | 105 | //!< windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml |
| 106 | #define ACTION_TAKE_SCREENSHOT 85 //!< take a screenshot | 106 | //!< windowid=10 |
| 107 | #define ACTION_RENAME_ITEM 87 //!< rename item | 107 | //!< @note see also ACTION_ANALOG_MOVE_X_LEFT, ACTION_ANALOG_MOVE_X_RIGHT, |
| 108 | 108 | //!< ACTION_ANALOG_MOVE_Y_UP, ACTION_ANALOG_MOVE_Y_DOWN | |
| 109 | #define ACTION_VOLUME_UP 88 | 109 | #define ACTION_ROTATE_PICTURE_CW \ |
| 110 | #define ACTION_VOLUME_DOWN 89 | 110 | 50 //!< rotate current picture clockwise during slideshow. Can be used in slideshow.xml window |
| 111 | #define ACTION_VOLAMP 90 | 111 | //!< id=2007 |
| 112 | #define ACTION_MUTE 91 | 112 | #define ACTION_ROTATE_PICTURE_CCW \ |
| 113 | #define ACTION_NAV_BACK 92 | 113 | 51 //!< rotate current picture counterclockwise during slideshow. Can be used in slideshow.xml |
| 114 | #define ACTION_VOLAMP_UP 93 | 114 | //!< window id=2007 |
| 115 | #define ACTION_VOLAMP_DOWN 94 | 115 | |
| 116 | 116 | #define ACTION_SUBTITLE_DELAY_MIN \ | |
| 117 | #define ACTION_CREATE_EPISODE_BOOKMARK 95 //!< Creates an episode bookmark on the currently playing video file containing more than one episode | 117 | 52 //!< Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 |
| 118 | #define ACTION_CREATE_BOOKMARK 96 //!< Creates a bookmark of the currently playing video file | 118 | #define ACTION_SUBTITLE_DELAY_PLUS \ |
| 119 | 119 | 53 //!< Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005 | |
| 120 | #define ACTION_CHAPTER_OR_BIG_STEP_FORWARD 97 //!< Goto the next chapter, if not available perform a big step forward | 120 | #define ACTION_AUDIO_DELAY_MIN \ |
| 121 | #define ACTION_CHAPTER_OR_BIG_STEP_BACK 98 //!< Goto the previous chapter, if not available perform a big step back | 121 | 54 //!< Increase avsync delay. Can b used in videoFullScreen.xml window id=2005 |
| 122 | 122 | #define ACTION_AUDIO_DELAY_PLUS \ | |
| 123 | #define ACTION_CYCLE_SUBTITLE 99 //!< switch to next subtitle of movie, but will not enable/disable the subtitles. Can be used in videoFullScreen.xml window id=2005 | 123 | 55 //!< Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005 |
| 124 | 124 | #define ACTION_AUDIO_NEXT_LANGUAGE \ | |
| 125 | #define ACTION_MOUSE_START 100 | 125 | 56 //!< Select next language in movie. Can b used in videoFullScreen.xml window id=2005 |
| 126 | #define ACTION_MOUSE_LEFT_CLICK 100 | 126 | #define ACTION_CHANGE_RESOLUTION \ |
| 127 | #define ACTION_MOUSE_RIGHT_CLICK 101 | 127 | 57 //!< switch 2 next resolution. Can b used during screen calibration |
| 128 | #define ACTION_MOUSE_MIDDLE_CLICK 102 | 128 | //!< settingsScreenCalibration.xml windowid=11 |
| 129 | #define ACTION_MOUSE_DOUBLE_CLICK 103 | 129 | |
| 130 | #define ACTION_MOUSE_WHEEL_UP 104 | 130 | #define REMOTE_0 58 //!< remote keys 0-9. are used by multiple windows |
| 131 | #define ACTION_MOUSE_WHEEL_DOWN 105 | 131 | #define REMOTE_1 59 //!< for example in videoFullScreen.xml window id=2005 you can |
| 132 | #define ACTION_MOUSE_DRAG 106 | 132 | #define REMOTE_2 60 //!< enter time (mmss) to jump to particular point in the movie |
| 133 | #define ACTION_MOUSE_MOVE 107 | 133 | #define REMOTE_3 61 |
| 134 | #define ACTION_MOUSE_LONG_CLICK 108 | 134 | #define REMOTE_4 62 //!< with spincontrols you can enter 3digit number to quickly set |
| 135 | #define ACTION_MOUSE_END 109 | 135 | #define REMOTE_5 63 //!< spincontrol to desired value |
| 136 | 136 | #define REMOTE_6 64 | |
| 137 | #define ACTION_BACKSPACE 110 | 137 | #define REMOTE_7 65 |
| 138 | #define ACTION_SCROLL_UP 111 | 138 | #define REMOTE_8 66 |
| 139 | #define ACTION_SCROLL_DOWN 112 | 139 | #define REMOTE_9 67 |
| 140 | #define ACTION_ANALOG_FORWARD 113 | 140 | |
| 141 | #define ACTION_ANALOG_REWIND 114 | 141 | #define ACTION_PLAYER_PROCESS_INFO \ |
| 142 | 142 | 69 //!< show player process info (video decoder, pixel format, pvr signal strength and the like | |
| 143 | #define ACTION_MOVE_ITEM_UP 115 //!< move item up in playlist | 143 | #define ACTION_PLAYER_PROGRAM_SELECT 70 |
| 144 | #define ACTION_MOVE_ITEM_DOWN 116 //!< move item down in playlist | 144 | #define ACTION_PLAYER_RESOLUTION_SELECT 71 |
| 145 | #define ACTION_CONTEXT_MENU 117 //!< pops up the context menu | 145 | #define ACTION_SMALL_STEP_BACK \ |
| 146 | 76 //!< jumps a few seconds back during playback of movie. Can b used in videoFullScreen.xml | ||
| 147 | //!< window id=2005 | ||
| 148 | |||
| 149 | #define ACTION_PLAYER_FORWARD 77 //!< FF in current file played. global action, can be used anywhere | ||
| 150 | #define ACTION_PLAYER_REWIND 78 //!< RW in current file played. global action, can be used anywhere | ||
| 151 | #define ACTION_PLAYER_PLAY \ | ||
| 152 | 79 //!< Play current song. Unpauses song and sets playspeed to 1x. global action, can be used | ||
| 153 | //!< anywhere | ||
| 154 | |||
| 155 | #define ACTION_DELETE_ITEM \ | ||
| 156 | 80 //!< delete current selected item. Can be used in myfiles.xml window id=3 and in | ||
| 157 | //!< myvideoTitle.xml window id=25 | ||
| 158 | #define ACTION_COPY_ITEM 81 //!< copy current selected item. Can be used in myfiles.xml window id=3 | ||
| 159 | #define ACTION_MOVE_ITEM 82 //!< move current selected item. Can be used in myfiles.xml window id=3 | ||
| 160 | #define ACTION_TAKE_SCREENSHOT 85 //!< take a screenshot | ||
| 161 | #define ACTION_RENAME_ITEM 87 //!< rename item | ||
| 162 | |||
| 163 | #define ACTION_VOLUME_UP 88 | ||
| 164 | #define ACTION_VOLUME_DOWN 89 | ||
| 165 | #define ACTION_VOLAMP 90 | ||
| 166 | #define ACTION_MUTE 91 | ||
| 167 | #define ACTION_NAV_BACK 92 | ||
| 168 | #define ACTION_VOLAMP_UP 93 | ||
| 169 | #define ACTION_VOLAMP_DOWN 94 | ||
| 170 | |||
| 171 | #define ACTION_CREATE_EPISODE_BOOKMARK \ | ||
| 172 | 95 //!< Creates an episode bookmark on the currently playing video file containing more than one | ||
| 173 | //!< episode | ||
| 174 | #define ACTION_CREATE_BOOKMARK 96 //!< Creates a bookmark of the currently playing video file | ||
| 175 | |||
| 176 | #define ACTION_CHAPTER_OR_BIG_STEP_FORWARD \ | ||
| 177 | 97 //!< Goto the next chapter, if not available perform a big step forward | ||
| 178 | #define ACTION_CHAPTER_OR_BIG_STEP_BACK \ | ||
| 179 | 98 //!< Goto the previous chapter, if not available perform a big step back | ||
| 180 | |||
| 181 | #define ACTION_CYCLE_SUBTITLE \ | ||
| 182 | 99 //!< switch to next subtitle of movie, but will not enable/disable the subtitles. Can be used | ||
| 183 | //!< in videoFullScreen.xml window id=2005 | ||
| 184 | |||
| 185 | #define ACTION_MOUSE_START 100 | ||
| 186 | #define ACTION_MOUSE_LEFT_CLICK 100 | ||
| 187 | #define ACTION_MOUSE_RIGHT_CLICK 101 | ||
| 188 | #define ACTION_MOUSE_MIDDLE_CLICK 102 | ||
| 189 | #define ACTION_MOUSE_DOUBLE_CLICK 103 | ||
| 190 | #define ACTION_MOUSE_WHEEL_UP 104 | ||
| 191 | #define ACTION_MOUSE_WHEEL_DOWN 105 | ||
| 192 | #define ACTION_MOUSE_DRAG 106 | ||
| 193 | #define ACTION_MOUSE_MOVE 107 | ||
| 194 | #define ACTION_MOUSE_LONG_CLICK 108 | ||
| 195 | #define ACTION_MOUSE_DRAG_END 109 | ||
| 196 | #define ACTION_MOUSE_END 109 | ||
| 197 | |||
| 198 | #define ACTION_BACKSPACE 110 | ||
| 199 | #define ACTION_SCROLL_UP 111 | ||
| 200 | #define ACTION_SCROLL_DOWN 112 | ||
| 201 | #define ACTION_ANALOG_FORWARD 113 | ||
| 202 | #define ACTION_ANALOG_REWIND 114 | ||
| 203 | |||
| 204 | #define ACTION_MOVE_ITEM_UP 115 //!< move item up in playlist | ||
| 205 | #define ACTION_MOVE_ITEM_DOWN 116 //!< move item down in playlist | ||
| 206 | #define ACTION_CONTEXT_MENU 117 //!< pops up the context menu | ||
| 146 | 207 | ||
| 147 | // stuff for virtual keyboard shortcuts | 208 | // stuff for virtual keyboard shortcuts |
| 148 | #define ACTION_SHIFT 118 //!< stuff for virtual keyboard shortcuts | 209 | #define ACTION_SHIFT 118 //!< stuff for virtual keyboard shortcuts |
| 149 | #define ACTION_SYMBOLS 119 //!< stuff for virtual keyboard shortcuts | 210 | #define ACTION_SYMBOLS 119 //!< stuff for virtual keyboard shortcuts |
| 150 | #define ACTION_CURSOR_LEFT 120 //!< stuff for virtual keyboard shortcuts | 211 | #define ACTION_CURSOR_LEFT 120 //!< stuff for virtual keyboard shortcuts |
| 151 | #define ACTION_CURSOR_RIGHT 121 //!< stuff for virtual keyboard shortcuts | 212 | #define ACTION_CURSOR_RIGHT 121 //!< stuff for virtual keyboard shortcuts |
| 152 | 213 | ||
| 153 | #define ACTION_BUILT_IN_FUNCTION 122 | 214 | #define ACTION_BUILT_IN_FUNCTION 122 |
| 154 | 215 | ||
| 155 | #define ACTION_SHOW_OSD_TIME 123 //!< displays current time, can be used in videoFullScreen.xml window id=2005 | 216 | #define ACTION_SHOW_OSD_TIME \ |
| 156 | #define ACTION_ANALOG_SEEK_FORWARD 124 //!< seeks forward, and displays the seek bar. | 217 | 123 //!< displays current time, can be used in videoFullScreen.xml window id=2005 |
| 157 | #define ACTION_ANALOG_SEEK_BACK 125 //!< seeks backward, and displays the seek bar. | 218 | #define ACTION_ANALOG_SEEK_FORWARD 124 //!< seeks forward, and displays the seek bar. |
| 158 | 219 | #define ACTION_ANALOG_SEEK_BACK 125 //!< seeks backward, and displays the seek bar. | |
| 159 | #define ACTION_VIS_PRESET_SHOW 126 | 220 | |
| 160 | #define ACTION_VIS_PRESET_NEXT 128 | 221 | #define ACTION_VIS_PRESET_SHOW 126 |
| 161 | #define ACTION_VIS_PRESET_PREV 129 | 222 | #define ACTION_VIS_PRESET_NEXT 128 |
| 162 | #define ACTION_VIS_PRESET_LOCK 130 | 223 | #define ACTION_VIS_PRESET_PREV 129 |
| 163 | #define ACTION_VIS_PRESET_RANDOM 131 | 224 | #define ACTION_VIS_PRESET_LOCK 130 |
| 164 | #define ACTION_VIS_RATE_PRESET_PLUS 132 | 225 | #define ACTION_VIS_PRESET_RANDOM 131 |
| 165 | #define ACTION_VIS_RATE_PRESET_MINUS 133 | 226 | #define ACTION_VIS_RATE_PRESET_PLUS 132 |
| 166 | 227 | #define ACTION_VIS_RATE_PRESET_MINUS 133 | |
| 167 | #define ACTION_SHOW_VIDEOMENU 134 | 228 | |
| 168 | #define ACTION_ENTER 135 | 229 | #define ACTION_SHOW_VIDEOMENU 134 |
| 169 | 230 | #define ACTION_ENTER 135 | |
| 170 | #define ACTION_INCREASE_RATING 136 | 231 | |
| 171 | #define ACTION_DECREASE_RATING 137 | 232 | #define ACTION_INCREASE_RATING 136 |
| 172 | 233 | #define ACTION_DECREASE_RATING 137 | |
| 173 | #define ACTION_NEXT_SCENE 138 //!< switch to next scene/cutpoint in movie | 234 | |
| 174 | #define ACTION_PREV_SCENE 139 //!< switch to previous scene/cutpoint in movie | 235 | #define ACTION_NEXT_SCENE 138 //!< switch to next scene/cutpoint in movie |
| 175 | 236 | #define ACTION_PREV_SCENE 139 //!< switch to previous scene/cutpoint in movie | |
| 176 | #define ACTION_NEXT_LETTER 140 //!< jump through a list or container by letter | 237 | |
| 177 | #define ACTION_PREV_LETTER 141 | 238 | #define ACTION_NEXT_LETTER 140 //!< jump through a list or container by letter |
| 178 | 239 | #define ACTION_PREV_LETTER 141 | |
| 179 | #define ACTION_JUMP_SMS2 142 //!< jump direct to a particular letter using SMS-style input | 240 | |
| 180 | #define ACTION_JUMP_SMS3 143 | 241 | #define ACTION_JUMP_SMS2 142 //!< jump direct to a particular letter using SMS-style input |
| 181 | #define ACTION_JUMP_SMS4 144 | 242 | #define ACTION_JUMP_SMS3 143 |
| 182 | #define ACTION_JUMP_SMS5 145 | 243 | #define ACTION_JUMP_SMS4 144 |
| 183 | #define ACTION_JUMP_SMS6 146 | 244 | #define ACTION_JUMP_SMS5 145 |
| 184 | #define ACTION_JUMP_SMS7 147 | 245 | #define ACTION_JUMP_SMS6 146 |
| 185 | #define ACTION_JUMP_SMS8 148 | 246 | #define ACTION_JUMP_SMS7 147 |
| 186 | #define ACTION_JUMP_SMS9 149 | 247 | #define ACTION_JUMP_SMS8 148 |
| 187 | 248 | #define ACTION_JUMP_SMS9 149 | |
| 188 | #define ACTION_FILTER_CLEAR 150 | 249 | |
| 189 | #define ACTION_FILTER_SMS2 151 | 250 | #define ACTION_FILTER_CLEAR 150 |
| 190 | #define ACTION_FILTER_SMS3 152 | 251 | #define ACTION_FILTER_SMS2 151 |
| 191 | #define ACTION_FILTER_SMS4 153 | 252 | #define ACTION_FILTER_SMS3 152 |
| 192 | #define ACTION_FILTER_SMS5 154 | 253 | #define ACTION_FILTER_SMS4 153 |
| 193 | #define ACTION_FILTER_SMS6 155 | 254 | #define ACTION_FILTER_SMS5 154 |
| 194 | #define ACTION_FILTER_SMS7 156 | 255 | #define ACTION_FILTER_SMS6 155 |
| 195 | #define ACTION_FILTER_SMS8 157 | 256 | #define ACTION_FILTER_SMS7 156 |
| 196 | #define ACTION_FILTER_SMS9 158 | 257 | #define ACTION_FILTER_SMS8 157 |
| 197 | 258 | #define ACTION_FILTER_SMS9 158 | |
| 198 | #define ACTION_FIRST_PAGE 159 | 259 | |
| 199 | #define ACTION_LAST_PAGE 160 | 260 | #define ACTION_FIRST_PAGE 159 |
| 200 | 261 | #define ACTION_LAST_PAGE 160 | |
| 201 | #define ACTION_AUDIO_DELAY 161 | 262 | |
| 202 | #define ACTION_SUBTITLE_DELAY 162 | 263 | #define ACTION_AUDIO_DELAY 161 |
| 203 | #define ACTION_MENU 163 | 264 | #define ACTION_SUBTITLE_DELAY 162 |
| 204 | 265 | #define ACTION_MENU 163 | |
| 205 | #define ACTION_SET_RATING 164 | 266 | |
| 206 | 267 | #define ACTION_SET_RATING 164 | |
| 207 | #define ACTION_RECORD 170 | 268 | |
| 208 | 269 | #define ACTION_RECORD 170 | |
| 209 | #define ACTION_PASTE 180 | 270 | |
| 210 | #define ACTION_NEXT_CONTROL 181 | 271 | #define ACTION_PASTE 180 |
| 211 | #define ACTION_PREV_CONTROL 182 | 272 | #define ACTION_NEXT_CONTROL 181 |
| 212 | #define ACTION_CHANNEL_SWITCH 183 | 273 | #define ACTION_PREV_CONTROL 182 |
| 213 | #define ACTION_CHANNEL_UP 184 | 274 | #define ACTION_CHANNEL_SWITCH 183 |
| 214 | #define ACTION_CHANNEL_DOWN 185 | 275 | #define ACTION_CHANNEL_UP 184 |
| 215 | #define ACTION_NEXT_CHANNELGROUP 186 | 276 | #define ACTION_CHANNEL_DOWN 185 |
| 216 | #define ACTION_PREVIOUS_CHANNELGROUP 187 | 277 | #define ACTION_NEXT_CHANNELGROUP 186 |
| 217 | #define ACTION_PVR_PLAY 188 | 278 | #define ACTION_PREVIOUS_CHANNELGROUP 187 |
| 218 | #define ACTION_PVR_PLAY_TV 189 | 279 | #define ACTION_PVR_PLAY 188 |
| 219 | #define ACTION_PVR_PLAY_RADIO 190 | 280 | #define ACTION_PVR_PLAY_TV 189 |
| 220 | #define ACTION_PVR_SHOW_TIMER_RULE 191 | 281 | #define ACTION_PVR_PLAY_RADIO 190 |
| 221 | #define ACTION_CHANNEL_NUMBER_SEP 192 | 282 | #define ACTION_PVR_SHOW_TIMER_RULE 191 |
| 283 | #define ACTION_CHANNEL_NUMBER_SEP 192 | ||
| 222 | #define ACTION_PVR_ANNOUNCE_REMINDERS 193 | 284 | #define ACTION_PVR_ANNOUNCE_REMINDERS 193 |
| 223 | 285 | ||
| 224 | #define ACTION_TOGGLE_FULLSCREEN 199 //!< switch 2 desktop resolution | 286 | #define ACTION_TOGGLE_FULLSCREEN 199 //!< switch 2 desktop resolution |
| 225 | #define ACTION_TOGGLE_WATCHED 200 //!< Toggle watched status (videos) | 287 | #define ACTION_TOGGLE_WATCHED 200 //!< Toggle watched status (videos) |
| 226 | #define ACTION_SCAN_ITEM 201 //!< scan item | 288 | #define ACTION_SCAN_ITEM 201 //!< scan item |
| 227 | #define ACTION_TOGGLE_DIGITAL_ANALOG 202 //!< switch digital <-> analog | 289 | #define ACTION_TOGGLE_DIGITAL_ANALOG 202 //!< switch digital <-> analog |
| 228 | #define ACTION_RELOAD_KEYMAPS 203 //!< reloads CButtonTranslator's keymaps | 290 | #define ACTION_RELOAD_KEYMAPS 203 //!< reloads CButtonTranslator's keymaps |
| 229 | #define ACTION_GUIPROFILE_BEGIN 204 //!< start the GUIControlProfiler running | 291 | #define ACTION_GUIPROFILE_BEGIN 204 //!< start the GUIControlProfiler running |
| 230 | 292 | ||
| 231 | #define ACTION_TELETEXT_RED 215 //!< Teletext Color button <b>Red</b> to control TopText | 293 | #define ACTION_TELETEXT_RED 215 //!< Teletext Color button <b>Red</b> to control TopText |
| 232 | #define ACTION_TELETEXT_GREEN 216 //!< Teletext Color button <b>Green</b> to control TopText | 294 | #define ACTION_TELETEXT_GREEN 216 //!< Teletext Color button <b>Green</b> to control TopText |
| 233 | #define ACTION_TELETEXT_YELLOW 217 //!< Teletext Color button <b>Yellow</b> to control TopText | 295 | #define ACTION_TELETEXT_YELLOW 217 //!< Teletext Color button <b>Yellow</b> to control TopText |
| 234 | #define ACTION_TELETEXT_BLUE 218 //!< Teletext Color button <b>Blue</b> to control TopText | 296 | #define ACTION_TELETEXT_BLUE 218 //!< Teletext Color button <b>Blue</b> to control TopText |
| 235 | 297 | ||
| 236 | #define ACTION_INCREASE_PAR 219 | 298 | #define ACTION_INCREASE_PAR 219 |
| 237 | #define ACTION_DECREASE_PAR 220 | 299 | #define ACTION_DECREASE_PAR 220 |
| 238 | 300 | ||
| 239 | #define ACTION_VSHIFT_UP 227 //!< shift up video image in VideoPlayer | 301 | #define ACTION_VSHIFT_UP 227 //!< shift up video image in VideoPlayer |
| 240 | #define ACTION_VSHIFT_DOWN 228 //!< shift down video image in VideoPlayer | 302 | #define ACTION_VSHIFT_DOWN 228 //!< shift down video image in VideoPlayer |
| 241 | 303 | ||
| 242 | #define ACTION_PLAYER_PLAYPAUSE 229 //!< Play/pause. If playing it pauses, if paused it plays. | 304 | #define ACTION_PLAYER_PLAYPAUSE 229 //!< Play/pause. If playing it pauses, if paused it plays. |
| 243 | 305 | ||
| 244 | #define ACTION_SUBTITLE_VSHIFT_UP 230 //!< shift up subtitles in VideoPlayer | 306 | #define ACTION_SUBTITLE_VSHIFT_UP 230 //!< shift up subtitles in VideoPlayer |
| 245 | #define ACTION_SUBTITLE_VSHIFT_DOWN 231 //!< shift down subtitles in VideoPlayer | 307 | #define ACTION_SUBTITLE_VSHIFT_DOWN 231 //!< shift down subtitles in VideoPlayer |
| 246 | #define ACTION_SUBTITLE_ALIGN 232 //!< toggle vertical alignment of subtitles | 308 | #define ACTION_SUBTITLE_ALIGN 232 //!< toggle vertical alignment of subtitles |
| 247 | 309 | ||
| 248 | #define ACTION_FILTER 233 | 310 | #define ACTION_FILTER 233 |
| 249 | 311 | ||
| 250 | #define ACTION_SWITCH_PLAYER 234 | 312 | #define ACTION_SWITCH_PLAYER 234 |
| 251 | 313 | ||
| 252 | #define ACTION_STEREOMODE_NEXT 235 | 314 | #define ACTION_STEREOMODE_NEXT 235 |
| 253 | #define ACTION_STEREOMODE_PREVIOUS 236 | 315 | #define ACTION_STEREOMODE_PREVIOUS 236 |
| 254 | #define ACTION_STEREOMODE_TOGGLE 237 //!< turns 3d mode on/off | 316 | #define ACTION_STEREOMODE_TOGGLE 237 //!< turns 3d mode on/off |
| 255 | #define ACTION_STEREOMODE_SELECT 238 | 317 | #define ACTION_STEREOMODE_SELECT 238 |
| 256 | #define ACTION_STEREOMODE_TOMONO 239 | 318 | #define ACTION_STEREOMODE_TOMONO 239 |
| 257 | #define ACTION_STEREOMODE_SET 240 | 319 | #define ACTION_STEREOMODE_SET 240 |
| 258 | 320 | ||
| 259 | #define ACTION_SETTINGS_RESET 241 | 321 | #define ACTION_SETTINGS_RESET 241 |
| 260 | #define ACTION_SETTINGS_LEVEL_CHANGE 242 | 322 | #define ACTION_SETTINGS_LEVEL_CHANGE 242 |
| 261 | 323 | ||
| 262 | #define ACTION_TRIGGER_OSD 243 //!< show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005 | 324 | #define ACTION_TRIGGER_OSD \ |
| 263 | #define ACTION_INPUT_TEXT 244 | 325 | 243 //!< show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005 |
| 264 | #define ACTION_VOLUME_SET 245 | 326 | #define ACTION_INPUT_TEXT 244 |
| 265 | #define ACTION_TOGGLE_COMMSKIP 246 | 327 | #define ACTION_VOLUME_SET 245 |
| 328 | #define ACTION_TOGGLE_COMMSKIP 246 | ||
| 266 | 329 | ||
| 267 | #define ACTION_PLAYER_RESET 248 //!< Send a reset command to the active game | 330 | #define ACTION_HDR_TOGGLE 247 //!< Toggle display HDR on/off |
| 268 | 331 | ||
| 269 | #define ACTION_TOGGLE_FONT 249 //!< Toggle font. Used in TextViewer dialog | 332 | #define ACTION_PLAYER_RESET 248 //!< Send a reset command to the active game |
| 270 | 333 | ||
| 271 | #define ACTION_VIDEO_NEXT_STREAM 250 //!< Cycle video streams. Used in videofullscreen. | 334 | #define ACTION_TOGGLE_FONT 249 //!< Toggle font. Used in TextViewer dialog |
| 272 | #define ACTION_QUEUE_ITEM_NEXT 251 //!< used to queue an item to the next position in the playlist | 335 | |
| 336 | #define ACTION_VIDEO_NEXT_STREAM 250 //!< Cycle video streams. Used in videofullscreen. | ||
| 337 | #define ACTION_QUEUE_ITEM_NEXT 251 //!< used to queue an item to the next position in the playlist | ||
| 273 | 338 | ||
| 274 | // Voice actions | 339 | // Voice actions |
| 275 | #define ACTION_VOICE_RECOGNIZE 300 | 340 | #define ACTION_VOICE_RECOGNIZE 300 |
| 276 | 341 | ||
| 277 | // Touch actions | 342 | // Touch actions |
| 278 | #define ACTION_TOUCH_TAP 401 //!< touch actions | 343 | #define ACTION_TOUCH_TAP 401 //!< touch actions |
| 279 | #define ACTION_TOUCH_TAP_TEN 410 //!< touch actions | 344 | #define ACTION_TOUCH_TAP_TEN 410 //!< touch actions |
| 280 | #define ACTION_TOUCH_LONGPRESS 411 //!< touch actions | 345 | #define ACTION_TOUCH_LONGPRESS 411 //!< touch actions |
| 281 | #define ACTION_TOUCH_LONGPRESS_TEN 420 //!< touch actions | 346 | #define ACTION_TOUCH_LONGPRESS_TEN 420 //!< touch actions |
| 282 | 347 | ||
| 283 | #define ACTION_GESTURE_NOTIFY 500 | 348 | #define ACTION_GESTURE_NOTIFY 500 |
| 284 | #define ACTION_GESTURE_BEGIN 501 | 349 | #define ACTION_GESTURE_BEGIN 501 |
| 285 | #define ACTION_GESTURE_ZOOM 502 //!< sendaction with point and currentPinchScale (fingers together < 1.0 -> fingers apart > 1.0) | 350 | #define ACTION_GESTURE_ZOOM \ |
| 286 | #define ACTION_GESTURE_ROTATE 503 | 351 | 502 //!< sendaction with point and currentPinchScale (fingers together < 1.0 -> fingers apart |
| 287 | #define ACTION_GESTURE_PAN 504 | 352 | //!< > 1.0) |
| 288 | #define ACTION_GESTURE_ABORT 505 //!< gesture was interrupted in unspecified state | 353 | #define ACTION_GESTURE_ROTATE 503 |
| 289 | 354 | #define ACTION_GESTURE_PAN 504 | |
| 290 | #define ACTION_GESTURE_SWIPE_LEFT 511 | 355 | #define ACTION_GESTURE_ABORT 505 //!< gesture was interrupted in unspecified state |
| 291 | #define ACTION_GESTURE_SWIPE_LEFT_TEN 520 | 356 | |
| 292 | #define ACTION_GESTURE_SWIPE_RIGHT 521 | 357 | #define ACTION_GESTURE_SWIPE_LEFT 511 |
| 293 | #define ACTION_GESTURE_SWIPE_RIGHT_TEN 530 | 358 | #define ACTION_GESTURE_SWIPE_LEFT_TEN 520 |
| 294 | #define ACTION_GESTURE_SWIPE_UP 531 | 359 | #define ACTION_GESTURE_SWIPE_RIGHT 521 |
| 295 | #define ACTION_GESTURE_SWIPE_UP_TEN 540 | 360 | #define ACTION_GESTURE_SWIPE_RIGHT_TEN 530 |
| 296 | #define ACTION_GESTURE_SWIPE_DOWN 541 | 361 | #define ACTION_GESTURE_SWIPE_UP 531 |
| 297 | #define ACTION_GESTURE_SWIPE_DOWN_TEN 550 | 362 | #define ACTION_GESTURE_SWIPE_UP_TEN 540 |
| 363 | #define ACTION_GESTURE_SWIPE_DOWN 541 | ||
| 364 | #define ACTION_GESTURE_SWIPE_DOWN_TEN 550 | ||
| 298 | // 5xx is reserved for additional gesture actions | 365 | // 5xx is reserved for additional gesture actions |
| 299 | #define ACTION_GESTURE_END 599 | 366 | #define ACTION_GESTURE_END 599 |
| 300 | 367 | ||
| 301 | // other, non-gesture actions | 368 | // other, non-gesture actions |
| 302 | #define ACTION_ANALOG_MOVE_X_LEFT 601 //!< analog thumbstick move, horizontal axis, left; see ACTION_ANALOG_MOVE | 369 | #define ACTION_ANALOG_MOVE_X_LEFT \ |
| 303 | #define ACTION_ANALOG_MOVE_X_RIGHT 602 //!< analog thumbstick move, horizontal axis, right; see ACTION_ANALOG_MOVE | 370 | 601 //!< analog thumbstick move, horizontal axis, left; see ACTION_ANALOG_MOVE |
| 304 | #define ACTION_ANALOG_MOVE_Y_UP 603 //!< analog thumbstick move, vertical axis, up; see ACTION_ANALOG_MOVE | 371 | #define ACTION_ANALOG_MOVE_X_RIGHT \ |
| 305 | #define ACTION_ANALOG_MOVE_Y_DOWN 604 //!< analog thumbstick move, vertical axis, down; see ACTION_ANALOG_MOVE | 372 | 602 //!< analog thumbstick move, horizontal axis, right; see ACTION_ANALOG_MOVE |
| 373 | #define ACTION_ANALOG_MOVE_Y_UP \ | ||
| 374 | 603 //!< analog thumbstick move, vertical axis, up; see ACTION_ANALOG_MOVE | ||
| 375 | #define ACTION_ANALOG_MOVE_Y_DOWN \ | ||
| 376 | 604 //!< analog thumbstick move, vertical axis, down; see ACTION_ANALOG_MOVE | ||
| 306 | //@} | 377 | //@} |
| 307 | 378 | ||
| 308 | // The NOOP action can be specified to disable an input event. This is | 379 | // The NOOP action can be specified to disable an input event. This is |
| 309 | // useful in user keyboard.xml etc to disable actions specified in the | 380 | // useful in user keyboard.xml etc to disable actions specified in the |
| 310 | // system mappings. ERROR action is used to play an error sound | 381 | // system mappings. ERROR action is used to play an error sound |
| 311 | #define ACTION_ERROR 998 | 382 | #define ACTION_ERROR 998 |
| 312 | #define ACTION_NOOP 999 | 383 | #define ACTION_NOOP 999 |
diff --git a/xbmc/interfaces/json-rpc/schema/version.txt b/xbmc/interfaces/json-rpc/schema/version.txt index a028c7d..6fb712b 100644 --- a/xbmc/interfaces/json-rpc/schema/version.txt +++ b/xbmc/interfaces/json-rpc/schema/version.txt | |||
| @@ -1 +1 @@ | |||
| JSONRPC_VERSION 10.5.0 | JSONRPC_VERSION 11.11.0 | ||
