11#include "../AddonBase.h"
12#include "../c-api/addon-instance/audioencoder.h"
23class CInstanceAudioEncoder;
75 void SetTitle(
const std::string& title) { m_title = title; }
78 const std::string&
GetTitle()
const {
return m_title; }
81 void SetArtist(
const std::string& artist) { m_artist = artist; }
84 const std::string&
GetArtist()
const {
return m_artist; }
87 void SetAlbum(
const std::string& album) { m_album = album; }
90 const std::string&
GetAlbum()
const {
return m_album; }
93 void SetAlbumArtist(
const std::string& albumArtist) { m_album_artist = albumArtist; }
108 void SetMediaType(
const std::string& mediaType) { m_media_type = mediaType; }
114 void SetGenre(
const std::string& genre) { m_genre = genre; }
117 const std::string&
GetGenre()
const {
return m_genre; }
138 void SetDiscSubtitle(
const std::string& discSubtitle) { m_disc_subtitle = discSubtitle; }
151 void SetReleaseDate(
const std::string& releaseDate) { m_release_date = releaseDate; }
157 void SetLyrics(
const std::string& lyrics) { m_lyrics = lyrics; }
160 const std::string&
GetLyrics()
const {
return m_lyrics; }
187 void SetComment(
const std::string& comment) { m_comment = comment; }
200 m_title = tag->title;
202 m_artist = tag->artist;
204 m_album = tag->album;
205 if (tag->album_artist)
206 m_album_artist = tag->album_artist;
208 m_media_type = tag->media_type;
210 m_genre = tag->genre;
211 m_duration = tag->duration;
212 m_track = tag->track;
215 m_disc_subtitle = tag->artist;
216 m_disc_total = tag->disc_total;
217 if (tag->release_date)
218 m_release_date = tag->release_date;
220 m_lyrics = tag->lyrics;
221 m_samplerate = tag->samplerate;
222 m_channels = tag->channels;
223 m_bits_per_sample = tag->bits_per_sample;
224 m_track_length = tag->track_length;
226 m_comment = tag->comment;
230 std::string m_artist;
232 std::string m_album_artist;
233 std::string m_media_type;
238 std::string m_disc_subtitle;
240 std::string m_release_date;
241 std::string m_lyrics;
244 int m_bits_per_sample{0};
245 int m_track_length{0};
246 std::string m_comment;
399 if (CPrivateBase::m_interface->globalSingleInstance !=
nullptr)
400 throw std::logic_error(
"kodi::addon::CInstanceAudioEncoder: Creation of multiple together "
401 "with single instance way is not allowed!");
403 SetAddonStruct(instance);
425 virtual ssize_t
Encode(
const uint8_t* pbtStream,
size_t numBytesRead) = 0;
447 ssize_t
Write(
const uint8_t* data,
size_t length)
449 return m_kodi->write(m_kodi->kodiInstance, data, length);
474 ssize_t
Seek(ssize_t position,
int whence = SEEK_SET)
476 return m_kodi->seek(m_kodi->kodiInstance, position, whence);
483 instance->hdl =
this;
484 instance->audioencoder->toAddon->start = ADDON_start;
485 instance->audioencoder->toAddon->encode = ADDON_encode;
486 instance->audioencoder->toAddon->finish = ADDON_finish;
487 m_kodi = instance->audioencoder->toKodi;
490 inline static bool ADDON_start(
const KODI_ADDON_AUDIOENCODER_HDL hdl,
493 return static_cast<CInstanceAudioEncoder*
>(hdl)->Start(tag);
496 inline static ssize_t ADDON_encode(
const KODI_ADDON_AUDIOENCODER_HDL hdl,
497 const uint8_t* pbtStream,
498 size_t num_bytes_read)
500 return static_cast<CInstanceAudioEncoder*
>(hdl)->Encode(pbtStream, num_bytes_read);
503 inline static bool ADDON_finish(
const KODI_ADDON_AUDIOENCODER_HDL hdl)
505 return static_cast<CInstanceAudioEncoder*
>(hdl)->Finish();
Definition AudioEncoder.h:40
Definition AudioEncoder.h:361
Definition AddonBase.h:565
Definition AddonBase.h:498
int GetDisc() const
Get disk number (if present)
Definition AudioEncoder.h:135
const std::string & GetAlbumArtist() const
Get album artist name.
Definition AudioEncoder.h:96
void SetDiscSubtitle(const std::string &discSubtitle)
Set disk subtitle name (if present) from music info.
Definition AudioEncoder.h:138
void SetAlbum(const std::string &album)
Set album name.
Definition AudioEncoder.h:87
void SetComment(const std::string &comment)
Set additional information comment (if present).
Definition AudioEncoder.h:187
void SetMediaType(const std::string &mediaType)
Set the media type of the music item.
Definition AudioEncoder.h:108
void SetDuration(int duration)
Set the duration of music as integer from info.
Definition AudioEncoder.h:120
void SetLyrics(const std::string &lyrics)
Set string from lyrics.
Definition AudioEncoder.h:157
const std::string & GetDiscSubtitle() const
Get disk subtitle name (if present) from music info.
Definition AudioEncoder.h:141
const std::string & GetAlbum() const
Get album name.
Definition AudioEncoder.h:90
void SetDiscTotal(int discTotal)
Set disks amount quantity (if present) from music info as integer.
Definition AudioEncoder.h:144
void SetTitle(const std::string &title)
Set the title from music as string on info tag.
Definition AudioEncoder.h:75
const std::string & GetMediaType() const
Get the media type of the music item.
Definition AudioEncoder.h:111
const std::string & GetReleaseDate() const
Get release date as string from music info (if present).
Definition AudioEncoder.h:154
void SetDisc(int disc)
Set disk number (if present) from music info as integer.
Definition AudioEncoder.h:132
void SetTrackLength(int track_length)
Set related stream track length.
Definition AudioEncoder.h:181
void SetArtist(const std::string &artist)
Set artist name.
Definition AudioEncoder.h:81
void SetAlbumArtist(const std::string &albumArtist)
Set album artist name.
Definition AudioEncoder.h:93
void SetChannels(int channels)
Set related stream channels amount.
Definition AudioEncoder.h:169
const std::string & GetComment() const
Get additional information comment (if present).
Definition AudioEncoder.h:190
int GetBitsPerSample() const
Get related stream bits per sample.
Definition AudioEncoder.h:178
int GetDuration() const
Get the duration of music as integer from info.
Definition AudioEncoder.h:123
void SetTrack(int track)
Set track number (if present) from music info as integer.
Definition AudioEncoder.h:126
const std::string & GetGenre() const
Get genre name from music as string if present.
Definition AudioEncoder.h:117
int GetTrackLength() const
Get related stream track length.
Definition AudioEncoder.h:184
void SetReleaseDate(const std::string &releaseDate)
Set release date as string from music info (if present). ISO8601 date YYYY, YYYY-MM or YYYY-MM-DD.
Definition AudioEncoder.h:151
const std::string & GetLyrics() const
Get string from lyrics.
Definition AudioEncoder.h:160
void SetBitsPerSample(int bits_per_sample)
Set related stream bits per sample.
Definition AudioEncoder.h:175
const std::string & GetTitle() const
Get title name.
Definition AudioEncoder.h:78
void SetSamplerate(int samplerate)
Set related stream samplerate.
Definition AudioEncoder.h:163
int GetDiscTotal() const
Get disks amount quantity (if present)
Definition AudioEncoder.h:147
int GetTrack() const
Get track number (if present).
Definition AudioEncoder.h:129
void SetGenre(const std::string &genre)
Set genre name from music as string if present.
Definition AudioEncoder.h:114
int GetChannels() const
Get related stream channels amount.
Definition AudioEncoder.h:172
const std::string & GetArtist() const
Get artist name.
Definition AudioEncoder.h:84
int GetSamplerate() const
Get related stream samplerate.
Definition AudioEncoder.h:166
virtual bool Finish()
Finalize encoding (optional)
Definition AudioEncoder.h:434
ssize_t Write(const uint8_t *data, size_t length)
Write block of data.
Definition AudioEncoder.h:447
virtual bool Start(const kodi::addon::AudioEncoderInfoTag &tag)=0
Start encoder (required)
ssize_t Seek(ssize_t position, int whence=SEEK_SET)
Set the file's current position.
Definition AudioEncoder.h:474
virtual ssize_t Encode(const uint8_t *pbtStream, size_t numBytesRead)=0
Encode a chunk of audio (required)
CInstanceAudioEncoder(const kodi::addon::IInstanceInfo &instance)
Audio encoder class constructor used to support multiple instances.
Definition AudioEncoder.h:396
Definition audioencoder.h:51
Definition audioencoder.h:22
Definition addon_base.h:268
Definition visualization.h:22