For audio encoders as binary add-ons. This class implements a way to handle the encode of given stream to a new format.
The addon.xml defines the capabilities of this add-on.
#include <kodi/addon-instance/AudioEncoder.h>
{
public:
CMyAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion)
: kodi::addon::CInstanceAudioEncoder(instance, kodiVersion)
bool Init(const std::string& filename, unsigned int filecache,
int& channels, int& samplerate,
int& bitspersample, int64_t& totaltime,
int& bitrate, AEDataFormat& format,
std::vector<AEChannel>& channellist) override;
int Encode(int numBytesRead, const uint8_t* pbtStream) override;
bool Finish() override;
};
CMyAudioEncoder::CMyAudioEncoder(KODI_HANDLE instance)
: kodi::addon::CInstanceAudioEncoder(instance)
{
...
}
bool CMyAudioEncoder::Start(int inChannels,
int inRate,
int inBits,
const std::string& title,
const std::string& artist,
const std::string& albumartist,
const std::string& album,
const std::string& year,
const std::string& track,
const std::string& genre,
const std::string& comment,
int trackLength)
{
...
return true;
}
int CMyAudioEncoder::Encode(int numBytesRead, const uint8_t* pbtStream)
{
uint8_t* data = nullptr;
int length = 0;
...
return 0;
}
bool CMyAudioEncoder::Finish()
{
...
return true;
}
{
public:
CMyAddon() = default;
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
};
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
{
addonInstance = new CMyAudioEncoder(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition: AddonBase.h:322
Definition: AudioEncoder.h:152
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:177
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_AUDIOENCODER
Audio encoder instance, see kodi::addon::CInstanceAudioEncoder.
Definition: versions.h:220
virtual ADDON_STATUS CreateInstance(int instanceType, const std::string &instanceID, KODI_HANDLE instance, const std::string &version, KODI_HANDLE &addonInstance)
Instance created.
Definition: AddonBase.h:481
int Write(const uint8_t *data, int length)
Write block of data.
Definition: AudioEncoder.h:268
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749