Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::ConnectStreamPlaybackUtil Class Reference

#include <stream_util_connect.hpp>

Inheritance diagram for kanzi::connect::ConnectStreamPlaybackUtil:
kanzi::connect::StreamPlaybackUtil kanzi::connect::StreamPlaybackUtil_zlib

Classes

class  FpsCounter
 A helper class that can be used to measure events per second. More...
 

Public Member Functions

const string & getAuxData () const
 Get the optional data from encoder or stream provider. More...
 
void startDecoderThread ()
 Perform decoding on a dedicated thread. Deriving class should call this function after it has initialized the infra for decoding. More...
 
void stopDecoderThread ()
 Perform decoding on main thread. Releases Decoder thread if it exists. More...
 
 ~ConnectStreamPlaybackUtil () KZ_OVERRIDE
 Destructor. More...
 
kzUint getWidth () KZ_OVERRIDE
 
kzUint getHeight () KZ_OVERRIDE
 Gets height of video frame. More...
 
kanzi::FramebufferSharedPtr getNextRenderBuffer () KZ_OVERRIDE
 
void onRendering () KZ_OVERRIDE
 notify frame consumed More...
 
- Public Member Functions inherited from kanzi::connect::StreamPlaybackUtil
virtual ~StreamPlaybackUtil ()
 

Static Public Member Functions

static shared_ptr< ConnectStreamPlaybackUtilcreate (Domain &domain, const string &streamId, function< void()> onProcessSampleTask, FrameBufferFactorySharedPtr bufferFactory)
 Create new stream playback util. More...
 

Protected Member Functions

 ConnectStreamPlaybackUtil (function< void()> onProcessSampleTask, int queueMaxLength, bool dropOldOnKeyFrame)
 Constructor. More...
 
virtual bool doDecode (const string &in, vector< char > &out)
 Decode frame from buffer. More...
 
bool hasConfigFrame (const StreamNewBlobEvent &blobMessage) const
 Check if the message contains a configuration frame for the encoder. More...
 
bool hasKeyFrame (const StreamNewBlobEvent &blobMessage) const
 Check if the message contains a key frame. More...
 
bool hasPartialFrame (const StreamNewBlobEvent &blobMessage) const
 Check if the message contains a partial frame. More...
 
bool initialize (Domain &domain, const string &streamId, FrameBufferFactorySharedPtr bufferFactory) KZ_OVERRIDE
 Initializes video util. More...
 
bool queueHasSpace () const
 Check if the data queue has space to add more items. More...
 
void queueRenderBuffer (FramebufferSharedPtr framebuffer)
 Add a buffer to ui-queue. More...
 
virtual void remoteSettingsChanged (bool wasValid, bool isValid)
 Callback from runtime data observer. More...
 
void requestEncoderParameter (const string &parameterName) const
 
void requestStreamInfo () const
 
void restartEncoder () const
 
void setEncoderParameter (const string &parameterName, const string &parameterValue) const
 
virtual bool shouldProcessThisFrame (const StreamNewBlobEvent &blobMessage)
 Check if this message should be passed to the decoder Decoder implementations should implement this function e.g. More...
 
void uninitialize () KZ_OVERRIDE
 Uninitializes video util. More...
 
virtual void updateVideoSurfaceTexture ()
 Populate framebuffer with data received from doDecode and queue render buffer for UI. More...
 

Constructor & Destructor Documentation

◆ ~ConnectStreamPlaybackUtil()

kanzi::connect::ConnectStreamPlaybackUtil::~ConnectStreamPlaybackUtil ( )

Destructor.

◆ ConnectStreamPlaybackUtil()

kanzi::connect::ConnectStreamPlaybackUtil::ConnectStreamPlaybackUtil ( function< void()>  onProcessSampleTask,
int  queueMaxLength,
bool  dropOldOnKeyFrame 
)
explicitprotected

Constructor.

Member Function Documentation

◆ create()

static shared_ptr<ConnectStreamPlaybackUtil> kanzi::connect::ConnectStreamPlaybackUtil::create ( Domain &  domain,
const string &  streamId,
function< void()>  onProcessSampleTask,
FrameBufferFactorySharedPtr  bufferFactory 
)
static

Create new stream playback util.

By default the class is using either zlib or zstd compression engine for decoding frames.

Parameters
domainKanzi::Domain that is used for obtaining Connect server connection
streamIdIdentifier of the stream to listen.
onProcessSampleTaskCallback to Kanzi to invalidate and re-render node hosting the playback util
bufferFactoryInstance of framebuffer provider to be used.
Returns
New playback util on success, otherwise empty pointer.

◆ doDecode()

virtual bool kanzi::connect::ConnectStreamPlaybackUtil::doDecode ( const string &  in,
vector< char > &  out 
)
protectedvirtual

Decode frame from buffer.

If output is pixel data, provide it to output buffer and return true. Depending on threading strategy, runs either on dedicated thread or within the main thread,

See also
startDecoderThread()
Parameters
inInput buffer as raw string. Connect infra has no knowledge on the contents. May contain a full or partial frame.
outOptional. If decoder provides pixels to be rendered, they need to be populated here. Decoder may use received input and pass a gpu handle to kanzi using getNextRenderBuffer instead.
Returns
Return true if output buffer is to be used. Class asks Kanzi to re-render if true is returned and creates new framebuffer with data.

