SmartSpectra C++ SDK
Measure human vitals from video with SmartSpectra C++ SDK.
Loading...
Searching...
No Matches
presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode > Class Template Reference

#include <file_ipc_stream_writer.hpp>

Inheritance diagram for presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >:
presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >

Public Types

using Base = ipc::IpcStreamWriter<TIntegrationMode>
using BackgroundContainer
Public Types inherited from presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >
using BackgroundContainer

Public Member Functions

 FileIpcStreamWriter (const FileIpcConfiguration &configuration)
absl::Status WriteStatus (const presage::physiology::StatusValue &status) override
absl::Status WriteCoreMetrics (const presage::physiology::MetricsBuffer &metrics, int64_t timestamp_us) override
absl::Status WriteEdgeMetrics (const presage::physiology::Metrics &metrics, int64_t timestamp_us) override
absl::Status WriteFrame (const cv::Mat &frame, int64_t timestamp_us) override
void Close () override
bool IsOperational () const override
absl::Status Flush () override
Public Member Functions inherited from presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >
virtual absl::Status SwapContainer (std::shared_ptr< BackgroundContainer > new_container)
const BackgroundContainerGetContainer () const

Protected Member Functions

absl::Status Initialize ()
absl::Status WriteJsonLine (std::ofstream &stream, const std::string &json_data)
absl::Status CompressFrameWithTurboJpeg (const cv::Mat &frame, std::vector< unsigned char > &jpeg_data)
Protected Member Functions inherited from presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >
virtual absl::Status RegisterCallbacks ()
virtual absl::Status SendInitialStatus ()
int64_t GetCurrentTimestampUs ()

Static Protected Member Functions

static std::string BuildEnvelope (const std::string &type, const std::string &json_payload, int64_t timestamp_us)
static std::string BuildStatusPayload (const presage::physiology::StatusValue &status)
static std::string JsonEscape (const std::string &value)
static const google::protobuf::util::JsonPrintOptions & GetJsonOptions ()

Additional Inherited Members

Protected Attributes inherited from presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >
std::shared_ptr< BackgroundContainercontainer_

Detailed Description

template<container::settings::IntegrationMode TIntegrationMode>
class presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >

File-based implementation of IPC stream writer. Provides functionality for writing to files including:

  • JSON serialization with envelope formatting
  • File stream management with configurable buffering
  • Frame storage with automatic cleanup
  • Error handling with rate limiting
  • Thread-safe operations

Member Function Documentation

◆ BuildEnvelope()

template<container::settings::IntegrationMode TIntegrationMode>
std::string presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::BuildEnvelope ( const std::string & type,
const std::string & json_payload,
int64_t timestamp_us )
staticprotected

Build an envelope with type, timestamp, and payload.

◆ BuildStatusPayload()

template<container::settings::IntegrationMode TIntegrationMode>
std::string presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::BuildStatusPayload ( const presage::physiology::StatusValue & status)
staticprotected

Build status payload with additional metadata.

◆ Close()

template<container::settings::IntegrationMode TIntegrationMode>
void presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::Close ( )
overridevirtual

Close the stream and release resources. After calling this, the writer should not be used again.

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.

◆ CompressFrameWithTurboJpeg()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::CompressFrameWithTurboJpeg ( const cv::Mat & frame,
std::vector< unsigned char > & jpeg_data )
protected

Compress a frame using TurboJPEG.

Parameters
frameThe OpenCV Mat to compress
jpeg_dataOutput vector for compressed JPEG data
Returns
Status indicating success or failure

◆ Flush()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::Flush ( )
overridevirtual

Flush any buffered data to the underlying stream. Some implementations may buffer data for performance.

Returns
Status indicating success or failure

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.

◆ GetJsonOptions()

template<container::settings::IntegrationMode TIntegrationMode>
const google::protobuf::util::JsonPrintOptions & presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::GetJsonOptions ( )
staticprotected

Get or create the JSON print options (singleton).

◆ Initialize()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::Initialize ( )
protected

Initialize file streams and directories. Called during construction.

◆ IsOperational()

template<container::settings::IntegrationMode TIntegrationMode>
bool presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::IsOperational ( ) const
overridevirtual

Check if the writer is currently operational.

Returns
true if the writer can accept writes, false otherwise

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.

◆ JsonEscape()

template<container::settings::IntegrationMode TIntegrationMode>
std::string presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::JsonEscape ( const std::string & value)
staticprotected

Escape a string for JSON.

◆ WriteCoreMetrics()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::WriteCoreMetrics ( const presage::physiology::MetricsBuffer & metrics,
int64_t timestamp_us )
overridevirtual

Write core metrics to the stream.

Parameters
metricsThe core metrics buffer to write
timestamp_usTimestamp in microseconds since epoch
Returns
Status indicating success or failure

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.

◆ WriteEdgeMetrics()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::WriteEdgeMetrics ( const presage::physiology::Metrics & metrics,
int64_t timestamp_us )
overridevirtual

Write edge metrics to the stream.

Parameters
metricsThe edge metrics to write
Returns
Status indicating success or failure

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.

◆ WriteFrame()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::WriteFrame ( const cv::Mat & frame,
int64_t timestamp_us )
overridevirtual

Write a video frame to the stream.

Parameters
frameThe video frame as an OpenCV Mat (RGB format expected)
timestamp_usTimestamp in microseconds since epoch
Returns
Status indicating success or failure

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.

◆ WriteJsonLine()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::WriteJsonLine ( std::ofstream & stream,
const std::string & json_data )
protected

Write a JSON line to a stream with optional locking.

◆ WriteStatus()

template<container::settings::IntegrationMode TIntegrationMode>
absl::Status presage::smartspectra::file_ipc::FileIpcStreamWriter< TIntegrationMode >::WriteStatus ( const presage::physiology::StatusValue & status)
overridevirtual

Write a status value to the stream.

Parameters
statusThe status value to write
Returns
Status indicating success or failure

Implements presage::smartspectra::ipc::IpcStreamWriter< TIntegrationMode >.


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