33#ifndef __ROGUE_UTILITIES_FILEIO_STREAM_WRITER_H__
34#define __ROGUE_UTILITIES_FILEIO_STREAM_WRITER_H__
40#include <condition_variable>
57class StreamWriterChannel;
81 std::shared_ptr<rogue::Logging>
log_;
129 void intWrite(
void* data, uint32_t size);
149 std::map<uint32_t, std::shared_ptr<rogue::utilities::fileio::StreamWriterChannel>>
channelMap_;
152 virtual void writeFile(uint8_t channel, std::shared_ptr<rogue::interfaces::stream::Frame> frame);
165 static std::shared_ptr<rogue::utilities::fileio::StreamWriter>
create();
192 void open(std::string file);
262 std::shared_ptr<rogue::utilities::fileio::StreamWriterChannel>
getChannel(uint8_t channel);
Typed shared-from-this helper for Rogue classes.
Stream sink that writes incoming frames into a tagged writer channel.
Coordinates channelized frame capture into Rogue stream data files.
bool waitFrameCount(uint32_t count, uint64_t timeout)
Blocks until a target frame count is reached or timeout expires.
void setMaxSize(uint64_t size)
Sets automatic file rollover size.
bool getRaw()
Gets raw output mode state.
void recordBandwidth(uint32_t size)
void close()
Closes the currently open data file.
StreamWriter()
Constructs a stream writer.
void pruneBandwidth(std::chrono::steady_clock::time_point now)
bool isOpen()
Returns whether a data file is open.
void setBufferSize(uint32_t size)
Sets write buffering size.
uint64_t getTotalSize()
Returns cumulative bytes written across all files.
virtual void writeFile(uint8_t channel, std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Write data to file. Called from StreamWriterChannel.
void setDropErrors(bool drop)
Configures whether errored frames are dropped.
virtual ~StreamWriter()
Destroys the stream writer and closes open resources.
void intWrite(void *data, uint32_t size)
Internal method for file writing with buffer and auto close and reopen.
std::deque< std::pair< std::chrono::steady_clock::time_point, uint32_t > > bandwidthHistory_
void open(std::string file)
Opens a data file.
static std::shared_ptr< rogue::utilities::fileio::StreamWriter > create()
Creates a stream writer instance.
static void setup_python()
Registers Python bindings for this class.
std::shared_ptr< rogue::utilities::fileio::StreamWriterChannel > getChannel(uint8_t channel)
Gets or creates a channel writer endpoint.
uint32_t getFrameCount()
Returns number of frames written to the current file session.
uint64_t getCurrentSize()
Returns current output file size.
std::map< uint32_t, std::shared_ptr< rogue::utilities::fileio::StreamWriterChannel > > channelMap_
double getBandwidth()
Returns recent write bandwidth estimate.
void checkSize(uint32_t size)
Check file size for next write.
void setRaw(bool raw)
Sets raw output mode.
std::shared_ptr< rogue::Logging > log_
std::condition_variable cond_
std::shared_ptr< rogue::utilities::fileio::StreamWriter > StreamWriterPtr