Reimplemented in kanzi::connect::StreamPlaybackUtil_zlib.

◆ getAuxData()

const string& kanzi::connect::ConnectStreamPlaybackUtil::getAuxData ( ) const
inline

Get the optional data from encoder or stream provider.

◆ getHeight()

kzUint kanzi::connect::ConnectStreamPlaybackUtil::getHeight ( )
virtual

Gets height of video frame.

Returns
Height of video frame.

Implements kanzi::connect::StreamPlaybackUtil.

◆ getNextRenderBuffer()

kanzi::FramebufferSharedPtr kanzi::connect::ConnectStreamPlaybackUtil::getNextRenderBuffer ( )
virtual
Returns
image texture.

Implements kanzi::connect::StreamPlaybackUtil.

◆ getWidth()

kzUint kanzi::connect::ConnectStreamPlaybackUtil::getWidth ( )
virtual

◆ hasConfigFrame()

bool kanzi::connect::ConnectStreamPlaybackUtil::hasConfigFrame ( const StreamNewBlobEvent blobMessage) const
protected

Check if the message contains a configuration frame for the encoder.

Parameters
blobMessageThe message
Returns
True if message contains configuration frame

◆ hasKeyFrame()

bool kanzi::connect::ConnectStreamPlaybackUtil::hasKeyFrame ( const StreamNewBlobEvent blobMessage) const
protected

Check if the message contains a key frame.

Parameters
blobMessageThe message
Returns
True if message contains key frame

◆ hasPartialFrame()

bool kanzi::connect::ConnectStreamPlaybackUtil::hasPartialFrame ( const StreamNewBlobEvent blobMessage) const
protected

Check if the message contains a partial frame.

Parameters
blobMessageThe message
Returns
True if message contains partial frame

◆ initialize()

bool kanzi::connect::ConnectStreamPlaybackUtil::initialize ( Domain &  domain,
const string &  streamId,
FrameBufferFactorySharedPtr  bufferFactory 
)
protectedvirtual

Initializes video util.

Implements kanzi::connect::StreamPlaybackUtil.

◆ onRendering()

void kanzi::connect::ConnectStreamPlaybackUtil::onRendering ( )
virtual

notify frame consumed

Implements kanzi::connect::StreamPlaybackUtil.

◆ queueHasSpace()

bool kanzi::connect::ConnectStreamPlaybackUtil::queueHasSpace ( ) const
protected

Check if the data queue has space to add more items.

Returns
True if there is space

◆ queueRenderBuffer()

void kanzi::connect::ConnectStreamPlaybackUtil::queueRenderBuffer ( FramebufferSharedPtr  framebuffer)
protected

Add a buffer to ui-queue.

◆ remoteSettingsChanged()

virtual void kanzi::connect::ConnectStreamPlaybackUtil::remoteSettingsChanged ( bool  wasValid,
bool  isValid 
)
protectedvirtual

Callback from runtime data observer.

◆ requestEncoderParameter()

void kanzi::connect::ConnectStreamPlaybackUtil::requestEncoderParameter ( const string &  parameterName) const
protected

◆ requestStreamInfo()

void kanzi::connect::ConnectStreamPlaybackUtil::requestStreamInfo ( ) const
protected

◆ restartEncoder()

void kanzi::connect::ConnectStreamPlaybackUtil::restartEncoder ( ) const
protected

◆ setEncoderParameter()

void kanzi::connect::ConnectStreamPlaybackUtil::setEncoderParameter ( const string &  parameterName,
const string &  parameterValue 
) const
protected

◆ shouldProcessThisFrame()

virtual bool kanzi::connect::ConnectStreamPlaybackUtil::shouldProcessThisFrame ( const StreamNewBlobEvent blobMessage)
protectedvirtual

Check if this message should be passed to the decoder Decoder implementations should implement this function e.g.

to make sure that they will wait for correct amount of configuration and key frames before proceeding to normal operation

Parameters
blobMessagecontains the message from stream provider.
Returns
True if the message should be passed to the decoder pipeline (default implementation always returns true)

◆ startDecoderThread()

void kanzi::connect::ConnectStreamPlaybackUtil::startDecoderThread ( )

Perform decoding on a dedicated thread. Deriving class should call this function after it has initialized the infra for decoding.

◆ stopDecoderThread()

void kanzi::connect::ConnectStreamPlaybackUtil::stopDecoderThread ( )

Perform decoding on main thread. Releases Decoder thread if it exists.

◆ uninitialize()

void kanzi::connect::ConnectStreamPlaybackUtil::uninitialize ( )
protectedvirtual

Uninitializes video util.

Implements kanzi::connect::StreamPlaybackUtil.

◆ updateVideoSurfaceTexture()

virtual void kanzi::connect::ConnectStreamPlaybackUtil::updateVideoSurfaceTexture ( )
protectedvirtual

Populate framebuffer with data received from doDecode and queue render buffer for UI.

This class implements a pipeline for software rendering.


The documentation for this class was generated from the following file: