Kodi Development  20.0
for Binary and Script based Add-Ons

Detailed Description

PVR stream demuxing
Read TV streams with own demux within addon.

This is only on Live TV streams and only if PVRCapabilities::SetHandlesDemuxing() has been set to "true".


Stream demuxing parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Header parts:

PVR_ERROR GetStreamProperties(std::vector<kodi::addon::PVRStreamProperties>& properties) override;
DEMUX_PACKET* DemuxRead() override;
void DemuxReset() override;
void DemuxAbort() override;
void DemuxFlush() override;
void SetSpeed(int speed) override;
void FillBuffer(bool mode) override;
bool SeekTime(double time, bool backwards, double& startpts) override;
Definition: demux_packet.h:46
PVR_ERROR
Definition: pvr_general.h:35
virtual PVR_ERROR GetStreamProperties(std::vector< kodi::addon::PVRStreamProperties > &properties)
Get the stream properties of the stream that's currently being read.
Definition: PVR.h:2427
virtual void DemuxReset()
Reset the demultiplexer in the add-on.
Definition: PVR.h:2455
virtual void DemuxAbort()
Abort the demultiplexer thread in the add-on.
Definition: PVR.h:2463
virtual DEMUX_PACKET * DemuxRead()
Read the next packet from the demultiplexer, if there is one.
Definition: PVR.h:2447
virtual void DemuxFlush()
Flush all data that's currently in the demultiplexer buffer in the add-on.
Definition: PVR.h:2472
virtual bool SeekTime(double time, bool backwards, double &startpts)
Notify the pvr addon/demuxer that Kodi wishes to seek the stream by time.
Definition: PVR.h:2508
virtual void SetSpeed(int speed)
Notify the pvr addon/demuxer that Kodi wishes to change playback speed.
Definition: PVR.h:2483
virtual void FillBuffer(bool mode)
Notify the pvr addon/demuxer that Kodi wishes to fill demux queue.
Definition: PVR.h:2493

Source parts:

PVR_ERROR CMyInstance::GetStreamProperties(std::vector<kodi::addon::PVRStreamProperties>& properties)
{
}
DEMUX_PACKET* CMyInstance::DemuxRead()
{
return nullptr;
}
void CMyInstance::DemuxReset()
{
}
void CMyInstance::DemuxAbort()
{
}
void CMyInstance::DemuxFlush()
{
}
void CMyInstance::SetSpeed(int speed)
{
}
void CMyInstance::FillBuffer(bool mode)
{
}
bool CMyInstance::SeekTime(double time, bool backwards, double& startpts)
{
return false;
}
@ PVR_ERROR_NOT_IMPLEMENTED
-2 : The method that Kodi called is not implemented by the add-on.
Definition: pvr_general.h:43

Modules

 Group header include
 
 Group source include
 

Function Documentation

◆ GetStreamProperties()

virtual PVR_ERROR GetStreamProperties ( std::vector< kodi::addon::PVRStreamProperties > &  properties)
inlinevirtual

Get the stream properties of the stream that's currently being read.

Parameters
[in]propertiesThe properties of the currently playing stream.
Returns
PVR_ERROR_NO_ERROR if the properties have been fetched successfully.
Remarks
Required, and only used if addon has its own demuxer.

◆ DemuxRead()

virtual DEMUX_PACKET* DemuxRead ( )
inlinevirtual

Read the next packet from the demultiplexer, if there is one.

Returns
The next packet. If there is no next packet, then the add-on should return the packet created by calling AllocateDemuxPacket(0) on the callback. If the stream changed and Kodi's player needs to be reinitialised, then, the add-on should call AllocateDemuxPacket(0) on the callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and return the value. The add-on should return nullptr if an error occurred.
Remarks
Required, and only used if addon has its own demuxer. Return nullptr if this add-on won't provide this function.

◆ DemuxReset()

virtual void DemuxReset ( )
inlinevirtual

Reset the demultiplexer in the add-on.

Remarks
Required, and only used if addon has its own demuxer.

◆ DemuxAbort()

virtual void DemuxAbort ( )
inlinevirtual

Abort the demultiplexer thread in the add-on.

Remarks
Required, and only used if addon has its own demuxer.

◆ DemuxFlush()

virtual void DemuxFlush ( )
inlinevirtual

Flush all data that's currently in the demultiplexer buffer in the add-on.

Remarks
Required, and only used if addon has its own demuxer.

◆ SetSpeed()

virtual void SetSpeed ( int  speed)
inlinevirtual

Notify the pvr addon/demuxer that Kodi wishes to change playback speed.

Parameters
[in]speedThe requested playback speed
Remarks
Optional, and only used if addon has its own demuxer.

◆ FillBuffer()

virtual void FillBuffer ( bool  mode)
inlinevirtual

Notify the pvr addon/demuxer that Kodi wishes to fill demux queue.

Parameters
[in]modeThe requested filling mode
Remarks
Optional, and only used if addon has its own demuxer.

◆ SeekTime()

virtual bool SeekTime ( double  time,
bool  backwards,
double &  startpts 
)
inlinevirtual

Notify the pvr addon/demuxer that Kodi wishes to seek the stream by time.

Parameters
[in]timeThe absolute time since stream start
[in]backwardsTrue to seek to keyframe BEFORE time, else AFTER
[in]startptscan be updated to point to where display should start
Returns
True if the seek operation was possible
Remarks
Optional, and only used if addon has its own demuxer. Return False if this add-on won't provide this function.

◆ GetCodecByName()

PVRCodec GetCodecByName ( const std::string &  codecName) const
inline

Callback to Kodi Function
Get the codec id used by Kodi.

Parameters
[in]codecNameThe name of the codec
Returns
The codec_id, or a codec_id with 0 values when not supported
Remarks
Only called from addon itself

◆ AllocateDemuxPacket()

DEMUX_PACKET* AllocateDemuxPacket ( int  iDataSize)
inline

Callback to Kodi Function
Allocate a demux packet. Free with FreeDemuxPacket().

Parameters
[in]iDataSizeThe size of the data that will go into the packet
Returns
The allocated packet
Remarks
Only called from addon itself

◆ FreeDemuxPacket()

void FreeDemuxPacket ( DEMUX_PACKET pPacket)
inline

Callback to Kodi Function
Free a packet that was allocated with AllocateDemuxPacket().

Parameters
[in]pPacketThe packet to free
Remarks
Only called from addon itself.