OpenShot Library | libopenshot
0.3.3
|
Go to the documentation of this file.
13 #ifndef OPENSHOT_CACHE_BASE_H
14 #define OPENSHOT_CACHE_BASE_H
62 virtual void Add(std::shared_ptr<openshot::Frame> frame) = 0;
65 virtual void Clear() = 0;
69 virtual bool Contains(int64_t frame_number) = 0;
72 virtual int64_t
Count() = 0;
76 virtual std::shared_ptr<openshot::Frame>
GetFrame(int64_t frame_number) = 0;
79 virtual std::vector<std::shared_ptr<openshot::Frame>>
GetFrames() = 0;
89 virtual void Remove(int64_t frame_number) = 0;
94 virtual void Remove(int64_t start_frame_number, int64_t end_frame_number) = 0;
109 void SetMaxBytesFromInfo(int64_t number_of_frames,
int width,
int height,
int sample_rate,
int channels);
112 virtual std::string
Json() = 0;
113 virtual void SetJson(
const std::string value) = 0;
virtual std::shared_ptr< openshot::Frame > GetSmallestFrame()=0
Get the smallest frame number.
virtual void Clear()=0
Clear the cache of all frames.
virtual std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number)=0
Get a frame from the cache.
bool needs_range_processing
Something has changed, and the range data needs to be re-calculated.
int64_t max_bytes
This is the max number of bytes to cache (0 = no limit)
std::vector< int64_t > ordered_frame_numbers
Ordered list of frame numbers used by cache.
This namespace is the default namespace for all code in the openshot library.
virtual void Add(std::shared_ptr< openshot::Frame > frame)=0
Add a Frame to the cache.
std::string json_ranges
JSON ranges of frame numbers.
virtual ~CacheBase()=default
All cache managers in libopenshot are based on this CacheBase class.
virtual void Remove(int64_t frame_number)=0
Remove a specific frame.
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.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
virtual std::vector< std::shared_ptr< openshot::Frame > > GetFrames()=0
Get an vector of all Frames.
std::map< int64_t, int64_t > frame_ranges
This map holds the ranges of frames, useful for quickly displaying the contents of the cache.
virtual void SetJson(const std::string value)=0
Load JSON string into this object.
virtual Json::Value JsonValue()=0
Generate Json::Value for this object.
void CalculateRanges()
Calculate ranges of frames.
virtual int64_t Count()=0
Count the frames in the queue.
std::string cache_type
This is a friendly type name of the derived cache instance.
virtual std::string Json()=0
Generate JSON string of this object.
int64_t GetMaxBytes()
Gets the maximum bytes value.
void SetMaxBytes(int64_t number_of_bytes)
Set maximum bytes to a different amount.
virtual int64_t GetBytes()=0
Gets the maximum bytes value.
virtual bool Contains(int64_t frame_number)=0
Check if frame is already contained in cache.
CacheBase()
Default constructor, no max bytes.
Header file for JSON class.
int64_t range_version
The version of the JSON range data (incremented with each change)
std::recursive_mutex * cacheMutex
Mutex for multiple threads.