Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches

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(const kodi::addon::IInstanceInfo& instance);
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;
ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl) override;
};
// 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_ADDON_INSTANCE_HDL& hdl)
{
{
kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
hdl = new CMyInputstream(instance);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition AddonBase.h:775
Definition Inputstream.h:1148
Definition AddonBase.h:498
Definition Inputstream.h:203
Definition 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:228
bool IsType(KODI_ADDON_INSTANCE_TYPE type) const
Check asked type used on this class.
Definition AddonBase.h:525
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:226
@ 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
virtual bool Open(const kodi::addon::InputstreamProperty &props)=0
Open a stream.
virtual void Close()=0
Close an open stream.
virtual void GetCapabilities(kodi::addon::InputstreamCapabilities &capabilities)=0
Get the list of features that this add-on provides.
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938

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

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.
 

Function Documentation

◆ 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.

◆ ~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:158

◆ 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