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"
108class 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; }
160 std::map<std::string, std::string> props;
161 for (
unsigned int i = 0; i < m_cStructure->m_nCountInfoValues; ++i)
163 props.emplace(m_cStructure->m_ListItemProperties[i].m_strKey,
164 m_cStructure->m_ListItemProperties[i].m_strValue);
202 :
public CStructHdl<InputstreamCapabilities, INPUTSTREAM_CAPABILITIES>
226 void SetMask(uint32_t mask)
const { m_cStructure->m_mask = mask; }
229 uint32_t
GetMask()
const {
return m_cStructure->m_mask; }
258 :
public CStructHdl<InputstreamMasteringMetadata, INPUTSTREAM_MASTERING_METADATA>
365 m_cStructure->white_point_chromaticity_x = value;
377 m_cStructure->white_point_chromaticity_y = value;
423 :
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 =
static_cast<unsigned int>(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 =
static_cast<unsigned int>(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 =
static_cast<unsigned int>(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; }
1163 if (CPrivateBase::m_interface->globalSingleInstance !=
nullptr)
1164 throw std::logic_error(
"kodi::addon::CInstanceInputStream: Creation of multiple together "
1165 "with single instance way is not allowed!");
1167 SetAddonStruct(instance);
1293 virtual int ReadStream(uint8_t* buffer,
unsigned int bufferSize) {
return -1; }
1314 virtual int64_t
SeekStream(int64_t position,
int whence = SEEK_SET) {
return -1; }
1402 virtual bool GetStreamIds(std::vector<unsigned int>& ids) {
return false; }
1541 virtual bool DemuxSeekTime(
double time,
bool backwards,
double& startpts) {
return false; }
1572 unsigned int height,
1573 unsigned int maxWidth,
1574 unsigned int maxHeight)
1589 return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance,
1605 return m_instanceData->toKodi->allocate_encrypted_demux_packet(
1606 m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount);
1619 return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet);
1771 static int compareVersion(
const int v1[3],
const int v2[3])
1773 for (
unsigned i(0); i < 3; ++i)
1775 return v1[i] - v2[i];
1781 int api[3] = {0, 0, 0};
1782 sscanf(GetInstanceAPIVersion().c_str(),
"%d.%d.%d", &api[0], &api[1], &api[2]);
1784 instance->hdl =
this;
1785 instance->inputstream->toAddon->open = ADDON_Open;
1786 instance->inputstream->toAddon->close = ADDON_Close;
1787 instance->inputstream->toAddon->get_capabilities = ADDON_GetCapabilities;
1789 instance->inputstream->toAddon->get_stream_ids = ADDON_GetStreamIds;
1790 instance->inputstream->toAddon->get_stream = ADDON_GetStream;
1791 instance->inputstream->toAddon->enable_stream = ADDON_EnableStream;
1792 instance->inputstream->toAddon->open_stream = ADDON_OpenStream;
1793 instance->inputstream->toAddon->demux_reset = ADDON_DemuxReset;
1794 instance->inputstream->toAddon->demux_abort = ADDON_DemuxAbort;
1795 instance->inputstream->toAddon->demux_flush = ADDON_DemuxFlush;
1796 instance->inputstream->toAddon->demux_read = ADDON_DemuxRead;
1797 instance->inputstream->toAddon->demux_seek_time = ADDON_DemuxSeekTime;
1798 instance->inputstream->toAddon->demux_set_speed = ADDON_DemuxSetSpeed;
1799 instance->inputstream->toAddon->set_video_resolution = ADDON_SetVideoResolution;
1801 instance->inputstream->toAddon->get_total_time = ADDON_GetTotalTime;
1802 instance->inputstream->toAddon->get_time = ADDON_GetTime;
1804 instance->inputstream->toAddon->get_times = ADDON_GetTimes;
1805 instance->inputstream->toAddon->pos_time = ADDON_PosTime;
1807 instance->inputstream->toAddon->read_stream = ADDON_ReadStream;
1808 instance->inputstream->toAddon->seek_stream = ADDON_SeekStream;
1809 instance->inputstream->toAddon->position_stream = ADDON_PositionStream;
1810 instance->inputstream->toAddon->length_stream = ADDON_LengthStream;
1811 instance->inputstream->toAddon->is_real_time_stream = ADDON_IsRealTimeStream;
1814 instance->inputstream->toAddon->get_chapter = ADDON_GetChapter;
1815 instance->inputstream->toAddon->get_chapter_count = ADDON_GetChapterCount;
1816 instance->inputstream->toAddon->get_chapter_name = ADDON_GetChapterName;
1817 instance->inputstream->toAddon->get_chapter_pos = ADDON_GetChapterPos;
1818 instance->inputstream->toAddon->seek_chapter = ADDON_SeekChapter;
1821 instance->inputstream->toAddon->block_size_stream = ADDON_GetBlockSize;
1832 m_instanceData = instance->inputstream;
1833 m_instanceData->toAddon->addonInstance =
this;
1839 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->Open(props);
1844 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->Close();
1850 InputstreamCapabilities caps(capabilities);
1851 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetCapabilities(caps);
1858 std::vector<unsigned int> idList;
1860 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetStreamIds(idList);
1863 for (
size_t i = 0; i < idList.size() && i < INPUTSTREAM_MAX_STREAM_COUNT; ++i)
1865 ids->m_streamCount++;
1866 ids->m_streamIds[i] = idList[i];
1872 inline static bool ADDON_GetStream(
1876 KODI_HANDLE* demuxStream,
1877 KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle,
1881 InputstreamInfo infoData(info);
1882 bool ret =
static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1883 ->GetStream(streamid, infoData);
1884 if (ret && transfer_stream)
1888 *demuxStream = transfer_stream(instance->toKodi->kodiInstance, streamid, info);
1897 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1898 ->EnableStream(streamid, enable);
1903 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1904 ->OpenStream(streamid);
1909 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxReset();
1914 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxAbort();
1919 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxFlush();
1924 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxRead();
1932 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1933 ->DemuxSeekTime(time, backwards, *startpts);
1938 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->DemuxSetSpeed(speed);
1943 unsigned int height,
1944 unsigned int maxWidth,
1945 unsigned int maxHeight)
1947 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1948 ->SetVideoResolution(width, height);
1949 static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
1950 ->SetVideoResolution(width, height, maxWidth, maxHeight);
1956 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetTotalTime();
1961 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetTime();
1968 InputstreamTimes cppTimes(times);
1969 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetTimes(cppTimes);
1975 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->PosTime(ms);
1980 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapter();
1985 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapterCount();
1990 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapterName(ch);
1995 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetChapterPos(ch);
2000 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->SeekChapter(ch);
2005 unsigned int bufferSize)
2007 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
2008 ->ReadStream(buffer, bufferSize);
2015 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)
2016 ->SeekStream(position, whence);
2021 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->PositionStream();
2026 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->LengthStream();
2031 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->GetBlockSize();
2036 return static_cast<CInstanceInputStream*
>(instance->toAddon->addonInstance)->IsRealTimeStream();
Definition AddonBase.h:206
Definition AddonBase.h:565
Definition AddonBase.h:498
Definition Inputstream.h:424
Definition StreamCrypto.h:43
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
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:504
MASTERING Metadata.
Definition inputstream.h:132
structure of key/value pairs passed to addon on Open()
Definition inputstream.h:104
Definition inputstream.h:596
Definition addon_base.h:268
Definition stream_crypto.h:121