Kodi Development  20.0
for Binary and Script based Add-Ons

Detailed Description

Class: kodi::addon::CInstanceVideoCodec

Video codec add-on instance

This is an addon instance class to add an additional video decoder to Kodi using addon.

This means that either a new type of decoding can be introduced to an input stream add-on that requires special types of decoding.

When using the inputstream addon, class InputstreamInfo to cpp_kodi_addon_inputstream_Defs_Info is used to declare that the decoder stored in the addon is used.

Note
At the moment this can only be used together with input stream addons, independent use as a codec addon is not yet possible.

Include the header #include <kodi/addon-instance/VideoCodec.h> to use this class.


Example: This as an example when used together with kodi::addon::CInstanceInputStream.

#include <kodi/addon-instance/Inputstream.h>
#include <kodi/addon-instance/VideoCodec.h>
class CMyVideoCodec : public kodi::addon::CInstanceVideoCodec
{
public:
CMyVideoCodec(KODI_HANDLE instance, CMyInputstream* inputstream);
...
private:
CMyInputstream* m_inputstream;
};
CMyVideoCodec::CMyVideoCodec(KODI_HANDLE instance,
const std::string& version,
CMyInputstream* inputstream)
: kodi::addon::CInstanceVideoCodec(instance, version),
m_inputstream(inputstream)
{
...
}
...
//----------------------------------------------------------------------
class CMyInputstream : public kodi::addon::CInstanceInputStream
{
public:
CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion);
ADDON_STATUS CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
...
};
CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
: kodi::addon::CInstanceInputStream(instance, kodiVersion)
{
...
}
ADDON_STATUS CMyInputstream::CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
if (instanceType == ADDON_INSTANCE_VIDEOCODEC)
{
addonInstance = new CMyVideoCodec(instance, version, this);
}
return ADDON_STATUS_NOT_IMPLEMENTED;
}
...
//----------------------------------------------------------------------
class CMyAddon : public kodi::addon::CAddonBase
{
public:
CMyAddon() { }
ADDON_STATUS CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
};
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
if (instanceType == ADDON_INSTANCE_INPUTSTREAM)
{
kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
addonInstance = new CMyInputstream(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition: AddonBase.h:322
Definition: Inputstream.h:1154
Definition: VideoCodec.h:260
ADDON_STATUS
Definition: addon_base.h:128
@ ADDON_STATUS_OK
For everything OK and no error.
Definition: addon_base.h:130
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition: addon_base.h:142
@ ADDON_INSTANCE_INPUTSTREAM
Input stream instance, see kodi::addon::CInstanceInputStream.
Definition: versions.h:226
@ ADDON_INSTANCE_VIDEOCODEC
Video Decoder instance, see kodi::addon::CInstanceVideoCodec.
Definition: versions.h:247
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749

The destruction of the example class CMyInputstream is called from Kodi's header. Manually deleting the add-on instance is not required.

Modules

 Definitions, structures and enumerators
 Video codec add-on general variables
 

Function Documentation

◆ CInstanceVideoCodec()

CInstanceVideoCodec ( KODI_HANDLE  instance,
const std::string &  kodiVersion = "" 
)
inlineexplicit

Video codec class constructor used to support multiple instance types.

Parameters
[in]instanceThe instance value given to kodi::addon::CAddonBase::CreateInstance(...), or by a inputstream instance if them declared as parent.
[in]kodiVersion[opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions.

◆ ~CInstanceVideoCodec()

~CInstanceVideoCodec ( )
overridedefault

Destructor.

◆ Open()

virtual bool Open ( const kodi::addon::VideoCodecInitdata initData)
inlinevirtual

Open the decoder, returns true on success.

Decoders not capable of running multiple instances should return false in case there is already a instance open.

Parameters
[in]initDataVideo codec init data
Returns
true if successfully done

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

Name Type Get call
Codec type VIDEOCODEC_TYPE GetCodecType
Codec profile STREAMCODEC_PROFILE GetCodecProfile
Video formats std::vector<VIDEOCODEC_FORMAT> GetVideoFormats
Width uint32_t GetWidth
Height uint32_t GetHeight
Extra data const uint8_t* GetExtraData
Extra data size unsigned int GetExtraDataSize
Crypto session kodi::addon::StreamCryptoSession GetCryptoSession

◆ Reconfigure()

virtual bool Reconfigure ( const kodi::addon::VideoCodecInitdata initData)
inlinevirtual

Reconfigure the decoder, returns true on success.

Decoders not capable of runnung multiple instances may be capable of reconfiguring the running instance. If Reconfigure returns false, player will close / open the decoder

Parameters
[in]initDataVideo codec reconfigure data
Returns
true if successfully done

◆ AddData()

virtual bool AddData ( const DEMUX_PACKET packet)
inlinevirtual

add data, decoder has to consume the entire packet

Parameters
[in]packetData to process for decode
Returns
true if the packet was consumed or if resubmitting it is useless

◆ GetPicture()

virtual VIDEOCODEC_RETVAL GetPicture ( VIDEOCODEC_PICTURE picture)
inlinevirtual

GetPicture controls decoding.

Player calls it on every cycle it can signal a picture, request a buffer, or return none, if nothing applies the data is valid until the next GetPicture return VC_PICTURE

Parameters
[in,out]Structurewhich contains the necessary data
Returns
The with VIDEOCODEC_RETVAL return values

◆ GetName()

virtual const char* GetName ( )
inlinevirtual

should return codecs name

Returns
Codec name

◆ Reset()

virtual void Reset ( )
inlinevirtual

Reset the decoder.

◆ GetFrameBuffer()

bool GetFrameBuffer ( VIDEOCODEC_PICTURE picture)
inline

AddonToKodi interface.

All picture members can be expected to be set correctly except decodedData and pts.

GetFrameBuffer has to set decodedData to a valid memory address and return true.

Parameters
[out]pictureThe buffer, or unmodified if false is returned
Returns
In case buffer allocation fails, it return false.
Note
If this returns true, buffer must be freed using ReleaseFrameBuffer().
Remarks
Only called from addon itself

◆ ReleaseFrameBuffer()

void ReleaseFrameBuffer ( void *  buffer)
inline

Release the with GetFrameBuffer() given framebuffer.

Parameters
[in]handlethe on VIDEOCODEC_PICTURE::videoBufferHandle defined buffer handle
Remarks
Only called from addon itself