OpenShot Library | libopenshot
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
CacheDisk.h
Go to the documentation of this file.
1
8
9
// Copyright (c) 2008-2019 OpenShot Studios, LLC
10
//
11
// SPDX-License-Identifier: LGPL-3.0-or-later
12
13
#ifndef OPENSHOT_CACHE_DISK_H
14
#define OPENSHOT_CACHE_DISK_H
15
16
#include "
CacheBase.h
"
17
18
#include <QDir>
19
20
namespace
openshot
{
21
class
Frame
;
22
30
class
CacheDisk
:
public
CacheBase
{
31
private
:
32
QDir path;
33
std::map<int64_t, int64_t> frames;
34
std::deque<int64_t> frame_numbers;
35
std::string image_format;
36
float
image_quality;
37
float
image_scale;
38
int64_t frame_size_bytes;
39
41
void
CleanUp();
42
44
void
InitPath(std::string cache_path);
45
46
public
:
52
CacheDisk
(std::string cache_path, std::string format,
float
quality,
float
scale);
53
60
CacheDisk
(std::string cache_path, std::string format,
float
quality,
float
scale, int64_t
max_bytes
);
61
62
// Default destructor
63
~CacheDisk
();
64
67
void
Add
(std::shared_ptr<openshot::Frame> frame);
68
70
void
Clear
();
71
74
bool
Contains
(int64_t frame_number);
75
77
int64_t
Count
();
78
81
std::shared_ptr<openshot::Frame>
GetFrame
(int64_t frame_number);
82
84
std::vector<std::shared_ptr<openshot::Frame>>
GetFrames
();
85
87
int64_t
GetBytes
();
88
90
std::shared_ptr<openshot::Frame>
GetSmallestFrame
();
91
94
void
Touch
(int64_t frame_number);
95
98
void
Remove
(int64_t frame_number);
99
103
void
Remove
(int64_t start_frame_number, int64_t end_frame_number);
104
105
// Get and Set JSON methods
106
std::string
Json
();
107
void
SetJson
(
const
std::string value);
108
Json::Value
JsonValue
();
109
void
SetJsonValue
(
const
Json::Value root);
110
};
111
112
}
113
114
#endif
CacheBase.h
Header file for CacheBase class.
openshot::CacheBase::CacheBase
CacheBase()
Default constructor, no max bytes.
Definition
CacheBase.cpp:19
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::GetFrames
std::vector< std::shared_ptr< openshot::Frame > > GetFrames()
Get an array of all Frames.
Definition
CacheDisk.cpp:227
openshot::CacheDisk::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number)
Get a frame from the cache.
Definition
CacheDisk.cpp:157
openshot::CacheDisk::CacheDisk
CacheDisk(std::string cache_path, std::string format, float quality, float scale)
Default constructor, no max bytes.
Definition
CacheDisk.cpp:27
openshot::CacheDisk::~CacheDisk
~CacheDisk()
Definition
CacheDisk.cpp:80
openshot::CacheDisk::Contains
bool Contains(int64_t frame_number)
Check if frame is already contained in cache.
Definition
CacheDisk.cpp:148
openshot::CacheDisk::Touch
void Touch(int64_t frame_number)
Move frame to front of queue (so it lasts longer).
Definition
CacheDisk.cpp:338
openshot::CacheDisk::Json
std::string Json()
Generate JSON string of this object.
Definition
CacheDisk.cpp:417
openshot::CacheDisk::Add
void Add(std::shared_ptr< openshot::Frame > frame)
Add a Frame to the cache.
Definition
CacheDisk.cpp:89
openshot::CacheDisk::GetSmallestFrame
std::shared_ptr< openshot::Frame > GetSmallestFrame()
Get the smallest frame number.
Definition
CacheDisk.cpp:244
openshot::CacheDisk::JsonValue
Json::Value JsonValue()
Generate Json::Value for this object.
Definition
CacheDisk.cpp:424
openshot::CacheDisk::Clear
void Clear()
Clear the cache of all frames.
Definition
CacheDisk.cpp:364
openshot::CacheDisk::SetJsonValue
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition
CacheDisk.cpp:468
openshot::CacheDisk::SetJson
void SetJson(const std::string value)
Load JSON string into this object.
Definition
CacheDisk.cpp:451
openshot::CacheDisk::GetBytes
int64_t GetBytes()
Gets the maximum bytes value.
Definition
CacheDisk.cpp:267
openshot::CacheDisk::Count
int64_t Count()
Count the frames in the queue.
Definition
CacheDisk.cpp:387
openshot::CacheDisk::Remove
void Remove(int64_t frame_number)
Remove a specific frame.
Definition
CacheDisk.cpp:283
openshot::Frame
This class represents a single frame of video (i.e. image & audio data).
Definition
Frame.h:90
openshot
This namespace is the default namespace for all code in the openshot library.
Definition
AnimatedCurve.h:24
CacheDisk.h
Generated by
1.17.0