33 int64_t bytes = number_of_frames * (height * width * 4 + (sample_rate * channels * 4));
43 const std::lock_guard<std::recursive_mutex> lock(*
cacheMutex);
49 Json::Value ranges = Json::Value(Json::arrayValue);
54 std::vector<int64_t>::iterator itr_ordered;
56 int64_t starting_frame = 0;
57 int64_t ending_frame = 0;
64 int64_t frame_number = *itr_ordered;
65 if (frame_number - ending_frame > 1) {
71 range[
"start"] = std::to_string(starting_frame);
72 range[
"end"] = std::to_string(ending_frame);
76 starting_frame = frame_number;
80 ending_frame = frame_number;
89 range[
"start"] = std::to_string(starting_frame);
90 range[
"end"] = std::to_string(ending_frame);
106 std::stringstream max_bytes_stream;
108 root[
"max_bytes"] = max_bytes_stream.str();
118 if (!root[
"max_bytes"].isNull())
119 max_bytes = std::stoll(root[
"max_bytes"].asString());
Header file for CacheBase class.
All cache managers in libopenshot are based on this CacheBase class.
int64_t range_version
The version of the JSON range data (incremented with each change)
CacheBase()
Default constructor, no max bytes.
virtual Json::Value JsonValue()=0
Generate Json::Value for this object.
void CalculateRanges()
Calculate ranges of frames.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
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)
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.
std::recursive_mutex * cacheMutex
Mutex for multiple threads.
std::string json_ranges
JSON ranges of frame numbers.
std::vector< int64_t > ordered_frame_numbers
Ordered list of frame numbers used by cache.
void SetMaxBytes(int64_t number_of_bytes)
Set maximum bytes to a different amount.
This namespace is the default namespace for all code in the openshot library.