OpenShot Library | libopenshot  0.1.9
Public Member Functions | Protected Attributes | List of all members
openshot::CacheBase Class Referenceabstract

All cache managers in libopenshot are based on this CacheBase class. More...

#include <CacheBase.h>

Inheritance diagram for openshot::CacheBase:
openshot::CacheDisk openshot::CacheMemory

Public Member Functions

virtual void Add (std::shared_ptr< Frame > frame)=0
 Add a Frame to the cache. More...
 
 CacheBase ()
 Default constructor, no max bytes. More...
 
 CacheBase (int64_t max_bytes)
 Constructor that sets the max bytes to cache. More...
 
virtual void Clear ()=0
 Clear the cache of all frames. More...
 
virtual int64_t Count ()=0
 Count the frames in the queue. More...
 
virtual int64_t GetBytes ()=0
 Gets the maximum bytes value. More...
 
virtual std::shared_ptr< FrameGetFrame (int64_t frame_number)=0
 Get a frame from the cache. More...
 
int64_t GetMaxBytes ()
 Gets the maximum bytes value. More...
 
virtual std::shared_ptr< FrameGetSmallestFrame ()=0
 Get the smallest frame number. More...
 
virtual string Json ()=0
 Get and Set JSON methods. More...
 
virtual Json::Value JsonValue ()=0
 Generate Json::JsonValue for this object. More...
 
virtual void Remove (int64_t frame_number)=0
 Remove a specific frame. More...
 
virtual void Remove (int64_t start_frame_number, int64_t end_frame_number)=0
 Remove a range of frames. More...
 
virtual void SetJson (string value)=0
 Load JSON string into this object. More...
 
virtual void SetJsonValue (Json::Value root)=0
 Load Json::JsonValue into this object. More...
 
void SetMaxBytes (int64_t number_of_bytes)
 Set maximum bytes to a different amount. More...
 
void SetMaxBytesFromInfo (int64_t number_of_frames, int width, int height, int sample_rate, int channels)
 Set maximum bytes to a different amount based on a ReaderInfo struct. More...
 

Protected Attributes

string cache_type
 This is a friendly type name of the derived cache instance. More...
 
CriticalSection * cacheCriticalSection
 Section lock for multiple threads. More...
 
int64_t max_bytes
 This is the max number of bytes to cache (0 = no limit) More...
 

Detailed Description

All cache managers in libopenshot are based on this CacheBase class.

Cache is a very important element of video editing, and is required to achieve a high degree of performance. There are multiple derived cache objects based on this class, some which use memory, and some which use disk to store the cache.

Definition at line 45 of file CacheBase.h.

Constructor & Destructor Documentation

◆ CacheBase() [1/2]

CacheBase::CacheBase ( )

Default constructor, no max bytes.

Definition at line 34 of file CacheBase.cpp.

◆ CacheBase() [2/2]

CacheBase::CacheBase ( int64_t  max_bytes)

Constructor that sets the max bytes to cache.

Parameters
max_bytesThe maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames.

Definition at line 40 of file CacheBase.cpp.

Member Function Documentation

◆ Add()

virtual void openshot::CacheBase::Add ( std::shared_ptr< Frame frame)
pure virtual

Add a Frame to the cache.

Parameters
frameThe openshot::Frame object needing to be cached.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ Clear()

virtual void openshot::CacheBase::Clear ( )
pure virtual

Clear the cache of all frames.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ Count()

virtual int64_t openshot::CacheBase::Count ( )
pure virtual

Count the frames in the queue.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ GetBytes()

virtual int64_t openshot::CacheBase::GetBytes ( )
pure virtual

Gets the maximum bytes value.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ GetFrame()

virtual std::shared_ptr<Frame> openshot::CacheBase::GetFrame ( int64_t  frame_number)
pure virtual

Get a frame from the cache.

Parameters
frame_numberThe frame number of the cached frame

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ GetMaxBytes()

int64_t openshot::CacheBase::GetMaxBytes ( )
inline

Gets the maximum bytes value.

Definition at line 93 of file CacheBase.h.

◆ GetSmallestFrame()

virtual std::shared_ptr<Frame> openshot::CacheBase::GetSmallestFrame ( )
pure virtual

Get the smallest frame number.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ Json()

virtual string openshot::CacheBase::Json ( )
pure virtual

Get and Set JSON methods.

Generate JSON string of this object

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ JsonValue()

Json::Value CacheBase::JsonValue ( )
pure virtual

Generate Json::JsonValue for this object.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

Definition at line 54 of file CacheBase.cpp.

◆ Remove() [1/2]

virtual void openshot::CacheBase::Remove ( int64_t  frame_number)
pure virtual

Remove a specific frame.

Parameters
frame_numberThe frame number of the cached frame

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ Remove() [2/2]

virtual void openshot::CacheBase::Remove ( int64_t  start_frame_number,
int64_t  end_frame_number 
)
pure virtual

Remove a range of frames.

Parameters
start_frame_numberThe starting frame number of the cached frame
end_frame_numberThe ending frame number of the cached frame

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ SetJson()

virtual void openshot::CacheBase::SetJson ( string  value)
pure virtual

Load JSON string into this object.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

◆ SetJsonValue()

void CacheBase::SetJsonValue ( Json::Value  root)
pure virtual

Load Json::JsonValue into this object.

Implemented in openshot::CacheDisk, and openshot::CacheMemory.

Definition at line 67 of file CacheBase.cpp.

◆ SetMaxBytes()

void openshot::CacheBase::SetMaxBytes ( int64_t  number_of_bytes)
inline

Set maximum bytes to a different amount.

Parameters
number_of_bytesThe maximum bytes to allow in the cache. Once exceeded, the cache will purge the oldest frames.

Definition at line 97 of file CacheBase.h.

◆ SetMaxBytesFromInfo()

void CacheBase::SetMaxBytesFromInfo ( int64_t  number_of_frames,
int  width,
int  height,
int  sample_rate,
int  channels 
)

Set maximum bytes to a different amount based on a ReaderInfo struct.

Parameters
number_of_framesThe maximum number of frames to hold in cache
widthThe width of the frame's image
heightThe height of the frame's image
sample_rateThe sample rate of the frame's audio data
channelsThe number of audio channels in the frame

Definition at line 46 of file CacheBase.cpp.

Member Data Documentation

◆ cache_type

string openshot::CacheBase::cache_type
protected

This is a friendly type name of the derived cache instance.

Definition at line 48 of file CacheBase.h.

◆ cacheCriticalSection

CriticalSection* openshot::CacheBase::cacheCriticalSection
protected

Section lock for multiple threads.

Definition at line 52 of file CacheBase.h.

◆ max_bytes

int64_t openshot::CacheBase::max_bytes
protected

This is the max number of bytes to cache (0 = no limit)

Definition at line 49 of file CacheBase.h.


The documentation for this class was generated from the following files: