Class: kodi::addon::CInstanceImageDecoder
Image decoder add-on instance
This instance type is used to allow Kodi various additional image format types.
More...
Class: kodi::addon::CInstanceImageDecoder
Image decoder add-on instance
This instance type is used to allow Kodi various additional image format types.
This usage can be requested under various conditions, by a Mimetype protocol defined in addon.xml
or supported file extensions.
Include the header #include <kodi/addon-instance/ImageDecoder.h> to use this class.
Here is an example of what the addon.xml.in
would look like for an image decoder addon:
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="imagedecoder.myspecialnamefor"
version="1.0.0"
name="My image decoder addon"
provider-name="Your Name">
<requires>@ADDON_DEPENDS@</requires>
<extension
point="kodi.imagedecoder"
extension=".imga|.imgb"
mimetype="image/mymimea|image/mymimea"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">My image decoder addon summary</summary>
<description lang="en_GB">My image decoder description</description>
<platform>@PLATFORM@</platform>
</extension>
</addon>
Standard values that can be declared for processing in <tt>addon.xml</tt>.
These values are used by Kodi to identify associated images and file extensions and then to select the associated addon.
Labels | Type | Description |
point | string | The identification of the addon instance to image decoder is mandatory kodi.imagedecoder . In addition, the instance declared in the first <extension ... /> is also the main type of addon. |
extension | string | The from addon operated and supported image file endings.
Use a | to separate between different ones. |
defaultPort | string | The from addon operated image mimetypes.
Use a | to separate between different ones. |
library_@PLATFORM@ | string | The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated addon.xml . |
Example:
{
public:
CMyImageDecoder(
KODI_HANDLE instance,
const std::string& kodiVersion);
bool LoadImageFromMemory(
unsigned char*
buffer,
unsigned int bufSize,
unsigned int& width,
unsigned int& height) override;
bool Decode(unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
...
};
CMyImageDecoder::CMyImageDecoder(
KODI_HANDLE instance,
const std::string& kodiVersion)
: CInstanceImageDecoder(instance, kodiVersion)
{
...
}
bool CMyImageDecoder::LoadImageFromMemory(
unsigned char*
buffer,
unsigned int bufSize,
unsigned int& width,
unsigned int& height)
{
...
return true;
}
bool CMyImageDecoder::Decode(unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
{
...
return true;
}
{
public:
CMyAddon() = default;
const std::string& instanceID,
const std::string& version,
};
const std::string& instanceID,
const std::string& version,
{
{
addonInstance = new CMyImageDecoder(instance, version);
}
else if (...)
{
...
}
}
#define ATTR_DLL_LOCAL
Definition: addon_base.h:81
void * KODI_HANDLE
Standard undefined pointer handle.
Definition: addon_base.h:199
uint8_t * buffer
Definition: addons/kodi-dev-kit/include/kodi/c-api/addon-instance/AudioDecoder.h:116
const char unsigned int int int int int64_t int enum AudioEngineDataFormat * format
Definition: addons/kodi-dev-kit/include/kodi/c-api/addon-instance/AudioDecoder.h:113
Definition: kodi-dev-kit/include/kodi/AddonBase.h:332
Definition: kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h:199
virtual ADDON_STATUS CreateInstance(int instanceType, const std::string &instanceID, KODI_HANDLE instance, const std::string &version, KODI_HANDLE &addonInstance)
Definition: kodi-dev-kit/include/kodi/AddonBase.h:204
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:183
ADDON_STATUS
Definition: addon_base.h:134
@ ADDON_STATUS_OK
For everything OK and no error.
Definition: addon_base.h:136
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition: addon_base.h:148
@ ADDON_INSTANCE_IMAGEDECODER
Image Decoder instance, see kodi::addon::CInstanceImageDecoder.
Definition: versions.h:244
ImageFormat
Image format types Used to define wanted target format where image decoder should give to Kodi.
Definition: image_decoder.h:26
void ATTR_DLL_LOCAL Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: kodi-dev-kit/include/kodi/AddonBase.h:758
#define ADDONCREATOR(AddonClass)
Definition: kodi-dev-kit/include/kodi/AddonBase.h:1443
The destruction of the example class CMyImageDecoder
is called from Kodi's header. Manually deleting the add-on instance is not required.
◆ CInstanceImageDecoder()
kodi::addon::CInstanceImageDecoder::CInstanceImageDecoder |
( |
KODI_HANDLE |
instance, |
|
|
const std::string & |
kodiVersion = "" |
|
) |
| |
|
inlineexplicit |
Class constructor.
- Parameters
-
[in] | instance | The from Kodi given instance given be add-on CreateInstance call with instance id ADDON_INSTANCE_IMAGEDECODER. |
[in] | kodiVersion | [opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions. |
- Note
- Recommended to set
kodiVersion
.
◆ Decode()
virtual bool kodi::addon::CInstanceImageDecoder::Decode |
( |
unsigned char * |
pixels, |
|
|
unsigned int |
width, |
|
|
unsigned int |
height, |
|
|
unsigned int |
pitch, |
|
|
ImageFormat |
format |
|
) |
| |
|
pure virtual |
Decode previously loaded image.
- Parameters
-
[in] | pixels | Output buffer |
[in] | width | Width of output image |
[in] | height | Height of output image |
[in] | pitch | Pitch of output image |
[in] | format | Format of output image |
- Returns
- true if successful done, false on error
◆ LoadImageFromMemory()
virtual bool kodi::addon::CInstanceImageDecoder::LoadImageFromMemory |
( |
unsigned char * |
buffer, |
|
|
unsigned int |
bufSize, |
|
|
unsigned int & |
width, |
|
|
unsigned int & |
height |
|
) |
| |
|
pure virtual |
Initialize an encoder.
- Parameters
-
[in] | buffer | The data to read from memory |
[in] | bufSize | The buffer size |
[in,out] | width | The optimal width of image on entry, obtained width on return |
[in,out] | height | The optimal height of image, actual obtained height on return |
- Returns
- true if successful done, false on error
◆ MimeType()
std::string kodi::addon::CInstanceImageDecoder::MimeType |
( |
| ) |
|
|
inline |
Callback to Kodi Function
Get the wanted mime type from Kodi.
- Returns
- the mimetype wanted from Kodi