Loading...
Searching...
No Matches
CacheDisk.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_CACHE_DISK_H
#define OPENSHOT_CACHE_DISK_H
#include "CacheBase.h"
#include <QDir>
namespace openshot {
class Frame;
class CacheDisk : public CacheBase {
private:
QDir path;
std::map<int64_t, int64_t> frames;
std::deque<int64_t> frame_numbers;
std::string image_format;
float image_quality;
float image_scale;
int64_t frame_size_bytes;
void CleanUp();
void InitPath(std::string cache_path);
public:
CacheDisk(std::string cache_path, std::string format, float quality, float scale);
CacheDisk(std::string cache_path, std::string format, float quality, float scale, int64_t max_bytes);
// Default destructor
~CacheDisk();
void Add(std::shared_ptr<openshot::Frame> frame);
void Clear();
bool Contains(int64_t frame_number);
int64_t Count();
std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number);
std::vector<std::shared_ptr<openshot::Frame>> GetFrames();
int64_t GetBytes();
std::shared_ptr<openshot::Frame> GetSmallestFrame();
void MoveToFront(int64_t frame_number);
void Remove(int64_t frame_number);
void Remove(int64_t start_frame_number, int64_t end_frame_number);
// Get and Set JSON methods
std::string Json();
void SetJson(const std::string value);
Json::Value JsonValue();
void SetJsonValue(const Json::Value root);
};
}
#endif
CacheBase.h
Header file for CacheBase class.
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition CacheBase.h:35
openshot::CacheBase::max_bytes
int64_t max_bytes
This is the max number of bytes to cache (0 = no limit)
Definition CacheBase.h:38
openshot::CacheDisk
This class is a disk-based cache manager for Frame objects.
Definition CacheDisk.h:30
openshot::CacheDisk::GetFrames
std::vector< std::shared_ptr< openshot::Frame > > GetFrames()
Get an array of all Frames.
Definition CacheDisk.cpp:226
openshot::CacheDisk::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number)
Get a frame from the cache.
Definition CacheDisk.cpp:156
openshot::CacheDisk::MoveToFront
void MoveToFront(int64_t frame_number)
Move frame to front of queue (so it lasts longer)
Definition CacheDisk.cpp:337
openshot::CacheDisk::~CacheDisk
~CacheDisk()
Definition CacheDisk.cpp:79
openshot::CacheDisk::Contains
bool Contains(int64_t frame_number)
Check if frame is already contained in cache.
Definition CacheDisk.cpp:147
openshot::CacheDisk::Json
std::string Json()
Generate JSON string of this object.
Definition CacheDisk.cpp:416
openshot::CacheDisk::Add
void Add(std::shared_ptr< openshot::Frame > frame)
Add a Frame to the cache.
Definition CacheDisk.cpp:88
openshot::CacheDisk::GetSmallestFrame
std::shared_ptr< openshot::Frame > GetSmallestFrame()
Get the smallest frame number.
Definition CacheDisk.cpp:243
openshot::CacheDisk::JsonValue
Json::Value JsonValue()
Generate Json::Value for this object.
Definition CacheDisk.cpp:423
openshot::CacheDisk::Clear
void Clear()
Clear the cache of all frames.
Definition CacheDisk.cpp:363
openshot::CacheDisk::SetJsonValue
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition CacheDisk.cpp:467
openshot::CacheDisk::SetJson
void SetJson(const std::string value)
Load JSON string into this object.
Definition CacheDisk.cpp:450
openshot::CacheDisk::GetBytes
int64_t GetBytes()
Gets the maximum bytes value.
Definition CacheDisk.cpp:266
openshot::CacheDisk::Count
int64_t Count()
Count the frames in the queue.
Definition CacheDisk.cpp:386
openshot::CacheDisk::Remove
void Remove(int64_t frame_number)
Remove a specific frame.
Definition CacheDisk.cpp:282
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29