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

Class: kodi::addon::CInstanceInputStream

Inputstream add-on instance More...

Topics

 Definitions, structures and enumerators
 Inputstream add-on instance definition values
All inputstream functions associated data structures.
 
 1. Stream read
 Functions required to read streams direct and demux inside Kodi.
 
 2. Stream demuxing (optional)
 Read demux streams.
 
 3. Time (optional)
 To get stream position time.
 
 4. Times (optional)
 Another way to get stream position time.
 
 5. Position time (optional)
 Third way get stream position time.
 
 6. Chapter (optional)
 Used to get available chapters.
 

Functions

 kodi::addon::CInstanceInputStream::CInstanceInputStream (const IInstanceInfo &instance)
 Inputstream class constructor used to support multiple instance types.
 
 kodi::addon::CInstanceInputStream::~CInstanceInputStream () override=default
 Destructor.
 
virtual void kodi::addon::CInstanceInputStream::GetCapabilities (kodi::addon::InputstreamCapabilities &capabilities)=0
 Get the list of features that this add-on provides.
 
virtual bool kodi::addon::CInstanceInputStream::Open (const kodi::addon::InputstreamProperty &props)=0
 Open a stream.
 
virtual void kodi::addon::CInstanceInputStream::Close ()=0
 Close an open stream.
 
virtual bool kodi::addon::CInstanceInputStream::IsRealTimeStream ()
 Check for real-time streaming.
 

Detailed Description

Class: kodi::addon::CInstanceInputStream

Inputstream add-on instance

This instance type is for using input streams to video and audio, to process and then give them to Kodi.

This usage can be requested under various conditions, for example explicitly by another addon, by a Mimetype protocol defined in addon.xml or supported file extensions.

In addition, stream files (* .strm) can be linked to an inputstream addon using #KODIPROP:inputstream=<ADDON_NAME>.

Include the header #include <kodi/addon-instance/Inputstream.h> to use this class.


Here is an example of what the addon.xml.in would look like for an inputstream addon:

<?xml version="1.0" encoding="UTF-8"?>
<addon
id="inputstream.myspecialnamefor"
version="1.0.0"
name="My InputStream addon"
provider-name="Your Name">
<requires>@ADDON_DEPENDS@</requires>
<extension
point="kodi.inputstream"
extension=".xyz|.zyx"
listitemprops="license_type|license_key|license_data|license_flags"
protocols="myspecialnamefor|myspecialnamefors"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">My InputStream addon</summary>
<description lang="en_GB">My InputStream description</description>
<platform>@PLATFORM@</platform>
</extension>
</addon>

At <extension point="kodi.inputstream" ...> the basic instance definition is declared, this is intended to identify the addon as an input stream and to see its supported types:

Name Description
point The identification of the addon instance to inputstream is mandatory kodi.inputstream. In addition, the instance declared in the first <extension ... /> is also
extension A filename extension is an identifier specified as a suffix to the name of a computer file where supported by addon.
listitemprops Values that are available to the addon at InputstreamProperty::GetProperties() and that can be passed to CInstanceInputStream::Open() ith the respective values.
protocols The streaming protocol is a special protocol supported by the addon for the transmission of streaming media data over a network.
library_@PLATFORM@ The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated addon.xml.
Remarks
For more detailed description of the addon.xml, see also https://kodi.wiki/view/Addon.xml.

Example:

class CMyInputstream : public kodi::addon::CInstanceInputStream
{
public:
CMyInputstream(const kodi::addon::IInstanceInfo& instance);
void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) override;
bool Open(const kodi::addon::InputstreamProperty& props) override;
void Close() override;
...
};
CMyInputstream::CMyInputstream(const kodi::addon::IInstanceInfo& instance)
: kodi::addon::CInstanceInputStream(instance)
{
...
}
void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities)
{
}
void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props)
{
std::string url = props.GetURL();
...
}
void CMyInputstream::Close()
{
...
}
...
//----------------------------------------------------------------------
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)
file Close()
void * KODI_ADDON_INSTANCE_HDL
Definition addon_base.h:121
KODI_ADDON_HDL * hdl
Definition addon_base.h:344
Definition kodi-dev-kit/include/kodi/AddonBase.h:583
Definition addon-instance/Inputstream.h:1148
Definition kodi-dev-kit/include/kodi/AddonBase.h:306
Definition addon-instance/Inputstream.h:203
Definition addon-instance/Inputstream.h:126
ADDON_STATUS
Definition addon_base.h:138
@ 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:227
std::string GetURL() const
Stream URL to open.
Definition addon-instance/Inputstream.h:149
void SetMask(uint32_t mask) const
Set of supported capabilities.
Definition addon-instance/Inputstream.h:226
@ INPUTSTREAM_SUPPORTS_PAUSE
0000 0000 0001 0000 : Supports pause
Definition c-api/addon-instance/Inputstream.h:73
@ INPUTSTREAM_SUPPORTS_IDEMUX
0000 0000 0000 0001 : Supports interface demuxing.
Definition c-api/addon-instance/Inputstream.h:52
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:1746
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:1855
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

◆ CInstanceInputStream()

kodi::addon::CInstanceInputStream::CInstanceInputStream ( const IInstanceInfo & instance)
inlineexplicit

Inputstream class constructor used to support multiple instance types.

Parameters
[in]instanceThe instance value given to kodi::addon::CAddonBase::CreateInstance(...)
[in]kodiVersion[opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions.
Warning
Only use instance from the CAddonBase::CreateInstance call.

◆ Close()

virtual void kodi::addon::CInstanceInputStream::Close ( )
pure virtual

Close an open stream.

Remarks

Note
Valid implementation required.

◆ GetCapabilities()

virtual void kodi::addon::CInstanceInputStream::GetCapabilities ( kodi::addon::InputstreamCapabilities & capabilities)
pure virtual

Get the list of features that this add-on provides.

Called by Kodi to query the add-on's capabilities. Used to check which options should be presented in the UI, which methods to call, etc. All capabilities that the add-on supports should be set to true.

Parameters
[out]capabilitiesThe with cpp_kodi_addon_inputstream_Defs_Capabilities defined add-on's capabilities.

The following table contains values that can be set with class InputstreamCapabilities :

Name Type Set call Get call
Capabilities bit mask uint32_t SetMask GetMask

Note
Valid implementation required.

Example:

void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities)
{
}

◆ IsRealTimeStream()

virtual bool kodi::addon::CInstanceInputStream::IsRealTimeStream ( )
inlinevirtual

Check for real-time streaming.

Returns
true if current stream is real-time

◆ Open()

virtual bool kodi::addon::CInstanceInputStream::Open ( const kodi::addon::InputstreamProperty & props)
pure virtual

Open a stream.

Parameters
[in]propsThe used properties about the stream
Returns
True if the stream has been opened successfully, false otherwise.

The following table contains values that can be set with class InputstreamProperty :

Name Type Get call
Stream URL std::string GetURL
Mime type std::string GetMimeType
Available amount of properties unsigned int GetPropertiesAmount
List of properties std::map<std::string, std::string> GetProperties
Get addon library folder std::string GetLibFolder
Get addon profile/user folder std::string GetProfileFolder

Note
Valid implementation required.

Example:

void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props)
{
std::string url = props.GetURL();
std::string license_key = props.GetProperties()["inputstream.myspecialnamefor.license_key"];
...
}
const std::map< std::string, std::string > GetProperties() const
List of available properties-.
Definition addon-instance/Inputstream.h:158

◆ ~CInstanceInputStream()

kodi::addon::CInstanceInputStream::~CInstanceInputStream ( )
overridedefault

Destructor.