1 #ifndef valkkafs_HEADER_GUARD 2 #define valkkafs_HEADER_GUARD 90 ValkkaFS(
const char *device_file,
const char *block_file, std::size_t blocksize, std::size_t n_blocks,
bool init=
false);
94 std::string device_file;
95 std::string block_file;
96 std::size_t blocksize;
99 std::size_t device_size;
100 std::vector<long int>
tab;
111 const static std::size_t n_cols = 2;
114 std::size_t
ind(std::size_t i, std::size_t j);
117 void setVal(std::size_t i, std::size_t j,
long int val);
118 long int getVal(std::size_t i, std::size_t j);
119 std::size_t getBlockSeek(std::size_t n_block);
120 std::size_t getCurrentBlockSeek();
123 const std::size_t getBlockSize() {
return this->blocksize;}
126 std::size_t get_n_blocks();
127 std::size_t get_n_cols();
143 void clearDevice(
bool writethrough=
false,
bool verbose=
false);
149 void reportTable(std::size_t from=0, std::size_t to=0,
bool show_all=
false);
155 void writeBlock(
bool pycall=
true,
bool use_gil=
true);
199 void dumpBlock(std::size_t n_block);
222 std::size_t bytecount;
242 void handleSignals();
245 void saveCurrentBlock(
bool pycall=
true,
bool use_gil=
true);
246 void setSlotId(SlotNumber slot, IdNumber
id);
247 void unSetSlotId(SlotNumber slot);
250 void seek(std::size_t n_block);
257 void setSlotIdCall(SlotNumber slot, IdNumber
id);
259 void unSetSlotIdCall(SlotNumber slot);
261 void clearSlotIdCall();
263 void reportSlotIdCall();
265 void seekCall(std::size_t n_block);
266 void requestStopCall();
void setCurrentBlock(std::size_t n_block)
Set block number that's being written.
Definition: valkkafs.cpp:315
FrameFifo infifo
Incoming frames are read from here.
Definition: valkkafs.h:225
std::deque< ValkkaFSWriterSignalContext > signal_fifo
Redefinition of signal fifo.
Definition: valkkafs.h:230
Writes frames to ValkkaFS.
Definition: valkkafs.h:211
void reportTable(std::size_t from=0, std::size_t to=0, bool show_all=false)
print blocktable
Definition: valkkafs.cpp:150
void dumpTable()
dump blocktable to disk
Definition: valkkafs.cpp:94
void readTable()
read blocktable from disk
Definition: valkkafs.cpp:107
FifoFrameFilter infilter
Write incoming frames here // TODO: add a chain of correcting FrameFilter(s)
Definition: valkkafs.h:226
Describes the stack structure and fifo behaviour for a FrameFifo.
Definition: framefifo.h:45
long int col_0
Current column 0 value (max keyframe timestamp)
Definition: valkkafs.h:104
void updateDumpTable_(std::size_t n_block)
dump single row of bloctable to disk.
Definition: valkkafs.cpp:99
Thread safe system of fifo and a stack.
PyObject * pyfunc
Python callback that's triggered at block write.
Definition: valkkafs.h:108
std::fstream os
Write handle to blocktable file.
Definition: valkkafs.h:101
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:72
void setVal(std::size_t i, std::size_t j, long int val)
set tab's value at block i, row j
Definition: valkkafs.cpp:125
std::size_t getDeviceSize()
returns device file size
Definition: valkkafs.cpp:273
long int col_1
Current column 1 value (max anyframe timestamp)
Definition: valkkafs.h:105
void markKeyFrame(long int mstimestamp)
Used by a writer class to inform that a key frame has been written.
Definition: valkkafs.cpp:262
Book-keeping for ValkkaFS.
Definition: valkkafs.h:78
Base class for multithreading.
Passes frames to a multiprocessing fifo.
Definition: framefilter.h:585
std::map< SlotNumber, IdNumber > slot_to_id
Map from slot numbers to ids.
Definition: valkkafs.h:221
void setArrayCall(PyObject *pyobj)
Copy blocktable to a given numpy array.
Definition: valkkafs.cpp:340
void writeBlock(bool pycall=true, bool use_gil=true)
Used by a writer class to inform that a new block has been written.
Definition: valkkafs.cpp:173
void clearTable()
clears the blocktable and writes it to the disk
Definition: valkkafs.cpp:305
std::string getDevice()
returns device filename
Definition: valkkafs.cpp:269
void markFrame(long int mstimestamp)
Used by a writer class to inform that a non-key frame has been written.
Definition: valkkafs.cpp:257
BlockingFifoFrameFilter infilter_block
Incoming frames can also be written here. If stack runs out of frames, writing will block...
Definition: valkkafs.h:227
bool init
Clear the blocktable or not even if it exists.
Definition: valkkafs.h:98
Definition of FrameFilter and derived classes for various purposes.
void setBlockCallback(PyObject *pobj)
Set a python callable that's being triggered when a new block is written.
Definition: valkkafs.cpp:321
ValkkaFS(const char *device_file, const char *block_file, std::size_t blocksize, std::size_t n_blocks, bool init=false)
Default Constructor.
Definition: valkkafs.cpp:37
Encapsulate data sent in the ValkkaFSWriterSignal.
Definition: threadsignal.h:163
std::size_t ind(std::size_t i, std::size_t j)
first index: block number (row), second index: column
Definition: valkkafs.cpp:115
A class for multithreading with a signaling system.
Definition: thread.h:90
Write directly to files and devices with POSIX O_DIRECT.
Passes frames to a FrameFifo.
Definition: framefilter.h:560
List of common header files.
std::vector< long int > tab
Blocktable.
Definition: valkkafs.h:100
std::size_t prev_row
Previous row number (block)
Definition: valkkafs.h:107
void clearDevice(bool writethrough=false, bool verbose=false)
writes zero bytes to the device
Definition: valkkafs.cpp:277
std::size_t maxFrameSize()
returns maximum allowed frame size in bytes
Definition: valkkafs.cpp:145
std::size_t current_row
Row number (block) that's being written.
Definition: valkkafs.h:106
void dumpTable_()
dump blocktable to disk.
Definition: valkkafs.cpp:86