You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Adding new GetFrames method to CacheBase, to return an ordered vector of Frame objects. Useful when needing to iterate through the current cached frames.
This commit is contained in:
@@ -64,6 +64,9 @@ namespace openshot {
|
||||
/// @param frame_number The frame number of the cached frame
|
||||
virtual std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) = 0;
|
||||
|
||||
/// @brief Get an vector of all Frames
|
||||
virtual std::vector<std::shared_ptr<openshot::Frame>> GetFrames() = 0;
|
||||
|
||||
/// Gets the maximum bytes value
|
||||
virtual int64_t GetBytes() = 0;
|
||||
|
||||
|
||||
@@ -279,6 +279,23 @@ std::shared_ptr<Frame> CacheDisk::GetFrame(int64_t frame_number)
|
||||
return std::shared_ptr<Frame>();
|
||||
}
|
||||
|
||||
// @brief Get an array of all Frames
|
||||
std::vector<std::shared_ptr<openshot::Frame>> CacheDisk::GetFrames()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const std::lock_guard<std::recursive_mutex> lock(*cacheMutex);
|
||||
|
||||
std::vector<std::shared_ptr<openshot::Frame>> all_frames;
|
||||
std::vector<int64_t>::iterator itr_ordered;
|
||||
for(itr_ordered = ordered_frame_numbers.begin(); itr_ordered != ordered_frame_numbers.end(); ++itr_ordered)
|
||||
{
|
||||
int64_t frame_number = *itr_ordered;
|
||||
all_frames.push_back(GetFrame(frame_number));
|
||||
}
|
||||
|
||||
return all_frames;
|
||||
}
|
||||
|
||||
// Get the smallest frame number (or NULL shared_ptr if no frame is found)
|
||||
std::shared_ptr<Frame> CacheDisk::GetSmallestFrame()
|
||||
{
|
||||
|
||||
@@ -93,6 +93,9 @@ namespace openshot {
|
||||
/// @param frame_number The frame number of the cached frame
|
||||
std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number);
|
||||
|
||||
/// @brief Get an array of all Frames
|
||||
std::vector<std::shared_ptr<openshot::Frame>> GetFrames();
|
||||
|
||||
/// Gets the maximum bytes value
|
||||
int64_t GetBytes();
|
||||
|
||||
|
||||
@@ -152,6 +152,23 @@ std::shared_ptr<Frame> CacheMemory::GetFrame(int64_t frame_number)
|
||||
return std::shared_ptr<Frame>();
|
||||
}
|
||||
|
||||
// @brief Get an array of all Frames
|
||||
std::vector<std::shared_ptr<openshot::Frame>> CacheMemory::GetFrames()
|
||||
{
|
||||
// Create a scoped lock, to protect the cache from multiple threads
|
||||
const std::lock_guard<std::recursive_mutex> lock(*cacheMutex);
|
||||
|
||||
std::vector<std::shared_ptr<openshot::Frame>> all_frames;
|
||||
std::vector<int64_t>::iterator itr_ordered;
|
||||
for(itr_ordered = ordered_frame_numbers.begin(); itr_ordered != ordered_frame_numbers.end(); ++itr_ordered)
|
||||
{
|
||||
int64_t frame_number = *itr_ordered;
|
||||
all_frames.push_back(GetFrame(frame_number));
|
||||
}
|
||||
|
||||
return all_frames;
|
||||
}
|
||||
|
||||
// Get the smallest frame number (or NULL shared_ptr if no frame is found)
|
||||
std::shared_ptr<Frame> CacheMemory::GetSmallestFrame()
|
||||
{
|
||||
|
||||
@@ -76,6 +76,9 @@ namespace openshot {
|
||||
/// @param frame_number The frame number of the cached frame
|
||||
std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number);
|
||||
|
||||
/// @brief Get an array of all Frames
|
||||
std::vector<std::shared_ptr<openshot::Frame>> GetFrames();
|
||||
|
||||
/// Gets the maximum bytes value
|
||||
int64_t GetBytes();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user