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

Class: kodi::addon::CInstanceVideoCodec

Video codec add-on instance More...

Topics

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

Functions

 kodi::addon::CInstanceVideoCodec::CInstanceVideoCodec (const IInstanceInfo &instance)
 Video codec class constructor used to support multiple instance types.
 
 kodi::addon::CInstanceVideoCodec::~CInstanceVideoCodec () override=default
 Destructor.
 
virtual bool kodi::addon::CInstanceVideoCodec::Open (const kodi::addon::VideoCodecInitdata &initData)
 Open the decoder, returns true on success.
 
virtual bool kodi::addon::CInstanceVideoCodec::Reconfigure (const kodi::addon::VideoCodecInitdata &initData)
 Reconfigure the decoder, returns true on success.
 
virtual bool kodi::addon::CInstanceVideoCodec::AddData (const DEMUX_PACKET &packet)
 add data, decoder has to consume the entire packet
 
virtual VIDEOCODEC_RETVAL kodi::addon::CInstanceVideoCodec::GetPicture (VIDEOCODEC_PICTURE &picture)
 GetPicture controls decoding.
 
virtual const char * kodi::addon::CInstanceVideoCodec::GetName ()
 should return codecs name
 
virtual void kodi::addon::CInstanceVideoCodec::Reset ()
 Reset the decoder.
 
bool kodi::addon::CInstanceVideoCodec::GetFrameBuffer (VIDEOCODEC_PICTURE &picture)
 AddonToKodi interface.
 
void kodi::addon::CInstanceVideoCodec::ReleaseFrameBuffer (void *buffer)
 Release the with GetFrameBuffer() given framebuffer.
 

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.

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);
...
};
CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
: kodi::addon::CInstanceInputStream(instance, kodiVersion)
{
...
}
ADDON_STATUS CMyInputstream::CreateInstance(const kodi::addon::IInstanceInfo& instance,
{
{
{
addonInstance = new CMyVideoCodec(instance, this);
}
}
...
//----------------------------------------------------------------------
class CMyAddon : public kodi::addon::CAddonBase
{
public:
CMyAddon() = default;
};
// 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::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
hdl = new CMyInputstream(instance);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
void * KODI_ADDON_INSTANCE_HDL
Definition addon_base.h:121
KODI_ADDON_HDL * hdl
Definition addon_base.h:344
void * KODI_HANDLE
Standard undefined pointer handle.
Definition addon_base.h:291
Definition kodi-dev-kit/include/kodi/AddonBase.h:775
Definition addon-instance/inputstream.h:1148
Definition VideoCodec.h:248
Definition kodi-dev-kit/include/kodi/AddonBase.h:498
ADDON_STATUS
Definition addon_base.h:138
@ ADDON_STATUS_NOT_IMPLEMENTED
Definition addon_base.h:159
@ 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
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition kodi-dev-kit/include/kodi/AddonBase.h:1938
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:2047
Definition addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h:21
Definition addon_base.h:268

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

Function Documentation

◆ AddData()

virtual bool kodi::addon::CInstanceVideoCodec::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

◆ CInstanceVideoCodec()

kodi::addon::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.

◆ GetFrameBuffer()

bool kodi::addon::CInstanceVideoCodec::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

◆ GetName()

virtual const char * kodi::addon::CInstanceVideoCodec::GetName ( )
inlinevirtual

should return codecs name

Returns
Codec name

◆ GetPicture()

virtual VIDEOCODEC_RETVAL kodi::addon::CInstanceVideoCodec::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

◆ Open()

virtual bool kodi::addon::CInstanceVideoCodec::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 kodi::addon::CInstanceVideoCodec::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

◆ ReleaseFrameBuffer()

void kodi::addon::CInstanceVideoCodec::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

◆ Reset()

virtual void kodi::addon::CInstanceVideoCodec::Reset ( )
inlinevirtual

Reset the decoder.

◆ ~CInstanceVideoCodec()

kodi::addon::CInstanceVideoCodec::~CInstanceVideoCodec ( )
overridedefault

Destructor.