Kanzi Connect  3.9.9
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_openh264

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 () override
 Destructor. More...
 
unsigned int getWidth () override
 
unsigned int getHeight () override
 Gets height of video frame. More...
 
void onRendering () 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, FrameReceiverSharedPtr host)
 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, PixelFrame &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, FrameReceiverSharedPtr frameReceiver) override
 Initializes video util. More...
 
bool queueHasSpace () const
 Check if the data queue has space to add more items. 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 () override
 Uninitializes video util. More...
 

Protected Attributes

FrameReceiverWeakPtr m_frameReceiver
 

Constructor & Destructor Documentation

◆ ~ConnectStreamPlaybackUtil()

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

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,
FrameReceiverSharedPtr  host 
)
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,
PixelFrame 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.

◆ getAuxData()

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

Get the optional data from encoder or stream provider.

◆ getHeight()

unsigned int kanzi::connect::ConnectStreamPlaybackUtil::getHeight ( )
overridevirtual

Gets height of video frame.

Returns
Height of video frame.

Implements kanzi::connect::StreamPlaybackUtil.

◆ getWidth()

unsigned int kanzi::connect::ConnectStreamPlaybackUtil::getWidth ( )
overridevirtual

◆ 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,
FrameReceiverSharedPtr  frameReceiver 
)
overrideprotectedvirtual

Initializes video util.

Implements kanzi::connect::StreamPlaybackUtil.

◆ onRendering()

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

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

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

Reimplemented in kanzi::connect::StreamPlaybackUtil_openh264.

◆ 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 ( )
overrideprotectedvirtual

Uninitializes video util.

Implements kanzi::connect::StreamPlaybackUtil.

Member Data Documentation

◆ m_frameReceiver

FrameReceiverWeakPtr kanzi::connect::ConnectStreamPlaybackUtil::m_frameReceiver
protected

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