Kodi Development  20.0
for Binary and Script based Add-Ons

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:

#include <kodi/addon-instance/Inputstream.h>
class CMyInputstream : public kodi::addon::CInstanceInputStream
{
public:
CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion);
void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) override;
bool Open(const kodi::addon::InputstreamProperty& props) override;
void Close() override;
...
};
CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
: kodi::addon::CInstanceInputStream(instance, kodiVersion)
{
...
}
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;
ADDON_STATUS CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
};
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
if (instanceType == ADDON_INSTANCE_INPUTSTREAM)
{
kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
addonInstance = new CMyInputstream(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition: AddonBase.h:322
Definition: Inputstream.h:1154
Definition: Inputstream.h:206
Definition: Inputstream.h:126
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_INPUTSTREAM
Input stream instance, see kodi::addon::CInstanceInputStream.
Definition: versions.h:226
std::string GetURL() const
Stream URL to open.
Definition: Inputstream.h:149
void SetMask(uint32_t mask) const
Set of supported capabilities.
Definition: Inputstream.h:229
@ INPUTSTREAM_SUPPORTS_PAUSE
0000 0000 0001 0000 : Supports pause
Definition: inputstream.h:73
@ INPUTSTREAM_SUPPORTS_IDEMUX
0000 0000 0000 0001 : Supports interface demuxing.
Definition: inputstream.h:52
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749

The destruction of the example class CMyInputstream is called from Kodi's header. Manually deleting the add-on instance is not required.

Modules

 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.
 

Function Documentation

◆ CInstanceInputStream()

CInstanceInputStream ( KODI_HANDLE  instance,
const std::string &  kodiVersion = "" 
)
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.

◆ ~CInstanceInputStream()

~CInstanceInputStream ( )
overridedefault

Destructor.

◆ GetCapabilities()

virtual void 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)
{
}

◆ Open()

virtual bool 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: Inputstream.h:161

◆ Close()

virtual void Close ( )
pure virtual

Close an open stream.

Remarks

Note
Valid implementation required.

◆ IsRealTimeStream()

virtual bool IsRealTimeStream ( )
inlinevirtual

Check for real-time streaming.

Returns
true if current stream is real-time