OpenShot Library | libopenshot
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
CacheMemory.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_MEMORY_H
14
#define OPENSHOT_CACHE_MEMORY_H
15
16
#include "
CacheBase.h
"
17
18
namespace
openshot
{
19
class
Frame
;
20
29
class
CacheMemory
:
public
CacheBase
{
30
private
:
31
std::map<int64_t, std::shared_ptr<openshot::Frame> > frames;
32
std::deque<int64_t> frame_numbers;
33
35
void
CleanUp();
36
37
public
:
39
CacheMemory
();
40
43
CacheMemory
(int64_t
max_bytes
);
44
45
// Default destructor
46
virtual
~CacheMemory
();
47
50
void
Add
(std::shared_ptr<openshot::Frame> frame);
51
53
void
Clear
();
54
57
bool
Contains
(int64_t frame_number);
58
60
int64_t
Count
();
61
64
std::shared_ptr<openshot::Frame>
GetFrame
(int64_t frame_number);
65
67
std::vector<std::shared_ptr<openshot::Frame>>
GetFrames
();
68
70
int64_t
GetBytes
();
71
73
std::shared_ptr<openshot::Frame>
GetSmallestFrame
();
74
77
void
Touch
(int64_t frame_number);
78
81
void
Remove
(int64_t frame_number);
82
86
void
Remove
(int64_t start_frame_number, int64_t end_frame_number);
87
88
// Get and Set JSON methods
89
std::string
Json
();
90
void
SetJson
(
const
std::string value);
91
Json::Value
JsonValue
();
92
void
SetJsonValue
(
const
Json::Value root);
93
};
94
95
}
96
97
#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::CacheMemory::CacheMemory
CacheMemory()
Default constructor, no max bytes.
Definition
CacheMemory.cpp:22
openshot::CacheMemory::Count
int64_t Count()
Count the frames in the queue.
Definition
CacheMemory.cpp:240
openshot::CacheMemory::Add
void Add(std::shared_ptr< openshot::Frame > frame)
Add a Frame to the cache.
Definition
CacheMemory.cpp:47
openshot::CacheMemory::SetJson
void SetJson(const std::string value)
Load JSON string into this object.
Definition
CacheMemory.cpp:300
openshot::CacheMemory::GetBytes
int64_t GetBytes()
Gets the maximum bytes value.
Definition
CacheMemory.cpp:140
openshot::CacheMemory::~CacheMemory
virtual ~CacheMemory()
Definition
CacheMemory.cpp:38
openshot::CacheMemory::Json
std::string Json()
Generate JSON string of this object.
Definition
CacheMemory.cpp:271
openshot::CacheMemory::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number)
Get a frame from the cache.
Definition
CacheMemory.cpp:84
openshot::CacheMemory::GetFrames
std::vector< std::shared_ptr< openshot::Frame > > GetFrames()
Get an array of all Frames.
Definition
CacheMemory.cpp:100
openshot::CacheMemory::SetJsonValue
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition
CacheMemory.cpp:317
openshot::CacheMemory::Remove
void Remove(int64_t frame_number)
Remove a specific frame.
Definition
CacheMemory.cpp:158
openshot::CacheMemory::Clear
void Clear()
Clear the cache of all frames.
Definition
CacheMemory.cpp:224
openshot::CacheMemory::JsonValue
Json::Value JsonValue()
Generate Json::Value for this object.
Definition
CacheMemory.cpp:278
openshot::CacheMemory::Touch
void Touch(int64_t frame_number)
Move frame to front of queue (so it lasts longer).
Definition
CacheMemory.cpp:198
openshot::CacheMemory::Contains
bool Contains(int64_t frame_number)
Check if frame is already contained in cache.
Definition
CacheMemory.cpp:72
openshot::CacheMemory::GetSmallestFrame
std::shared_ptr< openshot::Frame > GetSmallestFrame()
Get the smallest frame number.
Definition
CacheMemory.cpp:117
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
CacheMemory.h
Generated by
1.17.0