1 #ifndef valkkafs_HEADER_GUARD
2 #define valkkafs_HEADER_GUARD
95 ValkkaFS(
const char *device_file,
const char *block_file, std::size_t blocksize, std::size_t n_blocks,
bool init=
false);
99 std::string device_file;
100 std::string block_file;
101 std::size_t blocksize;
102 std::size_t n_blocks;
104 std::size_t device_size;
105 std::vector<long int>
tab;
119 void callPyFunc(std::string msg,
bool use_gil=
true);
122 const static std::size_t n_cols = 2;
125 std::size_t
ind(std::size_t i, std::size_t j);
128 void setVal(std::size_t i, std::size_t j,
long int val);
129 long int getVal(std::size_t i, std::size_t j);
130 std::size_t getBlockSeek(std::size_t n_block);
131 std::size_t getCurrentBlockSeek();
134 const std::size_t getBlockSize() {
return this->blocksize;}
137 std::size_t get_n_blocks();
138 std::size_t get_n_cols();
154 void clearDevice(
bool writethrough=
false,
bool verbose=
false);
160 void reportTable(std::size_t from=0, std::size_t to=0,
bool show_all=
false);
173 void writeBlock(
bool pycall=
true,
bool use_gil=
true);
209 ValkkaFS2(
const char *device_file,
const char *block_file, std::size_t blocksize, std::size_t n_blocks,
bool init=
false);
234 void dumpBlock(std::size_t n_block);
257 std::size_t bytecount;
285 void setSlotId(SlotNumber slot, IdNumber
id);
286 void unSetSlotId(SlotNumber slot);
289 void seek(std::size_t n_block);
Passes frames to a multiprocessing fifo.
Definition: framefilter.h:554
Passes frames to a FrameFifo.
Definition: framefilter.h:530
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:83
A class for multithreading with a signaling system.
Definition: thread.h:87
std::string name
Name of the thread.
Definition: thread.h:116
Definition: valkkafs.h:200
ValkkaFS2(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:442
virtual void markKeyFrame(long int mstimestamp)
Used by a writer class to inform that a key frame has been written.
Definition: valkkafs.cpp:449
Writes frames to ValkkaFS.
Definition: valkkafs.h:246
void reportSlotIdCall()
Print slot, id number mappings.
Definition: valkkafs.cpp:824
void requestStopCall()
API method: stops the thread.
Definition: valkkafs.cpp:852
void saveCurrentBlock(bool pycall=true, bool use_gil=true)
Save the current block GIL must be obtained for calls that originate purely from the cpp side For cal...
Definition: valkkafs.cpp:630
void handleSignals()
Call ValkkaFSWriterThread::handleSignal for every signal in the signal_fifo.
Definition: valkkafs.cpp:717
void run()
Main execution loop is defined here.
Definition: valkkafs.cpp:530
void preJoin()
Called before the thread is joined.
Definition: valkkafs.cpp:670
std::deque< ValkkaFSWriterSignalContext > signal_fifo
Redefinition of signal fifo.
Definition: valkkafs.h:265
void handleSignal(ValkkaFSWriterSignalContext &signal_ctx)
Handle an individual signal. Signal can originate from the frame fifo or from the signal_fifo deque.
Definition: valkkafs.cpp:682
void setSlotIdCall(SlotNumber slot, IdNumber id)
Set a slot => id number mapping.
Definition: valkkafs.cpp:776
std::map< SlotNumber, IdNumber > slot_to_id
Map from slot numbers to ids.
Definition: valkkafs.h:256
void sendSignal(ValkkaFSWriterSignalContext signal_ctx)
Insert a signal into the signal_fifo.
Definition: valkkafs.cpp:712
FrameFifo infifo
Incoming frames are read from here.
Definition: valkkafs.h:260
void unSetSlotIdCall(SlotNumber slot)
Clear a slot => id number mapping.
Definition: valkkafs.cpp:794
void clearSlotIdCall()
Clear all slot => id number mappings.
Definition: valkkafs.cpp:810
void postRun()
Called after the main execution loop exits, but before joining the thread.
Definition: valkkafs.cpp:666
BlockingFifoFrameFilter infilter_block
Incoming frames can also be written here. If stack runs out of frames, writing will block.
Definition: valkkafs.h:262
void preRun()
Called before entering the main execution loop, but after creating the thread.
Definition: valkkafs.cpp:663
void seekCall(std::size_t n_block)
Seek to a certain block.
Definition: valkkafs.cpp:835
void postJoin()
Called after the thread has been joined.
Definition: valkkafs.cpp:678
FifoFrameFilter infilter
Write incoming frames here // TODO: add a chain of correcting FrameFilter(s)
Definition: valkkafs.h:261
Book-keeping for ValkkaFS.
Definition: valkkafs.h:78
std::size_t getDeviceSize()
returns device file size
Definition: valkkafs.cpp:326
PyObject * pyfunc
A python callback that's triggered when the blocktable should be read again.
Definition: valkkafs.h:116
void setCurrentBlock(std::size_t n_block)
Set block number that's being written.
Definition: valkkafs.cpp:368
std::vector< long int > tab
Blocktable.
Definition: valkkafs.h:105
std::size_t current_row
Row number (block) that's being written.
Definition: valkkafs.h:113
std::fstream os
Write handle to blocktable file.
Definition: valkkafs.h:106
long int col_1_lu
col_1 at previous blocktable update
Definition: valkkafs.h:112
void setArrayCall(PyObject *pyobj)
Copy blocktable to a given numpy array.
Definition: valkkafs.cpp:393
virtual void markKeyFrame(long int mstimestamp)
Used by a writer class to inform that a key frame has been written.
Definition: valkkafs.cpp:315
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:39
bool init
Clear the blocktable or not even if it exists.
Definition: valkkafs.h:103
void updateDumpTable_(std::size_t n_block)
dump single row of bloctable to disk.
Definition: valkkafs.cpp:105
void setBlockCallback(PyObject *pobj)
Set a python callable that's being triggered when a new block is written.
Definition: valkkafs.cpp:374
long int col_1
Current column 1 value (max anyframe timestamp)
Definition: valkkafs.h:110
std::size_t ind(std::size_t i, std::size_t j)
first index: block number (row), second index: column
Definition: valkkafs.cpp:121
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:262
void markFrame(long int mstimestamp)
Used by a writer class to inform that a non-key frame has been written.
Definition: valkkafs.cpp:310
long int col_0_lu
col_0 at previous blocktable update
Definition: valkkafs.h:111
void readTable()
read blocktable from disk
Definition: valkkafs.cpp:113
long int col_0
Current column 0 value (max keyframe timestamp)
Definition: valkkafs.h:109
std::size_t prev_row
Previous row number (block)
Definition: valkkafs.h:114
void reportTable(std::size_t from=0, std::size_t to=0, bool show_all=false)
print blocktable
Definition: valkkafs.cpp:156
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:131
std::size_t maxFrameSize()
returns maximum allowed frame size in bytes
Definition: valkkafs.cpp:151
void clearTable()
clears the blocktable and writes it to the disk
Definition: valkkafs.cpp:358
void updateTable(bool disk_write=false)
Tell ValkkaFS to update the blocktable, even if the block hasn't finished Typically used by an extern...
Definition: valkkafs.cpp:229
void dumpTable_()
dump blocktable to disk.
Definition: valkkafs.cpp:92
std::string getDevice()
returns device filename
Definition: valkkafs.cpp:322
void clearDevice(bool writethrough=false, bool verbose=false)
writes zero bytes to the device
Definition: valkkafs.cpp:330
void dumpTable()
dump blocktable to disk
Definition: valkkafs.cpp:100
List of common header files.
Thread safe system of fifo and a stack.
Definition of FrameFilter and derived classes for various purposes.
Write directly to files and devices with POSIX O_DIRECT.
Describes the stack structure and fifo behaviour for a FrameFifo.
Definition: framefifo.h:56
Encapsulate data sent in the ValkkaFSWriterSignal.
Definition: threadsignal.h:185
Base class for multithreading.