FFmpegfs Fuse Multi Media Filesystem 2.14
|
The Cache_Entry class. More...
#include <cache_entry.h>
Public Member Functions | |
Cache_Entry & | operator= (Cache_Entry const &other)=delete |
operator = declared deleted, should use create to get this object to maintain reference count. More... | |
bool | destroy () |
Destroy this Cache_Entry object. More... | |
bool | openio (bool create_cache=true) |
Open the cache file. More... | |
bool | flush () |
Flush current memory cache to disk. More... | |
void | clear (bool fetch_file_time=true) |
Clear the cache entry. More... | |
size_t | size () const |
Return size of output file, as computed by encoder. More... | |
uint32_t | video_frame_count () const |
Get the video frame count. More... | |
time_t | age () const |
Get the age of the cache entry. More... | |
time_t | last_access () const |
Get last access time. More... | |
bool | expired () const |
Check if cache entry expired. More... | |
bool | suspend_timeout () const |
Check for decode suspend timeout. More... | |
bool | decode_timeout () const |
Check for decode timeout. More... | |
const char * | filename () const |
Return source filename. More... | |
const char * | destname () const |
Return destination filename. More... | |
const char * | virtname () const |
Return virtual filename. Same as destination filename, but with virtual (mount) path.. More... | |
bool | update_access (bool update_database=false) |
Update last access time. More... | |
void | lock () |
Lock the access mutex. More... | |
void | unlock () |
Unlock the access mutex. More... | |
int | ref_count () const |
Get the current reference counter. More... | |
int | inc_refcount () |
Increment the current reference counter. More... | |
int | decr_refcount () |
Decrement the current reference counter. More... | |
bool | outdated () const |
Check if cache entry needs to be recoded. More... | |
LPVIRTUALFILE | virtualfile () |
Get the underlying VIRTUALFILE object. More... | |
bool | closeio (int flags) |
Close the cache entry. More... | |
void | update_read_count () |
Update read counter. More... | |
unsigned int | read_count () const |
Get read counter. More... | |
bool | is_finished () const |
Get if cache has been finished. More... | |
bool | is_finished_incomplete () const |
Get if cache has been finished, but not completely filled. More... | |
bool | is_finished_success () const |
Get if cache has been finished and filled successfully. More... | |
bool | is_finished_error () const |
Get if cache has been finished and with an error. More... | |
Static Public Member Functions | |
static Cache_Entry * | create (Cache *owner, LPVIRTUALFILE virtualfile) |
Create a new Cache_Entry object. More... | |
Public Attributes | |
Buffer * | m_buffer |
Buffer object. More... | |
std::atomic_bool | m_is_decoding |
true while file is decoding More... | |
std::recursive_mutex | m_active_mutex |
Mutex while thread is active. More... | |
std::recursive_mutex | m_restart_mutex |
Mutex while thread is restarted. More... | |
std::atomic_bool | m_suspend_timeout |
true to temporarly disable read_frame timeout More... | |
CACHE_INFO | m_cache_info |
Info about cached object. More... | |
ID3v1 | m_id3v1 |
ID3v1 structure which is used to send to clients. More... | |
std::atomic_uint32_t | m_seek_to_no |
If not 0, seeks to specified frame. More... | |
Protected Member Functions | |
void | close_buffer (int flags) |
Close buffer object. More... | |
bool | read_info () |
Read cache info. More... | |
bool | write_info () |
Write cache info. More... | |
bool | delete_info () |
Delete cache info. More... | |
Protected Attributes | |
Cache * | m_owner |
Owner cache object. More... | |
std::recursive_mutex | m_mutex |
Access mutex. More... | |
std::atomic_int | m_ref_count |
Reference counter. More... | |
LPVIRTUALFILE | m_virtualfile |
Underlying virtual file object. More... | |
Private Member Functions | |
Cache_Entry (Cache *owner, LPVIRTUALFILE virtualfile) | |
Create Cache_Entry object. More... | |
Cache_Entry (Cache_Entry &)=delete | |
Copy constructor declared deleted, should use create to get this object to maintain reference count. | |
virtual | ~Cache_Entry () |
Destroy Cache_Entry object. More... | |
The Cache_Entry class.
Definition at line 48 of file cache_entry.h.
|
explicitprivate |
Create Cache_Entry object.
[in] | owner | - Cache object of owner. |
[in] | virtualfile | - Requesting virtual file. |
Definition at line 39 of file cache_entry.cc.
References clear(), FFMPEGFS_PARAMS::current_format(), FFmpegfs_Format::desttype(), filename(), m_buffer, m_cache_info, CACHE_INFO::m_destfile, VIRTUALFILE::m_destfile, CACHE_INFO::m_desttype, CACHE_INFO::m_origfile, VIRTUALFILE::m_origfile, Buffer::openio(), params, Logging::trace(), and virtualfile().
Referenced by create().
|
privatevirtual |
Destroy Cache_Entry object.
Definition at line 65 of file cache_entry.cc.
References filename(), m_active_mutex, m_buffer, Logging::trace(), and unlock().
time_t Cache_Entry::age | ( | ) | const |
Get the age of the cache entry.
Definition at line 288 of file cache_entry.cc.
References m_cache_info, and CACHE_INFO::m_creation_time.
Referenced by expired().
void Cache_Entry::clear | ( | bool | fetch_file_time = true | ) |
Clear the cache entry.
[in] | fetch_file_time | - If true, the entry file time will be filled in from the source file. |
Definition at line 87 of file cache_entry.cc.
References Buffer::clear(), filename(), init_id3v1(), CACHE_INFO::m_access_count, CACHE_INFO::m_access_time, CACHE_INFO::m_audiobitrate, FFMPEGFS_PARAMS::m_audiobitrate, CACHE_INFO::m_audiosamplerate, FFMPEGFS_PARAMS::m_audiosamplerate, CACHE_INFO::m_averror, m_buffer, m_cache_info, CACHE_INFO::m_creation_time, CACHE_INFO::m_deinterlace, FFMPEGFS_PARAMS::m_deinterlace, CACHE_INFO::m_encoded_filesize, CACHE_INFO::m_errno, CACHE_INFO::m_error, CACHE_INFO::m_file_size, CACHE_INFO::m_file_time, m_id3v1, m_is_decoding, CACHE_INFO::m_predicted_filesize, CACHE_INFO::m_result, CACHE_INFO::m_video_frame_count, CACHE_INFO::m_videobitrate, FFMPEGFS_PARAMS::m_videobitrate, CACHE_INFO::m_videoheight, FFMPEGFS_PARAMS::m_videoheight, CACHE_INFO::m_videowidth, FFMPEGFS_PARAMS::m_videowidth, params, and RESULTCODE_NONE.
Referenced by Cache_Entry(), openio(), transcode(), and transcoder_new().
|
protected |
Close buffer object.
[in] | flags | - one of the CACHE_CLOSE_* flags |
Definition at line 208 of file cache_entry.cc.
References delete_info(), m_buffer, and Buffer::release().
Referenced by closeio().
bool Cache_Entry::closeio | ( | int | flags | ) |
Close the cache entry.
[in] | flags | - one of the CACHE_CLOSE_* flags |
Definition at line 219 of file cache_entry.cc.
References close_buffer(), flush(), m_buffer, m_ref_count, and write_info().
|
static |
Create a new Cache_Entry object.
[in] | owner | - Cache object of owner. |
[in] | virtualfile | - Requesting virtual file. |
Definition at line 76 of file cache_entry.cc.
References Cache_Entry(), and virtualfile().
bool Cache_Entry::decode_timeout | ( | ) | const |
Check for decode timeout.
Definition at line 308 of file cache_entry.cc.
References CACHE_INFO::m_access_time, m_cache_info, FFMPEGFS_PARAMS::m_max_inactive_abort, m_ref_count, and params.
Referenced by transcode().
int Cache_Entry::decr_refcount | ( | ) |
Decrement the current reference counter.
Definition at line 348 of file cache_entry.cc.
References m_ref_count.
|
protected |
Delete cache info.
Definition at line 143 of file cache_entry.cc.
References Cache::delete_info(), filename(), m_cache_info, CACHE_INFO::m_desttype, and m_owner.
Referenced by close_buffer().
const char * Cache_Entry::destname | ( | ) | const |
Return destination filename.
Definition at line 318 of file cache_entry.cc.
References VIRTUALFILE::m_destfile, and m_virtualfile.
bool Cache_Entry::destroy | ( | ) |
Destroy this Cache_Entry object.
Definition at line 81 of file cache_entry.cc.
bool Cache_Entry::expired | ( | ) | const |
Check if cache entry expired.
Checks if entry is older or larger than the limit.
Definition at line 298 of file cache_entry.cc.
References age(), FFMPEGFS_PARAMS::m_expiry_time, and params.
const char * Cache_Entry::filename | ( | ) | const |
Return source filename.
Definition at line 313 of file cache_entry.cc.
References VIRTUALFILE::m_origfile, and m_virtualfile.
Referenced by Cache_Entry(), clear(), delete_info(), openio(), outdated(), transcode(), transcoder_new(), and ~Cache_Entry().
bool Cache_Entry::flush | ( | ) |
Flush current memory cache to disk.
Definition at line 248 of file cache_entry.cc.
References Buffer::flush(), and m_buffer.
Referenced by closeio(), and transcode_finish().
int Cache_Entry::inc_refcount | ( | ) |
Increment the current reference counter.
Definition at line 343 of file cache_entry.cc.
References m_ref_count.
bool Cache_Entry::is_finished | ( | ) | const |
Get if cache has been finished.
Definition at line 437 of file cache_entry.cc.
References m_cache_info, CACHE_INFO::m_result, and RESULTCODE_NONE.
Referenced by openio(), transcode(), and transcode_until().
bool Cache_Entry::is_finished_error | ( | ) | const |
Get if cache has been finished and with an error.
Definition at line 452 of file cache_entry.cc.
References m_cache_info, CACHE_INFO::m_result, and RESULTCODE_FINISHED_ERROR.
bool Cache_Entry::is_finished_incomplete | ( | ) | const |
Get if cache has been finished, but not completely filled.
Definition at line 442 of file cache_entry.cc.
References m_cache_info, CACHE_INFO::m_result, and RESULTCODE_FINISHED_INCOMPLETE.
bool Cache_Entry::is_finished_success | ( | ) | const |
Get if cache has been finished and filled successfully.
Definition at line 447 of file cache_entry.cc.
References m_cache_info, CACHE_INFO::m_result, and RESULTCODE_FINISHED_SUCCESS.
Referenced by transcoder_new(), and transcoder_read().
time_t Cache_Entry::last_access | ( | ) | const |
Get last access time.
Definition at line 293 of file cache_entry.cc.
References CACHE_INFO::m_access_time, and m_cache_info.
void Cache_Entry::lock | ( | ) |
Lock the access mutex.
Definition at line 328 of file cache_entry.cc.
References m_mutex.
Referenced by transcoder_new().
bool Cache_Entry::openio | ( | bool | create_cache = true | ) |
Open the cache file.
[in] | create_cache | - If true, the cache will be created if it does not yet exist. |
Definition at line 162 of file cache_entry.cc.
References clear(), filename(), Buffer::init(), is_finished(), m_buffer, m_cache_info, m_ref_count, CACHE_INFO::m_result, read_info(), Logging::trace(), and update_access().
Referenced by transcode(), and transcoder_new().
|
delete |
operator = declared deleted, should use create to get this object to maintain reference count.
[in] | other | - Assignment object |
bool Cache_Entry::outdated | ( | ) | const |
Check if cache entry needs to be recoded.
Definition at line 353 of file cache_entry.cc.
References Logging::debug(), filename(), CACHE_INFO::m_audiobitrate, FFMPEGFS_PARAMS::m_audiobitrate, CACHE_INFO::m_audiosamplerate, FFMPEGFS_PARAMS::m_audiosamplerate, m_cache_info, CACHE_INFO::m_deinterlace, FFMPEGFS_PARAMS::m_deinterlace, CACHE_INFO::m_file_size, CACHE_INFO::m_file_time, CACHE_INFO::m_videobitrate, FFMPEGFS_PARAMS::m_videobitrate, CACHE_INFO::m_videoheight, FFMPEGFS_PARAMS::m_videoheight, CACHE_INFO::m_videowidth, FFMPEGFS_PARAMS::m_videowidth, and params.
Referenced by transcoder_new().
unsigned int Cache_Entry::read_count | ( | ) | const |
Get read counter.
This is the number of read accesses to the cache entry.
Definition at line 432 of file cache_entry.cc.
References CACHE_INFO::m_access_count, and m_cache_info.
|
protected |
Read cache info.
Definition at line 133 of file cache_entry.cc.
References m_cache_info, m_owner, and Cache::read_info().
Referenced by openio().
int Cache_Entry::ref_count | ( | ) | const |
Get the current reference counter.
Definition at line 338 of file cache_entry.cc.
References m_ref_count.
Referenced by transcode().
size_t Cache_Entry::size | ( | ) | const |
Return size of output file, as computed by encoder.
Returns the file size, either the predicted size (which may be inaccurate) or the real size (which is only available once the file was completely recoded).
Definition at line 262 of file cache_entry.cc.
References Buffer::buffer_watermark(), m_buffer, m_cache_info, CACHE_INFO::m_encoded_filesize, and CACHE_INFO::m_predicted_filesize.
Referenced by transcoder_get_size().
bool Cache_Entry::suspend_timeout | ( | ) | const |
Check for decode suspend timeout.
Definition at line 303 of file cache_entry.cc.
References CACHE_INFO::m_access_time, m_cache_info, FFMPEGFS_PARAMS::m_max_inactive_suspend, m_ref_count, and params.
Referenced by transcode().
void Cache_Entry::unlock | ( | ) |
Unlock the access mutex.
Definition at line 333 of file cache_entry.cc.
References m_mutex.
Referenced by transcoder_new(), and ~Cache_Entry().
bool Cache_Entry::update_access | ( | bool | update_database = false | ) |
Update last access time.
[in] | update_database | - If true, also persist in SQL database. |
Definition at line 148 of file cache_entry.cc.
References CACHE_INFO::m_access_time, m_cache_info, m_owner, and Cache::write_info().
Referenced by openio(), transcode(), transcoder_read(), and transcoder_read_frame().
void Cache_Entry::update_read_count | ( | ) |
Update read counter.
Definition at line 427 of file cache_entry.cc.
References CACHE_INFO::m_access_count, and m_cache_info.
Referenced by transcoder_read(), and transcoder_read_frame().
uint32_t Cache_Entry::video_frame_count | ( | ) | const |
Get the video frame count.
Definition at line 283 of file cache_entry.cc.
References m_cache_info, and CACHE_INFO::m_video_frame_count.
const char * Cache_Entry::virtname | ( | ) | const |
Return virtual filename. Same as destination filename, but with virtual (mount) path..
Definition at line 323 of file cache_entry.cc.
References VIRTUALFILE::m_virtfile, and m_virtualfile.
Referenced by transcode(), transcode_until(), transcoder_new(), transcoder_read(), transcoder_read_frame(), transcoder_set_filesize(), and transcoder_thread().
LPVIRTUALFILE Cache_Entry::virtualfile | ( | ) |
Get the underlying VIRTUALFILE object.
Definition at line 422 of file cache_entry.cc.
References m_virtualfile.
Referenced by Cache_Entry(), create(), ffmpegfs_release(), transcode(), and transcoder_read().
|
protected |
Write cache info.
Definition at line 138 of file cache_entry.cc.
References m_cache_info, m_owner, and Cache::write_info().
Referenced by closeio().
std::recursive_mutex Cache_Entry::m_active_mutex |
Mutex while thread is active.
Definition at line 273 of file cache_entry.h.
Referenced by transcoder_thread(), and ~Cache_Entry().
Buffer* Cache_Entry::m_buffer |
Buffer object.
Definition at line 271 of file cache_entry.h.
Referenced by Cache_Entry(), clear(), close_buffer(), closeio(), ffmpegfs_release(), flush(), openio(), size(), transcode(), transcode_finish(), transcode_until(), transcoder_buffer_tell(), transcoder_buffer_watermark(), transcoder_read(), transcoder_read_frame(), and ~Cache_Entry().
CACHE_INFO Cache_Entry::m_cache_info |
Info about cached object.
Definition at line 277 of file cache_entry.h.
Referenced by age(), Cache_Entry(), clear(), decode_timeout(), delete_info(), is_finished(), is_finished_error(), is_finished_incomplete(), is_finished_success(), last_access(), openio(), outdated(), read_count(), read_info(), size(), suspend_timeout(), transcode(), transcode_finish(), transcode_until(), transcoder_cached_filesize(), transcoder_new(), transcoder_predict_filesize(), transcoder_read_frame(), transcoder_set_filesize(), transcoder_thread(), update_access(), update_read_count(), video_frame_count(), and write_info().
ID3v1 Cache_Entry::m_id3v1 |
ID3v1 structure which is used to send to clients.
Definition at line 279 of file cache_entry.h.
Referenced by clear(), and transcode().
std::atomic_bool Cache_Entry::m_is_decoding |
true while file is decoding
Definition at line 272 of file cache_entry.h.
Referenced by clear(), transcode(), transcode_finish(), transcode_until(), transcoder_new(), transcoder_read_frame(), and transcoder_thread().
|
protected |
|
protected |
Owner cache object.
Definition at line 263 of file cache_entry.h.
Referenced by delete_info(), read_info(), update_access(), and write_info().
|
protected |
Reference counter.
Definition at line 266 of file cache_entry.h.
Referenced by closeio(), decode_timeout(), decr_refcount(), inc_refcount(), openio(), ref_count(), and suspend_timeout().
std::recursive_mutex Cache_Entry::m_restart_mutex |
Mutex while thread is restarted.
Definition at line 274 of file cache_entry.h.
Referenced by transcoder_thread().
std::atomic_uint32_t Cache_Entry::m_seek_to_no |
If not 0, seeks to specified frame.
Definition at line 281 of file cache_entry.h.
Referenced by transcode(), transcoder_read(), transcoder_read_frame(), and transcoder_thread().
std::atomic_bool Cache_Entry::m_suspend_timeout |
true to temporarly disable read_frame timeout
Definition at line 275 of file cache_entry.h.
Referenced by transcode(), and transcoder_read_frame().
|
protected |
Underlying virtual file object.
Definition at line 268 of file cache_entry.h.
Referenced by destname(), filename(), virtname(), and virtualfile().