Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches

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(const kodi::addon::IInstanceInfo& instance,
CMyInputstream* inputstream);
...
private:
CMyInputstream* m_inputstream;
};
CMyVideoCodec::CMyVideoCodec(const kodi::addon::IInstanceInfo& instance,
CMyInputstream* inputstream)
: kodi::addon::CInstanceVideoCodec(instance),
m_inputstream(inputstream)
{
...
}
...
//----------------------------------------------------------------------
class CMyInputstream : public kodi::addon::CInstanceInputStream
{
public:
CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion);
ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl) override;
...
};
CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
: kodi::addon::CInstanceInputStream(instance, kodiVersion)
{
...
}
ADDON_STATUS CMyInputstream::CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl)
{
{
{
addonInstance = new CMyVideoCodec(instance, this);
}
return ADDON_STATUS_NOT_IMPLEMENTED;
}
...
//----------------------------------------------------------------------
class CMyAddon : public kodi::addon::CAddonBase
{
public:
CMyAddon() = default;
ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl) override;
};
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl)
{
{
kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
hdl = new CMyInputstream(instance);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition AddonBase.h:775
Definition Inputstream.h:1148
Definition VideoCodec.h:248
Definition AddonBase.h:498
ADDON_STATUS
Definition addon_base.h:138
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:140
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition addon_base.h:152
@ ADDON_INSTANCE_INPUTSTREAM
Input stream instance, see kodi::addon::CInstanceInputStream.
Definition versions.h:228
@ ADDON_INSTANCE_VIDEOCODEC
Video codec instance, see kodi::addon::CInstanceVideoCodec.
Definition versions.h:249
bool IsType(KODI_ADDON_INSTANCE_TYPE type) const
Check asked type used on this class.
Definition AddonBase.h:525
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938

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

Topics

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

Function Documentation

◆ CInstanceVideoCodec()

CInstanceVideoCodec ( const IInstanceInfo & instance)
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 running 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