| Valkka
    1.6.1
    OpenSource Video Management | 
Book-keeping for ValkkaFS. More...
#include <valkkafs.h>

| Public Member Functions | |
| ValkkaFS (const char *device_file, const char *block_file, std::size_t blocksize, std::size_t n_blocks, bool init=false) | |
| Default Constructor.  More... | |
| void | setVal (std::size_t i, std::size_t j, long int val) | 
| set tab's value at block i, row j | |
| long int | getVal (std::size_t i, std::size_t j) | 
| std::size_t | getBlockSeek (std::size_t n_block) | 
| std::size_t | getCurrentBlockSeek () | 
| const std::size_t | getBlockSize () | 
| std::size_t | get_n_blocks () | 
| std::size_t | get_n_cols () | 
| void | dumpTable_ () | 
| dump blocktable to disk.  More... | |
| void | updateDumpTable_ (std::size_t n_block) | 
| dump single row of bloctable to disk.  More... | |
| void | dumpTable () | 
| dump blocktable to disk | |
| void | readTable () | 
| read blocktable from disk | |
| std::string | getDevice () | 
| returns device filename | |
| std::size_t | getDeviceSize () | 
| returns device file size | |
| void | clearDevice (bool writethrough=false, bool verbose=false) | 
| writes zero bytes to the device | |
| void | clearTable () | 
| clears the blocktable and writes it to the disk | |
| std::size_t | maxFrameSize () | 
| returns maximum allowed frame size in bytes | |
| void | reportTable (std::size_t from=0, std::size_t to=0, bool show_all=false) | 
| print blocktable | |
| void | updateTable (bool disk_write=false) | 
| Tell ValkkaFS to update the blocktable, even if the block hasn't finished Typically used by an external manager that needs up-to-date information about the max timestamp in the block. | |
| void | writeBlock (bool pycall=true, bool use_gil=true) | 
| Used by a writer class to inform that a new block has been written.  More... | |
| void | markFrame (long int mstimestamp) | 
| Used by a writer class to inform that a non-key frame has been written. | |
| virtual void | markKeyFrame (long int mstimestamp) | 
| Used by a writer class to inform that a key frame has been written. | |
| void | setCurrentBlock (std::size_t n_block) | 
| Set block number that's being written. | |
| void | setBlockCallback (PyObject *pobj) | 
| Set a python callable that's being triggered when a new block is written. | |
| void | setArrayCall (PyObject *pyobj) | 
| Copy blocktable to a given numpy array.  More... | |
| Protected Member Functions | |
| std::size_t | ind (std::size_t i, std::size_t j) | 
| first index: block number (row), second index: column | |
| Protected Attributes | |
| std::string | device_file | 
| std::string | block_file | 
| std::size_t | blocksize | 
| std::size_t | n_blocks | 
| bool | init | 
| Clear the blocktable or not even if it exists. | |
| std::size_t | device_size | 
| std::vector< long int > | tab | 
| Blocktable. | |
| std::fstream | os | 
| Write handle to blocktable file. | |
| std::mutex | mutex | 
| long int | col_0 | 
| Current column 0 value (max keyframe timestamp) | |
| long int | col_1 | 
| Current column 1 value (max anyframe timestamp) | |
| long int | col_0_lu | 
| col_0 at previous blocktable update | |
| long int | col_1_lu | 
| col_1 at previous blocktable update | |
| std::size_t | current_row | 
| Row number (block) that's being written. | |
| std::size_t | prev_row | 
| Previous row number (block) | |
| PyObject * | pyfunc | 
| A python callback that's triggered when the blocktable should be read again. | |
| Static Protected Attributes | |
| static const std::size_t | n_cols = 2 | 
| Private Member Functions | |
| void | callPyFunc (std::string msg, bool use_gil=true) | 
Book-keeping for ValkkaFS.
| device_file | File where payload is written. Can be /dev/sdb etc., or just a plain file with some space reserved | 
| block_file | Book-keeping of the blocks in the device file | 
| blocksize | Size of a single block in bytes | 
| n_blocks | Size of the device (or the part we want to use) in bytes | 
| init | Clear the block_file even if it exists | 
Actual reading and writing of frames are done by other classes (ValkkaFSWriterThread and ValkkaFSReaderThread)
When reading frames, they are passed between processes typically like this:
ValkkaFSReaderThread => CacheStream => Decoder
| ValkkaFS::ValkkaFS | ( | const char * | device_file, | 
| const char * | block_file, | ||
| std::size_t | blocksize, | ||
| std::size_t | n_blocks, | ||
| bool | init = false | ||
| ) | 
Default Constructor.
| device_file | where the payload is written (a file or a disk device) | 
| block_file | where the filesystem (block) information is written. A dump of blocktable | 
| blocksize | size of a block | 
| n_blocks | number of blocks | 
| init | true = init and dump blocktable to disk. false = try to read blocktable from disk (default) | 
ValkkaFS is designed for a case when several streams are dumped into the same file/blockdevice. However, this idea has been abandoned for the moment (although cool idea, there are several complications with it) and we have opted to have a single stream per file/blockdevice. That (more conventional) idea is implemented in ValkkaFS2. The only different is how the keyframes are marked into the blocktable.
| void ValkkaFS::dumpTable_ | ( | ) | 
dump blocktable to disk.
Not thread safe.
| void ValkkaFS::setArrayCall | ( | PyObject * | pyobj | ) | 
Copy blocktable to a given numpy array.
| numpy | array | 
The array must be created on the python side with:
a = numpy.zeros((v.get_n_blocks(), v.get_n_cols()),dtype=numpy.int_)
| void ValkkaFS::updateDumpTable_ | ( | std::size_t | n_block | ) | 
dump single row of bloctable to disk.
Not thread safe.
| void ValkkaFS::writeBlock | ( | bool | pycall = true, | 
| bool | use_gil = true | ||
| ) | 
Used by a writer class to inform that a new block has been written.
| pycall | : Use the provided python callback function or not? default = true | 
| use_gil | : Acquire Python GIL or not? should be true, when evoked "autonomously" by this thread and false, when evoked from python. default = true |