11 #include "../AddonBase.h"
12 #include "../c-api/addon-instance/inputstream.h"
13 #include "inputstream/StreamCodec.h"
14 #include "inputstream/StreamConstants.h"
15 #include "inputstream/StreamCrypto.h"
16 #include "inputstream/TimingConstants.h"
108 class CInstanceInputStream;
125 :
public CStructHdl<InputstreamProperty, INPUTSTREAM_PROPERTY>
149 std::string
GetURL()
const {
return m_cStructure->m_strURL; }
152 std::string
GetMimeType()
const {
return m_cStructure->m_mimeType; }
157 return m_cStructure->m_nCountInfoValues;
163 std::map<std::string, std::string> props;
164 for (
unsigned int i = 0; i < m_cStructure->m_nCountInfoValues; ++i)
166 props.emplace(m_cStructure->m_ListItemProperties[i].m_strKey,
167 m_cStructure->m_ListItemProperties[i].m_strValue);
205 :
public CStructHdl<InputstreamCapabilities, INPUTSTREAM_CAPABILITIES>
229 void SetMask(uint32_t mask)
const { m_cStructure->m_mask = mask; }
232 uint32_t
GetMask()
const {
return m_cStructure->m_mask; }
261 :
public CStructHdl<InputstreamMasteringMetadata, INPUTSTREAM_MASTERING_METADATA>
366 m_cStructure->white_point_chromaticity_x = value;
378 m_cStructure->white_point_chromaticity_y = value;
424 :
public CStructHdl<InputstreamContentlightMetadata, INPUTSTREAM_CONTENTLIGHT_METADATA>
468 void SetMaxCll(uint64_t value) { m_cStructure->max_cll = value; }
477 void SetMaxFall(uint64_t value) { m_cStructure->max_fall = value; }
573 void SetFeatures(uint32_t features) { m_cStructure->m_features = features; }
581 void SetFlags(uint32_t flags) { m_cStructure->m_flags = flags; }
584 uint32_t
GetFlags()
const {
return m_cStructure->m_flags; }
591 strncpy(m_cStructure->m_name, name.c_str(), INPUTSTREAM_MAX_STRING_NAME_SIZE);
595 std::string
GetName()
const {
return m_cStructure->m_name; }
608 strncpy(m_cStructure->m_codecName, codecName.c_str(), INPUTSTREAM_MAX_STRING_CODEC_SIZE);
619 strncpy(m_cStructure->m_codecInternalName, codecName.c_str(),
620 INPUTSTREAM_MAX_STRING_CODEC_SIZE);
631 m_cStructure->m_codecProfile = codecProfile;
650 m_extraData = extraData;
651 m_cStructure->m_ExtraData = m_extraData.data();
652 m_cStructure->m_ExtraSize = m_extraData.size();
662 if (extraData && extraSize > 0)
664 for (
size_t i = 0; i < extraSize; ++i)
665 m_extraData.emplace_back(extraData[i]);
668 m_cStructure->m_ExtraData = m_extraData.data();
669 m_cStructure->m_ExtraSize = m_extraData.size();
685 if (!extraData || m_extraData.size() != extraSize)
687 for (
size_t i = 0; i < extraSize; ++i)
689 if (m_extraData[i] != extraData[i])
699 m_cStructure->m_ExtraData = m_extraData.data();
700 m_cStructure->m_ExtraSize = m_extraData.size();
708 strncpy(m_cStructure->m_language, language.c_str(), INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE);
712 std::string
GetLanguage()
const {
return m_cStructure->m_language; }
717 void SetFpsScale(
unsigned int fpsScale) { m_cStructure->m_FpsScale = fpsScale; }
720 unsigned int GetFpsScale()
const {
return m_cStructure->m_FpsScale; }
725 void SetFpsRate(
unsigned int fpsRate) { m_cStructure->m_FpsRate = fpsRate; }
728 unsigned int GetFpsRate()
const {
return m_cStructure->m_FpsRate; }
733 void SetHeight(
unsigned int height) { m_cStructure->m_Height = height; }
736 unsigned int GetHeight()
const {
return m_cStructure->m_Height; }
741 void SetWidth(
unsigned int width) { m_cStructure->m_Width = width; }
744 unsigned int GetWidth()
const {
return m_cStructure->m_Width; }
749 void SetAspect(
float aspect) { m_cStructure->m_Aspect = aspect; }
752 float GetAspect()
const {
return m_cStructure->m_Aspect; }
757 void SetChannels(
unsigned int channels) { m_cStructure->m_Channels = channels; }
760 unsigned int GetChannels()
const {
return m_cStructure->m_Channels; }
765 void SetSampleRate(
unsigned int sampleRate) { m_cStructure->m_SampleRate = sampleRate; }
773 void SetBitRate(
unsigned int bitRate) { m_cStructure->m_BitRate = bitRate; }
776 unsigned int GetBitRate()
const {
return m_cStructure->m_BitRate; }
783 m_cStructure->m_BitsPerSample = bitsPerSample;
792 void SetBlockAlign(
unsigned int blockAlign) { m_cStructure->m_BlockAlign = blockAlign; }
803 m_cryptoSession = cryptoSession;
804 memcpy(&m_cStructure->m_cryptoSession, m_cryptoSession.GetCStructure(),
814 void SetCodecFourCC(
unsigned int codecFourCC) { m_cStructure->m_codecFourCC = codecFourCC; }
840 m_cStructure->m_colorPrimaries = colorPrimaries;
851 m_cStructure->m_colorTransferCharacteristic = colorTransferCharacteristic;
857 return m_cStructure->m_colorTransferCharacteristic;
870 m_masteringMetadata = masteringMetadata;
871 m_cStructure->m_masteringMetadata = m_masteringMetadata;
877 return m_masteringMetadata;
892 m_contentLightMetadata = contentLightMetadata;
893 m_cStructure->m_contentLightMetadata = m_contentLightMetadata;
899 return m_contentLightMetadata;
915 SetCryptoSession(StreamCryptoSession(&stream->m_cryptoSession));
921 if (m_cStructure->m_ExtraData && m_cStructure->m_ExtraSize > 0)
923 for (
unsigned int i = 0; i < m_cStructure->m_ExtraSize; ++i)
924 m_extraData.emplace_back(m_cStructure->m_ExtraData[i]);
926 if (m_cStructure->m_masteringMetadata)
927 m_masteringMetadata = m_cStructure->m_masteringMetadata;
928 if (m_cStructure->m_contentLightMetadata)
929 m_contentLightMetadata = m_cStructure->m_contentLightMetadata;
931 std::vector<uint8_t> m_extraData;
932 StreamCryptoSession m_cryptoSession;
933 InputstreamMasteringMetadata m_masteringMetadata;
934 InputstreamContentlightMetadata m_contentLightMetadata;
978 void SetStartTime(time_t startTime)
const { m_cStructure->startTime = startTime; }
984 void SetPtsStart(
double ptsStart)
const { m_cStructure->ptsStart = ptsStart; }
990 void SetPtsBegin(
double ptsBegin)
const { m_cStructure->ptsBegin = ptsBegin; }
996 void SetPtsEnd(
double ptsEnd)
const { m_cStructure->ptsEnd = ptsEnd; }
999 double GetPtsEnd()
const {
return m_cStructure->ptsEnd; }
1169 !kodiVersion.empty() ? kodiVersion
1172 if (CAddonBase::m_interface->globalSingleInstance !=
nullptr)
1173 throw std::logic_error(
"kodi::addon::CInstanceInputStream: Creation of multiple together "
1174 "with single instance way is not allowed!");
1176 SetAddonStruct(instance, m_kodiVersion);
1302 virtual int ReadStream(uint8_t* buffer,
unsigned int bufferSize) {
return -1; }
1323 virtual int64_t
SeekStream(int64_t position,
int whence = SEEK_SET) {
return -1; }
1411 virtual bool GetStreamIds(std::vector<unsigned int>& ids) {
return false; }
1550 virtual bool DemuxSeekTime(
double time,
bool backwards,
double& startpts) {
return false; }
1582 return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance,
1598 return m_instanceData->toKodi->allocate_encrypted_demux_packet(
1599 m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount);
1612 return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet);
1764 static int compareVersion(
const int v1[3],
const int v2[3])
1766 for (
unsigned i(0); i < 3; ++i)
1768 return v1[i] - v2[i];
1772 void SetAddonStruct(KODI_HANDLE instance,
const std::string& kodiVersion)
1774 if (instance ==
nullptr)
1775 throw std::logic_error(
"kodi::addon::CInstanceInputStream: Creation with empty addon "
1776 "structure not allowed, table must be given from Kodi!");
1777 int api[3] = { 0, 0, 0 };
1778 sscanf(kodiVersion.c_str(),
"%d.%d.%d", &api[0], &api[1], &api[2]);
1781 m_instanceData->toAddon->addonInstance =
this;
1782 m_instanceData->toAddon->open = ADDON_Open;
1783 m_instanceData->toAddon->close = ADDON_Close;
1784 m_instanceData->toAddon->get_capabilities = ADDON_GetCapabilities;
1786 m_instanceData->toAddon->get_stream_ids = ADDON_GetStreamIds;
1787 m_instanceData->toAddon->get_stream = ADDON_GetStream;
1788 m_instanceData->toAddon->enable_stream = ADDON_EnableStream;
1789 m_instanceData->toAddon->open_stream = ADDON_OpenStream;
1790 m_instanceData->toAddon->demux_reset = ADDON_DemuxReset;
1791 m_instanceData->toAddon->demux_abort = ADDON_DemuxAbort;
1792 m_instanceData->toAddon->demux_flush = ADDON_DemuxFlush;
1793 m_instanceData->toAddon->demux_read = ADDON_DemuxRead;
1794 m_instanceData->toAddon->demux_seek_time = ADDON_DemuxSeekTime;
1795 m_instanceData->toAddon->demux_set_speed = ADDON_DemuxSetSpeed;
1796 m_instanceData->toAddon->set_video_resolution = ADDON_SetVideoResolution;
1798 m_instanceData->toAddon->get_total_time = ADDON_GetTotalTime;
1799 m_instanceData->toAddon->get_time = ADDON_GetTime;
1801 m_instanceData->toAddon->get_times = ADDON_GetTimes;
1802 m_instanceData->toAddon->pos_time = ADDON_PosTime;
1804 m_instanceData->toAddon->read_stream = ADDON_ReadStream;
1805 m_instanceData->toAddon->seek_stream = ADDON_SeekStream;
1806 m_instanceData->toAddon->position_stream = ADDON_PositionStream;
1807 m_instanceData->toAddon->length_stream = ADDON_LengthStream;
1808 m_instanceData->toAddon->is_real_time_stream = ADDON_IsRealTimeStream;
1811 m_instanceData->toAddon->get_chapter = ADDON_GetChapter;
1812 m_instanceData->toAddon->get_chapter_count = ADDON_GetChapterCount;
1813 m_instanceData->toAddon->get_chapter_name = ADDON_GetChapterName;
1814 m_instanceData->toAddon->get_chapter_pos = ADDON_GetChapterPos;
1815 m_instanceData->toAddon->seek_chapter = ADDON_SeekChapter;
1818 m_instanceData->toAddon->block_size_stream = ADDON_GetBlockSize;
1833 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->Open(props);
1838 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->Close();
1844 InputstreamCapabilities caps(capabilities);
1845 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetCapabilities(caps);
1853 std::vector<unsigned int> idList;
1855 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetStreamIds(idList);
1858 for (
size_t i = 0; i < idList.size() && i < INPUTSTREAM_MAX_STREAM_COUNT; ++i)
1860 ids->m_streamCount++;
1861 ids->m_streamIds[i] = idList[i];
1867 inline static bool ADDON_GetStream(
1871 KODI_HANDLE* demuxStream,
1872 KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle,
1876 InputstreamInfo infoData(info);
1877 bool ret =
static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1878 ->GetStream(streamid, infoData);
1879 if (ret && transfer_stream)
1883 *demuxStream = transfer_stream(instance->toKodi->kodiInstance, streamid, info);
1892 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1893 ->EnableStream(streamid, enable);
1898 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1899 ->OpenStream(streamid);
1904 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxReset();
1909 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxAbort();
1914 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxFlush();
1919 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxRead();
1927 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1928 ->DemuxSeekTime(time, backwards, *startpts);
1933 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxSetSpeed(speed);
1940 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1941 ->SetVideoResolution(width, height);
1948 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetTotalTime();
1953 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetTime();
1960 InputstreamTimes cppTimes(times);
1961 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetTimes(cppTimes);
1967 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->PosTime(ms);
1972 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapter();
1977 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapterCount();
1982 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapterName(ch);
1987 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapterPos(ch);
1992 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->SeekChapter(ch);
1997 unsigned int bufferSize)
1999 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
2000 ->ReadStream(buffer, bufferSize);
2007 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
2008 ->SeekStream(position, whence);
2013 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->PositionStream();
2018 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->LengthStream();
2023 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetBlockSize();
2028 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->IsRealTimeStream();
Definition: AddonBase.h:250
Definition: AddonBase.h:186
Definition: Inputstream.h:425
Definition: StreamCrypto.h:43
@ ADDON_INSTANCE_INPUTSTREAM
Input stream instance, see kodi::addon::CInstanceInputStream.
Definition: versions.h:226
void SetMaxCll(uint64_t value)
Set the maximum content light level (MaxCLL).
Definition: Inputstream.h:468
uint64_t GetMaxCll()
Get the maximum content light level (MaxCLL).
Definition: Inputstream.h:471
bool operator==(const kodi::addon::InputstreamContentlightMetadata &right) const
Metadata class compare.
Definition: Inputstream.h:457
void SetMaxFall(uint64_t value)
Set the maximum frame average light level (MaxFALL).
Definition: Inputstream.h:477
uint64_t GetMaxFall()
Get the maximum frame average light level (MaxFALL).
Definition: Inputstream.h:480
std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type)
To get used version inside Kodi itself about asked type.
Definition: AddonBase.h:630
InputStream add-on capabilities. All capabilities are set to "false" as default.
Definition: inputstream.h:95
CONTENTLIGHT Metadata.
Definition: inputstream.h:149
Array of stream IDs.
Definition: inputstream.h:123
stream properties
Definition: inputstream.h:501
MASTERING Metadata.
Definition: inputstream.h:132
structure of key/value pairs passed to addon on Open()
Definition: inputstream.h:104
Definition: inputstream.h:593
Definition: stream_crypto.h:109